@opentiny/vue-renderless 3.8.4 → 3.9.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.
Files changed (56) hide show
  1. package/alert/index.js +2 -2
  2. package/alert/vue.js +3 -3
  3. package/anchor/index.js +28 -19
  4. package/anchor/vue.js +3 -2
  5. package/button-group/index.js +6 -0
  6. package/button-group/vue.js +8 -3
  7. package/carousel/index.js +18 -20
  8. package/carousel/vue.js +29 -5
  9. package/carousel-item/index.js +2 -1
  10. package/carousel-item/vue.js +14 -2
  11. package/cascader/index.js +110 -11
  12. package/cascader/vue.js +35 -12
  13. package/chart-heatmap/index.js +12 -12
  14. package/checkbox/index.js +19 -6
  15. package/checkbox/vue.js +38 -20
  16. package/common/bigInt.js +2 -1
  17. package/common/browser.js +43 -37
  18. package/common/deps/ResizeObserver.js +2 -2
  19. package/common/deps/popper.js +26 -24
  20. package/common/validate/util.js +2 -2
  21. package/drawer/index.js +16 -1
  22. package/drawer/vue.js +14 -3
  23. package/dropdown-menu/index.js +3 -0
  24. package/dropdown-menu/vue.js +20 -2
  25. package/grid/utils/dom.js +2 -2
  26. package/image/vue.js +12 -1
  27. package/input/index.js +15 -3
  28. package/input/vue.js +34 -8
  29. package/ip-address/index.js +4 -4
  30. package/month-table/index.js +5 -2
  31. package/numeric/index.js +6 -3
  32. package/numeric/vue.js +1 -1
  33. package/package.json +8 -1
  34. package/popconfirm/index.js +1 -0
  35. package/popconfirm/vue.js +4 -2
  36. package/popover/index.js +19 -12
  37. package/popover/vue.js +15 -5
  38. package/progress/index.js +44 -6
  39. package/progress/vue.js +15 -4
  40. package/radio/index.js +2 -0
  41. package/radio/vue.js +3 -0
  42. package/record/index.js +166 -59
  43. package/record/vue.js +31 -14
  44. package/roles/index.js +5 -5
  45. package/roles/vue.js +1 -1
  46. package/slider/index.js +3 -1
  47. package/steps/index.js +8 -0
  48. package/steps/vue.js +3 -2
  49. package/tabs-mf/vue-bar.js +1 -1
  50. package/text-popup/vue.js +2 -1
  51. package/time-line/index.js +8 -0
  52. package/time-line/vue.js +2 -1
  53. package/tooltip/index.js +35 -25
  54. package/tooltip/vue.js +1 -1
  55. package/tree/index.js +1 -1
  56. package/user-head/vue.js +8 -1
package/alert/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- const close = ({ emit, state }) => () => {
2
+ const handleClose = ({ emit, state }) => () => {
3
3
  state.show = false;
4
4
  emit("close");
5
5
  };
@@ -27,8 +27,8 @@ const handleHeaderClick = ({ state, props, vm }) => () => {
27
27
  }
28
28
  };
29
29
  export {
30
- close,
31
30
  computedGetIcon,
32
31
  computedGetTitle,
32
+ handleClose,
33
33
  handleHeaderClick
34
34
  };
