@addsign/moje-agenda-shared-lib 2.0.65 → 2.0.67

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 (59) hide show
  1. package/dist/Calendar-DWT4e7Th.js.map +1 -1
  2. package/dist/Combination-DmhTQmbL.js +996 -0
  3. package/dist/Combination-DmhTQmbL.js.map +1 -0
  4. package/dist/Dialog-3u5-ws89.js +424 -0
  5. package/dist/Dialog-3u5-ws89.js.map +1 -0
  6. package/dist/Dialog-CCrUyF91.js.map +1 -1
  7. package/dist/assets/style.css +0 -3
  8. package/dist/components/datatable/DataTableServer.js +254 -245
  9. package/dist/components/datatable/DataTableServer.js.map +1 -1
  10. package/dist/components/form/FileInputForm.d.ts +14 -0
  11. package/dist/components/form/FileInputForm.js +173 -0
  12. package/dist/components/form/FileInputForm.js.map +1 -0
  13. package/dist/components/form/FileInputFormMultiple.d.ts +16 -0
  14. package/dist/components/form/FileInputFormMultiple.js +240 -0
  15. package/dist/components/form/FileInputFormMultiple.js.map +1 -0
  16. package/dist/components/form/FileInputFull.d.ts +17 -0
  17. package/dist/components/form/FileInputFull.js +188 -0
  18. package/dist/components/form/FileInputFull.js.map +1 -0
  19. package/dist/components/form/FileInputFullMultiple.d.ts +19 -0
  20. package/dist/components/form/FileInputFullMultiple.js +226 -0
  21. package/dist/components/form/FileInputFullMultiple.js.map +1 -0
  22. package/dist/components/ui/Combobox.js.map +1 -1
  23. package/dist/components/ui/checkbox.js.map +1 -1
  24. package/dist/components/ui/command.js.map +1 -1
  25. package/dist/components/ui/multi-select.js +6 -3
  26. package/dist/components/ui/multi-select.js.map +1 -1
  27. package/dist/components/ui/radioGroup.js.map +1 -1
  28. package/dist/components/ui/toast.js.map +1 -1
  29. package/dist/handleErrors-B2be_Hgy.js +31615 -0
  30. package/dist/handleErrors-B2be_Hgy.js.map +1 -0
  31. package/dist/handleErrors-P52guX3U.js +32 -0
  32. package/dist/handleErrors-P52guX3U.js.map +1 -0
  33. package/dist/index-BikTN7j8.js +2266 -0
  34. package/dist/index-BikTN7j8.js.map +1 -0
  35. package/dist/main.d.ts +2 -0
  36. package/dist/main.js +34 -30
  37. package/dist/main.js.map +1 -1
  38. package/dist/popover-BLI2Jq-c.js +319 -0
  39. package/dist/popover-BLI2Jq-c.js.map +1 -0
  40. package/dist/popover-CcrzvSk7.js.map +1 -1
  41. package/dist/tslib.es6-e8r3nMQ9.js +172 -0
  42. package/dist/tslib.es6-e8r3nMQ9.js.map +1 -0
  43. package/dist/types.d.ts +1 -0
  44. package/dist/types.js.map +1 -1
  45. package/lib/components/datatable/DataTableServer.tsx +14 -23
  46. package/lib/components/form/FileInputForm.tsx +184 -0
  47. package/lib/components/form/FileInputFormMultiple.tsx +220 -0
  48. package/lib/components/ui/Calendar.tsx +0 -2
  49. package/lib/components/ui/Combobox.tsx +0 -2
  50. package/lib/components/ui/Dialog.tsx +0 -2
  51. package/lib/components/ui/checkbox.tsx +0 -2
  52. package/lib/components/ui/command.tsx +0 -2
  53. package/lib/components/ui/multi-select.tsx +10 -4
  54. package/lib/components/ui/popover.tsx +0 -2
  55. package/lib/components/ui/radioGroup.tsx +0 -2
  56. package/lib/components/ui/toast.tsx +0 -1
  57. package/lib/main.ts +2 -0
  58. package/lib/types.ts +1 -0
  59. package/package.json +1 -2
