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,59 @@
|
|
|
1
|
+
function A(t = {}) {
|
|
2
|
+
const s = t.getAnchorId || ((n) => n?.id);
|
|
3
|
+
let e;
|
|
4
|
+
return {
|
|
5
|
+
name: "ScrollAnchorPlugin",
|
|
6
|
+
enabled: !0,
|
|
7
|
+
hooks: {
|
|
8
|
+
onMount: (n) => {
|
|
9
|
+
e = n.bus?.on("anchor:scrollToId", (c) => {
|
|
10
|
+
const o = (n.props?.items || []).findIndex((i, r) => s(i, r) === c.id);
|
|
11
|
+
o >= 0 && n.scrollToItem?.(o, { behavior: "smooth", block: "start" });
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
onUnmount: () => e?.()
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const a = "ScrollAnchorPlugin", l = '不需要自己算索引:外部只管 `bus.emit("anchor:scrollToId", { id })`,插件用 getAnchorId 找到对应项并滚过去。适合「从消息跳到某条内容」。', d = "2.0.0", m = [
|
|
19
|
+
"interaction",
|
|
20
|
+
"滚动"
|
|
21
|
+
], u = [
|
|
22
|
+
{
|
|
23
|
+
name: "getAnchorId",
|
|
24
|
+
type: "(item, index) => string | number | undefined",
|
|
25
|
+
default: "item.id",
|
|
26
|
+
description: "从项里取锚点 id"
|
|
27
|
+
}
|
|
28
|
+
], g = `// 监听 \`anchor:scrollToId\` 事件,按业务 id 滚动到对应项。
|
|
29
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
30
|
+
createScrollAnchorPlugin({
|
|
31
|
+
getAnchorId: "item.id",
|
|
32
|
+
}),
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, h = [
|
|
36
|
+
"按业务 id 定位,不用算下标",
|
|
37
|
+
"onMount 订阅 / onUnmount 退订(不泄漏)",
|
|
38
|
+
"平滑滚动"
|
|
39
|
+
], f = [
|
|
40
|
+
"从通知跳转到具体卡片",
|
|
41
|
+
"目录点击定位",
|
|
42
|
+
"外链深链定位"
|
|
43
|
+
], I = [
|
|
44
|
+
"目标项必须已在 items 里;分页场景请先切到对应页再发事件。"
|
|
45
|
+
], b = {
|
|
46
|
+
name: a,
|
|
47
|
+
description: l,
|
|
48
|
+
since: d,
|
|
49
|
+
tags: m,
|
|
50
|
+
config: u,
|
|
51
|
+
example: g,
|
|
52
|
+
features: h,
|
|
53
|
+
useCases: f,
|
|
54
|
+
notes: I
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
A as c,
|
|
58
|
+
b as d
|
|
59
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function g(r = {}) {
|
|
2
|
+
return {
|
|
3
|
+
name: "SortPlugin",
|
|
4
|
+
priority: 30,
|
|
5
|
+
enabled: !0,
|
|
6
|
+
hooks: {
|
|
7
|
+
transformProps: (o) => {
|
|
8
|
+
const e = Array.isArray(o.items) ? o.items : [], t = o.sortComparator || r.comparator;
|
|
9
|
+
if (typeof t != "function") return o;
|
|
10
|
+
const s = [...e].sort((a, n) => {
|
|
11
|
+
try {
|
|
12
|
+
return t(a, n);
|
|
13
|
+
} catch {
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return { ...o, items: s };
|
|
18
|
+
},
|
|
19
|
+
onPropsChange: (o, e, t) => {
|
|
20
|
+
const s = e?.sortComparator, a = t?.sortComparator;
|
|
21
|
+
if (((typeof t?.scrollToTopOnSortChange == "boolean" ? t.scrollToTopOnSortChange : void 0) ?? !!r.scrollToTop) && s !== a) {
|
|
22
|
+
const l = t?.scrollToTopBehavior ?? r.scrollBehavior ?? "auto";
|
|
23
|
+
o.scrollToTop?.({ behavior: l });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const c = "SortPlugin", i = "用比较函数排序,优先读 `props.sortComparator`。排序总是在过滤之后、分页之前执行,保证「第 N 页」是排序后的第 N 页。", m = "2.0.0", p = [
|
|
30
|
+
"data",
|
|
31
|
+
"数据管线"
|
|
32
|
+
], u = [
|
|
33
|
+
{
|
|
34
|
+
name: "comparator",
|
|
35
|
+
type: "(a, b) => number",
|
|
36
|
+
default: "—",
|
|
37
|
+
description: "默认比较函数,可被 props.sortComparator 覆盖"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "scrollToTop",
|
|
41
|
+
type: "boolean",
|
|
42
|
+
default: "false",
|
|
43
|
+
description: "排序变化后回顶"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "scrollBehavior",
|
|
47
|
+
type: '"auto" | "smooth"',
|
|
48
|
+
default: '"auto"',
|
|
49
|
+
description: "回顶行为"
|
|
50
|
+
}
|
|
51
|
+
], d = `// 按比较函数排序 items,比较函数变化可自动回顶。
|
|
52
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
53
|
+
createSortPlugin({
|
|
54
|
+
scrollToTop: false,
|
|
55
|
+
scrollBehavior: "auto",
|
|
56
|
+
}),
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, f = [
|
|
60
|
+
"稳定排序(不改原数组)",
|
|
61
|
+
"比较函数抛错按相等处理",
|
|
62
|
+
"与 Filter / Search 顺序固定"
|
|
63
|
+
], h = [
|
|
64
|
+
"价格 / 时间排序",
|
|
65
|
+
"热度排序",
|
|
66
|
+
"手动置顶项优先"
|
|
67
|
+
], C = [
|
|
68
|
+
"排序会复制数组(`[...items].sort`),不会改调用方传入的 items。"
|
|
69
|
+
], y = {
|
|
70
|
+
name: c,
|
|
71
|
+
description: i,
|
|
72
|
+
since: m,
|
|
73
|
+
tags: p,
|
|
74
|
+
config: u,
|
|
75
|
+
example: d,
|
|
76
|
+
features: f,
|
|
77
|
+
useCases: h,
|
|
78
|
+
notes: C
|
|
79
|
+
};
|
|
80
|
+
export {
|
|
81
|
+
g as c,
|
|
82
|
+
y as d
|
|
83
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsxs as a, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
function h(t = {}) {
|
|
3
|
+
const s = t.title || "分组标题", i = t.showHint ?? !1;
|
|
4
|
+
return {
|
|
5
|
+
name: "StickyHeaderPlugin",
|
|
6
|
+
enabled: !0,
|
|
7
|
+
hooks: {
|
|
8
|
+
renderOverlay: (o) => {
|
|
9
|
+
const e = o.sharedData?.get("GROUPS") || /* @__PURE__ */ new Map(), n = e.size > 0 ? Array.from(e.keys())[0] : void 0;
|
|
10
|
+
return /* @__PURE__ */ a(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
style: {
|
|
14
|
+
position: "sticky",
|
|
15
|
+
top: 0,
|
|
16
|
+
zIndex: 20,
|
|
17
|
+
background: "#111827",
|
|
18
|
+
color: "#fff",
|
|
19
|
+
borderBottom: "1px solid rgba(255,255,255,0.15)",
|
|
20
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
|
|
21
|
+
padding: "10px 14px",
|
|
22
|
+
fontSize: 15,
|
|
23
|
+
fontWeight: 600
|
|
24
|
+
},
|
|
25
|
+
children: [
|
|
26
|
+
s,
|
|
27
|
+
" ",
|
|
28
|
+
n !== void 0 ? `:${String(n)}` : "",
|
|
29
|
+
i ? /* @__PURE__ */ r("span", { style: { marginLeft: 8, fontSize: 12, opacity: 0.8 }, children: "向下滚动观察吸顶" }) : null
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const c = "StickyHeaderPlugin", l = "在滚动容器内渲染一条 `position: sticky` 的标题条,始终贴住容器顶部。装了 GroupingPlugin 时自动显示第一个分组名,也可用 title 写死。", d = "2.0.0", p = [
|
|
38
|
+
"ui",
|
|
39
|
+
"吸顶"
|
|
40
|
+
], f = [
|
|
41
|
+
{
|
|
42
|
+
name: "title",
|
|
43
|
+
type: "string",
|
|
44
|
+
default: '"分组标题"',
|
|
45
|
+
description: "标题文案"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "showHint",
|
|
49
|
+
type: "boolean",
|
|
50
|
+
default: "false",
|
|
51
|
+
description: "是否显示「向下滚动观察」提示"
|
|
52
|
+
}
|
|
53
|
+
], u = `// 滚动容器内的吸顶标题条,可与分组联动显示当前组。
|
|
54
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
55
|
+
createStickyHeaderPlugin({
|
|
56
|
+
title: "分组标题",
|
|
57
|
+
showHint: false,
|
|
58
|
+
}),
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, g = [
|
|
62
|
+
"sticky 吸顶,不依赖额外容器",
|
|
63
|
+
"与 Grouping 联动显示当前组",
|
|
64
|
+
"提示文案默认关闭"
|
|
65
|
+
], m = [
|
|
66
|
+
"分组信息流",
|
|
67
|
+
"按日期分组的时间线",
|
|
68
|
+
"长列表的上下文提示"
|
|
69
|
+
], y = [
|
|
70
|
+
"sticky 生效要求它作为滚动容器的直接子元素——由 composeSlots 保证,单测已锁。"
|
|
71
|
+
], k = {
|
|
72
|
+
name: c,
|
|
73
|
+
description: l,
|
|
74
|
+
since: d,
|
|
75
|
+
tags: p,
|
|
76
|
+
config: f,
|
|
77
|
+
example: u,
|
|
78
|
+
features: g,
|
|
79
|
+
useCases: m,
|
|
80
|
+
notes: y
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
h as c,
|
|
84
|
+
k as d
|
|
85
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function y(s = {}) {
|
|
2
|
+
const n = s.duration ?? 300, t = s.easing ?? "ease";
|
|
3
|
+
return {
|
|
4
|
+
name: "TransitionPlugin",
|
|
5
|
+
priority: 65,
|
|
6
|
+
enabled: !0,
|
|
7
|
+
hooks: {
|
|
8
|
+
onItemMount: (o, e, i) => {
|
|
9
|
+
i.style.transition = `transform ${n}ms ${t}, opacity ${n}ms ${t}`;
|
|
10
|
+
},
|
|
11
|
+
onLayout: (o) => {
|
|
12
|
+
o.itemRefs.forEach((e) => {
|
|
13
|
+
e && (e.style.transition = `transform ${n}ms ${t}, opacity ${n}ms ${t}`);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const a = "TransitionPlugin", r = "给每个项挂上 transform + opacity 的 CSS 过渡,布局重排、分页切换、筛选后重新排列时位置变化是滑过去的,不是瞬移。", c = "2.0.0", u = [
|
|
20
|
+
"perf",
|
|
21
|
+
"动效"
|
|
22
|
+
], m = [
|
|
23
|
+
{
|
|
24
|
+
name: "duration",
|
|
25
|
+
type: "number",
|
|
26
|
+
default: "300",
|
|
27
|
+
description: "过渡时长 ms"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "easing",
|
|
31
|
+
type: "string",
|
|
32
|
+
default: "ease",
|
|
33
|
+
description: "缓动函数"
|
|
34
|
+
}
|
|
35
|
+
], d = `// 布局变化时给项加 transform/opacity 过渡,插入新数据不「闪现」。
|
|
36
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
37
|
+
createTransitionPlugin({
|
|
38
|
+
duration: 300,
|
|
39
|
+
easing: "ease",
|
|
40
|
+
}),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, l = [
|
|
44
|
+
"ReducedMotionPlugin"
|
|
45
|
+
], f = [
|
|
46
|
+
"项位置变化平滑过渡",
|
|
47
|
+
"挂载时即生效(onItemMount)",
|
|
48
|
+
"与 ReducedMotionPlugin 互斥"
|
|
49
|
+
], g = [
|
|
50
|
+
"筛选 / 排序后重排",
|
|
51
|
+
"分页切换",
|
|
52
|
+
"动态插入卡片"
|
|
53
|
+
], p = [
|
|
54
|
+
"首屏大量项同时过渡会有一次「整体滑入」,想要更克制可以把 duration 降到 150ms。"
|
|
55
|
+
], $ = {
|
|
56
|
+
name: a,
|
|
57
|
+
description: r,
|
|
58
|
+
since: c,
|
|
59
|
+
tags: u,
|
|
60
|
+
config: m,
|
|
61
|
+
example: d,
|
|
62
|
+
conflicts: l,
|
|
63
|
+
features: f,
|
|
64
|
+
useCases: g,
|
|
65
|
+
notes: p
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
y as c,
|
|
69
|
+
$ as d
|
|
70
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
function C(t = {}) {
|
|
2
|
+
const c = t.fields ?? [];
|
|
3
|
+
return {
|
|
4
|
+
name: "SearchPlugin",
|
|
5
|
+
priority: 20,
|
|
6
|
+
enabled: !0,
|
|
7
|
+
hooks: {
|
|
8
|
+
transformProps: (e) => {
|
|
9
|
+
const s = String(e.searchQuery ?? "").trim(), o = Array.isArray(e.items) ? e.items : [];
|
|
10
|
+
if (!s) return e;
|
|
11
|
+
const n = s.toLowerCase(), a = o.filter((r) => {
|
|
12
|
+
if (typeof r != "object" || r === null) return !1;
|
|
13
|
+
const i = c.length > 0 ? c : Object.keys(r);
|
|
14
|
+
for (const l of i) {
|
|
15
|
+
const u = r[l];
|
|
16
|
+
if (u != null && String(u).toLowerCase().includes(n)) return !0;
|
|
17
|
+
}
|
|
18
|
+
return !1;
|
|
19
|
+
});
|
|
20
|
+
return { ...e, items: a };
|
|
21
|
+
},
|
|
22
|
+
onPropsChange: (e, s, o) => {
|
|
23
|
+
const n = String(s?.searchQuery ?? ""), a = String(o?.searchQuery ?? "");
|
|
24
|
+
if (((typeof o?.scrollToTopOnSearchChange == "boolean" ? o.scrollToTopOnSearchChange : void 0) ?? !!t.scrollToTop) && n !== a) {
|
|
25
|
+
const l = o?.scrollToTopBehavior ?? t.scrollBehavior ?? "auto";
|
|
26
|
+
e.scrollToTop?.({ behavior: l });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const f = "SearchPlugin", d = "读取 `props.searchQuery`,在指定字段上做大小写不敏感的 `includes` 匹配。没指定字段就对对象的全部自有字段匹配。", h = "2.0.0", m = [
|
|
33
|
+
"data",
|
|
34
|
+
"数据管线",
|
|
35
|
+
"搜索"
|
|
36
|
+
], p = [
|
|
37
|
+
{
|
|
38
|
+
name: "fields",
|
|
39
|
+
type: "(keyof T)[]",
|
|
40
|
+
default: "[]",
|
|
41
|
+
description: "参与匹配的字段;空则匹配全部自有字段"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "scrollToTop",
|
|
45
|
+
type: "boolean",
|
|
46
|
+
default: "false",
|
|
47
|
+
description: "关键词变化后回顶"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "scrollBehavior",
|
|
51
|
+
type: '"auto" | "smooth"',
|
|
52
|
+
default: '"auto"',
|
|
53
|
+
description: "回顶行为"
|
|
54
|
+
}
|
|
55
|
+
], y = `// 按 props.searchQuery 做大小写不敏感的多字段包含匹配。
|
|
56
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
57
|
+
createSearchPlugin({
|
|
58
|
+
fields: [],
|
|
59
|
+
scrollToTop: false,
|
|
60
|
+
scrollBehavior: "auto",
|
|
61
|
+
}),
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, g = [
|
|
65
|
+
"大小写不敏感",
|
|
66
|
+
"多字段 OR 匹配",
|
|
67
|
+
"空关键词直接放行(不触发过滤)"
|
|
68
|
+
], T = [
|
|
69
|
+
"站内搜索结果页",
|
|
70
|
+
"后台列表即时搜索",
|
|
71
|
+
"商品名 / 店铺名联合搜索"
|
|
72
|
+
], S = [
|
|
73
|
+
"纯前端 `includes`,不排序也不做拼音;要相关性排序请在 Search 之后接 SortPlugin。"
|
|
74
|
+
], b = {
|
|
75
|
+
name: f,
|
|
76
|
+
description: d,
|
|
77
|
+
since: h,
|
|
78
|
+
tags: m,
|
|
79
|
+
config: p,
|
|
80
|
+
example: y,
|
|
81
|
+
features: g,
|
|
82
|
+
useCases: T,
|
|
83
|
+
notes: S
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
C as c,
|
|
87
|
+
b as d
|
|
88
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
function b(n) {
|
|
2
|
+
if (!(n.minColumnWidth > 0))
|
|
3
|
+
throw new Error("[vane-waterfall] AutoColumnPlugin 需要正数的 minColumnWidth");
|
|
4
|
+
return {
|
|
5
|
+
name: "AutoColumnPlugin",
|
|
6
|
+
priority: 55,
|
|
7
|
+
enabled: !0,
|
|
8
|
+
hooks: {
|
|
9
|
+
calculateColumns: (s, i) => {
|
|
10
|
+
const t = s.props, e = t.columnGap ?? t.gap ?? 0, o = t.padding, l = typeof o == "number" ? o * 2 : (o?.left ?? 0) + (o?.right ?? 0), a = Math.max(0, i - l);
|
|
11
|
+
if (!a) return t.columns ?? 1;
|
|
12
|
+
const m = Math.max(
|
|
13
|
+
1,
|
|
14
|
+
Math.floor((a + e) / (n.minColumnWidth + e))
|
|
15
|
+
), u = Math.max(1, n.minColumns ?? 1), c = n.maxColumns ?? Number.POSITIVE_INFINITY;
|
|
16
|
+
return Math.min(Math.max(m, u), c);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const r = "AutoColumnPlugin", d = "按「容器可用宽度 ÷ 最小列宽」自动决定列数,取代写死 3 列。走 D1-A 布局钩子(calculateColumns),拿到的是真实容器宽度,不是 window.innerWidth。", p = "2.0.0", C = [
|
|
22
|
+
"layout",
|
|
23
|
+
"layout-hook",
|
|
24
|
+
"响应式"
|
|
25
|
+
], f = [
|
|
26
|
+
{
|
|
27
|
+
name: "minColumnWidth",
|
|
28
|
+
type: "number",
|
|
29
|
+
default: "—",
|
|
30
|
+
description: "每列最小宽度 px(必填)"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "maxColumns",
|
|
34
|
+
type: "number",
|
|
35
|
+
default: "Infinity",
|
|
36
|
+
description: "列数上限"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "minColumns",
|
|
40
|
+
type: "number",
|
|
41
|
+
default: "1",
|
|
42
|
+
description: "列数下限"
|
|
43
|
+
}
|
|
44
|
+
], h = `// 按容器宽与最小列宽自动算列数,窄屏自动降列。
|
|
45
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
46
|
+
createAutoColumnPlugin({
|
|
47
|
+
maxColumns: "Infinity",
|
|
48
|
+
minColumns: 1,
|
|
49
|
+
}),
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, g = [
|
|
53
|
+
"ResponsiveColumnsPlugin"
|
|
54
|
+
], x = [
|
|
55
|
+
"按容器宽度(不是视口宽度)算列数",
|
|
56
|
+
"列数上下限可夹",
|
|
57
|
+
"与 Gap / Padding 一起算,留白不吞列宽"
|
|
58
|
+
], P = [
|
|
59
|
+
"响应式信息流",
|
|
60
|
+
"侧边栏宽度可拖动的后台看板",
|
|
61
|
+
"移动端 → 桌面端同一套代码"
|
|
62
|
+
], y = [
|
|
63
|
+
"与 ResponsiveColumnsPlugin 同时装会互相覆盖列数,只选一个。"
|
|
64
|
+
], I = {
|
|
65
|
+
name: r,
|
|
66
|
+
description: d,
|
|
67
|
+
since: p,
|
|
68
|
+
tags: C,
|
|
69
|
+
config: f,
|
|
70
|
+
example: h,
|
|
71
|
+
conflicts: g,
|
|
72
|
+
features: x,
|
|
73
|
+
useCases: P,
|
|
74
|
+
notes: y
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
b as c,
|
|
78
|
+
I as d
|
|
79
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function d(n) {
|
|
2
|
+
return {
|
|
3
|
+
name: "FixedHeightPlugin",
|
|
4
|
+
priority: 45,
|
|
5
|
+
enabled: !0,
|
|
6
|
+
hooks: {
|
|
7
|
+
transformProps: (t) => {
|
|
8
|
+
const { itemHeight: i } = n, s = (t.items || []).map((e) => typeof e == "object" && e !== null && "height" in e ? { ...e, height: i } : e);
|
|
9
|
+
return { ...t, items: s };
|
|
10
|
+
},
|
|
11
|
+
onResize: (t) => {
|
|
12
|
+
t.relayout?.();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const o = "FixedHeightPlugin", a = "把数据里带 height 字段的项统一改写为固定高度,瀑布流变成等高网格。适合「图少字多」的卡片流——等高反而更好扫读。", r = "2.0.0", c = [
|
|
18
|
+
"layout",
|
|
19
|
+
"网格"
|
|
20
|
+
], g = [
|
|
21
|
+
{
|
|
22
|
+
name: "itemHeight",
|
|
23
|
+
type: "number",
|
|
24
|
+
default: "—",
|
|
25
|
+
description: "统一项高 px(必填)"
|
|
26
|
+
}
|
|
27
|
+
], l = `// 把项高度统一成固定值,瀑布流退化为等高网格。
|
|
28
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
29
|
+
createFixedHeightPlugin(),
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, u = [
|
|
33
|
+
"等高网格(严格对齐)",
|
|
34
|
+
"只改数据里已有的 height 字段",
|
|
35
|
+
"与 Pagination / Filter 组合仍然成立"
|
|
36
|
+
], h = [
|
|
37
|
+
"商品列表(图固定比例)",
|
|
38
|
+
"后台看板卡片",
|
|
39
|
+
"需要严格栅格对齐的页面"
|
|
40
|
+
], m = [
|
|
41
|
+
"数据里没有 height 字段时不会生效——高度由 renderItem 自己的内容决定。"
|
|
42
|
+
], f = {
|
|
43
|
+
name: o,
|
|
44
|
+
description: a,
|
|
45
|
+
since: r,
|
|
46
|
+
tags: c,
|
|
47
|
+
config: g,
|
|
48
|
+
example: l,
|
|
49
|
+
features: u,
|
|
50
|
+
useCases: h,
|
|
51
|
+
notes: m
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
d as c,
|
|
55
|
+
f as d
|
|
56
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function y(s) {
|
|
2
|
+
const e = /* @__PURE__ */ new Set(), o = () => {
|
|
3
|
+
if (e.size <= s.poolSize) return;
|
|
4
|
+
const t = e.values().next().value;
|
|
5
|
+
typeof t == "number" && e.delete(t);
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
name: "RecyclePlugin",
|
|
9
|
+
enabled: !0,
|
|
10
|
+
hooks: {
|
|
11
|
+
onItemEnterViewport: (t, n) => {
|
|
12
|
+
const i = t.getItemRef(n);
|
|
13
|
+
i && (i.style.visibility = "visible"), e.add(n), o();
|
|
14
|
+
},
|
|
15
|
+
onItemLeaveViewport: (t, n) => {
|
|
16
|
+
const i = t.getItemRef(n);
|
|
17
|
+
i && (i.style.visibility = "hidden"), e.delete(n);
|
|
18
|
+
},
|
|
19
|
+
onItemUnmount: (t, n) => {
|
|
20
|
+
e.delete(n);
|
|
21
|
+
},
|
|
22
|
+
onUnmount: () => {
|
|
23
|
+
e.clear();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const c = "RecyclePlugin", l = "纯绘制层优化:项离开视口就 `visibility: hidden`,回来再显示。DOM 节点不销毁,滚动位置与已加载的图片都保留,适合「项里有视频/Canvas,重建代价高」的场景。", a = "2.0.0", r = [
|
|
29
|
+
"interaction",
|
|
30
|
+
"性能"
|
|
31
|
+
], u = [
|
|
32
|
+
{
|
|
33
|
+
name: "poolSize",
|
|
34
|
+
type: "number",
|
|
35
|
+
default: "—",
|
|
36
|
+
description: "同时保持可见的项数上限(超出则回收最早的)"
|
|
37
|
+
}
|
|
38
|
+
], m = `// 视口外的项设 \`visibility: hidden\`,降低长列表的绘制压力。
|
|
39
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
40
|
+
createRecyclePlugin(),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, d = [
|
|
44
|
+
"不销毁 DOM,只隐藏",
|
|
45
|
+
"项内媒体不重新加载",
|
|
46
|
+
"与虚拟化正交(一个省绘制、一个省节点)"
|
|
47
|
+
], f = [
|
|
48
|
+
"项内含视频 / canvas",
|
|
49
|
+
"长列表滚动发虚",
|
|
50
|
+
"低端设备省电"
|
|
51
|
+
], v = [
|
|
52
|
+
"与 Core 的 `virtualize` 同开会让项被卸载又隐藏,收益互相抵消,建议只选一个。",
|
|
53
|
+
"只改 visibility 不改布局,所以不会引起重排。"
|
|
54
|
+
], p = {
|
|
55
|
+
name: c,
|
|
56
|
+
description: l,
|
|
57
|
+
since: a,
|
|
58
|
+
tags: r,
|
|
59
|
+
config: u,
|
|
60
|
+
example: m,
|
|
61
|
+
features: d,
|
|
62
|
+
useCases: f,
|
|
63
|
+
notes: v
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
y as c,
|
|
67
|
+
p as d
|
|
68
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function b(e) {
|
|
2
|
+
const c = Object.values(e.breakpoints).sort((s, n) => s.width - n.width);
|
|
3
|
+
return {
|
|
4
|
+
name: "ResponsiveColumnsPlugin",
|
|
5
|
+
priority: 55,
|
|
6
|
+
enabled: !0,
|
|
7
|
+
hooks: {
|
|
8
|
+
calculateColumns: (s, n) => {
|
|
9
|
+
const t = e.fallbackColumns ?? s.props.columns ?? 3;
|
|
10
|
+
if (!n) return t;
|
|
11
|
+
let o = t;
|
|
12
|
+
for (const l of c)
|
|
13
|
+
n >= l.width && (o = l.columns);
|
|
14
|
+
return o;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const u = "ResponsiveColumnsPlugin", a = "用一张断点表控制列数,命中哪档用哪档。走 D1-A 布局钩子(calculateColumns),按容器宽度匹配断点。", i = "2.0.0", r = [
|
|
20
|
+
"layout",
|
|
21
|
+
"layout-hook",
|
|
22
|
+
"响应式"
|
|
23
|
+
], m = [
|
|
24
|
+
{
|
|
25
|
+
name: "breakpoints",
|
|
26
|
+
type: "Record<string, { width: number; columns: number }>",
|
|
27
|
+
default: "—",
|
|
28
|
+
description: "断点表,按 width 升序匹配"
|
|
29
|
+
}
|
|
30
|
+
], p = `// 按断点表决定列数(如 640 → 2 列、1024 → 3 列、1440 → 4 列)。
|
|
31
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
32
|
+
createResponsiveColumnsPlugin(),
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, f = [
|
|
36
|
+
"AutoColumnPlugin"
|
|
37
|
+
], d = [
|
|
38
|
+
"断点表驱动,设计稿几档就写几档",
|
|
39
|
+
"按容器宽度而非视口宽度匹配",
|
|
40
|
+
"未命中任何断点时回退到 props.columns"
|
|
41
|
+
], C = [
|
|
42
|
+
"严格对齐设计断点的站点",
|
|
43
|
+
"同一个组件嵌在不同宽度的容器里"
|
|
44
|
+
], g = [
|
|
45
|
+
"与 AutoColumnPlugin 互斥。"
|
|
46
|
+
], h = {
|
|
47
|
+
name: u,
|
|
48
|
+
description: a,
|
|
49
|
+
since: i,
|
|
50
|
+
tags: r,
|
|
51
|
+
config: m,
|
|
52
|
+
example: p,
|
|
53
|
+
conflicts: f,
|
|
54
|
+
features: d,
|
|
55
|
+
useCases: C,
|
|
56
|
+
notes: g
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
b as c,
|
|
60
|
+
h as d
|
|
61
|
+
};
|