vane-waterfall 2.0.1 → 2.0.2
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-kTbJE7rY.js → doc-BCmEnh39.js} +31 -29
- package/dist/chunks/doc-BQQoKNto.js +126 -0
- package/dist/chunks/{doc-j4W9SUrY.js → doc-BSnWbrkH.js} +39 -27
- package/dist/chunks/{doc-BCGQ8Cp5.js → doc-BXaJl1By.js} +54 -41
- package/dist/chunks/{doc-CraXjOaA.js → doc-BindRMfO.js} +30 -26
- package/dist/chunks/{doc-78xF08vt.js → doc-BmoijI6q.js} +35 -35
- package/dist/chunks/{doc-BtzhgTYj.js → doc-CN4edvn_.js} +27 -27
- package/dist/chunks/{doc-NhL4Ux8q.js → doc-CkU5GtLw.js} +65 -54
- package/dist/chunks/doc-DAieSXLy.js +86 -0
- package/dist/chunks/{doc-BP0DmB7-.js → doc-D_ozEn0Q.js} +27 -27
- package/dist/chunks/{doc-f4Uijujv.js → doc-KN6Bvmty.js} +54 -32
- package/dist/chunks/{doc-B6kLfMPv.js → doc-a0MK2S3n.js} +61 -40
- package/dist/chunks/{index-COaun3nf.js → index-B8o6R4RZ.js} +2 -2
- package/dist/chunks/{index-DXAtA2f6.js → index-BFyYpEY_.js} +2 -2
- package/dist/chunks/{index-wLI6UXkY.js → index-CF0tYRop.js} +1 -1
- package/dist/chunks/{index-gjoCq0yC.js → index-CJR0Buju.js} +4 -4
- package/dist/chunks/{index-DsRLmBW-.js → index-DHTB3QEP.js} +3 -3
- package/dist/chunks/withPlugins-DG3YpSgL.js +655 -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/index.js +1 -1
- package/dist/custom-plugins/BookmarkPlugin/create.d.ts.map +1 -1
- 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/index.js +1 -1
- package/dist/custom-plugins/GapPlugin/create.d.ts.map +1 -1
- 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/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/index.js +1 -1
- package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts.map +1 -1
- 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/index.js +1 -1
- package/dist/custom-plugins/RecyclePlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/RecyclePlugin/index.js +1 -1
- package/dist/custom-plugins/StatePersistencePlugin/create.d.ts.map +1 -1
- 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/index.js +1 -1
- package/dist/custom-plugins/URLSyncPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/URLSyncPlugin/index.js +1 -1
- package/dist/custom-plugins/index.js +5 -5
- package/dist/entries/core.js +1 -1
- package/dist/entries/plugins.js +6 -6
- package/dist/index.js +2 -2
- package/dist/presets/dashboard/index.js +2 -2
- package/dist/presets/photo-feed/index.js +2 -2
- package/dist/presets/product-feed/index.js +1 -1
- package/package.json +31 -23
- package/dist/chunks/WaterfallCore-BSXw7bl_.js +0 -581
- package/dist/chunks/doc-B-7dugGv.js +0 -79
- package/dist/chunks/doc-DJjxOYzW.js +0 -111
- package/dist/chunks/withPlugins-DLoKg4AP.js +0 -559
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
let e = !1;
|
|
1
|
+
function y(t = {}) {
|
|
2
|
+
const s = Math.max(1, t.threshold ?? 300), n = /* @__PURE__ */ new WeakMap(), r = (e) => e.containerRef?.current ?? e.bus;
|
|
4
3
|
return {
|
|
5
4
|
name: "InfiniteScrollPlugin",
|
|
6
5
|
priority: 35,
|
|
7
6
|
enabled: !0,
|
|
8
7
|
hooks: {
|
|
9
|
-
transformProps: (
|
|
10
|
-
...
|
|
11
|
-
reachBottomOffset:
|
|
8
|
+
transformProps: (e) => ({
|
|
9
|
+
...e,
|
|
10
|
+
reachBottomOffset: s
|
|
12
11
|
}),
|
|
13
|
-
onReachBottom: async (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
onReachBottom: async (e, i) => {
|
|
13
|
+
const o = r(e);
|
|
14
|
+
if (n.get(o) || e.hasMore === !1 || i > s) return;
|
|
15
|
+
const a = t.onLoadMore ?? e.props.onLoadMore;
|
|
16
|
+
if (typeof a == "function") {
|
|
17
|
+
n.set(o, !0);
|
|
18
18
|
try {
|
|
19
|
-
await Promise.resolve(
|
|
19
|
+
await Promise.resolve(a());
|
|
20
20
|
} finally {
|
|
21
|
-
|
|
21
|
+
n.delete(o);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
onUnmount: () => {
|
|
26
|
-
e
|
|
25
|
+
onUnmount: (e) => {
|
|
26
|
+
n.delete(r(e));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const c = "InfiniteScrollPlugin", l = "监听 Core 的 onReachBottom,在距底部 `threshold` 像素内触发 onLoadMore。自带并发锁:上一次还没结束不会重复触发。", d = "2.0.0", f = [
|
|
32
32
|
"data",
|
|
33
33
|
"加载更多"
|
|
34
|
-
],
|
|
34
|
+
], u = [
|
|
35
35
|
{
|
|
36
36
|
name: "threshold",
|
|
37
37
|
type: "number",
|
|
@@ -44,39 +44,39 @@ const r = "InfiniteScrollPlugin", i = "监听 Core 的 onReachBottom,在距底
|
|
|
44
44
|
default: "props.onLoadMore",
|
|
45
45
|
description: "加载回调"
|
|
46
46
|
}
|
|
47
|
-
],
|
|
47
|
+
], m = `// 滚动到距底部阈值内触发加载更多,带并发锁防重复请求。
|
|
48
48
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
49
49
|
createInfiniteScrollPlugin({
|
|
50
50
|
threshold: 300,
|
|
51
51
|
}),
|
|
52
52
|
]);
|
|
53
53
|
|
|
54
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
54
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, p = [
|
|
55
55
|
"PaginationPlugin"
|
|
56
|
-
],
|
|
56
|
+
], h = [
|
|
57
57
|
"距底 300px 预加载,滚到底时数据已就位",
|
|
58
58
|
"并发锁:加载中不重复触发",
|
|
59
59
|
"context.hasMore 为 false 时自动停"
|
|
60
|
-
],
|
|
60
|
+
], g = [
|
|
61
61
|
"信息流无限滚动",
|
|
62
62
|
"画廊继续加载",
|
|
63
63
|
"搜索结果瀑布流"
|
|
64
|
-
],
|
|
64
|
+
], P = [
|
|
65
65
|
"阈值不要小于一屏(约 600px),否则用户滚到底会看到空白等待。",
|
|
66
66
|
"翻页类场景请用 PaginationPlugin,两者不要同装。"
|
|
67
|
-
],
|
|
68
|
-
name:
|
|
69
|
-
description:
|
|
70
|
-
since:
|
|
71
|
-
tags:
|
|
72
|
-
config:
|
|
73
|
-
example:
|
|
74
|
-
conflicts:
|
|
75
|
-
features:
|
|
76
|
-
useCases:
|
|
77
|
-
notes:
|
|
67
|
+
], M = {
|
|
68
|
+
name: c,
|
|
69
|
+
description: l,
|
|
70
|
+
since: d,
|
|
71
|
+
tags: f,
|
|
72
|
+
config: u,
|
|
73
|
+
example: m,
|
|
74
|
+
conflicts: p,
|
|
75
|
+
features: h,
|
|
76
|
+
useCases: g,
|
|
77
|
+
notes: P
|
|
78
78
|
};
|
|
79
79
|
export {
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
y as c,
|
|
81
|
+
M as d
|
|
82
82
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as c, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
function b(e = {}) {
|
|
3
|
+
const i = e.title || "分组标题", o = e.showHint ?? !1;
|
|
4
4
|
return {
|
|
5
5
|
name: "StickyHeaderPlugin",
|
|
6
6
|
enabled: !0,
|
|
7
7
|
hooks: {
|
|
8
|
-
renderOverlay: (
|
|
9
|
-
const
|
|
10
|
-
return /* @__PURE__ */
|
|
8
|
+
renderOverlay: (t) => {
|
|
9
|
+
const n = t.sharedData?.get("GROUPS") || /* @__PURE__ */ new Map(), a = t.sharedData?.get("GROUP_INDEX"), r = t.visibleRange?.start ?? 0, s = a?.get(r) ?? (n.size > 0 ? Array.from(n.keys())[0] : void 0);
|
|
10
|
+
return /* @__PURE__ */ c(
|
|
11
11
|
"div",
|
|
12
12
|
{
|
|
13
13
|
style: {
|
|
@@ -23,10 +23,10 @@ function h(t = {}) {
|
|
|
23
23
|
fontWeight: 600
|
|
24
24
|
},
|
|
25
25
|
children: [
|
|
26
|
-
|
|
26
|
+
i,
|
|
27
27
|
" ",
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
s !== void 0 ? `:${String(s)}` : "",
|
|
29
|
+
o ? /* @__PURE__ */ l("span", { style: { marginLeft: 8, fontSize: 12, opacity: 0.8 }, children: "向下滚动观察吸顶" }) : null
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
);
|
|
@@ -34,10 +34,10 @@ function h(t = {}) {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const d = "StickyHeaderPlugin", p = "在滚动容器内渲染一条 `position: sticky` 的标题条,始终贴住容器顶部。装了 GroupingPlugin 时自动显示第一个分组名,也可用 title 写死。", g = "2.0.0", f = [
|
|
38
38
|
"ui",
|
|
39
39
|
"吸顶"
|
|
40
|
-
],
|
|
40
|
+
], u = [
|
|
41
41
|
{
|
|
42
42
|
name: "title",
|
|
43
43
|
type: "string",
|
|
@@ -50,7 +50,7 @@ const c = "StickyHeaderPlugin", l = "在滚动容器内渲染一条 `position: s
|
|
|
50
50
|
default: "false",
|
|
51
51
|
description: "是否显示「向下滚动观察」提示"
|
|
52
52
|
}
|
|
53
|
-
],
|
|
53
|
+
], y = `// 滚动容器内的吸顶标题条,可与分组联动显示当前组。
|
|
54
54
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
55
55
|
createStickyHeaderPlugin({
|
|
56
56
|
title: "分组标题",
|
|
@@ -58,28 +58,28 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
58
58
|
}),
|
|
59
59
|
]);
|
|
60
60
|
|
|
61
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
61
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, m = [
|
|
62
62
|
"sticky 吸顶,不依赖额外容器",
|
|
63
63
|
"与 Grouping 联动显示当前组",
|
|
64
64
|
"提示文案默认关闭"
|
|
65
|
-
],
|
|
65
|
+
], h = [
|
|
66
66
|
"分组信息流",
|
|
67
67
|
"按日期分组的时间线",
|
|
68
68
|
"长列表的上下文提示"
|
|
69
|
-
],
|
|
69
|
+
], k = [
|
|
70
70
|
"sticky 生效要求它作为滚动容器的直接子元素——由 composeSlots 保证,单测已锁。"
|
|
71
|
-
],
|
|
72
|
-
name:
|
|
73
|
-
description:
|
|
74
|
-
since:
|
|
75
|
-
tags:
|
|
76
|
-
config:
|
|
77
|
-
example:
|
|
78
|
-
features:
|
|
79
|
-
useCases:
|
|
80
|
-
notes:
|
|
71
|
+
], H = {
|
|
72
|
+
name: d,
|
|
73
|
+
description: p,
|
|
74
|
+
since: g,
|
|
75
|
+
tags: f,
|
|
76
|
+
config: u,
|
|
77
|
+
example: y,
|
|
78
|
+
features: m,
|
|
79
|
+
useCases: h,
|
|
80
|
+
notes: k
|
|
81
81
|
};
|
|
82
82
|
export {
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
b as c,
|
|
84
|
+
H as d
|
|
85
85
|
};
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
|
|
1
|
+
function x(c = {}) {
|
|
2
|
+
const l = c.storageKey || "waterfall-state", u = c.persistScroll ?? !0, a = c.persistKeys || ["pageIndex", "pageSize", "searchQuery"];
|
|
3
|
+
let p = !1;
|
|
4
|
+
const f = 1, i = /* @__PURE__ */ new WeakSet(), S = (t) => t.containerRef?.current ?? t.bus;
|
|
5
|
+
function o() {
|
|
5
6
|
try {
|
|
6
|
-
const
|
|
7
|
-
|
|
7
|
+
const t = localStorage.getItem(l);
|
|
8
|
+
if (!t) return null;
|
|
9
|
+
const e = JSON.parse(t);
|
|
10
|
+
return !e || e.version !== f || typeof e.state != "object" ? null : e.state;
|
|
8
11
|
} catch {
|
|
9
12
|
return null;
|
|
10
13
|
}
|
|
11
14
|
}
|
|
12
|
-
function
|
|
15
|
+
function d(t) {
|
|
13
16
|
try {
|
|
14
|
-
localStorage.setItem(
|
|
17
|
+
localStorage.setItem(l, JSON.stringify({ version: f, state: t }));
|
|
15
18
|
} catch {
|
|
16
19
|
}
|
|
17
20
|
}
|
|
@@ -20,56 +23,64 @@ function K(o = {}) {
|
|
|
20
23
|
enabled: !0,
|
|
21
24
|
hooks: {
|
|
22
25
|
// 首次渲染时,尽量将本地快照中的分页/查询键注入到 props,便于核心按恢复后的状态渲染
|
|
23
|
-
transformProps: (
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
const n = { ...
|
|
26
|
+
transformProps: (t) => {
|
|
27
|
+
if (p) return t;
|
|
28
|
+
const e = o();
|
|
29
|
+
if (!e) return t;
|
|
30
|
+
const n = { ...t };
|
|
28
31
|
let s = !1;
|
|
29
32
|
return a.forEach((r) => {
|
|
30
|
-
|
|
31
|
-
}), s && (
|
|
33
|
+
e[r] !== void 0 && (n[r] = e[r], s = !0);
|
|
34
|
+
}), s && (p = !0), n;
|
|
32
35
|
},
|
|
33
|
-
onMount: (
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
36
|
-
if (l) {
|
|
37
|
-
const s = Number(t.scrollTop ?? 0), r = e.containerRef.current;
|
|
38
|
-
r ? r.scrollTo({ top: s, behavior: "auto" }) : e.scrollToTop?.({ behavior: "auto" });
|
|
39
|
-
}
|
|
36
|
+
onMount: (t) => {
|
|
37
|
+
const e = o();
|
|
38
|
+
if (!e) return;
|
|
40
39
|
const n = {};
|
|
41
40
|
if (a.forEach((s) => {
|
|
42
|
-
|
|
43
|
-
}), Object.keys(n).length > 0 && (
|
|
41
|
+
e[s] !== void 0 && (n[s] = e[s]);
|
|
42
|
+
}), Object.keys(n).length > 0 && (t.bus?.emit("state:restored", n), typeof window < "u"))
|
|
44
43
|
try {
|
|
45
44
|
window.dispatchEvent(new CustomEvent("waterfall:state-restored", { detail: n }));
|
|
46
45
|
} catch {
|
|
47
46
|
}
|
|
48
47
|
},
|
|
48
|
+
onLayoutComplete: (t) => {
|
|
49
|
+
if (!u) return;
|
|
50
|
+
const e = S(t);
|
|
51
|
+
if (i.has(e)) return;
|
|
52
|
+
const n = o(), s = Number(n?.scrollTop ?? 0);
|
|
53
|
+
if (!Number.isFinite(s) || s <= 0) {
|
|
54
|
+
i.add(e);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const r = t.containerRef.current;
|
|
58
|
+
r && (r.scrollTo({ top: s, behavior: "auto" }), i.add(e));
|
|
59
|
+
},
|
|
49
60
|
// props 变化时,增量更新快照(立即持久化分页/查询键)
|
|
50
|
-
onPropsChange: (
|
|
51
|
-
const r = { ...
|
|
52
|
-
a.forEach((
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
}),
|
|
61
|
+
onPropsChange: (t, e, n) => {
|
|
62
|
+
const r = { ...o() || {} }, m = n ?? {};
|
|
63
|
+
a.forEach((g) => {
|
|
64
|
+
const y = m[g];
|
|
65
|
+
y !== void 0 && (r[g] = y);
|
|
66
|
+
}), d(r);
|
|
56
67
|
},
|
|
57
|
-
onUnmount: (
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
const n =
|
|
68
|
+
onUnmount: (t) => {
|
|
69
|
+
const e = {};
|
|
70
|
+
u && (e.scrollTop = t.containerRef.current?.scrollTop || 0);
|
|
71
|
+
const n = t.props ?? {};
|
|
61
72
|
a.forEach((s) => {
|
|
62
73
|
const r = n[s];
|
|
63
|
-
r !== void 0 && (
|
|
64
|
-
}),
|
|
74
|
+
r !== void 0 && (e[s] = r);
|
|
75
|
+
}), d(e);
|
|
65
76
|
}
|
|
66
77
|
}
|
|
67
78
|
};
|
|
68
79
|
}
|
|
69
|
-
const
|
|
80
|
+
const h = "StatePersistencePlugin", w = "三个时机各做一件事:首次渲染把快照里的 pageIndex / searchQuery 注入 props;挂载后恢复 scrollTop;props 变化与卸载时写回快照。刷新页面不丢进度。", v = "2.0.0", P = [
|
|
70
81
|
"ui",
|
|
71
82
|
"持久化"
|
|
72
|
-
],
|
|
83
|
+
], b = [
|
|
73
84
|
{
|
|
74
85
|
name: "storageKey",
|
|
75
86
|
type: "string",
|
|
@@ -88,7 +99,7 @@ const y = "StatePersistencePlugin", m = "三个时机各做一件事:首次渲
|
|
|
88
99
|
default: '["pageIndex","pageSize","searchQuery"]',
|
|
89
100
|
description: "要持久化的 props 键"
|
|
90
101
|
}
|
|
91
|
-
],
|
|
102
|
+
], I = `// 把滚动位置与分页/查询状态存 localStorage,回来时恢复。
|
|
92
103
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
93
104
|
createStatePersistencePlugin({
|
|
94
105
|
storageKey: "waterfall-state",
|
|
@@ -97,29 +108,29 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
97
108
|
}),
|
|
98
109
|
]);
|
|
99
110
|
|
|
100
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
111
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, C = [
|
|
101
112
|
"滚动位置 + 分页/查询一起存",
|
|
102
113
|
"首帧注入只做一次,不会覆盖用户操作",
|
|
103
114
|
"SSR / 隐私模式下降级为不持久化"
|
|
104
|
-
],
|
|
115
|
+
], E = [
|
|
105
116
|
"后台列表刷新不丢页",
|
|
106
117
|
"搜索结果返回定位",
|
|
107
118
|
"移动端来回切换页面"
|
|
108
|
-
],
|
|
119
|
+
], K = [
|
|
109
120
|
"只能恢复「值」,不能替你把它写回 React state——页面应订阅 `state:restored` 事件或读 bus。",
|
|
110
121
|
"localStorage 不可用(隐私模式/配额满)时静默跳过,不会抛错。"
|
|
111
|
-
],
|
|
112
|
-
name:
|
|
113
|
-
description:
|
|
114
|
-
since:
|
|
115
|
-
tags:
|
|
116
|
-
config:
|
|
117
|
-
example:
|
|
118
|
-
features:
|
|
119
|
-
useCases:
|
|
120
|
-
notes:
|
|
122
|
+
], R = {
|
|
123
|
+
name: h,
|
|
124
|
+
description: w,
|
|
125
|
+
since: v,
|
|
126
|
+
tags: P,
|
|
127
|
+
config: b,
|
|
128
|
+
example: I,
|
|
129
|
+
features: C,
|
|
130
|
+
useCases: E,
|
|
131
|
+
notes: K
|
|
121
132
|
};
|
|
122
133
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
x as c,
|
|
135
|
+
R as d
|
|
125
136
|
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
function T(r = {}) {
|
|
2
|
+
return {
|
|
3
|
+
name: "PaginationPlugin",
|
|
4
|
+
priority: 10,
|
|
5
|
+
enabled: !0,
|
|
6
|
+
hooks: {
|
|
7
|
+
transformProps: (n) => {
|
|
8
|
+
const a = Number(n.pageIndex ?? 1), e = Math.max(
|
|
9
|
+
1,
|
|
10
|
+
Math.floor(Number.isFinite(a) ? a : 1)
|
|
11
|
+
), t = Number(n.pageSize ?? r.pageSize ?? 20), o = Math.max(1, Math.floor(Number.isFinite(t) ? t : 20)), l = Array.isArray(n.items) ? n.items : [], s = Math.max(1, Math.ceil(l.length / o)), i = Math.min(e, s);
|
|
12
|
+
e > s && console.warn(
|
|
13
|
+
`[vane-waterfall] PaginationPlugin:pageIndex=${e} 超出总页数 ${s},已钳制到第 ${i} 页`
|
|
14
|
+
);
|
|
15
|
+
const c = (i - 1) * o, p = l.slice(c, c + o);
|
|
16
|
+
return { ...n, items: p };
|
|
17
|
+
},
|
|
18
|
+
onPropsChange: (n, a, e) => {
|
|
19
|
+
const t = Math.max(1, Number(a?.pageIndex ?? 1)), o = Math.max(1, Number(e?.pageIndex ?? 1));
|
|
20
|
+
if (((typeof e?.scrollToTopOnPageChange == "boolean" ? e.scrollToTopOnPageChange : void 0) ?? !!r.scrollToTop) && t !== o) {
|
|
21
|
+
const i = e?.scrollToTopBehavior ?? r.scrollBehavior ?? "auto";
|
|
22
|
+
n.scrollToTop?.({ behavior: i });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const g = "PaginationPlugin", m = "读 `props.pageIndex`(1 基)与 `props.pageSize` 切片。放在数据管线最末端,保证切的是「过滤 + 排序 + 搜索」之后的结果。", u = "2.0.0", d = [
|
|
29
|
+
"data",
|
|
30
|
+
"数据管线",
|
|
31
|
+
"分页"
|
|
32
|
+
], h = [
|
|
33
|
+
{
|
|
34
|
+
name: "pageSize",
|
|
35
|
+
type: "number",
|
|
36
|
+
default: "props.pageSize ?? 20",
|
|
37
|
+
description: "每页条数"
|
|
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
|
+
], f = `// 按 props.pageIndex / pageSize 切片,页码从 1 开始。
|
|
52
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
53
|
+
createPaginationPlugin({
|
|
54
|
+
scrollToTop: false,
|
|
55
|
+
scrollBehavior: "auto",
|
|
56
|
+
}),
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, x = [
|
|
60
|
+
"InfiniteScrollPlugin"
|
|
61
|
+
], P = [
|
|
62
|
+
"1 基页码(与 UI 分页器一致)",
|
|
63
|
+
"pageIndex 非法值自动夹到 1",
|
|
64
|
+
"翻页自动回顶可选"
|
|
65
|
+
], S = [
|
|
66
|
+
"后台列表分页",
|
|
67
|
+
"搜索结果分页",
|
|
68
|
+
"与 URLSyncPlugin 配合做可分享链接"
|
|
69
|
+
], I = [
|
|
70
|
+
"pageSize 优先级:props.pageSize > 工厂 config.pageSize > 20。"
|
|
71
|
+
], b = {
|
|
72
|
+
name: g,
|
|
73
|
+
description: m,
|
|
74
|
+
since: u,
|
|
75
|
+
tags: d,
|
|
76
|
+
config: h,
|
|
77
|
+
example: f,
|
|
78
|
+
conflicts: x,
|
|
79
|
+
features: P,
|
|
80
|
+
useCases: S,
|
|
81
|
+
notes: I
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
T as c,
|
|
85
|
+
b as d
|
|
86
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
function
|
|
1
|
+
function B(s = {}) {
|
|
2
2
|
const c = s.storageKey || "waterfall-bookmark", l = s.scrollBehavior || "smooth", u = (r) => {
|
|
3
|
-
const
|
|
4
|
-
if (!
|
|
5
|
-
const n =
|
|
3
|
+
const o = r;
|
|
4
|
+
if (!o) return !1;
|
|
5
|
+
const n = o.tagName?.toLowerCase(), a = (o.getAttribute && o.getAttribute("contenteditable")) === "true";
|
|
6
6
|
return n === "input" || n === "textarea" || a;
|
|
7
7
|
};
|
|
8
8
|
return {
|
|
@@ -10,40 +10,40 @@ function v(s = {}) {
|
|
|
10
10
|
enabled: !0,
|
|
11
11
|
hooks: {
|
|
12
12
|
onMount: (r) => {
|
|
13
|
-
const
|
|
13
|
+
const o = (n) => {
|
|
14
14
|
if (u(n.target)) return;
|
|
15
15
|
const a = (n.key || "").toLowerCase(), i = n.code || "";
|
|
16
16
|
if (a === "b" || i === "KeyB") {
|
|
17
|
-
const
|
|
18
|
-
let
|
|
19
|
-
|
|
17
|
+
const e = r.containerRef?.current || null;
|
|
18
|
+
let t = 0;
|
|
19
|
+
e && e.scrollHeight > e.clientHeight ? t = e.scrollTop : t = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
20
20
|
try {
|
|
21
|
-
localStorage.setItem(c, String(Math.max(0,
|
|
21
|
+
localStorage.setItem(c, String(Math.max(0, t)));
|
|
22
22
|
} catch {
|
|
23
23
|
}
|
|
24
24
|
} else if (a === "r" || i === "KeyR") {
|
|
25
|
-
let
|
|
25
|
+
let e = 0;
|
|
26
26
|
try {
|
|
27
|
-
const
|
|
28
|
-
|
|
27
|
+
const m = localStorage.getItem(c) || "0";
|
|
28
|
+
e = Math.max(0, Number(m) || 0);
|
|
29
29
|
} catch {
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const t = r.containerRef?.current || null;
|
|
32
|
+
t && t.scrollHeight > t.clientHeight ? t.scrollTo({ top: e, behavior: l }) : window.scrollTo({ top: e, behavior: l });
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
return window.addEventListener("keydown",
|
|
36
|
-
window.removeEventListener("keydown",
|
|
35
|
+
return window.addEventListener("keydown", o, { capture: !0 }), () => {
|
|
36
|
+
window.removeEventListener("keydown", o, { capture: !0 });
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const g = "BookmarkPlugin", d = "长列表读到一半要跳走时按 **B** 存位置,回来按 **R** 复原。焦点在输入框/可编辑区域时不拦截按键。", f = "2.0.0", h = [
|
|
43
43
|
"ui",
|
|
44
44
|
"滚动",
|
|
45
45
|
"快捷键"
|
|
46
|
-
],
|
|
46
|
+
], k = [
|
|
47
47
|
{
|
|
48
48
|
name: "storageKey",
|
|
49
49
|
type: "string",
|
|
@@ -56,7 +56,7 @@ const m = "BookmarkPlugin", g = "长列表读到一半要跳走时按 **B** 存
|
|
|
56
56
|
default: '"smooth"',
|
|
57
57
|
description: "恢复时的滚动行为"
|
|
58
58
|
}
|
|
59
|
-
],
|
|
59
|
+
], p = `// 按 B 记录滚动位置、按 R 跳回(localStorage),忽略输入框按键。
|
|
60
60
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
61
61
|
createBookmarkPlugin({
|
|
62
62
|
storageKey: "waterfall-bookmark",
|
|
@@ -74,18 +74,18 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
74
74
|
"演示时快速复位"
|
|
75
75
|
], b = [
|
|
76
76
|
"键名全局共用,一个页面里多处瀑布流请各自传不同的 storageKey。"
|
|
77
|
-
],
|
|
78
|
-
name:
|
|
79
|
-
description:
|
|
77
|
+
], v = {
|
|
78
|
+
name: g,
|
|
79
|
+
description: d,
|
|
80
80
|
since: f,
|
|
81
|
-
tags:
|
|
82
|
-
config:
|
|
83
|
-
example:
|
|
81
|
+
tags: h,
|
|
82
|
+
config: k,
|
|
83
|
+
example: p,
|
|
84
84
|
features: w,
|
|
85
85
|
useCases: y,
|
|
86
86
|
notes: b
|
|
87
87
|
};
|
|
88
88
|
export {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
B as c,
|
|
90
|
+
v as d
|
|
91
91
|
};
|