@opentiny/vue-renderless 3.13.1 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action-sheet/index.js +20 -13
- package/action-sheet/vue.js +8 -7
- package/amount/index.js +100 -25
- package/amount/vue.js +102 -26
- package/anchor/index.js +1 -0
- package/area/index.js +8 -8
- package/area/vue.js +5 -5
- package/async-flowchart/index.js +16 -3
- package/autocomplete/index.js +58 -14
- package/autocomplete/vue.js +40 -12
- package/badge/index.js +12 -0
- package/badge/vue.js +6 -4
- package/breadcrumb/vue.js +3 -1
- package/breadcrumb-item/vue.js +6 -2
- package/button/index.js +5 -1
- package/calendar/index.js +2 -86
- package/calendar-bar/index.js +18 -4
- package/calendar-view/index.js +5 -1
- package/calendar-view/vue.js +16 -3
- package/card-group/vue.js +4 -2
- package/cascader/index.js +86 -34
- package/cascader/vue.js +61 -20
- package/cascader-menu/index.js +7 -7
- package/cascader-menu/vue.js +2 -3
- package/cascader-mobile/index.js +36 -23
- package/cascader-mobile/vue.js +6 -0
- package/cascader-node/index.js +13 -1
- package/cascader-node/vue.js +15 -4
- package/cascader-panel/index.js +1 -1
- package/cascader-select/column-index.js +150 -0
- package/cascader-select/column.js +120 -0
- package/cascader-select/index.js +29 -165
- package/cascader-select/usePicker.js +251 -0
- package/cascader-select/useTouch.js +65 -0
- package/cascader-select/vue.js +35 -47
- package/cell/vue.js +2 -1
- package/chart-bar/index.js +2 -3
- package/chart-core/deps/constants.js +43 -43
- package/chart-core/index.js +1 -1
- package/chart-gauge/index.js +2 -2
- package/chart-heatmap/index.js +17 -10
- package/chart-line/index.js +8 -9
- package/chart-tree/index.js +2 -2
- package/chart-waterfall/index.js +4 -6
- package/checkbox/index.js +18 -1
- package/checkbox/vue.js +15 -7
- package/checkbox-group/vue.js +1 -0
- package/col/vue.js +1 -1
- package/collapse/index.js +3 -3
- package/color-select-panel/vue.js +0 -7
- package/column-list-item/index.js +17 -1
- package/column-list-item/vue.js +8 -3
- package/common/date.js +7 -5
- package/common/deps/clickoutside.js +6 -2
- package/common/deps/dom.js +19 -4
- package/common/deps/popper.js +44 -11
- package/common/deps/resize-event.js +1 -0
- package/common/deps/touch-emulator.js +4 -1
- package/common/deps/tree-model/node.js +2 -2
- package/common/deps/tree-model/tree-store.js +2 -13
- package/common/deps/useRect.js +25 -0
- package/common/deps/vue-popper.js +38 -20
- package/common/index.js +2 -2
- package/common/runtime.js +1 -1
- package/common/string.js +2 -2
- package/common/type.js +2 -1
- package/common/validate/rules/enum.js +1 -1
- package/common/validate/rules/pattern.js +2 -2
- package/common/validate/rules/range.js +8 -5
- package/common/validate/rules/required.js +1 -1
- package/common/validate/rules/type.js +5 -5
- package/common/validate/rules/whitespace.js +1 -1
- package/common/validate/util.js +15 -16
- package/common/validate/validations/integer.js +1 -1
- package/common/validate/validations/method.js +1 -1
- package/currency/index.js +74 -7
- package/currency/vue.js +21 -5
- package/date-panel/index.js +16 -0
- package/date-panel/vue.js +8 -2
- package/date-picker-mobile/index.js +12 -0
- package/date-picker-mobile/vue.js +7 -1
- package/date-range/vue.js +14 -6
- package/date-table/index.js +5 -0
- package/date-table/vue.js +3 -1
- package/dialog-box/index.js +46 -14
- package/dialog-box/vue.js +30 -7
- package/dialog-select/index.js +6 -3
- package/dialog-select/vue.js +8 -4
- package/drawer/index.js +27 -5
- package/drawer/vue.js +14 -7
- package/dropdown/index.js +7 -7
- package/dropdown/vue.js +6 -2
- package/dropdown-item/index.js +9 -1
- package/dropdown-item/mf.js +6 -10
- package/dropdown-item/vue.js +20 -7
- package/dropdown-menu/index.js +20 -7
- package/dropdown-menu/vue.js +4 -3
- package/exception/index.js +2 -7
- package/exception/vue.js +7 -10
- package/fall-menu/index.js +5 -1
- package/fall-menu/vue.js +13 -2
- package/file-upload/index.js +68 -18
- package/file-upload/vue.js +38 -8
- package/filter-box/index.js +1 -0
- package/float-button/index.js +42 -0
- package/float-button/vue.js +101 -0
- package/floating-button/index.js +62 -16
- package/floating-button/vue.js +27 -9
- package/flowchart/index.js +134 -25
- package/flowchart/node.js +13 -4
- package/flowchart/vue.js +16 -4
- package/form/vue.js +8 -0
- package/form-item/index.js +5 -5
- package/form-item/vue.js +3 -1
- package/fullscreen/index.js +5 -5
- package/fullscreen/vue.js +3 -3
- package/grid/plugins/export.js +5 -2
- package/grid/utils/column.js +1 -0
- package/grid/utils/dom.js +7 -1
- package/image/index.js +6 -1
- package/image/vue.js +6 -3
- package/image-viewer/index.js +62 -51
- package/image-viewer/vue.js +17 -5
- package/input/index.js +81 -20
- package/input/vue.js +44 -18
- package/ip-address/index.js +61 -19
- package/ip-address/vue.js +22 -4
- package/link/vue.js +3 -1
- package/loading/index.js +2 -2
- package/loading/vue.js +8 -2
- package/logout/index.js +1 -1
- package/menu/index.js +15 -2
- package/menu/vue.js +22 -17
- package/mind-map/index.js +47 -0
- package/mind-map/vue.js +53 -0
- package/modal/index.js +44 -4
- package/modal/vue.js +18 -4
- package/multi-select/index.js +186 -11
- package/multi-select/vue.js +60 -15
- package/multi-select-item/index.js +23 -0
- package/multi-select-item/vue.js +31 -0
- package/numeric/index.js +46 -12
- package/numeric/vue.js +44 -19
- package/option/index.js +27 -9
- package/option/vue.js +37 -21
- package/option-group/index.js +3 -3
- package/package.json +1 -1
- package/pager/index.js +18 -4
- package/pager/vue.js +16 -5
- package/picker/index.js +258 -49
- package/picker/mb.js +42 -0
- package/picker/vue.js +70 -17
- package/picker-column/index.js +1 -1
- package/pop-upload/vue.js +3 -0
- package/popconfirm/index.js +3 -6
- package/popconfirm/vue.js +1 -1
- package/popeditor/index.js +71 -32
- package/popeditor/vue.js +15 -11
- package/popover/index.js +4 -4
- package/popover/vue.js +6 -6
- package/popup/index.js +3 -3
- package/popup/vue.js +5 -5
- package/pull-refresh/index.js +13 -13
- package/pull-refresh/vue.js +5 -4
- package/radio/index.js +0 -17
- package/radio/vue.js +4 -10
- package/rate/index.js +1 -1
- package/rate/vue.js +0 -2
- package/record/index.js +4 -1
- package/rich-text/clipboard.js +54 -0
- package/rich-text/index.js +192 -0
- package/rich-text/module/file-upload.js +107 -0
- package/rich-text/module/image-drop.js +63 -0
- package/rich-text/module/image-upload.js +89 -0
- package/rich-text/options.js +141 -0
- package/rich-text/table-module.js +382 -0
- package/rich-text/vue.js +102 -0
- package/{rich-text-edtior → rich-text-editor}/index.js +2 -2
- package/{rich-text-edtior → rich-text-editor}/vue.js +2 -5
- package/scrollbar/index.js +11 -11
- package/scrollbar/vue-bar.js +3 -3
- package/scrollbar/vue.js +5 -5
- package/search/index.js +9 -9
- package/search/vue.js +8 -6
- package/select/index.js +457 -389
- package/select/vue.js +257 -161
- package/select-dropdown/index.js +61 -3
- package/select-dropdown/vue.js +85 -8
- package/select-view/index.js +3 -1
- package/selected-box/index.js +2 -0
- package/selected-box/vue.js +6 -3
- package/signature/index.js +241 -0
- package/signature/vue.js +88 -0
- package/skeleton/index.js +14 -0
- package/skeleton/vue.js +15 -0
- package/skeleton-item/vue.js +15 -0
- package/slider/index.js +70 -17
- package/slider/vue.js +16 -7
- package/split/index.js +5 -3
- package/split/vue.js +4 -6
- package/standard-list-item/index.js +15 -1
- package/standard-list-item/vue.js +6 -5
- package/steps/index.js +25 -2
- package/steps/slide-bar.js +8 -1
- package/steps/vue.js +15 -3
- package/tab-item-mf/vue.js +14 -8
- package/tab-nav/index.js +30 -5
- package/tab-nav/vue.js +16 -4
- package/tabbar/vue.js +9 -3
- package/tabbar-item/vue.js +3 -2
- package/tabs/index.js +16 -4
- package/tabs/vue.js +2 -1
- package/tabs-mf/index.js +20 -6
- package/tabs-mf/vue-nav.js +26 -11
- package/tabs-mf/vue.js +7 -7
- package/tabs-mf/wheel.js +1 -0
- package/tag/index.js +1 -1
- package/tag-group/index.js +2 -1
- package/time/index.js +5 -2
- package/time/vue.js +1 -1
- package/time-line/index.js +3 -3
- package/time-line/vue.js +2 -2
- package/time-picker-mobile/index.js +24 -5
- package/time-picker-mobile/vue.js +17 -7
- package/time-range/index.js +2 -0
- package/timeline-item/vue.js +1 -1
- package/tooltip/index.js +6 -3
- package/tooltip/vue.js +4 -4
- package/transfer/index.js +20 -22
- package/transfer/vue.js +1 -6
- package/transfer-panel/vue.js +3 -5
- package/tree/index.js +21 -4
- package/tree/vue.js +10 -8
- package/tree-menu/index.js +31 -5
- package/tree-menu/vue.js +28 -15
- package/tree-node/index.js +18 -18
- package/tree-node/vue.js +6 -5
- package/types/action-sheet.type.d.ts +118 -1
- package/types/alert.type.d.ts +1 -1
- package/types/amount.type.d.ts +168 -1
- package/types/area.type.d.ts +134 -1
- package/types/async-flowchart.type.d.ts +72 -0
- package/types/autocomplete.type.d.ts +199 -1
- package/types/badge.type.d.ts +3 -1
- package/types/breadcrumb-item.type.d.ts +2 -0
- package/types/breadcrumb.type.d.ts +2 -0
- package/types/button-group.type.d.ts +3 -3
- package/types/button.type.d.ts +4 -0
- package/types/cascader-menu.type.d.ts +3 -4
- package/types/cascader-node.type.d.ts +5 -2
- package/types/cascader-panel.type-2bd03be3.d.ts +241 -0
- package/types/cascader-panel.type.d.ts +3 -241
- package/types/cascader.type.d.ts +329 -1
- package/types/checkbox.type.d.ts +9 -3
- package/types/collapse.type.d.ts +20 -3
- package/types/date-picker.type.d.ts +37 -0
- package/types/dialog-box.type.d.ts +13 -3
- package/types/drawer.type.d.ts +133 -1
- package/types/{dropdown-item.type-8ea6c633.d.ts → dropdown-item.type-8475a549.d.ts} +7 -13
- package/types/dropdown-item.type.d.ts +1 -1
- package/types/dropdown-menu.type.d.ts +1 -1
- package/types/dropdown.type.d.ts +1 -5
- package/types/fall-menu.type.d.ts +94 -1
- package/types/file-upload.type.d.ts +1 -1
- package/types/float-button.type.d.ts +123 -0
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-d0fd42f3.d.ts → form.type-222799ae.d.ts} +5 -2
- package/types/form.type.d.ts +1 -1
- package/types/{index-e0250f63.d.ts → index-b012f687.d.ts} +9 -0
- package/types/input.type.d.ts +1 -5
- package/types/ip-address.type.d.ts +160 -1
- package/types/link.type.d.ts +6 -3
- package/types/loading.type.d.ts +7 -0
- package/types/milestone.type.d.ts +1 -1
- package/types/mind-map.type.d.ts +20 -0
- package/types/modal.type.d.ts +29 -2
- package/types/numeric.type.d.ts +41 -10
- package/types/pager.type.d.ts +13 -1
- package/types/picker.type.d.ts +18 -0
- package/types/popconfirm.type.d.ts +86 -1
- package/types/popeditor.type.d.ts +5 -1
- package/types/popover.type.d.ts +3 -3
- package/types/progress.type.d.ts +3 -1
- package/types/radio.type.d.ts +0 -4
- package/types/rate.type.d.ts +236 -1
- package/types/search.type.d.ts +88 -1
- package/types/shared.type.d.ts +1 -1
- package/types/skeleton-item.type.d.ts +38 -0
- package/types/skeleton.type.d.ts +45 -0
- package/types/slider.type.d.ts +49 -10
- package/types/steps.type.d.ts +15 -4
- package/types/switch.type.d.ts +3 -3
- package/types/tab-bar.type.d.ts +1 -1
- package/types/tab-nav.type.d.ts +7 -2
- package/types/tabs.type.d.ts +9 -1
- package/types/tag-group.type.d.ts +64 -1
- package/types/{time-line.type-d7daa669.d.ts → time-line.type-b155cb4f.d.ts} +12 -0
- package/types/time-line.type.d.ts +1 -1
- package/types/timeline-item.type.d.ts +1 -1
- package/types/tooltip.type.d.ts +2 -2
- package/types/transfer.type.d.ts +185 -1
- package/types/tree-menu.type.d.ts +210 -1
- package/types/upload-dragger.type.d.ts +2 -2
- package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-a29aea50.d.ts} +31 -8
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/types/user-head.type.d.ts +146 -1
- package/types/wizard.type.d.ts +1 -0
- package/upload/index.js +64 -34
- package/upload/vue.js +9 -5
- package/upload-dragger/index.js +22 -20
- package/upload-list/index.js +24 -18
- package/upload-list/vue.js +9 -4
- package/user/index.js +34 -25
- package/user/vue.js +1 -1
- package/user-head/index.js +3 -3
- package/watermark/index.js +11 -0
- package/wheel/index.js +3 -0
- package/wizard/vue.js +4 -2
- package/common/deps/modal-queue.js +0 -6
- package/common/deps/requestAnimationFrame.js +0 -25
package/select/index.js
CHANGED
|
@@ -4,24 +4,28 @@ import {
|
|
|
4
4
|
} from "../chunk-G2ADBYYC.js";
|
|
5
5
|
import { find } from "../common/array";
|
|
6
6
|
import { getObj, isEqual } from "../common/object";
|
|
7
|
-
import { hasClass } from "../common/deps/dom";
|
|
8
7
|
import { isKorean } from "../common/string";
|
|
9
8
|
import scrollIntoView from "../common/deps/scroll-into-view";
|
|
10
9
|
import PopupManager from "../common/deps/popup-manager";
|
|
11
10
|
import debounce from "../common/deps/debounce";
|
|
12
11
|
import { getDataset } from "../common/dataset";
|
|
13
12
|
import Memorize from "../common/deps/memorize";
|
|
14
|
-
import { isEmptyObject
|
|
13
|
+
import { isEmptyObject } from "../common/type";
|
|
15
14
|
import { addResizeListener, removeResizeListener } from "../common/deps/resize-event";
|
|
16
15
|
import { extend } from "../common/object";
|
|
17
16
|
import { BROWSER_NAME } from "../common";
|
|
18
17
|
import browserInfo from "../common/browser";
|
|
18
|
+
import { isNull } from "../common/type";
|
|
19
19
|
import { fastdom } from "../common/deps/fastdom";
|
|
20
|
+
import { deepClone } from "../picker-column";
|
|
21
|
+
import { escapeRegexpString } from "../option";
|
|
20
22
|
const handleComposition = ({ api, nextTick, state }) => (event) => {
|
|
21
23
|
const text = event.target.value;
|
|
22
24
|
if (event.type === "compositionend") {
|
|
23
25
|
state.isOnComposition = false;
|
|
24
|
-
|
|
26
|
+
const isChange = false;
|
|
27
|
+
const isInput = true;
|
|
28
|
+
nextTick(() => api.handleQueryChange(text, isChange, isInput));
|
|
25
29
|
} else {
|
|
26
30
|
const lastCharacter = text[text.length - 1] || "";
|
|
27
31
|
state.isOnComposition = !isKorean(lastCharacter);
|
|
@@ -69,7 +73,7 @@ const gridOnQueryChange = ({ props, vm, constants, state }) => (value) => {
|
|
|
69
73
|
state.remoteData = data.filter((row) => !~selectedIds.indexOf(row[valueField])).concat(state.selected);
|
|
70
74
|
} else {
|
|
71
75
|
vm.$refs.selectGrid.clearRadioRow();
|
|
72
|
-
vm.$refs.selectGrid.setRadioRow(find(data, (item) => props.modelValue
|
|
76
|
+
vm.$refs.selectGrid.setRadioRow(find(data, (item) => props.modelValue === item[props.valueField]));
|
|
73
77
|
state.remoteData = data;
|
|
74
78
|
}
|
|
75
79
|
vm.$refs.selectGrid.$refs.tinyTable.lastScrollTop = 0;
|
|
@@ -78,7 +82,7 @@ const gridOnQueryChange = ({ props, vm, constants, state }) => (value) => {
|
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
84
|
};
|
|
81
|
-
const defaultOnQueryChange = ({ props, state, constants, api }) => (value) => {
|
|
85
|
+
const defaultOnQueryChange = ({ props, state, constants, api, nextTick }) => (value, isInput) => {
|
|
82
86
|
if (props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
83
87
|
state.hoverIndex = -1;
|
|
84
88
|
props.remoteMethod && props.remoteMethod(value, props.extraQueryParams);
|
|
@@ -86,13 +90,36 @@ const defaultOnQueryChange = ({ props, state, constants, api }) => (value) => {
|
|
|
86
90
|
props.filterMethod(value);
|
|
87
91
|
state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup, constants.EVENT_NAME.queryChange);
|
|
88
92
|
} else {
|
|
89
|
-
|
|
93
|
+
api.queryChange(value, isInput);
|
|
90
94
|
}
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
setFilteredSelectCls(nextTick, state, props);
|
|
96
|
+
api.getOptionIndexArr();
|
|
97
|
+
state.magicKey = state.magicKey > 0 ? -1 : 1;
|
|
98
|
+
};
|
|
99
|
+
const queryChange = ({ props, state, constants }) => (value, isInput) => {
|
|
100
|
+
if (props.optimization && isInput) {
|
|
101
|
+
const filterDatas = state.initDatas.filter((item) => new RegExp(escapeRegexpString(value), "i").test(item.label));
|
|
102
|
+
state.datas = filterDatas;
|
|
103
|
+
} else {
|
|
104
|
+
state.selectEmitter.emit(constants.EVENT_NAME.queryChange, value);
|
|
93
105
|
}
|
|
94
106
|
};
|
|
95
|
-
const
|
|
107
|
+
const setFilteredSelectCls = (nextTick, state, props) => {
|
|
108
|
+
nextTick(() => {
|
|
109
|
+
if (props.multiple && props.showAlloption && props.filterable && state.query && !props.remote) {
|
|
110
|
+
const filterSelectedVal = state.options.filter((item) => item.state.visible && item.state.itemSelected).map((opt) => opt.value);
|
|
111
|
+
const visibleOptions = state.options.filter((item) => item.state.visible);
|
|
112
|
+
if (filterSelectedVal.length === visibleOptions.length) {
|
|
113
|
+
state.filteredSelectCls = "checked-sur";
|
|
114
|
+
} else if (filterSelectedVal.length === 0) {
|
|
115
|
+
state.filteredSelectCls = "check";
|
|
116
|
+
} else {
|
|
117
|
+
state.filteredSelectCls = "halfselect";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (value, isChange = false, isInput = false) => {
|
|
96
123
|
if (state.previousQuery === value && !isChange || state.isOnComposition) {
|
|
97
124
|
return;
|
|
98
125
|
}
|
|
@@ -106,10 +133,11 @@ const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (v
|
|
|
106
133
|
}
|
|
107
134
|
if (props.renderType === constants.TYPE.Tree) {
|
|
108
135
|
state.previousQuery = value;
|
|
109
|
-
if (
|
|
136
|
+
if (props.filterable && typeof props.filterMethod === "function") {
|
|
110
137
|
vm.$refs.selectTree && vm.$refs.selectTree.filter(value);
|
|
111
138
|
}
|
|
112
139
|
}
|
|
140
|
+
state.query = value;
|
|
113
141
|
state.previousQuery = value;
|
|
114
142
|
window.requestAnimationFrame(() => {
|
|
115
143
|
if (state.visible) {
|
|
@@ -120,38 +148,34 @@ const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (v
|
|
|
120
148
|
state.hoverIndex = -1;
|
|
121
149
|
if (props.multiple && props.filterable && !props.shape) {
|
|
122
150
|
nextTick(() => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
api.resetInputHeight();
|
|
128
|
-
}
|
|
151
|
+
const length = vm.$refs.input.value.length * 15 + 20;
|
|
152
|
+
state.inputLength = state.collapseTags ? Math.min(50, length) : length;
|
|
153
|
+
api.managePlaceholder();
|
|
154
|
+
api.resetInputHeight();
|
|
129
155
|
});
|
|
130
156
|
}
|
|
131
157
|
if (props.renderType === constants.TYPE.Tree) {
|
|
132
158
|
return;
|
|
133
159
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const debouncedQueryChange = ({ props, api }) => (event) => {
|
|
137
|
-
const value = props.shape ? event : event.target.value;
|
|
138
|
-
api.handleDebouncedQueryChange(value);
|
|
160
|
+
state.triggerSearch = true;
|
|
161
|
+
api.defaultOnQueryChange(value, isInput);
|
|
139
162
|
};
|
|
140
|
-
const handleDebouncedQueryChange = ({ state, api }) => debounce(state.debounce, (value) => {
|
|
141
|
-
api.handleQueryChange(value);
|
|
142
|
-
});
|
|
143
163
|
const scrollToOption = ({ vm, constants }) => (option) => {
|
|
144
|
-
const target = Array.isArray(option) && option[0] ? option[0].el : option.el;
|
|
164
|
+
const target = Array.isArray(option) && option[0] && option[0].state ? option[0].state.el : option.state ? option.state.el : "";
|
|
145
165
|
if (vm.$refs.popper && target) {
|
|
146
166
|
const menu = vm.$refs.popper.$el.querySelector(constants.CLASS.SelectDropdownWrap);
|
|
147
|
-
scrollIntoView(menu, target);
|
|
167
|
+
setTimeout(() => scrollIntoView(menu, target));
|
|
148
168
|
}
|
|
149
169
|
vm.$refs.scrollbar && vm.$refs.scrollbar.handleScroll();
|
|
150
170
|
};
|
|
151
|
-
const handleMenuEnter = ({ api, nextTick, state }) => () => {
|
|
152
|
-
|
|
171
|
+
const handleMenuEnter = ({ api, nextTick, state, props }) => () => {
|
|
172
|
+
if (!props.optimization) {
|
|
173
|
+
nextTick(() => api.scrollToOption(state.selected));
|
|
174
|
+
}
|
|
153
175
|
};
|
|
154
|
-
const emitChange = ({ emit, props, state, constants }) => (value) => {
|
|
176
|
+
const emitChange = ({ emit, props, state, constants }) => (value, changed) => {
|
|
177
|
+
if (state.device === "mb" && props.multiple && !changed)
|
|
178
|
+
return;
|
|
155
179
|
const seekItem = (val, arr, items, flag) => {
|
|
156
180
|
if (constants.TYPE.Tree === flag) {
|
|
157
181
|
const recurNode = (node) => {
|
|
@@ -168,7 +192,7 @@ const emitChange = ({ emit, props, state, constants }) => (value) => {
|
|
|
168
192
|
}
|
|
169
193
|
}
|
|
170
194
|
};
|
|
171
|
-
if (!isEqual(props.modelValue,
|
|
195
|
+
if (!isEqual(props.modelValue, state.compareValue)) {
|
|
172
196
|
if (props.renderType === constants.TYPE.Grid && props.multiple) {
|
|
173
197
|
value = value || [];
|
|
174
198
|
const gridData = state.gridData || [];
|
|
@@ -190,47 +214,55 @@ const emitChange = ({ emit, props, state, constants }) => (value) => {
|
|
|
190
214
|
}
|
|
191
215
|
}
|
|
192
216
|
};
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
217
|
+
const directEmitChange = ({ emit, props, state }) => (value, key) => {
|
|
218
|
+
if (state.device === "mb" && props.multiple)
|
|
195
219
|
return;
|
|
196
|
-
|
|
197
|
-
if (props.multiple && props.modelValue.length !== newModelValue.length || !props.multiple && props.modelValue !== newModelValue) {
|
|
198
|
-
emit("update:modelValue", newModelValue);
|
|
199
|
-
}
|
|
220
|
+
emit("change", value, key);
|
|
200
221
|
};
|
|
201
|
-
const getOption = ({ props, state }) => (value) => {
|
|
222
|
+
const getOption = ({ props, state, api }) => (value) => {
|
|
202
223
|
let option;
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
224
|
+
const isObject = Object.prototype.toString.call(value).toLowerCase() === "[object object]";
|
|
225
|
+
const isNull2 = Object.prototype.toString.call(value).toLowerCase() === "[object null]";
|
|
226
|
+
const isUndefined = Object.prototype.toString.call(value).toLowerCase() === "[object undefined]";
|
|
227
|
+
for (let i = state.cachedOptions.length - 1; i >= 0; i--) {
|
|
228
|
+
const cachedOption = state.cachedOptions[i];
|
|
229
|
+
const isEqual2 = isObject ? getObj(cachedOption.value, props.valueKey) === getObj(value, props.valueKey) : cachedOption.value === value;
|
|
207
230
|
if (isEqual2) {
|
|
208
231
|
option = cachedOption;
|
|
209
232
|
break;
|
|
210
233
|
}
|
|
211
234
|
}
|
|
212
235
|
if (option) {
|
|
213
|
-
|
|
214
|
-
const cloneOption = extend(true, {}, option);
|
|
215
|
-
cloneOption.currentLabel = cloneOption[props.textField];
|
|
216
|
-
return cloneOption;
|
|
217
|
-
} else {
|
|
218
|
-
if (!option.currentLabel) {
|
|
219
|
-
option.currentLabel = option[props.textField];
|
|
220
|
-
}
|
|
221
|
-
return option;
|
|
222
|
-
}
|
|
236
|
+
return option;
|
|
223
237
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
238
|
+
if (props.optimization) {
|
|
239
|
+
option = api.getSelectedOption(value);
|
|
240
|
+
if (option) {
|
|
241
|
+
return { value: option.value, currentLabel: option.label || option.currentLabel };
|
|
242
|
+
}
|
|
243
|
+
option = state.datas.find((v) => getObj(v, props.valueKey) === value);
|
|
244
|
+
if (option) {
|
|
245
|
+
return { value: option.value, currentLabel: option.label || option.currentLabel };
|
|
246
|
+
}
|
|
227
247
|
}
|
|
248
|
+
const label = !isObject && !isNull2 && !isUndefined && !props.clearNoMatchValue ? value : "";
|
|
228
249
|
let newOption = { value, currentLabel: label };
|
|
229
250
|
if (props.multiple) {
|
|
230
251
|
newOption.hitState = false;
|
|
231
252
|
}
|
|
232
253
|
return newOption;
|
|
233
254
|
};
|
|
255
|
+
const getSelectedOption = ({ props, state }) => (value) => {
|
|
256
|
+
let option;
|
|
257
|
+
if (props.multiple) {
|
|
258
|
+
option = state.selected.find((v) => getObj(v, props.valueKey) === value);
|
|
259
|
+
} else {
|
|
260
|
+
if (!isEmptyObject(state.selected) && getObj(state.selected, props.valueKey) === value) {
|
|
261
|
+
option = state.selected;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return option;
|
|
265
|
+
};
|
|
234
266
|
const getOptionOfSetSelected = ({ api, props }) => {
|
|
235
267
|
const option = api.getOption(props.modelValue) || {};
|
|
236
268
|
if (!option.state) {
|
|
@@ -247,11 +279,11 @@ const getOptionOfSetSelected = ({ api, props }) => {
|
|
|
247
279
|
}
|
|
248
280
|
return option;
|
|
249
281
|
};
|
|
250
|
-
const getResultOfSetSelected = ({
|
|
282
|
+
const getResultOfSetSelected = ({ state, isGrid, isTree, api, props }) => {
|
|
251
283
|
let result = [];
|
|
252
284
|
const newModelValue = [];
|
|
253
|
-
if (Array.isArray(
|
|
254
|
-
|
|
285
|
+
if (Array.isArray(state.modelValue)) {
|
|
286
|
+
state.modelValue.forEach((value) => {
|
|
255
287
|
if (isGrid || isTree) {
|
|
256
288
|
const option = api.getPluginOption(value, isTree);
|
|
257
289
|
result = result.concat(option);
|
|
@@ -260,7 +292,7 @@ const getResultOfSetSelected = ({ props, isGrid, isTree, api }) => {
|
|
|
260
292
|
}
|
|
261
293
|
} else {
|
|
262
294
|
const option = api.getOption(value);
|
|
263
|
-
if (!props.clearNoMatchValue || props.clearNoMatchValue && option.
|
|
295
|
+
if (!props.clearNoMatchValue || props.clearNoMatchValue && option.label) {
|
|
264
296
|
result.push(option);
|
|
265
297
|
newModelValue.push(value);
|
|
266
298
|
}
|
|
@@ -279,14 +311,14 @@ const setGridOrTreeSelected = ({ props, state, vm, isTree, api }) => {
|
|
|
279
311
|
vm.$refs.selectTree && vm.$refs.selectTree.setCurrentKey && vm.$refs.selectTree.setCurrentKey(null);
|
|
280
312
|
return;
|
|
281
313
|
}
|
|
282
|
-
const isRemote =
|
|
314
|
+
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
283
315
|
const nestdata = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
|
|
284
|
-
const data = find(nestdata, (item) => props.modelValue
|
|
316
|
+
const data = find(nestdata, (item) => props.modelValue === item[props.valueField]);
|
|
285
317
|
if (isEmptyObject(data)) {
|
|
286
318
|
api.clearNoMatchValue("");
|
|
287
319
|
return;
|
|
288
320
|
}
|
|
289
|
-
const obj =
|
|
321
|
+
const obj = Object.assign({}, data);
|
|
290
322
|
const label = data[props.textField];
|
|
291
323
|
obj.currentLabel = label;
|
|
292
324
|
state.selectedLabel = label;
|
|
@@ -301,28 +333,25 @@ const setSelected = ({ api, constants, nextTick, props, vm, state }) => () => {
|
|
|
301
333
|
setGridOrTreeSelected({ props, state, vm, isTree, api });
|
|
302
334
|
} else {
|
|
303
335
|
const option = getOptionOfSetSelected({ api, props });
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (state.filterOrSearch && !props.shape && !props.allowCreate) {
|
|
308
|
-
state.query = state.selectedLabel;
|
|
309
|
-
}
|
|
310
|
-
});
|
|
336
|
+
state.selected = option;
|
|
337
|
+
state.selectedLabel = option.state.currentLabel || option.currentLabel;
|
|
338
|
+
props.filterable && !props.shape && (state.query = state.selectedLabel);
|
|
311
339
|
}
|
|
312
|
-
|
|
340
|
+
} else {
|
|
341
|
+
const result = getResultOfSetSelected({ state, props, isGrid, isTree, api });
|
|
342
|
+
state.selectCls = result.length ? result.length === state.options.length ? "checked-sur" : "halfselect" : "check";
|
|
343
|
+
state.selected = result;
|
|
344
|
+
vm.$refs.selectTree && vm.$refs.selectTree.setCheckedNodes && vm.$refs.selectTree.setCheckedNodes(state.selected);
|
|
345
|
+
state.tips = state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join(",");
|
|
346
|
+
setFilteredSelectCls(nextTick, state, props);
|
|
347
|
+
nextTick(api.resetInputHeight);
|
|
313
348
|
}
|
|
314
|
-
const result = getResultOfSetSelected({ props, isGrid, isTree, api });
|
|
315
|
-
state.selectCls = result.length ? result.length === state.options.length ? "checked-sur" : "halfselect" : "check";
|
|
316
|
-
state.selected = result;
|
|
317
|
-
vm.$refs.selectTree && vm.$refs.selectTree.setCheckedNodes && vm.$refs.selectTree.setCheckedNodes(state.selected);
|
|
318
|
-
state.tips = state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join(",");
|
|
319
|
-
nextTick(api.resetInputHeight);
|
|
320
349
|
};
|
|
321
350
|
const getPluginOption = ({ api, props, state }) => (value, isTree) => {
|
|
322
|
-
const isRemote =
|
|
351
|
+
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
323
352
|
const { textField, valueField } = props;
|
|
324
353
|
const sourceData = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
|
|
325
|
-
const selNode = find(sourceData, (item) => item[valueField]
|
|
354
|
+
const selNode = find(sourceData, (item) => item[valueField] === value);
|
|
326
355
|
const items = [];
|
|
327
356
|
if (selNode) {
|
|
328
357
|
selNode.currentLabel = selNode[textField];
|
|
@@ -330,46 +359,49 @@ const getPluginOption = ({ api, props, state }) => (value, isTree) => {
|
|
|
330
359
|
}
|
|
331
360
|
return items;
|
|
332
361
|
};
|
|
333
|
-
const toggleCheckAll = ({ api,
|
|
362
|
+
const toggleCheckAll = ({ api, state, props }) => (filtered) => {
|
|
334
363
|
const getEnabledValues = (options) => {
|
|
335
364
|
let values = [];
|
|
336
365
|
for (let i = 0; i < options.length; i++) {
|
|
337
|
-
|
|
338
|
-
|
|
366
|
+
const isEnabled = !options[i].state.disabled && !options[i].state.groupDisabled;
|
|
367
|
+
const isRequired = options[i].required;
|
|
368
|
+
const isDisabledAndChecked = !isEnabled && options[i].state.selectCls === "checked-sur";
|
|
369
|
+
if (state.isSelectAll) {
|
|
370
|
+
if (isRequired || isDisabledAndChecked) {
|
|
371
|
+
values.push(options[i].value);
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
if (isEnabled || isRequired || isDisabledAndChecked) {
|
|
375
|
+
values.push(options[i].value);
|
|
376
|
+
}
|
|
339
377
|
}
|
|
340
378
|
}
|
|
341
379
|
return values;
|
|
342
380
|
};
|
|
343
381
|
let value;
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
state.
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
})
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
value = requiredValue.concat(value.filter((val) => !requiredValue.find((requireVal) => requireVal === val)));
|
|
382
|
+
const enabledValues = getEnabledValues(state.options);
|
|
383
|
+
if (filtered) {
|
|
384
|
+
if (state.filteredSelectCls === "check" || state.filteredSelectCls === "halfselect") {
|
|
385
|
+
value = [.../* @__PURE__ */ new Set([...state.modelValue, ...enabledValues])];
|
|
386
|
+
} else {
|
|
387
|
+
value = state.modelValue.filter((val) => !enabledValues.includes(val));
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
if (state.selectCls === "check") {
|
|
391
|
+
value = enabledValues;
|
|
392
|
+
} else if (state.selectCls === "halfselect") {
|
|
393
|
+
const unchecked = state.options.filter((item) => !item.state.disabled && item.state.selectCls === "check");
|
|
394
|
+
unchecked.length ? value = enabledValues : value = [];
|
|
395
|
+
} else if (state.selectCls === "checked-sur") {
|
|
396
|
+
value = getEnabledValues(state.options);
|
|
397
|
+
}
|
|
361
398
|
}
|
|
362
399
|
api.setSoftFocus();
|
|
363
400
|
state.isSilentBlur = true;
|
|
364
401
|
api.updateModelValue(value);
|
|
365
|
-
|
|
366
|
-
};
|
|
367
|
-
const resetFilter = ({ state, api }) => () => {
|
|
368
|
-
state.query = "";
|
|
369
|
-
state.previousQuery = void 0;
|
|
370
|
-
api.handleQueryChange(state.query);
|
|
402
|
+
api.directEmitChange(value);
|
|
371
403
|
};
|
|
372
|
-
const handleFocus = ({ emit, props, state
|
|
404
|
+
const handleFocus = ({ emit, props, state }) => (event) => {
|
|
373
405
|
if (!state.softFocus) {
|
|
374
406
|
if (props.automaticDropdown || props.filterable) {
|
|
375
407
|
state.visible = true;
|
|
@@ -377,26 +409,22 @@ const handleFocus = ({ emit, props, state, api }) => (event) => {
|
|
|
377
409
|
}
|
|
378
410
|
emit("focus", event);
|
|
379
411
|
} else {
|
|
412
|
+
if (state.searchSingleCopy && state.selectedLabel) {
|
|
413
|
+
emit("focus", event);
|
|
414
|
+
}
|
|
380
415
|
state.softFocus = false;
|
|
381
416
|
}
|
|
382
|
-
if (props.remote && state.filterOrSearch && state.firstAutoSearch) {
|
|
383
|
-
state.firstAutoSearch = false;
|
|
384
|
-
api.resetFilter();
|
|
385
|
-
}
|
|
386
417
|
};
|
|
387
418
|
const focus = ({ vm, state }) => () => {
|
|
388
|
-
var _a;
|
|
389
419
|
if (!state.softFocus) {
|
|
390
|
-
|
|
420
|
+
vm.$refs.reference.focus();
|
|
391
421
|
}
|
|
392
422
|
};
|
|
393
423
|
const blur = ({ vm, state }) => () => {
|
|
394
|
-
var _a;
|
|
395
424
|
state.visible = false;
|
|
396
|
-
|
|
425
|
+
vm.$refs.reference.blur();
|
|
397
426
|
};
|
|
398
427
|
const handleBlur = ({ constants, dispatch, emit, state }) => (event) => {
|
|
399
|
-
var _a;
|
|
400
428
|
clearTimeout(state.timer);
|
|
401
429
|
state.timer = setTimeout(() => {
|
|
402
430
|
if (state.isSilentBlur) {
|
|
@@ -405,7 +433,7 @@ const handleBlur = ({ constants, dispatch, emit, state }) => (event) => {
|
|
|
405
433
|
emit("blur", event);
|
|
406
434
|
}
|
|
407
435
|
}, 200);
|
|
408
|
-
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formBlur,
|
|
436
|
+
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formBlur, event.target.value);
|
|
409
437
|
state.softFocus = false;
|
|
410
438
|
};
|
|
411
439
|
const handleClearClick = (api) => (event) => {
|
|
@@ -425,6 +453,9 @@ const toggleLastOptionHitState = ({ state }) => (hit) => {
|
|
|
425
453
|
if (!option) {
|
|
426
454
|
return;
|
|
427
455
|
}
|
|
456
|
+
if (option.required) {
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
428
459
|
const hitTarget = option.state || option;
|
|
429
460
|
if (hit === true || hit === false) {
|
|
430
461
|
hitTarget.hitState = hit;
|
|
@@ -435,8 +466,9 @@ const toggleLastOptionHitState = ({ state }) => (hit) => {
|
|
|
435
466
|
};
|
|
436
467
|
const deletePrevTag = ({ api, constants, props, state, vm }) => (event) => {
|
|
437
468
|
if (event.target.value.length <= 0 && !api.toggleLastOptionHitState()) {
|
|
438
|
-
const value =
|
|
469
|
+
const value = state.modelValue.slice();
|
|
439
470
|
value.pop();
|
|
471
|
+
state.compareValue = deepClone(value);
|
|
440
472
|
api.updateModelValue(value);
|
|
441
473
|
api.emitChange(value);
|
|
442
474
|
if (props.renderType === constants.TYPE.Grid) {
|
|
@@ -467,9 +499,7 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
467
499
|
if (!vm.$refs.reference) {
|
|
468
500
|
return;
|
|
469
501
|
}
|
|
470
|
-
|
|
471
|
-
const inputContainer = [].filter.call(inputChildNodes, (item) => hasClass(item, "tiny-input-display-only"))[0];
|
|
472
|
-
const input = inputContainer && inputContainer.querySelector("input");
|
|
502
|
+
let input = vm.$refs.reference.type === "text" && vm.$refs.reference.$el.querySelector("input");
|
|
473
503
|
const tags = vm.$refs.tags;
|
|
474
504
|
if (!input) {
|
|
475
505
|
return;
|
|
@@ -477,14 +507,15 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
477
507
|
if (!state.isDisplayOnly && props.hoverExpand && !props.disabled) {
|
|
478
508
|
api.calcCollapseTags();
|
|
479
509
|
}
|
|
480
|
-
const sizeInMap =
|
|
510
|
+
const sizeInMap = state.initialInputHeight || (state.isSaaSTheme ? 28 : 30);
|
|
481
511
|
const noSelected = state.selected.length === 0;
|
|
512
|
+
const spacingHeight = designConfig ? (_a = designConfig.state) == null ? void 0 : _a.spacingHeight : 2;
|
|
482
513
|
if (!state.isDisplayOnly) {
|
|
483
514
|
if (!noSelected && tags) {
|
|
484
515
|
fastdom.measure(() => {
|
|
485
516
|
const tagsClientHeight = tags.clientHeight;
|
|
486
517
|
fastdom.mutate(() => {
|
|
487
|
-
input.style.height = Math.max(tagsClientHeight +
|
|
518
|
+
input.style.height = Math.max(tagsClientHeight + spacingHeight, sizeInMap) + "px";
|
|
488
519
|
});
|
|
489
520
|
});
|
|
490
521
|
} else {
|
|
@@ -494,7 +525,7 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
494
525
|
input.style.height = "auto";
|
|
495
526
|
}
|
|
496
527
|
if (state.visible && state.emptyText !== false) {
|
|
497
|
-
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
528
|
+
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper, true);
|
|
498
529
|
}
|
|
499
530
|
});
|
|
500
531
|
};
|
|
@@ -514,34 +545,39 @@ const resetHoverIndex = ({ props, state }) => () => {
|
|
|
514
545
|
}
|
|
515
546
|
}
|
|
516
547
|
};
|
|
548
|
+
const resetDatas = ({ props, state }) => () => {
|
|
549
|
+
if (props.optimization && !props.remote && !props.filterMethod) {
|
|
550
|
+
state.datas = state.initDatas;
|
|
551
|
+
}
|
|
552
|
+
};
|
|
517
553
|
const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byClick) => {
|
|
518
|
-
var _a, _b;
|
|
519
554
|
state.memorize && state.memorize.updateByKey(option[state.memorize._dataKey] || option.value);
|
|
520
555
|
if (props.multiple) {
|
|
521
|
-
const value = (
|
|
556
|
+
const value = (state.modelValue || []).slice();
|
|
522
557
|
const optionIndex = api.getValueIndex(value, option.value);
|
|
523
558
|
if (optionIndex > -1) {
|
|
524
559
|
value.splice(optionIndex, 1);
|
|
525
560
|
} else if (state.multipleLimit <= 0 || value.length < state.multipleLimit) {
|
|
526
561
|
value.push(option.value);
|
|
527
562
|
}
|
|
563
|
+
state.compareValue = deepClone(value);
|
|
528
564
|
api.updateModelValue(value);
|
|
529
565
|
api.emitChange(value);
|
|
530
566
|
if (option.created) {
|
|
567
|
+
const isChange = false;
|
|
568
|
+
const isInput = true;
|
|
531
569
|
state.query = "";
|
|
532
|
-
api.handleQueryChange("");
|
|
570
|
+
api.handleQueryChange("", isChange, isInput);
|
|
533
571
|
state.inputLength = 20;
|
|
534
572
|
}
|
|
535
573
|
if (props.filterable) {
|
|
536
|
-
|
|
537
|
-
}
|
|
538
|
-
if (props.searchable) {
|
|
539
|
-
(_b = vm.$refs.reference) == null ? void 0 : _b.focus();
|
|
574
|
+
vm.$refs.input.focus();
|
|
540
575
|
}
|
|
541
576
|
if (props.autoClose) {
|
|
542
577
|
state.visible = false;
|
|
543
578
|
}
|
|
544
579
|
} else {
|
|
580
|
+
state.compareValue = deepClone(option.value);
|
|
545
581
|
api.updateModelValue(option.value);
|
|
546
582
|
api.emitChange(option.value);
|
|
547
583
|
if (option.created) {
|
|
@@ -566,11 +602,13 @@ const initValue = ({ state }) => (vm) => {
|
|
|
566
602
|
const setSoftFocus = ({ vm, state }) => () => {
|
|
567
603
|
state.softFocus = true;
|
|
568
604
|
const input = vm.$refs.input || vm.$refs.reference;
|
|
569
|
-
|
|
605
|
+
if (input) {
|
|
606
|
+
input.focus();
|
|
607
|
+
}
|
|
570
608
|
};
|
|
571
609
|
const getValueIndex = (props) => (arr = [], value = null) => {
|
|
572
|
-
const
|
|
573
|
-
if (!
|
|
610
|
+
const isObject = Object.prototype.toString.call(value).toLowerCase() === "[object object]";
|
|
611
|
+
if (!isObject) {
|
|
574
612
|
return arr.indexOf(value);
|
|
575
613
|
} else {
|
|
576
614
|
const valueKey = props.valueKey;
|
|
@@ -585,18 +623,25 @@ const getValueIndex = (props) => (arr = [], value = null) => {
|
|
|
585
623
|
return index;
|
|
586
624
|
}
|
|
587
625
|
};
|
|
588
|
-
const toggleMenu = ({ vm, state, props }) => (e) => {
|
|
626
|
+
const toggleMenu = ({ vm, state, props, api }) => (e) => {
|
|
627
|
+
if (props.keepFocus && state.visible && props.filterable) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
589
630
|
const event = e || window.event;
|
|
590
631
|
const enterCode = 13;
|
|
591
632
|
const nodeName = event.target && event.target.nodeName;
|
|
592
633
|
const toggleVisible = props.ignoreEnter ? event.keyCode !== enterCode && nodeName === "INPUT" : true;
|
|
634
|
+
if (!props.displayOnly) {
|
|
635
|
+
event.stopPropagation();
|
|
636
|
+
}
|
|
593
637
|
if (!state.selectDisabled) {
|
|
594
638
|
toggleVisible && !state.softFocus && (state.visible = !state.visible);
|
|
595
639
|
state.softFocus = false;
|
|
596
640
|
if (state.visible) {
|
|
597
641
|
if (!(props.filterable && props.shape)) {
|
|
598
642
|
const dom = vm.$refs.input || vm.$refs.reference;
|
|
599
|
-
dom == null ? void 0 : dom.focus();
|
|
643
|
+
(dom == null ? void 0 : dom.focus) && dom.focus();
|
|
644
|
+
api.setOptionHighlight();
|
|
600
645
|
}
|
|
601
646
|
}
|
|
602
647
|
}
|
|
@@ -605,45 +650,49 @@ const selectOption = ({ api, state, props }) => (e) => {
|
|
|
605
650
|
if (!state.visible || props.hideDrop) {
|
|
606
651
|
api.toggleMenu(e);
|
|
607
652
|
} else {
|
|
608
|
-
|
|
609
|
-
|
|
653
|
+
let option = "";
|
|
654
|
+
if (state.query || props.remote) {
|
|
655
|
+
option = state.options.find((item) => item.state.index === state.hoverValue);
|
|
656
|
+
} else {
|
|
657
|
+
option = state.options[state.hoverIndex];
|
|
610
658
|
}
|
|
659
|
+
option && api.handleOptionSelect(option);
|
|
611
660
|
}
|
|
612
661
|
};
|
|
613
662
|
const deleteSelected = ({ api, constants, emit, props, vm, state }) => (event) => {
|
|
614
|
-
event.stopPropagation();
|
|
663
|
+
event && event.stopPropagation();
|
|
615
664
|
let selectedValue = [];
|
|
616
665
|
if (props.multiple) {
|
|
617
666
|
const requireOptions = state.options.filter((opt) => opt.required && opt.value);
|
|
618
|
-
selectedValue =
|
|
667
|
+
selectedValue = state.modelValue.slice().filter((v) => requireOptions.find((opt) => opt.value === v));
|
|
619
668
|
}
|
|
620
669
|
const value = props.multiple ? selectedValue : "";
|
|
621
|
-
const refs = vm.$refs;
|
|
622
670
|
if (props.renderType === constants.TYPE.Tree) {
|
|
623
671
|
state.selected = {};
|
|
624
672
|
state.selectedLabel = "";
|
|
625
|
-
refs.selectTree.
|
|
673
|
+
vm.$refs.selectTree.state.currentRadio.value = null;
|
|
674
|
+
vm.$refs.selectTree.setCurrentKey(null);
|
|
626
675
|
} else if (props.renderType === constants.TYPE.Grid) {
|
|
627
676
|
state.selected = {};
|
|
628
677
|
state.selectedLabel = "";
|
|
629
|
-
refs.selectGrid.clearRadioRow();
|
|
678
|
+
vm.$refs.selectGrid.clearRadioRow();
|
|
630
679
|
}
|
|
631
680
|
state.showTip = false;
|
|
632
|
-
|
|
633
|
-
api.
|
|
681
|
+
state.compareValue = deepClone(value);
|
|
682
|
+
api.updateModelValue(value, true);
|
|
683
|
+
api.emitChange(value, true);
|
|
634
684
|
state.visible = false;
|
|
635
685
|
emit("clear");
|
|
636
686
|
};
|
|
637
687
|
const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (event, tag) => {
|
|
638
688
|
if (tag.required)
|
|
639
689
|
return;
|
|
640
|
-
const refs = vm.$refs;
|
|
641
690
|
const isTree = props.renderType === constants.TYPE.Tree;
|
|
642
691
|
const index = state.selected.indexOf(tag);
|
|
643
692
|
const treeValue = [];
|
|
644
693
|
const treeIds = [tag[props.valueField]];
|
|
645
694
|
if (isTree && !props.treeOp.checkStrictly) {
|
|
646
|
-
let node = refs.selectTree.getNode(tag[props.valueField]);
|
|
695
|
+
let node = vm.$refs.selectTree.getNode(tag[props.valueField]);
|
|
647
696
|
if (!node.isLeaf) {
|
|
648
697
|
treeIds.push(...api.getChildValue(node.childNodes, props.valueField));
|
|
649
698
|
}
|
|
@@ -654,28 +703,31 @@ const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (eve
|
|
|
654
703
|
state.selected.slice().map((node2) => !treeIds.includes(node2[props.valueField]) && treeValue.push(node2[props.valueField]));
|
|
655
704
|
}
|
|
656
705
|
if (index > -1 && !state.selectDisabled) {
|
|
657
|
-
const value =
|
|
706
|
+
const value = state.modelValue.slice();
|
|
658
707
|
value.splice(index, 1);
|
|
659
708
|
if (props.renderType === constants.TYPE.Tree) {
|
|
660
709
|
props.treeOp.checkStrictly && treeValue.push(...value);
|
|
661
|
-
refs.selectTree.setCheckedKeys(treeValue);
|
|
710
|
+
vm.$refs.selectTree.setCheckedKeys(treeValue);
|
|
662
711
|
} else if (props.renderType === constants.TYPE.Grid) {
|
|
663
712
|
const rows = state.selected.slice().filter((item) => value.includes(item[props.valueField]));
|
|
664
|
-
refs.selectGrid.clearSelection();
|
|
665
|
-
refs.selectGrid.setSelection(rows, true);
|
|
713
|
+
vm.$refs.selectGrid.clearSelection();
|
|
714
|
+
vm.$refs.selectGrid.setSelection(rows, true);
|
|
666
715
|
}
|
|
716
|
+
state.compareValue = deepClone(value);
|
|
667
717
|
api.updateModelValue(isTree ? treeValue : value);
|
|
668
718
|
api.emitChange(value);
|
|
669
719
|
emit(constants.EVENT_NAME.removeTag, tag[props.valueField]);
|
|
670
720
|
nextTick(() => state.key++);
|
|
671
721
|
}
|
|
672
|
-
event.stopPropagation();
|
|
722
|
+
event && event.stopPropagation();
|
|
673
723
|
};
|
|
674
724
|
const onInputChange = ({ api, props, state, constants, nextTick }) => () => {
|
|
675
725
|
if (!props.delay) {
|
|
676
726
|
if (props.filterable && state.query !== state.selectedLabel) {
|
|
727
|
+
const isChange = false;
|
|
728
|
+
const isInput = true;
|
|
677
729
|
state.query = state.selectedLabel;
|
|
678
|
-
api.handleQueryChange(state.query);
|
|
730
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
679
731
|
nextTick(() => {
|
|
680
732
|
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
681
733
|
});
|
|
@@ -695,8 +747,9 @@ const onOptionDestroy = (state) => (index) => {
|
|
|
695
747
|
}
|
|
696
748
|
};
|
|
697
749
|
const resetInputWidth = ({ vm, state }) => () => {
|
|
698
|
-
|
|
699
|
-
|
|
750
|
+
if (vm.$refs.reference && vm.$refs.reference.$el) {
|
|
751
|
+
state.inputWidth = vm.$refs.reference.$el.getBoundingClientRect().width;
|
|
752
|
+
}
|
|
700
753
|
};
|
|
701
754
|
const handleResize = ({ api, props, state }) => () => {
|
|
702
755
|
api.resetInputWidth();
|
|
@@ -704,29 +757,42 @@ const handleResize = ({ api, props, state }) => () => {
|
|
|
704
757
|
api.resetInputHeight();
|
|
705
758
|
}
|
|
706
759
|
};
|
|
760
|
+
const setOptionHighlight = (state) => () => {
|
|
761
|
+
for (let i = 0; i < state.options.length; ++i) {
|
|
762
|
+
const option = state.options[i];
|
|
763
|
+
if (!option.disabled && !option.groupDisabled && !option.state.created && option.state.visible && option.state.itemSelected) {
|
|
764
|
+
state.hoverIndex = i;
|
|
765
|
+
break;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
};
|
|
707
769
|
const checkDefaultFirstOption = (state) => () => {
|
|
708
770
|
state.hoverIndex = -1;
|
|
709
771
|
let hasCreated = false;
|
|
710
|
-
|
|
711
|
-
|
|
772
|
+
const visibleOptions = state.options.filter((item) => item.visible && item.state.visible);
|
|
773
|
+
for (let i = visibleOptions.length - 1; i >= 0; i--) {
|
|
774
|
+
if (visibleOptions[i].created) {
|
|
712
775
|
hasCreated = true;
|
|
713
776
|
state.hoverIndex = i;
|
|
777
|
+
state.hoverValue = state.optionIndexArr[i];
|
|
714
778
|
break;
|
|
715
779
|
}
|
|
716
780
|
}
|
|
717
781
|
if (hasCreated) {
|
|
718
782
|
return;
|
|
719
783
|
}
|
|
720
|
-
for (let i = 0; i
|
|
721
|
-
const option =
|
|
784
|
+
for (let i = 0; i < visibleOptions.length; i++) {
|
|
785
|
+
const option = visibleOptions[i];
|
|
722
786
|
if (state.query) {
|
|
723
|
-
if (!option.disabled && !option.groupDisabled && option.state.visible) {
|
|
787
|
+
if (!option.disabled && !option.groupDisabled && option.state.visible && option.visible) {
|
|
724
788
|
state.hoverIndex = i;
|
|
789
|
+
state.hoverValue = state.optionIndexArr[i];
|
|
725
790
|
break;
|
|
726
791
|
}
|
|
727
792
|
} else {
|
|
728
793
|
if (option.itemSelected) {
|
|
729
794
|
state.hoverIndex = i;
|
|
795
|
+
state.hoverValue = state.optionIndexArr[i];
|
|
730
796
|
break;
|
|
731
797
|
}
|
|
732
798
|
}
|
|
@@ -740,8 +806,12 @@ const getValueKey = (props) => (item) => {
|
|
|
740
806
|
}
|
|
741
807
|
return getObj(item.value, props.valueKey);
|
|
742
808
|
};
|
|
743
|
-
const navigateOptions = ({ api,
|
|
744
|
-
const
|
|
809
|
+
const navigateOptions = ({ api, state, props, nextTick }) => (direction) => {
|
|
810
|
+
const { optimization } = props;
|
|
811
|
+
if (optimization) {
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
const len = state.options.filter((item) => item.visible && item.state.visible).length;
|
|
745
815
|
if (!state.visible) {
|
|
746
816
|
state.visible = true;
|
|
747
817
|
return;
|
|
@@ -749,6 +819,13 @@ const navigateOptions = ({ api, nextTick, state }) => (direction) => {
|
|
|
749
819
|
if (len === 0 || state.filteredOptionsCount === 0) {
|
|
750
820
|
return;
|
|
751
821
|
}
|
|
822
|
+
state.disabledOptionHover = true;
|
|
823
|
+
setTimeout(() => {
|
|
824
|
+
state.disabledOptionHover = false;
|
|
825
|
+
}, 100);
|
|
826
|
+
if (state.hoverIndex < -1 || state.hoverIndex >= len) {
|
|
827
|
+
state.hoverIndex = 0;
|
|
828
|
+
}
|
|
752
829
|
if (!state.optionsAllDisabled) {
|
|
753
830
|
if (direction === "next") {
|
|
754
831
|
state.hoverIndex++;
|
|
@@ -761,39 +838,68 @@ const navigateOptions = ({ api, nextTick, state }) => (direction) => {
|
|
|
761
838
|
state.hoverIndex = len - 1;
|
|
762
839
|
}
|
|
763
840
|
}
|
|
764
|
-
|
|
765
|
-
|
|
841
|
+
let option = {};
|
|
842
|
+
state.hoverValue = state.optionIndexArr[state.hoverIndex];
|
|
843
|
+
if (state.query || props.remote) {
|
|
844
|
+
option = state.options.find((item) => item.state.index === state.hoverValue);
|
|
845
|
+
} else {
|
|
846
|
+
option = state.options[state.hoverIndex];
|
|
847
|
+
}
|
|
848
|
+
if (option.disabled === true || option.groupDisabled === true || !option.state.visible || option.state.limitReached) {
|
|
766
849
|
api.navigateOptions(direction);
|
|
767
850
|
}
|
|
768
|
-
nextTick(() => api.scrollToOption(state.
|
|
851
|
+
nextTick(() => api.scrollToOption(state.hoverIndex === -9 ? {} : option || {}));
|
|
769
852
|
}
|
|
770
853
|
};
|
|
771
|
-
const
|
|
854
|
+
const emptyFlag = ({ props, state }) => () => {
|
|
855
|
+
if (props.optimization) {
|
|
856
|
+
if (props.allowCreate) {
|
|
857
|
+
return state.query === "" && state.datas.length === 0;
|
|
858
|
+
} else {
|
|
859
|
+
return state.datas.length === 0;
|
|
860
|
+
}
|
|
861
|
+
} else {
|
|
862
|
+
return state.options.length === 0;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
const recycleScrollerHeight = ({ state, props, recycle }) => () => {
|
|
866
|
+
const { ITEM_HEIGHT, SAFE_MARGIN, SAAS_HEIGHT, AURORA_HEIGHT } = recycle;
|
|
867
|
+
let length = state.datas.length;
|
|
868
|
+
if (state.showNewOption) {
|
|
869
|
+
length += 1;
|
|
870
|
+
}
|
|
871
|
+
if (length === 0 || props.loading) {
|
|
872
|
+
return 0;
|
|
873
|
+
} else if (length < 6) {
|
|
874
|
+
return length * ITEM_HEIGHT + (state.isSaaSTheme ? SAFE_MARGIN * 2 : 0);
|
|
875
|
+
} else {
|
|
876
|
+
return state.isSaaSTheme ? SAAS_HEIGHT : AURORA_HEIGHT;
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
const emptyText = ({ I18N, props, state, t, isMobileFirstMode }) => () => {
|
|
772
880
|
if (props.loading) {
|
|
773
881
|
return props.loadingText || t(I18N.loading);
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
787
|
-
if (props.remote && state.query === "" && state.options.length === 0) {
|
|
788
|
-
if (props.shape === "filter") {
|
|
789
|
-
return "";
|
|
790
|
-
} else {
|
|
791
|
-
return false;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
882
|
+
}
|
|
883
|
+
if (props.remote && state.query === "" && props.renderType) {
|
|
884
|
+
return remoteEmptyText(props, state);
|
|
885
|
+
}
|
|
886
|
+
if (props.remote && state.query === "" && state.emptyFlag && !state.triggerSearch) {
|
|
887
|
+
return props.shape === "filter" || isMobileFirstMode ? "" : false;
|
|
888
|
+
}
|
|
889
|
+
if (props.filterable && state.query && (props.remote && state.emptyFlag || !state.options.some((option) => option.visible && option.state.visible))) {
|
|
890
|
+
return props.noMatchText || t(I18N.noMatch);
|
|
891
|
+
}
|
|
892
|
+
if (state.emptyFlag) {
|
|
893
|
+
return props.noDataText || t(I18N.noData);
|
|
794
894
|
}
|
|
795
895
|
return null;
|
|
796
896
|
};
|
|
897
|
+
const remoteEmptyText = function(props, state) {
|
|
898
|
+
if (props.multiple) {
|
|
899
|
+
return state.selected.length > 0 || state.remoteData.length >= 0;
|
|
900
|
+
}
|
|
901
|
+
return state.selected[props.valueField] || state.remoteData.length >= 0;
|
|
902
|
+
};
|
|
797
903
|
const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, oldValue) => {
|
|
798
904
|
if (props.multiple) {
|
|
799
905
|
api.resetInputHeight();
|
|
@@ -802,9 +908,11 @@ const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, o
|
|
|
802
908
|
} else {
|
|
803
909
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
804
910
|
}
|
|
805
|
-
if (
|
|
911
|
+
if (props.filterable && !props.reserveKeyword) {
|
|
912
|
+
const isChange = false;
|
|
913
|
+
const isInput = true;
|
|
806
914
|
props.renderType !== constants.TYPE.Grid && (state.query = "");
|
|
807
|
-
api.handleQueryChange(state.query);
|
|
915
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
808
916
|
}
|
|
809
917
|
}
|
|
810
918
|
api.setSelected();
|
|
@@ -816,13 +924,13 @@ const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, o
|
|
|
816
924
|
if (state.completed && !isEqual(value, oldValue)) {
|
|
817
925
|
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formChange, value);
|
|
818
926
|
}
|
|
819
|
-
|
|
927
|
+
props.optimization && optmzApis.setValueIndex({ props, state });
|
|
820
928
|
};
|
|
821
929
|
const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
822
930
|
if (props.multiple && props.showOverflowTooltip) {
|
|
823
931
|
state.overflow = false;
|
|
824
932
|
const tagDom = vm.$refs.tags;
|
|
825
|
-
const tags = tagDom.querySelectorAll("
|
|
933
|
+
const tags = tagDom.querySelectorAll('[data-tag="tiny-tag"]');
|
|
826
934
|
if (tags.length) {
|
|
827
935
|
tagDom.scrollTo && tagDom.scrollTo({ top: 0 });
|
|
828
936
|
let { x, width } = tags[0].getBoundingClientRect();
|
|
@@ -831,7 +939,7 @@ const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
|
831
939
|
} else {
|
|
832
940
|
for (let i = 1; i < tags.length; i++) {
|
|
833
941
|
let tx = tags[i].getBoundingClientRect().x;
|
|
834
|
-
if (tx
|
|
942
|
+
if (tx === x) {
|
|
835
943
|
state.overflow = i - 1;
|
|
836
944
|
break;
|
|
837
945
|
}
|
|
@@ -852,7 +960,6 @@ const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
|
852
960
|
}
|
|
853
961
|
};
|
|
854
962
|
const postOperOfToVisible = ({ props, state, constants }) => {
|
|
855
|
-
var _a;
|
|
856
963
|
if (props.multiple) {
|
|
857
964
|
return;
|
|
858
965
|
}
|
|
@@ -863,30 +970,32 @@ const postOperOfToVisible = ({ props, state, constants }) => {
|
|
|
863
970
|
if (props.filterable && props.allowCreate && state.createdSelected && state.createdLabel) {
|
|
864
971
|
state.selectedLabel = state.createdLabel;
|
|
865
972
|
} else {
|
|
866
|
-
state.selectedLabel =
|
|
973
|
+
state.selectedLabel = state.selected.state.currentLabel || state.selected.currentLabel;
|
|
867
974
|
}
|
|
868
975
|
if (props.filterable) {
|
|
869
976
|
state.query = state.selectedLabel;
|
|
870
977
|
}
|
|
871
978
|
}
|
|
872
|
-
if (
|
|
979
|
+
if (props.filterable) {
|
|
873
980
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
874
981
|
}
|
|
875
982
|
}
|
|
876
983
|
};
|
|
877
984
|
const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
878
|
-
var _a;
|
|
879
985
|
state.selectEmitter.emit(constants.EVENT_NAME.destroyPopper);
|
|
880
986
|
props.remote && props.dropOnlySearch && (state.showWarper = false);
|
|
881
|
-
(
|
|
987
|
+
if (vm.$refs.input) {
|
|
988
|
+
vm.$refs.input.blur();
|
|
989
|
+
}
|
|
882
990
|
state.query = "";
|
|
883
991
|
state.selectedLabel = "";
|
|
884
992
|
state.inputLength = 20;
|
|
885
993
|
state.previousQuery !== state.query && api.initQuery().then(() => api.setSelected());
|
|
886
994
|
if (props.renderType !== constants.TYPE.Tree) {
|
|
887
|
-
state.previousQuery =
|
|
995
|
+
state.previousQuery = null;
|
|
888
996
|
}
|
|
889
997
|
api.resetHoverIndex();
|
|
998
|
+
api.resetDatas();
|
|
890
999
|
nextTick(() => {
|
|
891
1000
|
if (vm.$refs.input && vm.$refs.input.value === "" && state.selected.length === 0) {
|
|
892
1001
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
@@ -897,23 +1006,22 @@ const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
|
897
1006
|
});
|
|
898
1007
|
postOperOfToVisible({ props, state, constants });
|
|
899
1008
|
};
|
|
900
|
-
const toHide = ({ constants, state, props, vm, api
|
|
901
|
-
|
|
902
|
-
state.selectEmitter.emit(constants.COMPONENT_NAME.SelectDropdown);
|
|
903
|
-
|
|
904
|
-
state.
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
state.query
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
props.filterable ? (_a = vm.$refs.input) == null ? void 0 : _a.focus() : (_b = vm.$refs.reference) == null ? void 0 : _b.focus();
|
|
1009
|
+
const toHide = ({ constants, state, props, vm, api }) => () => {
|
|
1010
|
+
const { filterable, remote, remoteConfig, shape, renderType, multiple, valueField } = props;
|
|
1011
|
+
state.selectEmitter.emit(constants.COMPONENT_NAME.SelectDropdown, constants.EVENT_NAME.updatePopper);
|
|
1012
|
+
if (filterable) {
|
|
1013
|
+
state.query = remote || shape ? "" : renderType !== constants.TYPE.Tree ? state.selectedLabel : "";
|
|
1014
|
+
const isChange = remote && remoteConfig.autoSearch && (state.firstAutoSearch || remoteConfig.clearData);
|
|
1015
|
+
state.firstAutoSearch = false;
|
|
1016
|
+
api.handleQueryChange(state.query, isChange);
|
|
1017
|
+
if (multiple) {
|
|
1018
|
+
vm.$refs.input.focus();
|
|
911
1019
|
} else {
|
|
912
|
-
if (!
|
|
913
|
-
state.selectEmitter.emit(constants.EVENT_NAME.queryChange);
|
|
914
|
-
state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup);
|
|
1020
|
+
if (!remote) {
|
|
1021
|
+
state.selectEmitter.emit(constants.EVENT_NAME.queryChange, "");
|
|
1022
|
+
state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup, constants.EVENT_NAME.queryChange);
|
|
915
1023
|
}
|
|
916
|
-
if (state.selectedLabel && !
|
|
1024
|
+
if (state.selectedLabel && !shape) {
|
|
917
1025
|
state.currentPlaceholder = state.selectedLabel;
|
|
918
1026
|
state.selectedLabel = "";
|
|
919
1027
|
}
|
|
@@ -921,32 +1029,34 @@ const toHide = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
|
921
1029
|
}
|
|
922
1030
|
if (vm.$refs.selectGrid) {
|
|
923
1031
|
let { fullData } = vm.$refs.selectGrid.getTableData();
|
|
924
|
-
if (
|
|
925
|
-
const selectedIds = state.selected.map((sel) => sel[
|
|
1032
|
+
if (multiple) {
|
|
1033
|
+
const selectedIds = state.selected.map((sel) => sel[valueField]);
|
|
926
1034
|
vm.$refs.selectGrid.clearSelection();
|
|
927
1035
|
vm.$refs.selectGrid.setSelection(
|
|
928
|
-
fullData.filter((row) => ~selectedIds.indexOf(row[
|
|
1036
|
+
fullData.filter((row) => ~selectedIds.indexOf(row[valueField])),
|
|
929
1037
|
true
|
|
930
1038
|
);
|
|
931
1039
|
} else {
|
|
932
1040
|
vm.$refs.selectGrid.clearRadioRow();
|
|
933
|
-
vm.$refs.selectGrid.setRadioRow(find(fullData, (item) => props.modelValue
|
|
1041
|
+
vm.$refs.selectGrid.setRadioRow(find(fullData, (item) => props.modelValue === item[valueField]));
|
|
934
1042
|
}
|
|
935
|
-
if (
|
|
1043
|
+
if (filterable && typeof props.filterMethod === "function") {
|
|
936
1044
|
vm.$refs.selectGrid.handleTableData(true);
|
|
937
|
-
} else if (
|
|
1045
|
+
} else if (filterable && remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
938
1046
|
vm.$refs.selectGrid.handleTableData();
|
|
939
1047
|
}
|
|
940
1048
|
}
|
|
941
1049
|
};
|
|
942
1050
|
const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) => {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
(_a = vm.$refs.reference) == null ? void 0 : _a.blur();
|
|
1051
|
+
if ((props.filterable || props.remote) && !value) {
|
|
1052
|
+
vm.$refs.reference.blur();
|
|
946
1053
|
}
|
|
947
1054
|
if (api.onCopying()) {
|
|
948
1055
|
return;
|
|
949
1056
|
}
|
|
1057
|
+
if (value && props.multiple && state.device === "mb") {
|
|
1058
|
+
state.selectedCopy = state.selected.slice();
|
|
1059
|
+
}
|
|
950
1060
|
setTimeout(() => {
|
|
951
1061
|
if (!value && !state.selectedLabel) {
|
|
952
1062
|
state.cachedOptions.forEach((item) => {
|
|
@@ -956,15 +1066,19 @@ const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) =>
|
|
|
956
1066
|
}, 200);
|
|
957
1067
|
value ? api.toHide() : api.toVisible();
|
|
958
1068
|
emit(constants.EVENT_NAME.visibleChange, value);
|
|
1069
|
+
setTimeout(() => {
|
|
1070
|
+
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
1071
|
+
if (value && vm.$refs.scrollbar) {
|
|
1072
|
+
if (props.optimization) {
|
|
1073
|
+
optmzApis.setScrollTop({ refs: vm.$refs, state });
|
|
1074
|
+
} else {
|
|
1075
|
+
vm.$refs.scrollbar.handleScroll();
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}, props.updateDelay);
|
|
959
1079
|
if (!value && props.shape === "filter") {
|
|
960
1080
|
state.softFocus = false;
|
|
961
1081
|
}
|
|
962
|
-
if (value && state.optimizeStore.flag) {
|
|
963
|
-
optmzApis.createMacro(() => {
|
|
964
|
-
optmzApis.setScrollTop({ refs: vm.$refs, state });
|
|
965
|
-
api.getScrollListener();
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
1082
|
};
|
|
969
1083
|
const watchOptions = ({ api, constants, nextTick, parent, props, state }) => () => {
|
|
970
1084
|
if (typeof window === "undefined") {
|
|
@@ -981,8 +1095,25 @@ const watchOptions = ({ api, constants, nextTick, parent, props, state }) => ()
|
|
|
981
1095
|
api.setSelected();
|
|
982
1096
|
}
|
|
983
1097
|
});
|
|
984
|
-
|
|
985
|
-
|
|
1098
|
+
api.getOptionIndexArr();
|
|
1099
|
+
};
|
|
1100
|
+
const getOptionIndexArr = ({ props, state, api }) => () => {
|
|
1101
|
+
setTimeout(() => {
|
|
1102
|
+
state.optionIndexArr = api.queryVisibleOptions().map((item) => Number(item.getAttribute("data-index")));
|
|
1103
|
+
if (props.defaultFirstOption && (props.filterable || props.remote) && state.filteredOptionsCount) {
|
|
1104
|
+
if (props.optimization) {
|
|
1105
|
+
optmzApis.checkDefaultFirstOption({ state });
|
|
1106
|
+
} else {
|
|
1107
|
+
api.checkDefaultFirstOption();
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
};
|
|
1112
|
+
const queryVisibleOptions = ({ props, vm, isMobileFirstMode }) => () => {
|
|
1113
|
+
if (props.optimization) {
|
|
1114
|
+
return optmzApis.queryVisibleOptions(vm, isMobileFirstMode);
|
|
1115
|
+
} else {
|
|
1116
|
+
return Array.from(vm.$refs.scrollbar.$el.querySelectorAll('[data-index]:not([style*="display: none"])'));
|
|
986
1117
|
}
|
|
987
1118
|
};
|
|
988
1119
|
const handleCopyClick = ({ parent, props, state }) => () => {
|
|
@@ -996,7 +1127,7 @@ const handleCopyClick = ({ parent, props, state }) => () => {
|
|
|
996
1127
|
document.execCommand("copy");
|
|
997
1128
|
parent.$el.removeChild(input);
|
|
998
1129
|
};
|
|
999
|
-
const selectChange = ({
|
|
1130
|
+
const selectChange = ({ props, state, api }) => ({ $table, selection, checked, row }) => {
|
|
1000
1131
|
const { textField, valueField } = props;
|
|
1001
1132
|
const remoteItem = (row2) => {
|
|
1002
1133
|
const removeItem = find(state.selected, (item) => item[valueField] === row2[valueField]);
|
|
@@ -1006,12 +1137,12 @@ const selectChange = ({ emit, props, state, api }) => ({ $table, selection, chec
|
|
|
1006
1137
|
checked ? state.selected.push(__spreadProps(__spreadValues({}, row), { value: row[valueField], currentLabel: row[textField] })) : remoteItem(row);
|
|
1007
1138
|
} else {
|
|
1008
1139
|
checked ? state.selected = state.selected.concat(
|
|
1009
|
-
selection.filter((row2) => !~
|
|
1140
|
+
selection.filter((row2) => !~state.modelValue.indexOf(row2[valueField]))
|
|
1010
1141
|
) : $table.tableFullData.forEach((row2) => remoteItem(row2));
|
|
1011
1142
|
}
|
|
1012
1143
|
const keys = state.selected.map((item) => item[valueField]);
|
|
1013
1144
|
api.updateModelValue(keys);
|
|
1014
|
-
|
|
1145
|
+
api.directEmitChange(keys, state.selected);
|
|
1015
1146
|
};
|
|
1016
1147
|
const getcheckedData = ({ props, state }) => () => {
|
|
1017
1148
|
const checkedKey = [];
|
|
@@ -1024,14 +1155,16 @@ const getcheckedData = ({ props, state }) => () => {
|
|
|
1024
1155
|
return checkedKey;
|
|
1025
1156
|
}
|
|
1026
1157
|
};
|
|
1027
|
-
const radioChange = ({
|
|
1158
|
+
const radioChange = ({ props, state, api, vm }) => ({ row }) => {
|
|
1028
1159
|
row.value = row[props.valueField];
|
|
1029
1160
|
row.currentLabel = row[props.textField];
|
|
1161
|
+
!state.hasClearSelection && vm.$refs.selectGrid.clearSelection();
|
|
1162
|
+
state.hasClearSelection = true;
|
|
1030
1163
|
state.selected = row;
|
|
1031
1164
|
state.visible = false;
|
|
1032
1165
|
state.currentKey = row[props.valueField];
|
|
1033
1166
|
api.updateModelValue(row.value);
|
|
1034
|
-
|
|
1167
|
+
api.directEmitChange(row);
|
|
1035
1168
|
};
|
|
1036
1169
|
const getTreeData = (props) => (data) => {
|
|
1037
1170
|
const nodes = [];
|
|
@@ -1047,14 +1180,14 @@ const getTreeData = (props) => (data) => {
|
|
|
1047
1180
|
getChild(data, null);
|
|
1048
1181
|
return nodes;
|
|
1049
1182
|
};
|
|
1050
|
-
const treeNodeClick = ({
|
|
1183
|
+
const treeNodeClick = ({ props, state, api, vm }) => (data) => {
|
|
1051
1184
|
if (!props.multiple) {
|
|
1052
1185
|
data.currentLabel = data[props.textField];
|
|
1053
1186
|
data.value = data[props.valueField];
|
|
1054
1187
|
state.selected = data;
|
|
1055
1188
|
state.visible = false;
|
|
1056
1189
|
api.updateModelValue(data.value);
|
|
1057
|
-
|
|
1190
|
+
api.directEmitChange(data);
|
|
1058
1191
|
} else {
|
|
1059
1192
|
if (props.treeOp.checkOnClickNode) {
|
|
1060
1193
|
const checkedNodes = vm.$refs.selectTree.getCheckedNodes();
|
|
@@ -1063,7 +1196,7 @@ const treeNodeClick = ({ emit, props, state, api, vm }) => (data) => {
|
|
|
1063
1196
|
}
|
|
1064
1197
|
}
|
|
1065
1198
|
};
|
|
1066
|
-
const nodeCheckClick = ({
|
|
1199
|
+
const nodeCheckClick = ({ props, state, api }) => (data, { checkedKeys, checkedNodes }) => {
|
|
1067
1200
|
const selected = state.selected.map((item) => api.getValueKey(item));
|
|
1068
1201
|
if (isEqual(selected, checkedKeys)) {
|
|
1069
1202
|
return;
|
|
@@ -1073,7 +1206,7 @@ const nodeCheckClick = ({ emit, props, state, api }) => (data, { checkedKeys, ch
|
|
|
1073
1206
|
node.value = node[props.valueField];
|
|
1074
1207
|
});
|
|
1075
1208
|
api.updateModelValue(checkedKeys);
|
|
1076
|
-
|
|
1209
|
+
api.directEmitChange(checkedKeys, checkedNodes);
|
|
1077
1210
|
};
|
|
1078
1211
|
const nodeCollapse = ({ state, constants }) => () => {
|
|
1079
1212
|
setTimeout(() => {
|
|
@@ -1086,9 +1219,11 @@ const nodeExpand = ({ state, constants }) => () => {
|
|
|
1086
1219
|
}, 310);
|
|
1087
1220
|
};
|
|
1088
1221
|
const debouncRquest = ({ api, state, props }) => debounce(props.delay, () => {
|
|
1089
|
-
if (
|
|
1222
|
+
if (props.filterable && state.query !== state.selectedLabel) {
|
|
1223
|
+
const isChange = false;
|
|
1224
|
+
const isInput = true;
|
|
1090
1225
|
state.query = state.selectedLabel;
|
|
1091
|
-
api.handleQueryChange(state.query);
|
|
1226
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
1092
1227
|
}
|
|
1093
1228
|
});
|
|
1094
1229
|
const getChildValue = () => (data, key) => {
|
|
@@ -1135,6 +1270,7 @@ const watchPropsOption = ({ constants, parent, props, state }) => () => {
|
|
|
1135
1270
|
state.datas = state.memorize.assemble(sortData.slice());
|
|
1136
1271
|
} else {
|
|
1137
1272
|
state.datas = sortData;
|
|
1273
|
+
state.initDatas = sortData;
|
|
1138
1274
|
}
|
|
1139
1275
|
}
|
|
1140
1276
|
});
|
|
@@ -1142,15 +1278,15 @@ const watchPropsOption = ({ constants, parent, props, state }) => () => {
|
|
|
1142
1278
|
const buildSelectConfig = ({ props, state }) => () => {
|
|
1143
1279
|
const checkRowKeys = state.gridCheckedData;
|
|
1144
1280
|
const selectConfig = props.selectConfig;
|
|
1145
|
-
return
|
|
1281
|
+
return Object.assign({}, selectConfig, { checkRowKeys });
|
|
1146
1282
|
};
|
|
1147
1283
|
const buildRadioConfig = ({ props, state }) => () => {
|
|
1148
1284
|
const checkRowKey = state.currentKey;
|
|
1149
1285
|
const highlight = true;
|
|
1150
1286
|
const radioConfig = props.radioConfig;
|
|
1151
|
-
return
|
|
1287
|
+
return Object.assign({}, radioConfig, { checkRowKey, highlight });
|
|
1152
1288
|
};
|
|
1153
|
-
const onMouseenterNative = ({ state }) => (
|
|
1289
|
+
const onMouseenterNative = ({ state }) => () => {
|
|
1154
1290
|
state.inputHovering = true;
|
|
1155
1291
|
if (state.searchSingleCopy && state.selectedLabel) {
|
|
1156
1292
|
state.softFocus = true;
|
|
@@ -1164,16 +1300,15 @@ const onMouseleaveNative = ({ state }) => (e) => {
|
|
|
1164
1300
|
state.softFocus = false;
|
|
1165
1301
|
}
|
|
1166
1302
|
};
|
|
1167
|
-
const onCopying = ({ state, vm }) => () =>
|
|
1303
|
+
const onCopying = ({ state, vm }) => () => {
|
|
1304
|
+
return state.searchSingleCopy && state.selectedLabel && vm.$refs.reference && vm.$refs.reference.hasSelection && vm.$refs.reference.hasSelection();
|
|
1305
|
+
};
|
|
1168
1306
|
const watchHoverIndex = ({ state }) => (value) => {
|
|
1169
|
-
if (
|
|
1170
|
-
state.
|
|
1171
|
-
} else
|
|
1172
|
-
state.
|
|
1307
|
+
if (value === -1 || value === -9) {
|
|
1308
|
+
state.hoverValue = -1;
|
|
1309
|
+
} else {
|
|
1310
|
+
state.hoverValue = state.optionIndexArr[value];
|
|
1173
1311
|
}
|
|
1174
|
-
state.options.forEach((option) => {
|
|
1175
|
-
option.hover = state.hoverOption === option;
|
|
1176
|
-
});
|
|
1177
1312
|
};
|
|
1178
1313
|
const handleDropdownClick = ({ emit }) => ($event) => {
|
|
1179
1314
|
emit("dropdown-click", $event);
|
|
@@ -1189,17 +1324,17 @@ const calcCollapseTags = ({ state, vm }) => () => {
|
|
|
1189
1324
|
return state.isHidden = true;
|
|
1190
1325
|
}
|
|
1191
1326
|
const tags = vm.$refs.tags;
|
|
1192
|
-
|
|
1327
|
+
const collapseTag = tags && tags.querySelector('[data-tag="tags-collapse"]');
|
|
1328
|
+
if (!tags || !collapseTag) {
|
|
1193
1329
|
return;
|
|
1194
1330
|
}
|
|
1195
1331
|
const { width: tagsContentWidth, paddingLeft, paddingRight } = window.getComputedStyle(tags);
|
|
1196
1332
|
const tagsWidth = parseFloat(tagsContentWidth) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
1197
|
-
const collapseTag = tags.querySelector(".tiny-select__tags-collapse");
|
|
1198
1333
|
const { width: collapseTagContentWidth, marginRight } = collapseTag && window.getComputedStyle(collapseTag);
|
|
1199
1334
|
const collapseTagWidth = collapseTag && parseFloat(collapseTagContentWidth) + parseFloat(marginRight);
|
|
1200
|
-
const tagList = Array.from(tags.querySelectorAll("
|
|
1335
|
+
const tagList = Array.from(tags.querySelectorAll('[data-tag="tiny-tag"]'));
|
|
1201
1336
|
let { total, dom, idx } = { total: collapseTagWidth, dom: null, idx: 0 };
|
|
1202
|
-
tagList.
|
|
1337
|
+
tagList.forEach((tag, index) => {
|
|
1203
1338
|
if (tag !== collapseTag) {
|
|
1204
1339
|
const { width: tagContentWidth, marginRight: marginRight2 } = tag && window.getComputedStyle(tag);
|
|
1205
1340
|
total += parseFloat(tagContentWidth) + parseFloat(marginRight2);
|
|
@@ -1250,21 +1385,22 @@ const initQuery = ({ props, state, constants, vm }) => ({ init } = {}) => {
|
|
|
1250
1385
|
}
|
|
1251
1386
|
return Promise.resolve(selected);
|
|
1252
1387
|
};
|
|
1253
|
-
const mounted = ({ api, parent, state, props, vm,
|
|
1388
|
+
const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
1254
1389
|
var _a;
|
|
1255
1390
|
state.defaultCheckedKeys = state.gridCheckedData;
|
|
1256
1391
|
const parentEl = parent.$el;
|
|
1257
|
-
const inputEl = parentEl.querySelector(
|
|
1258
|
-
const inputClientRect =
|
|
1392
|
+
const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]');
|
|
1393
|
+
const inputClientRect = inputEl && inputEl.getBoundingClientRect() || {};
|
|
1259
1394
|
if (inputEl === document.activeElement) {
|
|
1260
|
-
|
|
1395
|
+
document.activeElement.blur();
|
|
1261
1396
|
}
|
|
1262
1397
|
state.completed = true;
|
|
1263
|
-
const
|
|
1398
|
+
const defaultSizeMap = { default: 28, mini: 24, small: 32, medium: 40 };
|
|
1399
|
+
const sizeMap = ((_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.sizeMap) || defaultSizeMap;
|
|
1264
1400
|
if (props.multiple && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
|
|
1265
1401
|
state.currentPlaceholder = "";
|
|
1266
1402
|
}
|
|
1267
|
-
state.initialInputHeight = state.isDisplayOnly ? sizeMap[state.selectSize
|
|
1403
|
+
state.initialInputHeight = state.isDisplayOnly ? sizeMap[state.selectSize || "default"] : inputClientRect.height || sizeMap[state.selectSize];
|
|
1268
1404
|
addResizeListener(parentEl, api.handleResize);
|
|
1269
1405
|
if (vm.$refs.tags) {
|
|
1270
1406
|
addResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
@@ -1286,7 +1422,6 @@ const unMount = ({ api, parent, vm, state }) => () => {
|
|
|
1286
1422
|
removeResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
1287
1423
|
}
|
|
1288
1424
|
state.popperElm = null;
|
|
1289
|
-
state.optimizeStore.flag && optmzApis.removeScrollListener({ api, refs: vm.$refs, state });
|
|
1290
1425
|
};
|
|
1291
1426
|
const optmzApis = {
|
|
1292
1427
|
exist: (val, multiple) => multiple ? Array.isArray(val) && val.length : val,
|
|
@@ -1295,100 +1430,40 @@ const optmzApis = {
|
|
|
1295
1430
|
const contain = (val, arr) => Array.isArray(arr) && ~arr.indexOf(val);
|
|
1296
1431
|
const equal = (val, opt) => multiple ? contain(opt[valueField], [val]) : opt[valueField] === val;
|
|
1297
1432
|
let start = 0;
|
|
1298
|
-
if (optmzApis.exist(modelValue, multiple)) {
|
|
1433
|
+
if (optmzApis.exist(modelValue, multiple) && options) {
|
|
1299
1434
|
const lastVal = multiple ? modelValue[modelValue.length - 1] : modelValue;
|
|
1300
1435
|
for (let i = 0; i < options.length; i++) {
|
|
1301
|
-
if (!equal(lastVal, options[i]))
|
|
1436
|
+
if (!equal(lastVal, options[i]))
|
|
1302
1437
|
continue;
|
|
1303
|
-
}
|
|
1304
1438
|
return i;
|
|
1305
1439
|
}
|
|
1306
1440
|
}
|
|
1307
1441
|
return start;
|
|
1308
1442
|
},
|
|
1309
|
-
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1443
|
+
queryVisibleOptions: (vm, isMobileFirstMode) => {
|
|
1444
|
+
const querySelectKey = isMobileFirstMode ? ".cursor-not-allowed" : ".is-disabled";
|
|
1445
|
+
return Array.from(
|
|
1446
|
+
vm.$refs.scrollbar.$el.querySelectorAll(
|
|
1447
|
+
'.tiny-recycle-scroller__slot, .tiny-recycle-scroller__item-view:not([style*="transform: translateY(-9999px) translateX(0px)"])'
|
|
1448
|
+
)
|
|
1449
|
+
).map((item) => item.querySelector(`[data-tag="tiny-select-dropdown-item"]:not(${querySelectKey})`)).filter((v) => v);
|
|
1315
1450
|
},
|
|
1316
|
-
getViewStyle: ({ props, state }) => {
|
|
1317
|
-
const { options } = props;
|
|
1318
|
-
const { optimizeOpts } = state;
|
|
1319
|
-
const { optionHeight } = optimizeOpts;
|
|
1320
|
-
return `height:${optionHeight * options.length}px`;
|
|
1321
|
-
},
|
|
1322
|
-
getStoreDatas: ({ props, state }) => {
|
|
1323
|
-
const { options, valueField, modelValue, multiple } = props;
|
|
1324
|
-
const { datas, optimizeOpts, optimizeStore } = state;
|
|
1325
|
-
const { startIndex } = optimizeStore;
|
|
1326
|
-
const { rSize } = optimizeOpts;
|
|
1327
|
-
const sliced = datas.slice(startIndex, startIndex + rSize);
|
|
1328
|
-
const hiddenOptions = optimizeStore.hiddenOptions = [];
|
|
1329
|
-
const findPush = (val) => {
|
|
1330
|
-
const opt = options.find((option) => option[valueField] === val);
|
|
1331
|
-
if (opt && !~sliced.indexOf(opt)) {
|
|
1332
|
-
sliced.push(opt);
|
|
1333
|
-
hiddenOptions.push(opt);
|
|
1334
|
-
}
|
|
1335
|
-
};
|
|
1336
|
-
if (optmzApis.exist(modelValue, multiple)) {
|
|
1337
|
-
if (multiple) {
|
|
1338
|
-
modelValue.forEach(findPush);
|
|
1339
|
-
} else {
|
|
1340
|
-
findPush(modelValue);
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
return sliced;
|
|
1344
|
-
},
|
|
1345
|
-
queryWrap: (refs) => refs.scrollbar.$el.querySelector(".tiny-scrollbar__wrap.virtual"),
|
|
1346
|
-
queryItems: (refs) => refs.scrollbar.$el.querySelectorAll(".tiny-option.virtual"),
|
|
1347
|
-
createMacro: (cb) => setTimeout(cb),
|
|
1348
1451
|
setScrollTop: ({ refs, state }) => {
|
|
1349
|
-
const { optimizeOpts, optimizeStore } = state;
|
|
1350
|
-
const { optionHeight } = optimizeOpts;
|
|
1351
|
-
const wrap = optmzApis.queryWrap(refs);
|
|
1352
|
-
wrap.scrollTop = optionHeight * optimizeStore.valueIndex;
|
|
1353
|
-
},
|
|
1354
|
-
setValueIndex: ({ props, state }) => state.optimizeStore.valueIndex = optmzApis.getValueIndex(props),
|
|
1355
|
-
addScrollListener: ({ api, refs, state }) => {
|
|
1356
1452
|
const { optimizeStore } = state;
|
|
1357
|
-
|
|
1358
|
-
!optimizeStore.bind && wrap.addEventListener("scroll", api.getScrollListener) && (optimizeStore.bind = true);
|
|
1453
|
+
refs.scrollbar.scrollToItem(optimizeStore.valueIndex);
|
|
1359
1454
|
},
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
const wrap = optmzApis.queryWrap(refs);
|
|
1363
|
-
optimizeStore.bind && wrap.removeEventListener("scroll", api.getScrollListener) && (optimizeStore.bind = false);
|
|
1364
|
-
},
|
|
1365
|
-
isFirstPage: ({ props, state }) => {
|
|
1366
|
-
const { optimizeStore } = state;
|
|
1367
|
-
const { datas } = optimizeStore;
|
|
1368
|
-
const { options } = props;
|
|
1369
|
-
return Array.isArray(datas) && Array.isArray(options) && datas[0] === options[0];
|
|
1455
|
+
setValueIndex: ({ props, state }) => {
|
|
1456
|
+
state.optimizeStore.valueIndex = optmzApis.getValueIndex(props);
|
|
1370
1457
|
},
|
|
1371
1458
|
natural: (val) => val < 0 ? 0 : val,
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
const items = optmzApis.queryItems(refs);
|
|
1376
|
-
for (let i = 0; i < items.length; i++) {
|
|
1377
|
-
const item = items[i];
|
|
1378
|
-
const flag = item.classList.contains("virtual-hidden");
|
|
1379
|
-
item.style.top = flag ? `-${optionHeight}px` : `${itemFn(i)}px`;
|
|
1380
|
-
}
|
|
1381
|
-
},
|
|
1382
|
-
process: ({ props, start, state }) => {
|
|
1383
|
-
const { optimizeStore } = state;
|
|
1384
|
-
optimizeStore.startIndex = typeof start !== "undefined" ? start : optmzApis.getStartIndex({ props, state });
|
|
1385
|
-
optimizeStore.datas = optmzApis.getStoreDatas({ props, state });
|
|
1386
|
-
optimizeStore.firstPage = optmzApis.isFirstPage({ props, state });
|
|
1459
|
+
checkDefaultFirstOption: ({ state }) => {
|
|
1460
|
+
state.hoverIndex = 0;
|
|
1461
|
+
state.hoverValue = state.optionIndexArr[0];
|
|
1387
1462
|
}
|
|
1388
1463
|
};
|
|
1389
|
-
const computeOptimizeOpts = ({ props,
|
|
1464
|
+
const computeOptimizeOpts = ({ props, designConfig }) => () => {
|
|
1390
1465
|
const { optimization } = props;
|
|
1391
|
-
const baseOpts = { gt: 20, rSize: 10, optionHeight: 30, limit: 20 };
|
|
1466
|
+
const baseOpts = (designConfig == null ? void 0 : designConfig.baseOpts) ? designConfig.baseOpts : { gt: 20, rSize: 10, optionHeight: 30, limit: 20 };
|
|
1392
1467
|
let optOpts;
|
|
1393
1468
|
if (optimization) {
|
|
1394
1469
|
if (typeof optimization === "boolean") {
|
|
@@ -1396,60 +1471,33 @@ const computeOptimizeOpts = ({ props, state }) => () => {
|
|
|
1396
1471
|
} else {
|
|
1397
1472
|
optOpts = extend(true, {}, baseOpts, optimization);
|
|
1398
1473
|
}
|
|
1399
|
-
optOpts.virtualScroll = optOpts.gt > 0 && optOpts.gt <= state.datas.length;
|
|
1400
1474
|
return optOpts;
|
|
1401
1475
|
}
|
|
1402
1476
|
};
|
|
1403
|
-
const watchOptimizeOpts = ({
|
|
1477
|
+
const watchOptimizeOpts = ({ props, state }) => () => {
|
|
1404
1478
|
const { optimizeOpts, optimizeStore } = state;
|
|
1405
1479
|
if (optimizeOpts) {
|
|
1406
|
-
|
|
1407
|
-
optimizeStore.flag = virtualScroll;
|
|
1408
|
-
if (virtualScroll) {
|
|
1409
|
-
optimizeStore.viewStyle = optmzApis.getViewStyle({ props, state });
|
|
1480
|
+
if (props.optimization) {
|
|
1410
1481
|
optimizeStore.valueIndex = optmzApis.getValueIndex(props);
|
|
1411
|
-
optmzApis.process({ props, state });
|
|
1412
|
-
optmzApis.createMacro(() => {
|
|
1413
|
-
const itemFn = (i) => optionHeight * (optimizeStore.startIndex + i);
|
|
1414
|
-
optmzApis.addScrollListener({ api, refs: vm.$refs, state });
|
|
1415
|
-
optmzApis.updateItems({ refs: vm.$refs, state, itemFn });
|
|
1416
|
-
});
|
|
1417
1482
|
}
|
|
1418
1483
|
}
|
|
1419
1484
|
};
|
|
1420
|
-
const getScrollListener = ({ props, vm, state }) => {
|
|
1421
|
-
const listener = () => {
|
|
1422
|
-
const { options } = props;
|
|
1423
|
-
const { optimizeOpts } = state;
|
|
1424
|
-
const { optionHeight } = optimizeOpts;
|
|
1425
|
-
const viewHeight = optionHeight * options.length;
|
|
1426
|
-
const { clientHeight, scrollTop } = optmzApis.queryWrap(vm.$refs);
|
|
1427
|
-
const maxScrollTop = viewHeight - clientHeight;
|
|
1428
|
-
const start = Math.floor(scrollTop / optionHeight);
|
|
1429
|
-
if (scrollTop <= maxScrollTop) {
|
|
1430
|
-
optmzApis.process({ props, start, state });
|
|
1431
|
-
optmzApis.createMacro(() => {
|
|
1432
|
-
const itemFn = (i) => scrollTop + optionHeight * i - scrollTop % optionHeight;
|
|
1433
|
-
optmzApis.updateItems({ refs: vm.$refs, state, itemFn });
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
};
|
|
1437
|
-
const { optimization } = props;
|
|
1438
|
-
const delay = optmzApis.natural((optimization && typeof optimization === "object" ? optimization.delay : null) || 10);
|
|
1439
|
-
return debounce(delay, listener);
|
|
1440
|
-
};
|
|
1441
1485
|
const computeCollapseTags = (props) => () => props.collapseTags;
|
|
1442
1486
|
const computeMultipleLimit = ({ props, state }) => () => {
|
|
1443
|
-
const { multipleLimit, multiple } = props;
|
|
1444
|
-
const { optimizeOpts
|
|
1445
|
-
return optmzApis.natural(multiple &&
|
|
1487
|
+
const { multipleLimit, multiple, optimization } = props;
|
|
1488
|
+
const { optimizeOpts } = state;
|
|
1489
|
+
return optmzApis.natural(multiple && optimization ? multipleLimit || optimizeOpts.limit : multipleLimit);
|
|
1446
1490
|
};
|
|
1447
|
-
const updateModelValue = ({ emit, state }) => (value) => {
|
|
1491
|
+
const updateModelValue = ({ props, emit, state }) => (value, needUpdate) => {
|
|
1448
1492
|
state.isClickChoose = true;
|
|
1449
|
-
|
|
1493
|
+
if (state.device === "mb" && props.multiple && !needUpdate) {
|
|
1494
|
+
state.modelValue = value;
|
|
1495
|
+
} else {
|
|
1496
|
+
emit("update:modelValue", value);
|
|
1497
|
+
}
|
|
1450
1498
|
};
|
|
1451
1499
|
const getLabelSlotValue = ({ props, state }) => (item) => {
|
|
1452
|
-
const datas = state.
|
|
1500
|
+
const datas = state.datas;
|
|
1453
1501
|
const value = item.state ? item.state.currentValue : item.value;
|
|
1454
1502
|
const data = datas.find((data2) => data2.value === value);
|
|
1455
1503
|
const obj = __spreadProps(__spreadValues({}, data), {
|
|
@@ -1465,11 +1513,13 @@ const computedTagsStyle = ({ props, parent, state }) => () => {
|
|
|
1465
1513
|
width: "100%"
|
|
1466
1514
|
};
|
|
1467
1515
|
};
|
|
1468
|
-
const computedReadonly = ({ props, state }) => () => props.readonly || !props.filterable || props.multiple || browserInfo.name !== BROWSER_NAME.IE && browserInfo.name !== BROWSER_NAME.Edge && !state.visible;
|
|
1469
|
-
const computedShowClose = ({ props, state }) => () => props.clearable && !state.selectDisabled && state.inputHovering &&
|
|
1470
|
-
(props.multiple ? Array.isArray(props.modelValue) && props.modelValue.length > 0 : !isNull(props.modelValue) && props.modelValue !== "");
|
|
1516
|
+
const computedReadonly = ({ props, state }) => () => state.device === "mb" || props.readonly || !props.filterable || props.multiple || browserInfo.name !== BROWSER_NAME.IE && browserInfo.name !== BROWSER_NAME.Edge && !state.visible;
|
|
1517
|
+
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 !== "");
|
|
1471
1518
|
const computedCollapseTagSize = (state) => () => state.selectSize;
|
|
1472
|
-
const computedShowNewOption = ({ props, state }) => () =>
|
|
1519
|
+
const computedShowNewOption = ({ props, state }) => () => {
|
|
1520
|
+
const query = state.device === "mb" ? state.queryValue : state.query;
|
|
1521
|
+
return props.filterable && props.allowCreate && query && !state.options.filter((option) => !option.created).some((option) => option.state.currentLabel === state.query);
|
|
1522
|
+
};
|
|
1473
1523
|
const computedShowCopy = ({ props, state }) => () => props.multiple && props.copyable && state.inputHovering && state.selected.length;
|
|
1474
1524
|
const computedOptionsAllDisabled = (state) => () => state.options.filter((option) => option.visible).every((option) => option.disabled);
|
|
1475
1525
|
const computedDisabledTooltipContent = (state) => () => state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join("\uFF1B");
|
|
@@ -1514,15 +1564,18 @@ const watchInitValue = ({ props, emit }) => (value) => {
|
|
|
1514
1564
|
const watchShowClose = ({ nextTick, state, parent }) => () => {
|
|
1515
1565
|
nextTick(() => {
|
|
1516
1566
|
const parentEl = parent.$el;
|
|
1517
|
-
const inputEl = parentEl.querySelector("
|
|
1567
|
+
const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]');
|
|
1518
1568
|
if (inputEl) {
|
|
1519
1569
|
const { paddingRight } = getComputedStyle(inputEl);
|
|
1520
1570
|
state.inputPaddingRight = parseFloat(paddingRight);
|
|
1521
1571
|
}
|
|
1522
1572
|
});
|
|
1523
1573
|
};
|
|
1524
|
-
const computedGetIcon = ({
|
|
1525
|
-
return props.dropdownIcon
|
|
1574
|
+
const computedGetIcon = ({ designConfig, props }) => () => {
|
|
1575
|
+
return props.dropdownIcon ? { icon: props.dropdownIcon } : {
|
|
1576
|
+
icon: (designConfig == null ? void 0 : designConfig.icons.dropdownIcon) || "icon-delta-down",
|
|
1577
|
+
isDefault: true
|
|
1578
|
+
};
|
|
1526
1579
|
};
|
|
1527
1580
|
const computedGetTagType = ({ designConfig, props }) => () => {
|
|
1528
1581
|
var _a;
|
|
@@ -1531,8 +1584,18 @@ const computedGetTagType = ({ designConfig, props }) => () => {
|
|
|
1531
1584
|
}
|
|
1532
1585
|
return props.tagType;
|
|
1533
1586
|
};
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1587
|
+
const clearSearchText = ({ state, api }) => () => {
|
|
1588
|
+
state.query = "";
|
|
1589
|
+
state.previousQuery = void 0;
|
|
1590
|
+
api.handleQueryChange(state.query);
|
|
1591
|
+
};
|
|
1592
|
+
const clearNoMatchValue = ({ props, emit }) => (newModelValue) => {
|
|
1593
|
+
if (!props.clearNoMatchValue) {
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
if (props.multiple && props.modelValue.length !== newModelValue.length || !props.multiple && props.modelValue !== newModelValue) {
|
|
1597
|
+
emit("update:modelValue", newModelValue);
|
|
1598
|
+
}
|
|
1536
1599
|
};
|
|
1537
1600
|
export {
|
|
1538
1601
|
blur,
|
|
@@ -1542,6 +1605,7 @@ export {
|
|
|
1542
1605
|
calcOverFlow,
|
|
1543
1606
|
checkDefaultFirstOption,
|
|
1544
1607
|
clearNoMatchValue,
|
|
1608
|
+
clearSearchText,
|
|
1545
1609
|
computeCollapseTags,
|
|
1546
1610
|
computeMultipleLimit,
|
|
1547
1611
|
computeOptimizeOpts,
|
|
@@ -1555,24 +1619,25 @@ export {
|
|
|
1555
1619
|
computedSelectDisabled,
|
|
1556
1620
|
computedShowClose,
|
|
1557
1621
|
computedShowCopy,
|
|
1558
|
-
computedShowDropdownIcon,
|
|
1559
1622
|
computedShowNewOption,
|
|
1560
1623
|
computedTagsStyle,
|
|
1561
1624
|
debouncRquest,
|
|
1562
|
-
debouncedQueryChange,
|
|
1563
1625
|
defaultOnQueryChange,
|
|
1564
1626
|
deletePrevTag,
|
|
1565
1627
|
deleteSelected,
|
|
1566
1628
|
deleteTag,
|
|
1629
|
+
directEmitChange,
|
|
1567
1630
|
doDestroy,
|
|
1568
1631
|
emitChange,
|
|
1632
|
+
emptyFlag,
|
|
1569
1633
|
emptyText,
|
|
1570
1634
|
focus,
|
|
1571
1635
|
getChildValue,
|
|
1572
1636
|
getLabelSlotValue,
|
|
1573
1637
|
getOption,
|
|
1638
|
+
getOptionIndexArr,
|
|
1574
1639
|
getPluginOption,
|
|
1575
|
-
|
|
1640
|
+
getSelectedOption,
|
|
1576
1641
|
getTreeData,
|
|
1577
1642
|
getValueIndex,
|
|
1578
1643
|
getValueKey,
|
|
@@ -1583,7 +1648,6 @@ export {
|
|
|
1583
1648
|
handleClose,
|
|
1584
1649
|
handleComposition,
|
|
1585
1650
|
handleCopyClick,
|
|
1586
|
-
handleDebouncedQueryChange,
|
|
1587
1651
|
handleDropdownClick,
|
|
1588
1652
|
handleEnterTag,
|
|
1589
1653
|
handleFocus,
|
|
@@ -1605,8 +1669,11 @@ export {
|
|
|
1605
1669
|
onMouseenterNative,
|
|
1606
1670
|
onMouseleaveNative,
|
|
1607
1671
|
onOptionDestroy,
|
|
1672
|
+
queryChange,
|
|
1673
|
+
queryVisibleOptions,
|
|
1608
1674
|
radioChange,
|
|
1609
|
-
|
|
1675
|
+
recycleScrollerHeight,
|
|
1676
|
+
resetDatas,
|
|
1610
1677
|
resetHoverIndex,
|
|
1611
1678
|
resetInputHeight,
|
|
1612
1679
|
resetInputState,
|
|
@@ -1614,6 +1681,7 @@ export {
|
|
|
1614
1681
|
scrollToOption,
|
|
1615
1682
|
selectChange,
|
|
1616
1683
|
selectOption,
|
|
1684
|
+
setOptionHighlight,
|
|
1617
1685
|
setSelected,
|
|
1618
1686
|
setSoftFocus,
|
|
1619
1687
|
showTip,
|