vane-waterfall 2.0.1 → 2.0.3
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 +4 -4
- package/dist/chunks/WaterfallCore-EdAZuWAY.js +695 -0
- package/dist/chunks/doc-BAhVW3g8.js +150 -0
- package/dist/chunks/doc-BU0CKW63.js +156 -0
- package/dist/chunks/doc-BrEd0oZB.js +100 -0
- package/dist/chunks/{doc-bTHwfIVb.js → doc-Bud0hbaz.js} +39 -25
- package/dist/chunks/{doc-DukOmDCo.js → doc-C-B3zK2o.js} +52 -23
- package/dist/chunks/{doc-DElLNjIc.js → doc-C206ZwYC.js} +33 -24
- package/dist/chunks/doc-C2L8kkeI.js +112 -0
- package/dist/chunks/doc-CE1DGMBV.js +166 -0
- package/dist/chunks/{doc-BXSy2aPP.js → doc-CHbQXLwY.js} +33 -19
- package/dist/chunks/{doc-BfWnfTst.js → doc-CInpKZNU.js} +38 -24
- package/dist/chunks/{doc-gTAsLjVx.js → doc-CYxwSuG6.js} +30 -16
- package/dist/chunks/{doc-DzvTrZ13.js → doc-CaJ02INP.js} +25 -16
- package/dist/chunks/{doc-BXElhF2h.js → doc-CiCso5Ti.js} +44 -30
- package/dist/chunks/doc-CkuMr8Ca.js +118 -0
- package/dist/chunks/{doc-3Fpag2G8.js → doc-D7m1OFCW.js} +38 -24
- package/dist/chunks/doc-DEN2WTDh.js +153 -0
- package/dist/chunks/{doc-C5xrHNoC.js → doc-DhICh9S2.js} +37 -23
- package/dist/chunks/doc-DlJICsyN.js +100 -0
- package/dist/chunks/{doc-BtzhgTYj.js → doc-DtxS1-P0.js} +35 -26
- package/dist/chunks/{doc-BIzjYAZW.js → doc-DudYCn_-.js} +25 -16
- package/dist/chunks/doc-HoyAFR_m.js +101 -0
- package/dist/chunks/doc-RlBMCMNs.js +170 -0
- package/dist/chunks/doc-RwKQqySd.js +102 -0
- package/dist/chunks/{doc-CTUoMe7o.js → doc-eYhNJy97.js} +31 -22
- package/dist/chunks/{doc-CcPFavOs.js → doc-i6FY1We1.js} +27 -13
- package/dist/chunks/doc-skPl6ZMP.js +101 -0
- package/dist/chunks/index-8gEIzUxi.js +15 -0
- package/dist/chunks/index-B96I5CKE.js +21 -0
- package/dist/chunks/index-Bjmhy8jW.js +11 -0
- package/dist/chunks/index-Cuq0ofv-.js +13 -0
- package/dist/chunks/{index-BAWlVYr3.js → index-Cz4YEqRF.js} +1 -1
- package/dist/chunks/{index-wLI6UXkY.js → index-FBJVUYmH.js} +1 -1
- package/dist/chunks/withPlugins-BOeDFhof.js +743 -0
- package/dist/components/WaterfallPlugin/WaterfallCore.d.ts +19 -0
- package/dist/components/WaterfallPlugin/WaterfallCore.d.ts.map +1 -1
- package/dist/components/WaterfallPlugin/layout.d.ts +7 -0
- package/dist/components/WaterfallPlugin/layout.d.ts.map +1 -1
- package/dist/components/WaterfallPlugin/plugins/types.d.ts +3 -0
- package/dist/components/WaterfallPlugin/plugins/types.d.ts.map +1 -1
- package/dist/components/WaterfallPlugin/withPlugins.d.ts.map +1 -1
- package/dist/custom-plugins/A11yPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/A11yPlugin/doc.json.d.ts +64 -40
- package/dist/custom-plugins/A11yPlugin/index.js +1 -1
- package/dist/custom-plugins/AlignmentPlugin/doc.json.d.ts +42 -28
- package/dist/custom-plugins/AlignmentPlugin/index.js +1 -1
- package/dist/custom-plugins/AutoColumnPlugin/doc.json.d.ts +53 -44
- package/dist/custom-plugins/AutoColumnPlugin/index.js +1 -1
- package/dist/custom-plugins/BookmarkPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/BookmarkPlugin/doc.json.d.ts +44 -35
- package/dist/custom-plugins/BookmarkPlugin/index.js +1 -1
- package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts +2 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/ClickAnalyticsPlugin/doc.json.d.ts +29 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/index.js +1 -1
- package/dist/custom-plugins/DebounceLayoutPlugin/doc.json.d.ts +37 -28
- package/dist/custom-plugins/DebounceLayoutPlugin/index.js +1 -1
- package/dist/custom-plugins/DragReorderPlugin/doc.json.d.ts +14 -0
- package/dist/custom-plugins/DragReorderPlugin/index.js +1 -1
- package/dist/custom-plugins/FilterPlugin/doc.json.d.ts +53 -39
- package/dist/custom-plugins/FilterPlugin/index.js +1 -1
- package/dist/custom-plugins/FixedHeightPlugin/doc.json.d.ts +42 -28
- package/dist/custom-plugins/FixedHeightPlugin/index.js +1 -1
- package/dist/custom-plugins/GapPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/GapPlugin/doc.json.d.ts +61 -37
- package/dist/custom-plugins/GapPlugin/index.js +1 -1
- package/dist/custom-plugins/GroupingPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/GroupingPlugin/doc.json.d.ts +61 -32
- package/dist/custom-plugins/GroupingPlugin/index.js +1 -1
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts +2 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/doc.json.d.ts +24 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.js +1 -1
- package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/InfiniteScrollPlugin/doc.json.d.ts +55 -36
- package/dist/custom-plugins/InfiniteScrollPlugin/index.js +1 -1
- package/dist/custom-plugins/PaginationPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/PaginationPlugin/doc.json.d.ts +56 -42
- package/dist/custom-plugins/PaginationPlugin/index.js +1 -1
- package/dist/custom-plugins/PinItemPlugin/doc.json.d.ts +49 -35
- package/dist/custom-plugins/PinItemPlugin/index.js +1 -1
- package/dist/custom-plugins/RecyclePlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/RecyclePlugin/doc.json.d.ts +57 -28
- package/dist/custom-plugins/RecyclePlugin/index.js +1 -1
- package/dist/custom-plugins/ReducedMotionPlugin/doc.json.d.ts +29 -0
- package/dist/custom-plugins/ReducedMotionPlugin/index.js +1 -1
- package/dist/custom-plugins/ResponsiveColumnsPlugin/doc.json.d.ts +40 -31
- package/dist/custom-plugins/ResponsiveColumnsPlugin/index.js +1 -1
- package/dist/custom-plugins/ScrollAnchorPlugin/doc.json.d.ts +42 -28
- package/dist/custom-plugins/ScrollAnchorPlugin/index.js +1 -1
- package/dist/custom-plugins/SearchPlugin/doc.json.d.ts +53 -39
- package/dist/custom-plugins/SearchPlugin/index.js +1 -1
- package/dist/custom-plugins/SortPlugin/doc.json.d.ts +52 -38
- package/dist/custom-plugins/SortPlugin/index.js +1 -1
- package/dist/custom-plugins/StatePersistencePlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/StatePersistencePlugin/doc.json.d.ts +71 -37
- package/dist/custom-plugins/StatePersistencePlugin/index.js +1 -1
- package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/StickyHeaderPlugin/doc.json.d.ts +43 -34
- package/dist/custom-plugins/StickyHeaderPlugin/index.js +1 -1
- package/dist/custom-plugins/ThrottlePlugin/doc.json.d.ts +43 -34
- package/dist/custom-plugins/ThrottlePlugin/index.js +1 -1
- package/dist/custom-plugins/TransitionPlugin/doc.json.d.ts +49 -35
- package/dist/custom-plugins/TransitionPlugin/index.js +1 -1
- package/dist/custom-plugins/URLSyncPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/URLSyncPlugin/doc.json.d.ts +57 -33
- package/dist/custom-plugins/URLSyncPlugin/index.js +1 -1
- package/dist/custom-plugins/index.js +6 -6
- package/dist/entries/core.js +1 -1
- package/dist/entries/plugins.js +7 -7
- package/dist/index.js +2 -2
- package/dist/presets/dashboard/index.js +2 -2
- package/dist/presets/photo-feed/index.js +3 -3
- package/dist/presets/product-feed/index.js +2 -2
- package/package.json +16 -8
- package/dist/chunks/WaterfallCore-BSXw7bl_.js +0 -581
- package/dist/chunks/doc-78xF08vt.js +0 -82
- package/dist/chunks/doc-B-7dugGv.js +0 -79
- package/dist/chunks/doc-B6kLfMPv.js +0 -121
- package/dist/chunks/doc-BCGQ8Cp5.js +0 -114
- package/dist/chunks/doc-BP0DmB7-.js +0 -91
- package/dist/chunks/doc-CBHjiDG7.js +0 -88
- package/dist/chunks/doc-CraXjOaA.js +0 -68
- package/dist/chunks/doc-DJjxOYzW.js +0 -111
- package/dist/chunks/doc-NhL4Ux8q.js +0 -125
- package/dist/chunks/doc-f4Uijujv.js +0 -102
- package/dist/chunks/doc-j4W9SUrY.js +0 -76
- package/dist/chunks/doc-kTbJE7rY.js +0 -92
- package/dist/chunks/index-COaun3nf.js +0 -15
- package/dist/chunks/index-DXAtA2f6.js +0 -11
- package/dist/chunks/index-DsRLmBW-.js +0 -13
- package/dist/chunks/index-gjoCq0yC.js +0 -21
- package/dist/chunks/withPlugins-DLoKg4AP.js +0 -559
|
@@ -1,61 +1,70 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
1
|
+
function w(n) {
|
|
2
|
+
const l = Object.values(n.breakpoints).sort((e, s) => e.width - s.width);
|
|
3
3
|
return {
|
|
4
4
|
name: "ResponsiveColumnsPlugin",
|
|
5
5
|
priority: 55,
|
|
6
6
|
enabled: !0,
|
|
7
7
|
hooks: {
|
|
8
|
-
calculateColumns: (
|
|
9
|
-
const t =
|
|
10
|
-
if (!
|
|
8
|
+
calculateColumns: (e, s) => {
|
|
9
|
+
const t = n.fallbackColumns ?? e.props.columns ?? 3;
|
|
10
|
+
if (!s) return t;
|
|
11
11
|
let o = t;
|
|
12
|
-
for (const
|
|
13
|
-
|
|
12
|
+
for (const c of l)
|
|
13
|
+
s >= c.width && (o = c.columns);
|
|
14
14
|
return o;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const a = "ResponsiveColumnsPlugin", u = "用一张断点表控制列数,命中哪档用哪档。走 D1-A 布局钩子(calculateColumns),按容器宽度匹配断点。", i = "2.0.0", r = [
|
|
20
20
|
"layout",
|
|
21
21
|
"layout-hook",
|
|
22
22
|
"响应式"
|
|
23
23
|
], m = [
|
|
24
|
+
{
|
|
25
|
+
name: "calculateColumns",
|
|
26
|
+
when: "每次布局前,询问列数",
|
|
27
|
+
description: "返回列数则覆盖 props.columns;返回 undefined 沿用配置"
|
|
28
|
+
}
|
|
29
|
+
], p = [], d = "只读取 context 字段(props / state / data),不调用上下文方法", f = [
|
|
24
30
|
{
|
|
25
31
|
name: "breakpoints",
|
|
26
32
|
type: "Record<string, { width: number; columns: number }>",
|
|
27
33
|
default: "—",
|
|
28
34
|
description: "断点表,按 width 升序匹配"
|
|
29
35
|
}
|
|
30
|
-
],
|
|
36
|
+
], C = `// 按断点表决定列数(如 640 → 2 列、1024 → 3 列、1440 → 4 列)。
|
|
31
37
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
32
38
|
createResponsiveColumnsPlugin(),
|
|
33
39
|
]);
|
|
34
40
|
|
|
35
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
41
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, h = [
|
|
36
42
|
"AutoColumnPlugin"
|
|
37
|
-
],
|
|
43
|
+
], g = [
|
|
38
44
|
"断点表驱动,设计稿几档就写几档",
|
|
39
45
|
"按容器宽度而非视口宽度匹配",
|
|
40
46
|
"未命中任何断点时回退到 props.columns"
|
|
41
|
-
],
|
|
47
|
+
], b = [
|
|
42
48
|
"严格对齐设计断点的站点",
|
|
43
49
|
"同一个组件嵌在不同宽度的容器里"
|
|
44
|
-
],
|
|
50
|
+
], v = [
|
|
45
51
|
"与 AutoColumnPlugin 互斥。"
|
|
46
|
-
],
|
|
47
|
-
name:
|
|
48
|
-
description:
|
|
52
|
+
], P = {
|
|
53
|
+
name: a,
|
|
54
|
+
description: u,
|
|
49
55
|
since: i,
|
|
50
56
|
tags: r,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
events: m,
|
|
58
|
+
methods: p,
|
|
59
|
+
methodsNote: d,
|
|
60
|
+
config: f,
|
|
61
|
+
example: C,
|
|
62
|
+
conflicts: h,
|
|
63
|
+
features: g,
|
|
64
|
+
useCases: b,
|
|
65
|
+
notes: v
|
|
57
66
|
};
|
|
58
67
|
export {
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
w as c,
|
|
69
|
+
P as d
|
|
61
70
|
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
function p(o, t) {
|
|
2
|
+
const n = o.responsive || {};
|
|
3
|
+
return t >= 1200 && n.xl ? n.xl : t >= 992 && n.lg ? n.lg : t >= 768 && n.md ? n.md : t < 768 && n.sm ? n.sm : {};
|
|
4
|
+
}
|
|
5
|
+
function y(o) {
|
|
6
|
+
let t = 0, n = "";
|
|
7
|
+
const i = (e) => {
|
|
8
|
+
const s = e.containerRef?.current?.clientWidth ?? 0;
|
|
9
|
+
if (s <= 0) return;
|
|
10
|
+
const a = t;
|
|
11
|
+
t = s;
|
|
12
|
+
const r = JSON.stringify(p(o, s));
|
|
13
|
+
a > 0 && r !== n && e.bus?.emit("props:invalidate"), n = r;
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
name: "GapPlugin",
|
|
17
|
+
priority: 50,
|
|
18
|
+
enabled: !0,
|
|
19
|
+
hooks: {
|
|
20
|
+
transformProps: (e) => {
|
|
21
|
+
const s = t > 0 ? t : typeof window < "u" ? window.innerWidth : 1024, a = { columnGap: o.columnGap, rowGap: o.rowGap }, r = p(o, s), c = {
|
|
22
|
+
columnGap: r.columnGap ?? a.columnGap ?? e.columnGap,
|
|
23
|
+
rowGap: r.rowGap ?? a.rowGap ?? e.rowGap
|
|
24
|
+
};
|
|
25
|
+
return { ...e, ...c };
|
|
26
|
+
},
|
|
27
|
+
onMount: (e) => {
|
|
28
|
+
i(e);
|
|
29
|
+
},
|
|
30
|
+
onResize: (e) => {
|
|
31
|
+
i(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const m = "GapPlugin", u = "把 rowGap / columnGap 收敛到一处配置,并支持按窗口宽度切换间距(窄屏 8px、宽屏 16px 这类)。", l = "2.0.0", d = [
|
|
37
|
+
"layout",
|
|
38
|
+
"间距"
|
|
39
|
+
], G = [
|
|
40
|
+
{
|
|
41
|
+
name: "onMount",
|
|
42
|
+
when: "瀑布流挂载完成",
|
|
43
|
+
description: "初始化观察器与滚动监听,返回清理函数"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "onResize",
|
|
47
|
+
when: "容器宽度变化触发重排前",
|
|
48
|
+
description: "按新宽度调整列数或卡片密度"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "transformProps",
|
|
52
|
+
when: "渲染前链式改写瀑布流 props",
|
|
53
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "props:invalidate",
|
|
57
|
+
when: "内部布局参数变更需要重排时",
|
|
58
|
+
description: "通知宿主刷新 props 触发重新布局"
|
|
59
|
+
}
|
|
60
|
+
], f = [], w = "只读取 context 字段(props / state / data),不调用上下文方法", g = [
|
|
61
|
+
{
|
|
62
|
+
name: "columnGap",
|
|
63
|
+
type: "number",
|
|
64
|
+
default: "props.columnGap",
|
|
65
|
+
description: "列间距 px"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "rowGap",
|
|
69
|
+
type: "number",
|
|
70
|
+
default: "props.rowGap",
|
|
71
|
+
description: "行间距 px"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "responsive",
|
|
75
|
+
type: "{ sm?, md?, lg?, xl? }",
|
|
76
|
+
default: "—",
|
|
77
|
+
description: "断点覆盖(按 window 宽度)"
|
|
78
|
+
}
|
|
79
|
+
], h = `// 统一控制行/列间距,支持按断点给不同间距。
|
|
80
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
81
|
+
createGapPlugin(),
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, x = [
|
|
85
|
+
"行列间距一处配置",
|
|
86
|
+
"断点覆盖(sm/md/lg/xl)",
|
|
87
|
+
"不填则回退到 props"
|
|
88
|
+
], v = [
|
|
89
|
+
"设计规范里间距随断点变化",
|
|
90
|
+
"同一组件在不同页面用不同密度"
|
|
91
|
+
], W = [
|
|
92
|
+
"断点判断用的是 window.innerWidth(间距通常跟视口走,与列数按容器算不一样)。",
|
|
93
|
+
"断点是「命中即覆盖」:桌面窗口 ≥1200 又配了 responsive.lg,那就一直是 lg 的值,config.columnGap/rowGap 在这档不起作用;想让手写值生效就别给该档位配 responsive。",
|
|
94
|
+
"sm 只在小屏(<768)生效,不会被当成兜底档套到桌面端。"
|
|
95
|
+
], P = {
|
|
96
|
+
name: m,
|
|
97
|
+
description: u,
|
|
98
|
+
since: l,
|
|
99
|
+
tags: d,
|
|
100
|
+
events: G,
|
|
101
|
+
methods: f,
|
|
102
|
+
methodsNote: w,
|
|
103
|
+
config: g,
|
|
104
|
+
example: h,
|
|
105
|
+
features: x,
|
|
106
|
+
useCases: v,
|
|
107
|
+
notes: W
|
|
108
|
+
};
|
|
109
|
+
export {
|
|
110
|
+
y as c,
|
|
111
|
+
P as d
|
|
112
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
function V(y = {}) {
|
|
3
|
+
const w = y.showOverlay ?? y.showOverlaySummary ?? !1, o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
4
|
+
let l = !1, c = null;
|
|
5
|
+
const f = (t) => Array.from(t.values()).reduce((e, s) => e + s, 0), m = (t, e, s) => {
|
|
6
|
+
try {
|
|
7
|
+
const n = t.props?.keyExtractor?.(e, s);
|
|
8
|
+
if (n != null) return String(n);
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
11
|
+
return `#${s}`;
|
|
12
|
+
}, p = (t) => {
|
|
13
|
+
const e = t.items;
|
|
14
|
+
(c === null || e !== c) && (c = e, o.clear(), a.clear(), r.clear(), l = !1);
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
name: "HeatmapAnalyticsPlugin",
|
|
18
|
+
enabled: !0,
|
|
19
|
+
getStats: () => {
|
|
20
|
+
const t = /* @__PURE__ */ new Set([...o.keys(), ...a.keys()]);
|
|
21
|
+
return {
|
|
22
|
+
totalViews: f(o),
|
|
23
|
+
totalClicks: f(a),
|
|
24
|
+
items: Array.from(t).map((e) => ({
|
|
25
|
+
index: r.get(e) ?? 0,
|
|
26
|
+
key: e,
|
|
27
|
+
views: o.get(e) ?? 0,
|
|
28
|
+
clicks: a.get(e) ?? 0
|
|
29
|
+
})).sort((e, s) => e.index - s.index || e.key.localeCompare(s.key))
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
hooks: {
|
|
33
|
+
onLayoutComplete: (t) => {
|
|
34
|
+
if (p(t), l) return;
|
|
35
|
+
const { start: e, end: s } = t.visibleRange, n = t.items;
|
|
36
|
+
for (let i = e; i <= s; i++) {
|
|
37
|
+
const g = n[i];
|
|
38
|
+
if (g === void 0) continue;
|
|
39
|
+
const u = m(t, g, i);
|
|
40
|
+
r.set(u, i), o.set(u, (o.get(u) || 0) + 1);
|
|
41
|
+
}
|
|
42
|
+
l = !0;
|
|
43
|
+
},
|
|
44
|
+
onItemEnterViewport: (t, e) => {
|
|
45
|
+
p(t);
|
|
46
|
+
const s = t.items[e];
|
|
47
|
+
if (s === void 0) return;
|
|
48
|
+
const n = m(t, s, e);
|
|
49
|
+
r.set(n, e), o.set(n, (o.get(n) || 0) + 1);
|
|
50
|
+
},
|
|
51
|
+
onItemClick: (t, e, s) => {
|
|
52
|
+
p(t);
|
|
53
|
+
const n = m(t, s, e);
|
|
54
|
+
r.set(n, e), a.set(n, (a.get(n) || 0) + 1), t.forceUpdate?.();
|
|
55
|
+
},
|
|
56
|
+
renderOverlay: () => {
|
|
57
|
+
if (!w) return null;
|
|
58
|
+
const t = Array.from(o.values()).reduce((s, n) => s + n, 0), e = Array.from(a.values()).reduce((s, n) => s + n, 0);
|
|
59
|
+
return /* @__PURE__ */ d(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
style: {
|
|
63
|
+
position: "sticky",
|
|
64
|
+
top: 0,
|
|
65
|
+
zIndex: 100,
|
|
66
|
+
display: "flex",
|
|
67
|
+
gap: 12,
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
padding: "6px 10px",
|
|
70
|
+
background: "rgba(0,0,0,0.6)",
|
|
71
|
+
color: "white",
|
|
72
|
+
borderRadius: 8,
|
|
73
|
+
fontSize: 12,
|
|
74
|
+
marginBottom: 8
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ d("span", { children: [
|
|
78
|
+
"曝光总计: ",
|
|
79
|
+
t
|
|
80
|
+
] }),
|
|
81
|
+
/* @__PURE__ */ d("span", { children: [
|
|
82
|
+
"点击总计: ",
|
|
83
|
+
e
|
|
84
|
+
] })
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const h = "HeatmapAnalyticsPlugin", v = "统计每项进入视口次数与点击次数,可选顶部汇总条,`getStats()` 取出每项明细。曝光是瀑布流里最容易统计错的东西(滚动时反复进出视口),交给插件比自己写 IntersectionObserver 少踩坑。", k = "2.0.0", C = [
|
|
93
|
+
"interaction",
|
|
94
|
+
"埋点",
|
|
95
|
+
"曝光"
|
|
96
|
+
], O = [
|
|
97
|
+
{
|
|
98
|
+
name: "onItemClick",
|
|
99
|
+
when: "单个卡片被点击",
|
|
100
|
+
description: "卡片级跳转与点击埋点"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "onItemEnterViewport",
|
|
104
|
+
when: "单个卡片进入视口",
|
|
105
|
+
description: "卡片级曝光、视频自动播放等"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "onLayoutComplete",
|
|
109
|
+
when: "DOM 落位完成(可安全测量)",
|
|
110
|
+
description: "测量真实高度、懒加载判定、曝光上报"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "renderOverlay",
|
|
114
|
+
when: "每次渲染,滚动容器内的内容层之上",
|
|
115
|
+
description: "回到顶部、加载提示、浮层工具"
|
|
116
|
+
}
|
|
117
|
+
], I = [], S = "只读取 context 字段(props / state / data),不调用上下文方法", A = [
|
|
118
|
+
{
|
|
119
|
+
name: "showOverlay",
|
|
120
|
+
type: "boolean",
|
|
121
|
+
default: "false",
|
|
122
|
+
description: "是否显示顶部汇总条"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "showOverlaySummary",
|
|
126
|
+
type: "boolean",
|
|
127
|
+
default: "—",
|
|
128
|
+
description: "showOverlay 的旧别名"
|
|
129
|
+
}
|
|
130
|
+
], b = `// 统计每项曝光次数与点击次数,可显示汇总条。
|
|
131
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
132
|
+
createHeatmapAnalyticsPlugin({
|
|
133
|
+
showOverlay: false,
|
|
134
|
+
}),
|
|
135
|
+
]);
|
|
136
|
+
|
|
137
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, P = [
|
|
138
|
+
"按项的曝光 / 点击双计数",
|
|
139
|
+
"首屏曝光在 onLayoutComplete 补一次",
|
|
140
|
+
"getStats() 输出可上报的扁平结构"
|
|
141
|
+
], H = [
|
|
142
|
+
"信息流曝光分析",
|
|
143
|
+
"广告位可见性验证",
|
|
144
|
+
"调试曝光策略"
|
|
145
|
+
], L = [
|
|
146
|
+
"首屏曝光靠 onLayoutComplete 补一次,否则第一帧显示 0。",
|
|
147
|
+
"真实上报要自己做去重与批次(插件只负责计数,不区分「同一项第几次进入」)。",
|
|
148
|
+
"计数只在内存里,刷新即清零 —— 定时取 getStats() 上报。"
|
|
149
|
+
], x = {
|
|
150
|
+
name: h,
|
|
151
|
+
description: v,
|
|
152
|
+
since: k,
|
|
153
|
+
tags: C,
|
|
154
|
+
events: O,
|
|
155
|
+
methods: I,
|
|
156
|
+
methodsNote: S,
|
|
157
|
+
config: A,
|
|
158
|
+
example: b,
|
|
159
|
+
features: P,
|
|
160
|
+
useCases: H,
|
|
161
|
+
notes: L
|
|
162
|
+
};
|
|
163
|
+
export {
|
|
164
|
+
V as c,
|
|
165
|
+
x as d
|
|
166
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function
|
|
2
|
-
const s =
|
|
1
|
+
function P(o = {}) {
|
|
2
|
+
const s = o.getAnchorId || ((n) => n?.id);
|
|
3
3
|
let e;
|
|
4
4
|
return {
|
|
5
5
|
name: "ScrollAnchorPlugin",
|
|
@@ -7,53 +7,67 @@ function A(t = {}) {
|
|
|
7
7
|
hooks: {
|
|
8
8
|
onMount: (n) => {
|
|
9
9
|
e = n.bus?.on("anchor:scrollToId", (c) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const t = (n.props?.items || []).findIndex((i, r) => s(i, r) === c.id);
|
|
11
|
+
t >= 0 && n.scrollToItem?.(t, { behavior: "smooth", block: "start" });
|
|
12
12
|
});
|
|
13
13
|
},
|
|
14
14
|
onUnmount: () => e?.()
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
const a = "ScrollAnchorPlugin",
|
|
18
|
+
const a = "ScrollAnchorPlugin", d = '不需要自己算索引:外部只管 `bus.emit("anchor:scrollToId", { id })`,插件用 getAnchorId 找到对应项并滚过去。适合「从消息跳到某条内容」。', l = "2.0.0", m = [
|
|
19
19
|
"interaction",
|
|
20
20
|
"滚动"
|
|
21
21
|
], u = [
|
|
22
|
+
{
|
|
23
|
+
name: "onMount",
|
|
24
|
+
when: "瀑布流挂载完成",
|
|
25
|
+
description: "初始化观察器与滚动监听,返回清理函数"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "onUnmount",
|
|
29
|
+
when: "瀑布流卸载前",
|
|
30
|
+
description: "断开观察器、移除滚动监听"
|
|
31
|
+
}
|
|
32
|
+
], h = [], g = "只读取 context 字段(props / state / data),不调用上下文方法", p = [
|
|
22
33
|
{
|
|
23
34
|
name: "getAnchorId",
|
|
24
35
|
type: "(item, index) => string | number | undefined",
|
|
25
36
|
default: "item.id",
|
|
26
37
|
description: "从项里取锚点 id"
|
|
27
38
|
}
|
|
28
|
-
],
|
|
39
|
+
], f = `// 监听 \`anchor:scrollToId\` 事件,按业务 id 滚动到对应项。
|
|
29
40
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
30
41
|
createScrollAnchorPlugin({
|
|
31
42
|
getAnchorId: "item.id",
|
|
32
43
|
}),
|
|
33
44
|
]);
|
|
34
45
|
|
|
35
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
46
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, I = [
|
|
36
47
|
"按业务 id 定位,不用算下标",
|
|
37
48
|
"onMount 订阅 / onUnmount 退订(不泄漏)",
|
|
38
49
|
"平滑滚动"
|
|
39
|
-
],
|
|
50
|
+
], A = [
|
|
40
51
|
"从通知跳转到具体卡片",
|
|
41
52
|
"目录点击定位",
|
|
42
53
|
"外链深链定位"
|
|
43
|
-
],
|
|
54
|
+
], b = [
|
|
44
55
|
"目标项必须已在 items 里;分页场景请先切到对应页再发事件。"
|
|
45
|
-
],
|
|
56
|
+
], C = {
|
|
46
57
|
name: a,
|
|
47
|
-
description:
|
|
48
|
-
since:
|
|
58
|
+
description: d,
|
|
59
|
+
since: l,
|
|
49
60
|
tags: m,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
events: u,
|
|
62
|
+
methods: h,
|
|
63
|
+
methodsNote: g,
|
|
64
|
+
config: p,
|
|
65
|
+
example: f,
|
|
66
|
+
features: I,
|
|
67
|
+
useCases: A,
|
|
68
|
+
notes: b
|
|
55
69
|
};
|
|
56
70
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
P as c,
|
|
72
|
+
C as d
|
|
59
73
|
};
|
|
@@ -1,35 +1,46 @@
|
|
|
1
|
-
function
|
|
1
|
+
function S(e = {}) {
|
|
2
2
|
return {
|
|
3
3
|
name: "SortPlugin",
|
|
4
4
|
priority: 30,
|
|
5
5
|
enabled: !0,
|
|
6
6
|
hooks: {
|
|
7
7
|
transformProps: (o) => {
|
|
8
|
-
const
|
|
8
|
+
const r = Array.isArray(o.items) ? o.items : [], t = o.sortComparator || e.comparator;
|
|
9
9
|
if (typeof t != "function") return o;
|
|
10
|
-
const s = [...
|
|
10
|
+
const s = [...r].sort((n, a) => {
|
|
11
11
|
try {
|
|
12
|
-
return t(
|
|
12
|
+
return t(n, a);
|
|
13
13
|
} catch {
|
|
14
14
|
return 0;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
return { ...o, items: s };
|
|
18
18
|
},
|
|
19
|
-
onPropsChange: (o,
|
|
20
|
-
const s =
|
|
21
|
-
if (((typeof t?.scrollToTopOnSortChange == "boolean" ? t.scrollToTopOnSortChange : void 0) ?? !!
|
|
22
|
-
const
|
|
23
|
-
o.scrollToTop?.({ behavior:
|
|
19
|
+
onPropsChange: (o, r, t) => {
|
|
20
|
+
const s = r?.sortComparator, n = t?.sortComparator;
|
|
21
|
+
if (((typeof t?.scrollToTopOnSortChange == "boolean" ? t.scrollToTopOnSortChange : void 0) ?? !!e.scrollToTop) && s !== n) {
|
|
22
|
+
const c = t?.scrollToTopBehavior ?? e.scrollBehavior ?? "auto";
|
|
23
|
+
o.scrollToTop?.({ behavior: c });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const l = "SortPlugin", i = "用比较函数排序,优先读 `props.sortComparator`。排序总是在过滤之后、分页之前执行,保证「第 N 页」是排序后的第 N 页。", m = "2.0.0", p = [
|
|
30
30
|
"data",
|
|
31
31
|
"数据管线"
|
|
32
|
-
],
|
|
32
|
+
], d = [
|
|
33
|
+
{
|
|
34
|
+
name: "onPropsChange",
|
|
35
|
+
when: "props 变化后",
|
|
36
|
+
description: "数据或配置变化时请求重排"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "transformProps",
|
|
40
|
+
when: "渲染前链式改写瀑布流 props",
|
|
41
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
42
|
+
}
|
|
43
|
+
], u = [], h = "只读取 context 字段(props / state / data),不调用上下文方法", f = [
|
|
33
44
|
{
|
|
34
45
|
name: "comparator",
|
|
35
46
|
type: "(a, b) => number",
|
|
@@ -48,7 +59,7 @@ const c = "SortPlugin", i = "用比较函数排序,优先读 `props.sortCompar
|
|
|
48
59
|
default: '"auto"',
|
|
49
60
|
description: "回顶行为"
|
|
50
61
|
}
|
|
51
|
-
],
|
|
62
|
+
], C = `// 按比较函数排序 items,比较函数变化可自动回顶。
|
|
52
63
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
53
64
|
createSortPlugin({
|
|
54
65
|
scrollToTop: false,
|
|
@@ -56,28 +67,31 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
56
67
|
}),
|
|
57
68
|
]);
|
|
58
69
|
|
|
59
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
70
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, T = [
|
|
60
71
|
"稳定排序(不改原数组)",
|
|
61
72
|
"比较函数抛错按相等处理",
|
|
62
73
|
"与 Filter / Search 顺序固定"
|
|
63
|
-
],
|
|
74
|
+
], g = [
|
|
64
75
|
"价格 / 时间排序",
|
|
65
76
|
"热度排序",
|
|
66
77
|
"手动置顶项优先"
|
|
67
|
-
],
|
|
78
|
+
], v = [
|
|
68
79
|
"排序会复制数组(`[...items].sort`),不会改调用方传入的 items。"
|
|
69
|
-
],
|
|
70
|
-
name:
|
|
80
|
+
], b = {
|
|
81
|
+
name: l,
|
|
71
82
|
description: i,
|
|
72
83
|
since: m,
|
|
73
84
|
tags: p,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
events: d,
|
|
86
|
+
methods: u,
|
|
87
|
+
methodsNote: h,
|
|
88
|
+
config: f,
|
|
89
|
+
example: C,
|
|
90
|
+
features: T,
|
|
91
|
+
useCases: g,
|
|
92
|
+
notes: v
|
|
79
93
|
};
|
|
80
94
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
S as c,
|
|
96
|
+
b as d
|
|
83
97
|
};
|
|
@@ -1,55 +1,69 @@
|
|
|
1
|
-
function
|
|
1
|
+
function g(t) {
|
|
2
2
|
return {
|
|
3
3
|
name: "AlignmentPlugin",
|
|
4
4
|
priority: 60,
|
|
5
5
|
enabled: !0,
|
|
6
6
|
hooks: {
|
|
7
|
-
transformProps: (e) => ({ ...e, alignmentMode:
|
|
7
|
+
transformProps: (e) => ({ ...e, alignmentMode: t.mode }),
|
|
8
8
|
onResize: (e) => {
|
|
9
9
|
e.relayout?.();
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const n = "AlignmentPlugin", s = "设置瀑布流的列分配策略。shortest 让每列尽量等高(视觉最自然),balanced 让每列项数接近,sequential 按 index 轮转(可预测位置,适合需要与外部索引对齐的场景)。", o = "2.0.0", a = [
|
|
15
15
|
"layout",
|
|
16
16
|
"布局"
|
|
17
17
|
], i = [
|
|
18
|
+
{
|
|
19
|
+
name: "onResize",
|
|
20
|
+
when: "容器宽度变化触发重排前",
|
|
21
|
+
description: "按新宽度调整列数或卡片密度"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "transformProps",
|
|
25
|
+
when: "渲染前链式改写瀑布流 props",
|
|
26
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
27
|
+
}
|
|
28
|
+
], r = [], c = "只读取 context 字段(props / state / data),不调用上下文方法", l = [
|
|
18
29
|
{
|
|
19
30
|
name: "mode",
|
|
20
31
|
type: '"shortest" | "balanced" | "sequential"',
|
|
21
32
|
default: "shortest",
|
|
22
33
|
description: "列分配策略"
|
|
23
34
|
}
|
|
24
|
-
],
|
|
35
|
+
], m = `// 指定列分配策略:最矮列优先(shortest)/ 项数均衡(balanced)/ 顺序轮转(sequential)。
|
|
25
36
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
26
37
|
createAlignmentPlugin({
|
|
27
38
|
mode: "shortest",
|
|
28
39
|
}),
|
|
29
40
|
]);
|
|
30
41
|
|
|
31
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
42
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, d = [
|
|
32
43
|
"三种列分配策略",
|
|
33
44
|
"只改 props.alignmentMode,不影响其他配置",
|
|
34
45
|
"与 ResponsiveColumns / AutoColumn 正交"
|
|
35
|
-
],
|
|
46
|
+
], u = [
|
|
36
47
|
"内容流:默认 shortest",
|
|
37
48
|
"等长卡片:balanced 更整齐",
|
|
38
49
|
"需要与后端顺序对齐:sequential"
|
|
39
|
-
],
|
|
50
|
+
], p = [
|
|
40
51
|
"balanced 与 shortest 在列高相同时都取最左列,视觉上左偏是预期行为。"
|
|
41
|
-
],
|
|
42
|
-
name:
|
|
52
|
+
], h = {
|
|
53
|
+
name: n,
|
|
43
54
|
description: s,
|
|
44
55
|
since: o,
|
|
45
56
|
tags: a,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
events: i,
|
|
58
|
+
methods: r,
|
|
59
|
+
methodsNote: c,
|
|
60
|
+
config: l,
|
|
61
|
+
example: m,
|
|
62
|
+
features: d,
|
|
63
|
+
useCases: u,
|
|
64
|
+
notes: p
|
|
51
65
|
};
|
|
52
66
|
export {
|
|
53
|
-
|
|
54
|
-
d
|
|
67
|
+
g as c,
|
|
68
|
+
h as d
|
|
55
69
|
};
|