@opentiny/vue-renderless 3.16.0 → 3.17.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 (98) hide show
  1. package/action-sheet/index.js +0 -1
  2. package/base-select/index.js +1510 -0
  3. package/base-select/vue.js +555 -0
  4. package/breadcrumb-item/vue.js +4 -2
  5. package/card/index.js +15 -0
  6. package/card/vue.js +6 -3
  7. package/carousel/index.js +89 -17
  8. package/carousel/vue.js +29 -24
  9. package/carousel-item/index.js +24 -9
  10. package/carousel-item/vue.js +10 -9
  11. package/cascader/vue.js +2 -1
  12. package/cascader-panel/index.js +8 -1
  13. package/cascader-panel/vue.js +1 -1
  14. package/cascader-select/column-index.js +11 -6
  15. package/cascader-select/column.js +8 -5
  16. package/cascader-select/usePicker.js +3 -2
  17. package/checkbox/index.js +0 -17
  18. package/checkbox/vue.js +4 -10
  19. package/collapse-item/vue.js +4 -2
  20. package/common/deps/clickoutside.js +15 -8
  21. package/common/deps/popper.js +15 -1
  22. package/common/deps/throttle.js +7 -0
  23. package/common/deps/touch-emulator.js +1 -1
  24. package/common/deps/tree-model/node.js +1 -0
  25. package/common/deps/tree-model/tree-store.js +4 -1
  26. package/common/deps/useEventListener.js +9 -2
  27. package/common/deps/useInstanceSlots.js +22 -0
  28. package/common/deps/useRelation.js +72 -0
  29. package/common/deps/vue-popper.js +1 -0
  30. package/common/function.js +28 -0
  31. package/common/index.js +1 -1
  32. package/common/runtime.js +1 -1
  33. package/common/type.js +2 -0
  34. package/dialog-box/index.js +0 -22
  35. package/dialog-box/vue.js +1 -4
  36. package/drawer/index.js +27 -29
  37. package/drawer/vue.js +6 -10
  38. package/file-upload/index.js +1 -1
  39. package/fluent-editor/index.js +679 -0
  40. package/fluent-editor/options.js +234 -0
  41. package/fluent-editor/vue.js +192 -0
  42. package/form/index.js +5 -1
  43. package/grid/utils/column.js +4 -2
  44. package/grid/utils/common.js +18 -29
  45. package/grid/utils/event.js +14 -9
  46. package/guide/index.js +6 -5
  47. package/guide/vue.js +2 -2
  48. package/input/index.js +32 -2
  49. package/input/vue.js +21 -2
  50. package/nav-menu/index.js +1 -1
  51. package/numeric/index.js +4 -1
  52. package/option/vue.js +6 -6
  53. package/package.json +1 -1
  54. package/picker/mb.js +6 -1
  55. package/picker/vue.js +2 -1
  56. package/select/index.js +65 -40
  57. package/select/vue.js +1 -1
  58. package/split/index.js +16 -9
  59. package/split/vue.js +7 -2
  60. package/statistic/index.js +7 -0
  61. package/tabs/index.js +37 -13
  62. package/tabs-mf/index.js +116 -13
  63. package/tabs-mf/vue-bar.js +6 -0
  64. package/tabs-mf/vue-nav-item.js +1 -1
  65. package/tabs-mf/vue.js +42 -7
  66. package/tag-group/vue.js +7 -1
  67. package/time/index.js +1 -1
  68. package/time-line/index.js +2 -2
  69. package/time-line/vue.js +4 -13
  70. package/timeline-item/index.js +5 -5
  71. package/timeline-item/vue.js +13 -6
  72. package/tree/index.js +29 -2
  73. package/tree/vue.js +5 -2
  74. package/tree-node/vue.js +2 -1
  75. package/types/action-menu.type.d.ts +12 -4
  76. package/types/cascader-menu.type.d.ts +1 -1
  77. package/types/cascader-node.type.d.ts +1 -1
  78. package/types/{cascader-panel.type-2bd03be3.d.ts → cascader-panel.type-8f58e628.d.ts} +1 -1
  79. package/types/cascader-panel.type.d.ts +1 -1
  80. package/types/cascader.type.d.ts +1 -1
  81. package/types/collapse-item.type.d.ts +3 -0
  82. package/types/dialog-box.type.d.ts +2 -6
  83. package/types/drawer.type.d.ts +28 -30
  84. package/types/form-item.type.d.ts +1 -1
  85. package/types/{form.type-8e30b25c.d.ts → form.type-33aa784a.d.ts} +4 -0
  86. package/types/form.type.d.ts +1 -1
  87. package/types/input.type.d.ts +4 -0
  88. package/types/ip-address.type.d.ts +1 -6
  89. package/types/numeric.type.d.ts +1 -0
  90. package/types/search.type.d.ts +1 -3
  91. package/types/{time-line.type-1b501c41.d.ts → time-line.type-9fb16096.d.ts} +7 -5
  92. package/types/time-line.type.d.ts +1 -1
  93. package/types/timeline-item.type.d.ts +1 -1
  94. package/user/index.js +10 -4
  95. package/year-table/index.js +5 -3
  96. package/year-table/vue.js +1 -1
  97. package/common/deps/letter-only.js +0 -19
  98. package/common/deps/number-only.js +0 -20
