vane-waterfall 1.0.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -365
- package/dist/chunks/WaterfallCore-BSXw7bl_.js +581 -0
- package/dist/chunks/doc-3Fpag2G8.js +84 -0
- package/dist/chunks/doc-78xF08vt.js +82 -0
- package/dist/chunks/doc-B-7dugGv.js +79 -0
- package/dist/chunks/doc-B6kLfMPv.js +121 -0
- package/dist/chunks/doc-BCGQ8Cp5.js +114 -0
- package/dist/chunks/doc-BIzjYAZW.js +50 -0
- package/dist/chunks/doc-BP0DmB7-.js +91 -0
- package/dist/chunks/doc-BXElhF2h.js +138 -0
- package/dist/chunks/doc-BXSy2aPP.js +59 -0
- package/dist/chunks/doc-BfWnfTst.js +83 -0
- package/dist/chunks/doc-BtzhgTYj.js +85 -0
- package/dist/chunks/doc-C5xrHNoC.js +70 -0
- package/dist/chunks/doc-CBHjiDG7.js +88 -0
- package/dist/chunks/doc-CTUoMe7o.js +79 -0
- package/dist/chunks/doc-CcPFavOs.js +56 -0
- package/dist/chunks/doc-CraXjOaA.js +68 -0
- package/dist/chunks/doc-DElLNjIc.js +61 -0
- package/dist/chunks/doc-DJjxOYzW.js +111 -0
- package/dist/chunks/doc-DukOmDCo.js +95 -0
- package/dist/chunks/doc-DzvTrZ13.js +60 -0
- package/dist/chunks/doc-NhL4Ux8q.js +125 -0
- package/dist/chunks/doc-bTHwfIVb.js +78 -0
- package/dist/chunks/doc-f4Uijujv.js +102 -0
- package/dist/chunks/doc-gTAsLjVx.js +55 -0
- package/dist/chunks/doc-j4W9SUrY.js +76 -0
- package/dist/chunks/doc-kTbJE7rY.js +92 -0
- package/dist/chunks/index-BAWlVYr3.js +5 -0
- package/dist/chunks/index-COaun3nf.js +15 -0
- package/dist/chunks/index-DXAtA2f6.js +11 -0
- package/dist/chunks/index-DsRLmBW-.js +13 -0
- package/dist/chunks/index-gjoCq0yC.js +21 -0
- package/dist/chunks/index-wLI6UXkY.js +5 -0
- package/dist/chunks/withPlugins-DLoKg4AP.js +559 -0
- package/dist/components/WaterfallPlugin/WaterfallCore.d.ts +124 -0
- package/dist/components/WaterfallPlugin/WaterfallCore.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/index.d.ts +9 -10
- package/dist/components/WaterfallPlugin/index.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/layout.d.ts +41 -0
- package/dist/components/WaterfallPlugin/layout.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/plugins/types.d.ts +76 -380
- package/dist/components/WaterfallPlugin/plugins/types.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/virtualize.d.ts +62 -0
- package/dist/components/WaterfallPlugin/virtualize.d.ts.map +1 -0
- package/dist/components/WaterfallPlugin/{plugins/withPlugins.d.ts → withPlugins.d.ts} +4 -2
- package/dist/components/WaterfallPlugin/withPlugins.d.ts.map +1 -0
- package/dist/custom-plugins/A11yPlugin/create.d.ts +23 -0
- package/dist/custom-plugins/A11yPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/A11yPlugin/doc.json.d.ts +52 -0
- package/dist/custom-plugins/A11yPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/A11yPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/A11yPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Alignment/index.d.ts → custom-plugins/AlignmentPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/AlignmentPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/AlignmentPlugin/doc.json.d.ts +34 -0
- package/dist/custom-plugins/AlignmentPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/AlignmentPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/AlignmentPlugin/index.js +5 -0
- package/dist/custom-plugins/AutoColumnPlugin/create.d.ts +18 -0
- package/dist/custom-plugins/AutoColumnPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/AutoColumnPlugin/doc.json.d.ts +50 -0
- package/dist/custom-plugins/AutoColumnPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/AutoColumnPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/AutoColumnPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Bookmark/index.d.ts → custom-plugins/BookmarkPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/BookmarkPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/BookmarkPlugin/doc.json.d.ts +41 -0
- package/dist/custom-plugins/BookmarkPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/BookmarkPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/BookmarkPlugin/index.js +5 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts +25 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/doc.json.d.ts +41 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/DebounceLayout/index.d.ts → custom-plugins/DebounceLayoutPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/DebounceLayoutPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/DebounceLayoutPlugin/doc.json.d.ts +34 -0
- package/dist/custom-plugins/DebounceLayoutPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/DebounceLayoutPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/DebounceLayoutPlugin/index.js +5 -0
- package/dist/custom-plugins/DragReorderPlugin/create.d.ts +33 -0
- package/dist/custom-plugins/DragReorderPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/DragReorderPlugin/doc.json.d.ts +53 -0
- package/dist/custom-plugins/DragReorderPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/DragReorderPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/DragReorderPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Filter/index.d.ts → custom-plugins/FilterPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/FilterPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/FilterPlugin/doc.json.d.ts +47 -0
- package/dist/custom-plugins/FilterPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/FilterPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/FilterPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/FixedHeight/index.d.ts → custom-plugins/FixedHeightPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/FixedHeightPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/FixedHeightPlugin/doc.json.d.ts +34 -0
- package/dist/custom-plugins/FixedHeightPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/FixedHeightPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/FixedHeightPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Gap/index.d.ts → custom-plugins/GapPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/GapPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/GapPlugin/doc.json.d.ts +47 -0
- package/dist/custom-plugins/GapPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/GapPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/GapPlugin/index.js +5 -0
- package/dist/custom-plugins/GroupingPlugin/create.d.ts +16 -0
- package/dist/custom-plugins/GroupingPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/GroupingPlugin/doc.json.d.ts +40 -0
- package/dist/custom-plugins/GroupingPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/GroupingPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/GroupingPlugin/index.js +5 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts +31 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/doc.json.d.ts +43 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.js +5 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts +17 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/doc.json.d.ts +44 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/InfiniteScrollPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Pagination/index.d.ts → custom-plugins/PaginationPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/PaginationPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/PaginationPlugin/doc.json.d.ts +50 -0
- package/dist/custom-plugins/PaginationPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/PaginationPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/PaginationPlugin/index.js +5 -0
- package/dist/custom-plugins/PinItemPlugin/create.d.ts +23 -0
- package/dist/custom-plugins/PinItemPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/PinItemPlugin/doc.json.d.ts +43 -0
- package/dist/custom-plugins/PinItemPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/PinItemPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/PinItemPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Recycle/index.d.ts → custom-plugins/RecyclePlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/RecyclePlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/RecyclePlugin/doc.json.d.ts +35 -0
- package/dist/custom-plugins/RecyclePlugin/index.d.ts +11 -0
- package/dist/custom-plugins/RecyclePlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/RecyclePlugin/index.js +5 -0
- package/dist/custom-plugins/ReducedMotionPlugin/create.d.ts +25 -0
- package/dist/custom-plugins/ReducedMotionPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ReducedMotionPlugin/doc.json.d.ts +42 -0
- package/dist/custom-plugins/ReducedMotionPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/ReducedMotionPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ReducedMotionPlugin/index.js +5 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/create.d.ts +22 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/doc.json.d.ts +37 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/index.d.ts +10 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ResponsiveColumnsPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/ScrollAnchor/index.d.ts → custom-plugins/ScrollAnchorPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/ScrollAnchorPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ScrollAnchorPlugin/doc.json.d.ts +34 -0
- package/dist/custom-plugins/ScrollAnchorPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/ScrollAnchorPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ScrollAnchorPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Search/index.d.ts → custom-plugins/SearchPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/SearchPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/SearchPlugin/doc.json.d.ts +47 -0
- package/dist/custom-plugins/SearchPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/SearchPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/SearchPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Sort/index.d.ts → custom-plugins/SortPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/SortPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/SortPlugin/doc.json.d.ts +46 -0
- package/dist/custom-plugins/SortPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/SortPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/SortPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/StatePersistence/index.d.ts → custom-plugins/StatePersistencePlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/StatePersistencePlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/StatePersistencePlugin/doc.json.d.ts +47 -0
- package/dist/custom-plugins/StatePersistencePlugin/index.d.ts +11 -0
- package/dist/custom-plugins/StatePersistencePlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/StatePersistencePlugin/index.js +5 -0
- package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts +13 -0
- package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/StickyHeaderPlugin/doc.json.d.ts +40 -0
- package/dist/custom-plugins/StickyHeaderPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/StickyHeaderPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/StickyHeaderPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Throttle/index.d.ts → custom-plugins/ThrottlePlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/ThrottlePlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/ThrottlePlugin/doc.json.d.ts +40 -0
- package/dist/custom-plugins/ThrottlePlugin/index.d.ts +11 -0
- package/dist/custom-plugins/ThrottlePlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/ThrottlePlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/Transition/index.d.ts → custom-plugins/TransitionPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/TransitionPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/TransitionPlugin/doc.json.d.ts +43 -0
- package/dist/custom-plugins/TransitionPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/TransitionPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/TransitionPlugin/index.js +5 -0
- package/dist/{components/WaterfallPlugin/custom-plugins/URLSync/index.d.ts → custom-plugins/URLSyncPlugin/create.d.ts} +3 -3
- package/dist/custom-plugins/URLSyncPlugin/create.d.ts.map +1 -0
- package/dist/custom-plugins/URLSyncPlugin/doc.json.d.ts +41 -0
- package/dist/custom-plugins/URLSyncPlugin/index.d.ts +11 -0
- package/dist/custom-plugins/URLSyncPlugin/index.d.ts.map +1 -0
- package/dist/custom-plugins/URLSyncPlugin/index.js +5 -0
- package/dist/custom-plugins/index.d.ts +61 -0
- package/dist/custom-plugins/index.d.ts.map +1 -0
- package/dist/custom-plugins/index.js +34 -0
- package/dist/entries/core.d.ts +8 -0
- package/dist/entries/core.d.ts.map +1 -0
- package/dist/entries/core.js +7 -0
- package/dist/entries/plugins.d.ts +7 -0
- package/dist/entries/plugins.d.ts.map +1 -0
- package/dist/entries/plugins.js +36 -0
- package/dist/index.d.ts +14 -9
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/presets/dashboard/index.d.ts +13 -0
- package/dist/presets/dashboard/index.d.ts.map +1 -0
- package/dist/presets/dashboard/index.js +21 -0
- package/dist/presets/photo-feed/index.d.ts +13 -0
- package/dist/presets/photo-feed/index.d.ts.map +1 -0
- package/dist/presets/photo-feed/index.js +17 -0
- package/dist/presets/product-feed/index.d.ts +9 -0
- package/dist/presets/product-feed/index.d.ts.map +1 -0
- package/dist/presets/product-feed/index.js +23 -0
- package/package.json +222 -82
- package/dist/404.jpg +0 -0
- package/dist/components/WaterfallPlugin/core/WaterfallCore.d.ts +0 -174
- package/dist/components/WaterfallPlugin/custom-plugins/A11y/index.d.ts +0 -16
- package/dist/components/WaterfallPlugin/custom-plugins/AutoColumn/index.d.ts +0 -17
- package/dist/components/WaterfallPlugin/custom-plugins/ClickAnalytics/index.d.ts +0 -12
- package/dist/components/WaterfallPlugin/custom-plugins/DragReorder/index.d.ts +0 -13
- package/dist/components/WaterfallPlugin/custom-plugins/Grouping/index.d.ts +0 -12
- package/dist/components/WaterfallPlugin/custom-plugins/HeatmapAnalytics/index.d.ts +0 -14
- package/dist/components/WaterfallPlugin/custom-plugins/InfiniteScroll/index.d.ts +0 -13
- package/dist/components/WaterfallPlugin/custom-plugins/PinItem/index.d.ts +0 -13
- package/dist/components/WaterfallPlugin/custom-plugins/ReducedMotion/index.d.ts +0 -13
- package/dist/components/WaterfallPlugin/custom-plugins/ResponsiveColumns/index.d.ts +0 -10
- package/dist/components/WaterfallPlugin/custom-plugins/StickyHeader/index.d.ts +0 -11
- package/dist/components/WaterfallPlugin/custom-plugins/VirtualWaterfall/index.d.ts +0 -12
- package/dist/components/WaterfallPlugin/custom-plugins/index.d.ts +0 -30
- package/dist/components/WaterfallPlugin/plugins/PluginBus.d.ts +0 -2
- package/dist/components/WaterfallPlugin/plugins/PluginManager.d.ts +0 -2
- package/dist/components/WaterfallPlugin/plugins/index.d.ts +0 -8
- package/dist/index.es.js +0 -2382
- package/dist/index.umd.js +0 -30
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import { jsxs as Kt, jsx as $t } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Xt, useRef as c, useMemo as lt, useState as ut, useCallback as j, useEffect as vt, useImperativeHandle as Zt } from "react";
|
|
3
|
+
function Ot(r = 0) {
|
|
4
|
+
return typeof r == "number" ? { top: r, right: r, bottom: r, left: r } : {
|
|
5
|
+
top: r.top ?? 0,
|
|
6
|
+
right: r.right ?? 0,
|
|
7
|
+
bottom: r.bottom ?? 0,
|
|
8
|
+
left: r.left ?? 0
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function te(r, i) {
|
|
12
|
+
return typeof r == "number" && Number.isFinite(r) && r > 0 ? r : i && i > 0 ? i : 0;
|
|
13
|
+
}
|
|
14
|
+
function ee(r) {
|
|
15
|
+
const {
|
|
16
|
+
heights: i,
|
|
17
|
+
columnGap: f,
|
|
18
|
+
rowGap: o,
|
|
19
|
+
alignmentMode: p = "shortest",
|
|
20
|
+
estimateHeight: C,
|
|
21
|
+
hooks: s
|
|
22
|
+
} = r, u = Ot(r.padding), b = r.containerWidth, g = s?.calculateColumns?.(r.columns), m = Math.max(
|
|
23
|
+
1,
|
|
24
|
+
Math.round(
|
|
25
|
+
typeof g == "number" && Number.isFinite(g) ? g : r.columns
|
|
26
|
+
)
|
|
27
|
+
), I = (b - u.left - u.right - f * (m - 1)) / m, E = s?.calculateColumnWidth?.(
|
|
28
|
+
I,
|
|
29
|
+
m,
|
|
30
|
+
b
|
|
31
|
+
), S = typeof E == "number" && Number.isFinite(E) ? E : I, H = Array(m).fill(u.top), N = Array(m).fill(0), Q = /* @__PURE__ */ new Map();
|
|
32
|
+
let F = 0;
|
|
33
|
+
if (i.length === 0)
|
|
34
|
+
return {
|
|
35
|
+
columns: m,
|
|
36
|
+
columnWidth: S,
|
|
37
|
+
padding: u,
|
|
38
|
+
columnHeights: H,
|
|
39
|
+
totalHeight: u.top + u.bottom,
|
|
40
|
+
positions: Q,
|
|
41
|
+
estimatedCount: 0
|
|
42
|
+
};
|
|
43
|
+
for (let L = 0; L < i.length; L++) {
|
|
44
|
+
const J = i[L], V = te(J, C);
|
|
45
|
+
if (V === 0) continue;
|
|
46
|
+
typeof J == "number" && J > 0 || (F += 1);
|
|
47
|
+
let k = 0;
|
|
48
|
+
if (p === "sequential")
|
|
49
|
+
k = L % m;
|
|
50
|
+
else if (p === "balanced") {
|
|
51
|
+
let T = N[0];
|
|
52
|
+
for (let R = 1; R < m; R++)
|
|
53
|
+
N[R] < T && (T = N[R], k = R);
|
|
54
|
+
} else {
|
|
55
|
+
let T = H[0];
|
|
56
|
+
for (let R = 1; R < H.length; R++)
|
|
57
|
+
H[R] < T && (T = H[R], k = R);
|
|
58
|
+
}
|
|
59
|
+
let z = {
|
|
60
|
+
x: u.left + k * (S + f),
|
|
61
|
+
y: H[k],
|
|
62
|
+
width: S,
|
|
63
|
+
height: V,
|
|
64
|
+
column: k,
|
|
65
|
+
row: Math.floor(L / m)
|
|
66
|
+
};
|
|
67
|
+
const P = s?.calculateItemPosition?.(L, V, z);
|
|
68
|
+
if (P) {
|
|
69
|
+
const T = { ...z, ...P };
|
|
70
|
+
P.column !== void 0 && P.x === void 0 && (T.x = u.left + Math.min(Math.max(0, T.column), m - 1) * (S + f)), z = T;
|
|
71
|
+
}
|
|
72
|
+
Q.set(L, z);
|
|
73
|
+
const K = Math.min(
|
|
74
|
+
Math.max(0, z.column),
|
|
75
|
+
H.length - 1
|
|
76
|
+
);
|
|
77
|
+
H[K] = z.y + z.height + o, N[K] += 1;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
columns: m,
|
|
81
|
+
columnWidth: S,
|
|
82
|
+
padding: u,
|
|
83
|
+
columnHeights: H,
|
|
84
|
+
totalHeight: Math.max(...H) + u.bottom,
|
|
85
|
+
positions: Q,
|
|
86
|
+
estimatedCount: F
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function ne(r, i, f = "start", o = 0) {
|
|
90
|
+
let p = r.y + o;
|
|
91
|
+
return f === "center" ? p -= i / 2 - r.height / 2 : f === "end" && (p -= i - r.height), Math.max(0, p);
|
|
92
|
+
}
|
|
93
|
+
const re = 8;
|
|
94
|
+
function oe(r, i, f = 0.5) {
|
|
95
|
+
const o = [];
|
|
96
|
+
for (const s of r)
|
|
97
|
+
Number.isFinite(s) && s > 0 && o.push(s);
|
|
98
|
+
if (o.length < re) return i;
|
|
99
|
+
o.sort((s, u) => s - u);
|
|
100
|
+
const p = Math.min(1, Math.max(0, f)), C = Math.min(o.length - 1, Math.round(p * (o.length - 1)));
|
|
101
|
+
return Math.max(1, Math.ceil(o[C]));
|
|
102
|
+
}
|
|
103
|
+
function ie(r, i, f, o, p = 1) {
|
|
104
|
+
if (i <= 0) return { start: 0, end: -1, hiddenCount: 0 };
|
|
105
|
+
if (r.size === 0) {
|
|
106
|
+
const v = Math.max(1, Math.ceil(o / 240) + 2);
|
|
107
|
+
return { start: 0, end: Math.min(i - 1, v - 1), hiddenCount: 0 };
|
|
108
|
+
}
|
|
109
|
+
const C = Math.max(0, o * p), s = f - C, u = f + Math.max(o, 1) + C;
|
|
110
|
+
let b = Number.POSITIVE_INFINITY, g = -1;
|
|
111
|
+
if (r.forEach((v, I) => {
|
|
112
|
+
const E = v.y;
|
|
113
|
+
v.y + v.height > s && E < u && (I < b && (b = I), I > g && (g = I));
|
|
114
|
+
}), g < 0) {
|
|
115
|
+
let v = 0, I = Number.POSITIVE_INFINITY;
|
|
116
|
+
r.forEach((S, H) => {
|
|
117
|
+
const N = Math.abs(S.y - f);
|
|
118
|
+
N < I && (I = N, v = H);
|
|
119
|
+
});
|
|
120
|
+
const E = Math.max(1, Math.ceil(o / 240) + 2);
|
|
121
|
+
b = Math.max(0, v - E), g = Math.min(i - 1, v + E);
|
|
122
|
+
}
|
|
123
|
+
b = Math.max(0, b), g = Math.min(i - 1, g), g < b && (g = b);
|
|
124
|
+
const m = g - b + 1;
|
|
125
|
+
return { start: b, end: g, hiddenCount: Math.max(0, i - m) };
|
|
126
|
+
}
|
|
127
|
+
function ce(r) {
|
|
128
|
+
return r ? r === !0 ? {
|
|
129
|
+
overscan: 1,
|
|
130
|
+
estimateHeight: 240,
|
|
131
|
+
dynamicHeights: !0,
|
|
132
|
+
adaptiveEstimate: !0,
|
|
133
|
+
estimateQuantile: 0.5
|
|
134
|
+
} : {
|
|
135
|
+
overscan: r.overscan ?? 1,
|
|
136
|
+
estimateHeight: r.estimateHeight ?? 240,
|
|
137
|
+
dynamicHeights: r.dynamicHeights ?? !0,
|
|
138
|
+
adaptiveEstimate: r.adaptiveEstimate ?? !0,
|
|
139
|
+
estimateQuantile: r.estimateQuantile ?? 0.5
|
|
140
|
+
} : null;
|
|
141
|
+
}
|
|
142
|
+
function kt(r, i, f, o) {
|
|
143
|
+
const p = i.y, C = i.y + i.height, s = f + o, u = Math.max(
|
|
144
|
+
0,
|
|
145
|
+
Math.min(s, C) - Math.max(f, p)
|
|
146
|
+
);
|
|
147
|
+
return {
|
|
148
|
+
index: r,
|
|
149
|
+
isVisible: u > 0,
|
|
150
|
+
visibleRatio: i.height > 0 ? Math.min(1, u / i.height) : 0,
|
|
151
|
+
isAboveViewport: C <= f,
|
|
152
|
+
isBelowViewport: p >= s
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const ue = Xt(
|
|
156
|
+
function(i, f) {
|
|
157
|
+
const {
|
|
158
|
+
items: o = [],
|
|
159
|
+
renderItem: p,
|
|
160
|
+
keyExtractor: C = (t, e) => e,
|
|
161
|
+
columns: s = 3,
|
|
162
|
+
gap: u = 16,
|
|
163
|
+
rowGap: b,
|
|
164
|
+
columnGap: g,
|
|
165
|
+
alignmentMode: m = "shortest",
|
|
166
|
+
padding: v = 0,
|
|
167
|
+
containerStyle: I,
|
|
168
|
+
containerClassName: E,
|
|
169
|
+
itemStyle: S,
|
|
170
|
+
itemClassName: H,
|
|
171
|
+
useTransform: N = !0,
|
|
172
|
+
throttleDelay: Q = 16,
|
|
173
|
+
debounceDelay: F = 150,
|
|
174
|
+
reachBottomOffset: L = 100,
|
|
175
|
+
virtualize: J,
|
|
176
|
+
layoutHooks: V,
|
|
177
|
+
onMount: k,
|
|
178
|
+
onUnmount: z,
|
|
179
|
+
onBeforeLayout: P,
|
|
180
|
+
onLayout: K,
|
|
181
|
+
onLayoutComplete: T,
|
|
182
|
+
onItemMount: R,
|
|
183
|
+
onItemUnmount: At,
|
|
184
|
+
onItemEnterViewport: ht,
|
|
185
|
+
onItemLeaveViewport: ft,
|
|
186
|
+
onScroll: Rt,
|
|
187
|
+
onResize: It,
|
|
188
|
+
onReachBottom: mt,
|
|
189
|
+
onItemClick: Bt,
|
|
190
|
+
children: Ft,
|
|
191
|
+
containerRefExternal: Pt,
|
|
192
|
+
itemRefsExternal: Gt,
|
|
193
|
+
debug: gt = !1
|
|
194
|
+
} = i, _t = c(null), y = Pt ?? _t, xt = c(/* @__PURE__ */ new Map()), O = Gt ?? xt, $ = c(/* @__PURE__ */ new Map()), q = c(/* @__PURE__ */ new Map()), rt = c(null), X = c(), Z = c(), D = c(null), Tt = c(0), tt = c(!1), dt = c(0), pt = c(!1), Wt = c(""), Ct = c(void 0), ot = c(async () => {
|
|
195
|
+
}), et = c(!1), nt = c(!1), yt = c(/* @__PURE__ */ new Set()), bt = c(o);
|
|
196
|
+
bt.current = o;
|
|
197
|
+
const A = c(/* @__PURE__ */ new Map()), it = b ?? u, U = g ?? u, G = lt(() => Ot(v), [v]), Et = JSON.stringify(J ?? null), a = lt(
|
|
198
|
+
() => ce(JSON.parse(Et) ?? void 0),
|
|
199
|
+
[Et]
|
|
200
|
+
), [_, Qt] = ut(() => ({
|
|
201
|
+
columns: s,
|
|
202
|
+
columnWidth: 0,
|
|
203
|
+
gap: U,
|
|
204
|
+
columnHeights: Array(s).fill(0),
|
|
205
|
+
totalHeight: 0,
|
|
206
|
+
containerWidth: 0,
|
|
207
|
+
containerHeight: 0
|
|
208
|
+
})), [ct, qt] = ut(
|
|
209
|
+
() => /* @__PURE__ */ new Map()
|
|
210
|
+
), [B, St] = ut({
|
|
211
|
+
scrollTop: 0,
|
|
212
|
+
scrollLeft: 0,
|
|
213
|
+
scrollHeight: 0,
|
|
214
|
+
scrollWidth: 0,
|
|
215
|
+
clientHeight: 0,
|
|
216
|
+
clientWidth: 0,
|
|
217
|
+
isScrolling: !1,
|
|
218
|
+
direction: null
|
|
219
|
+
}), [, Dt] = ut({});
|
|
220
|
+
A.current = ct;
|
|
221
|
+
const Ht = c(_), Y = j(async () => {
|
|
222
|
+
const t = y.current;
|
|
223
|
+
if (!t) return;
|
|
224
|
+
const e = `${s}|${U}|${it}|${G.top},${G.right},${G.bottom},${G.left}|${m}|${a?.estimateHeight ?? ""}|${a?.adaptiveEstimate ?? ""}|${a?.estimateQuantile ?? ""}`;
|
|
225
|
+
if (tt.current) {
|
|
226
|
+
(e !== Wt.current || V !== Ct.current) && (pt.current = !0);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (tt.current = !0, Wt.current = e, Ct.current = V, nt.current = !1, await P?.() === !1) {
|
|
230
|
+
tt.current = !1;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
gt && console.time("[WaterfallCore] layout"), K?.();
|
|
234
|
+
const l = t.clientWidth, W = bt.current.map((M, at) => {
|
|
235
|
+
const Mt = O.current.get(at)?.offsetHeight ?? 0;
|
|
236
|
+
return Mt > 0 ? ($.current.set(at, Mt), Mt) : $.current.get(at) ?? 0;
|
|
237
|
+
});
|
|
238
|
+
let h;
|
|
239
|
+
if (a)
|
|
240
|
+
if (a.adaptiveEstimate === !1)
|
|
241
|
+
h = a.estimateHeight;
|
|
242
|
+
else {
|
|
243
|
+
const M = oe(
|
|
244
|
+
$.current.values(),
|
|
245
|
+
a.estimateHeight ?? 240,
|
|
246
|
+
a.estimateQuantile
|
|
247
|
+
);
|
|
248
|
+
Math.abs(M - dt.current) > 8 && (dt.current = M), h = dt.current || M;
|
|
249
|
+
}
|
|
250
|
+
const d = ee({
|
|
251
|
+
heights: W,
|
|
252
|
+
columns: s,
|
|
253
|
+
containerWidth: l,
|
|
254
|
+
columnGap: U,
|
|
255
|
+
rowGap: it,
|
|
256
|
+
padding: G,
|
|
257
|
+
alignmentMode: m,
|
|
258
|
+
estimateHeight: h,
|
|
259
|
+
hooks: V
|
|
260
|
+
}), w = {
|
|
261
|
+
columns: d.columns,
|
|
262
|
+
columnWidth: d.columnWidth,
|
|
263
|
+
gap: U,
|
|
264
|
+
columnHeights: d.columnHeights,
|
|
265
|
+
totalHeight: d.totalHeight,
|
|
266
|
+
containerWidth: l,
|
|
267
|
+
containerHeight: t.clientHeight
|
|
268
|
+
};
|
|
269
|
+
Ht.current = w, A.current = d.positions, Qt(w), qt(d.positions), et.current = !0, gt && (console.timeEnd("[WaterfallCore] layout"), d.estimatedCount > 0 && console.debug(
|
|
270
|
+
`[WaterfallCore] ${d.estimatedCount} 项按估值占位(estimateHeight=${h})`
|
|
271
|
+
)), T?.(), tt.current = !1, pt.current && (pt.current = !1, ot.current());
|
|
272
|
+
}, [
|
|
273
|
+
s,
|
|
274
|
+
U,
|
|
275
|
+
it,
|
|
276
|
+
G,
|
|
277
|
+
m,
|
|
278
|
+
a?.estimateHeight,
|
|
279
|
+
V,
|
|
280
|
+
P,
|
|
281
|
+
K,
|
|
282
|
+
T,
|
|
283
|
+
gt,
|
|
284
|
+
y,
|
|
285
|
+
O
|
|
286
|
+
]);
|
|
287
|
+
ot.current = Y;
|
|
288
|
+
const st = j(() => {
|
|
289
|
+
Z.current && window.clearTimeout(Z.current), Z.current = window.setTimeout(() => {
|
|
290
|
+
ot.current();
|
|
291
|
+
}, F);
|
|
292
|
+
}, [F]), Lt = j(() => {
|
|
293
|
+
D.current == null && (D.current = requestAnimationFrame(() => {
|
|
294
|
+
D.current = null, ot.current();
|
|
295
|
+
}));
|
|
296
|
+
}, []), Nt = j((t) => {
|
|
297
|
+
const e = y.current;
|
|
298
|
+
e && St((n) => {
|
|
299
|
+
const l = e.scrollTop, W = e.scrollLeft, h = l > n.scrollTop ? "down" : l < n.scrollTop ? "up" : W > n.scrollLeft ? "right" : W < n.scrollLeft ? "left" : n.direction;
|
|
300
|
+
return {
|
|
301
|
+
scrollTop: l,
|
|
302
|
+
scrollLeft: W,
|
|
303
|
+
scrollHeight: e.scrollHeight,
|
|
304
|
+
scrollWidth: e.scrollWidth,
|
|
305
|
+
clientHeight: e.clientHeight,
|
|
306
|
+
clientWidth: e.clientWidth,
|
|
307
|
+
isScrolling: t,
|
|
308
|
+
direction: h
|
|
309
|
+
};
|
|
310
|
+
});
|
|
311
|
+
}, [y]), Ut = j(() => {
|
|
312
|
+
const t = y.current;
|
|
313
|
+
if (!t) return;
|
|
314
|
+
const e = Date.now();
|
|
315
|
+
Nt(!0);
|
|
316
|
+
const n = t.scrollTop, { clientHeight: l, scrollHeight: W } = t;
|
|
317
|
+
if (Rt?.(n, t.scrollLeft), e - Tt.current >= Q) {
|
|
318
|
+
if (Tt.current = e, mt) {
|
|
319
|
+
const h = W - (n + l);
|
|
320
|
+
h < L && mt(h);
|
|
321
|
+
}
|
|
322
|
+
if (ht || ft) {
|
|
323
|
+
const h = A.current, d = /* @__PURE__ */ new Set();
|
|
324
|
+
h.forEach((w, M) => {
|
|
325
|
+
Math.max(
|
|
326
|
+
0,
|
|
327
|
+
Math.min(n + l, w.y + w.height) - Math.max(n, w.y)
|
|
328
|
+
) > 0 && (d.add(M), yt.current.has(M) || ht?.(
|
|
329
|
+
M,
|
|
330
|
+
kt(M, w, n, l)
|
|
331
|
+
));
|
|
332
|
+
}), yt.current.forEach((w) => {
|
|
333
|
+
if (d.has(w)) return;
|
|
334
|
+
const M = h.get(w);
|
|
335
|
+
M && ft?.(
|
|
336
|
+
w,
|
|
337
|
+
kt(w, M, n, l)
|
|
338
|
+
);
|
|
339
|
+
}), yt.current = d;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
X.current && window.clearTimeout(X.current), X.current = window.setTimeout(() => {
|
|
343
|
+
St((h) => ({ ...h, isScrolling: !1 }));
|
|
344
|
+
}, F);
|
|
345
|
+
}, [
|
|
346
|
+
Nt,
|
|
347
|
+
Rt,
|
|
348
|
+
mt,
|
|
349
|
+
ht,
|
|
350
|
+
ft,
|
|
351
|
+
Q,
|
|
352
|
+
F,
|
|
353
|
+
L
|
|
354
|
+
]), Yt = j(() => {
|
|
355
|
+
const t = y.current;
|
|
356
|
+
t && (It?.(t.clientWidth, t.clientHeight), st());
|
|
357
|
+
}, [It, st, y]);
|
|
358
|
+
vt(() => {
|
|
359
|
+
k?.(), et.current || Y();
|
|
360
|
+
const t = y.current;
|
|
361
|
+
return t && typeof ResizeObserver < "u" && (rt.current = new ResizeObserver(Yt), rt.current.observe(t)), () => {
|
|
362
|
+
z?.(), rt.current?.disconnect(), rt.current = null, q.current.forEach((e) => {
|
|
363
|
+
try {
|
|
364
|
+
e.disconnect();
|
|
365
|
+
} catch {
|
|
366
|
+
}
|
|
367
|
+
}), q.current.clear(), X.current && window.clearTimeout(X.current), Z.current && window.clearTimeout(Z.current), D.current != null && (cancelAnimationFrame(D.current), D.current = null);
|
|
368
|
+
};
|
|
369
|
+
}, []);
|
|
370
|
+
const wt = c(/* @__PURE__ */ new Map());
|
|
371
|
+
vt(() => {
|
|
372
|
+
et.current = !1, nt.current = !1, wt.current.clear(), st();
|
|
373
|
+
}, [o, st]), vt(() => {
|
|
374
|
+
et.current = !1, nt.current = !1, Y();
|
|
375
|
+
}, [
|
|
376
|
+
s,
|
|
377
|
+
U,
|
|
378
|
+
it,
|
|
379
|
+
G,
|
|
380
|
+
m,
|
|
381
|
+
a?.estimateHeight,
|
|
382
|
+
a?.adaptiveEstimate,
|
|
383
|
+
a?.estimateQuantile,
|
|
384
|
+
V
|
|
385
|
+
]);
|
|
386
|
+
const Vt = c(
|
|
387
|
+
() => {
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
Vt.current = (t, e) => {
|
|
391
|
+
if (e) {
|
|
392
|
+
O.current.set(t, e);
|
|
393
|
+
const n = e.offsetHeight;
|
|
394
|
+
if (n > 0 && $.current.set(t, n), (a ? a.dynamicHeights !== !1 : !0) && !q.current.has(t) && typeof ResizeObserver < "u") {
|
|
395
|
+
const W = new ResizeObserver(() => {
|
|
396
|
+
const h = e.offsetHeight;
|
|
397
|
+
if (h <= 0) return;
|
|
398
|
+
$.current.set(t, h);
|
|
399
|
+
const d = A.current.get(t), w = d ? Math.abs(d.height - h) > 0.5 : !1, M = wt.current.get(t) === h;
|
|
400
|
+
d ? w && !M && (wt.current.set(t, h), Lt()) : Lt();
|
|
401
|
+
});
|
|
402
|
+
try {
|
|
403
|
+
W.observe(e), q.current.set(t, W);
|
|
404
|
+
} catch {
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
R?.(t, e), et.current && !A.current.has(t) && !tt.current && !nt.current && (nt.current = !0, requestAnimationFrame(() => void Y()));
|
|
408
|
+
} else {
|
|
409
|
+
O.current.delete(t);
|
|
410
|
+
const n = q.current.get(t);
|
|
411
|
+
if (n) {
|
|
412
|
+
try {
|
|
413
|
+
n.disconnect();
|
|
414
|
+
} catch {
|
|
415
|
+
}
|
|
416
|
+
q.current.delete(t);
|
|
417
|
+
}
|
|
418
|
+
At?.(t);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
const zt = c(
|
|
422
|
+
/* @__PURE__ */ new Map()
|
|
423
|
+
), jt = (t) => {
|
|
424
|
+
let e = zt.current.get(t);
|
|
425
|
+
return e || (e = (n) => Vt.current(t, n), zt.current.set(t, e)), e;
|
|
426
|
+
}, x = lt(
|
|
427
|
+
() => a ? ie(
|
|
428
|
+
ct,
|
|
429
|
+
o.length,
|
|
430
|
+
B.scrollTop,
|
|
431
|
+
B.clientHeight || _.containerHeight || 600,
|
|
432
|
+
a.overscan
|
|
433
|
+
) : { start: 0, end: Math.max(0, o.length - 1), hiddenCount: 0 },
|
|
434
|
+
[
|
|
435
|
+
a,
|
|
436
|
+
ct,
|
|
437
|
+
o.length,
|
|
438
|
+
B.scrollTop,
|
|
439
|
+
B.clientHeight,
|
|
440
|
+
_.containerHeight
|
|
441
|
+
]
|
|
442
|
+
);
|
|
443
|
+
Zt(
|
|
444
|
+
f,
|
|
445
|
+
() => ({
|
|
446
|
+
relayout: () => {
|
|
447
|
+
$.current.clear(), bt.current.forEach((t, e) => {
|
|
448
|
+
const n = O.current.get(e);
|
|
449
|
+
n && $.current.set(e, n.offsetHeight);
|
|
450
|
+
}), Y();
|
|
451
|
+
},
|
|
452
|
+
scrollToItem: (t, e = {}) => {
|
|
453
|
+
const n = y.current, l = A.current.get(t);
|
|
454
|
+
!n || !l || n.scrollTo({
|
|
455
|
+
top: ne(
|
|
456
|
+
l,
|
|
457
|
+
n.clientHeight,
|
|
458
|
+
e.block ?? "start",
|
|
459
|
+
e.offset ?? 0
|
|
460
|
+
),
|
|
461
|
+
behavior: e.behavior ?? "auto"
|
|
462
|
+
});
|
|
463
|
+
},
|
|
464
|
+
scrollToTop: (t = {}) => {
|
|
465
|
+
y.current?.scrollTo({
|
|
466
|
+
top: t.offset ?? 0,
|
|
467
|
+
behavior: t.behavior ?? "auto"
|
|
468
|
+
});
|
|
469
|
+
},
|
|
470
|
+
scrollToBottom: (t = {}) => {
|
|
471
|
+
const e = y.current;
|
|
472
|
+
e && e.scrollTo({
|
|
473
|
+
top: e.scrollHeight - e.clientHeight + (t.offset ?? 0),
|
|
474
|
+
behavior: t.behavior ?? "auto"
|
|
475
|
+
});
|
|
476
|
+
},
|
|
477
|
+
getItemPosition: (t) => A.current.get(t) ?? null,
|
|
478
|
+
getAllItemPositions: () => A.current,
|
|
479
|
+
getColumnHeights: () => Ht.current.columnHeights,
|
|
480
|
+
getLayoutInfo: () => Ht.current,
|
|
481
|
+
getViewportInfo: () => {
|
|
482
|
+
const t = y.current;
|
|
483
|
+
return t ? {
|
|
484
|
+
scrollTop: t.scrollTop,
|
|
485
|
+
scrollLeft: t.scrollLeft,
|
|
486
|
+
scrollHeight: t.scrollHeight,
|
|
487
|
+
scrollWidth: t.scrollWidth,
|
|
488
|
+
clientHeight: t.clientHeight,
|
|
489
|
+
clientWidth: t.clientWidth,
|
|
490
|
+
isScrolling: B.isScrolling,
|
|
491
|
+
direction: B.direction
|
|
492
|
+
} : B;
|
|
493
|
+
},
|
|
494
|
+
getVisibleRange: () => ({ start: x.start, end: x.end }),
|
|
495
|
+
forceUpdate: () => Dt({}),
|
|
496
|
+
getContainer: () => y.current,
|
|
497
|
+
getItemElement: (t) => O.current.get(t) ?? null,
|
|
498
|
+
measureItem: async (t) => {
|
|
499
|
+
const e = O.current.get(t);
|
|
500
|
+
if (e) {
|
|
501
|
+
const l = { width: e.offsetWidth, height: e.offsetHeight };
|
|
502
|
+
return l.height > 0 && $.current.set(t, l.height), l;
|
|
503
|
+
}
|
|
504
|
+
const n = $.current.get(t);
|
|
505
|
+
return n ? { width: _.columnWidth, height: n } : { width: _.columnWidth, height: a?.estimateHeight ?? 0 };
|
|
506
|
+
}
|
|
507
|
+
}),
|
|
508
|
+
[Y, _, B, x, y, O, a?.estimateHeight]
|
|
509
|
+
);
|
|
510
|
+
const Jt = lt(() => {
|
|
511
|
+
if (!a) return o.map((e, n) => n);
|
|
512
|
+
const t = [];
|
|
513
|
+
for (let e = x.start; e <= x.end; e++) t.push(e);
|
|
514
|
+
return t;
|
|
515
|
+
}, [a, o, x.start, x.end]);
|
|
516
|
+
return /* @__PURE__ */ Kt(
|
|
517
|
+
"div",
|
|
518
|
+
{
|
|
519
|
+
ref: y,
|
|
520
|
+
style: {
|
|
521
|
+
position: "relative",
|
|
522
|
+
overflowX: "hidden",
|
|
523
|
+
overflowY: "auto",
|
|
524
|
+
...I
|
|
525
|
+
},
|
|
526
|
+
className: E,
|
|
527
|
+
onScroll: Ut,
|
|
528
|
+
"data-vane-waterfall": "",
|
|
529
|
+
children: [
|
|
530
|
+
Ft,
|
|
531
|
+
/* @__PURE__ */ $t(
|
|
532
|
+
"div",
|
|
533
|
+
{
|
|
534
|
+
style: {
|
|
535
|
+
position: "relative",
|
|
536
|
+
width: "100%",
|
|
537
|
+
height: _.totalHeight,
|
|
538
|
+
minWidth: 0
|
|
539
|
+
},
|
|
540
|
+
children: Jt.map((t) => {
|
|
541
|
+
const e = o[t];
|
|
542
|
+
if (e === void 0) return null;
|
|
543
|
+
const n = ct.get(t), l = n ? N ? {
|
|
544
|
+
position: "absolute",
|
|
545
|
+
transform: `translate(${n.x}px, ${n.y}px)`,
|
|
546
|
+
width: n.width,
|
|
547
|
+
boxSizing: "border-box"
|
|
548
|
+
} : {
|
|
549
|
+
position: "absolute",
|
|
550
|
+
left: n.x,
|
|
551
|
+
top: n.y,
|
|
552
|
+
width: n.width,
|
|
553
|
+
boxSizing: "border-box"
|
|
554
|
+
} : { position: "absolute", opacity: 0, pointerEvents: "none" };
|
|
555
|
+
return /* @__PURE__ */ $t(
|
|
556
|
+
"div",
|
|
557
|
+
{
|
|
558
|
+
ref: jt(t),
|
|
559
|
+
style: { ...l, ...S },
|
|
560
|
+
className: H,
|
|
561
|
+
onClick: (W) => Bt?.(t, e, W),
|
|
562
|
+
"data-index": t,
|
|
563
|
+
"data-column": n?.column,
|
|
564
|
+
children: p(e, t)
|
|
565
|
+
},
|
|
566
|
+
C(e, t)
|
|
567
|
+
);
|
|
568
|
+
})
|
|
569
|
+
}
|
|
570
|
+
)
|
|
571
|
+
]
|
|
572
|
+
}
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
);
|
|
576
|
+
export {
|
|
577
|
+
ue as W,
|
|
578
|
+
ne as a,
|
|
579
|
+
ie as b,
|
|
580
|
+
ee as c
|
|
581
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function g(o = {}) {
|
|
2
|
+
return {
|
|
3
|
+
name: "FilterPlugin",
|
|
4
|
+
priority: 40,
|
|
5
|
+
enabled: !0,
|
|
6
|
+
hooks: {
|
|
7
|
+
transformProps: (e) => {
|
|
8
|
+
const n = Array.isArray(e.items) ? e.items : [], t = e.filterFn || o.predicate;
|
|
9
|
+
if (typeof t != "function") return e;
|
|
10
|
+
const r = n.filter((a, i) => {
|
|
11
|
+
try {
|
|
12
|
+
return !!t(a, i);
|
|
13
|
+
} catch {
|
|
14
|
+
return !0;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return { ...e, items: r };
|
|
18
|
+
},
|
|
19
|
+
onPropsChange: (e, n, t) => {
|
|
20
|
+
const r = n?.filterFn, a = t?.filterFn;
|
|
21
|
+
if (((typeof t?.scrollToTopOnFilterChange == "boolean" ? t.scrollToTopOnFilterChange : void 0) ?? !!o.scrollToTop) && r !== a) {
|
|
22
|
+
const l = t?.scrollToTopBehavior ?? o.scrollBehavior ?? "auto";
|
|
23
|
+
e.scrollToTop?.({ behavior: l });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const s = "FilterPlugin", c = "用谓词函数过滤数据,优先读 `props.filterFn`,没有就用工厂里传入的 predicate。过滤条件变了可以自动滚回顶部(默认不开)。", u = "2.0.0", f = [
|
|
30
|
+
"data",
|
|
31
|
+
"数据管线"
|
|
32
|
+
], d = [
|
|
33
|
+
{
|
|
34
|
+
name: "predicate",
|
|
35
|
+
type: "(item, index) => boolean",
|
|
36
|
+
default: "—",
|
|
37
|
+
description: "默认谓词,可被 props.filterFn 覆盖"
|
|
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
|
+
], p = `// 按谓词过滤 items,参数变化可自动回顶。
|
|
52
|
+
const Waterfall = withPlugins(WaterfallCore, [
|
|
53
|
+
createFilterPlugin({
|
|
54
|
+
scrollToTop: false,
|
|
55
|
+
scrollBehavior: "auto",
|
|
56
|
+
}),
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, m = [
|
|
60
|
+
"谓词抛错时按「保留」处理,不会整表消失",
|
|
61
|
+
"props.filterFn 优先,便于页面动态换过滤条件",
|
|
62
|
+
"可与 Sort / Search / Pagination 串联"
|
|
63
|
+
], F = [
|
|
64
|
+
"分类 Tab 切换",
|
|
65
|
+
"只看有货 / 只看促销",
|
|
66
|
+
"价格区间筛选"
|
|
67
|
+
], h = [
|
|
68
|
+
"数据管线的执行顺序由 priority 决定:Filter(40) → Sort(30) → Search(20) → Pagination(10)。",
|
|
69
|
+
"先过滤再分页,页码总数才是过滤后的总数——顺序反了会出现「第 2 页空」。"
|
|
70
|
+
], y = {
|
|
71
|
+
name: s,
|
|
72
|
+
description: c,
|
|
73
|
+
since: u,
|
|
74
|
+
tags: f,
|
|
75
|
+
config: d,
|
|
76
|
+
example: p,
|
|
77
|
+
features: m,
|
|
78
|
+
useCases: F,
|
|
79
|
+
notes: h
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
g as c,
|
|
83
|
+
y as d
|
|
84
|
+
};
|