mimir-ui-kit 1.38.43 → 1.39.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/dist/assets/stories.css +1 -0
- package/dist/assets/styles2.css +1 -0
- package/dist/combobox-Dv6-ANkb.js +508 -0
- package/dist/components/Dropdown/Dropdown.js +176 -176
- package/dist/components/MultiSelectSearch/MultiSelectSearch.js +1 -1
- package/dist/components/SelectSearch/SelectSearch.js +1 -1
- package/dist/components/Table/ColumnOrderSettings.d.ts +18 -0
- package/dist/components/Table/ColumnOrderSettings.js +177 -0
- package/dist/components/Table/Table.d.ts +3 -0
- package/dist/components/Table/Table.js +204 -0
- package/dist/components/Table/TableBody.d.ts +5 -0
- package/dist/components/Table/TableBody.js +109 -0
- package/dist/components/Table/TableCard.d.ts +5 -0
- package/dist/components/Table/TableCard.js +45 -0
- package/dist/components/Table/TableCardsView.d.ts +5 -0
- package/dist/components/Table/TableCardsView.js +84 -0
- package/dist/components/Table/TableFilters.d.ts +12 -0
- package/dist/components/Table/TableFilters.js +165 -0
- package/dist/components/Table/TableHeader.d.ts +3 -0
- package/dist/components/Table/TableHeader.js +70 -0
- package/dist/components/Table/TableRow.d.ts +5 -0
- package/dist/components/Table/TableRow.js +76 -0
- package/dist/components/Table/TableScrollButtons.d.ts +11 -0
- package/dist/components/Table/TableScrollButtons.js +35 -0
- package/dist/components/Table/constants.d.ts +128 -0
- package/dist/components/Table/constants.js +434 -0
- package/dist/components/Table/hooks/index.d.ts +4 -0
- package/dist/components/Table/hooks/index.js +10 -0
- package/dist/components/Table/hooks/useTableInstance.d.ts +3 -0
- package/dist/components/Table/hooks/useTableInstance.js +68 -0
- package/dist/components/Table/hooks/useTableScroll.d.ts +8 -0
- package/dist/components/Table/hooks/useTableScroll.js +54 -0
- package/dist/components/Table/hooks/useTableState.d.ts +13 -0
- package/dist/components/Table/hooks/useTableState.js +56 -0
- package/dist/components/Table/hooks/useTableVirtualization.d.ts +13 -0
- package/dist/components/Table/hooks/useTableVirtualization.js +97 -0
- package/dist/components/Table/index.d.ts +3 -0
- package/dist/components/Table/index.js +10 -0
- package/dist/components/Table/types.d.ts +150 -0
- package/dist/components/Table/utils.d.ts +4 -0
- package/dist/components/Table/utils.js +25 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +72 -64
- package/dist/index-CVk4sixt.js +1862 -0
- package/dist/index-D5H8gPPn.js +546 -0
- package/dist/index.js +106 -98
- package/dist/{portal-D3A00sie.js → portal-C_u5auU1.js} +179 -183
- package/dist/stories.module-fud786VB.js +29 -0
- package/dist/styles.module--QBQYoA9.js +36 -0
- package/package.json +3 -1
- package/dist/combobox-BD-GHvMy.js +0 -980
@@ -0,0 +1,546 @@
|
|
1
|
+
import * as E from "react";
|
2
|
+
import { flushSync as w } from "react-dom";
|
3
|
+
function p(r, l, e) {
|
4
|
+
let s = e.initialDeps ?? [], t;
|
5
|
+
function n() {
|
6
|
+
var i, o, h, c;
|
7
|
+
let a;
|
8
|
+
e.key && ((i = e.debug) != null && i.call(e)) && (a = Date.now());
|
9
|
+
const u = r();
|
10
|
+
if (!(u.length !== s.length || u.some((m, f) => s[f] !== m)))
|
11
|
+
return t;
|
12
|
+
s = u;
|
13
|
+
let v;
|
14
|
+
if (e.key && ((o = e.debug) != null && o.call(e)) && (v = Date.now()), t = l(...u), e.key && ((h = e.debug) != null && h.call(e))) {
|
15
|
+
const m = Math.round((Date.now() - a) * 100) / 100, f = Math.round((Date.now() - v) * 100) / 100, x = f / 16, b = (g, z) => {
|
16
|
+
for (g = String(g); g.length < z; )
|
17
|
+
g = " " + g;
|
18
|
+
return g;
|
19
|
+
};
|
20
|
+
console.info(
|
21
|
+
`%c⏱ ${b(f, 5)} /${b(m, 5)} ms`,
|
22
|
+
`
|
23
|
+
font-size: .6rem;
|
24
|
+
font-weight: bold;
|
25
|
+
color: hsl(${Math.max(
|
26
|
+
0,
|
27
|
+
Math.min(120 - 120 * x, 120)
|
28
|
+
)}deg 100% 31%);`,
|
29
|
+
e == null ? void 0 : e.key
|
30
|
+
);
|
31
|
+
}
|
32
|
+
return (c = e == null ? void 0 : e.onChange) == null || c.call(e, t), t;
|
33
|
+
}
|
34
|
+
return n.updateDeps = (i) => {
|
35
|
+
s = i;
|
36
|
+
}, n;
|
37
|
+
}
|
38
|
+
function S(r, l) {
|
39
|
+
if (r === void 0)
|
40
|
+
throw new Error("Unexpected undefined");
|
41
|
+
return r;
|
42
|
+
}
|
43
|
+
const C = (r, l) => Math.abs(r - l) < 1, T = (r, l, e) => {
|
44
|
+
let s;
|
45
|
+
return function(...t) {
|
46
|
+
r.clearTimeout(s), s = r.setTimeout(() => l.apply(this, t), e);
|
47
|
+
};
|
48
|
+
}, _ = (r) => r, R = (r) => {
|
49
|
+
const l = Math.max(r.startIndex - r.overscan, 0), e = Math.min(r.endIndex + r.overscan, r.count - 1), s = [];
|
50
|
+
for (let t = l; t <= e; t++)
|
51
|
+
s.push(t);
|
52
|
+
return s;
|
53
|
+
}, D = (r, l) => {
|
54
|
+
const e = r.scrollElement;
|
55
|
+
if (!e)
|
56
|
+
return;
|
57
|
+
const s = r.targetWindow;
|
58
|
+
if (!s)
|
59
|
+
return;
|
60
|
+
const t = (i) => {
|
61
|
+
const { width: o, height: h } = i;
|
62
|
+
l({ width: Math.round(o), height: Math.round(h) });
|
63
|
+
};
|
64
|
+
if (t(e.getBoundingClientRect()), !s.ResizeObserver)
|
65
|
+
return () => {
|
66
|
+
};
|
67
|
+
const n = new s.ResizeObserver((i) => {
|
68
|
+
const o = () => {
|
69
|
+
const h = i[0];
|
70
|
+
if (h != null && h.borderBoxSize) {
|
71
|
+
const c = h.borderBoxSize[0];
|
72
|
+
if (c) {
|
73
|
+
t({ width: c.inlineSize, height: c.blockSize });
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
t(e.getBoundingClientRect());
|
78
|
+
};
|
79
|
+
r.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(o) : o();
|
80
|
+
});
|
81
|
+
return n.observe(e, { box: "border-box" }), () => {
|
82
|
+
n.unobserve(e);
|
83
|
+
};
|
84
|
+
}, M = {
|
85
|
+
passive: !0
|
86
|
+
}, y = typeof window > "u" ? !0 : "onscrollend" in window, A = (r, l) => {
|
87
|
+
const e = r.scrollElement;
|
88
|
+
if (!e)
|
89
|
+
return;
|
90
|
+
const s = r.targetWindow;
|
91
|
+
if (!s)
|
92
|
+
return;
|
93
|
+
let t = 0;
|
94
|
+
const n = r.options.useScrollendEvent && y ? () => {
|
95
|
+
} : T(
|
96
|
+
s,
|
97
|
+
() => {
|
98
|
+
l(t, !1);
|
99
|
+
},
|
100
|
+
r.options.isScrollingResetDelay
|
101
|
+
), i = (a) => () => {
|
102
|
+
const { horizontal: u, isRtl: d } = r.options;
|
103
|
+
t = u ? e.scrollLeft * (d && -1 || 1) : e.scrollTop, n(), l(t, a);
|
104
|
+
}, o = i(!0), h = i(!1);
|
105
|
+
h(), e.addEventListener("scroll", o, M);
|
106
|
+
const c = r.options.useScrollendEvent && y;
|
107
|
+
return c && e.addEventListener("scrollend", h, M), () => {
|
108
|
+
e.removeEventListener("scroll", o), c && e.removeEventListener("scrollend", h);
|
109
|
+
};
|
110
|
+
}, k = (r, l, e) => {
|
111
|
+
if (l != null && l.borderBoxSize) {
|
112
|
+
const s = l.borderBoxSize[0];
|
113
|
+
if (s)
|
114
|
+
return Math.round(
|
115
|
+
s[e.options.horizontal ? "inlineSize" : "blockSize"]
|
116
|
+
);
|
117
|
+
}
|
118
|
+
return Math.round(
|
119
|
+
r.getBoundingClientRect()[e.options.horizontal ? "width" : "height"]
|
120
|
+
);
|
121
|
+
}, F = (r, {
|
122
|
+
adjustments: l = 0,
|
123
|
+
behavior: e
|
124
|
+
}, s) => {
|
125
|
+
var t, n;
|
126
|
+
const i = r + l;
|
127
|
+
(n = (t = s.scrollElement) == null ? void 0 : t.scrollTo) == null || n.call(t, {
|
128
|
+
[s.options.horizontal ? "left" : "top"]: i,
|
129
|
+
behavior: e
|
130
|
+
});
|
131
|
+
};
|
132
|
+
class N {
|
133
|
+
constructor(l) {
|
134
|
+
this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollToIndexTimeoutId = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
|
135
|
+
let e = null;
|
136
|
+
const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((t) => {
|
137
|
+
t.forEach((n) => {
|
138
|
+
const i = () => {
|
139
|
+
this._measureElement(n.target, n);
|
140
|
+
};
|
141
|
+
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(i) : i();
|
142
|
+
});
|
143
|
+
}));
|
144
|
+
return {
|
145
|
+
disconnect: () => {
|
146
|
+
var t;
|
147
|
+
(t = s()) == null || t.disconnect(), e = null;
|
148
|
+
},
|
149
|
+
observe: (t) => {
|
150
|
+
var n;
|
151
|
+
return (n = s()) == null ? void 0 : n.observe(t, { box: "border-box" });
|
152
|
+
},
|
153
|
+
unobserve: (t) => {
|
154
|
+
var n;
|
155
|
+
return (n = s()) == null ? void 0 : n.unobserve(t);
|
156
|
+
}
|
157
|
+
};
|
158
|
+
})(), this.range = null, this.setOptions = (e) => {
|
159
|
+
Object.entries(e).forEach(([s, t]) => {
|
160
|
+
typeof t > "u" && delete e[s];
|
161
|
+
}), this.options = {
|
162
|
+
debug: !1,
|
163
|
+
initialOffset: 0,
|
164
|
+
overscan: 1,
|
165
|
+
paddingStart: 0,
|
166
|
+
paddingEnd: 0,
|
167
|
+
scrollPaddingStart: 0,
|
168
|
+
scrollPaddingEnd: 0,
|
169
|
+
horizontal: !1,
|
170
|
+
getItemKey: _,
|
171
|
+
rangeExtractor: R,
|
172
|
+
onChange: () => {
|
173
|
+
},
|
174
|
+
measureElement: k,
|
175
|
+
initialRect: { width: 0, height: 0 },
|
176
|
+
scrollMargin: 0,
|
177
|
+
gap: 0,
|
178
|
+
indexAttribute: "data-index",
|
179
|
+
initialMeasurementsCache: [],
|
180
|
+
lanes: 1,
|
181
|
+
isScrollingResetDelay: 150,
|
182
|
+
enabled: !0,
|
183
|
+
isRtl: !1,
|
184
|
+
useScrollendEvent: !1,
|
185
|
+
useAnimationFrameWithResizeObserver: !1,
|
186
|
+
...e
|
187
|
+
};
|
188
|
+
}, this.notify = (e) => {
|
189
|
+
var s, t;
|
190
|
+
(t = (s = this.options).onChange) == null || t.call(s, this, e);
|
191
|
+
}, this.maybeNotify = p(
|
192
|
+
() => (this.calculateRange(), [
|
193
|
+
this.isScrolling,
|
194
|
+
this.range ? this.range.startIndex : null,
|
195
|
+
this.range ? this.range.endIndex : null
|
196
|
+
]),
|
197
|
+
(e) => {
|
198
|
+
this.notify(e);
|
199
|
+
},
|
200
|
+
{
|
201
|
+
key: process.env.NODE_ENV !== "production" && "maybeNotify",
|
202
|
+
debug: () => this.options.debug,
|
203
|
+
initialDeps: [
|
204
|
+
this.isScrolling,
|
205
|
+
this.range ? this.range.startIndex : null,
|
206
|
+
this.range ? this.range.endIndex : null
|
207
|
+
]
|
208
|
+
}
|
209
|
+
), this.cleanup = () => {
|
210
|
+
this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
|
211
|
+
}, this._didMount = () => () => {
|
212
|
+
this.cleanup();
|
213
|
+
}, this._willUpdate = () => {
|
214
|
+
var e;
|
215
|
+
const s = this.options.enabled ? this.options.getScrollElement() : null;
|
216
|
+
if (this.scrollElement !== s) {
|
217
|
+
if (this.cleanup(), !s) {
|
218
|
+
this.maybeNotify();
|
219
|
+
return;
|
220
|
+
}
|
221
|
+
this.scrollElement = s, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((t) => {
|
222
|
+
this.observer.observe(t);
|
223
|
+
}), this._scrollToOffset(this.getScrollOffset(), {
|
224
|
+
adjustments: void 0,
|
225
|
+
behavior: void 0
|
226
|
+
}), this.unsubs.push(
|
227
|
+
this.options.observeElementRect(this, (t) => {
|
228
|
+
this.scrollRect = t, this.maybeNotify();
|
229
|
+
})
|
230
|
+
), this.unsubs.push(
|
231
|
+
this.options.observeElementOffset(this, (t, n) => {
|
232
|
+
this.scrollAdjustments = 0, this.scrollDirection = n ? this.getScrollOffset() < t ? "forward" : "backward" : null, this.scrollOffset = t, this.isScrolling = n, this.maybeNotify();
|
233
|
+
})
|
234
|
+
);
|
235
|
+
}
|
236
|
+
}, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, s) => {
|
237
|
+
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
238
|
+
for (let i = s - 1; i >= 0; i--) {
|
239
|
+
const o = e[i];
|
240
|
+
if (t.has(o.lane))
|
241
|
+
continue;
|
242
|
+
const h = n.get(
|
243
|
+
o.lane
|
244
|
+
);
|
245
|
+
if (h == null || o.end > h.end ? n.set(o.lane, o) : o.end < h.end && t.set(o.lane, !0), t.size === this.options.lanes)
|
246
|
+
break;
|
247
|
+
}
|
248
|
+
return n.size === this.options.lanes ? Array.from(n.values()).sort((i, o) => i.end === o.end ? i.index - o.index : i.end - o.end)[0] : void 0;
|
249
|
+
}, this.getMeasurementOptions = p(
|
250
|
+
() => [
|
251
|
+
this.options.count,
|
252
|
+
this.options.paddingStart,
|
253
|
+
this.options.scrollMargin,
|
254
|
+
this.options.getItemKey,
|
255
|
+
this.options.enabled
|
256
|
+
],
|
257
|
+
(e, s, t, n, i) => (this.pendingMeasuredCacheIndexes = [], {
|
258
|
+
count: e,
|
259
|
+
paddingStart: s,
|
260
|
+
scrollMargin: t,
|
261
|
+
getItemKey: n,
|
262
|
+
enabled: i
|
263
|
+
}),
|
264
|
+
{
|
265
|
+
key: !1
|
266
|
+
}
|
267
|
+
), this.getMeasurements = p(
|
268
|
+
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
269
|
+
({ count: e, paddingStart: s, scrollMargin: t, getItemKey: n, enabled: i }, o) => {
|
270
|
+
if (!i)
|
271
|
+
return this.measurementsCache = [], this.itemSizeCache.clear(), [];
|
272
|
+
this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((a) => {
|
273
|
+
this.itemSizeCache.set(a.key, a.size);
|
274
|
+
}));
|
275
|
+
const h = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
276
|
+
this.pendingMeasuredCacheIndexes = [];
|
277
|
+
const c = this.measurementsCache.slice(0, h);
|
278
|
+
for (let a = h; a < e; a++) {
|
279
|
+
const u = n(a), d = this.options.lanes === 1 ? c[a - 1] : this.getFurthestMeasurement(c, a), v = d ? d.end + this.options.gap : s + t, m = o.get(u), f = typeof m == "number" ? m : this.options.estimateSize(a), x = v + f, b = d ? d.lane : a % this.options.lanes;
|
280
|
+
c[a] = {
|
281
|
+
index: a,
|
282
|
+
start: v,
|
283
|
+
size: f,
|
284
|
+
end: x,
|
285
|
+
key: u,
|
286
|
+
lane: b
|
287
|
+
};
|
288
|
+
}
|
289
|
+
return this.measurementsCache = c, c;
|
290
|
+
},
|
291
|
+
{
|
292
|
+
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
293
|
+
debug: () => this.options.debug
|
294
|
+
}
|
295
|
+
), this.calculateRange = p(
|
296
|
+
() => [
|
297
|
+
this.getMeasurements(),
|
298
|
+
this.getSize(),
|
299
|
+
this.getScrollOffset(),
|
300
|
+
this.options.lanes
|
301
|
+
],
|
302
|
+
(e, s, t, n) => this.range = e.length > 0 && s > 0 ? W({
|
303
|
+
measurements: e,
|
304
|
+
outerSize: s,
|
305
|
+
scrollOffset: t,
|
306
|
+
lanes: n
|
307
|
+
}) : null,
|
308
|
+
{
|
309
|
+
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
310
|
+
debug: () => this.options.debug
|
311
|
+
}
|
312
|
+
), this.getVirtualIndexes = p(
|
313
|
+
() => {
|
314
|
+
let e = null, s = null;
|
315
|
+
const t = this.calculateRange();
|
316
|
+
return t && (e = t.startIndex, s = t.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, s]), [
|
317
|
+
this.options.rangeExtractor,
|
318
|
+
this.options.overscan,
|
319
|
+
this.options.count,
|
320
|
+
e,
|
321
|
+
s
|
322
|
+
];
|
323
|
+
},
|
324
|
+
(e, s, t, n, i) => n === null || i === null ? [] : e({
|
325
|
+
startIndex: n,
|
326
|
+
endIndex: i,
|
327
|
+
overscan: s,
|
328
|
+
count: t
|
329
|
+
}),
|
330
|
+
{
|
331
|
+
key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
|
332
|
+
debug: () => this.options.debug
|
333
|
+
}
|
334
|
+
), this.indexFromElement = (e) => {
|
335
|
+
const s = this.options.indexAttribute, t = e.getAttribute(s);
|
336
|
+
return t ? parseInt(t, 10) : (console.warn(
|
337
|
+
`Missing attribute name '${s}={index}' on measured element.`
|
338
|
+
), -1);
|
339
|
+
}, this._measureElement = (e, s) => {
|
340
|
+
const t = this.indexFromElement(e), n = this.measurementsCache[t];
|
341
|
+
if (!n)
|
342
|
+
return;
|
343
|
+
const i = n.key, o = this.elementsCache.get(i);
|
344
|
+
o !== e && (o && this.observer.unobserve(o), this.observer.observe(e), this.elementsCache.set(i, e)), e.isConnected && this.resizeItem(t, this.options.measureElement(e, s, this));
|
345
|
+
}, this.resizeItem = (e, s) => {
|
346
|
+
const t = this.measurementsCache[e];
|
347
|
+
if (!t)
|
348
|
+
return;
|
349
|
+
const n = this.itemSizeCache.get(t.key) ?? t.size, i = s - n;
|
350
|
+
i !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(t, i, this) : t.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", i), this._scrollToOffset(this.getScrollOffset(), {
|
351
|
+
adjustments: this.scrollAdjustments += i,
|
352
|
+
behavior: void 0
|
353
|
+
})), this.pendingMeasuredCacheIndexes.push(t.index), this.itemSizeCache = new Map(this.itemSizeCache.set(t.key, s)), this.notify(!1));
|
354
|
+
}, this.measureElement = (e) => {
|
355
|
+
if (!e) {
|
356
|
+
this.elementsCache.forEach((s, t) => {
|
357
|
+
s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(t));
|
358
|
+
});
|
359
|
+
return;
|
360
|
+
}
|
361
|
+
this._measureElement(e, void 0);
|
362
|
+
}, this.getVirtualItems = p(
|
363
|
+
() => [this.getVirtualIndexes(), this.getMeasurements()],
|
364
|
+
(e, s) => {
|
365
|
+
const t = [];
|
366
|
+
for (let n = 0, i = e.length; n < i; n++) {
|
367
|
+
const o = e[n], h = s[o];
|
368
|
+
t.push(h);
|
369
|
+
}
|
370
|
+
return t;
|
371
|
+
},
|
372
|
+
{
|
373
|
+
key: process.env.NODE_ENV !== "production" && "getVirtualItems",
|
374
|
+
debug: () => this.options.debug
|
375
|
+
}
|
376
|
+
), this.getVirtualItemForOffset = (e) => {
|
377
|
+
const s = this.getMeasurements();
|
378
|
+
if (s.length !== 0)
|
379
|
+
return S(
|
380
|
+
s[O(
|
381
|
+
0,
|
382
|
+
s.length - 1,
|
383
|
+
(t) => S(s[t]).start,
|
384
|
+
e
|
385
|
+
)]
|
386
|
+
);
|
387
|
+
}, this.getOffsetForAlignment = (e, s, t = 0) => {
|
388
|
+
const n = this.getSize(), i = this.getScrollOffset();
|
389
|
+
s === "auto" && (s = e >= i + n ? "end" : "start"), s === "center" ? e += (t - n) / 2 : s === "end" && (e -= n);
|
390
|
+
const o = this.options.horizontal ? "scrollWidth" : "scrollHeight", c = (this.scrollElement ? "document" in this.scrollElement ? this.scrollElement.document.documentElement[o] : this.scrollElement[o] : 0) - n;
|
391
|
+
return Math.max(Math.min(c, e), 0);
|
392
|
+
}, this.getOffsetForIndex = (e, s = "auto") => {
|
393
|
+
e = Math.max(0, Math.min(e, this.options.count - 1));
|
394
|
+
const t = this.measurementsCache[e];
|
395
|
+
if (!t)
|
396
|
+
return;
|
397
|
+
const n = this.getSize(), i = this.getScrollOffset();
|
398
|
+
if (s === "auto")
|
399
|
+
if (t.end >= i + n - this.options.scrollPaddingEnd)
|
400
|
+
s = "end";
|
401
|
+
else if (t.start <= i + this.options.scrollPaddingStart)
|
402
|
+
s = "start";
|
403
|
+
else
|
404
|
+
return [i, s];
|
405
|
+
const o = s === "end" ? t.end + this.options.scrollPaddingEnd : t.start - this.options.scrollPaddingStart;
|
406
|
+
return [
|
407
|
+
this.getOffsetForAlignment(o, s, t.size),
|
408
|
+
s
|
409
|
+
];
|
410
|
+
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.cancelScrollToIndex = () => {
|
411
|
+
this.scrollToIndexTimeoutId !== null && this.targetWindow && (this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId), this.scrollToIndexTimeoutId = null);
|
412
|
+
}, this.scrollToOffset = (e, { align: s = "start", behavior: t } = {}) => {
|
413
|
+
this.cancelScrollToIndex(), t === "smooth" && this.isDynamicMode() && console.warn(
|
414
|
+
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
415
|
+
), this._scrollToOffset(this.getOffsetForAlignment(e, s), {
|
416
|
+
adjustments: void 0,
|
417
|
+
behavior: t
|
418
|
+
});
|
419
|
+
}, this.scrollToIndex = (e, { align: s = "auto", behavior: t } = {}) => {
|
420
|
+
e = Math.max(0, Math.min(e, this.options.count - 1)), this.cancelScrollToIndex(), t === "smooth" && this.isDynamicMode() && console.warn(
|
421
|
+
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
422
|
+
);
|
423
|
+
const n = this.getOffsetForIndex(e, s);
|
424
|
+
if (!n) return;
|
425
|
+
const [i, o] = n;
|
426
|
+
this._scrollToOffset(i, { adjustments: void 0, behavior: t }), t !== "smooth" && this.isDynamicMode() && this.targetWindow && (this.scrollToIndexTimeoutId = this.targetWindow.setTimeout(() => {
|
427
|
+
if (this.scrollToIndexTimeoutId = null, this.elementsCache.has(
|
428
|
+
this.options.getItemKey(e)
|
429
|
+
)) {
|
430
|
+
const [c] = S(
|
431
|
+
this.getOffsetForIndex(e, o)
|
432
|
+
);
|
433
|
+
C(c, this.getScrollOffset()) || this.scrollToIndex(e, { align: o, behavior: t });
|
434
|
+
} else
|
435
|
+
this.scrollToIndex(e, { align: o, behavior: t });
|
436
|
+
}));
|
437
|
+
}, this.scrollBy = (e, { behavior: s } = {}) => {
|
438
|
+
this.cancelScrollToIndex(), s === "smooth" && this.isDynamicMode() && console.warn(
|
439
|
+
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
440
|
+
), this._scrollToOffset(this.getScrollOffset() + e, {
|
441
|
+
adjustments: void 0,
|
442
|
+
behavior: s
|
443
|
+
});
|
444
|
+
}, this.getTotalSize = () => {
|
445
|
+
var e;
|
446
|
+
const s = this.getMeasurements();
|
447
|
+
let t;
|
448
|
+
if (s.length === 0)
|
449
|
+
t = this.options.paddingStart;
|
450
|
+
else if (this.options.lanes === 1)
|
451
|
+
t = ((e = s[s.length - 1]) == null ? void 0 : e.end) ?? 0;
|
452
|
+
else {
|
453
|
+
const n = Array(this.options.lanes).fill(null);
|
454
|
+
let i = s.length - 1;
|
455
|
+
for (; i > 0 && n.some((o) => o === null); ) {
|
456
|
+
const o = s[i];
|
457
|
+
n[o.lane] === null && (n[o.lane] = o.end), i--;
|
458
|
+
}
|
459
|
+
t = Math.max(...n.filter((o) => o !== null));
|
460
|
+
}
|
461
|
+
return Math.max(
|
462
|
+
t - this.options.scrollMargin + this.options.paddingEnd,
|
463
|
+
0
|
464
|
+
);
|
465
|
+
}, this._scrollToOffset = (e, {
|
466
|
+
adjustments: s,
|
467
|
+
behavior: t
|
468
|
+
}) => {
|
469
|
+
this.options.scrollToFn(e, { behavior: t, adjustments: s }, this);
|
470
|
+
}, this.measure = () => {
|
471
|
+
this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
|
472
|
+
}, this.setOptions(l);
|
473
|
+
}
|
474
|
+
}
|
475
|
+
const O = (r, l, e, s) => {
|
476
|
+
for (; r <= l; ) {
|
477
|
+
const t = (r + l) / 2 | 0, n = e(t);
|
478
|
+
if (n < s)
|
479
|
+
r = t + 1;
|
480
|
+
else if (n > s)
|
481
|
+
l = t - 1;
|
482
|
+
else
|
483
|
+
return t;
|
484
|
+
}
|
485
|
+
return r > 0 ? r - 1 : 0;
|
486
|
+
};
|
487
|
+
function W({
|
488
|
+
measurements: r,
|
489
|
+
outerSize: l,
|
490
|
+
scrollOffset: e,
|
491
|
+
lanes: s
|
492
|
+
}) {
|
493
|
+
const t = r.length - 1, n = (h) => r[h].start;
|
494
|
+
if (r.length <= s)
|
495
|
+
return {
|
496
|
+
startIndex: 0,
|
497
|
+
endIndex: t
|
498
|
+
};
|
499
|
+
let i = O(
|
500
|
+
0,
|
501
|
+
t,
|
502
|
+
n,
|
503
|
+
e
|
504
|
+
), o = i;
|
505
|
+
if (s === 1)
|
506
|
+
for (; o < t && r[o].end < e + l; )
|
507
|
+
o++;
|
508
|
+
else if (s > 1) {
|
509
|
+
const h = Array(s).fill(0);
|
510
|
+
for (; o < t && h.some((a) => a < e + l); ) {
|
511
|
+
const a = r[o];
|
512
|
+
h[a.lane] = a.end, o++;
|
513
|
+
}
|
514
|
+
const c = Array(s).fill(e + l);
|
515
|
+
for (; i > 0 && c.some((a) => a >= e); ) {
|
516
|
+
const a = r[i];
|
517
|
+
c[a.lane] = a.start, i--;
|
518
|
+
}
|
519
|
+
i = Math.max(0, i - i % s), o = Math.min(t, o + (s - 1 - o % s));
|
520
|
+
}
|
521
|
+
return { startIndex: i, endIndex: o };
|
522
|
+
}
|
523
|
+
const I = typeof document < "u" ? E.useLayoutEffect : E.useEffect;
|
524
|
+
function V(r) {
|
525
|
+
const l = E.useReducer(() => ({}), {})[1], e = {
|
526
|
+
...r,
|
527
|
+
onChange: (t, n) => {
|
528
|
+
var i;
|
529
|
+
n ? w(l) : l(), (i = r.onChange) == null || i.call(r, t, n);
|
530
|
+
}
|
531
|
+
}, [s] = E.useState(
|
532
|
+
() => new N(e)
|
533
|
+
);
|
534
|
+
return s.setOptions(e), I(() => s._didMount(), []), I(() => s._willUpdate()), s;
|
535
|
+
}
|
536
|
+
function B(r) {
|
537
|
+
return V({
|
538
|
+
observeElementRect: D,
|
539
|
+
observeElementOffset: A,
|
540
|
+
scrollToFn: F,
|
541
|
+
...r
|
542
|
+
});
|
543
|
+
}
|
544
|
+
export {
|
545
|
+
B as u
|
546
|
+
};
|