@altinn/altinn-components 0.24.2 → 0.24.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/Checkmark-RgzvRNxP.js +25 -0
  2. package/dist/PersonCircle-DMwECpgW.js +25 -0
  3. package/dist/altinn-ds-overrides.css +5 -0
  4. package/dist/assets/AccountButton.css +1 -0
  5. package/dist/assets/EndUserLabel.css +1 -0
  6. package/dist/assets/GlobalMenuBase.css +1 -1
  7. package/dist/assets/MenuItemBase.css +1 -1
  8. package/dist/assets/MenuItemLabel.css +1 -1
  9. package/dist/components/Dialog/DialogListGroup.js +13 -32
  10. package/dist/components/Dropdown/DrawerBase.js +15 -8
  11. package/dist/components/Dropdown/DropdownBase.js +21 -21
  12. package/dist/components/DsComponents/index.js +23 -0
  13. package/dist/components/GlobalMenu/AccountButton.js +34 -12
  14. package/dist/components/GlobalMenu/AccountMenu.js +24 -24
  15. package/dist/components/GlobalMenu/EndUserLabel.js +13 -0
  16. package/dist/components/GlobalMenu/GlobalMenu.js +68 -60
  17. package/dist/components/GlobalMenu/GlobalMenuBase.js +9 -9
  18. package/dist/components/GlobalMenu/index.js +10 -8
  19. package/dist/components/Menu/MenuItemBase.js +5 -5
  20. package/dist/components/Menu/MenuItemLabel.js +21 -10
  21. package/dist/components/Menu/MenuItems.js +24 -23
  22. package/dist/components/Menu/MenuItemsVirtual.js +65 -602
  23. package/dist/components/index.js +266 -243
  24. package/dist/global.css +3 -0
  25. package/dist/index-DyDqjche.js +541 -0
  26. package/dist/index.js +256 -233
  27. package/dist/types/lib/components/Avatar/Examples.stories.d.ts +1 -1
  28. package/dist/types/lib/components/Avatar/avatar.stories.d.ts +1 -1
  29. package/dist/types/lib/components/Dropdown/DrawerBase.d.ts +2 -1
  30. package/dist/types/lib/components/Dropdown/DropdownBase.d.ts +2 -1
  31. package/dist/types/lib/components/DsComponents/DsComponents.stories.d.ts +23 -0
  32. package/dist/types/lib/components/DsComponents/index.d.ts +1 -0
  33. package/dist/types/lib/components/GlobalMenu/AccountMenu.d.ts +2 -2
  34. package/dist/types/lib/components/GlobalMenu/EndUserLabel.d.ts +5 -0
  35. package/dist/types/lib/components/GlobalMenu/GlobalMenu.d.ts +2 -1
  36. package/dist/types/lib/components/GlobalMenu/GlobalMenu.stories.d.ts +3 -1
  37. package/dist/types/lib/components/GlobalMenu/GlobalMenuBase.d.ts +3 -1
  38. package/dist/types/lib/components/GlobalMenu/index.d.ts +1 -0
  39. package/dist/types/lib/components/Header/LocaleSwitcher.stories.d.ts +1 -1
  40. package/dist/types/lib/components/Icon/IconOrAvatar.d.ts +1 -1
  41. package/dist/types/lib/components/Menu/Examples.stories.d.ts +4 -0
  42. package/dist/types/lib/components/Menu/MenuItemLabel.d.ts +2 -1
  43. package/dist/types/lib/components/Menu/MenuItems.d.ts +3 -1
  44. package/dist/types/lib/components/Search/AutocompleteBase.d.ts +1 -1
  45. package/dist/types/lib/components/Skeleton/Skeleton.d.ts +1 -1
  46. package/dist/types/lib/components/Transmission/Transmission.stories.d.ts +9 -9
  47. package/dist/types/lib/components/index.d.ts +1 -0
  48. package/dist/usePagination-CBMPUKt_.js +4073 -0
  49. package/package.json +4 -1
  50. package/dist/userMenuItems-vSWEGGu2.js +0 -84