package/alert/vue.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- import { close, computedGetIcon, computedGetTitle, handleHeaderClick } from "./index";
3
- const api = ["close", "state", "handleHeaderClick"];
2
+ import { handleClose, computedGetIcon, computedGetTitle, handleHeaderClick } from "./index";
3
+ const api = ["handleClose", "state", "handleHeaderClick"];
4
4
  const renderless = (props, { computed, reactive }, { t, emit, constants, vm, designConfig }) => {
5
5
  const state = reactive({
6
6
  show: true,
@@ -16,7 +16,7 @@ const renderless = (props, { computed, reactive }, { t, emit, constants, vm, des
16
16
  state,
17
17
  computedGetIcon: computedGetIcon({ constants, props, designConfig }),
18
18
  computedGetTitle: computedGetTitle({ constants, props, t }),
19
- close: close({ state, emit }),
19
+ handleClose: handleClose({ emit, state }),
20
20
  handleHeaderClick: handleHeaderClick({ state, props, vm })
21
21
  };
22
22
  return api2;
package/anchor/index.js CHANGED
@@ -85,12 +85,17 @@ const handleScroll = (state) => {
85
85
  clearTimeout(state.scrollTimer);
86
86
  }, 500);
87
87
  };
88
+ const setChildOffsetTop = ({ state, props }) => {
89
+ var _a;
90
+ state.offsetTop = ((_a = document.querySelector(props.links[0].link)) == null ? void 0 : _a.offsetTop) || 0;
91
+ };
88
92
  const getContainer = ({ props }) => () => props.containerId ? document.querySelector(props.containerId) : document.body;
89
- const mounted = ({ vm, state, api }) => () => {
93
+ const mounted = ({ vm, state, api, props }) => () => {
90
94
  setScrollContainer({ state, api });
91
95
  setFixAnchor({ vm });
92
96
  api.onItersectionObserver();
93
97
  setCurrentHash(state);
98
+ setChildOffsetTop({ state, props });
94
99
  };
95
100
  const updated = ({ state, api }) => () => {
96
101
  const cb = api.onItersectionObserver;
@@ -103,27 +108,31 @@ const unmounted = ({ state }) => () => {
103
108
  };
104
109
  const onItersectionObserver = ({ vm, state, props, emit }) => () => {
105
110
  const { expandLink, scrollContainer } = state;
106
- const containerTop = scrollContainer.getBoundingClientRect().top + 10;
107
- state.intersectionObserver = new IntersectionObserver((entries) => {
108
- entries.forEach((item) => {
109
- const key = item.target.id;
110
- state.observerLinks[key] = item;
111
- });
112
- for (let key in state.observerLinks) {
113
- if (Object.prototype.hasOwnProperty.call(state.observerLinks, key)) {
114
- const item = state.observerLinks[key];
115
- if (item.isIntersecting && item.intersectionRatio >= 0 && item.target.getBoundingClientRect().top < containerTop) {
116
- const link = `#${item.target.id}`;
117
- if (!expandLink[link].children) {
118
- getCurrentAnchor({ vm, state, link, emit });
119
- break;
120
- } else {
121
- getCurrentAnchor({ vm, state, link, emit });
111
+ state.intersectionObserver = new IntersectionObserver(
112
+ (entries) => {
113
+ const { top } = scrollContainer.getBoundingClientRect();
114
+ const scrollStartTop = top + state.offsetTop;
115
+ entries.forEach((item) => {
116
+ const key = item.target.id;
117
+ state.observerLinks[key] = item;
118
+ });
119
+ for (let key in state.observerLinks) {
120
+ if (Object.prototype.hasOwnProperty.call(state.observerLinks, key)) {
121
+ const item = state.observerLinks[key];
122
+ if (item.isIntersecting && item.intersectionRatio >= 0 && item.target.getBoundingClientRect().top < scrollStartTop) {
123
+ const link = `#${item.target.id}`;
124
+ if (!expandLink[link].children) {
125
+ getCurrentAnchor({ vm, state, link, emit });
126
+ break;
127
+ } else {
128
+ getCurrentAnchor({ vm, state, link, emit });
129
+ }
122
130
  }
123
131
  }
124
132
  }
125
- }
126
- });
133
+ },
134
+ { root: scrollContainer, threshold: [0] }
135
+ );
127
136
  addObserver({ props, state });
128
137
  };
129
138
  const linkClick = ({ state, vm, emit, props }) => (e, item) => {
package/anchor/vue.js CHANGED
@@ -11,11 +11,12 @@ const renderless = (props, { onMounted, onUnmounted, onUpdated, reactive }, { vm
11
11
  scrollContainer: null,
12
12
  currentHash: "",
13
13
  isScroll: false,
14
- scrollTimer: null
14
+ scrollTimer: null,
15
+ offsetTop: 0
15
16
  });
16
17
  Object.assign(api2, {
17
18
  state,
18
- mounted: mounted({ vm, state, api: api2 }),
19
+ mounted: mounted({ vm, state, api: api2, props }),
19
20
  updated: updated({ state, api: api2 }),
20
21
  unmounted: unmounted({ state }),
21
22
  getContainer: getContainer({ props }),
@@ -1,4 +1,9 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
+ const handleChange = ({ emit, state }) => () => {
3
+ if (!state.disabled) {
4
+ emit("change", state.value);
5
+ }
6
+ };
2
7
  const handleClick = ({ emit, props, state }) => (node) => {
3
8
  if (!state.disabled) {
4
9
  state.value = node[props.valueField];
@@ -15,6 +20,7 @@ const moreNodeClick = ({ emit, props, state }) => (node) => {
15
20
  }
16
21
  };
17
22
  export {
23
+ handleChange,
18
24
  handleClick,
19
25
  moreNodeClick
20
26
  };
@@ -1,6 +1,6 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- import { handleClick, moreNodeClick } from "./index";
3
- const api = ["state", "handleClick", "moreNodeClick"];
2
+ import { handleClick, moreNodeClick, handleChange } from "./index";
3
+ const api = ["state", "handleClick", "moreNodeClick", "handleChange"];
4
4
  const renderless = (props, { computed, reactive, watch, inject }, { emit, parent }) => {
5
5
  var _a, _b;
6
6
  parent.tinyForm = parent.tinyForm || inject("form", null);
@@ -26,10 +26,15 @@ const renderless = (props, { computed, reactive, watch, inject }, { emit, parent
26
26
  },
27
27
  { immediate: true }
28
28
  );
29
+ watch(
30
+ () => state.value,
31
+ () => api2.handleChange()
32
+ );
29
33
  const api2 = {
30
34
  state,
31
35
  handleClick: handleClick({ emit, props, state }),
32
- moreNodeClick: moreNodeClick({ emit, props, state })
36
+ moreNodeClick: moreNodeClick({ emit, props, state }),
37
+ handleChange: handleChange({ emit, state })
33
38
  };
34
39
  return api2;
35
40
  };
package/carousel/index.js CHANGED
@@ -1,6 +1,20 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
2
  import throttle from "../common/deps/throttle";
3
3
  import { POSITION } from "../common";
4
+ const pauseTimer = (state) => () => clearInterval(state.timer);
5
+ const playSlides = ({ props, state }) => () => {
6
+ if (state.activeIndex < state.items.length - 1) {
7
+ state.activeIndex++;
8
+ } else if (props.loop) {
9
+ state.activeIndex = 0;
10
+ }
11
+ };
12
+ const startTimer = ({ api, props, state }) => () => {
13
+ if (props.interval <= 0 || !props.autoplay) {
14
+ return;
15
+ }
16
+ state.timer = setInterval(api.playSlides, props.interval);
17
+ };
4
18
  const handleMouseEnter = ({ api, state }) => () => {
5
19
  state.hover = true;
6
20
  api.pauseTimer();
@@ -38,26 +52,10 @@ const resetItemPosition = (state) => (oldIndex) => {
38
52
  });
39
53
  }
40
54
  };
41
- const playSlides = ({ props, state }) => () => {
42
- if (state.activeIndex < state.items.length - 1) {
43
- state.activeIndex++;
44
- } else if (props.loop) {
45
- state.activeIndex = 0;
46
- }
47
- };
48
- const pauseTimer = (state) => () => clearInterval(state.timer);
49
- const startTimer = ({ api, props, state }) => () => {
50
- if (props.interval <= 0 || !props.autoplay) {
51
- return;
52
- }
53
- state.timer = setInterval(api.playSlides, props.interval);
54
- };
55
55
  const setActiveItem = ({ api, props, state }) => (index) => {
56
56
  if (typeof index === "string") {
57
- const filteredItems = state.items.filter((item) => item.name === index);
58
- if (filteredItems.length > 0) {
59
- index = state.items.indexOf(filteredItems[0]);
60
- }
57
+ const filteredItems = state.items.findIndex((item) => item.name === index);
58
+ index = filteredItems === -1 ? index : filteredItems;
61
59
  }
62
60
  index = Number(index);
63
61
  if (isNaN(index) || index !== Math.floor(index)) {
@@ -98,7 +96,7 @@ const watchActiveIndex = ({ emit, api }) => ({ value, oldValue }) => {
98
96
  const watchAutoplay = (api) => (value) => value ? api.startTimer() : api.pauseTimer();
99
97
  const throttledArrowClick = (api) => throttle(300, true, (index) => api.setActiveItem(index));
100
98
  const throttledIndicatorHover = (api) => throttle(300, (index) => api.handleIndicatorHover(index));
101
- const computedHasLable = (items) => items.some((item) => item.label.toString().length > 0);
99
+ const computedHasLabel = (items) => items.some((item) => item.label.toString().length > 0);
102
100
  const computedStyle = ({ props }) => () => {
103
101
  if (props.height) {
104
102
  return { "height": props.height };
@@ -192,7 +190,7 @@ function resetTouchStatus(state) {
192
190
  state.offsetPos.Y = 0;
193
191
  }
194
192
  export {
195
- computedHasLable,
193
+ computedHasLabel,
196
194
  computedStyle,
197
195
  handleButtonEnter,
198
196
  handleButtonLeave,
package/carousel/vue.js CHANGED
@@ -20,10 +20,11 @@ import {
20
20
  watchAutoplay,
21
21
  throttledArrowClick,
22
22
  throttledIndicatorHover,
23
- computedHasLable,
23
+ computedHasLabel,
24
24
  touchstart,
25
25
  touchmove,
26
- touchend
26
+ touchend,
27
+ computedStyle
27
28
  } from "./index";
28
29
  import { addResizeListener, removeResizeListener } from "../common/deps/resize-event";
29
30
  const api = [
@@ -58,19 +59,41 @@ const api = [
58
59
  const initState = ({ reactive, computed, api: api2 }) => {
59
60
  const state = reactive({
60
61
  items: [],
62
+ itemsTranslate: [],
61
63
  timer: null,
62
64
  hover: false,
63
65
  activeIndex: -1,
64
66
  completed: false,
65
67
  containerWidth: 0,
66
- hasLabel: computed(() => api2.computedHasLable(state.items))
68
+ delta: 0,
69
+ startPos: {
70
+ X: 0,
71
+ Y: 0
72
+ },
73
+ deltaPos: {
74
+ X: 0,
75
+ Y: 0
76
+ },
77
+ offsetPos: {
78
+ X: 0,
79
+ Y: 0
80
+ },
81
+ touchTime: 0,
82
+ direction: "",
83
+ size: 0,
84
+ moving: false,
85
+ moveDisable: false,
86
+ isCorrectDirection: false,
87
+ noTouchNode: ["svg", "BUTTON", "path", "g"],
88
+ style: computed(() => api2.computedStyle()),
89
+ hasLabel: computed(() => api2.computedHasLabel(state.items))
67
90
  });
68
91
  return state;
69
92
  };
70
93
  const initApi = ({ api: api2, state, props, emit, vm }) => {
71
94
  Object.assign(api2, {
72
95
  state,
73
- computedHasLable,
96
+ computedHasLabel,
74
97
  touchstart: touchstart({ state, api: api2 }),
75
98
  touchmove: touchmove({ props, state, vm }),
76
99
  touchend: touchend({ state, api: api2 }),
@@ -93,7 +116,8 @@ const initApi = ({ api: api2, state, props, emit, vm }) => {
93
116
  handleMouseLeave: handleMouseLeave({ api: api2, state }),
94
117
  handleButtonEnter: handleButtonEnter({ api: api2, state }),
95
118
  throttledArrowClick: throttledArrowClick(api2),
96
- throttledIndicatorHover: throttledIndicatorHover(api2)
119
+ throttledIndicatorHover: throttledIndicatorHover(api2),
120
+ computedStyle: computedStyle({ props })
97
121
  });
98
122
  };
99
123
  const initWatch = ({ watch, props, api: api2, state }) => {
@@ -28,6 +28,7 @@ const translateItem = ({ api, CARD_SCALE, parent, state }) => ({ activeIndex, in
28
28
  if (vnode.type !== TYPE_CARD && oldIndex !== void 0) {
29
29
  state.animating = index === activeIndex || index === oldIndex;
30
30
  }
31
+ state.animatingMf = [activeIndex, oldIndex].indexOf(index) < 0;
31
32
  if (index !== activeIndex && length > 2 && vnode.loop) {
32
33
  index = api.processIndex({ index, activeIndex, length });
33
34
  }
@@ -54,7 +55,7 @@ const handleItemClick = (parent) => () => {
54
55
  }
55
56
  };
56
57
  const computedTransform = ({ parent, TYPE_VERTICAL }) => (state) => {
57
- const TRANSLATE = parent.$parent.type === TYPE_VERTICAL ? `translateY(${state.translate}px) scale(${state.scale})` : `translateX(${state.translate}px) scale(${state.scale})`;
58
+ const TRANSLATE = parent.$parent.type === TYPE_VERTICAL ? `translateY(${state.translate + state.delta}px) scale(${state.scale})` : `translateX(${state.translate + state.delta}px) scale(${state.scale})`;
58
59
  return {
59
60
  msTransform: TRANSLATE,
60
61
  webkitTransform: TRANSLATE,
@@ -1,5 +1,13 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- import { processIndex, calculateTranslate, translateItem, handleItemClick, computedTransform, resetAnimatingMf, setDelta } from "./index";
2
+ import {
3
+ processIndex,
4
+ calculateTranslate,
5
+ translateItem,
6
+ handleItemClick,
7
+ computedTransform,
8
+ resetAnimatingMf,
9
+ setDelta
10
+ } from "./index";
3
11
  const api = [
4
12
  "state",
5
13
  "hover",
@@ -31,10 +39,14 @@ const renderless = (props, { computed, onMounted, onUnmounted, reactive }, { par
31
39
  active: false,
32
40
  inStage: false,
33
41
  animating: false,
42
+ animatingMf: false,
34
43
  isOblique: false,
35
44
  carouselParent: parent.$parent,
36
45
  hasTitle: computed(() => !!props.title),
37
- getTransform: computed(() => api2.computedTransform(state))
46
+ moving: computed(() => parent.$parent.state.moving),
47
+ animate: computed(() => Math.abs(parent.$parent.state.delta) > 0 ? !state.animatingMf : state.animating),
48
+ getTransform: computed(() => api2.computedTransform(state)),
49
+ delta: 0
38
50
  });
39
51
  Object.assign(api2, {
40
52
  state,
package/cascader/index.js CHANGED
@@ -47,7 +47,7 @@ const computePresentContent = ({ api, state }) => () => {
47
47
  const watchValue = ({ api, state }) => (value) => {
48
48
  if (!isEqual(value, state.checkedValue)) {
49
49
  state.checkedValue = value;
50
- api.computePresentContent();
50
+ setTimeout(api.computePresentContent);
51
51
  }
52
52
  };
53
53
  const watchCheckedValue = ({ api, emit, state }) => (value) => {
@@ -88,7 +88,7 @@ const isEmpty = (val) => {
88
88
  const selfMounted = ({ api, parent, props, refs, state }) => () => {
89
89
  const { input } = refs;
90
90
  const inputSizeMap = { medium: 36, small: 32, mini: 28 };
91
- input.$parent.popperElm = refs.popper;
91
+ input && (input.$parent.popperElm = refs.popper);
92
92
  if (input && input.$el) {
93
93
  state.inputInitialHeight = input.$el.offsetHeight || inputSizeMap[state.realSize] || 30;
94
94
  }
@@ -154,8 +154,13 @@ const handleKeyDown = ({ api }) => (event) => {
154
154
  const handleFocus = (emit) => (e) => {
155
155
  emit("focus", e);
156
156
  };
157
- const handleBlur = ({ constants, dispatch, emit, state }) => (e) => {
158
- dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.FormBlur, [state.multiple ? state.presentText : state.inputValue]);
157
+ const handleBlur = ({ constants, dispatch, emit, state, api, props }) => (e) => {
158
+ if (props.filterable) {
159
+ api.computePresentContent();
160
+ }
161
+ dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.FormBlur, [
162
+ state.multiple ? state.presentText : state.inputValue
163
+ ]);
159
164
  emit("blur", e);
160
165
  };
161
166
  const handleInput = ({ api, state, refs }) => (val, event) => {
@@ -188,7 +193,9 @@ const handleClear = (state) => () => {
188
193
  };
189
194
  const handleExpandChange = ({ constants, dispatch, emit, nextTick, state, updatePopper }) => (value) => {
190
195
  nextTick(() => {
191
- dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.FormBlur, [state.multiple ? state.presentText : state.inputValue]);
196
+ dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.FormBlur, [
197
+ state.multiple ? state.presentText : state.inputValue
198
+ ]);
192
199
  updatePopper(state.panel.$parent);
193
200
  });
194
201
  emit("expand-change", value);
@@ -241,7 +248,74 @@ const computePresentTags = ({ api, props, state }) => () => {
241
248
  }
242
249
  state.checkedNodes = checkedNodes;
243
250
  state.presentTags = tags;
251
+ if (props.hoverExpand) {
252
+ api.calcCollapseTags();
253
+ }
254
+ };
255
+ const calcCollapseTags = ({ state, refs, nextTick }) => () => {
256
+ nextTick(() => {
257
+ const content = refs["tags-content"];
258
+ if (state.inputHover || state.dropDownVisible) {
259
+ return state.isHidden = true;
260
+ }
261
+ if (content) {
262
+ const { width: contentWidth, paddingLeft, paddingRight } = content && window.getComputedStyle(content);
263
+ const contentWidthTotal = content && parseFloat(contentWidth) - parseFloat(paddingLeft) - parseFloat(paddingRight);
264
+ const tagsLength = content.querySelector(".tiny-cascader__tags-collapse");
265
+ const {
266
+ width: collapseTagContentWidth,
267
+ marginRight,
268
+ marginLeft
269
+ } = tagsLength && window.getComputedStyle(tagsLength);
270
+ const collapseTagWidth = tagsLength && parseFloat(collapseTagContentWidth) + parseFloat(marginRight) + parseFloat(marginLeft);
271
+ const tags = Array.from(content.querySelectorAll(".tiny-tag"));
272
+ let { total, dom, idx } = { total: collapseTagWidth, dom: null, idx: 0 };
273
+ tags.some((tag, index) => {
274
+ if (tag !== tagsLength) {
275
+ const { width: tagContentWidth, marginRight: marginRight2, marginLeft: marginLeft2 } = tag && window.getComputedStyle(tag);
276
+ total += parseFloat(tagContentWidth) + parseFloat(marginRight2) + parseFloat(marginLeft2);
277
+ }
278
+ if (tag !== tagsLength && total > contentWidthTotal && !dom) {
279
+ dom = tag;
280
+ idx = index;
281
+ }
282
+ });
283
+ let isOneLine = total - collapseTagWidth <= contentWidthTotal;
284
+ if (isOneLine) {
285
+ return state.isHidden = true;
286
+ }
287
+ if (dom) {
288
+ dom.before(tagsLength);
289
+ state.isHidden = false;
290
+ } else {
291
+ state.isHidden = true;
292
+ }
293
+ state.collapseTagsLength = tags.length - idx;
294
+ }
295
+ });
244
296
  };
297
+ const watchInputHover = ({ refs }) => (newVal) => {
298
+ const [inputHover, dropDownVisible] = newVal;
299
+ if (!inputHover && !dropDownVisible) {
300
+ const content = refs["tags-content"];
301
+ content && content.scrollTo({ top: 0, left: 0 });
302
+ }
303
+ };
304
+ const handleMouseenter = ({ refs, state }) => ($event) => {
305
+ const dom = $event.target;
306
+ const textNode = dom && dom.querySelector("span");
307
+ const { tooltip } = refs;
308
+ if (textNode && tooltip && textNode.scrollWidth > textNode.offsetWidth) {
309
+ const text = textNode.textContent;
310
+ tooltip.state.referenceElm = dom;
311
+ tooltip.state.popperElm && (tooltip.state.popperElm.style.display = "none");
312
+ tooltip.doDestroy();
313
+ state.tooltipVisible = true;
314
+ state.tooltipContent = text;
315
+ setTimeout(tooltip.updatePopper, 20);
316
+ }
317
+ };
318
+ const handleMouseleave = ({ state }) => () => state.tooltipVisible = false;
245
319
  const getSuggestions = ({ nextTick, props, state, updatePopper }) => () => {
246
320
  let filterMethod = null;
247
321
  if (!(props.filterMethod && typeof props.filterMethod === "function")) {
@@ -318,7 +392,7 @@ const deleteTag = ({ emit, state }) => (index) => {
318
392
  state.checkedValue = state.checkedValue.filter((n, i) => i !== index);
319
393
  emit("remove-tag", val);
320
394
  };
321
- const updateStyle = ({ parent, refs, state, updatePopper }) => () => {
395
+ const updateStyle = ({ parent, refs, state, updatePopper, nextTick, props }) => () => {
322
396
  const $el = parent.$el;
323
397
  const { suggestionPanel } = refs;
324
398
  const inputInner = $el.querySelector(CASCADER.InputClass);
@@ -333,17 +407,32 @@ const updateStyle = ({ parent, refs, state, updatePopper }) => () => {
333
407
  }
334
408
  if (tags) {
335
409
  const offsetHeight = tags.offsetHeight;
336
- const height = Math.max(offsetHeight + 6, state.inputInitialHeight) + "px";
410
+ let height = 0;
411
+ if (props.hoverExpand && !state.inputHover && !state.dropDownVisible) {
412
+ height = state.inputInitialHeight + "px";
413
+ } else {
414
+ height = Math.max(offsetHeight + 4, state.inputInitialHeight) + "px";
415
+ }
337
416
  inputInner.style.height = height;
338
417
  updatePopper();
418
+ } else {
419
+ nextTick(() => {
420
+ if (state.displayOnly) {
421
+ inputInner.style.height = "auto";
422
+ }
423
+ });
339
424
  }
340
425
  };
341
426
  const getCheckedNodes = (state) => (leafOnly) => state.panel.getCheckedNodes(leafOnly, state.checkedValue);
342
- const setInputHeightToTag = ({ nextTick, parent }) => () => {
427
+ const setInputHeightToTag = ({ nextTick, parent, state }) => () => {
343
428
  nextTick(() => {
344
429
  const parentEl = parent.$el;
345
430
  const height = parentEl.querySelector(CASCADER.TagClass).offsetHeight + 6 + "px";
346
- parentEl.querySelector(CASCADER.InputClass).style.height = height;
431
+ if (!state.isDisplayOnly) {
432
+ parentEl.querySelector(CASCADER.InputClass).style.height = height;
433
+ } else {
434
+ parentEl.querySelector(CASCADER.InputClass).style.height = "auto";
435
+ }
347
436
  });
348
437
  };
349
438
  const presentTextHandler = ({ state, value }) => {
@@ -357,12 +446,18 @@ const presentTextHandler = ({ state, value }) => {
357
446
  }
358
447
  }
359
448
  };
360
- const handleBeforeUpdate = ({ props, api }) => () => {
361
- if (!isEmpty(props.modelValue)) {
449
+ const handleBeforeUpdate = ({ props, api, state }) => () => {
450
+ if (!isEmpty(props.modelValue) && !props.filterable || props.hoverExpand && state.multiple) {
362
451
  api.computePresentContent();
363
452
  }
364
453
  };
454
+ const showPlaceholder = ({ props, state, t, constants }) => () => {
455
+ let placeholder = null;
456
+ placeholder = state.multiple && state.presentTags.length || state.present ? "" : props.placeholder || t(constants.placeholder);
457
+ return placeholder;
458
+ };
365
459
  export {
460
+ calcCollapseTags,
366
461
  computClearVisible,
367
462
  computePresentContent,
368
463
  computePresentTags,
@@ -381,14 +476,18 @@ export {
381
476
  handleFocus,
382
477
  handleInput,
383
478
  handleKeyDown,
479
+ handleMouseenter,
480
+ handleMouseleave,
384
481
  handleSuggestionClick,
385
482
  handleSuggestionKeyDown,
386
483
  isEmpty,
387
484
  presentTextHandler,
388
485
  selfMounted,
389
486
  setInputHeightToTag,
487
+ showPlaceholder,
390
488
  toggleDropDownVisible,
391
489
  updateStyle,
392
490
  watchCheckedValue,
491
+ watchInputHover,
393
492
  watchValue
394
493
  };
package/cascader/vue.js CHANGED
@@ -29,7 +29,12 @@ import {
29
29
  watchValue,
30
30
  setInputHeightToTag,
31
31
  presentTextHandler,
32
- handleBeforeUpdate
32
+ handleBeforeUpdate,
33
+ showPlaceholder,
34
+ calcCollapseTags,
35
+ watchInputHover,
36
+ handleMouseenter,
37
+ handleMouseleave
33
38
  } from "./index";
34
39
  import { removeResizeListener } from "../common/deps/resize-event";
35
40
  import userPopper from "../common/deps/vue-popper";
@@ -49,10 +54,13 @@ const api = [
49
54
  "handleBlur",
50
55
  "handleFocus",
51
56
  "toggleDropDownVisible",
52
- "handleKeyDown"
57
+ "handleKeyDown",
58
+ "handleMouseenter",
59
+ "handleMouseleave"
53
60
  ];
54
- const initState = ({ reactive, props, computed, parent, api: api2, refs, t, constants }) => {
61
+ const initState = ({ reactive, props, computed, parent, api: api2, t, constants, refs, inject }) => {
55
62
  const state = reactive({
63
+ showAutoWidth: inject("showAutoWidth", null),
56
64
  dropDownVisible: false,
57
65
  checkedValue: props.modelValue || null,
58
66
  inputHover: false,
@@ -66,9 +74,11 @@ const initState = ({ reactive, props, computed, parent, api: api2, refs, t, cons
66
74
  pressDeleteCount: 0,
67
75
  realSize: computed(() => props.size),
68
76
  formDisabled: computed(() => (parent.tinyForm || {}).disabled),
69
- disabled: computed(() => props.disabled || state.formDisabled),
77
+ displayOnly: computed(() => props.displayOnly),
78
+ disabled: computed(() => props.disabled || state.isDisplayOnly || state.formDisabled),
70
79
  tagSize: computed(() => ~["small", "mini"].indexOf(state.realSize) ? "mini" : "small"),
71
80
  isDisabled: computed(() => state.disabled),
81
+ isDisplayOnly: computed(() => state.displayOnly || (parent.auiForm || {}).displayOnly),
72
82
  config: computed(() => api2.getConfig()),
73
83
  multiple: computed(() => state.config.multiple),
74
84
  leafOnly: computed(() => !state.config.checkStrictly),
@@ -76,14 +86,17 @@ const initState = ({ reactive, props, computed, parent, api: api2, refs, t, cons
76
86
  clearBtnVisible: computed(() => api2.computClearVisible()),
77
87
  panel: computed(() => refs.panel),
78
88
  placeholder: computed(() => props.placeholder || t(constants.placeholder)),
79
- inputValues: computed(() => state.multiple ? state.presentText : state.inputValue)
89
+ inputValues: computed(() => state.multiple ? state.presentText : state.inputValue),
90
+ collapseTagsLength: 0,
91
+ isHidden: false,
92
+ tooltipVisible: false,
93
+ tooltipContent: ""
80
94
  });
81
95
  return state;
82
96
  };
83
- const initApi = ({ api: api2, state, constants, dispatch, emit, refs, props, updatePopper, nextTick, parent }) => {
97
+ const initApi = ({ api: api2, state, constants, dispatch, emit, refs, props, updatePopper, nextTick, parent, t }) => {
84
98
  Object.assign(api2, {
85
99
  state,
86
- handleBlur: handleBlur({ constants, dispatch, emit, state }),
87
100
  handleFocus: handleFocus(emit),
88
101
  handleClear: handleClear(state),
89
102
  getCheckedNodes: getCheckedNodes(state),
@@ -91,11 +104,12 @@ const initApi = ({ api: api2, state, constants, dispatch, emit, refs, props, upd
91
104
  handleDropdownLeave: handleDropdownLeave(state),
92
105
  focusFirstNode: focusFirstNode({ refs, state }),
93
106
  computClearVisible: computClearVisible({ props, state }),
94
- updateStyle: updateStyle({ parent, refs, state, updatePopper }),
107
+ showPlaceholder: showPlaceholder({ props, state, t, constants }),
108
+ updateStyle: updateStyle({ parent, refs, state, updatePopper, nextTick, props }),
95
109
  getSuggestions: getSuggestions({ nextTick, props, state, updatePopper }),
96
110
  handleExpandChange: handleExpandChange({ constants, emit, dispatch, nextTick, state, updatePopper }),
97
111
  getConfig: getConfig({ parent, props }),
98
- setInputHeightToTag: setInputHeightToTag({ nextTick, parent }),
112
+ setInputHeightToTag: setInputHeightToTag({ nextTick, parent, state }),
99
113
  handleSuggestionClick: handleSuggestionClick({ api: api2, state }),
100
114
  handleDelete: handleDelete({ api: api2, state }),
101
115
  computePresentText: computePresentText({ props, state }),
@@ -108,7 +122,12 @@ const initApi = ({ api: api2, state, constants, dispatch, emit, refs, props, upd
108
122
  watchCheckedValue: watchCheckedValue({ api: api2, emit, state }),
109
123
  toggleDropDownVisible: toggleDropDownVisible({ emit, nextTick, refs, state, updatePopper }),
110
124
  selfMounted: selfMounted({ api: api2, parent, props, refs, state }),
111
- handleBeforeUpdate: handleBeforeUpdate({ props, api: api2 })
125
+ handleBeforeUpdate: handleBeforeUpdate({ props, api: api2, state }),
126
+ handleBlur: handleBlur({ constants, dispatch, emit, state, api: api2, props }),
127
+ calcCollapseTags: calcCollapseTags({ refs, state, nextTick }),
128
+ watchInputHover: watchInputHover({ refs }),
129
+ handleMouseenter: handleMouseenter({ refs, state }),
130
+ handleMouseleave: handleMouseleave({ state })
112
131
  });
113
132
  };
114
133
  const initWatch = ({ watch, state, api: api2, props, nextTick, updatePopper }) => {
@@ -143,6 +162,7 @@ const initWatch = ({ watch, state, api: api2, props, nextTick, updatePopper }) =
143
162
  () => Array.isArray(state.checkedValue) && state.checkedValue.length,
144
163
  () => setTimeout(() => updatePopper())
145
164
  );
165
+ watch([() => state.inputHover, () => state.dropDownVisible], api2.watchInputHover);
146
166
  };
147
167
  const renderless = (props, { computed, onMounted, onBeforeUnmount, onDeactivated, onUpdated, onBeforeUpdate, reactive, toRefs, watch, inject }, { t, refs, emit, nextTick, constants, parent, slots, dispatch }) => {
148
168
  parent.tinyForm = parent.tinyForm || inject("form", null);
@@ -166,12 +186,15 @@ const renderless = (props, { computed, onMounted, onBeforeUnmount, onDeactivated
166
186
  onDeactivated
167
187
  });
168
188
  const api2 = {};
169
- const state = initState({ reactive, props, computed, parent, api: api2, refs, t, constants });
170
- initApi({ api: api2, state, constants, dispatch, emit, refs, props, updatePopper, nextTick, parent });
189
+ const state = initState({ reactive, props, computed, parent, api: api2, t, constants, refs, inject });
190
+ initApi({ api: api2, state, constants, dispatch, emit, refs, props, updatePopper, nextTick, parent, t });
171
191
  initWatch({ watch, state, api: api2, props, nextTick, updatePopper });
172
192
  onBeforeUpdate(api2.handleBeforeUpdate);
173
193
  onUpdated(api2.updateStyle);
174
194
  onMounted(api2.selfMounted);
195
+ parent.$on("handle-clear", (event) => {
196
+ api2.handleClear(event);
197
+ });
175
198
  onBeforeUnmount(() => removeResizeListener(parent.$el, api2.updateStyle));
176
199
  return api2;
177
200
  };