@aquera/nile-elements 0.1.49 → 0.1.50-beta-1.0

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.
Files changed (156) hide show
  1. package/README.md +5 -2
  2. package/demo/index.html +150 -33
  3. package/dist/index.cjs.js +1 -1
  4. package/dist/index.esm.js +1 -1
  5. package/dist/internal/form.cjs.js +1 -1
  6. package/dist/internal/form.cjs.js.map +1 -1
  7. package/dist/internal/form.esm.js +1 -1
  8. package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
  9. package/dist/nile-auto-complete/index.cjs.js +1 -1
  10. package/dist/nile-auto-complete/index.esm.js +1 -1
  11. package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -17
  12. package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
  13. package/dist/nile-auto-complete/nile-auto-complete.esm.js +8 -29
  14. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
  15. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js.map +1 -1
  16. package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
  17. package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
  18. package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
  19. package/dist/nile-button/nile-button.test.cjs.js +1 -1
  20. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
  21. package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
  22. package/dist/nile-calendar/nile-calendar.test.cjs.js.map +1 -1
  23. package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
  24. package/dist/nile-card/nile-card.test.cjs.js +1 -1
  25. package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
  26. package/dist/nile-chip/nile-chip.cjs.js +1 -1
  27. package/dist/nile-chip/nile-chip.cjs.js.map +1 -1
  28. package/dist/nile-chip/nile-chip.esm.js +0 -1
  29. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  30. package/dist/nile-chip/nile-chip.test.cjs.js.map +1 -1
  31. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  32. package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
  33. package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
  34. package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
  35. package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
  36. package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
  37. package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +1 -1
  38. package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
  39. package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
  40. package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
  41. package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
  42. package/dist/nile-input/nile-input.test.cjs.js +1 -1
  43. package/dist/nile-link/nile-link.test.cjs.js +1 -1
  44. package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
  45. package/dist/nile-option/nile-option.cjs.js +1 -1
  46. package/dist/nile-option/nile-option.cjs.js.map +1 -1
  47. package/dist/nile-option/nile-option.css.cjs.js +1 -1
  48. package/dist/nile-option/nile-option.css.cjs.js.map +1 -1
  49. package/dist/nile-option/nile-option.css.esm.js +1 -1
  50. package/dist/nile-option/nile-option.esm.js +2 -2
  51. package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
  52. package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
  53. package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
  54. package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
  55. package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
  56. package/dist/nile-select/index.cjs.js +1 -1
  57. package/dist/nile-select/index.esm.js +1 -1
  58. package/dist/nile-select/nile-select.cjs.js +1 -1
  59. package/dist/nile-select/nile-select.cjs.js.map +1 -1
  60. package/dist/nile-select/nile-select.esm.js +2 -2
  61. package/dist/nile-select/nile-select.test.cjs.js +1 -1
  62. package/dist/nile-select/nile-select.test.cjs.js.map +1 -1
  63. package/dist/nile-select/nile-select.test.esm.js +2 -2
  64. package/dist/nile-select/virtual-scroll-helper.cjs.js +2 -0
  65. package/dist/nile-select/virtual-scroll-helper.cjs.js.map +1 -0
  66. package/dist/nile-select/virtual-scroll-helper.esm.js +38 -0
  67. package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
  68. package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
  69. package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
  70. package/dist/nile-virtual-select/index.cjs.js +2 -0
  71. package/dist/nile-virtual-select/index.cjs.js.map +1 -0
  72. package/dist/nile-virtual-select/index.esm.js +1 -0
  73. package/dist/nile-virtual-select/nile-virtual-select.cjs.js +2 -0
  74. package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -0
  75. package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +2 -0
  76. package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +1 -0
  77. package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +467 -0
  78. package/dist/nile-virtual-select/nile-virtual-select.esm.js +227 -0
  79. package/dist/nile-virtual-select/nile-virtual-select.test.cjs.js +2 -0
  80. package/dist/nile-virtual-select/nile-virtual-select.test.cjs.js.map +1 -0
  81. package/dist/nile-virtual-select/nile-virtual-select.test.esm.js +49 -0
  82. package/dist/nile-virtual-select/renderer.cjs.js +2 -0
  83. package/dist/nile-virtual-select/renderer.cjs.js.map +1 -0
  84. package/dist/nile-virtual-select/renderer.esm.js +18 -0
  85. package/dist/nile-virtual-select/search-manager.cjs.js +2 -0
  86. package/dist/nile-virtual-select/search-manager.cjs.js.map +1 -0
  87. package/dist/nile-virtual-select/search-manager.esm.js +1 -0
  88. package/dist/nile-virtual-select/selection-manager.cjs.js +2 -0
  89. package/dist/nile-virtual-select/selection-manager.cjs.js.map +1 -0
  90. package/dist/nile-virtual-select/selection-manager.esm.js +1 -0
  91. package/dist/nile-virtual-select/types.cjs.js +2 -0
  92. package/dist/nile-virtual-select/types.cjs.js.map +1 -0
  93. package/dist/nile-virtual-select/types.esm.js +1 -0
  94. package/dist/src/index.d.ts +1 -0
  95. package/dist/src/index.js +1 -0
  96. package/dist/src/index.js.map +1 -1
  97. package/dist/src/internal/form.js +2 -2
  98. package/dist/src/internal/form.js.map +1 -1
  99. package/dist/src/nile-chip/nile-chip.js +0 -1
  100. package/dist/src/nile-chip/nile-chip.js.map +1 -1
  101. package/dist/src/nile-option/nile-option.css.js +1 -1
  102. package/dist/src/nile-option/nile-option.css.js.map +1 -1
  103. package/dist/src/nile-option/nile-option.d.ts +5 -1
  104. package/dist/src/nile-option/nile-option.js +21 -6
  105. package/dist/src/nile-option/nile-option.js.map +1 -1
  106. package/dist/src/nile-select/nile-select.d.ts +11 -2
  107. package/dist/src/nile-select/nile-select.js +37 -18
  108. package/dist/src/nile-select/nile-select.js.map +1 -1
  109. package/dist/src/nile-select/virtual-scroll-helper.d.ts +9 -0
  110. package/dist/src/nile-select/virtual-scroll-helper.js +51 -0
  111. package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -0
  112. package/dist/src/nile-virtual-select/index.d.ts +1 -0
  113. package/dist/src/nile-virtual-select/index.js +2 -0
  114. package/dist/src/nile-virtual-select/index.js.map +1 -0
  115. package/dist/src/nile-virtual-select/nile-virtual-select.css.d.ts +12 -0
  116. package/dist/src/nile-virtual-select/nile-virtual-select.css.js +479 -0
  117. package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -0
  118. package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +263 -0
  119. package/dist/src/nile-virtual-select/nile-virtual-select.js +1183 -0
  120. package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -0
  121. package/dist/src/nile-virtual-select/nile-virtual-select.test.d.ts +7 -0
  122. package/dist/src/nile-virtual-select/nile-virtual-select.test.js +341 -0
  123. package/dist/src/nile-virtual-select/nile-virtual-select.test.js.map +1 -0
  124. package/dist/src/nile-virtual-select/renderer.d.ts +11 -0
  125. package/dist/src/nile-virtual-select/renderer.js +51 -0
  126. package/dist/src/nile-virtual-select/renderer.js.map +1 -0
  127. package/dist/src/nile-virtual-select/search-manager.d.ts +12 -0
  128. package/dist/src/nile-virtual-select/search-manager.js +40 -0
  129. package/dist/src/nile-virtual-select/search-manager.js.map +1 -0
  130. package/dist/src/nile-virtual-select/selection-manager.d.ts +12 -0
  131. package/dist/src/nile-virtual-select/selection-manager.js +64 -0
  132. package/dist/src/nile-virtual-select/selection-manager.js.map +1 -0
  133. package/dist/src/nile-virtual-select/types.d.ts +50 -0
  134. package/dist/src/nile-virtual-select/types.js +8 -0
  135. package/dist/src/nile-virtual-select/types.js.map +1 -0
  136. package/dist/tsconfig.tsbuildinfo +1 -1
  137. package/dist/virtualize-a4a40d96.esm.js +22 -0
  138. package/dist/virtualize-b6a2fbe0.cjs.js +18 -0
  139. package/dist/virtualize-b6a2fbe0.cjs.js.map +1 -0
  140. package/package.json +1 -2
  141. package/src/index.ts +3 -1
  142. package/src/internal/form.ts +2 -2
  143. package/src/nile-chip/nile-chip.ts +0 -1
  144. package/src/nile-option/nile-option.css.ts +1 -1
  145. package/src/nile-option/nile-option.ts +17 -3
  146. package/src/nile-select/nile-select.ts +35 -9
  147. package/src/nile-select/virtual-scroll-helper.ts +56 -0
  148. package/src/nile-virtual-select/index.ts +1 -0
  149. package/src/nile-virtual-select/nile-virtual-select.css.ts +481 -0
  150. package/src/nile-virtual-select/nile-virtual-select.test.ts +414 -0
  151. package/src/nile-virtual-select/nile-virtual-select.ts +1268 -0
  152. package/src/nile-virtual-select/renderer.ts +73 -0
  153. package/src/nile-virtual-select/search-manager.ts +50 -0
  154. package/src/nile-virtual-select/selection-manager.ts +75 -0
  155. package/src/nile-virtual-select/types.ts +54 -0
  156. package/vscode-html-custom-data.json +229 -2
