@leabankab/component-library 8.12.0 → 8.13.0

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.
@@ -9,7 +9,8 @@ type ActionButtonLabel = {
9
9
  /**
10
10
  * Shows only the arrow: a round button, with the label kept for screen
11
11
  * readers. Used where space is short, such as a collapsed
12
- * `ExpandingCards` item.
12
+ * `ExpandingCards` item. Left out, it is what the nearest
13
+ * `ActionButtonProvider` says.
13
14
  * @default false
14
15
  */
15
16
  iconOnly?: false;
@@ -42,5 +43,27 @@ export type ActionButtonProps = Omit<ButtonRootProps, "loading" | "children"> &
42
43
  * <ActionButton size="sm" iconOnly render={<a href="/lan" />}>Se våra lån</ActionButton>
43
44
  * ```
44
45
  */
45
- export declare function ActionButton({ children, className, size, iconOnly, ...rest }: ActionButtonProps): import("react").JSX.Element;
46
+ export declare function ActionButton({ children, className, size, iconOnly: ownIconOnly, ...rest }: ActionButtonProps): import("react").JSX.Element;
47
+ export type ActionButtonProviderProps = {
48
+ /**
49
+ * Shows only the arrow on the `ActionButton`s inside, with their labels
50
+ * kept for screen readers. A button's own `iconOnly` wins.
51
+ */
52
+ iconOnly?: boolean;
53
+ children?: ReactNode;
54
+ };
55
+ /**
56
+ * Sets `iconOnly` for the `ActionButton`s inside it, also one that a
57
+ * component of the app's own renders, such as a shared call to action. A
58
+ * button that sets `iconOnly` itself keeps its own setting, and one without
59
+ * a label has nothing to hide. `ExpandingCardsItem` uses it to shrink its
60
+ * action to the arrow while the card is closed.
61
+ *
62
+ * ```tsx
63
+ * <ActionButtonProvider iconOnly={!open}>
64
+ * <Cta href="/lan">Søk nå</Cta>
65
+ * </ActionButtonProvider>
66
+ * ```
67
+ */
68
+ export declare function ActionButtonProvider({ iconOnly, children, }: ActionButtonProviderProps): import("react").JSX.Element;
46
69
  export {};
@@ -20,6 +20,14 @@ export type FeaturedImageProps = Omit<ComponentProps<"div">, "children"> & {
20
20
  * `ActionButton`, `size="lg"` on wide screens and `"sm"` on phones.
21
21
  */
22
22
  action?: ReactNode;
23
+ /**
24
+ * The width : height to crop the photo to from 1024px, for a photo that
25
+ * stands on its own rather than in a row of a grid: `ratio={8 / 3}` is
26
+ * 1272 × 477 across the website's column. It takes the place of the row's
27
+ * height, so the photo keeps it inside a row as well. Below 1024px the
28
+ * photo is 1 : 0.7 either way.
29
+ */
30
+ ratio?: number;
23
31
  };
24
32
  /**
25
33
  * A large photo with the website's 64px corners, and optionally a call to
@@ -36,7 +44,10 @@ export type FeaturedImageProps = Omit<ComponentProps<"div">, "children"> & {
36
44
  * ```
37
45
  *
38
46
  * From 1024px it fills the height its row gives it (the photo is cropped to
39
- * fit); below that it keeps the website's 1 : 0.7. The action comes after
47
+ * fit); below that it keeps the website's 1 : 0.7. Outside a row nothing
48
+ * gives it a height, and from 1024px it shows the whole photo at the photo's
49
+ * own ratio: give a photo that stands alone a `ratio` to crop it to, such
50
+ * as `ratio={8 / 3}` for a band across a `Section`. The action comes after
40
51
  * the photo in the reading order.
41
52
  */
42
- export declare function FeaturedImage({ src, alt, imageRender, action, className, ...rest }: FeaturedImageProps): import("react").JSX.Element;
53
+ export declare function FeaturedImage({ src, alt, imageRender, action, ratio, className, style, ...rest }: FeaturedImageProps): import("react").JSX.Element;
@@ -8,6 +8,7 @@ export * from './number-input/number-input';
8
8
  export * from './phone-number-input';
9
9
  export * as RadioGroup from './radio/radio';
10
10
  export * as RadioCard from './radio-card/radio-card';
11
+ export * from './search-input/search-input';
11
12
  export * from './select/select';
12
13
  export * from './slider/slider';
13
14
  export * from './switch/switch';
