@rikstv/shared-components 2.0.15 → 2.0.16

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,2 +1,2 @@
1
1
  import { RefObject } from "react";
2
- export declare const useMutationObserver: (target: Element | RefObject<HTMLElement>, onObservation: MutationCallback, config?: Partial<MutationObserverInit>) => void;
2
+ export declare const useMutationObserver: (target: Element | RefObject<Element>, onObservation: MutationCallback, config?: MutationObserverInit) => void;
@@ -0,0 +1,44 @@
1
+ import { j as e } from "../accordion/Accordion-5e72e67b.mjs";
2
+ const u = ({
3
+ label: r,
4
+ id: d,
5
+ options: l,
6
+ onChange: i,
7
+ className: t = "",
8
+ defaultValue: o,
9
+ rightIcon: h,
10
+ leftIcon: a,
11
+ innerRef: m,
12
+ ...x
13
+ }) => {
14
+ var c;
15
+ const j = `dropdown-styling ${a ? "menu-with-left-icon" : ""} ${t}`;
16
+ return /* @__PURE__ */ e.jsxs("span", { className: j, children: [
17
+ /* @__PURE__ */ e.jsx("label", { htmlFor: d, children: r }),
18
+ /* @__PURE__ */ e.jsxs("div", { className: "select-wrapper", children: [
19
+ /* @__PURE__ */ e.jsx(
20
+ "select",
21
+ {
22
+ defaultValue: o,
23
+ value: (c = l.find((s) => s.selected)) == null ? void 0 : c.value,
24
+ id: d,
25
+ ref: m,
26
+ onChange: ({ target: s }) => {
27
+ const n = l.find((p) => p.value === s.value) ?? l[0];
28
+ i(n);
29
+ },
30
+ ...x,
31
+ children: l.map((s, n) => /* @__PURE__ */ e.jsx("option", { value: s.value, children: s.title }, `dropdown-${r}-${s.title}-${n}`))
32
+ }
33
+ ),
34
+ /* @__PURE__ */ e.jsxs("div", { children: [
35
+ /* @__PURE__ */ e.jsx("div", { className: "left-icon", children: a }),
36
+ /* @__PURE__ */ e.jsx("div", { className: "right-icon", children: h })
37
+ ] })
38
+ ] })
39
+ ] });
40
+ };
41
+ u.displayName = "Dropdown";
42
+ export {
43
+ u as D
44
+ };
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { RefObject } from "react";
2
2
  interface BaseDropdownOption {
3
3
  title: string;
4
4
  value: string;
@@ -14,6 +14,10 @@ interface DropdownProps<T extends BaseDropdownOption> {
14
14
  isFilter?: boolean;
15
15
  rightIcon?: JSX.Element;
16
16
  leftIcon?: JSX.Element;
17
+ innerRef?: RefObject<HTMLSelectElement>;
17
18
  }
18
- export declare const Dropdown: import("react").ForwardRefExoticComponent<DropdownProps<BaseDropdownOption> & import("react").RefAttributes<HTMLSelectElement>>;
19
+ export declare const Dropdown: {
20
+ <T extends BaseDropdownOption>({ label, id, options, onChange, className, defaultValue, rightIcon, leftIcon, innerRef, ...rest }: DropdownProps<T>): JSX.Element;
21
+ displayName: string;
22
+ };
19
23
  export {};
@@ -10,10 +10,10 @@ import { B as ae, a as ce } from "./components/breadcrumb/Breadcrumb-19678339.mj
10
10
  import { P as me } from "./components/progress/Progress-068e34f7.mjs";
11
11
  import { L as fe } from "./components/loader/Loader-55215a54.mjs";
12
12
  import { C as xe } from "./components/progress/CircularProgress-ac261d40.mjs";
13
- import { D as ye } from "./components/dropdown/Dropdown-499736ab.mjs";
14
- import { P as ge, S as ve, T as Te } from "./components/button/Button-3754ac0a.mjs";
13
+ import { D as ge } from "./components/dropdown/Dropdown-3cf2ddf7.mjs";
14
+ import { P as he, S as Te, T as ve } from "./components/button/Button-3754ac0a.mjs";
15
15
  import { P as Be, S as we, T as Ee } from "./components/button/ArrowButton-4fa3c028.mjs";
16
- import { P as Me, S as be, T as Re } from "./components/button/IconButton-be3ae8eb.mjs";
16
+ import { P as Me, S as Re, T as be } from "./components/button/IconButton-be3ae8eb.mjs";
17
17
  import { T as Se } from "./components/toggleButton/ToggleButton-d50d64ec.mjs";
18
18
  import { T as Ce } from "./components/toggleInlineButton/ToggleInlineButton-ff76d094.mjs";
19
19
  import { T as Fe } from "./components/toggleLinkButton/ToggleLinkButton-c6127fa1.mjs";
@@ -27,7 +27,7 @@ import { C as sr } from "./components/list/CheckmarkListItem-f97a2aae.mjs";
27
27
  import { L as ar } from "./components/list/ListItem-fe58799f.mjs";
28
28
  import { C as ur } from "./components/list/CrossmarkListItem-60e093df.mjs";
29
29
  import { O as dr } from "./components/list/OrderedListItem-1a4b67c5.mjs";
30
- import { useState as x, useEffect as d, useRef as c, useCallback as p, useLayoutEffect as g } from "react";
30
+ import { useState as x, useEffect as d, useRef as c, useCallback as p, useLayoutEffect as y } from "react";
31
31
  import { L as lr } from "./components/button/LinkButton-3a3f73b6.mjs";
32
32
  import { B as pr } from "./components/button/BaseLinkButton-d325fecb.mjs";
33
33
  import "./components/core/Core-5cdbbcd4.mjs";
@@ -43,21 +43,21 @@ import "./components/icons/Arrow-48abbbdf.mjs";
43
43
  import "./components/checkbox/BaseCheckbox-9b7c43b3.mjs";
44
44
  import "./components/icons/HeartToggle-a5a93ca7.mjs";
45
45
  import "./components/icons/Icons-32b173f0.mjs";
46
- const y = "(prefers-reduced-motion: reduce)", v = (e) => typeof window < "u" && window.matchMedia ? window.matchMedia(e).matches : !1, T = (e, t) => {
46
+ const g = "(prefers-reduced-motion: reduce)", h = (e) => typeof window < "u" && window.matchMedia ? window.matchMedia(e).matches : !1, T = (e, t) => {
47
47
  typeof e.addEventListener < "u" && e.addEventListener("change", t);
48
- }, L = () => {
49
- const [e, t] = x(v(y));
48
+ }, v = () => {
49
+ const [e, t] = x(h(g));
50
50
  return d(() => {
51
- typeof window < "u" && window.matchMedia && T(window.matchMedia(y), (o) => {
52
- t(o.matches);
51
+ typeof window < "u" && window.matchMedia && T(window.matchMedia(g), (n) => {
52
+ t(n.matches);
53
53
  });
54
54
  }, []), { prefersReducedMotion: e };
55
55
  };
56
56
  function V(e, t) {
57
- const o = c(), s = c(), n = c(null), a = c(!0), { prefersReducedMotion: u } = L();
57
+ const n = c(), s = c(), o = c(null), a = c(!0), { prefersReducedMotion: u } = v();
58
58
  function m(r) {
59
59
  var l;
60
- const i = n.current;
60
+ const i = o.current;
61
61
  i && r.target === i && (i.removeAttribute("style"), (l = t == null ? void 0 : t.onTransitionEnd) == null || l.call(t, e));
62
62
  }
63
63
  const f = p(() => {
@@ -68,7 +68,7 @@ function V(e, t) {
68
68
  (l = t == null ? void 0 : t.onTransitionEnd) == null || l.call(t, e);
69
69
  return;
70
70
  }
71
- const r = n.current;
71
+ const r = o.current;
72
72
  if (r)
73
73
  if (r.style.display = "block", r.style.overflow = "hidden", e)
74
74
  r.style.height = "0", r.style.height = `${r.scrollHeight}px`;
@@ -77,55 +77,55 @@ function V(e, t) {
77
77
  r.removeAttribute("style");
78
78
  return;
79
79
  }
80
- r.style.height = `${r.scrollHeight}px`, o.current = requestAnimationFrame(() => {
80
+ r.style.height = `${r.scrollHeight}px`, n.current = requestAnimationFrame(() => {
81
81
  s.current = requestAnimationFrame(() => {
82
82
  r.style.height = `${0}px`;
83
83
  });
84
84
  });
85
85
  }
86
86
  }, [e, t, u]);
87
- return g(() => {
87
+ return y(() => {
88
88
  f();
89
89
  }, [e, f]), d(() => {
90
- const r = n.current;
90
+ const r = o.current;
91
91
  return r && r.addEventListener("transitionend", m), () => {
92
92
  r && r.removeEventListener("transitionend", m);
93
93
  };
94
94
  }, [e]), d(() => {
95
- const r = o.current, i = s.current;
95
+ const r = n.current, i = s.current;
96
96
  return a.current = !1, () => {
97
97
  r && cancelAnimationFrame(r), i && cancelAnimationFrame(i);
98
98
  };
99
- }, [o, s]), [n, f];
99
+ }, [n, s]), [o, f];
100
100
  }
101
- const N = ({ ref: e, callback: t, condition: o = !0 }) => {
101
+ const N = ({ ref: e, callback: t, condition: n = !0 }) => {
102
102
  const s = p(
103
- (n) => {
104
- e != null && e.current && !e.current.contains(n.target) && t(n);
103
+ (o) => {
104
+ e != null && e.current && !e.current.contains(o.target) && t(o);
105
105
  },
106
106
  [t, e]
107
107
  );
108
- d(() => (e && o && document && document.addEventListener("click", s), () => {
108
+ d(() => (e && n && document && document.addEventListener("click", s), () => {
109
109
  document && document.removeEventListener("click", s);
110
- }), [e, o, s]);
111
- }, B = (() => {
110
+ }), [e, n, s]);
111
+ }, L = (() => {
112
112
  const e = globalThis.IntersectionObserverEntry;
113
113
  return "IntersectionObserver" in globalThis && e && "isIntersecting" in e.prototype;
114
- })(), w = () => {
115
- }, E = (e, t = {}, o = w, s = !0) => {
116
- const [n, a] = x(null), u = p((r) => a(r), [a]), m = c(t), f = c(null);
114
+ })(), B = () => {
115
+ }, w = (e, t = {}, n = B, s = !0) => {
116
+ const [o, a] = x(null), u = p((r) => a(r), [a]), m = c(t), f = c(null);
117
117
  return d(() => {
118
- if (!B) {
119
- o == null || o();
118
+ if (!L) {
119
+ n == null || n();
120
120
  return;
121
121
  }
122
122
  let r = f.current;
123
- return r == null || r.disconnect(), n && s && (r = new IntersectionObserver(e, m.current), r.observe(n)), () => {
123
+ return r == null || r.disconnect(), o && s && (r = new IntersectionObserver(e, m.current), r.observe(o)), () => {
124
124
  r == null || r.disconnect();
125
125
  };
126
- }, [n, e, o, s]), [u];
126
+ }, [o, e, n, s]), [u];
127
127
  }, $ = (e = { rootMargin: "150px" }, t = !0) => {
128
- const [o, s] = x(!1), [n] = E(
128
+ const [n, s] = x(!1), [o] = w(
129
129
  (a) => {
130
130
  const u = a.some((m) => m.isIntersecting);
131
131
  s(u);
@@ -134,15 +134,15 @@ const N = ({ ref: e, callback: t, condition: o = !0 }) => {
134
134
  void 0,
135
135
  t
136
136
  );
137
- return [n, o];
138
- }, h = () => typeof window < "u" && typeof MutationObserver < "u", Q = (e, t, o) => {
139
- const s = c(null);
137
+ return [o, n];
138
+ }, E = () => typeof window < "u" && typeof MutationObserver < "u", Q = (e, t, n) => {
139
+ const s = c(n);
140
140
  d(() => {
141
- let n = s.current;
142
- return h() && (n && n.disconnect(), n = new MutationObserver(t), e && ("current" in e ? e.current && n.observe(e.current, o) : n.observe(e, o))), () => {
143
- h() && n && n.disconnect();
144
- };
145
- }, [e, t, o]);
141
+ if (E() && e) {
142
+ const o = new MutationObserver(t);
143
+ return "current" in e ? e.current && o.observe(e.current, s.current) : o.observe(e, s.current), () => o.disconnect();
144
+ }
145
+ }, [e, t]);
146
146
  };
147
147
  export {
148
148
  ne as Accordion,
@@ -156,7 +156,7 @@ export {
156
156
  xe as CircularProgress,
157
157
  ur as CrossmarkListItem,
158
158
  Ue as DisplayTitle,
159
- ye as Dropdown,
159
+ ge as Dropdown,
160
160
  Ne as FieldSet,
161
161
  X as Gutter,
162
162
  Z as GutterPadding,
@@ -175,29 +175,29 @@ export {
175
175
  dr as OrderedListItem,
176
176
  se as Panel,
177
177
  Be as PrimaryArrowButton,
178
- ge as PrimaryButton,
178
+ he as PrimaryButton,
179
179
  Me as PrimaryIconButton,
180
180
  me as Progress,
181
181
  Ge as RadioToggleInput,
182
182
  q as RiksTVProvider,
183
183
  we as SecondaryArrowButton,
184
- ve as SecondaryButton,
185
- be as SecondaryIconButton,
184
+ Te as SecondaryButton,
185
+ Re as SecondaryIconButton,
186
186
  Ze as Span,
187
187
  j as StrimProvider,
188
188
  er as SubBody,
189
189
  rr as Tag,
190
190
  Ee as TertiaryArrowButton,
191
- Te as TertiaryButton,
192
- Re as TertiaryIconButton,
191
+ ve as TertiaryButton,
192
+ be as TertiaryIconButton,
193
193
  Qe as TextField,
194
194
  Se as ToggleButton,
195
195
  Ce as ToggleInlineButton,
196
196
  Fe as ToggleLinkButton,
197
197
  V as useAnimatedHeight,
198
- L as useBrowserPreferences,
198
+ v as useBrowserPreferences,
199
199
  N as useClickOutsideListener,
200
200
  $ as useElementVisible,
201
- E as useIntersectionObserver,
201
+ w as useIntersectionObserver,
202
202
  Q as useMutationObserver
203
203
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rikstv/shared-components",
3
- "version": "2.0.15",
3
+ "version": "2.0.16",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,35 +0,0 @@
1
- import { j as e } from "../accordion/Accordion-5e72e67b.mjs";
2
- import { forwardRef as j } from "react";
3
- const u = j(
4
- ({ label: d, id: n, options: r, onChange: i, className: o = "", defaultValue: t, rightIcon: m, leftIcon: a }, h) => {
5
- var c;
6
- const p = `dropdown-styling ${a ? "menu-with-left-icon" : ""} ${o}`;
7
- return /* @__PURE__ */ e.jsxs("span", { className: p, children: [
8
- /* @__PURE__ */ e.jsx("label", { htmlFor: n, children: d }),
9
- /* @__PURE__ */ e.jsxs("div", { className: "select-wrapper", children: [
10
- /* @__PURE__ */ e.jsx(
11
- "select",
12
- {
13
- defaultValue: t,
14
- value: (c = r.find((s) => s.selected)) == null ? void 0 : c.value,
15
- id: n,
16
- ref: h,
17
- onChange: ({ target: s }) => {
18
- const l = r.find((x) => x.value === s.value) ?? r[0];
19
- i(l);
20
- },
21
- children: r.map((s, l) => /* @__PURE__ */ e.jsx("option", { value: s.value, children: s.title }, `dropdown-${d}-${s.title}-${l}`))
22
- }
23
- ),
24
- /* @__PURE__ */ e.jsxs("div", { children: [
25
- /* @__PURE__ */ e.jsx("div", { className: "left-icon", children: a }),
26
- /* @__PURE__ */ e.jsx("div", { className: "right-icon", children: m })
27
- ] })
28
- ] })
29
- ] });
30
- }
31
- );
32
- u.displayName = "Dropdown";
33
- export {
34
- u as D
35
- };