@opentiny/vue-renderless 3.9.1 → 3.9.3

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/checkbox/index.js CHANGED
@@ -106,6 +106,14 @@ const getDisplayedValue = ({ vm, state, props }) => () => {
106
106
  };
107
107
  const computedIsDisplayOnly = ({ state, props }) => () => props.displayOnly || state.formDisplayOnly;
108
108
  const computedIsGroupDisplayOnly = ({ state }) => () => state.isGroup && (state.checkboxGroup.displayOnly || state.formDisplayOnly);
109
+ const computedIsShowText = ({ props }) => () => props.text || props.label || !isNull(props.text) || !isNull(props.label);
110
+ const computedShowText = ({ props }) => () => {
111
+ if (props.text || !isNull(props.text)) {
112
+ return props.text;
113
+ } else {
114
+ return props.label;
115
+ }
116
+ };
109
117
  export {
110
118
  addToStore,
111
119
  computedCheckboxSize,
@@ -118,6 +126,8 @@ export {
118
126
  computedIsGroup,
119
127
  computedIsGroupDisplayOnly,
120
128
  computedIsLimitDisabled,
129
+ computedIsShowText,
130
+ computedShowText,
121
131
  computedStore,
122
132
  dispatchDisplayedValue,
123
133
  getDisplayedValue,
package/checkbox/vue.js CHANGED
@@ -17,7 +17,9 @@ import {
17
17
  mounted,
18
18
  toggleEvent,
19
19
  dispatchDisplayedValue,
20
- getDisplayedValue
20
+ getDisplayedValue,
21
+ computedIsShowText,
22
+ computedShowText
21
23
  } from "./index";
22
24
  const api = ["state", "handleChange", "computedStore"];
23
25
  const initState = ({ reactive, computed, parent, api: api2, inject, props }) => {
@@ -40,7 +42,9 @@ const initState = ({ reactive, computed, parent, api: api2, inject, props }) =>
40
42
  model: computed({
41
43
  get: () => api2.computedGetModelGet(),
42
44
  set: (value) => api2.computedGetModelSet(value)
43
- })
45
+ }),
46
+ showText: computed(() => api2.computedShowText()),
47
+ isShowText: computed(() => api2.computedIsShowText())
44
48
  });
45
49
  return state;
46
50
  };
@@ -63,7 +67,9 @@ const initApi = ({ vm, api: api2, state, dispatch, props, parent, constants, for
63
67
  mounted: mounted({ emit, props, api: api2, parent }),
64
68
  handleChange: handleChange({ state, props, emit, nextTick, dispatch, constants }),
65
69
  dispatchDisplayedValue: dispatchDisplayedValue({ state, api: api2, dispatch }),
66
- getDisplayedValue: getDisplayedValue({ state, props, vm })
70
+ getDisplayedValue: getDisplayedValue({ state, props, vm }),
71
+ computedIsShowText: computedIsShowText({ props }),
72
+ computedShowText: computedShowText({ props })
67
73
  });
68
74
  };
