@opentiny/vue-renderless 3.6.8 → 3.8.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 (314) hide show
  1. package/action-sheet/index.js +28 -1
  2. package/action-sheet/vue.js +10 -4
  3. package/alert/index.js +24 -2
  4. package/alert/vue.js +15 -11
  5. package/amount/index.js +4 -4
  6. package/anchor/index.js +1 -1
  7. package/autocomplete/vue.js +3 -3
  8. package/autonavi-map/index.js +1 -1
  9. package/badge/vue.js +6 -6
  10. package/baidu-map/index.js +1 -1
  11. package/bulletin-board/index.js +1 -1
  12. package/calendar/index.js +2 -2
  13. package/calendar-bar/index.js +268 -0
  14. package/calendar-bar/vue.js +87 -0
  15. package/card/index.js +84 -0
  16. package/card/vue.js +70 -0
  17. package/card-group/index.js +16 -0
  18. package/card-group/vue.js +21 -0
  19. package/card-template/index.js +1 -1
  20. package/carousel/index.js +89 -2
  21. package/carousel/vue.js +14 -5
  22. package/carousel-item/index.js +8 -0
  23. package/carousel-item/vue.js +7 -3
  24. package/cascader/index.js +6 -6
  25. package/cascader/vue.js +3 -3
  26. package/cascader-menu/vue.js +2 -2
  27. package/cascader-panel/index.js +4 -4
  28. package/cascader-panel/node.js +4 -4
  29. package/cascader-panel/vue.js +2 -2
  30. package/cascader-select/index.js +179 -0
  31. package/cascader-select/vue.js +74 -0
  32. package/cell/vue.js +16 -0
  33. package/chart-bar/index.js +3 -3
  34. package/chart-boxplot/index.js +2 -2
  35. package/chart-candle/index.js +3 -3
  36. package/chart-core/deps/utils.js +7 -7
  37. package/chart-core/index.js +2 -2
  38. package/chart-funnel/index.js +3 -3
  39. package/chart-gauge/index.js +3 -3
  40. package/chart-graph/index.js +1 -1
  41. package/chart-heatmap/index.js +2 -2
  42. package/chart-line/index.js +3 -3
  43. package/chart-liquidfill/index.js +2 -2
  44. package/chart-map/index.js +3 -3
  45. package/chart-pie/index.js +3 -3
  46. package/chart-radar/index.js +3 -3
  47. package/chart-sankey/index.js +3 -3
  48. package/chart-scatter/index.js +4 -4
  49. package/chart-sunburst/index.js +1 -1
  50. package/chart-tree/index.js +2 -2
  51. package/chart-waterfall/index.js +3 -3
  52. package/chart-wordcloud/index.js +2 -2
  53. package/checkbox/index.js +21 -0
  54. package/checkbox/vue.js +16 -3
  55. package/checkbox-button/vue.js +1 -1
  56. package/collapse-item/vue.js +1 -1
  57. package/column-list-group/index.js +0 -0
  58. package/column-list-group/vue.js +14 -0
  59. package/column-list-item/index.js +50 -0
  60. package/column-list-item/vue.js +39 -0
  61. package/common/array.js +3 -3
  62. package/common/bigInt.js +5 -2
  63. package/common/dataset/index.js +3 -3
  64. package/common/date.js +2 -2
  65. package/common/deps/ResizeObserver.js +1 -1
  66. package/common/deps/clickoutside.js +1 -1
  67. package/common/deps/date-util.js +4 -4
  68. package/common/deps/date.js +2 -2
  69. package/common/deps/debounce.js +1 -1
  70. package/common/deps/dom.js +1 -1
  71. package/common/deps/fullscreen/apis.js +3 -3
  72. package/common/deps/fullscreen/screenfull.js +1 -1
  73. package/common/deps/infinite-scroll.js +176 -0
  74. package/common/deps/letter-only.js +1 -1
  75. package/common/deps/number-only.js +1 -1
  76. package/common/deps/observe-visibility.js +106 -0
  77. package/common/deps/popper.js +20 -22
  78. package/common/deps/popup-manager.js +2 -2
  79. package/common/deps/repeat-click.js +1 -1
  80. package/common/deps/resize-event.js +1 -1
  81. package/common/deps/tree-model/node.js +5 -5
  82. package/common/deps/tree-model/tree-store.js +3 -3
  83. package/common/deps/upload-ajax.js +2 -2
  84. package/common/deps/vue-popper.js +4 -4
  85. package/common/deps/vue-popup.js +4 -4
  86. package/common/index.js +2 -2
  87. package/common/object.js +1 -1
  88. package/common/runtime.js +24 -24
  89. package/common/string.js +23 -4
  90. package/common/validate/rules/range.js +2 -2
  91. package/common/validate/rules/required.js +1 -1
  92. package/common/validate/rules/type.js +3 -3
  93. package/common/validate/schema.js +1 -1
  94. package/common/validate/util.js +1 -1
  95. package/common/validate/validations/array.js +1 -1
  96. package/common/validate/validations/date.js +1 -1
  97. package/common/validate/validations/enum.js +1 -1
  98. package/common/validate/validations/float.js +1 -1
  99. package/common/validate/validations/integer.js +1 -1
  100. package/common/validate/validations/method.js +1 -1
  101. package/common/validate/validations/number.js +1 -1
  102. package/common/validate/validations/pattern.js +1 -1
  103. package/common/validate/validations/string.js +1 -1
  104. package/common/validate/validations/type.js +1 -1
  105. package/container/index.js +1 -1
  106. package/crop/index.js +2 -2
  107. package/currency/index.js +2 -2
  108. package/date-panel/index.js +7 -7
  109. package/date-panel/vue.js +3 -2
  110. package/date-picker-mobile/index.js +250 -0
  111. package/date-picker-mobile/vue.js +86 -0
  112. package/date-range/index.js +1 -1
  113. package/date-range/vue.js +1 -1
  114. package/date-table/index.js +3 -3
  115. package/date-table/vue.js +1 -1
  116. package/dialog-box/index.js +6 -4
  117. package/dialog-box/vue.js +1 -1
  118. package/dialog-select/index.js +345 -0
  119. package/dialog-select/vue.js +110 -0
  120. package/drawer/index.js +83 -0
  121. package/drawer/vue.js +51 -0
  122. package/drop-times/index.js +1 -1
  123. package/dropdown/index.js +2 -2
  124. package/dropdown/vue.js +1 -1
  125. package/dropdown-item/index.js +1 -1
  126. package/dropdown-item/mf.js +79 -0
  127. package/dropdown-menu/index.js +30 -1
  128. package/dropdown-menu/vue.js +17 -7
  129. package/dynamic-scroller/index.js +117 -0
  130. package/dynamic-scroller/vue.js +88 -0
  131. package/dynamic-scroller-item/index.js +147 -0
  132. package/dynamic-scroller-item/vue.js +92 -0
  133. package/espace/index.js +1 -1
  134. package/espace/vue.js +1 -1
  135. package/exception/vue.js +3 -1
  136. package/fall-menu/index.js +4 -4
  137. package/file-upload/index.js +872 -408
  138. package/file-upload/vue.js +87 -36
  139. package/filter/index.js +131 -0
  140. package/filter/tag-group.js +43 -0
  141. package/filter/vue.js +73 -0
  142. package/filter-bar/index.js +9 -0
  143. package/filter-bar/vue.js +16 -0
  144. package/filter-box/index.js +17 -0
  145. package/filter-box/vue.js +19 -0
  146. package/filter-panel/index.js +42 -0
  147. package/filter-panel/vue.js +33 -0
  148. package/floatbar/index.js +1 -1
  149. package/flowchart/index.js +721 -0
  150. package/flowchart/vue.js +81 -0
  151. package/form/index.js +15 -1
  152. package/form/vue.js +10 -4
  153. package/form-item/index.js +46 -6
  154. package/form-item/vue.js +27 -3
  155. package/fullscreen/index.js +1 -1
  156. package/fullscreen/vue.js +1 -1
  157. package/grid/plugins/export.js +2 -2
  158. package/grid/plugins/exportExcel.js +2 -2
  159. package/grid/plugins/resize.js +1 -1
  160. package/grid/static/base/helperEqualCompare.js +1 -1
  161. package/grid/static/base/isPlainObject.js +1 -1
  162. package/grid/utils/common.js +3 -3
  163. package/grid/utils/dom.js +3 -3
  164. package/grid/utils/event.js +2 -2
  165. package/guide/index.js +168 -0
  166. package/guide/vue.js +36 -0
  167. package/hrapprover/index.js +1 -1
  168. package/image/index.js +8 -4
  169. package/image/vue.js +12 -6
  170. package/image-viewer/index.js +3 -3
  171. package/image-viewer/vue.js +16 -6
  172. package/input/index.js +34 -1
  173. package/input/vue.js +22 -6
  174. package/ip-address/index.js +1 -1
  175. package/ip-address/vue.js +1 -1
  176. package/link-menu/index.js +2 -2
  177. package/link-menu/vue.js +2 -2
  178. package/loading/index.js +2 -2
  179. package/loading/vue.js +2 -1
  180. package/locales/index.js +1 -1
  181. package/logout/index.js +1 -1
  182. package/milestone/index.js +5 -1
  183. package/modal/index.js +68 -39
  184. package/modal/vue.js +15 -12
  185. package/month-range/index.js +1 -1
  186. package/month-range/vue.js +1 -1
  187. package/month-table/index.js +5 -5
  188. package/month-table/vue.js +1 -1
  189. package/multi-select/index.js +5 -2
  190. package/multi-select/vue.js +4 -5
  191. package/nav-menu/index.js +6 -6
  192. package/notify/index.js +3 -3
  193. package/numeric/index.js +15 -5
  194. package/numeric/vue.js +15 -6
  195. package/option/index.js +1 -1
  196. package/package.json +2 -1
  197. package/pager-item/index.js +1 -1
  198. package/panel/index.js +1 -1
  199. package/picker/index.js +7 -7
  200. package/picker/vue.js +1 -1
  201. package/picker-column/index.js +1 -1
  202. package/popconfirm/index.js +25 -0
  203. package/popconfirm/vue.js +22 -0
  204. package/popeditor/index.js +7 -7
  205. package/popeditor/vue.js +2 -2
  206. package/popover/index.js +11 -3
  207. package/popover/vue.js +33 -10
  208. package/popup/index.js +4 -4
  209. package/pull-refresh/index.js +8 -11
  210. package/pull-refresh/vue.js +7 -7
  211. package/radio/index.js +17 -0
  212. package/radio/vue.js +18 -3
  213. package/radio-button/index.js +8 -0
  214. package/radio-button/vue.js +19 -4
  215. package/radio-group/index.js +1 -1
  216. package/radio-group/vue.js +5 -2
  217. package/rate/index.js +4 -2
  218. package/rate/vue.js +1 -1
  219. package/record/index.js +190 -0
  220. package/record/vue.js +44 -0
  221. package/recycle-scroller/index.js +470 -0
  222. package/recycle-scroller/vue.js +135 -0
  223. package/river/index.js +371 -0
  224. package/river/river.js +352 -0
  225. package/river/vue.js +77 -0
  226. package/roles/index.js +1 -1
  227. package/scrollbar/vue-bar.js +1 -1
  228. package/scrollbar/vue.js +1 -1
  229. package/search/index.js +3 -3
  230. package/select/index.js +17 -14
  231. package/select/vue.js +14 -8
  232. package/select-dropdown/vue.js +1 -1
  233. package/select-mobile/index.js +111 -0
  234. package/select-mobile/vue.js +58 -0
  235. package/select-view/index.js +170 -0
  236. package/select-view/vue.js +82 -0
  237. package/selected-box/index.js +216 -0
  238. package/selected-box/vue.js +98 -0
  239. package/slide-bar/index.js +1 -1
  240. package/slider/index.js +49 -4
  241. package/slider/vue.js +15 -4
  242. package/split/vue.js +1 -1
  243. package/standard-list-item/index.js +18 -0
  244. package/standard-list-item/vue.js +22 -0
  245. package/steps/index.js +30 -0
  246. package/steps/slide-bar.js +122 -0
  247. package/steps/vue.js +15 -3
  248. package/switch/index.js +1 -1
  249. package/switch/vue.js +2 -1
  250. package/tab-bar/index.js +2 -2
  251. package/tab-item/index.js +2 -2
  252. package/tab-item/vue.js +1 -1
  253. package/tab-item-mf/index.js +0 -0
  254. package/tab-item-mf/vue.js +16 -0
  255. package/tab-nav/index.js +78 -4
  256. package/tab-nav/vue.js +11 -3
  257. package/tabbar-item/index.js +1 -1
  258. package/tabbar-item/vue.js +1 -1
  259. package/tabs/index.js +8 -9
  260. package/tabs/vue.js +1 -1
  261. package/tabs-mf/index.js +109 -0
  262. package/tabs-mf/vue-bar.js +49 -0
  263. package/tabs-mf/vue-nav-item.js +22 -0
  264. package/tabs-mf/vue-nav.js +13 -0
  265. package/tabs-mf/vue.js +45 -0
  266. package/tabs-mf/wheel.js +71 -0
  267. package/tag/index.js +8 -2
  268. package/tag/vue.js +13 -5
  269. package/tag-group/index.js +24 -0
  270. package/tag-group/vue.js +29 -0
  271. package/tall-storage/index.js +1 -1
  272. package/tall-storage/vue.js +1 -1
  273. package/time/index.js +1 -1
  274. package/time/vue.js +2 -2
  275. package/time-line/index.js +28 -7
  276. package/time-line/vue.js +9 -4
  277. package/time-panel/index.js +2 -2
  278. package/time-panel/vue.js +1 -1
  279. package/time-picker-mobile/index.js +30 -0
  280. package/time-picker-mobile/vue.js +30 -0
  281. package/time-range/index.js +1 -1
  282. package/time-range/vue.js +1 -1
  283. package/time-spinner/index.js +2 -2
  284. package/time-spinner/vue.js +1 -1
  285. package/toggle-menu/index.js +2 -2
  286. package/toggle-menu/vue.js +1 -1
  287. package/tooltip/index.js +30 -3
  288. package/tooltip/vue.js +33 -12
  289. package/top-box/index.js +3 -3
  290. package/transfer/index.js +1 -1
  291. package/transfer-panel/index.js +2 -2
  292. package/tree/index.js +6 -6
  293. package/tree/vue.js +1 -1
  294. package/tree-node/index.js +1 -1
  295. package/upload/index.js +1 -1
  296. package/upload/vue.js +2 -2
  297. package/upload-dragger/index.js +5 -1
  298. package/upload-dragger/vue.js +9 -3
  299. package/upload-list/index.js +158 -8
  300. package/upload-list/vue.js +77 -25
  301. package/user/index.js +86 -70
  302. package/user/vue.js +15 -5
  303. package/user-account/vue.js +1 -1
  304. package/user-contact/index.js +49 -3
  305. package/user-contact/vue.js +17 -8
  306. package/user-head-group/vue.js +17 -0
  307. package/user-link/index.js +10 -2
  308. package/user-link/vue.js +11 -6
  309. package/wheel/index.js +1 -1
  310. package/wizard/index.js +3 -3
  311. package/year-range/index.js +125 -0
  312. package/year-range/vue.js +88 -0
  313. package/year-table/index.js +175 -11
  314. package/year-table/vue.js +17 -5
