@progress/kendo-angular-listbox 1.0.5 → 11.0.0-develop.80
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/NOTICE.txt +3 -3
- package/constants.d.ts +2 -2
- package/data-binding.directive.d.ts +1 -1
- package/{esm2015/constants.js → esm2020/constants.mjs} +6 -6
- package/{esm2015/data-binding.directive.js → esm2020/data-binding.directive.mjs} +6 -5
- package/{esm2015/main.js → esm2020/index.mjs} +1 -1
- package/{esm2015/item-selectable.directive.js → esm2020/item-selectable.directive.mjs} +5 -4
- package/{esm2015/item-template.directive.js → esm2020/item-template.directive.mjs} +5 -5
- package/{esm2015/listbox.component.js → esm2020/listbox.component.mjs} +53 -37
- package/{esm2015/listbox.module.js → esm2020/listbox.module.mjs} +5 -5
- package/{esm2015/package-metadata.js → esm2020/package-metadata.mjs} +2 -2
- package/{esm2015/kendo-angular-listbox.js → esm2020/progress-kendo-angular-listbox.mjs} +2 -2
- package/{esm2015/selection.service.js → esm2020/selection.service.mjs} +4 -4
- package/{esm2015/size.js → esm2020/size.mjs} +1 -1
- package/{esm2015/toolbar.js → esm2020/toolbar.mjs} +1 -1
- package/{esm2015/util.js → esm2020/util.mjs} +1 -1
- package/fesm2015/{kendo-angular-listbox.js → progress-kendo-angular-listbox.mjs} +75 -59
- package/fesm2020/progress-kendo-angular-listbox.mjs +603 -0
- package/{main.d.ts → index.d.ts} +2 -1
- package/item-selectable.directive.d.ts +1 -1
- package/item-template.directive.d.ts +1 -1
- package/listbox.component.d.ts +5 -2
- package/listbox.module.d.ts +1 -1
- package/package-metadata.d.ts +1 -1
- package/package.json +31 -57
- package/{kendo-angular-listbox.d.ts → progress-kendo-angular-listbox.d.ts} +2 -2
- package/schematics/ngAdd/index.js +1 -5
- package/selection.service.d.ts +1 -1
- package/size.d.ts +1 -1
- package/toolbar.d.ts +1 -1
- package/util.d.ts +1 -1
- package/bundles/kendo-angular-listbox.umd.js +0 -5
- package/schematics/ngAdd/index.js.map +0 -1
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2022 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, isDevMode, Component, ContentChild, 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 * as i2 from '@progress/kendo-angular-buttons';
|
|
11
|
+
import { ButtonsModule } from '@progress/kendo-angular-buttons';
|
|
12
|
+
import * as i3 from '@angular/common';
|
|
13
|
+
import { CommonModule } from '@angular/common';
|
|
14
|
+
import { isChanged } from '@progress/kendo-angular-common';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
19
|
+
const packageMetadata = {
|
|
20
|
+
name: '@progress/kendo-angular-listbox',
|
|
21
|
+
productName: 'Kendo UI for Angular',
|
|
22
|
+
productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
|
|
23
|
+
publishDate: 1672394553,
|
|
24
|
+
version: '',
|
|
25
|
+
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'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
class ListBoxSelectionService {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.onSelect = new EventEmitter();
|
|
34
|
+
this.selectedIndex = null;
|
|
35
|
+
}
|
|
36
|
+
select(index) {
|
|
37
|
+
this.selectedIndex = index;
|
|
38
|
+
this.onSelect.next({ index: this.selectedIndex });
|
|
39
|
+
}
|
|
40
|
+
isSelected(index) {
|
|
41
|
+
return index === this.selectedIndex;
|
|
42
|
+
}
|
|
43
|
+
clearSelection() {
|
|
44
|
+
this.selectedIndex = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
ListBoxSelectionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ListBoxSelectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
48
|
+
ListBoxSelectionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ListBoxSelectionService });
|
|
49
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ListBoxSelectionService, decorators: [{
|
|
50
|
+
type: Injectable
|
|
51
|
+
}] });
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Renders the ListBox item content. To define the item template, nest an `<ng-template>` tag
|
|
55
|
+
* with the `kendoListBoxItemTemplate` directive inside the `<kendo-listbox>` tag. The template context is
|
|
56
|
+
* set to the current data item.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* _@Component({
|
|
61
|
+
* selector: 'my-app',
|
|
62
|
+
* template: `
|
|
63
|
+
* <kendo-listbox [data]="listBoxItems">
|
|
64
|
+
* <ng-template kendoListBoxItemTemplate let-dataItem>
|
|
65
|
+
* <span>{{ dataItem }} item</span>
|
|
66
|
+
* </ng-template>
|
|
67
|
+
* </kendo-listbox>
|
|
68
|
+
* `
|
|
69
|
+
* })
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
class ItemTemplateDirective {
|
|
73
|
+
constructor(templateRef) {
|
|
74
|
+
this.templateRef = templateRef;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
ItemTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ItemTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
78
|
+
ItemTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: ItemTemplateDirective, selector: "[kendoListBoxItemTemplate]", ngImport: i0 });
|
|
79
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ItemTemplateDirective, decorators: [{
|
|
80
|
+
type: Directive,
|
|
81
|
+
args: [{
|
|
82
|
+
selector: '[kendoListBoxItemTemplate]'
|
|
83
|
+
}]
|
|
84
|
+
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @hidden
|
|
88
|
+
*/
|
|
89
|
+
const DEFAULT_TOOLBAR_POSITION = 'right';
|
|
90
|
+
/**
|
|
91
|
+
* @hidden
|
|
92
|
+
*/
|
|
93
|
+
const allTools = [
|
|
94
|
+
{
|
|
95
|
+
name: 'moveUp',
|
|
96
|
+
label: 'Move Up',
|
|
97
|
+
icon: 'arrow-n'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'moveDown',
|
|
101
|
+
label: 'Move Down',
|
|
102
|
+
icon: 'arrow-s'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'transferTo',
|
|
106
|
+
label: 'Transfer From',
|
|
107
|
+
icon: 'arrow-w'
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'transferFrom',
|
|
111
|
+
label: 'Transfer To',
|
|
112
|
+
icon: 'arrow-e'
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'transferAllTo',
|
|
116
|
+
label: 'Transfer All To',
|
|
117
|
+
icon: 'arrow-double-60-right'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'transferAllFrom',
|
|
121
|
+
label: 'Transfer All From',
|
|
122
|
+
icon: 'arrow-double-60-left'
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'remove',
|
|
126
|
+
label: 'Remove',
|
|
127
|
+
icon: 'x'
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
/**
|
|
131
|
+
* @hidden
|
|
132
|
+
*/
|
|
133
|
+
const sizeClassMap = {
|
|
134
|
+
small: 'sm',
|
|
135
|
+
medium: 'md',
|
|
136
|
+
large: 'lg'
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* @hidden
|
|
140
|
+
*/
|
|
141
|
+
const actionsClasses = {
|
|
142
|
+
left: 'k-listbox-actions-left',
|
|
143
|
+
right: 'k-listbox-actions-right',
|
|
144
|
+
top: 'k-listbox-actions-top',
|
|
145
|
+
bottom: 'k-listbox-actions-bottom'
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @hidden
|
|
150
|
+
*/
|
|
151
|
+
const isPresent = (value) => value !== null && value !== undefined;
|
|
152
|
+
/**
|
|
153
|
+
* @hidden
|
|
154
|
+
*/
|
|
155
|
+
const isObject = (value) => isPresent(value) && typeof value === 'object';
|
|
156
|
+
/**
|
|
157
|
+
* @hidden
|
|
158
|
+
*/
|
|
159
|
+
const fieldAccessor = (dataItem, field) => {
|
|
160
|
+
if (!isPresent(dataItem)) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
if (!isPresent(field) || !isObject(dataItem)) {
|
|
164
|
+
return dataItem;
|
|
165
|
+
}
|
|
166
|
+
// creates a field accessor supporting nested fields processing
|
|
167
|
+
const valueFrom = getter(field);
|
|
168
|
+
return valueFrom(dataItem);
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* @hidden
|
|
172
|
+
*/
|
|
173
|
+
const defaultItemDisabled = () => false;
|
|
174
|
+
/**
|
|
175
|
+
* @hidden
|
|
176
|
+
*/
|
|
177
|
+
const getTools = (names) => {
|
|
178
|
+
return names.map(tool => allTools.find(meta => meta.name === tool));
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @hidden
|
|
183
|
+
*/
|
|
184
|
+
class ItemSelectableDirective {
|
|
185
|
+
constructor(selectionService) {
|
|
186
|
+
this.selectionService = selectionService;
|
|
187
|
+
}
|
|
188
|
+
get selectedClassName() {
|
|
189
|
+
return this.selectionService.isSelected(this.index);
|
|
190
|
+
}
|
|
191
|
+
onClick(event) {
|
|
192
|
+
event.stopPropagation();
|
|
193
|
+
this.selectionService.select(this.index);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
ItemSelectableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ItemSelectableDirective, deps: [{ token: ListBoxSelectionService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
197
|
+
ItemSelectableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: ItemSelectableDirective, selector: "[kendoListBoxItemSelectable]", inputs: { index: "index" }, host: { listeners: { "click": "onClick($event)" }, properties: { "class.k-selected": "this.selectedClassName" } }, ngImport: i0 });
|
|
198
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ItemSelectableDirective, decorators: [{
|
|
199
|
+
type: Directive,
|
|
200
|
+
args: [{
|
|
201
|
+
selector: '[kendoListBoxItemSelectable]'
|
|
202
|
+
}]
|
|
203
|
+
}], ctorParameters: function () { return [{ type: ListBoxSelectionService }]; }, propDecorators: { index: [{
|
|
204
|
+
type: Input
|
|
205
|
+
}], selectedClassName: [{
|
|
206
|
+
type: HostBinding,
|
|
207
|
+
args: ['class.k-selected']
|
|
208
|
+
}], onClick: [{
|
|
209
|
+
type: HostListener,
|
|
210
|
+
args: ['click', ['$event']]
|
|
211
|
+
}] } });
|
|
212
|
+
|
|
213
|
+
const DEFAULT_SIZE = 'medium';
|
|
214
|
+
/**
|
|
215
|
+
* Represents the [Kendo UI ListBox component for Angular]({% slug overview_listbox %}).
|
|
216
|
+
*/
|
|
217
|
+
class ListBoxComponent {
|
|
218
|
+
constructor(selectionService, renderer, hostElement) {
|
|
219
|
+
this.selectionService = selectionService;
|
|
220
|
+
this.renderer = renderer;
|
|
221
|
+
this.hostElement = hostElement;
|
|
222
|
+
/**
|
|
223
|
+
* @hidden
|
|
224
|
+
*/
|
|
225
|
+
this.listboxClassName = true;
|
|
226
|
+
/**
|
|
227
|
+
* The data which will be displayed by the ListBox.
|
|
228
|
+
*/
|
|
229
|
+
this.data = [];
|
|
230
|
+
/**
|
|
231
|
+
* A function which determines if a specific item is disabled.
|
|
232
|
+
*/
|
|
233
|
+
this.itemDisabled = defaultItemDisabled;
|
|
234
|
+
/**
|
|
235
|
+
* Fires when the user selects a different ListBox item. Also fires when a node is moved, since that also changes its index.
|
|
236
|
+
*/
|
|
237
|
+
this.selectionChange = new EventEmitter();
|
|
238
|
+
/**
|
|
239
|
+
* Fires when the user clicks a ListBox item.
|
|
240
|
+
*/
|
|
241
|
+
this.actionClick = new EventEmitter();
|
|
242
|
+
/**
|
|
243
|
+
* @hidden
|
|
244
|
+
*/
|
|
245
|
+
this.selectedTools = allTools;
|
|
246
|
+
this._size = DEFAULT_SIZE;
|
|
247
|
+
this.sub = new Subscription();
|
|
248
|
+
validatePackage(packageMetadata);
|
|
249
|
+
this.setToolbarClass(DEFAULT_TOOLBAR_POSITION);
|
|
250
|
+
this.setSizingClass(this.size);
|
|
251
|
+
this.sub.add(this.selectionService.onSelect.subscribe((e) => {
|
|
252
|
+
this.selectionChange.next(e);
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Sets the size of the component.
|
|
257
|
+
*
|
|
258
|
+
* The possible values are:
|
|
259
|
+
* - `'small'`
|
|
260
|
+
* - `'medium'` (default)
|
|
261
|
+
* - `'large'`
|
|
262
|
+
*/
|
|
263
|
+
set size(size) {
|
|
264
|
+
const newSize = size ? size : DEFAULT_SIZE;
|
|
265
|
+
this.renderer.removeClass(this.hostElement.nativeElement, `k-listbox-${sizeClassMap[this.size]}`);
|
|
266
|
+
this.setSizingClass(newSize);
|
|
267
|
+
this._size = size;
|
|
268
|
+
}
|
|
269
|
+
get size() {
|
|
270
|
+
return this._size;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Sets whether a toolbar should be displayed with the ListBox, as well as what tools and position should be used.
|
|
274
|
+
*/
|
|
275
|
+
set toolbar(config) {
|
|
276
|
+
let position = DEFAULT_TOOLBAR_POSITION;
|
|
277
|
+
if (typeof config === 'boolean') {
|
|
278
|
+
this.selectedTools = config ? allTools : [];
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
this.selectedTools = config.tools ? getTools(config.tools) : allTools;
|
|
282
|
+
if (config.position) {
|
|
283
|
+
position = config.position;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
this.setToolbarClass(position);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* @hidden
|
|
290
|
+
*/
|
|
291
|
+
get listClasses() {
|
|
292
|
+
return `k-list k-list-${sizeClassMap[this.size]}`;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* @hidden
|
|
296
|
+
*/
|
|
297
|
+
ngOnDestroy() {
|
|
298
|
+
this.sub.unsubscribe();
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* @hidden
|
|
302
|
+
*/
|
|
303
|
+
performAction(actionName) {
|
|
304
|
+
this.actionClick.next(actionName);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Programmatically selects a ListBox node.
|
|
308
|
+
*/
|
|
309
|
+
selectItem(index) {
|
|
310
|
+
this.selectionService.selectedIndex = index;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Programmatically clears the ListBox selection.
|
|
314
|
+
*/
|
|
315
|
+
clearSelection() {
|
|
316
|
+
this.selectionService.clearSelection();
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* The index of the currently selected item in the ListBox.
|
|
320
|
+
*/
|
|
321
|
+
get selectedIndex() {
|
|
322
|
+
return this.selectionService.selectedIndex;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* @hidden
|
|
326
|
+
*/
|
|
327
|
+
getText(dataItem) {
|
|
328
|
+
if (typeof dataItem !== 'string' && !this.textField && isDevMode()) {
|
|
329
|
+
throw new Error('Missing textField input. When passing an array of objects as data, please set the textField input of the ListBox accordingly.');
|
|
330
|
+
}
|
|
331
|
+
return fieldAccessor(dataItem, this.textField);
|
|
332
|
+
}
|
|
333
|
+
setToolbarClass(pos) {
|
|
334
|
+
Object.keys(actionsClasses).forEach((className) => {
|
|
335
|
+
if (pos === className) {
|
|
336
|
+
this.renderer.addClass(this.hostElement.nativeElement, actionsClasses[className]);
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
this.renderer.removeClass(this.hostElement.nativeElement, actionsClasses[className]);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
setSizingClass(size) {
|
|
344
|
+
this.renderer.addClass(this.hostElement.nativeElement, `k-listbox-${sizeClassMap[size]}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
ListBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ListBoxComponent, deps: [{ token: ListBoxSelectionService }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
348
|
+
ListBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ListBoxComponent, selector: "kendo-listbox", inputs: { textField: "textField", data: "data", size: "size", toolbar: "toolbar", itemDisabled: "itemDisabled" }, outputs: { selectionChange: "selectionChange", actionClick: "actionClick" }, host: { properties: { "class.k-listbox": "this.listboxClassName" } }, providers: [ListBoxSelectionService], queries: [{ propertyName: "itemTemplate", first: true, predicate: ItemTemplateDirective, descendants: true }], ngImport: i0, template: `
|
|
349
|
+
<div class="k-listbox-actions" *ngIf="selectedTools.length > 0">
|
|
350
|
+
<button
|
|
351
|
+
*ngFor="let tool of selectedTools"
|
|
352
|
+
kendoButton
|
|
353
|
+
[size]="this.size"
|
|
354
|
+
[icon]="tool.icon"
|
|
355
|
+
(click)="performAction(tool.name)"
|
|
356
|
+
role="button"
|
|
357
|
+
></button>
|
|
358
|
+
</div>
|
|
359
|
+
<div class="k-list-scroller k-selectable">
|
|
360
|
+
<div class="{{ listClasses }}">
|
|
361
|
+
<div class="k-list-content">
|
|
362
|
+
<ul class="k-list-ul">
|
|
363
|
+
<li
|
|
364
|
+
class="k-list-item"
|
|
365
|
+
*ngFor="let item of data; let i = index;"
|
|
366
|
+
kendoListBoxItemSelectable
|
|
367
|
+
[index]="i"
|
|
368
|
+
[class.k-disabled]="itemDisabled(item)"
|
|
369
|
+
>
|
|
370
|
+
<ng-template *ngIf="itemTemplate; else defaultItemTemplate"
|
|
371
|
+
[templateContext]="{
|
|
372
|
+
templateRef: itemTemplate.templateRef,
|
|
373
|
+
$implicit: item
|
|
374
|
+
}">
|
|
375
|
+
</ng-template>
|
|
376
|
+
<ng-template #defaultItemTemplate>
|
|
377
|
+
<span class="k-list-item-text">{{ getText(item) }}</span>
|
|
378
|
+
</ng-template>
|
|
379
|
+
</li>
|
|
380
|
+
</ul>
|
|
381
|
+
</div>
|
|
382
|
+
</div>
|
|
383
|
+
</div>
|
|
384
|
+
`, isInline: true, components: [{ type: i2.Button, selector: "button[kendoButton], span[kendoButton], kendo-button", inputs: ["toggleable", "togglable", "selected", "tabIndex", "imageUrl", "iconClass", "icon", "disabled", "size", "rounded", "fillMode", "themeColor", "svgIcon", "role", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: ItemSelectableDirective, selector: "[kendoListBoxItemSelectable]", inputs: ["index"] }, { type: i2.TemplateContextDirective, selector: "[templateContext]", inputs: ["templateContext"] }] });
|
|
385
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ListBoxComponent, decorators: [{
|
|
386
|
+
type: Component,
|
|
387
|
+
args: [{
|
|
388
|
+
selector: 'kendo-listbox',
|
|
389
|
+
providers: [ListBoxSelectionService],
|
|
390
|
+
template: `
|
|
391
|
+
<div class="k-listbox-actions" *ngIf="selectedTools.length > 0">
|
|
392
|
+
<button
|
|
393
|
+
*ngFor="let tool of selectedTools"
|
|
394
|
+
kendoButton
|
|
395
|
+
[size]="this.size"
|
|
396
|
+
[icon]="tool.icon"
|
|
397
|
+
(click)="performAction(tool.name)"
|
|
398
|
+
role="button"
|
|
399
|
+
></button>
|
|
400
|
+
</div>
|
|
401
|
+
<div class="k-list-scroller k-selectable">
|
|
402
|
+
<div class="{{ listClasses }}">
|
|
403
|
+
<div class="k-list-content">
|
|
404
|
+
<ul class="k-list-ul">
|
|
405
|
+
<li
|
|
406
|
+
class="k-list-item"
|
|
407
|
+
*ngFor="let item of data; let i = index;"
|
|
408
|
+
kendoListBoxItemSelectable
|
|
409
|
+
[index]="i"
|
|
410
|
+
[class.k-disabled]="itemDisabled(item)"
|
|
411
|
+
>
|
|
412
|
+
<ng-template *ngIf="itemTemplate; else defaultItemTemplate"
|
|
413
|
+
[templateContext]="{
|
|
414
|
+
templateRef: itemTemplate.templateRef,
|
|
415
|
+
$implicit: item
|
|
416
|
+
}">
|
|
417
|
+
</ng-template>
|
|
418
|
+
<ng-template #defaultItemTemplate>
|
|
419
|
+
<span class="k-list-item-text">{{ getText(item) }}</span>
|
|
420
|
+
</ng-template>
|
|
421
|
+
</li>
|
|
422
|
+
</ul>
|
|
423
|
+
</div>
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
`
|
|
427
|
+
}]
|
|
428
|
+
}], ctorParameters: function () { return [{ type: ListBoxSelectionService }, { type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { listboxClassName: [{
|
|
429
|
+
type: HostBinding,
|
|
430
|
+
args: ['class.k-listbox']
|
|
431
|
+
}], itemTemplate: [{
|
|
432
|
+
type: ContentChild,
|
|
433
|
+
args: [ItemTemplateDirective, { static: false }]
|
|
434
|
+
}], textField: [{
|
|
435
|
+
type: Input
|
|
436
|
+
}], data: [{
|
|
437
|
+
type: Input
|
|
438
|
+
}], size: [{
|
|
439
|
+
type: Input
|
|
440
|
+
}], toolbar: [{
|
|
441
|
+
type: Input
|
|
442
|
+
}], itemDisabled: [{
|
|
443
|
+
type: Input
|
|
444
|
+
}], selectionChange: [{
|
|
445
|
+
type: Output
|
|
446
|
+
}], actionClick: [{
|
|
447
|
+
type: Output
|
|
448
|
+
}] } });
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* A directive which manages the functoinality of the ListBox tools out of the box, and modifies the provided data accordingly.
|
|
452
|
+
*/
|
|
453
|
+
class DataBindingDirective {
|
|
454
|
+
constructor(listbox) {
|
|
455
|
+
this.listbox = listbox;
|
|
456
|
+
this.actionClickSub = new Subscription();
|
|
457
|
+
this.selectedBoxSub = new Subscription();
|
|
458
|
+
this.selectedBox = this.listbox;
|
|
459
|
+
this.actionClickSub.add(this.listbox.actionClick.subscribe((actionName) => {
|
|
460
|
+
switch (actionName) {
|
|
461
|
+
case 'moveUp': {
|
|
462
|
+
this.moveVertically('up');
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
case 'moveDown': {
|
|
466
|
+
this.moveVertically('down');
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
case 'transferTo': {
|
|
470
|
+
this.transferItem(this.connectedWith, this.listbox);
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
case 'transferFrom': {
|
|
474
|
+
this.transferItem(this.listbox, this.connectedWith);
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
case 'transferAllTo': {
|
|
478
|
+
this.transferAll(this.listbox, this.connectedWith);
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
case 'transferAllFrom': {
|
|
482
|
+
this.transferAll(this.connectedWith, this.listbox);
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
case 'remove': {
|
|
486
|
+
this.removeItem();
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
default: {
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}));
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* @hidden
|
|
497
|
+
*/
|
|
498
|
+
ngOnChanges(changes) {
|
|
499
|
+
if (isChanged('connectedWith', changes, false)) {
|
|
500
|
+
if (!changes['connectedWith'].firstChange) {
|
|
501
|
+
this.selectedBoxSub.unsubscribe();
|
|
502
|
+
this.selectedBoxSub = new Subscription();
|
|
503
|
+
}
|
|
504
|
+
this.selectedBoxSub.add(this.listbox.selectionChange.subscribe(() => {
|
|
505
|
+
this.selectedBox = this.listbox;
|
|
506
|
+
this.connectedWith.clearSelection();
|
|
507
|
+
}));
|
|
508
|
+
this.selectedBoxSub.add(this.connectedWith.selectionChange.subscribe(() => {
|
|
509
|
+
this.selectedBox = this.connectedWith;
|
|
510
|
+
this.listbox.clearSelection();
|
|
511
|
+
}));
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* @hidden
|
|
516
|
+
*/
|
|
517
|
+
ngOnDestroy() {
|
|
518
|
+
if (this.actionClickSub) {
|
|
519
|
+
this.actionClickSub.unsubscribe();
|
|
520
|
+
this.actionClickSub = null;
|
|
521
|
+
}
|
|
522
|
+
if (this.selectedBoxSub) {
|
|
523
|
+
this.selectedBoxSub.unsubscribe();
|
|
524
|
+
this.selectedBoxSub = null;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
moveVertically(dir) {
|
|
528
|
+
const index = this.selectedBox.selectedIndex;
|
|
529
|
+
if (!isPresent(index)) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
const topReached = dir === 'up' && index <= 0;
|
|
533
|
+
const bottomReached = dir === 'down' && index >= this.selectedBox.data.length - 1;
|
|
534
|
+
if (topReached || bottomReached) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const newIndex = dir === 'up' ? index - 1 : index + 1;
|
|
538
|
+
// ES6 Destructuring swap
|
|
539
|
+
[this.selectedBox.data[newIndex], this.selectedBox.data[index]] = [this.selectedBox.data[index], this.selectedBox.data[newIndex]];
|
|
540
|
+
this.selectedBox.selectionService.select(newIndex);
|
|
541
|
+
}
|
|
542
|
+
removeItem() {
|
|
543
|
+
const index = this.selectedBox.selectedIndex;
|
|
544
|
+
if (!isPresent(index)) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
this.selectedBox.data.splice(index, 1);
|
|
548
|
+
this.selectedBox.selectionService.clearSelection();
|
|
549
|
+
}
|
|
550
|
+
transferItem(source, target) {
|
|
551
|
+
const item = source && source.data[source.selectedIndex];
|
|
552
|
+
if (!item || !target || !source) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
target.data.push(item);
|
|
556
|
+
source.data.splice(source.selectedIndex, 1);
|
|
557
|
+
source.clearSelection();
|
|
558
|
+
target.selectItem(target.data.length - 1);
|
|
559
|
+
this.selectedBox = target;
|
|
560
|
+
}
|
|
561
|
+
transferAll(source, target) {
|
|
562
|
+
if (!target || !source) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
target.data.splice(target.data.length, 0, ...source.data.splice(0, source.data.length));
|
|
566
|
+
target.selectItem(target.data.length - 1);
|
|
567
|
+
this.selectedBox = target;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
DataBindingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DataBindingDirective, deps: [{ token: ListBoxComponent }], target: i0.ɵɵFactoryTarget.Directive });
|
|
571
|
+
DataBindingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: DataBindingDirective, selector: "[kendoListBoxDataBinding]", inputs: { connectedWith: "connectedWith" }, usesOnChanges: true, ngImport: i0 });
|
|
572
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DataBindingDirective, decorators: [{
|
|
573
|
+
type: Directive,
|
|
574
|
+
args: [{
|
|
575
|
+
selector: '[kendoListBoxDataBinding]'
|
|
576
|
+
}]
|
|
577
|
+
}], ctorParameters: function () { return [{ type: ListBoxComponent }]; }, propDecorators: { connectedWith: [{
|
|
578
|
+
type: Input
|
|
579
|
+
}] } });
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Represents the [NgModule](https://angular.io/api/core/NgModule) definition for the ListBox component.
|
|
583
|
+
*/
|
|
584
|
+
class ListBoxModule {
|
|
585
|
+
}
|
|
586
|
+
ListBoxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ListBoxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
587
|
+
ListBoxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ListBoxModule, declarations: [ListBoxComponent, ItemTemplateDirective, ItemSelectableDirective, DataBindingDirective], imports: [ButtonsModule, CommonModule], exports: [ListBoxComponent, ItemTemplateDirective, ItemSelectableDirective, DataBindingDirective] });
|
|
588
|
+
ListBoxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ListBoxModule, imports: [[ButtonsModule, CommonModule]] });
|
|
589
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ListBoxModule, decorators: [{
|
|
590
|
+
type: NgModule,
|
|
591
|
+
args: [{
|
|
592
|
+
imports: [ButtonsModule, CommonModule],
|
|
593
|
+
declarations: [ListBoxComponent, ItemTemplateDirective, ItemSelectableDirective, DataBindingDirective],
|
|
594
|
+
exports: [ListBoxComponent, ItemTemplateDirective, ItemSelectableDirective, DataBindingDirective]
|
|
595
|
+
}]
|
|
596
|
+
}] });
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Generated bundle index. Do not edit.
|
|
600
|
+
*/
|
|
601
|
+
|
|
602
|
+
export { DataBindingDirective, ItemSelectableDirective, ItemTemplateDirective, ListBoxComponent, ListBoxModule };
|
|
603
|
+
|
package/{main.d.ts → index.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
5
|
export { ListBoxComponent } from './listbox.component';
|
|
@@ -12,3 +12,4 @@ export { ActionName } from './toolbar';
|
|
|
12
12
|
export { ListBoxToolbarPosition } from './toolbar';
|
|
13
13
|
export { Toolbar } from './toolbar';
|
|
14
14
|
export { ListBoxToolbarConfig } from './toolbar';
|
|
15
|
+
export { ListBoxSelectionEvent } from './selection.service';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { ListBoxSelectionService } from './selection.service';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { TemplateRef } from '@angular/core';
|
package/listbox.component.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { ElementRef, EventEmitter, OnDestroy, Renderer2 } from '@angular/core';
|
|
@@ -39,7 +39,8 @@ export declare class ListBoxComponent implements OnDestroy {
|
|
|
39
39
|
* - `'medium'` (default)
|
|
40
40
|
* - `'large'`
|
|
41
41
|
*/
|
|
42
|
-
size: ListBoxSize;
|
|
42
|
+
set size(size: ListBoxSize);
|
|
43
|
+
get size(): ListBoxSize;
|
|
43
44
|
/**
|
|
44
45
|
* Sets whether a toolbar should be displayed with the ListBox, as well as what tools and position should be used.
|
|
45
46
|
*/
|
|
@@ -64,6 +65,7 @@ export declare class ListBoxComponent implements OnDestroy {
|
|
|
64
65
|
* @hidden
|
|
65
66
|
*/
|
|
66
67
|
selectedTools: Tool[];
|
|
68
|
+
private _size;
|
|
67
69
|
private sub;
|
|
68
70
|
constructor(selectionService: ListBoxSelectionService, renderer: Renderer2, hostElement: ElementRef);
|
|
69
71
|
/**
|
|
@@ -91,6 +93,7 @@ export declare class ListBoxComponent implements OnDestroy {
|
|
|
91
93
|
*/
|
|
92
94
|
getText(dataItem: any): string;
|
|
93
95
|
private setToolbarClass;
|
|
96
|
+
private setSizingClass;
|
|
94
97
|
static ɵfac: i0.ɵɵFactoryDeclaration<ListBoxComponent, never>;
|
|
95
98
|
static ɵcmp: i0.ɵɵComponentDeclaration<ListBoxComponent, "kendo-listbox", never, { "textField": "textField"; "data": "data"; "size": "size"; "toolbar": "toolbar"; "itemDisabled": "itemDisabled"; }, { "selectionChange": "selectionChange"; "actionClick": "actionClick"; }, ["itemTemplate"], never>;
|
|
96
99
|
}
|
package/listbox.module.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as i0 from "@angular/core";
|
package/package-metadata.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { PackageMetadata } from '@progress/kendo-licensing';
|