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,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
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
function b(n = {}) {
|
|
2
|
+
const l = n.fields ?? [];
|
|
3
|
+
return {
|
|
4
|
+
name: "SearchPlugin",
|
|
5
|
+
priority: 20,
|
|
6
|
+
enabled: !0,
|
|
7
|
+
hooks: {
|
|
8
|
+
transformProps: (e) => {
|
|
9
|
+
const t = String(e.searchQuery ?? "").trim(), o = Array.isArray(e.items) ? e.items : [];
|
|
10
|
+
if (!t) return e;
|
|
11
|
+
const r = t.toLowerCase(), a = o.filter((s) => {
|
|
12
|
+
if (typeof s != "object" || s === null) return !1;
|
|
13
|
+
const i = l.length > 0 ? l : Object.keys(s);
|
|
14
|
+
for (const c of i) {
|
|
15
|
+
const u = s[c];
|
|
16
|
+
if (u != null && String(u).toLowerCase().includes(r)) return !0;
|
|
17
|
+
}
|
|
18
|
+
return !1;
|
|
19
|
+
});
|
|
20
|
+
return { ...e, items: a };
|
|
21
|
+
},
|
|
22
|
+
onPropsChange: (e, t, o) => {
|
|
23
|
+
const r = String(t?.searchQuery ?? ""), a = String(o?.searchQuery ?? "");
|
|
24
|
+
if (((typeof o?.scrollToTopOnSearchChange == "boolean" ? o.scrollToTopOnSearchChange : void 0) ?? !!n.scrollToTop) && r !== a) {
|
|
25
|
+
const c = o?.scrollToTopBehavior ?? n.scrollBehavior ?? "auto";
|
|
26
|
+
e.scrollToTop?.({ behavior: c });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const d = "SearchPlugin", h = "读取 `props.searchQuery`,在指定字段上做大小写不敏感的 `includes` 匹配。没指定字段就对对象的全部自有字段匹配。", f = "2.0.0", p = [
|
|
33
|
+
"data",
|
|
34
|
+
"数据管线",
|
|
35
|
+
"搜索"
|
|
36
|
+
], m = [
|
|
37
|
+
{
|
|
38
|
+
name: "onPropsChange",
|
|
39
|
+
when: "props 变化后",
|
|
40
|
+
description: "数据或配置变化时请求重排"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "transformProps",
|
|
44
|
+
when: "渲染前链式改写瀑布流 props",
|
|
45
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
46
|
+
}
|
|
47
|
+
], y = [], g = "只读取 context 字段(props / state / data),不调用上下文方法", T = [
|
|
48
|
+
{
|
|
49
|
+
name: "fields",
|
|
50
|
+
type: "(keyof T)[]",
|
|
51
|
+
default: "[]",
|
|
52
|
+
description: "参与匹配的字段;空则匹配全部自有字段"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "scrollToTop",
|
|
56
|
+
type: "boolean",
|
|
57
|
+
default: "false",
|
|
58
|
+
description: "关键词变化后回顶"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "scrollBehavior",
|
|
62
|
+
type: '"auto" | "smooth"',
|
|
63
|
+
default: '"auto"',
|
|
64
|
+
description: "回顶行为"
|
|
65
|
+
}
|
|
66
|
+
], S = `// 按 props.searchQuery 做大小写不敏感的多字段包含匹配。
|
|
67
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
68
|
+
createSearchPlugin({
|
|
69
|
+
fields: [],
|
|
70
|
+
scrollToTop: false,
|
|
71
|
+
scrollBehavior: "auto",
|
|
72
|
+
}),
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, v = [
|
|
76
|
+
"大小写不敏感",
|
|
77
|
+
"多字段 OR 匹配",
|
|
78
|
+
"空关键词直接放行(不触发过滤)"
|
|
79
|
+
], C = [
|
|
80
|
+
"站内搜索结果页",
|
|
81
|
+
"后台列表即时搜索",
|
|
82
|
+
"商品名 / 店铺名联合搜索"
|
|
83
|
+
], P = [
|
|
84
|
+
"纯前端 `includes`,不排序也不做拼音;要相关性排序请在 Search 之后接 SortPlugin。"
|
|
85
|
+
], Q = {
|
|
86
|
+
name: d,
|
|
87
|
+
description: h,
|
|
88
|
+
since: f,
|
|
89
|
+
tags: p,
|
|
90
|
+
events: m,
|
|
91
|
+
methods: y,
|
|
92
|
+
methodsNote: g,
|
|
93
|
+
config: T,
|
|
94
|
+
example: S,
|
|
95
|
+
features: v,
|
|
96
|
+
useCases: C,
|
|
97
|
+
notes: P
|
|
98
|
+
};
|
|
99
|
+
export {
|
|
100
|
+
b as c,
|
|
101
|
+
Q as d
|
|
102
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function w(n) {
|
|
2
2
|
if (!(n.minColumnWidth > 0))
|
|
3
3
|
throw new Error("[vane-waterfall] AutoColumnPlugin 需要正数的 minColumnWidth");
|
|
4
4
|
return {
|
|
@@ -6,14 +6,14 @@ function b(n) {
|
|
|
6
6
|
priority: 55,
|
|
7
7
|
enabled: !0,
|
|
8
8
|
hooks: {
|
|
9
|
-
calculateColumns: (
|
|
10
|
-
const t =
|
|
11
|
-
if (!
|
|
12
|
-
const
|
|
9
|
+
calculateColumns: (a, m) => {
|
|
10
|
+
const t = a.props, e = t.columnGap ?? t.gap ?? 0, o = t.padding, i = typeof o == "number" ? o * 2 : (o?.left ?? 0) + (o?.right ?? 0), s = Math.max(0, m - i);
|
|
11
|
+
if (!s) return t.columns ?? 1;
|
|
12
|
+
const l = Math.max(
|
|
13
13
|
1,
|
|
14
|
-
Math.floor((
|
|
14
|
+
Math.floor((s + e) / (n.minColumnWidth + e))
|
|
15
15
|
), u = Math.max(1, n.minColumns ?? 1), c = n.maxColumns ?? Number.POSITIVE_INFINITY;
|
|
16
|
-
return Math.min(Math.max(
|
|
16
|
+
return Math.min(Math.max(l, u), c);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
};
|
|
@@ -22,7 +22,13 @@ const r = "AutoColumnPlugin", d = "按「容器可用宽度 ÷ 最小列宽」
|
|
|
22
22
|
"layout",
|
|
23
23
|
"layout-hook",
|
|
24
24
|
"响应式"
|
|
25
|
-
],
|
|
25
|
+
], h = [
|
|
26
|
+
{
|
|
27
|
+
name: "calculateColumns",
|
|
28
|
+
when: "每次布局前,询问列数",
|
|
29
|
+
description: "返回列数则覆盖 props.columns;返回 undefined 沿用配置"
|
|
30
|
+
}
|
|
31
|
+
], f = [], g = "只读取 context 字段(props / state / data),不调用上下文方法", x = [
|
|
26
32
|
{
|
|
27
33
|
name: "minColumnWidth",
|
|
28
34
|
type: "number",
|
|
@@ -41,7 +47,7 @@ const r = "AutoColumnPlugin", d = "按「容器可用宽度 ÷ 最小列宽」
|
|
|
41
47
|
default: "1",
|
|
42
48
|
description: "列数下限"
|
|
43
49
|
}
|
|
44
|
-
],
|
|
50
|
+
], P = `// 按容器宽与最小列宽自动算列数,窄屏自动降列。
|
|
45
51
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
46
52
|
createAutoColumnPlugin({
|
|
47
53
|
maxColumns: "Infinity",
|
|
@@ -49,31 +55,34 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
49
55
|
}),
|
|
50
56
|
]);
|
|
51
57
|
|
|
52
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
58
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, y = [
|
|
53
59
|
"ResponsiveColumnsPlugin"
|
|
54
|
-
],
|
|
60
|
+
], b = [
|
|
55
61
|
"按容器宽度(不是视口宽度)算列数",
|
|
56
62
|
"列数上下限可夹",
|
|
57
63
|
"与 Gap / Padding 一起算,留白不吞列宽"
|
|
58
|
-
],
|
|
64
|
+
], I = [
|
|
59
65
|
"响应式信息流",
|
|
60
66
|
"侧边栏宽度可拖动的后台看板",
|
|
61
67
|
"移动端 → 桌面端同一套代码"
|
|
62
|
-
],
|
|
68
|
+
], W = [
|
|
63
69
|
"与 ResponsiveColumnsPlugin 同时装会互相覆盖列数,只选一个。"
|
|
64
|
-
],
|
|
70
|
+
], v = {
|
|
65
71
|
name: r,
|
|
66
72
|
description: d,
|
|
67
73
|
since: p,
|
|
68
74
|
tags: C,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
events: h,
|
|
76
|
+
methods: f,
|
|
77
|
+
methodsNote: g,
|
|
78
|
+
config: x,
|
|
79
|
+
example: P,
|
|
80
|
+
conflicts: y,
|
|
81
|
+
features: b,
|
|
82
|
+
useCases: I,
|
|
83
|
+
notes: W
|
|
75
84
|
};
|
|
76
85
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
w as c,
|
|
87
|
+
v as d
|
|
79
88
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function
|
|
1
|
+
function x(n) {
|
|
2
2
|
return {
|
|
3
3
|
name: "FixedHeightPlugin",
|
|
4
4
|
priority: 45,
|
|
5
5
|
enabled: !0,
|
|
6
6
|
hooks: {
|
|
7
7
|
transformProps: (t) => {
|
|
8
|
-
const { itemHeight:
|
|
9
|
-
return { ...t, items:
|
|
8
|
+
const { itemHeight: s } = n, o = (t.items || []).map((e) => typeof e == "object" && e !== null && "height" in e ? { ...e, height: s } : e);
|
|
9
|
+
return { ...t, items: o };
|
|
10
10
|
},
|
|
11
11
|
onResize: (t) => {
|
|
12
12
|
t.relayout?.();
|
|
@@ -14,10 +14,21 @@ function d(n) {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const i = "FixedHeightPlugin", a = "把数据里带 height 字段的项统一改写为固定高度,瀑布流变成等高网格。适合「图少字多」的卡片流——等高反而更好扫读。", r = "2.0.0", c = [
|
|
18
18
|
"layout",
|
|
19
19
|
"网格"
|
|
20
|
-
],
|
|
20
|
+
], h = [
|
|
21
|
+
{
|
|
22
|
+
name: "onResize",
|
|
23
|
+
when: "容器宽度变化触发重排前",
|
|
24
|
+
description: "按新宽度调整列数或卡片密度"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "transformProps",
|
|
28
|
+
when: "渲染前链式改写瀑布流 props",
|
|
29
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
30
|
+
}
|
|
31
|
+
], m = [], d = "只读取 context 字段(props / state / data),不调用上下文方法", g = [
|
|
21
32
|
{
|
|
22
33
|
name: "itemHeight",
|
|
23
34
|
type: "number",
|
|
@@ -33,24 +44,27 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
33
44
|
"等高网格(严格对齐)",
|
|
34
45
|
"只改数据里已有的 height 字段",
|
|
35
46
|
"与 Pagination / Filter 组合仍然成立"
|
|
36
|
-
],
|
|
47
|
+
], p = [
|
|
37
48
|
"商品列表(图固定比例)",
|
|
38
49
|
"后台看板卡片",
|
|
39
50
|
"需要严格栅格对齐的页面"
|
|
40
|
-
],
|
|
51
|
+
], f = [
|
|
41
52
|
"数据里没有 height 字段时不会生效——高度由 renderItem 自己的内容决定。"
|
|
42
|
-
],
|
|
43
|
-
name:
|
|
53
|
+
], P = {
|
|
54
|
+
name: i,
|
|
44
55
|
description: a,
|
|
45
56
|
since: r,
|
|
46
57
|
tags: c,
|
|
58
|
+
events: h,
|
|
59
|
+
methods: m,
|
|
60
|
+
methodsNote: d,
|
|
47
61
|
config: g,
|
|
48
62
|
example: l,
|
|
49
63
|
features: u,
|
|
50
|
-
useCases:
|
|
51
|
-
notes:
|
|
64
|
+
useCases: p,
|
|
65
|
+
notes: f
|
|
52
66
|
};
|
|
53
67
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
x as c,
|
|
69
|
+
P as d
|
|
56
70
|
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
function y(s) {
|
|
2
|
+
const n = /* @__PURE__ */ new Set(), o = (i) => {
|
|
3
|
+
if (n.size <= s.poolSize) return;
|
|
4
|
+
const e = n.values().next().value;
|
|
5
|
+
if (typeof e == "number") {
|
|
6
|
+
n.delete(e);
|
|
7
|
+
const t = i.getItemRef(e);
|
|
8
|
+
t && (t.style.visibility = "hidden");
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
name: "RecyclePlugin",
|
|
13
|
+
enabled: !0,
|
|
14
|
+
hooks: {
|
|
15
|
+
onItemEnterViewport: (i, e) => {
|
|
16
|
+
const t = i.getItemRef(e);
|
|
17
|
+
t && (t.style.visibility = "visible"), n.add(e), o(i);
|
|
18
|
+
},
|
|
19
|
+
onItemLeaveViewport: (i, e) => {
|
|
20
|
+
const t = i.getItemRef(e);
|
|
21
|
+
t && (t.style.visibility = "hidden"), n.delete(e);
|
|
22
|
+
},
|
|
23
|
+
onItemUnmount: (i, e) => {
|
|
24
|
+
n.delete(e);
|
|
25
|
+
},
|
|
26
|
+
onUnmount: () => {
|
|
27
|
+
n.clear();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const c = "RecyclePlugin", l = "纯绘制层优化:项离开视口就 `visibility: hidden`,回来再显示。DOM 节点不销毁,滚动位置与已加载的图片都保留,适合「项里有视频/Canvas,重建代价高」的场景。", a = "2.0.0", r = [
|
|
33
|
+
"interaction",
|
|
34
|
+
"性能"
|
|
35
|
+
], m = [
|
|
36
|
+
{
|
|
37
|
+
name: "onUnmount",
|
|
38
|
+
when: "瀑布流卸载前",
|
|
39
|
+
description: "断开观察器、移除滚动监听"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "onItemUnmount",
|
|
43
|
+
when: "单个卡片卸载时",
|
|
44
|
+
description: "解绑该卡片的监听与观察器"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "onItemEnterViewport",
|
|
48
|
+
when: "单个卡片进入视口",
|
|
49
|
+
description: "卡片级曝光、视频自动播放等"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "onItemLeaveViewport",
|
|
53
|
+
when: "单个卡片离开视口",
|
|
54
|
+
description: "暂停播放、回收资源"
|
|
55
|
+
}
|
|
56
|
+
], d = [
|
|
57
|
+
{
|
|
58
|
+
name: "getItemRef",
|
|
59
|
+
signature: "ctx.getItemRef(index: number): HTMLElement | null",
|
|
60
|
+
description: "取第 index 张卡片的 DOM 引用,可能为 null(尚未挂载 / 已回收)"
|
|
61
|
+
}
|
|
62
|
+
], u = [
|
|
63
|
+
{
|
|
64
|
+
name: "poolSize",
|
|
65
|
+
type: "number",
|
|
66
|
+
default: "—",
|
|
67
|
+
description: "同时保持可见的项数上限(超出则回收最早的)"
|
|
68
|
+
}
|
|
69
|
+
], f = `// 视口外的项设 \`visibility: hidden\`,降低长列表的绘制压力。
|
|
70
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
71
|
+
createRecyclePlugin(),
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, p = [
|
|
75
|
+
"不销毁 DOM,只隐藏",
|
|
76
|
+
"项内媒体不重新加载",
|
|
77
|
+
"与虚拟化正交(一个省绘制、一个省节点)"
|
|
78
|
+
], v = [
|
|
79
|
+
"项内含视频 / canvas",
|
|
80
|
+
"长列表滚动发虚",
|
|
81
|
+
"低端设备省电"
|
|
82
|
+
], g = [
|
|
83
|
+
"与 Core 的 `virtualize` 同开会让项被卸载又隐藏,收益互相抵消,建议只选一个。",
|
|
84
|
+
"只改 visibility 不改布局,所以不会引起重排。"
|
|
85
|
+
], b = {
|
|
86
|
+
name: c,
|
|
87
|
+
description: l,
|
|
88
|
+
since: a,
|
|
89
|
+
tags: r,
|
|
90
|
+
events: m,
|
|
91
|
+
methods: d,
|
|
92
|
+
config: u,
|
|
93
|
+
example: f,
|
|
94
|
+
features: p,
|
|
95
|
+
useCases: v,
|
|
96
|
+
notes: g
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
y as c,
|
|
100
|
+
b as d
|
|
101
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { c as a, d as e } from "./doc-C206ZwYC.js";
|
|
2
|
+
import { c as t, d as s } from "./doc-i6FY1We1.js";
|
|
3
|
+
import { c, d as i } from "./doc-D7m1OFCW.js";
|
|
4
|
+
import { c as n, d as o } from "./doc-CInpKZNU.js";
|
|
5
|
+
import { c as r, d as g } from "./doc-DlJICsyN.js";
|
|
6
|
+
import { c as l, d as m } from "./doc-DEN2WTDh.js";
|
|
7
|
+
const f = Object.assign(a, { meta: e }), j = Object.assign(t, { meta: s }), O = Object.assign(c, { meta: i }), C = Object.assign(n, { meta: o }), F = Object.assign(r, { meta: g }), x = Object.assign(l, { meta: m });
|
|
8
|
+
export {
|
|
9
|
+
O as a,
|
|
10
|
+
j as b,
|
|
11
|
+
x as c,
|
|
12
|
+
F as d,
|
|
13
|
+
f as e,
|
|
14
|
+
C as f
|
|
15
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { c as a, d as e } from "./doc-CYxwSuG6.js";
|
|
2
|
+
import { c, d as t } from "./doc-Bud0hbaz.js";
|
|
3
|
+
import { c as s, d as r } from "./doc-RwKQqySd.js";
|
|
4
|
+
import { c as n, d as i } from "./doc-CE1DGMBV.js";
|
|
5
|
+
import { c as o, d as g } from "./doc-CiCso5Ti.js";
|
|
6
|
+
import { c as m, d as l } from "./doc-CHbQXLwY.js";
|
|
7
|
+
import { c as d, d as u } from "./doc-BU0CKW63.js";
|
|
8
|
+
import { c as P, d as $ } from "./doc-DtxS1-P0.js";
|
|
9
|
+
import { c as p, d as b } from "./doc-BAhVW3g8.js";
|
|
10
|
+
const k = Object.assign(a, { meta: e }), D = Object.assign(c, { meta: t }), G = Object.assign(s, { meta: r }), I = Object.assign(n, { meta: i }), L = Object.assign(o, { meta: g }), U = Object.assign(m, { meta: l }), x = Object.assign(d, { meta: u }), q = Object.assign(P, { meta: $ }), v = Object.assign(p, { meta: b });
|
|
11
|
+
export {
|
|
12
|
+
L as a,
|
|
13
|
+
x as b,
|
|
14
|
+
k as c,
|
|
15
|
+
I as d,
|
|
16
|
+
D as e,
|
|
17
|
+
U as f,
|
|
18
|
+
G as g,
|
|
19
|
+
q as h,
|
|
20
|
+
v as i
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { c as a, d as e } from "./doc-eYhNJy97.js";
|
|
2
|
+
import { c as t, d as c } from "./doc-C2L8kkeI.js";
|
|
3
|
+
import { c as o, d as n } from "./doc-C-B3zK2o.js";
|
|
4
|
+
import { c as s, d as i } from "./doc-HoyAFR_m.js";
|
|
5
|
+
const d = Object.assign(a, { meta: e }), g = Object.assign(t, { meta: c }), P = Object.assign(o, { meta: n }), p = Object.assign(s, { meta: i });
|
|
6
|
+
export {
|
|
7
|
+
g as a,
|
|
8
|
+
p as b,
|
|
9
|
+
d as c,
|
|
10
|
+
P as d
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { c as e, d as t } from "./doc-CaJ02INP.js";
|
|
2
|
+
import { c as a, d as c } from "./doc-DudYCn_-.js";
|
|
3
|
+
import { c as s, d as o } from "./doc-skPl6ZMP.js";
|
|
4
|
+
import { c as r, d as n } from "./doc-BrEd0oZB.js";
|
|
5
|
+
import { c as i, d as m } from "./doc-RlBMCMNs.js";
|
|
6
|
+
const $ = Object.assign(e, { meta: t }), b = Object.assign(a, { meta: c }), p = Object.assign(s, { meta: o }), f = Object.assign(r, { meta: n }), j = Object.assign(i, { meta: m });
|
|
7
|
+
export {
|
|
8
|
+
b as a,
|
|
9
|
+
p as b,
|
|
10
|
+
f as c,
|
|
11
|
+
j as d,
|
|
12
|
+
$ as e
|
|
13
|
+
};
|