@@ -0,0 +1,51 @@
1
+ import { ReactNode, Ref } from 'react';
2
+ import { InputProps } from '../input/input';
3
+ /**
4
+ * Requires an accessible name so the field is never nameless. Provide a
5
+ * visible `label`, or an `aria-label` when the design has none.
6
+ */
7
+ type SearchInputAccessibleName = {
8
+ label: ReactNode;
9
+ "aria-label"?: never;
10
+ } | {
11
+ label?: never;
12
+ "aria-label": string;
13
+ };
14
+ export type SearchInputProps = Omit<InputProps, "type" | "label" | "aria-label" | "startAdornment" | "endAdornment" | "multiline" | "rows" | "minRows" | "maxRows" | "ref"> & SearchInputAccessibleName & {
15
+ /** The `<input>`. */
16
+ ref?: Ref<HTMLInputElement>;
17
+ /**
18
+ * The name of the button that empties the field.
19
+ * @default "Tøm søket", in the language of `LeaProvider`
20
+ */
21
+ clearLabel?: string;
22
+ };
23
+ /**
24
+ * A field to search with: an `Input` of `type="search"` with a search icon
25
+ * at its start and, once there is text, a button with an X at its end that
26
+ * empties the field and puts the focus back in it. The browser's own clear
27
+ * button is hidden. Escape empties the field too, where the browser does
28
+ * that for a search field (Chrome, Edge, Safari).
29
+ *
30
+ * It takes the props of `Input` and the same value contract: `value` /
31
+ * `defaultValue` / `onValueChange`, called with `""` when the field is
32
+ * emptied. It needs a `label`, or an `aria-label` where the design has no
33
+ * visible one, and the clear button is named in the language of
34
+ * `LeaProvider` ("Tøm søket").
35
+ *
36
+ * ```tsx
37
+ * <form role="search" onSubmit={search}>
38
+ * <SearchInput
39
+ * aria-label="Søk i spørsmål og svar"
40
+ * placeholder="Søk i spørsmål og svar"
41
+ * value={query}
42
+ * onValueChange={setQuery}
43
+ * />
44
+ * </form>
45
+ * ```
46
+ *
47
+ * The clear button is left out of the tab order, as in `Autocomplete`: the
48
+ * keyboard empties the field by deleting its text.
49
+ */
50
+ export declare function SearchInput({ value, defaultValue, onValueChange, clearLabel, enterKeyHint, disabled, className, ref, ...rest }: SearchInputProps): import("react").JSX.Element;
51
+ export {};
@@ -17,7 +17,7 @@ type SliderAccessibleName = {
17
17
  label?: never;
18
18
  "aria-label": string;
19
19
  };
