@opentiny/vue-renderless 3.27.0 → 3.28.1
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/autocomplete/index.js +7 -2
- package/autocomplete/vue.js +1 -1
- package/base-select/index.js +189 -86
- package/base-select/vue.js +82 -20
- package/drawer/index.js +20 -0
- package/drawer/vue.js +9 -1
- package/dropdown/index.js +10 -4
- package/file-upload/index.js +18 -5
- package/form-item/index.js +28 -16
- package/form-item/vue.js +50 -11
- package/grid/static/array/eachTree.js +1 -0
- package/grid/utils/common.js +10 -3
- package/grid-select/index.js +418 -32
- package/grid-select/vue.js +103 -9
- package/guide/vue.js +11 -1
- package/package.json +3 -3
- package/picker/index.js +30 -13
- package/popover/index.js +1 -1
- package/rich-text/index.js +42 -0
- package/select/index.js +2 -2
- package/select/vue.js +3 -2
- package/select-dropdown/vue.js +8 -3
- package/select-wrapper/vue.js +134 -0
- package/switch/vue.js +19 -0
- package/tabs-mf/index.js +9 -1
- package/tabs-mf/vue-nav.js +66 -9
- package/tabs-mf/vue.js +21 -5
- package/transfer-panel/index.js +2 -1
- package/tree-select/index.js +13 -4
- package/tree-select/vue.js +19 -3
- package/types/autocomplete.type.d.ts +2 -1
- package/types/date-picker.type.d.ts +38 -2
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-dd403065.d.ts → form.type-a54e1c06.d.ts} +2 -2
- package/types/form.type.d.ts +1 -1
- package/types/modal.type.d.ts +4 -0
- package/types/picker.type.d.ts +38 -2
- package/types/popeditor.type.d.ts +76 -4
- package/types/switch.type.d.ts +1 -0
- package/types/tree-menu.type.d.ts +38 -2
package/base-select/index.js
CHANGED
|
@@ -52,23 +52,29 @@ const showTip = ({ props, state, vm }) => (show) => {
|
|
|
52
52
|
state.showTip = show && overflow && !!state.tips && !state.visible;
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
const defaultOnQueryChange = ({ props, state, constants, api, nextTick }) => (value, isInput) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
props.remoteMethod && props.remoteMethod(value, props.extraQueryParams);
|
|
59
|
-
} else if (typeof props.filterMethod === "function") {
|
|
55
|
+
const defaultOnQueryChange = ({ props, state, constants, api, nextTick, vm }) => (value, isInput) => {
|
|
56
|
+
var _a;
|
|
57
|
+
if (typeof props.filterMethod === "function") {
|
|
60
58
|
props.filterMethod(value);
|
|
61
59
|
state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup, constants.EVENT_NAME.queryChange);
|
|
60
|
+
if (props.remote && typeof props.remoteMethod === "function" && !((_a = vm.$slots) == null ? void 0 : _a.panel)) {
|
|
61
|
+
state.hoverIndex = -1;
|
|
62
|
+
props.remoteMethod(value, props.extraQueryParams);
|
|
63
|
+
}
|
|
64
|
+
} else if (props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
65
|
+
state.hoverIndex = -1;
|
|
66
|
+
props.remoteMethod && props.remoteMethod(value, props.extraQueryParams);
|
|
62
67
|
} else {
|
|
63
68
|
api.queryChange(value, isInput);
|
|
64
69
|
}
|
|
65
70
|
setFilteredSelectCls(nextTick, state, props);
|
|
66
71
|
api.getOptionIndexArr();
|
|
67
|
-
state.magicKey = state.magicKey > 0 ? -1 : 1;
|
|
68
72
|
};
|
|
69
73
|
const queryChange = ({ props, state, constants }) => (value, isInput) => {
|
|
70
74
|
if (props.optimization && isInput) {
|
|
71
|
-
const filterDatas = state.initDatas.filter(
|
|
75
|
+
const filterDatas = state.initDatas.filter(
|
|
76
|
+
(item) => new RegExp(escapeRegexpString(value), "i").test(item[props.textField])
|
|
77
|
+
);
|
|
72
78
|
state.datas = filterDatas;
|
|
73
79
|
} else {
|
|
74
80
|
state.selectEmitter.emit(constants.EVENT_NAME.queryChange, value);
|
|
@@ -76,7 +82,7 @@ const queryChange = ({ props, state, constants }) => (value, isInput) => {
|
|
|
76
82
|
};
|
|
77
83
|
const setFilteredSelectCls = (nextTick, state, props) => {
|
|
78
84
|
nextTick(() => {
|
|
79
|
-
if (props.multiple && props.showAlloption && props.filterable && state.query && !props.remote) {
|
|
85
|
+
if (props.multiple && props.showAlloption && (props.filterable || props.searchable) && state.query && !props.remote) {
|
|
80
86
|
const filterSelectedVal = state.options.filter((item) => item.state.visible && item.state.itemSelected).map((opt) => opt.value);
|
|
81
87
|
const visibleOptions = state.options.filter((item) => item.state.visible);
|
|
82
88
|
if (filterSelectedVal.length === visibleOptions.length) {
|
|
@@ -106,7 +112,7 @@ const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (v
|
|
|
106
112
|
}
|
|
107
113
|
});
|
|
108
114
|
state.hoverIndex = -1;
|
|
109
|
-
if (props.multiple && props.filterable && !props.shape) {
|
|
115
|
+
if (props.multiple && (props.filterable || props.searchable) && !props.shape && !state.selectDisabled) {
|
|
110
116
|
nextTick(() => {
|
|
111
117
|
const length = vm.$refs.input.value.length * 15 + 20;
|
|
112
118
|
state.inputLength = state.collapseTags ? Math.min(50, length) : length;
|
|
@@ -130,8 +136,8 @@ const handleMenuEnter = ({ api, nextTick, state, props }) => () => {
|
|
|
130
136
|
nextTick(() => api.scrollToOption(state.selected));
|
|
131
137
|
}
|
|
132
138
|
};
|
|
133
|
-
const emitChange = ({ emit, props, state, constants }) => (value, changed) => {
|
|
134
|
-
if (state.device === "mb" && props.multiple && !changed)
|
|
139
|
+
const emitChange = ({ emit, props, state, constants, isMobileFirstMode }) => (value, changed) => {
|
|
140
|
+
if (isMobileFirstMode && state.device === "mb" && props.multiple && !changed)
|
|
135
141
|
return;
|
|
136
142
|
if (!isEqual(props.modelValue, state.compareValue)) {
|
|
137
143
|
emit("change", value);
|
|
@@ -165,15 +171,15 @@ const getOption = ({ props, state, api }) => (value) => {
|
|
|
165
171
|
if (props.optimization) {
|
|
166
172
|
option = api.getSelectedOption(value);
|
|
167
173
|
if (option) {
|
|
168
|
-
return { value: option.value, currentLabel: option.
|
|
174
|
+
return { value: option.value, currentLabel: option[props.textField] || option.currentLabel };
|
|
169
175
|
}
|
|
170
|
-
option = state.datas.find((v) => getObj(v, props.
|
|
176
|
+
option = state.datas.find((v) => getObj(v, props.valueField) === value);
|
|
171
177
|
if (option) {
|
|
172
|
-
return { value: option.
|
|
178
|
+
return { value: option[props.valueField], currentLabel: option[props.textField] || option.currentLabel };
|
|
173
179
|
}
|
|
174
180
|
}
|
|
175
181
|
const label = !isObject && !isNull2 && !isUndefined && !props.clearNoMatchValue ? value : "";
|
|
176
|
-
let newOption = { value, currentLabel: label };
|
|
182
|
+
let newOption = { value, currentLabel: label, isFakeLabel: true };
|
|
177
183
|
if (props.multiple) {
|
|
178
184
|
newOption.hitState = false;
|
|
179
185
|
}
|
|
@@ -182,9 +188,9 @@ const getOption = ({ props, state, api }) => (value) => {
|
|
|
182
188
|
const getSelectedOption = ({ props, state }) => (value) => {
|
|
183
189
|
let option;
|
|
184
190
|
if (props.multiple) {
|
|
185
|
-
option = state.selected.find((v) => getObj(v, props.
|
|
191
|
+
option = state.selected.find((v) => getObj(v, props.valueField) === value && !v.isFakeLabel);
|
|
186
192
|
} else {
|
|
187
|
-
if (!isEmptyObject(state.selected) && getObj(state.selected, props.
|
|
193
|
+
if (!isEmptyObject(state.selected) && getObj(state.selected, props.valueField) === value && !state.selected.isFakeLabel) {
|
|
188
194
|
option = state.selected;
|
|
189
195
|
}
|
|
190
196
|
}
|
|
@@ -195,13 +201,16 @@ const getOptionOfSetSelected = ({ api, props }) => {
|
|
|
195
201
|
if (!option.state) {
|
|
196
202
|
option.state = {};
|
|
197
203
|
}
|
|
204
|
+
if (option.currentLabel !== void 0 && option.state.currentLabel === void 0) {
|
|
205
|
+
option.state.currentLabel = option.currentLabel;
|
|
206
|
+
}
|
|
198
207
|
if (option.created) {
|
|
199
208
|
option.createdLabel = option.state.currentLabel;
|
|
200
209
|
option.createdSelected = true;
|
|
201
210
|
} else {
|
|
202
211
|
option.createdSelected = false;
|
|
203
212
|
}
|
|
204
|
-
if (!option.state.currentLabel) {
|
|
213
|
+
if (!option.state.currentLabel && !option.currentLabel) {
|
|
205
214
|
api.clearNoMatchValue("");
|
|
206
215
|
}
|
|
207
216
|
return option;
|
|
@@ -212,7 +221,8 @@ const getResultOfSetSelected = ({ state, api, props }) => {
|
|
|
212
221
|
if (Array.isArray(state.modelValue)) {
|
|
213
222
|
state.modelValue.forEach((value) => {
|
|
214
223
|
const option = api.getOption(value);
|
|
215
|
-
|
|
224
|
+
const hasLabel = (option == null ? void 0 : option.label) || (option == null ? void 0 : option.currentLabel) || (option == null ? void 0 : option.state) && option.state.currentLabel;
|
|
225
|
+
if (!props.clearNoMatchValue || props.clearNoMatchValue && hasLabel) {
|
|
216
226
|
result.push(option);
|
|
217
227
|
newModelValue.push(value);
|
|
218
228
|
}
|
|
@@ -226,7 +236,10 @@ const setSelected = ({ api, nextTick, props, vm, state }) => () => {
|
|
|
226
236
|
const option = getOptionOfSetSelected({ api, props });
|
|
227
237
|
state.selected = option;
|
|
228
238
|
state.selectedLabel = option.state.currentLabel || option.currentLabel;
|
|
229
|
-
props.filterable && !props.shape && (state.query = state.selectedLabel);
|
|
239
|
+
(props.filterable || props.searchable) && !props.shape && (state.query = state.selectedLabel);
|
|
240
|
+
if (vm.$slots.panel && state.selectedLabel && (props.filterable || props.searchable)) {
|
|
241
|
+
state.currentPlaceholder = "";
|
|
242
|
+
}
|
|
230
243
|
} else {
|
|
231
244
|
const result = getResultOfSetSelected({ state, props, api });
|
|
232
245
|
state.selectCls = result.length ? result.length === state.options.length ? "checked-sur" : "halfselect" : "check";
|
|
@@ -234,6 +247,9 @@ const setSelected = ({ api, nextTick, props, vm, state }) => () => {
|
|
|
234
247
|
state.selected = result;
|
|
235
248
|
}
|
|
236
249
|
state.selected.length && (state.selectedLabel = "");
|
|
250
|
+
if (vm.$slots.panel && result.length > 0 && (props.filterable || props.searchable)) {
|
|
251
|
+
state.currentPlaceholder = "";
|
|
252
|
+
}
|
|
237
253
|
state.tips = state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join(",");
|
|
238
254
|
setFilteredSelectCls(nextTick, state, props);
|
|
239
255
|
nextTick(api.resetInputHeight);
|
|
@@ -259,6 +275,7 @@ const toggleCheckAll = ({ api, state }) => (filtered) => {
|
|
|
259
275
|
value = [.../* @__PURE__ */ new Set([...state.modelValue, ...enabledValues])];
|
|
260
276
|
} else {
|
|
261
277
|
value = state.modelValue.filter((val) => !enabledValues.includes(val));
|
|
278
|
+
value = Array.from(/* @__PURE__ */ new Set([...state.modelValue, ...enabledValues]));
|
|
262
279
|
}
|
|
263
280
|
} else {
|
|
264
281
|
if (state.selectCls === "check") {
|
|
@@ -279,18 +296,28 @@ const toggleCheckAll = ({ api, state }) => (filtered) => {
|
|
|
279
296
|
api.directEmitChange(value);
|
|
280
297
|
};
|
|
281
298
|
const handleFocus = ({ emit, props, state }) => (event) => {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
299
|
+
state.willFocusRun = true;
|
|
300
|
+
state.willFocusTimer && clearTimeout(state.willFocusTimer);
|
|
301
|
+
state.willFocusTimer = setTimeout(() => {
|
|
302
|
+
state.willFocusTimer = 0;
|
|
303
|
+
if (!state.willFocusRun)
|
|
304
|
+
return;
|
|
305
|
+
if (!state.softFocus) {
|
|
306
|
+
if (props.shape === "filter") {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (props.automaticDropdown || props.filterable || props.searchable) {
|
|
310
|
+
state.visible = true;
|
|
311
|
+
state.softFocus = true;
|
|
312
|
+
}
|
|
290
313
|
emit("focus", event);
|
|
314
|
+
} else {
|
|
315
|
+
if (state.searchSingleCopy && state.selectedLabel) {
|
|
316
|
+
emit("focus", event);
|
|
317
|
+
}
|
|
318
|
+
state.softFocus = false;
|
|
291
319
|
}
|
|
292
|
-
|
|
293
|
-
}
|
|
320
|
+
}, 10);
|
|
294
321
|
};
|
|
295
322
|
const focus = ({ vm, state }) => () => {
|
|
296
323
|
if (!state.softFocus) {
|
|
@@ -303,6 +330,7 @@ const blur = ({ vm, state }) => () => {
|
|
|
303
330
|
};
|
|
304
331
|
const handleBlur = ({ constants, dispatch, emit, state, designConfig }) => (event) => {
|
|
305
332
|
var _a;
|
|
333
|
+
state.willFocusRun = false;
|
|
306
334
|
clearTimeout(state.timer);
|
|
307
335
|
state.timer = setTimeout(() => {
|
|
308
336
|
var _a2;
|
|
@@ -373,7 +401,7 @@ const resetInputState = ({ api, vm, state }) => (event) => {
|
|
|
373
401
|
api.resetInputHeight();
|
|
374
402
|
};
|
|
375
403
|
const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designConfig }) => () => {
|
|
376
|
-
if (state.collapseTags && !props.filterable) {
|
|
404
|
+
if (state.collapseTags && !(props.filterable || props.searchable)) {
|
|
377
405
|
return;
|
|
378
406
|
}
|
|
379
407
|
nextTick(() => {
|
|
@@ -390,7 +418,6 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
390
418
|
if (!state.isDisplayOnly && (props.hoverExpand || props.clickExpand) && !props.disabled) {
|
|
391
419
|
api.calcCollapseTags();
|
|
392
420
|
}
|
|
393
|
-
const sizeInMap = (designConfig == null ? void 0 : designConfig.state.initialInputHeight) || state.initialInputHeight || 32;
|
|
394
421
|
const noSelected = state.selected.length === 0;
|
|
395
422
|
const spacingHeight = (_b = (_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.spacingHeight) != null ? _b : constants.SPACING_HEIGHT;
|
|
396
423
|
if (!state.isDisplayOnly) {
|
|
@@ -398,11 +425,11 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
398
425
|
fastdom.measure(() => {
|
|
399
426
|
const tagsClientHeight = tags.clientHeight;
|
|
400
427
|
fastdom.mutate(() => {
|
|
401
|
-
input.style.height = Math.max(tagsClientHeight + spacingHeight,
|
|
428
|
+
input.style.height = Math.max(tagsClientHeight + spacingHeight, state.currentSizeMap) + "px";
|
|
402
429
|
});
|
|
403
430
|
});
|
|
404
431
|
} else {
|
|
405
|
-
input.style.height = noSelected ?
|
|
432
|
+
input.style.height = noSelected ? state.currentSizeMap + "px" : Math.max(0, state.currentSizeMap) + "px";
|
|
406
433
|
}
|
|
407
434
|
} else {
|
|
408
435
|
input.style.height = "auto";
|
|
@@ -440,6 +467,7 @@ const resetDatas = ({ props, state }) => () => {
|
|
|
440
467
|
}
|
|
441
468
|
};
|
|
442
469
|
const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byClick) => {
|
|
470
|
+
var _a;
|
|
443
471
|
state.memorize && state.memorize.updateByKey(option[state.memorize._dataKey] || option.value);
|
|
444
472
|
if (props.multiple) {
|
|
445
473
|
const value = (state.modelValue || []).slice();
|
|
@@ -459,8 +487,8 @@ const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byC
|
|
|
459
487
|
api.handleQueryChange("", isChange, isInput);
|
|
460
488
|
state.inputLength = 20;
|
|
461
489
|
}
|
|
462
|
-
if (props.filterable) {
|
|
463
|
-
vm.$refs.input.focus();
|
|
490
|
+
if (props.filterable || props.searchable) {
|
|
491
|
+
(_a = vm.$refs.input) == null ? void 0 : _a.focus();
|
|
464
492
|
}
|
|
465
493
|
if (props.autoClose) {
|
|
466
494
|
state.visible = false;
|
|
@@ -476,7 +504,8 @@ const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byC
|
|
|
476
504
|
state.visible = false;
|
|
477
505
|
}
|
|
478
506
|
state.isSilentBlur = byClick;
|
|
479
|
-
|
|
507
|
+
if (!props.automaticDropdown)
|
|
508
|
+
api.setSoftFocus();
|
|
480
509
|
if (state.visible) {
|
|
481
510
|
return;
|
|
482
511
|
}
|
|
@@ -488,13 +517,17 @@ const initValue = ({ state }) => (vm) => {
|
|
|
488
517
|
const isExist = state.initValue.find((val) => val === vm.value);
|
|
489
518
|
!isExist && state.initValue.push(vm.value);
|
|
490
519
|
};
|
|
491
|
-
const setSoftFocus = ({ vm, state }) => () => {
|
|
520
|
+
const setSoftFocus = ({ vm, state, props }) => () => {
|
|
521
|
+
if (vm.$slots.reference) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
492
524
|
state.softFocus = true;
|
|
493
525
|
const input = vm.$refs.input || vm.$refs.reference;
|
|
494
|
-
if (
|
|
495
|
-
input
|
|
526
|
+
if (!props.automaticDropdown) {
|
|
527
|
+
if (input) {
|
|
528
|
+
input.focus();
|
|
529
|
+
}
|
|
496
530
|
}
|
|
497
|
-
state.softFocus = false;
|
|
498
531
|
};
|
|
499
532
|
const getValueIndex = (props) => (arr = [], value = null) => {
|
|
500
533
|
const isObject = Object.prototype.toString.call(value).toLowerCase() === "[object object]";
|
|
@@ -513,22 +546,28 @@ const getValueIndex = (props) => (arr = [], value = null) => {
|
|
|
513
546
|
return index;
|
|
514
547
|
}
|
|
515
548
|
};
|
|
516
|
-
const toggleMenu = ({ vm, state, props, api }) => (e) => {
|
|
517
|
-
|
|
549
|
+
const toggleMenu = ({ vm, state, props, api, designConfig }) => (e) => {
|
|
550
|
+
var _a, _b, _c;
|
|
551
|
+
if (props.keepFocus && state.visible && (props.filterable || props.searchable)) {
|
|
518
552
|
return;
|
|
519
553
|
}
|
|
554
|
+
if (state.isIOS) {
|
|
555
|
+
state.selectHover = true;
|
|
556
|
+
state.inputHovering = true;
|
|
557
|
+
}
|
|
520
558
|
const event = e || window.event;
|
|
521
559
|
const enterCode = 13;
|
|
522
560
|
const nodeName = event.target && event.target.nodeName;
|
|
523
561
|
const toggleVisible = props.ignoreEnter ? event.keyCode !== enterCode && nodeName === "INPUT" : true;
|
|
524
|
-
|
|
562
|
+
const isStop = (_c = (_b = props.stopPropagation) != null ? _b : (_a = designConfig == null ? void 0 : designConfig.props) == null ? void 0 : _a.stopPropagation) != null ? _c : false;
|
|
563
|
+
if (!props.displayOnly && isStop) {
|
|
525
564
|
event.stopPropagation();
|
|
526
565
|
}
|
|
527
566
|
if (!state.selectDisabled) {
|
|
528
567
|
toggleVisible && !state.softFocus && (state.visible = !state.visible);
|
|
529
568
|
state.softFocus = false;
|
|
530
569
|
if (state.visible) {
|
|
531
|
-
if (!(props.filterable && props.shape)) {
|
|
570
|
+
if (!((props.filterable || props.searchable) && props.shape)) {
|
|
532
571
|
const dom = vm.$refs.input || vm.$refs.reference;
|
|
533
572
|
(dom == null ? void 0 : dom.focus) && dom.focus();
|
|
534
573
|
api.setOptionHighlight();
|
|
@@ -538,6 +577,7 @@ const toggleMenu = ({ vm, state, props, api }) => (e) => {
|
|
|
538
577
|
};
|
|
539
578
|
const selectOption = ({ api, state, props }) => (e) => {
|
|
540
579
|
if (!state.visible || props.hideDrop) {
|
|
580
|
+
state.softFocus = false;
|
|
541
581
|
api.toggleMenu(e);
|
|
542
582
|
} else {
|
|
543
583
|
let option = "";
|
|
@@ -581,7 +621,7 @@ const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (eve
|
|
|
581
621
|
};
|
|
582
622
|
const onInputChange = ({ api, props, state, constants, nextTick }) => () => {
|
|
583
623
|
if (!props.delay) {
|
|
584
|
-
if (props.filterable && state.query !== state.selectedLabel) {
|
|
624
|
+
if ((props.filterable || props.searchable) && state.query !== state.selectedLabel) {
|
|
585
625
|
const isChange = false;
|
|
586
626
|
const isInput = true;
|
|
587
627
|
state.query = state.selectedLabel;
|
|
@@ -744,7 +784,7 @@ const emptyText = ({ I18N, props, state, t, isMobileFirstMode }) => () => {
|
|
|
744
784
|
if (props.remote && state.query === "" && state.emptyFlag && !state.triggerSearch) {
|
|
745
785
|
return props.shape === "filter" || isMobileFirstMode ? "" : false;
|
|
746
786
|
}
|
|
747
|
-
if (props.filterable && state.query && (props.remote && state.emptyFlag || !state.options.some((option) => option.visible && option.state.visible))) {
|
|
787
|
+
if ((props.filterable || props.searchable) && state.query && (props.remote && state.emptyFlag || !state.options.some((option) => option.visible && option.state.visible))) {
|
|
748
788
|
return props.noMatchText || t(I18N.noMatch);
|
|
749
789
|
}
|
|
750
790
|
if (state.emptyFlag) {
|
|
@@ -761,19 +801,24 @@ const remoteEmptyText = function(props, state) {
|
|
|
761
801
|
const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, oldValue) => {
|
|
762
802
|
if (props.multiple) {
|
|
763
803
|
api.resetInputHeight();
|
|
764
|
-
if (value && value.length > 0
|
|
804
|
+
if (vm.$slots.panel && value && value.length > 0) {
|
|
805
|
+
state.currentPlaceholder = "";
|
|
806
|
+
} else if (value && value.length > 0 || vm.$refs.input && state.query !== "") {
|
|
765
807
|
state.currentPlaceholder = "";
|
|
766
808
|
} else {
|
|
767
809
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
768
810
|
}
|
|
769
|
-
if (props.filterable && !props.reserveKeyword) {
|
|
770
|
-
|
|
811
|
+
if ((props.filterable || props.searchable) && !props.reserveKeyword) {
|
|
812
|
+
const isChange = false;
|
|
813
|
+
const isInput = true;
|
|
814
|
+
state.query = "";
|
|
815
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
771
816
|
}
|
|
772
817
|
}
|
|
773
818
|
api.setSelected();
|
|
774
819
|
!state.isClickChoose && api.initQuery({ init: true }).then(() => api.setSelected());
|
|
775
820
|
state.isClickChoose = false;
|
|
776
|
-
if (props.filterable && !props.multiple) {
|
|
821
|
+
if ((props.filterable || props.searchable) && !props.multiple) {
|
|
777
822
|
state.inputLength = 20;
|
|
778
823
|
}
|
|
779
824
|
if (state.completed && !isEqual(value, oldValue)) {
|
|
@@ -814,22 +859,38 @@ const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
|
814
859
|
state.inputWidth = inputWidth;
|
|
815
860
|
}
|
|
816
861
|
};
|
|
817
|
-
const postOperOfToVisible = ({ props, state, constants }) => {
|
|
862
|
+
const postOperOfToVisible = ({ props, state, constants, vm }) => {
|
|
818
863
|
if (props.multiple) {
|
|
864
|
+
if (props.modelValue && props.modelValue.length && props.initLabel && !state.selected.length) {
|
|
865
|
+
state.selectedLabel = props.initLabel;
|
|
866
|
+
}
|
|
819
867
|
return;
|
|
820
868
|
}
|
|
821
869
|
if (state.selected) {
|
|
822
|
-
if (props.
|
|
823
|
-
state.selectedLabel = state.
|
|
870
|
+
if (props.renderType === constants.TYPE.Grid || props.renderType === constants.TYPE.Tree) {
|
|
871
|
+
state.selectedLabel = state.selected.currentLabel;
|
|
824
872
|
} else {
|
|
825
|
-
|
|
873
|
+
if ((props.filterable || props.searchable) && props.allowCreate && state.createdSelected && state.createdLabel) {
|
|
874
|
+
state.selectedLabel = state.createdLabel;
|
|
875
|
+
} else {
|
|
876
|
+
state.selectedLabel = state.selected.state.currentLabel || state.selected.currentLabel;
|
|
877
|
+
}
|
|
878
|
+
if (props.filterable || props.searchable) {
|
|
879
|
+
state.query = state.selectedLabel;
|
|
880
|
+
}
|
|
826
881
|
}
|
|
827
|
-
if (props.filterable) {
|
|
828
|
-
|
|
882
|
+
if (props.filterable || props.searchable) {
|
|
883
|
+
if (vm.$slots.panel && state.selectedLabel) {
|
|
884
|
+
state.currentPlaceholder = "";
|
|
885
|
+
} else {
|
|
886
|
+
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
887
|
+
}
|
|
829
888
|
}
|
|
830
|
-
if (props.
|
|
831
|
-
state.
|
|
889
|
+
if (props.modelValue && props.initLabel && !state.selectedLabel) {
|
|
890
|
+
state.selectedLabel = props.initLabel;
|
|
832
891
|
}
|
|
892
|
+
} else if (props.modelValue && props.initLabel) {
|
|
893
|
+
state.selectedLabel = props.initLabel;
|
|
833
894
|
}
|
|
834
895
|
};
|
|
835
896
|
const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
@@ -850,18 +911,19 @@ const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
|
850
911
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
851
912
|
}
|
|
852
913
|
});
|
|
853
|
-
postOperOfToVisible({ props, state, constants });
|
|
914
|
+
postOperOfToVisible({ props, state, constants, vm });
|
|
854
915
|
};
|
|
855
916
|
const toHide = ({ constants, state, props, vm, api }) => () => {
|
|
856
|
-
|
|
917
|
+
var _a;
|
|
918
|
+
const { remote, remoteConfig, shape, renderType, multiple, valueField } = props;
|
|
857
919
|
state.selectEmitter.emit(constants.COMPONENT_NAME.SelectDropdown, constants.EVENT_NAME.updatePopper);
|
|
858
|
-
if (filterable) {
|
|
920
|
+
if (props.filterable || props.searchable) {
|
|
859
921
|
state.query = remote || shape ? "" : state.selectedLabel;
|
|
860
922
|
const isChange = remote && remoteConfig.autoSearch && (state.firstAutoSearch || remoteConfig.clearData);
|
|
861
923
|
state.firstAutoSearch = false;
|
|
862
924
|
api.handleQueryChange(state.query, isChange);
|
|
863
925
|
if (multiple) {
|
|
864
|
-
vm.$refs.input.focus();
|
|
926
|
+
(_a = vm.$refs.input) == null ? void 0 : _a.focus();
|
|
865
927
|
} else {
|
|
866
928
|
if (!remote) {
|
|
867
929
|
state.selectEmitter.emit(constants.EVENT_NAME.queryChange, "");
|
|
@@ -874,14 +936,15 @@ const toHide = ({ constants, state, props, vm, api }) => () => {
|
|
|
874
936
|
}
|
|
875
937
|
}
|
|
876
938
|
};
|
|
877
|
-
const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) => {
|
|
878
|
-
|
|
879
|
-
|
|
939
|
+
const watchVisible = ({ api, constants, emit, state, vm, props, isMobileFirstMode }) => (value) => {
|
|
940
|
+
var _a;
|
|
941
|
+
if ((props.filterable || props.searchable || props.remote) && !value) {
|
|
942
|
+
(_a = vm.$refs.reference) == null ? void 0 : _a.blur();
|
|
880
943
|
}
|
|
881
944
|
if (api.onCopying()) {
|
|
882
945
|
return;
|
|
883
946
|
}
|
|
884
|
-
if (value && props.multiple && state.device === "mb") {
|
|
947
|
+
if (value && props.multiple && isMobileFirstMode && state.device === "mb") {
|
|
885
948
|
state.selectedCopy = state.selected.slice();
|
|
886
949
|
}
|
|
887
950
|
setTimeout(() => {
|
|
@@ -919,16 +982,32 @@ const watchOptions = ({ api, constants, nextTick, parent, props, state }) => ()
|
|
|
919
982
|
api.resetInputHeight();
|
|
920
983
|
}
|
|
921
984
|
nextTick(() => {
|
|
922
|
-
|
|
985
|
+
var _a;
|
|
986
|
+
if (parent.$el.querySelector("input") !== document.activeElement && // filterable时, 从 input 框离开了
|
|
987
|
+
!(((_a = document.activeElement) == null ? void 0 : _a.classList.contains("tiny-input__inner")) && // 并且当前不在下拉面板的searchable 的input中时, 才需要更新一下setSelect
|
|
988
|
+
document.activeElement.closest(".tiny-select-dropdown__search"))) {
|
|
923
989
|
api.setSelected();
|
|
924
990
|
}
|
|
925
991
|
});
|
|
926
992
|
api.getOptionIndexArr();
|
|
927
993
|
};
|
|
994
|
+
const watchOptionsWhenAutoSelect = ({ nextTick, props, state, api }) => () => {
|
|
995
|
+
if (props.autoSelect && props.remote) {
|
|
996
|
+
nextTick(() => {
|
|
997
|
+
var _a, _b;
|
|
998
|
+
if (((_a = props.options) == null ? void 0 : _a.length) === 1 || state.options.length === 1) {
|
|
999
|
+
const { valueField } = props;
|
|
1000
|
+
const option = ((_b = props.options) == null ? void 0 : _b.length) === 1 ? props.options[0] : state.options[0];
|
|
1001
|
+
api.updateModelValue(props.multiple ? [option[props.valueField]] : option[props.valueField]);
|
|
1002
|
+
state.visible = false;
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
928
1007
|
const getOptionIndexArr = ({ props, state, api }) => () => {
|
|
929
1008
|
setTimeout(() => {
|
|
930
1009
|
state.optionIndexArr = api.queryVisibleOptions().map((item) => Number(item.getAttribute("data-index")));
|
|
931
|
-
if (props.defaultFirstOption && (props.filterable || props.remote) && state.filteredOptionsCount) {
|
|
1010
|
+
if (props.defaultFirstOption && (props.filterable || props.searchable || props.remote) && state.filteredOptionsCount) {
|
|
932
1011
|
if (props.optimization) {
|
|
933
1012
|
optmzApis.checkDefaultFirstOption({ state });
|
|
934
1013
|
} else {
|
|
@@ -956,7 +1035,7 @@ const handleCopyClick = ({ parent, props, state }) => () => {
|
|
|
956
1035
|
parent.$el.removeChild(input);
|
|
957
1036
|
};
|
|
958
1037
|
const debouncRquest = ({ api, state, props }) => debounce(props.delay, () => {
|
|
959
|
-
if (props.filterable && state.query !== state.selectedLabel) {
|
|
1038
|
+
if ((props.filterable || props.searchable) && state.query !== state.selectedLabel) {
|
|
960
1039
|
const isChange = false;
|
|
961
1040
|
const isInput = true;
|
|
962
1041
|
state.query = state.selectedLabel;
|
|
@@ -1009,6 +1088,12 @@ const onMouseenterNative = ({ state }) => () => {
|
|
|
1009
1088
|
state.softFocus = true;
|
|
1010
1089
|
}
|
|
1011
1090
|
};
|
|
1091
|
+
const onMouseenterSelf = ({ state }) => () => {
|
|
1092
|
+
if (!state.isIOS) {
|
|
1093
|
+
state.selectHover = true;
|
|
1094
|
+
state.inputHovering = true;
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1012
1097
|
const onMouseleaveNative = ({ state }) => (e) => {
|
|
1013
1098
|
if (e.target === e.currentTarget)
|
|
1014
1099
|
return;
|
|
@@ -1106,7 +1191,7 @@ const watchInputHover = ({ vm }) => (newVal) => {
|
|
|
1106
1191
|
}
|
|
1107
1192
|
};
|
|
1108
1193
|
const initQuery = ({ props, state, constants, vm }) => ({ init } = {}) => {
|
|
1109
|
-
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
1194
|
+
const isRemote = (props.filterable || props.searchable) && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
1110
1195
|
let selected;
|
|
1111
1196
|
if (isRemote && props.initQuery) {
|
|
1112
1197
|
let initData = props.initQuery(props.modelValue, props.extraQueryParams, !!init);
|
|
@@ -1123,8 +1208,13 @@ const initQuery = ({ props, state, constants, vm }) => ({ init } = {}) => {
|
|
|
1123
1208
|
}
|
|
1124
1209
|
return Promise.resolve(selected);
|
|
1125
1210
|
};
|
|
1126
|
-
const
|
|
1211
|
+
const computedCurrentSizeMap = ({ state, designConfig }) => () => {
|
|
1127
1212
|
var _a;
|
|
1213
|
+
const defaultSizeMap = { default: 32, mini: 24, small: 28, medium: 40 };
|
|
1214
|
+
const sizeMap = ((_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.sizeMap) || defaultSizeMap;
|
|
1215
|
+
return sizeMap[state.selectSize || "default"];
|
|
1216
|
+
};
|
|
1217
|
+
const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
1128
1218
|
const parentEl = parent.$el;
|
|
1129
1219
|
const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]');
|
|
1130
1220
|
const inputClientRect = inputEl && inputEl.getBoundingClientRect() || {};
|
|
@@ -1132,12 +1222,9 @@ const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
|
1132
1222
|
document.activeElement.blur();
|
|
1133
1223
|
}
|
|
1134
1224
|
state.completed = true;
|
|
1135
|
-
const defaultSizeMap = { medium: 40, default: 32, small: 28, mini: 24 };
|
|
1136
|
-
const sizeMap = ((_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.sizeMap) || defaultSizeMap;
|
|
1137
1225
|
if (props.multiple && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
|
|
1138
1226
|
state.currentPlaceholder = "";
|
|
1139
1227
|
}
|
|
1140
|
-
state.initialInputHeight = state.isDisplayOnly ? sizeMap[state.selectSize || "default"] : inputClientRect.height || sizeMap[state.selectSize];
|
|
1141
1228
|
addResizeListener(parentEl, api.handleResize);
|
|
1142
1229
|
if (vm.$refs.tags) {
|
|
1143
1230
|
addResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
@@ -1146,7 +1233,12 @@ const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
|
1146
1233
|
api.resetInputHeight();
|
|
1147
1234
|
}
|
|
1148
1235
|
state.inputWidth = inputClientRect.width;
|
|
1149
|
-
api.initQuery({ init: true }).then(() =>
|
|
1236
|
+
api.initQuery({ init: true }).then(() => {
|
|
1237
|
+
api.setSelected(true);
|
|
1238
|
+
if (props.modelValue && props.initLabel) {
|
|
1239
|
+
state.selectedLabel = props.initLabel;
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1150
1242
|
if (props.dataset) {
|
|
1151
1243
|
api.watchPropsOption();
|
|
1152
1244
|
}
|
|
@@ -1225,9 +1317,9 @@ const computeMultipleLimit = ({ props, state }) => () => {
|
|
|
1225
1317
|
const { optimizeOpts } = state;
|
|
1226
1318
|
return optmzApis.natural(multiple && optimization ? multipleLimit || optimizeOpts.limit : multipleLimit);
|
|
1227
1319
|
};
|
|
1228
|
-
const updateModelValue = ({ props, emit, state }) => (value, needUpdate) => {
|
|
1320
|
+
const updateModelValue = ({ props, emit, state, isMobileFirstMode }) => (value, needUpdate) => {
|
|
1229
1321
|
state.isClickChoose = true;
|
|
1230
|
-
if (state.device === "mb" && props.multiple && !needUpdate) {
|
|
1322
|
+
if (isMobileFirstMode && state.device === "mb" && props.multiple && !needUpdate) {
|
|
1231
1323
|
state.modelValue = value;
|
|
1232
1324
|
} else {
|
|
1233
1325
|
emit("update:modelValue", value);
|
|
@@ -1265,17 +1357,25 @@ const computedTagsStyle = ({ props, parent, state, vm }) => () => {
|
|
|
1265
1357
|
}
|
|
1266
1358
|
return tagsStyle;
|
|
1267
1359
|
};
|
|
1268
|
-
const computedReadonly = ({ props, state }) => () =>
|
|
1360
|
+
const computedReadonly = ({ props, state, isMobileFirstMode }) => () => {
|
|
1361
|
+
if (state.isIOS && props.filterable) {
|
|
1362
|
+
return false;
|
|
1363
|
+
} else {
|
|
1364
|
+
return isMobileFirstMode && state.device === "mb" || props.readonly || !(props.filterable || props.searchable) || props.multiple || browserInfo.name !== BROWSER_NAME.IE && browserInfo.name !== BROWSER_NAME.Edge && !state.visible;
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1269
1367
|
const computedShowClose = ({ props, state }) => () => props.clearable && !state.selectDisabled && (state.inputHovering || props.multiple && state.visible) && (props.multiple ? Array.isArray(props.modelValue) && props.modelValue.length > 0 : !isNull(props.modelValue) && props.modelValue !== "");
|
|
1270
1368
|
const computedCollapseTagSize = (state) => () => state.selectSize;
|
|
1271
|
-
const computedShowNewOption = ({ props, state }) => () => {
|
|
1272
|
-
const query = state.device === "mb" ? state.queryValue : state.query;
|
|
1273
|
-
return props.filterable && props.allowCreate && query && !state.options.filter((option) => !option.created).some((option) => option.state.currentLabel === state.query);
|
|
1369
|
+
const computedShowNewOption = ({ props, state, isMobileFirstMode }) => () => {
|
|
1370
|
+
const query = isMobileFirstMode && state.device === "mb" ? state.queryValue : state.query;
|
|
1371
|
+
return (props.filterable || props.searchable) && props.allowCreate && query && !state.options.filter((option) => !option.created).some((option) => option.state.currentLabel === state.query);
|
|
1274
1372
|
};
|
|
1275
1373
|
const computedShowCopy = ({ props, state }) => () => props.multiple && props.copyable && state.inputHovering && state.selected.length;
|
|
1276
1374
|
const computedOptionsAllDisabled = (state) => () => state.options.filter((option) => option.visible).every((option) => option.disabled);
|
|
1277
|
-
const computedDisabledTooltipContent = (state
|
|
1278
|
-
|
|
1375
|
+
const computedDisabledTooltipContent = ({ state }) => () => {
|
|
1376
|
+
return state.displayOnlyContent;
|
|
1377
|
+
};
|
|
1378
|
+
const computedSelectDisabled = ({ state }) => () => state.isDisabled || state.isDisplayOnly;
|
|
1279
1379
|
const computedIsExpand = ({ props, state }) => () => {
|
|
1280
1380
|
const hoverExpanded = (state.selectHover || state.visible) && props.hoverExpand && !props.disabled;
|
|
1281
1381
|
const clickExpanded = props.clickExpand && state.exceedMaxVisibleRow && state.showCollapseTag;
|
|
@@ -1307,7 +1407,7 @@ const computedShowTagText = ({ state }) => () => state.isDisplayOnly;
|
|
|
1307
1407
|
const isTagClosable = () => (item) => !item.required;
|
|
1308
1408
|
const computedGetIcon = ({ designConfig, props }) => () => {
|
|
1309
1409
|
return props.dropdownIcon ? { icon: props.dropdownIcon } : {
|
|
1310
|
-
icon: (designConfig == null ? void 0 : designConfig.icons.dropdownIcon) || "icon-
|
|
1410
|
+
icon: (designConfig == null ? void 0 : designConfig.icons.dropdownIcon) || "icon-down-ward",
|
|
1311
1411
|
isDefault: true
|
|
1312
1412
|
};
|
|
1313
1413
|
};
|
|
@@ -1332,7 +1432,7 @@ const clearNoMatchValue = ({ props, emit }) => (newModelValue) => {
|
|
|
1332
1432
|
}
|
|
1333
1433
|
};
|
|
1334
1434
|
const handleDebouncedQueryChange = ({ state, api }) => debounce(state.debounce, (value) => {
|
|
1335
|
-
api.handleQueryChange(value);
|
|
1435
|
+
api.handleQueryChange(value, false, true);
|
|
1336
1436
|
});
|
|
1337
1437
|
const onClickCollapseTag = ({ state, props, nextTick, api }) => (event) => {
|
|
1338
1438
|
event.stopPropagation();
|
|
@@ -1358,6 +1458,7 @@ export {
|
|
|
1358
1458
|
computeMultipleLimit,
|
|
1359
1459
|
computeOptimizeOpts,
|
|
1360
1460
|
computedCollapseTagSize,
|
|
1461
|
+
computedCurrentSizeMap,
|
|
1361
1462
|
computedDisabledTooltipContent,
|
|
1362
1463
|
computedGetIcon,
|
|
1363
1464
|
computedGetTagType,
|
|
@@ -1413,6 +1514,7 @@ export {
|
|
|
1413
1514
|
onCopying,
|
|
1414
1515
|
onInputChange,
|
|
1415
1516
|
onMouseenterNative,
|
|
1517
|
+
onMouseenterSelf,
|
|
1416
1518
|
onMouseleaveNative,
|
|
1417
1519
|
onOptionDestroy,
|
|
1418
1520
|
queryChange,
|
|
@@ -1442,6 +1544,7 @@ export {
|
|
|
1442
1544
|
watchInputHover,
|
|
1443
1545
|
watchOptimizeOpts,
|
|
1444
1546
|
watchOptions,
|
|
1547
|
+
watchOptionsWhenAutoSelect,
|
|
1445
1548
|
watchPropsOption,
|
|
1446
1549
|
watchShowClose,
|
|
1447
1550
|
watchValue,
|