@progress/kendo-angular-listbox 17.0.0-develop.8 → 17.0.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 (31) hide show
  1. package/README.md +31 -16
  2. package/data-binding.directive.d.ts +1 -1
  3. package/{esm2020 → esm2022}/data-binding.directive.mjs +13 -6
  4. package/{esm2020 → esm2022}/item-selectable.directive.mjs +5 -3
  5. package/{esm2020 → esm2022}/item-template.directive.mjs +4 -3
  6. package/{esm2020 → esm2022}/keyboard-navigation.service.mjs +13 -11
  7. package/{esm2020 → esm2022}/listbox.component.mjs +124 -72
  8. package/{esm2020 → esm2022}/listbox.module.mjs +4 -4
  9. package/{esm2020 → esm2022}/localization/custom-messages.component.mjs +9 -8
  10. package/{esm2020 → esm2022}/localization/localized-messages.directive.mjs +9 -8
  11. package/esm2022/localization/messages.mjs +66 -0
  12. package/{esm2020 → esm2022}/package-metadata.mjs +2 -2
  13. package/{esm2020 → esm2022}/selection.service.mjs +5 -7
  14. package/{fesm2020 → fesm2022}/progress-kendo-angular-listbox.mjs +223 -127
  15. package/item-selectable.directive.d.ts +1 -1
  16. package/listbox.component.d.ts +1 -1
  17. package/localization/messages.d.ts +1 -1
  18. package/package.json +14 -20
  19. package/schematics/ngAdd/index.js +4 -4
  20. package/size.d.ts +1 -1
  21. package/toolbar.d.ts +3 -3
  22. package/util.d.ts +2 -2
  23. package/esm2020/localization/messages.mjs +0 -34
  24. package/fesm2015/progress-kendo-angular-listbox.mjs +0 -1362
  25. /package/{esm2020 → esm2022}/constants.mjs +0 -0
  26. /package/{esm2020 → esm2022}/directives.mjs +0 -0
  27. /package/{esm2020 → esm2022}/index.mjs +0 -0
  28. /package/{esm2020 → esm2022}/progress-kendo-angular-listbox.mjs +0 -0
  29. /package/{esm2020 → esm2022}/size.mjs +0 -0
  30. /package/{esm2020 → esm2022}/toolbar.mjs +0 -0
  31. /package/{esm2020 → esm2022}/util.mjs +0 -0
