@opentiny/vue-renderless 3.8.3 → 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 (65) hide show
  1. package/action-sheet/index.js +1 -1
  2. package/action-sheet/vue.js +12 -12
  3. package/alert/index.js +2 -2
  4. package/alert/vue.js +3 -3
  5. package/anchor/index.js +40 -23
  6. package/anchor/vue.js +5 -2
  7. package/button-group/index.js +6 -0
  8. package/button-group/vue.js +10 -5
  9. package/carousel/index.js +18 -20
  10. package/carousel/vue.js +29 -5
  11. package/carousel-item/index.js +2 -1
  12. package/carousel-item/vue.js +14 -2
  13. package/cascader/index.js +110 -11
  14. package/cascader/vue.js +35 -12
  15. package/chart-heatmap/index.js +12 -12
  16. package/checkbox/index.js +19 -6
  17. package/checkbox/vue.js +38 -20
  18. package/common/bigInt.js +2 -1
  19. package/common/browser.js +43 -37
  20. package/common/deps/ResizeObserver.js +2 -2
  21. package/common/deps/popper.js +26 -24
  22. package/common/index.js +1 -1
  23. package/common/runtime.js +1 -1
  24. package/common/validate/util.js +3 -2
  25. package/drawer/index.js +16 -1
  26. package/drawer/vue.js +14 -3
  27. package/dropdown-item/mf.js +1 -1
  28. package/dropdown-menu/index.js +3 -0
  29. package/dropdown-menu/vue.js +20 -2
  30. package/file-upload/index.js +0 -1
  31. package/grid/utils/column.js +1 -0
  32. package/grid/utils/dom.js +2 -2
  33. package/image/vue.js +12 -1
  34. package/input/index.js +15 -3
  35. package/input/vue.js +34 -8
  36. package/ip-address/index.js +4 -4
  37. package/month-table/index.js +5 -2
  38. package/numeric/index.js +6 -3
  39. package/numeric/vue.js +1 -1
  40. package/package.json +8 -1
  41. package/pager/vue.js +2 -2
  42. package/popconfirm/index.js +1 -0
  43. package/popconfirm/vue.js +4 -2
  44. package/popover/index.js +19 -12
  45. package/popover/vue.js +15 -5
  46. package/progress/index.js +44 -6
  47. package/progress/vue.js +15 -4
  48. package/radio/index.js +2 -0
  49. package/radio/vue.js +3 -0
  50. package/record/index.js +166 -59
  51. package/record/vue.js +31 -14
  52. package/roles/index.js +5 -5
  53. package/roles/vue.js +1 -1
  54. package/slider/index.js +3 -1
  55. package/steps/index.js +8 -0
  56. package/steps/vue.js +3 -2
  57. package/switch/vue.js +9 -2
  58. package/tabs-mf/vue-bar.js +1 -1
  59. package/text-popup/vue.js +2 -1
  60. package/time-line/index.js +8 -0
  61. package/time-line/vue.js +2 -1
  62. package/tooltip/index.js +35 -25
  63. package/tooltip/vue.js +1 -1
  64. package/tree/index.js +1 -1
  65. package/user-head/vue.js +8 -1
