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
|
@@ -1,35 +1,46 @@
|
|
|
1
|
-
function
|
|
1
|
+
function S(e = {}) {
|
|
2
2
|
return {
|
|
3
3
|
name: "SortPlugin",
|
|
4
4
|
priority: 30,
|
|
5
5
|
enabled: !0,
|
|
6
6
|
hooks: {
|
|
7
7
|
transformProps: (o) => {
|
|
8
|
-
const
|
|
8
|
+
const r = Array.isArray(o.items) ? o.items : [], t = o.sortComparator || e.comparator;
|
|
9
9
|
if (typeof t != "function") return o;
|
|
10
|
-
const s = [...
|
|
10
|
+
const s = [...r].sort((n, a) => {
|
|
11
11
|
try {
|
|
12
|
-
return t(
|
|
12
|
+
return t(n, a);
|
|
13
13
|
} catch {
|
|
14
14
|
return 0;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
return { ...o, items: s };
|
|
18
18
|
},
|
|
19
|
-
onPropsChange: (o,
|
|
20
|
-
const s =
|
|
21
|
-
if (((typeof t?.scrollToTopOnSortChange == "boolean" ? t.scrollToTopOnSortChange : void 0) ?? !!
|
|
22
|
-
const
|
|
23
|
-
o.scrollToTop?.({ behavior:
|
|
19
|
+
onPropsChange: (o, r, t) => {
|
|
20
|
+
const s = r?.sortComparator, n = t?.sortComparator;
|
|
21
|
+
if (((typeof t?.scrollToTopOnSortChange == "boolean" ? t.scrollToTopOnSortChange : void 0) ?? !!e.scrollToTop) && s !== n) {
|
|
22
|
+
const c = t?.scrollToTopBehavior ?? e.scrollBehavior ?? "auto";
|
|
23
|
+
o.scrollToTop?.({ behavior: c });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const l = "SortPlugin", i = "用比较函数排序,优先读 `props.sortComparator`。排序总是在过滤之后、分页之前执行,保证「第 N 页」是排序后的第 N 页。", m = "2.0.0", p = [
|
|
30
30
|
"data",
|
|
31
31
|
"数据管线"
|
|
32
|
-
],
|
|
32
|
+
], d = [
|
|
33
|
+
{
|
|
34
|
+
name: "onPropsChange",
|
|
35
|
+
when: "props 变化后",
|
|
36
|
+
description: "数据或配置变化时请求重排"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "transformProps",
|
|
40
|
+
when: "渲染前链式改写瀑布流 props",
|
|
41
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
42
|
+
}
|
|
43
|
+
], u = [], h = "只读取 context 字段(props / state / data),不调用上下文方法", f = [
|
|
33
44
|
{
|
|
34
45
|
name: "comparator",
|
|
35
46
|
type: "(a, b) => number",
|
|
@@ -48,7 +59,7 @@ const c = "SortPlugin", i = "用比较函数排序,优先读 `props.sortCompar
|
|
|
48
59
|
default: '"auto"',
|
|
49
60
|
description: "回顶行为"
|
|
50
61
|
}
|
|
51
|
-
],
|
|
62
|
+
], C = `// 按比较函数排序 items,比较函数变化可自动回顶。
|
|
52
63
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
53
64
|
createSortPlugin({
|
|
54
65
|
scrollToTop: false,
|
|
@@ -56,28 +67,31 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
56
67
|
}),
|
|
57
68
|
]);
|
|
58
69
|
|
|
59
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
70
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, T = [
|
|
60
71
|
"稳定排序(不改原数组)",
|
|
61
72
|
"比较函数抛错按相等处理",
|
|
62
73
|
"与 Filter / Search 顺序固定"
|
|
63
|
-
],
|
|
74
|
+
], g = [
|
|
64
75
|
"价格 / 时间排序",
|
|
65
76
|
"热度排序",
|
|
66
77
|
"手动置顶项优先"
|
|
67
|
-
],
|
|
78
|
+
], v = [
|
|
68
79
|
"排序会复制数组(`[...items].sort`),不会改调用方传入的 items。"
|
|
69
|
-
],
|
|
70
|
-
name:
|
|
80
|
+
], b = {
|
|
81
|
+
name: l,
|
|
71
82
|
description: i,
|
|
72
83
|
since: m,
|
|
73
84
|
tags: p,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
events: d,
|
|
86
|
+
methods: u,
|
|
87
|
+
methodsNote: h,
|
|
88
|
+
config: f,
|
|
89
|
+
example: C,
|
|
90
|
+
features: T,
|
|
91
|
+
useCases: g,
|
|
92
|
+
notes: v
|
|
79
93
|
};
|
|
80
94
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
S as c,
|
|
96
|
+
b as d
|
|
83
97
|
};
|
|
@@ -1,55 +1,69 @@
|
|
|
1
|
-
function
|
|
1
|
+
function g(t) {
|
|
2
2
|
return {
|
|
3
3
|
name: "AlignmentPlugin",
|
|
4
4
|
priority: 60,
|
|
5
5
|
enabled: !0,
|
|
6
6
|
hooks: {
|
|
7
|
-
transformProps: (e) => ({ ...e, alignmentMode:
|
|
7
|
+
transformProps: (e) => ({ ...e, alignmentMode: t.mode }),
|
|
8
8
|
onResize: (e) => {
|
|
9
9
|
e.relayout?.();
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const n = "AlignmentPlugin", s = "设置瀑布流的列分配策略。shortest 让每列尽量等高(视觉最自然),balanced 让每列项数接近,sequential 按 index 轮转(可预测位置,适合需要与外部索引对齐的场景)。", o = "2.0.0", a = [
|
|
15
15
|
"layout",
|
|
16
16
|
"布局"
|
|
17
17
|
], i = [
|
|
18
|
+
{
|
|
19
|
+
name: "onResize",
|
|
20
|
+
when: "容器宽度变化触发重排前",
|
|
21
|
+
description: "按新宽度调整列数或卡片密度"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "transformProps",
|
|
25
|
+
when: "渲染前链式改写瀑布流 props",
|
|
26
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
27
|
+
}
|
|
28
|
+
], r = [], c = "只读取 context 字段(props / state / data),不调用上下文方法", l = [
|
|
18
29
|
{
|
|
19
30
|
name: "mode",
|
|
20
31
|
type: '"shortest" | "balanced" | "sequential"',
|
|
21
32
|
default: "shortest",
|
|
22
33
|
description: "列分配策略"
|
|
23
34
|
}
|
|
24
|
-
],
|
|
35
|
+
], m = `// 指定列分配策略:最矮列优先(shortest)/ 项数均衡(balanced)/ 顺序轮转(sequential)。
|
|
25
36
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
26
37
|
createAlignmentPlugin({
|
|
27
38
|
mode: "shortest",
|
|
28
39
|
}),
|
|
29
40
|
]);
|
|
30
41
|
|
|
31
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
42
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, d = [
|
|
32
43
|
"三种列分配策略",
|
|
33
44
|
"只改 props.alignmentMode,不影响其他配置",
|
|
34
45
|
"与 ResponsiveColumns / AutoColumn 正交"
|
|
35
|
-
],
|
|
46
|
+
], u = [
|
|
36
47
|
"内容流:默认 shortest",
|
|
37
48
|
"等长卡片:balanced 更整齐",
|
|
38
49
|
"需要与后端顺序对齐:sequential"
|
|
39
|
-
],
|
|
50
|
+
], p = [
|
|
40
51
|
"balanced 与 shortest 在列高相同时都取最左列,视觉上左偏是预期行为。"
|
|
41
|
-
],
|
|
42
|
-
name:
|
|
52
|
+
], h = {
|
|
53
|
+
name: n,
|
|
43
54
|
description: s,
|
|
44
55
|
since: o,
|
|
45
56
|
tags: a,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
events: i,
|
|
58
|
+
methods: r,
|
|
59
|
+
methodsNote: c,
|
|
60
|
+
config: l,
|
|
61
|
+
example: m,
|
|
62
|
+
features: d,
|
|
63
|
+
useCases: u,
|
|
64
|
+
notes: p
|
|
51
65
|
};
|
|
52
66
|
export {
|
|
53
|
-
|
|
54
|
-
d
|
|
67
|
+
g as c,
|
|
68
|
+
h as d
|
|
55
69
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function h(e) {
|
|
2
2
|
return {
|
|
3
3
|
name: "ThrottlePlugin",
|
|
4
4
|
priority: 80,
|
|
@@ -12,10 +12,16 @@ function m(e) {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
const
|
|
15
|
+
const s = "ThrottlePlugin", n = "接管 Core 的 throttleDelay(滚动回调节流)与 debounceDelay(尺寸变化后多久重排)。默认 16ms / 150ms,长列表滚动卡顿时可以放宽到 32 / 300。", o = "2.0.0", r = [
|
|
16
16
|
"perf",
|
|
17
17
|
"性能"
|
|
18
18
|
], a = [
|
|
19
|
+
{
|
|
20
|
+
name: "transformProps",
|
|
21
|
+
when: "渲染前链式改写瀑布流 props",
|
|
22
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
23
|
+
}
|
|
24
|
+
], c = [], l = "只读取 context 字段(props / state / data),不调用上下文方法", i = [
|
|
19
25
|
{
|
|
20
26
|
name: "scroll",
|
|
21
27
|
type: "number",
|
|
@@ -28,33 +34,36 @@ const n = "ThrottlePlugin", s = "接管 Core 的 throttleDelay(滚动回调节
|
|
|
28
34
|
default: "props.debounceDelay",
|
|
29
35
|
description: "布局防抖 ms"
|
|
30
36
|
}
|
|
31
|
-
],
|
|
37
|
+
], m = `// 调整滚动节流与尺寸防抖,弱网/低端机可放宽。
|
|
32
38
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
33
39
|
createThrottlePlugin(),
|
|
34
40
|
]);
|
|
35
41
|
|
|
36
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
42
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, u = [
|
|
37
43
|
"滚动节流与布局防抖分开调",
|
|
38
44
|
"只改 props,不改算法",
|
|
39
45
|
"与 DebounceLayoutPlugin 叠加时后者优先"
|
|
40
|
-
],
|
|
46
|
+
], d = [
|
|
41
47
|
"低端安卓机长列表",
|
|
42
48
|
"滚动时 CPU 占用过高",
|
|
43
49
|
"拖拽侧栏时减少重排"
|
|
44
|
-
],
|
|
50
|
+
], p = [
|
|
45
51
|
"scroll 低于 16ms 没有意义(浏览器帧率上限)。"
|
|
46
|
-
],
|
|
47
|
-
name:
|
|
48
|
-
description:
|
|
52
|
+
], f = {
|
|
53
|
+
name: s,
|
|
54
|
+
description: n,
|
|
49
55
|
since: o,
|
|
50
56
|
tags: r,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
events: a,
|
|
58
|
+
methods: c,
|
|
59
|
+
methodsNote: l,
|
|
60
|
+
config: i,
|
|
61
|
+
example: m,
|
|
62
|
+
features: u,
|
|
63
|
+
useCases: d,
|
|
64
|
+
notes: p
|
|
56
65
|
};
|
|
57
66
|
export {
|
|
58
|
-
|
|
59
|
-
d
|
|
67
|
+
h as c,
|
|
68
|
+
f as d
|
|
60
69
|
};
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
import { jsx as E } from "react/jsx-runtime";
|
|
2
2
|
const i = "data-drag-over";
|
|
3
|
-
function
|
|
3
|
+
function w(a, c) {
|
|
4
4
|
if (typeof document > "u") return null;
|
|
5
|
-
const
|
|
6
|
-
if (!
|
|
7
|
-
const d = Number(
|
|
5
|
+
const l = document.elementFromPoint(a, c)?.closest?.("[data-index]");
|
|
6
|
+
if (!l) return null;
|
|
7
|
+
const d = Number(l.getAttribute("data-index"));
|
|
8
8
|
return Number.isFinite(d) ? d : null;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
10
|
+
function O(a = {}) {
|
|
11
|
+
const c = a.enabled ?? !0, g = a.showHandle ?? !1, l = a.touchHoldMs ?? 180, d = (t, n, r) => {
|
|
12
12
|
const e = Number(r);
|
|
13
13
|
if (!Number.isFinite(e) || e === n) return;
|
|
14
14
|
t.sharedData.set("drag-from", e), t.sharedData.set("drag-to", n), t.bus.emit("drag:reorder", { from: e, to: n });
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
},
|
|
15
|
+
const p = t.props.items;
|
|
16
|
+
a.onReorder?.(e, n, p?.[e]);
|
|
17
|
+
}, h = () => {
|
|
18
18
|
document.querySelectorAll(`[${i}]`).forEach((t) => t.removeAttribute(i));
|
|
19
19
|
}, m = () => {
|
|
20
|
-
typeof document > "u" || (
|
|
21
|
-
},
|
|
20
|
+
typeof document > "u" || (h(), document.body.style.userSelect = "", document.body.style.cursor = "");
|
|
21
|
+
}, y = (t, n, r) => {
|
|
22
22
|
if (t.pointerType === "mouse") return;
|
|
23
|
-
const e = t.clientX,
|
|
24
|
-
let
|
|
23
|
+
const e = t.clientX, p = t.clientY, R = Date.now();
|
|
24
|
+
let f = !1, b = null;
|
|
25
25
|
const v = (o) => {
|
|
26
|
-
if (!
|
|
27
|
-
const D = Date.now() - R >=
|
|
26
|
+
if (!f) {
|
|
27
|
+
const D = Date.now() - R >= l, H = Math.hypot(o.clientX - e, o.clientY - p) >= 6;
|
|
28
28
|
if (!D || !H) return;
|
|
29
|
-
|
|
29
|
+
f = !0, document.body.style.userSelect = "none", document.body.style.cursor = "grabbing";
|
|
30
30
|
}
|
|
31
31
|
o.preventDefault();
|
|
32
|
-
const
|
|
33
|
-
|
|
32
|
+
const s = w(o.clientX, o.clientY);
|
|
33
|
+
s !== b && (h(), b = s, s != null && document.querySelector(`[data-index="${s}"]`)?.setAttribute(i, ""));
|
|
34
34
|
}, u = (o) => {
|
|
35
|
-
if (window.removeEventListener("pointermove", v), window.removeEventListener("pointerup", u), window.removeEventListener("pointercancel", u), m(), !
|
|
36
|
-
const
|
|
37
|
-
|
|
35
|
+
if (window.removeEventListener("pointermove", v), window.removeEventListener("pointerup", u), window.removeEventListener("pointercancel", u), m(), !f) return;
|
|
36
|
+
const s = w(o.clientX, o.clientY);
|
|
37
|
+
s != null && d(r, s, String(n));
|
|
38
38
|
};
|
|
39
39
|
window.addEventListener("pointermove", v, { passive: !1 }), window.addEventListener("pointerup", u), window.addEventListener("pointercancel", u);
|
|
40
40
|
};
|
|
41
41
|
return {
|
|
42
42
|
name: "DragReorderPlugin",
|
|
43
|
-
enabled:
|
|
43
|
+
enabled: c,
|
|
44
44
|
hooks: {
|
|
45
|
-
renderItemWrapper: (t, n, r) =>
|
|
45
|
+
renderItemWrapper: (t, n, r) => c ? /* @__PURE__ */ E(
|
|
46
46
|
"div",
|
|
47
47
|
{
|
|
48
48
|
draggable: !0,
|
|
@@ -62,7 +62,7 @@ function C(s = {}) {
|
|
|
62
62
|
e.preventDefault(), m(), d(t, r, e.dataTransfer?.getData("text/plain") ?? "");
|
|
63
63
|
},
|
|
64
64
|
onDragEnd: m,
|
|
65
|
-
onPointerDown: (e) =>
|
|
65
|
+
onPointerDown: (e) => y(e, r, t),
|
|
66
66
|
style: {
|
|
67
67
|
cursor: "grab",
|
|
68
68
|
...g ? { border: "1px dashed #bdbdbd", borderRadius: 6 } : null
|
|
@@ -77,6 +77,17 @@ const L = "DragReorderPlugin", M = "给每个项加拖拽能力,松手时回
|
|
|
77
77
|
"interaction",
|
|
78
78
|
"拖拽"
|
|
79
79
|
], S = [
|
|
80
|
+
{
|
|
81
|
+
name: "renderItemWrapper",
|
|
82
|
+
when: "渲染每个卡片时包裹其内容",
|
|
83
|
+
description: "给单卡加包裹层(拖拽、无障碍语义、占位骨架)"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "drag:reorder",
|
|
87
|
+
when: "拖拽排序完成后",
|
|
88
|
+
description: "广播 { from, to },供业务层同步顺序"
|
|
89
|
+
}
|
|
90
|
+
], T = [], N = "只读取 context 字段(props / state / data),不调用上下文方法", x = [
|
|
80
91
|
{
|
|
81
92
|
name: "enabled",
|
|
82
93
|
type: "boolean",
|
|
@@ -101,7 +112,7 @@ const L = "DragReorderPlugin", M = "给每个项加拖拽能力,松手时回
|
|
|
101
112
|
default: "180",
|
|
102
113
|
description: "触屏长按多久进入拖拽(ms),0 表示不需要长按"
|
|
103
114
|
}
|
|
104
|
-
],
|
|
115
|
+
], W = `// 鼠标走 HTML5 draggable,触屏走长按 + pointer,松手时回调 onReorder(from, to)。
|
|
105
116
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
106
117
|
createDragReorderPlugin({
|
|
107
118
|
enabled: true,
|
|
@@ -121,18 +132,21 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
121
132
|
], q = [
|
|
122
133
|
"插件只负责「拖」和「告诉你从哪到哪」,数组重排由调用方在 onReorder 里做。",
|
|
123
134
|
"触屏用长按区分「想滚」和「想拖」:不这样做,手指一滑就变成拖拽,页面滚不动。"
|
|
124
|
-
],
|
|
135
|
+
], $ = {
|
|
125
136
|
name: L,
|
|
126
137
|
description: M,
|
|
127
138
|
since: A,
|
|
128
139
|
tags: P,
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
events: S,
|
|
141
|
+
methods: T,
|
|
142
|
+
methodsNote: N,
|
|
143
|
+
config: x,
|
|
144
|
+
example: W,
|
|
131
145
|
features: X,
|
|
132
146
|
useCases: Y,
|
|
133
147
|
notes: q
|
|
134
148
|
};
|
|
135
149
|
export {
|
|
136
|
-
|
|
137
|
-
|
|
150
|
+
O as c,
|
|
151
|
+
$ as d
|
|
138
152
|
};
|
|
@@ -1,39 +1,60 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
function
|
|
3
|
-
const l = n.containerRole ?? "list", c = n.itemRole ?? "listitem",
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
function w(n = {}) {
|
|
3
|
+
const l = n.containerRole ?? "list", c = n.itemRole ?? "listitem", m = n.enableTabIndex ?? !0, d = n.containerLabel ?? "Waterfall list", a = /* @__PURE__ */ new WeakMap(), s = (e) => e.containerRef?.current ?? e.bus, i = (e) => a.get(s(e)) ?? 0, o = (e) => {
|
|
4
4
|
const t = e.containerRef.current;
|
|
5
|
-
t && (t.setAttribute("role", l), t.setAttribute("aria-label",
|
|
5
|
+
t && (t.setAttribute("role", l), t.setAttribute("aria-label", d), t.setAttribute("aria-busy", e.isLayouting ? "true" : "false"));
|
|
6
6
|
};
|
|
7
7
|
return {
|
|
8
8
|
name: "A11yPlugin",
|
|
9
9
|
enabled: !0,
|
|
10
10
|
hooks: {
|
|
11
11
|
onMount: (e) => {
|
|
12
|
-
|
|
12
|
+
o(e);
|
|
13
13
|
},
|
|
14
14
|
onLayoutComplete: (e) => {
|
|
15
|
-
|
|
15
|
+
o(e);
|
|
16
16
|
},
|
|
17
17
|
onItemClick: (e, t) => {
|
|
18
|
-
|
|
18
|
+
i(e) !== t && (a.set(s(e), t), e.forceUpdate?.());
|
|
19
19
|
},
|
|
20
|
-
renderItemWrapper: (e, t,
|
|
20
|
+
renderItemWrapper: (e, t, r) => /* @__PURE__ */ u(
|
|
21
21
|
"div",
|
|
22
22
|
{
|
|
23
23
|
role: c,
|
|
24
|
-
"aria-posinset":
|
|
24
|
+
"aria-posinset": r + 1,
|
|
25
25
|
"aria-setsize": e.itemCount,
|
|
26
|
-
tabIndex:
|
|
26
|
+
tabIndex: m ? r === i(e) ? 0 : -1 : void 0,
|
|
27
27
|
children: t
|
|
28
28
|
}
|
|
29
29
|
)
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
const
|
|
33
|
+
const p = "A11yPlugin", b = "把瀑布流补成读屏可理解的列表:容器 `role=list` + `aria-label`,每项 `role=listitem` + `aria-posinset` / `aria-setsize`,并可选加 `tabIndex` 让键盘能逐项聚焦。", f = "2.0.0", y = [
|
|
34
34
|
"ui",
|
|
35
35
|
"a11y"
|
|
36
|
-
],
|
|
36
|
+
], I = [
|
|
37
|
+
{
|
|
38
|
+
name: "onMount",
|
|
39
|
+
when: "瀑布流挂载完成",
|
|
40
|
+
description: "初始化观察器与滚动监听,返回清理函数"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "onItemClick",
|
|
44
|
+
when: "单个卡片被点击",
|
|
45
|
+
description: "卡片级跳转与点击埋点"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "onLayoutComplete",
|
|
49
|
+
when: "DOM 落位完成(可安全测量)",
|
|
50
|
+
description: "测量真实高度、懒加载判定、曝光上报"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "renderItemWrapper",
|
|
54
|
+
when: "渲染每个卡片时包裹其内容",
|
|
55
|
+
description: "给单卡加包裹层(拖拽、无障碍语义、占位骨架)"
|
|
56
|
+
}
|
|
57
|
+
], g = [], R = "只读取 context 字段(props / state / data),不调用上下文方法", h = [
|
|
37
58
|
{
|
|
38
59
|
name: "containerRole",
|
|
39
60
|
type: "string",
|
|
@@ -58,7 +79,7 @@ const m = "A11yPlugin", p = "把瀑布流补成读屏可理解的列表:容器
|
|
|
58
79
|
default: '"Waterfall list"',
|
|
59
80
|
description: "容器 aria-label"
|
|
60
81
|
}
|
|
61
|
-
],
|
|
82
|
+
], C = `// 给容器与项补 ARIA role / label / posinset,支持键盘 Tab 遍历。
|
|
62
83
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
63
84
|
createA11yPlugin({
|
|
64
85
|
containerRole: "list",
|
|
@@ -67,28 +88,31 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
67
88
|
}),
|
|
68
89
|
]);
|
|
69
90
|
|
|
70
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
91
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, A = [
|
|
71
92
|
"容器 / 项 role 成对补齐",
|
|
72
93
|
"aria-posinset + aria-setsize 正确标注序号",
|
|
73
94
|
"键盘可逐项聚焦"
|
|
74
|
-
],
|
|
95
|
+
], W = [
|
|
75
96
|
"政务 / 金融等合规站点",
|
|
76
97
|
"读屏用户可用的信息流",
|
|
77
98
|
"键盘操作优先的桌面端"
|
|
78
|
-
],
|
|
99
|
+
], T = [
|
|
79
100
|
"项数很多时 `tabIndex=0` 会让 Tab 变长,建议配合「跳转主内容」链接使用。"
|
|
80
101
|
], x = {
|
|
81
|
-
name:
|
|
82
|
-
description:
|
|
102
|
+
name: p,
|
|
103
|
+
description: b,
|
|
83
104
|
since: f,
|
|
84
|
-
tags:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
105
|
+
tags: y,
|
|
106
|
+
events: I,
|
|
107
|
+
methods: g,
|
|
108
|
+
methodsNote: R,
|
|
109
|
+
config: h,
|
|
110
|
+
example: C,
|
|
111
|
+
features: A,
|
|
112
|
+
useCases: W,
|
|
113
|
+
notes: T
|
|
90
114
|
};
|
|
91
115
|
export {
|
|
92
|
-
|
|
116
|
+
w as c,
|
|
93
117
|
x as d
|
|
94
118
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function v(o = {}) {
|
|
2
2
|
return {
|
|
3
3
|
name: "FilterPlugin",
|
|
4
4
|
priority: 40,
|
|
@@ -7,9 +7,9 @@ function g(o = {}) {
|
|
|
7
7
|
transformProps: (e) => {
|
|
8
8
|
const n = Array.isArray(e.items) ? e.items : [], t = e.filterFn || o.predicate;
|
|
9
9
|
if (typeof t != "function") return e;
|
|
10
|
-
const r = n.filter((
|
|
10
|
+
const r = n.filter((s, a) => {
|
|
11
11
|
try {
|
|
12
|
-
return !!t(
|
|
12
|
+
return !!t(s, a);
|
|
13
13
|
} catch {
|
|
14
14
|
return !0;
|
|
15
15
|
}
|
|
@@ -17,19 +17,30 @@ function g(o = {}) {
|
|
|
17
17
|
return { ...e, items: r };
|
|
18
18
|
},
|
|
19
19
|
onPropsChange: (e, n, t) => {
|
|
20
|
-
const r = n?.filterFn,
|
|
21
|
-
if (((typeof t?.scrollToTopOnFilterChange == "boolean" ? t.scrollToTopOnFilterChange : void 0) ?? !!o.scrollToTop) && r !==
|
|
22
|
-
const
|
|
23
|
-
e.scrollToTop?.({ behavior:
|
|
20
|
+
const r = n?.filterFn, s = t?.filterFn;
|
|
21
|
+
if (((typeof t?.scrollToTopOnFilterChange == "boolean" ? t.scrollToTopOnFilterChange : void 0) ?? !!o.scrollToTop) && r !== s) {
|
|
22
|
+
const i = t?.scrollToTopBehavior ?? o.scrollBehavior ?? "auto";
|
|
23
|
+
e.scrollToTop?.({ behavior: i });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const l = "FilterPlugin", c = "用谓词函数过滤数据,优先读 `props.filterFn`,没有就用工厂里传入的 predicate。过滤条件变了可以自动滚回顶部(默认不开)。", p = "2.0.0", d = [
|
|
30
30
|
"data",
|
|
31
31
|
"数据管线"
|
|
32
|
-
],
|
|
32
|
+
], m = [
|
|
33
|
+
{
|
|
34
|
+
name: "onPropsChange",
|
|
35
|
+
when: "props 变化后",
|
|
36
|
+
description: "数据或配置变化时请求重排"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "transformProps",
|
|
40
|
+
when: "渲染前链式改写瀑布流 props",
|
|
41
|
+
description: "补 gap / columns 默认值、按断点覆盖配置"
|
|
42
|
+
}
|
|
43
|
+
], u = [], f = "只读取 context 字段(props / state / data),不调用上下文方法", h = [
|
|
33
44
|
{
|
|
34
45
|
name: "predicate",
|
|
35
46
|
type: "(item, index) => boolean",
|
|
@@ -48,7 +59,7 @@ const s = "FilterPlugin", c = "用谓词函数过滤数据,优先读 `props.fi
|
|
|
48
59
|
default: '"auto"',
|
|
49
60
|
description: "回顶行为"
|
|
50
61
|
}
|
|
51
|
-
],
|
|
62
|
+
], F = `// 按谓词过滤 items,参数变化可自动回顶。
|
|
52
63
|
const Waterfall = withPlugins(WaterfallCore, [
|
|
53
64
|
createFilterPlugin({
|
|
54
65
|
scrollToTop: false,
|
|
@@ -56,29 +67,32 @@ const Waterfall = withPlugins(WaterfallCore, [
|
|
|
56
67
|
}),
|
|
57
68
|
]);
|
|
58
69
|
|
|
59
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`,
|
|
70
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, T = [
|
|
60
71
|
"谓词抛错时按「保留」处理,不会整表消失",
|
|
61
72
|
"props.filterFn 优先,便于页面动态换过滤条件",
|
|
62
73
|
"可与 Sort / Search / Pagination 串联"
|
|
63
|
-
],
|
|
74
|
+
], g = [
|
|
64
75
|
"分类 Tab 切换",
|
|
65
76
|
"只看有货 / 只看促销",
|
|
66
77
|
"价格区间筛选"
|
|
67
|
-
],
|
|
78
|
+
], y = [
|
|
68
79
|
"数据管线的执行顺序由 priority 决定:Filter(40) → Sort(30) → Search(20) → Pagination(10)。",
|
|
69
80
|
"先过滤再分页,页码总数才是过滤后的总数——顺序反了会出现「第 2 页空」。"
|
|
70
|
-
],
|
|
71
|
-
name:
|
|
81
|
+
], b = {
|
|
82
|
+
name: l,
|
|
72
83
|
description: c,
|
|
73
|
-
since:
|
|
74
|
-
tags:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
since: p,
|
|
85
|
+
tags: d,
|
|
86
|
+
events: m,
|
|
87
|
+
methods: u,
|
|
88
|
+
methodsNote: f,
|
|
89
|
+
config: h,
|
|
90
|
+
example: F,
|
|
91
|
+
features: T,
|
|
92
|
+
useCases: g,
|
|
93
|
+
notes: y
|
|
80
94
|
};
|
|
81
95
|
export {
|
|
82
|
-
|
|
83
|
-
|
|
96
|
+
v as c,
|
|
97
|
+
b as d
|
|
84
98
|
};
|