@uninspired/cookie-banner 0.0.7 → 0.0.9

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.
@@ -1,10 +1,6 @@
1
1
  import * as React from "react";
2
2
  import React__default, { forwardRef, createElement, useMemo, useState, useEffect, useCallback, useContext, createContext } from "react";
3
- import * as ReactDOM from "react-dom";
4
3
  var l;
5
- function k(n) {
6
- return n.children;
7
- }
8
4
  l = { __e: function(n, l2, u2, t) {
9
5
  for (var i, r, o; l2 = l2.__; ) if ((i = l2.__c) && !i.__) try {
10
6
  if ((r = i.constructor) && null != r.getDerivedStateFromError && (i.setState(r.getDerivedStateFromError(n)), o = i.__d), null != i.componentDidCatch && (i.componentDidCatch(n, t || {}), o = i.__d), o) return i.__E = i;
@@ -79,25 +75,25 @@ const Text = ({
79
75
  )
80
76
  );
81
77
  };
82
- const root$2 = "_root_1wsw7_42";
83
- const noTarget = "_noTarget_1wsw7_53";
84
- const collapsible = "_collapsible_1wsw7_62";
85
- const header$1 = "_header_1wsw7_65";
86
- const heading = "_heading_1wsw7_72";
87
- const chevron$1 = "_chevron_1wsw7_78";
88
- const open$1 = "_open_1wsw7_83";
89
- const settings = "_settings_1wsw7_89";
90
- const footer = "_footer_1wsw7_103";
91
- const legal = "_legal_1wsw7_110";
92
- const actions$1 = "_actions_1wsw7_113";
78
+ const root$2 = "_root_2wcp0_53";
79
+ const open$1 = "_open_2wcp0_66";
80
+ const noTarget = "_noTarget_2wcp0_72";
81
+ const collapsible = "_collapsible_2wcp0_81";
82
+ const header$1 = "_header_2wcp0_84";
83
+ const heading = "_heading_2wcp0_91";
84
+ const chevron$1 = "_chevron_2wcp0_97";
85
+ const settings = "_settings_2wcp0_108";
86
+ const footer = "_footer_2wcp0_122";
87
+ const legal = "_legal_2wcp0_129";
88
+ const actions$1 = "_actions_2wcp0_132";
93
89
  const classes$2 = {
94
90
  root: root$2,
91
+ open: open$1,
95
92
  noTarget,
96
93
  collapsible,
97
94
  header: header$1,
98
95
  heading,
99
96
  chevron: chevron$1,
100
- open: open$1,
101
97
  settings,
102
98
  footer,
103
99
  legal,
@@ -139,9 +135,9 @@ function $constructor(name, initializer2, params) {
139
135
  const proto = _.prototype;
140
136
  const keys = Object.keys(proto);
141
137
  for (let i = 0; i < keys.length; i++) {
142
- const k2 = keys[i];
143
- if (!(k2 in inst)) {
144
- inst[k2] = proto[k2].bind(inst);
138
+ const k = keys[i];
139
+ if (!(k in inst)) {
140
+ inst[k] = proto[k].bind(inst);
145
141
  }
146
142
  }
147
143
  }
@@ -257,8 +253,8 @@ function normalizeParams(_params) {
257
253
  return {};
258
254
  }
259
255
  function optionalKeys(shape) {
260
- return Object.keys(shape).filter((k2) => {
261
- return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
256
+ return Object.keys(shape).filter((k) => {
257
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
262
258
  });
263
259
  }
264
260
  function aborted(x, startIndex = 0) {
@@ -326,7 +322,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
326
322
  }
327
323
  return result.value;
328
324
  };
329
- const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
325
+ const parse = /* @__PURE__ */ _parse($ZodRealError);
330
326
  const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
331
327
  const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
332
328
  let result = schema._zod.run({ value, issues: [] }, ctx);
@@ -541,9 +537,9 @@ function handlePropertyResult(result, final, key, input, isOptionalOut) {
541
537
  }
542
538
  function normalizeDef(def) {
543
539
  const keys = Object.keys(def.shape);
544
- for (const k2 of keys) {
545
- if (!def.shape?.[k2]?._zod?.traits?.has("$ZodType")) {
546
- throw new Error(`Invalid element at key "${k2}": expected a Zod schema`);
540
+ for (const k of keys) {
541
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
542
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
547
543
  }
548
544
  }
549
545
  const okeys = optionalKeys(def.shape);
@@ -728,11 +724,11 @@ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUn
728
724
  const pv = option._zod.propValues;
729
725
  if (!pv || Object.keys(pv).length === 0)
730
726
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
731
- for (const [k2, v] of Object.entries(pv)) {
732
- if (!propValues[k2])
733
- propValues[k2] = /* @__PURE__ */ new Set();
727
+ for (const [k, v] of Object.entries(pv)) {
728
+ if (!propValues[k])
729
+ propValues[k] = /* @__PURE__ */ new Set();
734
730
  for (const val of v) {
735
- propValues[k2].add(val);
731
+ propValues[k].add(val);
736
732
  }
737
733
  }
738
734
  }
@@ -964,7 +960,7 @@ const ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
964
960
  $ZodType.init(inst, def);
965
961
  inst.def = def;
966
962
  inst.type = def.type;
967
- inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
963
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
968
964
  inst.safeParse = (data, params) => safeParse(inst, data, params);
969
965
  inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
970
966
  inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
@@ -1091,7 +1087,7 @@ var hasRequiredReactJsxRuntime_production_min;
1091
1087
  function requireReactJsxRuntime_production_min() {
1092
1088
  if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
1093
1089
  hasRequiredReactJsxRuntime_production_min = 1;
1094
- var f2 = React__default, k2 = /* @__PURE__ */ Symbol.for("react.element"), l2 = /* @__PURE__ */ Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
1090
+ var f2 = React__default, k = /* @__PURE__ */ Symbol.for("react.element"), l2 = /* @__PURE__ */ Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
1095
1091
  function q(c, a, g) {
1096
1092
  var b, d = {}, e = null, h = null;
1097
1093
  void 0 !== g && (e = "" + g);
@@ -1099,7 +1095,7 @@ function requireReactJsxRuntime_production_min() {
1099
1095
  void 0 !== a.ref && (h = a.ref);
1100
1096
  for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
1101
1097
  if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
1102
- return { $$typeof: k2, type: c, key: e, ref: h, props: d, _owner: n.current };
1098
+ return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
1103
1099
  }
1104
1100
  reactJsxRuntime_production_min.Fragment = l2;
1105
1101
  reactJsxRuntime_production_min.jsx = q;
@@ -1936,8 +1932,8 @@ function requireReactJsxRuntime_development() {
1936
1932
  {
1937
1933
  if (hasOwnProperty.call(props, "key")) {
1938
1934
  var componentName = getComponentNameFromType(type);
1939
- var keys = Object.keys(props).filter(function(k2) {
1940
- return k2 !== "key";
1935
+ var keys = Object.keys(props).filter(function(k) {
1936
+ return k !== "key";
1941
1937
  });
1942
1938
  var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
1943
1939
  if (!didWarnAboutKeySpread[componentName + beforeExample]) {
@@ -1986,22 +1982,6 @@ function requireJsxRuntime() {
1986
1982
  return jsxRuntime.exports;
1987
1983
  }
1988
1984
  var jsxRuntimeExports = /* @__PURE__ */ requireJsxRuntime();
1989
- function createContext2(rootComponentName, defaultContext) {
1990
- const Context = React.createContext(defaultContext);
1991
- const Provider = (props) => {
1992
- const { children, ...context } = props;
1993
- const value = React.useMemo(() => context, Object.values(context));
1994
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Context.Provider, { value, children });
1995
- };
1996
- Provider.displayName = rootComponentName + "Provider";
1997
- function useContext2(consumerName) {
1998
- const context = React.useContext(Context);
1999
- if (context) return context;
2000
- if (defaultContext !== void 0) return defaultContext;
2001
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
2002
- }
2003
- return [Provider, useContext2];
2004
- }
2005
1985
  function createContextScope(scopeName, createContextScopeDeps = []) {
2006
1986
  let defaultContexts = [];
2007
1987
  function createContext3(rootComponentName, defaultContext) {
@@ -2331,21 +2311,18 @@ var NODES = [
2331
2311
  "ul"
2332
2312
  ];
2333
2313
  var Primitive = NODES.reduce((primitive, node) => {
2334
- const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
2335
- const Node2 = React.forwardRef((props, forwardedRef) => {
2314
+ const Slot = /* @__PURE__ */ createSlot(`Primitive.${node}`);
2315
+ const Node = React.forwardRef((props, forwardedRef) => {
2336
2316
  const { asChild, ...primitiveProps } = props;
2337
- const Comp = asChild ? Slot2 : node;
2317
+ const Comp = asChild ? Slot : node;
2338
2318
  if (typeof window !== "undefined") {
2339
2319
  window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
2340
2320
  }
2341
2321
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Comp, { ...primitiveProps, ref: forwardedRef });
2342
2322
  });
2343
- Node2.displayName = `Primitive.${node}`;
2344
- return { ...primitive, [node]: Node2 };
2323
+ Node.displayName = `Primitive.${node}`;
2324
+ return { ...primitive, [node]: Node };
2345
2325
  }, {});
2346
- function dispatchDiscreteCustomEvent(target, event) {
2347
- if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
2348
- }
2349
2326
  function useStateMachine(initialState, machine) {
2350
2327
  return React.useReducer((state, event) => {
2351
2328
  const nextState = machine[state][event];
@@ -2469,11 +2446,11 @@ function getElementRef(element) {
2469
2446
  return element.props.ref || element.ref;
2470
2447
  }
2471
2448
  var useReactId = React[" useId ".trim().toString()] || (() => void 0);
2472
- var count$1 = 0;
2449
+ var count = 0;
2473
2450
  function useId(deterministicId) {
2474
2451
  const [id, setId] = React.useState(useReactId());
2475
2452
  useLayoutEffect2(() => {
2476
- setId((reactId) => reactId ?? String(count$1++));
2453
+ setId((reactId) => reactId ?? String(count++));
2477
2454
  }, [deterministicId]);
2478
2455
  return deterministicId || (id ? `radix-${id}` : "");
2479
2456
  }
@@ -2507,7 +2484,7 @@ var Collapsible = React.forwardRef(
2507
2484
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2508
2485
  Primitive.div,
2509
2486
  {
2510
- "data-state": getState$3(open2),
2487
+ "data-state": getState$2(open2),
2511
2488
  "data-disabled": disabled ? "" : void 0,
2512
2489
  ...collapsibleProps,
2513
2490
  ref: forwardedRef
@@ -2518,18 +2495,18 @@ var Collapsible = React.forwardRef(
2518
2495
  }
2519
2496
  );
2520
2497
  Collapsible.displayName = COLLAPSIBLE_NAME;
2521
- var TRIGGER_NAME$2 = "CollapsibleTrigger";
2498
+ var TRIGGER_NAME$1 = "CollapsibleTrigger";
2522
2499
  var CollapsibleTrigger = React.forwardRef(
2523
2500
  (props, forwardedRef) => {
2524
2501
  const { __scopeCollapsible, ...triggerProps } = props;
2525
- const context = useCollapsibleContext(TRIGGER_NAME$2, __scopeCollapsible);
2502
+ const context = useCollapsibleContext(TRIGGER_NAME$1, __scopeCollapsible);
2526
2503
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
2527
2504
  Primitive.button,
2528
2505
  {
2529
2506
  type: "button",
2530
2507
  "aria-controls": context.contentId,
2531
2508
  "aria-expanded": context.open || false,
2532
- "data-state": getState$3(context.open),
2509
+ "data-state": getState$2(context.open),
2533
2510
  "data-disabled": context.disabled ? "" : void 0,
2534
2511
  disabled: context.disabled,
2535
2512
  ...triggerProps,
@@ -2539,19 +2516,19 @@ var CollapsibleTrigger = React.forwardRef(
2539
2516
  );
2540
2517
  }
2541
2518
  );
2542
- CollapsibleTrigger.displayName = TRIGGER_NAME$2;
2543
- var CONTENT_NAME$2 = "CollapsibleContent";
2519
+ CollapsibleTrigger.displayName = TRIGGER_NAME$1;
2520
+ var CONTENT_NAME$1 = "CollapsibleContent";
2544
2521
  var CollapsibleContent = React.forwardRef(
2545
2522
  (props, forwardedRef) => {
2546
2523
  const { forceMount, ...contentProps } = props;
2547
- const context = useCollapsibleContext(CONTENT_NAME$2, props.__scopeCollapsible);
2524
+ const context = useCollapsibleContext(CONTENT_NAME$1, props.__scopeCollapsible);
2548
2525
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Presence, { present: forceMount || context.open, children: ({ present }) => /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsibleContentImpl, { ...contentProps, ref: forwardedRef, present }) });
2549
2526
  }
2550
2527
  );
2551
- CollapsibleContent.displayName = CONTENT_NAME$2;
2528
+ CollapsibleContent.displayName = CONTENT_NAME$1;
2552
2529
  var CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
2553
2530
  const { __scopeCollapsible, present, children, ...contentProps } = props;
2554
- const context = useCollapsibleContext(CONTENT_NAME$2, __scopeCollapsible);
2531
+ const context = useCollapsibleContext(CONTENT_NAME$1, __scopeCollapsible);
2555
2532
  const [isPresent, setIsPresent] = React.useState(present);
2556
2533
  const ref = React.useRef(null);
2557
2534
  const composedRefs = useComposedRefs(forwardedRef, ref);
@@ -2588,7 +2565,7 @@ var CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
2588
2565
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
2589
2566
  Primitive.div,
2590
2567
  {
2591
- "data-state": getState$3(context.open),
2568
+ "data-state": getState$2(context.open),
2592
2569
  "data-disabled": context.disabled ? "" : void 0,
2593
2570
  id: context.contentId,
2594
2571
  hidden: !isOpen,
@@ -2603,12 +2580,12 @@ var CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
2603
2580
  }
2604
2581
  );
2605
2582
  });
2606
- function getState$3(open2) {
2583
+ function getState$2(open2) {
2607
2584
  return open2 ? "open" : "closed";
2608
2585
  }
2609
- var Root$2 = Collapsible;
2586
+ var Root$1 = Collapsible;
2610
2587
  var Trigger = CollapsibleTrigger;
2611
- var Content$1 = CollapsibleContent;
2588
+ var Content = CollapsibleContent;
2612
2589
  var DirectionContext = React.createContext(void 0);
2613
2590
  function useDirection(localDir) {
2614
2591
  const globalDir = React.useContext(DirectionContext);
@@ -2807,10 +2784,10 @@ var AccordionItem = React__default.forwardRef(
2807
2784
  disabled,
2808
2785
  triggerId,
2809
2786
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2810
- Root$2,
2787
+ Root$1,
2811
2788
  {
2812
2789
  "data-orientation": accordionContext.orientation,
2813
- "data-state": getState$2(open2),
2790
+ "data-state": getState$1(open2),
2814
2791
  ...collapsibleScope,
2815
2792
  ...accordionItemProps,
2816
2793
  ref: forwardedRef,
@@ -2840,7 +2817,7 @@ var AccordionHeader = React__default.forwardRef(
2840
2817
  Primitive.h3,
2841
2818
  {
2842
2819
  "data-orientation": accordionContext.orientation,
2843
- "data-state": getState$2(itemContext.open),
2820
+ "data-state": getState$1(itemContext.open),
2844
2821
  "data-disabled": itemContext.disabled ? "" : void 0,
2845
2822
  ...headerProps,
2846
2823
  ref: forwardedRef
@@ -2849,13 +2826,13 @@ var AccordionHeader = React__default.forwardRef(
2849
2826
  }
2850
2827
  );
2851
2828
  AccordionHeader.displayName = HEADER_NAME;
2852
- var TRIGGER_NAME$1 = "AccordionTrigger";
2829
+ var TRIGGER_NAME = "AccordionTrigger";
2853
2830
  var AccordionTrigger = React__default.forwardRef(
2854
2831
  (props, forwardedRef) => {
2855
2832
  const { __scopeAccordion, ...triggerProps } = props;
2856
2833
  const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
2857
- const itemContext = useAccordionItemContext(TRIGGER_NAME$1, __scopeAccordion);
2858
- const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME$1, __scopeAccordion);
2834
+ const itemContext = useAccordionItemContext(TRIGGER_NAME, __scopeAccordion);
2835
+ const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME, __scopeAccordion);
2859
2836
  const collapsibleScope = useCollapsibleScope(__scopeAccordion);
2860
2837
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Collection.ItemSlot, { scope: __scopeAccordion, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2861
2838
  Trigger,
@@ -2870,16 +2847,16 @@ var AccordionTrigger = React__default.forwardRef(
2870
2847
  ) });
2871
2848
  }
2872
2849
  );
2873
- AccordionTrigger.displayName = TRIGGER_NAME$1;
2874
- var CONTENT_NAME$1 = "AccordionContent";
2850
+ AccordionTrigger.displayName = TRIGGER_NAME;
2851
+ var CONTENT_NAME = "AccordionContent";
2875
2852
  var AccordionContent = React__default.forwardRef(
2876
2853
  (props, forwardedRef) => {
2877
2854
  const { __scopeAccordion, ...contentProps } = props;
2878
2855
  const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
2879
- const itemContext = useAccordionItemContext(CONTENT_NAME$1, __scopeAccordion);
2856
+ const itemContext = useAccordionItemContext(CONTENT_NAME, __scopeAccordion);
2880
2857
  const collapsibleScope = useCollapsibleScope(__scopeAccordion);
2881
2858
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
2882
- Content$1,
2859
+ Content,
2883
2860
  {
2884
2861
  role: "region",
2885
2862
  "aria-labelledby": itemContext.triggerId,
@@ -2896,8 +2873,8 @@ var AccordionContent = React__default.forwardRef(
2896
2873
  );
2897
2874
  }
2898
2875
  );
2899
- AccordionContent.displayName = CONTENT_NAME$1;
2900
- function getState$2(open2) {
2876
+ AccordionContent.displayName = CONTENT_NAME;
2877
+ function getState$1(open2) {
2901
2878
  return open2 ? "open" : "closed";
2902
2879
  }
2903
2880
  var Root2 = Accordion;
@@ -3063,7 +3040,7 @@ var Switch$1 = React.forwardRef(
3063
3040
  role: "switch",
3064
3041
  "aria-checked": checked,
3065
3042
  "aria-required": required,
3066
- "data-state": getState$1(checked),
3043
+ "data-state": getState(checked),
3067
3044
  "data-disabled": disabled ? "" : void 0,
3068
3045
  disabled,
3069
3046
  value,
@@ -3104,7 +3081,7 @@ var SwitchThumb = React.forwardRef(
3104
3081
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
3105
3082
  Primitive.span,
3106
3083
  {
3107
- "data-state": getState$1(context.checked),
3084
+ "data-state": getState(context.checked),
3108
3085
  "data-disabled": context.disabled ? "" : void 0,
3109
3086
  ...thumbProps,
3110
3087
  ref: forwardedRef
@@ -3163,10 +3140,10 @@ var SwitchBubbleInput = React.forwardRef(
3163
3140
  }
3164
3141
  );
3165
3142
  SwitchBubbleInput.displayName = BUBBLE_INPUT_NAME;
3166
- function getState$1(checked) {
3143
+ function getState(checked) {
3167
3144
  return checked ? "checked" : "unchecked";
3168
3145
  }
3169
- var Root$1 = Switch$1;
3146
+ var Root = Switch$1;
3170
3147
  var Thumb = SwitchThumb;
3171
3148
  const root = "_root_dibqz_1";
3172
3149
  const thumb = "_thumb_dibqz_38";
@@ -3178,7 +3155,7 @@ const classes = {
3178
3155
  const Switch = ({ label: label2, id, ...rest }) => {
3179
3156
  return /* @__PURE__ */ u("div", { className: classes.root, children: [
3180
3157
  label2 && /* @__PURE__ */ u(Text, { className: classes.label, as: "label", htmlFor: id, children: label2 }),
3181
- /* @__PURE__ */ u(Root$1, { className: classes.switch, ...rest, children: /* @__PURE__ */ u(Thumb, { className: classes.thumb }) })
3158
+ /* @__PURE__ */ u(Root, { className: classes.switch, ...rest, children: /* @__PURE__ */ u(Thumb, { className: classes.thumb }) })
3182
3159
  ] });
3183
3160
  };
3184
3161
  const selectionSchema = /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ boolean());
@@ -3363,1518 +3340,6 @@ const BannerItem = ({
3363
3340
  ) })
3364
3341
  ] });
3365
3342
  };
3366
- function useCallbackRef$1(callback) {
3367
- const callbackRef = React.useRef(callback);
3368
- React.useEffect(() => {
3369
- callbackRef.current = callback;
3370
- });
3371
- return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
3372
- }
3373
- function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
3374
- const onEscapeKeyDown = useCallbackRef$1(onEscapeKeyDownProp);
3375
- React.useEffect(() => {
3376
- const handleKeyDown = (event) => {
3377
- if (event.key === "Escape") {
3378
- onEscapeKeyDown(event);
3379
- }
3380
- };
3381
- ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
3382
- return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
3383
- }, [onEscapeKeyDown, ownerDocument]);
3384
- }
3385
- var DISMISSABLE_LAYER_NAME = "DismissableLayer";
3386
- var CONTEXT_UPDATE = "dismissableLayer.update";
3387
- var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
3388
- var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
3389
- var originalBodyPointerEvents;
3390
- var DismissableLayerContext = React.createContext({
3391
- layers: /* @__PURE__ */ new Set(),
3392
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
3393
- branches: /* @__PURE__ */ new Set()
3394
- });
3395
- var DismissableLayer = React.forwardRef(
3396
- (props, forwardedRef) => {
3397
- const {
3398
- disableOutsidePointerEvents = false,
3399
- onEscapeKeyDown,
3400
- onPointerDownOutside,
3401
- onFocusOutside,
3402
- onInteractOutside,
3403
- onDismiss,
3404
- ...layerProps
3405
- } = props;
3406
- const context = React.useContext(DismissableLayerContext);
3407
- const [node, setNode] = React.useState(null);
3408
- const ownerDocument = node?.ownerDocument ?? globalThis?.document;
3409
- const [, force] = React.useState({});
3410
- const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
3411
- const layers = Array.from(context.layers);
3412
- const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
3413
- const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
3414
- const index = node ? layers.indexOf(node) : -1;
3415
- const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
3416
- const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
3417
- const pointerDownOutside = usePointerDownOutside((event) => {
3418
- const target = event.target;
3419
- const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
3420
- if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
3421
- onPointerDownOutside?.(event);
3422
- onInteractOutside?.(event);
3423
- if (!event.defaultPrevented) onDismiss?.();
3424
- }, ownerDocument);
3425
- const focusOutside = useFocusOutside((event) => {
3426
- const target = event.target;
3427
- const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
3428
- if (isFocusInBranch) return;
3429
- onFocusOutside?.(event);
3430
- onInteractOutside?.(event);
3431
- if (!event.defaultPrevented) onDismiss?.();
3432
- }, ownerDocument);
3433
- useEscapeKeydown((event) => {
3434
- const isHighestLayer = index === context.layers.size - 1;
3435
- if (!isHighestLayer) return;
3436
- onEscapeKeyDown?.(event);
3437
- if (!event.defaultPrevented && onDismiss) {
3438
- event.preventDefault();
3439
- onDismiss();
3440
- }
3441
- }, ownerDocument);
3442
- React.useEffect(() => {
3443
- if (!node) return;
3444
- if (disableOutsidePointerEvents) {
3445
- if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
3446
- originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
3447
- ownerDocument.body.style.pointerEvents = "none";
3448
- }
3449
- context.layersWithOutsidePointerEventsDisabled.add(node);
3450
- }
3451
- context.layers.add(node);
3452
- dispatchUpdate();
3453
- return () => {
3454
- if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
3455
- ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
3456
- }
3457
- };
3458
- }, [node, ownerDocument, disableOutsidePointerEvents, context]);
3459
- React.useEffect(() => {
3460
- return () => {
3461
- if (!node) return;
3462
- context.layers.delete(node);
3463
- context.layersWithOutsidePointerEventsDisabled.delete(node);
3464
- dispatchUpdate();
3465
- };
3466
- }, [node, context]);
3467
- React.useEffect(() => {
3468
- const handleUpdate = () => force({});
3469
- document.addEventListener(CONTEXT_UPDATE, handleUpdate);
3470
- return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
3471
- }, []);
3472
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
3473
- Primitive.div,
3474
- {
3475
- ...layerProps,
3476
- ref: composedRefs,
3477
- style: {
3478
- pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
3479
- ...props.style
3480
- },
3481
- onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
3482
- onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
3483
- onPointerDownCapture: composeEventHandlers(
3484
- props.onPointerDownCapture,
3485
- pointerDownOutside.onPointerDownCapture
3486
- )
3487
- }
3488
- );
3489
- }
3490
- );
3491
- DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
3492
- var BRANCH_NAME = "DismissableLayerBranch";
3493
- var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
3494
- const context = React.useContext(DismissableLayerContext);
3495
- const ref = React.useRef(null);
3496
- const composedRefs = useComposedRefs(forwardedRef, ref);
3497
- React.useEffect(() => {
3498
- const node = ref.current;
3499
- if (node) {
3500
- context.branches.add(node);
3501
- return () => {
3502
- context.branches.delete(node);
3503
- };
3504
- }
3505
- }, [context.branches]);
3506
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.div, { ...props, ref: composedRefs });
3507
- });
3508
- DismissableLayerBranch.displayName = BRANCH_NAME;
3509
- function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
3510
- const handlePointerDownOutside = useCallbackRef$1(onPointerDownOutside);
3511
- const isPointerInsideReactTreeRef = React.useRef(false);
3512
- const handleClickRef = React.useRef(() => {
3513
- });
3514
- React.useEffect(() => {
3515
- const handlePointerDown = (event) => {
3516
- if (event.target && !isPointerInsideReactTreeRef.current) {
3517
- let handleAndDispatchPointerDownOutsideEvent2 = function() {
3518
- handleAndDispatchCustomEvent(
3519
- POINTER_DOWN_OUTSIDE,
3520
- handlePointerDownOutside,
3521
- eventDetail,
3522
- { discrete: true }
3523
- );
3524
- };
3525
- const eventDetail = { originalEvent: event };
3526
- if (event.pointerType === "touch") {
3527
- ownerDocument.removeEventListener("click", handleClickRef.current);
3528
- handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
3529
- ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
3530
- } else {
3531
- handleAndDispatchPointerDownOutsideEvent2();
3532
- }
3533
- } else {
3534
- ownerDocument.removeEventListener("click", handleClickRef.current);
3535
- }
3536
- isPointerInsideReactTreeRef.current = false;
3537
- };
3538
- const timerId = window.setTimeout(() => {
3539
- ownerDocument.addEventListener("pointerdown", handlePointerDown);
3540
- }, 0);
3541
- return () => {
3542
- window.clearTimeout(timerId);
3543
- ownerDocument.removeEventListener("pointerdown", handlePointerDown);
3544
- ownerDocument.removeEventListener("click", handleClickRef.current);
3545
- };
3546
- }, [ownerDocument, handlePointerDownOutside]);
3547
- return {
3548
- // ensures we check React component tree (not just DOM tree)
3549
- onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
3550
- };
3551
- }
3552
- function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
3553
- const handleFocusOutside = useCallbackRef$1(onFocusOutside);
3554
- const isFocusInsideReactTreeRef = React.useRef(false);
3555
- React.useEffect(() => {
3556
- const handleFocus = (event) => {
3557
- if (event.target && !isFocusInsideReactTreeRef.current) {
3558
- const eventDetail = { originalEvent: event };
3559
- handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
3560
- discrete: false
3561
- });
3562
- }
3563
- };
3564
- ownerDocument.addEventListener("focusin", handleFocus);
3565
- return () => ownerDocument.removeEventListener("focusin", handleFocus);
3566
- }, [ownerDocument, handleFocusOutside]);
3567
- return {
3568
- onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
3569
- onBlurCapture: () => isFocusInsideReactTreeRef.current = false
3570
- };
3571
- }
3572
- function dispatchUpdate() {
3573
- const event = new CustomEvent(CONTEXT_UPDATE);
3574
- document.dispatchEvent(event);
3575
- }
3576
- function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
3577
- const target = detail.originalEvent.target;
3578
- const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
3579
- if (handler) target.addEventListener(name, handler, { once: true });
3580
- if (discrete) {
3581
- dispatchDiscreteCustomEvent(target, event);
3582
- } else {
3583
- target.dispatchEvent(event);
3584
- }
3585
- }
3586
- var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
3587
- var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
3588
- var EVENT_OPTIONS = { bubbles: false, cancelable: true };
3589
- var FOCUS_SCOPE_NAME = "FocusScope";
3590
- var FocusScope = React.forwardRef((props, forwardedRef) => {
3591
- const {
3592
- loop = false,
3593
- trapped = false,
3594
- onMountAutoFocus: onMountAutoFocusProp,
3595
- onUnmountAutoFocus: onUnmountAutoFocusProp,
3596
- ...scopeProps
3597
- } = props;
3598
- const [container, setContainer] = React.useState(null);
3599
- const onMountAutoFocus = useCallbackRef$1(onMountAutoFocusProp);
3600
- const onUnmountAutoFocus = useCallbackRef$1(onUnmountAutoFocusProp);
3601
- const lastFocusedElementRef = React.useRef(null);
3602
- const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
3603
- const focusScope = React.useRef({
3604
- paused: false,
3605
- pause() {
3606
- this.paused = true;
3607
- },
3608
- resume() {
3609
- this.paused = false;
3610
- }
3611
- }).current;
3612
- React.useEffect(() => {
3613
- if (trapped) {
3614
- let handleFocusIn2 = function(event) {
3615
- if (focusScope.paused || !container) return;
3616
- const target = event.target;
3617
- if (container.contains(target)) {
3618
- lastFocusedElementRef.current = target;
3619
- } else {
3620
- focus(lastFocusedElementRef.current, { select: true });
3621
- }
3622
- }, handleFocusOut2 = function(event) {
3623
- if (focusScope.paused || !container) return;
3624
- const relatedTarget = event.relatedTarget;
3625
- if (relatedTarget === null) return;
3626
- if (!container.contains(relatedTarget)) {
3627
- focus(lastFocusedElementRef.current, { select: true });
3628
- }
3629
- }, handleMutations2 = function(mutations) {
3630
- const focusedElement = document.activeElement;
3631
- if (focusedElement !== document.body) return;
3632
- for (const mutation of mutations) {
3633
- if (mutation.removedNodes.length > 0) focus(container);
3634
- }
3635
- };
3636
- document.addEventListener("focusin", handleFocusIn2);
3637
- document.addEventListener("focusout", handleFocusOut2);
3638
- const mutationObserver = new MutationObserver(handleMutations2);
3639
- if (container) mutationObserver.observe(container, { childList: true, subtree: true });
3640
- return () => {
3641
- document.removeEventListener("focusin", handleFocusIn2);
3642
- document.removeEventListener("focusout", handleFocusOut2);
3643
- mutationObserver.disconnect();
3644
- };
3645
- }
3646
- }, [trapped, container, focusScope.paused]);
3647
- React.useEffect(() => {
3648
- if (container) {
3649
- focusScopesStack.add(focusScope);
3650
- const previouslyFocusedElement = document.activeElement;
3651
- const hasFocusedCandidate = container.contains(previouslyFocusedElement);
3652
- if (!hasFocusedCandidate) {
3653
- const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
3654
- container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
3655
- container.dispatchEvent(mountEvent);
3656
- if (!mountEvent.defaultPrevented) {
3657
- focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
3658
- if (document.activeElement === previouslyFocusedElement) {
3659
- focus(container);
3660
- }
3661
- }
3662
- }
3663
- return () => {
3664
- container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
3665
- setTimeout(() => {
3666
- const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
3667
- container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
3668
- container.dispatchEvent(unmountEvent);
3669
- if (!unmountEvent.defaultPrevented) {
3670
- focus(previouslyFocusedElement ?? document.body, { select: true });
3671
- }
3672
- container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
3673
- focusScopesStack.remove(focusScope);
3674
- }, 0);
3675
- };
3676
- }
3677
- }, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
3678
- const handleKeyDown = React.useCallback(
3679
- (event) => {
3680
- if (!loop && !trapped) return;
3681
- if (focusScope.paused) return;
3682
- const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
3683
- const focusedElement = document.activeElement;
3684
- if (isTabKey && focusedElement) {
3685
- const container2 = event.currentTarget;
3686
- const [first, last] = getTabbableEdges(container2);
3687
- const hasTabbableElementsInside = first && last;
3688
- if (!hasTabbableElementsInside) {
3689
- if (focusedElement === container2) event.preventDefault();
3690
- } else {
3691
- if (!event.shiftKey && focusedElement === last) {
3692
- event.preventDefault();
3693
- if (loop) focus(first, { select: true });
3694
- } else if (event.shiftKey && focusedElement === first) {
3695
- event.preventDefault();
3696
- if (loop) focus(last, { select: true });
3697
- }
3698
- }
3699
- }
3700
- },
3701
- [loop, trapped, focusScope.paused]
3702
- );
3703
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
3704
- });
3705
- FocusScope.displayName = FOCUS_SCOPE_NAME;
3706
- function focusFirst(candidates, { select = false } = {}) {
3707
- const previouslyFocusedElement = document.activeElement;
3708
- for (const candidate of candidates) {
3709
- focus(candidate, { select });
3710
- if (document.activeElement !== previouslyFocusedElement) return;
3711
- }
3712
- }
3713
- function getTabbableEdges(container) {
3714
- const candidates = getTabbableCandidates(container);
3715
- const first = findVisible(candidates, container);
3716
- const last = findVisible(candidates.reverse(), container);
3717
- return [first, last];
3718
- }
3719
- function getTabbableCandidates(container) {
3720
- const nodes = [];
3721
- const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
3722
- acceptNode: (node) => {
3723
- const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
3724
- if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
3725
- return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
3726
- }
3727
- });
3728
- while (walker.nextNode()) nodes.push(walker.currentNode);
3729
- return nodes;
3730
- }
3731
- function findVisible(elements, container) {
3732
- for (const element of elements) {
3733
- if (!isHidden(element, { upTo: container })) return element;
3734
- }
3735
- }
3736
- function isHidden(node, { upTo }) {
3737
- if (getComputedStyle(node).visibility === "hidden") return true;
3738
- while (node) {
3739
- if (upTo !== void 0 && node === upTo) return false;
3740
- if (getComputedStyle(node).display === "none") return true;
3741
- node = node.parentElement;
3742
- }
3743
- return false;
3744
- }
3745
- function isSelectableInput(element) {
3746
- return element instanceof HTMLInputElement && "select" in element;
3747
- }
3748
- function focus(element, { select = false } = {}) {
3749
- if (element && element.focus) {
3750
- const previouslyFocusedElement = document.activeElement;
3751
- element.focus({ preventScroll: true });
3752
- if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
3753
- element.select();
3754
- }
3755
- }
3756
- var focusScopesStack = createFocusScopesStack();
3757
- function createFocusScopesStack() {
3758
- let stack = [];
3759
- return {
3760
- add(focusScope) {
3761
- const activeFocusScope = stack[0];
3762
- if (focusScope !== activeFocusScope) {
3763
- activeFocusScope?.pause();
3764
- }
3765
- stack = arrayRemove(stack, focusScope);
3766
- stack.unshift(focusScope);
3767
- },
3768
- remove(focusScope) {
3769
- stack = arrayRemove(stack, focusScope);
3770
- stack[0]?.resume();
3771
- }
3772
- };
3773
- }
3774
- function arrayRemove(array, item) {
3775
- const updatedArray = [...array];
3776
- const index = updatedArray.indexOf(item);
3777
- if (index !== -1) {
3778
- updatedArray.splice(index, 1);
3779
- }
3780
- return updatedArray;
3781
- }
3782
- function removeLinks(items) {
3783
- return items.filter((item) => item.tagName !== "A");
3784
- }
3785
- var count = 0;
3786
- function useFocusGuards() {
3787
- React.useEffect(() => {
3788
- const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
3789
- document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
3790
- document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
3791
- count++;
3792
- return () => {
3793
- if (count === 1) {
3794
- document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
3795
- }
3796
- count--;
3797
- };
3798
- }, []);
3799
- }
3800
- function createFocusGuard() {
3801
- const element = document.createElement("span");
3802
- element.setAttribute("data-radix-focus-guard", "");
3803
- element.tabIndex = 0;
3804
- element.style.outline = "none";
3805
- element.style.opacity = "0";
3806
- element.style.position = "fixed";
3807
- element.style.pointerEvents = "none";
3808
- return element;
3809
- }
3810
- var __assign = function() {
3811
- __assign = Object.assign || function __assign2(t) {
3812
- for (var s, i = 1, n = arguments.length; i < n; i++) {
3813
- s = arguments[i];
3814
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3815
- }
3816
- return t;
3817
- };
3818
- return __assign.apply(this, arguments);
3819
- };
3820
- function __rest(s, e) {
3821
- var t = {};
3822
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3823
- t[p] = s[p];
3824
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
3825
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3826
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3827
- t[p[i]] = s[p[i]];
3828
- }
3829
- return t;
3830
- }
3831
- function __spreadArray(to, from, pack) {
3832
- if (pack || arguments.length === 2) for (var i = 0, l2 = from.length, ar; i < l2; i++) {
3833
- if (ar || !(i in from)) {
3834
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3835
- ar[i] = from[i];
3836
- }
3837
- }
3838
- return to.concat(ar || Array.prototype.slice.call(from));
3839
- }
3840
- var zeroRightClassName = "right-scroll-bar-position";
3841
- var fullWidthClassName = "width-before-scroll-bar";
3842
- var noScrollbarsClassName = "with-scroll-bars-hidden";
3843
- var removedBarSizeVariable = "--removed-body-scroll-bar-size";
3844
- function assignRef(ref, value) {
3845
- if (typeof ref === "function") {
3846
- ref(value);
3847
- } else if (ref) {
3848
- ref.current = value;
3849
- }
3850
- return ref;
3851
- }
3852
- function useCallbackRef(initialValue, callback) {
3853
- var ref = useState(function() {
3854
- return {
3855
- // value
3856
- value: initialValue,
3857
- // last callback
3858
- callback,
3859
- // "memoized" public interface
3860
- facade: {
3861
- get current() {
3862
- return ref.value;
3863
- },
3864
- set current(value) {
3865
- var last = ref.value;
3866
- if (last !== value) {
3867
- ref.value = value;
3868
- ref.callback(value, last);
3869
- }
3870
- }
3871
- }
3872
- };
3873
- })[0];
3874
- ref.callback = callback;
3875
- return ref.facade;
3876
- }
3877
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
3878
- var currentValues = /* @__PURE__ */ new WeakMap();
3879
- function useMergeRefs(refs, defaultValue) {
3880
- var callbackRef = useCallbackRef(null, function(newValue) {
3881
- return refs.forEach(function(ref) {
3882
- return assignRef(ref, newValue);
3883
- });
3884
- });
3885
- useIsomorphicLayoutEffect(function() {
3886
- var oldValue = currentValues.get(callbackRef);
3887
- if (oldValue) {
3888
- var prevRefs_1 = new Set(oldValue);
3889
- var nextRefs_1 = new Set(refs);
3890
- var current_1 = callbackRef.current;
3891
- prevRefs_1.forEach(function(ref) {
3892
- if (!nextRefs_1.has(ref)) {
3893
- assignRef(ref, null);
3894
- }
3895
- });
3896
- nextRefs_1.forEach(function(ref) {
3897
- if (!prevRefs_1.has(ref)) {
3898
- assignRef(ref, current_1);
3899
- }
3900
- });
3901
- }
3902
- currentValues.set(callbackRef, refs);
3903
- }, [refs]);
3904
- return callbackRef;
3905
- }
3906
- function ItoI(a) {
3907
- return a;
3908
- }
3909
- function innerCreateMedium(defaults, middleware) {
3910
- if (middleware === void 0) {
3911
- middleware = ItoI;
3912
- }
3913
- var buffer = [];
3914
- var assigned = false;
3915
- var medium = {
3916
- read: function() {
3917
- if (assigned) {
3918
- throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
3919
- }
3920
- if (buffer.length) {
3921
- return buffer[buffer.length - 1];
3922
- }
3923
- return defaults;
3924
- },
3925
- useMedium: function(data) {
3926
- var item = middleware(data, assigned);
3927
- buffer.push(item);
3928
- return function() {
3929
- buffer = buffer.filter(function(x) {
3930
- return x !== item;
3931
- });
3932
- };
3933
- },
3934
- assignSyncMedium: function(cb) {
3935
- assigned = true;
3936
- while (buffer.length) {
3937
- var cbs = buffer;
3938
- buffer = [];
3939
- cbs.forEach(cb);
3940
- }
3941
- buffer = {
3942
- push: function(x) {
3943
- return cb(x);
3944
- },
3945
- filter: function() {
3946
- return buffer;
3947
- }
3948
- };
3949
- },
3950
- assignMedium: function(cb) {
3951
- assigned = true;
3952
- var pendingQueue = [];
3953
- if (buffer.length) {
3954
- var cbs = buffer;
3955
- buffer = [];
3956
- cbs.forEach(cb);
3957
- pendingQueue = buffer;
3958
- }
3959
- var executeQueue = function() {
3960
- var cbs2 = pendingQueue;
3961
- pendingQueue = [];
3962
- cbs2.forEach(cb);
3963
- };
3964
- var cycle = function() {
3965
- return Promise.resolve().then(executeQueue);
3966
- };
3967
- cycle();
3968
- buffer = {
3969
- push: function(x) {
3970
- pendingQueue.push(x);
3971
- cycle();
3972
- },
3973
- filter: function(filter) {
3974
- pendingQueue = pendingQueue.filter(filter);
3975
- return buffer;
3976
- }
3977
- };
3978
- }
3979
- };
3980
- return medium;
3981
- }
3982
- function createSidecarMedium(options) {
3983
- if (options === void 0) {
3984
- options = {};
3985
- }
3986
- var medium = innerCreateMedium(null);
3987
- medium.options = __assign({ async: true, ssr: false }, options);
3988
- return medium;
3989
- }
3990
- var SideCar$1 = function(_a) {
3991
- var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
3992
- if (!sideCar) {
3993
- throw new Error("Sidecar: please provide `sideCar` property to import the right car");
3994
- }
3995
- var Target = sideCar.read();
3996
- if (!Target) {
3997
- throw new Error("Sidecar medium not found");
3998
- }
3999
- return React.createElement(Target, __assign({}, rest));
4000
- };
4001
- SideCar$1.isSideCarExport = true;
4002
- function exportSidecar(medium, exported) {
4003
- medium.useMedium(exported);
4004
- return SideCar$1;
4005
- }
4006
- var effectCar = createSidecarMedium();
4007
- var nothing = function() {
4008
- return;
4009
- };
4010
- var RemoveScroll = React.forwardRef(function(props, parentRef) {
4011
- var ref = React.useRef(null);
4012
- var _a = React.useState({
4013
- onScrollCapture: nothing,
4014
- onWheelCapture: nothing,
4015
- onTouchMoveCapture: nothing
4016
- }), callbacks = _a[0], setCallbacks = _a[1];
4017
- var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noRelative = props.noRelative, 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", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
4018
- var SideCar2 = sideCar;
4019
- var containerRef = useMergeRefs([ref, parentRef]);
4020
- var containerProps = __assign(__assign({}, rest), callbacks);
4021
- return React.createElement(
4022
- React.Fragment,
4023
- null,
4024
- enabled && React.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noRelative, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
4025
- forwardProps ? React.cloneElement(React.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
4026
- );
4027
- });
4028
- RemoveScroll.defaultProps = {
4029
- enabled: true,
4030
- removeScrollBar: true,
4031
- inert: false
4032
- };
4033
- RemoveScroll.classNames = {
4034
- fullWidth: fullWidthClassName,
4035
- zeroRight: zeroRightClassName
4036
- };
4037
- var getNonce = function() {
4038
- if (typeof __webpack_nonce__ !== "undefined") {
4039
- return __webpack_nonce__;
4040
- }
4041
- return void 0;
4042
- };
4043
- function makeStyleTag() {
4044
- if (!document)
4045
- return null;
4046
- var tag = document.createElement("style");
4047
- tag.type = "text/css";
4048
- var nonce = getNonce();
4049
- if (nonce) {
4050
- tag.setAttribute("nonce", nonce);
4051
- }
4052
- return tag;
4053
- }
4054
- function injectStyles(tag, css) {
4055
- if (tag.styleSheet) {
4056
- tag.styleSheet.cssText = css;
4057
- } else {
4058
- tag.appendChild(document.createTextNode(css));
4059
- }
4060
- }
4061
- function insertStyleTag(tag) {
4062
- var head = document.head || document.getElementsByTagName("head")[0];
4063
- head.appendChild(tag);
4064
- }
4065
- var stylesheetSingleton = function() {
4066
- var counter = 0;
4067
- var stylesheet = null;
4068
- return {
4069
- add: function(style) {
4070
- if (counter == 0) {
4071
- if (stylesheet = makeStyleTag()) {
4072
- injectStyles(stylesheet, style);
4073
- insertStyleTag(stylesheet);
4074
- }
4075
- }
4076
- counter++;
4077
- },
4078
- remove: function() {
4079
- counter--;
4080
- if (!counter && stylesheet) {
4081
- stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
4082
- stylesheet = null;
4083
- }
4084
- }
4085
- };
4086
- };
4087
- var styleHookSingleton = function() {
4088
- var sheet = stylesheetSingleton();
4089
- return function(styles, isDynamic) {
4090
- React.useEffect(function() {
4091
- sheet.add(styles);
4092
- return function() {
4093
- sheet.remove();
4094
- };
4095
- }, [styles && isDynamic]);
4096
- };
4097
- };
4098
- var styleSingleton = function() {
4099
- var useStyle = styleHookSingleton();
4100
- var Sheet = function(_a) {
4101
- var styles = _a.styles, dynamic = _a.dynamic;
4102
- useStyle(styles, dynamic);
4103
- return null;
4104
- };
4105
- return Sheet;
4106
- };
4107
- var zeroGap = {
4108
- left: 0,
4109
- top: 0,
4110
- right: 0,
4111
- gap: 0
4112
- };
4113
- var parse = function(x) {
4114
- return parseInt(x || "", 10) || 0;
4115
- };
4116
- var getOffset = function(gapMode) {
4117
- var cs = window.getComputedStyle(document.body);
4118
- var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"];
4119
- var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"];
4120
- var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"];
4121
- return [parse(left), parse(top), parse(right)];
4122
- };
4123
- var getGapWidth = function(gapMode) {
4124
- if (gapMode === void 0) {
4125
- gapMode = "margin";
4126
- }
4127
- if (typeof window === "undefined") {
4128
- return zeroGap;
4129
- }
4130
- var offsets = getOffset(gapMode);
4131
- var documentWidth = document.documentElement.clientWidth;
4132
- var windowWidth = window.innerWidth;
4133
- return {
4134
- left: offsets[0],
4135
- top: offsets[1],
4136
- right: offsets[2],
4137
- gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0])
4138
- };
4139
- };
4140
- var Style = styleSingleton();
4141
- var lockAttribute = "data-scroll-locked";
4142
- var getStyles = function(_a, allowRelative, gapMode, important) {
4143
- var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
4144
- if (gapMode === void 0) {
4145
- gapMode = "margin";
4146
- }
4147
- 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([
4148
- allowRelative && "position: relative ".concat(important, ";"),
4149
- 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 "),
4150
- gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
4151
- ].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");
4152
- };
4153
- var getCurrentUseCounter = function() {
4154
- var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10);
4155
- return isFinite(counter) ? counter : 0;
4156
- };
4157
- var useLockAttribute = function() {
4158
- React.useEffect(function() {
4159
- document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
4160
- return function() {
4161
- var newCounter = getCurrentUseCounter() - 1;
4162
- if (newCounter <= 0) {
4163
- document.body.removeAttribute(lockAttribute);
4164
- } else {
4165
- document.body.setAttribute(lockAttribute, newCounter.toString());
4166
- }
4167
- };
4168
- }, []);
4169
- };
4170
- var RemoveScrollBar = function(_a) {
4171
- var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
4172
- useLockAttribute();
4173
- var gap = React.useMemo(function() {
4174
- return getGapWidth(gapMode);
4175
- }, [gapMode]);
4176
- return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
4177
- };
4178
- var passiveSupported = false;
4179
- if (typeof window !== "undefined") {
4180
- try {
4181
- var options = Object.defineProperty({}, "passive", {
4182
- get: function() {
4183
- passiveSupported = true;
4184
- return true;
4185
- }
4186
- });
4187
- window.addEventListener("test", options, options);
4188
- window.removeEventListener("test", options, options);
4189
- } catch (err) {
4190
- passiveSupported = false;
4191
- }
4192
- }
4193
- var nonPassive = passiveSupported ? { passive: false } : false;
4194
- var alwaysContainsScroll = function(node) {
4195
- return node.tagName === "TEXTAREA";
4196
- };
4197
- var elementCanBeScrolled = function(node, overflow) {
4198
- if (!(node instanceof Element)) {
4199
- return false;
4200
- }
4201
- var styles = window.getComputedStyle(node);
4202
- return (
4203
- // not-not-scrollable
4204
- styles[overflow] !== "hidden" && // contains scroll inside self
4205
- !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible")
4206
- );
4207
- };
4208
- var elementCouldBeVScrolled = function(node) {
4209
- return elementCanBeScrolled(node, "overflowY");
4210
- };
4211
- var elementCouldBeHScrolled = function(node) {
4212
- return elementCanBeScrolled(node, "overflowX");
4213
- };
4214
- var locationCouldBeScrolled = function(axis, node) {
4215
- var ownerDocument = node.ownerDocument;
4216
- var current = node;
4217
- do {
4218
- if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
4219
- current = current.host;
4220
- }
4221
- var isScrollable = elementCouldBeScrolled(axis, current);
4222
- if (isScrollable) {
4223
- var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
4224
- if (scrollHeight > clientHeight) {
4225
- return true;
4226
- }
4227
- }
4228
- current = current.parentNode;
4229
- } while (current && current !== ownerDocument.body);
4230
- return false;
4231
- };
4232
- var getVScrollVariables = function(_a) {
4233
- var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
4234
- return [
4235
- scrollTop,
4236
- scrollHeight,
4237
- clientHeight
4238
- ];
4239
- };
4240
- var getHScrollVariables = function(_a) {
4241
- var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
4242
- return [
4243
- scrollLeft,
4244
- scrollWidth,
4245
- clientWidth
4246
- ];
4247
- };
4248
- var elementCouldBeScrolled = function(axis, node) {
4249
- return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
4250
- };
4251
- var getScrollVariables = function(axis, node) {
4252
- return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
4253
- };
4254
- var getDirectionFactor = function(axis, direction) {
4255
- return axis === "h" && direction === "rtl" ? -1 : 1;
4256
- };
4257
- var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
4258
- var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
4259
- var delta = directionFactor * sourceDelta;
4260
- var target = event.target;
4261
- var targetInLock = endTarget.contains(target);
4262
- var shouldCancelScroll = false;
4263
- var isDeltaPositive = delta > 0;
4264
- var availableScroll = 0;
4265
- var availableScrollTop = 0;
4266
- do {
4267
- if (!target) {
4268
- break;
4269
- }
4270
- var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
4271
- var elementScroll = scroll_1 - capacity - directionFactor * position;
4272
- if (position || elementScroll) {
4273
- if (elementCouldBeScrolled(axis, target)) {
4274
- availableScroll += elementScroll;
4275
- availableScrollTop += position;
4276
- }
4277
- }
4278
- var parent_1 = target.parentNode;
4279
- target = parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1;
4280
- } while (
4281
- // portaled content
4282
- !targetInLock && target !== document.body || // self content
4283
- targetInLock && (endTarget.contains(target) || endTarget === target)
4284
- );
4285
- if (isDeltaPositive && (Math.abs(availableScroll) < 1 || false)) {
4286
- shouldCancelScroll = true;
4287
- } else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || false)) {
4288
- shouldCancelScroll = true;
4289
- }
4290
- return shouldCancelScroll;
4291
- };
4292
- var getTouchXY = function(event) {
4293
- return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
4294
- };
4295
- var getDeltaXY = function(event) {
4296
- return [event.deltaX, event.deltaY];
4297
- };
4298
- var extractRef = function(ref) {
4299
- return ref && "current" in ref ? ref.current : ref;
4300
- };
4301
- var deltaCompare = function(x, y) {
4302
- return x[0] === y[0] && x[1] === y[1];
4303
- };
4304
- var generateStyle = function(id) {
4305
- return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
4306
- };
4307
- var idCounter = 0;
4308
- var lockStack = [];
4309
- function RemoveScrollSideCar(props) {
4310
- var shouldPreventQueue = React.useRef([]);
4311
- var touchStartRef = React.useRef([0, 0]);
4312
- var activeAxis = React.useRef();
4313
- var id = React.useState(idCounter++)[0];
4314
- var Style2 = React.useState(styleSingleton)[0];
4315
- var lastProps = React.useRef(props);
4316
- React.useEffect(function() {
4317
- lastProps.current = props;
4318
- }, [props]);
4319
- React.useEffect(function() {
4320
- if (props.inert) {
4321
- document.body.classList.add("block-interactivity-".concat(id));
4322
- var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
4323
- allow_1.forEach(function(el) {
4324
- return el.classList.add("allow-interactivity-".concat(id));
4325
- });
4326
- return function() {
4327
- document.body.classList.remove("block-interactivity-".concat(id));
4328
- allow_1.forEach(function(el) {
4329
- return el.classList.remove("allow-interactivity-".concat(id));
4330
- });
4331
- };
4332
- }
4333
- return;
4334
- }, [props.inert, props.lockRef.current, props.shards]);
4335
- var shouldCancelEvent = React.useCallback(function(event, parent) {
4336
- if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
4337
- return !lastProps.current.allowPinchZoom;
4338
- }
4339
- var touch = getTouchXY(event);
4340
- var touchStart = touchStartRef.current;
4341
- var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
4342
- var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
4343
- var currentAxis;
4344
- var target = event.target;
4345
- var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
4346
- if ("touches" in event && moveDirection === "h" && target.type === "range") {
4347
- return false;
4348
- }
4349
- var selection = window.getSelection();
4350
- var anchorNode = selection && selection.anchorNode;
4351
- var isTouchingSelection = anchorNode ? anchorNode === target || anchorNode.contains(target) : false;
4352
- if (isTouchingSelection) {
4353
- return false;
4354
- }
4355
- var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
4356
- if (!canBeScrolledInMainDirection) {
4357
- return true;
4358
- }
4359
- if (canBeScrolledInMainDirection) {
4360
- currentAxis = moveDirection;
4361
- } else {
4362
- currentAxis = moveDirection === "v" ? "h" : "v";
4363
- canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
4364
- }
4365
- if (!canBeScrolledInMainDirection) {
4366
- return false;
4367
- }
4368
- if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
4369
- activeAxis.current = currentAxis;
4370
- }
4371
- if (!currentAxis) {
4372
- return true;
4373
- }
4374
- var cancelingAxis = activeAxis.current || currentAxis;
4375
- return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY);
4376
- }, []);
4377
- var shouldPrevent = React.useCallback(function(_event) {
4378
- var event = _event;
4379
- if (!lockStack.length || lockStack[lockStack.length - 1] !== Style2) {
4380
- return;
4381
- }
4382
- var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
4383
- var sourceEvent = shouldPreventQueue.current.filter(function(e) {
4384
- return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
4385
- })[0];
4386
- if (sourceEvent && sourceEvent.should) {
4387
- if (event.cancelable) {
4388
- event.preventDefault();
4389
- }
4390
- return;
4391
- }
4392
- if (!sourceEvent) {
4393
- var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
4394
- return node.contains(event.target);
4395
- });
4396
- var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
4397
- if (shouldStop) {
4398
- if (event.cancelable) {
4399
- event.preventDefault();
4400
- }
4401
- }
4402
- }
4403
- }, []);
4404
- var shouldCancel = React.useCallback(function(name, delta, target, should) {
4405
- var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
4406
- shouldPreventQueue.current.push(event);
4407
- setTimeout(function() {
4408
- shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
4409
- return e !== event;
4410
- });
4411
- }, 1);
4412
- }, []);
4413
- var scrollTouchStart = React.useCallback(function(event) {
4414
- touchStartRef.current = getTouchXY(event);
4415
- activeAxis.current = void 0;
4416
- }, []);
4417
- var scrollWheel = React.useCallback(function(event) {
4418
- shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
4419
- }, []);
4420
- var scrollTouchMove = React.useCallback(function(event) {
4421
- shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
4422
- }, []);
4423
- React.useEffect(function() {
4424
- lockStack.push(Style2);
4425
- props.setCallbacks({
4426
- onScrollCapture: scrollWheel,
4427
- onWheelCapture: scrollWheel,
4428
- onTouchMoveCapture: scrollTouchMove
4429
- });
4430
- document.addEventListener("wheel", shouldPrevent, nonPassive);
4431
- document.addEventListener("touchmove", shouldPrevent, nonPassive);
4432
- document.addEventListener("touchstart", scrollTouchStart, nonPassive);
4433
- return function() {
4434
- lockStack = lockStack.filter(function(inst) {
4435
- return inst !== Style2;
4436
- });
4437
- document.removeEventListener("wheel", shouldPrevent, nonPassive);
4438
- document.removeEventListener("touchmove", shouldPrevent, nonPassive);
4439
- document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
4440
- };
4441
- }, []);
4442
- var removeScrollBar = props.removeScrollBar, inert = props.inert;
4443
- return React.createElement(
4444
- React.Fragment,
4445
- null,
4446
- inert ? React.createElement(Style2, { styles: generateStyle(id) }) : null,
4447
- removeScrollBar ? React.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null
4448
- );
4449
- }
4450
- function getOutermostShadowParent(node) {
4451
- var shadowParent = null;
4452
- while (node !== null) {
4453
- if (node instanceof ShadowRoot) {
4454
- shadowParent = node.host;
4455
- node = node.host;
4456
- }
4457
- node = node.parentNode;
4458
- }
4459
- return shadowParent;
4460
- }
4461
- const SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
4462
- var ReactRemoveScroll = React.forwardRef(function(props, ref) {
4463
- return React.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: SideCar }));
4464
- });
4465
- ReactRemoveScroll.classNames = RemoveScroll.classNames;
4466
- var getDefaultParent = function(originalTarget) {
4467
- if (typeof document === "undefined") {
4468
- return null;
4469
- }
4470
- var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
4471
- return sampleTarget.ownerDocument.body;
4472
- };
4473
- var counterMap = /* @__PURE__ */ new WeakMap();
4474
- var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
4475
- var markerMap = {};
4476
- var lockCount = 0;
4477
- var unwrapHost = function(node) {
4478
- return node && (node.host || unwrapHost(node.parentNode));
4479
- };
4480
- var correctTargets = function(parent, targets) {
4481
- return targets.map(function(target) {
4482
- if (parent.contains(target)) {
4483
- return target;
4484
- }
4485
- var correctedTarget = unwrapHost(target);
4486
- if (correctedTarget && parent.contains(correctedTarget)) {
4487
- return correctedTarget;
4488
- }
4489
- console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing");
4490
- return null;
4491
- }).filter(function(x) {
4492
- return Boolean(x);
4493
- });
4494
- };
4495
- var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) {
4496
- var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
4497
- if (!markerMap[markerName]) {
4498
- markerMap[markerName] = /* @__PURE__ */ new WeakMap();
4499
- }
4500
- var markerCounter = markerMap[markerName];
4501
- var hiddenNodes = [];
4502
- var elementsToKeep = /* @__PURE__ */ new Set();
4503
- var elementsToStop = new Set(targets);
4504
- var keep = function(el) {
4505
- if (!el || elementsToKeep.has(el)) {
4506
- return;
4507
- }
4508
- elementsToKeep.add(el);
4509
- keep(el.parentNode);
4510
- };
4511
- targets.forEach(keep);
4512
- var deep = function(parent) {
4513
- if (!parent || elementsToStop.has(parent)) {
4514
- return;
4515
- }
4516
- Array.prototype.forEach.call(parent.children, function(node) {
4517
- if (elementsToKeep.has(node)) {
4518
- deep(node);
4519
- } else {
4520
- try {
4521
- var attr = node.getAttribute(controlAttribute);
4522
- var alreadyHidden = attr !== null && attr !== "false";
4523
- var counterValue = (counterMap.get(node) || 0) + 1;
4524
- var markerValue = (markerCounter.get(node) || 0) + 1;
4525
- counterMap.set(node, counterValue);
4526
- markerCounter.set(node, markerValue);
4527
- hiddenNodes.push(node);
4528
- if (counterValue === 1 && alreadyHidden) {
4529
- uncontrolledNodes.set(node, true);
4530
- }
4531
- if (markerValue === 1) {
4532
- node.setAttribute(markerName, "true");
4533
- }
4534
- if (!alreadyHidden) {
4535
- node.setAttribute(controlAttribute, "true");
4536
- }
4537
- } catch (e) {
4538
- console.error("aria-hidden: cannot operate on ", node, e);
4539
- }
4540
- }
4541
- });
4542
- };
4543
- deep(parentNode);
4544
- elementsToKeep.clear();
4545
- lockCount++;
4546
- return function() {
4547
- hiddenNodes.forEach(function(node) {
4548
- var counterValue = counterMap.get(node) - 1;
4549
- var markerValue = markerCounter.get(node) - 1;
4550
- counterMap.set(node, counterValue);
4551
- markerCounter.set(node, markerValue);
4552
- if (!counterValue) {
4553
- if (!uncontrolledNodes.has(node)) {
4554
- node.removeAttribute(controlAttribute);
4555
- }
4556
- uncontrolledNodes.delete(node);
4557
- }
4558
- if (!markerValue) {
4559
- node.removeAttribute(markerName);
4560
- }
4561
- });
4562
- lockCount--;
4563
- if (!lockCount) {
4564
- counterMap = /* @__PURE__ */ new WeakMap();
4565
- counterMap = /* @__PURE__ */ new WeakMap();
4566
- uncontrolledNodes = /* @__PURE__ */ new WeakMap();
4567
- markerMap = {};
4568
- }
4569
- };
4570
- };
4571
- var hideOthers = function(originalTarget, parentNode, markerName) {
4572
- if (markerName === void 0) {
4573
- markerName = "data-aria-hidden";
4574
- }
4575
- var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
4576
- var activeParentNode = getDefaultParent(originalTarget);
4577
- if (!activeParentNode) {
4578
- return function() {
4579
- return null;
4580
- };
4581
- }
4582
- targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live], script")));
4583
- return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
4584
- };
4585
- var DIALOG_NAME = "Dialog";
4586
- var [createDialogContext] = createContextScope(DIALOG_NAME);
4587
- var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
4588
- var Dialog = (props) => {
4589
- const {
4590
- __scopeDialog,
4591
- children,
4592
- open: openProp,
4593
- defaultOpen,
4594
- onOpenChange,
4595
- modal = true
4596
- } = props;
4597
- const triggerRef = React.useRef(null);
4598
- const contentRef = React.useRef(null);
4599
- const [open2, setOpen] = useControllableState({
4600
- prop: openProp,
4601
- defaultProp: defaultOpen ?? false,
4602
- onChange: onOpenChange,
4603
- caller: DIALOG_NAME
4604
- });
4605
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
4606
- DialogProvider,
4607
- {
4608
- scope: __scopeDialog,
4609
- triggerRef,
4610
- contentRef,
4611
- contentId: useId(),
4612
- titleId: useId(),
4613
- descriptionId: useId(),
4614
- open: open2,
4615
- onOpenChange: setOpen,
4616
- onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
4617
- modal,
4618
- children
4619
- }
4620
- );
4621
- };
4622
- Dialog.displayName = DIALOG_NAME;
4623
- var TRIGGER_NAME = "DialogTrigger";
4624
- var DialogTrigger = React.forwardRef(
4625
- (props, forwardedRef) => {
4626
- const { __scopeDialog, ...triggerProps } = props;
4627
- const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
4628
- const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
4629
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
4630
- Primitive.button,
4631
- {
4632
- type: "button",
4633
- "aria-haspopup": "dialog",
4634
- "aria-expanded": context.open,
4635
- "aria-controls": context.contentId,
4636
- "data-state": getState(context.open),
4637
- ...triggerProps,
4638
- ref: composedTriggerRef,
4639
- onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
4640
- }
4641
- );
4642
- }
4643
- );
4644
- DialogTrigger.displayName = TRIGGER_NAME;
4645
- var PORTAL_NAME = "DialogPortal";
4646
- var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
4647
- forceMount: void 0
4648
- });
4649
- var OVERLAY_NAME = "DialogOverlay";
4650
- var DialogOverlay = React.forwardRef(
4651
- (props, forwardedRef) => {
4652
- const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
4653
- const { forceMount = portalContext.forceMount, ...overlayProps } = props;
4654
- const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
4655
- return context.modal ? /* @__PURE__ */ jsxRuntimeExports.jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
4656
- }
4657
- );
4658
- DialogOverlay.displayName = OVERLAY_NAME;
4659
- var Slot = /* @__PURE__ */ createSlot("DialogOverlay.RemoveScroll");
4660
- var DialogOverlayImpl = React.forwardRef(
4661
- (props, forwardedRef) => {
4662
- const { __scopeDialog, ...overlayProps } = props;
4663
- const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
4664
- return (
4665
- // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
4666
- // ie. when `Overlay` and `Content` are siblings
4667
- /* @__PURE__ */ jsxRuntimeExports.jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4668
- Primitive.div,
4669
- {
4670
- "data-state": getState(context.open),
4671
- ...overlayProps,
4672
- ref: forwardedRef,
4673
- style: { pointerEvents: "auto", ...overlayProps.style }
4674
- }
4675
- ) })
4676
- );
4677
- }
4678
- );
4679
- var CONTENT_NAME = "DialogContent";
4680
- var DialogContent = React.forwardRef(
4681
- (props, forwardedRef) => {
4682
- const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
4683
- const { forceMount = portalContext.forceMount, ...contentProps } = props;
4684
- const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
4685
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsxRuntimeExports.jsx(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsxRuntimeExports.jsx(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
4686
- }
4687
- );
4688
- DialogContent.displayName = CONTENT_NAME;
4689
- var DialogContentModal = React.forwardRef(
4690
- (props, forwardedRef) => {
4691
- const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
4692
- const contentRef = React.useRef(null);
4693
- const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
4694
- React.useEffect(() => {
4695
- const content = contentRef.current;
4696
- if (content) return hideOthers(content);
4697
- }, []);
4698
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
4699
- DialogContentImpl,
4700
- {
4701
- ...props,
4702
- ref: composedRefs,
4703
- trapFocus: context.open,
4704
- disableOutsidePointerEvents: true,
4705
- onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
4706
- event.preventDefault();
4707
- context.triggerRef.current?.focus();
4708
- }),
4709
- onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
4710
- const originalEvent = event.detail.originalEvent;
4711
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
4712
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
4713
- if (isRightClick) event.preventDefault();
4714
- }),
4715
- onFocusOutside: composeEventHandlers(
4716
- props.onFocusOutside,
4717
- (event) => event.preventDefault()
4718
- )
4719
- }
4720
- );
4721
- }
4722
- );
4723
- var DialogContentNonModal = React.forwardRef(
4724
- (props, forwardedRef) => {
4725
- const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
4726
- const hasInteractedOutsideRef = React.useRef(false);
4727
- const hasPointerDownOutsideRef = React.useRef(false);
4728
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
4729
- DialogContentImpl,
4730
- {
4731
- ...props,
4732
- ref: forwardedRef,
4733
- trapFocus: false,
4734
- disableOutsidePointerEvents: false,
4735
- onCloseAutoFocus: (event) => {
4736
- props.onCloseAutoFocus?.(event);
4737
- if (!event.defaultPrevented) {
4738
- if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
4739
- event.preventDefault();
4740
- }
4741
- hasInteractedOutsideRef.current = false;
4742
- hasPointerDownOutsideRef.current = false;
4743
- },
4744
- onInteractOutside: (event) => {
4745
- props.onInteractOutside?.(event);
4746
- if (!event.defaultPrevented) {
4747
- hasInteractedOutsideRef.current = true;
4748
- if (event.detail.originalEvent.type === "pointerdown") {
4749
- hasPointerDownOutsideRef.current = true;
4750
- }
4751
- }
4752
- const target = event.target;
4753
- const targetIsTrigger = context.triggerRef.current?.contains(target);
4754
- if (targetIsTrigger) event.preventDefault();
4755
- if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
4756
- event.preventDefault();
4757
- }
4758
- }
4759
- }
4760
- );
4761
- }
4762
- );
4763
- var DialogContentImpl = React.forwardRef(
4764
- (props, forwardedRef) => {
4765
- const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
4766
- const context = useDialogContext(CONTENT_NAME, __scopeDialog);
4767
- const contentRef = React.useRef(null);
4768
- const composedRefs = useComposedRefs(forwardedRef, contentRef);
4769
- useFocusGuards();
4770
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4771
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4772
- FocusScope,
4773
- {
4774
- asChild: true,
4775
- loop: true,
4776
- trapped: trapFocus,
4777
- onMountAutoFocus: onOpenAutoFocus,
4778
- onUnmountAutoFocus: onCloseAutoFocus,
4779
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4780
- DismissableLayer,
4781
- {
4782
- role: "dialog",
4783
- id: context.contentId,
4784
- "aria-describedby": context.descriptionId,
4785
- "aria-labelledby": context.titleId,
4786
- "data-state": getState(context.open),
4787
- ...contentProps,
4788
- ref: composedRefs,
4789
- onDismiss: () => context.onOpenChange(false)
4790
- }
4791
- )
4792
- }
4793
- ),
4794
- /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4795
- /* @__PURE__ */ jsxRuntimeExports.jsx(TitleWarning, { titleId: context.titleId }),
4796
- /* @__PURE__ */ jsxRuntimeExports.jsx(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
4797
- ] })
4798
- ] });
4799
- }
4800
- );
4801
- var TITLE_NAME = "DialogTitle";
4802
- var DialogTitle = React.forwardRef(
4803
- (props, forwardedRef) => {
4804
- const { __scopeDialog, ...titleProps } = props;
4805
- const context = useDialogContext(TITLE_NAME, __scopeDialog);
4806
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
4807
- }
4808
- );
4809
- DialogTitle.displayName = TITLE_NAME;
4810
- var DESCRIPTION_NAME = "DialogDescription";
4811
- var DialogDescription = React.forwardRef(
4812
- (props, forwardedRef) => {
4813
- const { __scopeDialog, ...descriptionProps } = props;
4814
- const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
4815
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
4816
- }
4817
- );
4818
- DialogDescription.displayName = DESCRIPTION_NAME;
4819
- var CLOSE_NAME = "DialogClose";
4820
- var DialogClose = React.forwardRef(
4821
- (props, forwardedRef) => {
4822
- const { __scopeDialog, ...closeProps } = props;
4823
- const context = useDialogContext(CLOSE_NAME, __scopeDialog);
4824
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
4825
- Primitive.button,
4826
- {
4827
- type: "button",
4828
- ...closeProps,
4829
- ref: forwardedRef,
4830
- onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
4831
- }
4832
- );
4833
- }
4834
- );
4835
- DialogClose.displayName = CLOSE_NAME;
4836
- function getState(open2) {
4837
- return open2 ? "open" : "closed";
4838
- }
4839
- var TITLE_WARNING_NAME = "DialogTitleWarning";
4840
- var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
4841
- contentName: CONTENT_NAME,
4842
- titleName: TITLE_NAME,
4843
- docsSlug: "dialog"
4844
- });
4845
- var TitleWarning = ({ titleId }) => {
4846
- const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
4847
- const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
4848
-
4849
- If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
4850
-
4851
- For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
4852
- React.useEffect(() => {
4853
- if (titleId) {
4854
- const hasTitle = document.getElementById(titleId);
4855
- if (!hasTitle) console.error(MESSAGE);
4856
- }
4857
- }, [MESSAGE, titleId]);
4858
- return null;
4859
- };
4860
- var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
4861
- var DescriptionWarning = ({ contentRef, descriptionId }) => {
4862
- const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
4863
- const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
4864
- React.useEffect(() => {
4865
- const describedById = contentRef.current?.getAttribute("aria-describedby");
4866
- if (descriptionId && describedById) {
4867
- const hasDescription = document.getElementById(descriptionId);
4868
- if (!hasDescription) console.warn(MESSAGE);
4869
- }
4870
- }, [MESSAGE, contentRef, descriptionId]);
4871
- return null;
4872
- };
4873
- var Root = Dialog;
4874
- var Content = DialogContent;
4875
- var Title = DialogTitle;
4876
- var Description = DialogDescription;
4877
- var Close = DialogClose;
4878
3343
  const BannerContent = ({
4879
3344
  noTarget: noTarget2 = true,
4880
3345
  heading: heading2 = "We use cookies.",
@@ -4890,12 +3355,16 @@ const BannerContent = ({
4890
3355
  const { onSave, onDeclineAll, selectionTaken } = useSelection();
4891
3356
  const [openItem, setOpenItem] = useState(void 0);
4892
3357
  const [settingsOpen, setSettingsOpen] = useState(defaultSettingsOpen);
4893
- return /* @__PURE__ */ u(Root, { open: !selectionTaken, children: /* @__PURE__ */ u(
4894
- Content,
3358
+ return /* @__PURE__ */ u(
3359
+ "div",
4895
3360
  {
4896
- className: cls(classes$2.root, noTarget2 ? classes$2.noTarget : ""),
3361
+ className: clx({
3362
+ [classes$2.root]: true,
3363
+ [classes$2.noTarget]: noTarget2,
3364
+ [classes$2.open]: !selectionTaken
3365
+ }),
4897
3366
  children: /* @__PURE__ */ u(
4898
- Root$2,
3367
+ Root$1,
4899
3368
  {
4900
3369
  open: settingsOpen,
4901
3370
  onOpenChange: setSettingsOpen,
@@ -4903,8 +3372,8 @@ const BannerContent = ({
4903
3372
  children: [
4904
3373
  /* @__PURE__ */ u("div", { className: classes$2.header, children: [
4905
3374
  /* @__PURE__ */ u("div", { className: classes$2.heading, children: [
4906
- /* @__PURE__ */ u(Title, { asChild: true, children: /* @__PURE__ */ u(Text, { weight: "bold", children: heading2 }) }),
4907
- /* @__PURE__ */ u(Description, { asChild: true, children: /* @__PURE__ */ u(Text, { size: "caption", color: "muted", children: subheading }) })
3375
+ /* @__PURE__ */ u(Text, { weight: "bold", children: heading2 }),
3376
+ /* @__PURE__ */ u(Text, { size: "caption", color: "muted", children: subheading })
4908
3377
  ] }),
4909
3378
  /* @__PURE__ */ u(Trigger, { asChild: true, children: /* @__PURE__ */ u(Button, { variant: "ghost", children: [
4910
3379
  settingsOpen ? hideLabel : selectLabel,
@@ -4922,7 +3391,7 @@ const BannerContent = ({
4922
3391
  ] }) })
4923
3392
  ] }),
4924
3393
  /* @__PURE__ */ u(
4925
- Content$1,
3394
+ Content,
4926
3395
  {
4927
3396
  className: clx({
4928
3397
  [classes$2.settings]: true
@@ -4934,7 +3403,7 @@ const BannerContent = ({
4934
3403
  collapsible: true,
4935
3404
  value: openItem,
4936
3405
  onValueChange: setOpenItem,
4937
- children: /* @__PURE__ */ u(k, { children: items.map((item) => /* @__PURE__ */ u(BannerItem, { ...item, openItem }, item.value)) })
3406
+ children: items.map((item) => /* @__PURE__ */ u(BannerItem, { ...item, openItem }, item.value))
4938
3407
  }
4939
3408
  )
4940
3409
  }
@@ -4942,15 +3411,15 @@ const BannerContent = ({
4942
3411
  /* @__PURE__ */ u("div", { className: classes$2.footer, children: [
4943
3412
  /* @__PURE__ */ u("div", { className: classes$2.legal, children: privacyPolicy && /* @__PURE__ */ u(Text, { size: "caption", children: /* @__PURE__ */ u("a", { href: privacyPolicy.url, target: "_blank", children: privacyPolicy.label }) }) }),
4944
3413
  /* @__PURE__ */ u("div", { className: classes$2.actions, children: [
4945
- /* @__PURE__ */ u(Close, { asChild: true, children: /* @__PURE__ */ u(Button, { variant: "neutral", onClick: () => onDeclineAll(), children: declineLabel }) }),
4946
- /* @__PURE__ */ u(Close, { asChild: true, children: /* @__PURE__ */ u(Button, { variant: "brand", onClick: () => onSave(), children: saveLabel }) })
3414
+ /* @__PURE__ */ u(Button, { variant: "neutral", onClick: () => onDeclineAll(), children: declineLabel }),
3415
+ /* @__PURE__ */ u(Button, { variant: "brand", onClick: () => onSave(), children: saveLabel })
4947
3416
  ] })
4948
3417
  ] })
4949
3418
  ]
4950
3419
  }
4951
3420
  )
4952
3421
  }
4953
- ) });
3422
+ );
4954
3423
  };
4955
3424
  const Banner = ({
4956
3425
  localStorageKey = "cb-selection",