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