@@ -0,0 +1,996 @@
1
+ import * as React from "react";
2
+ import { useState } from "react";
3
+ import { u as useComposedRefs } from "./index-D9mvqz1C.js";
4
+ import { P as Primitive } from "./index-B761_inZ.js";
5
+ import { a as useCallbackRef$1 } from "./index-NZPkObcw.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { d as __assign, e as __rest, b as __spreadArray } from "./tslib.es6-e8r3nMQ9.js";
8
+ var count = 0;
9
+ function useFocusGuards() {
10
+ React.useEffect(() => {
11
+ const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
12
+ document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
13
+ document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
14
+ count++;
15
+ return () => {
16
+ if (count === 1) {
17
+ document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
18
+ }
19
+ count--;
20
+ };
21
+ }, []);
22
+ }
23
+ function createFocusGuard() {
24
+ const element = document.createElement("span");
25
+ element.setAttribute("data-radix-focus-guard", "");
26
+ element.tabIndex = 0;
27
+ element.style.outline = "none";
28
+ element.style.opacity = "0";
29
+ element.style.position = "fixed";
30
+ element.style.pointerEvents = "none";
31
+ return element;
32
+ }
33
+ var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
34
+ var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
35
+ var EVENT_OPTIONS = { bubbles: false, cancelable: true };
36
+ var FOCUS_SCOPE_NAME = "FocusScope";
37
+ var FocusScope = React.forwardRef((props, forwardedRef) => {
38
+ const {
39
+ loop = false,
40
+ trapped = false,
41
+ onMountAutoFocus: onMountAutoFocusProp,
42
+ onUnmountAutoFocus: onUnmountAutoFocusProp,
43
+ ...scopeProps
44
+ } = props;
45
+ const [container, setContainer] = React.useState(null);
46
+ const onMountAutoFocus = useCallbackRef$1(onMountAutoFocusProp);
47
+ const onUnmountAutoFocus = useCallbackRef$1(onUnmountAutoFocusProp);
48
+ const lastFocusedElementRef = React.useRef(null);
49
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
50
+ const focusScope = React.useRef({
51
+ paused: false,
52
+ pause() {
53
+ this.paused = true;
54
+ },
55
+ resume() {
56
+ this.paused = false;
57
+ }
58
+ }).current;
59
+ React.useEffect(() => {
60
+ if (trapped) {
61
+ let handleFocusIn2 = function(event) {
62
+ if (focusScope.paused || !container)
63
+ return;
64
+ const target = event.target;
65
+ if (container.contains(target)) {
66
+ lastFocusedElementRef.current = target;
67
+ } else {
68
+ focus(lastFocusedElementRef.current, { select: true });
69
+ }
70
+ }, handleFocusOut2 = function(event) {
71
+ if (focusScope.paused || !container)
72
+ return;
73
+ const relatedTarget = event.relatedTarget;
74
+ if (relatedTarget === null)
75
+ return;
76
+ if (!container.contains(relatedTarget)) {
77
+ focus(lastFocusedElementRef.current, { select: true });
78
+ }
79
+ }, handleMutations2 = function(mutations) {
80
+ const focusedElement = document.activeElement;
81
+ if (focusedElement !== document.body)
82
+ return;
83
+ for (const mutation of mutations) {
84
+ if (mutation.removedNodes.length > 0)
85
+ focus(container);
86
+ }
87
+ };
88
+ document.addEventListener("focusin", handleFocusIn2);
89
+ document.addEventListener("focusout", handleFocusOut2);
90
+ const mutationObserver = new MutationObserver(handleMutations2);
91
+ if (container)
92
+ mutationObserver.observe(container, { childList: true, subtree: true });
93
+ return () => {
94
+ document.removeEventListener("focusin", handleFocusIn2);
95
+ document.removeEventListener("focusout", handleFocusOut2);
96
+ mutationObserver.disconnect();
97
+ };
98
+ }
99
+ }, [trapped, container, focusScope.paused]);
100
+ React.useEffect(() => {
101
+ if (container) {
102
+ focusScopesStack.add(focusScope);
103
+ const previouslyFocusedElement = document.activeElement;
104
+ const hasFocusedCandidate = container.contains(previouslyFocusedElement);
105
+ if (!hasFocusedCandidate) {
106
+ const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
107
+ container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
108
+ container.dispatchEvent(mountEvent);
109
+ if (!mountEvent.defaultPrevented) {
110
+ focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
111
+ if (document.activeElement === previouslyFocusedElement) {
112
+ focus(container);
113
+ }
114
+ }
115
+ }
116
+ return () => {
117
+ container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
118
+ setTimeout(() => {
119
+ const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
120
+ container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
121
+ container.dispatchEvent(unmountEvent);
122
+ if (!unmountEvent.defaultPrevented) {
123
+ focus(previouslyFocusedElement ?? document.body, { select: true });
124
+ }
125
+ container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
126
+ focusScopesStack.remove(focusScope);
127
+ }, 0);
128
+ };
129
+ }
130
+ }, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
131
+ const handleKeyDown = React.useCallback(
132
+ (event) => {
133
+ if (!loop && !trapped)
134
+ return;
135
+ if (focusScope.paused)
136
+ return;
137
+ const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
138
+ const focusedElement = document.activeElement;
139
+ if (isTabKey && focusedElement) {
140
+ const container2 = event.currentTarget;
141
+ const [first, last] = getTabbableEdges(container2);
142
+ const hasTabbableElementsInside = first && last;
143
+ if (!hasTabbableElementsInside) {
144
+ if (focusedElement === container2)
145
+ event.preventDefault();
146
+ } else {
147
+ if (!event.shiftKey && focusedElement === last) {
148
+ event.preventDefault();
149
+ if (loop)
150
+ focus(first, { select: true });
151
+ } else if (event.shiftKey && focusedElement === first) {
152
+ event.preventDefault();
153
+ if (loop)
154
+ focus(last, { select: true });
155
+ }
156
+ }
157
+ }
158
+ },
159
+ [loop, trapped, focusScope.paused]
160
+ );
161
+ return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
162
+ });
163
+ FocusScope.displayName = FOCUS_SCOPE_NAME;
164
+ function focusFirst(candidates, { select = false } = {}) {
165
+ const previouslyFocusedElement = document.activeElement;
166
+ for (const candidate of candidates) {
167
+ focus(candidate, { select });
168
+ if (document.activeElement !== previouslyFocusedElement)
169
+ return;
170
+ }
171
+ }
172
+ function getTabbableEdges(container) {
173
+ const candidates = getTabbableCandidates(container);
174
+ const first = findVisible(candidates, container);
175
+ const last = findVisible(candidates.reverse(), container);
176
+ return [first, last];
177
+ }
178
+ function getTabbableCandidates(container) {
179
+ const nodes = [];
180
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
181
+ acceptNode: (node) => {
182
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
183
+ if (node.disabled || node.hidden || isHiddenInput)
184
+ return NodeFilter.FILTER_SKIP;
185
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
186
+ }
187
+ });
188
+ while (walker.nextNode())
189
+ nodes.push(walker.currentNode);
190
+ return nodes;
191
+ }
192
+ function findVisible(elements, container) {
193
+ for (const element of elements) {
194
+ if (!isHidden(element, { upTo: container }))
195
+ return element;
196
+ }
197
+ }
198
+ function isHidden(node, { upTo }) {
199
+ if (getComputedStyle(node).visibility === "hidden")
200
+ return true;
201
+ while (node) {
202
+ if (upTo !== void 0 && node === upTo)
203
+ return false;
204
+ if (getComputedStyle(node).display === "none")
205
+ return true;
206
+ node = node.parentElement;
207
+ }
208
+ return false;
209
+ }
210
+ function isSelectableInput(element) {
211
+ return element instanceof HTMLInputElement && "select" in element;
212
+ }
213
+ function focus(element, { select = false } = {}) {
214
+ if (element && element.focus) {
215
+ const previouslyFocusedElement = document.activeElement;
216
+ element.focus({ preventScroll: true });
217
+ if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
218
+ element.select();
219
+ }
220
+ }
221
+ var focusScopesStack = createFocusScopesStack();
222
+ function createFocusScopesStack() {
223
+ let stack = [];
224
+ return {
225
+ add(focusScope) {
226
+ const activeFocusScope = stack[0];
227
+ if (focusScope !== activeFocusScope) {
228
+ activeFocusScope == null ? void 0 : activeFocusScope.pause();
229
+ }
230
+ stack = arrayRemove(stack, focusScope);
231
+ stack.unshift(focusScope);
232
+ },
233
+ remove(focusScope) {
234
+ var _a;
235
+ stack = arrayRemove(stack, focusScope);
236
+ (_a = stack[0]) == null ? void 0 : _a.resume();
237
+ }
238
+ };
239
+ }
240
+ function arrayRemove(array, item) {
241
+ const updatedArray = [...array];
242
+ const index = updatedArray.indexOf(item);
243
+ if (index !== -1) {
244
+ updatedArray.splice(index, 1);
245
+ }
246
+ return updatedArray;
247
+ }
248
+ function removeLinks(items) {
249
+ return items.filter((item) => item.tagName !== "A");
250
+ }
251
+ var getDefaultParent = function(originalTarget) {
252
+ if (typeof document === "undefined") {
253
+ return null;
254
+ }
255
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
256
+ return sampleTarget.ownerDocument.body;
257
+ };
258
+ var counterMap = /* @__PURE__ */ new WeakMap();
259
+ var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
260
+ var markerMap = {};
261
+ var lockCount = 0;
262
+ var unwrapHost = function(node) {
263
+ return node && (node.host || unwrapHost(node.parentNode));
264
+ };
265
+ var correctTargets = function(parent, targets) {
266
+ return targets.map(function(target) {
267
+ if (parent.contains(target)) {
268
+ return target;
269
+ }
270
+ var correctedTarget = unwrapHost(target);
271
+ if (correctedTarget && parent.contains(correctedTarget)) {
272
+ return correctedTarget;
273
+ }
274
+ console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing");
275
+ return null;
276
+ }).filter(function(x) {
277
+ return Boolean(x);
278
+ });
279
+ };
280
+ var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) {
281
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
282
+ if (!markerMap[markerName]) {
283
+ markerMap[markerName] = /* @__PURE__ */ new WeakMap();
284
+ }
285
+ var markerCounter = markerMap[markerName];
286
+ var hiddenNodes = [];
287
+ var elementsToKeep = /* @__PURE__ */ new Set();
288
+ var elementsToStop = new Set(targets);
289
+ var keep = function(el) {
290
+ if (!el || elementsToKeep.has(el)) {
291
+ return;
292
+ }
293
+ elementsToKeep.add(el);
294
+ keep(el.parentNode);
295
+ };
296
+ targets.forEach(keep);
297
+ var deep = function(parent) {
298
+ if (!parent || elementsToStop.has(parent)) {
299
+ return;
300
+ }
301
+ Array.prototype.forEach.call(parent.children, function(node) {
302
+ if (elementsToKeep.has(node)) {
303
+ deep(node);
304
+ } else {
305
+ try {
306
+ var attr = node.getAttribute(controlAttribute);
307
+ var alreadyHidden = attr !== null && attr !== "false";
308
+ var counterValue = (counterMap.get(node) || 0) + 1;
309
+ var markerValue = (markerCounter.get(node) || 0) + 1;
310
+ counterMap.set(node, counterValue);
311
+ markerCounter.set(node, markerValue);
312
+ hiddenNodes.push(node);
313
+ if (counterValue === 1 && alreadyHidden) {
314
+ uncontrolledNodes.set(node, true);
315
+ }
316
+ if (markerValue === 1) {
317
+ node.setAttribute(markerName, "true");
318
+ }
319
+ if (!alreadyHidden) {
320
+ node.setAttribute(controlAttribute, "true");
321
+ }
322
+ } catch (e) {
323
+ console.error("aria-hidden: cannot operate on ", node, e);
324
+ }
325
+ }
326
+ });
327
+ };
328
+ deep(parentNode);
329
+ elementsToKeep.clear();
330
+ lockCount++;
331
+ return function() {
332
+ hiddenNodes.forEach(function(node) {
333
+ var counterValue = counterMap.get(node) - 1;
334
+ var markerValue = markerCounter.get(node) - 1;
335
+ counterMap.set(node, counterValue);
336
+ markerCounter.set(node, markerValue);
337
+ if (!counterValue) {
338
+ if (!uncontrolledNodes.has(node)) {
339
+ node.removeAttribute(controlAttribute);
340
+ }
341
+ uncontrolledNodes.delete(node);
342
+ }
343
+ if (!markerValue) {
344
+ node.removeAttribute(markerName);
345
+ }
346
+ });
347
+ lockCount--;
348
+ if (!lockCount) {
349
+ counterMap = /* @__PURE__ */ new WeakMap();
350
+ counterMap = /* @__PURE__ */ new WeakMap();
351
+ uncontrolledNodes = /* @__PURE__ */ new WeakMap();
352
+ markerMap = {};
353
+ }
354
+ };
355
+ };
356
+ var hideOthers = function(originalTarget, parentNode, markerName) {
357
+ if (markerName === void 0) {
358
+ markerName = "data-aria-hidden";
359
+ }
360
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
361
+ var activeParentNode = getDefaultParent(originalTarget);
362
+ if (!activeParentNode) {
363
+ return function() {
364
+ return null;
365
+ };
366
+ }
367
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live]")));
368
+ return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
369
+ };
370
+ var zeroRightClassName = "right-scroll-bar-position";
371
+ var fullWidthClassName = "width-before-scroll-bar";
372
+ var noScrollbarsClassName = "with-scroll-bars-hidden";
373
+ var removedBarSizeVariable = "--removed-body-scroll-bar-size";
374
+ function assignRef(ref, value) {
375
+ if (typeof ref === "function") {
376
+ ref(value);
377
+ } else if (ref) {
378
+ ref.current = value;
379
+ }
380
+ return ref;
381
+ }
382
+ function useCallbackRef(initialValue, callback) {
383
+ var ref = useState(function() {
384
+ return {
385
+ // value
386
+ value: initialValue,
387
+ // last callback
388
+ callback,
389
+ // "memoized" public interface
390
+ facade: {
391
+ get current() {
392
+ return ref.value;
393
+ },
394
+ set current(value) {
395
+ var last = ref.value;
396
+ if (last !== value) {
397
+ ref.value = value;
398
+ ref.callback(value, last);
399
+ }
400
+ }
401
+ }
402
+ };
403
+ })[0];
404
+ ref.callback = callback;
405
+ return ref.facade;
406
+ }
407
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
408
+ var currentValues = /* @__PURE__ */ new WeakMap();
409
+ function useMergeRefs(refs, defaultValue) {
410
+ var callbackRef = useCallbackRef(null, function(newValue) {
411
+ return refs.forEach(function(ref) {
412
+ return assignRef(ref, newValue);
413
+ });
414
+ });
415
+ useIsomorphicLayoutEffect(function() {
416
+ var oldValue = currentValues.get(callbackRef);
417
+ if (oldValue) {
418
+ var prevRefs_1 = new Set(oldValue);
419
+ var nextRefs_1 = new Set(refs);
420
+ var current_1 = callbackRef.current;
421
+ prevRefs_1.forEach(function(ref) {
422
+ if (!nextRefs_1.has(ref)) {
423
+ assignRef(ref, null);
424
+ }
425
+ });
426
+ nextRefs_1.forEach(function(ref) {
427
+ if (!prevRefs_1.has(ref)) {
428
+ assignRef(ref, current_1);
429
+ }
430
+ });
431
+ }
432
+ currentValues.set(callbackRef, refs);
433
+ }, [refs]);
434
+ return callbackRef;
435
+ }
436
+ function ItoI(a) {
437
+ return a;
438
+ }
439
+ function innerCreateMedium(defaults, middleware) {
440
+ if (middleware === void 0) {
441
+ middleware = ItoI;
442
+ }
443
+ var buffer = [];
444
+ var assigned = false;
445
+ var medium = {
446
+ read: function() {
447
+ if (assigned) {
448
+ throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
449
+ }
450
+ if (buffer.length) {
451
+ return buffer[buffer.length - 1];
452
+ }
453
+ return defaults;
454
+ },
455
+ useMedium: function(data) {
456
+ var item = middleware(data, assigned);
457
+ buffer.push(item);
458
+ return function() {
459
+ buffer = buffer.filter(function(x) {
460
+ return x !== item;
461
+ });
462
+ };
463
+ },
464
+ assignSyncMedium: function(cb) {
465
+ assigned = true;
466
+ while (buffer.length) {
467
+ var cbs = buffer;
468
+ buffer = [];
469
+ cbs.forEach(cb);
470
+ }
471
+ buffer = {
472
+ push: function(x) {
473
+ return cb(x);
474
+ },
475
+ filter: function() {
476
+ return buffer;
477
+ }
478
+ };
479
+ },
480
+ assignMedium: function(cb) {
481
+ assigned = true;
482
+ var pendingQueue = [];
483
+ if (buffer.length) {
484
+ var cbs = buffer;
485
+ buffer = [];
486
+ cbs.forEach(cb);
487
+ pendingQueue = buffer;
488
+ }
489
+ var executeQueue = function() {
490
+ var cbs2 = pendingQueue;
491
+ pendingQueue = [];
492
+ cbs2.forEach(cb);
493
+ };
494
+ var cycle = function() {
495
+ return Promise.resolve().then(executeQueue);
496
+ };
497
+ cycle();
498
+ buffer = {
499
+ push: function(x) {
500
+ pendingQueue.push(x);
501
+ cycle();
502
+ },
503
+ filter: function(filter) {
504
+ pendingQueue = pendingQueue.filter(filter);
505
+ return buffer;
506
+ }
507
+ };
508
+ }
509
+ };
510
+ return medium;
511
+ }
512
+ function createSidecarMedium(options) {
513
+ if (options === void 0) {
514
+ options = {};
515
+ }
516
+ var medium = innerCreateMedium(null);
517
+ medium.options = __assign({ async: true, ssr: false }, options);
518
+ return medium;
519
+ }
520
+ var SideCar$1 = function(_a) {
521
+ var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
522
+ if (!sideCar) {
523
+ throw new Error("Sidecar: please provide `sideCar` property to import the right car");
524
+ }
525
+ var Target = sideCar.read();
526
+ if (!Target) {
527
+ throw new Error("Sidecar medium not found");
528
+ }
529
+ return React.createElement(Target, __assign({}, rest));
530
+ };
531
+ SideCar$1.isSideCarExport = true;
532
+ function exportSidecar(medium, exported) {
533
+ medium.useMedium(exported);
534
+ return SideCar$1;
535
+ }
536
+ var effectCar = createSidecarMedium();
537
+ var nothing = function() {
538
+ return;
539
+ };
540
+ var RemoveScroll = React.forwardRef(function(props, parentRef) {
541
+ var ref = React.useRef(null);
542
+ var _a = React.useState({
543
+ onScrollCapture: nothing,
544
+ onWheelCapture: nothing,
545
+ onTouchMoveCapture: nothing
546
+ }), callbacks = _a[0], setCallbacks = _a[1];
547
+ var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
548
+ var SideCar2 = sideCar;
549
+ var containerRef = useMergeRefs([ref, parentRef]);
550
+ var containerProps = __assign(__assign({}, rest), callbacks);
551
+ return React.createElement(
552
+ React.Fragment,
553
+ null,
554
+ enabled && React.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
555
+ forwardProps ? React.cloneElement(React.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
556
+ );
557
+ });
558
+ RemoveScroll.defaultProps = {
559
+ enabled: true,
560
+ removeScrollBar: true,
561
+ inert: false
562
+ };
563
+ RemoveScroll.classNames = {
564
+ fullWidth: fullWidthClassName,
565
+ zeroRight: zeroRightClassName
566
+ };
567
+ var getNonce = function() {
568
+ if (typeof __webpack_nonce__ !== "undefined") {
569
+ return __webpack_nonce__;
570
+ }
571
+ return void 0;
572
+ };
573
+ function makeStyleTag() {
574
+ if (!document)
575
+ return null;
576
+ var tag = document.createElement("style");
577
+ tag.type = "text/css";
578
+ var nonce = getNonce();
579
+ if (nonce) {
580
+ tag.setAttribute("nonce", nonce);
581
+ }
582
+ return tag;
583
+ }
584
+ function injectStyles(tag, css) {
585
+ if (tag.styleSheet) {
586
+ tag.styleSheet.cssText = css;
587
+ } else {
588
+ tag.appendChild(document.createTextNode(css));
589
+ }
590
+ }
591
+ function insertStyleTag(tag) {
592
+ var head = document.head || document.getElementsByTagName("head")[0];
593
+ head.appendChild(tag);
594
+ }
595
+ var stylesheetSingleton = function() {
596
+ var counter = 0;
597
+ var stylesheet = null;
598
+ return {
599
+ add: function(style) {
600
+ if (counter == 0) {
601
+ if (stylesheet = makeStyleTag()) {
602
+ injectStyles(stylesheet, style);
603
+ insertStyleTag(stylesheet);
604
+ }
605
+ }
606
+ counter++;
607
+ },
608
+ remove: function() {
609
+ counter--;
610
+ if (!counter && stylesheet) {
611
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
612
+ stylesheet = null;
613
+ }
614
+ }
615
+ };
616
+ };
617
+ var styleHookSingleton = function() {
618
+ var sheet = stylesheetSingleton();
619
+ return function(styles, isDynamic) {
620
+ React.useEffect(function() {
621
+ sheet.add(styles);
622
+ return function() {
623
+ sheet.remove();
624
+ };
625
+ }, [styles && isDynamic]);
626
+ };
627
+ };
628
+ var styleSingleton = function() {
629
+ var useStyle = styleHookSingleton();
630
+ var Sheet = function(_a) {
631
+ var styles = _a.styles, dynamic = _a.dynamic;
632
+ useStyle(styles, dynamic);
633
+ return null;
634
+ };
635
+ return Sheet;
636
+ };
637
+ var zeroGap = {
638
+ left: 0,
639
+ top: 0,
640
+ right: 0,
641
+ gap: 0
642
+ };
643
+ var parse = function(x) {
644
+ return parseInt(x || "", 10) || 0;
645
+ };
646
+ var getOffset = function(gapMode) {
647
+ var cs = window.getComputedStyle(document.body);
648
+ var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"];
649
+ var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"];
650
+ var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"];
651
+ return [parse(left), parse(top), parse(right)];
652
+ };
653
+ var getGapWidth = function(gapMode) {
654
+ if (gapMode === void 0) {
655
+ gapMode = "margin";
656
+ }
657
+ if (typeof window === "undefined") {
658
+ return zeroGap;
659
+ }
660
+ var offsets = getOffset(gapMode);
661
+ var documentWidth = document.documentElement.clientWidth;
662
+ var windowWidth = window.innerWidth;
663
+ return {
664
+ left: offsets[0],
665
+ top: offsets[1],
666
+ right: offsets[2],
667
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0])
668
+ };
669
+ };
670
+ var Style = styleSingleton();
671
+ var lockAttribute = "data-scroll-locked";
672
+ var getStyles = function(_a, allowRelative, gapMode, important) {
673
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
674
+ if (gapMode === void 0) {
675
+ gapMode = "margin";
676
+ }
677
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
678
+ allowRelative && "position: relative ".concat(important, ";"),
679
+ gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
680
+ gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
681
+ ].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
682
+ };
683
+ var getCurrentUseCounter = function() {
684
+ var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10);
685
+ return isFinite(counter) ? counter : 0;
686
+ };
687
+ var useLockAttribute = function() {
688
+ React.useEffect(function() {
689
+ document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
690
+ return function() {
691
+ var newCounter = getCurrentUseCounter() - 1;
692
+ if (newCounter <= 0) {
693
+ document.body.removeAttribute(lockAttribute);
694
+ } else {
695
+ document.body.setAttribute(lockAttribute, newCounter.toString());
696
+ }
697
+ };
698
+ }, []);
699
+ };
700
+ var RemoveScrollBar = function(_a) {
701
+ var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
702
+ useLockAttribute();
703
+ var gap = React.useMemo(function() {
704
+ return getGapWidth(gapMode);
705
+ }, [gapMode]);
706
+ return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
707
+ };
708
+ var passiveSupported = false;
709
+ if (typeof window !== "undefined") {
710
+ try {
711
+ var options = Object.defineProperty({}, "passive", {
712
+ get: function() {
713
+ passiveSupported = true;
714
+ return true;
715
+ }
716
+ });
717
+ window.addEventListener("test", options, options);
718
+ window.removeEventListener("test", options, options);
719
+ } catch (err) {
720
+ passiveSupported = false;
721
+ }
722
+ }
723
+ var nonPassive = passiveSupported ? { passive: false } : false;
724
+ var alwaysContainsScroll = function(node) {
725
+ return node.tagName === "TEXTAREA";
726
+ };
727
+ var elementCanBeScrolled = function(node, overflow) {
728
+ if (!(node instanceof Element)) {
729
+ return false;
730
+ }
731
+ var styles = window.getComputedStyle(node);
732
+ return (
733
+ // not-not-scrollable
734
+ styles[overflow] !== "hidden" && // contains scroll inside self
735
+ !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible")
736
+ );
737
+ };
738
+ var elementCouldBeVScrolled = function(node) {
739
+ return elementCanBeScrolled(node, "overflowY");
740
+ };
741
+ var elementCouldBeHScrolled = function(node) {
742
+ return elementCanBeScrolled(node, "overflowX");
743
+ };
744
+ var locationCouldBeScrolled = function(axis, node) {
745
+ var ownerDocument = node.ownerDocument;
746
+ var current = node;
747
+ do {
748
+ if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
749
+ current = current.host;
750
+ }
751
+ var isScrollable = elementCouldBeScrolled(axis, current);
752
+ if (isScrollable) {
753
+ var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
754
+ if (scrollHeight > clientHeight) {
755
+ return true;
756
+ }
757
+ }
758
+ current = current.parentNode;
759
+ } while (current && current !== ownerDocument.body);
760
+ return false;
761
+ };
762
+ var getVScrollVariables = function(_a) {
763
+ var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
764
+ return [
765
+ scrollTop,
766
+ scrollHeight,
767
+ clientHeight
768
+ ];
769
+ };
770
+ var getHScrollVariables = function(_a) {
771
+ var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
772
+ return [
773
+ scrollLeft,
774
+ scrollWidth,
775
+ clientWidth
776
+ ];
777
+ };
778
+ var elementCouldBeScrolled = function(axis, node) {
779
+ return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
780
+ };
781
+ var getScrollVariables = function(axis, node) {
782
+ return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
783
+ };
784
+ var getDirectionFactor = function(axis, direction) {
785
+ return axis === "h" && direction === "rtl" ? -1 : 1;
786
+ };
787
+ var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
788
+ var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
789
+ var delta = directionFactor * sourceDelta;
790
+ var target = event.target;
791
+ var targetInLock = endTarget.contains(target);
792
+ var shouldCancelScroll = false;
793
+ var isDeltaPositive = delta > 0;
794
+ var availableScroll = 0;
795
+ var availableScrollTop = 0;
796
+ do {
797
+ var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
798
+ var elementScroll = scroll_1 - capacity - directionFactor * position;
799
+ if (position || elementScroll) {
800
+ if (elementCouldBeScrolled(axis, target)) {
801
+ availableScroll += elementScroll;
802
+ availableScrollTop += position;
803
+ }
804
+ }
805
+ if (target instanceof ShadowRoot) {
806
+ target = target.host;
807
+ } else {
808
+ target = target.parentNode;
809
+ }
810
+ } while (
811
+ // portaled content
812
+ !targetInLock && target !== document.body || // self content
813
+ targetInLock && (endTarget.contains(target) || endTarget === target)
814
+ );
815
+ if (isDeltaPositive && (Math.abs(availableScroll) < 1 || !noOverscroll)) {
816
+ shouldCancelScroll = true;
817
+ } else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || !noOverscroll)) {
818
+ shouldCancelScroll = true;
819
+ }
820
+ return shouldCancelScroll;
821
+ };
822
+ var getTouchXY = function(event) {
823
+ return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
824
+ };
825
+ var getDeltaXY = function(event) {
826
+ return [event.deltaX, event.deltaY];
827
+ };
828
+ var extractRef = function(ref) {
829
+ return ref && "current" in ref ? ref.current : ref;
830
+ };
831
+ var deltaCompare = function(x, y) {
832
+ return x[0] === y[0] && x[1] === y[1];
833
+ };
834
+ var generateStyle = function(id) {
835
+ return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
836
+ };
837
+ var idCounter = 0;
838
+ var lockStack = [];
839
+ function RemoveScrollSideCar(props) {
840
+ var shouldPreventQueue = React.useRef([]);
841
+ var touchStartRef = React.useRef([0, 0]);
842
+ var activeAxis = React.useRef();
843
+ var id = React.useState(idCounter++)[0];
844
+ var Style2 = React.useState(styleSingleton)[0];
845
+ var lastProps = React.useRef(props);
846
+ React.useEffect(function() {
847
+ lastProps.current = props;
848
+ }, [props]);
849
+ React.useEffect(function() {
850
+ if (props.inert) {
851
+ document.body.classList.add("block-interactivity-".concat(id));
852
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
853
+ allow_1.forEach(function(el) {
854
+ return el.classList.add("allow-interactivity-".concat(id));
855
+ });
856
+ return function() {
857
+ document.body.classList.remove("block-interactivity-".concat(id));
858
+ allow_1.forEach(function(el) {
859
+ return el.classList.remove("allow-interactivity-".concat(id));
860
+ });
861
+ };
862
+ }
863
+ return;
864
+ }, [props.inert, props.lockRef.current, props.shards]);
865
+ var shouldCancelEvent = React.useCallback(function(event, parent) {
866
+ if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
867
+ return !lastProps.current.allowPinchZoom;
868
+ }
869
+ var touch = getTouchXY(event);
870
+ var touchStart = touchStartRef.current;
871
+ var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
872
+ var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
873
+ var currentAxis;
874
+ var target = event.target;
875
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
876
+ if ("touches" in event && moveDirection === "h" && target.type === "range") {
877
+ return false;
878
+ }
879
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
880
+ if (!canBeScrolledInMainDirection) {
881
+ return true;
882
+ }
883
+ if (canBeScrolledInMainDirection) {
884
+ currentAxis = moveDirection;
885
+ } else {
886
+ currentAxis = moveDirection === "v" ? "h" : "v";
887
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
888
+ }
889
+ if (!canBeScrolledInMainDirection) {
890
+ return false;
891
+ }
892
+ if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
893
+ activeAxis.current = currentAxis;
894
+ }
895
+ if (!currentAxis) {
896
+ return true;
897
+ }
898
+ var cancelingAxis = activeAxis.current || currentAxis;
899
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY, true);
900
+ }, []);
901
+ var shouldPrevent = React.useCallback(function(_event) {
902
+ var event = _event;
903
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style2) {
904
+ return;
905
+ }
906
+ var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
907
+ var sourceEvent = shouldPreventQueue.current.filter(function(e) {
908
+ return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
909
+ })[0];
910
+ if (sourceEvent && sourceEvent.should) {
911
+ if (event.cancelable) {
912
+ event.preventDefault();
913
+ }
914
+ return;
915
+ }
916
+ if (!sourceEvent) {
917
+ var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
918
+ return node.contains(event.target);
919
+ });
920
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
921
+ if (shouldStop) {
922
+ if (event.cancelable) {
923
+ event.preventDefault();
924
+ }
925
+ }
926
+ }
927
+ }, []);
928
+ var shouldCancel = React.useCallback(function(name, delta, target, should) {
929
+ var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
930
+ shouldPreventQueue.current.push(event);
931
+ setTimeout(function() {
932
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
933
+ return e !== event;
934
+ });
935
+ }, 1);
936
+ }, []);
937
+ var scrollTouchStart = React.useCallback(function(event) {
938
+ touchStartRef.current = getTouchXY(event);
939
+ activeAxis.current = void 0;
940
+ }, []);
941
+ var scrollWheel = React.useCallback(function(event) {
942
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
943
+ }, []);
944
+ var scrollTouchMove = React.useCallback(function(event) {
945
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
946
+ }, []);
947
+ React.useEffect(function() {
948
+ lockStack.push(Style2);
949
+ props.setCallbacks({
950
+ onScrollCapture: scrollWheel,
951
+ onWheelCapture: scrollWheel,
952
+ onTouchMoveCapture: scrollTouchMove
953
+ });
954
+ document.addEventListener("wheel", shouldPrevent, nonPassive);
955
+ document.addEventListener("touchmove", shouldPrevent, nonPassive);
956
+ document.addEventListener("touchstart", scrollTouchStart, nonPassive);
957
+ return function() {
958
+ lockStack = lockStack.filter(function(inst) {
959
+ return inst !== Style2;
960
+ });
961
+ document.removeEventListener("wheel", shouldPrevent, nonPassive);
962
+ document.removeEventListener("touchmove", shouldPrevent, nonPassive);
963
+ document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
964
+ };
965
+ }, []);
966
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
967
+ return React.createElement(
968
+ React.Fragment,
969
+ null,
970
+ inert ? React.createElement(Style2, { styles: generateStyle(id) }) : null,
971
+ removeScrollBar ? React.createElement(RemoveScrollBar, { gapMode: props.gapMode }) : null
972
+ );
973
+ }
974
+ function getOutermostShadowParent(node) {
975
+ var shadowParent = null;
976
+ while (node !== null) {
977
+ if (node instanceof ShadowRoot) {
978
+ shadowParent = node.host;
979
+ node = node.host;
980
+ }
981
+ node = node.parentNode;
982
+ }
983
+ return shadowParent;
984
+ }
985
+ const SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
986
+ var ReactRemoveScroll = React.forwardRef(function(props, ref) {
987
+ return React.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: SideCar }));
988
+ });
989
+ ReactRemoveScroll.classNames = RemoveScroll.classNames;
990
+ export {
991
+ FocusScope as F,
992
+ ReactRemoveScroll as R,
993
+ hideOthers as h,
994
+ useFocusGuards as u
995
+ };
996
+ //# sourceMappingURL=Combination-DmhTQmbL.js.map