@opentiny/vue-renderless 3.13.2 → 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 +435 -373
- package/select/vue.js +255 -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 +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/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 +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-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);
|
|
@@ -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,7 +359,7 @@ const getPluginOption = ({ api, props, state }) => (value, isTree) => {
|
|
|
335
359
|
}
|
|
336
360
|
return items;
|
|
337
361
|
};
|
|
338
|
-
const toggleCheckAll = ({ api, state }) => () => {
|
|
362
|
+
const toggleCheckAll = ({ api, state, props }) => (filtered) => {
|
|
339
363
|
const getEnabledValues = (options) => {
|
|
340
364
|
let values = [];
|
|
341
365
|
for (let i = 0; i < options.length; i++) {
|
|
@@ -355,25 +379,29 @@ const toggleCheckAll = ({ api, state }) => () => {
|
|
|
355
379
|
return values;
|
|
356
380
|
};
|
|
357
381
|
let value;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
+
}
|
|
365
398
|
}
|
|
366
399
|
api.setSoftFocus();
|
|
367
400
|
state.isSilentBlur = true;
|
|
368
401
|
api.updateModelValue(value);
|
|
369
402
|
api.directEmitChange(value);
|
|
370
403
|
};
|
|
371
|
-
const
|
|
372
|
-
state.query = "";
|
|
373
|
-
state.previousQuery = void 0;
|
|
374
|
-
api.handleQueryChange(state.query);
|
|
375
|
-
};
|
|
376
|
-
const handleFocus = ({ emit, props, state, api }) => (event) => {
|
|
404
|
+
const handleFocus = ({ emit, props, state }) => (event) => {
|
|
377
405
|
if (!state.softFocus) {
|
|
378
406
|
if (props.automaticDropdown || props.filterable) {
|
|
379
407
|
state.visible = true;
|
|
@@ -381,26 +409,22 @@ const handleFocus = ({ emit, props, state, api }) => (event) => {
|
|
|
381
409
|
}
|
|
382
410
|
emit("focus", event);
|
|
383
411
|
} else {
|
|
412
|
+
if (state.searchSingleCopy && state.selectedLabel) {
|
|
413
|
+
emit("focus", event);
|
|
414
|
+
}
|
|
384
415
|
state.softFocus = false;
|
|
385
416
|
}
|
|
386
|
-
if (props.remote && state.filterOrSearch && state.firstAutoSearch) {
|
|
387
|
-
state.firstAutoSearch = false;
|
|
388
|
-
api.resetFilter();
|
|
389
|
-
}
|
|
390
417
|
};
|
|
391
418
|
const focus = ({ vm, state }) => () => {
|
|
392
|
-
var _a;
|
|
393
419
|
if (!state.softFocus) {
|
|
394
|
-
|
|
420
|
+
vm.$refs.reference.focus();
|
|
395
421
|
}
|
|
396
422
|
};
|
|
397
423
|
const blur = ({ vm, state }) => () => {
|
|
398
|
-
var _a;
|
|
399
424
|
state.visible = false;
|
|
400
|
-
|
|
425
|
+
vm.$refs.reference.blur();
|
|
401
426
|
};
|
|
402
427
|
const handleBlur = ({ constants, dispatch, emit, state }) => (event) => {
|
|
403
|
-
var _a;
|
|
404
428
|
clearTimeout(state.timer);
|
|
405
429
|
state.timer = setTimeout(() => {
|
|
406
430
|
if (state.isSilentBlur) {
|
|
@@ -409,7 +433,7 @@ const handleBlur = ({ constants, dispatch, emit, state }) => (event) => {
|
|
|
409
433
|
emit("blur", event);
|
|
410
434
|
}
|
|
411
435
|
}, 200);
|
|
412
|
-
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formBlur,
|
|
436
|
+
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formBlur, event.target.value);
|
|
413
437
|
state.softFocus = false;
|
|
414
438
|
};
|
|
415
439
|
const handleClearClick = (api) => (event) => {
|
|
@@ -429,6 +453,9 @@ const toggleLastOptionHitState = ({ state }) => (hit) => {
|
|
|
429
453
|
if (!option) {
|
|
430
454
|
return;
|
|
431
455
|
}
|
|
456
|
+
if (option.required) {
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
432
459
|
const hitTarget = option.state || option;
|
|
433
460
|
if (hit === true || hit === false) {
|
|
434
461
|
hitTarget.hitState = hit;
|
|
@@ -439,8 +466,9 @@ const toggleLastOptionHitState = ({ state }) => (hit) => {
|
|
|
439
466
|
};
|
|
440
467
|
const deletePrevTag = ({ api, constants, props, state, vm }) => (event) => {
|
|
441
468
|
if (event.target.value.length <= 0 && !api.toggleLastOptionHitState()) {
|
|
442
|
-
const value =
|
|
469
|
+
const value = state.modelValue.slice();
|
|
443
470
|
value.pop();
|
|
471
|
+
state.compareValue = deepClone(value);
|
|
444
472
|
api.updateModelValue(value);
|
|
445
473
|
api.emitChange(value);
|
|
446
474
|
if (props.renderType === constants.TYPE.Grid) {
|
|
@@ -471,9 +499,7 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
471
499
|
if (!vm.$refs.reference) {
|
|
472
500
|
return;
|
|
473
501
|
}
|
|
474
|
-
|
|
475
|
-
const inputContainer = [].filter.call(inputChildNodes, (item) => hasClass(item, "tiny-input-display-only"))[0];
|
|
476
|
-
const input = inputContainer && inputContainer.querySelector("input");
|
|
502
|
+
let input = vm.$refs.reference.type === "text" && vm.$refs.reference.$el.querySelector("input");
|
|
477
503
|
const tags = vm.$refs.tags;
|
|
478
504
|
if (!input) {
|
|
479
505
|
return;
|
|
@@ -481,14 +507,15 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
481
507
|
if (!state.isDisplayOnly && props.hoverExpand && !props.disabled) {
|
|
482
508
|
api.calcCollapseTags();
|
|
483
509
|
}
|
|
484
|
-
const sizeInMap =
|
|
510
|
+
const sizeInMap = state.initialInputHeight || (state.isSaaSTheme ? 28 : 30);
|
|
485
511
|
const noSelected = state.selected.length === 0;
|
|
512
|
+
const spacingHeight = designConfig ? (_a = designConfig.state) == null ? void 0 : _a.spacingHeight : 2;
|
|
486
513
|
if (!state.isDisplayOnly) {
|
|
487
514
|
if (!noSelected && tags) {
|
|
488
515
|
fastdom.measure(() => {
|
|
489
516
|
const tagsClientHeight = tags.clientHeight;
|
|
490
517
|
fastdom.mutate(() => {
|
|
491
|
-
input.style.height = Math.max(tagsClientHeight +
|
|
518
|
+
input.style.height = Math.max(tagsClientHeight + spacingHeight, sizeInMap) + "px";
|
|
492
519
|
});
|
|
493
520
|
});
|
|
494
521
|
} else {
|
|
@@ -498,7 +525,7 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
498
525
|
input.style.height = "auto";
|
|
499
526
|
}
|
|
500
527
|
if (state.visible && state.emptyText !== false) {
|
|
501
|
-
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
528
|
+
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper, true);
|
|
502
529
|
}
|
|
503
530
|
});
|
|
504
531
|
};
|
|
@@ -518,34 +545,39 @@ const resetHoverIndex = ({ props, state }) => () => {
|
|
|
518
545
|
}
|
|
519
546
|
}
|
|
520
547
|
};
|
|
548
|
+
const resetDatas = ({ props, state }) => () => {
|
|
549
|
+
if (props.optimization && !props.remote && !props.filterMethod) {
|
|
550
|
+
state.datas = state.initDatas;
|
|
551
|
+
}
|
|
552
|
+
};
|
|
521
553
|
const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byClick) => {
|
|
522
|
-
var _a, _b;
|
|
523
554
|
state.memorize && state.memorize.updateByKey(option[state.memorize._dataKey] || option.value);
|
|
524
555
|
if (props.multiple) {
|
|
525
|
-
const value = (
|
|
556
|
+
const value = (state.modelValue || []).slice();
|
|
526
557
|
const optionIndex = api.getValueIndex(value, option.value);
|
|
527
558
|
if (optionIndex > -1) {
|
|
528
559
|
value.splice(optionIndex, 1);
|
|
529
560
|
} else if (state.multipleLimit <= 0 || value.length < state.multipleLimit) {
|
|
530
561
|
value.push(option.value);
|
|
531
562
|
}
|
|
563
|
+
state.compareValue = deepClone(value);
|
|
532
564
|
api.updateModelValue(value);
|
|
533
565
|
api.emitChange(value);
|
|
534
566
|
if (option.created) {
|
|
567
|
+
const isChange = false;
|
|
568
|
+
const isInput = true;
|
|
535
569
|
state.query = "";
|
|
536
|
-
api.handleQueryChange("");
|
|
570
|
+
api.handleQueryChange("", isChange, isInput);
|
|
537
571
|
state.inputLength = 20;
|
|
538
572
|
}
|
|
539
573
|
if (props.filterable) {
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
if (props.searchable) {
|
|
543
|
-
(_b = vm.$refs.reference) == null ? void 0 : _b.focus();
|
|
574
|
+
vm.$refs.input.focus();
|
|
544
575
|
}
|
|
545
576
|
if (props.autoClose) {
|
|
546
577
|
state.visible = false;
|
|
547
578
|
}
|
|
548
579
|
} else {
|
|
580
|
+
state.compareValue = deepClone(option.value);
|
|
549
581
|
api.updateModelValue(option.value);
|
|
550
582
|
api.emitChange(option.value);
|
|
551
583
|
if (option.created) {
|
|
@@ -570,11 +602,13 @@ const initValue = ({ state }) => (vm) => {
|
|
|
570
602
|
const setSoftFocus = ({ vm, state }) => () => {
|
|
571
603
|
state.softFocus = true;
|
|
572
604
|
const input = vm.$refs.input || vm.$refs.reference;
|
|
573
|
-
|
|
605
|
+
if (input) {
|
|
606
|
+
input.focus();
|
|
607
|
+
}
|
|
574
608
|
};
|
|
575
609
|
const getValueIndex = (props) => (arr = [], value = null) => {
|
|
576
|
-
const
|
|
577
|
-
if (!
|
|
610
|
+
const isObject = Object.prototype.toString.call(value).toLowerCase() === "[object object]";
|
|
611
|
+
if (!isObject) {
|
|
578
612
|
return arr.indexOf(value);
|
|
579
613
|
} else {
|
|
580
614
|
const valueKey = props.valueKey;
|
|
@@ -589,18 +623,25 @@ const getValueIndex = (props) => (arr = [], value = null) => {
|
|
|
589
623
|
return index;
|
|
590
624
|
}
|
|
591
625
|
};
|
|
592
|
-
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
|
+
}
|
|
593
630
|
const event = e || window.event;
|
|
594
631
|
const enterCode = 13;
|
|
595
632
|
const nodeName = event.target && event.target.nodeName;
|
|
596
633
|
const toggleVisible = props.ignoreEnter ? event.keyCode !== enterCode && nodeName === "INPUT" : true;
|
|
634
|
+
if (!props.displayOnly) {
|
|
635
|
+
event.stopPropagation();
|
|
636
|
+
}
|
|
597
637
|
if (!state.selectDisabled) {
|
|
598
638
|
toggleVisible && !state.softFocus && (state.visible = !state.visible);
|
|
599
639
|
state.softFocus = false;
|
|
600
640
|
if (state.visible) {
|
|
601
641
|
if (!(props.filterable && props.shape)) {
|
|
602
642
|
const dom = vm.$refs.input || vm.$refs.reference;
|
|
603
|
-
dom == null ? void 0 : dom.focus();
|
|
643
|
+
(dom == null ? void 0 : dom.focus) && dom.focus();
|
|
644
|
+
api.setOptionHighlight();
|
|
604
645
|
}
|
|
605
646
|
}
|
|
606
647
|
}
|
|
@@ -609,45 +650,49 @@ const selectOption = ({ api, state, props }) => (e) => {
|
|
|
609
650
|
if (!state.visible || props.hideDrop) {
|
|
610
651
|
api.toggleMenu(e);
|
|
611
652
|
} else {
|
|
612
|
-
|
|
613
|
-
|
|
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];
|
|
614
658
|
}
|
|
659
|
+
option && api.handleOptionSelect(option);
|
|
615
660
|
}
|
|
616
661
|
};
|
|
617
662
|
const deleteSelected = ({ api, constants, emit, props, vm, state }) => (event) => {
|
|
618
|
-
event.stopPropagation();
|
|
663
|
+
event && event.stopPropagation();
|
|
619
664
|
let selectedValue = [];
|
|
620
665
|
if (props.multiple) {
|
|
621
666
|
const requireOptions = state.options.filter((opt) => opt.required && opt.value);
|
|
622
|
-
selectedValue =
|
|
667
|
+
selectedValue = state.modelValue.slice().filter((v) => requireOptions.find((opt) => opt.value === v));
|
|
623
668
|
}
|
|
624
669
|
const value = props.multiple ? selectedValue : "";
|
|
625
|
-
const refs = vm.$refs;
|
|
626
670
|
if (props.renderType === constants.TYPE.Tree) {
|
|
627
671
|
state.selected = {};
|
|
628
672
|
state.selectedLabel = "";
|
|
629
|
-
refs.selectTree.
|
|
673
|
+
vm.$refs.selectTree.state.currentRadio.value = null;
|
|
674
|
+
vm.$refs.selectTree.setCurrentKey(null);
|
|
630
675
|
} else if (props.renderType === constants.TYPE.Grid) {
|
|
631
676
|
state.selected = {};
|
|
632
677
|
state.selectedLabel = "";
|
|
633
|
-
refs.selectGrid.clearRadioRow();
|
|
678
|
+
vm.$refs.selectGrid.clearRadioRow();
|
|
634
679
|
}
|
|
635
680
|
state.showTip = false;
|
|
636
|
-
|
|
637
|
-
api.
|
|
681
|
+
state.compareValue = deepClone(value);
|
|
682
|
+
api.updateModelValue(value, true);
|
|
683
|
+
api.emitChange(value, true);
|
|
638
684
|
state.visible = false;
|
|
639
685
|
emit("clear");
|
|
640
686
|
};
|
|
641
687
|
const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (event, tag) => {
|
|
642
688
|
if (tag.required)
|
|
643
689
|
return;
|
|
644
|
-
const refs = vm.$refs;
|
|
645
690
|
const isTree = props.renderType === constants.TYPE.Tree;
|
|
646
691
|
const index = state.selected.indexOf(tag);
|
|
647
692
|
const treeValue = [];
|
|
648
693
|
const treeIds = [tag[props.valueField]];
|
|
649
694
|
if (isTree && !props.treeOp.checkStrictly) {
|
|
650
|
-
let node = refs.selectTree.getNode(tag[props.valueField]);
|
|
695
|
+
let node = vm.$refs.selectTree.getNode(tag[props.valueField]);
|
|
651
696
|
if (!node.isLeaf) {
|
|
652
697
|
treeIds.push(...api.getChildValue(node.childNodes, props.valueField));
|
|
653
698
|
}
|
|
@@ -658,28 +703,31 @@ const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (eve
|
|
|
658
703
|
state.selected.slice().map((node2) => !treeIds.includes(node2[props.valueField]) && treeValue.push(node2[props.valueField]));
|
|
659
704
|
}
|
|
660
705
|
if (index > -1 && !state.selectDisabled) {
|
|
661
|
-
const value =
|
|
706
|
+
const value = state.modelValue.slice();
|
|
662
707
|
value.splice(index, 1);
|
|
663
708
|
if (props.renderType === constants.TYPE.Tree) {
|
|
664
709
|
props.treeOp.checkStrictly && treeValue.push(...value);
|
|
665
|
-
refs.selectTree.setCheckedKeys(treeValue);
|
|
710
|
+
vm.$refs.selectTree.setCheckedKeys(treeValue);
|
|
666
711
|
} else if (props.renderType === constants.TYPE.Grid) {
|
|
667
712
|
const rows = state.selected.slice().filter((item) => value.includes(item[props.valueField]));
|
|
668
|
-
refs.selectGrid.clearSelection();
|
|
669
|
-
refs.selectGrid.setSelection(rows, true);
|
|
713
|
+
vm.$refs.selectGrid.clearSelection();
|
|
714
|
+
vm.$refs.selectGrid.setSelection(rows, true);
|
|
670
715
|
}
|
|
716
|
+
state.compareValue = deepClone(value);
|
|
671
717
|
api.updateModelValue(isTree ? treeValue : value);
|
|
672
718
|
api.emitChange(value);
|
|
673
719
|
emit(constants.EVENT_NAME.removeTag, tag[props.valueField]);
|
|
674
720
|
nextTick(() => state.key++);
|
|
675
721
|
}
|
|
676
|
-
event.stopPropagation();
|
|
722
|
+
event && event.stopPropagation();
|
|
677
723
|
};
|
|
678
724
|
const onInputChange = ({ api, props, state, constants, nextTick }) => () => {
|
|
679
725
|
if (!props.delay) {
|
|
680
726
|
if (props.filterable && state.query !== state.selectedLabel) {
|
|
727
|
+
const isChange = false;
|
|
728
|
+
const isInput = true;
|
|
681
729
|
state.query = state.selectedLabel;
|
|
682
|
-
api.handleQueryChange(state.query);
|
|
730
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
683
731
|
nextTick(() => {
|
|
684
732
|
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
685
733
|
});
|
|
@@ -699,8 +747,9 @@ const onOptionDestroy = (state) => (index) => {
|
|
|
699
747
|
}
|
|
700
748
|
};
|
|
701
749
|
const resetInputWidth = ({ vm, state }) => () => {
|
|
702
|
-
|
|
703
|
-
|
|
750
|
+
if (vm.$refs.reference && vm.$refs.reference.$el) {
|
|
751
|
+
state.inputWidth = vm.$refs.reference.$el.getBoundingClientRect().width;
|
|
752
|
+
}
|
|
704
753
|
};
|
|
705
754
|
const handleResize = ({ api, props, state }) => () => {
|
|
706
755
|
api.resetInputWidth();
|
|
@@ -708,29 +757,42 @@ const handleResize = ({ api, props, state }) => () => {
|
|
|
708
757
|
api.resetInputHeight();
|
|
709
758
|
}
|
|
710
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
|
+
};
|
|
711
769
|
const checkDefaultFirstOption = (state) => () => {
|
|
712
770
|
state.hoverIndex = -1;
|
|
713
771
|
let hasCreated = false;
|
|
714
|
-
|
|
715
|
-
|
|
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) {
|
|
716
775
|
hasCreated = true;
|
|
717
776
|
state.hoverIndex = i;
|
|
777
|
+
state.hoverValue = state.optionIndexArr[i];
|
|
718
778
|
break;
|
|
719
779
|
}
|
|
720
780
|
}
|
|
721
781
|
if (hasCreated) {
|
|
722
782
|
return;
|
|
723
783
|
}
|
|
724
|
-
for (let i = 0; i
|
|
725
|
-
const option =
|
|
784
|
+
for (let i = 0; i < visibleOptions.length; i++) {
|
|
785
|
+
const option = visibleOptions[i];
|
|
726
786
|
if (state.query) {
|
|
727
|
-
if (!option.disabled && !option.groupDisabled && option.state.visible) {
|
|
787
|
+
if (!option.disabled && !option.groupDisabled && option.state.visible && option.visible) {
|
|
728
788
|
state.hoverIndex = i;
|
|
789
|
+
state.hoverValue = state.optionIndexArr[i];
|
|
729
790
|
break;
|
|
730
791
|
}
|
|
731
792
|
} else {
|
|
732
793
|
if (option.itemSelected) {
|
|
733
794
|
state.hoverIndex = i;
|
|
795
|
+
state.hoverValue = state.optionIndexArr[i];
|
|
734
796
|
break;
|
|
735
797
|
}
|
|
736
798
|
}
|
|
@@ -744,8 +806,12 @@ const getValueKey = (props) => (item) => {
|
|
|
744
806
|
}
|
|
745
807
|
return getObj(item.value, props.valueKey);
|
|
746
808
|
};
|
|
747
|
-
const navigateOptions = ({ api,
|
|
748
|
-
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;
|
|
749
815
|
if (!state.visible) {
|
|
750
816
|
state.visible = true;
|
|
751
817
|
return;
|
|
@@ -753,6 +819,13 @@ const navigateOptions = ({ api, nextTick, state }) => (direction) => {
|
|
|
753
819
|
if (len === 0 || state.filteredOptionsCount === 0) {
|
|
754
820
|
return;
|
|
755
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
|
+
}
|
|
756
829
|
if (!state.optionsAllDisabled) {
|
|
757
830
|
if (direction === "next") {
|
|
758
831
|
state.hoverIndex++;
|
|
@@ -765,39 +838,68 @@ const navigateOptions = ({ api, nextTick, state }) => (direction) => {
|
|
|
765
838
|
state.hoverIndex = len - 1;
|
|
766
839
|
}
|
|
767
840
|
}
|
|
768
|
-
|
|
769
|
-
|
|
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) {
|
|
770
849
|
api.navigateOptions(direction);
|
|
771
850
|
}
|
|
772
|
-
nextTick(() => api.scrollToOption(state.
|
|
851
|
+
nextTick(() => api.scrollToOption(state.hoverIndex === -9 ? {} : option || {}));
|
|
773
852
|
}
|
|
774
853
|
};
|
|
775
|
-
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 }) => () => {
|
|
776
880
|
if (props.loading) {
|
|
777
881
|
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
|
-
}
|
|
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);
|
|
798
894
|
}
|
|
799
895
|
return null;
|
|
800
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
|
+
};
|
|
801
903
|
const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, oldValue) => {
|
|
802
904
|
if (props.multiple) {
|
|
803
905
|
api.resetInputHeight();
|
|
@@ -806,9 +908,11 @@ const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, o
|
|
|
806
908
|
} else {
|
|
807
909
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
808
910
|
}
|
|
809
|
-
if (
|
|
911
|
+
if (props.filterable && !props.reserveKeyword) {
|
|
912
|
+
const isChange = false;
|
|
913
|
+
const isInput = true;
|
|
810
914
|
props.renderType !== constants.TYPE.Grid && (state.query = "");
|
|
811
|
-
api.handleQueryChange(state.query);
|
|
915
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
812
916
|
}
|
|
813
917
|
}
|
|
814
918
|
api.setSelected();
|
|
@@ -820,13 +924,13 @@ const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, o
|
|
|
820
924
|
if (state.completed && !isEqual(value, oldValue)) {
|
|
821
925
|
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formChange, value);
|
|
822
926
|
}
|
|
823
|
-
|
|
927
|
+
props.optimization && optmzApis.setValueIndex({ props, state });
|
|
824
928
|
};
|
|
825
929
|
const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
826
930
|
if (props.multiple && props.showOverflowTooltip) {
|
|
827
931
|
state.overflow = false;
|
|
828
932
|
const tagDom = vm.$refs.tags;
|
|
829
|
-
const tags = tagDom.querySelectorAll("
|
|
933
|
+
const tags = tagDom.querySelectorAll('[data-tag="tiny-tag"]');
|
|
830
934
|
if (tags.length) {
|
|
831
935
|
tagDom.scrollTo && tagDom.scrollTo({ top: 0 });
|
|
832
936
|
let { x, width } = tags[0].getBoundingClientRect();
|
|
@@ -856,7 +960,6 @@ const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
|
856
960
|
}
|
|
857
961
|
};
|
|
858
962
|
const postOperOfToVisible = ({ props, state, constants }) => {
|
|
859
|
-
var _a;
|
|
860
963
|
if (props.multiple) {
|
|
861
964
|
return;
|
|
862
965
|
}
|
|
@@ -867,30 +970,32 @@ const postOperOfToVisible = ({ props, state, constants }) => {
|
|
|
867
970
|
if (props.filterable && props.allowCreate && state.createdSelected && state.createdLabel) {
|
|
868
971
|
state.selectedLabel = state.createdLabel;
|
|
869
972
|
} else {
|
|
870
|
-
state.selectedLabel =
|
|
973
|
+
state.selectedLabel = state.selected.state.currentLabel || state.selected.currentLabel;
|
|
871
974
|
}
|
|
872
975
|
if (props.filterable) {
|
|
873
976
|
state.query = state.selectedLabel;
|
|
874
977
|
}
|
|
875
978
|
}
|
|
876
|
-
if (
|
|
979
|
+
if (props.filterable) {
|
|
877
980
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
878
981
|
}
|
|
879
982
|
}
|
|
880
983
|
};
|
|
881
984
|
const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
882
|
-
var _a;
|
|
883
985
|
state.selectEmitter.emit(constants.EVENT_NAME.destroyPopper);
|
|
884
986
|
props.remote && props.dropOnlySearch && (state.showWarper = false);
|
|
885
|
-
(
|
|
987
|
+
if (vm.$refs.input) {
|
|
988
|
+
vm.$refs.input.blur();
|
|
989
|
+
}
|
|
886
990
|
state.query = "";
|
|
887
991
|
state.selectedLabel = "";
|
|
888
992
|
state.inputLength = 20;
|
|
889
993
|
state.previousQuery !== state.query && api.initQuery().then(() => api.setSelected());
|
|
890
994
|
if (props.renderType !== constants.TYPE.Tree) {
|
|
891
|
-
state.previousQuery =
|
|
995
|
+
state.previousQuery = null;
|
|
892
996
|
}
|
|
893
997
|
api.resetHoverIndex();
|
|
998
|
+
api.resetDatas();
|
|
894
999
|
nextTick(() => {
|
|
895
1000
|
if (vm.$refs.input && vm.$refs.input.value === "" && state.selected.length === 0) {
|
|
896
1001
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
@@ -901,23 +1006,22 @@ const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
|
901
1006
|
});
|
|
902
1007
|
postOperOfToVisible({ props, state, constants });
|
|
903
1008
|
};
|
|
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();
|
|
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();
|
|
915
1019
|
} else {
|
|
916
|
-
if (!
|
|
917
|
-
state.selectEmitter.emit(constants.EVENT_NAME.queryChange);
|
|
918
|
-
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);
|
|
919
1023
|
}
|
|
920
|
-
if (state.selectedLabel && !
|
|
1024
|
+
if (state.selectedLabel && !shape) {
|
|
921
1025
|
state.currentPlaceholder = state.selectedLabel;
|
|
922
1026
|
state.selectedLabel = "";
|
|
923
1027
|
}
|
|
@@ -925,32 +1029,34 @@ const toHide = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
|
925
1029
|
}
|
|
926
1030
|
if (vm.$refs.selectGrid) {
|
|
927
1031
|
let { fullData } = vm.$refs.selectGrid.getTableData();
|
|
928
|
-
if (
|
|
929
|
-
const selectedIds = state.selected.map((sel) => sel[
|
|
1032
|
+
if (multiple) {
|
|
1033
|
+
const selectedIds = state.selected.map((sel) => sel[valueField]);
|
|
930
1034
|
vm.$refs.selectGrid.clearSelection();
|
|
931
1035
|
vm.$refs.selectGrid.setSelection(
|
|
932
|
-
fullData.filter((row) => ~selectedIds.indexOf(row[
|
|
1036
|
+
fullData.filter((row) => ~selectedIds.indexOf(row[valueField])),
|
|
933
1037
|
true
|
|
934
1038
|
);
|
|
935
1039
|
} else {
|
|
936
1040
|
vm.$refs.selectGrid.clearRadioRow();
|
|
937
|
-
vm.$refs.selectGrid.setRadioRow(find(fullData, (item) => props.modelValue === item[
|
|
1041
|
+
vm.$refs.selectGrid.setRadioRow(find(fullData, (item) => props.modelValue === item[valueField]));
|
|
938
1042
|
}
|
|
939
|
-
if (
|
|
1043
|
+
if (filterable && typeof props.filterMethod === "function") {
|
|
940
1044
|
vm.$refs.selectGrid.handleTableData(true);
|
|
941
|
-
} else if (
|
|
1045
|
+
} else if (filterable && remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
942
1046
|
vm.$refs.selectGrid.handleTableData();
|
|
943
1047
|
}
|
|
944
1048
|
}
|
|
945
1049
|
};
|
|
946
1050
|
const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) => {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
(_a = vm.$refs.reference) == null ? void 0 : _a.blur();
|
|
1051
|
+
if ((props.filterable || props.remote) && !value) {
|
|
1052
|
+
vm.$refs.reference.blur();
|
|
950
1053
|
}
|
|
951
1054
|
if (api.onCopying()) {
|
|
952
1055
|
return;
|
|
953
1056
|
}
|
|
1057
|
+
if (value && props.multiple && state.device === "mb") {
|
|
1058
|
+
state.selectedCopy = state.selected.slice();
|
|
1059
|
+
}
|
|
954
1060
|
setTimeout(() => {
|
|
955
1061
|
if (!value && !state.selectedLabel) {
|
|
956
1062
|
state.cachedOptions.forEach((item) => {
|
|
@@ -960,15 +1066,19 @@ const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) =>
|
|
|
960
1066
|
}, 200);
|
|
961
1067
|
value ? api.toHide() : api.toVisible();
|
|
962
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);
|
|
963
1079
|
if (!value && props.shape === "filter") {
|
|
964
1080
|
state.softFocus = false;
|
|
965
1081
|
}
|
|
966
|
-
if (value && state.optimizeStore.flag) {
|
|
967
|
-
optmzApis.createMacro(() => {
|
|
968
|
-
optmzApis.setScrollTop({ refs: vm.$refs, state });
|
|
969
|
-
api.getScrollListener();
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
1082
|
};
|
|
973
1083
|
const watchOptions = ({ api, constants, nextTick, parent, props, state }) => () => {
|
|
974
1084
|
if (typeof window === "undefined") {
|
|
@@ -985,8 +1095,25 @@ const watchOptions = ({ api, constants, nextTick, parent, props, state }) => ()
|
|
|
985
1095
|
api.setSelected();
|
|
986
1096
|
}
|
|
987
1097
|
});
|
|
988
|
-
|
|
989
|
-
|
|
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"])'));
|
|
990
1117
|
}
|
|
991
1118
|
};
|
|
992
1119
|
const handleCopyClick = ({ parent, props, state }) => () => {
|
|
@@ -1000,7 +1127,7 @@ const handleCopyClick = ({ parent, props, state }) => () => {
|
|
|
1000
1127
|
document.execCommand("copy");
|
|
1001
1128
|
parent.$el.removeChild(input);
|
|
1002
1129
|
};
|
|
1003
|
-
const selectChange = ({
|
|
1130
|
+
const selectChange = ({ props, state, api }) => ({ $table, selection, checked, row }) => {
|
|
1004
1131
|
const { textField, valueField } = props;
|
|
1005
1132
|
const remoteItem = (row2) => {
|
|
1006
1133
|
const removeItem = find(state.selected, (item) => item[valueField] === row2[valueField]);
|
|
@@ -1010,12 +1137,12 @@ const selectChange = ({ emit, props, state, api }) => ({ $table, selection, chec
|
|
|
1010
1137
|
checked ? state.selected.push(__spreadProps(__spreadValues({}, row), { value: row[valueField], currentLabel: row[textField] })) : remoteItem(row);
|
|
1011
1138
|
} else {
|
|
1012
1139
|
checked ? state.selected = state.selected.concat(
|
|
1013
|
-
selection.filter((row2) => !~
|
|
1140
|
+
selection.filter((row2) => !~state.modelValue.indexOf(row2[valueField]))
|
|
1014
1141
|
) : $table.tableFullData.forEach((row2) => remoteItem(row2));
|
|
1015
1142
|
}
|
|
1016
1143
|
const keys = state.selected.map((item) => item[valueField]);
|
|
1017
1144
|
api.updateModelValue(keys);
|
|
1018
|
-
|
|
1145
|
+
api.directEmitChange(keys, state.selected);
|
|
1019
1146
|
};
|
|
1020
1147
|
const getcheckedData = ({ props, state }) => () => {
|
|
1021
1148
|
const checkedKey = [];
|
|
@@ -1028,14 +1155,16 @@ const getcheckedData = ({ props, state }) => () => {
|
|
|
1028
1155
|
return checkedKey;
|
|
1029
1156
|
}
|
|
1030
1157
|
};
|
|
1031
|
-
const radioChange = ({
|
|
1158
|
+
const radioChange = ({ props, state, api, vm }) => ({ row }) => {
|
|
1032
1159
|
row.value = row[props.valueField];
|
|
1033
1160
|
row.currentLabel = row[props.textField];
|
|
1161
|
+
!state.hasClearSelection && vm.$refs.selectGrid.clearSelection();
|
|
1162
|
+
state.hasClearSelection = true;
|
|
1034
1163
|
state.selected = row;
|
|
1035
1164
|
state.visible = false;
|
|
1036
1165
|
state.currentKey = row[props.valueField];
|
|
1037
1166
|
api.updateModelValue(row.value);
|
|
1038
|
-
|
|
1167
|
+
api.directEmitChange(row);
|
|
1039
1168
|
};
|
|
1040
1169
|
const getTreeData = (props) => (data) => {
|
|
1041
1170
|
const nodes = [];
|
|
@@ -1051,14 +1180,14 @@ const getTreeData = (props) => (data) => {
|
|
|
1051
1180
|
getChild(data, null);
|
|
1052
1181
|
return nodes;
|
|
1053
1182
|
};
|
|
1054
|
-
const treeNodeClick = ({
|
|
1183
|
+
const treeNodeClick = ({ props, state, api, vm }) => (data) => {
|
|
1055
1184
|
if (!props.multiple) {
|
|
1056
1185
|
data.currentLabel = data[props.textField];
|
|
1057
1186
|
data.value = data[props.valueField];
|
|
1058
1187
|
state.selected = data;
|
|
1059
1188
|
state.visible = false;
|
|
1060
1189
|
api.updateModelValue(data.value);
|
|
1061
|
-
|
|
1190
|
+
api.directEmitChange(data);
|
|
1062
1191
|
} else {
|
|
1063
1192
|
if (props.treeOp.checkOnClickNode) {
|
|
1064
1193
|
const checkedNodes = vm.$refs.selectTree.getCheckedNodes();
|
|
@@ -1067,7 +1196,7 @@ const treeNodeClick = ({ emit, props, state, api, vm }) => (data) => {
|
|
|
1067
1196
|
}
|
|
1068
1197
|
}
|
|
1069
1198
|
};
|
|
1070
|
-
const nodeCheckClick = ({
|
|
1199
|
+
const nodeCheckClick = ({ props, state, api }) => (data, { checkedKeys, checkedNodes }) => {
|
|
1071
1200
|
const selected = state.selected.map((item) => api.getValueKey(item));
|
|
1072
1201
|
if (isEqual(selected, checkedKeys)) {
|
|
1073
1202
|
return;
|
|
@@ -1075,10 +1204,9 @@ const nodeCheckClick = ({ emit, props, state, api }) => (data, { checkedKeys, ch
|
|
|
1075
1204
|
state.selected = checkedNodes.filter((node) => {
|
|
1076
1205
|
node.currentLabel = node[props.textField];
|
|
1077
1206
|
node.value = node[props.valueField];
|
|
1078
|
-
return node;
|
|
1079
1207
|
});
|
|
1080
1208
|
api.updateModelValue(checkedKeys);
|
|
1081
|
-
|
|
1209
|
+
api.directEmitChange(checkedKeys, checkedNodes);
|
|
1082
1210
|
};
|
|
1083
1211
|
const nodeCollapse = ({ state, constants }) => () => {
|
|
1084
1212
|
setTimeout(() => {
|
|
@@ -1091,9 +1219,11 @@ const nodeExpand = ({ state, constants }) => () => {
|
|
|
1091
1219
|
}, 310);
|
|
1092
1220
|
};
|
|
1093
1221
|
const debouncRquest = ({ api, state, props }) => debounce(props.delay, () => {
|
|
1094
|
-
if (
|
|
1222
|
+
if (props.filterable && state.query !== state.selectedLabel) {
|
|
1223
|
+
const isChange = false;
|
|
1224
|
+
const isInput = true;
|
|
1095
1225
|
state.query = state.selectedLabel;
|
|
1096
|
-
api.handleQueryChange(state.query);
|
|
1226
|
+
api.handleQueryChange(state.query, isChange, isInput);
|
|
1097
1227
|
}
|
|
1098
1228
|
});
|
|
1099
1229
|
const getChildValue = () => (data, key) => {
|
|
@@ -1140,6 +1270,7 @@ const watchPropsOption = ({ constants, parent, props, state }) => () => {
|
|
|
1140
1270
|
state.datas = state.memorize.assemble(sortData.slice());
|
|
1141
1271
|
} else {
|
|
1142
1272
|
state.datas = sortData;
|
|
1273
|
+
state.initDatas = sortData;
|
|
1143
1274
|
}
|
|
1144
1275
|
}
|
|
1145
1276
|
});
|
|
@@ -1147,13 +1278,13 @@ const watchPropsOption = ({ constants, parent, props, state }) => () => {
|
|
|
1147
1278
|
const buildSelectConfig = ({ props, state }) => () => {
|
|
1148
1279
|
const checkRowKeys = state.gridCheckedData;
|
|
1149
1280
|
const selectConfig = props.selectConfig;
|
|
1150
|
-
return
|
|
1281
|
+
return Object.assign({}, selectConfig, { checkRowKeys });
|
|
1151
1282
|
};
|
|
1152
1283
|
const buildRadioConfig = ({ props, state }) => () => {
|
|
1153
1284
|
const checkRowKey = state.currentKey;
|
|
1154
1285
|
const highlight = true;
|
|
1155
1286
|
const radioConfig = props.radioConfig;
|
|
1156
|
-
return
|
|
1287
|
+
return Object.assign({}, radioConfig, { checkRowKey, highlight });
|
|
1157
1288
|
};
|
|
1158
1289
|
const onMouseenterNative = ({ state }) => () => {
|
|
1159
1290
|
state.inputHovering = true;
|
|
@@ -1169,16 +1300,15 @@ const onMouseleaveNative = ({ state }) => (e) => {
|
|
|
1169
1300
|
state.softFocus = false;
|
|
1170
1301
|
}
|
|
1171
1302
|
};
|
|
1172
|
-
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
|
+
};
|
|
1173
1306
|
const watchHoverIndex = ({ state }) => (value) => {
|
|
1174
|
-
if (
|
|
1175
|
-
state.
|
|
1176
|
-
} else
|
|
1177
|
-
state.
|
|
1307
|
+
if (value === -1 || value === -9) {
|
|
1308
|
+
state.hoverValue = -1;
|
|
1309
|
+
} else {
|
|
1310
|
+
state.hoverValue = state.optionIndexArr[value];
|
|
1178
1311
|
}
|
|
1179
|
-
state.options.forEach((option) => {
|
|
1180
|
-
option.hover = state.hoverOption === option;
|
|
1181
|
-
});
|
|
1182
1312
|
};
|
|
1183
1313
|
const handleDropdownClick = ({ emit }) => ($event) => {
|
|
1184
1314
|
emit("dropdown-click", $event);
|
|
@@ -1194,15 +1324,15 @@ const calcCollapseTags = ({ state, vm }) => () => {
|
|
|
1194
1324
|
return state.isHidden = true;
|
|
1195
1325
|
}
|
|
1196
1326
|
const tags = vm.$refs.tags;
|
|
1197
|
-
|
|
1327
|
+
const collapseTag = tags && tags.querySelector('[data-tag="tags-collapse"]');
|
|
1328
|
+
if (!tags || !collapseTag) {
|
|
1198
1329
|
return;
|
|
1199
1330
|
}
|
|
1200
1331
|
const { width: tagsContentWidth, paddingLeft, paddingRight } = window.getComputedStyle(tags);
|
|
1201
1332
|
const tagsWidth = parseFloat(tagsContentWidth) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
1202
|
-
const collapseTag = tags.querySelector(".tiny-select__tags-collapse");
|
|
1203
1333
|
const { width: collapseTagContentWidth, marginRight } = collapseTag && window.getComputedStyle(collapseTag);
|
|
1204
1334
|
const collapseTagWidth = collapseTag && parseFloat(collapseTagContentWidth) + parseFloat(marginRight);
|
|
1205
|
-
const tagList = Array.from(tags.querySelectorAll("
|
|
1335
|
+
const tagList = Array.from(tags.querySelectorAll('[data-tag="tiny-tag"]'));
|
|
1206
1336
|
let { total, dom, idx } = { total: collapseTagWidth, dom: null, idx: 0 };
|
|
1207
1337
|
tagList.forEach((tag, index) => {
|
|
1208
1338
|
if (tag !== collapseTag) {
|
|
@@ -1255,21 +1385,22 @@ const initQuery = ({ props, state, constants, vm }) => ({ init } = {}) => {
|
|
|
1255
1385
|
}
|
|
1256
1386
|
return Promise.resolve(selected);
|
|
1257
1387
|
};
|
|
1258
|
-
const mounted = ({ api, parent, state, props, vm,
|
|
1388
|
+
const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
1259
1389
|
var _a;
|
|
1260
1390
|
state.defaultCheckedKeys = state.gridCheckedData;
|
|
1261
1391
|
const parentEl = parent.$el;
|
|
1262
|
-
const inputEl = parentEl.querySelector(
|
|
1263
|
-
const inputClientRect =
|
|
1392
|
+
const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]');
|
|
1393
|
+
const inputClientRect = inputEl && inputEl.getBoundingClientRect() || {};
|
|
1264
1394
|
if (inputEl === document.activeElement) {
|
|
1265
|
-
|
|
1395
|
+
document.activeElement.blur();
|
|
1266
1396
|
}
|
|
1267
1397
|
state.completed = true;
|
|
1268
|
-
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;
|
|
1269
1400
|
if (props.multiple && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
|
|
1270
1401
|
state.currentPlaceholder = "";
|
|
1271
1402
|
}
|
|
1272
|
-
state.initialInputHeight = state.isDisplayOnly ? sizeMap[state.selectSize
|
|
1403
|
+
state.initialInputHeight = state.isDisplayOnly ? sizeMap[state.selectSize || "default"] : inputClientRect.height || sizeMap[state.selectSize];
|
|
1273
1404
|
addResizeListener(parentEl, api.handleResize);
|
|
1274
1405
|
if (vm.$refs.tags) {
|
|
1275
1406
|
addResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
@@ -1291,7 +1422,6 @@ const unMount = ({ api, parent, vm, state }) => () => {
|
|
|
1291
1422
|
removeResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
1292
1423
|
}
|
|
1293
1424
|
state.popperElm = null;
|
|
1294
|
-
state.optimizeStore.flag && optmzApis.removeScrollListener({ api, refs: vm.$refs, state });
|
|
1295
1425
|
};
|
|
1296
1426
|
const optmzApis = {
|
|
1297
1427
|
exist: (val, multiple) => multiple ? Array.isArray(val) && val.length : val,
|
|
@@ -1300,100 +1430,40 @@ const optmzApis = {
|
|
|
1300
1430
|
const contain = (val, arr) => Array.isArray(arr) && ~arr.indexOf(val);
|
|
1301
1431
|
const equal = (val, opt) => multiple ? contain(opt[valueField], [val]) : opt[valueField] === val;
|
|
1302
1432
|
let start = 0;
|
|
1303
|
-
if (optmzApis.exist(modelValue, multiple)) {
|
|
1433
|
+
if (optmzApis.exist(modelValue, multiple) && options) {
|
|
1304
1434
|
const lastVal = multiple ? modelValue[modelValue.length - 1] : modelValue;
|
|
1305
1435
|
for (let i = 0; i < options.length; i++) {
|
|
1306
|
-
if (!equal(lastVal, options[i]))
|
|
1436
|
+
if (!equal(lastVal, options[i]))
|
|
1307
1437
|
continue;
|
|
1308
|
-
}
|
|
1309
1438
|
return i;
|
|
1310
1439
|
}
|
|
1311
1440
|
}
|
|
1312
1441
|
return start;
|
|
1313
1442
|
},
|
|
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`;
|
|
1326
|
-
},
|
|
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;
|
|
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);
|
|
1349
1450
|
},
|
|
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
1451
|
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
1452
|
const { optimizeStore } = state;
|
|
1362
|
-
|
|
1363
|
-
!optimizeStore.bind && wrap.addEventListener("scroll", api.getScrollListener) && (optimizeStore.bind = true);
|
|
1453
|
+
refs.scrollbar.scrollToItem(optimizeStore.valueIndex);
|
|
1364
1454
|
},
|
|
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];
|
|
1455
|
+
setValueIndex: ({ props, state }) => {
|
|
1456
|
+
state.optimizeStore.valueIndex = optmzApis.getValueIndex(props);
|
|
1375
1457
|
},
|
|
1376
1458
|
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 });
|
|
1459
|
+
checkDefaultFirstOption: ({ state }) => {
|
|
1460
|
+
state.hoverIndex = 0;
|
|
1461
|
+
state.hoverValue = state.optionIndexArr[0];
|
|
1392
1462
|
}
|
|
1393
1463
|
};
|
|
1394
|
-
const computeOptimizeOpts = ({ props,
|
|
1464
|
+
const computeOptimizeOpts = ({ props, designConfig }) => () => {
|
|
1395
1465
|
const { optimization } = props;
|
|
1396
|
-
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 };
|
|
1397
1467
|
let optOpts;
|
|
1398
1468
|
if (optimization) {
|
|
1399
1469
|
if (typeof optimization === "boolean") {
|
|
@@ -1401,60 +1471,33 @@ const computeOptimizeOpts = ({ props, state }) => () => {
|
|
|
1401
1471
|
} else {
|
|
1402
1472
|
optOpts = extend(true, {}, baseOpts, optimization);
|
|
1403
1473
|
}
|
|
1404
|
-
optOpts.virtualScroll = optOpts.gt > 0 && optOpts.gt <= state.datas.length;
|
|
1405
1474
|
return optOpts;
|
|
1406
1475
|
}
|
|
1407
1476
|
};
|
|
1408
|
-
const watchOptimizeOpts = ({
|
|
1477
|
+
const watchOptimizeOpts = ({ props, state }) => () => {
|
|
1409
1478
|
const { optimizeOpts, optimizeStore } = state;
|
|
1410
1479
|
if (optimizeOpts) {
|
|
1411
|
-
|
|
1412
|
-
optimizeStore.flag = virtualScroll;
|
|
1413
|
-
if (virtualScroll) {
|
|
1414
|
-
optimizeStore.viewStyle = optmzApis.getViewStyle({ props, state });
|
|
1480
|
+
if (props.optimization) {
|
|
1415
1481
|
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
1482
|
}
|
|
1423
1483
|
}
|
|
1424
1484
|
};
|
|
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
1485
|
const computeCollapseTags = (props) => () => props.collapseTags;
|
|
1447
1486
|
const computeMultipleLimit = ({ props, state }) => () => {
|
|
1448
|
-
const { multipleLimit, multiple } = props;
|
|
1449
|
-
const { optimizeOpts
|
|
1450
|
-
return optmzApis.natural(multiple &&
|
|
1487
|
+
const { multipleLimit, multiple, optimization } = props;
|
|
1488
|
+
const { optimizeOpts } = state;
|
|
1489
|
+
return optmzApis.natural(multiple && optimization ? multipleLimit || optimizeOpts.limit : multipleLimit);
|
|
1451
1490
|
};
|
|
1452
|
-
const updateModelValue = ({ emit, state }) => (value) => {
|
|
1491
|
+
const updateModelValue = ({ props, emit, state }) => (value, needUpdate) => {
|
|
1453
1492
|
state.isClickChoose = true;
|
|
1454
|
-
|
|
1493
|
+
if (state.device === "mb" && props.multiple && !needUpdate) {
|
|
1494
|
+
state.modelValue = value;
|
|
1495
|
+
} else {
|
|
1496
|
+
emit("update:modelValue", value);
|
|
1497
|
+
}
|
|
1455
1498
|
};
|
|
1456
1499
|
const getLabelSlotValue = ({ props, state }) => (item) => {
|
|
1457
|
-
const datas = state.
|
|
1500
|
+
const datas = state.datas;
|
|
1458
1501
|
const value = item.state ? item.state.currentValue : item.value;
|
|
1459
1502
|
const data = datas.find((data2) => data2.value === value);
|
|
1460
1503
|
const obj = __spreadProps(__spreadValues({}, data), {
|
|
@@ -1470,11 +1513,13 @@ const computedTagsStyle = ({ props, parent, state }) => () => {
|
|
|
1470
1513
|
width: "100%"
|
|
1471
1514
|
};
|
|
1472
1515
|
};
|
|
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 !== "");
|
|
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 !== "");
|
|
1476
1518
|
const computedCollapseTagSize = (state) => () => state.selectSize;
|
|
1477
|
-
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
|
+
};
|
|
1478
1523
|
const computedShowCopy = ({ props, state }) => () => props.multiple && props.copyable && state.inputHovering && state.selected.length;
|
|
1479
1524
|
const computedOptionsAllDisabled = (state) => () => state.options.filter((option) => option.visible).every((option) => option.disabled);
|
|
1480
1525
|
const computedDisabledTooltipContent = (state) => () => state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join("\uFF1B");
|
|
@@ -1519,15 +1564,18 @@ const watchInitValue = ({ props, emit }) => (value) => {
|
|
|
1519
1564
|
const watchShowClose = ({ nextTick, state, parent }) => () => {
|
|
1520
1565
|
nextTick(() => {
|
|
1521
1566
|
const parentEl = parent.$el;
|
|
1522
|
-
const inputEl = parentEl.querySelector("
|
|
1567
|
+
const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]');
|
|
1523
1568
|
if (inputEl) {
|
|
1524
1569
|
const { paddingRight } = getComputedStyle(inputEl);
|
|
1525
1570
|
state.inputPaddingRight = parseFloat(paddingRight);
|
|
1526
1571
|
}
|
|
1527
1572
|
});
|
|
1528
1573
|
};
|
|
1529
|
-
const computedGetIcon = ({
|
|
1530
|
-
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
|
+
};
|
|
1531
1579
|
};
|
|
1532
1580
|
const computedGetTagType = ({ designConfig, props }) => () => {
|
|
1533
1581
|
var _a;
|
|
@@ -1536,8 +1584,18 @@ const computedGetTagType = ({ designConfig, props }) => () => {
|
|
|
1536
1584
|
}
|
|
1537
1585
|
return props.tagType;
|
|
1538
1586
|
};
|
|
1539
|
-
const
|
|
1540
|
-
|
|
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
|
+
}
|
|
1541
1599
|
};
|
|
1542
1600
|
export {
|
|
1543
1601
|
blur,
|
|
@@ -1547,6 +1605,7 @@ export {
|
|
|
1547
1605
|
calcOverFlow,
|
|
1548
1606
|
checkDefaultFirstOption,
|
|
1549
1607
|
clearNoMatchValue,
|
|
1608
|
+
clearSearchText,
|
|
1550
1609
|
computeCollapseTags,
|
|
1551
1610
|
computeMultipleLimit,
|
|
1552
1611
|
computeOptimizeOpts,
|
|
@@ -1560,11 +1619,9 @@ export {
|
|
|
1560
1619
|
computedSelectDisabled,
|
|
1561
1620
|
computedShowClose,
|
|
1562
1621
|
computedShowCopy,
|
|
1563
|
-
computedShowDropdownIcon,
|
|
1564
1622
|
computedShowNewOption,
|
|
1565
1623
|
computedTagsStyle,
|
|
1566
1624
|
debouncRquest,
|
|
1567
|
-
debouncedQueryChange,
|
|
1568
1625
|
defaultOnQueryChange,
|
|
1569
1626
|
deletePrevTag,
|
|
1570
1627
|
deleteSelected,
|
|
@@ -1572,13 +1629,15 @@ export {
|
|
|
1572
1629
|
directEmitChange,
|
|
1573
1630
|
doDestroy,
|
|
1574
1631
|
emitChange,
|
|
1632
|
+
emptyFlag,
|
|
1575
1633
|
emptyText,
|
|
1576
1634
|
focus,
|
|
1577
1635
|
getChildValue,
|
|
1578
1636
|
getLabelSlotValue,
|
|
1579
1637
|
getOption,
|
|
1638
|
+
getOptionIndexArr,
|
|
1580
1639
|
getPluginOption,
|
|
1581
|
-
|
|
1640
|
+
getSelectedOption,
|
|
1582
1641
|
getTreeData,
|
|
1583
1642
|
getValueIndex,
|
|
1584
1643
|
getValueKey,
|
|
@@ -1589,7 +1648,6 @@ export {
|
|
|
1589
1648
|
handleClose,
|
|
1590
1649
|
handleComposition,
|
|
1591
1650
|
handleCopyClick,
|
|
1592
|
-
handleDebouncedQueryChange,
|
|
1593
1651
|
handleDropdownClick,
|
|
1594
1652
|
handleEnterTag,
|
|
1595
1653
|
handleFocus,
|
|
@@ -1611,8 +1669,11 @@ export {
|
|
|
1611
1669
|
onMouseenterNative,
|
|
1612
1670
|
onMouseleaveNative,
|
|
1613
1671
|
onOptionDestroy,
|
|
1672
|
+
queryChange,
|
|
1673
|
+
queryVisibleOptions,
|
|
1614
1674
|
radioChange,
|
|
1615
|
-
|
|
1675
|
+
recycleScrollerHeight,
|
|
1676
|
+
resetDatas,
|
|
1616
1677
|
resetHoverIndex,
|
|
1617
1678
|
resetInputHeight,
|
|
1618
1679
|
resetInputState,
|
|
@@ -1620,6 +1681,7 @@ export {
|
|
|
1620
1681
|
scrollToOption,
|
|
1621
1682
|
selectChange,
|
|
1622
1683
|
selectOption,
|
|
1684
|
+
setOptionHighlight,
|
|
1623
1685
|
setSelected,
|
|
1624
1686
|
setSoftFocus,
|
|
1625
1687
|
showTip,
|