vane-waterfall 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +4 -4
  2. package/dist/chunks/WaterfallCore-EdAZuWAY.js +695 -0
  3. package/dist/chunks/doc-BAhVW3g8.js +150 -0
  4. package/dist/chunks/doc-BU0CKW63.js +156 -0
  5. package/dist/chunks/doc-BrEd0oZB.js +100 -0
  6. package/dist/chunks/{doc-bTHwfIVb.js → doc-Bud0hbaz.js} +39 -25
  7. package/dist/chunks/{doc-DukOmDCo.js → doc-C-B3zK2o.js} +52 -23
  8. package/dist/chunks/{doc-DElLNjIc.js → doc-C206ZwYC.js} +33 -24
  9. package/dist/chunks/doc-C2L8kkeI.js +112 -0
  10. package/dist/chunks/doc-CE1DGMBV.js +166 -0
  11. package/dist/chunks/{doc-BXSy2aPP.js → doc-CHbQXLwY.js} +33 -19
  12. package/dist/chunks/{doc-BfWnfTst.js → doc-CInpKZNU.js} +38 -24
  13. package/dist/chunks/{doc-gTAsLjVx.js → doc-CYxwSuG6.js} +30 -16
  14. package/dist/chunks/{doc-DzvTrZ13.js → doc-CaJ02INP.js} +25 -16
  15. package/dist/chunks/{doc-BXElhF2h.js → doc-CiCso5Ti.js} +44 -30
  16. package/dist/chunks/doc-CkuMr8Ca.js +118 -0
  17. package/dist/chunks/{doc-3Fpag2G8.js → doc-D7m1OFCW.js} +38 -24
  18. package/dist/chunks/doc-DEN2WTDh.js +153 -0
  19. package/dist/chunks/{doc-C5xrHNoC.js → doc-DhICh9S2.js} +37 -23
  20. package/dist/chunks/doc-DlJICsyN.js +100 -0
  21. package/dist/chunks/{doc-BtzhgTYj.js → doc-DtxS1-P0.js} +35 -26
  22. package/dist/chunks/{doc-BIzjYAZW.js → doc-DudYCn_-.js} +25 -16
  23. package/dist/chunks/doc-HoyAFR_m.js +101 -0
  24. package/dist/chunks/doc-RlBMCMNs.js +170 -0
  25. package/dist/chunks/doc-RwKQqySd.js +102 -0
  26. package/dist/chunks/{doc-CTUoMe7o.js → doc-eYhNJy97.js} +31 -22
  27. package/dist/chunks/{doc-CcPFavOs.js → doc-i6FY1We1.js} +27 -13
  28. package/dist/chunks/doc-skPl6ZMP.js +101 -0
  29. package/dist/chunks/index-8gEIzUxi.js +15 -0
  30. package/dist/chunks/index-B96I5CKE.js +21 -0
  31. package/dist/chunks/index-Bjmhy8jW.js +11 -0
  32. package/dist/chunks/index-Cuq0ofv-.js +13 -0
  33. package/dist/chunks/{index-BAWlVYr3.js → index-Cz4YEqRF.js} +1 -1
  34. package/dist/chunks/{index-wLI6UXkY.js → index-FBJVUYmH.js} +1 -1
  35. package/dist/chunks/withPlugins-BOeDFhof.js +743 -0
  36. package/dist/components/WaterfallPlugin/WaterfallCore.d.ts +19 -0
  37. package/dist/components/WaterfallPlugin/WaterfallCore.d.ts.map +1 -1
  38. package/dist/components/WaterfallPlugin/layout.d.ts +7 -0
  39. package/dist/components/WaterfallPlugin/layout.d.ts.map +1 -1
  40. package/dist/components/WaterfallPlugin/plugins/types.d.ts +3 -0
  41. package/dist/components/WaterfallPlugin/plugins/types.d.ts.map +1 -1
  42. package/dist/components/WaterfallPlugin/withPlugins.d.ts.map +1 -1
  43. package/dist/custom-plugins/A11yPlugin/create.d.ts.map +1 -1
  44. package/dist/custom-plugins/A11yPlugin/doc.json.d.ts +64 -40
  45. package/dist/custom-plugins/A11yPlugin/index.js +1 -1
  46. package/dist/custom-plugins/AlignmentPlugin/doc.json.d.ts +42 -28
  47. package/dist/custom-plugins/AlignmentPlugin/index.js +1 -1
  48. package/dist/custom-plugins/AutoColumnPlugin/doc.json.d.ts +53 -44
  49. package/dist/custom-plugins/AutoColumnPlugin/index.js +1 -1
  50. package/dist/custom-plugins/BookmarkPlugin/create.d.ts.map +1 -1
  51. package/dist/custom-plugins/BookmarkPlugin/doc.json.d.ts +44 -35
  52. package/dist/custom-plugins/BookmarkPlugin/index.js +1 -1
  53. package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts +2 -0
  54. package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts.map +1 -1
  55. package/dist/custom-plugins/ClickAnalyticsPlugin/doc.json.d.ts +29 -0
  56. package/dist/custom-plugins/ClickAnalyticsPlugin/index.js +1 -1
  57. package/dist/custom-plugins/DebounceLayoutPlugin/doc.json.d.ts +37 -28
  58. package/dist/custom-plugins/DebounceLayoutPlugin/index.js +1 -1
  59. package/dist/custom-plugins/DragReorderPlugin/doc.json.d.ts +14 -0
  60. package/dist/custom-plugins/DragReorderPlugin/index.js +1 -1
  61. package/dist/custom-plugins/FilterPlugin/doc.json.d.ts +53 -39
  62. package/dist/custom-plugins/FilterPlugin/index.js +1 -1
  63. package/dist/custom-plugins/FixedHeightPlugin/doc.json.d.ts +42 -28
  64. package/dist/custom-plugins/FixedHeightPlugin/index.js +1 -1
  65. package/dist/custom-plugins/GapPlugin/create.d.ts.map +1 -1
  66. package/dist/custom-plugins/GapPlugin/doc.json.d.ts +61 -37
  67. package/dist/custom-plugins/GapPlugin/index.js +1 -1
  68. package/dist/custom-plugins/GroupingPlugin/create.d.ts.map +1 -1
  69. package/dist/custom-plugins/GroupingPlugin/doc.json.d.ts +61 -32
  70. package/dist/custom-plugins/GroupingPlugin/index.js +1 -1
  71. package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts +2 -0
  72. package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts.map +1 -1
  73. package/dist/custom-plugins/HeatmapAnalyticsPlugin/doc.json.d.ts +24 -0
  74. package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.js +1 -1
  75. package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts.map +1 -1
  76. package/dist/custom-plugins/InfiniteScrollPlugin/doc.json.d.ts +55 -36
  77. package/dist/custom-plugins/InfiniteScrollPlugin/index.js +1 -1
  78. package/dist/custom-plugins/PaginationPlugin/create.d.ts.map +1 -1
  79. package/dist/custom-plugins/PaginationPlugin/doc.json.d.ts +56 -42
  80. package/dist/custom-plugins/PaginationPlugin/index.js +1 -1
  81. package/dist/custom-plugins/PinItemPlugin/doc.json.d.ts +49 -35
  82. package/dist/custom-plugins/PinItemPlugin/index.js +1 -1
  83. package/dist/custom-plugins/RecyclePlugin/create.d.ts.map +1 -1
  84. package/dist/custom-plugins/RecyclePlugin/doc.json.d.ts +57 -28
  85. package/dist/custom-plugins/RecyclePlugin/index.js +1 -1
  86. package/dist/custom-plugins/ReducedMotionPlugin/doc.json.d.ts +29 -0
  87. package/dist/custom-plugins/ReducedMotionPlugin/index.js +1 -1
  88. package/dist/custom-plugins/ResponsiveColumnsPlugin/doc.json.d.ts +40 -31
  89. package/dist/custom-plugins/ResponsiveColumnsPlugin/index.js +1 -1
  90. package/dist/custom-plugins/ScrollAnchorPlugin/doc.json.d.ts +42 -28
  91. package/dist/custom-plugins/ScrollAnchorPlugin/index.js +1 -1
  92. package/dist/custom-plugins/SearchPlugin/doc.json.d.ts +53 -39
  93. package/dist/custom-plugins/SearchPlugin/index.js +1 -1
  94. package/dist/custom-plugins/SortPlugin/doc.json.d.ts +52 -38
  95. package/dist/custom-plugins/SortPlugin/index.js +1 -1
  96. package/dist/custom-plugins/StatePersistencePlugin/create.d.ts.map +1 -1
  97. package/dist/custom-plugins/StatePersistencePlugin/doc.json.d.ts +71 -37
  98. package/dist/custom-plugins/StatePersistencePlugin/index.js +1 -1
  99. package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts.map +1 -1
  100. package/dist/custom-plugins/StickyHeaderPlugin/doc.json.d.ts +43 -34
  101. package/dist/custom-plugins/StickyHeaderPlugin/index.js +1 -1
  102. package/dist/custom-plugins/ThrottlePlugin/doc.json.d.ts +43 -34
  103. package/dist/custom-plugins/ThrottlePlugin/index.js +1 -1
  104. package/dist/custom-plugins/TransitionPlugin/doc.json.d.ts +49 -35
  105. package/dist/custom-plugins/TransitionPlugin/index.js +1 -1
  106. package/dist/custom-plugins/URLSyncPlugin/create.d.ts.map +1 -1
  107. package/dist/custom-plugins/URLSyncPlugin/doc.json.d.ts +57 -33
  108. package/dist/custom-plugins/URLSyncPlugin/index.js +1 -1
  109. package/dist/custom-plugins/index.js +6 -6
  110. package/dist/entries/core.js +1 -1
  111. package/dist/entries/plugins.js +7 -7
  112. package/dist/index.js +2 -2
  113. package/dist/presets/dashboard/index.js +2 -2
  114. package/dist/presets/photo-feed/index.js +3 -3
  115. package/dist/presets/product-feed/index.js +2 -2
  116. package/package.json +16 -8
  117. package/dist/chunks/WaterfallCore-BSXw7bl_.js +0 -581
  118. package/dist/chunks/doc-78xF08vt.js +0 -82
  119. package/dist/chunks/doc-B-7dugGv.js +0 -79
  120. package/dist/chunks/doc-B6kLfMPv.js +0 -121
  121. package/dist/chunks/doc-BCGQ8Cp5.js +0 -114
  122. package/dist/chunks/doc-BP0DmB7-.js +0 -91
  123. package/dist/chunks/doc-CBHjiDG7.js +0 -88
  124. package/dist/chunks/doc-CraXjOaA.js +0 -68
  125. package/dist/chunks/doc-DJjxOYzW.js +0 -111
  126. package/dist/chunks/doc-NhL4Ux8q.js +0 -125
  127. package/dist/chunks/doc-f4Uijujv.js +0 -102
  128. package/dist/chunks/doc-j4W9SUrY.js +0 -76
  129. package/dist/chunks/doc-kTbJE7rY.js +0 -92
  130. package/dist/chunks/index-COaun3nf.js +0 -15
  131. package/dist/chunks/index-DXAtA2f6.js +0 -11
  132. package/dist/chunks/index-DsRLmBW-.js +0 -13
  133. package/dist/chunks/index-gjoCq0yC.js +0 -21
  134. package/dist/chunks/withPlugins-DLoKg4AP.js +0 -559
