@uninspired/cookie-banner 0.0.5 → 0.0.7

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 (40) hide show
  1. package/dist/components/Banner/Banner.js +35 -0
  2. package/dist/components/Banner/index.js +1 -0
  3. package/dist/components/BannerItem/BannerItem.js +24 -0
  4. package/dist/components/BannerItem/index.js +1 -0
  5. package/dist/components/Button/Button.js +6 -0
  6. package/dist/components/Button/index.js +1 -0
  7. package/dist/components/Switch/Switch.js +7 -0
  8. package/dist/components/Switch/index.js +1 -0
  9. package/dist/components/Text/Text.js +9 -0
  10. package/dist/components/Text/index.js +1 -0
  11. package/dist/contexts/SelectionContext.js +101 -0
  12. package/dist/react/index.cjs +969 -345
  13. package/dist/react/index.d.ts +2 -2
  14. package/dist/react/index.js +965 -341
  15. package/dist/react.js +1 -0
  16. package/dist/script/index.cjs +1 -1
  17. package/dist/script/index.js +40 -40
  18. package/dist/script.js +1 -0
  19. package/dist/types/components/Banner/Banner.d.ts +21 -0
  20. package/dist/types/components/Banner/index.d.ts +1 -0
  21. package/dist/types/components/BannerItem/BannerItem.d.ts +23 -0
  22. package/dist/types/components/BannerItem/index.d.ts +1 -0
  23. package/dist/types/components/Button/Button.d.ts +5 -0
  24. package/dist/types/components/Button/index.d.ts +1 -0
  25. package/dist/types/components/Switch/Switch.d.ts +5 -0
  26. package/dist/types/components/Switch/index.d.ts +1 -0
  27. package/dist/types/components/Text/Text.d.ts +8 -0
  28. package/dist/types/components/Text/index.d.ts +1 -0
  29. package/dist/types/contexts/SelectionContext.d.ts +23 -0
  30. package/dist/types/react.d.ts +1 -0
  31. package/dist/types/script.d.ts +1 -0
  32. package/dist/types/utils/classes.d.ts +2 -0
  33. package/dist/types/utils/mountBanner.d.ts +2 -0
  34. package/dist/types/utils/scriptDefinition.d.ts +35 -0
  35. package/dist/types/utils/selection.d.ts +3 -0
  36. package/dist/utils/classes.js +9 -0
  37. package/dist/utils/mountBanner.js +18 -0
  38. package/dist/utils/scriptDefinition.js +21 -0
  39. package/dist/utils/selection.js +2 -0
  40. package/package.json +6 -6
package/dist/react.js ADDED
@@ -0,0 +1 @@
1
+ export { Banner } from "./components/Banner";
@@ -42,4 +42,4 @@
42
42
 
43
43
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
44
44
 
