@altinn/altinn-components 0.24.2 → 0.24.4
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/Checkmark-RgzvRNxP.js +25 -0
- package/dist/altinn-ds-overrides.css +5 -0
- package/dist/components/Dialog/DialogListGroup.js +13 -32
- package/dist/components/DsComponents/index.js +23 -0
- package/dist/components/GlobalMenu/AccountMenu.js +24 -24
- package/dist/components/Menu/MenuItemsVirtual.js +65 -602
- package/dist/components/index.js +162 -141
- package/dist/global.css +3 -0
- package/dist/index-DyDqjche.js +541 -0
- package/dist/index.js +179 -158
- package/dist/types/lib/components/Avatar/Examples.stories.d.ts +1 -1
- package/dist/types/lib/components/Avatar/avatar.stories.d.ts +1 -1
- package/dist/types/lib/components/DsComponents/DsComponents.stories.d.ts +23 -0
- package/dist/types/lib/components/DsComponents/index.d.ts +1 -0
- package/dist/types/lib/components/GlobalMenu/AccountMenu.d.ts +2 -2
- package/dist/types/lib/components/Header/LocaleSwitcher.stories.d.ts +1 -1
- package/dist/types/lib/components/Icon/IconOrAvatar.d.ts +1 -1
- package/dist/types/lib/components/Search/AutocompleteBase.d.ts +1 -1
- package/dist/types/lib/components/Skeleton/Skeleton.d.ts +1 -1
- package/dist/types/lib/components/Transmission/Transmission.stories.d.ts +9 -9
- package/dist/types/lib/components/index.d.ts +1 -0
- package/dist/usePagination-CBMPUKt_.js +4073 -0
- package/package.json +4 -1
|
@@ -1,634 +1,97 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { flushSync as N } from "react-dom";
|
|
2
|
+
import { jsxs as v, jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { u as E } from "../../index-DyDqjche.js";
|
|
4
|
+
import { useRef as b, useEffect as R } from "react";
|
|
6
5
|
import "../../index-L8X2o7IH.js";
|
|
7
|
-
import { useMenu as
|
|
6
|
+
import { useMenu as T } from "../../hooks/useMenu.js";
|
|
8
7
|
import "../RootProvider/RootProvider.js";
|
|
9
|
-
import { MenuItem as
|
|
10
|
-
import { MenuSearch as
|
|
11
|
-
import { MenuHeader as
|
|
12
|
-
import { MenuList as
|
|
8
|
+
import { MenuItem as V } from "./MenuItem.js";
|
|
9
|
+
import { MenuSearch as $ } from "./MenuSearch.js";
|
|
10
|
+
import { MenuHeader as j } from "./MenuHeader.js";
|
|
11
|
+
import { MenuList as k, MenuListItem as N } from "./MenuBase.js";
|
|
13
12
|
import "../Search/AutocompleteBase.js";
|
|
14
13
|
import "../Snackbar/useSnackbar.js";
|
|
15
|
-
import '../../assets/MenuItemsVirtual.css';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
e.key && ((i = e.debug) != null && i.call(e)) && (h = Date.now());
|
|
21
|
-
const f = r();
|
|
22
|
-
if (!(f.length !== s.length || f.some((u, p) => s[p] !== u)))
|
|
23
|
-
return t;
|
|
24
|
-
s = f;
|
|
25
|
-
let d;
|
|
26
|
-
if (e.key && ((o = e.debug) != null && o.call(e)) && (d = Date.now()), t = l(...f), e.key && ((a = e.debug) != null && a.call(e))) {
|
|
27
|
-
const u = Math.round((Date.now() - h) * 100) / 100, p = Math.round((Date.now() - d) * 100) / 100, x = p / 16, v = (g, b) => {
|
|
28
|
-
for (g = String(g); g.length < b; )
|
|
29
|
-
g = " " + g;
|
|
30
|
-
return g;
|
|
31
|
-
};
|
|
32
|
-
console.info(
|
|
33
|
-
`%c⏱ ${v(p, 5)} /${v(u, 5)} ms`,
|
|
34
|
-
`
|
|
35
|
-
font-size: .6rem;
|
|
36
|
-
font-weight: bold;
|
|
37
|
-
color: hsl(${Math.max(
|
|
38
|
-
0,
|
|
39
|
-
Math.min(120 - 120 * x, 120)
|
|
40
|
-
)}deg 100% 31%);`,
|
|
41
|
-
e == null ? void 0 : e.key
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
return (c = e == null ? void 0 : e.onChange) == null || c.call(e, t), t;
|
|
45
|
-
}
|
|
46
|
-
return n.updateDeps = (i) => {
|
|
47
|
-
s = i;
|
|
48
|
-
}, n;
|
|
49
|
-
}
|
|
50
|
-
function I(r, l) {
|
|
51
|
-
if (r === void 0)
|
|
52
|
-
throw new Error("Unexpected undefined");
|
|
53
|
-
return r;
|
|
54
|
-
}
|
|
55
|
-
const B = (r, l) => Math.abs(r - l) < 1, $ = (r, l, e) => {
|
|
56
|
-
let s;
|
|
57
|
-
return function(...t) {
|
|
58
|
-
r.clearTimeout(s), s = r.setTimeout(() => l.apply(this, t), e);
|
|
59
|
-
};
|
|
60
|
-
}, K = (r) => r, q = (r) => {
|
|
61
|
-
const l = Math.max(r.startIndex - r.overscan, 0), e = Math.min(r.endIndex + r.overscan, r.count - 1), s = [];
|
|
62
|
-
for (let t = l; t <= e; t++)
|
|
63
|
-
s.push(t);
|
|
64
|
-
return s;
|
|
65
|
-
}, H = (r, l) => {
|
|
66
|
-
const e = r.scrollElement;
|
|
67
|
-
if (!e)
|
|
68
|
-
return;
|
|
69
|
-
const s = r.targetWindow;
|
|
70
|
-
if (!s)
|
|
71
|
-
return;
|
|
72
|
-
const t = (i) => {
|
|
73
|
-
const { width: o, height: a } = i;
|
|
74
|
-
l({ width: Math.round(o), height: Math.round(a) });
|
|
75
|
-
};
|
|
76
|
-
if (t(e.getBoundingClientRect()), !s.ResizeObserver)
|
|
77
|
-
return () => {
|
|
78
|
-
};
|
|
79
|
-
const n = new s.ResizeObserver((i) => {
|
|
80
|
-
const o = () => {
|
|
81
|
-
const a = i[0];
|
|
82
|
-
if (a != null && a.borderBoxSize) {
|
|
83
|
-
const c = a.borderBoxSize[0];
|
|
84
|
-
if (c) {
|
|
85
|
-
t({ width: c.inlineSize, height: c.blockSize });
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
t(e.getBoundingClientRect());
|
|
90
|
-
};
|
|
91
|
-
r.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(o) : o();
|
|
92
|
-
});
|
|
93
|
-
return n.observe(e, { box: "border-box" }), () => {
|
|
94
|
-
n.unobserve(e);
|
|
95
|
-
};
|
|
96
|
-
}, C = {
|
|
97
|
-
passive: !0
|
|
98
|
-
}, T = typeof window > "u" ? !0 : "onscrollend" in window, U = (r, l) => {
|
|
99
|
-
const e = r.scrollElement;
|
|
100
|
-
if (!e)
|
|
101
|
-
return;
|
|
102
|
-
const s = r.targetWindow;
|
|
103
|
-
if (!s)
|
|
104
|
-
return;
|
|
105
|
-
let t = 0;
|
|
106
|
-
const n = r.options.useScrollendEvent && T ? () => {
|
|
107
|
-
} : $(
|
|
108
|
-
s,
|
|
109
|
-
() => {
|
|
110
|
-
l(t, !1);
|
|
111
|
-
},
|
|
112
|
-
r.options.isScrollingResetDelay
|
|
113
|
-
), i = (h) => () => {
|
|
114
|
-
const { horizontal: f, isRtl: m } = r.options;
|
|
115
|
-
t = f ? e.scrollLeft * (m && -1 || 1) : e.scrollTop, n(), l(t, h);
|
|
116
|
-
}, o = i(!0), a = i(!1);
|
|
117
|
-
a(), e.addEventListener("scroll", o, C);
|
|
118
|
-
const c = r.options.useScrollendEvent && T;
|
|
119
|
-
return c && e.addEventListener("scrollend", a, C), () => {
|
|
120
|
-
e.removeEventListener("scroll", o), c && e.removeEventListener("scrollend", a);
|
|
121
|
-
};
|
|
122
|
-
}, Y = (r, l, e) => {
|
|
123
|
-
if (l != null && l.borderBoxSize) {
|
|
124
|
-
const s = l.borderBoxSize[0];
|
|
125
|
-
if (s)
|
|
126
|
-
return Math.round(
|
|
127
|
-
s[e.options.horizontal ? "inlineSize" : "blockSize"]
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
return Math.round(
|
|
131
|
-
r.getBoundingClientRect()[e.options.horizontal ? "width" : "height"]
|
|
132
|
-
);
|
|
133
|
-
}, G = (r, {
|
|
134
|
-
adjustments: l = 0,
|
|
135
|
-
behavior: e
|
|
136
|
-
}, s) => {
|
|
137
|
-
var t, n;
|
|
138
|
-
const i = r + l;
|
|
139
|
-
(n = (t = s.scrollElement) == null ? void 0 : t.scrollTo) == null || n.call(t, {
|
|
140
|
-
[s.options.horizontal ? "left" : "top"]: i,
|
|
141
|
-
behavior: e
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
class J {
|
|
145
|
-
constructor(l) {
|
|
146
|
-
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__ */ (() => {
|
|
147
|
-
let e = null;
|
|
148
|
-
const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((t) => {
|
|
149
|
-
t.forEach((n) => {
|
|
150
|
-
const i = () => {
|
|
151
|
-
this._measureElement(n.target, n);
|
|
152
|
-
};
|
|
153
|
-
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(i) : i();
|
|
154
|
-
});
|
|
155
|
-
}));
|
|
156
|
-
return {
|
|
157
|
-
disconnect: () => {
|
|
158
|
-
var t;
|
|
159
|
-
(t = s()) == null || t.disconnect(), e = null;
|
|
160
|
-
},
|
|
161
|
-
observe: (t) => {
|
|
162
|
-
var n;
|
|
163
|
-
return (n = s()) == null ? void 0 : n.observe(t, { box: "border-box" });
|
|
164
|
-
},
|
|
165
|
-
unobserve: (t) => {
|
|
166
|
-
var n;
|
|
167
|
-
return (n = s()) == null ? void 0 : n.unobserve(t);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
})(), this.range = null, this.setOptions = (e) => {
|
|
171
|
-
Object.entries(e).forEach(([s, t]) => {
|
|
172
|
-
typeof t > "u" && delete e[s];
|
|
173
|
-
}), this.options = {
|
|
174
|
-
debug: !1,
|
|
175
|
-
initialOffset: 0,
|
|
176
|
-
overscan: 1,
|
|
177
|
-
paddingStart: 0,
|
|
178
|
-
paddingEnd: 0,
|
|
179
|
-
scrollPaddingStart: 0,
|
|
180
|
-
scrollPaddingEnd: 0,
|
|
181
|
-
horizontal: !1,
|
|
182
|
-
getItemKey: K,
|
|
183
|
-
rangeExtractor: q,
|
|
184
|
-
onChange: () => {
|
|
185
|
-
},
|
|
186
|
-
measureElement: Y,
|
|
187
|
-
initialRect: { width: 0, height: 0 },
|
|
188
|
-
scrollMargin: 0,
|
|
189
|
-
gap: 0,
|
|
190
|
-
indexAttribute: "data-index",
|
|
191
|
-
initialMeasurementsCache: [],
|
|
192
|
-
lanes: 1,
|
|
193
|
-
isScrollingResetDelay: 150,
|
|
194
|
-
enabled: !0,
|
|
195
|
-
isRtl: !1,
|
|
196
|
-
useScrollendEvent: !1,
|
|
197
|
-
useAnimationFrameWithResizeObserver: !1,
|
|
198
|
-
...e
|
|
199
|
-
};
|
|
200
|
-
}, this.notify = (e) => {
|
|
201
|
-
var s, t;
|
|
202
|
-
(t = (s = this.options).onChange) == null || t.call(s, this, e);
|
|
203
|
-
}, this.maybeNotify = y(
|
|
204
|
-
() => (this.calculateRange(), [
|
|
205
|
-
this.isScrolling,
|
|
206
|
-
this.range ? this.range.startIndex : null,
|
|
207
|
-
this.range ? this.range.endIndex : null
|
|
208
|
-
]),
|
|
209
|
-
(e) => {
|
|
210
|
-
this.notify(e);
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
key: process.env.NODE_ENV !== "production" && "maybeNotify",
|
|
214
|
-
debug: () => this.options.debug,
|
|
215
|
-
initialDeps: [
|
|
216
|
-
this.isScrolling,
|
|
217
|
-
this.range ? this.range.startIndex : null,
|
|
218
|
-
this.range ? this.range.endIndex : null
|
|
219
|
-
]
|
|
220
|
-
}
|
|
221
|
-
), this.cleanup = () => {
|
|
222
|
-
this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
|
|
223
|
-
}, this._didMount = () => () => {
|
|
224
|
-
this.cleanup();
|
|
225
|
-
}, this._willUpdate = () => {
|
|
226
|
-
var e;
|
|
227
|
-
const s = this.options.enabled ? this.options.getScrollElement() : null;
|
|
228
|
-
if (this.scrollElement !== s) {
|
|
229
|
-
if (this.cleanup(), !s) {
|
|
230
|
-
this.maybeNotify();
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
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) => {
|
|
234
|
-
this.observer.observe(t);
|
|
235
|
-
}), this._scrollToOffset(this.getScrollOffset(), {
|
|
236
|
-
adjustments: void 0,
|
|
237
|
-
behavior: void 0
|
|
238
|
-
}), this.unsubs.push(
|
|
239
|
-
this.options.observeElementRect(this, (t) => {
|
|
240
|
-
this.scrollRect = t, this.maybeNotify();
|
|
241
|
-
})
|
|
242
|
-
), this.unsubs.push(
|
|
243
|
-
this.options.observeElementOffset(this, (t, n) => {
|
|
244
|
-
this.scrollAdjustments = 0, this.scrollDirection = n ? this.getScrollOffset() < t ? "forward" : "backward" : null, this.scrollOffset = t, this.isScrolling = n, this.maybeNotify();
|
|
245
|
-
})
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
}, 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) => {
|
|
249
|
-
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
250
|
-
for (let i = s - 1; i >= 0; i--) {
|
|
251
|
-
const o = e[i];
|
|
252
|
-
if (t.has(o.lane))
|
|
253
|
-
continue;
|
|
254
|
-
const a = n.get(
|
|
255
|
-
o.lane
|
|
256
|
-
);
|
|
257
|
-
if (a == null || o.end > a.end ? n.set(o.lane, o) : o.end < a.end && t.set(o.lane, !0), t.size === this.options.lanes)
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
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;
|
|
261
|
-
}, this.getMeasurementOptions = y(
|
|
262
|
-
() => [
|
|
263
|
-
this.options.count,
|
|
264
|
-
this.options.paddingStart,
|
|
265
|
-
this.options.scrollMargin,
|
|
266
|
-
this.options.getItemKey,
|
|
267
|
-
this.options.enabled
|
|
268
|
-
],
|
|
269
|
-
(e, s, t, n, i) => (this.pendingMeasuredCacheIndexes = [], {
|
|
270
|
-
count: e,
|
|
271
|
-
paddingStart: s,
|
|
272
|
-
scrollMargin: t,
|
|
273
|
-
getItemKey: n,
|
|
274
|
-
enabled: i
|
|
275
|
-
}),
|
|
276
|
-
{
|
|
277
|
-
key: !1
|
|
278
|
-
}
|
|
279
|
-
), this.getMeasurements = y(
|
|
280
|
-
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
281
|
-
({ count: e, paddingStart: s, scrollMargin: t, getItemKey: n, enabled: i }, o) => {
|
|
282
|
-
if (!i)
|
|
283
|
-
return this.measurementsCache = [], this.itemSizeCache.clear(), [];
|
|
284
|
-
this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((h) => {
|
|
285
|
-
this.itemSizeCache.set(h.key, h.size);
|
|
286
|
-
}));
|
|
287
|
-
const a = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
288
|
-
this.pendingMeasuredCacheIndexes = [];
|
|
289
|
-
const c = this.measurementsCache.slice(0, a);
|
|
290
|
-
for (let h = a; h < e; h++) {
|
|
291
|
-
const f = n(h), m = this.options.lanes === 1 ? c[h - 1] : this.getFurthestMeasurement(c, h), d = m ? m.end + this.options.gap : s + t, u = o.get(f), p = typeof u == "number" ? u : this.options.estimateSize(h), x = d + p, v = m ? m.lane : h % this.options.lanes;
|
|
292
|
-
c[h] = {
|
|
293
|
-
index: h,
|
|
294
|
-
start: d,
|
|
295
|
-
size: p,
|
|
296
|
-
end: x,
|
|
297
|
-
key: f,
|
|
298
|
-
lane: v
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
return this.measurementsCache = c, c;
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
305
|
-
debug: () => this.options.debug
|
|
306
|
-
}
|
|
307
|
-
), this.calculateRange = y(
|
|
308
|
-
() => [
|
|
309
|
-
this.getMeasurements(),
|
|
310
|
-
this.getSize(),
|
|
311
|
-
this.getScrollOffset(),
|
|
312
|
-
this.options.lanes
|
|
313
|
-
],
|
|
314
|
-
(e, s, t, n) => this.range = e.length > 0 && s > 0 ? Q({
|
|
315
|
-
measurements: e,
|
|
316
|
-
outerSize: s,
|
|
317
|
-
scrollOffset: t,
|
|
318
|
-
lanes: n
|
|
319
|
-
}) : null,
|
|
320
|
-
{
|
|
321
|
-
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
322
|
-
debug: () => this.options.debug
|
|
323
|
-
}
|
|
324
|
-
), this.getVirtualIndexes = y(
|
|
325
|
-
() => {
|
|
326
|
-
let e = null, s = null;
|
|
327
|
-
const t = this.calculateRange();
|
|
328
|
-
return t && (e = t.startIndex, s = t.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, s]), [
|
|
329
|
-
this.options.rangeExtractor,
|
|
330
|
-
this.options.overscan,
|
|
331
|
-
this.options.count,
|
|
332
|
-
e,
|
|
333
|
-
s
|
|
334
|
-
];
|
|
335
|
-
},
|
|
336
|
-
(e, s, t, n, i) => n === null || i === null ? [] : e({
|
|
337
|
-
startIndex: n,
|
|
338
|
-
endIndex: i,
|
|
339
|
-
overscan: s,
|
|
340
|
-
count: t
|
|
341
|
-
}),
|
|
342
|
-
{
|
|
343
|
-
key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
|
|
344
|
-
debug: () => this.options.debug
|
|
345
|
-
}
|
|
346
|
-
), this.indexFromElement = (e) => {
|
|
347
|
-
const s = this.options.indexAttribute, t = e.getAttribute(s);
|
|
348
|
-
return t ? parseInt(t, 10) : (console.warn(
|
|
349
|
-
`Missing attribute name '${s}={index}' on measured element.`
|
|
350
|
-
), -1);
|
|
351
|
-
}, this._measureElement = (e, s) => {
|
|
352
|
-
const t = this.indexFromElement(e), n = this.measurementsCache[t];
|
|
353
|
-
if (!n)
|
|
354
|
-
return;
|
|
355
|
-
const i = n.key, o = this.elementsCache.get(i);
|
|
356
|
-
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));
|
|
357
|
-
}, this.resizeItem = (e, s) => {
|
|
358
|
-
const t = this.measurementsCache[e];
|
|
359
|
-
if (!t)
|
|
360
|
-
return;
|
|
361
|
-
const n = this.itemSizeCache.get(t.key) ?? t.size, i = s - n;
|
|
362
|
-
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(), {
|
|
363
|
-
adjustments: this.scrollAdjustments += i,
|
|
364
|
-
behavior: void 0
|
|
365
|
-
})), this.pendingMeasuredCacheIndexes.push(t.index), this.itemSizeCache = new Map(this.itemSizeCache.set(t.key, s)), this.notify(!1));
|
|
366
|
-
}, this.measureElement = (e) => {
|
|
367
|
-
if (!e) {
|
|
368
|
-
this.elementsCache.forEach((s, t) => {
|
|
369
|
-
s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(t));
|
|
370
|
-
});
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
this._measureElement(e, void 0);
|
|
374
|
-
}, this.getVirtualItems = y(
|
|
375
|
-
() => [this.getVirtualIndexes(), this.getMeasurements()],
|
|
376
|
-
(e, s) => {
|
|
377
|
-
const t = [];
|
|
378
|
-
for (let n = 0, i = e.length; n < i; n++) {
|
|
379
|
-
const o = e[n], a = s[o];
|
|
380
|
-
t.push(a);
|
|
381
|
-
}
|
|
382
|
-
return t;
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
key: process.env.NODE_ENV !== "production" && "getVirtualItems",
|
|
386
|
-
debug: () => this.options.debug
|
|
387
|
-
}
|
|
388
|
-
), this.getVirtualItemForOffset = (e) => {
|
|
389
|
-
const s = this.getMeasurements();
|
|
390
|
-
if (s.length !== 0)
|
|
391
|
-
return I(
|
|
392
|
-
s[D(
|
|
393
|
-
0,
|
|
394
|
-
s.length - 1,
|
|
395
|
-
(t) => I(s[t]).start,
|
|
396
|
-
e
|
|
397
|
-
)]
|
|
398
|
-
);
|
|
399
|
-
}, this.getOffsetForAlignment = (e, s, t = 0) => {
|
|
400
|
-
const n = this.getSize(), i = this.getScrollOffset();
|
|
401
|
-
s === "auto" && (s = e >= i + n ? "end" : "start"), s === "center" ? e += (t - n) / 2 : s === "end" && (e -= n);
|
|
402
|
-
const o = this.options.horizontal ? "scrollWidth" : "scrollHeight", c = (this.scrollElement ? "document" in this.scrollElement ? this.scrollElement.document.documentElement[o] : this.scrollElement[o] : 0) - n;
|
|
403
|
-
return Math.max(Math.min(c, e), 0);
|
|
404
|
-
}, this.getOffsetForIndex = (e, s = "auto") => {
|
|
405
|
-
e = Math.max(0, Math.min(e, this.options.count - 1));
|
|
406
|
-
const t = this.measurementsCache[e];
|
|
407
|
-
if (!t)
|
|
408
|
-
return;
|
|
409
|
-
const n = this.getSize(), i = this.getScrollOffset();
|
|
410
|
-
if (s === "auto")
|
|
411
|
-
if (t.end >= i + n - this.options.scrollPaddingEnd)
|
|
412
|
-
s = "end";
|
|
413
|
-
else if (t.start <= i + this.options.scrollPaddingStart)
|
|
414
|
-
s = "start";
|
|
415
|
-
else
|
|
416
|
-
return [i, s];
|
|
417
|
-
const o = s === "end" ? t.end + this.options.scrollPaddingEnd : t.start - this.options.scrollPaddingStart;
|
|
418
|
-
return [
|
|
419
|
-
this.getOffsetForAlignment(o, s, t.size),
|
|
420
|
-
s
|
|
421
|
-
];
|
|
422
|
-
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.cancelScrollToIndex = () => {
|
|
423
|
-
this.scrollToIndexTimeoutId !== null && this.targetWindow && (this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId), this.scrollToIndexTimeoutId = null);
|
|
424
|
-
}, this.scrollToOffset = (e, { align: s = "start", behavior: t } = {}) => {
|
|
425
|
-
this.cancelScrollToIndex(), t === "smooth" && this.isDynamicMode() && console.warn(
|
|
426
|
-
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
427
|
-
), this._scrollToOffset(this.getOffsetForAlignment(e, s), {
|
|
428
|
-
adjustments: void 0,
|
|
429
|
-
behavior: t
|
|
430
|
-
});
|
|
431
|
-
}, this.scrollToIndex = (e, { align: s = "auto", behavior: t } = {}) => {
|
|
432
|
-
e = Math.max(0, Math.min(e, this.options.count - 1)), this.cancelScrollToIndex(), t === "smooth" && this.isDynamicMode() && console.warn(
|
|
433
|
-
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
434
|
-
);
|
|
435
|
-
const n = this.getOffsetForIndex(e, s);
|
|
436
|
-
if (!n) return;
|
|
437
|
-
const [i, o] = n;
|
|
438
|
-
this._scrollToOffset(i, { adjustments: void 0, behavior: t }), t !== "smooth" && this.isDynamicMode() && this.targetWindow && (this.scrollToIndexTimeoutId = this.targetWindow.setTimeout(() => {
|
|
439
|
-
if (this.scrollToIndexTimeoutId = null, this.elementsCache.has(
|
|
440
|
-
this.options.getItemKey(e)
|
|
441
|
-
)) {
|
|
442
|
-
const [c] = I(
|
|
443
|
-
this.getOffsetForIndex(e, o)
|
|
444
|
-
);
|
|
445
|
-
B(c, this.getScrollOffset()) || this.scrollToIndex(e, { align: o, behavior: t });
|
|
446
|
-
} else
|
|
447
|
-
this.scrollToIndex(e, { align: o, behavior: t });
|
|
448
|
-
}));
|
|
449
|
-
}, this.scrollBy = (e, { behavior: s } = {}) => {
|
|
450
|
-
this.cancelScrollToIndex(), s === "smooth" && this.isDynamicMode() && console.warn(
|
|
451
|
-
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
452
|
-
), this._scrollToOffset(this.getScrollOffset() + e, {
|
|
453
|
-
adjustments: void 0,
|
|
454
|
-
behavior: s
|
|
455
|
-
});
|
|
456
|
-
}, this.getTotalSize = () => {
|
|
457
|
-
var e;
|
|
458
|
-
const s = this.getMeasurements();
|
|
459
|
-
let t;
|
|
460
|
-
if (s.length === 0)
|
|
461
|
-
t = this.options.paddingStart;
|
|
462
|
-
else if (this.options.lanes === 1)
|
|
463
|
-
t = ((e = s[s.length - 1]) == null ? void 0 : e.end) ?? 0;
|
|
464
|
-
else {
|
|
465
|
-
const n = Array(this.options.lanes).fill(null);
|
|
466
|
-
let i = s.length - 1;
|
|
467
|
-
for (; i > 0 && n.some((o) => o === null); ) {
|
|
468
|
-
const o = s[i];
|
|
469
|
-
n[o.lane] === null && (n[o.lane] = o.end), i--;
|
|
470
|
-
}
|
|
471
|
-
t = Math.max(...n.filter((o) => o !== null));
|
|
472
|
-
}
|
|
473
|
-
return Math.max(
|
|
474
|
-
t - this.options.scrollMargin + this.options.paddingEnd,
|
|
475
|
-
0
|
|
476
|
-
);
|
|
477
|
-
}, this._scrollToOffset = (e, {
|
|
478
|
-
adjustments: s,
|
|
479
|
-
behavior: t
|
|
480
|
-
}) => {
|
|
481
|
-
this.options.scrollToFn(e, { behavior: t, adjustments: s }, this);
|
|
482
|
-
}, this.measure = () => {
|
|
483
|
-
this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
|
|
484
|
-
}, this.setOptions(l);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
const D = (r, l, e, s) => {
|
|
488
|
-
for (; r <= l; ) {
|
|
489
|
-
const t = (r + l) / 2 | 0, n = e(t);
|
|
490
|
-
if (n < s)
|
|
491
|
-
r = t + 1;
|
|
492
|
-
else if (n > s)
|
|
493
|
-
l = t - 1;
|
|
494
|
-
else
|
|
495
|
-
return t;
|
|
496
|
-
}
|
|
497
|
-
return r > 0 ? r - 1 : 0;
|
|
498
|
-
};
|
|
499
|
-
function Q({
|
|
500
|
-
measurements: r,
|
|
501
|
-
outerSize: l,
|
|
502
|
-
scrollOffset: e,
|
|
503
|
-
lanes: s
|
|
504
|
-
}) {
|
|
505
|
-
const t = r.length - 1;
|
|
506
|
-
let i = D(
|
|
507
|
-
0,
|
|
508
|
-
t,
|
|
509
|
-
(a) => r[a].start,
|
|
510
|
-
e
|
|
511
|
-
), o = i;
|
|
512
|
-
if (s === 1)
|
|
513
|
-
for (; o < t && r[o].end < e + l; )
|
|
514
|
-
o++;
|
|
515
|
-
else if (s > 1) {
|
|
516
|
-
const a = Array(s).fill(0);
|
|
517
|
-
for (; o < t && a.some((h) => h < e + l); ) {
|
|
518
|
-
const h = r[o];
|
|
519
|
-
a[h.lane] = h.end, o++;
|
|
520
|
-
}
|
|
521
|
-
const c = Array(s).fill(e + l);
|
|
522
|
-
for (; i > 0 && c.some((h) => h >= e); ) {
|
|
523
|
-
const h = r[i];
|
|
524
|
-
c[h.lane] = h.start, i--;
|
|
525
|
-
}
|
|
526
|
-
i = Math.max(0, i - i % s), o = Math.min(t, o + (s - 1 - o % s));
|
|
527
|
-
}
|
|
528
|
-
return { startIndex: i, endIndex: o };
|
|
529
|
-
}
|
|
530
|
-
const _ = typeof document < "u" ? S.useLayoutEffect : S.useEffect;
|
|
531
|
-
function X(r) {
|
|
532
|
-
const l = S.useReducer(() => ({}), {})[1], e = {
|
|
533
|
-
...r,
|
|
534
|
-
onChange: (t, n) => {
|
|
535
|
-
var i;
|
|
536
|
-
n ? N(l) : l(), (i = r.onChange) == null || i.call(r, t, n);
|
|
537
|
-
}
|
|
538
|
-
}, [s] = S.useState(
|
|
539
|
-
() => new J(e)
|
|
540
|
-
);
|
|
541
|
-
return s.setOptions(e), _(() => s._didMount(), []), _(() => s._willUpdate()), s;
|
|
542
|
-
}
|
|
543
|
-
function Z(r) {
|
|
544
|
-
return X({
|
|
545
|
-
observeElementRect: H,
|
|
546
|
-
observeElementOffset: U,
|
|
547
|
-
scrollToFn: G,
|
|
548
|
-
...r
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
const ee = "_virtualScrollRef_12fdc_1", te = "_virtualMenuListItem_12fdc_6", R = {
|
|
552
|
-
virtualScrollRef: ee,
|
|
553
|
-
virtualMenuListItem: te
|
|
554
|
-
}, me = ({
|
|
555
|
-
level: r = 0,
|
|
14
|
+
import '../../assets/MenuItemsVirtual.css';const g = "_virtualScrollRef_12fdc_1", q = "_virtualMenuListItem_12fdc_6", h = {
|
|
15
|
+
virtualScrollRef: g,
|
|
16
|
+
virtualMenuListItem: q
|
|
17
|
+
}, U = ({
|
|
18
|
+
level: y = 0,
|
|
556
19
|
search: l,
|
|
557
|
-
items:
|
|
558
|
-
groups:
|
|
559
|
-
defaultItemSize:
|
|
560
|
-
defaultItemColor:
|
|
561
|
-
defaultItemTheme:
|
|
562
|
-
defaultIconTheme:
|
|
20
|
+
items: I,
|
|
21
|
+
groups: M = {},
|
|
22
|
+
defaultItemSize: x,
|
|
23
|
+
defaultItemColor: S,
|
|
24
|
+
defaultItemTheme: P,
|
|
25
|
+
defaultIconTheme: L
|
|
563
26
|
}) => {
|
|
564
|
-
const { menu:
|
|
565
|
-
items:
|
|
566
|
-
groups:
|
|
27
|
+
const { menu: z } = T({
|
|
28
|
+
items: I,
|
|
29
|
+
groups: M,
|
|
567
30
|
groupByKey: "groupId",
|
|
568
31
|
keyboardEvents: !1
|
|
569
|
-
}),
|
|
570
|
-
var
|
|
571
|
-
const
|
|
572
|
-
var
|
|
573
|
-
return !((
|
|
32
|
+
}), m = b(null), a = z.flatMap((t, e) => {
|
|
33
|
+
var u;
|
|
34
|
+
const _ = (t == null ? void 0 : t.props) || {}, { title: c } = _, p = ((u = t == null ? void 0 : t.items) == null ? void 0 : u.filter((r) => {
|
|
35
|
+
var s;
|
|
36
|
+
return !((s = r.props) != null && s.hidden);
|
|
574
37
|
})) || [];
|
|
575
38
|
return [
|
|
576
|
-
...
|
|
577
|
-
...
|
|
578
|
-
...
|
|
579
|
-
var
|
|
39
|
+
...e > 0 || y > 0 ? [{ type: "separator" }] : [],
|
|
40
|
+
...c ? [{ type: "title", title: c }] : [],
|
|
41
|
+
...p.map((r, s) => {
|
|
42
|
+
var d, f;
|
|
580
43
|
return {
|
|
581
44
|
type: "item",
|
|
582
|
-
itemProps:
|
|
583
|
-
active:
|
|
584
|
-
hasChildren: ((
|
|
585
|
-
isLastItem:
|
|
45
|
+
itemProps: r.props || {},
|
|
46
|
+
active: r.active,
|
|
47
|
+
hasChildren: ((d = r.props) == null ? void 0 : d.expanded) && ((f = r.props) == null ? void 0 : f.items),
|
|
48
|
+
isLastItem: s === p.length - 1
|
|
586
49
|
};
|
|
587
50
|
})
|
|
588
51
|
];
|
|
589
|
-
}),
|
|
590
|
-
count:
|
|
52
|
+
}), n = E({
|
|
53
|
+
count: a.length,
|
|
591
54
|
gap: 8,
|
|
592
55
|
estimateSize: () => 44,
|
|
593
|
-
getScrollElement: () =>
|
|
594
|
-
}),
|
|
595
|
-
return
|
|
596
|
-
for (const
|
|
597
|
-
const
|
|
598
|
-
|
|
56
|
+
getScrollElement: () => m.current
|
|
57
|
+
}), o = n.getVirtualItems();
|
|
58
|
+
return R(() => {
|
|
59
|
+
for (const t of o) {
|
|
60
|
+
const e = document.querySelector(`[data-index="${t.index}"]`);
|
|
61
|
+
e && n.measureElement(e);
|
|
599
62
|
}
|
|
600
|
-
}, [
|
|
601
|
-
l && /* @__PURE__ */
|
|
602
|
-
/* @__PURE__ */
|
|
603
|
-
const
|
|
604
|
-
return
|
|
605
|
-
|
|
63
|
+
}, [o]), /* @__PURE__ */ v(k, { children: [
|
|
64
|
+
l && /* @__PURE__ */ i($, { ...l }),
|
|
65
|
+
/* @__PURE__ */ i("div", { ref: m, className: h.virtualScrollRef, children: /* @__PURE__ */ i("div", { style: { position: "relative", height: `${n.getTotalSize()}px` }, children: o.map((t) => {
|
|
66
|
+
const e = a[t.index];
|
|
67
|
+
return e ? /* @__PURE__ */ v(
|
|
68
|
+
N,
|
|
606
69
|
{
|
|
607
|
-
dataIndex:
|
|
608
|
-
className:
|
|
609
|
-
style: { transform: `translateY(${
|
|
610
|
-
role:
|
|
70
|
+
dataIndex: t.index,
|
|
71
|
+
className: h.virtualMenuListItem,
|
|
72
|
+
style: { transform: `translateY(${t.start}px)` },
|
|
73
|
+
role: e.type === "separator" ? "separator" : void 0,
|
|
611
74
|
children: [
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
75
|
+
e.type === "title" && /* @__PURE__ */ i(j, { title: e.title }),
|
|
76
|
+
e.type === "item" && /* @__PURE__ */ i(
|
|
77
|
+
V,
|
|
615
78
|
{
|
|
616
|
-
...
|
|
617
|
-
size:
|
|
618
|
-
color:
|
|
619
|
-
theme:
|
|
620
|
-
iconTheme:
|
|
621
|
-
active:
|
|
622
|
-
tabIndex:
|
|
79
|
+
...e.itemProps,
|
|
80
|
+
size: e.itemProps.size || x,
|
|
81
|
+
color: e.itemProps.color || S,
|
|
82
|
+
theme: e.itemProps.theme || P,
|
|
83
|
+
iconTheme: e.itemProps.iconTheme || L,
|
|
84
|
+
active: e.active,
|
|
85
|
+
tabIndex: e.itemProps.disabled ? -1 : 0
|
|
623
86
|
}
|
|
624
87
|
)
|
|
625
88
|
]
|
|
626
89
|
},
|
|
627
|
-
|
|
90
|
+
t.key
|
|
628
91
|
) : null;
|
|
629
92
|
}) }) })
|
|
630
93
|
] });
|
|
631
94
|
};
|
|
632
95
|
export {
|
|
633
|
-
|
|
96
|
+
U as MenuItemsVirtual
|
|
634
97
|
};
|