@opentiny/vue-renderless 3.16.1 → 3.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action-sheet/index.js +0 -1
- package/base-select/index.js +1510 -0
- package/base-select/vue.js +555 -0
- package/breadcrumb-item/vue.js +4 -2
- package/card/index.js +15 -0
- package/card/vue.js +6 -3
- package/carousel/index.js +89 -17
- package/carousel/vue.js +29 -24
- package/carousel-item/index.js +24 -9
- package/carousel-item/vue.js +10 -9
- package/cascader/vue.js +2 -1
- package/cascader-panel/index.js +8 -1
- package/cascader-panel/vue.js +1 -1
- package/cascader-select/column-index.js +11 -6
- package/cascader-select/column.js +8 -5
- package/cascader-select/usePicker.js +3 -2
- package/checkbox/index.js +0 -17
- package/checkbox/vue.js +4 -10
- package/collapse-item/vue.js +4 -2
- package/common/deps/clickoutside.js +15 -8
- package/common/deps/popper.js +15 -1
- package/common/deps/throttle.js +7 -0
- package/common/deps/touch-emulator.js +1 -1
- package/common/deps/tree-model/node.js +1 -0
- package/common/deps/tree-model/tree-store.js +4 -1
- package/common/deps/useEventListener.js +9 -2
- package/common/deps/useInstanceSlots.js +22 -0
- package/common/deps/useRelation.js +72 -0
- package/common/deps/vue-popper.js +1 -0
- package/common/function.js +28 -0
- package/common/index.js +1 -1
- package/common/runtime.js +1 -1
- package/common/type.js +2 -0
- package/dialog-box/index.js +0 -22
- package/dialog-box/vue.js +1 -4
- package/drawer/index.js +28 -29
- package/drawer/vue.js +7 -11
- package/file-upload/index.js +1 -1
- package/fluent-editor/index.js +679 -0
- package/fluent-editor/options.js +234 -0
- package/fluent-editor/vue.js +192 -0
- package/form/index.js +5 -1
- package/grid/utils/column.js +4 -2
- package/grid/utils/common.js +18 -29
- package/grid/utils/event.js +14 -9
- package/guide/index.js +6 -5
- package/guide/vue.js +2 -2
- package/input/index.js +32 -2
- package/input/vue.js +21 -2
- package/nav-menu/index.js +1 -1
- package/numeric/index.js +4 -1
- package/option/vue.js +6 -6
- package/package.json +1 -1
- package/picker/mb.js +6 -1
- package/picker/vue.js +2 -1
- package/select/index.js +65 -40
- package/select/vue.js +1 -1
- package/split/index.js +16 -9
- package/split/vue.js +7 -2
- package/statistic/index.js +7 -0
- package/tabs-mf/index.js +116 -13
- package/tabs-mf/vue-bar.js +6 -0
- package/tabs-mf/vue-nav-item.js +1 -1
- package/tabs-mf/vue.js +42 -7
- package/tag-group/vue.js +7 -1
- package/time/index.js +1 -1
- package/time-line/index.js +2 -2
- package/time-line/vue.js +4 -13
- package/timeline-item/index.js +5 -5
- package/timeline-item/vue.js +13 -6
- package/tree/index.js +29 -2
- package/tree/vue.js +5 -2
- package/tree-node/vue.js +2 -1
- package/types/cascader-menu.type.d.ts +1 -1
- package/types/cascader-node.type.d.ts +1 -1
- package/types/{cascader-panel.type-2bd03be3.d.ts → cascader-panel.type-8f58e628.d.ts} +1 -1
- package/types/cascader-panel.type.d.ts +1 -1
- package/types/cascader.type.d.ts +1 -1
- package/types/collapse-item.type.d.ts +3 -0
- package/types/dialog-box.type.d.ts +2 -6
- package/types/drawer.type.d.ts +29 -34
- package/types/file-upload.type.d.ts +1 -1
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-8e30b25c.d.ts → form.type-33aa784a.d.ts} +4 -0
- package/types/form.type.d.ts +1 -1
- package/types/input.type.d.ts +5 -1
- package/types/ip-address.type.d.ts +1 -6
- package/types/numeric.type.d.ts +1 -0
- package/types/popover.type.d.ts +1 -1
- package/types/search.type.d.ts +1 -3
- package/types/{time-line.type-1b501c41.d.ts → time-line.type-9fb16096.d.ts} +7 -5
- package/types/time-line.type.d.ts +1 -1
- package/types/timeline-item.type.d.ts +1 -1
- package/types/transfer.type.d.ts +3 -3
- package/types/upload-dragger.type.d.ts +1 -1
- package/types/{upload-list.type-02a1effb.d.ts → upload-list.type-023fd6e9.d.ts} +3 -3
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/user/index.js +10 -4
- package/year-table/index.js +5 -3
- package/year-table/vue.js +1 -1
- package/common/deps/letter-only.js +0 -19
- package/common/deps/number-only.js +0 -20
package/input/index.js
CHANGED
|
@@ -77,7 +77,9 @@ const calcTextareaHeight = ({
|
|
|
77
77
|
if (mode === "mobile") {
|
|
78
78
|
height = Math.max(hiddenTextarea.scrollHeight, constants.TEXTAREA_HEIGHT_MOBILE);
|
|
79
79
|
}
|
|
80
|
-
if (boxSizing === STYLE.
|
|
80
|
+
if (boxSizing === STYLE.BorderBox) {
|
|
81
|
+
height = height + borderSize * 2 + paddingSize;
|
|
82
|
+
} else if (boxSizing === STYLE.ContentBox) {
|
|
81
83
|
height = height - paddingSize;
|
|
82
84
|
}
|
|
83
85
|
hiddenTextarea.value = "";
|
|
@@ -265,7 +267,9 @@ const hasSelection = (api) => () => {
|
|
|
265
267
|
return input && input.selectionStart !== input.selectionEnd;
|
|
266
268
|
};
|
|
267
269
|
const handleEnterDisplayOnlyContent = ({ state, props }) => ($event, type) => {
|
|
268
|
-
|
|
270
|
+
if (type === "textarea" && props.popupMore)
|
|
271
|
+
return;
|
|
272
|
+
const target = type === "textarea" ? $event.target.querySelector(".text-box") : $event.target;
|
|
269
273
|
state.displayOnlyTooltip = "";
|
|
270
274
|
if (!target) {
|
|
271
275
|
return;
|
|
@@ -333,6 +337,31 @@ const getDisplayOnlyText = ({ parent, state, props }) => () => {
|
|
|
333
337
|
const showEmptyValue = typeof props.showEmptyValue === "boolean" ? props.showEmptyValue : (parent.tinyForm || {}).showEmptyValue;
|
|
334
338
|
return showEmptyValue ? text : text || "-";
|
|
335
339
|
};
|
|
340
|
+
const setShowMoreBtn = ({ state, vm }) => (init) => {
|
|
341
|
+
if (state.timer)
|
|
342
|
+
clearTimeout(state.timer);
|
|
343
|
+
state.timer = setTimeout(() => {
|
|
344
|
+
const textBox = vm.$refs && vm.$refs.textBox;
|
|
345
|
+
if (!textBox)
|
|
346
|
+
return;
|
|
347
|
+
if (init && textBox.offsetHeight === 0) {
|
|
348
|
+
let textBoxClone = textBox.cloneNode(true);
|
|
349
|
+
textBoxClone.style.visibility = "hidden";
|
|
350
|
+
textBoxClone.style.position = "absolute";
|
|
351
|
+
textBoxClone.style.left = "-9999px";
|
|
352
|
+
document.body.appendChild(textBoxClone);
|
|
353
|
+
if (textBoxClone.scrollHeight > textBoxClone.offsetHeight) {
|
|
354
|
+
state.showMoreBtn = true;
|
|
355
|
+
}
|
|
356
|
+
document.body.removeChild(textBoxClone);
|
|
357
|
+
textBoxClone = null;
|
|
358
|
+
} else if (textBox.scrollHeight > textBox.offsetHeight) {
|
|
359
|
+
state.showMoreBtn = true;
|
|
360
|
+
} else {
|
|
361
|
+
state.showMoreBtn = false;
|
|
362
|
+
}
|
|
363
|
+
}, 100);
|
|
364
|
+
};
|
|
336
365
|
export {
|
|
337
366
|
blur,
|
|
338
367
|
calcIconOffset,
|
|
@@ -362,6 +391,7 @@ export {
|
|
|
362
391
|
select,
|
|
363
392
|
setInputDomValue,
|
|
364
393
|
setNativeInputValue,
|
|
394
|
+
setShowMoreBtn,
|
|
365
395
|
showBox,
|
|
366
396
|
textLength,
|
|
367
397
|
updateIconOffset,
|
package/input/vue.js
CHANGED
|
@@ -34,9 +34,11 @@ import {
|
|
|
34
34
|
inputStyle,
|
|
35
35
|
handleEnterTextarea,
|
|
36
36
|
handleLeaveTextarea,
|
|
37
|
-
getDisplayOnlyText
|
|
37
|
+
getDisplayOnlyText,
|
|
38
|
+
setShowMoreBtn
|
|
38
39
|
} from "./index";
|
|
39
40
|
import useStorageBox from "../tall-storage/vue-storage-box";
|
|
41
|
+
import { on, off } from "../common/deps/dom";
|
|
40
42
|
const api = [
|
|
41
43
|
"blur",
|
|
42
44
|
"showBox",
|
|
@@ -123,6 +125,7 @@ const initState = ({
|
|
|
123
125
|
nativeInputValue: computed(
|
|
124
126
|
() => props.modelValue === null || props.modelValue === void 0 ? "" : String(props.modelValue)
|
|
125
127
|
),
|
|
128
|
+
tooltipConfig: computed(() => parent.tinyForm ? parent.tinyForm.tooltipConfig : {}),
|
|
126
129
|
isWordLimitVisible: computed(
|
|
127
130
|
() => (props.showWordLimit && parent.$attrs.maxlength || props.counter) && (parent.type === "text" || parent.type === "textarea") && !state.inputDisabled && !props.readonly && !props.showPassword
|
|
128
131
|
),
|
|
@@ -130,6 +133,9 @@ const initState = ({
|
|
|
130
133
|
() => (props.displayOnly || (parent.tinyForm || {}).displayOnly) && ["text", "textarea", "password", "number"].includes(props.type)
|
|
131
134
|
),
|
|
132
135
|
displayOnlyTooltip: "",
|
|
136
|
+
showMoreBtn: false,
|
|
137
|
+
showDisplayOnlyBox: false,
|
|
138
|
+
timer: null,
|
|
133
139
|
hiddenPassword: computed(() => api2.hiddenPassword()),
|
|
134
140
|
displayedMaskValue: computed(() => api2.getDisplayedMaskValue()),
|
|
135
141
|
displayOnlyText: computed(() => api2.getDisplayOnlyText())
|
|
@@ -155,6 +161,7 @@ const initApi = ({
|
|
|
155
161
|
showBox: showBox(state),
|
|
156
162
|
clear: clear(emit),
|
|
157
163
|
getInput: getInput(vm),
|
|
164
|
+
setShowMoreBtn: setShowMoreBtn({ state, vm }),
|
|
158
165
|
handleChange: handleChange(emit),
|
|
159
166
|
watchFormSelect: watchFormSelect({ emit, props, state }),
|
|
160
167
|
calcIconOffset: calcIconOffset({ CLASS_PREFIX, parent }),
|
|
@@ -244,6 +251,9 @@ const initWatch = ({
|
|
|
244
251
|
if (props.validateEvent) {
|
|
245
252
|
api2.dispatch(componentName, eventName.change, [value]);
|
|
246
253
|
}
|
|
254
|
+
if (props.type === "textarea" && props.popupMore && state.isDisplayOnly) {
|
|
255
|
+
api2.setShowMoreBtn();
|
|
256
|
+
}
|
|
247
257
|
api2.setInputDomValue();
|
|
248
258
|
}
|
|
249
259
|
);
|
|
@@ -292,7 +302,7 @@ const initWatch = ({
|
|
|
292
302
|
{ immediate: true }
|
|
293
303
|
);
|
|
294
304
|
};
|
|
295
|
-
const renderless = (props, { computed, onMounted, onUpdated, reactive, toRefs, watch, inject }, { vm, refs, parent, emit, constants, nextTick, broadcast, dispatch, mode }) => {
|
|
305
|
+
const renderless = (props, { computed, onMounted, onBeforeUnmount, onUpdated, reactive, toRefs, watch, inject }, { vm, refs, parent, emit, constants, nextTick, broadcast, dispatch, mode }) => {
|
|
296
306
|
const api2 = {};
|
|
297
307
|
const componentName = constants.COMPONENT_NAME.FormItem;
|
|
298
308
|
const eventName = { change: "form.change", blur: "form.blur" };
|
|
@@ -313,6 +323,15 @@ const renderless = (props, { computed, onMounted, onUpdated, reactive, toRefs, w
|
|
|
313
323
|
api2.setInputDomValue();
|
|
314
324
|
dispatch("Select", "input-mounted", vm.$el);
|
|
315
325
|
dispatch("Tooltip", "tooltip-update", vm.$el);
|
|
326
|
+
if (props.type === "textarea" && props.popupMore && state.isDisplayOnly) {
|
|
327
|
+
api2.setShowMoreBtn(true);
|
|
328
|
+
on(window, "resize", api2.setShowMoreBtn);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
onBeforeUnmount(() => {
|
|
332
|
+
if (props.type === "textarea" && props.popupMore && state.isDisplayOnly) {
|
|
333
|
+
off(window, "resize", api2.setShowMoreBtn);
|
|
334
|
+
}
|
|
316
335
|
});
|
|
317
336
|
onUpdated(() => {
|
|
318
337
|
nextTick(api2.updateIconOffset);
|
package/nav-menu/index.js
CHANGED
|
@@ -145,7 +145,7 @@ const mounted = ({
|
|
|
145
145
|
on(window, "resize", api.calcWidth);
|
|
146
146
|
if (router) {
|
|
147
147
|
state.afterEach = () => {
|
|
148
|
-
api.setActiveMenu(api.getSelectedIndex(
|
|
148
|
+
api.setActiveMenu(api.getSelectedIndex(router.currentRoute.path));
|
|
149
149
|
};
|
|
150
150
|
router.afterEach(state.afterEach);
|
|
151
151
|
}
|
package/numeric/index.js
CHANGED
|
@@ -196,6 +196,9 @@ const setCurrentValue = ({
|
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
const handleInput = ({ state, api, emit, props }) => (event) => {
|
|
199
|
+
if (event.isComposing) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
199
202
|
const { fraction } = state.format;
|
|
200
203
|
const emitError = () => {
|
|
201
204
|
if (state.pasting) {
|
|
@@ -206,7 +209,7 @@ const handleInput = ({ state, api, emit, props }) => (event) => {
|
|
|
206
209
|
if (value !== "-" && api.getDecimal(value).isNaN()) {
|
|
207
210
|
emitError();
|
|
208
211
|
if (!(value === "" && props.allowEmpty)) {
|
|
209
|
-
value =
|
|
212
|
+
value = state.lastInput;
|
|
210
213
|
}
|
|
211
214
|
} else {
|
|
212
215
|
value = value.split(".").map((a, i) => {
|
package/option/vue.js
CHANGED
|
@@ -105,16 +105,16 @@ const initOnBeforeUnmount = ({ onBeforeUnmount, props, select, vm, state }) => {
|
|
|
105
105
|
select.onOptionDestroy(select.state.options.findIndex((opt) => opt.state === state));
|
|
106
106
|
});
|
|
107
107
|
};
|
|
108
|
-
const initSelectState = ({ state, select,
|
|
109
|
-
let vm = __spreadProps(__spreadValues({}, props), { state });
|
|
110
|
-
select.state.options.push(
|
|
111
|
-
select.state.cachedOptions.push(
|
|
108
|
+
const initSelectState = ({ state, select, props, toRefs, reactive }) => {
|
|
109
|
+
let vm = reactive(__spreadProps(__spreadValues({}, toRefs(props)), { state }));
|
|
110
|
+
select.state.options.push(vm);
|
|
111
|
+
select.state.cachedOptions.push(vm);
|
|
112
112
|
select.state.optionsIndex++;
|
|
113
113
|
state.index = select.state.optionsIndex;
|
|
114
114
|
select.state.optionsCount++;
|
|
115
115
|
select.state.filteredOptionsCount++;
|
|
116
116
|
};
|
|
117
|
-
const renderless = (props, { computed, onMounted, onBeforeUnmount, reactive, watch, inject, markRaw }, { vm, parent }) => {
|
|
117
|
+
const renderless = (props, { computed, onMounted, onBeforeUnmount, reactive, watch, inject, markRaw, toRefs }, { vm, parent }) => {
|
|
118
118
|
const api2 = {};
|
|
119
119
|
const select = inject("select");
|
|
120
120
|
const constants = select._constants;
|
|
@@ -123,7 +123,7 @@ const renderless = (props, { computed, onMounted, onBeforeUnmount, reactive, wat
|
|
|
123
123
|
initWatch({ watch, props, state, select, constants });
|
|
124
124
|
initOnMounted({ onMounted, props, api: api2, vm, state, constants, select });
|
|
125
125
|
initOnBeforeUnmount({ onBeforeUnmount, props, select, vm, state });
|
|
126
|
-
initSelectState({ state, select,
|
|
126
|
+
initSelectState({ state, select, props, toRefs, reactive });
|
|
127
127
|
parent.$on(constants.EVENT_NAME.handleGroupDisabled, api2.handleGroupDisabled);
|
|
128
128
|
return api2;
|
|
129
129
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/vue-renderless",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.1",
|
|
4
4
|
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
|
|
5
5
|
"homepage": "https://opentiny.design/tiny-vue",
|
|
6
6
|
"keywords": [
|
package/picker/mb.js
CHANGED
|
@@ -12,6 +12,7 @@ const timeMobileToggle = ({ state, props, api }) => (visible) => {
|
|
|
12
12
|
return;
|
|
13
13
|
if (visible) {
|
|
14
14
|
state.timeMobileOption.value = api.dateToTimeArray(props.modelValue);
|
|
15
|
+
state.timeMobileOption.defaultValue = api.dateToTimeArray(props.defaultValue);
|
|
15
16
|
}
|
|
16
17
|
state.timeMobileOption.visible = visible;
|
|
17
18
|
};
|
|
@@ -20,7 +21,11 @@ const timeMobileConfirm = ({ state, api }) => () => {
|
|
|
20
21
|
};
|
|
21
22
|
const dateToTimeArray = (value) => {
|
|
22
23
|
const date = new Date(value);
|
|
23
|
-
|
|
24
|
+
if (isNaN(date.getTime())) {
|
|
25
|
+
return [];
|
|
26
|
+
} else {
|
|
27
|
+
return [date.getHours(), date.getMinutes(), date.getSeconds()];
|
|
28
|
+
}
|
|
24
29
|
};
|
|
25
30
|
const timeArrayToDate = ({ props }) => (value) => {
|
|
26
31
|
const timeArr = value;
|
package/picker/vue.js
CHANGED
|
@@ -132,7 +132,8 @@ const initState = ({ api: api2, reactive, vm, computed, props, utils, parent, br
|
|
|
132
132
|
timeMobileOption: {
|
|
133
133
|
visible: false,
|
|
134
134
|
type: props.type,
|
|
135
|
-
value: [0, 0, 0]
|
|
135
|
+
value: [0, 0, 0],
|
|
136
|
+
defaultValue: [0, 0, 0]
|
|
136
137
|
},
|
|
137
138
|
isDateMobileComponent: computed(
|
|
138
139
|
() => [
|
package/select/index.js
CHANGED
|
@@ -52,8 +52,8 @@ const showTip = ({ props, state, vm }) => (show) => {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
const gridOnQueryChange = ({ props, vm, constants, state }) => (value) => {
|
|
55
|
-
const { multiple, valueField, filterMethod,
|
|
56
|
-
if (filterable && typeof filterMethod === "function") {
|
|
55
|
+
const { multiple, valueField, filterMethod, remote, remoteMethod } = props;
|
|
56
|
+
if ((props.filterable || props.searchable) && typeof filterMethod === "function") {
|
|
57
57
|
const table = vm.$refs.selectGrid.$refs.tinyTable;
|
|
58
58
|
const fullData = table.afterFullData;
|
|
59
59
|
vm.$refs.selectGrid.scrollTo(null, 0);
|
|
@@ -106,7 +106,7 @@ const queryChange = ({ props, state, constants }) => (value, isInput) => {
|
|
|
106
106
|
};
|
|
107
107
|
const setFilteredSelectCls = (nextTick, state, props) => {
|
|
108
108
|
nextTick(() => {
|
|
109
|
-
if (props.multiple && props.showAlloption && props.filterable && state.query && !props.remote) {
|
|
109
|
+
if (props.multiple && props.showAlloption && (props.filterable || props.searchable) && state.query && !props.remote) {
|
|
110
110
|
const filterSelectedVal = state.options.filter((item) => item.state.visible && item.state.itemSelected).map((opt) => opt.value);
|
|
111
111
|
const visibleOptions = state.options.filter((item) => item.state.visible);
|
|
112
112
|
if (filterSelectedVal.length === visibleOptions.length) {
|
|
@@ -133,7 +133,7 @@ const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (v
|
|
|
133
133
|
}
|
|
134
134
|
if (props.renderType === constants.TYPE.Tree) {
|
|
135
135
|
state.previousQuery = value;
|
|
136
|
-
if (props.filterable && typeof props.filterMethod === "function") {
|
|
136
|
+
if ((props.filterable || props.searchable) && typeof props.filterMethod === "function") {
|
|
137
137
|
vm.$refs.selectTree && vm.$refs.selectTree.filter(value);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -146,8 +146,11 @@ const handleQueryChange = ({ api, constants, nextTick, props, vm, state }) => (v
|
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
state.hoverIndex = -1;
|
|
149
|
-
if (props.multiple && props.filterable && !props.shape) {
|
|
149
|
+
if (props.multiple && (props.filterable || props.searchable) && !props.shape) {
|
|
150
150
|
nextTick(() => {
|
|
151
|
+
if (!vm.$refs.input) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
151
154
|
const length = vm.$refs.input.value.length * 15 + 20;
|
|
152
155
|
state.inputLength = state.collapseTags ? Math.min(50, length) : length;
|
|
153
156
|
api.managePlaceholder();
|
|
@@ -302,7 +305,7 @@ const getResultOfSetSelected = ({ state, isGrid, isTree, api, props }) => {
|
|
|
302
305
|
api.clearNoMatchValue(newModelValue);
|
|
303
306
|
return result;
|
|
304
307
|
};
|
|
305
|
-
const setGridOrTreeSelected = ({ props, state, vm, isTree, api }) => {
|
|
308
|
+
const setGridOrTreeSelected = ({ props, state, vm, isTree, api, init }) => {
|
|
306
309
|
if (!props.modelValue) {
|
|
307
310
|
state.selectedLabel = "";
|
|
308
311
|
state.selected = {};
|
|
@@ -311,7 +314,7 @@ const setGridOrTreeSelected = ({ props, state, vm, isTree, api }) => {
|
|
|
311
314
|
vm.$refs.selectTree && vm.$refs.selectTree.setCurrentKey && vm.$refs.selectTree.setCurrentKey(null);
|
|
312
315
|
return;
|
|
313
316
|
}
|
|
314
|
-
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
317
|
+
const isRemote = (props.filterable || props.searchable) && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
315
318
|
const nestdata = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
|
|
316
319
|
const data = find(nestdata, (item) => props.modelValue === item[props.valueField]);
|
|
317
320
|
if (isEmptyObject(data)) {
|
|
@@ -321,26 +324,28 @@ const setGridOrTreeSelected = ({ props, state, vm, isTree, api }) => {
|
|
|
321
324
|
const obj = Object.assign({}, data);
|
|
322
325
|
const label = data[props.textField];
|
|
323
326
|
obj.currentLabel = label;
|
|
327
|
+
state.selectedLabel = init && !label && props.initLabel ? props.initLabel : label;
|
|
324
328
|
state.selectedLabel = label;
|
|
325
329
|
state.selected = obj;
|
|
326
330
|
state.currentKey = data[props.valueField];
|
|
327
331
|
};
|
|
328
|
-
const setSelected = ({ api, constants, nextTick, props, vm, state }) => () => {
|
|
332
|
+
const setSelected = ({ api, constants, nextTick, props, vm, state }) => (init) => {
|
|
329
333
|
const isTree = props.renderType === constants.TYPE.Tree;
|
|
330
334
|
const isGrid = props.renderType === constants.TYPE.Grid;
|
|
331
335
|
if (!props.multiple) {
|
|
332
336
|
if (isGrid || isTree) {
|
|
333
|
-
setGridOrTreeSelected({ props, state, vm, isTree, api });
|
|
337
|
+
setGridOrTreeSelected({ props, state, vm, isTree, api, init });
|
|
334
338
|
} else {
|
|
335
339
|
const option = getOptionOfSetSelected({ api, props });
|
|
336
340
|
state.selected = option;
|
|
337
341
|
state.selectedLabel = option.state.currentLabel || option.currentLabel;
|
|
338
|
-
props.filterable && !props.shape && (state.query = state.selectedLabel);
|
|
342
|
+
(props.filterable || props.searchable) && !props.shape && (state.query = state.selectedLabel);
|
|
339
343
|
}
|
|
340
344
|
} else {
|
|
341
345
|
const result = getResultOfSetSelected({ state, props, isGrid, isTree, api });
|
|
342
346
|
state.selectCls = result.length ? result.length === state.options.length ? "checked-sur" : "halfselect" : "check";
|
|
343
347
|
state.selected = result;
|
|
348
|
+
state.selected.length && (state.selectedLabel = "");
|
|
344
349
|
vm.$refs.selectTree && vm.$refs.selectTree.setCheckedNodes && vm.$refs.selectTree.setCheckedNodes(state.selected);
|
|
345
350
|
state.tips = state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join(",");
|
|
346
351
|
setFilteredSelectCls(nextTick, state, props);
|
|
@@ -348,7 +353,7 @@ const setSelected = ({ api, constants, nextTick, props, vm, state }) => () => {
|
|
|
348
353
|
}
|
|
349
354
|
};
|
|
350
355
|
const getPluginOption = ({ api, props, state }) => (value, isTree) => {
|
|
351
|
-
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
356
|
+
const isRemote = (props.filterable || props.searchable) && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
352
357
|
const { textField, valueField } = props;
|
|
353
358
|
const sourceData = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
|
|
354
359
|
const selNode = find(sourceData, (item) => item[valueField] === value);
|
|
@@ -364,7 +369,7 @@ const toggleCheckAll = ({ api, state, props }) => (filtered) => {
|
|
|
364
369
|
const enabledValues = state.options.filter((op) => !op.state.disabled && !op.state.groupDisabled && !op.required && op.state.visible).map((op) => op.value);
|
|
365
370
|
if (filtered) {
|
|
366
371
|
if (state.filteredSelectCls === "check" || state.filteredSelectCls === "halfselect") {
|
|
367
|
-
value =
|
|
372
|
+
value = Array.from(/* @__PURE__ */ new Set([...state.modelValue, ...enabledValues]));
|
|
368
373
|
} else {
|
|
369
374
|
value = state.modelValue.filter((val) => !enabledValues.includes(val));
|
|
370
375
|
}
|
|
@@ -388,7 +393,7 @@ const toggleCheckAll = ({ api, state, props }) => (filtered) => {
|
|
|
388
393
|
};
|
|
389
394
|
const handleFocus = ({ emit, props, state }) => (event) => {
|
|
390
395
|
if (!state.softFocus) {
|
|
391
|
-
if (props.automaticDropdown || props.filterable) {
|
|
396
|
+
if (props.automaticDropdown || props.filterable || props.searchable) {
|
|
392
397
|
state.visible = true;
|
|
393
398
|
state.softFocus = true;
|
|
394
399
|
}
|
|
@@ -486,7 +491,7 @@ const resetInputState = ({ api, vm, state }) => (event) => {
|
|
|
486
491
|
api.resetInputHeight();
|
|
487
492
|
};
|
|
488
493
|
const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designConfig }) => () => {
|
|
489
|
-
if (state.collapseTags && !props.filterable) {
|
|
494
|
+
if (state.collapseTags && !(props.filterable || props.searchable)) {
|
|
490
495
|
return;
|
|
491
496
|
}
|
|
492
497
|
nextTick(() => {
|
|
@@ -503,7 +508,7 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
|
|
|
503
508
|
if (!state.isDisplayOnly && (props.hoverExpand || props.clickExpand) && !props.disabled) {
|
|
504
509
|
api.calcCollapseTags();
|
|
505
510
|
}
|
|
506
|
-
const sizeInMap = (designConfig == null ? void 0 : designConfig.state.initialInputHeight) || state.initialInputHeight || (state.isSaaSTheme ? 28 : 30);
|
|
511
|
+
const sizeInMap = (designConfig == null ? void 0 : designConfig.state.initialInputHeight) || Math.round(state.initialInputHeight) || (state.isSaaSTheme ? 28 : 30);
|
|
507
512
|
const noSelected = state.selected.length === 0;
|
|
508
513
|
const spacingHeight = designConfig ? (_a = designConfig.state) == null ? void 0 : _a.spacingHeight : constants.SPACING_HEIGHT;
|
|
509
514
|
if (!state.isDisplayOnly) {
|
|
@@ -553,6 +558,7 @@ const resetDatas = ({ props, state }) => () => {
|
|
|
553
558
|
}
|
|
554
559
|
};
|
|
555
560
|
const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byClick) => {
|
|
561
|
+
var _a;
|
|
556
562
|
state.memorize && state.memorize.updateByKey(option[state.memorize._dataKey] || option.value);
|
|
557
563
|
if (props.multiple) {
|
|
558
564
|
const value = (state.modelValue || []).slice();
|
|
@@ -572,8 +578,8 @@ const handleOptionSelect = ({ api, nextTick, props, vm, state }) => (option, byC
|
|
|
572
578
|
api.handleQueryChange("", isChange, isInput);
|
|
573
579
|
state.inputLength = 20;
|
|
574
580
|
}
|
|
575
|
-
if (props.filterable) {
|
|
576
|
-
vm.$refs.input.focus();
|
|
581
|
+
if (props.filterable || props.searchable) {
|
|
582
|
+
(_a = vm.$refs.input) == null ? void 0 : _a.focus();
|
|
577
583
|
}
|
|
578
584
|
if (props.autoClose) {
|
|
579
585
|
state.visible = false;
|
|
@@ -627,7 +633,7 @@ const getValueIndex = (props) => (arr = [], value = null) => {
|
|
|
627
633
|
}
|
|
628
634
|
};
|
|
629
635
|
const toggleMenu = ({ vm, state, props, api }) => (e) => {
|
|
630
|
-
if (props.keepFocus && state.visible && props.filterable) {
|
|
636
|
+
if (props.keepFocus && state.visible && (props.filterable || props.searchable)) {
|
|
631
637
|
return;
|
|
632
638
|
}
|
|
633
639
|
const event = e || window.event;
|
|
@@ -641,7 +647,7 @@ const toggleMenu = ({ vm, state, props, api }) => (e) => {
|
|
|
641
647
|
toggleVisible && !state.softFocus && (state.visible = !state.visible);
|
|
642
648
|
state.softFocus = false;
|
|
643
649
|
if (state.visible) {
|
|
644
|
-
if (!(props.filterable && props.shape)) {
|
|
650
|
+
if (!((props.filterable || props.searchable) && props.shape)) {
|
|
645
651
|
const dom = vm.$refs.input || vm.$refs.reference;
|
|
646
652
|
(dom == null ? void 0 : dom.focus) && dom.focus();
|
|
647
653
|
api.setOptionHighlight();
|
|
@@ -726,7 +732,7 @@ const deleteTag = ({ api, constants, emit, props, state, nextTick, vm }) => (eve
|
|
|
726
732
|
};
|
|
727
733
|
const onInputChange = ({ api, props, state, constants, nextTick }) => () => {
|
|
728
734
|
if (!props.delay) {
|
|
729
|
-
if (props.filterable && state.query !== state.selectedLabel) {
|
|
735
|
+
if ((props.filterable || props.searchable) && state.query !== state.selectedLabel) {
|
|
730
736
|
const isChange = false;
|
|
731
737
|
const isInput = true;
|
|
732
738
|
state.query = state.selectedLabel;
|
|
@@ -889,7 +895,7 @@ const emptyText = ({ I18N, props, state, t, isMobileFirstMode }) => () => {
|
|
|
889
895
|
if (props.remote && state.query === "" && state.emptyFlag && !state.triggerSearch) {
|
|
890
896
|
return props.shape === "filter" || isMobileFirstMode ? "" : false;
|
|
891
897
|
}
|
|
892
|
-
if (props.filterable && state.query && (props.remote && state.emptyFlag || !state.options.some((option) => option.visible && option.state.visible))) {
|
|
898
|
+
if ((props.filterable || props.searchable) && state.query && (props.remote && state.emptyFlag || !state.options.some((option) => option.visible && option.state.visible))) {
|
|
893
899
|
return props.noMatchText || t(I18N.noMatch);
|
|
894
900
|
}
|
|
895
901
|
if (state.emptyFlag) {
|
|
@@ -911,14 +917,14 @@ const watchValue = ({ api, constants, dispatch, props, vm, state }) => (value, o
|
|
|
911
917
|
} else {
|
|
912
918
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
913
919
|
}
|
|
914
|
-
if (props.filterable && !props.reserveKeyword) {
|
|
920
|
+
if ((props.filterable || props.searchable) && !props.reserveKeyword) {
|
|
915
921
|
props.renderType !== constants.TYPE.Grid && !props.searchable && (state.query = "");
|
|
916
922
|
}
|
|
917
923
|
}
|
|
918
924
|
api.setSelected();
|
|
919
925
|
!state.isClickChoose && api.initQuery({ init: true }).then(() => api.setSelected());
|
|
920
926
|
state.isClickChoose = false;
|
|
921
|
-
if (props.filterable && !props.multiple) {
|
|
927
|
+
if ((props.filterable || props.searchable) && !props.multiple) {
|
|
922
928
|
state.inputLength = 20;
|
|
923
929
|
}
|
|
924
930
|
if (state.completed && !isEqual(value, oldValue)) {
|
|
@@ -961,24 +967,30 @@ const calcOverFlow = ({ vm, props, state }) => (height) => {
|
|
|
961
967
|
};
|
|
962
968
|
const postOperOfToVisible = ({ props, state, constants }) => {
|
|
963
969
|
if (props.multiple) {
|
|
970
|
+
if (props.modelValue && props.modelValue.length && props.initLabel && !state.selected.length) {
|
|
971
|
+
state.selectedLabel = props.initLabel;
|
|
972
|
+
}
|
|
964
973
|
return;
|
|
965
974
|
}
|
|
966
975
|
if (state.selected) {
|
|
967
976
|
if (props.renderType === constants.TYPE.Grid || props.renderType === constants.TYPE.Tree) {
|
|
968
977
|
state.selectedLabel = state.selected.currentLabel;
|
|
969
978
|
} else {
|
|
970
|
-
if (props.filterable && props.allowCreate && state.createdSelected && state.createdLabel) {
|
|
979
|
+
if ((props.filterable || props.searchable) && props.allowCreate && state.createdSelected && state.createdLabel) {
|
|
971
980
|
state.selectedLabel = state.createdLabel;
|
|
972
981
|
} else {
|
|
973
982
|
state.selectedLabel = state.selected.state.currentLabel || state.selected.currentLabel;
|
|
974
983
|
}
|
|
975
|
-
if (props.filterable) {
|
|
984
|
+
if (props.filterable || props.searchable) {
|
|
976
985
|
state.query = state.selectedLabel;
|
|
977
986
|
}
|
|
978
987
|
}
|
|
979
|
-
if (props.filterable) {
|
|
988
|
+
if (props.filterable || props.searchable) {
|
|
980
989
|
state.currentPlaceholder = state.cachedPlaceHolder;
|
|
981
990
|
}
|
|
991
|
+
if (props.modelValue && props.initLabel && !state.selectedLabel) {
|
|
992
|
+
state.selectedLabel = props.initLabel;
|
|
993
|
+
}
|
|
982
994
|
}
|
|
983
995
|
};
|
|
984
996
|
const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
@@ -1007,15 +1019,16 @@ const toVisible = ({ constants, state, props, vm, api, nextTick }) => () => {
|
|
|
1007
1019
|
postOperOfToVisible({ props, state, constants });
|
|
1008
1020
|
};
|
|
1009
1021
|
const toHide = ({ constants, state, props, vm, api }) => () => {
|
|
1010
|
-
|
|
1022
|
+
var _a;
|
|
1023
|
+
const { remote, remoteConfig, shape, renderType, multiple, valueField } = props;
|
|
1011
1024
|
state.selectEmitter.emit(constants.COMPONENT_NAME.SelectDropdown, constants.EVENT_NAME.updatePopper);
|
|
1012
|
-
if (filterable) {
|
|
1025
|
+
if (props.filterable || props.searchable) {
|
|
1013
1026
|
state.query = remote || shape ? "" : renderType !== constants.TYPE.Tree ? state.selectedLabel : "";
|
|
1014
1027
|
const isChange = remote && remoteConfig.autoSearch && (state.firstAutoSearch || remoteConfig.clearData);
|
|
1015
1028
|
state.firstAutoSearch = false;
|
|
1016
1029
|
api.handleQueryChange(state.query, isChange);
|
|
1017
1030
|
if (multiple) {
|
|
1018
|
-
vm.$refs.input.focus();
|
|
1031
|
+
(_a = vm.$refs.input) == null ? void 0 : _a.focus();
|
|
1019
1032
|
} else {
|
|
1020
1033
|
if (!remote) {
|
|
1021
1034
|
state.selectEmitter.emit(constants.EVENT_NAME.queryChange, "");
|
|
@@ -1040,16 +1053,17 @@ const toHide = ({ constants, state, props, vm, api }) => () => {
|
|
|
1040
1053
|
vm.$refs.selectGrid.clearRadioRow();
|
|
1041
1054
|
vm.$refs.selectGrid.setRadioRow(find(fullData, (item) => props.modelValue === item[valueField]));
|
|
1042
1055
|
}
|
|
1043
|
-
if (filterable && typeof props.filterMethod === "function") {
|
|
1056
|
+
if ((props.filterable || props.searchable) && typeof props.filterMethod === "function") {
|
|
1044
1057
|
vm.$refs.selectGrid.handleTableData(true);
|
|
1045
|
-
} else if (filterable && remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
1058
|
+
} else if ((props.filterable || props.searchable) && remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function")) {
|
|
1046
1059
|
vm.$refs.selectGrid.handleTableData();
|
|
1047
1060
|
}
|
|
1048
1061
|
}
|
|
1049
1062
|
};
|
|
1050
1063
|
const watchVisible = ({ api, constants, emit, state, vm, props }) => (value) => {
|
|
1051
|
-
|
|
1052
|
-
|
|
1064
|
+
var _a;
|
|
1065
|
+
if ((props.filterable || props.searchable || props.remote) && !value) {
|
|
1066
|
+
(_a = vm.$refs.reference) == null ? void 0 : _a.blur();
|
|
1053
1067
|
}
|
|
1054
1068
|
if (api.onCopying()) {
|
|
1055
1069
|
return;
|
|
@@ -1101,7 +1115,7 @@ const watchOptions = ({ api, constants, nextTick, parent, props, state }) => ()
|
|
|
1101
1115
|
const getOptionIndexArr = ({ props, state, api }) => () => {
|
|
1102
1116
|
setTimeout(() => {
|
|
1103
1117
|
state.optionIndexArr = api.queryVisibleOptions().map((item) => Number(item.getAttribute("data-index")));
|
|
1104
|
-
if (props.defaultFirstOption && (props.filterable || props.remote) && state.filteredOptionsCount) {
|
|
1118
|
+
if (props.defaultFirstOption && (props.filterable || props.searchable || props.remote) && state.filteredOptionsCount) {
|
|
1105
1119
|
if (props.optimization) {
|
|
1106
1120
|
optmzApis.checkDefaultFirstOption({ state });
|
|
1107
1121
|
} else {
|
|
@@ -1220,7 +1234,7 @@ const nodeExpand = ({ state, constants }) => () => {
|
|
|
1220
1234
|
}, 310);
|
|
1221
1235
|
};
|
|
1222
1236
|
const debouncRquest = ({ api, state, props }) => debounce(props.delay, () => {
|
|
1223
|
-
if (props.filterable && state.query !== state.selectedLabel) {
|
|
1237
|
+
if ((props.filterable || props.searchable) && state.query !== state.selectedLabel) {
|
|
1224
1238
|
const isChange = false;
|
|
1225
1239
|
const isInput = true;
|
|
1226
1240
|
state.query = state.selectedLabel;
|
|
@@ -1390,7 +1404,7 @@ const watchInputHover = ({ vm }) => (newVal) => {
|
|
|
1390
1404
|
}
|
|
1391
1405
|
};
|
|
1392
1406
|
const initQuery = ({ props, state, constants, vm }) => ({ init } = {}) => {
|
|
1393
|
-
const isRemote = props.filterable && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
1407
|
+
const isRemote = (props.filterable || props.searchable) && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
1394
1408
|
const isGrid = props.renderType === constants.TYPE.Grid;
|
|
1395
1409
|
let selected;
|
|
1396
1410
|
if (isRemote && isGrid && props.initQuery) {
|
|
@@ -1434,7 +1448,12 @@ const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
|
|
|
1434
1448
|
api.resetInputHeight();
|
|
1435
1449
|
}
|
|
1436
1450
|
state.inputWidth = inputClientRect.width;
|
|
1437
|
-
api.initQuery({ init: true }).then(() =>
|
|
1451
|
+
api.initQuery({ init: true }).then(() => {
|
|
1452
|
+
api.setSelected(true);
|
|
1453
|
+
if (props.modelValue && props.initLabel) {
|
|
1454
|
+
state.selectedLabel = props.initLabel;
|
|
1455
|
+
}
|
|
1456
|
+
});
|
|
1438
1457
|
if (props.dataset) {
|
|
1439
1458
|
api.watchPropsOption();
|
|
1440
1459
|
}
|
|
@@ -1553,16 +1572,22 @@ const computedTagsStyle = ({ props, parent, state, vm }) => () => {
|
|
|
1553
1572
|
}
|
|
1554
1573
|
return tagsStyle;
|
|
1555
1574
|
};
|
|
1556
|
-
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;
|
|
1575
|
+
const computedReadonly = ({ props, state }) => () => state.device === "mb" || props.readonly || !(props.filterable || props.searchable) || props.multiple || browserInfo.name !== BROWSER_NAME.IE && browserInfo.name !== BROWSER_NAME.Edge && !state.visible;
|
|
1557
1576
|
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 !== "");
|
|
1558
1577
|
const computedCollapseTagSize = (state) => () => state.selectSize;
|
|
1559
1578
|
const computedShowNewOption = ({ props, state }) => () => {
|
|
1560
1579
|
const query = state.device === "mb" ? state.queryValue : state.query;
|
|
1561
|
-
return props.filterable && props.allowCreate && query && !state.options.filter((option) => !option.created).some((option) => option.state.currentLabel === state.query);
|
|
1580
|
+
return (props.filterable || props.searchable) && props.allowCreate && query && !state.options.filter((option) => !option.created).some((option) => option.state.currentLabel === state.query);
|
|
1562
1581
|
};
|
|
1563
1582
|
const computedShowCopy = ({ props, state }) => () => props.multiple && props.copyable && state.inputHovering && state.selected.length;
|
|
1564
1583
|
const computedOptionsAllDisabled = (state) => () => state.options.filter((option) => option.visible).every((option) => option.disabled);
|
|
1565
|
-
const computedDisabledTooltipContent = (state
|
|
1584
|
+
const computedDisabledTooltipContent = ({ props, state }) => () => {
|
|
1585
|
+
if (props.multiple) {
|
|
1586
|
+
return state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join(";");
|
|
1587
|
+
} else {
|
|
1588
|
+
return state.selected.state ? state.selected.state.currentLabel : state.selected.currentLabel;
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1566
1591
|
const computedSelectDisabled = ({ props, parent }) => () => props.disabled || (parent.form || {}).disabled || props.displayOnly || (parent.form || {}).displayOnly;
|
|
1567
1592
|
const computedIsExpand = ({ props, state }) => () => {
|
|
1568
1593
|
const hoverExpanded = (state.selectHover || state.visible) && props.hoverExpand && !props.disabled;
|
package/select/vue.js
CHANGED
|
@@ -285,7 +285,7 @@ const initStateAdd = ({ computed, props, api: api2, parent }) => {
|
|
|
285
285
|
isDisplayOnly: computed(() => props.displayOnly || (parent.form || {}).displayOnly),
|
|
286
286
|
gridCheckedData: computed(() => api2.getcheckedData()),
|
|
287
287
|
isExpandAll: computed(() => api2.computedIsExpandAll()),
|
|
288
|
-
searchSingleCopy: computed(() => props.allowCopy && !props.multiple && props.filterable),
|
|
288
|
+
searchSingleCopy: computed(() => props.allowCopy && !props.multiple && (props.filterable || props.searchable)),
|
|
289
289
|
childrenName: computed(() => props.treeOp.props && props.treeOp.props.children || "children"),
|
|
290
290
|
tooltipContent: {},
|
|
291
291
|
isHidden: false,
|