@progress/kendo-vue-listbox 3.7.4-dev.202212300853
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 +86 -0
- package/README.md +52 -0
- package/dist/cdn/js/kendo-vue-listbox.js +1 -0
- package/dist/es/ListBox.d.ts +40 -0
- package/dist/es/ListBox.js +253 -0
- package/dist/es/ListBoxToolbar.d.ts +40 -0
- package/dist/es/ListBoxToolbar.js +166 -0
- package/dist/es/additionalTypes.ts +21 -0
- package/dist/es/interfaces/Enums.d.ts +7 -0
- package/dist/es/interfaces/Enums.js +8 -0
- package/dist/es/interfaces/ListBoxEvents.d.ts +13 -0
- package/dist/es/interfaces/ListBoxEvents.js +1 -0
- package/dist/es/interfaces/ListBoxProps.d.ts +93 -0
- package/dist/es/interfaces/ListBoxProps.js +2 -0
- package/dist/es/interfaces/ListBoxToolBarProps.d.ts +32 -0
- package/dist/es/interfaces/ListBoxToolBarProps.js +1 -0
- package/dist/es/main.d.ts +7 -0
- package/dist/es/main.js +4 -0
- package/dist/es/messages/main.d.ts +40 -0
- package/dist/es/messages/main.js +41 -0
- package/dist/es/package-metadata.d.ts +5 -0
- package/dist/es/package-metadata.js +11 -0
- package/dist/es/utils.d.ts +31 -0
- package/dist/es/utils.js +195 -0
- package/dist/esm/ListBox.d.ts +40 -0
- package/dist/esm/ListBox.js +253 -0
- package/dist/esm/ListBoxToolbar.d.ts +40 -0
- package/dist/esm/ListBoxToolbar.js +166 -0
- package/dist/esm/additionalTypes.ts +21 -0
- package/dist/esm/interfaces/Enums.d.ts +7 -0
- package/dist/esm/interfaces/Enums.js +8 -0
- package/dist/esm/interfaces/ListBoxEvents.d.ts +13 -0
- package/dist/esm/interfaces/ListBoxEvents.js +1 -0
- package/dist/esm/interfaces/ListBoxProps.d.ts +93 -0
- package/dist/esm/interfaces/ListBoxProps.js +2 -0
- package/dist/esm/interfaces/ListBoxToolBarProps.d.ts +32 -0
- package/dist/esm/interfaces/ListBoxToolBarProps.js +1 -0
- package/dist/esm/main.d.ts +7 -0
- package/dist/esm/main.js +4 -0
- package/dist/esm/messages/main.d.ts +40 -0
- package/dist/esm/messages/main.js +41 -0
- package/dist/esm/package-metadata.d.ts +5 -0
- package/dist/esm/package-metadata.js +11 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/utils.d.ts +31 -0
- package/dist/esm/utils.js +195 -0
- package/dist/npm/ListBox.d.ts +40 -0
- package/dist/npm/ListBox.js +260 -0
- package/dist/npm/ListBoxToolbar.d.ts +40 -0
- package/dist/npm/ListBoxToolbar.js +173 -0
- package/dist/npm/additionalTypes.ts +21 -0
- package/dist/npm/interfaces/Enums.d.ts +7 -0
- package/dist/npm/interfaces/Enums.js +14 -0
- package/dist/npm/interfaces/ListBoxEvents.d.ts +13 -0
- package/dist/npm/interfaces/ListBoxEvents.js +5 -0
- package/dist/npm/interfaces/ListBoxProps.d.ts +93 -0
- package/dist/npm/interfaces/ListBoxProps.js +3 -0
- package/dist/npm/interfaces/ListBoxToolBarProps.d.ts +32 -0
- package/dist/npm/interfaces/ListBoxToolBarProps.js +5 -0
- package/dist/npm/main.d.ts +7 -0
- package/dist/npm/main.js +11 -0
- package/dist/npm/messages/main.d.ts +40 -0
- package/dist/npm/messages/main.js +44 -0
- package/dist/npm/package-metadata.d.ts +5 -0
- package/dist/npm/package-metadata.js +14 -0
- package/dist/npm/utils.d.ts +31 -0
- package/dist/npm/utils.js +204 -0
- package/package.json +57 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as Vue from 'vue';
|
|
3
|
+
var allVue = Vue;
|
|
4
|
+
var gh = allVue.h;
|
|
5
|
+
var isV3 = allVue.version && allVue.version[0] === '3';
|
|
6
|
+
import { classNames, guid, kendoThemeMaps, validatePackage, templateRendering, getListeners, getTemplate } from '@progress/kendo-vue-common';
|
|
7
|
+
import { toolbarPosition } from './interfaces/Enums';
|
|
8
|
+
import { packageMetadata } from './package-metadata';
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
var ListBoxVue2 = {
|
|
13
|
+
name: 'KendoListBox',
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
emits: {
|
|
16
|
+
dragstart: null,
|
|
17
|
+
itemclick: null,
|
|
18
|
+
drop: null,
|
|
19
|
+
dragover: null,
|
|
20
|
+
keydown: null,
|
|
21
|
+
dragleave: null
|
|
22
|
+
},
|
|
23
|
+
props: {
|
|
24
|
+
size: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'medium',
|
|
27
|
+
validator: function validator(value) {
|
|
28
|
+
return [null, 'small', 'medium', 'large'].includes(value);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
toolbarPosition: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: toolbarPosition.RIGHT,
|
|
34
|
+
validator: function validator(value) {
|
|
35
|
+
return ['none', 'top', 'bottom', 'left', 'right'].includes(value);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
textField: String,
|
|
39
|
+
valueField: String,
|
|
40
|
+
keyField: String,
|
|
41
|
+
selectedField: String,
|
|
42
|
+
item: [String, Object, Function],
|
|
43
|
+
toolbar: [String, Object, Function],
|
|
44
|
+
tabIndex: Number,
|
|
45
|
+
dataItems: {
|
|
46
|
+
type: Array,
|
|
47
|
+
default: function _default() {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
draggable: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
created: function created() {
|
|
57
|
+
validatePackage(packageMetadata);
|
|
58
|
+
},
|
|
59
|
+
computed: {
|
|
60
|
+
wrapperClass: function wrapperClass() {
|
|
61
|
+
var _a;
|
|
62
|
+
var nonePosition = this.$props.toolbarPosition === toolbarPosition.NONE || this.$props.toolbar === undefined;
|
|
63
|
+
return _a = {
|
|
64
|
+
'k-listbox': true
|
|
65
|
+
}, _a["k-listbox-toolbar-".concat(this.$props.toolbarPosition)] = !nonePosition, _a;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
setup: !isV3 ? undefined : function () {
|
|
70
|
+
var v3 = !!isV3;
|
|
71
|
+
return {
|
|
72
|
+
v3: v3
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
render: function render(createElement) {
|
|
77
|
+
var _a;
|
|
78
|
+
var h = gh || createElement;
|
|
79
|
+
var toolbarTemplate = templateRendering.call(this, this.$props.toolbar, getListeners.call(this));
|
|
80
|
+
var toolbarRender = getTemplate.call(this, {
|
|
81
|
+
h: h,
|
|
82
|
+
template: toolbarTemplate
|
|
83
|
+
});
|
|
84
|
+
return h("div", {
|
|
85
|
+
"class": this.wrapperClass,
|
|
86
|
+
unselectable: "on",
|
|
87
|
+
attrs: this.v3 ? undefined : {
|
|
88
|
+
unselectable: "on"
|
|
89
|
+
}
|
|
90
|
+
}, [this.$props.toolbarPosition !== 'bottom' && toolbarRender, h("div", {
|
|
91
|
+
"class": 'k-list-scroller k-selectable',
|
|
92
|
+
"data-role": 'selectable',
|
|
93
|
+
attrs: this.v3 ? undefined : {
|
|
94
|
+
"data-role": 'selectable'
|
|
95
|
+
},
|
|
96
|
+
onDragover: function onDragover(e) {
|
|
97
|
+
return e.preventDefault();
|
|
98
|
+
},
|
|
99
|
+
on: this.v3 ? undefined : {
|
|
100
|
+
"dragover": function onDragover(e) {
|
|
101
|
+
return e.preventDefault();
|
|
102
|
+
},
|
|
103
|
+
"drop": this.handleContainerDrop,
|
|
104
|
+
"dragleave": this.handleOnDragLeave
|
|
105
|
+
},
|
|
106
|
+
onDrop: this.handleContainerDrop,
|
|
107
|
+
onDragleave: this.handleOnDragLeave
|
|
108
|
+
}, [h("div", {
|
|
109
|
+
"class": classNames('k-list', (_a = {}, _a["k-list-".concat(kendoThemeMaps.sizeMap[this.$props.size] || this.$props.size)] = this.$props.size, _a))
|
|
110
|
+
}, [h("div", {
|
|
111
|
+
"class": 'k-list-content'
|
|
112
|
+
}, [h("ul", {
|
|
113
|
+
"class": 'k-list-ul',
|
|
114
|
+
role: 'listbox',
|
|
115
|
+
attrs: this.v3 ? undefined : {
|
|
116
|
+
role: 'listbox',
|
|
117
|
+
"aria-label": 'listbox-container',
|
|
118
|
+
tabIndex: this.tabIndex
|
|
119
|
+
},
|
|
120
|
+
"aria-label": 'listbox-container',
|
|
121
|
+
tabIndex: this.tabIndex,
|
|
122
|
+
onKeydown: this.handleKeyDown,
|
|
123
|
+
on: this.v3 ? undefined : {
|
|
124
|
+
"keydown": this.handleKeyDown
|
|
125
|
+
}
|
|
126
|
+
}, [this.$props.dataItems.map(function (item, index) {
|
|
127
|
+
var _this = this;
|
|
128
|
+
var selectedValue = this.setSelected(item);
|
|
129
|
+
var itemGuid = guid();
|
|
130
|
+
var defaultRendering = h("span", {
|
|
131
|
+
"class": 'k-list-item-text'
|
|
132
|
+
}, [this.$props.textField ? item[this.$props.textField] : item.toString()]);
|
|
133
|
+
var itemTemplate = templateRendering.call(this, this.$props.item, getListeners.call(this));
|
|
134
|
+
var itemRender = getTemplate.call(this, {
|
|
135
|
+
h: h,
|
|
136
|
+
template: itemTemplate,
|
|
137
|
+
defaultRendering: defaultRendering,
|
|
138
|
+
additionalProps: {
|
|
139
|
+
dataItem: item,
|
|
140
|
+
index: index
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return h("li", {
|
|
144
|
+
"class": classNames('k-list-item', {
|
|
145
|
+
'k-selected': selectedValue
|
|
146
|
+
}, item.class),
|
|
147
|
+
style: item.style,
|
|
148
|
+
role: 'option',
|
|
149
|
+
attrs: this.v3 ? undefined : {
|
|
150
|
+
role: 'option',
|
|
151
|
+
"aria-selected": selectedValue,
|
|
152
|
+
id: itemGuid + index,
|
|
153
|
+
"data-uid": itemGuid + index,
|
|
154
|
+
draggable: this.$props.draggable
|
|
155
|
+
},
|
|
156
|
+
"aria-selected": selectedValue,
|
|
157
|
+
key: this.$props.keyField ? item[this.$props.keyField] : index,
|
|
158
|
+
id: itemGuid + index,
|
|
159
|
+
"data-uid": itemGuid + index,
|
|
160
|
+
draggable: this.$props.draggable,
|
|
161
|
+
onDragstart: function onDragstart(event) {
|
|
162
|
+
return _this.dispatchEvent('dragstart', event, item);
|
|
163
|
+
},
|
|
164
|
+
on: this.v3 ? undefined : {
|
|
165
|
+
"dragstart": function onDragstart(event) {
|
|
166
|
+
return _this.dispatchEvent('dragstart', event, item);
|
|
167
|
+
},
|
|
168
|
+
"dragOver": function dragOver(event) {
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
_this.dispatchEvent('dragover', event, item);
|
|
171
|
+
},
|
|
172
|
+
"drop": function drop(event) {
|
|
173
|
+
return _this.dispatchEvent('drop', event, item);
|
|
174
|
+
},
|
|
175
|
+
"click": function click(event) {
|
|
176
|
+
return _this.dispatchEvent('itemclick', event, item);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
onDragOver: function dragOver(event) {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
_this.dispatchEvent('dragover', event, item);
|
|
182
|
+
},
|
|
183
|
+
onDrop: function drop(event) {
|
|
184
|
+
return _this.dispatchEvent('drop', event, item);
|
|
185
|
+
},
|
|
186
|
+
onClick: function click(event) {
|
|
187
|
+
return _this.dispatchEvent('itemclick', event, item);
|
|
188
|
+
}
|
|
189
|
+
}, [itemRender]);
|
|
190
|
+
}, this)])])])]), this.$props.toolbarPosition === 'bottom' && toolbarRender, h("select", {
|
|
191
|
+
style: {
|
|
192
|
+
display: 'none'
|
|
193
|
+
},
|
|
194
|
+
multiple: true,
|
|
195
|
+
attrs: this.v3 ? undefined : {
|
|
196
|
+
multiple: true,
|
|
197
|
+
"data-role": "listbox"
|
|
198
|
+
},
|
|
199
|
+
"data-role": "listbox"
|
|
200
|
+
}, [this.$props.dataItems.map(function (item, index) {
|
|
201
|
+
var value = item[this.$props.valueField || this.$props.textField];
|
|
202
|
+
return h("option", {
|
|
203
|
+
key: index,
|
|
204
|
+
value: this.v3 ? value : null,
|
|
205
|
+
domProps: this.v3 ? undefined : {
|
|
206
|
+
"value": value
|
|
207
|
+
}
|
|
208
|
+
}, [value]);
|
|
209
|
+
}, this)])]);
|
|
210
|
+
},
|
|
211
|
+
methods: {
|
|
212
|
+
dispatchEvent: function dispatchEvent(eventName, event, item) {
|
|
213
|
+
this.$emit(eventName, {
|
|
214
|
+
event: event,
|
|
215
|
+
component: this,
|
|
216
|
+
dataItem: item
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
setSelected: function setSelected(item) {
|
|
220
|
+
if (this.$props.selectedField) {
|
|
221
|
+
return item[this.$props.selectedField] ? true : false;
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
handleKeyDown: function handleKeyDown(event) {
|
|
225
|
+
this.$emit('keydown', {
|
|
226
|
+
event: event,
|
|
227
|
+
component: this
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
handleContainerDrop: function handleContainerDrop(event) {
|
|
231
|
+
var targetElement = event.target;
|
|
232
|
+
var isTargetContainer = targetElement.classList.contains('k-list-scroller');
|
|
233
|
+
var items = this.$props.dataItems;
|
|
234
|
+
if (isTargetContainer) {
|
|
235
|
+
this.$emit('drop', {
|
|
236
|
+
event: event,
|
|
237
|
+
component: this,
|
|
238
|
+
dataItem: items.length > 0 ? items[items.length - 1] : null
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
handleOnDragLeave: function handleOnDragLeave(event) {
|
|
243
|
+
if (this.$props.onDragLeave && event.target.classList.contains('k-list-scroller')) {
|
|
244
|
+
this.$emit('dragleave', {
|
|
245
|
+
event: event,
|
|
246
|
+
component: this
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
var ListBox = ListBoxVue2;
|
|
253
|
+
export { ListBox, ListBoxVue2 };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DefineComponent } from './additionalTypes';
|
|
2
|
+
import { RecordPropsDefinition, ComponentOptions } from 'vue/types/options';
|
|
3
|
+
declare type DefaultData<V> = object | ((this: V) => {});
|
|
4
|
+
declare type DefaultMethods<V> = {
|
|
5
|
+
[key: string]: (this: V, ...args: any[]) => any;
|
|
6
|
+
};
|
|
7
|
+
import { ListBoxToolbarProps } from './interfaces/ListBoxToolBarProps';
|
|
8
|
+
/**
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export interface ListBoxToolbarState {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
export interface ListBoxToolbarComputed {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
export interface ListBoxToolbarMethods {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
28
|
+
export interface ListBoxToolbarData {
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
33
|
+
export interface ListBoxToolbarAll extends Vue, ListBoxToolbarMethods, ListBoxToolbarData, ListBoxToolbarComputed, ListBoxToolbarState {
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @hidden
|
|
37
|
+
*/
|
|
38
|
+
declare let ListBoxToolbarVue2: ComponentOptions<ListBoxToolbarAll, DefaultData<ListBoxToolbarData>, DefaultMethods<ListBoxToolbarAll>, ListBoxToolbarComputed, RecordPropsDefinition<ListBoxToolbarProps>>;
|
|
39
|
+
declare const ListBoxToolbar: DefineComponent<ListBoxToolbarProps, any, ListBoxToolbarData, ListBoxToolbarComputed, ListBoxToolbarMethods, {}, {}, {}, string, ListBoxToolbarProps, ListBoxToolbarProps, {}>;
|
|
40
|
+
export { ListBoxToolbar, ListBoxToolbarVue2 };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as Vue from 'vue';
|
|
3
|
+
var allVue = Vue;
|
|
4
|
+
var gh = allVue.h;
|
|
5
|
+
var isV3 = allVue.version && allVue.version[0] === '3';
|
|
6
|
+
import { Button } from '@progress/kendo-vue-buttons';
|
|
7
|
+
import { provideLocalizationService } from '@progress/kendo-vue-intl';
|
|
8
|
+
import { messages } from './messages/main';
|
|
9
|
+
var tools = [{
|
|
10
|
+
name: 'moveUp',
|
|
11
|
+
iconName: 'caret-alt-up'
|
|
12
|
+
}, {
|
|
13
|
+
name: 'moveDown',
|
|
14
|
+
iconName: 'caret-alt-down'
|
|
15
|
+
}, {
|
|
16
|
+
name: 'transferTo',
|
|
17
|
+
iconName: 'caret-alt-right'
|
|
18
|
+
}, {
|
|
19
|
+
name: 'transferFrom',
|
|
20
|
+
iconName: 'caret-alt-left'
|
|
21
|
+
}, {
|
|
22
|
+
name: 'transferAllTo',
|
|
23
|
+
iconName: 'caret-double-alt-right'
|
|
24
|
+
}, {
|
|
25
|
+
name: 'transferAllFrom',
|
|
26
|
+
iconName: 'caret-double-alt-left'
|
|
27
|
+
}, {
|
|
28
|
+
name: 'remove',
|
|
29
|
+
iconName: 'x'
|
|
30
|
+
}];
|
|
31
|
+
/**
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
var ListBoxToolbarVue2 = {
|
|
35
|
+
name: 'KendoListBoxToolbar',
|
|
36
|
+
props: {
|
|
37
|
+
dataItems: Array,
|
|
38
|
+
dataConnected: Array,
|
|
39
|
+
tools: Array,
|
|
40
|
+
selectedField: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: 'selected'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
inject: {
|
|
46
|
+
kendoLocalizationService: {
|
|
47
|
+
default: null
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
setup: !isV3 ? undefined : function () {
|
|
52
|
+
var v3 = !!isV3;
|
|
53
|
+
return {
|
|
54
|
+
v3: v3
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
render: function render(createElement) {
|
|
59
|
+
var h = gh || createElement;
|
|
60
|
+
var localizationService = provideLocalizationService(this);
|
|
61
|
+
return h("div", {
|
|
62
|
+
"class": 'k-listbox-toolbar'
|
|
63
|
+
}, [h("ul", {
|
|
64
|
+
"class": "k-reset"
|
|
65
|
+
}, [this.$props.tools && this.$props.tools.map(function (tool, index) {
|
|
66
|
+
var _this = this;
|
|
67
|
+
var indexOfTool = tools.findIndex(function (x) {
|
|
68
|
+
return x.name === tool;
|
|
69
|
+
});
|
|
70
|
+
var currentTool = tools[indexOfTool];
|
|
71
|
+
var isDisabled = this.isItemDisabled(currentTool.name);
|
|
72
|
+
var toolKey = "listbox.".concat(currentTool.name);
|
|
73
|
+
var title = localizationService.toLanguageString(toolKey, messages[toolKey]);
|
|
74
|
+
return h("li", {
|
|
75
|
+
key: index
|
|
76
|
+
}, [h(Button, {
|
|
77
|
+
disabled: isDisabled,
|
|
78
|
+
attrs: this.v3 ? undefined : {
|
|
79
|
+
disabled: isDisabled,
|
|
80
|
+
"data-command": currentTool.name,
|
|
81
|
+
title: title,
|
|
82
|
+
"aria-label": title,
|
|
83
|
+
icon: currentTool.iconName
|
|
84
|
+
},
|
|
85
|
+
"data-command": currentTool.name,
|
|
86
|
+
title: title,
|
|
87
|
+
"aria-label": title,
|
|
88
|
+
icon: currentTool.iconName,
|
|
89
|
+
onClick: function onClick(e) {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
_this.handleToolClick(e, currentTool.name || null);
|
|
92
|
+
},
|
|
93
|
+
on: this.v3 ? undefined : {
|
|
94
|
+
"click": function onClick(e) {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
_this.handleToolClick(e, currentTool.name || null);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
})]);
|
|
100
|
+
}, this)])]);
|
|
101
|
+
},
|
|
102
|
+
methods: {
|
|
103
|
+
handleToolClick: function handleToolClick(event, name) {
|
|
104
|
+
this.$emit('toolclick', {
|
|
105
|
+
event: event,
|
|
106
|
+
component: this,
|
|
107
|
+
toolName: name
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
isItemDisabled: function isItemDisabled(tool) {
|
|
111
|
+
var disabled = true;
|
|
112
|
+
var selectedField = this.$props.selectedField || 'selected';
|
|
113
|
+
var dataLength = this.$props.dataItems.length;
|
|
114
|
+
var dataConnectedLength = this.$props.dataConnected.length;
|
|
115
|
+
var hasSelected = this.$props.dataItems.findIndex(function (item) {
|
|
116
|
+
return item[selectedField] === true;
|
|
117
|
+
}) >= 0;
|
|
118
|
+
var hasSelectedTwo = this.$props.dataConnected.findIndex(function (item) {
|
|
119
|
+
return item[selectedField] === true;
|
|
120
|
+
}) >= 0;
|
|
121
|
+
switch (tool) {
|
|
122
|
+
case 'moveUp':
|
|
123
|
+
if (hasSelected) {
|
|
124
|
+
disabled = this.$props.dataItems.length > 0 ? this.$props.dataItems[0].selected : true;
|
|
125
|
+
} else if (hasSelectedTwo) {
|
|
126
|
+
disabled = this.$props.dataConnected.length > 0 ? this.$props.dataConnected[0].selected : true;
|
|
127
|
+
} else {
|
|
128
|
+
disabled = true;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case 'moveDown':
|
|
132
|
+
if (hasSelected) {
|
|
133
|
+
disabled = this.$props.dataItems[dataLength - 1] ? this.$props.dataItems[dataLength - 1].selectedField : true;
|
|
134
|
+
} else if (hasSelectedTwo) {
|
|
135
|
+
disabled = this.$props.dataConnected.length > 0 ? this.$props.dataConnected[dataConnectedLength - 1].selected : true;
|
|
136
|
+
} else {
|
|
137
|
+
disabled = true;
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case 'transferTo':
|
|
141
|
+
disabled = !(this.$props.dataConnected && hasSelected);
|
|
142
|
+
break;
|
|
143
|
+
case 'transferFrom':
|
|
144
|
+
if (this.$props.dataConnected) {
|
|
145
|
+
disabled = !(this.$props.dataConnected && hasSelectedTwo);
|
|
146
|
+
} else {
|
|
147
|
+
disabled = true;
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
case 'transferAllTo':
|
|
151
|
+
disabled = !(this.$props.dataConnected && this.$props.dataItems.length > 0);
|
|
152
|
+
break;
|
|
153
|
+
case 'transferAllFrom':
|
|
154
|
+
disabled = !(this.$props.dataConnected && this.$props.dataConnected.length > 0);
|
|
155
|
+
break;
|
|
156
|
+
case 'remove':
|
|
157
|
+
disabled = !(hasSelected || hasSelectedTwo);
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
}
|
|
161
|
+
return disabled;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
var ListBoxToolbar = ListBoxToolbarVue2;
|
|
166
|
+
export { ListBoxToolbar, ListBoxToolbarVue2 };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { DefineComponent } from 'vue';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import * as Vue from 'vue';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
type Vue2type = Vue.default;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
import { RecordPropsDefinition, ComponentOptions } from 'vue/types/options';
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
export { DefineComponent, RecordPropsDefinition, ComponentOptions, Vue2type };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var toolbarPosition;
|
|
2
|
+
(function (toolbarPosition) {
|
|
3
|
+
toolbarPosition["TOP"] = "top";
|
|
4
|
+
toolbarPosition["BOTTOM"] = "bottom";
|
|
5
|
+
toolbarPosition["LEFT"] = "left";
|
|
6
|
+
toolbarPosition["RIGHT"] = "right";
|
|
7
|
+
toolbarPosition["NONE"] = "none";
|
|
8
|
+
})(toolbarPosition || (toolbarPosition = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ListBoxItemClickEvent {
|
|
2
|
+
dataItem?: any;
|
|
3
|
+
}
|
|
4
|
+
export interface ListBoxKeyDownEvent {
|
|
5
|
+
}
|
|
6
|
+
export interface ListBoxDragLeaveEvent {
|
|
7
|
+
}
|
|
8
|
+
export interface ListBoxToolbarClickEvent {
|
|
9
|
+
toolName?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ListBoxDragEvent {
|
|
12
|
+
dataItem?: any;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ListBoxItemClickEvent, ListBoxKeyDownEvent, ListBoxDragEvent, ListBoxDragLeaveEvent } from './ListBoxEvents';
|
|
2
|
+
import { toolbarPosition } from './Enums';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the props of the [Kendo UI for Vue ListBox component]({% slug overview_listbox %}).
|
|
5
|
+
*/
|
|
6
|
+
export interface ListBoxProps {
|
|
7
|
+
/**
|
|
8
|
+
* Sets a class of the Tooltip animation container.
|
|
9
|
+
*/
|
|
10
|
+
className?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Configures the `size` of the ListBox.
|
|
13
|
+
*
|
|
14
|
+
* The available options are:
|
|
15
|
+
* - small
|
|
16
|
+
* - medium
|
|
17
|
+
* - large
|
|
18
|
+
* - null—Does not set a size `className`.
|
|
19
|
+
*
|
|
20
|
+
* @default `medium`
|
|
21
|
+
*/
|
|
22
|
+
size?: null | 'small' | 'medium' | 'large' | string;
|
|
23
|
+
/**
|
|
24
|
+
* Set the data of the ListBox.
|
|
25
|
+
*/
|
|
26
|
+
dataItems: Array<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Makes the items of the ListBox draggable. The items are draggable by default.
|
|
29
|
+
*/
|
|
30
|
+
draggable?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Set the selected field of the ListBox. Based on that value of that field, an item will be selected or not.
|
|
33
|
+
*/
|
|
34
|
+
selectedField?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the data item field that represents the item text. If the data contains only primitive values, do not define it.
|
|
37
|
+
*/
|
|
38
|
+
textField: string;
|
|
39
|
+
/**
|
|
40
|
+
* The field that be used during form submit. Defaults to the textField if not set.
|
|
41
|
+
*/
|
|
42
|
+
valueField?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The field that is used for rendering key of the items.
|
|
45
|
+
*/
|
|
46
|
+
keyField?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Sets the position of the toolbar of the ListBox if one is set. The ListBox may have no toolbar.
|
|
49
|
+
* * The possible values are:
|
|
50
|
+
* * `top`
|
|
51
|
+
* * `bottom`
|
|
52
|
+
* * `left`
|
|
53
|
+
* * `right` (Default)
|
|
54
|
+
* * `none`
|
|
55
|
+
*/
|
|
56
|
+
toolbarPosition?: toolbarPosition | string;
|
|
57
|
+
/**
|
|
58
|
+
* Renders a toolbar component next to the ListBox.
|
|
59
|
+
*/
|
|
60
|
+
toolbar?: string | object | Function;
|
|
61
|
+
/**
|
|
62
|
+
* Sets the `tabIndex` attribute of the ListBox.
|
|
63
|
+
*/
|
|
64
|
+
tabIndex?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Defines the component that will be rendered for each item of the data collection.
|
|
67
|
+
*/
|
|
68
|
+
item?: string | object | Function;
|
|
69
|
+
/**
|
|
70
|
+
* Fires when an item from the ListBox is clicked. Contains the clicked item.
|
|
71
|
+
*/
|
|
72
|
+
onItemclick?: (event: ListBoxItemClickEvent) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Fires on keydown over the ListBox list items. It can be use to add keyboard extra keyboard navigation option.
|
|
75
|
+
*/
|
|
76
|
+
onKeydown?: (event: ListBoxKeyDownEvent) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Fires when an the user start to drag an item from the ListBox. The event contains information for the item that is being dragged.
|
|
79
|
+
*/
|
|
80
|
+
onDragstart?: (event: ListBoxDragEvent) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Fires when an the user drags over an item from the ListBox. The event contains information for the item that is dragged over.
|
|
83
|
+
*/
|
|
84
|
+
onDragover?: (event: ListBoxDragEvent) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Fires when an the user drops an item. The event contains information for the drop target item.
|
|
87
|
+
*/
|
|
88
|
+
onDrop?: (event: ListBoxDragEvent) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Fires when a dragged element or text selection leaves the ListBox element.
|
|
91
|
+
*/
|
|
92
|
+
onDragleave?: (event: ListBoxDragLeaveEvent) => void;
|
|
93
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ListBoxToolbarClickEvent } from './ListBoxEvents';
|
|
2
|
+
export interface ListBoxToolbarProps {
|
|
3
|
+
/**
|
|
4
|
+
* Sets the tools of the ListBoxToolbar. By default, the ListBoxToolbar renders no tools.
|
|
5
|
+
* The built-in tools are:
|
|
6
|
+
* * `moveUp`
|
|
7
|
+
* * `moveDown`
|
|
8
|
+
* * `transferTo`
|
|
9
|
+
* * `transferFrom`
|
|
10
|
+
* * `transferAllTo`
|
|
11
|
+
* * `transferAllFrom`
|
|
12
|
+
* * `remove`
|
|
13
|
+
*/
|
|
14
|
+
tools?: Array<string>;
|
|
15
|
+
/**
|
|
16
|
+
* The data of the main ListBox.
|
|
17
|
+
*/
|
|
18
|
+
dataItems: Array<any>;
|
|
19
|
+
/**
|
|
20
|
+
* The data of the connected ListBox.
|
|
21
|
+
*/
|
|
22
|
+
dataConnected: Array<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Set the selected field of the ListBoxToolbar.
|
|
25
|
+
* Based on that value of that field the ListBoxToolbar will determine which actions are allowed and which disabled.
|
|
26
|
+
*/
|
|
27
|
+
selectedField?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Fires when one of the ListBoxToolbar tools is clicked.
|
|
30
|
+
*/
|
|
31
|
+
onToolclick?: (event: ListBoxToolbarClickEvent) => void;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ListBox } from './ListBox';
|
|
2
|
+
import { ListBoxProps } from './interfaces/ListBoxProps';
|
|
3
|
+
import { ListBoxToolbar } from './ListBoxToolbar';
|
|
4
|
+
import { ListBoxToolbarProps } from './interfaces/ListBoxToolBarProps';
|
|
5
|
+
import { processListBoxData, moveItem, processListBoxDragAndDrop } from './utils';
|
|
6
|
+
import { ListBoxDragEvent, ListBoxItemClickEvent, ListBoxKeyDownEvent, ListBoxToolbarClickEvent } from './interfaces/ListBoxEvents';
|
|
7
|
+
export { ListBox, ListBoxProps, ListBoxToolbar, ListBoxToolbarProps, processListBoxData, moveItem, processListBoxDragAndDrop, ListBoxDragEvent, ListBoxItemClickEvent, ListBoxKeyDownEvent, ListBoxToolbarClickEvent };
|
package/dist/es/main.js
ADDED