package/split/index.js CHANGED
@@ -10,13 +10,18 @@ const getComputedThresholdValue = ({ api, props, vm, state }) => (type) => {
10
10
  };
11
11
  const getleftTopMin = (state) => ({ oldvalue, newvalue }) => state.valueIsPx ? `${Math.min(parseFloat(oldvalue), parseFloat(newvalue))}px` : Math.min(oldvalue, newvalue);
12
12
  const getrightBottomMin = (state) => ({ oldvalue, newvalue }) => state.valueIsPx ? `${Math.max(parseFloat(oldvalue), parseFloat(newvalue))}px` : Math.max(oldvalue, newvalue);
13
- const getAnotherOffset = ({ vm, state }) => (value) => state.valueIsPx ? `${vm.$refs.outerWrapper[state.offsetSize] - parseFloat(value)}px` : 1 - value;
13
+ const getAnotherOffset = ({ vm, state }) => (value, isPercent) => {
14
+ return isPercent ? 100 - value : state.valueIsPx ? `${vm.$refs.outerWrapper[state.offsetSize] - parseFloat(value)}px` : 1 - value;
15
+ };
14
16
  const handleMove = ({ api, emit, props, vm, state }) => (event) => {
15
17
  const pageOffset = state.isHorizontal ? event.pageX : event.pageY;
16
18
  const offset = pageOffset - state.initOffset;
17
19
  const outerWidth = vm.$refs.outerWrapper[state.offsetSize];
18
20
  let value = state.valueIsPx ? `${parseFloat(state.oldOffset) + offset}px` : api.px2percent({ numerator: outerWidth * state.oldOffset + offset, denominator: outerWidth });
19
- const anotherValue = api.getAnotherOffset(value);
21
+ const anotherValue = props.rightBottomValue ? value : api.getAnotherOffset(value);
22
+ if (props.rightBottomValue) {
23
+ value = api.getAnotherOffset(value);
24
+ }
20
25
  if (parseFloat(value) <= parseFloat(state.computedleftTopMin)) {
21
26
  value = api.getrightBottomMin({
22
27
  oldvalue: value,
@@ -57,7 +62,7 @@ const handleMousedown = ({ api, emit, on, props, state, vm }) => (event) => {
57
62
  state.oldOffset = val;
58
63
  emit("update:modelValue", val);
59
64
  } else {
60
- state.oldOffset = props.modelValue;
65
+ state.oldOffset = props.rightBottomValue ? api.getAnotherOffset(props.modelValue) : props.modelValue;
61
66
  }
62
67
  }
63
68
  state.isMoving = true;
@@ -75,9 +80,9 @@ const buttonLeftTopClick = ({ emit, props, state }) => () => {
75
80
  emit("update:modelValue", state.lastmodelValue);
76
81
  } else if (state.offset !== 0) {
77
82
  state.lastClickOffset = state.offset;
78
- state.offset = 0;
83
+ state.offset = props.rightBottomValue ? 100 : 0;
79
84
  state.lastmodelValue = props.modelValue;
80
- emit("update:modelValue", 0);
85
+ emit("update:modelValue", props.rightBottomValue ? 1 : 0);
81
86
  }
82
87
  emit("left-top-click");
83
88
  };
@@ -87,9 +92,9 @@ const buttonRightBottomClick = ({ emit, props, state }) => () => {
87
92
  emit("update:modelValue", state.lastmodelValue);
88
93
  } else if (state.offset !== 100) {
89
94
  state.lastClickOffset = state.offset;
90
- state.offset = 100;
95
+ state.offset = props.rightBottomValue ? 0 : 100;
91
96
  state.lastmodelValue = props.modelValue;
92
- emit("update:modelValue", 1);
97
+ emit("update:modelValue", props.rightBottomValue ? 0 : 1);
93
98
  }
94
99
  emit("right-bottom-click");
95
100
  };
@@ -102,13 +107,15 @@ const computeOffset = ({ api, nextTick, props, vm, state }) => () => {
102
107
  });
