vane-waterfall 1.0.5 → 2.0.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.
- package/README.md +174 -365
- package/dist/chunks/WaterfallCore-BSXw7bl_.js +581 -0
- package/dist/chunks/doc-3Fpag2G8.js +84 -0
- package/dist/chunks/doc-78xF08vt.js +82 -0
- package/dist/chunks/doc-B-7dugGv.js +79 -0
- package/dist/chunks/doc-B6kLfMPv.js +121 -0
- package/dist/chunks/doc-BCGQ8Cp5.js +114 -0
- package/dist/chunks/doc-BIzjYAZW.js +50 -0
- package/dist/chunks/doc-BP0DmB7-.js +91 -0
- package/dist/chunks/doc-BXElhF2h.js +138 -0
- package/dist/chunks/doc-BXSy2aPP.js +59 -0
- package/dist/chunks/doc-BfWnfTst.js +83 -0
- package/dist/chunks/doc-BtzhgTYj.js +85 -0
- package/dist/chunks/doc-C5xrHNoC.js +70 -0
- package/dist/chunks/doc-CBHjiDG7.js +88 -0
- package/dist/chunks/doc-CTUoMe7o.js +79 -0
- package/dist/chunks/doc-CcPFavOs.js +56 -0
- package/dist/chunks/doc-CraXjOaA.js +68 -0
- package/dist/chunks/doc-DElLNjIc.js +61 -0
- package/dist/chunks/doc-DJjxOYzW.js +111 -0
- package/dist/chunks/doc-DukOmDCo.js +95 -0
- package/dist/chunks/doc-DzvTrZ13.js +60 -0
- package/dist/chunks/doc-NhL4Ux8q.js +125 -0
- package/dist/chunks/doc-bTHwfIVb.js +78 -0
- package/dist/chunks/doc-f4Uijujv.js +102 -0
- package/dist/chunks/doc-gTAsLjVx.js +55 -0
- package/dist/chunks/doc-j4W9SUrY.js +76 -0
- package/dist/chunks/doc-kTbJE7rY.js +92 -0
- package/dist/chunks/index-BAWlVYr3.js +5 -0
- package/dist/chunks/index-COaun3nf.js +15 -0
- package/dist/chunks/index-DXAtA2f6.js +11 -0
- package/dist/chunks/index-DsRLmBW-.js +13 -0
- package/dist/chunks/index-gjoCq0yC.js +21 -0
- package/dist/chunks/index-wLI6UXkY.js +5 -0
- package/dist/chunks/withPlugins-DLoKg4AP.js +559 -0
- package/dist/components/WaterfallPlugin/WaterfallCore.d.ts +124 -0
- package/dist/components/WaterfallPlugin/WaterfallCore.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/index.d.ts +9 -10
- package/dist/components/WaterfallPlugin/index.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/layout.d.ts +41 -0
- package/dist/components/WaterfallPlugin/layout.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/plugins/types.d.ts +76 -380
- package/dist/components/WaterfallPlugin/plugins/types.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/virtualize.d.ts +62 -0
- package/dist/components/WaterfallPlugin/virtualize.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/{plugins/withPlugins.d.ts → withPlugins.d.ts} +4 -2
- package/dist/components/WaterfallPlugin/withPlugins.d.ts.map +1 -0
- package/dist/custom-plugins/A11yPlugin/create.d.ts +23 -0
- package/dist/custom-plugins/A11yPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/A11yPlugin/doc.json.d.ts +52 -0
- package/dist/custom-plugins/A11yPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/A11yPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/A11yPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Alignment/index.d.ts → custom-plugins/AlignmentPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/AlignmentPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/AlignmentPlugin/doc.json.d.ts +34 -0
- package/dist/custom-plugins/AlignmentPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/AlignmentPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/AlignmentPlugin/index.js +5 -0
- package/dist/custom-plugins/AutoColumnPlugin/create.d.ts +18 -0
- package/dist/custom-plugins/AutoColumnPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/AutoColumnPlugin/doc.json.d.ts +50 -0
- package/dist/custom-plugins/AutoColumnPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/AutoColumnPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/AutoColumnPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Bookmark/index.d.ts → custom-plugins/BookmarkPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/BookmarkPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/BookmarkPlugin/doc.json.d.ts +41 -0
- package/dist/custom-plugins/BookmarkPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/BookmarkPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/BookmarkPlugin/index.js +5 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts +25 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/doc.json.d.ts +41 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/DebounceLayout/index.d.ts → custom-plugins/DebounceLayoutPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/DebounceLayoutPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/DebounceLayoutPlugin/doc.json.d.ts +34 -0
- package/dist/custom-plugins/DebounceLayoutPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/DebounceLayoutPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/DebounceLayoutPlugin/index.js +5 -0
- package/dist/custom-plugins/DragReorderPlugin/create.d.ts +33 -0
- package/dist/custom-plugins/DragReorderPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/DragReorderPlugin/doc.json.d.ts +53 -0
- package/dist/custom-plugins/DragReorderPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/DragReorderPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/DragReorderPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Filter/index.d.ts → custom-plugins/FilterPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/FilterPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/FilterPlugin/doc.json.d.ts +47 -0
- package/dist/custom-plugins/FilterPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/FilterPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/FilterPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/FixedHeight/index.d.ts → custom-plugins/FixedHeightPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/FixedHeightPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/FixedHeightPlugin/doc.json.d.ts +34 -0
- package/dist/custom-plugins/FixedHeightPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/FixedHeightPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/FixedHeightPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Gap/index.d.ts → custom-plugins/GapPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/GapPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/GapPlugin/doc.json.d.ts +47 -0
- package/dist/custom-plugins/GapPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/GapPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/GapPlugin/index.js +5 -0
- package/dist/custom-plugins/GroupingPlugin/create.d.ts +16 -0
- package/dist/custom-plugins/GroupingPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/GroupingPlugin/doc.json.d.ts +40 -0
- package/dist/custom-plugins/GroupingPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/GroupingPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/GroupingPlugin/index.js +5 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts +31 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/doc.json.d.ts +43 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.js +5 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts +17 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/doc.json.d.ts +44 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Pagination/index.d.ts → custom-plugins/PaginationPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/PaginationPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/PaginationPlugin/doc.json.d.ts +50 -0
- package/dist/custom-plugins/PaginationPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/PaginationPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/PaginationPlugin/index.js +5 -0
- package/dist/custom-plugins/PinItemPlugin/create.d.ts +23 -0
- package/dist/custom-plugins/PinItemPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/PinItemPlugin/doc.json.d.ts +43 -0
- package/dist/custom-plugins/PinItemPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/PinItemPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/PinItemPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Recycle/index.d.ts → custom-plugins/RecyclePlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/RecyclePlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/RecyclePlugin/doc.json.d.ts +35 -0
- package/dist/custom-plugins/RecyclePlugin/index.d.ts +11 -0
- package/dist/custom-plugins/RecyclePlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/RecyclePlugin/index.js +5 -0
- package/dist/custom-plugins/ReducedMotionPlugin/create.d.ts +25 -0
- package/dist/custom-plugins/ReducedMotionPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ReducedMotionPlugin/doc.json.d.ts +42 -0
- package/dist/custom-plugins/ReducedMotionPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/ReducedMotionPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ReducedMotionPlugin/index.js +5 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/create.d.ts +22 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/doc.json.d.ts +37 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/index.d.ts +10 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/ScrollAnchor/index.d.ts → custom-plugins/ScrollAnchorPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/ScrollAnchorPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ScrollAnchorPlugin/doc.json.d.ts +34 -0
- package/dist/custom-plugins/ScrollAnchorPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/ScrollAnchorPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ScrollAnchorPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Search/index.d.ts → custom-plugins/SearchPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/SearchPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/SearchPlugin/doc.json.d.ts +47 -0
- package/dist/custom-plugins/SearchPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/SearchPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/SearchPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Sort/index.d.ts → custom-plugins/SortPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/SortPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/SortPlugin/doc.json.d.ts +46 -0
- package/dist/custom-plugins/SortPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/SortPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/SortPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/StatePersistence/index.d.ts → custom-plugins/StatePersistencePlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/StatePersistencePlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/StatePersistencePlugin/doc.json.d.ts +47 -0
- package/dist/custom-plugins/StatePersistencePlugin/index.d.ts +11 -0
- package/dist/custom-plugins/StatePersistencePlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/StatePersistencePlugin/index.js +5 -0
- package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts +13 -0
- package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/StickyHeaderPlugin/doc.json.d.ts +40 -0
- package/dist/custom-plugins/StickyHeaderPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/StickyHeaderPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/StickyHeaderPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Throttle/index.d.ts → custom-plugins/ThrottlePlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/ThrottlePlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ThrottlePlugin/doc.json.d.ts +40 -0
- package/dist/custom-plugins/ThrottlePlugin/index.d.ts +11 -0
- package/dist/custom-plugins/ThrottlePlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ThrottlePlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Transition/index.d.ts → custom-plugins/TransitionPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/TransitionPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/TransitionPlugin/doc.json.d.ts +43 -0
- package/dist/custom-plugins/TransitionPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/TransitionPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/TransitionPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/URLSync/index.d.ts → custom-plugins/URLSyncPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/URLSyncPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/URLSyncPlugin/doc.json.d.ts +41 -0
- package/dist/custom-plugins/URLSyncPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/URLSyncPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/URLSyncPlugin/index.js +5 -0
- package/dist/custom-plugins/index.d.ts +61 -0
- package/dist/custom-plugins/index.d.ts.map +1 -0
- package/dist/custom-plugins/index.js +34 -0
- package/dist/entries/core.d.ts +8 -0
- package/dist/entries/core.d.ts.map +1 -0
- package/dist/entries/core.js +7 -0
- package/dist/entries/plugins.d.ts +7 -0
- package/dist/entries/plugins.d.ts.map +1 -0
- package/dist/entries/plugins.js +36 -0
- package/dist/index.d.ts +14 -9
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/presets/dashboard/index.d.ts +13 -0
- package/dist/presets/dashboard/index.d.ts.map +1 -0
- package/dist/presets/dashboard/index.js +21 -0
- package/dist/presets/photo-feed/index.d.ts +13 -0
- package/dist/presets/photo-feed/index.d.ts.map +1 -0
- package/dist/presets/photo-feed/index.js +17 -0
- package/dist/presets/product-feed/index.d.ts +9 -0
- package/dist/presets/product-feed/index.d.ts.map +1 -0
- package/dist/presets/product-feed/index.js +23 -0
- package/package.json +222 -82
- package/dist/404.jpg +0 -0
- package/dist/components/WaterfallPlugin/core/WaterfallCore.d.ts +0 -174
- package/dist/components/WaterfallPlugin/custom-plugins/A11y/index.d.ts +0 -16
- package/dist/components/WaterfallPlugin/custom-plugins/AutoColumn/index.d.ts +0 -17
- package/dist/components/WaterfallPlugin/custom-plugins/ClickAnalytics/index.d.ts +0 -12
- package/dist/components/WaterfallPlugin/custom-plugins/DragReorder/index.d.ts +0 -13
- package/dist/components/WaterfallPlugin/custom-plugins/Grouping/index.d.ts +0 -12
- package/dist/components/WaterfallPlugin/custom-plugins/HeatmapAnalytics/index.d.ts +0 -14
- package/dist/components/WaterfallPlugin/custom-plugins/InfiniteScroll/index.d.ts +0 -13
- package/dist/components/WaterfallPlugin/custom-plugins/PinItem/index.d.ts +0 -13
- package/dist/components/WaterfallPlugin/custom-plugins/ReducedMotion/index.d.ts +0 -13
- package/dist/components/WaterfallPlugin/custom-plugins/ResponsiveColumns/index.d.ts +0 -10
- package/dist/components/WaterfallPlugin/custom-plugins/StickyHeader/index.d.ts +0 -11
- package/dist/components/WaterfallPlugin/custom-plugins/VirtualWaterfall/index.d.ts +0 -12
- package/dist/components/WaterfallPlugin/custom-plugins/index.d.ts +0 -30
- package/dist/components/WaterfallPlugin/plugins/PluginBus.d.ts +0 -2
- package/dist/components/WaterfallPlugin/plugins/PluginManager.d.ts +0 -2
- package/dist/components/WaterfallPlugin/plugins/index.d.ts +0 -8
- package/dist/index.es.js +0 -2382
- package/dist/index.umd.js +0 -30
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
function g(n = {}) {
|
|
2
|
+
const t = Math.max(1, n.threshold ?? 300);
|
|
3
|
+
let e = !1;
|
|
4
|
+
return {
|
|
5
|
+
name: "InfiniteScrollPlugin",
|
|
6
|
+
priority: 35,
|
|
7
|
+
enabled: !0,
|
|
8
|
+
hooks: {
|
|
9
|
+
transformProps: (o) => ({
|
|
10
|
+
...o,
|
|
11
|
+
reachBottomOffset: t
|
|
12
|
+
}),
|
|
13
|
+
onReachBottom: async (o, a) => {
|
|
14
|
+
if (e || o.hasMore === !1 || a > t) return;
|
|
15
|
+
const s = n.onLoadMore ?? o.props.onLoadMore;
|
|
16
|
+
if (typeof s == "function") {
|
|
17
|
+
e = !0;
|
|
18
|
+
try {
|
|
19
|
+
await Promise.resolve(s());
|
|
20
|
+
} finally {
|
|
21
|
+
e = !1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
onUnmount: () => {
|
|
26
|
+
e = !1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const r = "InfiniteScrollPlugin", i = "监听 Core 的 onReachBottom,在距底部 `threshold` 像素内触发 onLoadMore。自带并发锁:上一次还没结束不会重复触发。", l = "2.0.0", c = [
|
|
32
|
+
"data",
|
|
33
|
+
"加载更多"
|
|
34
|
+
], f = [
|
|
35
|
+
{
|
|
36
|
+
name: "threshold",
|
|
37
|
+
type: "number",
|
|
38
|
+
default: "300",
|
|
39
|
+
description: "触发距离 px"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "onLoadMore",
|
|
43
|
+
type: "() => void | Promise<void>",
|
|
44
|
+
default: "props.onLoadMore",
|
|
45
|
+
description: "加载回调"
|
|
46
|
+
}
|
|
47
|
+
], d = `// 滚动到距底部阈值内触发加载更多,带并发锁防重复请求。
|
|
48
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
49
|
+
createInfiniteScrollPlugin({
|
|
50
|
+
threshold: 300,
|
|
51
|
+
}),
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, u = [
|
|
55
|
+
"PaginationPlugin"
|
|
56
|
+
], m = [
|
|
57
|
+
"距底 300px 预加载,滚到底时数据已就位",
|
|
58
|
+
"并发锁:加载中不重复触发",
|
|
59
|
+
"context.hasMore 为 false 时自动停"
|
|
60
|
+
], p = [
|
|
61
|
+
"信息流无限滚动",
|
|
62
|
+
"画廊继续加载",
|
|
63
|
+
"搜索结果瀑布流"
|
|
64
|
+
], h = [
|
|
65
|
+
"阈值不要小于一屏(约 600px),否则用户滚到底会看到空白等待。",
|
|
66
|
+
"翻页类场景请用 PaginationPlugin,两者不要同装。"
|
|
67
|
+
], P = {
|
|
68
|
+
name: r,
|
|
69
|
+
description: i,
|
|
70
|
+
since: l,
|
|
71
|
+
tags: c,
|
|
72
|
+
config: f,
|
|
73
|
+
example: d,
|
|
74
|
+
conflicts: u,
|
|
75
|
+
features: m,
|
|
76
|
+
useCases: p,
|
|
77
|
+
notes: h
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
g as c,
|
|
81
|
+
P as d
|
|
82
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
function S(a = {}) {
|
|
2
|
+
return {
|
|
3
|
+
name: "PaginationPlugin",
|
|
4
|
+
priority: 10,
|
|
5
|
+
enabled: !0,
|
|
6
|
+
hooks: {
|
|
7
|
+
transformProps: (e) => {
|
|
8
|
+
const t = Math.max(1, Number(e.pageIndex ?? 1)), o = Math.max(1, Number(e.pageSize ?? a.pageSize ?? 20)), s = Array.isArray(e.items) ? e.items : [], n = (t - 1) * o, i = n + o, r = s.slice(n, i);
|
|
9
|
+
return { ...e, items: r };
|
|
10
|
+
},
|
|
11
|
+
onPropsChange: (e, t, o) => {
|
|
12
|
+
const s = Math.max(1, Number(t?.pageIndex ?? 1)), n = Math.max(1, Number(o?.pageIndex ?? 1));
|
|
13
|
+
if (((typeof o?.scrollToTopOnPageChange == "boolean" ? o.scrollToTopOnPageChange : void 0) ?? !!a.scrollToTop) && s !== n) {
|
|
14
|
+
const l = o?.scrollToTopBehavior ?? a.scrollBehavior ?? "auto";
|
|
15
|
+
e.scrollToTop?.({ behavior: l });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const c = "PaginationPlugin", p = "读 `props.pageIndex`(1 基)与 `props.pageSize` 切片。放在数据管线最末端,保证切的是「过滤 + 排序 + 搜索」之后的结果。", g = "2.0.0", d = [
|
|
22
|
+
"data",
|
|
23
|
+
"数据管线",
|
|
24
|
+
"分页"
|
|
25
|
+
], m = [
|
|
26
|
+
{
|
|
27
|
+
name: "pageSize",
|
|
28
|
+
type: "number",
|
|
29
|
+
default: "props.pageSize ?? 20",
|
|
30
|
+
description: "每页条数"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "scrollToTop",
|
|
34
|
+
type: "boolean",
|
|
35
|
+
default: "false",
|
|
36
|
+
description: "翻页后回顶"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "scrollBehavior",
|
|
40
|
+
type: '"auto" | "smooth"',
|
|
41
|
+
default: '"auto"',
|
|
42
|
+
description: "回顶行为"
|
|
43
|
+
}
|
|
44
|
+
], u = `// 按 props.pageIndex / pageSize 切片,页码从 1 开始。
|
|
45
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
46
|
+
createPaginationPlugin({
|
|
47
|
+
scrollToTop: false,
|
|
48
|
+
scrollBehavior: "auto",
|
|
49
|
+
}),
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, f = [
|
|
53
|
+
"InfiniteScrollPlugin"
|
|
54
|
+
], h = [
|
|
55
|
+
"1 基页码(与 UI 分页器一致)",
|
|
56
|
+
"pageIndex 非法值自动夹到 1",
|
|
57
|
+
"翻页自动回顶可选"
|
|
58
|
+
], x = [
|
|
59
|
+
"后台列表分页",
|
|
60
|
+
"搜索结果分页",
|
|
61
|
+
"与 URLSyncPlugin 配合做可分享链接"
|
|
62
|
+
], P = [
|
|
63
|
+
"pageSize 优先级:props.pageSize > 工厂 config.pageSize > 20。"
|
|
64
|
+
], T = {
|
|
65
|
+
name: c,
|
|
66
|
+
description: p,
|
|
67
|
+
since: g,
|
|
68
|
+
tags: d,
|
|
69
|
+
config: m,
|
|
70
|
+
example: u,
|
|
71
|
+
conflicts: f,
|
|
72
|
+
features: h,
|
|
73
|
+
useCases: x,
|
|
74
|
+
notes: P
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
S as c,
|
|
78
|
+
T as d
|
|
79
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
function k(l = {}) {
|
|
3
|
+
const m = l.showOverlay ?? l.showOverlaySummary ?? !1, a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
4
|
+
let i = !1;
|
|
5
|
+
const c = (t) => Array.from(t.values()).reduce((e, s) => e + s, 0);
|
|
6
|
+
return {
|
|
7
|
+
name: "HeatmapAnalyticsPlugin",
|
|
8
|
+
enabled: !0,
|
|
9
|
+
getStats: () => {
|
|
10
|
+
const t = /* @__PURE__ */ new Set([...a.keys(), ...o.keys()]);
|
|
11
|
+
return {
|
|
12
|
+
totalViews: c(a),
|
|
13
|
+
totalClicks: c(o),
|
|
14
|
+
items: Array.from(t).sort((e, s) => e - s).map((e) => ({
|
|
15
|
+
index: e,
|
|
16
|
+
views: a.get(e) ?? 0,
|
|
17
|
+
clicks: o.get(e) ?? 0
|
|
18
|
+
}))
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
hooks: {
|
|
22
|
+
onLayoutComplete: (t) => {
|
|
23
|
+
if (i) return;
|
|
24
|
+
const { start: e, end: s } = t.visibleRange;
|
|
25
|
+
for (let n = e; n <= s; n++)
|
|
26
|
+
a.set(n, (a.get(n) || 0) + 1);
|
|
27
|
+
i = !0;
|
|
28
|
+
},
|
|
29
|
+
onItemEnterViewport: (t, e) => {
|
|
30
|
+
a.set(e, (a.get(e) || 0) + 1);
|
|
31
|
+
},
|
|
32
|
+
onItemClick: (t, e) => {
|
|
33
|
+
o.set(e, (o.get(e) || 0) + 1), t.forceUpdate?.();
|
|
34
|
+
},
|
|
35
|
+
renderOverlay: () => {
|
|
36
|
+
if (!m) return null;
|
|
37
|
+
const t = Array.from(a.values()).reduce((s, n) => s + n, 0), e = Array.from(o.values()).reduce((s, n) => s + n, 0);
|
|
38
|
+
return /* @__PURE__ */ r(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
style: {
|
|
42
|
+
position: "sticky",
|
|
43
|
+
top: 0,
|
|
44
|
+
zIndex: 100,
|
|
45
|
+
display: "flex",
|
|
46
|
+
gap: 12,
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
padding: "6px 10px",
|
|
49
|
+
background: "rgba(0,0,0,0.6)",
|
|
50
|
+
color: "white",
|
|
51
|
+
borderRadius: 8,
|
|
52
|
+
fontSize: 12,
|
|
53
|
+
marginBottom: 8
|
|
54
|
+
},
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ r("span", { children: [
|
|
57
|
+
"曝光总计: ",
|
|
58
|
+
t
|
|
59
|
+
] }),
|
|
60
|
+
/* @__PURE__ */ r("span", { children: [
|
|
61
|
+
"点击总计: ",
|
|
62
|
+
e
|
|
63
|
+
] })
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const u = "HeatmapAnalyticsPlugin", p = "统计每项进入视口次数与点击次数,可选顶部汇总条,`getStats()` 取出每项明细。曝光是瀑布流里最容易统计错的东西(滚动时反复进出视口),交给插件比自己写 IntersectionObserver 少踩坑。", y = "2.0.0", d = [
|
|
72
|
+
"interaction",
|
|
73
|
+
"埋点",
|
|
74
|
+
"曝光"
|
|
75
|
+
], f = [
|
|
76
|
+
{
|
|
77
|
+
name: "showOverlay",
|
|
78
|
+
type: "boolean",
|
|
79
|
+
default: "false",
|
|
80
|
+
description: "是否显示顶部汇总条"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "showOverlaySummary",
|
|
84
|
+
type: "boolean",
|
|
85
|
+
default: "—",
|
|
86
|
+
description: "showOverlay 的旧别名"
|
|
87
|
+
}
|
|
88
|
+
], g = `// 统计每项曝光次数与点击次数,可显示汇总条。
|
|
89
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
90
|
+
createHeatmapAnalyticsPlugin({
|
|
91
|
+
showOverlay: false,
|
|
92
|
+
}),
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, w = [
|
|
96
|
+
"按项的曝光 / 点击双计数",
|
|
97
|
+
"首屏曝光在 onLayoutComplete 补一次",
|
|
98
|
+
"getStats() 输出可上报的扁平结构"
|
|
99
|
+
], v = [
|
|
100
|
+
"信息流曝光分析",
|
|
101
|
+
"广告位可见性验证",
|
|
102
|
+
"调试曝光策略"
|
|
103
|
+
], h = [
|
|
104
|
+
"首屏曝光靠 onLayoutComplete 补一次,否则第一帧显示 0。",
|
|
105
|
+
"真实上报要自己做去重与批次(插件只负责计数,不区分「同一项第几次进入」)。",
|
|
106
|
+
"计数只在内存里,刷新即清零 —— 定时取 getStats() 上报。"
|
|
107
|
+
], O = {
|
|
108
|
+
name: u,
|
|
109
|
+
description: p,
|
|
110
|
+
since: y,
|
|
111
|
+
tags: d,
|
|
112
|
+
config: f,
|
|
113
|
+
example: g,
|
|
114
|
+
features: w,
|
|
115
|
+
useCases: v,
|
|
116
|
+
notes: h
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
k as c,
|
|
120
|
+
O as d
|
|
121
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
const p = "GROUPS";
|
|
3
|
+
function x(i = {}) {
|
|
4
|
+
const u = i.groupBy ?? ((e) => e?.category ?? "default"), l = i.showOverlay ?? !1, r = (e) => {
|
|
5
|
+
const t = /* @__PURE__ */ new Map();
|
|
6
|
+
return (e.props.items ?? []).forEach((s, n) => {
|
|
7
|
+
const o = u(s, n);
|
|
8
|
+
t.has(o) || t.set(o, []), t.get(o).push(n);
|
|
9
|
+
}), e.sharedData.set(p, t), t.size > 0 && e.bus.emit("grouping:change", { groups: t }), t;
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
name: "GroupingPlugin",
|
|
13
|
+
enabled: !0,
|
|
14
|
+
hooks: {
|
|
15
|
+
onMount: (e) => {
|
|
16
|
+
r(e);
|
|
17
|
+
},
|
|
18
|
+
onLayoutComplete: (e) => {
|
|
19
|
+
r(e);
|
|
20
|
+
},
|
|
21
|
+
onPropsChange: (e) => {
|
|
22
|
+
r(e);
|
|
23
|
+
},
|
|
24
|
+
renderOverlay: (e) => {
|
|
25
|
+
if (!l) return null;
|
|
26
|
+
const t = e.sharedData.get(p) ?? /* @__PURE__ */ new Map();
|
|
27
|
+
if (t.size === 0) return null;
|
|
28
|
+
const s = Array.from(t.entries()).slice(0, 3);
|
|
29
|
+
return /* @__PURE__ */ a(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
style: {
|
|
33
|
+
position: "absolute",
|
|
34
|
+
top: 12,
|
|
35
|
+
left: 12,
|
|
36
|
+
zIndex: 99,
|
|
37
|
+
background: "#111827",
|
|
38
|
+
color: "#fff",
|
|
39
|
+
padding: "10px 12px",
|
|
40
|
+
borderRadius: 8,
|
|
41
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.25)",
|
|
42
|
+
border: "1px solid rgba(255,255,255,0.15)",
|
|
43
|
+
minWidth: 150,
|
|
44
|
+
fontSize: 12,
|
|
45
|
+
pointerEvents: "none"
|
|
46
|
+
},
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ a("div", { style: { opacity: 0.85, marginBottom: 6 }, children: [
|
|
49
|
+
"分组:",
|
|
50
|
+
t.size,
|
|
51
|
+
" 组"
|
|
52
|
+
] }),
|
|
53
|
+
s.map(([n, o]) => /* @__PURE__ */ a("div", { children: [
|
|
54
|
+
String(n),
|
|
55
|
+
" · ",
|
|
56
|
+
o.length,
|
|
57
|
+
" 项"
|
|
58
|
+
] }, String(n)))
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const c = "GroupingPlugin", d = "用 groupBy 把项按业务字段分组,结果放进 sharedData 的 `GROUPS`(Map<组键, 索引数组>),供 StickyHeaderPlugin、分组统计条等消费。挂载即算一次,之后 props 变化重算。", g = "2.0.0", f = [
|
|
67
|
+
"ui",
|
|
68
|
+
"分组"
|
|
69
|
+
], m = [
|
|
70
|
+
{
|
|
71
|
+
name: "groupBy",
|
|
72
|
+
type: "(item, index) => string | number",
|
|
73
|
+
default: 'item.category ?? "default"',
|
|
74
|
+
description: "分组函数"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "showOverlay",
|
|
78
|
+
type: "boolean",
|
|
79
|
+
default: "false",
|
|
80
|
+
description: "是否显示分组统计角标"
|
|
81
|
+
}
|
|
82
|
+
], h = `// 按字段把项分组,结果写进 sharedData(GROUPS) 供吸顶条 / 统计用。
|
|
83
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
84
|
+
createGroupingPlugin({
|
|
85
|
+
groupBy: "item.category ?? \\"default\\"",
|
|
86
|
+
showOverlay: false,
|
|
87
|
+
}),
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, y = [
|
|
91
|
+
"挂载即计算(旧版只在 props 变化时算,首屏永远拿不到分组)",
|
|
92
|
+
"结果写 sharedData,跨插件可读",
|
|
93
|
+
"统计角标默认关闭"
|
|
94
|
+
], b = [
|
|
95
|
+
"按分类分组的信息流",
|
|
96
|
+
"按日期分组的时间线",
|
|
97
|
+
"吸顶条显示当前分组"
|
|
98
|
+
], P = [
|
|
99
|
+
"分组只产出索引映射,不改变渲染顺序;要视觉分组请自己按分组建行。"
|
|
100
|
+
], w = {
|
|
101
|
+
name: c,
|
|
102
|
+
description: d,
|
|
103
|
+
since: g,
|
|
104
|
+
tags: f,
|
|
105
|
+
config: m,
|
|
106
|
+
example: h,
|
|
107
|
+
features: y,
|
|
108
|
+
useCases: b,
|
|
109
|
+
notes: P
|
|
110
|
+
};
|
|
111
|
+
export {
|
|
112
|
+
x as c,
|
|
113
|
+
w as d
|
|
114
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function d(e) {
|
|
2
|
+
return {
|
|
3
|
+
name: "DebounceLayoutPlugin",
|
|
4
|
+
priority: 75,
|
|
5
|
+
enabled: !0,
|
|
6
|
+
hooks: {
|
|
7
|
+
transformProps: (n) => ({ ...n, debounceDelay: e.delay })
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const t = "DebounceLayoutPlugin", o = "只调 debounceDelay:容器宽度连续变化(抽屉展开、分栏拖拽)时,等变化停下来再算一次布局,避免每帧重排。", s = "2.0.0", a = [
|
|
12
|
+
"perf",
|
|
13
|
+
"性能"
|
|
14
|
+
], c = [
|
|
15
|
+
{
|
|
16
|
+
name: "delay",
|
|
17
|
+
type: "number",
|
|
18
|
+
default: "—",
|
|
19
|
+
description: "布局防抖 ms(必填)"
|
|
20
|
+
}
|
|
21
|
+
], r = `// 单独放大布局防抖,容器频繁变宽时(抽屉/侧栏动画)不抖。
|
|
22
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
23
|
+
createDebounceLayoutPlugin(),
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, u = [
|
|
27
|
+
"只影响布局时机,不影响渲染",
|
|
28
|
+
"可被 ThrottlePlugin 覆盖",
|
|
29
|
+
"对移动端软键盘弹出也有效"
|
|
30
|
+
], i = [
|
|
31
|
+
"可折叠侧栏",
|
|
32
|
+
"分栏宽度拖拽",
|
|
33
|
+
"横竖屏切换"
|
|
34
|
+
], l = [
|
|
35
|
+
"delay 过大会让「展开后布局」明显滞后,建议 120–250ms。"
|
|
36
|
+
], m = {
|
|
37
|
+
name: t,
|
|
38
|
+
description: o,
|
|
39
|
+
since: s,
|
|
40
|
+
tags: a,
|
|
41
|
+
config: c,
|
|
42
|
+
example: r,
|
|
43
|
+
features: u,
|
|
44
|
+
useCases: i,
|
|
45
|
+
notes: l
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
d as c,
|
|
49
|
+
m as d
|
|
50
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
function v(s = {}) {
|
|
2
|
+
const c = s.storageKey || "waterfall-bookmark", l = s.scrollBehavior || "smooth", u = (r) => {
|
|
3
|
+
const e = r;
|
|
4
|
+
if (!e) return !1;
|
|
5
|
+
const n = e.tagName?.toLowerCase(), a = (e.getAttribute && e.getAttribute("contenteditable")) === "true";
|
|
6
|
+
return n === "input" || n === "textarea" || a;
|
|
7
|
+
};
|
|
8
|
+
return {
|
|
9
|
+
name: "BookmarkPlugin",
|
|
10
|
+
enabled: !0,
|
|
11
|
+
hooks: {
|
|
12
|
+
onMount: (r) => {
|
|
13
|
+
const e = (n) => {
|
|
14
|
+
if (u(n.target)) return;
|
|
15
|
+
const a = (n.key || "").toLowerCase(), i = n.code || "";
|
|
16
|
+
if (a === "b" || i === "KeyB") {
|
|
17
|
+
const t = r.containerRef?.current || null;
|
|
18
|
+
let o = 0;
|
|
19
|
+
t && t.scrollHeight > t.clientHeight ? o = t.scrollTop : o = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
20
|
+
try {
|
|
21
|
+
localStorage.setItem(c, String(Math.max(0, o)));
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
} else if (a === "r" || i === "KeyR") {
|
|
25
|
+
let t = 0;
|
|
26
|
+
try {
|
|
27
|
+
const d = localStorage.getItem(c) || "0";
|
|
28
|
+
t = Math.max(0, Number(d) || 0);
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
const o = r.containerRef?.current || null;
|
|
32
|
+
o && o.scrollHeight > o.clientHeight ? o.scrollTo({ top: t, behavior: l }) : window.scrollTo({ top: t, behavior: l });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return window.addEventListener("keydown", e, { capture: !0 }), document.addEventListener("keydown", e, { capture: !0 }), () => {
|
|
36
|
+
window.removeEventListener("keydown", e, { capture: !0 }), document.removeEventListener("keydown", e, { capture: !0 });
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const m = "BookmarkPlugin", g = "长列表读到一半要跳走时按 **B** 存位置,回来按 **R** 复原。焦点在输入框/可编辑区域时不拦截按键。", f = "2.0.0", k = [
|
|
43
|
+
"ui",
|
|
44
|
+
"滚动",
|
|
45
|
+
"快捷键"
|
|
46
|
+
], p = [
|
|
47
|
+
{
|
|
48
|
+
name: "storageKey",
|
|
49
|
+
type: "string",
|
|
50
|
+
default: '"waterfall-bookmark"',
|
|
51
|
+
description: "localStorage 键名"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "scrollBehavior",
|
|
55
|
+
type: '"auto" | "smooth"',
|
|
56
|
+
default: '"smooth"',
|
|
57
|
+
description: "恢复时的滚动行为"
|
|
58
|
+
}
|
|
59
|
+
], h = `// 按 B 记录滚动位置、按 R 跳回(localStorage),忽略输入框按键。
|
|
60
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
61
|
+
createBookmarkPlugin({
|
|
62
|
+
storageKey: "waterfall-bookmark",
|
|
63
|
+
scrollBehavior: "smooth",
|
|
64
|
+
}),
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, w = [
|
|
68
|
+
"B 存 / R 取,零 UI 侵入",
|
|
69
|
+
"自动区分容器滚动与页面滚动",
|
|
70
|
+
"输入框内不误触"
|
|
71
|
+
], y = [
|
|
72
|
+
"长文列表阅读",
|
|
73
|
+
"后台大表格浏览",
|
|
74
|
+
"演示时快速复位"
|
|
75
|
+
], b = [
|
|
76
|
+
"键名全局共用,一个页面里多处瀑布流请各自传不同的 storageKey。"
|
|
77
|
+
], B = {
|
|
78
|
+
name: m,
|
|
79
|
+
description: g,
|
|
80
|
+
since: f,
|
|
81
|
+
tags: k,
|
|
82
|
+
config: p,
|
|
83
|
+
example: h,
|
|
84
|
+
features: w,
|
|
85
|
+
useCases: y,
|
|
86
|
+
notes: b
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
v as c,
|
|
90
|
+
B as d
|
|
91
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
const i = "data-drag-over";
|
|
3
|
+
function y(s, l) {
|
|
4
|
+
if (typeof document > "u") return null;
|
|
5
|
+
const c = document.elementFromPoint(s, l)?.closest?.("[data-index]");
|
|
6
|
+
if (!c) return null;
|
|
7
|
+
const d = Number(c.getAttribute("data-index"));
|
|
8
|
+
return Number.isFinite(d) ? d : null;
|
|
9
|
+
}
|
|
10
|
+
function C(s = {}) {
|
|
11
|
+
const l = s.enabled ?? !0, g = s.showHandle ?? !1, c = s.touchHoldMs ?? 180, d = (t, n, r) => {
|
|
12
|
+
const e = Number(r);
|
|
13
|
+
if (!Number.isFinite(e) || e === n) return;
|
|
14
|
+
t.sharedData.set("drag-from", e), t.sharedData.set("drag-to", n), t.bus.emit("drag:reorder", { from: e, to: n });
|
|
15
|
+
const f = t.props.items;
|
|
16
|
+
s.onReorder?.(e, n, f?.[e]);
|
|
17
|
+
}, b = () => {
|
|
18
|
+
document.querySelectorAll(`[${i}]`).forEach((t) => t.removeAttribute(i));
|
|
19
|
+
}, m = () => {
|
|
20
|
+
typeof document > "u" || (b(), document.body.style.userSelect = "", document.body.style.cursor = "");
|
|
21
|
+
}, w = (t, n, r) => {
|
|
22
|
+
if (t.pointerType === "mouse") return;
|
|
23
|
+
const e = t.clientX, f = t.clientY, R = Date.now();
|
|
24
|
+
let p = !1, h = null;
|
|
25
|
+
const v = (o) => {
|
|
26
|
+
if (!p) {
|
|
27
|
+
const D = Date.now() - R >= c, H = Math.hypot(o.clientX - e, o.clientY - f) >= 6;
|
|
28
|
+
if (!D || !H) return;
|
|
29
|
+
p = !0, document.body.style.userSelect = "none", document.body.style.cursor = "grabbing";
|
|
30
|
+
}
|
|
31
|
+
o.preventDefault();
|
|
32
|
+
const a = y(o.clientX, o.clientY);
|
|
33
|
+
a !== h && (b(), h = a, a != null && document.querySelector(`[data-index="${a}"]`)?.setAttribute(i, ""));
|
|
34
|
+
}, u = (o) => {
|
|
35
|
+
if (window.removeEventListener("pointermove", v), window.removeEventListener("pointerup", u), window.removeEventListener("pointercancel", u), m(), !p) return;
|
|
36
|
+
const a = y(o.clientX, o.clientY);
|
|
37
|
+
a != null && d(r, a, String(n));
|
|
38
|
+
};
|
|
39
|
+
window.addEventListener("pointermove", v, { passive: !1 }), window.addEventListener("pointerup", u), window.addEventListener("pointercancel", u);
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
name: "DragReorderPlugin",
|
|
43
|
+
enabled: l,
|
|
44
|
+
hooks: {
|
|
45
|
+
renderItemWrapper: (t, n, r) => l ? /* @__PURE__ */ E(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
draggable: !0,
|
|
49
|
+
onDragStart: (e) => {
|
|
50
|
+
e.dataTransfer?.setData("text/plain", String(r)), t.sharedData.set("drag-from", r);
|
|
51
|
+
},
|
|
52
|
+
onDragOver: (e) => {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
},
|
|
55
|
+
onDragEnter: () => {
|
|
56
|
+
document.querySelector(`[data-index="${r}"]`)?.setAttribute(i, "");
|
|
57
|
+
},
|
|
58
|
+
onDragLeave: () => {
|
|
59
|
+
document.querySelector(`[data-index="${r}"]`)?.removeAttribute(i);
|
|
60
|
+
},
|
|
61
|
+
onDrop: (e) => {
|
|
62
|
+
e.preventDefault(), m(), d(t, r, e.dataTransfer?.getData("text/plain") ?? "");
|
|
63
|
+
},
|
|
64
|
+
onDragEnd: m,
|
|
65
|
+
onPointerDown: (e) => w(e, r, t),
|
|
66
|
+
style: {
|
|
67
|
+
cursor: "grab",
|
|
68
|
+
...g ? { border: "1px dashed #bdbdbd", borderRadius: 6 } : null
|
|
69
|
+
},
|
|
70
|
+
children: n
|
|
71
|
+
}
|
|
72
|
+
) : n
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const L = "DragReorderPlugin", M = "给每个项加拖拽能力,松手时回调 `onReorder(from, to)`,同时向 bus 发 `drag:reorder`。鼠标走原生 HTML5 拖拽,触屏走「长按 + pointer」——触摸设备上 `draggable` 根本不触发,旧版因此在手机上完全失效。", A = "2.0.0", P = [
|
|
77
|
+
"interaction",
|
|
78
|
+
"拖拽"
|
|
79
|
+
], S = [
|
|
80
|
+
{
|
|
81
|
+
name: "enabled",
|
|
82
|
+
type: "boolean",
|
|
83
|
+
default: "true",
|
|
84
|
+
description: "是否启用拖拽"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "onReorder",
|
|
88
|
+
type: "(from, to, item) => void",
|
|
89
|
+
default: "—",
|
|
90
|
+
description: "重排回调"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "showHandle",
|
|
94
|
+
type: "boolean",
|
|
95
|
+
default: "false",
|
|
96
|
+
description: "是否显示虚线边框提示可拖"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "touchHoldMs",
|
|
100
|
+
type: "number",
|
|
101
|
+
default: "180",
|
|
102
|
+
description: "触屏长按多久进入拖拽(ms),0 表示不需要长按"
|
|
103
|
+
}
|
|
104
|
+
], T = `// 鼠标走 HTML5 draggable,触屏走长按 + pointer,松手时回调 onReorder(from, to)。
|
|
105
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
106
|
+
createDragReorderPlugin({
|
|
107
|
+
enabled: true,
|
|
108
|
+
showHandle: false,
|
|
109
|
+
touchHoldMs: 180,
|
|
110
|
+
}),
|
|
111
|
+
]);
|
|
112
|
+
|
|
113
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, X = [
|
|
114
|
+
"鼠标:原生 HTML5 拖拽,无额外依赖",
|
|
115
|
+
"触屏:长按 180ms 后 pointer 拖拽(可配 touchHoldMs)",
|
|
116
|
+
"onReorder 回调真正可用,bus 发 `drag:reorder`"
|
|
117
|
+
], Y = [
|
|
118
|
+
"后台卡片排序",
|
|
119
|
+
"收藏夹手动排序",
|
|
120
|
+
"仪表盘组件排列"
|
|
121
|
+
], q = [
|
|
122
|
+
"插件只负责「拖」和「告诉你从哪到哪」,数组重排由调用方在 onReorder 里做。",
|
|
123
|
+
"触屏用长按区分「想滚」和「想拖」:不这样做,手指一滑就变成拖拽,页面滚不动。"
|
|
124
|
+
], N = {
|
|
125
|
+
name: L,
|
|
126
|
+
description: M,
|
|
127
|
+
since: A,
|
|
128
|
+
tags: P,
|
|
129
|
+
config: S,
|
|
130
|
+
example: T,
|
|
131
|
+
features: X,
|
|
132
|
+
useCases: Y,
|
|
133
|
+
notes: q
|
|
134
|
+
};
|
|
135
|
+
export {
|
|
136
|
+
C as c,
|
|
137
|
+
N as d
|
|
138
|
+
};
|