@opentiny/vue-renderless 3.13.2 → 3.14.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/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/bigInt.js +2 -2
- package/common/date.js +7 -5
- package/common/deps/clickoutside.js +6 -2
- package/common/deps/date-util.js +4 -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 +15 -6
- package/date-table/index.js +35 -53
- package/date-table/vue.js +4 -2
- 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 +48 -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 +290 -77
- package/picker/mb.js +42 -0
- package/picker/vue.js +76 -20
- 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 +73 -34
- 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 +442 -393
- package/select/vue.js +278 -164
- 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 +29 -3
- 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/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 +6 -0
- package/types/collapse.type.d.ts +19 -2
- package/types/date-picker.type.d.ts +38 -1
- 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-a2dc0099.d.ts} +4 -1
- 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 +2 -6
- 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/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 +12 -0
- package/types/picker.type.d.ts +18 -0
- package/types/popconfirm.type.d.ts +86 -1
- package/types/popeditor.type.d.ts +4 -0
- package/types/popover.type.d.ts +3 -3
- package/types/progress.type.d.ts +2 -0
- 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 +14 -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 +1 -1
- package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-6d6e3d0e.d.ts} +35 -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 +35 -26
- 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);
|
|
@@ -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 || [];
|
|
@@ -195,47 +219,50 @@ const directEmitChange = ({ emit, props, state }) => (value, key) => {
|
|
|
195
219
|
return;
|
|
196
220
|
emit("change", value, key);
|
|
197
221
|
};
|
|
198
|
-
const
|
|
199
|
-
if (!props.clearNoMatchValue) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if (props.multiple && props.modelValue.length !== newModelValue.length || !props.multiple && props.modelValue !== newModelValue) {
|
|
203
|
-
emit("update:modelValue", newModelValue);
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
const getOption = ({ props, state }) => (value) => {
|
|
222
|
+
const getOption = ({ props, state, api }) => (value) => {
|
|
207
223
|
let option;
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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;
|
|
212
230
|
if (isEqual2) {
|
|
213
231
|
option = cachedOption;
|
|
214
232
|
break;
|
|
215
233
|
}
|
|
216
234
|
}
|
|
217
235
|
if (option) {
|
|
218
|
-
|
|
219
|
-
const cloneOption = extend(true, {}, option);
|
|
220
|
-
cloneOption.currentLabel = cloneOption[props.textField];
|
|
221
|
-
return cloneOption;
|
|
222
|
-
} else {
|
|
223
|
-
if (!option.currentLabel) {
|
|
224
|
-
option.currentLabel = option[props.textField];
|
|
225
|
-
}
|
|
226
|
-
return option;
|
|
227
|
-
}
|
|
236
|
+
return option;
|
|
228
237
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
+
}
|
|
232
247
|
}
|
|
248
|
+
const label = !isObject && !isNull2 && !isUndefined && !props.clearNoMatchValue ? value : "";
|
|
233
249
|
let newOption = { value, currentLabel: label };
|
|
234
250
|
if (props.multiple) {
|
|
235
251
|
newOption.hitState = false;
|
|
236
252
|
}
|
|
237
253
|
return newOption;
|
|
238
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
|
+
};
|
|
239
266
|
const getOptionOfSetSelected = ({ api, props }) => {
|
|
240
267
|
const option = api.getOption(props.modelValue) || {};
|
|
241
268
|
if (!option.state) {
|
|
@@ -252,11 +279,11 @@ const getOptionOfSetSelected = ({ api, props }) => {
|
|
|
252
279
|
}
|
|
253
280
|
return option;
|
|
254
281
|
};
|
|
255
|
-
const getResultOfSetSelected = ({
|
|
282
|
+
const getResultOfSetSelected = ({ state, isGrid, isTree, api, props }) => {
|
|
256
283
|
let result = [];
|
|
257
284
|
const newModelValue = [];
|
|
258
|
-
if (Array.isArray(
|
|
259
|
-
|
|
285
|
+
if (Array.isArray(state.modelValue)) {
|
|
286
|
+
state.modelValue.forEach((value) => {
|
|
260
287
|
if (isGrid || isTree) {
|
|
261
288
|
const option = api.getPluginOption(value, isTree);
|
|
262
289
|
result = result.concat(option);
|
|
@@ -265,7 +292,7 @@ const getResultOfSetSelected = ({ props, isGrid, isTree, api }) => {
|
|
|
265
292
|
}
|
|
266
293
|
} else {
|
|
267
294
|
const option = api.getOption(value);
|
|
268
|
-
if (!props.clearNoMatchValue || props.clearNoMatchValue && option.
|
|
295
|
+
if (!props.clearNoMatchValue || props.clearNoMatchValue && option.label) {
|
|
269
296
|
result.push(option);
|
|
270
297
|
newModelValue.push(value);
|
|
271
298
|
}
|
|
@@ -284,14 +311,14 @@ const setGridOrTreeSelected = ({ props, state, vm, isTree, api }) => {
|
|
|
284
311
|
vm.$refs.selectTree && vm.$refs.selectTree.setCurrentKey && vm.$refs.selectTree.setCurrentKey(null);
|
|
285
312
|
return;
|
|
286
313
|
}
|
|
287
|
-
const isRemote =
|
|
314
|
+
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
288
315
|
const nestdata = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
|
|
289
316
|
const data = find(nestdata, (item) => props.modelValue === item[props.valueField]);
|
|
290
317
|
if (isEmptyObject(data)) {
|
|
291
318
|
api.clearNoMatchValue("");
|
|
292
319
|
return;
|
|
293
320
|
}
|
|
294
|
-
const obj =
|
|
321
|
+
const obj = Object.assign({}, data);
|
|
295
322
|
const label = data[props.textField];
|
|
296
323
|
obj.currentLabel = label;
|
|
297
324
|
state.selectedLabel = label;
|
|
@@ -306,25 +333,22 @@ const setSelected = ({ api, constants, nextTick, props, vm, state }) => () => {
|
|
|
306
333
|
setGridOrTreeSelected({ props, state, vm, isTree, api });
|
|
307
334
|
} else {
|
|
308
335
|
const option = getOptionOfSetSelected({ api, props });
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (state.filterOrSearch && !props.shape && !props.allowCreate) {
|
|
313
|
-
state.query = state.selectedLabel;
|
|
314
|
-
}
|
|
315
|
-
});
|
|
336
|
+
state.selected = option;
|
|
337
|
+
state.selectedLabel = option.state.currentLabel || option.currentLabel;
|
|
338
|
+
props.filterable && !props.shape && (state.query = state.selectedLabel);
|
|
316
339
|
}
|
|
317
|
-
|
|
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);
|
|
318
348
|
}
|
|
319
|
-
const result = getResultOfSetSelected({ props, isGrid, isTree, api });
|
|
320
|
-
state.selectCls = result.length ? result.length === state.options.length ? "checked-sur" : "halfselect" : "check";
|
|
321
|
-
state.selected = result;
|
|
322
|
-
vm.$refs.selectTree && vm.$refs.selectTree.setCheckedNodes && vm.$refs.selectTree.setCheckedNodes(state.selected);
|
|
323
|
-
state.tips = state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join(",");
|
|
324
|
-
nextTick(api.resetInputHeight);
|
|
325
349
|
};
|
|
326
350
|
const getPluginOption = ({ api, props, state }) => (value, isTree) => {
|
|
327
|
-
const isRemote =
|
|
351
|
+
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
328
352
|
const { textField, valueField } = props;
|
|
329
353
|
const sourceData = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
|
|
330
354
|
const selNode = find(sourceData, (item) => item[valueField] === value);
|
|
@@ -335,45 +359,34 @@ const getPluginOption = ({ api, props, state }) => (value, isTree) => {
|
|
|
335
359
|
}
|
|
336
360
|
return items;
|
|
337
361
|
};
|
|
338
|
-
const toggleCheckAll = ({ api, state }) => () => {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
362
|
+
const toggleCheckAll = ({ api, state, props }) => (filtered) => {
|
|
363
|
+
let value = [];
|
|
364
|
+
const enabledValues = state.options.filter((op) => !op.state.disabled && !op.state.groupDisabled && !op.required && op.state.visible).map((op) => op.value);
|
|
365
|
+
if (filtered) {
|
|
366
|
+
if (state.filteredSelectCls === "check" || state.filteredSelectCls === "halfselect") {
|
|
367
|
+
value = [.../* @__PURE__ */ new Set([...state.modelValue, ...enabledValues])];
|
|
368
|
+
} else {
|
|
369
|
+
value = state.modelValue.filter((val) => !enabledValues.includes(val));
|
|
370
|
+
}
|
|
371
|
+
} else {
|
|
372
|
+
if (state.selectCls === "check") {
|
|
373
|
+
value = enabledValues;
|
|
374
|
+
} else if (state.selectCls === "halfselect") {
|
|
375
|
+
const unchecked = state.options.filter((item) => !item.state.disabled && item.state.selectCls === "check");
|
|
376
|
+
unchecked.length ? value = enabledValues : value = [];
|
|
377
|
+
} else if (state.selectCls === "checked-sur") {
|
|
378
|
+
value = [];
|
|
354
379
|
}
|
|
355
|
-
return values;
|
|
356
|
-
};
|
|
357
|
-
let value;
|
|
358
|
-
if (state.selectCls === "check") {
|
|
359
|
-
value = getEnabledValues(state.options);
|
|
360
|
-
} else if (state.selectCls === "halfselect") {
|
|
361
|
-
const unchecked = state.options.filter((item) => !item.disabled && item.state.selectCls === "check");
|
|
362
|
-
unchecked.length ? value = getEnabledValues(state.options) : value = [];
|
|
363
|
-
} else if (state.selectCls === "checked-sur") {
|
|
364
|
-
value = getEnabledValues(state.options);
|
|
365
380
|
}
|
|
381
|
+
const requiredValue = state.options.filter((op) => op.required).map((op) => op.value);
|
|
382
|
+
const disabledSelectedValues = state.options.filter((op) => (op.state.disabled || op.state.groupDisabled) && op.state.selectCls === "checked-sur").map((op) => op.value);
|
|
383
|
+
value = [...value, ...requiredValue, ...disabledSelectedValues];
|
|
366
384
|
api.setSoftFocus();
|
|
367
385
|
state.isSilentBlur = true;
|
|
368
386
|
api.updateModelValue(value);
|
|
369
387
|
api.directEmitChange(value);
|
|
370
388
|
};
|
|
371
|
-
const
|
|
372
|
-
state.query = "";
|
|
373
|
-
state.previousQuery = void 0;
|
|
374
|
-
api.handleQueryChange(state.query);
|
|
375
|
-
};
|
|
376
|
-
const handleFocus = ({ emit, props, state, api }) => (event) => {
|
|
389
|
+
const handleFocus = ({ emit, props, state }) => (event) => {
|
|
377
390
|
if (!state.softFocus) {
|
|
378
391
|
if (props.automaticDropdown || props.filterable) {
|
|
379
392
|
state.visible = true;
|
|
@@ -381,26 +394,22 @@ const handleFocus = ({ emit, props, state, api }) => (event) => {
|
|
|
381
394
|
}
|
|
382
395
|
emit("focus", event);
|
|
383
396
|
} else {
|
|
397
|
+
if (state.searchSingleCopy && state.selectedLabel) {
|
|
398
|
+
emit("focus", event);
|
|
399
|
+
}
|
|
384
400
|
state.softFocus = false;
|
|
385
401
|
}
|
|
386
|
-
if (props.remote && state.filterOrSearch && state.firstAutoSearch) {
|
|
387
|
-
state.firstAutoSearch = false;
|
|
388
|
-
api.resetFilter();
|
|
389
|
-
}
|
|
390
402
|
};
|
|
391
403
|
const focus = ({ vm, state }) => () => {
|
|
392
|
-
var _a;
|
|
393
404
|
if (!state.softFocus) {
|
|
394
|
-
|
|
405
|
+
vm.$refs.reference.focus();
|
|
395
406
|
}
|
|
396
407
|
};
|
|
397
408
|
const blur = ({ vm, state }) => () => {
|
|
398
|
-
var _a;
|
|
399
409
|
state.visible = false;
|
|
400
|
-
|
|
410
|
+
vm.$refs.reference.blur();
|
|
401
411
|
};
|
|
402
412
|
const handleBlur = ({ constants, dispatch, emit, state }) => (event) => {
|
|
403
|
-
var _a;
|
|
404
413
|
clearTimeout(state.timer);
|
|
405
414
|
state.timer = setTimeout(() => {
|
|
406
415
|
if (state.isSilentBlur) {
|
|
@@ -409,7 +418,7 @@ const handleBlur = ({ constants, dispatch, emit, state }) => (event) => {
|
|
|
409
418
|
emit("blur", event);
|
|
410
419
|
}
|
|
411
420
|
}, 200);
|
|
412
|
-
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formBlur,
|
|
421
|
+
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formBlur, event.target.value);
|
|
413
422
|
state.softFocus = false;
|
|
414
423
|
};
|
|
415
424
|
const handleClearClick = (api) => (event) => {
|
|
@@ -429,6 +438,9 @@ const toggleLastOptionHitState = ({ state }) => (hit) => {
|
|
|
429
438
|
if (!option) {
|
|
430
439
|
return;
|
|
431
440
|
}
|
|
441
|
+
if (option.required) {
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
432
444
|
const hitTarget = option.state || option;
|
|
433
445
|
if (hit === true || hit === false) {
|
|
434
446
|
hitTarget.hitState = hit;
|
|
@@ -439,8 +451,9 @@ const toggleLastOptionHitState = ({ state }) => (hit) => {
|
|
|
439
451
|
};
|
|
440
452
|
const deletePrevTag = ({ api, constants, props, state, vm }) => (event) => {
|
|
441
453
|
if (event.target.value.length <= 0 && !api.toggleLastOptionHitState()) {
|
|
442
|
-
const value =
|
|
454
|
+
const value = state.modelValue.slice();
|
|
443
455
|
value.pop();
|
|
456
|
+
state.compareValue = deepClone(value);
|
|
444
457
|
api.updateModelValue(value);
|
|
445
458
|
api.emitChange(value);
|
|
446
459
|
if (props.renderType === constants.TYPE.Grid) {
|
|
@@ -471,9 +484,7 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
471
484
|
if (!vm.$refs.reference) {
|
|
472
485
|
return;
|
|
473
486
|
}
|
|
474
|
-
|
|
475
|
-
const inputContainer = [].filter.call(inputChildNodes, (item) => hasClass(item, "tiny-input-display-only"))[0];
|
|
476
|
-
const input = inputContainer && inputContainer.querySelector("input");
|
|
487
|
+
let input = vm.$refs.reference.type === "text" && vm.$refs.reference.$el.querySelector("input");
|
|
477
488
|
const tags = vm.$refs.tags;
|
|
478
489
|
if (!input) {
|
|
479
490
|
return;
|
|
@@ -481,14 +492,15 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
481
492
|
if (!state.isDisplayOnly && props.hoverExpand && !props.disabled) {
|
|
482
493
|
api.calcCollapseTags();
|
|
483
494
|
}
|
|
484
|
-
const sizeInMap =
|
|
495
|
+
const sizeInMap = state.initialInputHeight || (state.isSaaSTheme ? 28 : 30);
|
|
485
496
|
const noSelected = state.selected.length === 0;
|
|
497
|
+
const spacingHeight = designConfig ? (_a = designConfig.state) == null ? void 0 : _a.spacingHeight : 2;
|
|
486
498
|
if (!state.isDisplayOnly) {
|
|
487
499
|
if (!noSelected && tags) {
|
|
488
500
|
fastdom.measure(() => {
|
|
489
501
|
const tagsClientHeight = tags.clientHeight;
|
|
490
502
|
fastdom.mutate(() => {
|
|
491
|
-
input.style.height = Math.max(tagsClientHeight +
|
|
503
|
+
input.style.height = Math.max(tagsClientHeight + spacingHeight, sizeInMap) + "px";
|
|
492
504
|
});
|
|
493
505
|
});
|
|
494
506
|
} else {
|
|
@@ -498,7 +510,7 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
498
510
|
input.style.height = "auto";
|
|
499
511
|
}
|
|
500
512
|
if (state.visible && state.emptyText !== false) {
|
|
501
|
-
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
513
|
+
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper, true);
|
|
502
514
|
}
|
|
503
515
|
});
|
|
504
516
|
};
|
|
@@ -518,34 +530,39 @@ const resetHoverIndex = ({ props, state }) => () => {
|
|
|
518
530
|
}
|
|
519
531
|
}
|
|
520
532
|
};
|
|
533
|
+
const resetDatas = ({ props, state }) => () => {
|
|
534
|
+
if (props.optimization && !props.remote && !props.filterMethod) {
|
|
535
|
+
state.datas = state.initDatas;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
521
538
|
const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byClick) => {
|
|
522
|
-
var _a, _b;
|
|
523
539
|
state.memorize && state.memorize.updateByKey(option[state.memorize._dataKey] || option.value);
|
|
524
540
|
if (props.multiple) {
|
|
525
|
-
const value = (
|
|
541
|
+
const value = (state.modelValue || []).slice();
|
|
526
542
|
const optionIndex = api.getValueIndex(value, option.value);
|
|
527
543
|
if (optionIndex > -1) {
|
|
528
544
|
value.splice(optionIndex, 1);
|
|
529
545
|
} else if (state.multipleLimit <= 0 || value.length < state.multipleLimit) {
|
|
530
546
|
value.push(option.value);
|
|
531
547
|
}
|
|
548
|
+
state.compareValue = deepClone(value);
|
|
532
549
|
api.updateModelValue(value);
|
|
533
550
|
api.emitChange(value);
|
|
534
551
|
if (option.created) {
|
|
552
|
+
const isChange = false;
|
|
553
|
+
const isInput = true;
|
|
535
554
|
state.query = "";
|
|
536
|
-
api.handleQueryChange("");
|
|
555
|
+
api.handleQueryChange("", isChange, isInput);
|
|
537
556
|
state.inputLength = 20;
|
|
538
557
|
}
|
|
539
558
|
if (props.filterable) {
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
if (props.searchable) {
|
|
543
|
-
(_b = vm.$refs.reference) == null ? void 0 : _b.focus();
|
|
559
|
+
vm.$refs.input.focus();
|
|
544
560
|
}
|
|
545
561
|
if (props.autoClose) {
|
|
546
562
|
state.visible = false;
|
|
547
563
|
}
|
|
548
564
|
} else {
|
|
565
|
+
state.compareValue = deepClone(option.value);
|
|
549
566
|
api.updateModelValue(option.value);
|
|
550
567
|
api.emitChange(option.value);
|
|
551
568
|
if (option.created) {
|
|
@@ -570,11 +587,13 @@ const initValue = ({ state }) => (vm) => {
|
|
|
570
587
|
const setSoftFocus = ({ vm, state }) => () => {
|
|
571
588
|
state.softFocus = true;
|
|
572
589
|
const input = vm.$refs.input || vm.$refs.reference;
|
|
573
|
-
|
|
590
|
+
if (input) {
|
|
591
|
+
input.focus();
|
|
592
|
+
}
|
|
574
593
|
};
|
|
575
594
|
const getValueIndex = (props) => (arr = [], value = null) => {
|
|
576
|
-
const
|
|
577
|
-
if (!
|
|
595
|
+
const isObject = Object.prototype.toString.call(value).toLowerCase() === "[object object]";
|
|
596
|
+
if (!isObject) {
|
|
578
597
|
return arr.indexOf(value);
|
|
579
598
|
} else {
|
|
580
599
|
const valueKey = props.valueKey;
|
|
@@ -589,18 +608,25 @@ const getValueIndex = (props) => (arr = [], value = null) => {
|
|
|
589
608
|
return index;
|
|
590
609
|
}
|
|
591
610
|
};
|
|
592
|
-
const toggleMenu = ({ vm, state, props }) => (e) => {
|
|
611
|
+
const toggleMenu = ({ vm, state, props, api }) => (e) => {
|
|
612
|
+
if (props.keepFocus && state.visible && props.filterable) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
593
615
|
const event = e || window.event;
|
|
594
616
|
const enterCode = 13;
|
|
595
617
|
const nodeName = event.target && event.target.nodeName;
|
|
596
618
|
const toggleVisible = props.ignoreEnter ? event.keyCode !== enterCode && nodeName === "INPUT" : true;
|
|
619
|
+
if (!props.displayOnly) {
|
|
620
|
+
event.stopPropagation();
|
|
621
|
+
}
|
|
597
622
|
if (!state.selectDisabled) {
|
|
598
623
|
toggleVisible && !state.softFocus && (state.visible = !state.visible);
|
|
599
624
|
state.softFocus = false;
|
|
600
625
|
if (state.visible) {
|
|
601
626
|
if (!(props.filterable && props.shape)) {
|
|
602
627
|
const dom = vm.$refs.input || vm.$refs.reference;
|
|
603
|
-
dom == null ? void 0 : dom.focus();
|
|
628
|
+
(dom == null ? void 0 : dom.focus) && dom.focus();
|
|
629
|
+
api.setOptionHighlight();
|
|
604
630
|
}
|
|
605
631
|
}
|
|
606
632
|
}
|
|
@@ -609,45 +635,49 @@ const selectOption = ({ api, state, props }) => (e) => {
|
|
|
609
635
|
if (!state.visible || props.hideDrop) {
|
|
610
636
|
api.toggleMenu(e);
|
|
611
637
|
} else {
|
|
612
|
-
|
|
613
|
-
|
|
638
|
+
let option = "";
|
|
639
|
+
if (state.query || props.remote) {
|
|
640
|
+
option = state.options.find((item) => item.state.index === state.hoverValue);
|
|
641
|
+
} else {
|
|
642
|
+
option = state.options[state.hoverIndex];
|
|
614
643
|
}
|
|
644
|
+
option && api.handleOptionSelect(option);
|
|
615
645
|
}
|
|
616
646
|
};
|
|
617
647
|
const deleteSelected = ({ api, constants, emit, props, vm, state }) => (event) => {
|
|
618
|
-
event.stopPropagation();
|
|
648
|
+
event && event.stopPropagation();
|
|
619
649
|
let selectedValue = [];
|
|
620
650
|
if (props.multiple) {
|
|
621
651
|
const requireOptions = state.options.filter((opt) => opt.required && opt.value);
|
|
622
|
-
selectedValue =
|
|
652
|
+
selectedValue = state.modelValue.slice().filter((v) => requireOptions.find((opt) => opt.value === v));
|
|
623
653
|
}
|
|
624
654
|
const value = props.multiple ? selectedValue : "";
|
|
625
|
-
const refs = vm.$refs;
|
|
626
655
|
if (props.renderType === constants.TYPE.Tree) {
|
|
627
656
|
state.selected = {};
|
|
628
657
|
state.selectedLabel = "";
|
|
629
|
-
refs.selectTree.
|
|
658
|
+
vm.$refs.selectTree.state.currentRadio.value = null;
|
|
659
|
+
vm.$refs.selectTree.setCurrentKey(null);
|
|
630
660
|
} else if (props.renderType === constants.TYPE.Grid) {
|
|
631
661
|
state.selected = {};
|
|
632
662
|
state.selectedLabel = "";
|
|
633
|
-
refs.selectGrid.clearRadioRow();
|
|
663
|
+
vm.$refs.selectGrid.clearRadioRow();
|
|
634
664
|
}
|
|
635
665
|
state.showTip = false;
|
|
636
|
-
|
|
637
|
-
api.
|
|
666
|
+
state.compareValue = deepClone(value);
|
|
667
|
+
api.updateModelValue(value, true);
|
|
668
|
+
api.emitChange(value, true);
|
|
638
669
|
state.visible = false;
|
|
639
670
|
emit("clear");
|
|
640
671
|
};
|
|
641
672
|
const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (event, tag) => {
|
|
642
673
|
if (tag.required)
|
|
643
674
|
return;
|
|
644
|
-
const refs = vm.$refs;
|
|
645
675
|
const isTree = props.renderType === constants.TYPE.Tree;
|
|
646
676
|
const index = state.selected.indexOf(tag);
|
|
647
677
|
const treeValue = [];
|
|
648
678
|
const treeIds = [tag[props.valueField]];
|
|
649
679
|
if (isTree && !props.treeOp.checkStrictly) {
|
|
650
|
-
let node = refs.selectTree.getNode(tag[props.valueField]);
|
|
680
|
+
let node = vm.$refs.selectTree.getNode(tag[props.valueField]);
|
|
651
681
|
if (!node.isLeaf) {
|
|
652
682
|
treeIds.push(...api.getChildValue(node.childNodes, props.valueField));
|
|
653
683
|
}
|
|
@@ -658,28 +688,31 @@ const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (eve
|
|
|
658
688
|
state.selected.slice().map((node2) => !treeIds.includes(node2[props.valueField]) && treeValue.push(node2[props.valueField]));
|
|
659
689
|
}
|
|
660
690
|
if (index > -1 && !state.selectDisabled) {
|
|
661
|
-
const value =
|
|
691
|
+
const value = state.modelValue.slice();
|
|
662
692
|
value.splice(index, 1);
|
|
663
693
|
if (props.renderType === constants.TYPE.Tree) {
|
|
664
694
|
props.treeOp.checkStrictly && treeValue.push(...value);
|
|
665
|
-
refs.selectTree.setCheckedKeys(treeValue);
|
|
695
|
+
vm.$refs.selectTree.setCheckedKeys(treeValue);
|
|
666
696
|
} else if (props.renderType === constants.TYPE.Grid) {
|
|
667
697
|
const rows = state.selected.slice().filter((item) => value.includes(item[props.valueField]));
|
|
668
|
-
refs.selectGrid.clearSelection();
|
|
669
|
-
refs.selectGrid.setSelection(rows, true);
|
|
698
|
+
vm.$refs.selectGrid.clearSelection();
|
|
699
|
+
vm.$refs.selectGrid.setSelection(rows, true);
|
|
670
700
|
}
|
|
701
|
+
state.compareValue = deepClone(value);
|
|
671
702
|
api.updateModelValue(isTree ? treeValue : value);
|
|
672
703
|
api.emitChange(value);
|
|
673
704
|
emit(constants.EVENT_NAME.removeTag, tag[props.valueField]);
|
|
674
705
|
nextTick(() => state.key++);
|
|
675
706
|
}
|
|
676
|
-
event.stopPropagation();
|
|
707
|
+
event && event.stopPropagation();
|
|
677
708
|
};
|
|
678
709
|
const onInputChange = ({ api, props, state, constants, nextTick }) => () => {
|
|
679
710
|
if (!props.delay) {
|
|
680
711
|
if (props.filterable && state.query !== state.selectedLabel) {
|
|
712
|
+
const isChange = false;
|
|
713
|
+
const isInput = true;
|
|
681
714
|
state.query = state.selectedLabel;
|
|
682
|
-
api.handleQueryChange(state.query);
|
|
715
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
683
716
|
nextTick(() => {
|
|
684
717
|
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
685
718
|
});
|
|
@@ -699,8 +732,9 @@ const onOptionDestroy = (state) => (index) => {
|
|
|
699
732
|
}
|
|
700
733
|
};
|
|
701
734
|
const resetInputWidth = ({ vm, state }) => () => {
|
|
702
|
-
|
|
703
|
-
|
|
735
|
+
if (vm.$refs.reference && vm.$refs.reference.$el) {
|
|
736
|
+
state.inputWidth = vm.$refs.reference.$el.getBoundingClientRect().width;
|
|
737
|
+
}
|
|
704
738
|
};
|
|
705
739
|
const handleResize = ({ api, props, state }) => () => {
|
|
706
740
|
api.resetInputWidth();
|
|
@@ -708,29 +742,42 @@ const handleResize = ({ api, props, state }) => () => {
|
|
|
708
742
|
api.resetInputHeight();
|
|
709
743
|
}
|
|
710
744
|
};
|
|
745
|
+
const setOptionHighlight = (state) => () => {
|
|
746
|
+
for (let i = 0; i < state.options.length; ++i) {
|
|
747
|
+
const option = state.options[i];
|
|
748
|
+
if (!option.disabled && !option.groupDisabled && !option.state.created && option.state.visible && option.state.itemSelected) {
|
|
749
|
+
state.hoverIndex = i;
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
};
|
|
711
754
|
const checkDefaultFirstOption = (state) => () => {
|
|
712
755
|
state.hoverIndex = -1;
|
|
713
756
|
let hasCreated = false;
|
|
714
|
-
|
|
715
|
-
|
|
757
|
+
const visibleOptions = state.options.filter((item) => item.visible && item.state.visible);
|
|
758
|
+
for (let i = visibleOptions.length - 1; i >= 0; i--) {
|
|
759
|
+
if (visibleOptions[i].created) {
|
|
716
760
|
hasCreated = true;
|
|
717
761
|
state.hoverIndex = i;
|
|
762
|
+
state.hoverValue = state.optionIndexArr[i];
|
|
718
763
|
break;
|
|
719
764
|
}
|
|
720
765
|
}
|
|
721
766
|
if (hasCreated) {
|
|
722
767
|
return;
|
|
723
768
|
}
|
|
724
|
-
for (let i = 0; i
|
|
725
|
-
const option =
|
|
769
|
+
for (let i = 0; i < visibleOptions.length; i++) {
|
|
770
|
+
const option = visibleOptions[i];
|
|
726
771
|
if (state.query) {
|
|
727
|
-
if (!option.disabled && !option.groupDisabled && option.state.visible) {
|
|
772
|
+
if (!option.disabled && !option.groupDisabled && option.state.visible && option.visible) {
|
|
728
773
|
state.hoverIndex = i;
|
|
774
|
+
state.hoverValue = state.optionIndexArr[i];
|
|
729
775
|
break;
|
|
730
776
|
}
|
|
731
777
|
} else {
|
|
732
778
|
if (option.itemSelected) {
|
|
733
779
|
state.hoverIndex = i;
|
|
780
|
+
state.hoverValue = state.optionIndexArr[i];
|
|
734
781
|
break;
|
|
735
782
|
}
|
|
736
783
|
}
|
|
@@ -744,8 +791,12 @@ const getValueKey = (props) => (item) => {
|
|
|
744
791
|
}
|
|
745
792
|
return getObj(item.value, props.valueKey);
|
|
746
793
|
};
|
|
747
|
-
const navigateOptions = ({ api,
|
|
748
|
-
const
|
|
794
|
+
const navigateOptions = ({ api, state, props, nextTick }) => (direction) => {
|
|
795
|
+
const { optimization } = props;
|
|
796
|
+
if (optimization) {
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
const len = state.options.filter((item) => item.visible && item.state.visible).length;
|
|
749
800
|
if (!state.visible) {
|
|
750
801
|
state.visible = true;
|
|
751
802
|
return;
|
|
@@ -753,6 +804,13 @@ const navigateOptions = ({ api, nextTick, state }) => (direction) => {
|
|
|
753
804
|
if (len === 0 || state.filteredOptionsCount === 0) {
|
|
754
805
|
return;
|
|
755
806
|
}
|
|
807
|
+
state.disabledOptionHover = true;
|
|
808
|
+
setTimeout(() => {
|
|
809
|
+
state.disabledOptionHover = false;
|
|
810
|
+
}, 100);
|
|
811
|
+
if (state.hoverIndex < -1 || state.hoverIndex >= len) {
|
|
812
|
+
state.hoverIndex = 0;
|
|
813
|
+
}
|
|
756
814
|
if (!state.optionsAllDisabled) {
|
|
757
815
|
if (direction === "next") {
|
|
758
816
|
state.hoverIndex++;
|
|
@@ -765,39 +823,68 @@ const navigateOptions = ({ api, nextTick, state }) => (direction) => {
|
|
|
765
823
|
state.hoverIndex = len - 1;
|
|
766
824
|
}
|
|
767
825
|
}
|
|
768
|
-
|
|
769
|
-
|
|
826
|
+
let option = {};
|
|
827
|
+
state.hoverValue = state.optionIndexArr[state.hoverIndex];
|
|
828
|
+
if (state.query || props.remote) {
|
|
829
|
+
option = state.options.find((item) => item.state.index === state.hoverValue);
|
|
830
|
+
} else {
|
|
831
|
+
option = state.options[state.hoverIndex];
|
|
832
|
+
}
|
|
833
|
+
if (option.disabled === true || option.groupDisabled === true || !option.state.visible || option.state.limitReached) {
|
|
770
834
|
api.navigateOptions(direction);
|
|
771
835
|
}
|
|
772
|
-
nextTick(() => api.scrollToOption(state.
|
|
836
|
+
nextTick(() => api.scrollToOption(state.hoverIndex === -9 ? {} : option || {}));
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
const emptyFlag = ({ props, state }) => () => {
|
|
840
|
+
if (props.optimization) {
|
|
841
|
+
if (props.allowCreate) {
|
|
842
|
+
return state.query === "" && state.datas.length === 0;
|
|
843
|
+
} else {
|
|
844
|
+
return state.datas.length === 0;
|
|
845
|
+
}
|
|
846
|
+
} else {
|
|
847
|
+
return state.options.length === 0;
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
const recycleScrollerHeight = ({ state, props, recycle }) => () => {
|
|
851
|
+
const { ITEM_HEIGHT, SAFE_MARGIN, SAAS_HEIGHT, AURORA_HEIGHT } = recycle;
|
|
852
|
+
let length = state.datas.length;
|
|
853
|
+
if (state.showNewOption) {
|
|
854
|
+
length += 1;
|
|
855
|
+
}
|
|
856
|
+
if (length === 0 || props.loading) {
|
|
857
|
+
return 0;
|
|
858
|
+
} else if (length < 6) {
|
|
859
|
+
return length * ITEM_HEIGHT + (state.isSaaSTheme ? SAFE_MARGIN * 2 : 0);
|
|
860
|
+
} else {
|
|
861
|
+
return state.isSaaSTheme ? SAAS_HEIGHT : AURORA_HEIGHT;
|
|
773
862
|
}
|
|
774
863
|
};
|
|
775
|
-
const emptyText = ({ I18N, props, state, t }) => () => {
|
|
864
|
+
const emptyText = ({ I18N, props, state, t, isMobileFirstMode }) => () => {
|
|
776
865
|
if (props.loading) {
|
|
777
866
|
return props.loadingText || t(I18N.loading);
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
if (props.remote && state.query === "" && state.options.length === 0) {
|
|
792
|
-
if (props.shape === "filter") {
|
|
793
|
-
return "";
|
|
794
|
-
} else {
|
|
795
|
-
return false;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
867
|
+
}
|
|
868
|
+
if (props.remote && state.query === "" && props.renderType) {
|
|
869
|
+
return remoteEmptyText(props, state);
|
|
870
|
+
}
|
|
871
|
+
if (props.remote && state.query === "" && state.emptyFlag && !state.triggerSearch) {
|
|
872
|
+
return props.shape === "filter" || isMobileFirstMode ? "" : false;
|
|
873
|
+
}
|
|
874
|
+
if (props.filterable && state.query && (props.remote && state.emptyFlag || !state.options.some((option) => option.visible && option.state.visible))) {
|
|
875
|
+
return props.noMatchText || t(I18N.noMatch);
|
|
876
|
+
}
|
|
877
|
+
if (state.emptyFlag) {
|
|
878
|
+
return props.noDataText || t(I18N.noData);
|
|
798
879
|
}
|
|
799
880
|
return null;
|
|
800
881
|
};
|
|
882
|
+
const remoteEmptyText = function(props, state) {
|
|
883
|
+
if (props.multiple) {
|
|
884
|
+
return state.selected.length > 0 || state.remoteData.length >= 0;
|
|
885
|
+
}
|
|
886
|
+
return state.selected[props.valueField] || state.remoteData.length >= 0;
|
|
887
|
+
};
|
|
801
888
|
const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, oldValue) => {
|
|
802
889
|
if (props.multiple) {
|
|
803
890
|
api.resetInputHeight();
|
|
@@ -806,9 +893,8 @@ const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, o
|
|
|
806
893
|
} else {
|
|
807
894
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
808
895
|
}
|
|
809
|
-
if (
|
|
810
|
-
props.renderType !== constants.TYPE.Grid && (state.query = "");
|
|
811
|
-
api.handleQueryChange(state.query);
|
|
896
|
+
if (props.filterable && !props.reserveKeyword) {
|
|
897
|
+
props.renderType !== constants.TYPE.Grid && !props.searchable && (state.query = "");
|
|
812
898
|
}
|
|
813
899
|
}
|
|
814
900
|
api.setSelected();
|
|
@@ -820,13 +906,13 @@ const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, o
|
|
|
820
906
|
if (state.completed && !isEqual(value, oldValue)) {
|
|
821
907
|
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formChange, value);
|
|
822
908
|
}
|
|
823
|
-
|
|
909
|
+
props.optimization && optmzApis.setValueIndex({ props, state });
|
|
824
910
|
};
|
|
825
911
|
const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
826
912
|
if (props.multiple && props.showOverflowTooltip) {
|
|
827
913
|
state.overflow = false;
|
|
828
914
|
const tagDom = vm.$refs.tags;
|
|
829
|
-
const tags = tagDom.querySelectorAll("
|
|
915
|
+
const tags = tagDom.querySelectorAll('[data-tag="tiny-tag"]');
|
|
830
916
|
if (tags.length) {
|
|
831
917
|
tagDom.scrollTo && tagDom.scrollTo({ top: 0 });
|
|
832
918
|
let { x, width } = tags[0].getBoundingClientRect();
|
|
@@ -856,7 +942,6 @@ const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
|
856
942
|
}
|
|
857
943
|
};
|
|
858
944
|
const postOperOfToVisible = ({ props, state, constants }) => {
|
|
859
|
-
var _a;
|
|
860
945
|
if (props.multiple) {
|
|
861
946
|
return;
|
|
862
947
|
}
|
|
@@ -867,30 +952,32 @@ const postOperOfToVisible = ({ props, state, constants }) => {
|
|
|
867
952
|
if (props.filterable && props.allowCreate && state.createdSelected && state.createdLabel) {
|
|
868
953
|
state.selectedLabel = state.createdLabel;
|
|
869
954
|
} else {
|
|
870
|
-
state.selectedLabel =
|
|
955
|
+
state.selectedLabel = state.selected.state.currentLabel || state.selected.currentLabel;
|
|
871
956
|
}
|
|
872
957
|
if (props.filterable) {
|
|
873
958
|
state.query = state.selectedLabel;
|
|
874
959
|
}
|
|
875
960
|
}
|
|
876
|
-
if (
|
|
961
|
+
if (props.filterable) {
|
|
877
962
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
878
963
|
}
|
|
879
964
|
}
|
|
880
965
|
};
|
|
881
966
|
const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
882
|
-
var _a;
|
|
883
967
|
state.selectEmitter.emit(constants.EVENT_NAME.destroyPopper);
|
|
884
968
|
props.remote && props.dropOnlySearch && (state.showWarper = false);
|
|
885
|
-
(
|
|
969
|
+
if (vm.$refs.input) {
|
|
970
|
+
vm.$refs.input.blur();
|
|
971
|
+
}
|
|
886
972
|
state.query = "";
|
|
887
973
|
state.selectedLabel = "";
|
|
888
974
|
state.inputLength = 20;
|
|
889
975
|
state.previousQuery !== state.query && api.initQuery().then(() => api.setSelected());
|
|
890
976
|
if (props.renderType !== constants.TYPE.Tree) {
|
|
891
|
-
state.previousQuery =
|
|
977
|
+
state.previousQuery = null;
|
|
892
978
|
}
|
|
893
979
|
api.resetHoverIndex();
|
|
980
|
+
api.resetDatas();
|
|
894
981
|
nextTick(() => {
|
|
895
982
|
if (vm.$refs.input && vm.$refs.input.value === "" && state.selected.length === 0) {
|
|
896
983
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
@@ -901,23 +988,22 @@ const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
|
901
988
|
});
|
|
902
989
|
postOperOfToVisible({ props, state, constants });
|
|
903
990
|
};
|
|
904
|
-
const toHide = ({ constants, state, props, vm, api
|
|
905
|
-
|
|
906
|
-
state.selectEmitter.emit(constants.COMPONENT_NAME.SelectDropdown);
|
|
907
|
-
|
|
908
|
-
state.
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
state.query
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
props.filterable ? (_a = vm.$refs.input) == null ? void 0 : _a.focus() : (_b = vm.$refs.reference) == null ? void 0 : _b.focus();
|
|
991
|
+
const toHide = ({ constants, state, props, vm, api }) => () => {
|
|
992
|
+
const { filterable, remote, remoteConfig, shape, renderType, multiple, valueField } = props;
|
|
993
|
+
state.selectEmitter.emit(constants.COMPONENT_NAME.SelectDropdown, constants.EVENT_NAME.updatePopper);
|
|
994
|
+
if (filterable) {
|
|
995
|
+
state.query = remote || shape ? "" : renderType !== constants.TYPE.Tree ? state.selectedLabel : "";
|
|
996
|
+
const isChange = remote && remoteConfig.autoSearch && (state.firstAutoSearch || remoteConfig.clearData);
|
|
997
|
+
state.firstAutoSearch = false;
|
|
998
|
+
api.handleQueryChange(state.query, isChange);
|
|
999
|
+
if (multiple) {
|
|
1000
|
+
vm.$refs.input.focus();
|
|
915
1001
|
} else {
|
|
916
|
-
if (!
|
|
917
|
-
state.selectEmitter.emit(constants.EVENT_NAME.queryChange);
|
|
918
|
-
state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup);
|
|
1002
|
+
if (!remote) {
|
|
1003
|
+
state.selectEmitter.emit(constants.EVENT_NAME.queryChange, "");
|
|
1004
|
+
state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup, constants.EVENT_NAME.queryChange);
|
|
919
1005
|
}
|
|
920
|
-
if (state.selectedLabel && !
|
|
1006
|
+
if (state.selectedLabel && !shape) {
|
|
921
1007
|
state.currentPlaceholder = state.selectedLabel;
|
|
922
1008
|
state.selectedLabel = "";
|
|
923
1009
|
}
|
|
@@ -925,32 +1011,34 @@ const toHide = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
|
925
1011
|
}
|
|
926
1012
|
if (vm.$refs.selectGrid) {
|
|
927
1013
|
let { fullData } = vm.$refs.selectGrid.getTableData();
|
|
928
|
-
if (
|
|
929
|
-
const selectedIds = state.selected.map((sel) => sel[
|
|
1014
|
+
if (multiple) {
|
|
1015
|
+
const selectedIds = state.selected.map((sel) => sel[valueField]);
|
|
930
1016
|
vm.$refs.selectGrid.clearSelection();
|
|
931
1017
|
vm.$refs.selectGrid.setSelection(
|
|
932
|
-
fullData.filter((row) => ~selectedIds.indexOf(row[
|
|
1018
|
+
fullData.filter((row) => ~selectedIds.indexOf(row[valueField])),
|
|
933
1019
|
true
|
|
934
1020
|
);
|
|
935
1021
|
} else {
|
|
936
1022
|
vm.$refs.selectGrid.clearRadioRow();
|
|
937
|
-
vm.$refs.selectGrid.setRadioRow(find(fullData, (item) => props.modelValue === item[
|
|
1023
|
+
vm.$refs.selectGrid.setRadioRow(find(fullData, (item) => props.modelValue === item[valueField]));
|
|
938
1024
|
}
|
|
939
|
-
if (
|
|
1025
|
+
if (filterable && typeof props.filterMethod === "function") {
|
|
940
1026
|
vm.$refs.selectGrid.handleTableData(true);
|
|
941
|
-
} else if (
|
|
1027
|
+
} else if (filterable && remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
942
1028
|
vm.$refs.selectGrid.handleTableData();
|
|
943
1029
|
}
|
|
944
1030
|
}
|
|
945
1031
|
};
|
|
946
1032
|
const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) => {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
(_a = vm.$refs.reference) == null ? void 0 : _a.blur();
|
|
1033
|
+
if ((props.filterable || props.remote) && !value) {
|
|
1034
|
+
vm.$refs.reference.blur();
|
|
950
1035
|
}
|
|
951
1036
|
if (api.onCopying()) {
|
|
952
1037
|
return;
|
|
953
1038
|
}
|
|
1039
|
+
if (value && props.multiple && state.device === "mb") {
|
|
1040
|
+
state.selectedCopy = state.selected.slice();
|
|
1041
|
+
}
|
|
954
1042
|
setTimeout(() => {
|
|
955
1043
|
if (!value && !state.selectedLabel) {
|
|
956
1044
|
state.cachedOptions.forEach((item) => {
|
|
@@ -960,15 +1048,19 @@ const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) =>
|
|
|
960
1048
|
}, 200);
|
|
961
1049
|
value ? api.toHide() : api.toVisible();
|
|
962
1050
|
emit(constants.EVENT_NAME.visibleChange, value);
|
|
1051
|
+
setTimeout(() => {
|
|
1052
|
+
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
1053
|
+
if (value && vm.$refs.scrollbar) {
|
|
1054
|
+
if (props.optimization) {
|
|
1055
|
+
optmzApis.setScrollTop({ refs: vm.$refs, state });
|
|
1056
|
+
} else {
|
|
1057
|
+
vm.$refs.scrollbar.handleScroll();
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}, props.updateDelay);
|
|
963
1061
|
if (!value && props.shape === "filter") {
|
|
964
1062
|
state.softFocus = false;
|
|
965
1063
|
}
|
|
966
|
-
if (value && state.optimizeStore.flag) {
|
|
967
|
-
optmzApis.createMacro(() => {
|
|
968
|
-
optmzApis.setScrollTop({ refs: vm.$refs, state });
|
|
969
|
-
api.getScrollListener();
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
1064
|
};
|
|
973
1065
|
const watchOptions = ({ api, constants, nextTick, parent, props, state }) => () => {
|
|
974
1066
|
if (typeof window === "undefined") {
|
|
@@ -985,8 +1077,26 @@ const watchOptions = ({ api, constants, nextTick, parent, props, state }) => ()
|
|
|
985
1077
|
api.setSelected();
|
|
986
1078
|
}
|
|
987
1079
|
});
|
|
988
|
-
|
|
989
|
-
|
|
1080
|
+
api.getOptionIndexArr();
|
|
1081
|
+
};
|
|
1082
|
+
const getOptionIndexArr = ({ props, state, api }) => () => {
|
|
1083
|
+
setTimeout(() => {
|
|
1084
|
+
state.optionIndexArr = api.queryVisibleOptions().map((item) => Number(item.getAttribute("data-index")));
|
|
1085
|
+
if (props.defaultFirstOption && (props.filterable || props.remote) && state.filteredOptionsCount) {
|
|
1086
|
+
if (props.optimization) {
|
|
1087
|
+
optmzApis.checkDefaultFirstOption({ state });
|
|
1088
|
+
} else {
|
|
1089
|
+
api.checkDefaultFirstOption();
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
};
|
|
1094
|
+
const queryVisibleOptions = ({ props, vm, isMobileFirstMode }) => () => {
|
|
1095
|
+
var _a;
|
|
1096
|
+
if (props.optimization) {
|
|
1097
|
+
return optmzApis.queryVisibleOptions(vm, isMobileFirstMode);
|
|
1098
|
+
} else {
|
|
1099
|
+
return Array.from(((_a = vm.$refs.scrollbar) == null ? void 0 : _a.$el.querySelectorAll('[data-index]:not([style*="display: none"])')) || []);
|
|
990
1100
|
}
|
|
991
1101
|
};
|
|
992
1102
|
const handleCopyClick = ({ parent, props, state }) => () => {
|
|
@@ -1000,7 +1110,7 @@ const handleCopyClick = ({ parent, props, state }) => () => {
|
|
|
1000
1110
|
document.execCommand("copy");
|
|
1001
1111
|
parent.$el.removeChild(input);
|
|
1002
1112
|
};
|
|
1003
|
-
const selectChange = ({
|
|
1113
|
+
const selectChange = ({ props, state, api }) => ({ $table, selection, checked, row }) => {
|
|
1004
1114
|
const { textField, valueField } = props;
|
|
1005
1115
|
const remoteItem = (row2) => {
|
|
1006
1116
|
const removeItem = find(state.selected, (item) => item[valueField] === row2[valueField]);
|
|
@@ -1010,12 +1120,12 @@ const selectChange = ({ emit, props, state, api }) => ({ $table, selection, chec
|
|
|
1010
1120
|
checked ? state.selected.push(__spreadProps(__spreadValues({}, row), { value: row[valueField], currentLabel: row[textField] })) : remoteItem(row);
|
|
1011
1121
|
} else {
|
|
1012
1122
|
checked ? state.selected = state.selected.concat(
|
|
1013
|
-
selection.filter((row2) => !~
|
|
1123
|
+
selection.filter((row2) => !~state.modelValue.indexOf(row2[valueField]))
|
|
1014
1124
|
) : $table.tableFullData.forEach((row2) => remoteItem(row2));
|
|
1015
1125
|
}
|
|
1016
1126
|
const keys = state.selected.map((item) => item[valueField]);
|
|
1017
1127
|
api.updateModelValue(keys);
|
|
1018
|
-
|
|
1128
|
+
api.directEmitChange(keys, state.selected);
|
|
1019
1129
|
};
|
|
1020
1130
|
const getcheckedData = ({ props, state }) => () => {
|
|
1021
1131
|
const checkedKey = [];
|
|
@@ -1028,14 +1138,16 @@ const getcheckedData = ({ props, state }) => () => {
|
|
|
1028
1138
|
return checkedKey;
|
|
1029
1139
|
}
|
|
1030
1140
|
};
|
|
1031
|
-
const radioChange = ({
|
|
1141
|
+
const radioChange = ({ props, state, api, vm }) => ({ row }) => {
|
|
1032
1142
|
row.value = row[props.valueField];
|
|
1033
1143
|
row.currentLabel = row[props.textField];
|
|
1144
|
+
!state.hasClearSelection && vm.$refs.selectGrid.clearSelection();
|
|
1145
|
+
state.hasClearSelection = true;
|
|
1034
1146
|
state.selected = row;
|
|
1035
1147
|
state.visible = false;
|
|
1036
1148
|
state.currentKey = row[props.valueField];
|
|
1037
1149
|
api.updateModelValue(row.value);
|
|
1038
|
-
|
|
1150
|
+
api.directEmitChange(row);
|
|
1039
1151
|
};
|
|
1040
1152
|
const getTreeData = (props) => (data) => {
|
|
1041
1153
|
const nodes = [];
|
|
@@ -1051,14 +1163,14 @@ const getTreeData = (props) => (data) => {
|
|
|
1051
1163
|
getChild(data, null);
|
|
1052
1164
|
return nodes;
|
|
1053
1165
|
};
|
|
1054
|
-
const treeNodeClick = ({
|
|
1166
|
+
const treeNodeClick = ({ props, state, api, vm }) => (data) => {
|
|
1055
1167
|
if (!props.multiple) {
|
|
1056
1168
|
data.currentLabel = data[props.textField];
|
|
1057
1169
|
data.value = data[props.valueField];
|
|
1058
1170
|
state.selected = data;
|
|
1059
1171
|
state.visible = false;
|
|
1060
1172
|
api.updateModelValue(data.value);
|
|
1061
|
-
|
|
1173
|
+
api.directEmitChange(data);
|
|
1062
1174
|
} else {
|
|
1063
1175
|
if (props.treeOp.checkOnClickNode) {
|
|
1064
1176
|
const checkedNodes = vm.$refs.selectTree.getCheckedNodes();
|
|
@@ -1067,7 +1179,7 @@ const treeNodeClick = ({ emit, props, state, api, vm }) => (data) => {
|
|
|
1067
1179
|
}
|
|
1068
1180
|
}
|
|
1069
1181
|
};
|
|
1070
|
-
const nodeCheckClick = ({
|
|
1182
|
+
const nodeCheckClick = ({ props, state, api }) => (data, { checkedKeys, checkedNodes }) => {
|
|
1071
1183
|
const selected = state.selected.map((item) => api.getValueKey(item));
|
|
1072
1184
|
if (isEqual(selected, checkedKeys)) {
|
|
1073
1185
|
return;
|
|
@@ -1075,10 +1187,9 @@ const nodeCheckClick = ({ emit, props, state, api }) => (data, { checkedKeys, ch
|
|
|
1075
1187
|
state.selected = checkedNodes.filter((node) => {
|
|
1076
1188
|
node.currentLabel = node[props.textField];
|
|
1077
1189
|
node.value = node[props.valueField];
|
|
1078
|
-
return node;
|
|
1079
1190
|
});
|
|
1080
1191
|
api.updateModelValue(checkedKeys);
|
|
1081
|
-
|
|
1192
|
+
api.directEmitChange(checkedKeys, checkedNodes);
|
|
1082
1193
|
};
|
|
1083
1194
|
const nodeCollapse = ({ state, constants }) => () => {
|
|
1084
1195
|
setTimeout(() => {
|
|
@@ -1091,9 +1202,11 @@ const nodeExpand = ({ state, constants }) => () => {
|
|
|
1091
1202
|
}, 310);
|
|
1092
1203
|
};
|
|
1093
1204
|
const debouncRquest = ({ api, state, props }) => debounce(props.delay, () => {
|
|
1094
|
-
if (
|
|
1205
|
+
if (props.filterable && state.query !== state.selectedLabel) {
|
|
1206
|
+
const isChange = false;
|
|
1207
|
+
const isInput = true;
|
|
1095
1208
|
state.query = state.selectedLabel;
|
|
1096
|
-
api.handleQueryChange(state.query);
|
|
1209
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
1097
1210
|
}
|
|
1098
1211
|
});
|
|
1099
1212
|
const getChildValue = () => (data, key) => {
|
|
@@ -1140,6 +1253,7 @@ const watchPropsOption = ({ constants, parent, props, state }) => () => {
|
|
|
1140
1253
|
state.datas = state.memorize.assemble(sortData.slice());
|
|
1141
1254
|
} else {
|
|
1142
1255
|
state.datas = sortData;
|
|
1256
|
+
state.initDatas = sortData;
|
|
1143
1257
|
}
|
|
1144
1258
|
}
|
|
1145
1259
|
});
|
|
@@ -1147,13 +1261,13 @@ const watchPropsOption = ({ constants, parent, props, state }) => () => {
|
|
|
1147
1261
|
const buildSelectConfig = ({ props, state }) => () => {
|
|
1148
1262
|
const checkRowKeys = state.gridCheckedData;
|
|
1149
1263
|
const selectConfig = props.selectConfig;
|
|
1150
|
-
return
|
|
1264
|
+
return Object.assign({}, selectConfig, { checkRowKeys });
|
|
1151
1265
|
};
|
|
1152
1266
|
const buildRadioConfig = ({ props, state }) => () => {
|
|
1153
1267
|
const checkRowKey = state.currentKey;
|
|
1154
1268
|
const highlight = true;
|
|
1155
1269
|
const radioConfig = props.radioConfig;
|
|
1156
|
-
return
|
|
1270
|
+
return Object.assign({}, radioConfig, { checkRowKey, highlight });
|
|
1157
1271
|
};
|
|
1158
1272
|
const onMouseenterNative = ({ state }) => () => {
|
|
1159
1273
|
state.inputHovering = true;
|
|
@@ -1169,18 +1283,21 @@ const onMouseleaveNative = ({ state }) => (e) => {
|
|
|
1169
1283
|
state.softFocus = false;
|
|
1170
1284
|
}
|
|
1171
1285
|
};
|
|
1172
|
-
const onCopying = ({ state, vm }) => () =>
|
|
1286
|
+
const onCopying = ({ state, vm }) => () => {
|
|
1287
|
+
return state.searchSingleCopy && state.selectedLabel && vm.$refs.reference && vm.$refs.reference.hasSelection && vm.$refs.reference.hasSelection();
|
|
1288
|
+
};
|
|
1173
1289
|
const watchHoverIndex = ({ state }) => (value) => {
|
|
1174
|
-
if (
|
|
1175
|
-
state.
|
|
1176
|
-
} else
|
|
1177
|
-
state.
|
|
1290
|
+
if (value === -1 || value === -9) {
|
|
1291
|
+
state.hoverValue = -1;
|
|
1292
|
+
} else {
|
|
1293
|
+
state.hoverValue = state.optionIndexArr[value];
|
|
1178
1294
|
}
|
|
1179
|
-
state.options.forEach((option) => {
|
|
1180
|
-
option.hover = state.hoverOption === option;
|
|
1181
|
-
});
|
|
1182
1295
|
};
|
|
1183
|
-
const handleDropdownClick = ({ emit }) => ($event) => {
|
|
1296
|
+
const handleDropdownClick = ({ vm, state, props, emit }) => ($event) => {
|
|
1297
|
+
if (props.allowCopy && vm.$refs.reference) {
|
|
1298
|
+
vm.$refs.reference.$el.querySelector("input").selectionEnd = 0;
|
|
1299
|
+
}
|
|
1300
|
+
state.softFocus = false;
|
|
1184
1301
|
emit("dropdown-click", $event);
|
|
1185
1302
|
};
|
|
1186
1303
|
const handleEnterTag = ({ state }) => ($event, key) => {
|
|
@@ -1194,15 +1311,15 @@ const calcCollapseTags = ({ state, vm }) => () => {
|
|
|
1194
1311
|
return state.isHidden = true;
|
|
1195
1312
|
}
|
|
1196
1313
|
const tags = vm.$refs.tags;
|
|
1197
|
-
|
|
1314
|
+
const collapseTag = tags && tags.querySelector('[data-tag="tags-collapse"]');
|
|
1315
|
+
if (!tags || !collapseTag) {
|
|
1198
1316
|
return;
|
|
1199
1317
|
}
|
|
1200
1318
|
const { width: tagsContentWidth, paddingLeft, paddingRight } = window.getComputedStyle(tags);
|
|
1201
1319
|
const tagsWidth = parseFloat(tagsContentWidth) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
1202
|
-
const collapseTag = tags.querySelector(".tiny-select__tags-collapse");
|
|
1203
1320
|
const { width: collapseTagContentWidth, marginRight } = collapseTag && window.getComputedStyle(collapseTag);
|
|
1204
1321
|
const collapseTagWidth = collapseTag && parseFloat(collapseTagContentWidth) + parseFloat(marginRight);
|
|
1205
|
-
const tagList = Array.from(tags.querySelectorAll("
|
|
1322
|
+
const tagList = Array.from(tags.querySelectorAll('[data-tag="tiny-tag"]'));
|
|
1206
1323
|
let { total, dom, idx } = { total: collapseTagWidth, dom: null, idx: 0 };
|
|
1207
1324
|
tagList.forEach((tag, index) => {
|
|
1208
1325
|
if (tag !== collapseTag) {
|
|
@@ -1255,21 +1372,22 @@ const initQuery = ({ props, state, constants, vm }) => ({ init } = {}) => {
|
|
|
1255
1372
|
}
|
|
1256
1373
|
return Promise.resolve(selected);
|
|
1257
1374
|
};
|
|
1258
|
-
const mounted = ({ api, parent, state, props, vm,
|
|
1375
|
+
const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
1259
1376
|
var _a;
|
|
1260
1377
|
state.defaultCheckedKeys = state.gridCheckedData;
|
|
1261
1378
|
const parentEl = parent.$el;
|
|
1262
|
-
const inputEl = parentEl.querySelector(
|
|
1263
|
-
const inputClientRect =
|
|
1379
|
+
const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]');
|
|
1380
|
+
const inputClientRect = inputEl && inputEl.getBoundingClientRect() || {};
|
|
1264
1381
|
if (inputEl === document.activeElement) {
|
|
1265
|
-
|
|
1382
|
+
document.activeElement.blur();
|
|
1266
1383
|
}
|
|
1267
1384
|
state.completed = true;
|
|
1268
|
-
const
|
|
1385
|
+
const defaultSizeMap = { default: 28, mini: 24, small: 32, medium: 40 };
|
|
1386
|
+
const sizeMap = ((_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.sizeMap) || defaultSizeMap;
|
|
1269
1387
|
if (props.multiple && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
|
|
1270
1388
|
state.currentPlaceholder = "";
|
|
1271
1389
|
}
|
|
1272
|
-
state.initialInputHeight = state.isDisplayOnly ? sizeMap[state.selectSize
|
|
1390
|
+
state.initialInputHeight = state.isDisplayOnly ? sizeMap[state.selectSize || "default"] : inputClientRect.height || sizeMap[state.selectSize];
|
|
1273
1391
|
addResizeListener(parentEl, api.handleResize);
|
|
1274
1392
|
if (vm.$refs.tags) {
|
|
1275
1393
|
addResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
@@ -1291,7 +1409,6 @@ const unMount = ({ api, parent, vm, state }) => () => {
|
|
|
1291
1409
|
removeResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
1292
1410
|
}
|
|
1293
1411
|
state.popperElm = null;
|
|
1294
|
-
state.optimizeStore.flag && optmzApis.removeScrollListener({ api, refs: vm.$refs, state });
|
|
1295
1412
|
};
|
|
1296
1413
|
const optmzApis = {
|
|
1297
1414
|
exist: (val, multiple) => multiple ? Array.isArray(val) && val.length : val,
|
|
@@ -1300,100 +1417,40 @@ const optmzApis = {
|
|
|
1300
1417
|
const contain = (val, arr) => Array.isArray(arr) && ~arr.indexOf(val);
|
|
1301
1418
|
const equal = (val, opt) => multiple ? contain(opt[valueField], [val]) : opt[valueField] === val;
|
|
1302
1419
|
let start = 0;
|
|
1303
|
-
if (optmzApis.exist(modelValue, multiple)) {
|
|
1420
|
+
if (optmzApis.exist(modelValue, multiple) && options) {
|
|
1304
1421
|
const lastVal = multiple ? modelValue[modelValue.length - 1] : modelValue;
|
|
1305
1422
|
for (let i = 0; i < options.length; i++) {
|
|
1306
|
-
if (!equal(lastVal, options[i]))
|
|
1423
|
+
if (!equal(lastVal, options[i]))
|
|
1307
1424
|
continue;
|
|
1308
|
-
}
|
|
1309
1425
|
return i;
|
|
1310
1426
|
}
|
|
1311
1427
|
}
|
|
1312
1428
|
return start;
|
|
1313
1429
|
},
|
|
1314
|
-
|
|
1315
|
-
const
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
getViewStyle: ({ props, state }) => {
|
|
1322
|
-
const { options } = props;
|
|
1323
|
-
const { optimizeOpts } = state;
|
|
1324
|
-
const { optionHeight } = optimizeOpts;
|
|
1325
|
-
return `height:${optionHeight * options.length}px`;
|
|
1430
|
+
queryVisibleOptions: (vm, isMobileFirstMode) => {
|
|
1431
|
+
const querySelectKey = isMobileFirstMode ? ".cursor-not-allowed" : ".is-disabled";
|
|
1432
|
+
return Array.from(
|
|
1433
|
+
vm.$refs.scrollbar.$el.querySelectorAll(
|
|
1434
|
+
'.tiny-recycle-scroller__slot, .tiny-recycle-scroller__item-view:not([style*="transform: translateY(-9999px) translateX(0px)"])'
|
|
1435
|
+
)
|
|
1436
|
+
).map((item) => item.querySelector(`[data-tag="tiny-select-dropdown-item"]:not(${querySelectKey})`)).filter((v) => v);
|
|
1326
1437
|
},
|
|
1327
|
-
getStoreDatas: ({ props, state }) => {
|
|
1328
|
-
const { options, valueField, modelValue, multiple } = props;
|
|
1329
|
-
const { datas, optimizeOpts, optimizeStore } = state;
|
|
1330
|
-
const { startIndex } = optimizeStore;
|
|
1331
|
-
const { rSize } = optimizeOpts;
|
|
1332
|
-
const sliced = datas.slice(startIndex, startIndex + rSize);
|
|
1333
|
-
const hiddenOptions = optimizeStore.hiddenOptions = [];
|
|
1334
|
-
const findPush = (val) => {
|
|
1335
|
-
const opt = options.find((option) => option[valueField] === val);
|
|
1336
|
-
if (opt && !~sliced.indexOf(opt)) {
|
|
1337
|
-
sliced.push(opt);
|
|
1338
|
-
hiddenOptions.push(opt);
|
|
1339
|
-
}
|
|
1340
|
-
};
|
|
1341
|
-
if (optmzApis.exist(modelValue, multiple)) {
|
|
1342
|
-
if (multiple) {
|
|
1343
|
-
modelValue.forEach(findPush);
|
|
1344
|
-
} else {
|
|
1345
|
-
findPush(modelValue);
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
return sliced;
|
|
1349
|
-
},
|
|
1350
|
-
queryWrap: (refs) => refs.scrollbar.$el.querySelector(".tiny-scrollbar__wrap.virtual"),
|
|
1351
|
-
queryItems: (refs) => refs.scrollbar.$el.querySelectorAll(".tiny-option.virtual"),
|
|
1352
|
-
createMacro: (cb) => setTimeout(cb),
|
|
1353
1438
|
setScrollTop: ({ refs, state }) => {
|
|
1354
|
-
const { optimizeOpts, optimizeStore } = state;
|
|
1355
|
-
const { optionHeight } = optimizeOpts;
|
|
1356
|
-
const wrap = optmzApis.queryWrap(refs);
|
|
1357
|
-
wrap.scrollTop = optionHeight * optimizeStore.valueIndex;
|
|
1358
|
-
},
|
|
1359
|
-
setValueIndex: ({ props, state }) => state.optimizeStore.valueIndex = optmzApis.getValueIndex(props),
|
|
1360
|
-
addScrollListener: ({ api, refs, state }) => {
|
|
1361
1439
|
const { optimizeStore } = state;
|
|
1362
|
-
|
|
1363
|
-
!optimizeStore.bind && wrap.addEventListener("scroll", api.getScrollListener) && (optimizeStore.bind = true);
|
|
1440
|
+
refs.scrollbar.scrollToItem(optimizeStore.valueIndex);
|
|
1364
1441
|
},
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
const wrap = optmzApis.queryWrap(refs);
|
|
1368
|
-
optimizeStore.bind && wrap.removeEventListener("scroll", api.getScrollListener) && (optimizeStore.bind = false);
|
|
1369
|
-
},
|
|
1370
|
-
isFirstPage: ({ props, state }) => {
|
|
1371
|
-
const { optimizeStore } = state;
|
|
1372
|
-
const { datas } = optimizeStore;
|
|
1373
|
-
const { options } = props;
|
|
1374
|
-
return Array.isArray(datas) && Array.isArray(options) && datas[0] === options[0];
|
|
1442
|
+
setValueIndex: ({ props, state }) => {
|
|
1443
|
+
state.optimizeStore.valueIndex = optmzApis.getValueIndex(props);
|
|
1375
1444
|
},
|
|
1376
1445
|
natural: (val) => val < 0 ? 0 : val,
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
const items = optmzApis.queryItems(refs);
|
|
1381
|
-
for (let i = 0; i < items.length; i++) {
|
|
1382
|
-
const item = items[i];
|
|
1383
|
-
const flag = item.classList.contains("virtual-hidden");
|
|
1384
|
-
item.style.top = flag ? `-${optionHeight}px` : `${itemFn(i)}px`;
|
|
1385
|
-
}
|
|
1386
|
-
},
|
|
1387
|
-
process: ({ props, start, state }) => {
|
|
1388
|
-
const { optimizeStore } = state;
|
|
1389
|
-
optimizeStore.startIndex = typeof start !== "undefined" ? start : optmzApis.getStartIndex({ props, state });
|
|
1390
|
-
optimizeStore.datas = optmzApis.getStoreDatas({ props, state });
|
|
1391
|
-
optimizeStore.firstPage = optmzApis.isFirstPage({ props, state });
|
|
1446
|
+
checkDefaultFirstOption: ({ state }) => {
|
|
1447
|
+
state.hoverIndex = 0;
|
|
1448
|
+
state.hoverValue = state.optionIndexArr[0];
|
|
1392
1449
|
}
|
|
1393
1450
|
};
|
|
1394
|
-
const computeOptimizeOpts = ({ props,
|
|
1451
|
+
const computeOptimizeOpts = ({ props, designConfig }) => () => {
|
|
1395
1452
|
const { optimization } = props;
|
|
1396
|
-
const baseOpts = { gt: 20, rSize: 10, optionHeight: 30, limit: 20 };
|
|
1453
|
+
const baseOpts = (designConfig == null ? void 0 : designConfig.baseOpts) ? designConfig.baseOpts : { gt: 20, rSize: 10, optionHeight: 30, limit: 20 };
|
|
1397
1454
|
let optOpts;
|
|
1398
1455
|
if (optimization) {
|
|
1399
1456
|
if (typeof optimization === "boolean") {
|
|
@@ -1401,60 +1458,33 @@ const computeOptimizeOpts = ({ props, state }) => () => {
|
|
|
1401
1458
|
} else {
|
|
1402
1459
|
optOpts = extend(true, {}, baseOpts, optimization);
|
|
1403
1460
|
}
|
|
1404
|
-
optOpts.virtualScroll = optOpts.gt > 0 && optOpts.gt <= state.datas.length;
|
|
1405
1461
|
return optOpts;
|
|
1406
1462
|
}
|
|
1407
1463
|
};
|
|
1408
|
-
const watchOptimizeOpts = ({
|
|
1464
|
+
const watchOptimizeOpts = ({ props, state }) => () => {
|
|
1409
1465
|
const { optimizeOpts, optimizeStore } = state;
|
|
1410
1466
|
if (optimizeOpts) {
|
|
1411
|
-
|
|
1412
|
-
optimizeStore.flag = virtualScroll;
|
|
1413
|
-
if (virtualScroll) {
|
|
1414
|
-
optimizeStore.viewStyle = optmzApis.getViewStyle({ props, state });
|
|
1467
|
+
if (props.optimization) {
|
|
1415
1468
|
optimizeStore.valueIndex = optmzApis.getValueIndex(props);
|
|
1416
|
-
optmzApis.process({ props, state });
|
|
1417
|
-
optmzApis.createMacro(() => {
|
|
1418
|
-
const itemFn = (i) => optionHeight * (optimizeStore.startIndex + i);
|
|
1419
|
-
optmzApis.addScrollListener({ api, refs: vm.$refs, state });
|
|
1420
|
-
optmzApis.updateItems({ refs: vm.$refs, state, itemFn });
|
|
1421
|
-
});
|
|
1422
1469
|
}
|
|
1423
1470
|
}
|
|
1424
1471
|
};
|
|
1425
|
-
const getScrollListener = ({ props, vm, state }) => {
|
|
1426
|
-
const listener = () => {
|
|
1427
|
-
const { options } = props;
|
|
1428
|
-
const { optimizeOpts } = state;
|
|
1429
|
-
const { optionHeight } = optimizeOpts;
|
|
1430
|
-
const viewHeight = optionHeight * options.length;
|
|
1431
|
-
const { clientHeight, scrollTop } = optmzApis.queryWrap(vm.$refs);
|
|
1432
|
-
const maxScrollTop = viewHeight - clientHeight;
|
|
1433
|
-
const start = Math.floor(scrollTop / optionHeight);
|
|
1434
|
-
if (scrollTop <= maxScrollTop) {
|
|
1435
|
-
optmzApis.process({ props, start, state });
|
|
1436
|
-
optmzApis.createMacro(() => {
|
|
1437
|
-
const itemFn = (i) => scrollTop + optionHeight * i - scrollTop % optionHeight;
|
|
1438
|
-
optmzApis.updateItems({ refs: vm.$refs, state, itemFn });
|
|
1439
|
-
});
|
|
1440
|
-
}
|
|
1441
|
-
};
|
|
1442
|
-
const { optimization } = props;
|
|
1443
|
-
const delay = optmzApis.natural((optimization && typeof optimization === "object" ? optimization.delay : null) || 10);
|
|
1444
|
-
return debounce(delay, listener);
|
|
1445
|
-
};
|
|
1446
1472
|
const computeCollapseTags = (props) => () => props.collapseTags;
|
|
1447
1473
|
const computeMultipleLimit = ({ props, state }) => () => {
|
|
1448
|
-
const { multipleLimit, multiple } = props;
|
|
1449
|
-
const { optimizeOpts
|
|
1450
|
-
return optmzApis.natural(multiple &&
|
|
1474
|
+
const { multipleLimit, multiple, optimization } = props;
|
|
1475
|
+
const { optimizeOpts } = state;
|
|
1476
|
+
return optmzApis.natural(multiple && optimization ? multipleLimit || optimizeOpts.limit : multipleLimit);
|
|
1451
1477
|
};
|
|
1452
|
-
const updateModelValue = ({ emit, state }) => (value) => {
|
|
1478
|
+
const updateModelValue = ({ props, emit, state }) => (value, needUpdate) => {
|
|
1453
1479
|
state.isClickChoose = true;
|
|
1454
|
-
|
|
1480
|
+
if (state.device === "mb" && props.multiple && !needUpdate) {
|
|
1481
|
+
state.modelValue = value;
|
|
1482
|
+
} else {
|
|
1483
|
+
emit("update:modelValue", value);
|
|
1484
|
+
}
|
|
1455
1485
|
};
|
|
1456
1486
|
const getLabelSlotValue = ({ props, state }) => (item) => {
|
|
1457
|
-
const datas = state.
|
|
1487
|
+
const datas = state.datas;
|
|
1458
1488
|
const value = item.state ? item.state.currentValue : item.value;
|
|
1459
1489
|
const data = datas.find((data2) => data2.value === value);
|
|
1460
1490
|
const obj = __spreadProps(__spreadValues({}, data), {
|
|
@@ -1470,11 +1500,13 @@ const computedTagsStyle = ({ props, parent, state }) => () => {
|
|
|
1470
1500
|
width: "100%"
|
|
1471
1501
|
};
|
|
1472
1502
|
};
|
|
1473
|
-
const computedReadonly = ({ props, state }) => () => props.readonly || !props.filterable || props.multiple || browserInfo.name !== BROWSER_NAME.IE && browserInfo.name !== BROWSER_NAME.Edge && !state.visible;
|
|
1474
|
-
const computedShowClose = ({ props, state }) => () => props.clearable && !state.selectDisabled && state.inputHovering &&
|
|
1475
|
-
(props.multiple ? Array.isArray(props.modelValue) && props.modelValue.length > 0 : !isNull(props.modelValue) && props.modelValue !== "");
|
|
1503
|
+
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;
|
|
1504
|
+
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 !== "");
|
|
1476
1505
|
const computedCollapseTagSize = (state) => () => state.selectSize;
|
|
1477
|
-
const computedShowNewOption = ({ props, state }) => () =>
|
|
1506
|
+
const computedShowNewOption = ({ props, state }) => () => {
|
|
1507
|
+
const query = state.device === "mb" ? state.queryValue : state.query;
|
|
1508
|
+
return props.filterable && props.allowCreate && query && !state.options.filter((option) => !option.created).some((option) => option.state.currentLabel === state.query);
|
|
1509
|
+
};
|
|
1478
1510
|
const computedShowCopy = ({ props, state }) => () => props.multiple && props.copyable && state.inputHovering && state.selected.length;
|
|
1479
1511
|
const computedOptionsAllDisabled = (state) => () => state.options.filter((option) => option.visible).every((option) => option.disabled);
|
|
1480
1512
|
const computedDisabledTooltipContent = (state) => () => state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join("\uFF1B");
|
|
@@ -1519,15 +1551,18 @@ const watchInitValue = ({ props, emit }) => (value) => {
|
|
|
1519
1551
|
const watchShowClose = ({ nextTick, state, parent }) => () => {
|
|
1520
1552
|
nextTick(() => {
|
|
1521
1553
|
const parentEl = parent.$el;
|
|
1522
|
-
const inputEl = parentEl.querySelector("
|
|
1554
|
+
const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]');
|
|
1523
1555
|
if (inputEl) {
|
|
1524
1556
|
const { paddingRight } = getComputedStyle(inputEl);
|
|
1525
1557
|
state.inputPaddingRight = parseFloat(paddingRight);
|
|
1526
1558
|
}
|
|
1527
1559
|
});
|
|
1528
1560
|
};
|
|
1529
|
-
const computedGetIcon = ({
|
|
1530
|
-
return props.dropdownIcon
|
|
1561
|
+
const computedGetIcon = ({ designConfig, props }) => () => {
|
|
1562
|
+
return props.dropdownIcon ? { icon: props.dropdownIcon } : {
|
|
1563
|
+
icon: (designConfig == null ? void 0 : designConfig.icons.dropdownIcon) || "icon-delta-down",
|
|
1564
|
+
isDefault: true
|
|
1565
|
+
};
|
|
1531
1566
|
};
|
|
1532
1567
|
const computedGetTagType = ({ designConfig, props }) => () => {
|
|
1533
1568
|
var _a;
|
|
@@ -1536,8 +1571,18 @@ const computedGetTagType = ({ designConfig, props }) => () => {
|
|
|
1536
1571
|
}
|
|
1537
1572
|
return props.tagType;
|
|
1538
1573
|
};
|
|
1539
|
-
const
|
|
1540
|
-
|
|
1574
|
+
const clearSearchText = ({ state, api }) => () => {
|
|
1575
|
+
state.query = "";
|
|
1576
|
+
state.previousQuery = void 0;
|
|
1577
|
+
api.handleQueryChange(state.query);
|
|
1578
|
+
};
|
|
1579
|
+
const clearNoMatchValue = ({ props, emit }) => (newModelValue) => {
|
|
1580
|
+
if (!props.clearNoMatchValue) {
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
if (props.multiple && props.modelValue.length !== newModelValue.length || !props.multiple && props.modelValue !== newModelValue) {
|
|
1584
|
+
emit("update:modelValue", newModelValue);
|
|
1585
|
+
}
|
|
1541
1586
|
};
|
|
1542
1587
|
export {
|
|
1543
1588
|
blur,
|
|
@@ -1547,6 +1592,7 @@ export {
|
|
|
1547
1592
|
calcOverFlow,
|
|
1548
1593
|
checkDefaultFirstOption,
|
|
1549
1594
|
clearNoMatchValue,
|
|
1595
|
+
clearSearchText,
|
|
1550
1596
|
computeCollapseTags,
|
|
1551
1597
|
computeMultipleLimit,
|
|
1552
1598
|
computeOptimizeOpts,
|
|
@@ -1560,11 +1606,9 @@ export {
|
|
|
1560
1606
|
computedSelectDisabled,
|
|
1561
1607
|
computedShowClose,
|
|
1562
1608
|
computedShowCopy,
|
|
1563
|
-
computedShowDropdownIcon,
|
|
1564
1609
|
computedShowNewOption,
|
|
1565
1610
|
computedTagsStyle,
|
|
1566
1611
|
debouncRquest,
|
|
1567
|
-
debouncedQueryChange,
|
|
1568
1612
|
defaultOnQueryChange,
|
|
1569
1613
|
deletePrevTag,
|
|
1570
1614
|
deleteSelected,
|
|
@@ -1572,13 +1616,15 @@ export {
|
|
|
1572
1616
|
directEmitChange,
|
|
1573
1617
|
doDestroy,
|
|
1574
1618
|
emitChange,
|
|
1619
|
+
emptyFlag,
|
|
1575
1620
|
emptyText,
|
|
1576
1621
|
focus,
|
|
1577
1622
|
getChildValue,
|
|
1578
1623
|
getLabelSlotValue,
|
|
1579
1624
|
getOption,
|
|
1625
|
+
getOptionIndexArr,
|
|
1580
1626
|
getPluginOption,
|
|
1581
|
-
|
|
1627
|
+
getSelectedOption,
|
|
1582
1628
|
getTreeData,
|
|
1583
1629
|
getValueIndex,
|
|
1584
1630
|
getValueKey,
|
|
@@ -1589,7 +1635,6 @@ export {
|
|
|
1589
1635
|
handleClose,
|
|
1590
1636
|
handleComposition,
|
|
1591
1637
|
handleCopyClick,
|
|
1592
|
-
handleDebouncedQueryChange,
|
|
1593
1638
|
handleDropdownClick,
|
|
1594
1639
|
handleEnterTag,
|
|
1595
1640
|
handleFocus,
|
|
@@ -1611,8 +1656,11 @@ export {
|
|
|
1611
1656
|
onMouseenterNative,
|
|
1612
1657
|
onMouseleaveNative,
|
|
1613
1658
|
onOptionDestroy,
|
|
1659
|
+
queryChange,
|
|
1660
|
+
queryVisibleOptions,
|
|
1614
1661
|
radioChange,
|
|
1615
|
-
|
|
1662
|
+
recycleScrollerHeight,
|
|
1663
|
+
resetDatas,
|
|
1616
1664
|
resetHoverIndex,
|
|
1617
1665
|
resetInputHeight,
|
|
1618
1666
|
resetInputState,
|
|
@@ -1620,6 +1668,7 @@ export {
|
|
|
1620
1668
|
scrollToOption,
|
|
1621
1669
|
selectChange,
|
|
1622
1670
|
selectOption,
|
|
1671
|
+
setOptionHighlight,
|
|
1623
1672
|
setSelected,
|
|
1624
1673
|
setSoftFocus,
|
|
1625
1674
|
showTip,
|