69
75
  const renderless = (props, { computed, onMounted, onBeforeUnmount, reactive, watch, inject }, { vm, parent, emit, constants, nextTick, dispatch }) => {
@@ -10,7 +10,7 @@ import {
10
10
  computedIsDisabled,
11
11
  toggleEvent
12
12
  } from "./index";
13
- import { addToStore, computedIsChecked, computedStore, computedIsLimitDisabled } from "../checkbox";
13
+ import { addToStore, computedIsChecked, computedStore, computedIsLimitDisabled, computedIsShowText, computedShowText } from "../checkbox";
14
14
  const api = ["state", "handleChange"];
15
15
  const initState = ({ reactive, computed, api: api2 }) => {
16
16
  const state = reactive({
@@ -27,7 +27,9 @@ const initState = ({ reactive, computed, api: api2 }) => {
27
27
  isDisabled: computed(() => api2.computedIsDisabled()),
28
28
  activeStyle: computed(() => api2.computedActiveStyle()),
29
29
  checkboxGroup: computed(() => api2.computedCheckboxGroup()),
30
- isLimitDisabled: computed(() => api2.computedIsLimitDisabled())
30
+ isLimitDisabled: computed(() => api2.computedIsLimitDisabled()),
31
+ showText: computed(() => api2.computedShowText()),
32
+ isShowText: computed(() => api2.computedIsShowText())
31
33
  });
32
34
  return state;
33
35
  };
@@ -45,7 +47,9 @@ const initApi = ({ api: api2, state, props, formItemSize, parent, constants, emi
45
47
  computedGetModelGet: computedGetModelGet({ state, props }),
46
48
  computedCheckboxGroup: computedCheckboxGroup({ parent, constants }),
47
49
  handleChange: handleChange({ state, props, emit, nextTick, dispatch, constants }),
48
- computedGetModelSet: computedGetModelSet({ state, props, emit, dispatch, constants })
50
+ computedGetModelSet: computedGetModelSet({ state, props, emit, dispatch, constants }),
51
+ computedIsShowText: computedIsShowText({ props }),
52
+ computedShowText: computedShowText({ props })
49
53
  });
50
54
  };
51
55
  const renderless = (props, { computed, onMounted, onBeforeUnmount, reactive }, { parent, emit, dispatch, constants, nextTick }) => {
package/input/vue.js CHANGED
@@ -91,7 +91,7 @@ const initState = ({ reactive, computed, mode, props, parent, constants }) => {
91
91
  validateIcon: computed(() => constants.VALIDATE_ICON[state.validateState]),
92
92
  showWordLimit: computed(() => props.showWordLimit && parent.$attrs.maxlength),
93
93
  inputDisabled: computed(
94
- () => props.disabled || (parent.auiForm || {}).disabled || state.isDisplayOnly || (parent.tinyForm || {}).displayOnly
94
+ () => props.disabled || (parent.tinyForm || {}).disabled || state.isDisplayOnly || (parent.tinyForm || {}).displayOnly
95
95
  ),
96
96
  validateState: computed(() => parent.formItem ? parent.formItem.validateState : ""),
97
97
  textareaStyle: computed(() => __spreadProps(__spreadValues({}, state.textareaCalcStyle), {
@@ -6,7 +6,9 @@ const ipValidator = ({ props, api }) => (value) => {
6
6
  let result = true;
7
7
  if (props.type) {
8
8
  if (api.isIP6(props.type)) {
9
- result = typeof value === "string";
9
+ result = /^(((([\da-fA-F]{1,4}):){7}([\da-fA-F]{1,4}))|(((([\da-fA-F]{1,4}):){1,7}:)|((([\da-fA-F]{1,4}):){6}:([\da-fA-F]{1,4}))|((([\da-fA-F]{1,4}):){5}:(([\da-fA-F]{1,4}):)?([\da-fA-F]{1,4}))|((([\da-fA-F]{1,4}):){4}:(([\da-fA-F]{1,4}):){0,2}([\da-fA-F]{1,4}))|((([\da-fA-F]{1,4}):){3}:(([\da-fA-F]{1,4}):){0,3}([\da-fA-F]{1,4}))|((([\da-fA-F]{1,4}):){2}:(([\da-fA-F]{1,4}):){0,4}([\da-fA-F]{1,4}))|((([\da-fA-F]{1,4}):){1}:(([\da-fA-F]{1,4}):){0,5}([\da-fA-F]{1,4}))|(::(([\da-fA-F]{1,4}):){0,6}([\da-fA-F]{1,4}))|(::([\da-fA-F]{1,4})?))|(((([\da-fA-F]{1,4}):){6}(((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5]))\.){3}((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5])))|((([\da-fA-F]{1,4}):){5}:(((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5]))\.){3}((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5])))|((([\da-fA-F]{1,4}):){4}:(([\da-fA-F]{1,4}):)?(((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5]))\.){3}((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5])))|((([\da-fA-F]{1,4}):){3}:(([\da-fA-F]{1,4}):){0,2}(((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5]))\.){3}((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5])))|((([\da-fA-F]{1,4}):){2}:(([\da-fA-F]{1,4}):){0,3}(((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5]))\.){3}((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5])))|(([\da-fA-F]{1,4})::(([\da-fA-F]{1,4}):){0,4}(((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5]))\.){3}((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5])))|(::(([\da-fA-F]{1,4}):){0,5}(((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5]))\.){3}((1?[1-9]?\d)|(10\d)|(2[0-4]\d)|(25[0-5])))))$/.test(
10
+ value
11
+ );
10
12
  } else if (api.isIP4(props.type)) {
11
13
  result = /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/.test(value);
12
14
  }
