@aquera/nile-elements 0.1.75-beta-1.4 → 0.1.75-beta-1.5
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 +0 -25
- package/dist/index.js +357 -331
- package/dist/nile-button/nile-button.cjs.js +1 -1
- package/dist/nile-button/nile-button.cjs.js.map +1 -1
- package/dist/nile-button/nile-button.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
- 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 -5
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.css.cjs.js +1 -1
- package/dist/nile-select/nile-select.css.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.css.esm.js +1 -1
- package/dist/nile-select/nile-select.esm.js +2 -7
- package/dist/nile-select/nile-select.test.cjs.js +1 -1
- package/dist/nile-select/nile-select.test.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.test.esm.js +1 -1
- 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 +2 -0
- 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 +5 -1
- 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 +20 -1
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +21 -12
- 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 +11 -10
- package/dist/nile-virtual-select/selection-manager.cjs.js +1 -1
- package/dist/nile-virtual-select/selection-manager.cjs.js.map +1 -1
- package/dist/nile-virtual-select/selection-manager.esm.js +1 -1
- package/dist/src/nile-button/nile-button.d.ts +1 -1
- package/dist/src/nile-button/nile-button.js +1 -1
- package/dist/src/nile-button/nile-button.js.map +1 -1
- package/dist/src/nile-select/nile-select.css.js +1 -1
- package/dist/src/nile-select/nile-select.css.js.map +1 -1
- package/dist/src/nile-select/nile-select.d.ts +5 -1
- package/dist/src/nile-select/nile-select.js +31 -15
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-select/virtual-scroll-helper.js +2 -0
- package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +20 -1
- 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 +22 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.js +148 -22
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
- package/dist/src/nile-virtual-select/renderer.d.ts +2 -2
- package/dist/src/nile-virtual-select/renderer.js +9 -8
- package/dist/src/nile-virtual-select/renderer.js.map +1 -1
- package/dist/src/nile-virtual-select/selection-manager.js +1 -1
- package/dist/src/nile-virtual-select/selection-manager.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/src/nile-button/nile-button.ts +1 -1
- package/src/nile-select/nile-select.css.ts +1 -1
- package/src/nile-select/nile-select.ts +31 -17
- package/src/nile-select/virtual-scroll-helper.ts +2 -0
- package/src/nile-virtual-select/nile-virtual-select.css.ts +20 -1
- package/src/nile-virtual-select/nile-virtual-select.ts +158 -26
- package/src/nile-virtual-select/renderer.ts +10 -8
- package/src/nile-virtual-select/selection-manager.ts +1 -1
- package/vscode-html-custom-data.json +61 -34
|
@@ -8,8 +8,9 @@ import '../nile-icon';
|
|
|
8
8
|
import '../nile-popup/nile-popup';
|
|
9
9
|
import '../nile-tag/nile-tag';
|
|
10
10
|
import '../nile-checkbox/nile-checkbox';
|
|
11
|
+
import '../nile-loader/nile-loader';
|
|
11
12
|
import NileElement from '../internal/nile-element';
|
|
12
|
-
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
13
|
+
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
13
14
|
import type { NileFormControl } from '../internal/nile-element';
|
|
14
15
|
import type NilePopup from '../nile-popup/nile-popup';
|
|
15
16
|
import type { VirtualOption, RenderItemConfig } from './types.js';
|
|
@@ -45,6 +46,10 @@ import type { VirtualOption, RenderItemConfig } from './types.js';
|
|
|
45
46
|
* @event nile-hide - Emitted when the select's menu closes.
|
|
46
47
|
* @event nile-after-hide - Emitted after the select's menu closes and all animations are complete.
|
|
47
48
|
* @event nile-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.
|
|
49
|
+
* @event nile-search - Emitted when the user types in the search input. The event payload includes the search query for backend search functionality.
|
|
50
|
+
* @event nile-scroll - Emitted when the user scrolls within the virtualized container. The event payload includes scroll position information.
|
|
51
|
+
* @event nile-scroll-start - Emitted when the user starts scrolling within the virtualized container.
|
|
52
|
+
* @event nile-scroll-end - Emitted when the user stops scrolling and reaches the bottom of the virtualized container (debounced).
|
|
48
53
|
*
|
|
49
54
|
* @csspart form-control - The form control that wraps the label, input, and help text.
|
|
50
55
|
* @csspart form-control-label - The label's wrapper.
|
|
@@ -72,6 +77,8 @@ export declare class NileVirtualSelect extends NileElement implements NileFormCo
|
|
|
72
77
|
displayLabel: string;
|
|
73
78
|
selectedOptions: VirtualOption[];
|
|
74
79
|
oldValue: string | string[];
|
|
80
|
+
private scrollTimeout;
|
|
81
|
+
private scrolling;
|
|
75
82
|
/** The name of the select, submitted as a name/value pair with form data. */
|
|
76
83
|
name: string;
|
|
77
84
|
/** Array of all option items for virtual scrolling */
|
|
@@ -88,6 +95,8 @@ export declare class NileVirtualSelect extends NileElement implements NileFormCo
|
|
|
88
95
|
size: 'small' | 'medium' | 'large';
|
|
89
96
|
/** Placeholder text to show as a hint when the select is empty. */
|
|
90
97
|
placeholder: string;
|
|
98
|
+
/** Enable automatic resizing of tags area */
|
|
99
|
+
autoResize: boolean;
|
|
91
100
|
/** Current search value */
|
|
92
101
|
searchValue: string;
|
|
93
102
|
/** Enable search functionality */
|
|
@@ -98,6 +107,8 @@ export declare class NileVirtualSelect extends NileElement implements NileFormCo
|
|
|
98
107
|
disableLocalSearch: boolean;
|
|
99
108
|
/** Show loading state */
|
|
100
109
|
optionsLoading: boolean;
|
|
110
|
+
/** Show loading state using nile-loader */
|
|
111
|
+
loading: boolean;
|
|
101
112
|
/** Allows more than one option to be selected. */
|
|
102
113
|
multiple: boolean;
|
|
103
114
|
/** Help text */
|
|
@@ -158,12 +169,14 @@ export declare class NileVirtualSelect extends NileElement implements NileFormCo
|
|
|
158
169
|
*/
|
|
159
170
|
maxOptionsVisible: number;
|
|
160
171
|
oldMaxOptionsVisible: number;
|
|
172
|
+
showListbox: boolean;
|
|
161
173
|
/** Gets the validity state object */
|
|
162
174
|
get validity(): ValidityState;
|
|
163
175
|
/** Gets the validation message */
|
|
164
176
|
get validationMessage(): string;
|
|
165
177
|
connectedCallback(): void;
|
|
166
178
|
disconnectedCallback(): void;
|
|
179
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
167
180
|
private initializeComponent;
|
|
168
181
|
/**
|
|
169
182
|
* Get display text for an item using renderItemConfig
|
|
@@ -190,11 +203,18 @@ export declare class NileVirtualSelect extends NileElement implements NileFormCo
|
|
|
190
203
|
private isEnterOrSpaceKey;
|
|
191
204
|
private handleEnterOrSpaceKey;
|
|
192
205
|
private handleDocumentMouseDown;
|
|
206
|
+
/**
|
|
207
|
+
* This is a workaround for an error in the Lit Labs virtualizer.
|
|
208
|
+
* Since there are no specific guidelines available to fix the issue,
|
|
209
|
+
* we are catching only the error message related to the virtualizer.
|
|
210
|
+
*/
|
|
211
|
+
private handleWindowError;
|
|
193
212
|
private handleFooterClick;
|
|
194
213
|
private toggleShowSelected;
|
|
195
214
|
private unSelectAll;
|
|
196
215
|
private handleLabelClick;
|
|
197
216
|
private handleComboboxMouseDown;
|
|
217
|
+
private resizeController;
|
|
198
218
|
private shouldIgnoreComboboxClick;
|
|
199
219
|
private handleComboboxKeyDown;
|
|
200
220
|
private handleClearClick;
|
|
@@ -212,6 +232,7 @@ export declare class NileVirtualSelect extends NileElement implements NileFormCo
|
|
|
212
232
|
handleSearchFocus(): void;
|
|
213
233
|
handleSearchBlur(): void;
|
|
214
234
|
handleSearchChange(e: any): void;
|
|
235
|
+
handleScroll(e: Event): void;
|
|
215
236
|
filterVirtualOptions(searchValue: string): void;
|
|
216
237
|
private handleInvalid;
|
|
217
238
|
handleDisabledChange(): void;
|
|
@@ -12,6 +12,7 @@ import '../nile-icon';
|
|
|
12
12
|
import '../nile-popup/nile-popup';
|
|
13
13
|
import '../nile-tag/nile-tag';
|
|
14
14
|
import '../nile-checkbox/nile-checkbox';
|
|
15
|
+
import '../nile-loader/nile-loader';
|
|
15
16
|
import { animateTo, stopAnimations } from '../internal/animate';
|
|
16
17
|
import { classMap } from 'lit/directives/class-map.js';
|
|
17
18
|
import { query, state } from 'lit/decorators.js';
|
|
@@ -26,6 +27,7 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
|
26
27
|
import { VirtualSelectSelectionManager } from './selection-manager.js';
|
|
27
28
|
import { VirtualSelectSearchManager } from './search-manager.js';
|
|
28
29
|
import { VirtualSelectRenderer } from './renderer.js';
|
|
30
|
+
import { ResizeController } from '@lit-labs/observers/resize-controller.js';
|
|
29
31
|
/**
|
|
30
32
|
* Nile Virtual Select component.
|
|
31
33
|
*
|
|
@@ -58,6 +60,10 @@ import { VirtualSelectRenderer } from './renderer.js';
|
|
|
58
60
|
* @event nile-hide - Emitted when the select's menu closes.
|
|
59
61
|
* @event nile-after-hide - Emitted after the select's menu closes and all animations are complete.
|
|
60
62
|
* @event nile-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.
|
|
63
|
+
* @event nile-search - Emitted when the user types in the search input. The event payload includes the search query for backend search functionality.
|
|
64
|
+
* @event nile-scroll - Emitted when the user scrolls within the virtualized container. The event payload includes scroll position information.
|
|
65
|
+
* @event nile-scroll-start - Emitted when the user starts scrolling within the virtualized container.
|
|
66
|
+
* @event nile-scroll-end - Emitted when the user stops scrolling and reaches the bottom of the virtualized container (debounced).
|
|
61
67
|
*
|
|
62
68
|
* @csspart form-control - The form control that wraps the label, input, and help text.
|
|
63
69
|
* @csspart form-control-label - The label's wrapper.
|
|
@@ -84,6 +90,7 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
84
90
|
this.displayLabel = '';
|
|
85
91
|
this.selectedOptions = [];
|
|
86
92
|
this.oldValue = '';
|
|
93
|
+
this.scrolling = false;
|
|
87
94
|
/** The name of the select, submitted as a name/value pair with form data. */
|
|
88
95
|
this.name = '';
|
|
89
96
|
/** Array of all option items for virtual scrolling */
|
|
@@ -100,6 +107,8 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
100
107
|
this.size = 'medium';
|
|
101
108
|
/** Placeholder text to show as a hint when the select is empty. */
|
|
102
109
|
this.placeholder = 'Select...';
|
|
110
|
+
/** Enable automatic resizing of tags area */
|
|
111
|
+
this.autoResize = false;
|
|
103
112
|
/** Current search value */
|
|
104
113
|
this.searchValue = '';
|
|
105
114
|
/** Enable search functionality */
|
|
@@ -110,6 +119,8 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
110
119
|
this.disableLocalSearch = false;
|
|
111
120
|
/** Show loading state */
|
|
112
121
|
this.optionsLoading = false;
|
|
122
|
+
/** Show loading state using nile-loader */
|
|
123
|
+
this.loading = false;
|
|
113
124
|
/** Allows more than one option to be selected. */
|
|
114
125
|
this.multiple = false;
|
|
115
126
|
/** Help text */
|
|
@@ -168,6 +179,7 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
168
179
|
*/
|
|
169
180
|
this.maxOptionsVisible = 3;
|
|
170
181
|
this.oldMaxOptionsVisible = 1;
|
|
182
|
+
this.showListbox = false;
|
|
171
183
|
this.handleDocumentMouseDown = (event) => {
|
|
172
184
|
if (!this.open)
|
|
173
185
|
return;
|
|
@@ -178,6 +190,27 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
178
190
|
this.hide();
|
|
179
191
|
}
|
|
180
192
|
};
|
|
193
|
+
/**
|
|
194
|
+
* This is a workaround for an error in the Lit Labs virtualizer.
|
|
195
|
+
* Since there are no specific guidelines available to fix the issue,
|
|
196
|
+
* we are catching only the error message related to the virtualizer.
|
|
197
|
+
*/
|
|
198
|
+
this.handleWindowError = (event) => {
|
|
199
|
+
const errorMessage = event.error?.message || event.message || '';
|
|
200
|
+
if (errorMessage.includes('Cannot read properties of null (reading \'insertBefore\')')) {
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
this.resizeController = new ResizeController(this, {
|
|
206
|
+
callback: (entries) => {
|
|
207
|
+
for (const entry of entries) {
|
|
208
|
+
if (entry.target.classList.contains('select__tags')) {
|
|
209
|
+
this.calculateTotalWidthOfTags();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
});
|
|
181
214
|
}
|
|
182
215
|
/** Gets the validity state object */
|
|
183
216
|
get validity() {
|
|
@@ -199,6 +232,25 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
199
232
|
}
|
|
200
233
|
disconnectedCallback() {
|
|
201
234
|
this.removeOpenListeners();
|
|
235
|
+
// Clear any pending scroll timeout to prevent memory leaks
|
|
236
|
+
if (this.scrollTimeout) {
|
|
237
|
+
clearTimeout(this.scrollTimeout);
|
|
238
|
+
this.scrollTimeout = undefined;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
updated(changedProperties) {
|
|
242
|
+
if (changedProperties.has('value')) {
|
|
243
|
+
this.selectionChanged();
|
|
244
|
+
}
|
|
245
|
+
if (changedProperties.has('autoResize')) {
|
|
246
|
+
const tagsDiv = this.shadowRoot?.querySelector('.select__tags');
|
|
247
|
+
if (this.autoResize && tagsDiv) {
|
|
248
|
+
this.resizeController.observe(tagsDiv);
|
|
249
|
+
}
|
|
250
|
+
else if (tagsDiv) {
|
|
251
|
+
this.resizeController.unobserve(tagsDiv);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
202
254
|
}
|
|
203
255
|
initializeComponent() {
|
|
204
256
|
this.open = false;
|
|
@@ -236,16 +288,19 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
236
288
|
this.handleDocumentFocusIn = this.handleDocumentFocusIn.bind(this);
|
|
237
289
|
this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);
|
|
238
290
|
this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);
|
|
291
|
+
this.handleWindowError = this.handleWindowError.bind(this);
|
|
239
292
|
}
|
|
240
293
|
addOpenListeners() {
|
|
241
294
|
document.addEventListener('focusin', this.handleDocumentFocusIn);
|
|
242
295
|
document.addEventListener('keydown', this.handleDocumentKeyDown);
|
|
243
296
|
document.addEventListener('mousedown', this.handleDocumentMouseDown);
|
|
297
|
+
window.addEventListener('error', this.handleWindowError);
|
|
244
298
|
}
|
|
245
299
|
removeOpenListeners() {
|
|
246
300
|
document.removeEventListener('focusin', this.handleDocumentFocusIn);
|
|
247
301
|
document.removeEventListener('keydown', this.handleDocumentKeyDown);
|
|
248
302
|
document.removeEventListener('mousedown', this.handleDocumentMouseDown);
|
|
303
|
+
window.removeEventListener('error', this.handleWindowError);
|
|
249
304
|
}
|
|
250
305
|
handleFocus() {
|
|
251
306
|
this.hasFocus = true;
|
|
@@ -319,7 +374,10 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
319
374
|
this.showSelected = !this.showSelected;
|
|
320
375
|
if (this.showSelected) {
|
|
321
376
|
const selectedValues = Array.isArray(this.value) ? this.value : [this.value];
|
|
322
|
-
this.data = this.originalOptionItems.filter((item) =>
|
|
377
|
+
this.data = this.originalOptionItems.filter((item) => {
|
|
378
|
+
const itemValue = this.getItemValue(item);
|
|
379
|
+
return selectedValues.some(val => String(val) === String(itemValue));
|
|
380
|
+
});
|
|
323
381
|
}
|
|
324
382
|
else {
|
|
325
383
|
this.data = [...this.originalOptionItems];
|
|
@@ -483,9 +541,58 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
483
541
|
}
|
|
484
542
|
handleSearchChange(e) {
|
|
485
543
|
this.searchValue = e.detail.value;
|
|
544
|
+
this.emit('nile-search', {
|
|
545
|
+
query: this.searchValue,
|
|
546
|
+
name: this.name
|
|
547
|
+
});
|
|
486
548
|
if (!this.disableLocalSearch) {
|
|
487
549
|
this.filterVirtualOptions(this.searchValue);
|
|
488
550
|
this.resetScrollPosition();
|
|
551
|
+
this.updateComplete.then(() => {
|
|
552
|
+
const virtualized = this.shadowRoot?.querySelector('.virtualized');
|
|
553
|
+
if (virtualized) {
|
|
554
|
+
if (this.data.length <= 5) {
|
|
555
|
+
virtualized.classList.add('no-scroll');
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
virtualized.classList.remove('no-scroll');
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
handleScroll(e) {
|
|
565
|
+
if (this.showSelected) {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const target = e.target;
|
|
569
|
+
this.emit('nile-scroll', {
|
|
570
|
+
scrollTop: target.scrollTop,
|
|
571
|
+
scrollLeft: target.scrollLeft,
|
|
572
|
+
name: this.name
|
|
573
|
+
});
|
|
574
|
+
if (!this.scrolling) {
|
|
575
|
+
this.scrolling = true;
|
|
576
|
+
this.emit('nile-scroll-start', {
|
|
577
|
+
scrollTop: target.scrollTop,
|
|
578
|
+
scrollLeft: target.scrollLeft,
|
|
579
|
+
name: this.name
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
clearTimeout(this.scrollTimeout);
|
|
583
|
+
this.scrollTimeout = window.setTimeout(() => {
|
|
584
|
+
if (this.scrolling) {
|
|
585
|
+
this.scrolling = false;
|
|
586
|
+
}
|
|
587
|
+
}, 300);
|
|
588
|
+
const isAtBottom = Math.ceil(target.scrollTop) >= Math.floor(target.scrollHeight - target.offsetHeight);
|
|
589
|
+
if (isAtBottom && !this.searchValue) {
|
|
590
|
+
this.emit('nile-scroll-end', {
|
|
591
|
+
scrollTop: target.scrollTop,
|
|
592
|
+
scrollLeft: target.scrollLeft,
|
|
593
|
+
name: this.name,
|
|
594
|
+
isAtBottom: true
|
|
595
|
+
});
|
|
489
596
|
}
|
|
490
597
|
}
|
|
491
598
|
filterVirtualOptions(searchValue) {
|
|
@@ -510,18 +617,18 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
510
617
|
this.requestUpdate();
|
|
511
618
|
}
|
|
512
619
|
handleDataChange() {
|
|
620
|
+
if (this.data.length > 0 && this.open && !this.showSelected && !this.searchValue) {
|
|
621
|
+
this.originalOptionItems = [...this.data];
|
|
622
|
+
}
|
|
513
623
|
this.selectionChanged();
|
|
514
624
|
// Show no results message when data is empty and not loading
|
|
515
|
-
if (!this.optionsLoading && this.data.length === 0) {
|
|
625
|
+
if (!this.optionsLoading && !this.loading && this.data.length === 0) {
|
|
516
626
|
this.showNoResults = true;
|
|
517
627
|
}
|
|
518
628
|
else if (this.data.length > 0) {
|
|
519
629
|
this.showNoResults = false;
|
|
520
630
|
}
|
|
521
631
|
this.requestUpdate();
|
|
522
|
-
if (this.open) {
|
|
523
|
-
this.resetScrollPosition();
|
|
524
|
-
}
|
|
525
632
|
}
|
|
526
633
|
handleRenderItemConfigChange() {
|
|
527
634
|
if (this.value && this.data.length > 0) {
|
|
@@ -539,9 +646,11 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
539
646
|
async handleOpenChange() {
|
|
540
647
|
if (this.open && !this.disabled) {
|
|
541
648
|
await this.handleOpen();
|
|
649
|
+
this.showListbox = true;
|
|
542
650
|
}
|
|
543
651
|
else {
|
|
544
652
|
await this.handleClose();
|
|
653
|
+
this.showListbox = false;
|
|
545
654
|
}
|
|
546
655
|
}
|
|
547
656
|
async handleOpen() {
|
|
@@ -572,7 +681,7 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
572
681
|
this.emit('nile-after-hide', { value: this.value, name: this.name });
|
|
573
682
|
}
|
|
574
683
|
initializeOriginalItems() {
|
|
575
|
-
if (this.
|
|
684
|
+
if (this.data.length > 0) {
|
|
576
685
|
this.originalOptionItems = [...this.data];
|
|
577
686
|
}
|
|
578
687
|
}
|
|
@@ -697,7 +806,7 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
697
806
|
>
|
|
698
807
|
${this.renderCustomSelect(hasCustomSelect)}
|
|
699
808
|
${this.renderCombobox(hasCustomSelect, hasClearIcon)}
|
|
700
|
-
${this.renderListbox()}
|
|
809
|
+
${this.showListbox ? this.renderListbox() : html ``}
|
|
701
810
|
</nile-popup>
|
|
702
811
|
`;
|
|
703
812
|
}
|
|
@@ -915,23 +1024,31 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
915
1024
|
: html ``;
|
|
916
1025
|
}
|
|
917
1026
|
renderLoader() {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
1027
|
+
if (this.loading) {
|
|
1028
|
+
return html `
|
|
1029
|
+
<span part="loader" class="virtual-select-loader">
|
|
1030
|
+
<nile-loader size="sm"></nile-loader>
|
|
1031
|
+
</span>
|
|
1032
|
+
`;
|
|
1033
|
+
}
|
|
1034
|
+
if (this.optionsLoading) {
|
|
1035
|
+
return html `
|
|
1036
|
+
<span part="loader" class="select__loader">
|
|
1037
|
+
<nile-icon
|
|
1038
|
+
class="select__loader--icon"
|
|
1039
|
+
name="button-loading-blue"
|
|
1040
|
+
></nile-icon>
|
|
1041
|
+
</span>
|
|
1042
|
+
`;
|
|
1043
|
+
}
|
|
1044
|
+
return html ``;
|
|
928
1045
|
}
|
|
929
1046
|
renderFooter() {
|
|
930
1047
|
return this.multiple
|
|
931
1048
|
? html `
|
|
932
1049
|
<div
|
|
933
1050
|
part="footer"
|
|
934
|
-
class="select__footer"
|
|
1051
|
+
class="select__footer ${this.loading ? 'loading' : ''}"
|
|
935
1052
|
@click="${this.handleFooterClick}"
|
|
936
1053
|
>
|
|
937
1054
|
<span
|
|
@@ -974,7 +1091,7 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
974
1091
|
`;
|
|
975
1092
|
}
|
|
976
1093
|
getVirtualizedContent() {
|
|
977
|
-
return VirtualSelectRenderer.getVirtualizedContent(this.data, this.searchEnabled, this.getDisplayText.bind(this), this.value, this.multiple, this.renderItemConfig?.getDisplayText, this.renderItemConfig?.getValue, this.showNoResults, this.noResultsMessage, this.optionsLoading);
|
|
1094
|
+
return VirtualSelectRenderer.getVirtualizedContent(this.data, this.searchEnabled, this.getDisplayText.bind(this), this.value, this.multiple, this.renderItemConfig?.getDisplayText, this.renderItemConfig?.getValue, this.showNoResults, this.noResultsMessage, this.optionsLoading || this.loading, this.handleScroll.bind(this));
|
|
978
1095
|
}
|
|
979
1096
|
nileInput(value) {
|
|
980
1097
|
this.emit('nile-input', value);
|
|
@@ -1034,14 +1151,14 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
1034
1151
|
}
|
|
1035
1152
|
resetScrollPosition() {
|
|
1036
1153
|
this.updateComplete.then(() => {
|
|
1037
|
-
if (this.virtualizedContainer) {
|
|
1154
|
+
if (this.virtualizedContainer && this.virtualizedContainer.isConnected) {
|
|
1038
1155
|
this.virtualizedContainer.scrollTop = 0;
|
|
1039
1156
|
const listbox = this.shadowRoot?.querySelector('.select__listbox');
|
|
1040
|
-
if (listbox) {
|
|
1157
|
+
if (listbox && listbox.isConnected) {
|
|
1041
1158
|
listbox.scrollTop = 0;
|
|
1042
1159
|
}
|
|
1043
1160
|
const virtualizer = this.virtualizedContainer.querySelector('lit-virtualizer');
|
|
1044
|
-
if (virtualizer) {
|
|
1161
|
+
if (virtualizer && virtualizer.isConnected) {
|
|
1045
1162
|
virtualizer.scrollTop = 0;
|
|
1046
1163
|
}
|
|
1047
1164
|
}
|
|
@@ -1099,6 +1216,9 @@ __decorate([
|
|
|
1099
1216
|
__decorate([
|
|
1100
1217
|
property()
|
|
1101
1218
|
], NileVirtualSelect.prototype, "placeholder", void 0);
|
|
1219
|
+
__decorate([
|
|
1220
|
+
property({ type: Boolean })
|
|
1221
|
+
], NileVirtualSelect.prototype, "autoResize", void 0);
|
|
1102
1222
|
__decorate([
|
|
1103
1223
|
state()
|
|
1104
1224
|
], NileVirtualSelect.prototype, "searchValue", void 0);
|
|
@@ -1114,6 +1234,9 @@ __decorate([
|
|
|
1114
1234
|
__decorate([
|
|
1115
1235
|
property({ type: Boolean, reflect: true })
|
|
1116
1236
|
], NileVirtualSelect.prototype, "optionsLoading", void 0);
|
|
1237
|
+
__decorate([
|
|
1238
|
+
property({ type: Boolean, reflect: true, attribute: true })
|
|
1239
|
+
], NileVirtualSelect.prototype, "loading", void 0);
|
|
1117
1240
|
__decorate([
|
|
1118
1241
|
property({ type: Boolean, reflect: true })
|
|
1119
1242
|
], NileVirtualSelect.prototype, "multiple", void 0);
|
|
@@ -1186,6 +1309,9 @@ __decorate([
|
|
|
1186
1309
|
__decorate([
|
|
1187
1310
|
state()
|
|
1188
1311
|
], NileVirtualSelect.prototype, "oldMaxOptionsVisible", void 0);
|
|
1312
|
+
__decorate([
|
|
1313
|
+
state()
|
|
1314
|
+
], NileVirtualSelect.prototype, "showListbox", void 0);
|
|
1189
1315
|
__decorate([
|
|
1190
1316
|
watch('disabled', { waitUntilFirstUpdate: true })
|
|
1191
1317
|
], NileVirtualSelect.prototype, "handleDisabledChange", null);
|