45
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return P(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Kc="DialogDescriptionWarning",qc=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Xr(Kc).contentName}}.`;return P(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Gc=jr,Yc=Br,Xc=Zr,Jc=Kr,bn=Gr;const Qc=({noTarget:e=!0,heading:t="We use cookies.",subheading:n="Please define your selection below.",selectLabel:r="Select",hideLabel:o="Hide",saveLabel:i="Save selection",declineLabel:c="Decline all",defaultSettingsOpen:s=!0,privacyPolicy:a,items:u})=>{const{onSave:l,onDeclineAll:d,selectionTaken:_}=Sr(),[g,y]=I(void 0),[f,v]=I(s);return p(Gc,{open:!_,children:p(Yc,{className:Ot(F.root,e?F.noTarget:""),children:p(rr,{open:f,onOpenChange:v,className:F.collapsible,children:[p("div",{className:F.header,children:[p("div",{className:F.heading,children:[p(Xc,{asChild:!0,children:p(te,{weight:"bold",children:t})}),p(Jc,{asChild:!0,children:p(te,{size:"caption",color:"muted",children:n})})]}),p(or,{asChild:!0,children:p(nt,{variant:"ghost",children:[f?o:r," ",p(Cs,{size:12,className:ft({[F.chevron]:!0,[F.open]:f})})]})})]}),p(ir,{className:ft({[F.settings]:!0}),children:p(ls,{type:"single",collapsible:!0,value:g,onValueChange:y,children:u.map(m=>p(Ms,{...m,openItem:g},m.value))})}),p("div",{className:F.footer,children:[p("div",{className:F.legal,children:a&&p(te,{size:"caption",children:p("a",{href:a.url,target:"_blank",children:a.label})})}),p("div",{className:F.actions,children:[p(bn,{asChild:!0,children:p(nt,{variant:"neutral",onClick:()=>d(),children:c})}),p(bn,{asChild:!0,children:p(nt,{variant:"brand",onClick:()=>l(),children:i})})]})]})]})})})},ea=({localStorageKey:e="cb-selection",items:t,...n})=>{const r=D(()=>t.filter(o=>!o.required).map(o=>({value:o.value,script:o.script,defaultSelected:o.defaultSelected,required:o.required})),[t]);return p(xs,{items:r,localStorageKey:e,children:p(Qc,{items:t,...n})})};function ta(e,t){const n=t===void 0;let r;if(typeof t=="string"){const o=document.querySelector(t);if(!o)throw new Error(`Element with selector "${t}" not found`);r=o}else r=t;h.render(p(ea,{noTarget:n,...e}),r??document.body)}exports.mountBanner=ta;
45
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return P(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Kc="DialogDescriptionWarning",qc=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Xr(Kc).contentName}}.`;return P(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Gc=jr,Yc=Br,Xc=Zr,Jc=Kr,bn=Gr;const Qc=({noTarget:e=!0,heading:t="We use cookies.",subheading:n="Please define your selection below.",selectLabel:r="Select",hideLabel:o="Hide",saveLabel:i="Save selection",declineLabel:c="Decline all",defaultSettingsOpen:s=!0,privacyPolicy:a,items:u})=>{const{onSave:l,onDeclineAll:d,selectionTaken:_}=Sr(),[g,y]=I(void 0),[f,v]=I(s);return p(Gc,{open:!_,children:p(Yc,{className:Ot(F.root,e?F.noTarget:""),children:p(rr,{open:f,onOpenChange:v,className:F.collapsible,children:[p("div",{className:F.header,children:[p("div",{className:F.heading,children:[p(Xc,{asChild:!0,children:p(te,{weight:"bold",children:t})}),p(Jc,{asChild:!0,children:p(te,{size:"caption",color:"muted",children:n})})]}),p(or,{asChild:!0,children:p(nt,{variant:"ghost",children:[f?o:r," ",p(Cs,{size:12,className:ft({[F.chevron]:!0,[F.open]:f})})]})})]}),p(ir,{className:ft({[F.settings]:!0}),children:p(ls,{type:"single",collapsible:!0,value:g,onValueChange:y,children:p(h.Fragment,{children:u.map(m=>p(Ms,{...m,openItem:g},m.value))})})}),p("div",{className:F.footer,children:[p("div",{className:F.legal,children:a&&p(te,{size:"caption",children:p("a",{href:a.url,target:"_blank",children:a.label})})}),p("div",{className:F.actions,children:[p(bn,{asChild:!0,children:p(nt,{variant:"neutral",onClick:()=>d(),children:c})}),p(bn,{asChild:!0,children:p(nt,{variant:"brand",onClick:()=>l(),children:i})})]})]})]})})})},ea=({localStorageKey:e="cb-selection",items:t,...n})=>{const r=D(()=>t.filter(o=>!o.required).map(o=>({value:o.value,script:o.script,defaultSelected:o.defaultSelected,required:o.required})),[t]);return p(xs,{items:r,localStorageKey:e,children:p(Qc,{items:t,...n})})};function ta(e,t){const n=t===void 0;let r;if(typeof t=="string"){const o=document.querySelector(t);if(!o)throw new Error(`Element with selector "${t}" not found`);r=o}else r=t;h.render(p(ea,{noTarget:n,...e}),r??document.body)}exports.mountBanner=ta;
@@ -1,4 +1,4 @@
1
- import { options as z, Fragment as W, Component as se, createRef as On, createContext as ee, createElement as T, toChildArray as Q, cloneElement as io, render as Ae, hydrate as so } from "preact";
1
+ import { options as z, Fragment as F, Component as se, createRef as On, createContext as ee, createElement as T, toChildArray as Q, cloneElement as io, render as Ae, hydrate as so } from "preact";
2
2
  var co = 0;
3
3
  function p(e, t, n, r, o, i) {
4
4
  t || (t = {});
@@ -332,8 +332,8 @@ z.unmount = function(e) {
332
332
  }
333
333
  this.__b = null;
334
334
  }
335
- var o = t.__a && T(W, null, e.fallback);
336
- return o && (o.__u &= -33), [T(W, null, t.__a ? null : e.children), o];
335
+ var o = t.__a && T(F, null, e.fallback);
336
+ return o && (o.__u &= -33), [T(F, null, t.__a ? null : e.children), o];
337
337
  };
