vane-waterfall 2.0.2 → 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/dist/chunks/doc-BAhVW3g8.js +150 -0
- package/dist/chunks/{doc-BXaJl1By.js → doc-BU0CKW63.js} +64 -35
- package/dist/chunks/{doc-D_ozEn0Q.js → doc-BrEd0oZB.js} +41 -32
- 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-BSnWbrkH.js → doc-C2L8kkeI.js} +49 -25
- package/dist/chunks/{doc-a0MK2S3n.js → doc-CE1DGMBV.js} +62 -38
- 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-BCmEnh39.js → doc-CkuMr8Ca.js} +49 -25
- 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-DAieSXLy.js → doc-DlJICsyN.js} +41 -27
- package/dist/chunks/{doc-CN4edvn_.js → doc-DtxS1-P0.js} +32 -23
- package/dist/chunks/{doc-BIzjYAZW.js → doc-DudYCn_-.js} +25 -16
- package/dist/chunks/{doc-BmoijI6q.js → doc-HoyAFR_m.js} +43 -24
- 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-CF0tYRop.js → index-FBJVUYmH.js} +1 -1
- package/dist/chunks/withPlugins-BOeDFhof.js +743 -0
- 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/doc.json.d.ts +44 -35
- package/dist/custom-plugins/BookmarkPlugin/index.js +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/doc.json.d.ts +61 -37
- package/dist/custom-plugins/GapPlugin/index.js +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/doc.json.d.ts +24 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.js +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/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/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/doc.json.d.ts +71 -37
- package/dist/custom-plugins/StatePersistencePlugin/index.js +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/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/plugins.js +7 -7
- package/dist/index.js +1 -1
- 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 +26 -26
- package/dist/chunks/doc-BQQoKNto.js +0 -126
- package/dist/chunks/doc-BindRMfO.js +0 -72
- package/dist/chunks/doc-CBHjiDG7.js +0 -88
- package/dist/chunks/doc-CkU5GtLw.js +0 -136
- package/dist/chunks/doc-KN6Bvmty.js +0 -124
- package/dist/chunks/index-B8o6R4RZ.js +0 -15
- package/dist/chunks/index-BFyYpEY_.js +0 -11
- package/dist/chunks/index-CJR0Buju.js +0 -21
- package/dist/chunks/index-DHTB3QEP.js +0 -13
- package/dist/chunks/withPlugins-DG3YpSgL.js +0 -655
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const l = "(prefers-reduced-motion: reduce)";
|
|
2
|
-
function
|
|
2
|
+
function C(c = {}) {
|
|
3
3
|
const i = typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia(l) : null;
|
|
4
4
|
let s = i?.matches ?? !1;
|
|
5
|
-
const m = c.disableTransform ?? !0,
|
|
6
|
-
if (!(!e || !
|
|
5
|
+
const m = c.disableTransform ?? !0, d = c.removeTransitions ?? !0, o = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), a = (e) => {
|
|
6
|
+
if (!(!e || !d))
|
|
7
7
|
if (s) {
|
|
8
8
|
const n = e.style.transitionDuration;
|
|
9
9
|
n && n !== "0s" ? t.set(e, n) : t.has(e) || t.set(e, n), e.style.setProperty("transition-duration", "0s");
|
|
@@ -12,10 +12,10 @@ function R(c = {}) {
|
|
|
12
12
|
if (n === void 0) return;
|
|
13
13
|
n ? e.style.setProperty("transition-duration", n) : e.style.removeProperty("transition-duration"), t.delete(e);
|
|
14
14
|
}
|
|
15
|
-
}, f = () => o.forEach((e) => a(e)),
|
|
15
|
+
}, f = () => o.forEach((e) => a(e)), u = (e) => {
|
|
16
16
|
e.matches !== s && (s = e.matches, f());
|
|
17
17
|
};
|
|
18
|
-
return i?.addEventListener?.("change",
|
|
18
|
+
return i?.addEventListener?.("change", u), {
|
|
19
19
|
name: "ReducedMotionPlugin",
|
|
20
20
|
priority: 70,
|
|
21
21
|
enabled: !0,
|
|
@@ -23,7 +23,7 @@ function R(c = {}) {
|
|
|
23
23
|
transformProps: (e) => {
|
|
24
24
|
if (!s) return e;
|
|
25
25
|
const n = { ...e };
|
|
26
|
-
return m && (n.useTransform = !1),
|
|
26
|
+
return m && (n.useTransform = !1), d && (n.itemStyle = { ...e.itemStyle ?? {}, transitionDuration: "0s" }), n;
|
|
27
27
|
},
|
|
28
28
|
onItemMount: (e, n, r) => {
|
|
29
29
|
o.set(n, r), a(r);
|
|
@@ -37,15 +37,41 @@ function R(c = {}) {
|
|
|
37
37
|
});
|
|
38
38
|
},
|
|
39
39
|
onUnmount: () => {
|
|
40
|
-
i?.removeEventListener?.("change",
|
|
40
|
+
i?.removeEventListener?.("change", u), o.clear(), t.clear();
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
const p = "ReducedMotionPlugin",
|
|
45
|
+
const p = "ReducedMotionPlugin", h = "检测 `prefers-reduced-motion: reduce`,命中后把 useTransform 关掉并清掉项上的 transition。前庭功能敏感用户不会因为滚动时的位置微动而不适。", y = "2.0.0", g = [
|
|
46
46
|
"perf",
|
|
47
47
|
"a11y"
|
|
48
|
-
],
|
|
48
|
+
], w = [
|
|
49
|
+
{
|
|
50
|
+
name: "onUnmount",
|
|
51
|
+
when: "瀑布流卸载前",
|
|
52
|
+
description: "断开观察器、移除滚动监听"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "onItemMount",
|
|
56
|
+
when: "单个卡片挂载并拿到 DOM 元素时",
|
|
57
|
+
description: "按卡片绑定监听、观察器、埋点"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "onItemUnmount",
|
|
61
|
+
when: "单个卡片卸载时",
|
|
62
|
+
description: "解绑该卡片的监听与观察器"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "onLayoutComplete",
|
|
66
|
+
when: "DOM 落位完成(可安全测量)",
|
|
67
|
+
description: "测量真实高度、懒加载判定、曝光上报"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "transformProps",
|
|
71
|
+
when: "渲染前链式改写瀑布流 props",
|
|
72
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
73
|
+
}
|
|
74
|
+
], M = [], P = "只读取 context 字段(props / state / data),不调用上下文方法", T = [
|
|
49
75
|
{
|
|
50
76
|
name: "disableTransform",
|
|
51
77
|
type: "boolean",
|
|
@@ -58,7 +84,7 @@ const p = "ReducedMotionPlugin", y = "检测 `prefers-reduced-motion: reduce`,
|
|
|
58
84
|
default: "true",
|
|
59
85
|
description: "命中偏好时清掉项过渡"
|
|
60
86
|
}
|
|
61
|
-
],
|
|
87
|
+
], v = `// 尊重系统「减少动画」偏好:关掉 transform 定位与项过渡。
|
|
62
88
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
63
89
|
createReducedMotionPlugin({
|
|
64
90
|
disableTransform: true,
|
|
@@ -66,30 +92,33 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
66
92
|
}),
|
|
67
93
|
]);
|
|
68
94
|
|
|
69
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
95
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, R = [
|
|
70
96
|
"系统偏好驱动,零配置生效",
|
|
71
97
|
"两项能力可分别关闭",
|
|
72
98
|
"与 TransitionPlugin 同装时优先生效"
|
|
73
|
-
],
|
|
99
|
+
], b = [
|
|
74
100
|
"政务 / 医疗类站点",
|
|
75
101
|
"无障碍合规要求",
|
|
76
102
|
"低性能设备"
|
|
77
|
-
],
|
|
103
|
+
], x = [
|
|
78
104
|
"偏好由 matchMedia 驱动,并监听 change:运行中改系统设置即时生效(定位方式要等下一次重渲染才切过来)。",
|
|
79
105
|
"只压 `transition-duration`,不写 `transition: none` —— 写简写会把 TransitionPlugin 的过渡整条覆盖,撤销偏好后无从还原。",
|
|
80
106
|
"与 TransitionPlugin 同装不是冲突:ReducedMotion 优先级更高,会先执行并压住过渡。"
|
|
81
|
-
],
|
|
107
|
+
], D = {
|
|
82
108
|
name: p,
|
|
83
|
-
description:
|
|
84
|
-
since:
|
|
85
|
-
tags:
|
|
109
|
+
description: h,
|
|
110
|
+
since: y,
|
|
111
|
+
tags: g,
|
|
112
|
+
events: w,
|
|
113
|
+
methods: M,
|
|
114
|
+
methodsNote: P,
|
|
86
115
|
config: T,
|
|
87
|
-
example:
|
|
88
|
-
features:
|
|
89
|
-
useCases:
|
|
90
|
-
notes:
|
|
116
|
+
example: v,
|
|
117
|
+
features: R,
|
|
118
|
+
useCases: b,
|
|
119
|
+
notes: x
|
|
91
120
|
};
|
|
92
121
|
export {
|
|
93
|
-
|
|
94
|
-
|
|
122
|
+
C as c,
|
|
123
|
+
D as d
|
|
95
124
|
};
|
|
@@ -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
|
};
|
|
@@ -2,15 +2,15 @@ function p(o, t) {
|
|
|
2
2
|
const n = o.responsive || {};
|
|
3
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
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function y(o) {
|
|
6
6
|
let t = 0, n = "";
|
|
7
7
|
const i = (e) => {
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
8
|
+
const s = e.containerRef?.current?.clientWidth ?? 0;
|
|
9
|
+
if (s <= 0) return;
|
|
10
10
|
const a = t;
|
|
11
|
-
t =
|
|
12
|
-
const
|
|
13
|
-
a > 0 &&
|
|
11
|
+
t = s;
|
|
12
|
+
const r = JSON.stringify(p(o, s));
|
|
13
|
+
a > 0 && r !== n && e.bus?.emit("props:invalidate"), n = r;
|
|
14
14
|
};
|
|
15
15
|
return {
|
|
16
16
|
name: "GapPlugin",
|
|
@@ -18,9 +18,9 @@ function W(o) {
|
|
|
18
18
|
enabled: !0,
|
|
19
19
|
hooks: {
|
|
20
20
|
transformProps: (e) => {
|
|
21
|
-
const
|
|
22
|
-
columnGap:
|
|
23
|
-
rowGap:
|
|
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
24
|
};
|
|
25
25
|
return { ...e, ...c };
|
|
26
26
|
},
|
|
@@ -33,10 +33,31 @@ function W(o) {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const m = "GapPlugin", u = "把 rowGap / columnGap 收敛到一处配置,并支持按窗口宽度切换间距(窄屏 8px、宽屏 16px 这类)。", l = "2.0.0", d = [
|
|
37
37
|
"layout",
|
|
38
38
|
"间距"
|
|
39
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 = [
|
|
40
61
|
{
|
|
41
62
|
name: "columnGap",
|
|
42
63
|
type: "number",
|
|
@@ -55,34 +76,37 @@ const u = "GapPlugin", l = "把 rowGap / columnGap 收敛到一处配置,并
|
|
|
55
76
|
default: "—",
|
|
56
77
|
description: "断点覆盖(按 window 宽度)"
|
|
57
78
|
}
|
|
58
|
-
],
|
|
79
|
+
], h = `// 统一控制行/列间距,支持按断点给不同间距。
|
|
59
80
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
60
81
|
createGapPlugin(),
|
|
61
82
|
]);
|
|
62
83
|
|
|
63
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
84
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, x = [
|
|
64
85
|
"行列间距一处配置",
|
|
65
86
|
"断点覆盖(sm/md/lg/xl)",
|
|
66
87
|
"不填则回退到 props"
|
|
67
|
-
],
|
|
88
|
+
], v = [
|
|
68
89
|
"设计规范里间距随断点变化",
|
|
69
90
|
"同一组件在不同页面用不同密度"
|
|
70
|
-
],
|
|
91
|
+
], W = [
|
|
71
92
|
"断点判断用的是 window.innerWidth(间距通常跟视口走,与列数按容器算不一样)。",
|
|
72
93
|
"断点是「命中即覆盖」:桌面窗口 ≥1200 又配了 responsive.lg,那就一直是 lg 的值,config.columnGap/rowGap 在这档不起作用;想让手写值生效就别给该档位配 responsive。",
|
|
73
94
|
"sm 只在小屏(<768)生效,不会被当成兜底档套到桌面端。"
|
|
74
|
-
],
|
|
75
|
-
name:
|
|
76
|
-
description:
|
|
77
|
-
since:
|
|
95
|
+
], P = {
|
|
96
|
+
name: m,
|
|
97
|
+
description: u,
|
|
98
|
+
since: l,
|
|
78
99
|
tags: d,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
events: G,
|
|
101
|
+
methods: f,
|
|
102
|
+
methodsNote: w,
|
|
103
|
+
config: g,
|
|
104
|
+
example: h,
|
|
105
|
+
features: x,
|
|
106
|
+
useCases: v,
|
|
107
|
+
notes: W
|
|
84
108
|
};
|
|
85
109
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
110
|
+
y as c,
|
|
111
|
+
P as d
|
|
88
112
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
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
4
|
let l = !1, c = null;
|
|
5
5
|
const f = (t) => Array.from(t.values()).reduce((e, s) => e + s, 0), m = (t, e, s) => {
|
|
6
6
|
try {
|
|
@@ -9,54 +9,54 @@ function H(d = {}) {
|
|
|
9
9
|
} catch {
|
|
10
10
|
}
|
|
11
11
|
return `#${s}`;
|
|
12
|
-
},
|
|
12
|
+
}, p = (t) => {
|
|
13
13
|
const e = t.items;
|
|
14
|
-
(c === null || e !== c) && (c = e,
|
|
14
|
+
(c === null || e !== c) && (c = e, o.clear(), a.clear(), r.clear(), l = !1);
|
|
15
15
|
};
|
|
16
16
|
return {
|
|
17
17
|
name: "HeatmapAnalyticsPlugin",
|
|
18
18
|
enabled: !0,
|
|
19
19
|
getStats: () => {
|
|
20
|
-
const t = /* @__PURE__ */ new Set([...
|
|
20
|
+
const t = /* @__PURE__ */ new Set([...o.keys(), ...a.keys()]);
|
|
21
21
|
return {
|
|
22
|
-
totalViews: f(
|
|
23
|
-
totalClicks: f(
|
|
22
|
+
totalViews: f(o),
|
|
23
|
+
totalClicks: f(a),
|
|
24
24
|
items: Array.from(t).map((e) => ({
|
|
25
25
|
index: r.get(e) ?? 0,
|
|
26
26
|
key: e,
|
|
27
|
-
views:
|
|
28
|
-
clicks:
|
|
27
|
+
views: o.get(e) ?? 0,
|
|
28
|
+
clicks: a.get(e) ?? 0
|
|
29
29
|
})).sort((e, s) => e.index - s.index || e.key.localeCompare(s.key))
|
|
30
30
|
};
|
|
31
31
|
},
|
|
32
32
|
hooks: {
|
|
33
33
|
onLayoutComplete: (t) => {
|
|
34
|
-
if (
|
|
34
|
+
if (p(t), l) return;
|
|
35
35
|
const { start: e, end: s } = t.visibleRange, n = t.items;
|
|
36
36
|
for (let i = e; i <= s; i++) {
|
|
37
37
|
const g = n[i];
|
|
38
38
|
if (g === void 0) continue;
|
|
39
|
-
const
|
|
40
|
-
r.set(
|
|
39
|
+
const u = m(t, g, i);
|
|
40
|
+
r.set(u, i), o.set(u, (o.get(u) || 0) + 1);
|
|
41
41
|
}
|
|
42
42
|
l = !0;
|
|
43
43
|
},
|
|
44
44
|
onItemEnterViewport: (t, e) => {
|
|
45
|
-
|
|
45
|
+
p(t);
|
|
46
46
|
const s = t.items[e];
|
|
47
47
|
if (s === void 0) return;
|
|
48
48
|
const n = m(t, s, e);
|
|
49
|
-
r.set(n, e),
|
|
49
|
+
r.set(n, e), o.set(n, (o.get(n) || 0) + 1);
|
|
50
50
|
},
|
|
51
51
|
onItemClick: (t, e, s) => {
|
|
52
|
-
|
|
52
|
+
p(t);
|
|
53
53
|
const n = m(t, s, e);
|
|
54
|
-
r.set(n, e),
|
|
54
|
+
r.set(n, e), a.set(n, (a.get(n) || 0) + 1), t.forceUpdate?.();
|
|
55
55
|
},
|
|
56
56
|
renderOverlay: () => {
|
|
57
|
-
if (!
|
|
58
|
-
const t = Array.from(
|
|
59
|
-
return /* @__PURE__ */
|
|
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
60
|
"div",
|
|
61
61
|
{
|
|
62
62
|
style: {
|
|
@@ -74,11 +74,11 @@ function H(d = {}) {
|
|
|
74
74
|
marginBottom: 8
|
|
75
75
|
},
|
|
76
76
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ d("span", { children: [
|
|
78
78
|
"曝光总计: ",
|
|
79
79
|
t
|
|
80
80
|
] }),
|
|
81
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ d("span", { children: [
|
|
82
82
|
"点击总计: ",
|
|
83
83
|
e
|
|
84
84
|
] })
|
|
@@ -89,11 +89,32 @@ function H(d = {}) {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const h = "HeatmapAnalyticsPlugin", v = "统计每项进入视口次数与点击次数,可选顶部汇总条,`getStats()` 取出每项明细。曝光是瀑布流里最容易统计错的东西(滚动时反复进出视口),交给插件比自己写 IntersectionObserver 少踩坑。", k = "2.0.0", C = [
|
|
93
93
|
"interaction",
|
|
94
94
|
"埋点",
|
|
95
95
|
"曝光"
|
|
96
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 = [
|
|
97
118
|
{
|
|
98
119
|
name: "showOverlay",
|
|
99
120
|
type: "boolean",
|
|
@@ -106,37 +127,40 @@ const w = "HeatmapAnalyticsPlugin", k = "统计每项进入视口次数与点击
|
|
|
106
127
|
default: "—",
|
|
107
128
|
description: "showOverlay 的旧别名"
|
|
108
129
|
}
|
|
109
|
-
],
|
|
130
|
+
], b = `// 统计每项曝光次数与点击次数,可显示汇总条。
|
|
110
131
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
111
132
|
createHeatmapAnalyticsPlugin({
|
|
112
133
|
showOverlay: false,
|
|
113
134
|
}),
|
|
114
135
|
]);
|
|
115
136
|
|
|
116
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
137
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, P = [
|
|
117
138
|
"按项的曝光 / 点击双计数",
|
|
118
139
|
"首屏曝光在 onLayoutComplete 补一次",
|
|
119
140
|
"getStats() 输出可上报的扁平结构"
|
|
120
|
-
],
|
|
141
|
+
], H = [
|
|
121
142
|
"信息流曝光分析",
|
|
122
143
|
"广告位可见性验证",
|
|
123
144
|
"调试曝光策略"
|
|
124
|
-
],
|
|
145
|
+
], L = [
|
|
125
146
|
"首屏曝光靠 onLayoutComplete 补一次,否则第一帧显示 0。",
|
|
126
147
|
"真实上报要自己做去重与批次(插件只负责计数,不区分「同一项第几次进入」)。",
|
|
127
148
|
"计数只在内存里,刷新即清零 —— 定时取 getStats() 上报。"
|
|
128
|
-
],
|
|
129
|
-
name:
|
|
130
|
-
description:
|
|
131
|
-
since:
|
|
149
|
+
], x = {
|
|
150
|
+
name: h,
|
|
151
|
+
description: v,
|
|
152
|
+
since: k,
|
|
132
153
|
tags: C,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
154
|
+
events: O,
|
|
155
|
+
methods: I,
|
|
156
|
+
methodsNote: S,
|
|
157
|
+
config: A,
|
|
158
|
+
example: b,
|
|
159
|
+
features: P,
|
|
160
|
+
useCases: H,
|
|
161
|
+
notes: L
|
|
138
162
|
};
|
|
139
163
|
export {
|
|
140
|
-
|
|
141
|
-
|
|
164
|
+
V as c,
|
|
165
|
+
x as d
|
|
142
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
|
};
|