@@ -0,0 +1,541 @@
1
+ import * as x from "react";
2
+ import { flushSync as I } from "react-dom";
3
+ function p(l, r, 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 = l();
10
+ if (!(u.length !== s.length || u.some((m, f) => s[f] !== m)))
11
+ return t;
12
+ s = u;
13
+ let b;
14
+ if (e.key && ((o = e.debug) != null && o.call(e)) && (b = Date.now()), t = r(...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() - b) * 100) / 100, S = f / 16, E = (g, w) => {
16
+ for (g = String(g); g.length < w; )
17
+ g = " " + g;
18
+ return g;
19
+ };
20
+ console.info(
21
+ `%c⏱ ${E(f, 5)} /${E(m, 5)} ms`,
22
+ `
23
+ font-size: .6rem;
24
+ font-weight: bold;
25
+ color: hsl(${Math.max(
26
+ 0,
27
+ Math.min(120 - 120 * S, 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 M(l, r) {
39
+ if (l === void 0)
40
+ throw new Error("Unexpected undefined");
41
+ return l;
42
+ }
43
+ const C = (l, r) => Math.abs(l - r) < 1, T = (l, r, e) => {
44
+ let s;
45
+ return function(...t) {
46
+ l.clearTimeout(s), s = l.setTimeout(() => r.apply(this, t), e);
47
+ };
48
+ }, _ = (l) => l, R = (l) => {
49
+ const r = Math.max(l.startIndex - l.overscan, 0), e = Math.min(l.endIndex + l.overscan, l.count - 1), s = [];
50
+ for (let t = r; t <= e; t++)
51
+ s.push(t);
52
+ return s;
53
+ }, D = (l, r) => {
54
+ const e = l.scrollElement;
55
+ if (!e)
56
+ return;
57
+ const s = l.targetWindow;
58
+ if (!s)
59
+ return;
60
+ const t = (i) => {
61
+ const { width: o, height: h } = i;
62
+ r({ 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
+ l.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(o) : o();
80
+ });
81
+ return n.observe(e, { box: "border-box" }), () => {
82
+ n.unobserve(e);
83
+ };
84
+ }, y = {
85
+ passive: !0
86
+ }, O = typeof window > "u" ? !0 : "onscrollend" in window, A = (l, r) => {
87
+ const e = l.scrollElement;
88
+ if (!e)
89
+ return;
90
+ const s = l.targetWindow;
91
+ if (!s)
92
+ return;
93
+ let t = 0;
94
+ const n = l.options.useScrollendEvent && O ? () => {
95
+ } : T(
96
+ s,
97
+ () => {
98
+ r(t, !1);
99
+ },
100
+ l.options.isScrollingResetDelay
101
+ ), i = (a) => () => {
102
+ const { horizontal: u, isRtl: d } = l.options;
103
+ t = u ? e.scrollLeft * (d && -1 || 1) : e.scrollTop, n(), r(t, a);
104
+ }, o = i(!0), h = i(!1);
105
+ h(), e.addEventListener("scroll", o, y);
106
+ const c = l.options.useScrollendEvent && O;
107
+ return c && e.addEventListener("scrollend", h, y), () => {
108
+ e.removeEventListener("scroll", o), c && e.removeEventListener("scrollend", h);
109
+ };
110
+ }, k = (l, r, e) => {
111
+ if (r != null && r.borderBoxSize) {
112
+ const s = r.borderBoxSize[0];
113
+ if (s)
114
+ return Math.round(
115
+ s[e.options.horizontal ? "inlineSize" : "blockSize"]
116
+ );
117
+ }
118
+ return Math.round(
119
+ l.getBoundingClientRect()[e.options.horizontal ? "width" : "height"]
120
+ );
121
+ }, F = (l, {
122
+ adjustments: r = 0,
123
+ behavior: e
124
+ }, s) => {
125
+ var t, n;
126
+ const i = l + r;
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(r) {
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), b = d ? d.end + this.options.gap : s + t, m = o.get(u), f = typeof m == "number" ? m : this.options.estimateSize(a), S = b + f, E = d ? d.lane : a % this.options.lanes;
280
+ c[a] = {
281
+ index: a,
282
+ start: b,
283
+ size: f,
284
+ end: S,
285
+ key: u,
286
+ lane: E
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 M(
380
+ s[z(
381
+ 0,
382
+ s.length - 1,
383
+ (t) => M(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] = M(
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(r);
473
+ }
474
+ }
475
+ const z = (l, r, e, s) => {
476
+ for (; l <= r; ) {
477
+ const t = (l + r) / 2 | 0, n = e(t);
478
+ if (n < s)
479
+ l = t + 1;
480
+ else if (n > s)
481
+ r = t - 1;
482
+ else
483
+ return t;
484
+ }
485
+ return l > 0 ? l - 1 : 0;
486
+ };
487
+ function W({
488
+ measurements: l,
489
+ outerSize: r,
490
+ scrollOffset: e,
491
+ lanes: s
492
+ }) {
493
+ const t = l.length - 1;
494
+ let i = z(
495
+ 0,
496
+ t,
497
+ (h) => l[h].start,
498
+ e
499
+ ), o = i;
500
+ if (s === 1)
501
+ for (; o < t && l[o].end < e + r; )
502
+ o++;
503
+ else if (s > 1) {
504
+ const h = Array(s).fill(0);
505
+ for (; o < t && h.some((a) => a < e + r); ) {
506
+ const a = l[o];
507
+ h[a.lane] = a.end, o++;
508
+ }
509
+ const c = Array(s).fill(e + r);
510
+ for (; i > 0 && c.some((a) => a >= e); ) {
511
+ const a = l[i];
512
+ c[a.lane] = a.start, i--;
513
+ }
514
+ i = Math.max(0, i - i % s), o = Math.min(t, o + (s - 1 - o % s));
515
+ }
516
+ return { startIndex: i, endIndex: o };
517
+ }
518
+ const v = typeof document < "u" ? x.useLayoutEffect : x.useEffect;
519
+ function V(l) {
520
+ const r = x.useReducer(() => ({}), {})[1], e = {
521
+ ...l,
522
+ onChange: (t, n) => {
523
+ var i;
524
+ n ? I(r) : r(), (i = l.onChange) == null || i.call(l, t, n);
525
+ }
526
+ }, [s] = x.useState(
527
+ () => new N(e)
528
+ );
529
+ return s.setOptions(e), v(() => s._didMount(), []), v(() => s._willUpdate()), s;
530
+ }
531
+ function B(l) {
532
+ return V({
533
+ observeElementRect: D,
534
+ observeElementOffset: A,
535
+ scrollToFn: F,
536
+ ...l
537
+ });
538
+ }
539
+ export {
540
+ B as u
541
+ };