@@ -0,0 +1,470 @@
1
+ import "../chunk-PKUHTIDK.js";
2
+ import { getScrollContainer } from "../common/deps/infinite-scroll";
3
+ import { isNull } from "../common/type";
4
+ let supportsPassive = false;
5
+ if (typeof window !== "undefined") {
6
+ supportsPassive = false;
7
+ try {
8
+ const opts = Object.defineProperty({}, "passive", {
9
+ // eslint-disable-next-line getter-return
10
+ get() {
11
+ supportsPassive = true;
12
+ }
13
+ });
14
+ window.addEventListener("test", null, opts);
15
+ } catch (e) {
16
+ }
17
+ }
18
+ const handleVisibilityChange = ({ api, emit, state }) => (isVisible, entry) => {
19
+ if (state.ready) {
20
+ if (isVisible || entry.boundingClientRect.width !== 0 || entry.boundingClientRect.height !== 0) {
21
+ emit("visible");
22
+ requestAnimationFrame(() => {
23
+ api.updateVisibleItems(false);
24
+ });
25
+ } else {
26
+ emit("hidden");
27
+ }
28
+ }
29
+ };
30
+ const updateVisibleItems = ({ api, emit, props, state, vm }) => (checkItem, checkPositionDiff = false) => {
31
+ const itemSize = props.itemSize;
32
+ const gridItems = props.gridItems || 1;
33
+ const itemSecondarySize = props.itemSecondarySize || itemSize;
34
+ const minItemSize = state.temporary.computedMinItemSize;
35
+ const typeField = props.typeField;
36
+ const keyField = state.simpleArray ? null : props.keyField;
37
+ const items = props.items;
38
+ const count = items.length;
39
+ const sizes = state.sizes;
40
+ const views = state.temporary.views;
41
+ const unusedViews = state.temporary.unusedViews;
42
+ const pool = state.pool;
43
+ const itemIndexByKey = state.itemIndexByKey;
44
+ let startIndex, endIndex, visibleStartIndex, visibleEndIndex, totalSize;
45
+ if (!count) {
46
+ startIndex = endIndex = visibleStartIndex = visibleEndIndex = totalSize = 0;
47
+ } else if (state.temporary.prerender) {
48
+ startIndex = visibleStartIndex = 0;
49
+ visibleEndIndex = endIndex = Math.min(props.prerender, items.length);
50
+ totalSize = null;
51
+ } else {
52
+ const scroll = api.getScroll();
53
+ if (doCheckPositionDiff({ checkPositionDiff, scroll, state, itemSize, minItemSize })) {
54
+ return { continuous: true };
55
+ }
56
+ state.temporary.lastUpdateScrollPosition = scroll.start;
57
+ const args2 = { props, scroll, vm, itemSize, count, sizes, startIndex, totalSize };
58
+ Object.assign(args2, { endIndex, items, visibleStartIndex, visibleEndIndex, gridItems });
59
+ const ret = computeRange(args2);
60
+ startIndex = ret.startIndex;
61
+ endIndex = ret.endIndex;
62
+ visibleStartIndex = ret.visibleStartIndex;
63
+ visibleEndIndex = ret.visibleEndIndex;
64
+ totalSize = ret.totalSize;
65
+ }
66
+ if (endIndex - startIndex > props.itemsLimit) {
67
+ throw new Error("[TINY Error][RecycleScroller] Rendered items limit reached");
68
+ }
69
+ state.totalSize = totalSize;
70
+ const continuous = startIndex <= state.temporary.endIndex && endIndex >= state.temporary.startIndex;
71
+ const args = { continuous, pool, checkItem, itemIndexByKey, keyField, startIndex };
72
+ Object.assign(args, { endIndex, api, items, views, itemSize, sizes, typeField, unusedViews });
73
+ Object.assign(args, { emit, gridItems, itemSecondarySize });
74
+ computePool(args);
75
+ state.temporary.startIndex = startIndex;
76
+ state.temporary.endIndex = endIndex;
77
+ if (props.emitUpdate) {
78
+ emit("update", startIndex, endIndex, visibleStartIndex, visibleEndIndex);
79
+ }
80
+ clearTimeout(state.temporary.sortTimer);
81
+ state.temporary.sortTimer = setTimeout(api.sortViews, props.updateInterval + 300);
82
+ return { continuous };
83
+ };
84
+ const computedSizes = ({ props, state }) => () => {
85
+ if (props.itemSize === null) {
86
+ const sizes = { "-1": { accumulator: 0 } };
87
+ const items = props.items;
88
+ const field = props.sizeField;
89
+ const minItemSize = props.minItemSize;
90
+ let computedMinSize = 1e4;
91
+ let accumulator = 0;
92
+ let current;
93
+ for (let i = 0, l = items.length; i < l; i++) {
94
+ current = items[i][field] || minItemSize;
95
+ if (current < computedMinSize) {
96
+ computedMinSize = current;
97
+ }
98
+ accumulator += current;
99
+ sizes[i] = { accumulator, size: current };
100
+ }
101
+ state.temporary.computedMinItemSize = computedMinSize;
102
+ return sizes;
103
+ }
104
+ return [];
105
+ };
106
+ const computedItemIndexByKey = (props) => () => {
107
+ const { keyField, items } = props;
108
+ const result = {};
109
+ for (let i = 0, l = items.length; i < l; i++) {
110
+ result[items[i][keyField]] = i;
111
+ }
112
+ return result;
113
+ };
114
+ const getScroll = ({ props, vm }) => () => {
115
+ const { $el: el } = vm;
116
+ const direction = props.direction;
117
+ const isVertical = direction === "vertical";
118
+ let scrollRange;
119
+ if (props.pageMode) {
120
+ const bounds = el.getBoundingClientRect();
121
+ const boundsSize = isVertical ? bounds.height : bounds.width;
122
+ let size = isVertical ? window.innerHeight : window.innerWidth;
123
+ let start = -(isVertical ? bounds.top : bounds.left);
124
+ if (start < 0) {
125
+ size += start;
126
+ start = 0;
127
+ }
128
+ if (start + size > boundsSize) {
129
+ size = boundsSize - start;
130
+ }
131
+ scrollRange = { start, end: start + size };
132
+ } else if (isVertical) {
133
+ scrollRange = { start: el.scrollTop, end: el.scrollTop + el.clientHeight };
134
+ } else {
135
+ scrollRange = { start: el.scrollLeft, end: el.scrollLeft + el.clientWidth };
136
+ }
137
+ return scrollRange;
138
+ };
139
+ const unuseView = (state) => (view, fake = false) => {
140
+ const unusedViews = state.temporary.unusedViews;
141
+ const type = view.nr.type;
142
+ let unusedPool = unusedViews.get(type);
143
+ if (!unusedPool) {
144
+ unusedPool = [];
145
+ unusedViews.set(type, unusedPool);
146
+ }
147
+ unusedPool.push(view);
148
+ if (!fake) {
149
+ view.nr.used = false;
150
+ view.position = -9999;
151
+ }
152
+ };
153
+ let uid = 0;
154
+ const addView = ({ markRaw, shallowReactive }) => (pool, index, item, key, type) => {
155
+ const nr = markRaw({ id: uid++, index, used: true, key, type });
156
+ const view = shallowReactive({ item, position: 0, nr });
157
+ pool.push(view);
158
+ return view;
159
+ };
160
+ const sortViews = (state) => () => {
161
+ state.pool.sort((viewA, viewB) => viewA.nr.index - viewB.nr.index);
162
+ };
163
+ const handleScroll = ({ api, props, state }) => () => {
164
+ if (!state.temporary.scrollDirty) {
165
+ state.temporary.scrollDirty = true;
166
+ if (state.temporary.updateTimeout)
167
+ return;
168
+ const requestUpdate = () => requestAnimationFrame(() => {
169
+ state.temporary.scrollDirty = false;
170
+ const { continuous } = api.updateVisibleItems(false, true);
171
+ if (!continuous) {
172
+ cancelAnimationFrame(state.temporary.refreshTimeout);
173
+ state.temporary.refreshTimeout = requestAnimationFrame(() => api.updateVisibleItems(false));
174
+ }
175
+ });
176
+ requestUpdate();
177
+ if (props.updateInterval) {
178
+ state.temporary.updateTimeout = setTimeout(() => {
179
+ state.temporary.updateTimeout = 0;
180
+ if (state.temporary.scrollDirty)
181
+ requestUpdate();
182
+ }, props.updateInterval);
183
+ }
184
+ }
185
+ };
186
+ const handleResize = ({ api, emit, state }) => () => {
187
+ emit("resize");
188
+ if (state.ready)
189
+ api.updateVisibleItems(false);
190
+ };
191
+ const applyPageMode = ({ api, props }) => () => {
192
+ if (props.pageMode) {
193
+ api.addListeners();
194
+ } else {
195
+ api.removeListeners();
196
+ }
197
+ };
198
+ const addListeners = ({ api, state }) => () => {
199
+ state.listenerTarget = api.getListenerTarget();
200
+ const options = supportsPassive ? { passive: true } : false;
201
+ state.listenerTarget.addEventListener("scroll", api.handleScroll, options);
202
+ state.listenerTarget.addEventListener("resize", api.handleResize);
203
+ };
204
+ const removeListeners = ({ api, state }) => () => {
205
+ if (!state.listenerTarget) {
206
+ return;
207
+ }
208
+ state.listenerTarget.removeEventListener("scroll", api.handleScroll);
209
+ state.listenerTarget.removeEventListener("resize", api.handleResize);
210
+ state.listenerTarget = null;
211
+ };
212
+ const getListenerTarget = ({ props, vm }) => () => {
213
+ let target = getScrollContainer(vm.$el.parentNode, props.direction === "vertical");
214
+ if (window.document && (target === window.document.documentElement || target === window.document.body)) {
215
+ target = window;
216
+ }
217
+ return target;
218
+ };
219
+ const scrollToPosition = ({ props, vm }) => (position) => {
220
+ const direction = props.direction === "vertical" ? { scroll: "scrollTop", start: "top" } : { scroll: "scrollLeft", start: "left" };
221
+ let viewport, scrollDirection, scrollDistance;
222
+ if (props.pageMode) {
223
+ const viewportEl = getScrollContainer(vm.$el.parentNode, props.direction === "vertical");
224
+ const scrollTop = viewportEl.tagName === "HTML" ? 0 : viewportEl[direction.scroll];
225
+ const bounds = viewportEl.getBoundingClientRect();
226
+ const scroller = vm.$el.getBoundingClientRect();
227
+ const scrollerPosition = scroller[direction.start] - bounds[direction.start];
228
+ viewport = viewportEl;
229
+ scrollDirection = direction.scroll;
230
+ scrollDistance = position + scrollTop + scrollerPosition;
231
+ } else {
232
+ viewport = vm.$el;
233
+ scrollDirection = direction.scroll;
234
+ scrollDistance = position;
235
+ }
236
+ viewport[scrollDirection] = scrollDistance;
237
+ };
238
+ const scrollToItem = ({ api, props, state }) => (index) => {
239
+ const gridItems = props.gridItems || 1;
240
+ let scroll;
241
+ if (props.itemSize === null) {
242
+ scroll = index > 0 ? state.sizes[index - 1].accumulator : 0;
243
+ } else {
244
+ scroll = Math.floor(index / gridItems) * props.itemSize;
245
+ }
246
+ api.scrollToPosition(scroll);
247
+ };
248
+ const doCheckPositionDiff = ({ checkPositionDiff, scroll, state, itemSize, minItemSize }) => {
249
+ if (checkPositionDiff) {
250
+ let positionDiff = scroll.start - state.temporary.lastUpdateScrollPosition;
251
+ if (positionDiff < 0)
252
+ positionDiff = -positionDiff;
253
+ if (itemSize === null && positionDiff < minItemSize || positionDiff < itemSize) {
254
+ return true;
255
+ }
256
+ }
257
+ };
258
+ const computeRange = (args) => {
259
+ let { props, scroll, vm, itemSize, count, sizes, startIndex, totalSize } = args;
260
+ let { endIndex, items, visibleStartIndex, visibleEndIndex, gridItems } = args;
261
+ const buffer = props.buffer;
262
+ let beforeSize = 0;
263
+ scroll.start -= buffer;
264
+ scroll.end += buffer;
265
+ if (vm.$refs.before) {
266
+ beforeSize = vm.$refs.before.scrollHeight;
267
+ scroll.start -= beforeSize;
268
+ }
269
+ if (vm.$refs.after) {
270
+ const afterSize = vm.$refs.after.scrollHeight;
271
+ scroll.end += afterSize;
272
+ }
273
+ if (itemSize === null) {
274
+ let args2 = { count, sizes, scroll, startIndex, totalSize, endIndex };
275
+ Object.assign(args2, { items, visibleStartIndex, beforeSize, visibleEndIndex });
276
+ const ret = computeRangeVariableSizeMode(args2);
277
+ startIndex = ret.startIndex;
278
+ endIndex = ret.endIndex;
279
+ visibleStartIndex = ret.visibleStartIndex;
280
+ visibleEndIndex = ret.visibleEndIndex;
281
+ totalSize = ret.totalSize;
282
+ } else {
283
+ startIndex = ~~(scroll.start / itemSize * gridItems);
284
+ const remainer = startIndex % gridItems;
285
+ startIndex -= remainer;
286
+ endIndex = Math.ceil(scroll.end / itemSize * gridItems);
287
+ visibleStartIndex = Math.max(0, Math.floor((scroll.start - beforeSize) / itemSize * gridItems));
288
+ visibleEndIndex = Math.floor((scroll.end - beforeSize) / itemSize * gridItems);
289
+ startIndex < 0 && (startIndex = 0);
290
+ endIndex > count && (endIndex = count);
291
+ visibleStartIndex < 0 && (visibleStartIndex = 0);
292
+ visibleEndIndex > count && (visibleEndIndex = count);
293
+ totalSize = Math.ceil(count / gridItems) * itemSize;
294
+ }
295
+ return { startIndex, endIndex, visibleStartIndex, visibleEndIndex, totalSize };
296
+ };
297
+ const computeRangeVariableSizeMode = (args) => {
298
+ let { count, sizes, scroll, startIndex, totalSize, endIndex } = args;
299
+ let { items, visibleStartIndex, beforeSize, visibleEndIndex } = args;
300
+ let h, a, b, i, oldI;
301
+ a = 0;
302
+ b = count - 1;
303
+ i = ~~(count / 2);
304
+ do {
305
+ oldI = i;
306
+ h = sizes[i].accumulator;
307
+ if (h < scroll.start) {
308
+ a = i;
309
+ } else if (i < count - 1 && sizes[i + 1].accumulator > scroll.start) {
310
+ b = i;
311
+ }
312
+ i = ~~((a + b) / 2);
313
+ } while (i !== oldI);
314
+ i < 0 && (i = 0);
315
+ startIndex = i;
316
+ totalSize = sizes[count - 1].accumulator;
317
+ for (endIndex = i; endIndex < count && sizes[endIndex].accumulator < scroll.end; endIndex++) {
318
+ }
319
+ if (endIndex === -1) {
320
+ endIndex = items.length - 1;
321
+ } else {
322
+ endIndex++;
323
+ endIndex > count && (endIndex = count);
324
+ }
325
+ for (visibleStartIndex = startIndex; visibleStartIndex < count && beforeSize + sizes[visibleStartIndex].accumulator < scroll.start; visibleStartIndex++) {
326
+ }
327
+ for (visibleEndIndex = visibleStartIndex; visibleEndIndex < count && beforeSize + sizes[visibleEndIndex].accumulator < scroll.end; visibleEndIndex++) {
328
+ }
329
+ return { startIndex, totalSize, endIndex, visibleStartIndex, visibleEndIndex };
330
+ };
331
+ const computePool = (args) => {
332
+ let { continuous, pool, checkItem, itemIndexByKey, keyField, startIndex } = args;
333
+ let { endIndex, api, items, views, itemSize, sizes, typeField, unusedViews } = args;
334
+ let { emit, gridItems, itemSecondarySize } = args;
335
+ let view = unuseInvisible({ continuous, pool, checkItem, itemIndexByKey, keyField, startIndex, endIndex, api });
336
+ const unusedIndex = continuous ? null : /* @__PURE__ */ new Map();
337
+ let item, type;
338
+ for (let i = startIndex; i < endIndex; i++) {
339
+ item = items[i];
340
+ const key = keyField ? item[keyField] : item;
341
+ if (isNull(key)) {
342
+ throw new Error(`[TINY Error][RecycleScroller] Key is ${key} on item (keyField is '${keyField}')`);
343
+ }
344
+ view = views.get(key);
345
+ if (!itemSize && !sizes[i].size) {
346
+ if (view)
347
+ api.unuseView(view);
348
+ continue;
349
+ }
350
+ type = item[typeField];
351
+ let unusedPool = unusedViews.get(type);
352
+ let newlyUsedView = false;
353
+ let args2 = { view, continuous, unusedPool, api, pool, i, item };
354
+ Object.assign(args2, { key, type, unusedIndex, unusedViews, views, newlyUsedView });
355
+ const ret = computePoolView(args2);
356
+ view = ret.view;
357
+ unusedPool = ret.unusedPool;
358
+ newlyUsedView = ret.newlyUsedView;
359
+ if (newlyUsedView) {
360
+ if (i === items.length - 1)
361
+ emit("scroll-end");
362
+ if (i === 0)
363
+ emit("scroll-start");
364
+ }
365
+ if (itemSize === null) {
366
+ view.position = sizes[i - 1].accumulator;
367
+ view.offset = 0;
368
+ } else {
369
+ view.position = Math.floor(i / gridItems) * itemSize;
370
+ view.offset = i % gridItems * itemSecondarySize;
371
+ }
372
+ }
373
+ };
374
+ const unuseInvisible = ({ continuous, pool, checkItem, itemIndexByKey, keyField, startIndex, endIndex, api }) => {
375
+ let view;
376
+ if (continuous) {
377
+ for (let i = 0, l = pool.length; i < l; i++) {
378
+ view = pool[i];
379
+ if (view.nr.used) {
380
+ if (checkItem) {
381
+ view.nr.index = itemIndexByKey[view.item[keyField]];
382
+ }
383
+ if (isNull(view.nr.index) || view.nr.index < startIndex || view.nr.index >= endIndex) {
384
+ api.unuseView(view);
385
+ }
386
+ }
387
+ }
388
+ }
389
+ return view;
390
+ };
391
+ const computePoolView = (args) => {
392
+ let { view, continuous, unusedPool, api, pool, i, item } = args;
393
+ let { key, type, unusedIndex, unusedViews, views, newlyUsedView } = args;
394
+ let v;
395
+ if (!view) {
396
+ if (continuous) {
397
+ if (unusedPool && unusedPool.length) {
398
+ view = unusedPool.pop();
399
+ } else {
400
+ view = api.addView(pool, i, item, key, type);
401
+ }
402
+ } else {
403
+ v = unusedIndex.get(type) || 0;
404
+ if (!unusedPool || v >= unusedPool.length) {
405
+ view = api.addView(pool, i, item, key, type);
406
+ api.unuseView(view, true);
407
+ unusedPool = unusedViews.get(type);
408
+ }
409
+ view = unusedPool[v];
410
+ unusedIndex.set(type, v + 1);
411
+ }
412
+ views.delete(view.nr.key);
413
+ view.nr.used = true;
414
+ view.nr.index = i;
415
+ view.nr.key = key;
416
+ view.nr.type = type;
417
+ views.set(key, view);
418
+ newlyUsedView = true;
419
+ } else {
420
+ if (!view.nr.used) {
421
+ view.nr.used = true;
422
+ newlyUsedView = true;
423
+ if (unusedPool) {
424
+ const index = unusedPool.indexOf(view);
425
+ if (~index)
426
+ unusedPool.splice(index, 1);
427
+ }
428
+ }
429
+ }
430
+ view.item = item;
431
+ return { view, unusedPool, newlyUsedView };
432
+ };
433
+ const computeViewStyle = ({ props, state }) => (view) => {
434
+ const { direction, gridItems, itemSecondarySize, itemSize } = props;
435
+ let transform = `translate${direction === "vertical" ? "Y" : "X"}(${view.position}px)`;
436
+ transform = `${transform} translate${direction === "vertical" ? "X" : "Y"}(${view.offset}px)`;
437
+ let width = gridItems ? `${direction === "vertical" ? itemSecondarySize || itemSize : itemSize}px` : void 0;
438
+ let height = gridItems ? `${direction === "horizontal" ? itemSecondarySize || itemSize : itemSize}px` : void 0;
439
+ return state.ready ? { transform, width, height } : null;
440
+ };
441
+ const computeViewEvent = ({ props, state }) => (view) => {
442
+ if (props.skipHover) {
443
+ return {};
444
+ } else {
445
+ return {
446
+ mouseenter: () => state.hoverKey = view.nr.key,
447
+ mouseleave: () => state.hoverKey = null
448
+ };
449
+ }
450
+ };
451
+ export {
452
+ addListeners,
453
+ addView,
454
+ applyPageMode,
455
+ computeViewEvent,
456
+ computeViewStyle,
457
+ computedItemIndexByKey,
458
+ computedSizes,
459
+ getListenerTarget,
460
+ getScroll,
461
+ handleResize,
462
+ handleScroll,
463
+ handleVisibilityChange,
464
+ removeListeners,
465
+ scrollToItem,
466
+ scrollToPosition,
467
+ sortViews,
468
+ unuseView,
469
+ updateVisibleItems
470
+ };
@@ -0,0 +1,135 @@
1
+ import "../chunk-PKUHTIDK.js";
2
+ import {
3
+ handleVisibilityChange,
4
+ updateVisibleItems,
5
+ computedSizes,
6
+ computedItemIndexByKey,
7
+ getScroll,
8
+ unuseView,
9
+ addView,
10
+ sortViews,
11
+ handleScroll,
12
+ handleResize,
13
+ applyPageMode,
14
+ addListeners,
15
+ removeListeners,
16
+ getListenerTarget,
17
+ scrollToPosition,
18
+ scrollToItem,
19
+ computeViewStyle,
20
+ computeViewEvent
21
+ } from "./index";
22
+ import { addResizeListener, removeResizeListener } from "../common/deps/resize-event";
23
+ const api = [
24
+ "state",
25
+ "handleVisibilityChange",
26
+ "handleScroll",
27
+ "scrollToItem",
28
+ "computeViewStyle",
29
+ "computeViewEvent"
30
+ ];
31
+ const addWatchers = ({ watch, props, api: api2, state }) => {
32
+ watch(
33
+ () => props.items,
34
+ () => api2.updateVisibleItems(true)
35
+ );
36
+ watch(
37
+ () => props.pageMode,
38
+ () => {
39
+ api2.applyPageMode();
40
+ api2.updateVisibleItems(false);
41
+ }
42
+ );
43
+ watch(
44
+ () => state.sizes,
45
+ () => api2.updateVisibleItems(false),
46
+ { deep: true }
47
+ );
48
+ watch(
49
+ () => props.gridItems,
50
+ () => api2.updateVisibleItems(true)
51
+ );
52
+ watch(
53
+ () => props.itemSecondarySize,
54
+ () => api2.updateVisibleItems(true)
55
+ );
56
+ };
57
+ const checkProps = (props) => {
58
+ if (props.gridItems && !props.itemSize) {
59
+ throw new Error("[TINY Error][RecycleScroller] You must provide an itemSize when using gridItems");
60
+ }
61
+ };
62
+ const renderless = (props, { reactive, computed, onBeforeUnmount, onMounted, onActivated, watch, markRaw, shallowReactive }, { vm, nextTick, emit }) => {
63
+ const state = reactive({
64
+ pool: [],
65
+ totalSize: 0,
66
+ ready: false,
67
+ hoverKey: null,
68
+ simpleArray: computed(() => props.items.length && typeof props.items[0] !== "object"),
69
+ sizes: computed(() => api2.computedSizes()),
70
+ itemIndexByKey: computed(() => api2.computedItemIndexByKey())
71
+ });
72
+ const api2 = {
73
+ state,
74
+ computedSizes: computedSizes({ props, state }),
75
+ computedItemIndexByKey: computedItemIndexByKey(props),
76
+ getScroll: getScroll({ props, vm }),
77
+ unuseView: unuseView(state),
78
+ addView: addView({ markRaw, shallowReactive }),
79
+ sortViews: sortViews(state),
80
+ getListenerTarget: getListenerTarget({ props, vm }),
81
+ scrollToPosition: scrollToPosition({ props, vm }),
82
+ computeViewStyle: computeViewStyle({ props, state }),
83
+ computeViewEvent: computeViewEvent({ props, state })
84
+ };
85
+ Object.assign(api2, {
86
+ handleVisibilityChange: handleVisibilityChange({ api: api2, emit, state }),
87
+ updateVisibleItems: updateVisibleItems({ api: api2, emit, props, state, vm }),
88
+ handleScroll: handleScroll({ api: api2, props, state }),
89
+ handleResize: handleResize({ api: api2, emit, state }),
90
+ applyPageMode: applyPageMode({ api: api2, props }),
91
+ addListeners: addListeners({ api: api2, state }),
92
+ removeListeners: removeListeners({ api: api2, state }),
93
+ scrollToItem: scrollToItem({ api: api2, props, state })
94
+ });
95
+ state.temporary = {
96
+ startIndex: 0,
97
+ endIndex: 0,
98
+ views: /* @__PURE__ */ new Map(),
99
+ unusedViews: /* @__PURE__ */ new Map(),
100
+ scrollDirty: false,
101
+ lastUpdateScrollPosition: 0
102
+ };
103
+ if (props.prerender) {
104
+ state.temporary.prerender = true;
105
+ api2.updateVisibleItems(false);
106
+ }
107
+ checkProps(props);
108
+ onActivated(() => {
109
+ const lastPosition = state.temporary.lastUpdateScrollPosition;
110
+ if (typeof lastPosition === "number") {
111
+ nextTick(() => {
112
+ api2.scrollToPosition(lastPosition);
113
+ });
114
+ }
115
+ });
116
+ onMounted(() => {
117
+ addResizeListener(vm.$el, api2.handleResize);
118
+ api2.applyPageMode();
119
+ nextTick(() => {
120
+ state.temporary.prerender = false;
121
+ api2.updateVisibleItems(true);
122
+ state.ready = true;
123
+ });
124
+ });
125
+ onBeforeUnmount(() => {
126
+ removeResizeListener(vm.$el, api2.handleResize);
127
+ api2.removeListeners();
128
+ });
129
+ addWatchers({ watch, props, api: api2, state });
130
+ return api2;
131
+ };
132
+ export {
133
+ api,
134
+ renderless
135
+ };