rk-designsystem 1.3.2 → 1.3.5

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,13 +1,13 @@
1
1
  "use client";
2
2
  import { jsxs as l, jsx as t } from "react/jsx-runtime";
3
- import { useId as J, useState as m, useEffect as K } from "react";
3
+ import { useId as K, useState as u, useEffect as Q } from "react";
4
4
  import { Tabs as s } from "../Tabs/index.js";
5
- import { Button as Q } from "../Button/index.js";
6
- import { Textfield as X } from "../Textfield/index.js";
7
- import { Paragraph as Y } from "../Paragraph/index.js";
8
- import { Link as A } from "../Link/index.js";
5
+ import { Button as X } from "../Button/index.js";
6
+ import { Textfield as Y } from "../Textfield/index.js";
7
+ import { Paragraph as A } from "../Paragraph/index.js";
8
+ import { Link as ee } from "../Link/index.js";
9
9
  import i from "./styles.module.css.js";
10
- const L = () => /* @__PURE__ */ t(
10
+ const k = () => /* @__PURE__ */ t(
11
11
  "svg",
12
12
  {
13
13
  width: "19",
@@ -25,7 +25,7 @@ const L = () => /* @__PURE__ */ t(
25
25
  }
26
26
  )
27
27
  }
28
- ), ee = () => /* @__PURE__ */ t(
28
+ ), te = () => /* @__PURE__ */ t(
29
29
  "svg",
30
30
  {
31
31
  width: "16",
@@ -43,7 +43,7 @@ const L = () => /* @__PURE__ */ t(
43
43
  }
44
44
  )
45
45
  }
46
- ), te = () => /* @__PURE__ */ t(
46
+ ), ie = () => /* @__PURE__ */ t(
47
47
  "svg",
48
48
  {
49
49
  width: "64",
@@ -61,79 +61,82 @@ const L = () => /* @__PURE__ */ t(
61
61
  }
62
62
  )
63
63
  }