@@ -0,0 +1,414 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { expect, fixture, html } from '@open-wc/testing';
9
+ import type NileVirtualSelect from './nile-virtual-select';
10
+
11
+ describe('<nile-virtual-select>', () => {
12
+ describe('maxOptionsVisible functionality', () => {
13
+ it('should show "+n More" when more options are selected than maxOptionsVisible', async () => {
14
+ const el = await fixture<NileVirtualSelect>(html`
15
+ <nile-virtual-select multiple max-options-visible="2">
16
+ <div slot="label">Test Select</div>
17
+ </nile-virtual-select>
18
+ `);
19
+
20
+ // Set up test data
21
+ el.data = [
22
+ { value: 'option-1', label: 'Option 1' },
23
+ { value: 'option-2', label: 'Option 2' },
24
+ { value: 'option-3', label: 'Option 3' },
25
+ { value: 'option-4', label: 'Option 4' }
26
+ ];
27
+ el.renderItemConfig = {
28
+ getDisplayText: (item: any) => item.label
29
+ };
30
+
31
+ // Set multiple values
32
+ el.value = ['option-1', 'option-2', 'option-3'];
33
+
34
+ await el.updateComplete;
35
+
36
+ // Check that the tags count element exists
37
+ const tagsCount = el.shadowRoot?.querySelector('.select__tags-count');
38
+ expect(tagsCount).to.exist;
39
+ expect(tagsCount?.textContent?.trim()).to.equal('+1 More');
40
+ });
41
+
42
+ it('should not show "+n More" when selected options are within maxOptionsVisible limit', async () => {
43
+ const el = await fixture<NileVirtualSelect>(html`
44
+ <nile-virtual-select multiple max-options-visible="3">
45
+ <div slot="label">Test Select</div>
46
+ </nile-virtual-select>
47
+ `);
48
+
49
+ // Set up test data
50
+ el.data = [
51
+ { value: 'option-1', label: 'Option 1' },
52
+ { value: 'option-2', label: 'Option 2' },
53
+ { value: 'option-3', label: 'Option 3' }
54
+ ];
55
+ el.renderItemConfig = {
56
+ getDisplayText: (item: any) => item.label
57
+ };
58
+
59
+ // Set values within limit
60
+ el.value = ['option-1', 'option-2'];
61
+
62
+ await el.updateComplete;
63
+
64
+ // Check that the tags count element does not exist
65
+ const tagsCount = el.shadowRoot?.querySelector('.select__tags-count');
66
+ expect(tagsCount).to.not.exist;
67
+ });
68
+
69
+ it('should show all tags when maxOptionsVisible is 0', async () => {
70
+ const el = await fixture<NileVirtualSelect>(html`
71
+ <nile-virtual-select multiple max-options-visible="0">
72
+ <div slot="label">Test Select</div>
73
+ </nile-virtual-select>
74
+ `);
75
+
76
+ // Set up test data
77
+ el.data = [
78
+ { value: 'option-1', label: 'Option 1' },
79
+ { value: 'option-2', label: 'Option 2' },
80
+ { value: 'option-3', label: 'Option 3' },
81
+ { value: 'option-4', label: 'Option 4' }
82
+ ];
83
+ el.renderItemConfig = {
84
+ getDisplayText: (item: any) => item.label
85
+ };
86
+
87
+ // Set multiple values
88
+ el.value = ['option-1', 'option-2', 'option-3', 'option-4'];
89
+
90
+ await el.updateComplete;
91
+
92
+ // Check that the tags count element does not exist
93
+ const tagsCount = el.shadowRoot?.querySelector('.select__tags-count');
94
+ expect(tagsCount).to.not.exist;
95
+
96
+ // Check that all tags are rendered
97
+ const tags = el.shadowRoot?.querySelectorAll('nile-tag');
98
+ expect(tags?.length).to.equal(4);
99
+ });
100
+ });
101
+
102
+ describe('option width functionality', () => {
103
+ it('should render options with full width', async () => {
104
+ const el = await fixture<NileVirtualSelect>(html`
105
+ <nile-virtual-select>
106
+ <div slot="label">Test Select</div>
107
+ </nile-virtual-select>
108
+ `);
109
+
110
+ // Set up test data
111
+ el.data = [
112
+ { value: 'option-1', label: 'Option 1' },
113
+ { value: 'option-2', label: 'Option 2' },
114
+ { value: 'option-3', label: 'Option 3' }
115
+ ];
116
+ el.renderItemConfig = {
117
+ getDisplayText: (item: any) => item.label
118
+ };
119
+
120
+ // Open the select to render options
121
+ el.open = true;
122
+ await el.updateComplete;
123
+
124
+ // Get the virtualized content
125
+ const virtualizedContent = el.shadowRoot?.querySelector('.virtualized');
126
+ expect(virtualizedContent).to.exist;
127
+
128
+ // Check that the select__options wrapper exists
129
+ const selectOptions = el.shadowRoot?.querySelector('.select__options');
130
+ expect(selectOptions).to.exist;
131
+
132
+ // Verify the structure matches the regular select
133
+ const listbox = el.shadowRoot?.querySelector('.select__listbox');
134
+ expect(listbox).to.exist;
135
+ expect(listbox?.querySelector('.select__options')).to.exist;
136
+ });
137
+
138
+ it('should render options with proper CSS classes for width', async () => {
139
+ const el = await fixture<NileVirtualSelect>(html`
140
+ <nile-virtual-select>
141
+ <div slot="label">Test Select</div>
142
+ </nile-virtual-select>
143
+ `);
144
+
145
+ // Set up test data
146
+ el.data = [
147
+ { value: 'option-1', label: 'Option 1' },
148
+ { value: 'option-2', label: 'Option 2' }
149
+ ];
150
+ el.renderItemConfig = {
151
+ getDisplayText: (item: any) => item.label
152
+ };
153
+
154
+ // Open the select to render options
155
+ el.open = true;
156
+ await el.updateComplete;
157
+
158
+ // Check that the virtualized container has the proper class
159
+ const virtualized = el.shadowRoot?.querySelector('.virtualized');
160
+ expect(virtualized).to.exist;
161
+
162
+ // Check that the select__options container exists and has proper styling
163
+ const selectOptions = el.shadowRoot?.querySelector('.select__options');
164
+ expect(selectOptions).to.exist;
165
+
166
+ // Check that the virtualizer element exists and has proper width styling
167
+ const virtualizer = el.shadowRoot?.querySelector('lit-virtualizer');
168
+ expect(virtualizer).to.exist;
169
+ });
170
+
171
+ it('should render virtualized options with full width structure', async () => {
172
+ const el = await fixture<NileVirtualSelect>(html`
173
+ <nile-virtual-select>
174
+ <div slot="label">Test Select</div>
175
+ </nile-virtual-select>
176
+ `);
177
+
178
+ // Set up test data
179
+ el.data = [
180
+ { value: 'option-1', label: 'Option 1' },
181
+ { value: 'option-2', label: 'Option 2' },
182
+ { value: 'option-3', label: 'Option 3' }
183
+ ];
184
+ el.renderItemConfig = {
185
+ getDisplayText: (item: any) => item.label
186
+ };
187
+
188
+ // Open the select to render options
189
+ el.open = true;
190
+ await el.updateComplete;
191
+
192
+ // Verify the complete structure matches the regular select
193
+ const listbox = el.shadowRoot?.querySelector('.select__listbox');
194
+ expect(listbox).to.exist;
195
+
196
+ const selectOptions = listbox?.querySelector('.select__options');
197
+ expect(selectOptions).to.exist;
198
+
199
+ const virtualized = selectOptions?.querySelector('.virtualized');
200
+ expect(virtualized).to.exist;
201
+
202
+ // Check that the structure is properly nested
203
+ expect(listbox?.contains(selectOptions || null)).to.be.true;
204
+ expect(selectOptions?.contains(virtualized || null)).to.be.true;
205
+ });
206
+ });
207
+
208
+ describe('selected options highlighting', () => {
209
+ it('should highlight selected options with red border in single select mode', async () => {
210
+ const el = await fixture<NileVirtualSelect>(html`
211
+ <nile-virtual-select>
212
+ <div slot="label">Test Select</div>
213
+ </nile-virtual-select>
214
+ `);
215
+
216
+ // Set up test data
217
+ el.data = [
218
+ { value: 'option-1', label: 'Option 1' },
219
+ { value: 'option-2', label: 'Option 2' },
220
+ { value: 'option-3', label: 'Option 3' }
221
+ ];
222
+ el.renderItemConfig = {
223
+ getDisplayText: (item: any) => item.label
224
+ };
225
+
226
+ // Set a selected value
227
+ el.value = 'option-2';
228
+
229
+ // Open the select to render options
230
+ el.open = true;
231
+ await el.updateComplete;
232
+
233
+ // Check that the selected option has the selected attribute
234
+ const selectedOption = el.shadowRoot?.querySelector('nile-option[selected]');
235
+ expect(selectedOption).to.exist;
236
+ expect(selectedOption?.getAttribute('value')).to.equal('option-2');
237
+ });
238
+
239
+ it('should highlight selected options with red border in multiple select mode', async () => {
240
+ const el = await fixture<NileVirtualSelect>(html`
241
+ <nile-virtual-select multiple>
242
+ <div slot="label">Test Select</div>
243
+ </nile-virtual-select>
244
+ `);
245
+
246
+ // Set up test data
247
+ el.data = [
248
+ { value: 'option-1', label: 'Option 1' },
249
+ { value: 'option-2', label: 'Option 2' },
250
+ { value: 'option-3', label: 'Option 3' }
251
+ ];
252
+ el.renderItemConfig = {
253
+ getDisplayText: (item: any) => item.label
254
+ };
255
+
256
+ // Set multiple selected values
257
+ el.value = ['option-1', 'option-3'];
258
+
259
+ // Open the select to render options
260
+ el.open = true;
261
+ await el.updateComplete;
262
+
263
+ // Check that the selected options have the selected attribute
264
+ const selectedOptions = el.shadowRoot?.querySelectorAll('nile-option[selected]');
265
+ expect(selectedOptions?.length).to.equal(2);
266
+
267
+ const selectedValues = Array.from(selectedOptions || []).map(option => option.getAttribute('value'));
268
+ expect(selectedValues).to.include('option-1');
269
+ expect(selectedValues).to.include('option-3');
270
+ });
271
+
272
+ it('should not highlight unselected options', async () => {
273
+ const el = await fixture<NileVirtualSelect>(html`
274
+ <nile-virtual-select>
275
+ <div slot="label">Test Select</div>
276
+ </nile-virtual-select>
277
+ `);
278
+
279
+ // Set up test data
280
+ el.data = [
281
+ { value: 'option-1', label: 'Option 1' },
282
+ { value: 'option-2', label: 'Option 2' },
283
+ { value: 'option-3', label: 'Option 3' }
284
+ ];
285
+ el.renderItemConfig = {
286
+ getDisplayText: (item: any) => item.label
287
+ };
288
+
289
+ // Set a selected value
290
+ el.value = 'option-2';
291
+
292
+ // Open the select to render options
293
+ el.open = true;
294
+ await el.updateComplete;
295
+
296
+ // Check that unselected options don't have the selected attribute
297
+ const unselectedOption = el.shadowRoot?.querySelector('nile-option[value="option-1"]');
298
+ expect(unselectedOption).to.exist;
299
+ expect(unselectedOption?.hasAttribute('selected')).to.be.false;
300
+ });
301
+
302
+ it('should show tags for pre-selected values when data is set after value', async () => {
303
+ const el = await fixture<NileVirtualSelect>(html`
304
+ <nile-virtual-select multiple>
305
+ <div slot="label">Test Select</div>
306
+ </nile-virtual-select>
307
+ `);
308
+
309
+ // Set renderItemFunction first
310
+ el.renderItemConfig = {
311
+ getDisplayText: (item: any) => item.label
312
+ };
313
+
314
+ // Set value before data
315
+ el.value = ['option-1', 'option-3'];
316
+
317
+ await el.updateComplete;
318
+
319
+ // Initially, no tags should be shown because data is empty
320
+ const initialTags = el.shadowRoot?.querySelectorAll('nile-tag');
321
+ expect(initialTags?.length).to.equal(0);
322
+
323
+ // Now set data
324
+ el.data = [
325
+ { value: 'option-1', label: 'Option 1' },
326
+ { value: 'option-2', label: 'Option 2' },
327
+ { value: 'option-3', label: 'Option 3' }
328
+ ];
329
+
330
+ await el.updateComplete;
331
+
332
+ // Now tags should be shown
333
+ const tags = el.shadowRoot?.querySelectorAll('nile-tag');
334
+ expect(tags?.length).to.equal(2);
335
+
336
+ const tagTexts = Array.from(tags || []).map(tag => tag.textContent?.trim());
337
+ expect(tagTexts).to.include('Option 1');
338
+ expect(tagTexts).to.include('Option 3');
339
+ });
340
+
341
+ it('should show tags immediately without opening dropdown', async () => {
342
+ const el = await fixture<NileVirtualSelect>(html`
343
+ <nile-virtual-select multiple>
344
+ <div slot="label">Test Select</div>
345
+ </nile-virtual-select>
346
+ `);
347
+
348
+ // Set up test data
349
+ el.renderItemConfig = {
350
+ getDisplayText: (item: any) => item.label
351
+ };
352
+ el.data = [
353
+ { value: 'option-1', label: 'Option 1' },
354
+ { value: 'option-2', label: 'Option 2' },
355
+ { value: 'option-3', label: 'Option 3' }
356
+ ];
357
+ el.value = ['option-1', 'option-3'];
358
+
359
+ await el.updateComplete;
360
+
361
+ // Ensure dropdown is closed
362
+ el.open = false;
363
+ await el.updateComplete;
364
+
365
+ // Check that tags are shown even when dropdown is closed
366
+ const tags = el.shadowRoot?.querySelectorAll('nile-tag');
367
+ expect(tags?.length).to.equal(2);
368
+
369
+ const tagTexts = Array.from(tags || []).map(tag => tag.textContent?.trim());
370
+ expect(tagTexts).to.include('Option 1');
371
+ expect(tagTexts).to.include('Option 3');
372
+ });
373
+
374
+ it('should show checkbox as checked for selected options in multiple mode', async () => {
375
+ const el = await fixture<NileVirtualSelect>(html`
376
+ <nile-virtual-select multiple>
377
+ <div slot="label">Test Select</div>
378
+ </nile-virtual-select>
379
+ `);
380
+
381
+ // Set up test data
382
+ el.renderItemConfig = {
383
+ getDisplayText: (item: any) => item.label
384
+ };
385
+ el.data = [
386
+ { value: 'option-1', label: 'Option 1' },
387
+ { value: 'option-2', label: 'Option 2' },
388
+ { value: 'option-3', label: 'Option 3' }
389
+ ];
390
+ el.value = ['option-1', 'option-3'];
391
+
392
+ // Open the select to render options
393
+ el.open = true;
394
+ await el.updateComplete;
395
+
396
+ // Check that selected options have checked checkboxes
397
+ const selectedOptions = el.shadowRoot?.querySelectorAll('nile-option[selected]');
398
+ expect(selectedOptions?.length).to.equal(2);
399
+
400
+ selectedOptions?.forEach(option => {
401
+ const checkbox = option.shadowRoot?.querySelector('nile-checkbox');
402
+ expect(checkbox).to.exist;
403
+ expect(checkbox?.checked).to.be.true;
404
+ });
405
+
406
+ // Check that unselected options have unchecked checkboxes
407
+ const unselectedOption = el.shadowRoot?.querySelector('nile-option[value="option-2"]');
408
+ expect(unselectedOption).to.exist;
409
+ const unselectedCheckbox = unselectedOption?.shadowRoot?.querySelector('nile-checkbox');
410
+ expect(unselectedCheckbox).to.exist;
411
+ expect(unselectedCheckbox?.checked).to.be.false;
412
+ });
413
+ });
414
+ });