@opentiny/vue-renderless 3.9.2 → 3.10.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/vue.js +25 -2
- package/anchor/index.js +3 -3
- package/anchor/vue.js +7 -1
- package/area/index.js +4 -4
- package/button/vue.js +4 -2
- package/button-group/index.js +8 -1
- package/button-group/vue.js +5 -10
- package/calendar/index.js +14 -14
- package/calendar-bar/index.js +3 -3
- package/carousel-item/index.js +1 -1
- package/cascader/vue.js +1 -1
- package/cascader-mobile/index.js +299 -0
- package/cascader-mobile/vue.js +102 -0
- package/cascader-panel/store.js +3 -1
- package/chart-boxplot/index.js +0 -1
- package/chart-core/deps/constants.js +20 -2
- package/chart-core/index.js +9 -1
- package/chart-core/modules/extend.js +14 -1
- package/chart-gauge/index.js +3 -1
- package/chart-graph/index.js +3 -1
- package/chart-map/index.js +11 -1
- package/chart-scatter/index.js +10 -2
- package/chart-waterfall/index.js +4 -1
- package/checkbox/index.js +16 -14
- package/checkbox/vue.js +14 -10
- package/checkbox-button/vue.js +7 -3
- package/column-list-item/vue.js +10 -1
- package/common/bigInt.js +4 -11
- package/common/date.js +2 -2
- package/common/deps/ResizeObserver.js +3 -1
- package/common/deps/date-util.js +9 -1
- package/common/deps/date.js +18 -5
- package/common/deps/fastdom/async.js +41 -0
- package/common/deps/fastdom/index.js +9 -0
- package/common/deps/fastdom/sandbox.js +53 -0
- package/common/deps/fastdom/singleton.js +80 -0
- package/common/deps/fullscreen/screenfull.js +16 -2
- package/common/deps/memorize.js +3 -3
- package/common/deps/popup-manager.js +0 -1
- package/common/deps/requestAnimationFrame.js +1 -1
- package/common/deps/throttle.js +2 -2
- package/common/deps/tree-model/node.js +23 -11
- package/common/deps/tree-model/tree-store.js +28 -7
- package/common/deps/vue-popper.js +14 -2
- package/common/deps/vue-popup.js +16 -23
- package/common/index.js +7 -35
- package/common/runtime.js +1 -1
- package/common/validate/rules/type.js +3 -1
- package/credit-card-form/vue.js +2 -2
- package/date-panel/index.js +35 -31
- package/date-panel/vue.js +12 -12
- package/date-picker/index.js +9 -5
- package/date-picker/vue.js +20 -8
- package/date-picker-mobile/index.js +3 -3
- package/date-range/index.js +91 -19
- package/date-range/vue.js +19 -11
- package/date-table/index.js +39 -6
- package/date-table/vue.js +2 -2
- package/dept/index.js +1 -1
- package/detail-page/vue.js +9 -1
- package/dialog-box/index.js +11 -2
- package/dialog-box/vue.js +30 -6
- package/dialog-select/index.js +27 -5
- package/dialog-select/vue.js +11 -4
- package/drop-roles/index.js +3 -1
- package/dropdown/index.js +28 -7
- package/dropdown/vue.js +12 -7
- package/dropdown-item/index.js +9 -1
- package/dropdown-item/mf.js +3 -3
- package/dropdown-item/vue.js +12 -10
- package/dropdown-menu/index.js +13 -14
- package/dropdown-menu/vue.js +8 -7
- package/espace/vue.js +9 -1
- package/fall-menu/vue.js +12 -1
- package/file-upload/index.js +137 -89
- package/file-upload/vue.js +24 -14
- package/filter/index.js +1 -1
- package/filter/vue.js +1 -3
- package/floating-button/index.js +73 -0
- package/floating-button/vue.js +35 -0
- package/form/index.js +13 -4
- package/form/vue.js +7 -2
- package/form-item/index.js +4 -1
- package/form-item/vue.js +6 -3
- package/fullscreen/vue.js +24 -3
- package/grid/plugins/exportExcel.js +54 -8
- package/grid/static/base/helperGetHGSKeys.js +1 -4
- package/grid/utils/common.js +15 -11
- package/grid/utils/dom.js +5 -1
- package/guide/index.js +2 -3
- package/hrapprover/index.js +3 -1
- package/index-bar/vue.js +8 -1
- package/input/index.js +1 -11
- package/input/vue.js +6 -12
- package/ip-address/index.js +66 -33
- package/ip-address/vue.js +8 -1
- package/link-menu/vue.js +22 -2
- package/locales/index.js +4 -2
- package/logon-user/index.js +3 -1
- package/logout/index.js +6 -2
- package/milestone/vue.js +1 -1
- package/mini-picker/index.js +12 -10
- package/mini-picker/vue.js +10 -10
- package/modal/index.js +5 -3
- package/modal/vue.js +4 -2
- package/month-range/index.js +18 -18
- package/month-range/vue.js +16 -4
- package/month-table/index.js +7 -3
- package/multi-select/vue.js +1 -9
- package/nav-menu/index.js +33 -4
- package/nav-menu/vue.js +9 -1
- package/notify/vue.js +12 -1
- package/numeric/vue.js +6 -2
- package/option/index.js +10 -2
- package/option/vue.js +20 -9
- package/option-group/index.js +3 -1
- package/package.json +2 -1
- package/picker/index.js +88 -17
- package/picker/vue.js +42 -17
- package/picker-column/index.js +6 -6
- package/picker-column/vue.js +5 -5
- package/popconfirm/vue.js +3 -1
- package/popeditor/index.js +55 -13
- package/popeditor/vue.js +23 -7
- package/popover/vue.js +1 -2
- package/popup/vue.js +15 -2
- package/progress/index.js +9 -7
- package/progress/vue.js +12 -4
- package/pull-refresh/vue.js +10 -1
- package/query-builder/index.js +9 -0
- package/query-builder/vue.js +18 -0
- package/radio/vue.js +3 -1
- package/radio-button/vue.js +1 -1
- package/rate/index.js +8 -2
- package/rate/vue.js +27 -4
- package/recycle-scroller/index.js +0 -1
- package/scrollbar/vue-bar.js +18 -2
- package/search/index.js +12 -5
- package/search/vue.js +7 -5
- package/select/index.js +596 -304
- package/select/vue.js +167 -101
- package/select-dropdown/vue.js +8 -6
- package/select-mobile/index.js +26 -13
- package/select-mobile/vue.js +14 -5
- package/select-view/index.js +5 -21
- package/select-view/vue.js +0 -3
- package/selected-box/index.js +3 -1
- package/slider/index.js +5 -5
- package/slider/vue.js +16 -0
- package/slider-button/index.js +41 -0
- package/slider-button/vue.js +36 -0
- package/slider-button-group/slide-button.js +142 -0
- package/slider-button-group/vue.js +52 -0
- package/steps/slide-bar.js +0 -1
- package/switch/index.js +1 -1
- package/switch/vue.js +1 -1
- package/tab-bar/index.js +8 -6
- package/tab-nav/index.js +19 -13
- package/tab-nav/vue.js +10 -9
- package/tabs/index.js +21 -17
- package/tabs/vue.js +1 -4
- package/tag/vue.js +2 -1
- package/tag-group/index.js +23 -10
- package/tag-group/vue.js +5 -4
- package/time/index.js +8 -8
- package/time/vue.js +9 -9
- package/time-line/index.js +24 -2
- package/time-line/vue.js +30 -4
- package/time-panel/index.js +2 -2
- package/time-panel/vue.js +2 -2
- package/time-range/index.js +24 -21
- package/time-range/vue.js +26 -16
- package/time-spinner/index.js +32 -21
- package/time-spinner/vue.js +37 -12
- package/timeline-item/index.js +77 -0
- package/timeline-item/vue.js +44 -0
- package/toggle-menu/vue.js +0 -1
- package/tooltip/index.js +11 -12
- package/tooltip/vue.js +11 -1
- package/top-box/vue.js +13 -1
- package/tree/index.js +228 -15
- package/tree/vue.js +119 -15
- package/tree-menu/index.js +35 -0
- package/tree-menu/vue.js +27 -5
- package/tree-node/index.js +75 -10
- package/tree-node/vue.js +45 -23
- package/upload/index.js +90 -49
- package/upload/vue.js +22 -10
- package/upload-dragger/index.js +4 -3
- package/upload-list/index.js +67 -16
- package/upload-list/vue.js +26 -9
- package/user/index.js +7 -4
- package/user-link/index.js +2 -1
- package/wizard/index.js +4 -1
- package/wizard/vue.js +19 -2
- package/year-range/index.js +1 -1
- package/year-range/vue.js +3 -3
- package/year-table/index.js +2 -2
package/select/index.js
CHANGED
|
@@ -4,15 +4,19 @@ import {
|
|
|
4
4
|
} from "../chunk-PKUHTIDK.js";
|
|
5
5
|
import { find } from "../common/array";
|
|
6
6
|
import { getObj, isEqual } from "../common/object";
|
|
7
|
+
import { hasClass } from "../common/deps/dom";
|
|
7
8
|
import { isKorean } from "../common/string";
|
|
8
9
|
import scrollIntoView from "../common/deps/scroll-into-view";
|
|
9
10
|
import PopupManager from "../common/deps/popup-manager";
|
|
10
11
|
import debounce from "../common/deps/debounce";
|
|
11
12
|
import { getDataset } from "../common/dataset";
|
|
12
13
|
import Memorize from "../common/deps/memorize";
|
|
13
|
-
import { isEmptyObject } from "../common/type";
|
|
14
|
+
import { isEmptyObject, isNull } from "../common/type";
|
|
14
15
|
import { addResizeListener, removeResizeListener } from "../common/deps/resize-event";
|
|
15
16
|
import { extend } from "../common/object";
|
|
17
|
+
import { BROWSER_NAME } from "../common";
|
|
18
|
+
import browserInfo from "../common/browser";
|
|
19
|
+
import { fastdom } from "../common/deps/fastdom";
|
|
16
20
|
const handleComposition = ({ api, nextTick, state }) => (event) => {
|
|
17
21
|
const text = event.target.value;
|
|
18
22
|
if (event.type === "compositionend") {
|
|
@@ -23,7 +27,7 @@ const handleComposition = ({ api, nextTick, state }) => (event) => {
|
|
|
23
27
|
state.isOnComposition = !isKorean(lastCharacter);
|
|
24
28
|
}
|
|
25
29
|
};
|
|
26
|
-
const showTip = ({ props, state,
|
|
30
|
+
const showTip = ({ props, state, vm }) => (show) => {
|
|
27
31
|
if (!props.showOverflowTooltip) {
|
|
28
32
|
return;
|
|
29
33
|
}
|
|
@@ -32,52 +36,52 @@ const showTip = ({ props, state, refs }) => (show) => {
|
|
|
32
36
|
clearTimeout(state.tipTimer);
|
|
33
37
|
state.tipTimer = setTimeout(() => {
|
|
34
38
|
state.showTip = state.tipHover;
|
|
35
|
-
}, refs.popover.closeDelay);
|
|
39
|
+
}, vm.$refs.popover.closeDelay);
|
|
36
40
|
} else {
|
|
37
41
|
if (!props.multiple) {
|
|
38
|
-
const reference = refs.reference.$el;
|
|
42
|
+
const reference = vm.$refs.reference.$el;
|
|
39
43
|
overflow = reference.querySelector("input").scrollWidth > reference.scrollWidth;
|
|
40
44
|
} else {
|
|
41
|
-
overflow = refs.tags.scrollHeight > refs.tags.getBoundingClientRect().height;
|
|
45
|
+
overflow = vm.$refs.tags.scrollHeight > vm.$refs.tags.getBoundingClientRect().height;
|
|
42
46
|
}
|
|
43
47
|
state.showTip = show && overflow && !!state.tips && !state.visible;
|
|
44
48
|
}
|
|
45
49
|
};
|
|
46
|
-
const gridOnQueryChange = ({ props,
|
|
50
|
+
const gridOnQueryChange = ({ props, vm, constants, state }) => (value) => {
|
|
47
51
|
const { multiple, valueField, filterMethod, filterable, remote, remoteMethod } = props;
|
|
48
52
|
if (filterable && typeof filterMethod === "function") {
|
|
49
|
-
const table = refs.selectGrid.$refs.tinyTable;
|
|
53
|
+
const table = vm.$refs.selectGrid.$refs.tinyTable;
|
|
50
54
|
const fullData = table.afterFullData;
|
|
51
|
-
refs.selectGrid.scrollTo(null, 0);
|
|
55
|
+
vm.$refs.selectGrid.scrollTo(null, 0);
|
|
52
56
|
table.afterFullData = filterMethod(value, fullData) || [];
|
|
53
|
-
refs.selectGrid.handleTableData(!value).then(() => state.selectEmitter.emit(constants.EVENT_NAME.updatePopper));
|
|
57
|
+
vm.$refs.selectGrid.handleTableData(!value).then(() => state.selectEmitter.emit(constants.EVENT_NAME.updatePopper));
|
|
54
58
|
state.previousQuery = value;
|
|
55
59
|
} else if (remote && typeof remoteMethod === "function") {
|
|
56
60
|
state.previousQuery = value;
|
|
57
|
-
remoteMethod(value).then((data) => {
|
|
61
|
+
remoteMethod(value, props.extraQueryParams).then((data) => {
|
|
58
62
|
if (multiple) {
|
|
59
63
|
const selectedIds = state.selected.map((sel) => sel[valueField]);
|
|
60
|
-
refs.selectGrid.clearSelection();
|
|
61
|
-
refs.selectGrid.setSelection(
|
|
64
|
+
vm.$refs.selectGrid.clearSelection();
|
|
65
|
+
vm.$refs.selectGrid.setSelection(
|
|
62
66
|
data.filter((row) => ~selectedIds.indexOf(row[valueField])),
|
|
63
67
|
true
|
|
64
68
|
);
|
|
65
69
|
state.remoteData = data.filter((row) => !~selectedIds.indexOf(row[valueField])).concat(state.selected);
|
|
66
70
|
} else {
|
|
67
|
-
refs.selectGrid.clearRadioRow();
|
|
68
|
-
refs.selectGrid.setRadioRow(find(data, (item) => props.modelValue == item[props.valueField]));
|
|
71
|
+
vm.$refs.selectGrid.clearRadioRow();
|
|
72
|
+
vm.$refs.selectGrid.setRadioRow(find(data, (item) => props.modelValue == item[props.valueField]));
|
|
69
73
|
state.remoteData = data;
|
|
70
74
|
}
|
|
71
|
-
refs.selectGrid.$refs.tinyTable.lastScrollTop = 0;
|
|
72
|
-
refs.selectGrid.loadData(data);
|
|
73
|
-
refs.selectGrid.handleTableData(!value).then(() => state.selectEmitter.emit(constants.EVENT_NAME.updatePopper));
|
|
75
|
+
vm.$refs.selectGrid.$refs.tinyTable.lastScrollTop = 0;
|
|
76
|
+
vm.$refs.selectGrid.loadData(data);
|
|
77
|
+
vm.$refs.selectGrid.handleTableData(!value).then(() => state.selectEmitter.emit(constants.EVENT_NAME.updatePopper));
|
|
74
78
|
});
|
|
75
79
|
}
|
|
76
80
|
};
|
|
77
81
|
const defaultOnQueryChange = ({ props, state, constants, api }) => (value) => {
|
|
78
|
-
if (props.remote && typeof props.remoteMethod === "function") {
|
|
82
|
+
if (props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
79
83
|
state.hoverIndex = -1;
|
|
80
|
-
props.remoteMethod(value);
|
|
84
|
+
props.remoteMethod && props.remoteMethod(value, props.extraQueryParams);
|
|
81
85
|
} else if (typeof props.filterMethod === "function") {
|
|
82
86
|
props.filterMethod(value);
|
|
83
87
|
state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup, constants.EVENT_NAME.queryChange);
|
|
@@ -89,12 +93,11 @@ const defaultOnQueryChange = ({ props, state, constants, api }) => (value) => {
|
|
|
89
93
|
api.checkDefaultFirstOption();
|
|
90
94
|
}
|
|
91
95
|
};
|
|
92
|
-
const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (value) => {
|
|
93
|
-
|
|
94
|
-
if (state.previousQuery === value || state.isOnComposition) {
|
|
96
|
+
const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (value, isChange = false) => {
|
|
97
|
+
if (state.previousQuery === value && !isChange || state.isOnComposition) {
|
|
95
98
|
return;
|
|
96
99
|
}
|
|
97
|
-
if (state.previousQuery === null && (typeof props.filterMethod === "function" || typeof props.remoteMethod === "function")) {
|
|
100
|
+
if (state.previousQuery === null && !isChange && (typeof props.filterMethod === "function" || typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
98
101
|
state.previousQuery = value;
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
@@ -105,21 +108,21 @@ const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (v
|
|
|
105
108
|
if (props.renderType === constants.TYPE.Tree) {
|
|
106
109
|
state.previousQuery = value;
|
|
107
110
|
if (state.filterOrSearch && typeof props.filterMethod === "function") {
|
|
108
|
-
refs.selectTree && refs.selectTree.filter(value);
|
|
111
|
+
vm.$refs.selectTree && vm.$refs.selectTree.filter(value);
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
state.previousQuery = value;
|
|
112
|
-
|
|
115
|
+
window.requestAnimationFrame(() => {
|
|
113
116
|
if (state.visible) {
|
|
114
117
|
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
115
118
|
state.showWarper = true;
|
|
116
119
|
}
|
|
117
120
|
});
|
|
118
121
|
state.hoverIndex = -1;
|
|
119
|
-
if (props.multiple && props.filterable) {
|
|
122
|
+
if (props.multiple && props.filterable && !props.shape) {
|
|
120
123
|
nextTick(() => {
|
|
121
|
-
if (refs.input) {
|
|
122
|
-
const length = refs.input.value.length * 15 + 20;
|
|
124
|
+
if (vm.$refs.input) {
|
|
125
|
+
const length = vm.$refs.input.value.length * 15 + 20;
|
|
123
126
|
state.inputLength = state.collapseTags ? Math.min(50, length) : length;
|
|
124
127
|
api.managePlaceholder();
|
|
125
128
|
api.resetInputHeight();
|
|
@@ -131,13 +134,13 @@ const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (v
|
|
|
131
134
|
}
|
|
132
135
|
api.defaultOnQueryChange(value);
|
|
133
136
|
};
|
|
134
|
-
const scrollToOption = ({
|
|
137
|
+
const scrollToOption = ({ vm, constants }) => (option) => {
|
|
135
138
|
const target = Array.isArray(option) && option[0] ? option[0].el : option.el;
|
|
136
|
-
if (refs.popper && target) {
|
|
137
|
-
const menu = refs.popper.$el.querySelector(constants.CLASS.SelectDropdownWrap);
|
|
139
|
+
if (vm.$refs.popper && target) {
|
|
140
|
+
const menu = vm.$refs.popper.$el.querySelector(constants.CLASS.SelectDropdownWrap);
|
|
138
141
|
scrollIntoView(menu, target);
|
|
139
142
|
}
|
|
140
|
-
refs.scrollbar && refs.scrollbar.handleScroll();
|
|
143
|
+
vm.$refs.scrollbar && vm.$refs.scrollbar.handleScroll();
|
|
141
144
|
};
|
|
142
145
|
const handleMenuEnter = ({ api, nextTick, state }) => () => {
|
|
143
146
|
nextTick(() => api.scrollToOption(state.selected));
|
|
@@ -184,7 +187,7 @@ const emitChange = ({ emit, props, state, constants }) => (value) => {
|
|
|
184
187
|
const getOption = ({ props, state }) => (value) => {
|
|
185
188
|
let option;
|
|
186
189
|
const isObject = Object.prototype.toString.call(value).toLowerCase() === "[object object]";
|
|
187
|
-
const
|
|
190
|
+
const isNull2 = Object.prototype.toString.call(value).toLowerCase() === "[object null]";
|
|
188
191
|
const isUndefined = Object.prototype.toString.call(value).toLowerCase() === "[object undefined]";
|
|
189
192
|
for (let i = state.cachedOptions.length - 1; i >= 0; i--) {
|
|
190
193
|
const cachedOption = state.cachedOptions[i];
|
|
@@ -197,7 +200,7 @@ const getOption = ({ props, state }) => (value) => {
|
|
|
197
200
|
if (option) {
|
|
198
201
|
return option;
|
|
199
202
|
}
|
|
200
|
-
const label = !isObject && !
|
|
203
|
+
const label = !isObject && !isNull2 && !isUndefined ? value : "";
|
|
201
204
|
let newOption = { value, currentLabel: label };
|
|
202
205
|
if (props.multiple) {
|
|
203
206
|
newOption.hitState = false;
|
|
@@ -231,37 +234,42 @@ const getResultOfSetSelected = ({ props, isGrid, isTree, api }) => {
|
|
|
231
234
|
}
|
|
232
235
|
return result;
|
|
233
236
|
};
|
|
234
|
-
const
|
|
237
|
+
const setGridOrTreeSelected = ({ props, state, vm, isTree, api }) => {
|
|
238
|
+
if (!props.modelValue) {
|
|
239
|
+
state.selectedLabel = "";
|
|
240
|
+
state.selected = {};
|
|
241
|
+
state.currentKey = "";
|
|
242
|
+
vm.$refs.selectGrid && vm.$refs.selectGrid.clearRadioRow();
|
|
243
|
+
vm.$refs.selectTree && vm.$refs.selectTree.setCurrentKey && vm.$refs.selectTree.setCurrentKey(null);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const isRemote = state.filterOrSearch && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
247
|
+
const nestdata = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
|
|
248
|
+
const data = find(nestdata, (item) => props.modelValue == item[props.valueField]);
|
|
249
|
+
if (isEmptyObject(data)) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const obj = __spreadValues({}, data);
|
|
253
|
+
const label = data[props.textField];
|
|
254
|
+
obj.currentLabel = label;
|
|
255
|
+
state.selectedLabel = label;
|
|
256
|
+
state.selected = obj;
|
|
257
|
+
state.currentKey = data[props.valueField];
|
|
258
|
+
};
|
|
259
|
+
const setSelected = ({ api, constants, nextTick, props, vm, state }) => () => {
|
|
235
260
|
const isTree = props.renderType === constants.TYPE.Tree;
|
|
236
261
|
const isGrid = props.renderType === constants.TYPE.Grid;
|
|
237
262
|
if (!props.multiple) {
|
|
238
263
|
if (isGrid || isTree) {
|
|
239
|
-
|
|
240
|
-
state.selectedLabel = "";
|
|
241
|
-
state.selected = {};
|
|
242
|
-
state.currentKey = "";
|
|
243
|
-
refs.selectGrid && refs.selectGrid.clearRadioRow();
|
|
244
|
-
refs.selectTree && refs.selectTree.setCurrentKey && refs.selectTree.setCurrentKey(null);
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
const isRemote = state.filterOrSearch && props.remote && typeof props.remoteMethod === "function";
|
|
248
|
-
const nestdata = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
|
|
249
|
-
const data = find(nestdata, (item) => props.modelValue == item[props.valueField]);
|
|
250
|
-
if (isEmptyObject(data)) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const obj = __spreadValues({}, data);
|
|
254
|
-
const label = data[props.textField];
|
|
255
|
-
obj.currentLabel = label;
|
|
256
|
-
state.selectedLabel = label;
|
|
257
|
-
state.selected = obj;
|
|
258
|
-
state.currentKey = data[props.valueField];
|
|
264
|
+
setGridOrTreeSelected({ props, state, vm, isTree, api });
|
|
259
265
|
} else {
|
|
260
266
|
const option = getOptionOfSetSelected({ api, props });
|
|
261
267
|
nextTick(() => {
|
|
262
268
|
state.selected = option;
|
|
263
269
|
state.selectedLabel = option.state.currentLabel || option.currentLabel;
|
|
264
|
-
|
|
270
|
+
if (state.filterOrSearch && !props.shape && !props.allowCreate) {
|
|
271
|
+
state.query = state.selectedLabel;
|
|
272
|
+
}
|
|
265
273
|
});
|
|
266
274
|
}
|
|
267
275
|
return;
|
|
@@ -269,12 +277,12 @@ const setSelected = ({ api, constants, nextTick, props, refs, state }) => () =>
|
|
|
269
277
|
const result = getResultOfSetSelected({ props, isGrid, isTree, api });
|
|
270
278
|
state.selectCls = result.length ? result.length === state.options.length ? "checked-sur" : "halfselect" : "check";
|
|
271
279
|
state.selected = result;
|
|
272
|
-
refs.selectTree && refs.selectTree.setCheckedNodes && refs.selectTree.setCheckedNodes(state.selected);
|
|
280
|
+
vm.$refs.selectTree && vm.$refs.selectTree.setCheckedNodes && vm.$refs.selectTree.setCheckedNodes(state.selected);
|
|
273
281
|
state.tips = state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join(",");
|
|
274
282
|
nextTick(api.resetInputHeight);
|
|
275
283
|
};
|
|
276
284
|
const getPluginOption = ({ api, props, state }) => (value, isTree) => {
|
|
277
|
-
const isRemote = state.filterOrSearch && props.remote && typeof props.remoteMethod === "function";
|
|
285
|
+
const isRemote = state.filterOrSearch && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
278
286
|
const { textField, valueField } = props;
|
|
279
287
|
const sourceData = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
|
|
280
288
|
const selNode = find(sourceData, (item) => item[valueField] == value);
|
|
@@ -285,7 +293,7 @@ const getPluginOption = ({ api, props, state }) => (value, isTree) => {
|
|
|
285
293
|
}
|
|
286
294
|
return items;
|
|
287
295
|
};
|
|
288
|
-
const toggleCheckAll = ({ api, emit, state }) => () => {
|
|
296
|
+
const toggleCheckAll = ({ api, emit, state, props }) => () => {
|
|
289
297
|
const getEnabledValues = (options) => {
|
|
290
298
|
let values = [];
|
|
291
299
|
for (let i = 0; i < options.length; i++) {
|
|
@@ -304,8 +312,19 @@ const toggleCheckAll = ({ api, emit, state }) => () => {
|
|
|
304
312
|
} else if (state.selectCls === "checked-sur") {
|
|
305
313
|
value = [];
|
|
306
314
|
}
|
|
315
|
+
const requiredValue = [];
|
|
316
|
+
if (props.multiple) {
|
|
317
|
+
state.options.forEach((opt) => {
|
|
318
|
+
if (opt.required)
|
|
319
|
+
requiredValue.push(opt.value);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (Array.isArray(value)) {
|
|
323
|
+
value = requiredValue.concat(value.filter((val) => !requiredValue.find((requireVal) => requireVal === val)));
|
|
324
|
+
}
|
|
307
325
|
api.setSoftFocus();
|
|
308
|
-
|
|
326
|
+
state.isSilentBlur = true;
|
|
327
|
+
api.updateModelValue(value);
|
|
309
328
|
emit("change", value);
|
|
310
329
|
};
|
|
311
330
|
const resetFilter = ({ state, api }) => () => {
|
|
@@ -328,19 +347,20 @@ const handleFocus = ({ emit, props, state, api }) => (event) => {
|
|
|
328
347
|
api.resetFilter();
|
|
329
348
|
}
|
|
330
349
|
};
|
|
331
|
-
const focus = ({
|
|
350
|
+
const focus = ({ vm, state }) => () => {
|
|
332
351
|
var _a;
|
|
333
352
|
if (!state.softFocus) {
|
|
334
|
-
(_a = refs.reference) == null ? void 0 : _a.focus();
|
|
353
|
+
(_a = vm.$refs.reference) == null ? void 0 : _a.focus();
|
|
335
354
|
}
|
|
336
355
|
};
|
|
337
|
-
const blur = ({
|
|
356
|
+
const blur = ({ vm, state }) => () => {
|
|
338
357
|
var _a;
|
|
339
358
|
state.visible = false;
|
|
340
|
-
(_a = refs.reference) == null ? void 0 : _a.blur();
|
|
359
|
+
(_a = vm.$refs.reference) == null ? void 0 : _a.blur();
|
|
341
360
|
};
|
|
342
361
|
const handleBlur = ({ constants, dispatch, emit, state }) => (event) => {
|
|
343
|
-
|
|
362
|
+
clearTimeout(state.timer);
|
|
363
|
+
state.timer = setTimeout(() => {
|
|
344
364
|
var _a;
|
|
345
365
|
if (state.isSilentBlur) {
|
|
346
366
|
state.isSilentBlur = false;
|
|
@@ -348,14 +368,14 @@ const handleBlur = ({ constants, dispatch, emit, state }) => (event) => {
|
|
|
348
368
|
emit("blur", event);
|
|
349
369
|
}
|
|
350
370
|
dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formBlur, (_a = event == null ? void 0 : event.target) == null ? void 0 : _a.value);
|
|
351
|
-
},
|
|
371
|
+
}, 200);
|
|
352
372
|
state.softFocus = false;
|
|
353
373
|
};
|
|
354
374
|
const handleClearClick = (api) => (event) => {
|
|
355
375
|
api.deleteSelected(event);
|
|
356
376
|
};
|
|
357
|
-
const doDestroy = (
|
|
358
|
-
refs.popper && refs.popper.doDestroy();
|
|
377
|
+
const doDestroy = (vm) => () => {
|
|
378
|
+
vm.$refs.popper && vm.$refs.popper.doDestroy();
|
|
359
379
|
};
|
|
360
380
|
const handleClose = (state) => () => {
|
|
361
381
|
state.visible = false;
|
|
@@ -376,50 +396,67 @@ const toggleLastOptionHitState = ({ state }) => (hit) => {
|
|
|
376
396
|
hitTarget.hitState = !hitTarget.hitState;
|
|
377
397
|
return hitTarget.hitState;
|
|
378
398
|
};
|
|
379
|
-
const deletePrevTag = ({ api, constants,
|
|
380
|
-
const refs = vm.$refs;
|
|
399
|
+
const deletePrevTag = ({ api, constants, props, state, vm }) => (event) => {
|
|
381
400
|
if (event.target.value.length <= 0 && !api.toggleLastOptionHitState()) {
|
|
382
401
|
const value = props.modelValue.slice();
|
|
383
402
|
value.pop();
|
|
384
|
-
|
|
403
|
+
api.updateModelValue(value);
|
|
385
404
|
api.emitChange(value);
|
|
386
405
|
if (props.renderType === constants.TYPE.Grid) {
|
|
387
406
|
const rows = state.selected.slice().filter((item) => value.includes(item[props.valueField]));
|
|
388
|
-
refs.selectGrid.clearSelection();
|
|
389
|
-
refs.selectGrid.setSelection(rows, true);
|
|
407
|
+
vm.$refs.selectGrid.clearSelection();
|
|
408
|
+
vm.$refs.selectGrid.setSelection(rows, true);
|
|
390
409
|
}
|
|
391
410
|
}
|
|
392
411
|
};
|
|
393
|
-
const managePlaceholder = ({
|
|
412
|
+
const managePlaceholder = ({ vm, state }) => () => {
|
|
394
413
|
if (state.currentPlaceholder !== "") {
|
|
395
|
-
state.currentPlaceholder = refs.input.value ? "" : state.cachedPlaceHolder;
|
|
414
|
+
state.currentPlaceholder = vm.$refs.input.value ? "" : state.cachedPlaceHolder;
|
|
396
415
|
}
|
|
397
416
|
};
|
|
398
|
-
const resetInputState = ({ api,
|
|
417
|
+
const resetInputState = ({ api, vm, state }) => (event) => {
|
|
399
418
|
if (event.keyCode !== 8) {
|
|
400
419
|
api.toggleLastOptionHitState(false);
|
|
401
420
|
}
|
|
402
|
-
state.inputLength = refs.input.value.length * 15 + 20;
|
|
421
|
+
state.inputLength = vm.$refs.input.value.length * 15 + 20;
|
|
403
422
|
api.resetInputHeight();
|
|
404
423
|
};
|
|
405
|
-
const resetInputHeight = ({ constants, nextTick, props,
|
|
406
|
-
if (state.collapseTags &&
|
|
424
|
+
const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designConfig }) => () => {
|
|
425
|
+
if (state.collapseTags && !props.filterable) {
|
|
407
426
|
return;
|
|
408
427
|
}
|
|
409
428
|
nextTick(() => {
|
|
410
|
-
|
|
429
|
+
var _a;
|
|
430
|
+
if (!vm.$refs.reference) {
|
|
411
431
|
return;
|
|
412
432
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
const
|
|
433
|
+
const inputChildNodes = vm.$refs.reference.$el.childNodes;
|
|
434
|
+
const inputContainer = [].filter.call(inputChildNodes, (item) => hasClass(item, "tiny-input-display-only"))[0];
|
|
435
|
+
const input = inputContainer && inputContainer.querySelector("input");
|
|
436
|
+
const tags = vm.$refs.tags;
|
|
416
437
|
if (!input) {
|
|
417
438
|
return;
|
|
418
439
|
}
|
|
419
|
-
|
|
440
|
+
if (!state.isDisplayOnly && props.hoverExpand && !props.disabled) {
|
|
441
|
+
api.calcCollapseTags();
|
|
442
|
+
}
|
|
443
|
+
const sizeInMap = ((_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.initialInputHeight) || state.initialInputHeight;
|
|
420
444
|
const noSelected = state.selected.length === 0;
|
|
421
445
|
const borderHeight = 2;
|
|
422
|
-
|
|
446
|
+
if (!state.isDisplayOnly) {
|
|
447
|
+
if (!noSelected && tags) {
|
|
448
|
+
fastdom.measure(() => {
|
|
449
|
+
const tagsClientHeight = tags.clientHeight;
|
|
450
|
+
fastdom.mutate(() => {
|
|
451
|
+
input.style.height = Math.max(tagsClientHeight + (tagsClientHeight > sizeInMap ? borderHeight : 0), sizeInMap) + "px";
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
} else {
|
|
455
|
+
input.style.height = noSelected ? sizeInMap + "px" : Math.max(0, sizeInMap) + "px";
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
input.style.height = "auto";
|
|
459
|
+
}
|
|
423
460
|
if (state.visible && state.emptyText !== false) {
|
|
424
461
|
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper, true);
|
|
425
462
|
}
|
|
@@ -441,7 +478,7 @@ const resetHoverIndex = ({ props, state }) => () => {
|
|
|
441
478
|
}
|
|
442
479
|
}
|
|
443
480
|
};
|
|
444
|
-
const handleOptionSelect = ({ api,
|
|
481
|
+
const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byClick) => {
|
|
445
482
|
var _a, _b;
|
|
446
483
|
state.memorize && state.memorize.updateByKey(option[state.memorize._dataKey] || option.value);
|
|
447
484
|
if (props.multiple) {
|
|
@@ -452,7 +489,7 @@ const handleOptionSelect = ({ api, emit, nextTick, props, refs, state }) => (opt
|
|
|
452
489
|
} else if (state.multipleLimit <= 0 || value.length < state.multipleLimit) {
|
|
453
490
|
value.push(option.value);
|
|
454
491
|
}
|
|
455
|
-
|
|
492
|
+
api.updateModelValue(value);
|
|
456
493
|
api.emitChange(value);
|
|
457
494
|
if (option.created) {
|
|
458
495
|
state.query = "";
|
|
@@ -460,16 +497,16 @@ const handleOptionSelect = ({ api, emit, nextTick, props, refs, state }) => (opt
|
|
|
460
497
|
state.inputLength = 20;
|
|
461
498
|
}
|
|
462
499
|
if (props.filterable) {
|
|
463
|
-
(_a = refs.input) == null ? void 0 : _a.focus();
|
|
500
|
+
(_a = vm.$refs.input) == null ? void 0 : _a.focus();
|
|
464
501
|
}
|
|
465
502
|
if (props.searchable) {
|
|
466
|
-
(_b = refs.reference) == null ? void 0 : _b.focus();
|
|
503
|
+
(_b = vm.$refs.reference) == null ? void 0 : _b.focus();
|
|
467
504
|
}
|
|
468
505
|
if (props.autoClose) {
|
|
469
506
|
state.visible = false;
|
|
470
507
|
}
|
|
471
508
|
} else {
|
|
472
|
-
|
|
509
|
+
api.updateModelValue(option.value);
|
|
473
510
|
api.emitChange(option.value);
|
|
474
511
|
if (option.created) {
|
|
475
512
|
state.createdSelected = true;
|
|
@@ -486,9 +523,13 @@ const handleOptionSelect = ({ api, emit, nextTick, props, refs, state }) => (opt
|
|
|
486
523
|
api.scrollToOption(option);
|
|
487
524
|
});
|
|
488
525
|
};
|
|
489
|
-
const
|
|
526
|
+
const initValue = ({ state }) => (vm) => {
|
|
527
|
+
const isExist = state.initValue.find((val) => val === vm.value);
|
|
528
|
+
!isExist && state.initValue.push(vm.value);
|
|
529
|
+
};
|
|
530
|
+
const setSoftFocus = ({ vm, state }) => () => {
|
|
490
531
|
state.softFocus = true;
|
|
491
|
-
const input = refs.input || refs.reference;
|
|
532
|
+
const input = vm.$refs.input || vm.$refs.reference;
|
|
492
533
|
input == null ? void 0 : input.focus();
|
|
493
534
|
};
|
|
494
535
|
const getValueIndex = (props) => (arr = [], value = null) => {
|
|
@@ -508,22 +549,25 @@ const getValueIndex = (props) => (arr = [], value = null) => {
|
|
|
508
549
|
return index;
|
|
509
550
|
}
|
|
510
551
|
};
|
|
511
|
-
const toggleMenu = ({
|
|
552
|
+
const toggleMenu = ({ vm, state, props }) => (e) => {
|
|
553
|
+
const event = e || window.event;
|
|
554
|
+
const enterCode = 13;
|
|
555
|
+
const nodeName = event.target && event.target.nodeName;
|
|
556
|
+
const toggleVisible = props.ignoreEnter ? event.keyCode !== enterCode && nodeName === "INPUT" : true;
|
|
512
557
|
if (!state.selectDisabled) {
|
|
513
|
-
!
|
|
514
|
-
|
|
515
|
-
!props.ignoreEnter && (state.visible = !state.visible);
|
|
516
|
-
state.softFocus = false;
|
|
517
|
-
}
|
|
558
|
+
toggleVisible && !state.softFocus && (state.visible = !state.visible);
|
|
559
|
+
state.softFocus = false;
|
|
518
560
|
if (state.visible) {
|
|
519
|
-
|
|
520
|
-
|
|
561
|
+
if (!(props.filterable && props.shape)) {
|
|
562
|
+
const dom = vm.$refs.input || vm.$refs.reference;
|
|
563
|
+
dom == null ? void 0 : dom.focus();
|
|
564
|
+
}
|
|
521
565
|
}
|
|
522
566
|
}
|
|
523
567
|
};
|
|
524
|
-
const selectOption = ({ api, state, props }) => () => {
|
|
568
|
+
const selectOption = ({ api, state, props }) => (e) => {
|
|
525
569
|
if (!state.visible || props.hideDrop) {
|
|
526
|
-
api.toggleMenu();
|
|
570
|
+
api.toggleMenu(e);
|
|
527
571
|
} else {
|
|
528
572
|
if (state.options[state.hoverIndex]) {
|
|
529
573
|
api.handleOptionSelect(state.options[state.hoverIndex]);
|
|
@@ -532,7 +576,12 @@ const selectOption = ({ api, state, props }) => () => {
|
|
|
532
576
|
};
|
|
533
577
|
const deleteSelected = ({ api, constants, emit, props, vm, state }) => (event) => {
|
|
534
578
|
event.stopPropagation();
|
|
535
|
-
|
|
579
|
+
let selectedValue = [];
|
|
580
|
+
if (props.multiple) {
|
|
581
|
+
const requireOptions = state.options.filter((opt) => opt.required && opt.value);
|
|
582
|
+
selectedValue = props.modelValue.slice().filter((v) => requireOptions.find((opt) => opt.value === v));
|
|
583
|
+
}
|
|
584
|
+
const value = props.multiple ? selectedValue : "";
|
|
536
585
|
const refs = vm.$refs;
|
|
537
586
|
if (props.renderType === constants.TYPE.Tree) {
|
|
538
587
|
state.selected = {};
|
|
@@ -544,12 +593,14 @@ const deleteSelected = ({ api, constants, emit, props, vm, state }) => (event) =
|
|
|
544
593
|
refs.selectGrid.clearRadioRow();
|
|
545
594
|
}
|
|
546
595
|
state.showTip = false;
|
|
547
|
-
|
|
596
|
+
api.updateModelValue(value);
|
|
548
597
|
api.emitChange(value);
|
|
549
598
|
state.visible = false;
|
|
550
599
|
emit("clear");
|
|
551
600
|
};
|
|
552
|
-
const deleteTag = ({ api, constants, emit, props, state, vm }) => (event, tag) => {
|
|
601
|
+
const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (event, tag) => {
|
|
602
|
+
if (tag.required)
|
|
603
|
+
return;
|
|
553
604
|
const refs = vm.$refs;
|
|
554
605
|
const isTree = props.renderType === constants.TYPE.Tree;
|
|
555
606
|
const index = state.selected.indexOf(tag);
|
|
@@ -561,7 +612,7 @@ const deleteTag = ({ api, constants, emit, props, state, vm }) => (event, tag) =
|
|
|
561
612
|
treeIds.push(...api.getChildValue(node.childNodes, props.valueField));
|
|
562
613
|
}
|
|
563
614
|
while (node.parent && !Array.isArray(node.parent.data)) {
|
|
564
|
-
treeIds.push(node.parent.data[props.valueField]);
|
|
615
|
+
node.parent.data && treeIds.push(node.parent.data[props.valueField]);
|
|
565
616
|
node = node.parent;
|
|
566
617
|
}
|
|
567
618
|
state.selected.slice().map((node2) => !treeIds.includes(node2[props.valueField]) && treeValue.push(node2[props.valueField]));
|
|
@@ -577,9 +628,10 @@ const deleteTag = ({ api, constants, emit, props, state, vm }) => (event, tag) =
|
|
|
577
628
|
refs.selectGrid.clearSelection();
|
|
578
629
|
refs.selectGrid.setSelection(rows, true);
|
|
579
630
|
}
|
|
580
|
-
|
|
631
|
+
api.updateModelValue(isTree ? treeValue : value);
|
|
581
632
|
api.emitChange(value);
|
|
582
633
|
emit(constants.EVENT_NAME.removeTag, tag[props.valueField]);
|
|
634
|
+
nextTick(() => state.key++);
|
|
583
635
|
}
|
|
584
636
|
event.stopPropagation();
|
|
585
637
|
};
|
|
@@ -606,13 +658,13 @@ const onOptionDestroy = (state) => (index) => {
|
|
|
606
658
|
state.options.splice(index, 1);
|
|
607
659
|
}
|
|
608
660
|
};
|
|
609
|
-
const resetInputWidth = ({
|
|
661
|
+
const resetInputWidth = ({ vm, state }) => () => {
|
|
610
662
|
var _a, _b, _c;
|
|
611
|
-
state.inputWidth = ((_c = (_b = (_a = refs.reference) == null ? void 0 : _a.$el) == null ? void 0 : _b.getBoundingClientRect()) == null ? void 0 : _c.width) || 0;
|
|
663
|
+
state.inputWidth = ((_c = (_b = (_a = vm.$refs.reference) == null ? void 0 : _a.$el) == null ? void 0 : _b.getBoundingClientRect()) == null ? void 0 : _c.width) || 0;
|
|
612
664
|
};
|
|
613
|
-
const handleResize = ({ api, props }) => () => {
|
|
665
|
+
const handleResize = ({ api, props, state }) => () => {
|
|
614
666
|
api.resetInputWidth();
|
|
615
|
-
if (props.multiple) {
|
|
667
|
+
if (props.multiple && !state.isDisplayOnly) {
|
|
616
668
|
api.resetInputHeight();
|
|
617
669
|
}
|
|
618
670
|
};
|
|
@@ -632,7 +684,7 @@ const checkDefaultFirstOption = (state) => () => {
|
|
|
632
684
|
for (let i = 0; i !== state.options.length; ++i) {
|
|
633
685
|
const option = state.options[i];
|
|
634
686
|
if (state.query) {
|
|
635
|
-
if (!option.disabled && !option.groupDisabled && option.visible) {
|
|
687
|
+
if (!option.disabled && !option.groupDisabled && option.state.visible) {
|
|
636
688
|
state.hoverIndex = i;
|
|
637
689
|
break;
|
|
638
690
|
}
|
|
@@ -645,8 +697,10 @@ const checkDefaultFirstOption = (state) => () => {
|
|
|
645
697
|
}
|
|
646
698
|
};
|
|
647
699
|
const getValueKey = (props) => (item) => {
|
|
700
|
+
if (!item)
|
|
701
|
+
return;
|
|
648
702
|
if (Object.prototype.toString.call(item.value).toLowerCase() !== "[object object]") {
|
|
649
|
-
return item.value;
|
|
703
|
+
return item.value || item[props.valueField];
|
|
650
704
|
}
|
|
651
705
|
return getObj(item.value, props.valueKey);
|
|
652
706
|
};
|
|
@@ -688,120 +742,26 @@ const emptyText = ({ I18N, props, state, t }) => () => {
|
|
|
688
742
|
}
|
|
689
743
|
return state.selected[props.valueField] || state.remoteData.length > 0;
|
|
690
744
|
}
|
|
691
|
-
if (
|
|
692
|
-
return false;
|
|
693
|
-
}
|
|
694
|
-
if (state.filterOrSearch && state.query && state.options.length > 0 && state.filteredOptionsCount === 0) {
|
|
745
|
+
if (state.filterOrSearch && state.query && state.options.length >= 0 && state.filteredOptionsCount === 0) {
|
|
695
746
|
return props.noMatchText || t(I18N.noMatch);
|
|
696
747
|
}
|
|
697
748
|
if (!state.options.some((option) => option.visible)) {
|
|
698
749
|
return props.noDataText || t(I18N.noData);
|
|
699
750
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
const optmzApis = {
|
|
704
|
-
exist: (val, multiple) => multiple ? Array.isArray(val) && val.length : val,
|
|
705
|
-
getValueIndex: (props) => {
|
|
706
|
-
const { options, valueField, modelValue, multiple } = props;
|
|
707
|
-
const contain = (val, arr) => Array.isArray(arr) && ~arr.indexOf(val);
|
|
708
|
-
const equal = (val, opt) => multiple ? contain(opt[valueField], [val]) : opt[valueField] === val;
|
|
709
|
-
let start = 0;
|
|
710
|
-
if (optmzApis.exist(modelValue, multiple)) {
|
|
711
|
-
const lastVal = multiple ? modelValue[modelValue.length - 1] : modelValue;
|
|
712
|
-
for (let i = 0; i < options.length; i++) {
|
|
713
|
-
if (!equal(lastVal, options[i])) {
|
|
714
|
-
continue;
|
|
715
|
-
}
|
|
716
|
-
return i;
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
return start;
|
|
720
|
-
},
|
|
721
|
-
getStartIndex: ({ props, state }) => {
|
|
722
|
-
const { options } = props;
|
|
723
|
-
const { optimizeOpts, optimizeStore } = state;
|
|
724
|
-
const { rSize } = optimizeOpts;
|
|
725
|
-
const { valueIndex } = optimizeStore;
|
|
726
|
-
return valueIndex + rSize > options.length ? options.length - rSize : valueIndex;
|
|
727
|
-
},
|
|
728
|
-
getViewStyle: ({ props, state }) => {
|
|
729
|
-
const { options } = props;
|
|
730
|
-
const { optimizeOpts } = state;
|
|
731
|
-
const { optionHeight } = optimizeOpts;
|
|
732
|
-
return `height:${optionHeight * options.length}px`;
|
|
733
|
-
},
|
|
734
|
-
getStoreDatas: ({ props, state }) => {
|
|
735
|
-
const { options, valueField, modelValue, multiple } = props;
|
|
736
|
-
const { datas, optimizeOpts, optimizeStore } = state;
|
|
737
|
-
const { startIndex } = optimizeStore;
|
|
738
|
-
const { rSize } = optimizeOpts;
|
|
739
|
-
const sliced = datas.slice(startIndex, startIndex + rSize);
|
|
740
|
-
const hiddenOptions = optimizeStore.hiddenOptions = [];
|
|
741
|
-
const findPush = (val) => {
|
|
742
|
-
const opt = options.find((option) => option[valueField] === val);
|
|
743
|
-
if (opt && !~sliced.indexOf(opt)) {
|
|
744
|
-
sliced.push(opt);
|
|
745
|
-
hiddenOptions.push(opt);
|
|
746
|
-
}
|
|
747
|
-
};
|
|
748
|
-
if (optmzApis.exist(modelValue, multiple)) {
|
|
749
|
-
if (multiple) {
|
|
750
|
-
modelValue.forEach(findPush);
|
|
751
|
+
if (props.remote && state.query === "" && state.options.length === 0) {
|
|
752
|
+
if (props.shape === "filter") {
|
|
753
|
+
return "";
|
|
751
754
|
} else {
|
|
752
|
-
|
|
755
|
+
return false;
|
|
753
756
|
}
|
|
754
757
|
}
|
|
755
|
-
return sliced;
|
|
756
|
-
},
|
|
757
|
-
queryWrap: (refs) => refs.scrollbar.$el.querySelector(".tiny-scrollbar__wrap.virtual"),
|
|
758
|
-
queryItems: (refs) => refs.scrollbar.$el.querySelectorAll(".tiny-option.virtual"),
|
|
759
|
-
createMacro: (cb) => setTimeout(cb),
|
|
760
|
-
setScrollTop: ({ refs, state }) => {
|
|
761
|
-
const { optimizeOpts, optimizeStore } = state;
|
|
762
|
-
const { optionHeight } = optimizeOpts;
|
|
763
|
-
const wrap = optmzApis.queryWrap(refs);
|
|
764
|
-
wrap.scrollTop = optionHeight * optimizeStore.valueIndex;
|
|
765
|
-
},
|
|
766
|
-
setValueIndex: ({ props, state }) => state.optimizeStore.valueIndex = optmzApis.getValueIndex(props),
|
|
767
|
-
addScrollListener: ({ api, refs, state }) => {
|
|
768
|
-
const { optimizeStore } = state;
|
|
769
|
-
const wrap = optmzApis.queryWrap(refs);
|
|
770
|
-
!optimizeStore.bind && wrap.addEventListener("scroll", api.getScrollListener) && (optimizeStore.bind = true);
|
|
771
|
-
},
|
|
772
|
-
removeScrollListener: ({ api, refs, state }) => {
|
|
773
|
-
const { optimizeStore } = state;
|
|
774
|
-
const wrap = optmzApis.queryWrap(refs);
|
|
775
|
-
optimizeStore.bind && wrap.removeEventListener("scroll", api.getScrollListener) && (optimizeStore.bind = false);
|
|
776
|
-
},
|
|
777
|
-
isFirstPage: ({ props, state }) => {
|
|
778
|
-
const { optimizeStore } = state;
|
|
779
|
-
const { datas } = optimizeStore;
|
|
780
|
-
const { options } = props;
|
|
781
|
-
return Array.isArray(datas) && Array.isArray(options) && datas[0] === options[0];
|
|
782
|
-
},
|
|
783
|
-
natural: (val) => val < 0 ? 0 : val,
|
|
784
|
-
updateItems: ({ refs, state, itemFn }) => {
|
|
785
|
-
const { optimizeOpts } = state;
|
|
786
|
-
const { optionHeight } = optimizeOpts;
|
|
787
|
-
const items = optmzApis.queryItems(refs);
|
|
788
|
-
for (let i = 0; i < items.length; i++) {
|
|
789
|
-
const item = items[i];
|
|
790
|
-
const flag = item.classList.contains("virtual-hidden");
|
|
791
|
-
item.style.top = flag ? `-${optionHeight}px` : `${itemFn(i)}px`;
|
|
792
|
-
}
|
|
793
|
-
},
|
|
794
|
-
process: ({ props, start, state }) => {
|
|
795
|
-
const { optimizeStore } = state;
|
|
796
|
-
optimizeStore.startIndex = typeof start !== "undefined" ? start : optmzApis.getStartIndex({ props, state });
|
|
797
|
-
optimizeStore.datas = optmzApis.getStoreDatas({ props, state });
|
|
798
|
-
optimizeStore.firstPage = optmzApis.isFirstPage({ props, state });
|
|
799
758
|
}
|
|
759
|
+
return null;
|
|
800
760
|
};
|
|
801
|
-
const watchValue = ({ api, constants, dispatch, props,
|
|
761
|
+
const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, oldValue) => {
|
|
802
762
|
if (props.multiple) {
|
|
803
763
|
api.resetInputHeight();
|
|
804
|
-
if (value && value.length > 0 || refs.input && state.query !== "") {
|
|
764
|
+
if (value && value.length > 0 || vm.$refs.input && state.query !== "") {
|
|
805
765
|
state.currentPlaceholder = "";
|
|
806
766
|
} else {
|
|
807
767
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
@@ -812,6 +772,8 @@ const watchValue = ({ api, constants, dispatch, props, refs, state }) => (value,
|
|
|
812
772
|
}
|
|
813
773
|
}
|
|
814
774
|
api.setSelected();
|
|
775
|
+
!state.isClickChoose && api.initQuery({ init: true }).then(() => api.setSelected());
|
|
776
|
+
state.isClickChoose = false;
|
|
815
777
|
if (props.filterable && !props.multiple) {
|
|
816
778
|
state.inputLength = 20;
|
|
817
779
|
}
|
|
@@ -820,41 +782,41 @@ const watchValue = ({ api, constants, dispatch, props, refs, state }) => (value,
|
|
|
820
782
|
}
|
|
821
783
|
state.optimizeStore.flag && optmzApis.setValueIndex({ props, state });
|
|
822
784
|
};
|
|
823
|
-
const calcOverFlow = ({
|
|
824
|
-
if (
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
break;
|
|
785
|
+
const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
786
|
+
if (props.multiple && props.showOverflowTooltip) {
|
|
787
|
+
state.overflow = false;
|
|
788
|
+
const tagDom = vm.$refs.tags;
|
|
789
|
+
const tags = tagDom.querySelectorAll(".tiny-tag");
|
|
790
|
+
if (tags.length) {
|
|
791
|
+
tagDom.scrollTo && tagDom.scrollTo({ top: 0 });
|
|
792
|
+
let { x, width } = tags[0].getBoundingClientRect();
|
|
793
|
+
if (width >= tagDom.getBoundingClientRect().width) {
|
|
794
|
+
state.overflow = 0;
|
|
795
|
+
} else {
|
|
796
|
+
for (let i = 1; i < tags.length; i++) {
|
|
797
|
+
let tx = tags[i].getBoundingClientRect().x;
|
|
798
|
+
if (tx == x) {
|
|
799
|
+
state.overflow = i - 1;
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
841
802
|
}
|
|
842
803
|
}
|
|
843
804
|
}
|
|
805
|
+
vm.$refs.select.style.height = vm.$refs.select.style.height || height;
|
|
806
|
+
vm.$refs.reference.$el.style.position = "absolute";
|
|
807
|
+
const inputWidth = vm.$refs.select.getBoundingClientRect().width;
|
|
808
|
+
const position = state.visible ? "absolute" : "";
|
|
809
|
+
state.selectFiexd = {
|
|
810
|
+
height,
|
|
811
|
+
position,
|
|
812
|
+
width: inputWidth + "px",
|
|
813
|
+
zIndex: PopupManager.nextZIndex()
|
|
814
|
+
};
|
|
815
|
+
state.inputWidth = inputWidth;
|
|
844
816
|
}
|
|
845
|
-
refs.select.style.height = refs.select.style.height || height;
|
|
846
|
-
refs.reference.$el.style.position = "absolute";
|
|
847
|
-
const inputWidth = refs.select.getBoundingClientRect().width;
|
|
848
|
-
const position = state.visible ? "absolute" : "";
|
|
849
|
-
state.selectFiexd = {
|
|
850
|
-
height,
|
|
851
|
-
position,
|
|
852
|
-
width: inputWidth + "px",
|
|
853
|
-
zIndex: PopupManager.nextZIndex()
|
|
854
|
-
};
|
|
855
|
-
state.inputWidth = inputWidth;
|
|
856
817
|
};
|
|
857
818
|
const postOperOfToVisible = ({ props, state, constants }) => {
|
|
819
|
+
var _a;
|
|
858
820
|
if (props.multiple) {
|
|
859
821
|
return;
|
|
860
822
|
}
|
|
@@ -865,7 +827,7 @@ const postOperOfToVisible = ({ props, state, constants }) => {
|
|
|
865
827
|
if (props.filterable && props.allowCreate && state.createdSelected && state.createdLabel) {
|
|
866
828
|
state.selectedLabel = state.createdLabel;
|
|
867
829
|
} else {
|
|
868
|
-
state.selectedLabel = state.selected.state.currentLabel || state.selected.currentLabel;
|
|
830
|
+
state.selectedLabel = ((_a = state.selected.state) == null ? void 0 : _a.currentLabel) || state.selected.currentLabel;
|
|
869
831
|
}
|
|
870
832
|
if (props.filterable) {
|
|
871
833
|
state.query = state.selectedLabel;
|
|
@@ -878,69 +840,92 @@ const postOperOfToVisible = ({ props, state, constants }) => {
|
|
|
878
840
|
};
|
|
879
841
|
const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
880
842
|
var _a;
|
|
881
|
-
const refs = vm.$refs;
|
|
882
843
|
state.selectEmitter.emit(constants.EVENT_NAME.destroyPopper);
|
|
883
844
|
props.remote && props.dropOnlySearch && (state.showWarper = false);
|
|
884
|
-
(_a = refs.input) == null ? void 0 : _a.blur();
|
|
845
|
+
(_a = vm.$refs.input) == null ? void 0 : _a.blur();
|
|
885
846
|
state.query = "";
|
|
886
847
|
state.selectedLabel = "";
|
|
887
848
|
state.inputLength = 20;
|
|
849
|
+
state.previousQuery !== state.query && api.initQuery().then(() => api.setSelected());
|
|
888
850
|
if (props.renderType !== constants.TYPE.Tree) {
|
|
889
851
|
state.previousQuery = props.remoteConfig.clearData && state.previousQuery !== state.query ? void 0 : null;
|
|
890
852
|
}
|
|
891
853
|
api.resetHoverIndex();
|
|
892
854
|
nextTick(() => {
|
|
893
|
-
if (refs.input && refs.input.value === "" && state.selected.length === 0) {
|
|
855
|
+
if (vm.$refs.input && vm.$refs.input.value === "" && state.selected.length === 0) {
|
|
894
856
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
895
857
|
}
|
|
896
|
-
if (refs.selectGrid) {
|
|
897
|
-
refs.selectGrid.clearScroll();
|
|
858
|
+
if (vm.$refs.selectGrid) {
|
|
859
|
+
vm.$refs.selectGrid.clearScroll();
|
|
898
860
|
}
|
|
899
861
|
});
|
|
900
862
|
postOperOfToVisible({ props, state, constants });
|
|
901
863
|
};
|
|
902
864
|
const toHide = ({ constants, state, props, vm, api }) => () => {
|
|
903
865
|
var _a, _b;
|
|
904
|
-
const refs = vm.$refs;
|
|
905
866
|
state.selectEmitter.emit(constants.COMPONENT_NAME.SelectDropdown, constants.EVENT_NAME.updatePopper);
|
|
906
867
|
if (state.filterOrSearch) {
|
|
907
|
-
state.query = props.remote || props.
|
|
868
|
+
state.query = props.remote || props.shape ? "" : props.renderType !== constants.TYPE.Tree ? state.selectedLabel : "";
|
|
908
869
|
state.previousQuery !== state.query && api.handleQueryChange(state.query);
|
|
909
870
|
if (props.multiple) {
|
|
910
|
-
props.filterable ? (_a = refs.input) == null ? void 0 : _a.focus() : (_b = refs.reference) == null ? void 0 : _b.focus();
|
|
871
|
+
props.filterable ? (_a = vm.$refs.input) == null ? void 0 : _a.focus() : (_b = vm.$refs.reference) == null ? void 0 : _b.focus();
|
|
911
872
|
} else {
|
|
912
873
|
if (!props.remote) {
|
|
913
874
|
state.selectEmitter.emit(constants.EVENT_NAME.queryChange, "");
|
|
914
875
|
state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup, constants.EVENT_NAME.queryChange);
|
|
915
876
|
}
|
|
916
|
-
if (state.selectedLabel) {
|
|
877
|
+
if (state.selectedLabel && !props.shape) {
|
|
917
878
|
state.currentPlaceholder = state.selectedLabel;
|
|
918
879
|
state.selectedLabel = "";
|
|
919
880
|
}
|
|
920
881
|
}
|
|
921
882
|
}
|
|
922
|
-
if (refs.selectGrid) {
|
|
923
|
-
refs.selectGrid.
|
|
924
|
-
|
|
883
|
+
if (vm.$refs.selectGrid) {
|
|
884
|
+
let { fullData } = vm.$refs.selectGrid.getTableData();
|
|
885
|
+
if (props.multiple) {
|
|
886
|
+
const selectedIds = state.selected.map((sel) => sel[props.valueField]);
|
|
887
|
+
vm.$refs.selectGrid.clearSelection();
|
|
888
|
+
vm.$refs.selectGrid.setSelection(
|
|
889
|
+
fullData.filter((row) => ~selectedIds.indexOf(row[props.valueField])),
|
|
890
|
+
true
|
|
891
|
+
);
|
|
892
|
+
} else {
|
|
893
|
+
vm.$refs.selectGrid.clearRadioRow();
|
|
894
|
+
vm.$refs.selectGrid.setRadioRow(find(fullData, (item) => props.modelValue == item[props.valueField]));
|
|
895
|
+
}
|
|
925
896
|
if (state.filterOrSearch && typeof props.filterMethod === "function") {
|
|
926
|
-
refs.selectGrid.handleTableData(true);
|
|
927
|
-
} else if (state.filterOrSearch && props.remote && typeof props.remoteMethod === "function") {
|
|
928
|
-
refs.selectGrid.handleTableData();
|
|
897
|
+
vm.$refs.selectGrid.handleTableData(true);
|
|
898
|
+
} else if (state.filterOrSearch && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
899
|
+
vm.$refs.selectGrid.handleTableData();
|
|
929
900
|
}
|
|
930
901
|
}
|
|
931
902
|
};
|
|
932
|
-
const watchVisible = ({ api, constants, emit, state,
|
|
903
|
+
const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) => {
|
|
904
|
+
var _a;
|
|
905
|
+
if ((state.filterOrSearch || props.remote) && !value) {
|
|
906
|
+
(_a = vm.$refs.reference) == null ? void 0 : _a.blur();
|
|
907
|
+
}
|
|
933
908
|
if (api.onCopying()) {
|
|
934
909
|
return;
|
|
935
910
|
}
|
|
911
|
+
setTimeout(() => {
|
|
912
|
+
if (!value && !state.selectedLabel) {
|
|
913
|
+
state.cachedOptions.forEach((item) => {
|
|
914
|
+
item.state.visible = true;
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
}, 200);
|
|
936
918
|
value ? api.toHide() : api.toVisible();
|
|
937
919
|
emit(constants.EVENT_NAME.visibleChange, value);
|
|
938
920
|
setTimeout(() => {
|
|
939
921
|
state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
|
|
940
|
-
});
|
|
922
|
+
}, props.updateDelay);
|
|
923
|
+
if (!value && props.shape === "filter") {
|
|
924
|
+
state.softFocus = false;
|
|
925
|
+
}
|
|
941
926
|
if (value && state.optimizeStore.flag) {
|
|
942
927
|
optmzApis.createMacro(() => {
|
|
943
|
-
optmzApis.setScrollTop({ refs, state });
|
|
928
|
+
optmzApis.setScrollTop({ refs: vm.$refs, state });
|
|
944
929
|
api.getScrollListener();
|
|
945
930
|
});
|
|
946
931
|
}
|
|
@@ -960,7 +945,7 @@ const watchOptions = ({ api, constants, nextTick, parent, props, state }) => ()
|
|
|
960
945
|
api.setSelected();
|
|
961
946
|
}
|
|
962
947
|
});
|
|
963
|
-
if (props.defaultFirstOption && (props.
|
|
948
|
+
if (props.defaultFirstOption && (props.filterable || props.searchable || props.remote) && state.filteredOptionsCount) {
|
|
964
949
|
api.checkDefaultFirstOption();
|
|
965
950
|
}
|
|
966
951
|
};
|
|
@@ -975,7 +960,7 @@ const handleCopyClick = ({ parent, props, state }) => () => {
|
|
|
975
960
|
document.execCommand("copy");
|
|
976
961
|
parent.$el.removeChild(input);
|
|
977
962
|
};
|
|
978
|
-
const selectChange = ({ emit, props, state }) => ({ $table, selection, checked, row }) => {
|
|
963
|
+
const selectChange = ({ emit, props, state, api }) => ({ $table, selection, checked, row }) => {
|
|
979
964
|
const { textField, valueField } = props;
|
|
980
965
|
const remoteItem = (row2) => {
|
|
981
966
|
const removeItem = find(state.selected, (item) => item[valueField] === row2[valueField]);
|
|
@@ -986,10 +971,10 @@ const selectChange = ({ emit, props, state }) => ({ $table, selection, checked,
|
|
|
986
971
|
} else {
|
|
987
972
|
checked ? state.selected = state.selected.concat(
|
|
988
973
|
selection.filter((row2) => !~props.modelValue.indexOf(row2[valueField]))
|
|
989
|
-
) : $table.
|
|
974
|
+
) : $table.tableFullData.forEach((row2) => remoteItem(row2));
|
|
990
975
|
}
|
|
991
976
|
const keys = state.selected.map((item) => item[valueField]);
|
|
992
|
-
|
|
977
|
+
api.updateModelValue(keys);
|
|
993
978
|
emit("change", keys, state.selected);
|
|
994
979
|
};
|
|
995
980
|
const getcheckedData = ({ props, state }) => () => {
|
|
@@ -1003,13 +988,13 @@ const getcheckedData = ({ props, state }) => () => {
|
|
|
1003
988
|
return checkedKey;
|
|
1004
989
|
}
|
|
1005
990
|
};
|
|
1006
|
-
const radioChange = ({ emit, props, state }) => ({ row }) => {
|
|
991
|
+
const radioChange = ({ emit, props, state, api }) => ({ row }) => {
|
|
1007
992
|
row.value = row[props.valueField];
|
|
1008
993
|
row.currentLabel = row[props.textField];
|
|
1009
994
|
state.selected = row;
|
|
1010
995
|
state.visible = false;
|
|
1011
996
|
state.currentKey = row[props.valueField];
|
|
1012
|
-
|
|
997
|
+
api.updateModelValue(row.value);
|
|
1013
998
|
emit("change", row);
|
|
1014
999
|
};
|
|
1015
1000
|
const getTreeData = (props) => (data) => {
|
|
@@ -1026,22 +1011,32 @@ const getTreeData = (props) => (data) => {
|
|
|
1026
1011
|
getChild(data, null);
|
|
1027
1012
|
return nodes;
|
|
1028
1013
|
};
|
|
1029
|
-
const treeNodeClick = ({ emit, props, state }) => (data) => {
|
|
1014
|
+
const treeNodeClick = ({ emit, props, state, api, vm }) => (data) => {
|
|
1030
1015
|
if (!props.multiple) {
|
|
1031
1016
|
data.currentLabel = data[props.textField];
|
|
1032
1017
|
data.value = data[props.valueField];
|
|
1033
1018
|
state.selected = data;
|
|
1034
1019
|
state.visible = false;
|
|
1035
|
-
|
|
1020
|
+
api.updateModelValue(data.value);
|
|
1036
1021
|
emit("change", data);
|
|
1022
|
+
} else {
|
|
1023
|
+
if (props.treeOp.checkOnClickNode) {
|
|
1024
|
+
const checkedNodes = vm.$refs.selectTree.getCheckedNodes();
|
|
1025
|
+
const checkedKeys = vm.$refs.selectTree.getCheckedKeys();
|
|
1026
|
+
api.nodeCheckClick(data, { checkedNodes, checkedKeys });
|
|
1027
|
+
}
|
|
1037
1028
|
}
|
|
1038
1029
|
};
|
|
1039
|
-
const nodeCheckClick = ({ emit, props }) => (data, { checkedKeys, checkedNodes }) => {
|
|
1040
|
-
|
|
1030
|
+
const nodeCheckClick = ({ emit, props, state, api }) => (data, { checkedKeys, checkedNodes }) => {
|
|
1031
|
+
const selected = state.selected.map((item) => api.getValueKey(item));
|
|
1032
|
+
if (isEqual(selected, checkedKeys)) {
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
state.selected = checkedNodes.filter((node) => {
|
|
1041
1036
|
node.currentLabel = node[props.textField];
|
|
1042
1037
|
node.value = node[props.valueField];
|
|
1043
1038
|
});
|
|
1044
|
-
|
|
1039
|
+
api.updateModelValue(checkedKeys);
|
|
1045
1040
|
emit("change", checkedKeys, checkedNodes);
|
|
1046
1041
|
};
|
|
1047
1042
|
const nodeCollapse = ({ state, constants }) => () => {
|
|
@@ -1087,11 +1082,23 @@ const watchPropsOption = ({ constants, parent, props, state }) => () => {
|
|
|
1087
1082
|
} else if (renderType === constants.TYPE.Grid) {
|
|
1088
1083
|
state.gridData = data;
|
|
1089
1084
|
} else {
|
|
1085
|
+
let sortData = data.slice();
|
|
1086
|
+
if (props.multiple) {
|
|
1087
|
+
const requiredData = [];
|
|
1088
|
+
sortData = sortData.filter((item) => {
|
|
1089
|
+
if (item.required) {
|
|
1090
|
+
requiredData.push(item);
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1093
|
+
return true;
|
|
1094
|
+
});
|
|
1095
|
+
sortData = requiredData.concat(sortData);
|
|
1096
|
+
}
|
|
1090
1097
|
if (props.cacheOp && props.cacheOp.key) {
|
|
1091
1098
|
state.memorize = new Memorize(props.cacheOp);
|
|
1092
|
-
state.datas = state.memorize.assemble(
|
|
1099
|
+
state.datas = state.memorize.assemble(sortData.slice());
|
|
1093
1100
|
} else {
|
|
1094
|
-
state.datas =
|
|
1101
|
+
state.datas = sortData;
|
|
1095
1102
|
}
|
|
1096
1103
|
}
|
|
1097
1104
|
});
|
|
@@ -1107,19 +1114,23 @@ const buildRadioConfig = ({ props, state }) => () => {
|
|
|
1107
1114
|
const radioConfig = props.radioConfig;
|
|
1108
1115
|
return __spreadValues(__spreadValues({}, radioConfig), { checkRowKey, highlight });
|
|
1109
1116
|
};
|
|
1110
|
-
const onMouseenterNative = ({ state }) => () => {
|
|
1117
|
+
const onMouseenterNative = ({ state }) => (e) => {
|
|
1118
|
+
if (e.target === e.currentTarget)
|
|
1119
|
+
return;
|
|
1111
1120
|
state.inputHovering = true;
|
|
1112
1121
|
if (state.searchSingleCopy && state.selectedLabel) {
|
|
1113
1122
|
state.softFocus = true;
|
|
1114
1123
|
}
|
|
1115
1124
|
};
|
|
1116
|
-
const onMouseleaveNative = ({ state }) => () => {
|
|
1125
|
+
const onMouseleaveNative = ({ state }) => (e) => {
|
|
1126
|
+
if (e.target === e.currentTarget)
|
|
1127
|
+
return;
|
|
1117
1128
|
state.inputHovering = false;
|
|
1118
1129
|
if (state.searchSingleCopy && state.selectedLabel) {
|
|
1119
1130
|
state.softFocus = false;
|
|
1120
1131
|
}
|
|
1121
1132
|
};
|
|
1122
|
-
const onCopying = ({ state,
|
|
1133
|
+
const onCopying = ({ state, vm }) => () => state.searchSingleCopy && state.selectedLabel && vm.$refs.reference && vm.$refs.reference.hasSelection && vm.$refs.reference.hasSelection();
|
|
1123
1134
|
const watchHoverIndex = ({ state }) => (value) => {
|
|
1124
1135
|
if (typeof value === "number" && value > -1) {
|
|
1125
1136
|
state.hoverOption = state.options[value] || {};
|
|
@@ -1130,11 +1141,87 @@ const watchHoverIndex = ({ state }) => (value) => {
|
|
|
1130
1141
|
option.hover = state.hoverOption === option;
|
|
1131
1142
|
});
|
|
1132
1143
|
};
|
|
1133
|
-
const
|
|
1144
|
+
const handleDropdownClick = ({ emit }) => ($event) => {
|
|
1145
|
+
emit("dropdown-click", $event);
|
|
1146
|
+
};
|
|
1147
|
+
const handleEnterTag = ({ state }) => ($event, key) => {
|
|
1148
|
+
const target = $event.target;
|
|
1149
|
+
if (target && target.scrollWidth > target.offsetWidth) {
|
|
1150
|
+
state.tooltipContent = __spreadProps(__spreadValues({}, state.tooltipContent), { [key]: target.innerText });
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
const calcCollapseTags = ({ state, vm }) => () => {
|
|
1154
|
+
if (state.inputHovering) {
|
|
1155
|
+
return state.isHidden = true;
|
|
1156
|
+
}
|
|
1157
|
+
const tags = vm.$refs.tags;
|
|
1158
|
+
if (!tags) {
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
const { width: tagsContentWidth, paddingLeft, paddingRight } = window.getComputedStyle(tags);
|
|
1162
|
+
const tagsWidth = parseFloat(tagsContentWidth) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
1163
|
+
const collapseTag = tags.querySelector(".tiny-select__tags-collapse");
|
|
1164
|
+
const { width: collapseTagContentWidth, marginRight } = collapseTag && window.getComputedStyle(collapseTag);
|
|
1165
|
+
const collapseTagWidth = collapseTag && parseFloat(collapseTagContentWidth) + parseFloat(marginRight);
|
|
1166
|
+
const tagList = Array.from(tags.querySelectorAll(".tiny-tag"));
|
|
1167
|
+
let { total, dom, idx } = { total: collapseTagWidth, dom: null, idx: 0 };
|
|
1168
|
+
tagList.some((tag, index) => {
|
|
1169
|
+
if (tag !== collapseTag) {
|
|
1170
|
+
const { width: tagContentWidth, marginRight: marginRight2 } = tag && window.getComputedStyle(tag);
|
|
1171
|
+
total += parseFloat(tagContentWidth) + parseFloat(marginRight2);
|
|
1172
|
+
}
|
|
1173
|
+
if (tag !== collapseTag && total > tagsWidth && !dom) {
|
|
1174
|
+
dom = tag;
|
|
1175
|
+
idx = index;
|
|
1176
|
+
}
|
|
1177
|
+
});
|
|
1178
|
+
let isOneLine = total - collapseTagWidth <= tagsWidth;
|
|
1179
|
+
if (isOneLine) {
|
|
1180
|
+
return state.isHidden = true;
|
|
1181
|
+
}
|
|
1182
|
+
if (dom) {
|
|
1183
|
+
dom.before(collapseTag);
|
|
1184
|
+
state.isHidden = false;
|
|
1185
|
+
} else {
|
|
1186
|
+
state.isHidden = true;
|
|
1187
|
+
}
|
|
1188
|
+
state.collapseTagsLength = tagList.length - idx;
|
|
1189
|
+
};
|
|
1190
|
+
const watchInputHover = ({ vm }) => (newVal) => {
|
|
1191
|
+
const [inputHovering, visible] = newVal;
|
|
1192
|
+
if (!inputHovering && !visible) {
|
|
1193
|
+
const tags = vm.$refs.tags;
|
|
1194
|
+
const content = vm.$refs["tags-content"];
|
|
1195
|
+
tags && content && tags.scrollTo({ top: content });
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
const initQuery = ({ props, state, constants, vm }) => ({ init } = {}) => {
|
|
1199
|
+
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
1200
|
+
const isGrid = props.renderType === constants.TYPE.Grid;
|
|
1201
|
+
let selected;
|
|
1202
|
+
if (isRemote && isGrid && props.initQuery) {
|
|
1203
|
+
let initData = props.initQuery(props.modelValue, props.extraQueryParams, !!init);
|
|
1204
|
+
if (initData.then) {
|
|
1205
|
+
return new Promise((resolve) => {
|
|
1206
|
+
initData.then((selected2) => {
|
|
1207
|
+
state.remoteData = selected2;
|
|
1208
|
+
vm.$refs.selectGrid.loadData(selected2);
|
|
1209
|
+
resolve(selected2);
|
|
1210
|
+
});
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
selected = initData;
|
|
1214
|
+
state.remoteData = selected;
|
|
1215
|
+
vm.$refs.selectGrid.loadData(selected);
|
|
1216
|
+
}
|
|
1217
|
+
return Promise.resolve(selected);
|
|
1218
|
+
};
|
|
1219
|
+
const mounted = ({ api, parent, state, props, vm }) => () => {
|
|
1134
1220
|
var _a;
|
|
1221
|
+
state.defaultCheckedKeys = state.gridCheckedData;
|
|
1135
1222
|
const parentEl = parent.$el;
|
|
1136
1223
|
const inputEl = parentEl.querySelector("input.tiny-input__inner") || parentEl.querySelector("input.tiny-mobile-input__inner");
|
|
1137
|
-
const inputClientRect = inputEl == null ? void 0 : inputEl.getBoundingClientRect();
|
|
1224
|
+
const inputClientRect = (inputEl == null ? void 0 : inputEl.getBoundingClientRect()) || {};
|
|
1138
1225
|
if (inputEl === document.activeElement) {
|
|
1139
1226
|
(_a = document.activeElement) == null ? void 0 : _a.blur();
|
|
1140
1227
|
}
|
|
@@ -1143,31 +1230,127 @@ const mounted = ({ api, parent, state, props, refs }) => () => {
|
|
|
1143
1230
|
if (props.multiple && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
|
|
1144
1231
|
state.currentPlaceholder = "";
|
|
1145
1232
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
addResizeListener(refs.tags, api.resetInputHeight);
|
|
1151
|
-
}
|
|
1152
|
-
if (props.remote && props.multiple) {
|
|
1153
|
-
api.resetInputHeight();
|
|
1154
|
-
}
|
|
1155
|
-
state.inputWidth = inputClientRect.width;
|
|
1233
|
+
state.initialInputHeight = state.isDisplayOnly ? sizeMap[state.selectSize] : inputClientRect.height || sizeMap[state.selectSize];
|
|
1234
|
+
addResizeListener(parentEl, api.handleResize);
|
|
1235
|
+
if (vm.$refs.tags) {
|
|
1236
|
+
addResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
1156
1237
|
}
|
|
1157
|
-
|
|
1238
|
+
if (props.remote && props.multiple) {
|
|
1239
|
+
api.resetInputHeight();
|
|
1240
|
+
}
|
|
1241
|
+
state.inputWidth = inputClientRect.width;
|
|
1242
|
+
api.initQuery({ init: true }).then(() => api.setSelected());
|
|
1158
1243
|
if (props.dataset) {
|
|
1159
1244
|
api.watchPropsOption();
|
|
1160
1245
|
}
|
|
1161
1246
|
};
|
|
1162
|
-
const unMount = ({ api, parent,
|
|
1247
|
+
const unMount = ({ api, parent, vm, state }) => () => {
|
|
1163
1248
|
if (parent.$el && api.handleResize) {
|
|
1164
1249
|
removeResizeListener(parent.$el, api.handleResize);
|
|
1165
1250
|
}
|
|
1166
|
-
if (refs.tags) {
|
|
1167
|
-
removeResizeListener(refs.tags, api.resetInputHeight);
|
|
1251
|
+
if (vm.$refs.tags) {
|
|
1252
|
+
removeResizeListener(vm.$refs.tags, api.resetInputHeight);
|
|
1168
1253
|
}
|
|
1169
1254
|
state.popperElm = null;
|
|
1170
|
-
state.optimizeStore.flag && optmzApis.removeScrollListener({ api, refs, state });
|
|
1255
|
+
state.optimizeStore.flag && optmzApis.removeScrollListener({ api, refs: vm.$refs, state });
|
|
1256
|
+
};
|
|
1257
|
+
const optmzApis = {
|
|
1258
|
+
exist: (val, multiple) => multiple ? Array.isArray(val) && val.length : val,
|
|
1259
|
+
getValueIndex: (props) => {
|
|
1260
|
+
const { options, valueField, modelValue, multiple } = props;
|
|
1261
|
+
const contain = (val, arr) => Array.isArray(arr) && ~arr.indexOf(val);
|
|
1262
|
+
const equal = (val, opt) => multiple ? contain(opt[valueField], [val]) : opt[valueField] === val;
|
|
1263
|
+
let start = 0;
|
|
1264
|
+
if (optmzApis.exist(modelValue, multiple)) {
|
|
1265
|
+
const lastVal = multiple ? modelValue[modelValue.length - 1] : modelValue;
|
|
1266
|
+
for (let i = 0; i < options.length; i++) {
|
|
1267
|
+
if (!equal(lastVal, options[i])) {
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
return i;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
return start;
|
|
1274
|
+
},
|
|
1275
|
+
getStartIndex: ({ props, state }) => {
|
|
1276
|
+
const { options } = props;
|
|
1277
|
+
const { optimizeOpts, optimizeStore } = state;
|
|
1278
|
+
const { rSize } = optimizeOpts;
|
|
1279
|
+
const { valueIndex } = optimizeStore;
|
|
1280
|
+
return valueIndex + rSize > options.length ? options.length - rSize : valueIndex;
|
|
1281
|
+
},
|
|
1282
|
+
getViewStyle: ({ props, state }) => {
|
|
1283
|
+
const { options } = props;
|
|
1284
|
+
const { optimizeOpts } = state;
|
|
1285
|
+
const { optionHeight } = optimizeOpts;
|
|
1286
|
+
return `height:${optionHeight * options.length}px`;
|
|
1287
|
+
},
|
|
1288
|
+
getStoreDatas: ({ props, state }) => {
|
|
1289
|
+
const { options, valueField, modelValue, multiple } = props;
|
|
1290
|
+
const { datas, optimizeOpts, optimizeStore } = state;
|
|
1291
|
+
const { startIndex } = optimizeStore;
|
|
1292
|
+
const { rSize } = optimizeOpts;
|
|
1293
|
+
const sliced = datas.slice(startIndex, startIndex + rSize);
|
|
1294
|
+
const hiddenOptions = optimizeStore.hiddenOptions = [];
|
|
1295
|
+
const findPush = (val) => {
|
|
1296
|
+
const opt = options.find((option) => option[valueField] === val);
|
|
1297
|
+
if (opt && !~sliced.indexOf(opt)) {
|
|
1298
|
+
sliced.push(opt);
|
|
1299
|
+
hiddenOptions.push(opt);
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
if (optmzApis.exist(modelValue, multiple)) {
|
|
1303
|
+
if (multiple) {
|
|
1304
|
+
modelValue.forEach(findPush);
|
|
1305
|
+
} else {
|
|
1306
|
+
findPush(modelValue);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
return sliced;
|
|
1310
|
+
},
|
|
1311
|
+
queryWrap: (refs) => refs.scrollbar.$el.querySelector(".tiny-scrollbar__wrap.virtual"),
|
|
1312
|
+
queryItems: (refs) => refs.scrollbar.$el.querySelectorAll(".tiny-option.virtual"),
|
|
1313
|
+
createMacro: (cb) => setTimeout(cb),
|
|
1314
|
+
setScrollTop: ({ refs, state }) => {
|
|
1315
|
+
const { optimizeOpts, optimizeStore } = state;
|
|
1316
|
+
const { optionHeight } = optimizeOpts;
|
|
1317
|
+
const wrap = optmzApis.queryWrap(refs);
|
|
1318
|
+
wrap.scrollTop = optionHeight * optimizeStore.valueIndex;
|
|
1319
|
+
},
|
|
1320
|
+
setValueIndex: ({ props, state }) => state.optimizeStore.valueIndex = optmzApis.getValueIndex(props),
|
|
1321
|
+
addScrollListener: ({ api, refs, state }) => {
|
|
1322
|
+
const { optimizeStore } = state;
|
|
1323
|
+
const wrap = optmzApis.queryWrap(refs);
|
|
1324
|
+
!optimizeStore.bind && wrap.addEventListener("scroll", api.getScrollListener) && (optimizeStore.bind = true);
|
|
1325
|
+
},
|
|
1326
|
+
removeScrollListener: ({ api, refs, state }) => {
|
|
1327
|
+
const { optimizeStore } = state;
|
|
1328
|
+
const wrap = optmzApis.queryWrap(refs);
|
|
1329
|
+
optimizeStore.bind && wrap.removeEventListener("scroll", api.getScrollListener) && (optimizeStore.bind = false);
|
|
1330
|
+
},
|
|
1331
|
+
isFirstPage: ({ props, state }) => {
|
|
1332
|
+
const { optimizeStore } = state;
|
|
1333
|
+
const { datas } = optimizeStore;
|
|
1334
|
+
const { options } = props;
|
|
1335
|
+
return Array.isArray(datas) && Array.isArray(options) && datas[0] === options[0];
|
|
1336
|
+
},
|
|
1337
|
+
natural: (val) => val < 0 ? 0 : val,
|
|
1338
|
+
updateItems: ({ refs, state, itemFn }) => {
|
|
1339
|
+
const { optimizeOpts } = state;
|
|
1340
|
+
const { optionHeight } = optimizeOpts;
|
|
1341
|
+
const items = optmzApis.queryItems(refs);
|
|
1342
|
+
for (let i = 0; i < items.length; i++) {
|
|
1343
|
+
const item = items[i];
|
|
1344
|
+
const flag = item.classList.contains("virtual-hidden");
|
|
1345
|
+
item.style.top = flag ? `-${optionHeight}px` : `${itemFn(i)}px`;
|
|
1346
|
+
}
|
|
1347
|
+
},
|
|
1348
|
+
process: ({ props, start, state }) => {
|
|
1349
|
+
const { optimizeStore } = state;
|
|
1350
|
+
optimizeStore.startIndex = typeof start !== "undefined" ? start : optmzApis.getStartIndex({ props, state });
|
|
1351
|
+
optimizeStore.datas = optmzApis.getStoreDatas({ props, state });
|
|
1352
|
+
optimizeStore.firstPage = optmzApis.isFirstPage({ props, state });
|
|
1353
|
+
}
|
|
1171
1354
|
};
|
|
1172
1355
|
const computeOptimizeOpts = ({ props, state }) => () => {
|
|
1173
1356
|
const { optimization } = props;
|
|
@@ -1183,7 +1366,7 @@ const computeOptimizeOpts = ({ props, state }) => () => {
|
|
|
1183
1366
|
return optOpts;
|
|
1184
1367
|
}
|
|
1185
1368
|
};
|
|
1186
|
-
const watchOptimizeOpts = ({ api, props,
|
|
1369
|
+
const watchOptimizeOpts = ({ api, props, vm, state }) => () => {
|
|
1187
1370
|
const { optimizeOpts, optimizeStore } = state;
|
|
1188
1371
|
if (optimizeOpts) {
|
|
1189
1372
|
const { virtualScroll, optionHeight } = optimizeOpts;
|
|
@@ -1194,26 +1377,26 @@ const watchOptimizeOpts = ({ api, props, refs, state }) => () => {
|
|
|
1194
1377
|
optmzApis.process({ props, state });
|
|
1195
1378
|
optmzApis.createMacro(() => {
|
|
1196
1379
|
const itemFn = (i) => optionHeight * (optimizeStore.startIndex + i);
|
|
1197
|
-
optmzApis.addScrollListener({ api, refs, state });
|
|
1198
|
-
optmzApis.updateItems({ refs, state, itemFn });
|
|
1380
|
+
optmzApis.addScrollListener({ api, refs: vm.$refs, state });
|
|
1381
|
+
optmzApis.updateItems({ refs: vm.$refs, state, itemFn });
|
|
1199
1382
|
});
|
|
1200
1383
|
}
|
|
1201
1384
|
}
|
|
1202
1385
|
};
|
|
1203
|
-
const getScrollListener = ({ props,
|
|
1386
|
+
const getScrollListener = ({ props, vm, state }) => {
|
|
1204
1387
|
const listener = () => {
|
|
1205
1388
|
const { options } = props;
|
|
1206
1389
|
const { optimizeOpts } = state;
|
|
1207
1390
|
const { optionHeight } = optimizeOpts;
|
|
1208
1391
|
const viewHeight = optionHeight * options.length;
|
|
1209
|
-
const { clientHeight, scrollTop } = optmzApis.queryWrap(refs);
|
|
1392
|
+
const { clientHeight, scrollTop } = optmzApis.queryWrap(vm.$refs);
|
|
1210
1393
|
const maxScrollTop = viewHeight - clientHeight;
|
|
1211
1394
|
const start = Math.floor(scrollTop / optionHeight);
|
|
1212
1395
|
if (scrollTop <= maxScrollTop) {
|
|
1213
1396
|
optmzApis.process({ props, start, state });
|
|
1214
1397
|
optmzApis.createMacro(() => {
|
|
1215
1398
|
const itemFn = (i) => scrollTop + optionHeight * i - scrollTop % optionHeight;
|
|
1216
|
-
optmzApis.updateItems({ refs, state, itemFn });
|
|
1399
|
+
optmzApis.updateItems({ refs: vm.$refs, state, itemFn });
|
|
1217
1400
|
});
|
|
1218
1401
|
}
|
|
1219
1402
|
};
|
|
@@ -1227,19 +1410,118 @@ const computeMultipleLimit = ({ props, state }) => () => {
|
|
|
1227
1410
|
const { optimizeOpts, optimizeStore } = state;
|
|
1228
1411
|
return optmzApis.natural(multiple && optimizeStore.flag ? multipleLimit || optimizeOpts.limit : multipleLimit);
|
|
1229
1412
|
};
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1413
|
+
const updateModelValue = ({ emit, state }) => (value) => {
|
|
1414
|
+
state.isClickChoose = true;
|
|
1415
|
+
emit("update:modelValue", value);
|
|
1416
|
+
};
|
|
1417
|
+
const getLabelSlotValue = ({ props, state }) => (item) => {
|
|
1418
|
+
const datas = state.optimizeStore.flag ? state.optimizeStore.datas : state.datas;
|
|
1419
|
+
const value = item.state ? item.state.currentValue : item.value;
|
|
1420
|
+
const data = datas.find((data2) => data2.value === value);
|
|
1421
|
+
const obj = __spreadProps(__spreadValues({}, data), {
|
|
1422
|
+
label: item.state ? item.state.currentLabel : item.currentLabel,
|
|
1423
|
+
value
|
|
1424
|
+
});
|
|
1425
|
+
return ["grid", "tree"].includes(props.renderType) ? item : obj;
|
|
1426
|
+
};
|
|
1427
|
+
const computedTagsStyle = ({ props, parent, state }) => () => {
|
|
1428
|
+
const isReadonly = props.disabled || (parent.form || {}).disabled || props.displayOnly;
|
|
1429
|
+
return {
|
|
1430
|
+
"max-width": isReadonly ? "" : state.inputWidth - state.inputPaddingRight + "px",
|
|
1431
|
+
width: "100%"
|
|
1432
|
+
};
|
|
1433
|
+
};
|
|
1434
|
+
const computedReadonly = ({ props, state }) => () => props.readonly || !props.filterable || props.multiple || browserInfo.name !== BROWSER_NAME.IE && browserInfo.name !== BROWSER_NAME.Edge && !state.visible;
|
|
1435
|
+
const computedShowClose = ({ props, state }) => () => props.clearable && !state.selectDisabled && state.inputHovering && (props.multiple ? Array.isArray(props.modelValue) && props.modelValue.length > 0 : !isNull(props.modelValue) && props.modelValue !== "");
|
|
1436
|
+
const computedCollapseTagSize = (state) => () => state.selectSize;
|
|
1437
|
+
const computedShowNewOption = ({ props, state }) => () => props.filterable && props.allowCreate && state.query !== "" && !state.options.filter((option) => !option.created).some((option) => option.state.currentLabel === state.query);
|
|
1438
|
+
const computedShowCopy = ({ props, state }) => () => props.multiple && props.copyable && state.inputHovering && state.selected.length;
|
|
1439
|
+
const computedOptionsAllDisabled = (state) => () => state.options.filter((option) => option.visible).every((option) => option.disabled);
|
|
1440
|
+
const computedDisabledTooltipContent = (state) => () => state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join("\uFF1B");
|
|
1441
|
+
const computedSelectDisabled = ({ props, parent }) => () => props.disabled || (parent.form || {}).disabled || props.displayOnly || (parent.form || {}).displayOnly;
|
|
1442
|
+
const computedIsExpandAll = (props) => () => {
|
|
1443
|
+
const { defaultExpandAll, lazy } = props.treeOp;
|
|
1444
|
+
return !lazy && defaultExpandAll !== false;
|
|
1445
|
+
};
|
|
1446
|
+
const loadTreeData = ({ state, vm, props, api }) => ({ data = [], init = false }) => {
|
|
1447
|
+
const getTreeDatas = (datas, newDatas = []) => {
|
|
1448
|
+
datas.forEach(({ data: data2, childNodes }) => {
|
|
1449
|
+
let temData = __spreadProps(__spreadValues({}, data2), { children: [] });
|
|
1450
|
+
if (childNodes && childNodes.length) {
|
|
1451
|
+
getTreeDatas(childNodes, temData.children);
|
|
1452
|
+
}
|
|
1453
|
+
newDatas.push(temData);
|
|
1454
|
+
});
|
|
1455
|
+
};
|
|
1456
|
+
if (init) {
|
|
1457
|
+
state.treeData = data;
|
|
1458
|
+
} else if (vm.$refs.selectTree) {
|
|
1459
|
+
const treeData = [];
|
|
1460
|
+
getTreeDatas(vm.$refs.selectTree.state.root.childNodes, treeData);
|
|
1461
|
+
state.treeData = treeData;
|
|
1462
|
+
const { multiple, treeOp } = props;
|
|
1463
|
+
if (multiple && treeOp.lazy) {
|
|
1464
|
+
const checkedNodes = vm.$refs.selectTree.getCheckedNodes();
|
|
1465
|
+
const checkedKeys = vm.$refs.selectTree.getCheckedKeys();
|
|
1466
|
+
api.nodeCheckClick(null, { checkedNodes, checkedKeys });
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
};
|
|
1470
|
+
const watchInitValue = ({ props, emit }) => (value) => {
|
|
1471
|
+
if (props.multiple) {
|
|
1472
|
+
let modelValue = props.modelValue.slice();
|
|
1473
|
+
value.forEach((val) => {
|
|
1474
|
+
modelValue = modelValue.filter((item) => item !== val);
|
|
1475
|
+
});
|
|
1476
|
+
emit("update:modelValue", value.concat(modelValue));
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
const watchShowClose = ({ nextTick, state, parent }) => () => {
|
|
1480
|
+
nextTick(() => {
|
|
1481
|
+
const parentEl = parent.$el;
|
|
1482
|
+
const inputEl = parentEl.querySelector("input.tiny-input__inner");
|
|
1483
|
+
if (inputEl) {
|
|
1484
|
+
const { paddingRight } = getComputedStyle(inputEl);
|
|
1485
|
+
state.inputPaddingRight = parseFloat(paddingRight);
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
};
|
|
1489
|
+
const computedGetIcon = ({ constants, designConfig, props }) => (name) => {
|
|
1490
|
+
return props.dropdownIcon || (designConfig == null ? void 0 : designConfig.icons[name]) || (constants == null ? void 0 : constants.ICON_MAP[name]);
|
|
1491
|
+
};
|
|
1492
|
+
const computedGetTagType = ({ designConfig, props }) => () => {
|
|
1493
|
+
var _a;
|
|
1494
|
+
if (((_a = designConfig == null ? void 0 : designConfig.props) == null ? void 0 : _a.tagType) && !props.tagType) {
|
|
1495
|
+
return designConfig.props.tagType;
|
|
1496
|
+
}
|
|
1497
|
+
return props.tagType;
|
|
1498
|
+
};
|
|
1499
|
+
const computedShowDropdownIcon = ({ props, state }) => () => {
|
|
1500
|
+
return !state.showClose && !(props.remote && props.filterable && !props.remoteConfig.showIcon);
|
|
1232
1501
|
};
|
|
1233
1502
|
export {
|
|
1234
1503
|
blur,
|
|
1235
1504
|
buildRadioConfig,
|
|
1236
1505
|
buildSelectConfig,
|
|
1506
|
+
calcCollapseTags,
|
|
1237
1507
|
calcOverFlow,
|
|
1238
1508
|
checkDefaultFirstOption,
|
|
1239
1509
|
computeCollapseTags,
|
|
1240
1510
|
computeMultipleLimit,
|
|
1241
1511
|
computeOptimizeOpts,
|
|
1512
|
+
computedCollapseTagSize,
|
|
1513
|
+
computedDisabledTooltipContent,
|
|
1242
1514
|
computedGetIcon,
|
|
1515
|
+
computedGetTagType,
|
|
1516
|
+
computedIsExpandAll,
|
|
1517
|
+
computedOptionsAllDisabled,
|
|
1518
|
+
computedReadonly,
|
|
1519
|
+
computedSelectDisabled,
|
|
1520
|
+
computedShowClose,
|
|
1521
|
+
computedShowCopy,
|
|
1522
|
+
computedShowDropdownIcon,
|
|
1523
|
+
computedShowNewOption,
|
|
1524
|
+
computedTagsStyle,
|
|
1243
1525
|
debouncRquest,
|
|
1244
1526
|
defaultOnQueryChange,
|
|
1245
1527
|
deletePrevTag,
|
|
@@ -1250,6 +1532,7 @@ export {
|
|
|
1250
1532
|
emptyText,
|
|
1251
1533
|
focus,
|
|
1252
1534
|
getChildValue,
|
|
1535
|
+
getLabelSlotValue,
|
|
1253
1536
|
getOption,
|
|
1254
1537
|
getPluginOption,
|
|
1255
1538
|
getScrollListener,
|
|
@@ -1263,11 +1546,16 @@ export {
|
|
|
1263
1546
|
handleClose,
|
|
1264
1547
|
handleComposition,
|
|
1265
1548
|
handleCopyClick,
|
|
1549
|
+
handleDropdownClick,
|
|
1550
|
+
handleEnterTag,
|
|
1266
1551
|
handleFocus,
|
|
1267
1552
|
handleMenuEnter,
|
|
1268
1553
|
handleOptionSelect,
|
|
1269
1554
|
handleQueryChange,
|
|
1270
1555
|
handleResize,
|
|
1556
|
+
initQuery,
|
|
1557
|
+
initValue,
|
|
1558
|
+
loadTreeData,
|
|
1271
1559
|
managePlaceholder,
|
|
1272
1560
|
mounted,
|
|
1273
1561
|
navigateOptions,
|
|
@@ -1298,10 +1586,14 @@ export {
|
|
|
1298
1586
|
toggleMenu,
|
|
1299
1587
|
treeNodeClick,
|
|
1300
1588
|
unMount,
|
|
1589
|
+
updateModelValue,
|
|
1301
1590
|
watchHoverIndex,
|
|
1591
|
+
watchInitValue,
|
|
1592
|
+
watchInputHover,
|
|
1302
1593
|
watchOptimizeOpts,
|
|
1303
1594
|
watchOptions,
|
|
1304
1595
|
watchPropsOption,
|
|
1596
|
+
watchShowClose,
|
|
1305
1597
|
watchValue,
|
|
1306
1598
|
watchVisible
|
|
1307
1599
|
};
|