@opentiny/vue-renderless 3.6.8 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action-sheet/index.js +28 -1
- package/action-sheet/vue.js +10 -4
- package/alert/index.js +24 -2
- package/alert/vue.js +15 -11
- package/amount/index.js +4 -4
- package/anchor/index.js +1 -1
- package/autocomplete/vue.js +3 -3
- package/autonavi-map/index.js +1 -1
- package/badge/vue.js +6 -6
- package/baidu-map/index.js +1 -1
- package/bulletin-board/index.js +1 -1
- package/button-group/vue.js +5 -4
- package/calendar/index.js +2 -2
- package/calendar-bar/index.js +268 -0
- package/calendar-bar/vue.js +87 -0
- package/card/index.js +84 -0
- package/card/vue.js +70 -0
- package/card-group/index.js +16 -0
- package/card-group/vue.js +21 -0
- package/card-template/index.js +1 -1
- package/carousel/index.js +89 -2
- package/carousel/vue.js +14 -5
- package/carousel-item/index.js +8 -0
- package/carousel-item/vue.js +7 -3
- package/cascader/index.js +6 -6
- package/cascader/vue.js +3 -3
- package/cascader-menu/vue.js +2 -2
- package/cascader-panel/index.js +4 -4
- package/cascader-panel/node.js +4 -4
- package/cascader-panel/vue.js +2 -2
- package/cascader-select/index.js +179 -0
- package/cascader-select/vue.js +74 -0
- package/cell/vue.js +16 -0
- package/chart-bar/index.js +3 -3
- package/chart-boxplot/index.js +2 -2
- package/chart-candle/index.js +3 -3
- package/chart-core/deps/utils.js +7 -7
- package/chart-core/index.js +2 -2
- package/chart-funnel/index.js +3 -3
- package/chart-gauge/index.js +3 -3
- package/chart-graph/index.js +1 -1
- package/chart-heatmap/index.js +2 -2
- package/chart-line/index.js +3 -3
- package/chart-liquidfill/index.js +2 -2
- package/chart-map/index.js +3 -3
- package/chart-pie/index.js +3 -3
- package/chart-radar/index.js +3 -3
- package/chart-sankey/index.js +3 -3
- package/chart-scatter/index.js +4 -4
- package/chart-sunburst/index.js +1 -1
- package/chart-tree/index.js +2 -2
- package/chart-waterfall/index.js +3 -3
- package/chart-wordcloud/index.js +2 -2
- package/checkbox/index.js +21 -0
- package/checkbox/vue.js +16 -3
- package/checkbox-button/vue.js +1 -1
- package/collapse-item/vue.js +1 -1
- package/column-list-group/index.js +0 -0
- package/column-list-group/vue.js +14 -0
- package/column-list-item/index.js +50 -0
- package/column-list-item/vue.js +39 -0
- package/common/array.js +3 -3
- package/common/bigInt.js +5 -2
- package/common/dataset/index.js +3 -3
- package/common/date.js +2 -2
- package/common/deps/ResizeObserver.js +1 -1
- package/common/deps/clickoutside.js +1 -1
- package/common/deps/date-util.js +4 -4
- package/common/deps/date.js +2 -2
- package/common/deps/debounce.js +1 -1
- package/common/deps/dom.js +1 -1
- package/common/deps/fullscreen/apis.js +3 -3
- package/common/deps/fullscreen/screenfull.js +1 -1
- package/common/deps/infinite-scroll.js +176 -0
- package/common/deps/letter-only.js +1 -1
- package/common/deps/number-only.js +1 -1
- package/common/deps/observe-visibility.js +106 -0
- package/common/deps/popper.js +20 -22
- package/common/deps/popup-manager.js +2 -2
- package/common/deps/repeat-click.js +1 -1
- package/common/deps/resize-event.js +1 -1
- package/common/deps/tree-model/node.js +5 -5
- package/common/deps/tree-model/tree-store.js +3 -3
- package/common/deps/upload-ajax.js +2 -2
- package/common/deps/vue-popper.js +6 -6
- package/common/deps/vue-popup.js +4 -4
- package/common/index.js +2 -2
- package/common/object.js +1 -1
- package/common/runtime.js +24 -24
- package/common/string.js +23 -4
- package/common/validate/rules/range.js +2 -2
- package/common/validate/rules/required.js +1 -1
- package/common/validate/rules/type.js +3 -3
- package/common/validate/schema.js +1 -1
- package/common/validate/util.js +1 -1
- package/common/validate/validations/array.js +1 -1
- package/common/validate/validations/date.js +1 -1
- package/common/validate/validations/enum.js +1 -1
- package/common/validate/validations/float.js +1 -1
- package/common/validate/validations/integer.js +1 -1
- package/common/validate/validations/method.js +1 -1
- package/common/validate/validations/number.js +1 -1
- package/common/validate/validations/pattern.js +1 -1
- package/common/validate/validations/string.js +1 -1
- package/common/validate/validations/type.js +1 -1
- package/container/index.js +1 -1
- package/crop/index.js +2 -2
- package/currency/index.js +2 -2
- package/date-panel/index.js +7 -7
- package/date-panel/vue.js +3 -2
- package/date-picker-mobile/index.js +250 -0
- package/date-picker-mobile/vue.js +86 -0
- package/date-range/index.js +1 -1
- package/date-range/vue.js +1 -1
- package/date-table/index.js +3 -3
- package/date-table/vue.js +1 -1
- package/dialog-box/index.js +6 -4
- package/dialog-box/vue.js +1 -1
- package/dialog-select/index.js +345 -0
- package/dialog-select/vue.js +110 -0
- package/drawer/index.js +83 -0
- package/drawer/vue.js +51 -0
- package/drop-times/index.js +1 -1
- package/dropdown/index.js +2 -2
- package/dropdown/vue.js +4 -3
- package/dropdown-item/index.js +5 -1
- package/dropdown-item/mf.js +79 -0
- package/dropdown-item/vue.js +9 -6
- package/dropdown-menu/index.js +30 -1
- package/dropdown-menu/vue.js +17 -7
- package/dynamic-scroller/index.js +117 -0
- package/dynamic-scroller/vue.js +88 -0
- package/dynamic-scroller-item/index.js +147 -0
- package/dynamic-scroller-item/vue.js +92 -0
- package/espace/index.js +1 -1
- package/espace/vue.js +1 -1
- package/exception/vue.js +3 -1
- package/fall-menu/index.js +4 -4
- package/file-upload/index.js +872 -408
- package/file-upload/vue.js +87 -36
- package/filter/index.js +131 -0
- package/filter/tag-group.js +43 -0
- package/filter/vue.js +73 -0
- package/filter-bar/index.js +9 -0
- package/filter-bar/vue.js +16 -0
- package/filter-box/index.js +17 -0
- package/filter-box/vue.js +19 -0
- package/filter-panel/index.js +42 -0
- package/filter-panel/vue.js +33 -0
- package/floatbar/index.js +1 -1
- package/flowchart/index.js +721 -0
- package/flowchart/vue.js +81 -0
- package/form/index.js +15 -1
- package/form/vue.js +10 -4
- package/form-item/index.js +46 -6
- package/form-item/vue.js +27 -3
- package/fullscreen/index.js +1 -1
- package/fullscreen/vue.js +1 -1
- package/grid/plugins/export.js +2 -2
- package/grid/plugins/exportExcel.js +2 -2
- package/grid/plugins/resize.js +1 -1
- package/grid/static/base/helperEqualCompare.js +1 -1
- package/grid/static/base/isPlainObject.js +1 -1
- package/grid/utils/common.js +3 -3
- package/grid/utils/dom.js +3 -3
- package/grid/utils/event.js +2 -2
- package/guide/index.js +168 -0
- package/guide/vue.js +36 -0
- package/hrapprover/index.js +1 -1
- package/image/index.js +8 -4
- package/image/vue.js +12 -6
- package/image-viewer/index.js +3 -3
- package/image-viewer/vue.js +16 -6
- package/input/index.js +34 -1
- package/input/vue.js +22 -6
- package/ip-address/index.js +1 -1
- package/ip-address/vue.js +1 -1
- package/link-menu/index.js +2 -2
- package/link-menu/vue.js +2 -2
- package/loading/index.js +2 -2
- package/loading/vue.js +2 -1
- package/locales/index.js +1 -1
- package/logout/index.js +1 -1
- package/milestone/index.js +5 -1
- package/modal/index.js +68 -39
- package/modal/vue.js +15 -12
- package/month-range/index.js +1 -1
- package/month-range/vue.js +1 -1
- package/month-table/index.js +5 -5
- package/month-table/vue.js +1 -1
- package/multi-select/index.js +5 -2
- package/multi-select/vue.js +4 -5
- package/nav-menu/index.js +6 -6
- package/notify/index.js +3 -3
- package/numeric/index.js +15 -5
- package/numeric/vue.js +15 -6
- package/option/index.js +1 -1
- package/package.json +2 -1
- package/pager/vue.js +10 -0
- package/pager-item/index.js +1 -1
- package/panel/index.js +1 -1
- package/picker/index.js +7 -7
- package/picker/vue.js +1 -1
- package/picker-column/index.js +1 -1
- package/popconfirm/index.js +25 -0
- package/popconfirm/vue.js +22 -0
- package/popeditor/index.js +7 -7
- package/popeditor/vue.js +2 -2
- package/popover/index.js +11 -3
- package/popover/vue.js +33 -10
- package/popup/index.js +4 -4
- package/pull-refresh/index.js +8 -11
- package/pull-refresh/vue.js +7 -7
- package/radio/index.js +17 -0
- package/radio/vue.js +18 -3
- package/radio-button/index.js +8 -0
- package/radio-button/vue.js +19 -4
- package/radio-group/index.js +1 -1
- package/radio-group/vue.js +5 -2
- package/rate/index.js +4 -2
- package/rate/vue.js +1 -1
- package/record/index.js +190 -0
- package/record/vue.js +44 -0
- package/recycle-scroller/index.js +470 -0
- package/recycle-scroller/vue.js +135 -0
- package/river/index.js +371 -0
- package/river/river.js +352 -0
- package/river/vue.js +77 -0
- package/roles/index.js +1 -1
- package/scrollbar/vue-bar.js +1 -1
- package/scrollbar/vue.js +1 -1
- package/search/index.js +3 -3
- package/select/index.js +21 -14
- package/select/vue.js +38 -15
- package/select-dropdown/vue.js +1 -1
- package/select-mobile/index.js +111 -0
- package/select-mobile/vue.js +58 -0
- package/select-view/index.js +170 -0
- package/select-view/vue.js +82 -0
- package/selected-box/index.js +216 -0
- package/selected-box/vue.js +98 -0
- package/slide-bar/index.js +1 -1
- package/slider/index.js +49 -4
- package/slider/vue.js +15 -4
- package/split/vue.js +1 -1
- package/standard-list-item/index.js +18 -0
- package/standard-list-item/vue.js +22 -0
- package/steps/index.js +30 -0
- package/steps/slide-bar.js +122 -0
- package/steps/vue.js +15 -3
- package/switch/index.js +1 -1
- package/switch/vue.js +2 -1
- package/tab-bar/index.js +2 -2
- package/tab-item/index.js +3 -3
- package/tab-item/vue.js +4 -3
- package/tab-item-mf/index.js +0 -0
- package/tab-item-mf/vue.js +16 -0
- package/tab-nav/index.js +78 -4
- package/tab-nav/vue.js +11 -3
- package/tabbar-item/index.js +1 -1
- package/tabbar-item/vue.js +1 -1
- package/tabs/index.js +8 -9
- package/tabs/vue.js +1 -1
- package/tabs-mf/index.js +109 -0
- package/tabs-mf/vue-bar.js +49 -0
- package/tabs-mf/vue-nav-item.js +22 -0
- package/tabs-mf/vue-nav.js +13 -0
- package/tabs-mf/vue.js +45 -0
- package/tabs-mf/wheel.js +71 -0
- package/tag/index.js +8 -2
- package/tag/vue.js +13 -5
- package/tag-group/index.js +24 -0
- package/tag-group/vue.js +29 -0
- package/tall-storage/index.js +1 -1
- package/tall-storage/vue.js +1 -1
- package/time/index.js +1 -1
- package/time/vue.js +2 -2
- package/time-line/index.js +28 -7
- package/time-line/vue.js +9 -4
- package/time-panel/index.js +2 -2
- package/time-panel/vue.js +1 -1
- package/time-picker-mobile/index.js +30 -0
- package/time-picker-mobile/vue.js +30 -0
- package/time-range/index.js +1 -1
- package/time-range/vue.js +1 -1
- package/time-spinner/index.js +2 -2
- package/time-spinner/vue.js +1 -1
- package/toggle-menu/index.js +2 -2
- package/toggle-menu/vue.js +1 -1
- package/tooltip/index.js +30 -3
- package/tooltip/vue.js +34 -13
- package/top-box/index.js +3 -3
- package/transfer/index.js +1 -1
- package/transfer-panel/index.js +2 -2
- package/tree/index.js +6 -6
- package/tree/vue.js +1 -1
- package/tree-node/index.js +1 -1
- package/upload/index.js +1 -1
- package/upload/vue.js +2 -2
- package/upload-dragger/index.js +5 -1
- package/upload-dragger/vue.js +9 -3
- package/upload-list/index.js +158 -8
- package/upload-list/vue.js +77 -25
- package/user/index.js +86 -70
- package/user/vue.js +15 -5
- package/user-account/vue.js +1 -1
- package/user-contact/index.js +49 -3
- package/user-contact/vue.js +17 -8
- package/user-head-group/vue.js +17 -0
- package/user-link/index.js +10 -2
- package/user-link/vue.js +11 -6
- package/wheel/index.js +1 -1
- package/wizard/index.js +3 -3
- package/year-range/index.js +125 -0
- package/year-range/vue.js +88 -0
- package/year-table/index.js +175 -11
- 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
|
+
};
|