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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
function E(p = {}) {
|
|
2
|
+
const u = p.mode || "hash", o = p.keys || ["pageIndex", "pageSize", "searchQuery"];
|
|
3
|
+
let h = null, d = !1;
|
|
4
|
+
const l = () => (h === null && (h = f()), h);
|
|
5
|
+
function f() {
|
|
6
|
+
try {
|
|
7
|
+
if (u === "hash") {
|
|
8
|
+
const s = window.location.hash || "", a = s.indexOf("?"), t = a >= 0 ? s.slice(a + 1) : s.replace(/^#/, ""), e = new URLSearchParams(t), n = {};
|
|
9
|
+
return o.forEach((c) => {
|
|
10
|
+
const r = e.get(c);
|
|
11
|
+
r !== null && (n[c] = r);
|
|
12
|
+
}), n;
|
|
13
|
+
} else {
|
|
14
|
+
const s = new URLSearchParams(window.location.search), a = {};
|
|
15
|
+
return o.forEach((t) => {
|
|
16
|
+
const e = s.get(t);
|
|
17
|
+
e !== null && (a[t] = e);
|
|
18
|
+
}), a;
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function w(s) {
|
|
25
|
+
try {
|
|
26
|
+
const a = new URLSearchParams();
|
|
27
|
+
o.forEach((e) => {
|
|
28
|
+
const n = s[e];
|
|
29
|
+
n != null && String(n).length > 0 && a.set(e, String(n));
|
|
30
|
+
});
|
|
31
|
+
const t = a.toString();
|
|
32
|
+
if (u === "hash") {
|
|
33
|
+
const e = window.location.hash || "", r = `#${e.replace(/^#/, "").split("?")[0] || ""}${t ? `?${t}` : ""}`;
|
|
34
|
+
e !== r && history.replaceState(
|
|
35
|
+
null,
|
|
36
|
+
"",
|
|
37
|
+
`${window.location.pathname}${window.location.search}${r}`
|
|
38
|
+
);
|
|
39
|
+
} else {
|
|
40
|
+
const n = window.location.pathname + (t ? `?${t}` : "") + (window.location.hash || "");
|
|
41
|
+
history.replaceState(null, "", n);
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
name: "URLSyncPlugin",
|
|
48
|
+
enabled: !0,
|
|
49
|
+
hooks: {
|
|
50
|
+
// 首次渲染就把 URL 里的值注入 props:旧实现只广播 `urlsync:init`,
|
|
51
|
+
// 页面不手动订阅时深链参数根本不会生效(「只写不读」,P2-6)
|
|
52
|
+
transformProps: (s) => {
|
|
53
|
+
if (d) return s;
|
|
54
|
+
const a = l(), t = { ...s };
|
|
55
|
+
let e = !1;
|
|
56
|
+
return o.forEach((n) => {
|
|
57
|
+
a[n] !== void 0 && (t[n] = a[n], e = !0);
|
|
58
|
+
}), e && (d = !0), t;
|
|
59
|
+
},
|
|
60
|
+
onMount: (s) => {
|
|
61
|
+
s.bus?.emit("urlsync:init", l());
|
|
62
|
+
},
|
|
63
|
+
onPropsChange: (s, a, t) => {
|
|
64
|
+
const e = {}, n = t ?? {};
|
|
65
|
+
o.forEach((i) => {
|
|
66
|
+
const m = n[i];
|
|
67
|
+
m !== void 0 && (e[i] = m);
|
|
68
|
+
});
|
|
69
|
+
const c = l();
|
|
70
|
+
o.some(
|
|
71
|
+
(i) => String(e[i] ?? "") !== String(c[i] ?? "")
|
|
72
|
+
) && w(e);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const g = "URLSyncPlugin", S = "props 变化时把指定键写进 URL(hash 或 search),挂载时读出来广播 `urlsync:init`。刷新与分享都能还原筛选状态。", y = "2.0.0", P = [
|
|
78
|
+
"ui",
|
|
79
|
+
"URL",
|
|
80
|
+
"可分享"
|
|
81
|
+
], R = [
|
|
82
|
+
{
|
|
83
|
+
name: "onMount",
|
|
84
|
+
when: "瀑布流挂载完成",
|
|
85
|
+
description: "初始化观察器与滚动监听,返回清理函数"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "onPropsChange",
|
|
89
|
+
when: "props 变化后",
|
|
90
|
+
description: "数据或配置变化时请求重排"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "transformProps",
|
|
94
|
+
when: "渲染前链式改写瀑布流 props",
|
|
95
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "urlsync:init",
|
|
99
|
+
when: "从 URL 参数初始化完成后",
|
|
100
|
+
description: "广播初始参数快照"
|
|
101
|
+
}
|
|
102
|
+
], L = [], U = "只读取 context 字段(props / state / data),不调用上下文方法", x = [
|
|
103
|
+
{
|
|
104
|
+
name: "mode",
|
|
105
|
+
type: '"hash" | "search"',
|
|
106
|
+
default: '"hash"',
|
|
107
|
+
description: "写 hash 还是 search"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "keys",
|
|
111
|
+
type: "string[]",
|
|
112
|
+
default: '["pageIndex","pageSize","searchQuery"]',
|
|
113
|
+
description: "要同步的 props 键"
|
|
114
|
+
}
|
|
115
|
+
], v = `// 把分页/搜索/排序同步进 URL(hash 或 search),链接可分享。
|
|
116
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
117
|
+
createURLSyncPlugin({
|
|
118
|
+
mode: "hash",
|
|
119
|
+
keys: ["pageIndex","pageSize","searchQuery"],
|
|
120
|
+
}),
|
|
121
|
+
]);
|
|
122
|
+
|
|
123
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, $ = [
|
|
124
|
+
"hash 模式会保留已有路由路径",
|
|
125
|
+
"用 replaceState,不污染后退栈",
|
|
126
|
+
"SSR 安全:无 window 时直接跳过"
|
|
127
|
+
], C = [
|
|
128
|
+
"搜索结果可分享",
|
|
129
|
+
"后台筛选状态可刷新",
|
|
130
|
+
"带参数的深链"
|
|
131
|
+
], I = [
|
|
132
|
+
"只做单向同步(props → URL)与初始读取;URL 前进后退的监听请页面自己做。"
|
|
133
|
+
], b = {
|
|
134
|
+
name: g,
|
|
135
|
+
description: S,
|
|
136
|
+
since: y,
|
|
137
|
+
tags: P,
|
|
138
|
+
events: R,
|
|
139
|
+
methods: L,
|
|
140
|
+
methodsNote: U,
|
|
141
|
+
config: x,
|
|
142
|
+
example: v,
|
|
143
|
+
features: $,
|
|
144
|
+
useCases: C,
|
|
145
|
+
notes: I
|
|
146
|
+
};
|
|
147
|
+
export {
|
|
148
|
+
E as c,
|
|
149
|
+
b as d
|
|
150
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as p } from "react/jsx-runtime";
|
|
2
2
|
const d = "GROUPS", y = "GROUP_INDEX";
|
|
3
|
-
function
|
|
4
|
-
const g =
|
|
5
|
-
let
|
|
3
|
+
function E(u = {}) {
|
|
4
|
+
const g = u.groupBy ?? ((e) => e?.category ?? "default"), h = u.showOverlay ?? !1;
|
|
5
|
+
let l = null, r = null;
|
|
6
6
|
const m = (e, n) => {
|
|
7
7
|
if (e.size !== n.size) return !1;
|
|
8
8
|
for (const [t, s] of e) {
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
9
|
+
const o = n.get(t);
|
|
10
|
+
if (!o || o.length !== s.length) return !1;
|
|
11
11
|
}
|
|
12
12
|
return !0;
|
|
13
13
|
}, i = (e) => {
|
|
14
14
|
const n = e.items ?? [];
|
|
15
|
-
if (
|
|
15
|
+
if (r && l === n) return r;
|
|
16
16
|
const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
17
|
-
n.forEach((
|
|
18
|
-
const a = g(
|
|
19
|
-
s.set(
|
|
17
|
+
n.forEach((f, c) => {
|
|
18
|
+
const a = g(f, c);
|
|
19
|
+
s.set(c, a), t.has(a) || t.set(a, []), t.get(a).push(c);
|
|
20
20
|
});
|
|
21
|
-
const
|
|
22
|
-
return
|
|
21
|
+
const o = r ? !m(t, r) : !0;
|
|
22
|
+
return l = n, r = t, e.sharedData.set(d, t), e.sharedData.set(y, s), o && t.size > 0 && e.bus.emit("grouping:change", { groups: t }), t;
|
|
23
23
|
};
|
|
24
24
|
return {
|
|
25
25
|
name: "GroupingPlugin",
|
|
@@ -35,11 +35,11 @@ function B(c = {}) {
|
|
|
35
35
|
i(e);
|
|
36
36
|
},
|
|
37
37
|
renderOverlay: (e) => {
|
|
38
|
-
if (!
|
|
38
|
+
if (!h) return null;
|
|
39
39
|
const n = e.sharedData.get(d) ?? /* @__PURE__ */ new Map();
|
|
40
40
|
if (n.size === 0) return null;
|
|
41
41
|
const t = Array.from(n.entries()).slice(0, 3);
|
|
42
|
-
return /* @__PURE__ */
|
|
42
|
+
return /* @__PURE__ */ p(
|
|
43
43
|
"div",
|
|
44
44
|
{
|
|
45
45
|
style: {
|
|
@@ -58,15 +58,15 @@ function B(c = {}) {
|
|
|
58
58
|
pointerEvents: "none"
|
|
59
59
|
},
|
|
60
60
|
children: [
|
|
61
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ p("div", { style: { opacity: 0.85, marginBottom: 6 }, children: [
|
|
62
62
|
"分组:",
|
|
63
63
|
n.size,
|
|
64
64
|
" 组"
|
|
65
65
|
] }),
|
|
66
|
-
t.map(([s,
|
|
66
|
+
t.map(([s, o]) => /* @__PURE__ */ p("div", { children: [
|
|
67
67
|
String(s),
|
|
68
68
|
" · ",
|
|
69
|
-
|
|
69
|
+
o.length,
|
|
70
70
|
" 项"
|
|
71
71
|
] }, String(s)))
|
|
72
72
|
]
|
|
@@ -76,10 +76,36 @@ function B(c = {}) {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
-
const
|
|
79
|
+
const w = "GroupingPlugin", v = "用 groupBy 把项按业务字段分组,结果放进 sharedData 的 `GROUPS`(Map<组键, 索引数组>),供 StickyHeaderPlugin、分组统计条等消费。挂载即算一次,之后 props 变化重算。", P = "2.0.0", O = [
|
|
80
80
|
"ui",
|
|
81
81
|
"分组"
|
|
82
|
-
],
|
|
82
|
+
], b = [
|
|
83
|
+
{
|
|
84
|
+
name: "onMount",
|
|
85
|
+
when: "瀑布流挂载完成",
|
|
86
|
+
description: "初始化观察器与滚动监听,返回清理函数"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "onPropsChange",
|
|
90
|
+
when: "props 变化后",
|
|
91
|
+
description: "数据或配置变化时请求重排"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "onLayoutComplete",
|
|
95
|
+
when: "DOM 落位完成(可安全测量)",
|
|
96
|
+
description: "测量真实高度、懒加载判定、曝光上报"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "renderOverlay",
|
|
100
|
+
when: "每次渲染,滚动容器内的内容层之上",
|
|
101
|
+
description: "回到顶部、加载提示、浮层工具"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "grouping:change",
|
|
105
|
+
when: "分组结果变化时",
|
|
106
|
+
description: "广播 { groups } 分组结构"
|
|
107
|
+
}
|
|
108
|
+
], G = [], x = "只读取 context 字段(props / state / data),不调用上下文方法", D = [
|
|
83
109
|
{
|
|
84
110
|
name: "groupBy",
|
|
85
111
|
type: "(item, index) => string | number",
|
|
@@ -92,7 +118,7 @@ const P = "GroupingPlugin", b = "用 groupBy 把项按业务字段分组,结
|
|
|
92
118
|
default: "false",
|
|
93
119
|
description: "是否显示分组统计角标"
|
|
94
120
|
}
|
|
95
|
-
],
|
|
121
|
+
], C = `// 按字段把项分组,结果写进 sharedData(GROUPS) 供吸顶条 / 统计用。
|
|
96
122
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
97
123
|
createGroupingPlugin({
|
|
98
124
|
groupBy: "item.category ?? \\"default\\"",
|
|
@@ -100,28 +126,31 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
100
126
|
}),
|
|
101
127
|
]);
|
|
102
128
|
|
|
103
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
129
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, M = [
|
|
104
130
|
"挂载即计算(旧版只在 props 变化时算,首屏永远拿不到分组)",
|
|
105
131
|
"结果写 sharedData,跨插件可读",
|
|
106
132
|
"统计角标默认关闭"
|
|
107
|
-
],
|
|
133
|
+
], S = [
|
|
108
134
|
"按分类分组的信息流",
|
|
109
135
|
"按日期分组的时间线",
|
|
110
136
|
"吸顶条显示当前分组"
|
|
111
|
-
],
|
|
137
|
+
], z = [
|
|
112
138
|
"分组只产出索引映射,不改变渲染顺序;要视觉分组请自己按分组建行。"
|
|
113
|
-
],
|
|
114
|
-
name:
|
|
115
|
-
description:
|
|
116
|
-
since:
|
|
117
|
-
tags:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
139
|
+
], I = {
|
|
140
|
+
name: w,
|
|
141
|
+
description: v,
|
|
142
|
+
since: P,
|
|
143
|
+
tags: O,
|
|
144
|
+
events: b,
|
|
145
|
+
methods: G,
|
|
146
|
+
methodsNote: x,
|
|
147
|
+
config: D,
|
|
148
|
+
example: C,
|
|
149
|
+
features: M,
|
|
150
|
+
useCases: S,
|
|
151
|
+
notes: z
|
|
123
152
|
};
|
|
124
153
|
export {
|
|
125
|
-
|
|
126
|
-
|
|
154
|
+
E as c,
|
|
155
|
+
I as d
|
|
127
156
|
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
function
|
|
2
|
-
const c = s.storageKey || "waterfall-bookmark", l = s.scrollBehavior || "smooth",
|
|
3
|
-
const o =
|
|
1
|
+
function x(s = {}) {
|
|
2
|
+
const c = s.storageKey || "waterfall-bookmark", l = s.scrollBehavior || "smooth", m = (a) => {
|
|
3
|
+
const o = a;
|
|
4
4
|
if (!o) return !1;
|
|
5
|
-
const n = o.tagName?.toLowerCase(),
|
|
6
|
-
return n === "input" || n === "textarea" ||
|
|
5
|
+
const n = o.tagName?.toLowerCase(), r = (o.getAttribute && o.getAttribute("contenteditable")) === "true";
|
|
6
|
+
return n === "input" || n === "textarea" || r;
|
|
7
7
|
};
|
|
8
8
|
return {
|
|
9
9
|
name: "BookmarkPlugin",
|
|
10
10
|
enabled: !0,
|
|
11
11
|
hooks: {
|
|
12
|
-
onMount: (
|
|
12
|
+
onMount: (a) => {
|
|
13
13
|
const o = (n) => {
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
const e =
|
|
14
|
+
if (m(n.target)) return;
|
|
15
|
+
const r = (n.key || "").toLowerCase(), i = n.code || "";
|
|
16
|
+
if (r === "b" || i === "KeyB") {
|
|
17
|
+
const e = a.containerRef?.current || null;
|
|
18
18
|
let t = 0;
|
|
19
19
|
e && e.scrollHeight > e.clientHeight ? t = e.scrollTop : t = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
20
20
|
try {
|
|
21
21
|
localStorage.setItem(c, String(Math.max(0, t)));
|
|
22
22
|
} catch {
|
|
23
23
|
}
|
|
24
|
-
} else if (
|
|
24
|
+
} else if (r === "r" || i === "KeyR") {
|
|
25
25
|
let e = 0;
|
|
26
26
|
try {
|
|
27
|
-
const
|
|
28
|
-
e = Math.max(0, Number(
|
|
27
|
+
const u = localStorage.getItem(c) || "0";
|
|
28
|
+
e = Math.max(0, Number(u) || 0);
|
|
29
29
|
} catch {
|
|
30
30
|
}
|
|
31
|
-
const t =
|
|
31
|
+
const t = a.containerRef?.current || null;
|
|
32
32
|
t && t.scrollHeight > t.clientHeight ? t.scrollTo({ top: e, behavior: l }) : window.scrollTo({ top: e, behavior: l });
|
|
33
33
|
}
|
|
34
34
|
};
|
|
@@ -39,11 +39,17 @@ function B(s = {}) {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const d = "BookmarkPlugin", g = "长列表读到一半要跳走时按 **B** 存位置,回来按 **R** 复原。焦点在输入框/可编辑区域时不拦截按键。", h = "2.0.0", f = [
|
|
43
43
|
"ui",
|
|
44
44
|
"滚动",
|
|
45
45
|
"快捷键"
|
|
46
|
-
],
|
|
46
|
+
], p = [
|
|
47
|
+
{
|
|
48
|
+
name: "onMount",
|
|
49
|
+
when: "瀑布流挂载完成",
|
|
50
|
+
description: "初始化观察器与滚动监听,返回清理函数"
|
|
51
|
+
}
|
|
52
|
+
], k = [], w = "只读取 context 字段(props / state / data),不调用上下文方法", y = [
|
|
47
53
|
{
|
|
48
54
|
name: "storageKey",
|
|
49
55
|
type: "string",
|
|
@@ -56,7 +62,7 @@ const g = "BookmarkPlugin", d = "长列表读到一半要跳走时按 **B** 存
|
|
|
56
62
|
default: '"smooth"',
|
|
57
63
|
description: "恢复时的滚动行为"
|
|
58
64
|
}
|
|
59
|
-
],
|
|
65
|
+
], b = `// 按 B 记录滚动位置、按 R 跳回(localStorage),忽略输入框按键。
|
|
60
66
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
61
67
|
createBookmarkPlugin({
|
|
62
68
|
storageKey: "waterfall-bookmark",
|
|
@@ -64,28 +70,31 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
64
70
|
}),
|
|
65
71
|
]);
|
|
66
72
|
|
|
67
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
73
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, B = [
|
|
68
74
|
"B 存 / R 取,零 UI 侵入",
|
|
69
75
|
"自动区分容器滚动与页面滚动",
|
|
70
76
|
"输入框内不误触"
|
|
71
|
-
],
|
|
77
|
+
], v = [
|
|
72
78
|
"长文列表阅读",
|
|
73
79
|
"后台大表格浏览",
|
|
74
80
|
"演示时快速复位"
|
|
75
|
-
],
|
|
81
|
+
], K = [
|
|
76
82
|
"键名全局共用,一个页面里多处瀑布流请各自传不同的 storageKey。"
|
|
77
|
-
],
|
|
78
|
-
name:
|
|
79
|
-
description:
|
|
80
|
-
since:
|
|
81
|
-
tags:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
], C = {
|
|
84
|
+
name: d,
|
|
85
|
+
description: g,
|
|
86
|
+
since: h,
|
|
87
|
+
tags: f,
|
|
88
|
+
events: p,
|
|
89
|
+
methods: k,
|
|
90
|
+
methodsNote: w,
|
|
91
|
+
config: y,
|
|
92
|
+
example: b,
|
|
93
|
+
features: B,
|
|
94
|
+
useCases: v,
|
|
95
|
+
notes: K
|
|
87
96
|
};
|
|
88
97
|
export {
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
x as c,
|
|
99
|
+
C as d
|
|
91
100
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
function
|
|
2
|
-
const r = new Set(s.pinnedIndices),
|
|
1
|
+
function v(s) {
|
|
2
|
+
const r = new Set(s.pinnedIndices), n = Math.max(0, s.column ?? 0), e = /* @__PURE__ */ new Map();
|
|
3
3
|
return {
|
|
4
4
|
name: "PinItemPlugin",
|
|
5
5
|
priority: 100,
|
|
6
6
|
enabled: !0,
|
|
7
7
|
hooks: {
|
|
8
|
-
onBeforeLayout: () => (
|
|
9
|
-
calculateItemPosition: (i,
|
|
10
|
-
const
|
|
11
|
-
if (!r.has(
|
|
12
|
-
const o =
|
|
8
|
+
onBeforeLayout: () => (e.clear(), !0),
|
|
9
|
+
calculateItemPosition: (i, l, c, t) => {
|
|
10
|
+
const m = i.props.rowGap ?? i.props.gap ?? 0;
|
|
11
|
+
if (!r.has(l)) {
|
|
12
|
+
const o = e.get(t.column);
|
|
13
13
|
return o !== void 0 && t.y < o ? { y: o } : void 0;
|
|
14
14
|
}
|
|
15
|
-
const a =
|
|
16
|
-
return
|
|
17
|
-
column:
|
|
15
|
+
const a = e.get(n) ?? 0;
|
|
16
|
+
return e.set(n, a + c + m), {
|
|
17
|
+
column: n,
|
|
18
18
|
y: a,
|
|
19
19
|
width: t.width,
|
|
20
20
|
height: c,
|
|
@@ -24,11 +24,22 @@ function w(s) {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const u = "PinItemPlugin", d = "把若干索引的项钉在顶部指定列,其余项从它们下方继续排。走 D1-A 布局钩子(calculateItemPosition),是旧版宣称但从未生效的能力。", p = "2.0.0", f = [
|
|
28
28
|
"layout",
|
|
29
29
|
"layout-hook",
|
|
30
30
|
"置顶"
|
|
31
|
-
],
|
|
31
|
+
], h = [
|
|
32
|
+
{
|
|
33
|
+
name: "onBeforeLayout",
|
|
34
|
+
when: "开始一次布局之前",
|
|
35
|
+
description: "返回 false 可阻止本次布局(如数据仍在加载)"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "calculateItemPosition",
|
|
39
|
+
when: "每个卡片参与布局时(拿到 index / item / columns)",
|
|
40
|
+
description: "返回坐标片段可覆盖列分配结果(置顶、跨列、错位)"
|
|
41
|
+
}
|
|
42
|
+
], g = [], I = "只读取 context 字段(props / state / data),不调用上下文方法", P = [
|
|
32
43
|
{
|
|
33
44
|
name: "pinnedIndices",
|
|
34
45
|
type: "number[]",
|
|
@@ -41,7 +52,7 @@ const m = "PinItemPlugin", d = "把若干索引的项钉在顶部指定列,其
|
|
|
41
52
|
default: "0",
|
|
42
53
|
description: "钉到第几列"
|
|
43
54
|
}
|
|
44
|
-
],
|
|
55
|
+
], y = `// 把指定索引的项钉在顶部同一列,不参与常规列高推进(广告位 / 公告卡)。
|
|
45
56
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
46
57
|
createPinItemPlugin({
|
|
47
58
|
pinnedIndices: [],
|
|
@@ -49,30 +60,33 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
49
60
|
}),
|
|
50
61
|
]);
|
|
51
62
|
|
|
52
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
63
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, w = [
|
|
53
64
|
"置顶项不占常规列高:后续项从置顶块下方开始",
|
|
54
65
|
"支持多列分别置顶(column 可不同)",
|
|
55
66
|
"每次布局前重置偏移,items 变化后不会累加错位"
|
|
56
|
-
],
|
|
67
|
+
], x = [
|
|
57
68
|
"信息流首位的推广卡",
|
|
58
69
|
"公告 / 置顶帖",
|
|
59
70
|
"需要固定在左上角的活动位"
|
|
60
|
-
],
|
|
71
|
+
], C = [
|
|
61
72
|
"置顶项之间按 pinnedIndices 顺序纵向堆叠,同一列多条会依次往下排。",
|
|
62
73
|
"置顶会挤掉该列的正常网格位置,pinnedIndices 建议控制在 1~2 条。",
|
|
63
74
|
"换列后的 x 由布局引擎按本轮列宽补齐,插件只返回 column 即可 —— 自己用「列宽 + 间距」反推 x 会在间距由其它插件(GapPlugin)注入时算错。"
|
|
64
|
-
],
|
|
65
|
-
name:
|
|
75
|
+
], B = {
|
|
76
|
+
name: u,
|
|
66
77
|
description: d,
|
|
67
78
|
since: p,
|
|
68
79
|
tags: f,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
events: h,
|
|
81
|
+
methods: g,
|
|
82
|
+
methodsNote: I,
|
|
83
|
+
config: P,
|
|
84
|
+
example: y,
|
|
85
|
+
features: w,
|
|
86
|
+
useCases: x,
|
|
87
|
+
notes: C
|
|
74
88
|
};
|
|
75
89
|
export {
|
|
76
|
-
|
|
77
|
-
|
|
90
|
+
v as c,
|
|
91
|
+
B as d
|
|
78
92
|
};
|