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