@@ -22,7 +22,7 @@ const setSheetStyle = ({ state, props }) => () => {
22
22
  const initScrollMenu = ({ state, nextTick, refs, BScroll }) => () => {
23
23
  nextTick(() => {
24
24
  const { scrollMenu } = refs;
25
- if (state.scroll) {
25
+ if (!state.scroll) {
26
26
  state.scroll = new BScroll(scrollMenu, {
27
27
  probeType: 3,
28
28
  tap: "tap"
@@ -1,6 +1,6 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
2
  import { setSheetStyle, initScrollMenu, visibleHandle, watchVisible, menuHandle, close, selectOption, confirm, actionSelectOption, hide } from "./index";
3
- const api = ["state", "setSheetStyle", "initScrollMenu", "visibleHandle", "menuHandle", "close", "selectOption", "confirm", "actionSelectOption", "hide"];
3
+ const api = ["state", "setSheetStyle", "initScrollMenu", "visibleHandle", "watchVisible", "menuHandle", "close", "selectOption", "confirm", "actionSelectOption", "hide"];
4
4
  const renderless = (props, { reactive, watch }, { emit, nextTick, refs, vm }, { BScroll }) => {
5
5
  const api2 = {};
6
6
  const state = reactive({
@@ -10,17 +10,6 @@ const renderless = (props, { reactive, watch }, { emit, nextTick, refs, vm }, {
10
10
  sheetContentStyle: {},
11
11
  scroll: null
12
12
  });
13
- watch(
14
- () => props.visible,
15
- (value) => {
16
- if (value) {
17
- api2.setSheetStyle({ state, props });
18
- api2.initScrollMenu({ state, nextTick, refs, BScroll });
19
- }
20
- api2.watchVisible(value);
21
- }
22
- );
23
- watch(() => props.visible, api2.watchVisible, { immediate: true });
24
13
  Object.assign(api2, {
25
14
  state,
26
15
  setSheetStyle: setSheetStyle({ state, props }),
@@ -34,6 +23,17 @@ const renderless = (props, { reactive, watch }, { emit, nextTick, refs, vm }, {
34
23
  close: close({ emit, vm }),
35
24
  hide: hide(emit)
36
25
  });
26
+ watch(
27
+ () => props.visible,
28
+ (value) => {
29
+ if (value) {
30
+ api2.setSheetStyle({ state, props });
31
+ api2.initScrollMenu({ state, nextTick, refs, BScroll });
32
+ }
33
+ api2.watchVisible(value);
34
+ }
35
+ );
36
+ watch(() => props.visible, api2.watchVisible, { immediate: true });
37
37
  return api2;
38
38
  };
39
39
  export {
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
@@ -22,9 +22,7 @@ const setScrollContainer = ({ state, api, cb = null }) => {
22
22
  const currentContainer = api.getContainer();
23
23
  const { scrollContainer } = state;
24
24
  if (scrollContainer !== currentContainer) {
25
- removeClass(scrollContainer, "tiny-anchor-scroll-container");
26
25
  state.scrollContainer = currentContainer;
27
- addClass(currentContainer, "tiny-anchor-scroll-container");
28
26
  cb && cb();
29
27
  }
30
28
  };
@@ -51,7 +49,7 @@ const updateSkidPosition = ({ vm, state, emit }) => {
51
49
  }
52
50
  };
53
51
  const getCurrentAnchor = ({ vm, state, link, emit }) => {
54
- if (state.currentLink === link) {
52
+ if (state.currentLink === link || state.isScroll) {
55
53
  return;
56
54
  }
57
55
  state.currentLink = link;
@@ -80,12 +78,24 @@ const setCurrentHash = (state) => {
80
78
  }
81
79
  return false;
82
80
  };
81
+ const handleScroll = (state) => {
82
+ clearTimeout(state.scrollTimer);
83
+ state.scrollTimer = setTimeout(() => {
84
+ state.isScroll = false;
85
+ clearTimeout(state.scrollTimer);
86
+ }, 500);
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
+ };
83
92
  const getContainer = ({ props }) => () => props.containerId ? document.querySelector(props.containerId) : document.body;
84
- const mounted = ({ vm, state, api }) => () => {
93
+ const mounted = ({ vm, state, api, props }) => () => {
85
94
  setScrollContainer({ state, api });
86
95
  setFixAnchor({ vm });
87
96
  api.onItersectionObserver();
88
97
  setCurrentHash(state);
98
+ setChildOffsetTop({ state, props });
89
99
  };
90
100
  const updated = ({ state, api }) => () => {
91
101
  const cb = api.onItersectionObserver;
@@ -94,33 +104,39 @@ const updated = ({ state, api }) => () => {
94
104
  const unmounted = ({ state }) => () => {
95
105
  const { intersectionObserver } = state;
96
106
  intersectionObserver.disconnect();
107
+ state.scrollContainer.removeEventListener("scroll", handleScroll(state));
97
108
  };
98
109
  const onItersectionObserver = ({ vm, state, props, emit }) => () => {
99
110
  const { expandLink, scrollContainer } = state;
100
- const containerTop = scrollContainer.getBoundingClientRect().top + 10;
101
- state.intersectionObserver = new IntersectionObserver((entries) => {
102
- entries.forEach((item) => {
103
- const key = item.target.id;
104
- state.observerLinks[key] = item;
105
- });
106
- for (let key in state.observerLinks) {
107
- if (Object.prototype.hasOwnProperty.call(state.observerLinks, key)) {
108
- const item = state.observerLinks[key];
109
- if (item.isIntersecting && item.intersectionRatio >= 0 && item.target.getBoundingClientRect().top < containerTop) {
110
- const link = `#${item.target.id}`;
111
- if (!expandLink[link].children) {
112
- getCurrentAnchor({ vm, state, link, emit });
113
- break;
114
- } else {
115
- 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
+ }
116
130
  }
117
131
  }
118
132
  }
119
- }
120
- });
133
+ },
134
+ { root: scrollContainer, threshold: [0] }
135
+ );
121
136
  addObserver({ props, state });
122
137
  };
123
138
  const linkClick = ({ state, vm, emit, props }) => (e, item) => {
139
+ state.isScroll = true;
124
140
  const { link, title } = item;
125
141
  const emitLink = { link, title };
126
142
  emit("linkClick", e, emitLink);
@@ -131,9 +147,10 @@ const linkClick = ({ state, vm, emit, props }) => (e, item) => {
131
147
  setMarkClass({ state, props });
132
148
  if (scrollContainer !== document.body && !isChangeHash) {
133
149
  const linkEl = scrollContainer.querySelector(item.link);
134
- const top = linkEl.offsetTop;
150
+ const top = linkEl.offsetTop - scrollContainer.offsetTop;
135
151
  const param = { top, left: 0, behavior: "smooth" };
136
152
  scrollContainer.scrollTo(param);
153
+ scrollContainer.addEventListener("scroll", handleScroll(state));
137
154
  }
138
155
  };
139
156
  export {
package/anchor/vue.js CHANGED
@@ -9,11 +9,14 @@ const renderless = (props, { onMounted, onUnmounted, onUpdated, reactive }, { vm
9
9
  expandLink: {},
10
10
  intersectionObserver: null,
11
11
  scrollContainer: null,
12
- currentHash: ""
12
+ currentHash: "",
13
+ isScroll: false,
14
+ scrollTimer: null,
15
+ offsetTop: 0
13
16
  });
14
17
  Object.assign(api2, {
15
18
  state,
16
- mounted: mounted({ vm, state, api: api2 }),
19
+ mounted: mounted({ vm, state, api: api2, props }),
17
20
  updated: updated({ state, api: api2 }),
18
21
  unmounted: unmounted({ state }),
19
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,7 +1,7 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- import { handleClick, moreNodeClick } from "./index";
3
- const api = ["state", "handleClick", "moreNodeClick"];
4
- function renderless(props, { computed, reactive, watch, inject }, { emit, parent }) {
2
+ import { handleClick, moreNodeClick, handleChange } from "./index";
3
+ const api = ["state", "handleClick", "moreNodeClick", "handleChange"];
4
+ const renderless = (props, { computed, reactive, watch, inject }, { emit, parent }) => {
5
5
  var _a, _b;
6
6
  parent.tinyForm = parent.tinyForm || inject("form", null);
7
7
  const state = reactive({
@@ -26,13 +26,18 @@ function 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
+ };
36
41
  export {
37
42
  api,
38
43
  renderless
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
  };