e355dd49
梁灏
add Select Component
|
1
|
<template>
|
2fbe636b
梁灏
Select support a ...
|
2
|
<div
|
2fbe636b
梁灏
Select support a ...
|
3
|
:class="classes"
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
4
|
v-click-outside.capture="onClickOutside"
|
4a9974f6
Graham Fairweather
Normalise v-ckick...
|
5
|
v-click-outside:mousedown.capture="onClickOutside"
|
69c2de7a
Роман Ковжогин
iOS click-outside...
|
6
|
v-click-outside:touchstart.capture="onClickOutside"
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
7
|
>
|
e355dd49
梁灏
add Select Component
|
8
|
<div
|
4aec6a66
梁灏
support Select
|
9
|
ref="reference"
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
10
11
12
13
14
15
16
17
18
19
|
:class="selectionCls"
:tabindex="selectTabindex"
@blur="toggleHeaderFocus"
@focus="toggleHeaderFocus"
@click="toggleMenu"
@keydown.esc="handleKeydown"
@keydown.enter="handleKeydown"
|
66f807ed
梁灏
update Select
|
20
21
|
@keydown.up.prevent="handleKeydown"
@keydown.down.prevent="handleKeydown"
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
22
23
24
25
26
27
28
29
|
@keydown.tab="handleKeydown"
@keydown.delete="handleKeydown"
@mouseenter="hasMouseHoverHead = true"
@mouseleave="hasMouseHoverHead = false"
>
|
fed3e09d
梁灏
add AutoComplete ...
|
30
|
<slot name="input">
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
31
32
33
34
35
36
|
<input type="hidden" :name="name" :value="publicValue">
<select-head
:filterable="filterable"
:multiple="multiple"
:values="values"
:clearable="canBeCleared"
|
2739fc29
梁灏
Select add prefix...
|
37
|
:prefix="prefix"
|
fed3e09d
梁灏
add AutoComplete ...
|
38
|
:disabled="disabled"
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
39
40
41
42
43
|
:remote="remote"
:input-element-id="elementId"
:initial-label="initialLabel"
:placeholder="placeholder"
:query-prop="query"
|
90399f84
梁灏
fix #5568 ,close ...
|
44
45
|
:max-tag-count="maxTagCount"
:max-tag-placeholder="maxTagPlaceholder"
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
46
47
48
49
|
@on-query-change="onQueryChange"
@on-input-focus="isFocused = true"
@on-input-blur="isFocused = false"
|
7dbde804
Sergio Crisostomo
add on-clear event
|
50
|
@on-clear="clearSingleSelect"
|
2739fc29
梁灏
Select add prefix...
|
51
52
53
|
>
<slot name="prefix" slot="prefix"></slot>
</select-head>
|
fed3e09d
梁灏
add AutoComplete ...
|
54
|
</slot>
|
e355dd49
梁灏
add Select Component
|
55
|
</div>
|
e09b07b7
huanghong
解决drop弹出动画异常
|
56
|
<transition name="transition-drop">
|
595cfa72
梁灏
fixed #1187 #844 ...
|
57
|
<Drop
|
ecaf8d51
梁灏
Date add transfer...
|
58
|
:class="dropdownCls"
|
595cfa72
梁灏
fixed #1187 #844 ...
|
59
60
61
62
|
v-show="dropVisible"
:placement="placement"
ref="dropdown"
:data-transfer="transfer"
|
7bafe9d9
梁灏
fixes #4453 #4480...
|
63
|
:transfer="transfer"
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
64
65
66
67
|
v-transfer-dom
>
<ul v-show="showNotFoundLabel" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul>
<ul :class="prefixCls + '-dropdown-list'">
|
220161f5
Sergio Crisostomo
Clean up empty/nu...
|
68
69
70
71
72
73
|
<functional-options
v-if="(!remote) || (remote && !loading)"
:options="selectOptions"
:slot-update-hook="updateSlotOptions"
:slot-options="slotOptions"
></functional-options>
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
74
|
</ul>
|
01b54e30
梁灏
Select support re...
|
75
|
<ul v-show="loading" :class="[prefixCls + '-loading']">{{ localeLoadingText }}</ul>
|
4aec6a66
梁灏
support Select
|
76
77
|
</Drop>
</transition>
|
e355dd49
梁灏
add Select Component
|
78
79
80
|
</div>
</template>
<script>
|
4aec6a66
梁灏
support Select
|
81
|
import Drop from './dropdown.vue';
|
26369639
Graham Fairweather
Update v-click-ou...
|
82
|
import {directive as clickOutside} from 'v-click-outside-x';
|
595cfa72
梁灏
fixed #1187 #844 ...
|
83
|
import TransferDom from '../../directives/transfer-dom';
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
84
|
import { oneOf } from '../../utils/assist';
|
4aec6a66
梁灏
support Select
|
85
|
import Emitter from '../../mixins/emitter';
|
e5337c81
梁灏
fixed some compon...
|
86
|
import Locale from '../../mixins/locale';
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
87
88
|
import SelectHead from './select-head.vue';
import FunctionalOptions from './functional-options.vue';
|
e355dd49
梁灏
add Select Component
|
89
90
|
const prefixCls = 'ivu-select';
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
91
|
const optionRegexp = /^i-option$|^Option$/i;
|
523e2c81
Sergio Crisostomo
correct match log...
|
92
|
const optionGroupRegexp = /option-?group/i;
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
93
94
95
96
97
98
99
100
101
102
|
const findChild = (instance, checkFn) => {
let match = checkFn(instance);
if (match) return instance;
for (let i = 0, l = instance.$children.length; i < l; i++){
const child = instance.$children[i];
match = findChild(child, checkFn);
if (match) return match;
}
};
|
e355dd49
梁灏
add Select Component
|
103
|
|
06a74f9e
Sergio Crisostomo
Allow select to n...
|
104
105
|
const findOptionsInVNode = (node) => {
const opts = node.componentOptions;
|
523e2c81
Sergio Crisostomo
correct match log...
|
106
|
if (opts && opts.tag.match(optionRegexp)) return [node];
|
7d14e70c
Sergio Crisostomo
Include both node...
|
107
|
if (!node.children && (!opts || !opts.children)) return [];
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
108
|
const children = [...(node.children || []), ...(opts && opts.children || [])];
|
7d14e70c
Sergio Crisostomo
Include both node...
|
109
|
const options = children.reduce(
|
06a74f9e
Sergio Crisostomo
Allow select to n...
|
110
111
112
113
114
115
116
117
118
|
(arr, el) => [...arr, ...findOptionsInVNode(el)], []
).filter(Boolean);
return options.length > 0 ? options : [];
};
const extractOptions = (options) => options.reduce((options, slotEntry) => {
return options.concat(findOptionsInVNode(slotEntry));
}, []);
|
aa21cdf9
Sergio Crisostomo
Process also shal...
|
119
120
121
122
123
124
125
126
127
128
129
130
131
|
const applyProp = (node, propName, value) => {
return {
...node,
componentOptions: {
...node.componentOptions,
propsData: {
...node.componentOptions.propsData,
[propName]: value,
}
}
};
};
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
132
133
134
135
136
137
|
const getNestedProperty = (obj, path) => {
const keys = path.split('.');
return keys.reduce((o, key) => o && o[key] || null, obj);
};
const getOptionLabel = option => {
|
1b39f569
Sergio Crisostomo
Use label first i...
|
138
|
if (option.componentOptions.propsData.label) return option.componentOptions.propsData.label;
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
139
140
|
const textContent = (option.componentOptions.children || []).reduce((str, child) => str + (child.text || ''), '');
const innerHTML = getNestedProperty(option, 'data.domProps.innerHTML');
|
1b39f569
Sergio Crisostomo
Use label first i...
|
141
|
return textContent || (typeof innerHTML === 'string' ? innerHTML : '');
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
142
143
|
};
|
cd8f1be8
任珽
fixed bug #4466 #...
|
144
145
146
147
148
149
150
151
152
|
const checkValuesNotEqual = (value,publicValue,values) => {
const strValue = JSON.stringify(value);
const strPublic = JSON.stringify(publicValue);
const strValues = JSON.stringify(values.map( item => {
return item.value;
}));
return strValue !== strPublic || strValue !== strValues || strValues !== strPublic;
};
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
153
|
|
31788df3
Sergio Crisostomo
Normalise behavio...
|
154
155
|
const ANIMATION_TIMEOUT = 300;
|
e355dd49
梁灏
add Select Component
|
156
|
export default {
|
8f5b1686
梁灏
fixed #196
|
157
|
name: 'iSelect',
|
e5337c81
梁灏
fixed some compon...
|
158
|
mixins: [ Emitter, Locale ],
|
9eba26fe
梁灏
update Select Icons
|
159
|
components: { FunctionalOptions, Drop, SelectHead },
|
26369639
Graham Fairweather
Update v-click-ou...
|
160
|
directives: { clickOutside, TransferDom },
|
e355dd49
梁灏
add Select Component
|
161
|
props: {
|
4aec6a66
梁灏
support Select
|
162
|
value: {
|
e355dd49
梁灏
add Select Component
|
163
164
165
|
type: [String, Number, Array],
default: ''
},
|
98bf25b3
梁灏
fixed #1286
|
166
|
// 使用时,也得设置 value 才行
|
ddc35c9a
梁灏
fixed #952
|
167
168
169
170
|
label: {
type: [String, Number, Array],
default: ''
},
|
e355dd49
梁灏
add Select Component
|
171
172
173
174
175
176
177
178
179
180
181
182
183
|
multiple: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
clearable: {
type: Boolean,
default: false
},
placeholder: {
|
e5337c81
梁灏
fixed some compon...
|
184
|
type: String
|
e355dd49
梁灏
add Select Component
|
185
186
187
188
189
190
191
192
|
},
filterable: {
type: Boolean,
default: false
},
filterMethod: {
type: Function
},
|
01b54e30
梁灏
Select support re...
|
193
194
195
196
197
198
199
200
201
202
|
remoteMethod: {
type: Function
},
loading: {
type: Boolean,
default: false
},
loadingText: {
type: String
},
|
e355dd49
梁灏
add Select Component
|
203
204
|
size: {
validator (value) {
|
6932b4d7
梁灏
update Page compo...
|
205
|
return oneOf(value, ['small', 'large', 'default']);
|
be2c3198
梁灏
Select support gl...
|
206
207
|
},
default () {
|
fe5ffd7f
梁灏
fixed #4196 #4165
|
208
|
return !this.$IVIEW || this.$IVIEW.size === '' ? 'default' : this.$IVIEW.size;
|
e355dd49
梁灏
add Select Component
|
209
210
211
212
213
|
}
},
labelInValue: {
type: Boolean,
default: false
|
294e2412
梁灏
update Select com...
|
214
215
|
},
notFoundText: {
|
e5337c81
梁灏
fixed some compon...
|
216
|
type: String
|
f89dd9c2
梁灏
Paeg、Select add p...
|
217
218
219
|
},
placement: {
validator (value) {
|
74ef0a6a
梁灏
fixed #4194
|
220
|
return oneOf(value, ['top', 'bottom', 'top-start', 'bottom-start', 'top-end', 'bottom-end']);
|
f89dd9c2
梁灏
Paeg、Select add p...
|
221
|
},
|
74ef0a6a
梁灏
fixed #4194
|
222
|
default: 'bottom-start'
|
595cfa72
梁灏
fixed #1187 #844 ...
|
223
224
225
|
},
transfer: {
type: Boolean,
|
517917a2
梁灏
add global settin...
|
226
|
default () {
|
fe5ffd7f
梁灏
fixed #4196 #4165
|
227
|
return !this.$IVIEW || this.$IVIEW.transfer === '' ? false : this.$IVIEW.transfer;
|
517917a2
梁灏
add global settin...
|
228
|
}
|
fed3e09d
梁灏
add AutoComplete ...
|
229
230
231
232
233
|
},
// Use for AutoComplete
autoComplete: {
type: Boolean,
default: false
|
0460a1e8
梁灏
fixed #812
|
234
235
236
|
},
name: {
type: String
|
acb79ba3
梁灏
fixed #433
|
237
238
239
|
},
elementId: {
type: String
|
202c2cf3
梁灏
Select add prop t...
|
240
241
242
243
|
},
transferClassName: {
type: String
},
|
90399f84
梁灏
fix #5568 ,close ...
|
244
|
// 3.4.0
|
2739fc29
梁灏
Select add prefix...
|
245
246
247
|
prefix: {
type: String
},
|
90399f84
梁灏
fix #5568 ,close ...
|
248
249
250
251
252
253
|
// 3.4.0
maxTagCount: {
type: Number
},
// 3.4.0
maxTagPlaceholder: {
|
38b5b760
梁灏
update Select max...
|
254
|
type: Function
|
90399f84
梁灏
fix #5568 ,close ...
|
255
|
}
|
e355dd49
梁灏
add Select Component
|
256
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
257
258
259
260
|
mounted(){
this.$on('on-select-selected', this.onOptionClick);
// set the initial values if there are any
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
261
262
263
264
265
|
if (!this.remote && this.selectOptions.length > 0){
this.values = this.getInitialValue().map(value => {
if (typeof value !== 'number' && !value) return null;
return this.getOptionData(value);
}).filter(Boolean);
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
266
|
}
|
7f63e58c
Sergio Crisostomo
Make possible for...
|
267
|
|
73b01ee0
郑敏
fixed #3722 that ...
|
268
|
this.checkUpdateStatus();
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
269
|
},
|
e355dd49
梁灏
add Select Component
|
270
|
data () {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
271
|
|
e355dd49
梁灏
add Select Component
|
272
273
|
return {
prefixCls: prefixCls,
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
274
|
values: [],
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
275
|
dropDownWidth: 0,
|
e355dd49
梁灏
add Select Component
|
276
|
visible: false,
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
277
278
|
focusIndex: -1,
isFocused: false,
|
e355dd49
梁灏
add Select Component
|
279
|
query: '',
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
280
281
282
283
284
|
initialLabel: this.label,
hasMouseHoverHead: false,
slotOptions: this.$slots.default,
caretPosition: -1,
lastRemoteQuery: '',
|
31788df3
Sergio Crisostomo
Normalise behavio...
|
285
|
unchangedQuery: true,
|
7f63e58c
Sergio Crisostomo
Make possible for...
|
286
|
hasExpectedValue: false,
|
45bcc14d
Sergio Crisostomo
prevent calling r...
|
287
|
preventRemoteCall: false,
|
e7327532
vincentfintend
fix select
|
288
|
filterQueryChange: false, // #4273
|
b0893113
jingsam
add eslint
|
289
|
};
|
e355dd49
梁灏
add Select Component
|
290
291
292
293
|
},
computed: {
classes () {
return [
|
4b7138b9
梁灏
fixed some bugs
|
294
|
`${prefixCls}`,
|
e355dd49
梁灏
add Select Component
|
295
|
{
|
4b7138b9
梁灏
fixed some bugs
|
296
297
298
299
300
301
|
[`${prefixCls}-visible`]: this.visible,
[`${prefixCls}-disabled`]: this.disabled,
[`${prefixCls}-multiple`]: this.multiple,
[`${prefixCls}-single`]: !this.multiple,
[`${prefixCls}-show-clear`]: this.showCloseIcon,
[`${prefixCls}-${this.size}`]: !!this.size
|
e355dd49
梁灏
add Select Component
|
302
|
}
|
b0893113
jingsam
add eslint
|
303
|
];
|
e355dd49
梁灏
add Select Component
|
304
|
},
|
ecaf8d51
梁灏
Date add transfer...
|
305
306
307
|
dropdownCls () {
return {
[prefixCls + '-dropdown-transfer']: this.transfer,
|
fed3e09d
梁灏
add AutoComplete ...
|
308
309
|
[prefixCls + '-multiple']: this.multiple && this.transfer,
['ivu-auto-complete']: this.autoComplete,
|
202c2cf3
梁灏
Select add prop t...
|
310
|
[this.transferClassName]: this.transferClassName
|
fed3e09d
梁灏
add AutoComplete ...
|
311
312
313
314
|
};
},
selectionCls () {
return {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
315
316
|
[`${prefixCls}-selection`]: !this.autoComplete,
[`${prefixCls}-selection-focused`]: this.isFocused
|
ecaf8d51
梁灏
Date add transfer...
|
317
318
|
};
},
|
e5337c81
梁灏
fixed some compon...
|
319
|
localeNotFoundText () {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
320
|
if (typeof this.notFoundText === 'undefined') {
|
e5337c81
梁灏
fixed some compon...
|
321
322
323
324
|
return this.t('i.select.noMatch');
} else {
return this.notFoundText;
}
|
f89dd9c2
梁灏
Paeg、Select add p...
|
325
|
},
|
01b54e30
梁灏
Select support re...
|
326
|
localeLoadingText () {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
327
|
if (typeof this.loadingText === 'undefined') {
|
01b54e30
梁灏
Select support re...
|
328
329
330
331
332
|
return this.t('i.select.loading');
} else {
return this.loadingText;
}
},
|
f89dd9c2
梁灏
Paeg、Select add p...
|
333
334
|
transitionName () {
return this.placement === 'bottom' ? 'slide-up' : 'slide-down';
|
ec98f3c3
梁灏
update Select
|
335
336
337
|
},
dropVisible () {
let status = true;
|
bc348e7e
Sergio Crisostomo
adapt to auto-com...
|
338
339
|
const noOptions = !this.selectOptions || this.selectOptions.length === 0;
if (!this.loading && this.remote && this.query === '' && noOptions) status = false;
|
fed3e09d
梁灏
add AutoComplete ...
|
340
|
|
bc348e7e
Sergio Crisostomo
adapt to auto-com...
|
341
|
if (this.autoComplete && noOptions) status = false;
|
fed3e09d
梁灏
add AutoComplete ...
|
342
|
|
ec98f3c3
梁灏
update Select
|
343
|
return this.visible && status;
|
29264399
梁灏
update Select
|
344
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
345
346
|
showNotFoundLabel () {
const {loading, remote, selectOptions} = this;
|
bc348e7e
Sergio Crisostomo
adapt to auto-com...
|
347
|
return selectOptions && selectOptions.length === 0 && (!remote || (remote && !loading));
|
e355dd49
梁灏
add Select Component
|
348
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
349
350
351
|
publicValue(){
if (this.labelInValue){
return this.multiple ? this.values : this.values[0];
|
e355dd49
梁灏
add Select Component
|
352
|
} else {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
353
|
return this.multiple ? this.values.map(option => option.value) : (this.values[0] || {}).value;
|
e355dd49
梁灏
add Select Component
|
354
355
|
}
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
356
357
|
canBeCleared(){
const uiStateMatch = this.hasMouseHoverHead || this.active;
|
9050e61c
Emilio Losada
fix(select): don'...
|
358
|
const qualifiesForClear = !this.multiple && !this.disabled && this.clearable;
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
359
360
361
362
|
return uiStateMatch && qualifiesForClear && this.reset; // we return a function
},
selectOptions() {
const selectOptions = [];
|
06a74f9e
Sergio Crisostomo
Allow select to n...
|
363
|
const slotOptions = (this.slotOptions || []);
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
364
365
|
let optionCounter = -1;
const currentIndex = this.focusIndex;
|
220161f5
Sergio Crisostomo
Clean up empty/nu...
|
366
|
const selectedValues = this.values.filter(Boolean).map(({value}) => value);
|
06a74f9e
Sergio Crisostomo
Allow select to n...
|
367
368
369
370
371
372
373
374
375
376
|
if (this.autoComplete) {
const copyChildren = (node, fn) => {
return {
...node,
children: (node.children || []).map(fn).map(child => copyChildren(child, fn))
};
};
const autoCompleteOptions = extractOptions(slotOptions);
const selectedSlotOption = autoCompleteOptions[currentIndex];
|
aa21cdf9
Sergio Crisostomo
Process also shal...
|
377
|
return slotOptions.map(node => {
|
f8620d9a
Sergio Crisostomo
Fix autocomplete ...
|
378
|
if (node === selectedSlotOption || getNestedProperty(node, 'componentOptions.propsData.value') === this.value) return applyProp(node, 'isFocused', true);
|
aa21cdf9
Sergio Crisostomo
Process also shal...
|
379
380
381
382
383
|
return copyChildren(node, (child) => {
if (child !== selectedSlotOption) return child;
return applyProp(child, 'isFocused', true);
});
});
|
06a74f9e
Sergio Crisostomo
Allow select to n...
|
384
|
}
|
06a74f9e
Sergio Crisostomo
Allow select to n...
|
385
|
for (let option of slotOptions) {
|
e355dd49
梁灏
add Select Component
|
386
|
|
b6c069ca
Sergio Crisostomo
reset query if op...
|
387
388
|
const cOptions = option.componentOptions;
if (!cOptions) continue;
|
b6c069ca
Sergio Crisostomo
reset query if op...
|
389
390
|
if (cOptions.tag.match(optionGroupRegexp)){
let children = cOptions.children;
|
20719945
Aresn
Revert "Fix select"
|
391
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
392
393
394
395
396
397
|
// remove filtered children
if (this.filterable){
children = children.filter(
({componentOptions}) => this.validateOption(componentOptions)
);
}
|
e355dd49
梁灏
add Select Component
|
398
|
|
1d8b4d13
梁灏
fix #4371 close #...
|
399
400
|
// fix #4371
children = children.map(opt => {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
401
402
403
|
optionCounter = optionCounter + 1;
return this.processOption(opt, selectedValues, optionCounter === currentIndex);
});
|
3e855e34
梁灏
fixed #46
|
404
|
|
1d8b4d13
梁灏
fix #4371 close #...
|
405
406
|
// keep the group if it still has children // fix #4371
if (children.length > 0) selectOptions.push({...option,componentOptions:{...cOptions,children:children}});
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
407
408
|
} else {
// ignore option if not passing filter
|
e7327532
vincentfintend
fix select
|
409
|
if (this.filterQueryChange) {
|
bef01c91
梁灏
it will make a ne...
|
410
411
412
|
const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option;
if (!optionPassesFilter) continue;
}
|
20719945
Aresn
Revert "Fix select"
|
413
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
414
|
optionCounter = optionCounter + 1;
|
fdc71ffe
郑敏
reset the focus i...
|
415
|
selectOptions.push(this.processOption(option, selectedValues, optionCounter === currentIndex));
|
3e855e34
梁灏
fixed #46
|
416
|
}
|
e355dd49
梁灏
add Select Component
|
417
418
|
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
419
|
return selectOptions;
|
e355dd49
梁灏
add Select Component
|
420
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
421
|
flatOptions(){
|
06a74f9e
Sergio Crisostomo
Allow select to n...
|
422
|
return extractOptions(this.selectOptions);
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
},
selectTabindex(){
return this.disabled || this.filterable ? -1 : 0;
},
remote(){
return typeof this.remoteMethod === 'function';
}
},
methods: {
setQuery(query){ // PUBLIC API
if (query) {
this.onQueryChange(query);
return;
}
if (query === null) {
this.onQueryChange('');
this.values = [];
|
e355dd49
梁灏
add Select Component
|
440
441
|
}
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
442
|
clearSingleSelect(){ // PUBLIC API
|
7dbde804
Sergio Crisostomo
add on-clear event
|
443
|
this.$emit('on-clear');
|
c3304bce
Sergio Crisostomo
correct unchanged...
|
444
|
this.hideMenu();
|
743f6e06
Sergio Crisostomo
Be more hard on t...
|
445
|
if (this.clearable) this.reset();
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
446
447
448
|
},
getOptionData(value){
const option = this.flatOptions.find(({componentOptions}) => componentOptions.propsData.value === value);
|
7f63e58c
Sergio Crisostomo
Make possible for...
|
449
|
if (!option) return null;
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
450
|
const label = getOptionLabel(option);
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
451
452
453
454
455
456
|
return {
value: value,
label: label,
};
},
getInitialValue(){
|
c741fa2f
Sergio Crisostomo
Use label as query
|
457
|
const {multiple, remote, value} = this;
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
458
|
let initialValue = Array.isArray(value) ? value : [value];
|
31e4380d
luffyzhao
还是要保留multiple判断
|
459
|
if (!multiple && (typeof initialValue[0] === 'undefined' || (String(initialValue[0]).trim() === '' && !Number.isFinite(initialValue[0])))) initialValue = [];
|
c741fa2f
Sergio Crisostomo
Use label as query
|
460
461
462
463
|
if (remote && !multiple && value) {
const data = this.getOptionData(value);
this.query = data ? data.label : String(value);
}
|
b4138675
luffyzhao
select-binding-0
|
464
|
return initialValue.filter((item) => {
|
5c846d28
Sergio Crisostomo
Correct event pro...
|
465
|
return Boolean(item) || item === 0;
|
b4138675
luffyzhao
select-binding-0
|
466
|
});
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
467
468
469
470
471
472
473
474
475
476
477
478
479
|
},
processOption(option, values, isFocused){
if (!option.componentOptions) return option;
const optionValue = option.componentOptions.propsData.value;
const disabled = option.componentOptions.propsData.disabled;
const isSelected = values.includes(optionValue);
const propsData = {
...option.componentOptions.propsData,
selected: isSelected,
isFocused: isFocused,
disabled: typeof disabled === 'undefined' ? false : disabled !== false,
};
|
e355dd49
梁灏
add Select Component
|
480
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
481
482
483
484
485
|
return {
...option,
componentOptions: {
...option.componentOptions,
propsData: propsData
|
e355dd49
梁灏
add Select Component
|
486
|
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
487
488
|
};
},
|
e355dd49
梁灏
add Select Component
|
489
|
|
db5110c2
Sergio Crisostomo
Allow wider searc...
|
490
|
validateOption({children, elm, propsData}){
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
491
492
|
const value = propsData.value;
const label = propsData.label || '';
|
db5110c2
Sergio Crisostomo
Allow wider searc...
|
493
494
495
496
|
const textContent = (elm && elm.textContent) || (children || []).reduce((str, node) => {
const nodeText = node.elm ? node.elm.textContent : node.text;
return `${str} ${nodeText}`;
}, '') || '';
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
497
|
const stringValues = JSON.stringify([value, label, textContent]);
|
5266c905
Sergio Crisostomo
Trim label so we ...
|
498
|
const query = this.query.toLowerCase().trim();
|
c3304bce
Sergio Crisostomo
correct unchanged...
|
499
|
return stringValues.toLowerCase().includes(query);
|
e355dd49
梁灏
add Select Component
|
500
|
},
|
d87ce40a
梁灏
update Select
|
501
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
502
|
toggleMenu (e, force) {
|
f8620d9a
Sergio Crisostomo
Fix autocomplete ...
|
503
|
if (this.disabled) {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
504
|
return false;
|
d87ce40a
梁灏
update Select
|
505
|
}
|
d87ce40a
梁灏
update Select
|
506
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
507
508
509
|
this.visible = typeof force !== 'undefined' ? force : !this.visible;
if (this.visible){
this.dropDownWidth = this.$el.getBoundingClientRect().width;
|
cf753854
Sergio Crisostomo
Corrections after...
|
510
|
this.broadcast('Drop', 'on-update-popper');
|
e4ce9917
梁灏
update Select com...
|
511
|
}
|
e355dd49
梁灏
add Select Component
|
512
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
513
514
|
hideMenu () {
this.toggleMenu(null, false);
|
31788df3
Sergio Crisostomo
Normalise behavio...
|
515
|
setTimeout(() => this.unchangedQuery = true, ANIMATION_TIMEOUT);
|
e355dd49
梁灏
add Select Component
|
516
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
517
518
|
onClickOutside(event){
if (this.visible) {
|
4a9974f6
Graham Fairweather
Normalise v-ckick...
|
519
520
521
522
|
if (event.type === 'mousedown') {
event.preventDefault();
return;
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
523
|
|
5c846d28
Sergio Crisostomo
Correct event pro...
|
524
525
526
527
528
529
530
531
|
if (this.transfer) {
const {$el} = this.$refs.dropdown;
if ($el === event.target || $el.contains(event.target)) {
return;
}
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
532
|
if (this.filterable) {
|
ae7579e9
Sergio Crisostomo
Fix input getters...
|
533
|
const input = this.$el.querySelector('input[type="text"]');
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
534
535
536
537
|
this.caretPosition = input.selectionStart;
this.$nextTick(() => {
const caretPosition = this.caretPosition === -1 ? input.value.length : this.caretPosition;
input.setSelectionRange(caretPosition, caretPosition);
|
e355dd49
梁灏
add Select Component
|
538
539
540
|
});
}
|
ae7579e9
Sergio Crisostomo
Fix input getters...
|
541
|
if (!this.autoComplete) event.stopPropagation();
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
542
543
544
545
546
547
|
event.preventDefault();
this.hideMenu();
this.isFocused = true;
} else {
this.caretPosition = -1;
this.isFocused = false;
|
e355dd49
梁灏
add Select Component
|
548
549
|
}
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
550
|
reset(){
|
743f6e06
Sergio Crisostomo
Be more hard on t...
|
551
552
|
this.query = '';
this.focusIndex = -1;
|
31788df3
Sergio Crisostomo
Normalise behavio...
|
553
|
this.unchangedQuery = true;
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
554
|
this.values = [];
|
e7327532
vincentfintend
fix select
|
555
|
this.filterQueryChange = false;
|
e355dd49
梁灏
add Select Component
|
556
557
|
},
handleKeydown (e) {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
558
559
560
561
|
if (e.key === 'Backspace'){
return; // so we don't call preventDefault
}
|
e355dd49
梁灏
add Select Component
|
562
|
if (this.visible) {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
563
564
565
566
567
|
e.preventDefault();
if (e.key === 'Tab'){
e.stopPropagation();
}
|
e355dd49
梁灏
add Select Component
|
568
|
// Esc slide-up
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
569
|
if (e.key === 'Escape') {
|
16fc6361
Sergio Crisostomo
stop propagation ...
|
570
|
e.stopPropagation();
|
e355dd49
梁灏
add Select Component
|
571
572
573
|
this.hideMenu();
}
// next
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
574
575
|
if (e.key === 'ArrowUp') {
this.navigateOptions(-1);
|
e355dd49
梁灏
add Select Component
|
576
577
|
}
// prev
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
578
579
|
if (e.key === 'ArrowDown') {
this.navigateOptions(1);
|
e355dd49
梁灏
add Select Component
|
580
581
|
}
// enter
|
7e3fc4a5
Sergio Crisostomo
close the menu if...
|
582
583
|
if (e.key === 'Enter') {
if (this.focusIndex === -1) return this.hideMenu();
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
584
|
const optionComponent = this.flatOptions[this.focusIndex];
|
c87d7efb
Rookie_Zoe
fix a script erro...
|
585
586
587
588
589
590
591
592
|
// fix a script error when searching
if (optionComponent) {
const option = this.getOptionData(optionComponent.componentOptions.propsData.value);
this.onOptionClick(option);
} else {
this.hideMenu();
}
|
e355dd49
梁灏
add Select Component
|
593
|
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
594
595
596
|
} else {
const keysThatCanOpenSelect = ['ArrowUp', 'ArrowDown'];
if (keysThatCanOpenSelect.includes(e.key)) this.toggleMenu(null, true);
|
e355dd49
梁灏
add Select Component
|
597
598
|
}
|
e355dd49
梁灏
add Select Component
|
599
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
600
601
602
|
},
navigateOptions(direction){
const optionsLength = this.flatOptions.length - 1;
|
e4ebd304
梁灏
update Select com...
|
603
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
604
605
606
|
let index = this.focusIndex + direction;
if (index < 0) index = optionsLength;
if (index > optionsLength) index = 0;
|
e355dd49
梁灏
add Select Component
|
607
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
608
609
610
611
612
613
614
|
// find nearest option in case of disabled options in between
if (direction > 0){
let nearestActiveOption = -1;
for (let i = 0; i < this.flatOptions.length; i++){
const optionIsActive = !this.flatOptions[i].componentOptions.propsData.disabled;
if (optionIsActive) nearestActiveOption = i;
if (nearestActiveOption >= index) break;
|
e355dd49
梁灏
add Select Component
|
615
|
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
616
617
618
619
620
621
622
|
index = nearestActiveOption;
} else {
let nearestActiveOption = this.flatOptions.length;
for (let i = optionsLength; i >= 0; i--){
const optionIsActive = !this.flatOptions[i].componentOptions.propsData.disabled;
if (optionIsActive) nearestActiveOption = i;
if (nearestActiveOption <= index) break;
|
e4ebd304
梁灏
update Select com...
|
623
|
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
624
|
index = nearestActiveOption;
|
e355dd49
梁灏
add Select Component
|
625
|
}
|
e355dd49
梁灏
add Select Component
|
626
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
627
|
this.focusIndex = index;
|
e4ebd304
梁灏
update Select com...
|
628
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
629
630
631
632
633
634
|
onOptionClick(option) {
if (this.multiple){
// keep the query for remote select
if (this.remote) this.lastRemoteQuery = this.lastRemoteQuery || this.query;
else this.lastRemoteQuery = '';
|
e4ebd304
梁灏
update Select com...
|
635
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
636
637
638
|
const valueIsSelected = this.values.find(({value}) => value === option.value);
if (valueIsSelected){
this.values = this.values.filter(({value}) => value !== option.value);
|
e4ebd304
梁灏
update Select com...
|
639
|
} else {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
640
|
this.values = this.values.concat(option);
|
e4ebd304
梁灏
update Select com...
|
641
|
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
642
643
644
|
this.isFocused = true; // so we put back focus after clicking with mouse on option elements
} else {
|
5266c905
Sergio Crisostomo
Trim label so we ...
|
645
|
this.query = String(option.label).trim();
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
646
647
648
649
650
|
this.values = [option];
this.lastRemoteQuery = '';
this.hideMenu();
}
|
52cfcd66
Sergio Crisostomo
Keep last selecte...
|
651
652
653
654
655
|
this.focusIndex = this.flatOptions.findIndex((opt) => {
if (!opt || !opt.componentOptions) return false;
return opt.componentOptions.propsData.value === option.value;
});
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
656
|
if (this.filterable){
|
ae7579e9
Sergio Crisostomo
Fix input getters...
|
657
658
|
const inputField = this.$el.querySelector('input[type="text"]');
if (!this.autoComplete) this.$nextTick(() => inputField.focus());
|
e4ce9917
梁灏
update Select com...
|
659
|
}
|
88ef37f5
Aresn
fixed in multiple...
|
660
|
this.broadcast('Drop', 'on-update-popper');
|
ee5a8bcc
vincentfintend
change time
|
661
|
setTimeout(() => {
|
2bdeea65
梁灏
fix #4626 , close...
|
662
663
|
this.filterQueryChange = false;
}, ANIMATION_TIMEOUT);
|
3e855e34
梁灏
fixed #46
|
664
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
665
|
onQueryChange(query) {
|
33c826ec
Rookie_Zoe
fix #5150
|
666
667
668
669
|
if (query.length > 0 && query !== this.query) {
// in 'AutoComplete', when set an initial value asynchronously,
// the 'dropdown list' should be stay hidden.
// [issue #5150]
|
5f25feca
Aresn
Update select.vue
|
670
671
672
673
674
675
676
677
678
|
if (this.autoComplete) {
let isInputFocused =
document.hasFocus &&
document.hasFocus() &&
document.activeElement === this.$el.querySelector('input');
this.visible = isInputFocused;
} else {
this.visible = true;
}
|
33c826ec
Rookie_Zoe
fix #5150
|
679
680
|
}
|
2f0b086d
梁灏
fixed #116
|
681
|
this.query = query;
|
c3304bce
Sergio Crisostomo
correct unchanged...
|
682
|
this.unchangedQuery = this.visible;
|
e7327532
vincentfintend
fix select
|
683
|
this.filterQueryChange = true;
|
9c3a3e7d
YikaJ
更新 Select 组件
|
684
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
685
686
687
|
toggleHeaderFocus({type}){
if (this.disabled) {
return;
|
15b72d31
梁灏
fixed #566
|
688
|
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
689
|
this.isFocused = type === 'focus';
|
98bf25b3
梁灏
fixed #1286
|
690
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
691
692
|
updateSlotOptions(){
this.slotOptions = this.$slots.default;
|
73b01ee0
郑敏
fixed #3722 that ...
|
693
694
695
696
697
|
},
checkUpdateStatus() {
if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) {
this.hasExpectedValue = true;
}
|
47f03c54
梁灏
fix #4273
|
698
|
},
|
e355dd49
梁灏
add Select Component
|
699
|
},
|
e355dd49
梁灏
add Select Component
|
700
|
watch: {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
701
|
value(value){
|
cd8f1be8
任珽
fixed bug #4466 #...
|
702
|
const {getInitialValue, getOptionData, publicValue, values} = this;
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
703
|
|
73b01ee0
郑敏
fixed #3722 that ...
|
704
|
this.checkUpdateStatus();
|
9ccd8196
郑敏
fixed #3722
|
705
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
706
|
if (value === '') this.values = [];
|
cd8f1be8
任珽
fixed bug #4466 #...
|
707
|
else if (checkValuesNotEqual(value,publicValue,values)) {
|
220161f5
Sergio Crisostomo
Clean up empty/nu...
|
708
|
this.$nextTick(() => this.values = getInitialValue().map(getOptionData).filter(Boolean));
|
315dd685
梁灏
fix #4910
|
709
|
this.dispatch('FormItem', 'on-form-change', this.publicValue);
|
e355dd49
梁灏
add Select Component
|
710
|
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
711
712
713
714
|
},
values(now, before){
const newValue = JSON.stringify(now);
const oldValue = JSON.stringify(before);
|
9366c9a7
Sergio Crisostomo
Select improvemen...
|
715
716
717
718
719
|
// v-model is always just the value, event with labelInValue === true
const vModelValue = (this.publicValue && this.labelInValue) ?
(this.multiple ? this.publicValue.map(({value}) => value) : this.publicValue.value) :
this.publicValue;
const shouldEmitInput = newValue !== oldValue && vModelValue !== this.value;
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
720
|
if (shouldEmitInput) {
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
721
722
723
|
this.$emit('input', vModelValue); // to update v-model
this.$emit('on-change', this.publicValue);
this.dispatch('FormItem', 'on-form-change', this.publicValue);
|
219e5c92
梁灏
fixed #957
|
724
|
}
|
e355dd49
梁灏
add Select Component
|
725
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
726
727
728
729
|
query (query) {
this.$emit('on-query-change', query);
const {remoteMethod, lastRemoteQuery} = this;
const hasValidQuery = query !== '' && (query !== lastRemoteQuery || !lastRemoteQuery);
|
45bcc14d
Sergio Crisostomo
prevent calling r...
|
730
731
|
const shouldCallRemoteMethod = remoteMethod && hasValidQuery && !this.preventRemoteCall;
this.preventRemoteCall = false; // remove the flag
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
732
733
734
735
736
737
738
739
740
|
if (shouldCallRemoteMethod){
this.focusIndex = -1;
const promise = this.remoteMethod(query);
this.initialLabel = '';
if (promise && promise.then){
promise.then(options => {
if (options) this.options = options;
});
|
b7cf983e
梁灏
update Select com...
|
741
|
}
|
e355dd49
梁灏
add Select Component
|
742
|
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
743
|
if (query !== '' && this.remote) this.lastRemoteQuery = query;
|
e4ebd304
梁灏
update Select com...
|
744
|
},
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
745
746
747
748
749
750
|
loading(state){
if (state === false){
this.updateSlotOptions();
}
},
isFocused(focused){
|
ae7579e9
Sergio Crisostomo
Fix input getters...
|
751
|
const el = this.filterable ? this.$el.querySelector('input[type="text"]') : this.$el;
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
752
|
el[this.isFocused ? 'focus' : 'blur']();
|
d8bb1771
windywany
let select compon...
|
753
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
754
755
756
|
// restore query value in filterable single selects
const [selectedOption] = this.values;
if (selectedOption && this.filterable && !this.multiple && !focused){
|
5266c905
Sergio Crisostomo
Trim label so we ...
|
757
|
const selectedLabel = String(selectedOption.label || selectedOption.value).trim();
|
9ca6671c
Sergio Crisostomo
Check for selecte...
|
758
|
if (selectedLabel && this.query !== selectedLabel) {
|
45bcc14d
Sergio Crisostomo
prevent calling r...
|
759
760
761
|
this.preventRemoteCall = true;
this.query = selectedLabel;
}
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
762
763
764
|
}
},
focusIndex(index){
|
06a74f9e
Sergio Crisostomo
Allow select to n...
|
765
|
if (index < 0 || this.autoComplete) return;
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
766
767
768
769
770
|
// update scroll
const optionValue = this.flatOptions[index].componentOptions.propsData.value;
const optionInstance = findChild(this, ({$options}) => {
return $options.componentName === 'select-item' && $options.propsData.value === optionValue;
});
|
e4ce9917
梁灏
update Select com...
|
771
|
|
c9b86944
Sergio Crisostomo
Refactor Select!
|
772
773
774
775
776
777
778
|
let bottomOverflowDistance = optionInstance.$el.getBoundingClientRect().bottom - this.$refs.dropdown.$el.getBoundingClientRect().bottom;
let topOverflowDistance = optionInstance.$el.getBoundingClientRect().top - this.$refs.dropdown.$el.getBoundingClientRect().top;
if (bottomOverflowDistance > 0) {
this.$refs.dropdown.$el.scrollTop += bottomOverflowDistance;
}
if (topOverflowDistance < 0) {
this.$refs.dropdown.$el.scrollTop += topOverflowDistance;
|
01b54e30
梁灏
Select support re...
|
779
|
}
|
cf753854
Sergio Crisostomo
Corrections after...
|
780
781
782
|
},
dropVisible(open){
this.broadcast('Drop', open ? 'on-update-popper' : 'on-destroy-popper');
|
7f63e58c
Sergio Crisostomo
Make possible for...
|
783
|
},
|
f7f65c84
Sergio Crisostomo
reset query only ...
|
784
|
selectOptions(){
|
0fb9d645
郑敏
fix bug #3795
|
785
786
787
788
|
if (this.hasExpectedValue && this.selectOptions.length > 0){
if (this.values.length === 0) {
this.values = this.getInitialValue();
}
|
220161f5
Sergio Crisostomo
Clean up empty/nu...
|
789
|
this.values = this.values.map(this.getOptionData).filter(Boolean);
|
7f63e58c
Sergio Crisostomo
Make possible for...
|
790
791
|
this.hasExpectedValue = false;
}
|
b6c069ca
Sergio Crisostomo
reset query if op...
|
792
|
|
f7f65c84
Sergio Crisostomo
reset query only ...
|
793
|
if (this.slotOptions && this.slotOptions.length === 0){
|
b6c069ca
Sergio Crisostomo
reset query if op...
|
794
795
|
this.query = '';
}
|
c87d7efb
Rookie_Zoe
fix a script erro...
|
796
|
|
2fa83db1
yJs
fix: dropdown位置自动...
|
797
798
|
// 当 dropdown 一开始在控件下部显示,而滚动页面后变成在上部显示,如果选项列表的长度由内部动态变更了(搜索情况)
// dropdown 的位置不会重新计算,需要重新计算
|
2bdeea65
梁灏
fix #4626 , close...
|
799
|
this.broadcast('Drop', 'on-update-popper');
|
1376a01a
Sergio Crisostomo
Emit on-open-chan...
|
800
801
802
|
},
visible(state){
this.$emit('on-open-change', state);
|
0f58570a
Rookie_Zoe
[Select, AutoComp...
|
803
804
|
},
slotOptions(options, old){
|
2bdeea65
梁灏
fix #4626 , close...
|
805
|
// #4626,当 Options 的 label 更新时,v-model 的值未更新
|
07201151
梁灏
fix #5090
|
806
807
808
809
810
811
|
// remote 下,调用 getInitialValue 有 bug
if (!this.remote) {
const values = this.getInitialValue();
if (this.flatOptions && this.flatOptions.length && values.length && !this.multiple) {
this.values = values.map(this.getOptionData).filter(Boolean);
}
|
2bdeea65
梁灏
fix #4626 , close...
|
812
813
|
}
|
0f58570a
Rookie_Zoe
[Select, AutoComp...
|
814
815
816
817
818
819
|
// 当 dropdown 在控件上部显示时,如果选项列表的长度由外部动态变更了,
// dropdown 的位置会有点问题,需要重新计算
if (options && old && options.length !== old.length) {
this.broadcast('Drop', 'on-update-popper');
}
},
|
e355dd49
梁灏
add Select Component
|
820
|
}
|
b0893113
jingsam
add eslint
|
821
|
};
|
d6342fe1
jingsam
fixed ie bug
|
822
|
</script>
|