@aquera/nile-elements 1.4.8 → 1.4.9
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 +4 -0
- package/dist/index.js +67 -28
- package/dist/nile-option/nile-option.cjs.js +1 -1
- package/dist/nile-option/nile-option.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.cjs.js +1 -1
- package/dist/nile-option/nile-option.css.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.esm.js +28 -2
- package/dist/nile-option/nile-option.esm.js +10 -7
- 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 +2 -2
- 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 +3 -0
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +3 -3
- 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 +4 -1
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +4 -4
- 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 +20 -16
- package/dist/nile-virtual-select/search-manager.cjs.js +1 -1
- package/dist/nile-virtual-select/search-manager.cjs.js.map +1 -1
- package/dist/nile-virtual-select/search-manager.esm.js +1 -1
- 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-option/nile-option.css.js +26 -0
- package/dist/src/nile-option/nile-option.css.js.map +1 -1
- package/dist/src/nile-option/nile-option.d.ts +8 -0
- package/dist/src/nile-option/nile-option.js +57 -5
- package/dist/src/nile-option/nile-option.js.map +1 -1
- package/dist/src/nile-select/nile-select.d.ts +4 -0
- package/dist/src/nile-select/nile-select.js +46 -9
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-select/virtual-scroll-helper.js +3 -0
- package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +4 -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 +15 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.js +50 -3
- 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 +18 -8
- package/dist/src/nile-virtual-select/renderer.js.map +1 -1
- package/dist/src/nile-virtual-select/search-manager.d.ts +1 -1
- package/dist/src/nile-virtual-select/search-manager.js +5 -1
- package/dist/src/nile-virtual-select/search-manager.js.map +1 -1
- package/dist/src/nile-virtual-select/selection-manager.d.ts +1 -1
- package/dist/src/nile-virtual-select/selection-manager.js +4 -1
- package/dist/src/nile-virtual-select/selection-manager.js.map +1 -1
- package/dist/src/nile-virtual-select/types.d.ts +3 -0
- package/dist/src/nile-virtual-select/types.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-option/nile-option.css.ts +26 -0
- package/src/nile-option/nile-option.ts +49 -5
- package/src/nile-select/nile-select.ts +44 -10
- package/src/nile-select/virtual-scroll-helper.ts +3 -0
- package/src/nile-virtual-select/nile-virtual-select.css.ts +4 -1
- package/src/nile-virtual-select/nile-virtual-select.ts +53 -2
- package/src/nile-virtual-select/renderer.ts +29 -8
- package/src/nile-virtual-select/search-manager.ts +6 -0
- package/src/nile-virtual-select/selection-manager.ts +6 -1
- package/src/nile-virtual-select/types.ts +3 -0
- package/vscode-html-custom-data.json +42 -3
package/package.json
CHANGED
|
@@ -117,6 +117,32 @@ export const styles = css`
|
|
|
117
117
|
outline-offset: -1px;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
+
|
|
121
|
+
.option__label-container {
|
|
122
|
+
display: flex;
|
|
123
|
+
flex-direction: column;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.option__description {
|
|
127
|
+
font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm));
|
|
128
|
+
color: var(--nile-colors-dark-500, var(--ng-colors-text-tertiary-600));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.text-ellipsis {
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
text-overflow: ellipsis;
|
|
134
|
+
white-space: nowrap;
|
|
135
|
+
display: inline-block;
|
|
136
|
+
width: 99%;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.option__label-text-ellipsis {
|
|
140
|
+
overflow: hidden;
|
|
141
|
+
text-overflow: ellipsis;
|
|
142
|
+
white-space: nowrap;
|
|
143
|
+
display: inline-block;
|
|
144
|
+
width: 99%;
|
|
145
|
+
}
|
|
120
146
|
`;
|
|
121
147
|
|
|
122
148
|
export default [styles];
|
|
@@ -71,6 +71,19 @@ export class NileOption extends NileElement {
|
|
|
71
71
|
/* used to pass group name to the option, so that grouped options can be shown */
|
|
72
72
|
@property({ type: String, reflect: true, attribute: true }) groupName: string = '';
|
|
73
73
|
|
|
74
|
+
/* used to pass description to the option, so that description can be shown */
|
|
75
|
+
@property({ type: String, reflect: true, attribute: true }) description: string = '';
|
|
76
|
+
|
|
77
|
+
@query('slot[name="prefix"]') prefixSlot!: HTMLSlotElement;
|
|
78
|
+
|
|
79
|
+
@query('slot[name="suffix"]') suffixSlot!: HTMLSlotElement;
|
|
80
|
+
|
|
81
|
+
@query('.option__label-container') labelContainer!: HTMLElement;
|
|
82
|
+
|
|
83
|
+
@state() isParentVirtualSelect = false;
|
|
84
|
+
|
|
85
|
+
@property({ type: Boolean, reflect: true, attribute: true }) isDescriptionEnabled = false;
|
|
86
|
+
|
|
74
87
|
connectedCallback() {
|
|
75
88
|
super.connectedCallback();
|
|
76
89
|
this.setAttribute('role', 'option');
|
|
@@ -79,6 +92,28 @@ export class NileOption extends NileElement {
|
|
|
79
92
|
this.checkIfMultipleSelect();
|
|
80
93
|
}
|
|
81
94
|
|
|
95
|
+
protected firstUpdated() {
|
|
96
|
+
if (this.parentElement?.tagName === 'NILE-SELECT') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.isParentVirtualSelect = true;
|
|
101
|
+
this.applyWidthToLabelContainer();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
applyWidthToLabelContainer() {
|
|
105
|
+
const hasPrefix = (this.prefixSlot?.assignedNodes({ flatten: true }) ?? []).length > 0;
|
|
106
|
+
const hasSuffix = (this.suffixSlot?.assignedNodes({ flatten: true }) ?? []).length > 0;
|
|
107
|
+
|
|
108
|
+
let totalWidth = 0;
|
|
109
|
+
if (hasPrefix) totalWidth += 30;
|
|
110
|
+
if (hasSuffix) totalWidth += 30;
|
|
111
|
+
if (this.showCheckbox) totalWidth += 50;
|
|
112
|
+
if (this.labelContainer) {
|
|
113
|
+
this.labelContainer.style.width = `calc(100% - ${totalWidth}px)`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
82
117
|
checkIfMultipleSelect() {
|
|
83
118
|
// Find the closest parent 'nile-select' element
|
|
84
119
|
const parentSelect = this.closest('nile-select');
|
|
@@ -186,11 +221,20 @@ export class NileOption extends NileElement {
|
|
|
186
221
|
${this.isMultipleSelect ? html`<nile-checkbox part="checkbox" class="option--checkbox" .checked=${this.selected}></nile-checkbox>` : ''}
|
|
187
222
|
|
|
188
223
|
<slot part="prefix" name="prefix" class="option__prefix"></slot>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
224
|
+
<div class="option__label-container" part="option_label_container">
|
|
225
|
+
<slot
|
|
226
|
+
part="label"
|
|
227
|
+
@slotchange=${this.handleDefaultSlotChange}
|
|
228
|
+
class=${classMap({
|
|
229
|
+
'option__label': true,
|
|
230
|
+
'option__label-text-ellipsis': this.isParentVirtualSelect,
|
|
231
|
+
})}
|
|
232
|
+
></slot>
|
|
233
|
+
${this.isDescriptionEnabled && this.description ? html`<span part="option_description" class=${classMap({
|
|
234
|
+
'option__description': true,
|
|
235
|
+
'text-ellipsis': this.isParentVirtualSelect,
|
|
236
|
+
})}>${this.description}</span>` : ''}
|
|
237
|
+
</div>
|
|
194
238
|
<slot part="suffix" name="suffix" class="option__suffix"></slot>
|
|
195
239
|
</div>`
|
|
196
240
|
: ''}
|
|
@@ -298,6 +298,19 @@ export class NileSelect extends NileElement implements NileFormControl{
|
|
|
298
298
|
|
|
299
299
|
@property({ type: Boolean, reflect: true }) stickyHeader = false;
|
|
300
300
|
|
|
301
|
+
@property({ type: Boolean, reflect: true, attribute: true }) descriptionSearchEnabled = false;
|
|
302
|
+
|
|
303
|
+
@property({ type: Boolean, reflect: true, attribute: true }) enableDescription = false;
|
|
304
|
+
|
|
305
|
+
@property({
|
|
306
|
+
type: Boolean,
|
|
307
|
+
reflect: true,
|
|
308
|
+
attribute: true,
|
|
309
|
+
converter: {
|
|
310
|
+
fromAttribute: (value) => value === 'true' || value === '',
|
|
311
|
+
toAttribute: (value) => String(value),
|
|
312
|
+
},
|
|
313
|
+
}) allowHtmlLabel = true;
|
|
301
314
|
|
|
302
315
|
/** Gets the validity state object */
|
|
303
316
|
get validity() {
|
|
@@ -372,11 +385,16 @@ export class NileSelect extends NileElement implements NileFormControl{
|
|
|
372
385
|
if (_changedProperties.has('autoResize')) {
|
|
373
386
|
this.setupResizeObserver();
|
|
374
387
|
}
|
|
388
|
+
if(_changedProperties.has('enableDescription')) {
|
|
389
|
+
this.setEnableDescriptionInOptions();
|
|
390
|
+
}
|
|
375
391
|
}
|
|
376
392
|
|
|
377
393
|
protected firstUpdated(_changedProperties: PropertyValues): void {
|
|
378
394
|
if(this.enableGroupHeader) {
|
|
379
|
-
this.
|
|
395
|
+
if(!this.disableLocalSearch) {
|
|
396
|
+
this.handleGroupSearchChange();
|
|
397
|
+
}
|
|
380
398
|
this.applyStickyToGroups();
|
|
381
399
|
}
|
|
382
400
|
|
|
@@ -384,6 +402,10 @@ export class NileSelect extends NileElement implements NileFormControl{
|
|
|
384
402
|
if(_changedProperties.has('multiple')) {
|
|
385
403
|
this.setCheckBoxInOption(this.multiple as boolean);
|
|
386
404
|
}
|
|
405
|
+
if(_changedProperties.has('enableDescription')) {
|
|
406
|
+
this.setEnableDescriptionInOptions();
|
|
407
|
+
}
|
|
408
|
+
|
|
387
409
|
this.visibilityManager = new VisibilityManager({
|
|
388
410
|
host: this,
|
|
389
411
|
target: this.combobox,
|
|
@@ -420,6 +442,18 @@ export class NileSelect extends NileElement implements NileFormControl{
|
|
|
420
442
|
})
|
|
421
443
|
}
|
|
422
444
|
|
|
445
|
+
setEnableDescriptionInOptions() {
|
|
446
|
+
if (!this.options.length) {
|
|
447
|
+
this.options = this.getAllOptions();
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
this.options.forEach((option: NileOption) => {
|
|
451
|
+
if (option) {
|
|
452
|
+
option.isDescriptionEnabled = !!this.enableDescription;
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
|
|
423
457
|
private addOpenListeners() {
|
|
424
458
|
document.addEventListener('focusin', this.handleDocumentFocusIn);
|
|
425
459
|
document.addEventListener('keydown', this.handleDocumentKeyDown);
|
|
@@ -1011,7 +1045,7 @@ export class NileSelect extends NileElement implements NileFormControl{
|
|
|
1011
1045
|
name: this.name
|
|
1012
1046
|
});
|
|
1013
1047
|
|
|
1014
|
-
if(this.enableGroupHeader) {
|
|
1048
|
+
if(this.enableGroupHeader && !this.disableLocalSearch) {
|
|
1015
1049
|
this.handleGroupSearchChange();
|
|
1016
1050
|
}
|
|
1017
1051
|
if (!this.disableLocalSearch) {
|
|
@@ -1070,15 +1104,15 @@ export class NileSelect extends NileElement implements NileFormControl{
|
|
|
1070
1104
|
allOptions.forEach(el => {
|
|
1071
1105
|
const lowerCaseLabel = el.getTextLabel().toLowerCase();
|
|
1072
1106
|
const lowerCaseValue = (el.value || '').toLowerCase();
|
|
1073
|
-
|
|
1107
|
+
const lowerCaseDescription = (el.description || '').toLowerCase();
|
|
1108
|
+
|
|
1109
|
+
const matches =
|
|
1074
1110
|
lowerCaseLabel.includes(lowerCaseSearchValue) ||
|
|
1075
|
-
lowerCaseValue.includes(lowerCaseSearchValue)
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
el.hidden = true;
|
|
1081
|
-
}
|
|
1111
|
+
lowerCaseValue.includes(lowerCaseSearchValue) ||
|
|
1112
|
+
(this.descriptionSearchEnabled && lowerCaseDescription.includes(lowerCaseSearchValue));
|
|
1113
|
+
|
|
1114
|
+
el.hidden = !matches;
|
|
1115
|
+
if (matches) filteredOptions.push(el);
|
|
1082
1116
|
});
|
|
1083
1117
|
|
|
1084
1118
|
// Update portal content if portal is active
|
|
@@ -53,6 +53,9 @@ export class VirtualScrollHelper {
|
|
|
53
53
|
.open=${component.open}
|
|
54
54
|
.loading=${component.loading}
|
|
55
55
|
.portal=${component.portal}
|
|
56
|
+
.descriptionSearchEnabled=${component.descriptionSearchEnabled}
|
|
57
|
+
.allowHtmlLabel=${component.allowHtmlLabel}
|
|
58
|
+
.enableDescription=${component.enableDescription}
|
|
56
59
|
exportparts="
|
|
57
60
|
select-options,
|
|
58
61
|
select-no-results,
|
|
@@ -537,8 +537,11 @@ export const styles = css`
|
|
|
537
537
|
.select.select--open .select__combobox {
|
|
538
538
|
border-color: var(--ng-colors-border-brand);
|
|
539
539
|
box-shadow: 0 0 0 1px var(--ng-colors-border-brand) inset ;
|
|
540
|
-
}
|
|
540
|
+
}
|
|
541
541
|
|
|
542
|
+
:host([enableDescription]) .option::part(base) {
|
|
543
|
+
height: 41px;
|
|
544
|
+
}
|
|
542
545
|
`;
|
|
543
546
|
|
|
544
547
|
export default [styles];
|
|
@@ -271,6 +271,19 @@ export class NileVirtualSelect extends NileElement implements NileFormControl {
|
|
|
271
271
|
|
|
272
272
|
@property({ type: Boolean, reflect: true, attribute: true }) enableTabClose = false;
|
|
273
273
|
|
|
274
|
+
@property({ type: Boolean, reflect: true, attribute: true }) descriptionSearchEnabled = false;
|
|
275
|
+
|
|
276
|
+
@property({
|
|
277
|
+
type: Boolean,
|
|
278
|
+
reflect: true,
|
|
279
|
+
attribute: true,
|
|
280
|
+
converter: {
|
|
281
|
+
fromAttribute: (value) => value === 'true',
|
|
282
|
+
toAttribute: (value) => String(value),
|
|
283
|
+
},
|
|
284
|
+
}) allowHtmlLabel = true;
|
|
285
|
+
|
|
286
|
+
@property({ type: Boolean, reflect: true, attribute: true }) enableDescription = false;
|
|
274
287
|
|
|
275
288
|
@state() showListbox: boolean = false;
|
|
276
289
|
@state() private wasShowSelectedCheckedOnClose: boolean = false;
|
|
@@ -349,6 +362,36 @@ export class NileVirtualSelect extends NileElement implements NileFormControl {
|
|
|
349
362
|
return item?.value || item;
|
|
350
363
|
}
|
|
351
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Get description for an item using renderItemConfig or fallback to item.description
|
|
367
|
+
*/
|
|
368
|
+
private getItemDescription(item: any): string {
|
|
369
|
+
if (this.renderItemConfig?.getDescription) {
|
|
370
|
+
return this.renderItemConfig.getDescription(item);
|
|
371
|
+
}
|
|
372
|
+
return item?.description || item || '';
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Get description for an item using renderItemConfig or fallback to item.description
|
|
377
|
+
*/
|
|
378
|
+
private getItemPrefix(item: any): string {
|
|
379
|
+
if (this.renderItemConfig?.getPrefix) {
|
|
380
|
+
return this.renderItemConfig.getPrefix(item);
|
|
381
|
+
}
|
|
382
|
+
return item?.prefix || item || '';
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Get suffix for an item using renderItemConfig or fallback to item.suffix
|
|
387
|
+
*/
|
|
388
|
+
private getItemSuffix(item: any): string {
|
|
389
|
+
if (this.renderItemConfig?.getSuffix) {
|
|
390
|
+
return this.renderItemConfig.getSuffix(item);
|
|
391
|
+
}
|
|
392
|
+
return item?.suffix || item || '';
|
|
393
|
+
}
|
|
394
|
+
|
|
352
395
|
/**
|
|
353
396
|
* Get search text for an item using renderItemConfig or fallback to display text
|
|
354
397
|
*/
|
|
@@ -731,7 +774,8 @@ export class NileVirtualSelect extends NileElement implements NileFormControl {
|
|
|
731
774
|
this.value,
|
|
732
775
|
itemsToSearch,
|
|
733
776
|
this.getDisplayText.bind(this),
|
|
734
|
-
this.renderItemConfig?.getValue
|
|
777
|
+
this.renderItemConfig?.getValue,
|
|
778
|
+
this.allowHtmlLabel
|
|
735
779
|
);
|
|
736
780
|
|
|
737
781
|
if (this.multiple) {
|
|
@@ -848,6 +892,8 @@ export class NileVirtualSelect extends NileElement implements NileFormControl {
|
|
|
848
892
|
this.originalOptionItems,
|
|
849
893
|
this.data,
|
|
850
894
|
this.getDisplayText.bind(this),
|
|
895
|
+
this.getItemDescription.bind(this),
|
|
896
|
+
this.descriptionSearchEnabled,
|
|
851
897
|
this.renderItemConfig?.getSearchText
|
|
852
898
|
);
|
|
853
899
|
if (this.portal) {
|
|
@@ -1493,10 +1539,15 @@ export class NileVirtualSelect extends NileElement implements NileFormControl {
|
|
|
1493
1539
|
this.multiple,
|
|
1494
1540
|
this.renderItemConfig?.getDisplayText,
|
|
1495
1541
|
this.renderItemConfig?.getValue,
|
|
1542
|
+
this.renderItemConfig?.getDescription,
|
|
1543
|
+
this.renderItemConfig?.getPrefix,
|
|
1544
|
+
this.renderItemConfig?.getSuffix,
|
|
1496
1545
|
this.showNoResults,
|
|
1497
1546
|
this.noResultsMessage,
|
|
1498
1547
|
this.optionsLoading || this.loading,
|
|
1499
|
-
this.handleScroll.bind(this)
|
|
1548
|
+
this.handleScroll.bind(this),
|
|
1549
|
+
this.allowHtmlLabel,
|
|
1550
|
+
this.enableDescription
|
|
1500
1551
|
);
|
|
1501
1552
|
}
|
|
1502
1553
|
|
|
@@ -9,6 +9,7 @@ import { html, type TemplateResult } from 'lit';
|
|
|
9
9
|
import { virtualize } from '@lit-labs/virtualizer/virtualize.js';
|
|
10
10
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
11
11
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
12
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
12
13
|
|
|
13
14
|
export class VirtualSelectRenderer {
|
|
14
15
|
static getVirtualizedContent(
|
|
@@ -19,10 +20,15 @@ export class VirtualSelectRenderer {
|
|
|
19
20
|
multiple: boolean,
|
|
20
21
|
getDisplayText?: (item: any) => string,
|
|
21
22
|
getItemValue?: (item: any) => string,
|
|
23
|
+
getItemDescription?: (item: any) => string,
|
|
24
|
+
getItemPrefix?: (item: any) => string,
|
|
25
|
+
getItemSuffix?: (item: any) => string,
|
|
22
26
|
showNoResults?: boolean,
|
|
23
27
|
noResultsMessage?: string,
|
|
24
28
|
loading?: boolean,
|
|
25
|
-
onScroll?: (e: Event) => void
|
|
29
|
+
onScroll?: (e: Event) => void,
|
|
30
|
+
allowHtmlLabel?: boolean,
|
|
31
|
+
enableDescription?: boolean
|
|
26
32
|
): TemplateResult {
|
|
27
33
|
return html`
|
|
28
34
|
<div part="select-options" class="select__options ${
|
|
@@ -45,13 +51,13 @@ export class VirtualSelectRenderer {
|
|
|
45
51
|
${virtualize({
|
|
46
52
|
items: data,
|
|
47
53
|
renderItem: (item: any): TemplateResult =>
|
|
48
|
-
VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue),
|
|
54
|
+
VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue, getItemDescription, getItemPrefix, getItemSuffix, allowHtmlLabel, enableDescription),
|
|
49
55
|
scroller: true,
|
|
50
56
|
})}
|
|
51
57
|
`
|
|
52
58
|
: html`
|
|
53
59
|
${data.map((item: any) =>
|
|
54
|
-
VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue)
|
|
60
|
+
VirtualSelectRenderer.getItemRenderFunction(item, renderItemFunction, value, multiple, getDisplayText, getItemValue, getItemDescription, getItemPrefix, getItemSuffix, allowHtmlLabel, enableDescription)
|
|
55
61
|
)}
|
|
56
62
|
`}
|
|
57
63
|
</div>
|
|
@@ -65,7 +71,12 @@ export class VirtualSelectRenderer {
|
|
|
65
71
|
value: string | string[],
|
|
66
72
|
multiple: boolean,
|
|
67
73
|
getDisplayText?: (item: any) => string,
|
|
68
|
-
getItemValue?: (item: any) => string
|
|
74
|
+
getItemValue?: (item: any) => string,
|
|
75
|
+
getItemDescription?: (item: any) => string,
|
|
76
|
+
getItemPrefix?: (item: any) => string,
|
|
77
|
+
getItemSuffix?: (item: any) => string,
|
|
78
|
+
allowHtmlLabel?: boolean,
|
|
79
|
+
enableDescription?: boolean,
|
|
69
80
|
): TemplateResult {
|
|
70
81
|
if(!item) {
|
|
71
82
|
return html``;
|
|
@@ -77,6 +88,9 @@ export class VirtualSelectRenderer {
|
|
|
77
88
|
const displayText = displayTextFn(item);
|
|
78
89
|
const isDisabled = item?.disabled || false;
|
|
79
90
|
const className = item?.className;
|
|
91
|
+
const description = (getItemDescription ? getItemDescription(item) : item?.description) ?? '';
|
|
92
|
+
const prefix = (getItemPrefix ? getItemPrefix(item) : item?.prefix) ?? '';
|
|
93
|
+
const suffix = (getItemSuffix ? getItemSuffix(item) : item?.suffix) ?? '';
|
|
80
94
|
|
|
81
95
|
let isSelected = false;
|
|
82
96
|
if (multiple) {
|
|
@@ -84,16 +98,23 @@ export class VirtualSelectRenderer {
|
|
|
84
98
|
} else {
|
|
85
99
|
isSelected = (Array.isArray(value) ? value[0] : value) === optionValue;
|
|
86
100
|
}
|
|
87
|
-
|
|
101
|
+
|
|
88
102
|
return html`
|
|
89
|
-
<nile-option
|
|
103
|
+
<nile-option
|
|
90
104
|
value=${optionValue}
|
|
91
105
|
.selected=${isSelected}
|
|
92
106
|
.disabled=${isDisabled}
|
|
93
107
|
.showCheckbox=${multiple}
|
|
94
|
-
class=${
|
|
108
|
+
class=${classMap({
|
|
109
|
+
option: enableDescription ?? false,
|
|
110
|
+
[className ?? '']: !!className,
|
|
111
|
+
})}
|
|
112
|
+
.description=${description}
|
|
113
|
+
.isDescriptionEnabled=${enableDescription}
|
|
95
114
|
>
|
|
96
|
-
${unsafeHTML(
|
|
115
|
+
${unsafeHTML(prefix)}
|
|
116
|
+
${allowHtmlLabel ? unsafeHTML(displayText) : displayText}
|
|
117
|
+
${unsafeHTML(suffix)}
|
|
97
118
|
</nile-option>
|
|
98
119
|
`;
|
|
99
120
|
}
|
|
@@ -11,6 +11,8 @@ export class VirtualSelectSearchManager {
|
|
|
11
11
|
originalOptionItems: any[],
|
|
12
12
|
data: any[],
|
|
13
13
|
renderItemFunction: (item: any) => string,
|
|
14
|
+
getItemDescription: (item: any) => string,
|
|
15
|
+
descriptionSearchEnabled: boolean,
|
|
14
16
|
getSearchText?: (item: any) => string
|
|
15
17
|
): { filteredItems: any[], showNoResults: boolean } {
|
|
16
18
|
if (originalOptionItems.length === 0 && data.length > 0) {
|
|
@@ -39,6 +41,10 @@ export class VirtualSelectSearchManager {
|
|
|
39
41
|
const filteredItems = originalOptionItems.filter((item: any) => {
|
|
40
42
|
const itemValue = searchTextFn(item);
|
|
41
43
|
const lowerCaseItemValue = itemValue.toLowerCase();
|
|
44
|
+
const itemDescription = getItemDescription(item);
|
|
45
|
+
if (descriptionSearchEnabled && itemDescription) {
|
|
46
|
+
return lowerCaseItemValue.includes(lowerCaseSearchValue) || itemDescription.includes(lowerCaseSearchValue);
|
|
47
|
+
}
|
|
42
48
|
return lowerCaseItemValue.includes(lowerCaseSearchValue);
|
|
43
49
|
});
|
|
44
50
|
|
|
@@ -12,7 +12,8 @@ export class VirtualSelectSelectionManager {
|
|
|
12
12
|
value: string | string[],
|
|
13
13
|
data: any[],
|
|
14
14
|
getDisplayText: (item: any) => string,
|
|
15
|
-
getItemValue?: (item: any) => string
|
|
15
|
+
getItemValue?: (item: any) => string,
|
|
16
|
+
allowHtmlLabel?: boolean
|
|
16
17
|
): VirtualOption[] {
|
|
17
18
|
if (!value || (Array.isArray(value) && value.length === 0)) {
|
|
18
19
|
return [];
|
|
@@ -37,6 +38,10 @@ export class VirtualSelectSelectionManager {
|
|
|
37
38
|
value: valueItem,
|
|
38
39
|
selected: true,
|
|
39
40
|
getTextLabel: () => {
|
|
41
|
+
if(!allowHtmlLabel){
|
|
42
|
+
return displayText;
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
// If displayText contains HTML, strip tags
|
|
41
46
|
if (typeof displayText === 'string' && /<[^>]+>/.test(displayText)) {
|
|
42
47
|
const div = document.createElement('div');
|
|
@@ -18,6 +18,9 @@ export interface RenderItemConfig {
|
|
|
18
18
|
getDisplayText: (item: any) => string;
|
|
19
19
|
getValue?: (item: any) => string;
|
|
20
20
|
getSearchText?: (item: any) => string;
|
|
21
|
+
getDescription?: (item: any) => string;
|
|
22
|
+
getPrefix?: (item: any) => string;
|
|
23
|
+
getSuffix?: (item: any) => string;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export interface VirtualSelectProperties {
|