@aquera/nile-elements 2.0.26 → 2.0.27
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 +7 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +441 -418
- package/dist/nile-calendar/nile-calendar.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +5 -5
- package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.cjs.js.map +1 -1
- package/dist/nile-combobox/nile-combobox.css.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.css.cjs.js.map +1 -1
- package/dist/nile-combobox/nile-combobox.css.esm.js +2 -0
- package/dist/nile-combobox/nile-combobox.esm.js +1 -1
- package/dist/nile-detail/nile-detail.cjs.js +1 -1
- package/dist/nile-detail/nile-detail.cjs.js.map +1 -1
- package/dist/nile-detail/nile-detail.esm.js +6 -5
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/index.esm.js +1 -1
- 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 +1 -1
- package/dist/nile-virtual-select/index.cjs.js +1 -1
- package/dist/nile-virtual-select/index.esm.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +4 -4
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +19 -5
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +5 -5
- package/dist/nile-virtual-select/renderer.cjs.js +1 -1
- package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
- package/dist/nile-virtual-select/renderer.esm.js +23 -22
- package/dist/src/nile-calendar/nile-calendar.d.ts +4 -0
- package/dist/src/nile-calendar/nile-calendar.js +18 -2
- package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.test.js +50 -0
- package/dist/src/nile-calendar/nile-calendar.test.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +12 -0
- package/dist/src/nile-code-editor/nile-code-editor.js +92 -0
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-combobox/nile-combobox.css.js +2 -0
- package/dist/src/nile-combobox/nile-combobox.css.js.map +1 -1
- package/dist/src/nile-combobox/nile-combobox.d.ts +1 -0
- package/dist/src/nile-combobox/nile-combobox.js +12 -1
- package/dist/src/nile-combobox/nile-combobox.js.map +1 -1
- package/dist/src/nile-combobox/nile-combobox.test.js +375 -0
- package/dist/src/nile-combobox/nile-combobox.test.js.map +1 -1
- package/dist/src/nile-detail/nile-detail.d.ts +4 -0
- package/dist/src/nile-detail/nile-detail.js +35 -3
- package/dist/src/nile-detail/nile-detail.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +19 -5
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +29 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.js +120 -13
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.test.js +187 -2
- package/dist/src/nile-virtual-select/nile-virtual-select.test.js.map +1 -1
- package/dist/src/nile-virtual-select/renderer.d.ts +1 -1
- package/dist/src/nile-virtual-select/renderer.js +11 -4
- package/dist/src/nile-virtual-select/renderer.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-calendar/nile-calendar.test.ts +54 -0
- package/src/nile-calendar/nile-calendar.ts +17 -3
- package/src/nile-code-editor/nile-code-editor.ts +82 -0
- package/src/nile-combobox/nile-combobox.css.ts +2 -0
- package/src/nile-combobox/nile-combobox.test.ts +416 -0
- package/src/nile-combobox/nile-combobox.ts +11 -1
- package/src/nile-detail/nile-detail.ts +34 -3
- package/src/nile-virtual-select/nile-virtual-select.css.ts +19 -5
- package/src/nile-virtual-select/nile-virtual-select.test.ts +230 -2
- package/src/nile-virtual-select/nile-virtual-select.ts +117 -11
- package/src/nile-virtual-select/renderer.ts +12 -5
- package/vscode-html-custom-data.json +14 -4
|
@@ -103,6 +103,8 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
103
103
|
/** The name of the select, submitted as a name/value pair with form data. */
|
|
104
104
|
this.name = '';
|
|
105
105
|
this.data = [];
|
|
106
|
+
/** Set by direct user selection changes so the value watcher can tell them from external ones. */
|
|
107
|
+
this.userSelectionChange = false;
|
|
106
108
|
/** Original unfiltered option items for search functionality */
|
|
107
109
|
this.originalOptionItems = [];
|
|
108
110
|
/**
|
|
@@ -520,6 +522,97 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
520
522
|
return selectedValues.some(val => String(val) === String(itemValue));
|
|
521
523
|
});
|
|
522
524
|
}
|
|
525
|
+
isValueSelected(item) {
|
|
526
|
+
const selectedValues = Array.isArray(this.value) ? this.value : [this.value];
|
|
527
|
+
const itemValue = this.getItemValue(item);
|
|
528
|
+
return selectedValues.some(val => String(val) === String(itemValue));
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Keeps the "Selected" view in sync with the current selection without a full repaint:
|
|
532
|
+
* `data` is only reassigned when the filtered list actually differs (no needless watcher runs or
|
|
533
|
+
* virtualization rebuilds), and scroll position is left alone. The `no-scroll` class is only touched
|
|
534
|
+
* when the item count crosses the threshold.
|
|
535
|
+
*/
|
|
536
|
+
refreshSelectedList() {
|
|
537
|
+
if (!this.showSelected)
|
|
538
|
+
return;
|
|
539
|
+
const next = this.originalOptionItems.filter((item) => this.isValueSelected(item));
|
|
540
|
+
const prev = this.data || [];
|
|
541
|
+
if (next.length === prev.length && next.every((item, i) => item === prev[i])) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
this.data = next;
|
|
545
|
+
if (prev.length < 5 || next.length < 5) {
|
|
546
|
+
this.updateNoScroll();
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Hides the scrollbar only for short lists that genuinely fit. A short list can still overflow
|
|
551
|
+
* (tall rows, small popup), and then it must stay scrollable.
|
|
552
|
+
*/
|
|
553
|
+
updateNoScroll() {
|
|
554
|
+
this.updateComplete.then(() => requestAnimationFrame(() => {
|
|
555
|
+
const virtualized = this.shadowRoot?.querySelector('.virtualized');
|
|
556
|
+
if (!virtualized)
|
|
557
|
+
return;
|
|
558
|
+
virtualized.classList.remove('no-scroll');
|
|
559
|
+
if (this.data.length < 5 && virtualized.scrollHeight <= virtualized.clientHeight + 1) {
|
|
560
|
+
virtualized.classList.add('no-scroll');
|
|
561
|
+
}
|
|
562
|
+
}));
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Until the virtualizer has measured its rows it positions them by an estimated size (100px), so for a frame or two
|
|
566
|
+
* they sit far apart. The popup is hidden while it positions itself, but that is not always long enough; keep it
|
|
567
|
+
* hidden until the first two rows are spaced by their own height. Capped, so it can never block opening.
|
|
568
|
+
*/
|
|
569
|
+
async waitForRowLayout(maxFrames = 30) {
|
|
570
|
+
const settled = () => {
|
|
571
|
+
if (!VirtualSelectRenderer.shouldUseVirtualizer(this.data ?? []))
|
|
572
|
+
return true; // plain list: nothing is estimated
|
|
573
|
+
const virtualized = this.shadowRoot?.querySelector('.virtualized--scroller');
|
|
574
|
+
if (!virtualized)
|
|
575
|
+
return false; // not rendered yet
|
|
576
|
+
const rows = [...virtualized.querySelectorAll('nile-option')]
|
|
577
|
+
.map(row => row.getBoundingClientRect())
|
|
578
|
+
.sort((a, b) => a.top - b.top);
|
|
579
|
+
return rows.length >= 2 && Math.abs(rows[1].top - rows[0].top - rows[0].height) <= 1;
|
|
580
|
+
};
|
|
581
|
+
for (let frame = 0; frame < maxFrames && !settled(); frame += 1) {
|
|
582
|
+
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Safety net for a stale row measurement. The virtualizer measures rows with getBoundingClientRect, so anything
|
|
587
|
+
* that scales the popup while it measures (a custom open animation, a transformed ancestor) records rows too small
|
|
588
|
+
* and positions them too close together: they overlap and the gap between them disappears until something
|
|
589
|
+
* re-measures. Once the popup is open, detect that and nudge the list's width by 1px: the virtualizer re-measures
|
|
590
|
+
* all rows when its host resizes, without re-creating anything.
|
|
591
|
+
*/
|
|
592
|
+
async healOverlappingRows() {
|
|
593
|
+
const frames = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
|
594
|
+
const virtualized = this.shadowRoot?.querySelector('.virtualized--scroller');
|
|
595
|
+
if (!virtualized)
|
|
596
|
+
return;
|
|
597
|
+
const overlapping = () => {
|
|
598
|
+
const rows = [...virtualized.querySelectorAll('nile-option')]
|
|
599
|
+
.map(row => row.getBoundingClientRect())
|
|
600
|
+
.sort((a, b) => a.top - b.top);
|
|
601
|
+
return rows.length >= 2 && rows[1].top - rows[0].top < rows[0].height - 0.5;
|
|
602
|
+
};
|
|
603
|
+
try {
|
|
604
|
+
await (document.fonts?.ready ?? Promise.resolve());
|
|
605
|
+
if (!this.open || !overlapping())
|
|
606
|
+
return;
|
|
607
|
+
virtualized.style.width = 'calc(100% - 1px)';
|
|
608
|
+
await frames();
|
|
609
|
+
virtualized.style.width = '';
|
|
610
|
+
await frames();
|
|
611
|
+
}
|
|
612
|
+
catch {
|
|
613
|
+
virtualized.style.width = '';
|
|
614
|
+
}
|
|
615
|
+
}
|
|
523
616
|
toggleShowSelected(event) {
|
|
524
617
|
event.stopPropagation();
|
|
525
618
|
event.preventDefault();
|
|
@@ -636,6 +729,7 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
636
729
|
}
|
|
637
730
|
toggleOptionSelection(optionValue) {
|
|
638
731
|
const currentValues = Array.isArray(this.value) ? this.value : [];
|
|
732
|
+
this.userSelectionChange = this.showSelected;
|
|
639
733
|
if (currentValues.includes(optionValue)) {
|
|
640
734
|
this.value = currentValues.filter(v => v !== optionValue);
|
|
641
735
|
}
|
|
@@ -657,6 +751,7 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
657
751
|
currentValue = currentValue ? [currentValue] : [];
|
|
658
752
|
}
|
|
659
753
|
const newValue = currentValue.filter((v) => v !== option.value);
|
|
754
|
+
this.userSelectionChange = this.showSelected;
|
|
660
755
|
this.value = newValue;
|
|
661
756
|
this.selectionChanged();
|
|
662
757
|
}
|
|
@@ -718,17 +813,7 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
718
813
|
}
|
|
719
814
|
repaintOptionsContainer() {
|
|
720
815
|
this.resetScrollPosition();
|
|
721
|
-
this.
|
|
722
|
-
const virtualized = this.shadowRoot?.querySelector('.virtualized');
|
|
723
|
-
if (virtualized) {
|
|
724
|
-
if (this.data.length < 5) {
|
|
725
|
-
virtualized.classList.add('no-scroll');
|
|
726
|
-
}
|
|
727
|
-
else {
|
|
728
|
-
virtualized.classList.remove('no-scroll');
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
});
|
|
816
|
+
this.updateNoScroll();
|
|
732
817
|
}
|
|
733
818
|
handleScroll(e) {
|
|
734
819
|
if (this.showSelected) {
|
|
@@ -798,6 +883,11 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
798
883
|
if (externalValueChange && this.showTooltip && this.showSelected) {
|
|
799
884
|
this.applySelectedFilter();
|
|
800
885
|
}
|
|
886
|
+
else if (this.userSelectionChange) {
|
|
887
|
+
// A direct user unselect while "Show Selected" is on drops that item from the list.
|
|
888
|
+
this.refreshSelectedList();
|
|
889
|
+
}
|
|
890
|
+
this.userSelectionChange = false;
|
|
801
891
|
this.requestUpdate();
|
|
802
892
|
// Update body append content if it's active
|
|
803
893
|
if (this.portal && this.portalManager.portalContainerElement) {
|
|
@@ -808,6 +898,12 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
808
898
|
if (this.data.length > 0 && this.open && !this.showSelected && !this.searchValue) {
|
|
809
899
|
this.originalOptionItems = [...this.data];
|
|
810
900
|
}
|
|
901
|
+
if (this.showSelected && this.data.length > 0 && !this.data.every((item) => this.isValueSelected(item))) {
|
|
902
|
+
// The consumer replaced `data` with unfiltered items while "Show Selected" is on:
|
|
903
|
+
// adopt them as the source list and narrow back to the selection.
|
|
904
|
+
this.originalOptionItems = [...this.data];
|
|
905
|
+
this.refreshSelectedList();
|
|
906
|
+
}
|
|
811
907
|
this.selectionChanged();
|
|
812
908
|
// Show no results message when data is empty and not loading
|
|
813
909
|
if (!this.optionsLoading && !this.loading && this.data.length === 0) {
|
|
@@ -885,6 +981,8 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
885
981
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
886
982
|
// Wait for next frame to allow Floating UI to calculate position
|
|
887
983
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
984
|
+
// Keep the popup hidden until the virtualizer has laid its rows out, so its 100px starting estimate is never seen.
|
|
985
|
+
await this.waitForRowLayout();
|
|
888
986
|
// Show popup after positioning is calculated
|
|
889
987
|
if (this.popup?.popup) {
|
|
890
988
|
this.popup.popup.style.visibility = '';
|
|
@@ -892,7 +990,12 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
892
990
|
const { keyframes, options } = getAnimation(this, 'select.show', {
|
|
893
991
|
dir: 'ltr',
|
|
894
992
|
});
|
|
895
|
-
|
|
993
|
+
// Drop the `scale` property (the default animation is opacity + scale 0.9 -> 1). The virtualizer measures rows with
|
|
994
|
+
// getBoundingClientRect, so rows measured while the popup is scaled come out too small and are then snapped apart.
|
|
995
|
+
// Only `scale` is removed: other properties, including a consumer's `transform`, are left as they set them.
|
|
996
|
+
const withoutScale = keyframes.map(({ scale, ...rest }) => rest);
|
|
997
|
+
await animateTo(this.popup.popup, withoutScale, options);
|
|
998
|
+
await this.healOverlappingRows();
|
|
896
999
|
if (this.wasShowSelectedCheckedOnClose) {
|
|
897
1000
|
this.showSelected = false;
|
|
898
1001
|
this.data = [...this.originalOptionItems];
|
|
@@ -1203,7 +1306,11 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
1203
1306
|
}
|
|
1204
1307
|
renderLegacyTag(option, index) {
|
|
1205
1308
|
const classes = {
|
|
1206
|
-
|
|
1309
|
+
// While the fit is re-measured (maxOptionsVisible = Infinity), hide only the chips that were previously clipped.
|
|
1310
|
+
// A previous limit of 0 means every chip fitted (see `maxOptionsVisible <= 0` in renderTags), so none are hidden;
|
|
1311
|
+
// treating 0 as "none visible" blinked the whole chip row on every re-fit, e.g. each time the dropdown opened.
|
|
1312
|
+
select__invisible: this.oldMaxOptionsVisible > 0 &&
|
|
1313
|
+
index + 1 > this.oldMaxOptionsVisible &&
|
|
1207
1314
|
this.maxOptionsVisible === Infinity,
|
|
1208
1315
|
};
|
|
1209
1316
|
return html `
|