338
338
  var en = function(e, t, n) {
339
339
  if (++n[1] === n[0] && e.l.delete(t), e.props.revealOrder && (e.props.revealOrder[0] !== "t" || !e.l.size)) for (n = e.i; n; ) {
@@ -455,7 +455,7 @@ function G(e) {
455
455
  return !!e && e.$$typeof === $n;
456
456
  }
457
457
  function Wn(e) {
458
- return G(e) && e.type === W;
458
+ return G(e) && e.type === F;
459
459
  }
460
460
  function Bn(e) {
461
461
  return !!e && typeof e.displayName == "string" && e.displayName.startsWith("Memo(");
@@ -473,12 +473,12 @@ var Vn = function(e, t) {
473
473
  return e(t);
474
474
  }, kt = function(e, t) {
475
475
  return e(t);
476
- }, Kn = W, qn = G, I = { useState: R, useId: Et, useReducer: Te, useEffect: E, useLayoutEffect: te, useInsertionEffect: It, useTransition: Rt, useDeferredValue: At, useSyncExternalStore: Nt, startTransition: Ot, useRef: w, useImperativeHandle: wt, useMemo: D, useCallback: M, useContext: Y, useDebugValue: St, version: "18.3.1", Children: K, render: Ln, hydrate: Fn, unmountComponentAtNode: Hn, createPortal: zn, createElement: T, createContext: ee, createFactory: jn, cloneElement: ge, createRef: On, Fragment: W, isValidElement: G, isElement: qn, isFragment: Wn, isMemo: Bn, findDOMNode: Zn, Component: se, PureComponent: Ve, memo: Tn, forwardRef: P, flushSync: kt, unstable_batchedUpdates: Vn, StrictMode: Kn, Suspense: Pe, SuspenseList: _e, lazy: Mn, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: Un };
476
+ }, Kn = F, qn = G, I = { useState: R, useId: Et, useReducer: Te, useEffect: E, useLayoutEffect: te, useInsertionEffect: It, useTransition: Rt, useDeferredValue: At, useSyncExternalStore: Nt, startTransition: Ot, useRef: w, useImperativeHandle: wt, useMemo: D, useCallback: M, useContext: Y, useDebugValue: St, version: "18.3.1", Children: K, render: Ln, hydrate: Fn, unmountComponentAtNode: Hn, createPortal: zn, createElement: T, createContext: ee, createFactory: jn, cloneElement: ge, createRef: On, Fragment: F, isValidElement: G, isElement: qn, isFragment: Wn, isMemo: Bn, findDOMNode: Zn, Component: se, PureComponent: Ve, memo: Tn, forwardRef: P, flushSync: kt, unstable_batchedUpdates: Vn, StrictMode: Kn, Suspense: Pe, SuspenseList: _e, lazy: Mn, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: Un };
477
477
  const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
478
478
  __proto__: null,
479
479
  Children: K,
480
480
  Component: se,
481
- Fragment: W,
481
+ Fragment: F,
482
482
  PureComponent: Ve,
483
483
  StrictMode: Kn,
484
484
  Suspense: Pe,
@@ -561,7 +561,7 @@ const No = "_root_hw69b_1", Oo = "_neutral_hw69b_17", Ao = "_brand_hw69b_30", Ro
561
561
  ...o
562
562
  }
563
563
  )
564
- ), zo = "_root_1wsw7_42", $o = "_noTarget_1wsw7_53", Lo = "_collapsible_1wsw7_62", Fo = "_header_1wsw7_65", Uo = "_heading_1wsw7_72", jo = "_chevron_1wsw7_78", Wo = "_open_1wsw7_83", Bo = "_settings_1wsw7_89", Ho = "_footer_1wsw7_103", Zo = "_legal_1wsw7_110", Vo = "_actions_1wsw7_113", U = {
564
+ ), zo = "_root_1wsw7_42", $o = "_noTarget_1wsw7_53", Lo = "_collapsible_1wsw7_62", Fo = "_header_1wsw7_65", Uo = "_heading_1wsw7_72", jo = "_chevron_1wsw7_78", Wo = "_open_1wsw7_83", Bo = "_settings_1wsw7_89", Ho = "_footer_1wsw7_103", Zo = "_legal_1wsw7_110", Vo = "_actions_1wsw7_113", j = {
565
565
  root: zo,
566
566
  noTarget: $o,
567
567
  collapsible: Lo,
@@ -1356,7 +1356,7 @@ function Wi(e) {
1356
1356
  const { children: o, ...i } = n;
1357
1357
  if (G(o)) {
1358
1358
  const c = Vi(o), s = Zi(i, o.props);
1359
- return o.type !== W && (s.ref = r ? or(r, c) : c), ge(o, s);
1359
+ return o.type !== F && (s.ref = r ? or(r, c) : c), ge(o, s);
1360
1360
  }
1361
1361
  return K.count(o) > 1 ? K.only(null) : null;
1362
1362
  });
@@ -1423,7 +1423,7 @@ function Ki(e) {
1423
1423
  r
1424
1424
  ];
1425
1425
  }