@@ -30,7 +32,13 @@ const getValue = ({ api, props, state }) => () => {
30
32
  const valueArr = [];
31
33
  let result = "";
32
34
  if (api.isIP6(props.type)) {
33
- result = state.address[0].value || "";
35
+ state.address.forEach((item) => {
36
+ if (item.value) {
37
+ item.value = item.value.replace(/[^a-fA-F\d]/g, "");
38
+ }
39
+ item.value && valueArr.push(item.value);
40
+ });
41
+ result = state.address.filter((item) => item.value).length === 8 ? valueArr.join(":") : "";
34
42
  } else {
35
43
  state.address.forEach((item) => {
36
44
  if (api.isIP4(props.type) && item.value) {
@@ -46,13 +54,25 @@ const setValue = ({ api, props, state }) => (value) => {
46
54
  if (value) {
47
55
  if (api.ipValidator(value)) {
48
56
  if (api.isIP6(props.type)) {
49
- state.address = [{ value }];
57
+ state.address = value.split(":").map((item) => ({ value: item }));
58
+ if (state.address.length < 8) {
59
+ let insertIndex = 0;
60
+ state.address.forEach((item, index) => {
61
+ if (item.value === "") {
62
+ item.value = "0000";
63
+ insertIndex = index;
64
+ }
65
+ });
66
+ for (var i = 0; i <= 8 - state.address.length; i++) {
67
+ state.address.splice(insertIndex, 0, { value: "0000" });
68
+ }
69
+ }
50
70
  } else {
51
71
  state.address = value.split(".").map((item) => ({ value: item }));
52
72
  }
53
73
  }
54
74
  } else {
55
- state.address = api.isIP6(props.type) ? [{ value: "" }] : [{ value: "" }, { value: "" }, { value: "" }, { value: "" }];
75
+ state.address = api.isIP6(props.type) ? new Array(8).fill({ value: "" }) : new Array(4).fill({ value: "" });
56
76
  }
57
77
  };
58
78
  const activeEvent = ({ emit, parent, state, index, event, type }) => {
@@ -87,7 +107,11 @@ const inputEvent = ({ api, componentName, emit, eventName, props }) => ({ item,
87
107
  item.value = "";
88
108
  }
89
109
  } else {
90
- item.value = val.replace(/[\u4E00-\u9FA5]/g, "");
110
+ if (!index && api.ipValidator(val)) {
111
+ api.setValue(val);
112
+ } else if (val.length > 4) {
113
+ item.value = item.value.slice(0, 4);
114
+ }
91
115
  }
92
116
  value = api.getValue();
93
117
  emit("update:modelValue", value, index);
@@ -125,15 +149,31 @@ const keyup = ({ api, props }) => ({ item, index, event }) => {
125
149
  return false;
126
150
  }
127
151
  }
152
+ if (api.isIP6(props.type)) {
153
+ if ([KEY_CODE.Tab, KEY_CODE.Space, KEY_CODE.NumpadDecimal, KEY_CODE.NumpadComma].includes(keyCode) && value) {
154
+ api.select({ index: nextIndex });
155
+ return false;
156
+ }
157
+ if ((value.length === 4 || value === "0000") && (!isNaN(event.key) || keyCode >= KEY_CODE.KeyA && keyCode <= KEY_CODE.KeyF)) {
158
+ api.focus({ index: nextIndex });
159
+ api.select({ index: nextIndex });
160
+ return false;
161
+ }
162
+ }
128
163
  };
129
164
  const checkError1 = ({ Tab, Space, NumpadDecimal, NumpadComma, keyCode, value }) => [Tab, Space, NumpadDecimal, NumpadComma].includes(keyCode) && value;
130
165
  const checkError2 = (newValue) => newValue && (isNaN(newValue) || newValue > IPTHRESHOLD.Max);
131
166
  const checkError3 = ({ isfilterKeyCodes, isSelected, value }) => !isfilterKeyCodes && !isSelected && value === "0";
132
167
  const checkError4 = ({ isfilterKeyCodes, isSelected, value, key }) => !isfilterKeyCodes && !isSelected && value + key > IPTHRESHOLD.Max;
133
168
  const checkError5 = ({ key, isfilterKeyCodes, value, ctrlKey, keyCode, KeyV }) => isNaN(key) && !isfilterKeyCodes && !(!value && ctrlKey && keyCode === KeyV);
134
- const isError = ({ key, value, isSelected, isfilterKeyCodes, ctrlKey, keyCode, newValue }) => {
135
- const { Tab, Space, NumpadDecimal, NumpadComma, KeyV } = KEY_CODE;
136
- return checkError1({ Tab, Space, NumpadDecimal, NumpadComma, keyCode, value }) || checkError2(newValue) || checkError3({ isfilterKeyCodes, isSelected, value }) || checkError4({ isfilterKeyCodes, isSelected, value, key }) || checkError5({ key, isfilterKeyCodes, value, ctrlKey, keyCode, KeyV });
169
+ const checkError6 = ({ KeyA, KeyF, key, isfilterKeyCodes, value, keyCode }) => !(keyCode >= KeyA && keyCode <= KeyF) && isNaN(key) && !isfilterKeyCodes && value;
170
+ const isError = ({ key, value, isSelected, isfilterKeyCodes, ctrlKey, keyCode, newValue, api, props }) => {
171
+ const { Tab, Space, KeyA, KeyF, NumpadDecimal, NumpadComma, KeyV } = KEY_CODE;
172
+ if (api.isIP4(props.type)) {
173
+ return checkError1({ Tab, Space, NumpadDecimal, NumpadComma, keyCode, value }) || checkError2(newValue) || checkError3({ isfilterKeyCodes, isSelected, value }) || checkError4({ isfilterKeyCodes, isSelected, value, key }) || checkError5({ key, isfilterKeyCodes, value, ctrlKey, keyCode, KeyV });
174
+ } else if (api.isIP6(props.type)) {
175
+ return checkError1({ Tab, Space, NumpadDecimal, NumpadComma, keyCode, value }) || checkError6({ KeyA, KeyF, key, isfilterKeyCodes, value, keyCode });
176
+ }
137
177
  };
138
178
  const keydown = ({ api, props, state }) => ({ item, index, event }) => {
139
179
  const { target, key, keyCode, ctrlKey } = event;
@@ -146,34 +186,34 @@ const keydown = ({ api, props, state }) => ({ item, index, event }) => {
146
186
  const nextIndex = index + 1;
147
187
  const lastIndex = index - 1;
148
188
  const newValue = isSelected && !isfilterKeyCodes && value.substr(0, selectionStart) + key + value.substr(selectionEnd);
149
- if (api.isIP4(props.type)) {
150
- state.isDel = keyCode === KEY_CODE.Backspace || keyCode === KEY_CODE.Delete;
151
- if (keyCode === KEY_CODE.Backspace && cursorPosition === 0 && !selectionEnd) {
152
- api.focus({ index: lastIndex });
153
- return false;
154
- }
155
- if (keyCode === KEY_CODE.ArrowLeft && cursorPosition === 0) {
156
- api.focus({ index: lastIndex });
157
- event.preventDefault();
158
- return false;
159
- }
160
- if (keyCode === KEY_CODE.ArrowRight && cursorPosition === value.length) {
161
- api.focus({ index: nextIndex });
162
- event.preventDefault();
163
- return false;
164
- }
165
- if (isError({
166
- key,
167
- value,
168
- isSelected,
169
- isfilterKeyCodes,
170
- ctrlKey,
171
- keyCode,
172
- newValue
173
- })) {
174
- event.preventDefault();
175
- return false;
176
- }
189
+ state.isDel = keyCode === KEY_CODE.Backspace || keyCode === KEY_CODE.Delete;
190
+ if (keyCode === KEY_CODE.Backspace && cursorPosition === 0 && !selectionEnd) {
191
+ api.focus({ index: lastIndex });
192
+ return false;
193
+ }
194
+ if (keyCode === KEY_CODE.ArrowLeft && cursorPosition === 0) {
195
+ api.focus({ index: lastIndex });
196
+ event.preventDefault();
197
+ return false;
198
+ }
199
+ if (keyCode === KEY_CODE.ArrowRight && cursorPosition === value.length) {
200
+ api.focus({ index: nextIndex });
201
+ event.preventDefault();
202
+ return false;
203
+ }
204
+ if (isError({
205
+ key,
206
+ value,
207
+ isSelected,
208
+ isfilterKeyCodes,
209
+ ctrlKey,
210
+ keyCode,
211
+ newValue,
212
+ api,
213
+ props
214
+ })) {
215
+ event.preventDefault();
216
+ return false;
177
217
  }
178
218
  };
179
219
  const getHeightOfSize = (size, isLineHeight = "height") => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/vue-renderless",
3
- "version": "3.9.1",
3
+ "version": "3.9.3",
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/select/index.js CHANGED
@@ -4,6 +4,7 @@ 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";
@@ -231,37 +232,42 @@ const getResultOfSetSelected = ({ props, isGrid, isTree, api }) => {
231
232
  }
232
233
  return result;
233
234
  };
234
- const setSelected = ({ api, constants, nextTick, props, refs, state }) => () => {
235
+ const setGridOrTreeSelected = ({ props, state, vm, isTree, api }) => () => {
236
+ if (!props.modelValue) {
237
+ state.selectedLabel = "";
238
+ state.selected = {};
239
+ state.currentKey = "";
240
+ vm.$refs.selectGrid && vm.$refs.selectGrid.clearRadioRow();
241
+ vm.$refs.selectTree && vm.$refs.selectTree.setCurrentKey && vm.$refs.selectTree.setCurrentKey(null);
242
+ return;
243
+ }
244
+ const isRemote = state.filterOrSearch && props.remote && typeof props.remoteMethod === "function";
245
+ const nestdata = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
246
+ const data = find(nestdata, (item) => props.modelValue == item[props.valueField]);
247
+ if (isEmptyObject(data)) {
248
+ return;
249
+ }
250
+ const obj = __spreadValues({}, data);
251
+ const label = data[props.textField];
252
+ obj.currentLabel = label;
253
+ state.selectedLabel = label;
254
+ state.selected = obj;
255
+ state.currentKey = data[props.valueField];
256
+ };
257
+ const setSelected = ({ api, constants, nextTick, props, vm, state }) => () => {
235
258
  const isTree = props.renderType === constants.TYPE.Tree;
236
259
  const isGrid = props.renderType === constants.TYPE.Grid;
237
260
  if (!props.multiple) {
238
261
  if (isGrid || isTree) {
239
- if (!props.modelValue) {
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];
262
+ setGridOrTreeSelected({ props, state, vm, isTree, api });
259
263
  } else {
260
264
  const option = getOptionOfSetSelected({ api, props });
261
265
  nextTick(() => {
262
266
  state.selected = option;
263
267
  state.selectedLabel = option.state.currentLabel || option.currentLabel;
264
- props.filterable && (state.query = state.selectedLabel);
268
+ if (state.filterOrSearch && !props.shape && !props.allowCreate) {
269
+ state.query = state.selectedLabel;
270
+ }
265
271
  });
266
272
  }
267
273
  return;
@@ -269,7 +275,7 @@ const setSelected = ({ api, constants, nextTick, props, refs, state }) => () =>
269
275
  const result = getResultOfSetSelected({ props, isGrid, isTree, api });
270
276
  state.selectCls = result.length ? result.length === state.options.length ? "checked-sur" : "halfselect" : "check";
271
277
  state.selected = result;
272
- refs.selectTree && refs.selectTree.setCheckedNodes && refs.selectTree.setCheckedNodes(state.selected);
278
+ vm.$refs.selectTree && vm.$refs.selectTree.setCheckedNodes && vm.$refs.selectTree.setCheckedNodes(state.selected);
273
279
  state.tips = state.selected.map((item) => item.state ? item.state.currentLabel : item.currentLabel).join(",");
274
280
  nextTick(api.resetInputHeight);
275
281
  };
@@ -410,8 +416,9 @@ const resetInputHeight = ({ constants, nextTick, props, refs, state }) => () =>
410
416
  if (!refs.reference) {
411
417
  return;
412
418
  }
413
- let inputChildNodes = refs.reference.$el.childNodes;
414
- let input = [].filter.call(inputChildNodes, (item) => item.tagName === "INPUT")[0];
419
+ const inputChildNodes = refs.reference.$el.childNodes;
420
+ const inputContainer = [].filter.call(inputChildNodes, (item) => hasClass(item, "tiny-input-display-only"))[0];
421
+ const input = inputContainer && inputContainer.querySelector("input");
415
422
  const tags = refs.tags;
416
423
  if (!input) {
417
424
  return;
@@ -1288,6 +1295,7 @@ export {
1288
1295
  scrollToOption,
1289
1296
  selectChange,
1290
1297
  selectOption,
1298
+ setGridOrTreeSelected,
1291
1299
  setSelected,
1292
1300
  setSoftFocus,
1293
1301
  showTip,
package/select/vue.js CHANGED
@@ -223,14 +223,14 @@ const initState = ({ reactive, computed, props, api: api2, emitter, parent, cons
223
223
  };
224
224
  const addApi = ({ api: api2, props, state, refs, emit, constants, parent, nextTick, dispatch, vm, designConfig }) => {
225
225
  Object.assign(api2, {
226
- resetInputHeight: resetInputHeight({ api: api2, constants, nextTick, props, refs, state }),
226
+ resetInputHeight: resetInputHeight({ constants, nextTick, props, refs, state }),
227
227
  calcOverFlow: calcOverFlow({ refs, props, state }),
228
228
  handleFocus: handleFocus({ api: api2, emit, props, state }),
229
229
  deleteTag: deleteTag({ api: api2, constants, emit, props, vm, state }),
230
230
  watchValue: watchValue({ api: api2, constants, dispatch, props, refs, state }),
231
231
  toHide: toHide({ constants, state, props, vm, api: api2 }),
232
232
  toVisible: toVisible({ constants, state, props, vm, api: api2, nextTick }),
233
- setSelected: setSelected({ api: api2, constants, nextTick, props, refs, state }),
233
+ setSelected: setSelected({ api: api2, constants, nextTick, props, vm, state }),
234
234
  selectOption: selectOption({ api: api2, state, props }),
235
235
  handleResize: handleResize({ api: api2, props }),
236
236
  watchOptions: watchOptions({ api: api2, constants, nextTick, parent, props, state }),
@@ -327,27 +327,37 @@ const initApi = ({
327
327
  };
328
328
  const addWatch = ({ watch, props, api: api2, state }) => {
329
329
  watch(() => [...state.options], api2.watchOptions);
330
- watch(() => state.gridData, api2.setSelected, { immediate: true });
331
- watch(() => state.treeData, api2.setSelected, { immediate: true });
330
+ if (props.renderType === "grid") {
331
+ watch(() => state.gridData, api2.setSelected, { immediate: true });
332
+ }
333
+ if (props.renderType === "tree") {
334
+ watch(() => state.treeData, api2.setSelected, { immediate: true });
335
+ }
332
336
  watch(() => state.hoverIndex, api2.watchHoverIndex);
333
- props.options && watch(() => props.options, api2.watchPropsOption, { immediate: true, deep: true });
337
+ if (props.options) {
338
+ watch(() => props.options, api2.watchPropsOption, { immediate: true, deep: true });
339
+ }
334
340
  watch(() => state.optimizeOpts, api2.watchOptimizeOpts);
335
341
  };
336
342
  const initWatch = ({ watch, props, api: api2, state, nextTick, refs }) => {
337
- props.treeOp.data && watch(
338
- () => props.treeOp.data,
339
- (data) => {
340
- state.treeData = data;
341
- },
342
- { immediate: true, deep: true }
343
- );
344
- props.gridOp.data && watch(
345
- () => props.gridOp.data,
346
- (data) => {
347
- state.gridData = data;
348
- },
349
- { immediate: true, deep: true }
350
- );
343
+ if (props.renderType === "tree" && props.treeOp.data) {
344
+ watch(
345
+ () => props.treeOp.data,
346
+ (data) => {
347
+ state.treeData = data;
348
+ },
349
+ { immediate: true, deep: true }
350
+ );
351
+ }
352
+ if (props.renderType === "grid" && props.gridOp.data) {
353
+ watch(
354
+ () => props.gridOp.data,
355
+ (data) => {
356
+ state.gridData = data;
357
+ },
358
+ { immediate: true, deep: true }
359
+ );
360
+ }
351
361
  watch(
352
362
  () => state.selectDisabled,
353
363
  () => nextTick(api2.resetInputHeight)