@@ -1,1362 +0,0 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the project root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- import * as i0 from '@angular/core';
6
- import { EventEmitter, Injectable, Directive, Input, HostBinding, HostListener, forwardRef, isDevMode, Component, ContentChild, ViewChild, ViewChildren, Output, NgModule } from '@angular/core';
7
- import { validatePackage } from '@progress/kendo-licensing';
8
- import { Subscription } from 'rxjs';
9
- import { getter } from '@progress/kendo-common';
10
- import { caretAltUpIcon, caretAltDownIcon, caretAltRightIcon, caretAltLeftIcon, caretDoubleAltRightIcon, caretDoubleAltLeftIcon, xIcon } from '@progress/kendo-svg-icons';
11
- import { ButtonComponent } from '@progress/kendo-angular-buttons';
12
- import { Keys, TemplateContextDirective, isChanged, ResizeBatchService } from '@progress/kendo-angular-common';
13
- import { take } from 'rxjs/operators';
14
- import * as i1 from '@progress/kendo-angular-l10n';
15
- import { ComponentMessages, LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
16
- import { NgIf, NgFor } from '@angular/common';
17
- import { IconsService } from '@progress/kendo-angular-icons';
18
- import { PopupService } from '@progress/kendo-angular-popup';
19
-
20
- /**
21
- * @hidden
22
- */
23
- const packageMetadata = {
24
- name: '@progress/kendo-angular-listbox',
25
- productName: 'Kendo UI for Angular',
26
- productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
27
- publishDate: 1729170414,
28
- version: '17.0.0-develop.8',
29
- licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
30
- };
31
-
32
- /**
33
- * @hidden
34
- */
35
- class ListBoxSelectionService {
36
- constructor() {
37
- this.onSelect = new EventEmitter();
38
- this.selectedIndex = null;
39
- }
40
- select(index) {
41
- this.onSelect.next({ index: index, prevIndex: this.selectedIndex });
42
- this.selectedIndex = index;
43
- }
44
- isSelected(index) {
45
- return index === this.selectedIndex;
46
- }
47
- clearSelection() {
48
- this.selectedIndex = null;
49
- }
50
- }
51
- ListBoxSelectionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ListBoxSelectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
52
- ListBoxSelectionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ListBoxSelectionService });
53
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ListBoxSelectionService, decorators: [{
54
- type: Injectable
55
- }] });
56
-
57
- /**
58
- * Renders the ListBox item content. To define the item template, nest an `<ng-template>` tag
59
- * with the `kendoListBoxItemTemplate` directive inside the `<kendo-listbox>` tag. The template context is
60
- * set to the current data item.
61
- *
62
- * @example
63
- * ```ts
64
- * _@Component({
65
- * selector: 'my-app',
66
- * template: `
67
- * <kendo-listbox [data]="listBoxItems">
68
- * <ng-template kendoListBoxItemTemplate let-dataItem>
69
- * <span>{{ dataItem }} item</span>
70
- * </ng-template>
71
- * </kendo-listbox>
72
- * `
73
- * })
74
- * ```
75
- */
76
- class ItemTemplateDirective {
77
- constructor(templateRef) {
78
- this.templateRef = templateRef;
79
- }
80
- }
81
- ItemTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ItemTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
82
- ItemTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: ItemTemplateDirective, isStandalone: true, selector: "[kendoListBoxItemTemplate]", ngImport: i0 });
83
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ItemTemplateDirective, decorators: [{
84
- type: Directive,
85
- args: [{
86
- selector: '[kendoListBoxItemTemplate]',
87
- standalone: true
88
- }]
89
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
90
-
91
- /**
92
- * @hidden
93
- */
94
- const DEFAULT_TOOLBAR_POSITION = 'right';
95
- /**
96
- * @hidden
97
- */
98
- const allTools = [
99
- {
100
- name: 'moveUp',
101
- label: 'Move Up',
102
- icon: 'caret-alt-up',
103
- svgIcon: caretAltUpIcon
104
- },
105
- {
106
- name: 'moveDown',
107
- label: 'Move Down',
108
- icon: 'caret-alt-down',
109
- svgIcon: caretAltDownIcon
110
- },
111
- {
112
- name: 'transferTo',
113
- label: 'Transfer To',
114
- icon: 'caret-alt-right',
115
- svgIcon: caretAltRightIcon
116
- },
117
- {
118
- name: 'transferFrom',
119
- label: 'Transfer From',
120
- icon: 'caret-alt-left',
121
- svgIcon: caretAltLeftIcon
122
- },
123
- {
124
- name: 'transferAllTo',
125
- label: 'Transfer All To',
126
- icon: 'caret-double-alt-right',
127
- svgIcon: caretDoubleAltRightIcon
128
- },
129
- {
130
- name: 'transferAllFrom',
131
- label: 'Transfer All From',
132
- icon: 'caret-double-alt-left',
133
- svgIcon: caretDoubleAltLeftIcon
134
- },
135
- {
136
- name: 'remove',
137
- label: 'Remove',
138
- icon: 'x',
139
- svgIcon: xIcon
140
- }
141
- ];
142
- /**
143
- * @hidden
144
- */
145
- const sizeClassMap = {
146
- small: 'sm',
147
- medium: 'md',
148
- large: 'lg'
149
- };
150
- /**
151
- * @hidden
152
- */
153
- const actionsClasses = {
154
- left: 'k-listbox-actions-left',
155
- right: 'k-listbox-actions-right',
156
- top: 'k-listbox-actions-top',
157
- bottom: 'k-listbox-actions-bottom'
158
- };
159
-
160
- /**
161
- * @hidden
162
- */
163
- const isPresent = (value) => value !== null && value !== undefined;
164
- /**
165
- * @hidden
166
- */
167
- const isObject = (value) => isPresent(value) && typeof value === 'object';
168
- /**
169
- * @hidden
170
- */
171
- const fieldAccessor = (dataItem, field) => {
172
- if (!isPresent(dataItem)) {
173
- return null;
174
- }
175
- if (!isPresent(field) || !isObject(dataItem)) {
176
- return dataItem;
177
- }
178
- // creates a field accessor supporting nested fields processing
179
- const valueFrom = getter(field);
180
- return valueFrom(dataItem);
181
- };
182
- /**
183
- * @hidden
184
- */
185
- const defaultItemDisabled = () => false;
186
- /**
187
- * @hidden
188
- */
189
- const getTools = (names) => {
190
- return names.map(tool => allTools.find(meta => meta.name === tool));
191
- };
192
-
193
- /* eslint-disable @typescript-eslint/no-inferrable-types */
194
- /* eslint-disable @typescript-eslint/no-explicit-any */
195
- /**
196
- * @hidden
197
- */
198
- class KeyboardNavigationService {
199
- constructor(renderer, zone) {
200
- this.renderer = renderer;
201
- this.zone = zone;
202
- this.selectedListboxItemIndex = 0;
203
- this.focusedListboxItemIndex = 0;
204
- this.focusedToolIndex = 0;
205
- this.onDeleteEvent = new EventEmitter();
206
- this.onMoveSelectedItem = new EventEmitter();
207
- this.onTransferAllEvent = new EventEmitter();
208
- this.onShiftSelectedItem = new EventEmitter();
209
- this.onSelectionChange = new EventEmitter();
210
- }
211
- onKeyDown(event, toolsRef, toolbar, childListbox, parentListbox, listboxItems) {
212
- const target = event.target;
213
- const keyCode = event.keyCode;
214
- const ctrlOrMetaKey = event.ctrlKey || event.metaKey;
215
- const parentListboxToolbar = parentListbox === null || parentListbox === void 0 ? void 0 : parentListbox.selectedTools;
216
- const tool = toolsRef.find(elem => elem.element === target);
217
- const activeToolbar = toolbar.length > 0 ? toolbar : parentListboxToolbar;
218
- if (toolsRef.length > 0 || (parentListbox === null || parentListbox === void 0 ? void 0 : parentListbox.tools.toArray().length) > 0) {
219
- const focusNextTool = (keyCode === Keys.ArrowDown || keyCode === Keys.ArrowRight);
220
- const focusPrevTool = (keyCode === Keys.ArrowUp || keyCode === Keys.ArrowLeft);
221
- if ((focusNextTool || focusPrevTool) && tool) {
222
- const dir = focusPrevTool ? 'up' : 'down';
223
- this.handleToolbarArrows(toolsRef, dir);
224
- }
225
- else if (keyCode === Keys.F10) {
226
- event.preventDefault();
227
- this.onF10Key(toolsRef);
228
- }
229
- else if (keyCode === Keys.Delete && activeToolbar.some(tool => tool.name === 'remove')) {
230
- this.onDeleteEvent.emit(this.selectedListboxItemIndex);
231
- }
232
- }
233
- const isTargetListboxItem = listboxItems.find(elem => elem.nativeElement === target);
234
- if (isTargetListboxItem) {
235
- let isTransferToolVisible;
236
- if (activeToolbar) {
237
- isTransferToolVisible = activeToolbar.some(tool => tool.name.startsWith('transfer'));
238
- }
239
- if ((keyCode === Keys.ArrowRight || keyCode === Keys.ArrowLeft) && ctrlOrMetaKey && isTransferToolVisible) {
240
- this.onArrowLeftOrRight(keyCode, parentListbox, childListbox, event, listboxItems);
241
- }
242
- else if ((keyCode === Keys.ArrowUp || keyCode === Keys.ArrowDown)) {
243
- this.onArrowUpOrDown(keyCode, ctrlOrMetaKey, event, activeToolbar, listboxItems);
244
- }
245
- else if ((event.metaKey && keyCode === Keys.Enter) || (event.ctrlKey && keyCode === Keys.Space)) {
246
- this.onSelectChange(event, listboxItems);
247
- }
248
- else if (keyCode === Keys.Space) {
249
- if (this.selectedListboxItemIndex !== this.focusedListboxItemIndex) {
250
- this.onSpaceKey(event, listboxItems);
251
- }
252
- }
253
- }
254
- }
255
- changeTabindex(previousItem, currentItem, shouldBlur = true) {
256
- if (previousItem) {
257
- this.renderer.setAttribute(previousItem, 'tabindex', '-1');
258
- if (shouldBlur) {
259
- previousItem.blur();
260
- }
261
- }
262
- if (currentItem) {
263
- this.renderer.setAttribute(currentItem, 'tabindex', '0');
264
- currentItem.focus();
265
- }
266
- }
267
- handleToolbarArrows(toolsRef, dir) {
268
- const topReached = dir === 'up' && this.focusedToolIndex <= 0;
269
- const bottomReached = dir === 'down' && this.focusedToolIndex >= toolsRef.length - 1;
270
- if (topReached || bottomReached) {
271
- return;
272
- }
273
- const offset = dir === 'up' ? -1 : 1;
274
- this.focusedToolIndex += offset;
275
- const prevItem = toolsRef[this.focusedToolIndex + (offset * -1)].element;
276
- const currentItem = toolsRef[this.focusedToolIndex].element;
277
- this.changeTabindex(prevItem, currentItem);
278
- }
279
- onSpaceKey(event, listboxItems) {
280
- var _a, _b;
281
- event.stopImmediatePropagation();
282
- event.preventDefault();
283
- const previousItem = (_a = listboxItems[this.selectedListboxItemIndex]) === null || _a === void 0 ? void 0 : _a.nativeElement;
284
- const currentItem = (_b = listboxItems[this.focusedListboxItemIndex]) === null || _b === void 0 ? void 0 : _b.nativeElement;
285
- this.changeTabindex(previousItem, currentItem);
286
- this.onSelectionChange.emit({ index: this.focusedListboxItemIndex, prevIndex: this.selectedListboxItemIndex });
287
- this.selectedListboxItemIndex = this.focusedListboxItemIndex;
288
- }
289
- onArrowUpOrDown(keyCode, ctrlOrMetaKey, event, activeToolbar, listboxItems) {
290
- event.preventDefault();
291
- const dir = keyCode === Keys.ArrowUp ? 'moveUp' : 'moveDown';
292
- if (ctrlOrMetaKey) {
293
- let isMoveToolVisible;
294
- if (activeToolbar) {
295
- isMoveToolVisible = activeToolbar.some(tool => tool.name.startsWith('move'));
296
- }
297
- if (event.shiftKey && isMoveToolVisible) {
298
- this.onMoveSelectedItem.emit(dir);
299
- return;
300
- }
301
- this.changeFocusedItem(dir, listboxItems);
302
- return;
303
- }
304
- dir === 'moveUp' ? this.onArrowUp(listboxItems) : this.onArrowDown(listboxItems);
305
- this.onSelectionChange.emit({ index: this.selectedListboxItemIndex, prevIndex: this.focusedListboxItemIndex });
306
- this.focusedListboxItemIndex = this.selectedListboxItemIndex;
307
- }
308
- onArrowLeftOrRight(keyCode, parentListbox, childListbox, event, listboxItems) {
309
- event.preventDefault();
310
- if (event.shiftKey) {
311
- this.transferAllItems(keyCode, childListbox, parentListbox);
312
- return;
313
- }
314
- if (this.selectedListboxItemIndex >= 0) {
315
- this.transferItem(keyCode, childListbox, parentListbox, listboxItems);
316
- }
317
- }
318
- onSelectChange(event, listboxItems) {
319
- var _a, _b, _c;
320
- event.stopImmediatePropagation();
321
- event.preventDefault();
322
- const areIndexesEqual = this.selectedListboxItemIndex === this.focusedListboxItemIndex;
323
- const canDeselect = (this.selectedListboxItemIndex || this.selectedListboxItemIndex === 0) && areIndexesEqual;
324
- let previousItem;
325
- let currentItem;
326
- let prevIndex;
327
- if (canDeselect) {
328
- previousItem = (_a = listboxItems[this.selectedListboxItemIndex]) === null || _a === void 0 ? void 0 : _a.nativeElement;
329
- this.selectedListboxItemIndex = null;
330
- }
331
- else {
332
- previousItem = (_b = listboxItems[this.selectedListboxItemIndex]) === null || _b === void 0 ? void 0 : _b.nativeElement;
333
- currentItem = (_c = listboxItems[this.focusedListboxItemIndex]) === null || _c === void 0 ? void 0 : _c.nativeElement;
334
- prevIndex = this.selectedListboxItemIndex;
335
- this.selectedListboxItemIndex = this.focusedListboxItemIndex;
336
- }
337
- this.changeTabindex(previousItem, currentItem, !!currentItem);
338
- this.onSelectionChange.emit({ index: this.selectedListboxItemIndex, prevIndex });
339
- }
340
- onF10Key(tools) {
341
- var _a;
342
- if (this.focusedToolIndex && this.focusedToolIndex > -1) {
343
- if (this.focusedToolIndex >= tools.length) {
344
- tools[tools.length - 1].element.focus();
345
- }
346
- else {
347
- tools[this.focusedToolIndex].element.focus();
348
- }
349
- }
350
- else {
351
- (_a = tools[0]) === null || _a === void 0 ? void 0 : _a.element.focus();
352
- }
353
- }
354
- transferAllItems(keyCode, childListbox, parentListbox) {
355
- const isArrowRight = keyCode === Keys.ArrowRight;
356
- const actionToPerform = isArrowRight ? 'transferAllTo' : 'transferAllFrom';
357
- this.onTransferAllEvent.emit(actionToPerform);
358
- const adjustTabindex = (items) => {
359
- items.forEach(item => {
360
- if (item.nativeElement.getAttribute('tabindex') === '0') {
361
- this.changeTabindex(item.nativeElement, null);
362
- }
363
- });
364
- };
365
- this.zone.onStable.pipe(take(1)).subscribe(() => {
366
- const childListboxNav = (childListbox === null || childListbox === void 0 ? void 0 : childListbox.keyboardNavigationService) || (parentListbox === null || parentListbox === void 0 ? void 0 : parentListbox.childListbox.keyboardNavigationService);
367
- let currentItem;
368
- if (isArrowRight) {
369
- if (childListbox) {
370
- const childListBoxItems = childListbox.listboxItems.toArray();
371
- const childListboxItemsLength = childListBoxItems.length - 1;
372
- currentItem = childListBoxItems[childListboxItemsLength].nativeElement;
373
- childListboxNav.focusedListboxItemIndex = childListboxItemsLength;
374
- childListboxNav.selectedListboxItemIndex = childListboxItemsLength;
375
- this.focusedListboxItemIndex = 0;
376
- this.selectedListboxItemIndex = 0;
377
- adjustTabindex(childListBoxItems);
378
- }
379
- }
380
- else {
381
- if (parentListbox) {
382
- const parentListboxNav = parentListbox.keyboardNavigationService;
383
- const parentListBoxItems = parentListbox.listboxItems.toArray();
384
- const parentListboxItemsLength = parentListBoxItems.length - 1;
385
- currentItem = parentListBoxItems[parentListboxItemsLength].nativeElement;
386
- parentListboxNav.focusedListboxItemIndex = parentListboxItemsLength;
387
- parentListboxNav.selectedListboxItemIndex = parentListboxItemsLength;
388
- childListboxNav.focusedListboxItemIndex = 0;
389
- childListboxNav.selectedListboxItemIndex = 0;
390
- adjustTabindex(parentListBoxItems);
391
- }
392
- }
393
- this.changeTabindex(null, currentItem);
394
- });
395
- }
396
- transferItem(keyCode, childListbox, parentListbox, listboxItems) {
397
- const isArrowRight = keyCode === Keys.ArrowRight;
398
- const actionToPerform = isArrowRight ? 'transferTo' : 'transferFrom';
399
- this.onShiftSelectedItem.emit(actionToPerform);
400
- const adjustTabindex = (items, firstItem, currentItem) => {
401
- items.forEach(item => {
402
- if (item.nativeElement.getAttribute('tabindex') === '0') {
403
- this.changeTabindex(item.nativeElement, firstItem);
404
- }
405
- });
406
- this.changeTabindex(null, currentItem);
407
- };
408
- this.zone.onStable.pipe(take(1)).subscribe(() => {
409
- if (isArrowRight) {
410
- if (childListbox) {
411
- const childListBoxItems = childListbox.listboxItems.toArray();
412
- const childListboxNav = childListbox.keyboardNavigationService;
413
- const childListboxItemsLength = childListbox.listboxItems.length - 1;
414
- const parentListboxFirstItem = listboxItems[0].nativeElement;
415
- const currentItem = childListBoxItems[childListboxItemsLength].nativeElement;
416
- childListboxNav.focusedListboxItemIndex = childListboxItemsLength;
417
- childListboxNav.selectedListboxItemIndex = childListboxItemsLength;
418
- this.focusedListboxItemIndex = 0;
419
- this.selectedListboxItemIndex = 0;
420
- adjustTabindex(childListBoxItems, parentListboxFirstItem, currentItem);
421
- }
422
- }
423
- else {
424
- if (parentListbox) {
425
- const parentListBoxItems = parentListbox.listboxItems.toArray();
426
- const childListboxNav = parentListbox.childListbox.keyboardNavigationService;
427
- const parentListboxNav = parentListbox.keyboardNavigationService;
428
- const parentListboxItemsLength = parentListbox.listboxItems.length - 1;
429
- const childListboxFirstItem = listboxItems[0].nativeElement;
430
- const currentItem = parentListBoxItems[parentListboxItemsLength].nativeElement;
431
- parentListboxNav.focusedListboxItemIndex = parentListboxItemsLength;
432
- parentListboxNav.selectedListboxItemIndex = parentListboxItemsLength;
433
- childListboxNav.focusedListboxItemIndex = 0;
434
- childListboxNav.selectedListboxItemIndex = 0;
435
- adjustTabindex(parentListBoxItems, childListboxFirstItem, currentItem);
436
- }
437
- }
438
- });
439
- }
440
- changeFocusedItem(dir, listboxItems) {
441
- listboxItems[this.focusedListboxItemIndex].nativeElement.blur();
442
- if (this.focusedListboxItemIndex > 0 && dir === 'moveUp') {
443
- this.focusedListboxItemIndex -= 1;
444
- }
445
- else if (this.focusedListboxItemIndex < listboxItems.length - 1 && dir === 'moveDown') {
446
- this.focusedListboxItemIndex += 1;
447
- }
448
- listboxItems[this.focusedListboxItemIndex].nativeElement.focus();
449
- }
450
- onArrowDown(listboxItems) {
451
- var _a, _b;
452
- if (this.selectedListboxItemIndex < listboxItems.length - 1) {
453
- const offset = this.selectedListboxItemIndex ? this.selectedListboxItemIndex : this.focusedListboxItemIndex;
454
- this.selectedListboxItemIndex = offset + 1;
455
- const previousItem = (_a = listboxItems[this.selectedListboxItemIndex - 1]) === null || _a === void 0 ? void 0 : _a.nativeElement;
456
- const currentItem = (_b = listboxItems[this.selectedListboxItemIndex]) === null || _b === void 0 ? void 0 : _b.nativeElement;
457
- this.changeTabindex(previousItem, currentItem);
458
- }
459
- }
460
- onArrowUp(listboxItems) {
461
- var _a, _b;
462
- if (this.selectedListboxItemIndex > 0 || this.focusedListboxItemIndex > 0) {
463
- const offset = this.selectedListboxItemIndex ? this.selectedListboxItemIndex : this.focusedListboxItemIndex;
464
- this.selectedListboxItemIndex = offset - 1;
465
- const previousItem = (_a = listboxItems[this.selectedListboxItemIndex + 1]) === null || _a === void 0 ? void 0 : _a.nativeElement;
466
- const currentItem = (_b = listboxItems[this.selectedListboxItemIndex]) === null || _b === void 0 ? void 0 : _b.nativeElement;
467
- this.changeTabindex(previousItem, currentItem);
468
- }
469
- }
470
- }
471
- KeyboardNavigationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: KeyboardNavigationService, deps: [{ token: i0.Renderer2 }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
472
- KeyboardNavigationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: KeyboardNavigationService });
473
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: KeyboardNavigationService, decorators: [{
474
- type: Injectable
475
- }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.NgZone }]; } });
476
-
477
- /**
478
- * @hidden
479
- */
480
- class ItemSelectableDirective {
481
- constructor(selectionService) {
482
- this.selectionService = selectionService;
483
- }
484
- get selectedClassName() {
485
- return this.selectionService.isSelected(this.index);
486
- }
487
- onClick(event) {
488
- event.stopPropagation();
489
- this.selectionService.select(this.index);
490
- }
491
- }
492
- ItemSelectableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ItemSelectableDirective, deps: [{ token: ListBoxSelectionService }], target: i0.ɵɵFactoryTarget.Directive });
493
- ItemSelectableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: ItemSelectableDirective, isStandalone: true, selector: "[kendoListBoxItemSelectable]", inputs: { index: "index" }, host: { listeners: { "mousedown": "onClick($event)" }, properties: { "class.k-selected": "this.selectedClassName" } }, ngImport: i0 });
494
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ItemSelectableDirective, decorators: [{
495
- type: Directive,
496
- args: [{
497
- selector: '[kendoListBoxItemSelectable]',
498
- standalone: true
499
- }]
500
- }], ctorParameters: function () { return [{ type: ListBoxSelectionService }]; }, propDecorators: { index: [{
501
- type: Input
502
- }], selectedClassName: [{
503
- type: HostBinding,
504
- args: ['class.k-selected']
505
- }], onClick: [{
506
- type: HostListener,
507
- args: ['mousedown', ['$event']]
508
- }] } });
509
-
510
- /**
511
- * @hidden
512
- */
513
- class Messages extends ComponentMessages {
514
- }
515
- Messages.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: Messages, deps: null, target: i0.ɵɵFactoryTarget.Directive });
516
- Messages.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: Messages, inputs: { moveUp: "moveUp", moveDown: "moveDown", remove: "remove", transferTo: "transferTo", transferFrom: "transferFrom", transferAllTo: "transferAllTo", transferAllFrom: "transferAllFrom", noDataText: "noDataText" }, usesInheritance: true, ngImport: i0 });
517
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: Messages, decorators: [{
518
- type: Directive
519
- }], propDecorators: { moveUp: [{
520
- type: Input
521
- }], moveDown: [{
522
- type: Input
523
- }], remove: [{
524
- type: Input
525
- }], transferTo: [{
526
- type: Input
527
- }], transferFrom: [{
528
- type: Input
529
- }], transferAllTo: [{
530
- type: Input
531
- }], transferAllFrom: [{
532
- type: Input
533
- }], noDataText: [{
534
- type: Input
535
- }] } });
536
-
537
- /**
538
- * @hidden
539
- */
540
- class LocalizedMessagesDirective extends Messages {
541
- constructor(service) {
542
- super();
543
- this.service = service;
544
- }
545
- }
546
- LocalizedMessagesDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: LocalizedMessagesDirective, deps: [{ token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Directive });
547
- LocalizedMessagesDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: LocalizedMessagesDirective, isStandalone: true, selector: "[kendoListBoxLocalizedMessages]", providers: [
548
- {
549
- provide: Messages,
550
- useExisting: forwardRef(() => LocalizedMessagesDirective)
551
- }
552
- ], usesInheritance: true, ngImport: i0 });
553
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: LocalizedMessagesDirective, decorators: [{
554
- type: Directive,
555
- args: [{
556
- providers: [
557
- {
558
- provide: Messages,
559
- useExisting: forwardRef(() => LocalizedMessagesDirective)
560
- }
561
- ],
562
- selector: '[kendoListBoxLocalizedMessages]',
563
- standalone: true
564
- }]
565
- }], ctorParameters: function () { return [{ type: i1.LocalizationService }]; } });
566
-
567
- /* eslint-disable @typescript-eslint/no-inferrable-types */
568
- /* eslint-disable @typescript-eslint/no-explicit-any */
569
- const DEFAULT_SIZE = 'medium';
570
- let idx = 0;
571
- /**
572
- * Represents the [Kendo UI ListBox component for Angular]({% slug overview_listbox %}).
573
- */
574
- class ListBoxComponent {
575
- constructor(keyboardNavigationService, selectionService, hostElement, renderer, zone, localization, changeDetector) {
576
- this.keyboardNavigationService = keyboardNavigationService;
577
- this.selectionService = selectionService;
578
- this.hostElement = hostElement;
579
- this.renderer = renderer;
580
- this.zone = zone;
581
- this.localization = localization;
582
- this.changeDetector = changeDetector;
583
- /**
584
- * @hidden
585
- */
586
- this.listboxClassName = true;
587
- /**
588
- * The data which will be displayed by the ListBox.
589
- */
590
- this.data = [];
591
- /**
592
- * The value of the aria-label attribute of the Listbox element.
593
- */
594
- this.listboxLabel = 'Listbox';
595
- /**
596
- * The value of the aria-label attribute of the Listbox toolbar element.
597
- */
598
- this.listboxToolbarLabel = 'Toolbar';
599
- /**
600
- * A function which determines if a specific item is disabled.
601
- */
602
- this.itemDisabled = defaultItemDisabled;
603
- /**
604
- * Fires when the user selects a different ListBox item. Also fires when a node is moved, since that also changes its index.
605
- */
606
- this.selectionChange = new EventEmitter();
607
- /**
608
- * Fires when the user clicks a ListBox item.
609
- */
610
- this.actionClick = new EventEmitter();
611
- /**
612
- * @hidden
613
- */
614
- this.getChildListbox = new EventEmitter();
615
- /**
616
- * @hidden
617
- */
618
- this.selectedTools = allTools;
619
- /**
620
- * @hidden
621
- */
622
- this.caretAltLeftIcon = caretAltLeftIcon;
623
- /**
624
- * @hidden
625
- */
626
- this.caretAltRightIcon = caretAltRightIcon;
627
- this._size = DEFAULT_SIZE;
628
- this.subs = new Subscription();
629
- this.shouldFireFocusIn = true;
630
- validatePackage(packageMetadata);
631
- this.setToolbarClass(DEFAULT_TOOLBAR_POSITION);
632
- this.setSizingClass(this.size);
633
- this.direction = localization.rtl ? 'rtl' : 'ltr';
634
- }
635
- /**
636
- * Sets the size of the component.
637
- *
638
- * The possible values are:
639
- * - `'small'`
640
- * - `'medium'` (default)
641
- * - `'large'`
642
- */
643
- set size(size) {
644
- const newSize = size ? size : DEFAULT_SIZE;
645
- this.renderer.removeClass(this.hostElement.nativeElement, `k-listbox-${sizeClassMap[this.size]}`);
646
- this.setSizingClass(newSize);
647
- this._size = size;
648
- }
649
- get size() {
650
- return this._size;
651
- }
652
- /**
653
- * Sets whether a toolbar should be displayed with the ListBox, as well as what tools and position should be used.
654
- */
655
- set toolbar(config) {
656
- let position = DEFAULT_TOOLBAR_POSITION;
657
- if (typeof config === 'boolean') {
658
- this.selectedTools = config ? allTools : [];
659
- }
660
- else {
661
- this.selectedTools = config.tools ? getTools(config.tools) : allTools;
662
- if (config.position) {
663
- position = config.position;
664
- }
665
- }
666
- this.setToolbarClass(position);
667
- }
668
- /**
669
- * @hidden
670
- */
671
- get listClasses() {
672
- return `k-list k-list-${sizeClassMap[this.size]}`;
673
- }
674
- /**
675
- * @hidden
676
- */
677
- messageFor(key) {
678
- return this.localization.get(key);
679
- }
680
- ngOnInit() {
681
- // This event emitter gives us the connectedWith value from the DataBinding directive
682
- this.getChildListbox.emit();
683
- if (this.childListbox) {
684
- // This allows us to know to which parent Listbox the child Listbox is connected to
685
- this.childListbox.parentListbox = this;
686
- }
687
- if (this.selectedIndex) {
688
- this.keyboardNavigationService.focusedToolIndex = this.selectedIndex;
689
- }
690
- this.localizationSubscription = this.localization.changes.subscribe(({ rtl }) => {
691
- this.direction = rtl ? 'rtl' : 'ltr';
692
- });
693
- this.subs.add(this.localizationSubscription);
694
- }
695
- ngAfterViewInit() {
696
- const toolsRef = this.tools.toArray();
697
- const hostEl = this.hostElement.nativeElement;
698
- const navService = this.keyboardNavigationService;
699
- this.setIds();
700
- this.initSubscriptions(navService, hostEl, toolsRef);
701
- }
702
- ngOnDestroy() {
703
- this.subs.unsubscribe();
704
- }
705
- /**
706
- * @hidden
707
- */
708
- performAction(actionName) {
709
- var _a, _b;
710
- const isActionTransferFrom = actionName === 'transferFrom' || actionName === 'transferAllFrom';
711
- const isListboxChild = this.parentListbox && !this.childListbox;
712
- const isListboxParentAndChild = !!(this.parentListbox && this.childListbox);
713
- const isListboxParent = !!(this.childListbox || (!this.childListbox && !this.parentListbox));
714
- if (isListboxChild || (isListboxParentAndChild && isActionTransferFrom)) {
715
- this.parentListbox.actionClick.next(actionName);
716
- }
717
- else if (isListboxParent || (isListboxParentAndChild && !isActionTransferFrom)) {
718
- this.actionClick.next(actionName);
719
- }
720
- const toolsRef = this.tools.toArray() || this.parentListbox.tools.toArray();
721
- const focusedToolIndex = toolsRef.findIndex(elem => elem.nativeElement === document.activeElement);
722
- if ((this.selectedTools.length > 0 || this.parentListbox.selectedTools.length > 0) && focusedToolIndex > -1) {
723
- const navService = this.keyboardNavigationService || this.parentListbox.keyboardNavigationService;
724
- const selectedTools = this.selectedTools || this.parentListbox.selectedTools;
725
- const prevTool = (_a = toolsRef[navService.focusedToolIndex]) === null || _a === void 0 ? void 0 : _a.element;
726
- navService.focusedToolIndex = selectedTools.findIndex(tool => tool.name === actionName);
727
- const currentTool = (_b = toolsRef[navService.focusedToolIndex]) === null || _b === void 0 ? void 0 : _b.element;
728
- navService.changeTabindex(prevTool, currentTool);
729
- }
730
- }
731
- /**
732
- * Programmatically selects a ListBox node.
733
- */
734
- selectItem(index) {
735
- this.selectionService.selectedIndex = index;
736
- }
737
- /**
738
- * Programmatically clears the ListBox selection.
739
- */
740
- clearSelection() {
741
- this.selectionService.clearSelection();
742
- }
743
- /**
744
- * The index of the currently selected item in the ListBox.
745
- */
746
- get selectedIndex() {
747
- return this.selectionService.selectedIndex;
748
- }
749
- /**
750
- * @hidden
751
- */
752
- get getListboxId() {
753
- const id = ++idx;
754
- const listboxId = `k-listbox-${id}`;
755
- return listboxId;
756
- }
757
- /**
758
- * @hidden
759
- */
760
- getText(dataItem) {
761
- if (typeof dataItem !== 'string' && !this.textField && isDevMode()) {
762
- throw new Error('Missing textField input. When passing an array of objects as data, please set the textField input of the ListBox accordingly.');
763
- }
764
- return fieldAccessor(dataItem, this.textField);
765
- }
766
- /**
767
- * @hidden
768
- */
769
- toolIcon(icon) {
770
- return this.direction === 'ltr' ?
771
- icon :
772
- icon === 'caret-alt-left' ?
773
- 'caret-alt-right' :
774
- icon === 'caret-alt-right' ?
775
- 'caret-alt-left' :
776
- icon;
777
- }
778
- /**
779
- * @hidden
780
- */
781
- toolSVGIcon(icon) {
782
- return this.direction === 'ltr' ?
783
- icon :
784
- icon === this.caretAltLeftIcon ?
785
- this.caretAltRightIcon :
786
- icon === this.caretAltRightIcon ?
787
- this.caretAltLeftIcon :
788
- icon;
789
- }
790
- onClickEvent(prevIndex, index) {
791
- this.shouldFireFocusIn = false;
792
- this.selectionChange.next({ index, prevIndex: this.keyboardNavigationService.selectedListboxItemIndex });
793
- this.keyboardNavigationService.selectedListboxItemIndex = index;
794
- this.keyboardNavigationService.focusedListboxItemIndex = index;
795
- this.zone.onStable.pipe(take(1)).subscribe(() => {
796
- const listboxItems = this.listboxItems.toArray();
797
- const previousItem = prevIndex ? listboxItems[prevIndex].nativeElement : listboxItems[0].nativeElement;
798
- const currentItem = listboxItems[index].nativeElement;
799
- this.keyboardNavigationService.changeTabindex(previousItem, currentItem);
800
- });
801
- this.zone.onStable.pipe(take(1)).subscribe(() => {
802
- this.shouldFireFocusIn = true;
803
- });
804
- }
805
- initSubscriptions(navService, hostEl, toolsRef) {
806
- this.subs.add(navService.onShiftSelectedItem.subscribe((actionToPerform) => this.performAction(actionToPerform)));
807
- this.subs.add(navService.onTransferAllEvent.subscribe((actionToPerform) => this.performAction(actionToPerform)));
808
- this.subs.add(this.selectionService.onSelect.subscribe((e) => this.onClickEvent(e.prevIndex, e.index)));
809
- this.subs.add(navService.onDeleteEvent.subscribe((index) => this.onDeleteEvent(index, navService)));
810
- this.subs.add(navService.onMoveSelectedItem.subscribe((dir) => this.performAction(dir)));
811
- if (this.listboxElement) {
812
- this.subs.add(this.renderer.listen(this.listboxElement.nativeElement, 'focusin', (event) => this.onFocusIn(event)));
813
- }
814
- this.subs.add(this.renderer.listen(hostEl, 'keydown', (event) => navService.onKeyDown(event, toolsRef, this.selectedTools, this.childListbox, this.parentListbox, this.listboxItems.toArray())));
815
- this.subs.add(navService.onSelectionChange.subscribe((indexes) => {
816
- const { prevIndex, index } = indexes;
817
- this.selectionService.selectedIndex = index;
818
- this.selectionChange.next({ index, prevIndex });
819
- this.changeDetector.markForCheck();
820
- }));
821
- }
822
- onFocusIn(event) {
823
- var _a, _b;
824
- const navService = this.keyboardNavigationService;
825
- if (navService.focusedListboxItemIndex === navService.selectedListboxItemIndex && this.shouldFireFocusIn) {
826
- const items = this.listboxItems.toArray();
827
- const index = items.findIndex(elem => elem.nativeElement === event.target);
828
- if (index === -1) {
829
- return;
830
- }
831
- this.selectionService.selectedIndex = index;
832
- this.selectionChange.next({ index, prevIndex: null });
833
- const previousItem = (_a = items[navService.selectedListboxItemIndex]) === null || _a === void 0 ? void 0 : _a.nativeElement;
834
- const currentItem = (_b = items[index]) === null || _b === void 0 ? void 0 : _b.nativeElement;
835
- this.renderer.setAttribute(previousItem, 'tabindex', '-1');
836
- this.renderer.setAttribute(currentItem, 'tabindex', '0');
837
- }
838
- }
839
- setIds() {
840
- var _a, _b, _c, _d;
841
- if (!this.listboxElement) {
842
- return;
843
- }
844
- const listbox = this.listboxElement.nativeElement;
845
- this.listboxId = this.getListboxId;
846
- this.renderer.setAttribute(listbox, 'id', this.listboxId);
847
- if (this.selectedTools.length > 0 || ((_a = this.parentListbox) === null || _a === void 0 ? void 0 : _a.selectedTools.length) > 0) {
848
- const toolbar = (_b = this.toolbarElement) === null || _b === void 0 ? void 0 : _b.nativeElement;
849
- const parentToolbar = (_d = (_c = this.parentListbox) === null || _c === void 0 ? void 0 : _c.toolbarElement) === null || _d === void 0 ? void 0 : _d.nativeElement;
850
- if (this.parentListbox && this.childListbox) {
851
- this.zone.onStable.pipe(take(1)).subscribe(() => {
852
- this.toolbarId = `${this.parentListbox.listboxId} ${this.listboxId} ${this.childListbox.listboxId}`;
853
- this.renderer.setAttribute(toolbar, 'aria-controls', this.toolbarId);
854
- });
855
- }
856
- else if (this.childListbox && !this.parentListbox) {
857
- this.zone.onStable.pipe(take(1)).subscribe(() => {
858
- this.toolbarId = this.toolbarId = `${this.listboxId} ${this.childListbox.listboxId}`;
859
- this.renderer.setAttribute(toolbar, 'aria-controls', this.toolbarId);
860
- });
861
- }
862
- else if (this.parentListbox && this.selectedTools.length > 0) {
863
- this.toolbarId = `${this.parentListbox.listboxId} ${this.listboxId}`;
864
- this.parentListbox.toolbarId = this.toolbarId = `${this.parentListbox.listboxId} ${this.listboxId}`;
865
- this.renderer.setAttribute(toolbar, 'aria-controls', this.toolbarId);
866
- parentToolbar && this.renderer.setAttribute(parentToolbar, 'aria-controls', this.parentListbox.toolbarId);
867
- }
868
- else if (!this.parentListbox && !this.childListbox) {
869
- this.toolbarId = this.listboxId;
870
- this.renderer.setAttribute(toolbar, 'aria-controls', this.toolbarId);
871
- }
872
- }
873
- }
874
- onDeleteEvent(index, navService) {
875
- var _a;
876
- this.selectionService.selectedIndex = index;
877
- this.performAction('remove');
878
- const listboxItems = this.listboxItems.toArray();
879
- const setIndex = index + 1 === listboxItems.length ?
880
- { index: index - 1, tabindex: index - 1 } : { index, tabindex: index + 1 };
881
- navService.changeTabindex(null, (_a = listboxItems[setIndex['tabindex']]) === null || _a === void 0 ? void 0 : _a.nativeElement);
882
- this.selectionChange.next({ index: setIndex['index'], prevIndex: null });
883
- navService.selectedListboxItemIndex = setIndex['index'];
884
- navService.focusedListboxItemIndex = setIndex['index'];
885
- navService.focusedListboxItem = setIndex['index'];
886
- this.selectionService.selectedIndex = setIndex['index'];
887
- }
888
- setToolbarClass(pos) {
889
- Object.keys(actionsClasses).forEach((className) => {
890
- if (pos === className) {
891
- this.renderer.addClass(this.hostElement.nativeElement, actionsClasses[className]);
892
- }
893
- else {
894
- this.renderer.removeClass(this.hostElement.nativeElement, actionsClasses[className]);
895
- }
896
- });
897
- }
898
- setSizingClass(size) {
899
- this.renderer.addClass(this.hostElement.nativeElement, `k-listbox-${sizeClassMap[size]}`);
900
- }
901
- }
902
- ListBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ListBoxComponent, deps: [{ token: KeyboardNavigationService }, { token: ListBoxSelectionService }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: i1.LocalizationService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
903
- ListBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ListBoxComponent, isStandalone: true, selector: "kendo-listbox", inputs: { textField: "textField", data: "data", size: "size", toolbar: "toolbar", listboxLabel: "listboxLabel", listboxToolbarLabel: "listboxToolbarLabel", itemDisabled: "itemDisabled" }, outputs: { selectionChange: "selectionChange", actionClick: "actionClick", getChildListbox: "getChildListbox" }, host: { properties: { "class.k-listbox": "this.listboxClassName", "attr.dir": "this.direction" } }, providers: [
904
- ListBoxSelectionService,
905
- KeyboardNavigationService,
906
- LocalizationService,
907
- {
908
- provide: L10N_PREFIX,
909
- useValue: 'kendo.listbox'
910
- },
911
- ], queries: [{ propertyName: "itemTemplate", first: true, predicate: ItemTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "listboxElement", first: true, predicate: ["listbox"], descendants: true }, { propertyName: "toolbarElement", first: true, predicate: ["toolbar"], descendants: true }, { propertyName: "listboxItems", predicate: ["listboxItems"], descendants: true }, { propertyName: "tools", predicate: ["tools"], descendants: true }], ngImport: i0, template: `
912
- <ng-container kendoListBoxLocalizedMessages
913
- i18n-moveUp="kendo.listbox.moveUp|The title of the Move Up button"
914
- moveUp="Move Up"
915
-
916
- i18n-moveDown="kendo.listbox.moveDown|The title of the Move Down button"
917
- moveDown="Move Down"
918
-
919
- i18n-transferTo="kendo.listbox.transferTo|The title of the Transfer To button"
920
- transferTo="Transfer To"
921
-
922
- i18n-transferAllTo="kendo.listbox.transferAllTo|The title of the Transfer All To button"
923
- transferAllTo="Transfer All To"
924
-
925
- i18n-transferFrom="kendo.listbox.transferFrom|The title of the Transfer From button"
926
- transferFrom="Transfer From"
927
-
928
- i18n-transferAllFrom="kendo.listbox.transferAllFrom|The title of the Transfer All From button"
929
- transferAllFrom="Transfer All From"
930
-
931
- i18n-remove="kendo.listbox.remove|The title of the Remove button"
932
- remove="Remove"
933
-
934
- i18n-noDataText="kendo.listbox.noDataText|The text displayed when there are no items"
935
- noDataText="No data found."
936
- >
937
- </ng-container>
938
- <div
939
- #toolbar
940
- class="k-listbox-actions"
941
- *ngIf="selectedTools.length > 0"
942
- role="toolbar"
943
- [attr.aria-label]="listboxToolbarLabel"
944
- >
945
- <button
946
- #tools
947
- *ngFor="let tool of selectedTools; let i = index"
948
- kendoButton
949
- [attr.tabindex]="i === 0 ? '0' : '-1'"
950
- [size]="this.size"
951
- [icon]="toolIcon(tool.icon)"
952
- [svgIcon]="toolSVGIcon(tool.svgIcon)"
953
- [attr.title]="messageFor(tool.name)"
954
- (click)="performAction(tool.name)"
955
- role="button"
956
- type="button"
957
- ></button>
958
- </div>
959
- <div class="k-list-scroller k-selectable">
960
- <div class="{{ listClasses }}">
961
- <div
962
- *ngIf="data.length > 0"
963
- class="k-list-content"
964
- >
965
- <ul
966
- #listbox
967
- class="k-list-ul"
968
- role="listbox"
969
- [attr.aria-label]="listboxLabel"
970
- [attr.aria-multiselectable]="false"
971
- >
972
- <li
973
- #listboxItems
974
- *ngFor="let item of data; let i = index"
975
- kendoListBoxItemSelectable
976
- class="k-list-item"
977
- [attr.tabindex]="i === 0 ? '0' : '-1'"
978
- role="option"
979
- [attr.aria-selected]="selectedIndex === i"
980
- [index]="i"
981
- [class.k-disabled]="itemDisabled(item)"
982
- >
983
- <ng-template
984
- *ngIf="itemTemplate; else defaultItemTemplate"
985
- [templateContext]="{
986
- templateRef: itemTemplate.templateRef,
987
- $implicit: item
988
- }"
989
- >
990
- </ng-template>
991
- <ng-template #defaultItemTemplate>
992
- <span class="k-list-item-text">{{ getText(item) }}</span>
993
- </ng-template>
994
- </li>
995
- </ul>
996
- </div>
997
- <span
998
- *ngIf="data.length === 0"
999
- class="k-nodata"
1000
- >{{ messageFor('noDataText') }}</span>
1001
- </div>
1002
- </div>
1003
- `, isInline: true, dependencies: [{ kind: "directive", type: LocalizedMessagesDirective, selector: "[kendoListBoxLocalizedMessages]" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: ButtonComponent, selector: "button[kendoButton]", inputs: ["arrowIcon", "toggleable", "togglable", "selected", "tabIndex", "imageUrl", "iconClass", "icon", "disabled", "size", "rounded", "fillMode", "themeColor", "svgIcon", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }, { kind: "directive", type: ItemSelectableDirective, selector: "[kendoListBoxItemSelectable]", inputs: ["index"] }, { kind: "directive", type: TemplateContextDirective, selector: "[templateContext]", inputs: ["templateContext"] }] });
1004
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ListBoxComponent, decorators: [{
1005
- type: Component,
1006
- args: [{
1007
- selector: 'kendo-listbox',
1008
- providers: [
1009
- ListBoxSelectionService,
1010
- KeyboardNavigationService,
1011
- LocalizationService,
1012
- {
1013
- provide: L10N_PREFIX,
1014
- useValue: 'kendo.listbox'
1015
- },
1016
- ],
1017
- template: `
1018
- <ng-container kendoListBoxLocalizedMessages
1019
- i18n-moveUp="kendo.listbox.moveUp|The title of the Move Up button"
1020
- moveUp="Move Up"
1021
-
1022
- i18n-moveDown="kendo.listbox.moveDown|The title of the Move Down button"
1023
- moveDown="Move Down"
1024
-
1025
- i18n-transferTo="kendo.listbox.transferTo|The title of the Transfer To button"
1026
- transferTo="Transfer To"
1027
-
1028
- i18n-transferAllTo="kendo.listbox.transferAllTo|The title of the Transfer All To button"
1029
- transferAllTo="Transfer All To"
1030
-
1031
- i18n-transferFrom="kendo.listbox.transferFrom|The title of the Transfer From button"
1032
- transferFrom="Transfer From"
1033
-
1034
- i18n-transferAllFrom="kendo.listbox.transferAllFrom|The title of the Transfer All From button"
1035
- transferAllFrom="Transfer All From"
1036
-
1037
- i18n-remove="kendo.listbox.remove|The title of the Remove button"
1038
- remove="Remove"
1039
-
1040
- i18n-noDataText="kendo.listbox.noDataText|The text displayed when there are no items"
1041
- noDataText="No data found."
1042
- >
1043
- </ng-container>
1044
- <div
1045
- #toolbar
1046
- class="k-listbox-actions"
1047
- *ngIf="selectedTools.length > 0"
1048
- role="toolbar"
1049
- [attr.aria-label]="listboxToolbarLabel"
1050
- >
1051
- <button
1052
- #tools
1053
- *ngFor="let tool of selectedTools; let i = index"
1054
- kendoButton
1055
- [attr.tabindex]="i === 0 ? '0' : '-1'"
1056
- [size]="this.size"
1057
- [icon]="toolIcon(tool.icon)"
1058
- [svgIcon]="toolSVGIcon(tool.svgIcon)"
1059
- [attr.title]="messageFor(tool.name)"
1060
- (click)="performAction(tool.name)"
1061
- role="button"
1062
- type="button"
1063
- ></button>
1064
- </div>
1065
- <div class="k-list-scroller k-selectable">
1066
- <div class="{{ listClasses }}">
1067
- <div
1068
- *ngIf="data.length > 0"
1069
- class="k-list-content"
1070
- >
1071
- <ul
1072
- #listbox
1073
- class="k-list-ul"
1074
- role="listbox"
1075
- [attr.aria-label]="listboxLabel"
1076
- [attr.aria-multiselectable]="false"
1077
- >
1078
- <li
1079
- #listboxItems
1080
- *ngFor="let item of data; let i = index"
1081
- kendoListBoxItemSelectable
1082
- class="k-list-item"
1083
- [attr.tabindex]="i === 0 ? '0' : '-1'"
1084
- role="option"
1085
- [attr.aria-selected]="selectedIndex === i"
1086
- [index]="i"
1087
- [class.k-disabled]="itemDisabled(item)"
1088
- >
1089
- <ng-template
1090
- *ngIf="itemTemplate; else defaultItemTemplate"
1091
- [templateContext]="{
1092
- templateRef: itemTemplate.templateRef,
1093
- $implicit: item
1094
- }"
1095
- >
1096
- </ng-template>
1097
- <ng-template #defaultItemTemplate>
1098
- <span class="k-list-item-text">{{ getText(item) }}</span>
1099
- </ng-template>
1100
- </li>
1101
- </ul>
1102
- </div>
1103
- <span
1104
- *ngIf="data.length === 0"
1105
- class="k-nodata"
1106
- >{{ messageFor('noDataText') }}</span>
1107
- </div>
1108
- </div>
1109
- `,
1110
- standalone: true,
1111
- imports: [LocalizedMessagesDirective, NgIf, NgFor, ButtonComponent, ItemSelectableDirective, TemplateContextDirective]
1112
- }]
1113
- }], ctorParameters: function () { return [{ type: KeyboardNavigationService }, { type: ListBoxSelectionService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: i1.LocalizationService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { listboxClassName: [{
1114
- type: HostBinding,
1115
- args: ['class.k-listbox']
1116
- }], direction: [{
1117
- type: HostBinding,
1118
- args: ['attr.dir']
1119
- }], itemTemplate: [{
1120
- type: ContentChild,
1121
- args: [ItemTemplateDirective]
1122
- }], listboxElement: [{
1123
- type: ViewChild,
1124
- args: ['listbox']
1125
- }], listboxItems: [{
1126
- type: ViewChildren,
1127
- args: ['listboxItems']
1128
- }], toolbarElement: [{
1129
- type: ViewChild,
1130
- args: ['toolbar']
1131
- }], tools: [{
1132
- type: ViewChildren,
1133
- args: ['tools']
1134
- }], textField: [{
1135
- type: Input
1136
- }], data: [{
1137
- type: Input
1138
- }], size: [{
1139
- type: Input
1140
- }], toolbar: [{
1141
- type: Input
1142
- }], listboxLabel: [{
1143
- type: Input
1144
- }], listboxToolbarLabel: [{
1145
- type: Input
1146
- }], itemDisabled: [{
1147
- type: Input
1148
- }], selectionChange: [{
1149
- type: Output
1150
- }], actionClick: [{
1151
- type: Output
1152
- }], getChildListbox: [{
1153
- type: Output
1154
- }] } });
1155
-
1156
- /**
1157
- * A directive which manages the functoinality of the ListBox tools out of the box, and modifies the provided data accordingly.
1158
- */
1159
- class DataBindingDirective {
1160
- constructor(listbox) {
1161
- this.listbox = listbox;
1162
- this.actionClickSub = new Subscription();
1163
- this.selectedBoxSub = new Subscription();
1164
- this.connectedWithSub = new Subscription();
1165
- this.selectedBox = this.listbox;
1166
- this.connectedWithSub.add(this.listbox.getChildListbox.subscribe(() => {
1167
- this.listbox.childListbox = this.connectedWith;
1168
- }));
1169
- this.actionClickSub.add(this.listbox.actionClick.subscribe((actionName) => {
1170
- switch (actionName) {
1171
- case 'moveUp': {
1172
- this.moveVertically('up');
1173
- break;
1174
- }
1175
- case 'moveDown': {
1176
- this.moveVertically('down');
1177
- break;
1178
- }
1179
- case 'transferFrom': {
1180
- this.transferItem(this.connectedWith, this.listbox);
1181
- break;
1182
- }
1183
- case 'transferTo': {
1184
- this.transferItem(this.listbox, this.connectedWith);
1185
- break;
1186
- }
1187
- case 'transferAllTo': {
1188
- this.transferAll(this.listbox, this.connectedWith);
1189
- break;
1190
- }
1191
- case 'transferAllFrom': {
1192
- this.transferAll(this.connectedWith, this.listbox);
1193
- break;
1194
- }
1195
- case 'remove': {
1196
- this.removeItem();
1197
- break;
1198
- }
1199
- default: {
1200
- break;
1201
- }
1202
- }
1203
- }));
1204
- }
1205
- /**
1206
- * @hidden
1207
- */
1208
- ngOnChanges(changes) {
1209
- if (isChanged('connectedWith', changes, false)) {
1210
- if (!changes['connectedWith'].firstChange) {
1211
- this.selectedBoxSub.unsubscribe();
1212
- this.selectedBoxSub = new Subscription();
1213
- }
1214
- this.selectedBoxSub.add(this.listbox.selectionChange.subscribe(() => {
1215
- this.selectedBox = this.listbox;
1216
- this.connectedWith.clearSelection();
1217
- }));
1218
- this.selectedBoxSub.add(this.connectedWith.selectionChange.subscribe(() => {
1219
- this.selectedBox = this.connectedWith;
1220
- this.listbox.clearSelection();
1221
- }));
1222
- }
1223
- }
1224
- /**
1225
- * @hidden
1226
- */
1227
- ngOnDestroy() {
1228
- if (this.actionClickSub) {
1229
- this.actionClickSub.unsubscribe();
1230
- this.actionClickSub = null;
1231
- }
1232
- if (this.selectedBoxSub) {
1233
- this.selectedBoxSub.unsubscribe();
1234
- this.selectedBoxSub = null;
1235
- }
1236
- }
1237
- moveVertically(dir) {
1238
- const index = this.selectedBox.selectedIndex;
1239
- if (!isPresent(index)) {
1240
- return;
1241
- }
1242
- const topReached = dir === 'up' && index <= 0;
1243
- const bottomReached = dir === 'down' && index >= this.selectedBox.data.length - 1;
1244
- if (topReached || bottomReached) {
1245
- return;
1246
- }
1247
- const newIndex = dir === 'up' ? index - 1 : index + 1;
1248
- const navigation = this.selectedBox.keyboardNavigationService;
1249
- navigation.focusedListboxItemIndex = navigation.selectedListboxItemIndex = newIndex;
1250
- [this.selectedBox.data[newIndex], this.selectedBox.data[index]] = [this.selectedBox.data[index], this.selectedBox.data[newIndex]];
1251
- this.selectedBox.selectionService.select(newIndex);
1252
- }
1253
- removeItem() {
1254
- const index = this.selectedBox.selectedIndex;
1255
- if (!isPresent(index)) {
1256
- return;
1257
- }
1258
- this.selectedBox.data.splice(index, 1);
1259
- this.selectedBox.selectionService.clearSelection();
1260
- }
1261
- transferItem(source, target) {
1262
- const item = source && source.data[source.selectedIndex];
1263
- if (!item || !target || !source) {
1264
- return;
1265
- }
1266
- target.data.push(item);
1267
- source.data.splice(source.selectedIndex, 1);
1268
- source.clearSelection();
1269
- target.selectItem(target.data.length - 1);
1270
- this.selectedBox = target;
1271
- }
1272
- transferAll(source, target) {
1273
- if (!target || !source) {
1274
- return;
1275
- }
1276
- target.data.splice(target.data.length, 0, ...source.data.splice(0, source.data.length));
1277
- target.selectItem(target.data.length - 1);
1278
- this.selectedBox = target;
1279
- }
1280
- }
1281
- DataBindingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DataBindingDirective, deps: [{ token: ListBoxComponent }], target: i0.ɵɵFactoryTarget.Directive });
1282
- DataBindingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: DataBindingDirective, isStandalone: true, selector: "[kendoListBoxDataBinding]", inputs: { connectedWith: "connectedWith" }, usesOnChanges: true, ngImport: i0 });
1283
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DataBindingDirective, decorators: [{
1284
- type: Directive,
1285
- args: [{
1286
- selector: '[kendoListBoxDataBinding]',
1287
- standalone: true
1288
- }]
1289
- }], ctorParameters: function () { return [{ type: ListBoxComponent }]; }, propDecorators: { connectedWith: [{
1290
- type: Input
1291
- }] } });
1292
-
1293
- /**
1294
- * Custom component messages override default component messages
1295
- * ([see example](slug:globalization_listbox#toc-custom-messages)).
1296
- */
1297
- class CustomMessagesComponent extends Messages {
1298
- constructor(service) {
1299
- super();
1300
- this.service = service;
1301
- }
1302
- get override() {
1303
- return true;
1304
- }
1305
- }
1306
- CustomMessagesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CustomMessagesComponent, deps: [{ token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
1307
- CustomMessagesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: CustomMessagesComponent, isStandalone: true, selector: "kendo-listbox-messages", providers: [
1308
- {
1309
- provide: Messages,
1310
- useExisting: forwardRef(() => CustomMessagesComponent)
1311
- }
1312
- ], usesInheritance: true, ngImport: i0, template: ``, isInline: true });
1313
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CustomMessagesComponent, decorators: [{
1314
- type: Component,
1315
- args: [{
1316
- providers: [
1317
- {
1318
- provide: Messages,
1319
- useExisting: forwardRef(() => CustomMessagesComponent)
1320
- }
1321
- ],
1322
- selector: 'kendo-listbox-messages',
1323
- template: ``,
1324
- standalone: true
1325
- }]
1326
- }], ctorParameters: function () { return [{ type: i1.LocalizationService }]; } });
1327
-
1328
- /**
1329
- * Utility array that contains all `@progress/kendo-angular-listbox` related components and directives
1330
- */
1331
- const KENDO_LISTBOX = [
1332
- ListBoxComponent,
1333
- ItemTemplateDirective,
1334
- ItemSelectableDirective,
1335
- DataBindingDirective,
1336
- CustomMessagesComponent,
1337
- ];
1338
-
1339
- //IMPORTANT: NgModule export kept for backwards compatibility
1340
- /**
1341
- * Represents the [NgModule](https://angular.io/api/core/NgModule) definition for the ListBox component.
1342
- */
1343
- class ListBoxModule {
1344
- }
1345
- ListBoxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ListBoxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1346
- ListBoxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: ListBoxModule, imports: [ListBoxComponent, ItemTemplateDirective, ItemSelectableDirective, DataBindingDirective, CustomMessagesComponent], exports: [ListBoxComponent, ItemTemplateDirective, ItemSelectableDirective, DataBindingDirective, CustomMessagesComponent] });
1347
- ListBoxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ListBoxModule, providers: [IconsService, PopupService, ResizeBatchService], imports: [ListBoxComponent, CustomMessagesComponent] });
1348
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ListBoxModule, decorators: [{
1349
- type: NgModule,
1350
- args: [{
1351
- imports: [...KENDO_LISTBOX],
1352
- exports: [...KENDO_LISTBOX],
1353
- providers: [IconsService, PopupService, ResizeBatchService]
1354
- }]
1355
- }] });
1356
-
1357
- /**
1358
- * Generated bundle index. Do not edit.
1359
- */
1360
-
1361
- export { CustomMessagesComponent, DataBindingDirective, ItemSelectableDirective, ItemTemplateDirective, KENDO_LISTBOX, ListBoxComponent, ListBoxModule, LocalizedMessagesDirective };
1362
-