1426
- function j(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
1426
+ function W(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
1427
1427
  return function(o) {
1428
1428
  if (e?.(o), n === !1 || !o.defaultPrevented)
1429
1429
  return t?.(o);
@@ -1628,7 +1628,7 @@ var cr = "CollapsibleTrigger", ar = P(
1628
1628
  disabled: o.disabled,
1629
1629
  ...r,
1630
1630
  ref: t,
1631
- onClick: j(e.onClick, o.onOpenToggle)
1631
+ onClick: W(e.onClick, o.onOpenToggle)
1632
1632
  }
1633
1633
  );
1634
1634
  }
@@ -1752,9 +1752,9 @@ var [_r, fs] = tt(B), [vr, ps] = tt(
1752
1752
  );
1753
1753
  }), [hs, nt] = tt(B), hr = I.forwardRef(
1754
1754
  (e, t) => {
1755
- const { __scopeAccordion: n, disabled: r, dir: o, orientation: i = "vertical", ...c } = e, s = I.useRef(null), a = L(s, t), u = ls(n), d = as(o) === "ltr", _ = j(e.onKeyDown, (m) => {
1755
+ const { __scopeAccordion: n, disabled: r, dir: o, orientation: i = "vertical", ...c } = e, s = I.useRef(null), a = L(s, t), u = ls(n), d = as(o) === "ltr", _ = W(e.onKeyDown, (m) => {
1756
1756
  if (!us.includes(m.key)) return;
1757
- const g = m.target, f = u().filter((F) => !F.ref.current?.disabled), v = f.findIndex((F) => F.ref.current === g), h = f.length;
1757
+ const g = m.target, f = u().filter((U) => !U.ref.current?.disabled), v = f.findIndex((U) => U.ref.current === g), h = f.length;
1758
1758
  if (v === -1) return;
1759
1759
  m.preventDefault();
1760
1760
  let y = v;
@@ -2026,7 +2026,7 @@ var rt = "Switch", [Ds] = ke(rt), [xs, Ms] = Ds(rt), Pr = P(
2026
2026
  value: a,
2027
2027
  ...d,
2028
2028
  ref: g,
2029
- onClick: j(e.onClick, (b) => {
2029
+ onClick: W(e.onClick, (b) => {
2030
2030
  y((C) => !C), v && (f.current = b.isPropagationStopped(), f.current || b.stopPropagation());
2031
2031
  })
2032
2032
  }
@@ -2305,11 +2305,11 @@ var Vs = "DismissableLayer", bt = "dismissableLayer.update", Ks = "dismissableLa
2305
2305
  onDismiss: s,
2306
2306
  ...a
2307
2307
  } = e, u = Y(kr), [l, d] = R(null), _ = l?.ownerDocument ?? globalThis?.document, [, m] = R({}), g = L(t, (S) => d(S)), f = Array.from(u.layers), [v] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), h = f.indexOf(v), y = l ? f.indexOf(l) : -1, b = u.layersWithOutsidePointerEventsDisabled.size > 0, C = y >= h, O = Xs((S) => {
2308
- const F = S.target, le = [...u.branches].some((we) => we.contains(F));
2308
+ const U = S.target, le = [...u.branches].some((we) => we.contains(U));
2309
2309
  !C || le || (o?.(S), c?.(S), S.defaultPrevented || s?.());
2310
2310
  }, _), k = Js((S) => {
2311
- const F = S.target;
2312
- [...u.branches].some((we) => we.contains(F)) || (i?.(S), c?.(S), S.defaultPrevented || s?.());
2311
+ const U = S.target;
2312
+ [...u.branches].some((we) => we.contains(U)) || (i?.(S), c?.(S), S.defaultPrevented || s?.());
2313
2313
  }, _);
2314
2314
  return Zs((S) => {
2315
2315
  y === u.layers.size - 1 && (r?.(S), !S.defaultPrevented && s && (S.preventDefault(), s()));
@@ -2332,9 +2332,9 @@ var Vs = "DismissableLayer", bt = "dismissableLayer.update", Ks = "dismissableLa
2332
2332
  pointerEvents: b ? C ? "auto" : "none" : void 0,
2333
2333
  ...e.style
2334
2334
  },
2335
- onFocusCapture: j(e.onFocusCapture, k.onFocusCapture),
2336
- onBlurCapture: j(e.onBlurCapture, k.onBlurCapture),
2337
- onPointerDownCapture: j(
2335
+ onFocusCapture: W(e.onFocusCapture, k.onFocusCapture),
2336
+ onBlurCapture: W(e.onBlurCapture, k.onBlurCapture),
2337
+ onPointerDownCapture: W(
2338
2338
  e.onPointerDownCapture,
2339
2339
  O.onPointerDownCapture
2340
2340
  )
@@ -2698,7 +2698,7 @@ var Fr = vc(), pt = function() {
2698
2698
  onTouchMoveCapture: pt
2699
2699
  }), o = r[0], i = r[1], c = e.forwardProps, s = e.children, a = e.className, u = e.removeScrollBar, l = e.enabled, d = e.shards, _ = e.sideCar, m = e.noRelative, g = e.noIsolation, f = e.inert, v = e.allowPinchZoom, h = e.as, y = h === void 0 ? "div" : h, b = e.gapMode, C = $r(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), O = _, k = fc([n, t]), S = H(H({}, C), o);
2700
2700
  return T(
2701
- W,
2701
+ F,
2702
2702
  null,
2703
2703
  l && T(O, { sideCar: Fr, removeScrollBar: u, shards: d, noRelative: m, noIsolation: g, inert: f, setCallbacks: i, allowPinchZoom: !!v, lockRef: n, gapMode: b }),
2704
2704
  c ? ge(K.only(s), H(H({}, S), { ref: k })) : T(y, H({}, S, { className: a, ref: k }), s)
@@ -2950,7 +2950,7 @@ function Uc(e) {
2950
2950
  var h = Ue(f), y = n.current, b = "deltaX" in f ? f.deltaX : y[0] - h[0], C = "deltaY" in f ? f.deltaY : y[1] - h[1], O, k = f.target, S = Math.abs(b) > Math.abs(C) ? "h" : "v";
2951
2951
  if ("touches" in f && S === "h" && k.type === "range")
2952
2952
  return !1;
2953
- var F = window.getSelection(), le = F && F.anchorNode, we = le ? le === k || le.contains(k) : !1;
2953
+ var U = window.getSelection(), le = U && U.anchorNode, we = le ? le === k || le.contains(k) : !1;
2954
2954
  if (we)
2955
2955
  return !1;
2956
2956
  var xe = Sn(S, k);
@@ -3006,7 +3006,7 @@ function Uc(e) {
3006
3006
  }, []);
3007
3007
  var m = e.removeScrollBar, g = e.inert;
3008
3008
  return T(
3009
- W,
3009
+ F,
3010
3010
  null,
3011
3011
  g ? T(i, { styles: Lc(o) }) : null,
3012
3012
  m ? T(Rc, { noRelative: e.noRelative, gapMode: e.gapMode }) : null
@@ -3115,7 +3115,7 @@ var qr = "DialogTrigger", qc = P(
3115
3115
  "data-state": jt(o.open),
3116
3116
  ...r,
3117
3117
  ref: i,
3118
- onClick: j(e.onClick, o.onOpenToggle)
3118
+ onClick: W(e.onClick, o.onOpenToggle)
3119
3119
  }
3120
3120
  );
3121
3121
  }
@@ -3167,14 +3167,14 @@ var Qc = P(
3167
3167
  ref: o,
3168
3168
  trapFocus: n.open,
3169
3169
  disableOutsidePointerEvents: !0,
3170
- onCloseAutoFocus: j(e.onCloseAutoFocus, (i) => {
3170
+ onCloseAutoFocus: W(e.onCloseAutoFocus, (i) => {
3171
3171
  i.preventDefault(), n.triggerRef.current?.focus();
3172
3172
  }),
3173
- onPointerDownOutside: j(e.onPointerDownOutside, (i) => {
3173
+ onPointerDownOutside: W(e.onPointerDownOutside, (i) => {
3174
3174
  const c = i.detail.originalEvent, s = c.button === 0 && c.ctrlKey === !0;
3175
3175
  (c.button === 2 || s) && i.preventDefault();
3176
3176
  }),
3177
- onFocusOutside: j(
3177
+ onFocusOutside: W(
3178
3178
  e.onFocusOutside,
3179
3179
  (i) => i.preventDefault()
3180
3180
  )
@@ -3205,7 +3205,7 @@ var Qc = P(
3205
3205
  ), Xr = P(
3206
3206
  (e, t) => {
3207
3207
  const { __scopeDialog: n, trapFocus: r, onOpenAutoFocus: o, onCloseAutoFocus: i, ...c } = e, s = V(ce, n), a = w(null), u = L(t, a);
3208
- return sc(), /* @__PURE__ */ p(W, { children: [
3208
+ return sc(), /* @__PURE__ */ p(F, { children: [
3209
3209
  /* @__PURE__ */ p(
3210
3210
  Mr,
3211
3211
  {
@@ -3229,7 +3229,7 @@ var Qc = P(
3229
3229
  )
3230
3230
  }
3231
3231
  ),
3232
- /* @__PURE__ */ p(W, { children: [
3232
+ /* @__PURE__ */ p(F, { children: [
3233
3233
  /* @__PURE__ */ p(ta, { titleId: s.titleId }),
3234
3234
  /* @__PURE__ */ p(ra, { contentRef: a, descriptionId: s.descriptionId })
3235
3235
  ] })
@@ -3258,7 +3258,7 @@ var to = "DialogClose", no = P(
3258
3258
  type: "button",
3259
3259
  ...r,
3260
3260
  ref: t,
3261
- onClick: j(e.onClick, () => o.onOpenChange(!1))
3261
+ onClick: W(e.onClick, () => o.onOpenChange(!1))
3262
3262
  }
3263
3263
  );
3264
3264
  }
@@ -3303,16 +3303,16 @@ const aa = ({
3303
3303
  return /* @__PURE__ */ p(oa, { open: !_, children: /* @__PURE__ */ p(
3304
3304
  ia,
3305
3305
  {
3306
- className: Dt(U.root, e ? U.noTarget : ""),
3306
+ className: Dt(j.root, e ? j.noTarget : ""),
3307
3307
  children: /* @__PURE__ */ p(
3308
3308
  lr,
3309
3309
  {
3310
3310
  open: f,
3311
3311
  onOpenChange: v,
3312
- className: U.collapsible,
3312
+ className: j.collapsible,
3313
3313
  children: [
3314
- /* @__PURE__ */ p("div", { className: U.header, children: [
3315
- /* @__PURE__ */ p("div", { className: U.heading, children: [
3314
+ /* @__PURE__ */ p("div", { className: j.header, children: [
3315
+ /* @__PURE__ */ p("div", { className: j.heading, children: [
3316
3316
  /* @__PURE__ */ p(sa, { asChild: !0, children: /* @__PURE__ */ p(ie, { weight: "bold", children: t }) }),
3317
3317
  /* @__PURE__ */ p(ca, { asChild: !0, children: /* @__PURE__ */ p(ie, { size: "caption", color: "muted", children: n }) })
3318
3318
  ] }),
@@ -3324,8 +3324,8 @@ const aa = ({
3324
3324
  {
3325
3325
  size: 12,
3326
3326
  className: gt({
3327
- [U.chevron]: !0,
3328
- [U.open]: f
3327
+ [j.chevron]: !0,
3328
+ [j.open]: f
3329
3329
  })
3330
3330
  }
3331
3331
  )
@@ -3335,7 +3335,7 @@ const aa = ({
3335
3335
  fr,
3336
3336
  {
3337
3337
  className: gt({
3338
- [U.settings]: !0
3338
+ [j.settings]: !0
3339
3339
  }),
3340
3340
  children: /* @__PURE__ */ p(
3341
3341
  ys,
@@ -3344,14 +3344,14 @@ const aa = ({
3344
3344
  collapsible: !0,
3345
3345
  value: m,
3346
3346
  onValueChange: g,
3347
- children: u.map((h) => /* @__PURE__ */ p(Hs, { ...h, openItem: m }, h.value))
3347
+ children: /* @__PURE__ */ p(F, { children: u.map((h) => /* @__PURE__ */ p(Hs, { ...h, openItem: m }, h.value)) })
3348
3348
  }
3349
3349
  )
3350
3350
  }
3351
3351
  ),
3352
- /* @__PURE__ */ p("div", { className: U.footer, children: [
3353
- /* @__PURE__ */ p("div", { className: U.legal, children: a && /* @__PURE__ */ p(ie, { size: "caption", children: /* @__PURE__ */ p("a", { href: a.url, target: "_blank", children: a.label }) }) }),
3354
- /* @__PURE__ */ p("div", { className: U.actions, children: [
3352
+ /* @__PURE__ */ p("div", { className: j.footer, children: [
3353
+ /* @__PURE__ */ p("div", { className: j.legal, children: a && /* @__PURE__ */ p(ie, { size: "caption", children: /* @__PURE__ */ p("a", { href: a.url, target: "_blank", children: a.label }) }) }),
3354
+ /* @__PURE__ */ p("div", { className: j.actions, children: [
3355
3355
  /* @__PURE__ */ p(Nn, { asChild: !0, children: /* @__PURE__ */ p(at, { variant: "neutral", onClick: () => d(), children: c }) }),
3356
3356
  /* @__PURE__ */ p(Nn, { asChild: !0, children: /* @__PURE__ */ p(at, { variant: "brand", onClick: () => l(), children: i }) })
3357
3357
  ] })
package/dist/script.js ADDED
@@ -0,0 +1 @@
1
+ export { mountBanner } from "./utils/mountBanner";
@@ -0,0 +1,21 @@
1
+ import { type BannerItemOptions } from "../BannerItem";
2
+ import "../../styles/variables.css";
3
+ export interface BannerOptions {
4
+ localStorageKey?: string;
5
+ heading?: string;
6
+ subheading?: string;
7
+ selectLabel?: string;
8
+ hideLabel?: string;
9
+ saveLabel?: string;
10
+ declineLabel?: string;
11
+ defaultSettingsOpen?: boolean;
12
+ privacyPolicy?: {
13
+ label: string;
14
+ url: string;
15
+ };
16
+ items: BannerItemOptions[];
17
+ }
18
+ export interface BannerProps extends BannerOptions {
19
+ noTarget?: boolean;
20
+ }
21
+ export declare const Banner: ({ localStorageKey, items, ...rest }: BannerProps) => import("preact").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Banner";
@@ -0,0 +1,23 @@
1
+ import { type ScriptDefinition } from "../../utils/scriptDefinition";
2
+ interface BannerItemOptionsBase {
3
+ value: string;
4
+ label: string;
5
+ defaultSelected?: boolean;
6
+ sublabel?: string;
7
+ required?: boolean;
8
+ description?: string;
9
+ }
10
+ interface BannerItemOptionsRequired extends BannerItemOptionsBase {
11
+ required: true;
12
+ script: undefined;
13
+ }
14
+ interface BannerItemOptionsOptional extends BannerItemOptionsBase {
15
+ required: false;
16
+ script: ScriptDefinition;
17
+ }
18
+ export type BannerItemOptions = BannerItemOptionsRequired | BannerItemOptionsOptional;
19
+ export interface BannerItemProps extends Omit<BannerItemOptions, "script"> {
20
+ openItem?: string;
21
+ }
22
+ export declare const BannerItem: ({ value, label, sublabel, required, description, openItem, }: BannerItemProps) => import("preact").JSX.Element;
23
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./BannerItem";
@@ -0,0 +1,5 @@
1
+ import type { HTMLAttributes } from "react";
2
+ export interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {
3
+ variant?: "neutral" | "brand" | "ghost";
4
+ }
5
+ export declare const Button: ({ variant, ...rest }: ButtonProps) => import("preact").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Button";
@@ -0,0 +1,5 @@
1
+ import { type SwitchProps as RadixSwitchProps } from "@radix-ui/react-switch";
2
+ export interface SwitchProps extends RadixSwitchProps {
3
+ label?: string;
4
+ }
5
+ export declare const Switch: ({ label, id, ...rest }: SwitchProps) => import("preact").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Switch";
@@ -0,0 +1,8 @@
1
+ import type { JSX } from "react";
2
+ export type TextProps<T extends keyof JSX.IntrinsicElements> = JSX.IntrinsicElements[T] & {
3
+ as?: T;
4
+ size?: "body" | "caption";
5
+ weight?: "normal" | "bold";
6
+ color?: "default" | "muted";
7
+ };
8
+ export declare const Text: <T extends keyof JSX.IntrinsicElements>({ as, size, weight, color, ...rest }: TextProps<T>) => JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Text";
@@ -0,0 +1,23 @@
1
+ import { type PropsWithChildren } from "react";
2
+ import { type SelectionSchema } from "../utils/selection";
3
+ import type { BannerItemOptions } from "../components/BannerItem";
4
+ export type SelectionContextType = {
5
+ selection: SelectionSchema | null;
6
+ toggleSelection: (key: string, value: boolean) => void;
7
+ onDeclineAll: () => void;
8
+ onSave: () => void;
9
+ selectionTaken: boolean;
10
+ } | null;
11
+ export declare const SelectionContext: import("preact").Context<SelectionContextType>;
12
+ export interface SelectionProviderProps extends PropsWithChildren {
13
+ items: Pick<BannerItemOptions, "value" | "script" | "required" | "defaultSelected">[];
14
+ localStorageKey: string;
15
+ }
16
+ export declare const SelectionProvider: ({ children, items, localStorageKey, }: SelectionProviderProps) => import("preact").JSX.Element;
17
+ export declare function useSelection(): {
18
+ selection: SelectionSchema | null;
19
+ toggleSelection: (key: string, value: boolean) => void;
20
+ onDeclineAll: () => void;
21
+ onSave: () => void;
22
+ selectionTaken: boolean;
23
+ };
@@ -0,0 +1 @@
1
+ export { Banner, type BannerProps } from "./components/Banner";
@@ -0,0 +1 @@
1
+ export { mountBanner } from "./utils/mountBanner";
@@ -0,0 +1,2 @@
1
+ export declare function cls(...classes: (string | undefined)[]): string;
2
+ export declare function clx(classes: Record<string, boolean>): string;
@@ -0,0 +1,2 @@
1
+ import { type BannerOptions } from "../components/Banner";
2
+ export declare function mountBanner(options: BannerOptions, targetElement?: HTMLElement | string): void;
@@ -0,0 +1,35 @@
1
+ import * as z from "zod/mini";
2
+ export declare const remoteScriptDefinitionSchema: z.ZodMiniObject<{
3
+ variant: z.ZodMiniLiteral<"remote">;
4
+ type: z.ZodMiniOptional<z.ZodMiniString<string>>;
5
+ src: z.ZodMiniString<string>;
6
+ async: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
7
+ defer: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
8
+ crossorigin: z.ZodMiniOptional<z.ZodMiniString<string>>;
9
+ integrity: z.ZodMiniOptional<z.ZodMiniString<string>>;
10
+ }, z.core.$strip>;
11
+ export type RemoteScriptDefinition = z.infer<typeof remoteScriptDefinitionSchema>;
12
+ export declare const inlineScriptDefinitionSchema: z.ZodMiniObject<{
13
+ variant: z.ZodMiniLiteral<"inline">;
14
+ type: z.ZodMiniOptional<z.ZodMiniString<string>>;
15
+ async: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
16
+ defer: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
17
+ content: z.ZodMiniString<string>;
18
+ }, z.core.$strip>;
19
+ export type InlineScriptDefinition = z.infer<typeof inlineScriptDefinitionSchema>;
20
+ export declare const scriptDefinitionSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
21
+ variant: z.ZodMiniLiteral<"remote">;
22
+ type: z.ZodMiniOptional<z.ZodMiniString<string>>;
23
+ src: z.ZodMiniString<string>;
24
+ async: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
25
+ defer: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
26
+ crossorigin: z.ZodMiniOptional<z.ZodMiniString<string>>;
27
+ integrity: z.ZodMiniOptional<z.ZodMiniString<string>>;
28
+ }, z.core.$strip>, z.ZodMiniObject<{
29
+ variant: z.ZodMiniLiteral<"inline">;
30
+ type: z.ZodMiniOptional<z.ZodMiniString<string>>;
31
+ async: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
32
+ defer: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
33
+ content: z.ZodMiniString<string>;
34
+ }, z.core.$strip>], "variant">;
35
+ export type ScriptDefinition = z.infer<typeof scriptDefinitionSchema>;
@@ -0,0 +1,3 @@
1
+ import * as z from "zod/mini";
2
+ export declare const selectionSchema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>>;
3
+ export type SelectionSchema = z.infer<typeof selectionSchema>;
@@ -0,0 +1,9 @@
1
+ export function cls(...classes) {
2
+ return classes.filter(Boolean).join(" ");
3
+ }
4
+ export function clx(classes) {
5
+ return Object.entries(classes)
6
+ .filter(([, value]) => value)
7
+ .map(([key]) => key)
8
+ .join(" ");
9
+ }
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "preact/jsx-runtime";
2
+ import { Banner } from "../components/Banner";
3
+ import { render } from "preact";
4
+ export function mountBanner(options, targetElement) {
5
+ const noTarget = targetElement === undefined;
6
+ let element;
7
+ if (typeof targetElement === "string") {
8
+ const target = document.querySelector(targetElement);
9
+ if (!target) {
10
+ throw new Error(`Element with selector "${targetElement}" not found`);
11
+ }
12
+ element = target;
13
+ }
14
+ else {
15
+ element = targetElement;
16
+ }
17
+ render(_jsx(Banner, { noTarget: noTarget, ...options }), element ?? document.body);
18
+ }
@@ -0,0 +1,21 @@
1
+ import * as z from "zod/mini";
2
+ export const remoteScriptDefinitionSchema = z.object({
3
+ variant: z.literal("remote"),
4
+ type: z.optional(z.string()),
5
+ src: z.string(),
6
+ async: z.optional(z.boolean()),
7
+ defer: z.optional(z.boolean()),
8
+ crossorigin: z.optional(z.string()),
9
+ integrity: z.optional(z.string()),
10
+ });
11
+ export const inlineScriptDefinitionSchema = z.object({
12
+ variant: z.literal("inline"),
13
+ type: z.optional(z.string()),
14
+ async: z.optional(z.boolean()),
15
+ defer: z.optional(z.boolean()),
16
+ content: z.string(),
17
+ });
18
+ export const scriptDefinitionSchema = z.discriminatedUnion("variant", [
19
+ remoteScriptDefinitionSchema,
20
+ inlineScriptDefinitionSchema,
21
+ ]);
@@ -0,0 +1,2 @@
1
+ import * as z from "zod/mini";
2
+ export const selectionSchema = z.record(z.string(), z.boolean());
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Chris Kolb <chris@uninspired.studio>",
5
5
  "license": "MIT",
6
6
  "private": false,
7
- "version": "0.0.5",
7
+ "version": "0.0.7",
8
8
  "type": "module",
9
9
  "exports": {
10
10
  "./react": {
@@ -31,13 +31,13 @@
31
31
  "dev": "bunx --bun vite -c vite.config.dev.ts",
32
32
  "build:script": "bunx --bun vite build -c vite.config.script.ts",
33
33
  "build:react": "bunx --bun vite build -c vite.config.react.ts",
34
- "build:safe": "tsc -b && bunx --bun vite build",
34
+ "build:safe": "tsc -b && bun run build:script && bun run build:react",
35
35
  "build": "bun run build:script && bun run build:react",
36
36
  "preview": "bunx --bun vite preview"
37
37
  },
38
38
  "peerDependencies": {
39
- "react": "^19",
40
- "react-dom": "^19",
39
+ "react": "^18",
40
+ "react-dom": "^18",
41
41
  "preact": "^10.28.4"
42
42
  },
43
43
  "dependencies": {
@@ -52,8 +52,8 @@
52
52
  "@preact/preset-vite": "^2.10.3",
53
53
  "@types/bun": "^1.3.9",
54
54
  "@types/node": "^24.10.1",
55
- "@types/react": "^19",
56
- "@types/react-dom": "^19",
55
+ "@types/react": "^18",
56
+ "@types/react-dom": "^18",
57
57
  "@vitejs/plugin-react": "^5.1.4",
58
58
  "typescript": "~5.9.3",
59
59
  "vite": "^7.3.1",