20
- export type SliderProps = Omit<BaseSlider.Root.Props<number>, "children" | "orientation" | "minStepsBetweenValues" | "thumbAlignment" | "thumbCollisionBehavior" | "aria-label" | "aria-labelledby"> & SliderAccessibleName & {
20
+ export type SliderProps = Omit<BaseSlider.Root.Props<number>, "children" | "orientation" | "minStepsBetweenValues" | "thumbAlignment" | "thumbCollisionBehavior" | "aria-label" | "aria-labelledby" | "largeStep"> & SliderAccessibleName & {
21
21
  /** Helper / error text shown below the slider and linked via `aria-describedby`. */
22
22
  helperText?: ReactNode;
23
23
  /** Puts the slider and its helper text into the error state. */
@@ -29,6 +29,25 @@ export type SliderProps = Omit<BaseSlider.Root.Props<number>, "children" | "orie
29
29
  * @default "primary"
30
30
  */
31
31
  color?: SliderColor;
32
+ /**
33
+ * Writes the value wherever it is shown or read out: above the track,
34
+ * `min` and `max` under its ends, and the range input's
35
+ * `aria-valuetext`. For a unit that `Intl.NumberFormat` has no style
36
+ * for, such as "kr/måned". Wins over `format` and `locale`.
37
+ *
38
+ * ```tsx
39
+ * formatValue={(value) => `${new Intl.NumberFormat("nb-NO").format(value)} kr/måned`}
40
+ * ```
41
+ */
42
+ formatValue?: (value: number) => string;
43
+ /**
44
+ * How far Page Up and Page Down, and Shift with an arrow key, move the
45
+ * value. By default a tenth of the range, rounded to a whole number of
46
+ * `step`s and at least one: 10 from 0 to 100, 55 000 from 50 000 to
47
+ * 600 000 by 5 000. Give a multiple of `step`, or the value leaves the
48
+ * step grid.
49
+ */
50
+ largeStep?: number;
32
51
  };
33
52
  /**
34
53
  * A single-value slider built on Base UI's accessible `Slider` primitive.
@@ -41,7 +60,8 @@ export type SliderProps = Omit<BaseSlider.Root.Props<number>, "children" | "orie
41
60
  * `name` is set.
42
61
  *
43
62
  * Pass `format` and `locale` to control how the value, `min` and `max` are
44
- * written and announced. On a dark surface, pass `color="contrast"`.
63
+ * written and announced, or `formatValue` for a unit `Intl.NumberFormat`
64
+ * doesn't have. On a dark surface, pass `color="contrast"`.
45
65
  *
46
66
  * ```tsx
47
67
  * <Slider
@@ -55,6 +75,11 @@ export type SliderProps = Omit<BaseSlider.Root.Props<number>, "children" | "orie
55
75
  * onValueChange={(value) => setAmount(value)}
56
76
  * />
57
77
  * ```
78
+ *
79
+ * The range input fires `input` on every change the user makes and `change`
80
+ * when they let go, as a native one does, so a listener on the page (such
81
+ * as analytics) can follow the slider without a callback. Setting `value`
82
+ * fires neither.
58
83
  */
59
- export declare function Slider({ label, "aria-label": ariaLabel, helperText, error, color, min, max, format, locale, className, ...rest }: SliderProps): import("react").JSX.Element;
84
+ export declare function Slider({ label, "aria-label": ariaLabel, helperText, error, color, min, max, step, largeStep, value, defaultValue, onValueChange, onValueCommitted, format, locale, formatValue, className, ...rest }: SliderProps): import("react").JSX.Element;
60
85
  export {};
@@ -1,28 +1,36 @@
1
- import { Field } from '@base-ui/react/field';
2
- import { ReactNode } from 'react';
1
+ import { ReactNode, Ref } from 'react';
3
2
  /**
4
- * `render` for a `Field.Root` that is only there to hand a control its
5
- * validity state, which is how Base UI puts `aria-invalid` on the slider's
6
- * nested range input. It makes the field render no element of its own.
3
+ * A `Field.Root` that is only there to hand the slider its validity state,
4
+ * which is how Base UI puts `aria-invalid` on the nested range input. It
5
+ * renders no element of its own.
7
6
  */
8
- export declare const renderWithoutElement: Field.Root.Props["render"];
7
+ export declare function SliderField({ invalid, children, }: {
8
+ invalid: boolean;
9
+ children: ReactNode;
10
+ }): import("react").JSX.Element;
9
11
  type SliderTrackProps = {
10
12
  "aria-label"?: string;
11
13
  "aria-describedby"?: string;
14
+ /** The range input inside the thumb. */
15
+ inputRef?: Ref<HTMLInputElement>;
16
+ /** Writes the value for `aria-valuetext`, in place of `format`. */
17
+ formatValue?: (value: number) => string;
12
18
  };
13
19
  /**
14
20
  * The clickable control with its track, fill and thumb. The thumb is rendered
15
21
  * here so it can never be left out. Must sit inside a Base UI `Slider.Root`.
16
22
  */
17
- export declare function SliderTrack({ "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, }: SliderTrackProps): import("react").JSX.Element;
23
+ export declare function SliderTrack({ "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, inputRef, formatValue, }: SliderTrackProps): import("react").JSX.Element;
18
24
  type SliderRangeProps = {
19
25
  min: number;
20
26
  max: number;
21
27
  format?: Intl.NumberFormatOptions;
22
28
  locale?: Intl.LocalesArgument;
29
+ /** Writes `min` and `max`, in place of `format` and `locale`. */
30
+ formatValue?: (value: number) => string;
23
31
  };
24
32
  /** `min` and `max` under each end of the track, written like the value. */
25
- export declare function SliderRange({ min, max, format, locale }: SliderRangeProps): import("react").JSX.Element;
33
+ export declare function SliderRange({ min, max, format, locale, formatValue, }: SliderRangeProps): import("react").JSX.Element;
26
34
  type SliderHelperTextProps = {
27
35
  /** Id the controls point at with `aria-describedby`. */
28
36
  id: string;
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});require('./cookie-consent.css');const e=require("./cookie-consent-core-BYak3SKZ.cjs");let t=require("react"),n=require("@base-ui/react/button"),r=require("@base-ui/react/use-render"),i=require("react/jsx-runtime"),a=require("@base-ui/react/dialog"),o=require("lucide-react"),s=require("@base-ui/react/switch"),c=require("@base-ui/react/accordion");var l=(e,t)=>n=>[e,typeof t==`function`?t(n):t].filter(Boolean).join(` `),u={Button:`_Button_dq81c_1`,IconButton:`_IconButton_dq81c_141`,Spinner:`_Spinner_dq81c_172`,"button-spin":`_button-spin_dq81c_1`,SrOnly:`_SrOnly_dq81c_190`},d=e=>(0,t.isValidElement)(e)&&(e.props.href!=null||e.props.to!=null),f=e=>e.preventDefault();function p({loading:e=!1,disabled:t,className:a,render:o,nativeButton:s,focusableWhenDisabled:c,ref:l,...u}){let p=!!(t||e),m=d(o),h={"aria-busy":e||void 0,"data-loading":e||void 0};return(0,r.useRender)({enabled:m,render:m?o:void 0,ref:l,defaultTagName:`a`,props:{...u,...h,"aria-disabled":p||void 0,"data-disabled":p?``:void 0,className:typeof a==`function`?a({disabled:p}):a,onClick:p?f:u.onClick}})||(0,i.jsx)(n.Button,{...u,...h,ref:l,render:o,nativeButton:s,focusableWhenDisabled:c,disabled:p,className:a})}function m({variant:e=`solid`,color:t=`primary`,size:n=`md`,className:r,...a}){return(0,i.jsx)(p,{...a,"data-variant":e,"data-color":t,"data-size":n,className:l(u.Button,r)})}function h({startIcon:e,endIcon:t,loading:n=!1,loadingLabel:r,children:a,...o}){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(m,{...o,loading:n,"data-start-icon":n||e!=null||void 0,"data-end-icon":t!=null||void 0,children:[n?(0,i.jsx)(`span`,{className:u.Spinner,"aria-hidden":!0}):e,a,t]}),r!=null&&(0,i.jsx)(`span`,{role:`status`,className:u.SrOnly,children:n?r:null})]})}var g={Backdrop:`_Backdrop_1do7v_8`,Viewport:`_Viewport_1do7v_22`,Popup:`_Popup_1do7v_38`,Header:`_Header_1do7v_78`,Title:`_Title_1do7v_88`,Description:`_Description_1do7v_97`,Content:`_Content_1do7v_111`,Footer:`_Footer_1do7v_119`,CloseButton:`_CloseButton_1do7v_135`},_=(0,t.createContext)(`no`),v=()=>(0,t.useContext)(_);function y(e){return function(){let t=v(),n={};return Object.keys(e).forEach(r=>{let i=e[r];n[r]=i[t]??i.no}),n}}var b=y({close:{no:`Lukk`,se:`Stäng`,fi:`Sulje`,es:`Cerrar`}}),x=a.Dialog.Root;a.Dialog.Trigger;var S=a.Dialog.Portal;function C({className:e,...t}){return(0,i.jsx)(a.Dialog.Backdrop,{...t,className:l(g.Backdrop,e)})}function w({className:e,...t}){return(0,i.jsx)(a.Dialog.Viewport,{...t,className:l(g.Viewport,e)})}function T({size:e=`sm`,fullScreenOnMobile:t,className:n,...r}){return(0,i.jsx)(a.Dialog.Popup,{...r,"data-size":e,"data-full-screen-on-mobile":t||void 0,className:l(g.Popup,n)})}function E({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Header,e].filter(Boolean).join(` `)})}function D({className:e,...t}){return(0,i.jsx)(a.Dialog.Title,{...t,className:l(g.Title,e)})}function O({className:e,...t}){return(0,i.jsx)(a.Dialog.Description,{...t,className:l(g.Description,e)})}function k({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Content,e].filter(Boolean).join(` `)})}function A({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Footer,e].filter(Boolean).join(` `)})}a.Dialog.Close;function j({label:e,className:t,...n}){let r=b();return(0,i.jsx)(a.Dialog.Close,{...n,"aria-label":e??r.close,className:l(g.CloseButton,t),children:(0,i.jsx)(o.X,{size:20,"aria-hidden":!0})})}var M={Switch:`_Switch_9c9ji_7`,Thumb:`_Thumb_9c9ji_36`};function N({className:e,...t}){return(0,i.jsx)(s.Switch.Root,{...t,className:l(M.Switch,e),children:(0,i.jsx)(s.Switch.Thumb,{className:M.Thumb})})}var P={Root:`_Root_oibl2_13`,Item:`_Item_oibl2_10`,Header:`_Header_oibl2_10`,Trigger:`_Trigger_oibl2_108`,Label:`_Label_oibl2_149`,Icon:`_Icon_oibl2_153`,Panel:`_Panel_oibl2_171`,Content:`_Content_oibl2_182`};function F({variant:e=`outline`,iconPosition:t=`end`,className:n,...r}){return(0,i.jsx)(c.Accordion.Root,{...r,"data-variant":e,"data-icon-position":t,className:l(P.Root,n)})}function I({className:e,...t}){return(0,i.jsx)(c.Accordion.Item,{...t,className:l(P.Item,e)})}function L({className:e,...t}){return(0,i.jsx)(c.Accordion.Header,{...t,className:l(P.Header,e)})}function R({children:e,className:t,...n}){return(0,i.jsxs)(c.Accordion.Trigger,{...n,className:l(P.Trigger,t),children:[(0,i.jsx)(`span`,{className:P.Label,children:e}),(0,i.jsx)(o.ChevronDown,{className:P.Icon,size:20,"aria-hidden":!0})]})}function z({children:e,className:t,...n}){return(0,i.jsx)(c.Accordion.Panel,{...n,className:l(P.Panel,t),children:(0,i.jsx)(`div`,{className:P.Content,children:e})})}var B={Intro:`_Intro_nxwj4_7`,Categories:`_Categories_nxwj4_39`,CategoryDescription:`_CategoryDescription_nxwj4_43`,Actions:`_Actions_nxwj4_52`,Save:`_Save_nxwj4_63`},V=`https://relative.invalid`;function H(e,t){try{return new URL(e,t)}catch{return null}}function U(e){let t=e.trim();if(!t)return!1;let n=H(t);return n?n.protocol===`https:`||n.protocol===`mailto:`:H(t,V)?.origin===V}function W({href:e,resolveHref:t=e=>e,children:n}){let r=t(e);return!r||!U(r)?(0,i.jsx)(i.Fragment,{children:n}):(0,i.jsx)(`a`,{href:r.trim(),target:`_blank`,rel:`noopener noreferrer`,children:n})}function G({node:e}){let t=e.text;return e.underline&&(t=(0,i.jsx)(`u`,{children:t})),e.italic&&(t=(0,i.jsx)(`em`,{children:t})),e.bold&&(t=(0,i.jsx)(`strong`,{children:t})),(0,i.jsx)(i.Fragment,{children:t})}function K({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:(e??[]).map((e,n)=>e.type===`text`?(0,i.jsx)(G,{node:e},n):e.type===`link`?(0,i.jsx)(W,{href:e.url??``,resolveHref:t,children:(e.children??[]).filter(e=>e.type===`text`).map((e,t)=>(0,i.jsx)(G,{node:e},t))},n):null)})}function q({node:e,resolveHref:t}){let n=e.format===`ordered`?`ol`:`ul`;return(0,i.jsx)(n,{children:(e.children??[]).map((e,n)=>e.type===`list`?(0,i.jsx)(`li`,{children:(0,i.jsx)(q,{node:e,resolveHref:t})},n):e.type===`list-item`?(0,i.jsx)(`li`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n):null)})}function J({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:e.map((e,n)=>{switch(e.type){case`paragraph`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n);case`heading`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(`strong`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})})},n);case`list`:return(0,i.jsx)(q,{node:e,resolveHref:t},n);default:return null}})})}function Y(e){return{necessary:!0,preferences:e?.preferences??!1,analytics:e?.analytics??!1,marketing:e?.marketing??!1}}function X({category:e,copy:n,checked:r,onCheckedChange:a}){let o=(0,t.useId)(),s=(0,t.useId)(),{title:c,description:l}=n.categories[e];return(0,i.jsxs)(I,{value:e,children:[(0,i.jsxs)(L,{children:[(0,i.jsx)(R,{children:(0,i.jsx)(`span`,{id:o,children:c})}),(0,i.jsx)(N,{"aria-labelledby":o,"aria-describedby":l?s:void 0,checked:r,disabled:e===`necessary`,onCheckedChange:a})]}),(0,i.jsx)(z,{keepMounted:!0,children:l&&(0,i.jsx)(`p`,{id:s,className:B.CategoryDescription,children:l})})]})}function Z({open:n,consent:r,copy:a,resolveHref:o,onAcceptAll:s,onAcceptNecessary:c,onSave:l,onClose:u}){let d=r!==null,[f,p]=(0,t.useState)(()=>Y(r)),[m,g]=(0,t.useState)(n);return n!==m&&(g(n),n&&p(Y(r))),(0,i.jsx)(x,{open:n,onOpenChange:e=>{!e&&d&&u()},disablePointerDismissal:!d,children:(0,i.jsxs)(S,{children:[(0,i.jsx)(C,{}),(0,i.jsx)(w,{children:(0,i.jsxs)(T,{fullScreenOnMobile:!0,size:`md`,children:[(0,i.jsxs)(E,{children:[(0,i.jsx)(D,{children:a.modalTitle}),d&&(0,i.jsx)(j,{label:a.closeIconLabel})]}),(0,i.jsxs)(k,{children:[(0,i.jsx)(O,{render:(0,i.jsx)(`div`,{}),className:B.Intro,children:(0,i.jsx)(J,{nodes:a.intro,resolveHref:o})}),(0,i.jsx)(F,{variant:`solid`,iconPosition:`start`,multiple:!0,className:B.Categories,children:e.d.map(e=>(0,i.jsx)(X,{category:e,copy:a,checked:f[e],onCheckedChange:t=>p(n=>({...n,[e]:t}))},e))})]}),(0,i.jsxs)(A,{className:B.Actions,children:[(0,i.jsx)(h,{onClick:s,color:`secondary`,size:`sm`,children:a.btnAcceptAll}),(0,i.jsx)(h,{onClick:c,color:`secondary`,size:`sm`,children:a.btnAcceptNecessary}),(0,i.jsx)(h,{variant:`outline`,color:`secondary`,size:`sm`,className:B.Save,onClick:()=>l(e.d.filter(e=>f[e])),children:a.btnSaveSettings})]})]})})]})})}var Q=typeof document>`u`?t.useEffect:t.useLayoutEffect,$=(0,t.createContext)(null);function ee({market:n,copy:r,resolveHref:a,onConsentChange:o,autoOpen:s=!0,children:c}){let{consent:l,settingsOpen:u,ready:d}=(0,t.useSyncExternalStore)(e.u,e.i,e.r),f=(0,t.useRef)(o);Q(()=>{f.current=o});let p=(0,t.useRef)(null);(0,t.useEffect)(()=>{let t=()=>{let{consent:t}=e.i();if(!(t===null||e.c(t,p.current))){p.current=t;try{f.current?.(t)}catch(e){reportError(e)}}};return t(),e.u(t)},[]),(0,t.useEffect)(()=>{e.a({market:n})},[]);let m=(0,t.useMemo)(()=>({consent:l,openSettings:e.s}),[l]),h=d&&(u||l===null&&s&&!e.o(navigator.userAgent));return(0,i.jsxs)($.Provider,{value:m,children:[c,d&&(0,i.jsx)(Z,{open:h,consent:l,copy:r,resolveHref:a,onAcceptAll:()=>e.l(`all`),onAcceptNecessary:()=>e.l([]),onSave:e.l,onClose:e.t})]})}function te(){let e=(0,t.useContext)($);if(!e)throw Error(`useCookieConsent must be used inside a CookieConsentProvider.`);return e}exports.CookieConsentProvider=ee,exports.useCookieConsent=te;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});require('./cookie-consent.css');const e=require("./cookie-consent-core-BYak3SKZ.cjs");let t=require("react"),n=require("@base-ui/react/button"),r=require("@base-ui/react/use-render"),i=require("react/jsx-runtime"),a=require("@base-ui/react/dialog"),o=require("lucide-react"),s=require("@base-ui/react/switch"),c=require("@base-ui/react/accordion");var l=(e,t)=>n=>[e,typeof t==`function`?t(n):t].filter(Boolean).join(` `),u={Button:`_Button_dq81c_1`,IconButton:`_IconButton_dq81c_141`,Spinner:`_Spinner_dq81c_172`,"button-spin":`_button-spin_dq81c_1`,SrOnly:`_SrOnly_dq81c_190`},d=e=>(0,t.isValidElement)(e)&&(e.props.href!=null||e.props.to!=null),f=e=>e.preventDefault();function p({loading:e=!1,disabled:t,className:a,render:o,nativeButton:s,focusableWhenDisabled:c,ref:l,...u}){let p=!!(t||e),m=d(o),h={"aria-busy":e||void 0,"data-loading":e||void 0};return(0,r.useRender)({enabled:m,render:m?o:void 0,ref:l,defaultTagName:`a`,props:{...u,...h,"aria-disabled":p||void 0,"data-disabled":p?``:void 0,className:typeof a==`function`?a({disabled:p}):a,onClick:p?f:u.onClick}})||(0,i.jsx)(n.Button,{...u,...h,ref:l,render:o,nativeButton:s,focusableWhenDisabled:c,disabled:p,className:a})}function m({variant:e=`solid`,color:t=`primary`,size:n=`md`,className:r,...a}){return(0,i.jsx)(p,{...a,"data-variant":e,"data-color":t,"data-size":n,className:l(u.Button,r)})}function h({startIcon:e,endIcon:t,loading:n=!1,loadingLabel:r,children:a,...o}){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(m,{...o,loading:n,"data-start-icon":n||e!=null||void 0,"data-end-icon":t!=null||void 0,children:[n?(0,i.jsx)(`span`,{className:u.Spinner,"aria-hidden":!0}):e,a,t]}),r!=null&&(0,i.jsx)(`span`,{role:`status`,className:u.SrOnly,children:n?r:null})]})}var g={Backdrop:`_Backdrop_1do7v_8`,Viewport:`_Viewport_1do7v_22`,Popup:`_Popup_1do7v_38`,Header:`_Header_1do7v_78`,Title:`_Title_1do7v_88`,Description:`_Description_1do7v_97`,Content:`_Content_1do7v_111`,Footer:`_Footer_1do7v_119`,CloseButton:`_CloseButton_1do7v_135`},_=(0,t.createContext)(`no`),v=()=>(0,t.useContext)(_);function y(e){return function(){let t=v(),n={};return Object.keys(e).forEach(r=>{let i=e[r];n[r]=i[t]??i.no}),n}}var b=y({close:{no:`Lukk`,se:`Stäng`,fi:`Sulje`,es:`Cerrar`}}),x=a.Dialog.Root;a.Dialog.Trigger;var S=a.Dialog.Portal;function C({className:e,...t}){return(0,i.jsx)(a.Dialog.Backdrop,{...t,className:l(g.Backdrop,e)})}function w({className:e,...t}){return(0,i.jsx)(a.Dialog.Viewport,{...t,className:l(g.Viewport,e)})}function T({size:e=`sm`,fullScreenOnMobile:t,className:n,...r}){return(0,i.jsx)(a.Dialog.Popup,{...r,"data-size":e,"data-full-screen-on-mobile":t||void 0,className:l(g.Popup,n)})}function E({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Header,e].filter(Boolean).join(` `)})}function D({className:e,...t}){return(0,i.jsx)(a.Dialog.Title,{...t,className:l(g.Title,e)})}function O({className:e,...t}){return(0,i.jsx)(a.Dialog.Description,{...t,className:l(g.Description,e)})}function k({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Content,e].filter(Boolean).join(` `)})}function A({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Footer,e].filter(Boolean).join(` `)})}a.Dialog.Close;function j({label:e,className:t,...n}){let r=b();return(0,i.jsx)(a.Dialog.Close,{...n,"aria-label":e??r.close,className:l(g.CloseButton,t),children:(0,i.jsx)(o.X,{size:20,"aria-hidden":!0})})}var M={Switch:`_Switch_9c9ji_7`,Thumb:`_Thumb_9c9ji_36`};function N({className:e,...t}){return(0,i.jsx)(s.Switch.Root,{...t,className:l(M.Switch,e),children:(0,i.jsx)(s.Switch.Thumb,{className:M.Thumb})})}var P={Root:`_Root_b4izd_13`,Item:`_Item_b4izd_10`,Header:`_Header_b4izd_10`,Trigger:`_Trigger_b4izd_110`,Label:`_Label_b4izd_151`,Icon:`_Icon_b4izd_155`,Panel:`_Panel_b4izd_173`,Content:`_Content_b4izd_184`};function F({variant:e=`outline`,iconPosition:t=`end`,className:n,...r}){return(0,i.jsx)(c.Accordion.Root,{...r,"data-variant":e,"data-icon-position":t,className:l(P.Root,n)})}function I({className:e,...t}){return(0,i.jsx)(c.Accordion.Item,{...t,className:l(P.Item,e)})}function L({className:e,...t}){return(0,i.jsx)(c.Accordion.Header,{...t,className:l(P.Header,e)})}function R({children:e,className:t,...n}){return(0,i.jsxs)(c.Accordion.Trigger,{...n,className:l(P.Trigger,t),children:[(0,i.jsx)(`span`,{className:P.Label,children:e}),(0,i.jsx)(o.ChevronDown,{className:P.Icon,size:20,"aria-hidden":!0})]})}function z({children:e,className:t,...n}){return(0,i.jsx)(c.Accordion.Panel,{...n,className:l(P.Panel,t),children:(0,i.jsx)(`div`,{className:P.Content,children:e})})}var B={Intro:`_Intro_nxwj4_7`,Categories:`_Categories_nxwj4_39`,CategoryDescription:`_CategoryDescription_nxwj4_43`,Actions:`_Actions_nxwj4_52`,Save:`_Save_nxwj4_63`},V=`https://relative.invalid`;function H(e,t){try{return new URL(e,t)}catch{return null}}function U(e){let t=e.trim();if(!t)return!1;let n=H(t);return n?n.protocol===`https:`||n.protocol===`mailto:`:H(t,V)?.origin===V}function W({href:e,resolveHref:t=e=>e,children:n}){let r=t(e);return!r||!U(r)?(0,i.jsx)(i.Fragment,{children:n}):(0,i.jsx)(`a`,{href:r.trim(),target:`_blank`,rel:`noopener noreferrer`,children:n})}function G({node:e}){let t=e.text;return e.underline&&(t=(0,i.jsx)(`u`,{children:t})),e.italic&&(t=(0,i.jsx)(`em`,{children:t})),e.bold&&(t=(0,i.jsx)(`strong`,{children:t})),(0,i.jsx)(i.Fragment,{children:t})}function K({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:(e??[]).map((e,n)=>e.type===`text`?(0,i.jsx)(G,{node:e},n):e.type===`link`?(0,i.jsx)(W,{href:e.url??``,resolveHref:t,children:(e.children??[]).filter(e=>e.type===`text`).map((e,t)=>(0,i.jsx)(G,{node:e},t))},n):null)})}function q({node:e,resolveHref:t}){let n=e.format===`ordered`?`ol`:`ul`;return(0,i.jsx)(n,{children:(e.children??[]).map((e,n)=>e.type===`list`?(0,i.jsx)(`li`,{children:(0,i.jsx)(q,{node:e,resolveHref:t})},n):e.type===`list-item`?(0,i.jsx)(`li`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n):null)})}function J({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:e.map((e,n)=>{switch(e.type){case`paragraph`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n);case`heading`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(`strong`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})})},n);case`list`:return(0,i.jsx)(q,{node:e,resolveHref:t},n);default:return null}})})}function Y(e){return{necessary:!0,preferences:e?.preferences??!1,analytics:e?.analytics??!1,marketing:e?.marketing??!1}}function X({category:e,copy:n,checked:r,onCheckedChange:a}){let o=(0,t.useId)(),s=(0,t.useId)(),{title:c,description:l}=n.categories[e];return(0,i.jsxs)(I,{value:e,children:[(0,i.jsxs)(L,{children:[(0,i.jsx)(R,{children:(0,i.jsx)(`span`,{id:o,children:c})}),(0,i.jsx)(N,{"aria-labelledby":o,"aria-describedby":l?s:void 0,checked:r,disabled:e===`necessary`,onCheckedChange:a})]}),(0,i.jsx)(z,{keepMounted:!0,children:l&&(0,i.jsx)(`p`,{id:s,className:B.CategoryDescription,children:l})})]})}function Z({open:n,consent:r,copy:a,resolveHref:o,onAcceptAll:s,onAcceptNecessary:c,onSave:l,onClose:u}){let d=r!==null,[f,p]=(0,t.useState)(()=>Y(r)),[m,g]=(0,t.useState)(n);return n!==m&&(g(n),n&&p(Y(r))),(0,i.jsx)(x,{open:n,onOpenChange:e=>{!e&&d&&u()},disablePointerDismissal:!d,children:(0,i.jsxs)(S,{children:[(0,i.jsx)(C,{}),(0,i.jsx)(w,{children:(0,i.jsxs)(T,{fullScreenOnMobile:!0,size:`md`,children:[(0,i.jsxs)(E,{children:[(0,i.jsx)(D,{children:a.modalTitle}),d&&(0,i.jsx)(j,{label:a.closeIconLabel})]}),(0,i.jsxs)(k,{children:[(0,i.jsx)(O,{render:(0,i.jsx)(`div`,{}),className:B.Intro,children:(0,i.jsx)(J,{nodes:a.intro,resolveHref:o})}),(0,i.jsx)(F,{variant:`solid`,iconPosition:`start`,multiple:!0,className:B.Categories,children:e.d.map(e=>(0,i.jsx)(X,{category:e,copy:a,checked:f[e],onCheckedChange:t=>p(n=>({...n,[e]:t}))},e))})]}),(0,i.jsxs)(A,{className:B.Actions,children:[(0,i.jsx)(h,{onClick:s,color:`secondary`,size:`sm`,children:a.btnAcceptAll}),(0,i.jsx)(h,{onClick:c,color:`secondary`,size:`sm`,children:a.btnAcceptNecessary}),(0,i.jsx)(h,{variant:`outline`,color:`secondary`,size:`sm`,className:B.Save,onClick:()=>l(e.d.filter(e=>f[e])),children:a.btnSaveSettings})]})]})})]})})}var Q=typeof document>`u`?t.useEffect:t.useLayoutEffect,$=(0,t.createContext)(null);function ee({market:n,copy:r,resolveHref:a,onConsentChange:o,autoOpen:s=!0,children:c}){let{consent:l,settingsOpen:u,ready:d}=(0,t.useSyncExternalStore)(e.u,e.i,e.r),f=(0,t.useRef)(o);Q(()=>{f.current=o});let p=(0,t.useRef)(null);(0,t.useEffect)(()=>{let t=()=>{let{consent:t}=e.i();if(!(t===null||e.c(t,p.current))){p.current=t;try{f.current?.(t)}catch(e){reportError(e)}}};return t(),e.u(t)},[]),(0,t.useEffect)(()=>{e.a({market:n})},[]);let m=(0,t.useMemo)(()=>({consent:l,openSettings:e.s}),[l]),h=d&&(u||l===null&&s&&!e.o(navigator.userAgent));return(0,i.jsxs)($.Provider,{value:m,children:[c,d&&(0,i.jsx)(Z,{open:h,consent:l,copy:r,resolveHref:a,onAcceptAll:()=>e.l(`all`),onAcceptNecessary:()=>e.l([]),onSave:e.l,onClose:e.t})]})}function te(){let e=(0,t.useContext)($);if(!e)throw Error(`useCookieConsent must be used inside a CookieConsentProvider.`);return e}exports.CookieConsentProvider=ee,exports.useCookieConsent=te;
2
2
  //# sourceMappingURL=cookie-consent-react.cjs.map