103
108
  if (state.valueIsPx) {
104
109
  nextTick(() => {
105
- state.offset = api.px2percent({
110
+ const offset = api.px2percent({
106
111
  numerator: props.modelValue,
107
112
  denominator: vm.$refs.outerWrapper && vm.$refs.outerWrapper[state.offsetSize]
108
113
  }) * 1e4 / 100;
114
+ state.offset = props.rightBottomValue ? api.getAnotherOffset(offset, true) : offset;
109
115
  });
110
116
  } else {
111
- state.offset = props.modelValue * 1e4 / 100;
117
+ const offset = props.modelValue * 1e4 / 100;
118
+ state.offset = props.rightBottomValue ? api.getAnotherOffset(offset, true) : offset;
112
119
  }
113
120
  };
114
121
  export {
package/split/vue.js CHANGED
@@ -31,7 +31,11 @@ const renderless = (props, hooks, { vm, nextTick, emit, constants }) => {
31
31
  prefix: constants.PREFIX,
32
32
  computedleftTopMin: computed(() => api2.getComputedThresholdValue("leftTopMin")),
33
33
  computedrightBottomMin: computed(() => api2.getComputedThresholdValue("rightBottomMin")),
34
- wrapperClasses: computed(() => [`${state.prefix}-wrapper`, state.isMoving ? "no-select" : ""]),
34
+ wrapperClasses: computed(() => [
35
+ `${state.prefix}-wrapper`,
36
+ state.isMoving ? "no-select" : "",
37
+ props.border ? "" : "no-border"
38
+ ]),
35
39
  paneClasses: computed(() => [
36
40
  `${state.prefix}-pane ${props.scrollable ? "tiny-split-scroll" : ""}`,
37
41
  { [`${state.prefix}-pane-moving`]: state.isMoving }
@@ -67,7 +71,8 @@ const useOffset = ({ nextTick, props, vm, constants, hooks }) => {
67
71
  });
68
72
  Object.assign(api2, {
69
73
  px2percent,
70
- computeOffset: computeOffset({ api: api2, nextTick, props, vm, state })
74
+ computeOffset: computeOffset({ api: api2, nextTick, props, vm, state }),
75
+ getAnotherOffset: getAnotherOffset({ vm, state })
71
76
  });
72
77
  watch(() => props.modelValue, api2.computeOffset, { immediate: true });
73
78
  onMounted(() => {
@@ -14,6 +14,13 @@ const getIntegerAndDecimal = ({ props }) => () => {
14
14
  let displayValue = props.value ? String(props.value).split(".") : "";
15
15
  let integer = (_a = displayValue[0]) == null ? void 0 : _a.replace(/\B(?=(\d{3})+(?!\d))/g, props.groupSeparator);
16
16
  let decimal = (_b = displayValue[1]) == null ? void 0 : _b.padEnd(props.precision, "0").slice(0, props.precision > 0 ? props.precision : 0);
17
+ if (!displayValue) {
18
+ integer = "0";
19
+ }
20
+ if (!decimal && props.precision) {
21
+ let display = "0";
22
+ decimal = display.padEnd(props.precision, "0");
23
+ }
17
24
  return [integer, decimal].join(decimal ? "." : "");
18
25
  };
19
26
  export {
package/tabs/index.js CHANGED
@@ -1,4 +1,40 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
+ const getOrderedPanes = (parent, panes) => {
3
+ const slotDefault = parent.$slots.default;
4
+ let orders;
5
+ if (typeof slotDefault === "function") {
6
+ orders = [];
7
+ const tabVnodes = slotDefault();
8
+ const handler = ({ type, componentOptions, props }) => {
9
+ let componentName = type && type.componentName;
10
+ if (!componentName)
11
+ componentName = componentOptions && componentOptions.Ctor.extendOptions.componentName;
12
+ if (componentName === "TabItem") {
13
+ const paneName = props && props.name || componentOptions && componentOptions.propsData.name;
14
+ orders.push(paneName);
15
+ }
16
+ };
17
+ tabVnodes.forEach(({ type, componentOptions, props, children }) => {
18
+ if (type && (type.toString() === "Symbol(Fragment)" || // vue@3.3之前的开发模式
19
+ type.toString() === "Symbol(v-fgt)" || // vue@3.3.1 的变更
20
+ type.toString() === "Symbol()")) {
21
+ Array.isArray(children) && children.forEach(({ type: type2, componentOptions: componentOptions2, props: props2 }) => handler({ type: type2, componentOptions: componentOptions2, props: props2 }));
22
+ } else {
23
+ handler({ type, componentOptions, props });
24
+ }
25
+ });
26
+ }
27
+ if (orders.length > 0) {
28
+ let tmpPanes = [];
29
+ orders.forEach((paneName) => {
30
+ let pane = panes.find((pane2) => pane2.name === paneName);
31
+ if (pane)
32
+ tmpPanes.push(pane);
33
+ });
34
+ panes = tmpPanes;
35
+ }
36
+ return panes;
37
+ };
2
38
  const calcPaneInstances = ({
3
39
  constants,
4
40
  parent,
@@ -28,19 +64,7 @@ const calcPaneInstances = ({
28
64
  index > -1 ? currentPanes[index] = vm : currentPanes.push(vm);
29
65
  }
30
66
  });
31
- const currentPaneStates = currentPanes.map((pane) => pane.state);
32
- const paneStates = state.panes.map((pane) => pane.state);
33
- let newPanes = [];
34
- for (let i = 0; i < paneStates.length; i++) {
35
- const paneState = paneStates[i];
36
- const index = currentPaneStates.indexOf(paneState);
37
- if (index > -1) {
38
- newPanes.push(state.panes[i]);
39
- currentPanes.splice(index, 1);
40
- currentPaneStates.splice(index, 1);
41
- }
42
- }
43
- newPanes = newPanes.concat(currentPanes);
67
+ const newPanes = getOrderedPanes(parent, currentPanes);
44
68
  const panesChanged = !(newPanes.length === state.panes.length && newPanes.every((pane, index) => pane.state === state.panes[index].state));
45
69
  if (isForceUpdate || panesChanged) {
46
70
  state.panes = newPanes;
package/tabs-mf/index.js CHANGED
@@ -2,21 +2,42 @@ import "../chunk-G2ADBYYC.js";
2
2
  import { random } from "../common/string";
3
3
  import debounce from "../common/deps/debounce";
4
4
  import { fastdom } from "../common/deps/fastdom";
5
- const setActive = ({ state, props, api }) => (name) => {
5
+ const setActive = ({ state, api }) => (name) => {
6
6
  const current = state.currentItem ? state.currentItem.name : "";
7
- if (current && current !== name && props.beforeLeave) {
8
- const before = props.beforeLeave(name, current);
9
- if (before && before.then) {
10
- before.then(() => {
7
+ if (current && current !== name) {
8
+ api.canLeave(name, current).then((result) => {
9
+ if (result) {
11
10
  api.changeCurrentName(name);
12
- }).catch(() => null);
13
- } else if (before !== false) {
14
- api.changeCurrentName(name);
15
- }
11
+ }
12
+ });
16
13
  } else {
17
14
  api.changeCurrentName(name);
18
15
  }
19
16
  };
17
+ const canLeave = (props) => (newTab, oldTab) => {
18
+ if (typeof props.beforeLeave === "function") {
19
+ const before = props.beforeLeave(newTab, oldTab);
20
+ if (before && before.then) {
21
+ return {
22
+ then: (cb) => {
23
+ before.then(cb).catch(() => cb(false));
24
+ }
25
+ };
26
+ } else {
27
+ return {
28
+ then: (cb) => {
29
+ cb(before);
30
+ }
31
+ };
32
+ }
33
+ } else {
34
+ return {
35
+ then: (cb) => {
36
+ cb(true);
37
+ }
38
+ };
39
+ }
40
+ };
20
41
  const changeCurrentName = ({ emit, state }) => (name) => {
21
42
  state.items.forEach((item) => item.selected = item.name === name);
22
43
  emit("update:activeName", name);
@@ -52,10 +73,12 @@ const clickMore = (api) => (name) => {
52
73
  api.setActive(name);
53
74
  api.scrollTo(name);
54
75
  };
55
- const removeItem = ({ state, emit }) => (name, silent = false) => {
76
+ const removeItem = ({ props, state, emit }) => (name, silent = false) => {
56
77
  const itemIndex = state.items.findIndex((item) => item.name === name);
57
78
  const navIndex = state.navs.findIndex((item) => item.name === name);
58
- if (~itemIndex) {
79
+ if (!~itemIndex)
80
+ return;
81
+ const emitEvent = () => {
59
82
  state.items.splice(itemIndex, 1);
60
83
  state.items = [...state.items];
61
84
  state.navs.splice(navIndex, 1);
@@ -64,6 +87,72 @@ const removeItem = ({ state, emit }) => (name, silent = false) => {
64
87
  emit("edit", name, "remove");
65
88
  emit("close", name);
66
89
  }
90
+ };
91
+ if (typeof props.beforeClose === "function") {
92
+ const beforeCloseResult = props.beforeClose(name);
93
+ if (beforeCloseResult && beforeCloseResult.then) {
94
+ beforeCloseResult.then((res) => res && emitEvent());
95
+ } else {
96
+ beforeCloseResult && emitEvent();
97
+ }
98
+ } else {
99
+ emitEvent();
100
+ }
101
+ };
102
+ const beforeCarouselSwipe = ({ api, state, vm }) => (newIndex, oldIndex) => {
103
+ const [newTab, oldTab] = [newIndex, oldIndex].map((index) => state.items[index] ? state.items[index].name : "");
104
+ return api.canLeave(newTab, oldTab).then((result) => {
105
+ if (result) {
106
+ vm.setActive(newTab);
107
+ }
108
+ return result;
109
+ });
110
+ };
111
+ const clearOtherTabSwipeScroll = ({ state, vm }) => (name) => {
112
+ if (!state.swipeable)
113
+ return;
114
+ state.items.forEach((tab, i) => {
115
+ const tabName = tab ? tab.name : "";
116
+ if (tabName !== name) {
117
+ const tabSwipeVm = vm.$refs[`tabSwipe${i}`];
118
+ tabSwipeVm && tabSwipeVm.clearScroll();
119
+ }
120
+ });
121
+ };
122
+ const computedSwipeable = ({ props, state }) => () => state.items.every((item) => !item.lazy) && props.swipeable;
123
+ const observeTabSwipeSize = ({ state, vm }) => () => {
124
+ if (!state.swipeable)
125
+ return;
126
+ state._resizeObserver = new ResizeObserver((entries) => {
127
+ for (const entry of entries) {
128
+ let sizeEntry, blockSize;
129
+ if (entry.borderBoxSize && entry.borderBoxSize.length > 0) {
130
+ sizeEntry = entry.borderBoxSize[0];
131
+ blockSize = sizeEntry.blockSize;
132
+ } else {
133
+ sizeEntry = entry.contentRect;
134
+ blockSize = sizeEntry.height;
135
+ }
136
+ if (blockSize > state.maxTabSwipeHeight) {
137
+ state.maxTabSwipeHeight = blockSize;
138
+ }
139
+ }
140
+ });
141
+ state.items.forEach((_, i) => {
142
+ const tabSwipeVm = vm.$refs[`tabSwipe${i}`];
143
+ tabSwipeVm && state._resizeObserver.observe(tabSwipeVm.$el);
144
+ });
145
+ };
146
+ const unobserveTabSwipeSize = ({ state, vm }) => () => {
147
+ if (!state.swipeable)
148
+ return;
149
+ if (state._resizeObserver) {
150
+ state.items.forEach((_, i) => {
151
+ const tabSwipeVm = vm.$refs[`tabSwipe${i}`];
152
+ tabSwipeVm && state._resizeObserver.unobserve(tabSwipeVm.$el);
153
+ });
154
+ state._resizeObserver.disconnect();
155
+ state._resizeObserver = null;
67
156
  }
68
157
  };
69
158
  const wheelListener = ({ vm, api, tabs, state }) => debounce(10, (e) => {
@@ -97,8 +186,16 @@ const emitAdd = (tabs) => () => {
97
186
  tabs.$emit("edit", null, "add");
98
187
  tabs.$emit("add");
99
188
  };
100
- const handleNavItemClick = ({ tabs, props }) => () => {
101
- tabs.setActive(props.navItem.name);
189
+ const handleNavItemClick = ({ tabs, props, vm }) => () => {
190
+ const index = tabs.state.navs.indexOf(vm);
191
+ const newTab = props.navItem.name;
192
+ const oldTab = tabs.state.currentItem ? tabs.state.currentItem.name : "";
193
+ tabs.setActive(newTab);
194
+ props.swipeable && tabs.canLeave(newTab, oldTab).then((result) => {
195
+ if (result) {
196
+ tabs.$refs.swipe && tabs.$refs.swipe.setActiveItem(index);
197
+ }
198
+ });
102
199
  tabs.$emit("click", props.navItem);
103
200
  };
104
201
  const getBoundRectNV = ({ vm, props }) => () => ({
@@ -112,8 +209,12 @@ const handleNavItemClose = ({ tabs, props }) => (e) => {
112
209
  export {
113
210
  addItem,
114
211
  addNav,
212
+ beforeCarouselSwipe,
213
+ canLeave,
115
214
  changeCurrentName,
215
+ clearOtherTabSwipeScroll,
116
216
  clickMore,
217
+ computedSwipeable,
117
218
  emitAdd,
118
219
  getBoundRect,
119
220
  getBoundRectNV,
@@ -121,8 +222,10 @@ export {
121
222
  handleNavItemClick,
122
223
  handleNavItemClose,
123
224
  key,
225
+ observeTabSwipeSize,
124
226
  removeItem,
125
227
  scrollTo,
126
228
  setActive,
229
+ unobserveTabSwipeSize,
127
230
  wheelListener
128
231
  };
@@ -33,6 +33,12 @@ const renderless = (props, { onMounted, onBeforeUnmount, reactive, watch, inject
33
33
  state.moreOptions = state.moreList.map((name) => tabs.state.items.find((item) => item.name === name));
34
34
  }
35
35
  );
36
+ watch(
37
+ () => tabs.state.navs,
38
+ () => {
39
+ api2.wheelListener();
40
+ }
41
+ );
36
42
  onMounted(() => {
37
43
  addWheelListener(vm.$refs.scroll, api2.wheelListener);
38
44
  addResizeListener(vm.$el, api2.wheelListener);
@@ -11,7 +11,7 @@ const renderless = (props, { inject, markRaw, reactive, computed }, { vm }) => {
11
11
  });
12
12
  const api2 = {
13
13
  state,
14
- handleNavItemClick: handleNavItemClick({ tabs, props }),
14
+ handleNavItemClick: handleNavItemClick({ tabs, props, vm }),
15
15
  getBoundRect: getBoundRectNV({ vm, props }),
16
16
  handleNavItemClose: handleNavItemClose({ tabs, props })
17
17
  };
package/tabs-mf/vue.js CHANGED
@@ -1,25 +1,58 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
2
  import { random } from "../common/string";
3
- import { setActive, addItem, addNav, scrollTo, clickMore, removeItem, changeCurrentName } from "./index";
4
- const api = ["state", "setActive", "addItem", "addNav", "scrollTo", "clickMore", "removeItem"];
5
- const renderless = (props, { onMounted, onBeforeUnmount, provide, reactive, watch, computed }, { vm, emit }) => {
3
+ import {
4
+ setActive,
5
+ addItem,
6
+ addNav,
7
+ scrollTo,
8
+ clickMore,
9
+ removeItem,
10
+ changeCurrentName,
11
+ beforeCarouselSwipe,
12
+ canLeave,
13
+ clearOtherTabSwipeScroll,
14
+ computedSwipeable,
15
+ observeTabSwipeSize,
16
+ unobserveTabSwipeSize
17
+ } from "./index";
18
+ const api = [
19
+ "state",
20
+ "setActive",
21
+ "addItem",
22
+ "addNav",
23
+ "scrollTo",
24
+ "clickMore",
25
+ "removeItem",
26
+ "beforeCarouselSwipe",
27
+ "canLeave",
28
+ "clearOtherTabSwipeScroll"
29
+ ];
30
+ const renderless = (props, { onMounted, onBeforeUnmount, provide, reactive, watch, computed, nextTick }, { vm, emit }) => {
6
31
  const state = reactive({
7
32
  items: [],
8
33
  navs: [],
9
34
  currentItem: computed(() => state.items.find((item) => item.selected)),
10
35
  key: computed(() => state.currentItem ? state.currentItem.name : random()),
11
- separator: props.separator
36
+ separator: props.separator,
37
+ swipeable: computed(() => api2.computedSwipeable()),
38
+ maxTabSwipeHeight: 0
12
39
  });
13
40
  const api2 = {};
14
41
  Object.assign(api2, {
15
42
  state,
16
- setActive: setActive({ api: api2, state, props }),
43
+ setActive: setActive({ state, api: api2 }),
17
44
  addItem: addItem(state),
18
45
  addNav: addNav(state),
19
46
  scrollTo: scrollTo({ vm, state }),
20
- removeItem: removeItem({ state, emit }),
47
+ removeItem: removeItem({ props, state, emit }),
21
48
  changeCurrentName: changeCurrentName({ state, emit }),
22
- clickMore: clickMore(api2)
49
+ clickMore: clickMore(api2),
50
+ beforeCarouselSwipe: beforeCarouselSwipe({ api: api2, state, vm }),
51
+ canLeave: canLeave(props),
52
+ clearOtherTabSwipeScroll: clearOtherTabSwipeScroll({ state, vm }),
53
+ computedSwipeable: computedSwipeable({ props, state }),
54
+ observeTabSwipeSize: observeTabSwipeSize({ state, vm }),
55
+ unobserveTabSwipeSize: unobserveTabSwipeSize({ state, vm })
23
56
  });
24
57
  provide("tabs", vm);
25
58
  watch(
@@ -31,10 +64,12 @@ const renderless = (props, { onMounted, onBeforeUnmount, provide, reactive, watc
31
64
  (name) => name && api2.setActive(name)
32
65
  );
33
66
  onMounted(() => {
67
+ nextTick(() => api2.observeTabSwipeSize());
34
68
  props.activeName && api2.scrollTo(props.activeName);
35
69
  props.modelValue && api2.scrollTo(props.modelValue);
36
70
  });
37
71
  onBeforeUnmount(() => {
72
+ api2.unobserveTabSwipeSize();
38
73
  state.navs.forEach((n, i) => state.navs[i] = null);
39
74
  state.navs.length = 0;
40
75
  });
package/tag-group/vue.js CHANGED
@@ -3,7 +3,7 @@ import { addResizeListener, removeResizeListener } from "../common/deps/resize-e
3
3
  import debounce from "../common/deps/debounce";
4
4
  import { getHiddenTags, handelItemClick } from "./index";
5
5
  const api = ["state", "handelItemClick"];
6
- const renderless = (props, { onMounted, onBeforeUnmount, reactive }, { vm, emit }) => {
6
+ const renderless = (props, { onMounted, onBeforeUnmount, reactive, watch }, { vm, emit }) => {
7
7
  const delay = 100;
8
8
  const state = reactive({
9
9
  showMore: false,
@@ -19,6 +19,12 @@ const renderless = (props, { onMounted, onBeforeUnmount, reactive }, { vm, emit
19
19
  api2.debouncedGetHiddenTags = debounce(delay, api2.getHiddenTags);
20
20
  addResizeListener(vm.$refs.tagGroup, debounce(delay, api2.debouncedGetHiddenTags));
21
21
  });
22
+ watch(
23
+ () => props.data.length,
24
+ () => {
25
+ api2.getHiddenTags();
26
+ }
27
+ );
22
28
  onBeforeUnmount(() => {
23
29
  removeResizeListener(vm.$refs.tagGroup, api2.debouncedGetHiddenTags);
24
30
  });
package/time/index.js CHANGED
@@ -15,8 +15,8 @@ const watchValue = ({ api, nextTick, state }) => (value) => {
15
15
  };
16
16
  const watchVisible = ({ nextTick, vm, state, api }) => (value) => {
17
17
  if (value) {
18
- state.oldValue = state.value;
19
18
  nextTick(() => {
19
+ state.oldValue = state.value;
20
20
  vm.$refs.spinner.emitSelectRange("hours");
21
21
  api.adjustSpinners();
22
22
  });
@@ -39,10 +39,10 @@ const getStatusCls = ({ constants, state }) => (index, node) => {
39
39
  return cls;
40
40
  };
41
41
  const computedData = ({ props, state }) => () => {
42
- if (props.data) {
42
+ if (props.data && props.data.length > 0) {
43
43
  return state.isReverse ? props.data.map((item, i) => __spreadProps(__spreadValues({}, props.data[props.data.length - 1 - i]), { index: i })) : props.data.map((item, i) => __spreadProps(__spreadValues({}, item), { index: i }));
44
44
  }
45
- return state.timelineItems;
45
+ return state.itemsArray;
46
46
  };
47
47
  const computedCurrent = ({ props, state }) => () => state.isReverse ? state.nodes.length - props.active - 1 : props.active;
48
48
  const computedIsReverse = (props) => () => props.reverse && props.vertical;
package/time-line/vue.js CHANGED
@@ -14,11 +14,12 @@ import {
14
14
  toggleFold
15
15
  } from "./index";
16
16
  const api = ["state", "handleClick", "getStatusCls", "getStatus", "getDate", "changeStatus", "toggleFold"];
17
- const renderless = (props, { computed, reactive, provide, watch }, { t, emit, constants, designConfig }) => {
17
+ const renderless = (props, { computed, reactive, provide, watch }, { t, emit, constants }) => {
18
18
  const api2 = {};
19
19
  const state = reactive({
20
+ // 当标签式使用时,记录有多少个 item 的标签
21
+ itemsArray: [],
20
22
  nodes: computed(() => api2.computedData()),
21
- timelineItems: [],
22
23
  current: computed(() => api2.computedCurrent()),
23
24
  isReverse: computed(() => api2.computedIsReverse()),
24
25
  stackNodes: computed(() => state.showAll ? state.nodes : api2.computedStackNodes()),
@@ -42,17 +43,7 @@ const renderless = (props, { computed, reactive, provide, watch }, { t, emit, co
42
43
  computedWrapperClass: computedWrapperClass({ props }),
43
44
  toggleFold: toggleFold({ props })
44
45
  });
45
- provide("nodesInject", { timelineItems: state.timelineItems, nodes: state.nodes, props });
46
- watch(
47
- () => state.timelineItems,
48
- (newVal) => {
49
- newVal.forEach((item, i) => item.index = i);
50
- },
51
- {
52
- immediate: true,
53
- deep: true
54
- }
55
- );
46
+ provide("nodesInject", { state, props });
56
47
  return api2;
57
48
  };
58
49
  export {
@@ -11,14 +11,14 @@ const getStatus = ({ state, t }) => (value) => {
11
11
  const computedWidth = () => (width) => {
12
12
  return /^\d+$/.test(String(width)) ? `${width}px` : width || "";
13
13
  };
14
- const handleClick = ({ emit, state }) => (node) => {
15
- const { index } = node || {};
14
+ const handleClick = ({ emit, state, props }) => (node) => {
15
+ const index = props.nodeIndex;
16
16
  if (!node.disabled) {
17
17
  emit("click", state.isReverse ? state.nodesLength - index - 1 : index, node);
18
18
  }
19
19
  };
20
- const getStatusCls = ({ constants, state }) => (node) => {
21
- const { index } = node;
20
+ const getStatusCls = ({ constants, state, props }) => (node) => {
21
+ const index = props.nodeIndex;
22
22
  const { PROCESS_DONE_CLS, PROCESS_CUR_CLS, PROCESS_WAIT_CLS, PROCESS_DISABLED_CLS, PROCESS_ERROR_CLS } = constants;
23
23
  const cls = {};
24
24
  const reverse = state.isReverse;
@@ -64,7 +64,7 @@ const computedIconClass = ({ props, api }) => () => {
64
64
  return iconClass;
65
65
  };
66
66
  const computedItemStyle = ({ props, state, api }) => () => {
67
- const { index } = props.node;
67
+ const index = props.nodeIndex;
68
68
  const { computedSpace, nodesLength } = state;
69
69
  const { textPosition, vertical } = api.rootProps;
70
70
  if (vertical) {
@@ -12,12 +12,19 @@ import {
12
12
  computedIconClass
13
13
  } from "./index";
14
14
  const api = ["state", "handleClick", "getStatusCls", "getStatus", "getDate", "rootProps"];
15
- const renderless = (props, { computed, reactive, inject }, { t, emit, constants }) => {
15
+ const renderless = (props, { computed, reactive, inject, onUnmounted }, { t, emit, constants }) => {
16
16
  const api2 = {};
17
- const { timelineItems, nodes, props: rootProps } = inject("nodesInject");
18
- timelineItems.push(props.node);
17
+ const { state: rootState, props: rootProps } = inject("nodesInject");
18
+ if (!rootState.itemsArray.includes(props.node)) {
19
+ rootState.itemsArray.push(props.node);
20
+ }
21
+ onUnmounted(() => {
22
+ if (rootState.itemsArray.includes(props.node)) {
23
+ rootState.itemsArray.splice(rootState.itemsArray.indexOf(props.node), 1);
24
+ }
25
+ });
19
26
  const state = reactive({
20
- nodesLength: computed(() => nodes.length),
27
+ nodesLength: computed(() => rootState.nodes.length),
21
28
  current: computed(() => api2.computedCurrent()),
22
29
  isReverse: computed(() => api2.computedIsReverse()),
23
30
  computedSpace: computed(() => api2.computedWidth(props.space || api2.rootProps.space)),
@@ -36,8 +43,8 @@ const renderless = (props, { computed, reactive, inject }, { t, emit, constants
36
43
  computedItemStyle: computedItemStyle({ props, state, api: api2 }),
37
44
  computedWidth: computedWidth(),
38
45
  getStatus: getStatus({ state, t }),
39
- handleClick: handleClick({ emit, state }),
40
- getStatusCls: getStatusCls({ constants, state }),
46
+ handleClick: handleClick({ emit, state, props }),
47
+ getStatusCls: getStatusCls({ constants, state, props }),
41
48
  computedIconClass: computedIconClass({ props, api: api2 })
42
49
  });
43
50
  return api2;
package/tree/index.js CHANGED
@@ -6,6 +6,7 @@ import { addClass, removeClass } from "../common/deps/dom";
6
6
  import { on, off } from "../common/deps/dom";
7
7
  import { getDataset } from "../common/dataset";
8
8
  import { copyArray } from "../common/object";
9
+ import { log } from "../common";
9
10
  const setChildren = (props) => (data) => props.data = data;
10
11
  const getChildren = () => (props) => props.data;
11
12
  const computedTreeItemArray = () => (props, state) => Array.prototype.slice.call(state.treeItems);
@@ -540,8 +541,19 @@ const saveNode = ({ state, emit, api }) => () => {
540
541
  }
541
542
  state.action.node = null;
542
543
  };
543
- const addNode = ({ api }) => (node) => {
544
- const newNode = { label: "" };
544
+ const addNode = ({ api, props, state }) => (node) => {
545
+ let nodeId = 0;
546
+ if (typeof props.editConfig.initNodeIdMethod === "function") {
547
+ nodeId = props.editConfig.initNodeIdMethod(node);
548
+ } else {
549
+ nodeId = state.newNodeId;
550
+ state.newNodeId++;
551
+ }
552
+ if (state.allNodeKeys.includes(nodeId) && !props.editConfig.noWarning) {
553
+ log.logger.warn(`the ${props.nodeKey || "id"} ${nodeId} is already exists. Please check.`);
554
+ }
555
+ state.allNodeKeys.push(nodeId);
556
+ const newNode = { label: "", [props.nodeKey || "id"]: nodeId };
545
557
  const isLeafField = node.store && node.store.props.isLeaf;
546
558
  if (isLeafField) {
547
559
  newNode[isLeafField] = true;
@@ -609,9 +621,24 @@ const deleteConfirm = ({ state, props, api }) => (event2, node) => {
609
621
  const openEdit = ({ props, state, api, emit }) => () => {
610
622
  state.action.show = true;
611
623
  state.action.data = copyArray(props.data);
624
+ if (!state.allNodeKeys.length) {
625
+ getAllNodeKeys(state.action.data, state.allNodeKeys, props.nodeKey || "id", props.props.children || "children");
626
+ }
612
627
  api.watchData(state.action.data);
613
628
  emit("open-edit");
614
629
  };
630
+ const getAllNodeKeys = (node, nodeKeys, nodeKey, children) => {
631
+ if (Array.isArray(node)) {
632
+ node.forEach((item) => {
633
+ if (item[nodeKey] || item[nodeKey] !== 0) {
634
+ nodeKeys.push(item[nodeKey]);
635
+ }
636
+ if (item[children]) {
637
+ getAllNodeKeys(item[children], nodeKeys, nodeKey, children);
638
+ }
639
+ });
640
+ }
641
+ };
615
642
  const closeEdit = ({ props, state, api, emit }) => () => {
616
643
  state.action.show = false;
617
644
  state.action.popoverVisible = false;