64
- ), ie = [
64
+ ), ae = [
65
65
  { value: 220, label: "220 kr" },
66
66
  { value: 345, label: "345 kr" },
67
67
  { value: 660, label: "660 kr" }
68
- ], me = ({
68
+ ], N = (e) => {
69
+ const d = Number(e);
70
+ return Number.isSafeInteger(d) && d > 0 ? d : null;
71
+ }, ue = ({
69
72
  "data-color": e = "primary-color-red",
70
- amounts: N = ie,
71
- defaultAmount: I = 345,
73
+ amounts: d = ae,
74
+ defaultAmount: z = 345,
72
75
  oneTimeLabel: B = "En gang",
73
- monthlyLabel: z = "Hver måned",
76
+ monthlyLabel: I = "Hver måned",
74
77
  customAmountPlaceholder: x = "Valgfritt beløp",
75
- amountLabel: H = "Velg ønsket beløp:",
78
+ amountLabel: S = "Velg ønsket beløp:",
76
79
  impactMessage: M = "En gave på {amount} bidrar til ...",
77
- vippsButtonLabel: g = "Gi med",
78
- avtalegiroLabel: k = "Gi med avtalegiro",
79
- avtalegiroHref: S = "#",
80
- currencySuffix: Z = "kr",
80
+ vippsButtonLabel: v = "Gi med",
81
+ avtalegiroLabel: H = "Gi med avtalegiro",
82
+ avtalegiroHref: Z = "#",
83
+ currencySuffix: T = "kr",
81
84
  onVippsClick: f,
82
- onAvtalegiroClick: c,
85
+ onAvtalegiroClick: p,
83
86
  onAmountChange: r,
84
- showVippsButton: T = !0,
87
+ showVippsButton: j = !0,
85
88
  showAvtalegiroLink: V = !0,
86
- showImpactMessage: j = !0,
87
- heartVariant: E = "outlined"
89
+ showImpactMessage: E = !0,
90
+ heartVariant: F = "outlined"
88
91
  }) => {
89
- const v = J(), [d, F] = m("monthly"), [C, P] = m(I), [u, b] = m(""), [w, h] = m(!1);
90
- K(() => {
92
+ const g = K(), [c, P] = u("monthly"), [b, D] = u(z), [C, w] = u(""), [y, h] = u(!1);
93
+ Q(() => {
91
94
  const a = "rk-donor-inline-styles";
92
95
  if (typeof document > "u" || document.getElementById(a)) return;
93
- const n = ae(i), o = document.createElement("style");
96
+ const n = ne(i), o = document.createElement("style");
94
97
  o.id = a, o.textContent = n, document.head.prepend(o);
95
98
  }, []);
96
- const y = parseInt(u, 10), p = w && u && y > 0 ? y : C, D = (a) => {
97
- P(a), h(!1), b(""), r == null || r(a, d);
98
- }, W = (a) => {
99
+ const $ = N(C), m = y && $ !== null ? $ : b, W = (a) => {
100
+ D(a), h(!1), w(""), r == null || r(a, c);
101
+ }, q = (a) => {
99
102
  const n = a.target.value;
100
- b(n), h(!0);
101
- const o = parseInt(n, 10);
102
- o > 0 && (r == null || r(o, d));
103
- }, q = () => {
103
+ w(n), h(!0);
104
+ const o = N(n);
105
+ o !== null && (r == null || r(o, c));
106
+ }, R = () => {
104
107
  h(!0);
105
108
  }, G = (a) => {
106
109
  const n = a;
107
- F(n), r == null || r(p, n);
108
- }, R = () => {
109
- p > 0 && (f == null || f(p, d));
110
+ P(n), r == null || r(m, n);
110
111
  }, U = () => {
111
- c == null || c();
112
+ m > 0 && (f == null || f(m, c));
112
113
  }, O = () => {
113
- const a = `${p} ${Z}`, n = M.split("{amount}");
114
+ p == null || p();
115
+ }, _ = () => {
116
+ const a = `${m} ${T}`, n = M.split("{amount}");
114
117
  return /* @__PURE__ */ l("span", { children: [
115
118
  n[0],
116
119
  /* @__PURE__ */ t("span", { className: i.impactAmount, children: a }),
117
120
  n[1] || ""
118
121
  ] });
119
- }, $ = /* @__PURE__ */ l("div", { className: i.content, children: [
122
+ }, L = /* @__PURE__ */ l("div", { className: i.content, children: [
120
123
  /* @__PURE__ */ l("div", { className: i.amountSection, children: [
121
- /* @__PURE__ */ t(Y, { className: i.amountLabel, "data-size": "sm", id: v, children: H }),
124
+ /* @__PURE__ */ t(A, { className: i.amountLabel, "data-size": "sm", id: g, children: S }),
122
125
  /* @__PURE__ */ t(
123
126
  "div",
124
127
  {
125
128
  className: i.amountButtons,
126
129
  role: "group",
127
- "aria-labelledby": v,
128
- children: N.map((a) => {
129
- const n = !w && C === a.value;
130
+ "aria-labelledby": g,
131
+ children: d.map((a) => {
132
+ const n = !y && b === a.value;
130
133
  return /* @__PURE__ */ t(
131
- Q,
134
+ X,
132
135
  {
133
136
  variant: n ? "primary" : "secondary",
134
137
  "data-color": n ? "primary-color-red" : "neutral",
135
138
  "aria-pressed": n,
136
- onClick: () => D(a.value),
139
+ onClick: () => W(a.value),
137
140
  children: a.label
138
141
  },
139
142
  a.value
@@ -142,52 +145,52 @@ const L = () => /* @__PURE__ */ t(
142
145
  }
143
146
  ),
144
147
  /* @__PURE__ */ t("div", { className: i.customAmountField, children: /* @__PURE__ */ t(
145
- X,
148
+ Y,
146
149
  {
147
150
  "aria-label": x,
148
151
  placeholder: x,
149
- value: u,
150
- onChange: W,
151
- onFocus: q,
152
+ value: C,
153
+ onChange: q,
154
+ onFocus: R,
152
155
  type: "number",
153
156
  min: 1
154
157
  }
155
158
  ) })
156
159
  ] }),
157
- j && /* @__PURE__ */ l("div", { className: i.impactRow, children: [
158
- /* @__PURE__ */ t("div", { className: i.heartIcon, children: E === "filled" ? /* @__PURE__ */ t(L, {}) : /* @__PURE__ */ t(ee, {}) }),
159
- /* @__PURE__ */ t("p", { className: i.impactText, children: O() })
160
+ E && /* @__PURE__ */ l("div", { className: i.impactRow, children: [
161
+ /* @__PURE__ */ t("div", { className: i.heartIcon, children: F === "filled" ? /* @__PURE__ */ t(k, {}) : /* @__PURE__ */ t(te, {}) }),
162
+ /* @__PURE__ */ t("p", { className: i.impactText, children: _() })
160
163
  ] }),
161
164
  /* @__PURE__ */ l("div", { className: i.actionsSection, children: [
162
- T && /* @__PURE__ */ l(
165
+ j && /* @__PURE__ */ l(
163
166
  "button",
164
167
  {
165
168
  className: i.vippsButton,
166
- onClick: R,
169
+ onClick: U,
167
170
  type: "button",
168
- "aria-label": `${g} Vipps`,
171
+ "aria-label": `${v} Vipps`,
169
172
  "data-brand-exception": "vipps",
170
173
  children: [
171
- /* @__PURE__ */ t("span", { className: i.vippsButtonLabel, children: g }),
172
- /* @__PURE__ */ t("span", { className: i.vippsLogo, children: /* @__PURE__ */ t(te, {}) })
174
+ /* @__PURE__ */ t("span", { className: i.vippsButtonLabel, children: v }),
175
+ /* @__PURE__ */ t("span", { className: i.vippsLogo, children: /* @__PURE__ */ t(ie, {}) })
173
176
  ]
174
177
  }
175
178
  ),
176
179
  V && /* @__PURE__ */ t(
177
- A,
180
+ ee,
178
181
  {
179
- href: S,
182
+ href: Z,
180
183
  "data-color": "neutral",
181
184
  className: i.avtalegiroLink,
182
185
  onClick: (a) => {
183
- c && (a.preventDefault(), U());
186
+ p && (a.preventDefault(), O());
184
187
  },
185
- children: k
188
+ children: H
186
189
  }
187
190
  )
188
191
  ] })
189
- ] }), _ = e === "primary" ? "primary-color-red" : e;
190
- return /* @__PURE__ */ t("div", { className: i.donor, "data-color": _, children: /* @__PURE__ */ l(
192
+ ] }), J = e === "primary" ? "primary-color-red" : e;
193
+ return /* @__PURE__ */ t("div", { className: i.donor, "data-color": J, children: /* @__PURE__ */ l(
191
194
  s,
192
195
  {
193
196
  defaultValue: "monthly",
@@ -198,17 +201,17 @@ const L = () => /* @__PURE__ */ t(
198
201
  /* @__PURE__ */ l(s.List, { children: [
199
202
  /* @__PURE__ */ t(s.Tab, { value: "one-time", children: B }),
200
203
  /* @__PURE__ */ l(s.Tab, { value: "monthly", children: [
201
- /* @__PURE__ */ t("span", { className: i.tabHeartIcon, children: /* @__PURE__ */ t(L, {}) }),
202
- z
204
+ /* @__PURE__ */ t("span", { className: i.tabHeartIcon, children: /* @__PURE__ */ t(k, {}) }),
205
+ I
203
206
  ] })
204
207
  ] }),
205
- /* @__PURE__ */ t(s.Panel, { value: "one-time", className: i.tabPanel, children: d === "one-time" ? $ : null }),
206
- /* @__PURE__ */ t(s.Panel, { value: "monthly", className: i.tabPanel, children: d === "monthly" ? $ : null })
208
+ /* @__PURE__ */ t(s.Panel, { value: "one-time", className: i.tabPanel, children: c === "one-time" ? L : null }),
209
+ /* @__PURE__ */ t(s.Panel, { value: "monthly", className: i.tabPanel, children: c === "monthly" ? L : null })
207
210
  ]
208
211
  }
209
212
  ) });
210
213
  };
211
- function ae(e) {
214
+ function ne(e) {
212
215
  return `
213
216
  .${e.donor} {
214
217
  border-radius: 16px;
@@ -325,7 +328,7 @@ function ae(e) {
325
328
  justify-content: center;
326
329
  width: 300px;
327
330
  height: 44px;
328
- padding: 12px 16px;
331
+ padding: var(--ds-size-3, 12px) var(--ds-size-4, 16px);
329
332
  background-color: #ff5b24;
330
333
  border: none;
331
334
  border-radius: var(--ds-border-radius-xl, 12px);
@@ -368,15 +371,26 @@ function ae(e) {
368
371
  .${e.tabHeartIcon} {
369
372
  display: inline-flex;
370
373
  align-items: center;
371
- margin-right: 4px;
374
+ margin-right: var(--ds-size-1, 4px);
372
375
  vertical-align: middle;
373
376
  }
374
377
  .${e.tabHeartIcon} svg {
375
378
  width: 16px;
376
379
  height: 15px;
377
380
  }
381
+
382
+ /* Mobil: uten disse fikk en konsument som ikke importerer stilarket
383
+ skrivebordsbreddene på telefon — kortet låst til 344px på en 390px-skjerm.
384
+ Speiler @media-blokken i styles.module.css. */
385
+ @media (max-width: 480px) {
386
+ .${e.donor} { max-width: 100%; }
387
+ .${e.amountSection},
388
+ .${e.impactRow},
389
+ .${e.actionsSection} { width: 100%; }
390
+ .${e.vippsButton} { width: 100%; max-width: 300px; }
391
+ }
378
392
  `;
379
393
  }
380
394
  export {
381
- me as Donor
395
+ ue as Donor
382
396
  };
@@ -1,42 +1,42 @@
1
1
  "use client";
2
- const t = "_donor_xzqak_1", o = "_tabsWrapper_xzqak_14", a = "_content_xzqak_35", n = "_amountSection_xzqak_47", _ = "_amountLabel_xzqak_55", c = "_amountButtons_xzqak_64", s = "_customAmountField_xzqak_75", e = "_impactRow_xzqak_80", i = "_heartIcon_xzqak_88", p = "_impactText_xzqak_102", u = "_impactAmount_xzqak_112", m = "_actionsSection_xzqak_117", x = "_vippsButton_xzqak_127", k = "_vippsButtonLabel_xzqak_157", r = "_vippsLogo_xzqak_166", l = "_avtalegiroLink_xzqak_179", q = "_tabHeartIcon_xzqak_184", z = "_tabPanel_xzqak_214", b = {
2
+ const t = "_donor_5kh8b_1", o = "_tabsWrapper_5kh8b_14", n = "_content_5kh8b_35", a = "_amountSection_5kh8b_47", _ = "_amountLabel_5kh8b_55", c = "_amountButtons_5kh8b_64", s = "_customAmountField_5kh8b_75", e = "_impactRow_5kh8b_80", i = "_heartIcon_5kh8b_88", p = "_impactText_5kh8b_102", b = "_impactAmount_5kh8b_112", u = "_actionsSection_5kh8b_117", m = "_vippsButton_5kh8b_127", h = "_vippsButtonLabel_5kh8b_157", k = "_vippsLogo_5kh8b_166", r = "_avtalegiroLink_5kh8b_179", l = "_tabHeartIcon_5kh8b_184", v = "_tabPanel_5kh8b_214", L = {
3
3
  donor: t,
4
4
  tabsWrapper: o,
5
- content: a,
6
- amountSection: n,
5
+ content: n,
6
+ amountSection: a,
7
7
  amountLabel: _,
8
8
  amountButtons: c,
9
9
  customAmountField: s,
10
10
  impactRow: e,
11
11
  heartIcon: i,
12
12
  impactText: p,
13
- impactAmount: u,
14
- actionsSection: m,
15
- vippsButton: x,
16
- vippsButtonLabel: k,
17
- vippsLogo: r,
18
- avtalegiroLink: l,
19
- tabHeartIcon: q,
20
- tabPanel: z
13
+ impactAmount: b,
14
+ actionsSection: u,
15
+ vippsButton: m,
16
+ vippsButtonLabel: h,
17
+ vippsLogo: k,
18
+ avtalegiroLink: r,
19
+ tabHeartIcon: l,
20
+ tabPanel: v
21
21
  };
22
22
  export {
23
- m as actionsSection,
23
+ u as actionsSection,
24
24
  c as amountButtons,
25
25
  _ as amountLabel,
26
- n as amountSection,
27
- l as avtalegiroLink,
28
- a as content,
26
+ a as amountSection,
27
+ r as avtalegiroLink,
28
+ n as content,
29
29
  s as customAmountField,
30
- b as default,
30
+ L as default,
31
31
  t as donor,
32
32
  i as heartIcon,
33
- u as impactAmount,
33
+ b as impactAmount,
34
34
  e as impactRow,
35
35
  p as impactText,
36
- q as tabHeartIcon,
37
- z as tabPanel,
36
+ l as tabHeartIcon,
37
+ v as tabPanel,
38
38
  o as tabsWrapper,
39
- x as vippsButton,
40
- k as vippsButtonLabel,
41
- r as vippsLogo
39
+ m as vippsButton,
40
+ h as vippsButtonLabel,
41
+ k as vippsLogo
42
42
  };