@opentinyvue/vue-renderless 3.27.0 → 3.27.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/base-select/index.js +177 -81
- package/base-select/vue.js +82 -20
- package/dropdown/index.js +9 -3
- package/file-upload/index.js +17 -4
- package/grid/static/array/eachTree.js +1 -0
- package/grid-select/index.js +416 -30
- package/grid-select/vue.js +103 -9
- package/package.json +1 -1
- package/picker/index.js +29 -12
- package/rich-text/index.js +42 -0
- package/select-wrapper/vue.js +133 -0
- package/tabs-mf/vue-nav.js +66 -9
- package/tree-select/index.js +13 -4
- package/tree-select/vue.js +19 -3
- package/types/date-picker.type.d.ts +38 -2
- package/types/file-upload.type.d.ts +1 -1
- package/types/input.type.d.ts +1 -1
- package/types/numeric.type.d.ts +1 -1
- package/types/picker.type.d.ts +38 -2
- package/types/popeditor.type.d.ts +76 -4
- package/types/popover.type.d.ts +1 -1
- package/types/transfer.type.d.ts +3 -3
- package/types/tree-menu.type.d.ts +38 -2
- package/types/upload-dragger.type.d.ts +1 -1
- package/types/{upload-list.type-d5ff675d.d.ts → upload-list.type-36a8374a.d.ts} +1 -1
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
package/base-select/index.js
CHANGED
|
@@ -64,11 +64,12 @@ const defaultOnQueryChange = ({ props, state, constants, api, nextTick }) => (va
|
|
|
64
64
|
}
|
|
65
65
|
setFilteredSelectCls(nextTick, state, props);
|
|
66
66
|
api.getOptionIndexArr();
|
|
67
|
-
state.magicKey = state.magicKey > 0 ? -1 : 1;
|
|
68
67
|
};
|
|
69
68
|
const queryChange = ({ props, state, constants }) => (value, isInput) => {
|
|
70
69
|
if (props.optimization && isInput) {
|
|
71
|
-
const filterDatas = state.initDatas.filter(
|
|
70
|
+
const filterDatas = state.initDatas.filter(
|
|
71
|
+
(item) => new RegExp(escapeRegexpString(value), "i").test(item[props.textField])
|
|
72
|
+
);
|
|
72
73
|
state.datas = filterDatas;
|
|
73
74
|
} else {
|
|
74
75
|
state.selectEmitter.emit(constants.EVENT_NAME.queryChange, value);
|
|
@@ -76,7 +77,7 @@ const queryChange = ({ props, state, constants }) => (value, isInput) => {
|
|
|
76
77
|
};
|
|
77
78
|
const setFilteredSelectCls = (nextTick, state, props) => {
|
|
78
79
|
nextTick(() => {
|
|
79
|
-
if (props.multiple && props.showAlloption && props.filterable && state.query && !props.remote) {
|
|
80
|
+
if (props.multiple && props.showAlloption && (props.filterable || props.searchable) && state.query && !props.remote) {
|
|
80
81
|
const filterSelectedVal = state.options.filter((item) => item.state.visible && item.state.itemSelected).map((opt) => opt.value);
|
|
81
82
|
const visibleOptions = state.options.filter((item) => item.state.visible);
|
|
82
83
|
if (filterSelectedVal.length === visibleOptions.length) {
|
|
@@ -106,7 +107,7 @@ const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (v
|
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
109
|
state.hoverIndex = -1;
|
|
109
|
-
if (props.multiple && props.filterable && !props.shape) {
|
|
110
|
+
if (props.multiple && (props.filterable || props.searchable) && !props.shape && !state.selectDisabled) {
|
|
110
111
|
nextTick(() => {
|
|
111
112
|
const length = vm.$refs.input.value.length * 15 + 20;
|
|
112
113
|
state.inputLength = state.collapseTags ? Math.min(50, length) : length;
|
|
@@ -130,8 +131,8 @@ const handleMenuEnter = ({ api, nextTick, state, props }) => () => {
|
|
|
130
131
|
nextTick(() => api.scrollToOption(state.selected));
|
|
131
132
|
}
|
|
132
133
|
};
|
|
133
|
-
const emitChange = ({ emit, props, state, constants }) => (value, changed) => {
|
|
134
|
-
if (state.device === "mb" && props.multiple && !changed)
|
|
134
|
+
const emitChange = ({ emit, props, state, constants, isMobileFirstMode }) => (value, changed) => {
|
|
135
|
+
if (isMobileFirstMode && state.device === "mb" && props.multiple && !changed)
|
|
135
136
|
return;
|
|
136
137
|
if (!isEqual(props.modelValue, state.compareValue)) {
|
|
137
138
|
emit("change", value);
|
|
@@ -165,15 +166,15 @@ const getOption = ({ props, state, api }) => (value) => {
|
|
|
165
166
|
if (props.optimization) {
|
|
166
167
|
option = api.getSelectedOption(value);
|
|
167
168
|
if (option) {
|
|
168
|
-
return { value: option.value, currentLabel: option.
|
|
169
|
+
return { value: option.value, currentLabel: option[props.textField] || option.currentLabel };
|
|
169
170
|
}
|
|
170
|
-
option = state.datas.find((v) => getObj(v, props.
|
|
171
|
+
option = state.datas.find((v) => getObj(v, props.valueField) === value);
|
|
171
172
|
if (option) {
|
|
172
|
-
return { value: option.
|
|
173
|
+
return { value: option[props.valueField], currentLabel: option[props.textField] || option.currentLabel };
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
const label = !isObject && !isNull2 && !isUndefined && !props.clearNoMatchValue ? value : "";
|
|
176
|
-
let newOption = { value, currentLabel: label };
|
|
177
|
+
let newOption = { value, currentLabel: label, isFakeLabel: true };
|
|
177
178
|
if (props.multiple) {
|
|
178
179
|
newOption.hitState = false;
|
|
179
180
|
}
|
|
@@ -182,9 +183,9 @@ const getOption = ({ props, state, api }) => (value) => {
|
|
|
182
183
|
const getSelectedOption = ({ props, state }) => (value) => {
|
|
183
184
|
let option;
|
|
184
185
|
if (props.multiple) {
|
|
185
|
-
option = state.selected.find((v) => getObj(v, props.
|
|
186
|
+
option = state.selected.find((v) => getObj(v, props.valueField) === value && !v.isFakeLabel);
|
|
186
187
|
} else {
|
|
187
|
-
if (!isEmptyObject(state.selected) && getObj(state.selected, props.
|
|
188
|
+
if (!isEmptyObject(state.selected) && getObj(state.selected, props.valueField) === value && !state.selected.isFakeLabel) {
|
|
188
189
|
option = state.selected;
|
|
189
190
|
}
|
|
190
191
|
}
|
|
@@ -195,13 +196,16 @@ const getOptionOfSetSelected = ({ api, props }) => {
|
|
|
195
196
|
if (!option.state) {
|
|
196
197
|
option.state = {};
|
|
197
198
|
}
|
|
199
|
+
if (option.currentLabel !== void 0 && option.state.currentLabel === void 0) {
|
|
200
|
+
option.state.currentLabel = option.currentLabel;
|
|
201
|
+
}
|
|
198
202
|
if (option.created) {
|
|
199
203
|
option.createdLabel = option.state.currentLabel;
|
|
200
204
|
option.createdSelected = true;
|
|
201
205
|
} else {
|
|
202
206
|
option.createdSelected = false;
|
|
203
207
|
}
|
|
204
|
-
if (!option.state.currentLabel) {
|
|
208
|
+
if (!option.state.currentLabel && !option.currentLabel) {
|
|
205
209
|
api.clearNoMatchValue("");
|
|
206
210
|
}
|
|
207
211
|
return option;
|
|
@@ -212,7 +216,8 @@ const getResultOfSetSelected = ({ state, api, props }) => {
|
|
|
212
216
|
if (Array.isArray(state.modelValue)) {
|
|
213
217
|
state.modelValue.forEach((value) => {
|
|
214
218
|
const option = api.getOption(value);
|
|
215
|
-
|
|
219
|
+
const hasLabel = (option == null ? void 0 : option.label) || (option == null ? void 0 : option.currentLabel) || (option == null ? void 0 : option.state) && option.state.currentLabel;
|
|
220
|
+
if (!props.clearNoMatchValue || props.clearNoMatchValue && hasLabel) {
|
|
216
221
|
result.push(option);
|
|
217
222
|
newModelValue.push(value);
|
|
218
223
|
}
|
|
@@ -226,7 +231,10 @@ const setSelected = ({ api, nextTick, props, vm, state }) => () => {
|
|
|
226
231
|
const option = getOptionOfSetSelected({ api, props });
|
|
227
232
|
state.selected = option;
|
|
228
233
|
state.selectedLabel = option.state.currentLabel || option.currentLabel;
|
|
229
|
-
props.filterable && !props.shape && (state.query = state.selectedLabel);
|
|
234
|
+
(props.filterable || props.searchable) && !props.shape && (state.query = state.selectedLabel);
|
|
235
|
+
if (vm.$slots.panel && state.selectedLabel && (props.filterable || props.searchable)) {
|
|
236
|
+
state.currentPlaceholder = "";
|
|
237
|
+
}
|
|
230
238
|
} else {
|
|
231
239
|
const result = getResultOfSetSelected({ state, props, api });
|
|
232
240
|
state.selectCls = result.length ? result.length === state.options.length ? "checked-sur" : "halfselect" : "check";
|
|
@@ -234,6 +242,9 @@ const setSelected = ({ api, nextTick, props, vm, state }) => () => {
|
|
|
234
242
|
state.selected = result;
|
|
235
243
|
}
|
|
236
244
|
state.selected.length && (state.selectedLabel = "");
|
|
245
|
+
if (vm.$slots.panel && result.length > 0 && (props.filterable || props.searchable)) {
|
|
246
|
+
state.currentPlaceholder = "";
|
|
247
|
+
}
|
|
237
248
|
state.tips = state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join(",");
|
|
238
249
|
setFilteredSelectCls(nextTick, state, props);
|
|
239
250
|
nextTick(api.resetInputHeight);
|
|
@@ -259,6 +270,7 @@ const toggleCheckAll = ({ api, state }) => (filtered) => {
|
|
|
259
270
|
value = [.../* @__PURE__ */ new Set([...state.modelValue, ...enabledValues])];
|
|
260
271
|
} else {
|
|
261
272
|
value = state.modelValue.filter((val) => !enabledValues.includes(val));
|
|
273
|
+
value = Array.from(/* @__PURE__ */ new Set([...state.modelValue, ...enabledValues]));
|
|
262
274
|
}
|
|
263
275
|
} else {
|
|
264
276
|
if (state.selectCls === "check") {
|
|
@@ -279,18 +291,28 @@ const toggleCheckAll = ({ api, state }) => (filtered) => {
|
|
|
279
291
|
api.directEmitChange(value);
|
|
280
292
|
};
|
|
281
293
|
const handleFocus = ({ emit, props, state }) => (event) => {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
294
|
+
state.willFocusRun = true;
|
|
295
|
+
state.willFocusTimer && clearTimeout(state.willFocusTimer);
|
|
296
|
+
state.willFocusTimer = setTimeout(() => {
|
|
297
|
+
state.willFocusTimer = 0;
|
|
298
|
+
if (!state.willFocusRun)
|
|
299
|
+
return;
|
|
300
|
+
if (!state.softFocus) {
|
|
301
|
+
if (props.shape === "filter") {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (props.automaticDropdown || props.filterable || props.searchable) {
|
|
305
|
+
state.visible = true;
|
|
306
|
+
state.softFocus = true;
|
|
307
|
+
}
|
|
290
308
|
emit("focus", event);
|
|
309
|
+
} else {
|
|
310
|
+
if (state.searchSingleCopy && state.selectedLabel) {
|
|
311
|
+
emit("focus", event);
|
|
312
|
+
}
|
|
313
|
+
state.softFocus = false;
|
|
291
314
|
}
|
|
292
|
-
|
|
293
|
-
}
|
|
315
|
+
}, 10);
|
|
294
316
|
};
|
|
295
317
|
const focus = ({ vm, state }) => () => {
|
|
296
318
|
if (!state.softFocus) {
|
|
@@ -303,6 +325,7 @@ const blur = ({ vm, state }) => () => {
|
|
|
303
325
|
};
|
|
304
326
|
const handleBlur = ({ constants, dispatch, emit, state, designConfig }) => (event) => {
|
|
305
327
|
var _a;
|
|
328
|
+
state.willFocusRun = false;
|
|
306
329
|
clearTimeout(state.timer);
|
|
307
330
|
state.timer = setTimeout(() => {
|
|
308
331
|
var _a2;
|
|
@@ -373,7 +396,7 @@ const resetInputState = ({ api, vm, state }) => (event) => {
|
|
|
373
396
|
api.resetInputHeight();
|
|
374
397
|
};
|
|
375
398
|
const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designConfig }) => () => {
|
|
376
|
-
if (state.collapseTags && !props.filterable) {
|
|
399
|
+
if (state.collapseTags && !(props.filterable || props.searchable)) {
|
|
377
400
|
return;
|
|
378
401
|
}
|
|
379
402
|
nextTick(() => {
|
|
@@ -390,7 +413,6 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
390
413
|
if (!state.isDisplayOnly && (props.hoverExpand || props.clickExpand) && !props.disabled) {
|
|
391
414
|
api.calcCollapseTags();
|
|
392
415
|
}
|
|
393
|
-
const sizeInMap = (designConfig == null ? void 0 : designConfig.state.initialInputHeight) || state.initialInputHeight || 32;
|
|
394
416
|
const noSelected = state.selected.length === 0;
|
|
395
417
|
const spacingHeight = (_b = (_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.spacingHeight) != null ? _b : constants.SPACING_HEIGHT;
|
|
396
418
|
if (!state.isDisplayOnly) {
|
|
@@ -398,11 +420,11 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
398
420
|
fastdom.measure(() => {
|
|
399
421
|
const tagsClientHeight = tags.clientHeight;
|
|
400
422
|
fastdom.mutate(() => {
|
|
401
|
-
input.style.height = Math.max(tagsClientHeight + spacingHeight,
|
|
423
|
+
input.style.height = Math.max(tagsClientHeight + spacingHeight, state.currentSizeMap) + "px";
|
|
402
424
|
});
|
|
403
425
|
});
|
|
404
426
|
} else {
|
|
405
|
-
input.style.height = noSelected ?
|
|
427
|
+
input.style.height = noSelected ? state.currentSizeMap + "px" : Math.max(0, state.currentSizeMap) + "px";
|
|
406
428
|
}
|
|
407
429
|
} else {
|
|
408
430
|
input.style.height = "auto";
|
|
@@ -440,6 +462,7 @@ const resetDatas = ({ props, state }) => () => {
|
|
|
440
462
|
}
|
|
441
463
|
};
|
|
442
464
|
const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byClick) => {
|
|
465
|
+
var _a;
|
|
443
466
|
state.memorize && state.memorize.updateByKey(option[state.memorize._dataKey] || option.value);
|
|
444
467
|
if (props.multiple) {
|
|
445
468
|
const value = (state.modelValue || []).slice();
|
|
@@ -459,8 +482,8 @@ const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byC
|
|
|
459
482
|
api.handleQueryChange("", isChange, isInput);
|
|
460
483
|
state.inputLength = 20;
|
|
461
484
|
}
|
|
462
|
-
if (props.filterable) {
|
|
463
|
-
vm.$refs.input.focus();
|
|
485
|
+
if (props.filterable || props.searchable) {
|
|
486
|
+
(_a = vm.$refs.input) == null ? void 0 : _a.focus();
|
|
464
487
|
}
|
|
465
488
|
if (props.autoClose) {
|
|
466
489
|
state.visible = false;
|
|
@@ -476,7 +499,8 @@ const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byC
|
|
|
476
499
|
state.visible = false;
|
|
477
500
|
}
|
|
478
501
|
state.isSilentBlur = byClick;
|
|
479
|
-
|
|
502
|
+
if (!props.automaticDropdown)
|
|
503
|
+
api.setSoftFocus();
|
|
480
504
|
if (state.visible) {
|
|
481
505
|
return;
|
|
482
506
|
}
|
|
@@ -488,13 +512,17 @@ const initValue = ({ state }) => (vm) => {
|
|
|
488
512
|
const isExist = state.initValue.find((val) => val === vm.value);
|
|
489
513
|
!isExist && state.initValue.push(vm.value);
|
|
490
514
|
};
|
|
491
|
-
const setSoftFocus = ({ vm, state }) => () => {
|
|
515
|
+
const setSoftFocus = ({ vm, state, props }) => () => {
|
|
516
|
+
if (vm.$slots.reference) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
492
519
|
state.softFocus = true;
|
|
493
520
|
const input = vm.$refs.input || vm.$refs.reference;
|
|
494
|
-
if (
|
|
495
|
-
input
|
|
521
|
+
if (!props.automaticDropdown) {
|
|
522
|
+
if (input) {
|
|
523
|
+
input.focus();
|
|
524
|
+
}
|
|
496
525
|
}
|
|
497
|
-
state.softFocus = false;
|
|
498
526
|
};
|
|
499
527
|
const getValueIndex = (props) => (arr = [], value = null) => {
|
|
500
528
|
const isObject = Object.prototype.toString.call(value).toLowerCase() === "[object object]";
|
|
@@ -513,22 +541,28 @@ const getValueIndex = (props) => (arr = [], value = null) => {
|
|
|
513
541
|
return index;
|
|
514
542
|
}
|
|
515
543
|
};
|
|
516
|
-
const toggleMenu = ({ vm, state, props, api }) => (e) => {
|
|
517
|
-
|
|
544
|
+
const toggleMenu = ({ vm, state, props, api, designConfig }) => (e) => {
|
|
545
|
+
var _a, _b, _c;
|
|
546
|
+
if (props.keepFocus && state.visible && (props.filterable || props.searchable)) {
|
|
518
547
|
return;
|
|
519
548
|
}
|
|
549
|
+
if (state.isIOS) {
|
|
550
|
+
state.selectHover = true;
|
|
551
|
+
state.inputHovering = true;
|
|
552
|
+
}
|
|
520
553
|
const event = e || window.event;
|
|
521
554
|
const enterCode = 13;
|
|
522
555
|
const nodeName = event.target && event.target.nodeName;
|
|
523
556
|
const toggleVisible = props.ignoreEnter ? event.keyCode !== enterCode && nodeName === "INPUT" : true;
|
|
524
|
-
|
|
557
|
+
const isStop = (_c = (_b = props.stopPropagation) != null ? _b : (_a = designConfig == null ? void 0 : designConfig.props) == null ? void 0 : _a.stopPropagation) != null ? _c : false;
|
|
558
|
+
if (!props.displayOnly && isStop) {
|
|
525
559
|
event.stopPropagation();
|
|
526
560
|
}
|
|
527
561
|
if (!state.selectDisabled) {
|
|
528
562
|
toggleVisible && !state.softFocus && (state.visible = !state.visible);
|
|
529
563
|
state.softFocus = false;
|
|
530
564
|
if (state.visible) {
|
|
531
|
-
if (!(props.filterable && props.shape)) {
|
|
565
|
+
if (!((props.filterable || props.searchable) && props.shape)) {
|
|
532
566
|
const dom = vm.$refs.input || vm.$refs.reference;
|
|
533
567
|
(dom == null ? void 0 : dom.focus) && dom.focus();
|
|
534
568
|
api.setOptionHighlight();
|
|
@@ -538,6 +572,7 @@ const toggleMenu = ({ vm, state, props, api }) => (e) => {
|
|
|
538
572
|
};
|
|
539
573
|
const selectOption = ({ api, state, props }) => (e) => {
|
|
540
574
|
if (!state.visible || props.hideDrop) {
|
|
575
|
+
state.softFocus = false;
|
|
541
576
|
api.toggleMenu(e);
|
|
542
577
|
} else {
|
|
543
578
|
let option = "";
|
|
@@ -581,7 +616,7 @@ const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (eve
|
|
|
581
616
|
};
|
|
582
617
|
const onInputChange = ({ api, props, state, constants, nextTick }) => () => {
|
|
583
618
|
if (!props.delay) {
|
|
584
|
-
if (props.filterable && state.query !== state.selectedLabel) {
|
|
619
|
+
if ((props.filterable || props.searchable) && state.query !== state.selectedLabel) {
|
|
585
620
|
const isChange = false;
|
|
586
621
|
const isInput = true;
|
|
587
622
|
state.query = state.selectedLabel;
|
|
@@ -744,7 +779,7 @@ const emptyText = ({ I18N, props, state, t, isMobileFirstMode }) => () => {
|
|
|
744
779
|
if (props.remote && state.query === "" && state.emptyFlag && !state.triggerSearch) {
|
|
745
780
|
return props.shape === "filter" || isMobileFirstMode ? "" : false;
|
|
746
781
|
}
|
|
747
|
-
if (props.filterable && state.query && (props.remote && state.emptyFlag || !state.options.some((option) => option.visible && option.state.visible))) {
|
|
782
|
+
if ((props.filterable || props.searchable) && state.query && (props.remote && state.emptyFlag || !state.options.some((option) => option.visible && option.state.visible))) {
|
|
748
783
|
return props.noMatchText || t(I18N.noMatch);
|
|
749
784
|
}
|
|
750
785
|
if (state.emptyFlag) {
|
|
@@ -761,19 +796,24 @@ const remoteEmptyText = function(props, state) {
|
|
|
761
796
|
const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, oldValue) => {
|
|
762
797
|
if (props.multiple) {
|
|
763
798
|
api.resetInputHeight();
|
|
764
|
-
if (value && value.length > 0
|
|
799
|
+
if (vm.$slots.panel && value && value.length > 0) {
|
|
800
|
+
state.currentPlaceholder = "";
|
|
801
|
+
} else if (value && value.length > 0 || vm.$refs.input && state.query !== "") {
|
|
765
802
|
state.currentPlaceholder = "";
|
|
766
803
|
} else {
|
|
767
804
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
768
805
|
}
|
|
769
|
-
if (props.filterable && !props.reserveKeyword) {
|
|
770
|
-
|
|
806
|
+
if ((props.filterable || props.searchable) && !props.reserveKeyword) {
|
|
807
|
+
const isChange = false;
|
|
808
|
+
const isInput = true;
|
|
809
|
+
state.query = "";
|
|
810
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
771
811
|
}
|
|
772
812
|
}
|
|
773
813
|
api.setSelected();
|
|
774
814
|
!state.isClickChoose && api.initQuery({ init: true }).then(() => api.setSelected());
|
|
775
815
|
state.isClickChoose = false;
|
|
776
|
-
if (props.filterable && !props.multiple) {
|
|
816
|
+
if ((props.filterable || props.searchable) && !props.multiple) {
|
|
777
817
|
state.inputLength = 20;
|
|
778
818
|
}
|
|
779
819
|
if (state.completed && !isEqual(value, oldValue)) {
|
|
@@ -814,21 +854,35 @@ const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
|
814
854
|
state.inputWidth = inputWidth;
|
|
815
855
|
}
|
|
816
856
|
};
|
|
817
|
-
const postOperOfToVisible = ({ props, state, constants }) => {
|
|
857
|
+
const postOperOfToVisible = ({ props, state, constants, vm }) => {
|
|
818
858
|
if (props.multiple) {
|
|
859
|
+
if (props.modelValue && props.modelValue.length && props.initLabel && !state.selected.length) {
|
|
860
|
+
state.selectedLabel = props.initLabel;
|
|
861
|
+
}
|
|
819
862
|
return;
|
|
820
863
|
}
|
|
821
864
|
if (state.selected) {
|
|
822
|
-
if (props.
|
|
823
|
-
state.selectedLabel = state.
|
|
865
|
+
if (props.renderType === constants.TYPE.Grid || props.renderType === constants.TYPE.Tree) {
|
|
866
|
+
state.selectedLabel = state.selected.currentLabel;
|
|
824
867
|
} else {
|
|
825
|
-
|
|
868
|
+
if ((props.filterable || props.searchable) && props.allowCreate && state.createdSelected && state.createdLabel) {
|
|
869
|
+
state.selectedLabel = state.createdLabel;
|
|
870
|
+
} else {
|
|
871
|
+
state.selectedLabel = state.selected.state.currentLabel || state.selected.currentLabel;
|
|
872
|
+
}
|
|
873
|
+
if (props.filterable || props.searchable) {
|
|
874
|
+
state.query = state.selectedLabel;
|
|
875
|
+
}
|
|
826
876
|
}
|
|
827
|
-
if (props.filterable) {
|
|
828
|
-
|
|
877
|
+
if (props.filterable || props.searchable) {
|
|
878
|
+
if (vm.$slots.panel && state.selectedLabel) {
|
|
879
|
+
state.currentPlaceholder = "";
|
|
880
|
+
} else {
|
|
881
|
+
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
882
|
+
}
|
|
829
883
|
}
|
|
830
|
-
if (props.
|
|
831
|
-
state.
|
|
884
|
+
if (props.modelValue && props.initLabel && !state.selectedLabel) {
|
|
885
|
+
state.selectedLabel = props.initLabel;
|
|
832
886
|
}
|
|
833
887
|
}
|
|
834
888
|
};
|
|
@@ -850,18 +904,19 @@ const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
|
850
904
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
851
905
|
}
|
|
852
906
|
});
|
|
853
|
-
postOperOfToVisible({ props, state, constants });
|
|
907
|
+
postOperOfToVisible({ props, state, constants, vm });
|
|
854
908
|
};
|
|
855
909
|
const toHide = ({ constants, state, props, vm, api }) => () => {
|
|
856
|
-
|
|
910
|
+
var _a;
|
|
911
|
+
const { remote, remoteConfig, shape, renderType, multiple, valueField } = props;
|
|
857
912
|
state.selectEmitter.emit(constants.COMPONENT_NAME.SelectDropdown, constants.EVENT_NAME.updatePopper);
|
|
858
|
-
if (filterable) {
|
|
913
|
+
if (props.filterable || props.searchable) {
|
|
859
914
|
state.query = remote || shape ? "" : state.selectedLabel;
|
|
860
915
|
const isChange = remote && remoteConfig.autoSearch && (state.firstAutoSearch || remoteConfig.clearData);
|
|
861
916
|
state.firstAutoSearch = false;
|
|
862
917
|
api.handleQueryChange(state.query, isChange);
|
|
863
918
|
if (multiple) {
|
|
864
|
-
vm.$refs.input.focus();
|
|
919
|
+
(_a = vm.$refs.input) == null ? void 0 : _a.focus();
|
|
865
920
|
} else {
|
|
866
921
|
if (!remote) {
|
|
867
922
|
state.selectEmitter.emit(constants.EVENT_NAME.queryChange, "");
|
|
@@ -874,14 +929,15 @@ const toHide = ({ constants, state, props, vm, api }) => () => {
|
|
|
874
929
|
}
|
|
875
930
|
}
|
|
876
931
|
};
|
|
877
|
-
const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) => {
|
|
878
|
-
|
|
879
|
-
|
|
932
|
+
const watchVisible = ({ api, constants, emit, state, vm, props, isMobileFirstMode }) => (value) => {
|
|
933
|
+
var _a;
|
|
934
|
+
if ((props.filterable || props.searchable || props.remote) && !value) {
|
|
935
|
+
(_a = vm.$refs.reference) == null ? void 0 : _a.blur();
|
|
880
936
|
}
|
|
881
937
|
if (api.onCopying()) {
|
|
882
938
|
return;
|
|
883
939
|
}
|
|
884
|
-
if (value && props.multiple && state.device === "mb") {
|
|
940
|
+
if (value && props.multiple && isMobileFirstMode && state.device === "mb") {
|
|
885
941
|
state.selectedCopy = state.selected.slice();
|
|
886
942
|
}
|
|
887
943
|
setTimeout(() => {
|
|
@@ -919,16 +975,32 @@ const watchOptions = ({ api, constants, nextTick, parent, props, state }) => ()
|
|
|
919
975
|
api.resetInputHeight();
|
|
920
976
|
}
|
|
921
977
|
nextTick(() => {
|
|
922
|
-
|
|
978
|
+
var _a;
|
|
979
|
+
if (parent.$el.querySelector("input") !== document.activeElement && // filterable时, 从 input 框离开了
|
|
980
|
+
!(((_a = document.activeElement) == null ? void 0 : _a.classList.contains("tiny-input__inner")) && // 并且当前不在下拉面板的searchable 的input中时, 才需要更新一下setSelect
|
|
981
|
+
document.activeElement.closest(".tiny-select-dropdown__search"))) {
|
|
923
982
|
api.setSelected();
|
|
924
983
|
}
|
|
925
984
|
});
|
|
926
985
|
api.getOptionIndexArr();
|
|
927
986
|
};
|
|
987
|
+
const watchOptionsWhenAutoSelect = ({ nextTick, props, state, api }) => () => {
|
|
988
|
+
if (props.autoSelect && props.remote) {
|
|
989
|
+
nextTick(() => {
|
|
990
|
+
var _a, _b;
|
|
991
|
+
if (((_a = props.options) == null ? void 0 : _a.length) === 1 || state.options.length === 1) {
|
|
992
|
+
const { valueField } = props;
|
|
993
|
+
const option = ((_b = props.options) == null ? void 0 : _b.length) === 1 ? props.options[0] : state.options[0];
|
|
994
|
+
api.updateModelValue(props.multiple ? [option[props.valueField]] : option[props.valueField]);
|
|
995
|
+
state.visible = false;
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
};
|
|
928
1000
|
const getOptionIndexArr = ({ props, state, api }) => () => {
|
|
929
1001
|
setTimeout(() => {
|
|
930
1002
|
state.optionIndexArr = api.queryVisibleOptions().map((item) => Number(item.getAttribute("data-index")));
|
|
931
|
-
if (props.defaultFirstOption && (props.filterable || props.remote) && state.filteredOptionsCount) {
|
|
1003
|
+
if (props.defaultFirstOption && (props.filterable || props.searchable || props.remote) && state.filteredOptionsCount) {
|
|
932
1004
|
if (props.optimization) {
|
|
933
1005
|
optmzApis.checkDefaultFirstOption({ state });
|
|
934
1006
|
} else {
|
|
@@ -956,7 +1028,7 @@ const handleCopyClick = ({ parent, props, state }) => () => {
|
|
|
956
1028
|
parent.$el.removeChild(input);
|
|
957
1029
|
};
|
|
958
1030
|
const debouncRquest = ({ api, state, props }) => debounce(props.delay, () => {
|
|
959
|
-
if (props.filterable && state.query !== state.selectedLabel) {
|
|
1031
|
+
if ((props.filterable || props.searchable) && state.query !== state.selectedLabel) {
|
|
960
1032
|
const isChange = false;
|
|
961
1033
|
const isInput = true;
|
|
962
1034
|
state.query = state.selectedLabel;
|
|
@@ -1009,6 +1081,12 @@ const onMouseenterNative = ({ state }) => () => {
|
|
|
1009
1081
|
state.softFocus = true;
|
|
1010
1082
|
}
|
|
1011
1083
|
};
|
|
1084
|
+
const onMouseenterSelf = ({ state }) => () => {
|
|
1085
|
+
if (!state.isIOS) {
|
|
1086
|
+
state.selectHover = true;
|
|
1087
|
+
state.inputHovering = true;
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1012
1090
|
const onMouseleaveNative = ({ state }) => (e) => {
|
|
1013
1091
|
if (e.target === e.currentTarget)
|
|
1014
1092
|
return;
|
|
@@ -1106,7 +1184,7 @@ const watchInputHover = ({ vm }) => (newVal) => {
|
|
|
1106
1184
|
}
|
|
1107
1185
|
};
|
|
1108
1186
|
const initQuery = ({ props, state, constants, vm }) => ({ init } = {}) => {
|
|
1109
|
-
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
1187
|
+
const isRemote = (props.filterable || props.searchable) && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
1110
1188
|
let selected;
|
|
1111
1189
|
if (isRemote && props.initQuery) {
|
|
1112
1190
|
let initData = props.initQuery(props.modelValue, props.extraQueryParams, !!init);
|
|
@@ -1123,8 +1201,13 @@ const initQuery = ({ props, state, constants, vm }) => ({ init } = {}) => {
|
|
|
1123
1201
|
}
|
|
1124
1202
|
return Promise.resolve(selected);
|
|
1125
1203
|
};
|
|
1126
|
-
const
|
|
1204
|
+
const computedCurrentSizeMap = ({ state, designConfig }) => () => {
|
|
1127
1205
|
var _a;
|
|
1206
|
+
const defaultSizeMap = { default: 32, mini: 24, small: 28, medium: 40 };
|
|
1207
|
+
const sizeMap = ((_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.sizeMap) || defaultSizeMap;
|
|
1208
|
+
return sizeMap[state.selectSize || "default"];
|
|
1209
|
+
};
|
|
1210
|
+
const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
1128
1211
|
const parentEl = parent.$el;
|
|
1129
1212
|
const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]');
|
|
1130
1213
|
const inputClientRect = inputEl && inputEl.getBoundingClientRect() || {};
|
|
@@ -1132,12 +1215,9 @@ const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
|
1132
1215
|
document.activeElement.blur();
|
|
1133
1216
|
}
|
|
1134
1217
|
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
1218
|
if (props.multiple && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
|
|
1138
1219
|
state.currentPlaceholder = "";
|
|
1139
1220
|
}
|
|
1140
|
-
state.initialInputHeight = state.isDisplayOnly ? sizeMap[state.selectSize || "default"] : inputClientRect.height || sizeMap[state.selectSize];
|
|
1141
1221
|
addResizeListener(parentEl, api.handleResize);
|
|
1142
1222
|
if (vm.$refs.tags) {
|
|
1143
1223
|
addResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
@@ -1146,7 +1226,12 @@ const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
|
1146
1226
|
api.resetInputHeight();
|
|
1147
1227
|
}
|
|
1148
1228
|
state.inputWidth = inputClientRect.width;
|
|
1149
|
-
api.initQuery({ init: true }).then(() =>
|
|
1229
|
+
api.initQuery({ init: true }).then(() => {
|
|
1230
|
+
api.setSelected(true);
|
|
1231
|
+
if (props.modelValue && props.initLabel) {
|
|
1232
|
+
state.selectedLabel = props.initLabel;
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1150
1235
|
if (props.dataset) {
|
|
1151
1236
|
api.watchPropsOption();
|
|
1152
1237
|
}
|
|
@@ -1225,9 +1310,9 @@ const computeMultipleLimit = ({ props, state }) => () => {
|
|
|
1225
1310
|
const { optimizeOpts } = state;
|
|
1226
1311
|
return optmzApis.natural(multiple && optimization ? multipleLimit || optimizeOpts.limit : multipleLimit);
|
|
1227
1312
|
};
|
|
1228
|
-
const updateModelValue = ({ props, emit, state }) => (value, needUpdate) => {
|
|
1313
|
+
const updateModelValue = ({ props, emit, state, isMobileFirstMode }) => (value, needUpdate) => {
|
|
1229
1314
|
state.isClickChoose = true;
|
|
1230
|
-
if (state.device === "mb" && props.multiple && !needUpdate) {
|
|
1315
|
+
if (isMobileFirstMode && state.device === "mb" && props.multiple && !needUpdate) {
|
|
1231
1316
|
state.modelValue = value;
|
|
1232
1317
|
} else {
|
|
1233
1318
|
emit("update:modelValue", value);
|
|
@@ -1265,17 +1350,25 @@ const computedTagsStyle = ({ props, parent, state, vm }) => () => {
|
|
|
1265
1350
|
}
|
|
1266
1351
|
return tagsStyle;
|
|
1267
1352
|
};
|
|
1268
|
-
const computedReadonly = ({ props, state }) => () =>
|
|
1353
|
+
const computedReadonly = ({ props, state, isMobileFirstMode }) => () => {
|
|
1354
|
+
if (state.isIOS && props.filterable) {
|
|
1355
|
+
return false;
|
|
1356
|
+
} else {
|
|
1357
|
+
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;
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1269
1360
|
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
1361
|
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);
|
|
1362
|
+
const computedShowNewOption = ({ props, state, isMobileFirstMode }) => () => {
|
|
1363
|
+
const query = isMobileFirstMode && state.device === "mb" ? state.queryValue : state.query;
|
|
1364
|
+
return (props.filterable || props.searchable) && props.allowCreate && query && !state.options.filter((option) => !option.created).some((option) => option.state.currentLabel === state.query);
|
|
1274
1365
|
};
|
|
1275
1366
|
const computedShowCopy = ({ props, state }) => () => props.multiple && props.copyable && state.inputHovering && state.selected.length;
|
|
1276
1367
|
const computedOptionsAllDisabled = (state) => () => state.options.filter((option) => option.visible).every((option) => option.disabled);
|
|
1277
|
-
const computedDisabledTooltipContent = (state
|
|
1278
|
-
|
|
1368
|
+
const computedDisabledTooltipContent = ({ state }) => () => {
|
|
1369
|
+
return state.displayOnlyContent;
|
|
1370
|
+
};
|
|
1371
|
+
const computedSelectDisabled = ({ state }) => () => state.isDisabled || state.isDisplayOnly;
|
|
1279
1372
|
const computedIsExpand = ({ props, state }) => () => {
|
|
1280
1373
|
const hoverExpanded = (state.selectHover || state.visible) && props.hoverExpand && !props.disabled;
|
|
1281
1374
|
const clickExpanded = props.clickExpand && state.exceedMaxVisibleRow && state.showCollapseTag;
|
|
@@ -1307,7 +1400,7 @@ const computedShowTagText = ({ state }) => () => state.isDisplayOnly;
|
|
|
1307
1400
|
const isTagClosable = () => (item) => !item.required;
|
|
1308
1401
|
const computedGetIcon = ({ designConfig, props }) => () => {
|
|
1309
1402
|
return props.dropdownIcon ? { icon: props.dropdownIcon } : {
|
|
1310
|
-
icon: (designConfig == null ? void 0 : designConfig.icons.dropdownIcon) || "icon-
|
|
1403
|
+
icon: (designConfig == null ? void 0 : designConfig.icons.dropdownIcon) || "icon-down-ward",
|
|
1311
1404
|
isDefault: true
|
|
1312
1405
|
};
|
|
1313
1406
|
};
|
|
@@ -1332,7 +1425,7 @@ const clearNoMatchValue = ({ props, emit }) => (newModelValue) => {
|
|
|
1332
1425
|
}
|
|
1333
1426
|
};
|
|
1334
1427
|
const handleDebouncedQueryChange = ({ state, api }) => debounce(state.debounce, (value) => {
|
|
1335
|
-
api.handleQueryChange(value);
|
|
1428
|
+
api.handleQueryChange(value, false, true);
|
|
1336
1429
|
});
|
|
1337
1430
|
const onClickCollapseTag = ({ state, props, nextTick, api }) => (event) => {
|
|
1338
1431
|
event.stopPropagation();
|
|
@@ -1358,6 +1451,7 @@ export {
|
|
|
1358
1451
|
computeMultipleLimit,
|
|
1359
1452
|
computeOptimizeOpts,
|
|
1360
1453
|
computedCollapseTagSize,
|
|
1454
|
+
computedCurrentSizeMap,
|
|
1361
1455
|
computedDisabledTooltipContent,
|
|
1362
1456
|
computedGetIcon,
|
|
1363
1457
|
computedGetTagType,
|
|
@@ -1413,6 +1507,7 @@ export {
|
|
|
1413
1507
|
onCopying,
|
|
1414
1508
|
onInputChange,
|
|
1415
1509
|
onMouseenterNative,
|
|
1510
|
+
onMouseenterSelf,
|
|
1416
1511
|
onMouseleaveNative,
|
|
1417
1512
|
onOptionDestroy,
|
|
1418
1513
|
queryChange,
|
|
@@ -1442,6 +1537,7 @@ export {
|
|
|
1442
1537
|
watchInputHover,
|
|
1443
1538
|
watchOptimizeOpts,
|
|
1444
1539
|
watchOptions,
|
|
1540
|
+
watchOptionsWhenAutoSelect,
|
|
1445
1541
|
watchPropsOption,
|
|
1446
1542
|
watchShowClose,
|
|
1447
1543
|
watchValue,
|