@@ -1,25 +1,36 @@
1
- function y(s = {}) {
2
- const n = s.duration ?? 300, t = s.easing ?? "ease";
1
+ function P(s = {}) {
2
+ const t = s.duration ?? 300, n = s.easing ?? "ease";
3
3
  return {
4
4
  name: "TransitionPlugin",
5
5
  priority: 65,
6
6
  enabled: !0,
7
7
  hooks: {
8
- onItemMount: (o, e, i) => {
9
- i.style.transition = `transform ${n}ms ${t}, opacity ${n}ms ${t}`;
8
+ onItemMount: (o, e, a) => {
9
+ a.style.transition = `transform ${t}ms ${n}, opacity ${t}ms ${n}`;
10
10
  },
11
11
  onLayout: (o) => {
12
12
  o.itemRefs.forEach((e) => {
13
- e && (e.style.transition = `transform ${n}ms ${t}, opacity ${n}ms ${t}`);
13
+ e && (e.style.transition = `transform ${t}ms ${n}, opacity ${t}ms ${n}`);
14
14
  });
15
15
  }
16
16
  }
17
17
  };
18
18
  }
19
- const a = "TransitionPlugin", r = "给每个项挂上 transform + opacity 的 CSS 过渡,布局重排、分页切换、筛选后重新排列时位置变化是滑过去的,不是瞬移。", c = "2.0.0", u = [
19
+ const i = "TransitionPlugin", r = "给每个项挂上 transform + opacity 的 CSS 过渡,布局重排、分页切换、筛选后重新排列时位置变化是滑过去的,不是瞬移。", c = "2.0.0", m = [
20
20
  "perf",
21
21
  "动效"
22
- ], m = [
22
+ ], d = [
23
+ {
24
+ name: "onItemMount",
25
+ when: "单个卡片挂载并拿到 DOM 元素时",
26
+ description: "按卡片绑定监听、观察器、埋点"
27
+ },
28
+ {
29
+ name: "onLayout",
30
+ when: "布局计算完成、结果已确定",
31
+ description: "读取每列高度、做二次修正或上报"
32
+ }
33
+ ], u = [], l = "只读取 context 字段(props / state / data),不调用上下文方法", f = [
23
34
  {
24
35
  name: "duration",
25
36
  type: "number",
@@ -32,7 +43,7 @@ const a = "TransitionPlugin", r = "给每个项挂上 transform + opacity 的 CS
32
43
  default: "ease",
33
44
  description: "缓动函数"
34
45
  }
35
- ], d = `// 布局变化时给项加 transform/opacity 过渡,插入新数据不「闪现」。
46
+ ], p = `// 布局变化时给项加 transform/opacity 过渡,插入新数据不「闪现」。
36
47
  const Waterfall = withPlugins(WaterfallCore, [
37
48
  createTransitionPlugin({
38
49
  duration: 300,
@@ -40,31 +51,34 @@ const Waterfall = withPlugins(WaterfallCore, [
40
51
  }),
41
52
  ]);
42
53
 
43
- <Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, l = [
54
+ <Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, g = [
44
55
  "ReducedMotionPlugin"
45
- ], f = [
56
+ ], y = [
46
57
  "项位置变化平滑过渡",
47
58
  "挂载时即生效(onItemMount)",
48
59
  "与 ReducedMotionPlugin 互斥"
49
- ], g = [
60
+ ], h = [
50
61
  "筛选 / 排序后重排",
51
62
  "分页切换",
52
63
  "动态插入卡片"
53
- ], p = [
64
+ ], $ = [
54
65
  "首屏大量项同时过渡会有一次「整体滑入」,想要更克制可以把 duration 降到 150ms。"
55
- ], $ = {
56
- name: a,
66
+ ], x = {
67
+ name: i,
57
68
  description: r,
58
69
  since: c,
59
- tags: u,
60
- config: m,
61
- example: d,
62
- conflicts: l,
63
- features: f,
64
- useCases: g,
65
- notes: p
70
+ tags: m,
71
+ events: d,
72
+ methods: u,
73
+ methodsNote: l,
74
+ config: f,
75
+ example: p,
76
+ conflicts: g,
77
+ features: y,
78
+ useCases: h,
79
+ notes: $
66
80
  };
67
81
  export {
68
- y as c,
69
- $ as d
82
+ P as c,
83
+ x as d
70
84
  };
@@ -0,0 +1,100 @@
1
+ function v(r = {}) {
2
+ return {
3
+ name: "PaginationPlugin",
4
+ priority: 10,
5
+ enabled: !0,
6
+ hooks: {
7
+ transformProps: (o) => {
8
+ const a = Number(o.pageIndex ?? 1), e = Math.max(
9
+ 1,
10
+ Math.floor(Number.isFinite(a) ? a : 1)
11
+ ), t = Number(o.pageSize ?? r.pageSize ?? 20), n = Math.max(1, Math.floor(Number.isFinite(t) ? t : 20)), c = Array.isArray(o.items) ? o.items : [], s = Math.max(1, Math.ceil(c.length / n)), i = Math.min(e, s);
12
+ e > s && console.warn(
13
+ `[vane-waterfall] PaginationPlugin:pageIndex=${e} 超出总页数 ${s},已钳制到第 ${i} 页`
14
+ );
15
+ const l = (i - 1) * n, p = c.slice(l, l + n);
16
+ return { ...o, items: p };
17
+ },
18
+ onPropsChange: (o, a, e) => {
19
+ const t = Math.max(1, Number(a?.pageIndex ?? 1)), n = Math.max(1, Number(e?.pageIndex ?? 1));
20
+ if (((typeof e?.scrollToTopOnPageChange == "boolean" ? e.scrollToTopOnPageChange : void 0) ?? !!r.scrollToTop) && t !== n) {
21
+ const i = e?.scrollToTopBehavior ?? r.scrollBehavior ?? "auto";
22
+ o.scrollToTop?.({ behavior: i });
23
+ }
24
+ }
25
+ }
26
+ };
27
+ }
28
+ const g = "PaginationPlugin", m = "读 `props.pageIndex`(1 基)与 `props.pageSize` 切片。放在数据管线最末端,保证切的是「过滤 + 排序 + 搜索」之后的结果。", d = "2.0.0", u = [
29
+ "data",
30
+ "数据管线",
31
+ "分页"
32
+ ], h = [
33
+ {
34
+ name: "onPropsChange",
35
+ when: "props 变化后",
36
+ description: "数据或配置变化时请求重排"
37
+ },
38
+ {
39
+ name: "transformProps",
40
+ when: "渲染前链式改写瀑布流 props",
41
+ description: "补 gap / columns 默认值、按断点覆盖配置"
42
+ }
43
+ ], f = [], P = "只读取 context 字段(props / state / data),不调用上下文方法", x = [
44
+ {
45
+ name: "pageSize",
46
+ type: "number",
47
+ default: "props.pageSize ?? 20",
48
+ description: "每页条数"
49
+ },
50
+ {
51
+ name: "scrollToTop",
52
+ type: "boolean",
53
+ default: "false",
54
+ description: "翻页后回顶"
55
+ },
56
+ {
57
+ name: "scrollBehavior",
58
+ type: '"auto" | "smooth"',
59
+ default: '"auto"',
60
+ description: "回顶行为"
61
+ }
62
+ ], S = `// 按 props.pageIndex / pageSize 切片,页码从 1 开始。
63
+ const Waterfall = withPlugins(WaterfallCore, [
64
+ createPaginationPlugin({
65
+ scrollToTop: false,
66
+ scrollBehavior: "auto",
67
+ }),
68
+ ]);
69
+
70
+ <Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, I = [
71
+ "InfiniteScrollPlugin"
72
+ ], T = [
73
+ "1 基页码(与 UI 分页器一致)",
74
+ "pageIndex 非法值自动夹到 1",
75
+ "翻页自动回顶可选"
76
+ ], b = [
77
+ "后台列表分页",
78
+ "搜索结果分页",
79
+ "与 URLSyncPlugin 配合做可分享链接"
80
+ ], z = [
81
+ "pageSize 优先级:props.pageSize > 工厂 config.pageSize > 20。"
82
+ ], C = {
83
+ name: g,
84
+ description: m,
85
+ since: d,
86
+ tags: u,
87
+ events: h,
88
+ methods: f,
89
+ methodsNote: P,
90
+ config: x,
91
+ example: S,
92
+ conflicts: I,
93
+ features: T,
94
+ useCases: b,
95
+ notes: z
96
+ };
97
+ export {
98
+ v as c,
99
+ C as d
100
+ };
@@ -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 d } from "react/jsx-runtime";
2
+ function H(t = {}) {
3
+ const o = t.title || "分组标题", i = t.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: (e) => {
9
+ const n = e.sharedData?.get("GROUPS") || /* @__PURE__ */ new Map(), a = e.sharedData?.get("GROUP_INDEX"), r = e.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
+ o,
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
+ i ? /* @__PURE__ */ d("span", { style: { marginLeft: 8, fontSize: 12, opacity: 0.8 }, children: "向下滚动观察吸顶" }) : null
30
30
  ]
31
31
  }
32
32
  );
@@ -34,10 +34,16 @@ 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 l = "StickyHeaderPlugin", p = "在滚动容器内渲染一条 `position: sticky` 的标题条,始终贴住容器顶部。装了 GroupingPlugin 时自动显示第一个分组名,也可用 title 写死。", g = "2.0.0", m = [
38
38
  "ui",
39
39
  "吸顶"
40
40
  ], f = [
41
+ {
42
+ name: "renderOverlay",
43
+ when: "每次渲染,滚动容器内的内容层之上",
44
+ description: "回到顶部、加载提示、浮层工具"
45
+ }
46
+ ], u = [], y = "只读取 context 字段(props / state / data),不调用上下文方法", h = [
41
47
  {
42
48
  name: "title",
43
49
  type: "string",
@@ -50,7 +56,7 @@ const c = "StickyHeaderPlugin", l = "在滚动容器内渲染一条 `position: s
50
56
  default: "false",
51
57
  description: "是否显示「向下滚动观察」提示"
52
58
  }
53
- ], u = `// 滚动容器内的吸顶标题条,可与分组联动显示当前组。
59
+ ], x = `// 滚动容器内的吸顶标题条,可与分组联动显示当前组。
54
60
  const Waterfall = withPlugins(WaterfallCore, [
55
61
  createStickyHeaderPlugin({
56
62
  title: "分组标题",
@@ -58,28 +64,31 @@ const Waterfall = withPlugins(WaterfallCore, [
58
64
  }),
59
65
  ]);
60
66
 
61
- <Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, g = [
67
+ <Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, k = [
62
68
  "sticky 吸顶,不依赖额外容器",
63
69
  "与 Grouping 联动显示当前组",
64
70
  "提示文案默认关闭"
65
- ], m = [
71
+ ], v = [
66
72
  "分组信息流",
67
73
  "按日期分组的时间线",
68
74
  "长列表的上下文提示"
69
- ], y = [
75
+ ], S = [
70
76
  "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
77
+ ], P = {
78
+ name: l,
79
+ description: p,
80
+ since: g,
81
+ tags: m,
82
+ events: f,
83
+ methods: u,
84
+ methodsNote: y,
85
+ config: h,
86
+ example: x,
87
+ features: k,
88
+ useCases: v,
89
+ notes: S
81
90
  };
82
91
  export {
83
- h as c,
84
- k as d
92
+ H as c,
93
+ P as d
85
94
  };
@@ -1,50 +1,59 @@
1
- function d(e) {
1
+ function f(e) {
2
2
  return {
3
3
  name: "DebounceLayoutPlugin",
4
4
  priority: 75,
5
5
  enabled: !0,
6
6
  hooks: {
7
- transformProps: (n) => ({ ...n, debounceDelay: e.delay })
7
+ transformProps: (t) => ({ ...t, debounceDelay: e.delay })
8
8
  }
9
9
  };
10
10
  }
11
- const t = "DebounceLayoutPlugin", o = "只调 debounceDelay:容器宽度连续变化(抽屉展开、分栏拖拽)时,等变化停下来再算一次布局,避免每帧重排。", s = "2.0.0", a = [
11
+ const n = "DebounceLayoutPlugin", o = "只调 debounceDelay:容器宽度连续变化(抽屉展开、分栏拖拽)时,等变化停下来再算一次布局,避免每帧重排。", s = "2.0.0", a = [
12
12
  "perf",
13
13
  "性能"
14
14
  ], c = [
15
+ {
16
+ name: "transformProps",
17
+ when: "渲染前链式改写瀑布流 props",
18
+ description: "补 gap / columns 默认值、按断点覆盖配置"
19
+ }
20
+ ], r = [], u = "只读取 context 字段(props / state / data),不调用上下文方法", i = [
15
21
  {
16
22
  name: "delay",
17
23
  type: "number",
18
24
  default: "—",
19
25
  description: "布局防抖 ms(必填)"
20
26
  }
21
- ], r = `// 单独放大布局防抖,容器频繁变宽时(抽屉/侧栏动画)不抖。
27
+ ], l = `// 单独放大布局防抖,容器频繁变宽时(抽屉/侧栏动画)不抖。
22
28
  const Waterfall = withPlugins(WaterfallCore, [
23
29
  createDebounceLayoutPlugin(),
24
30
  ]);
25
31
 
26
- <Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, u = [
32
+ <Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, m = [
27
33
  "只影响布局时机,不影响渲染",
28
34
  "可被 ThrottlePlugin 覆盖",
29
35
  "对移动端软键盘弹出也有效"
30
- ], i = [
36
+ ], d = [
31
37
  "可折叠侧栏",
32
38
  "分栏宽度拖拽",
33
39
  "横竖屏切换"
34
- ], l = [
40
+ ], p = [
35
41
  "delay 过大会让「展开后布局」明显滞后,建议 120–250ms。"
36
- ], m = {
37
- name: t,
42
+ ], g = {
43
+ name: n,
38
44
  description: o,
39
45
  since: s,
40
46
  tags: a,
41
- config: c,
42
- example: r,
43
- features: u,
44
- useCases: i,
45
- notes: l
47
+ events: c,
48
+ methods: r,
49
+ methodsNote: u,
50
+ config: i,
51
+ example: l,
52
+ features: m,
53
+ useCases: d,
54
+ notes: p
46
55
  };
47
56
  export {
48
- d as c,
49
- m as d
57
+ f as c,
58
+ g as d
50
59
  };
@@ -0,0 +1,101 @@
1
+ function x(t = {}) {
2
+ const s = Math.max(1, t.threshold ?? 300), n = /* @__PURE__ */ new WeakMap(), a = (e) => e.containerRef?.current ?? e.bus;
3
+ return {
4
+ name: "InfiniteScrollPlugin",
5
+ priority: 35,
6
+ enabled: !0,
7
+ hooks: {
8
+ transformProps: (e) => ({
9
+ ...e,
10
+ reachBottomOffset: s
11
+ }),
12
+ onReachBottom: async (e, i) => {
13
+ const o = a(e);
14
+ if (n.get(o) || e.hasMore === !1 || i > s) return;
15
+ const r = t.onLoadMore ?? e.props.onLoadMore;
16
+ if (typeof r == "function") {
17
+ n.set(o, !0);
18
+ try {
19
+ await Promise.resolve(r());
20
+ } finally {
21
+ n.delete(o);
22
+ }
23
+ }
24
+ },
25
+ onUnmount: (e) => {
26
+ n.delete(a(e));
27
+ }
28
+ }
29
+ };
30
+ }
31
+ const c = "InfiniteScrollPlugin", l = "监听 Core 的 onReachBottom,在距底部 `threshold` 像素内触发 onLoadMore。自带并发锁:上一次还没结束不会重复触发。", d = "2.0.0", m = [
32
+ "data",
33
+ "加载更多"
34
+ ], f = [
35
+ {
36
+ name: "onUnmount",
37
+ when: "瀑布流卸载前",
38
+ description: "断开观察器、移除滚动监听"
39
+ },
40
+ {
41
+ name: "onReachBottom",
42
+ when: "滚动触底(distance 为距底像素)",
43
+ description: "加载更多、预取下一页"
44
+ },
45
+ {
46
+ name: "transformProps",
47
+ when: "渲染前链式改写瀑布流 props",
48
+ description: "补 gap / columns 默认值、按断点覆盖配置"
49
+ }
50
+ ], p = [], u = "只读取 context 字段(props / state / data),不调用上下文方法", h = [
51
+ {
52
+ name: "threshold",
53
+ type: "number",
54
+ default: "300",
55
+ description: "触发距离 px"
56
+ },
57
+ {
58
+ name: "onLoadMore",
59
+ type: "() => void | Promise<void>",
60
+ default: "props.onLoadMore",
61
+ description: "加载回调"
62
+ }
63
+ ], g = `// 滚动到距底部阈值内触发加载更多,带并发锁防重复请求。
64
+ const Waterfall = withPlugins(WaterfallCore, [
65
+ createInfiniteScrollPlugin({
66
+ threshold: 300,
67
+ }),
68
+ ]);
69
+
70
+ <Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, P = [
71
+ "PaginationPlugin"
72
+ ], y = [
73
+ "距底 300px 预加载,滚到底时数据已就位",
74
+ "并发锁:加载中不重复触发",
75
+ "context.hasMore 为 false 时自动停"
76
+ ], M = [
77
+ "信息流无限滚动",
78
+ "画廊继续加载",
79
+ "搜索结果瀑布流"
80
+ ], w = [
81
+ "阈值不要小于一屏(约 600px),否则用户滚到底会看到空白等待。",
82
+ "翻页类场景请用 PaginationPlugin,两者不要同装。"
83
+ ], I = {
84
+ name: c,
85
+ description: l,
86
+ since: d,
87
+ tags: m,
88
+ events: f,
89
+ methods: p,
90
+ methodsNote: u,
91
+ config: h,
92
+ example: g,
93
+ conflicts: P,
94
+ features: y,
95
+ useCases: M,
96
+ notes: w
97
+ };
98
+ export {
99
+ x as c,
100
+ I as d
101
+ };
@@ -0,0 +1,170 @@
1
+ function O(c = {}) {
2
+ const l = c.storageKey || "waterfall-state", p = c.persistScroll ?? !0, o = c.persistKeys || ["pageIndex", "pageSize", "searchQuery"];
3
+ let u = !1;
4
+ const d = 1, i = /* @__PURE__ */ new WeakSet(), h = (t) => t.containerRef?.current ?? t.bus;
5
+ function a() {
6
+ try {
7
+ const t = localStorage.getItem(l);
8
+ if (!t) return null;
9
+ const e = JSON.parse(t);
10
+ return !e || e.version !== d || typeof e.state != "object" ? null : e.state;
11
+ } catch {
12
+ return null;
13
+ }
14
+ }
15
+ function f(t) {
16
+ try {
17
+ localStorage.setItem(l, JSON.stringify({ version: d, state: t }));
18
+ } catch {
19
+ }
20
+ }
21
+ return {
22
+ name: "StatePersistencePlugin",
23
+ enabled: !0,
24
+ hooks: {
25
+ // 首次渲染时,尽量将本地快照中的分页/查询键注入到 props,便于核心按恢复后的状态渲染
26
+ transformProps: (t) => {
27
+ if (u) return t;
28
+ const e = a();
29
+ if (!e) return t;
30
+ const s = { ...t };
31
+ let n = !1;
32
+ return o.forEach((r) => {
33
+ e[r] !== void 0 && (s[r] = e[r], n = !0);
34
+ }), n && (u = !0), s;
35
+ },
36
+ onMount: (t) => {
37
+ const e = a();
38
+ if (!e) return;
39
+ const s = {};
40
+ if (o.forEach((n) => {
41
+ e[n] !== void 0 && (s[n] = e[n]);
42
+ }), Object.keys(s).length > 0 && (t.bus?.emit("state:restored", s), typeof window < "u"))
43
+ try {
44
+ window.dispatchEvent(new CustomEvent("waterfall:state-restored", { detail: s }));
45
+ } catch {
46
+ }
47
+ },
48
+ onLayoutComplete: (t) => {
49
+ if (!p) return;
50
+ const e = h(t);
51
+ if (i.has(e)) return;
52
+ const s = a(), n = Number(s?.scrollTop ?? 0);
53
+ if (!Number.isFinite(n) || n <= 0) {
54
+ i.add(e);
55
+ return;
56
+ }
57
+ const r = t.containerRef.current;
58
+ r && (r.scrollTo({ top: n, behavior: "auto" }), i.add(e));
59
+ },
60
+ // props 变化时,增量更新快照(立即持久化分页/查询键)
61
+ onPropsChange: (t, e, s) => {
62
+ const r = { ...a() || {} }, y = s ?? {};
63
+ o.forEach((m) => {
64
+ const g = y[m];
65
+ g !== void 0 && (r[m] = g);
66
+ }), f(r);
67
+ },
68
+ onUnmount: (t) => {
69
+ const e = {};
70
+ p && (e.scrollTop = t.containerRef.current?.scrollTop || 0);
71
+ const s = t.props ?? {};
72
+ o.forEach((n) => {
73
+ const r = s[n];
74
+ r !== void 0 && (e[n] = r);
75
+ }), f(e);
76
+ }
77
+ }
78
+ };
79
+ }
80
+ const S = "StatePersistencePlugin", w = "三个时机各做一件事:首次渲染把快照里的 pageIndex / searchQuery 注入 props;挂载后恢复 scrollTop;props 变化与卸载时写回快照。刷新页面不丢进度。", v = "2.0.0", P = [
81
+ "ui",
82
+ "持久化"
83
+ ], b = [
84
+ {
85
+ name: "onMount",
86
+ when: "瀑布流挂载完成",
87
+ description: "初始化观察器与滚动监听,返回清理函数"
88
+ },
89
+ {
90
+ name: "onUnmount",
91
+ when: "瀑布流卸载前",
92
+ description: "断开观察器、移除滚动监听"
93
+ },
94
+ {
95
+ name: "onPropsChange",
96
+ when: "props 变化后",
97
+ description: "数据或配置变化时请求重排"
98
+ },
99
+ {
100
+ name: "onLayoutComplete",
101
+ when: "DOM 落位完成(可安全测量)",
102
+ description: "测量真实高度、懒加载判定、曝光上报"
103
+ },
104
+ {
105
+ name: "transformProps",
106
+ when: "渲染前链式改写瀑布流 props",
107
+ description: "补 gap / columns 默认值、按断点覆盖配置"
108
+ },
109
+ {
110
+ name: "state:restored",
111
+ when: "从持久化恢复滚动位置 / 顺序后",
112
+ description: "广播恢复后的状态快照"
113
+ }
114
+ ], C = [], I = "只读取 context 字段(props / state / data),不调用上下文方法", E = [
115
+ {
116
+ name: "storageKey",
117
+ type: "string",
118
+ default: '"waterfall-state"',
119
+ description: "localStorage 键名"
120
+ },
121
+ {
122
+ name: "persistScroll",
123
+ type: "boolean",
124
+ default: "true",
125
+ description: "是否持久化滚动位置"
126
+ },
127
+ {
128
+ name: "persistKeys",
129
+ type: "string[]",
130
+ default: '["pageIndex","pageSize","searchQuery"]',
131
+ description: "要持久化的 props 键"
132
+ }
133
+ ], K = `// 把滚动位置与分页/查询状态存 localStorage,回来时恢复。
134
+ const Waterfall = withPlugins(WaterfallCore, [
135
+ createStatePersistencePlugin({
136
+ storageKey: "waterfall-state",
137
+ persistScroll: true,
138
+ persistKeys: ["pageIndex","pageSize","searchQuery"],
139
+ }),
140
+ ]);
141
+
142
+ <Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, x = [
143
+ "滚动位置 + 分页/查询一起存",
144
+ "首帧注入只做一次,不会覆盖用户操作",
145
+ "SSR / 隐私模式下降级为不持久化"
146
+ ], N = [
147
+ "后台列表刷新不丢页",
148
+ "搜索结果返回定位",
149
+ "移动端来回切换页面"
150
+ ], R = [
151
+ "只能恢复「值」,不能替你把它写回 React state——页面应订阅 `state:restored` 事件或读 bus。",
152
+ "localStorage 不可用(隐私模式/配额满)时静默跳过,不会抛错。"
153
+ ], T = {
154
+ name: S,
155
+ description: w,
156
+ since: v,
157
+ tags: P,
158
+ events: b,
159
+ methods: C,
160
+ methodsNote: I,
161
+ config: E,
162
+ example: K,
163
+ features: x,
164
+ useCases: N,
165
+ notes: R
166
+ };
167
+ export {
168
+ O as c,
169
+ T as d
170
+ };