rk-designsystem 1.3.4 → 1.4.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.
- package/README.md +9 -3
- package/dist/components/Carousel/index.js +215 -166
- package/dist/components/Carousel/styles.module.css.js +35 -31
- package/dist/components/DateInput/index.js +85 -87
- package/dist/components/DateInput/styles.module.css.js +1 -1
- package/dist/components/DatePicker/index.js +197 -175
- package/dist/components/DatePicker/styles.module.css.js +20 -20
- package/dist/components/Donor/index.js +71 -68
- package/dist/components/Donor/styles.module.css.js +22 -22
- package/dist/components/Footer/index.js +88 -86
- package/dist/components/GraphicElement/index.js +3 -3
- package/dist/components/Header/index.js +277 -242
- package/dist/components/Header/styles.module.css.js +49 -49
- package/dist/context/LanguageContext.js +17 -14
- package/dist/index.d.ts +44 -5
- package/dist/rk-designsystem.css +1 -1
- package/dist/translations/index.js +10 -2
- package/package.json +18 -26
- package/dist/utils/search-index.js +0 -106
|
@@ -1,115 +1,113 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import pe, { forwardRef as be, useEffect as
|
|
2
|
+
import { jsxs as L, jsx as g } from "react/jsx-runtime";
|
|
3
|
+
import pe, { forwardRef as be, useEffect as M, useRef as S, useCallback as k, useState as me, useId as ve } from "react";
|
|
4
4
|
import { parse as ge, isValid as xe } from "date-fns";
|
|
5
|
-
import
|
|
5
|
+
import o from "./styles.module.css.js";
|
|
6
6
|
import { useLanguageOptional as he } from "../../context/LanguageContext.js";
|
|
7
7
|
const x = (e) => {
|
|
8
|
-
const
|
|
9
|
-
return e.length > 4 ? `${
|
|
10
|
-
}, N = (e) => (e || "").replace(/\D/g, "").slice(0, 8),
|
|
8
|
+
const a = e.slice(0, 2), h = e.slice(2, 4), s = e.slice(4, 8);
|
|
9
|
+
return e.length > 4 ? `${a}.${h}.${s}` : e.length > 2 ? `${a}.${h}` : e.length > 0 ? a : "";
|
|
10
|
+
}, N = (e) => (e || "").replace(/\D/g, "").slice(0, 8), O = (e) => {
|
|
11
11
|
if (e.length < 8) return null;
|
|
12
|
-
const
|
|
13
|
-
return xe(
|
|
12
|
+
const a = ge(x(e), "dd.MM.yyyy", /* @__PURE__ */ new Date());
|
|
13
|
+
return xe(a);
|
|
14
14
|
}, ye = be(
|
|
15
|
-
(e,
|
|
15
|
+
(e, a) => {
|
|
16
16
|
const { t: h } = he();
|
|
17
|
-
|
|
17
|
+
M(() => {
|
|
18
18
|
const r = "rk-dateinput-inline-styles";
|
|
19
19
|
if (typeof document > "u" || document.getElementById(r)) return;
|
|
20
|
-
const t = Ie(
|
|
20
|
+
const t = Ie(o), m = document.createElement("style");
|
|
21
21
|
m.id = r, m.textContent = t, document.head.prepend(m);
|
|
22
22
|
}, []);
|
|
23
23
|
const {
|
|
24
|
-
label:
|
|
24
|
+
label: s,
|
|
25
25
|
suffixIcon: V,
|
|
26
|
-
onSuffixClick:
|
|
27
|
-
className:
|
|
28
|
-
inputWrapperClassName:
|
|
29
|
-
inputClassName:
|
|
26
|
+
onSuffixClick: u,
|
|
27
|
+
className: P,
|
|
28
|
+
inputWrapperClassName: q,
|
|
29
|
+
inputClassName: H,
|
|
30
30
|
value: y,
|
|
31
|
-
defaultValue:
|
|
31
|
+
defaultValue: A,
|
|
32
32
|
onChange: I,
|
|
33
33
|
onValidationChange: $,
|
|
34
|
-
readOnly:
|
|
35
|
-
placeholder:
|
|
36
|
-
id:
|
|
37
|
-
name:
|
|
38
|
-
required:
|
|
34
|
+
readOnly: G,
|
|
35
|
+
placeholder: J = "dd.mm.åååå",
|
|
36
|
+
id: K,
|
|
37
|
+
name: Q,
|
|
38
|
+
required: T,
|
|
39
39
|
disabled: w,
|
|
40
|
-
onClick:
|
|
41
|
-
onFocus:
|
|
40
|
+
onClick: U,
|
|
41
|
+
onFocus: X,
|
|
42
42
|
onBlur: z,
|
|
43
|
-
autoComplete:
|
|
44
|
-
"aria-label":
|
|
45
|
-
"aria-labelledby":
|
|
43
|
+
autoComplete: Y = "off",
|
|
44
|
+
"aria-label": Z,
|
|
45
|
+
"aria-labelledby": _,
|
|
46
46
|
description: C,
|
|
47
|
-
error:
|
|
47
|
+
error: c,
|
|
48
48
|
"data-color": ee,
|
|
49
49
|
"data-size": re,
|
|
50
50
|
...te
|
|
51
|
-
} = e, B = y !== void 0, f =
|
|
51
|
+
} = e, B = y !== void 0, f = S(null);
|
|
52
52
|
pe.useImperativeHandle(
|
|
53
|
-
|
|
53
|
+
a,
|
|
54
54
|
() => f.current
|
|
55
55
|
);
|
|
56
|
-
const
|
|
56
|
+
const j = S(null), l = k(
|
|
57
57
|
(r, t) => {
|
|
58
|
-
r !==
|
|
58
|
+
r !== j.current && (j.current = r, $ == null || $(r, t));
|
|
59
59
|
},
|
|
60
60
|
[$]
|
|
61
61
|
), D = k(
|
|
62
62
|
(r) => x(N(r)),
|
|
63
63
|
[]
|
|
64
|
-
), [p,
|
|
65
|
-
() => D(y ??
|
|
64
|
+
), [p, W] = me(
|
|
65
|
+
() => D(y ?? A)
|
|
66
66
|
);
|
|
67
|
-
|
|
67
|
+
M(() => {
|
|
68
68
|
if (B) {
|
|
69
69
|
const r = D(y);
|
|
70
|
-
r !== p && (
|
|
70
|
+
r !== p && (W(r), f.current && f.current.value !== r && (f.current.value = r));
|
|
71
71
|
}
|
|
72
72
|
}, [y, B, p, D]);
|
|
73
73
|
const oe = k(
|
|
74
74
|
(r) => {
|
|
75
|
-
const t = r.target, m = p,
|
|
76
|
-
let
|
|
77
|
-
const v =
|
|
78
|
-
v <= 2 ?
|
|
79
|
-
const fe =
|
|
80
|
-
(
|
|
75
|
+
const t = r.target, m = p, i = N(t.value), d = x(i);
|
|
76
|
+
let n = 0;
|
|
77
|
+
const v = i.length;
|
|
78
|
+
v <= 2 ? n = v : v <= 4 ? n = v + 1 : n = v + 2, n = Math.min(n, d.length), W(d), t.value = d, t.setSelectionRange(n, n), (d !== m || B) && (I == null || I(r, d));
|
|
79
|
+
const fe = O(i);
|
|
80
|
+
(i.length === 0 || i.length === 8) && l(i.length === 0 ? null : fe, d);
|
|
81
81
|
},
|
|
82
|
-
[p, B, I,
|
|
82
|
+
[p, B, I, l]
|
|
83
83
|
), ae = k(
|
|
84
84
|
(r) => {
|
|
85
85
|
const t = N(r.target.value);
|
|
86
|
-
t.length === 0 ?
|
|
86
|
+
t.length === 0 ? l(null, "") : t.length < 8 ? l(!1, x(t)) : l(O(t), x(t)), z == null || z(r);
|
|
87
87
|
},
|
|
88
|
-
[z,
|
|
89
|
-
), ne = [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
[z, l]
|
|
89
|
+
), ne = [o.fieldset, P].filter(Boolean).join(" "), le = [
|
|
90
|
+
o.inputWrapper,
|
|
91
|
+
q,
|
|
92
|
+
c ? o.inputWrapperError : ""
|
|
93
93
|
].filter(Boolean).join(" "), ie = [
|
|
94
|
-
|
|
95
|
-
].filter(Boolean).join(" "),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
].filter(Boolean).join(" ");
|
|
99
|
-
!o && !j && !W && console.warn("Advarsel: DateInput-komponenten bør ha label, aria-label, eller aria-labelledby for tilgjengelighet.");
|
|
100
|
-
const de = ve(), b = T ?? `dateinput${de}`, F = o && typeof o == "string" ? `${b}-label` : void 0, L = C ? `${b}-desc` : void 0, M = u ? `${b}-err` : void 0, ce = [L, M].filter(Boolean).join(" ") || void 0, ue = W ?? F;
|
|
94
|
+
H
|
|
95
|
+
].filter(Boolean).join(" "), de = [
|
|
96
|
+
o.suffixButton,
|
|
97
|
+
u ? o.suffixButtonInteractive : ""
|
|
98
|
+
].filter(Boolean).join(" "), se = ve(), b = K ?? `dateinput${se}`, R = s ? `${b}-label` : void 0, E = C ? `${b}-desc` : void 0, F = c ? `${b}-err` : void 0, ue = [E, F].filter(Boolean).join(" ") || void 0, ce = _ ?? R;
|
|
101
99
|
return (
|
|
102
100
|
// --- Bruk data-color og data-size på den ytre wrapperen ---
|
|
103
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ L(
|
|
104
102
|
"div",
|
|
105
103
|
{
|
|
106
104
|
className: ne,
|
|
107
105
|
"data-color": ee,
|
|
108
106
|
"data-size": re,
|
|
109
107
|
children: [
|
|
110
|
-
|
|
111
|
-
C && /* @__PURE__ */ g("p", { id:
|
|
112
|
-
/* @__PURE__ */
|
|
108
|
+
s ? /* @__PURE__ */ g("label", { id: R, htmlFor: b, children: s }) : null,
|
|
109
|
+
C && /* @__PURE__ */ g("p", { id: E, className: o.description, children: C }),
|
|
110
|
+
/* @__PURE__ */ L("div", { className: le, children: [
|
|
113
111
|
/* @__PURE__ */ g(
|
|
114
112
|
"input",
|
|
115
113
|
{
|
|
@@ -119,21 +117,21 @@ const x = (e) => {
|
|
|
119
117
|
pattern: "\\d{2}\\.\\d{2}\\.\\d{4}",
|
|
120
118
|
maxLength: 10,
|
|
121
119
|
value: p,
|
|
122
|
-
readOnly:
|
|
123
|
-
placeholder:
|
|
120
|
+
readOnly: G,
|
|
121
|
+
placeholder: J,
|
|
124
122
|
id: b,
|
|
125
|
-
name:
|
|
126
|
-
required:
|
|
123
|
+
name: Q,
|
|
124
|
+
required: T,
|
|
127
125
|
disabled: w,
|
|
128
|
-
onClick:
|
|
126
|
+
onClick: U,
|
|
129
127
|
onChange: oe,
|
|
130
|
-
onFocus:
|
|
128
|
+
onFocus: X,
|
|
131
129
|
onBlur: ae,
|
|
132
|
-
autoComplete:
|
|
133
|
-
"aria-label":
|
|
134
|
-
"aria-labelledby":
|
|
135
|
-
"aria-describedby":
|
|
136
|
-
"aria-invalid": !!
|
|
130
|
+
autoComplete: Y,
|
|
131
|
+
"aria-label": Z,
|
|
132
|
+
"aria-labelledby": ce,
|
|
133
|
+
"aria-describedby": ue,
|
|
134
|
+
"aria-invalid": !!c,
|
|
137
135
|
className: ie,
|
|
138
136
|
...te
|
|
139
137
|
}
|
|
@@ -142,17 +140,17 @@ const x = (e) => {
|
|
|
142
140
|
"button",
|
|
143
141
|
{
|
|
144
142
|
type: "button",
|
|
145
|
-
className:
|
|
146
|
-
onClick: w ? void 0 :
|
|
147
|
-
tabIndex:
|
|
148
|
-
"aria-hidden": !
|
|
143
|
+
className: de,
|
|
144
|
+
onClick: w ? void 0 : u,
|
|
145
|
+
tabIndex: u && !w ? 0 : -1,
|
|
146
|
+
"aria-hidden": !u,
|
|
149
147
|
disabled: w,
|
|
150
|
-
"aria-label":
|
|
148
|
+
"aria-label": u ? h("dateInput.openDatePicker") : void 0,
|
|
151
149
|
children: V
|
|
152
150
|
}
|
|
153
151
|
)
|
|
154
152
|
] }),
|
|
155
|
-
|
|
153
|
+
c && /* @__PURE__ */ g("p", { id: F, className: o.error, role: "alert", children: c })
|
|
156
154
|
]
|
|
157
155
|
}
|
|
158
156
|
)
|
|
@@ -169,11 +167,11 @@ function Ie(e) {
|
|
|
169
167
|
display: block;
|
|
170
168
|
margin-bottom: var(--ds-size-1, 4px);
|
|
171
169
|
font-weight: var(--ds-font-weight-medium, 500);
|
|
172
|
-
color: var(--ds-color-text-default, #2b2b2b);
|
|
170
|
+
color: var(--ds-color-neutral-text-default, #2b2b2b);
|
|
173
171
|
}
|
|
174
172
|
.${e.description} {
|
|
175
173
|
font-size: var(--ds-font-size-2, 14px);
|
|
176
|
-
color: var(--ds-color-text-subtle, #5d5d5d);
|
|
174
|
+
color: var(--ds-color-neutral-text-subtle, #5d5d5d);
|
|
177
175
|
margin-top: var(--ds-size-1, 4px);
|
|
178
176
|
margin-bottom: var(--ds-size-2, 8px);
|
|
179
177
|
}
|
|
@@ -187,7 +185,7 @@ function Ie(e) {
|
|
|
187
185
|
align-items: stretch;
|
|
188
186
|
width: 100%;
|
|
189
187
|
position: relative;
|
|
190
|
-
border: var(--ds-border-width-default, 1px) solid var(--ds-color-border-default, #797979);
|
|
188
|
+
border: var(--ds-border-width-default, 1px) solid var(--ds-color-neutral-border-default, #797979);
|
|
191
189
|
border-radius: var(--ds-border-radius-md, 4px);
|
|
192
190
|
overflow: hidden;
|
|
193
191
|
transition: border-color 0.1s ease-out, outline 0.1s ease-out;
|
|
@@ -204,8 +202,8 @@ function Ie(e) {
|
|
|
204
202
|
flex-grow: 1;
|
|
205
203
|
width: auto;
|
|
206
204
|
min-width: 0;
|
|
207
|
-
background-color: var(--ds-color-background-default, #fff);
|
|
208
|
-
color: var(--ds-color-text-default, #2b2b2b);
|
|
205
|
+
background-color: var(--ds-color-neutral-background-default, #fff);
|
|
206
|
+
color: var(--ds-color-neutral-text-default, #2b2b2b);
|
|
209
207
|
border: none;
|
|
210
208
|
border-radius: 0;
|
|
211
209
|
outline: none;
|
|
@@ -230,9 +228,9 @@ function Ie(e) {
|
|
|
230
228
|
margin: 0;
|
|
231
229
|
border: none;
|
|
232
230
|
border-radius: 0;
|
|
233
|
-
border-left: var(--ds-border-width-default, 1px) solid var(--ds-color-border-default, #797979);
|
|
234
|
-
background-color: var(--ds-color-surface-tinted, #e8e8e8);
|
|
235
|
-
color: var(--ds-color-text-subtle, #5d5d5d);
|
|
231
|
+
border-left: var(--ds-border-width-default, 1px) solid var(--ds-color-neutral-border-default, #797979);
|
|
232
|
+
background-color: var(--ds-color-neutral-surface-tinted, #e8e8e8);
|
|
233
|
+
color: var(--ds-color-neutral-text-subtle, #5d5d5d);
|
|
236
234
|
font-size: 1.25rem;
|
|
237
235
|
box-sizing: border-box;
|
|
238
236
|
cursor: default;
|
|
@@ -242,8 +240,8 @@ function Ie(e) {
|
|
|
242
240
|
cursor: pointer;
|
|
243
241
|
}
|
|
244
242
|
.${e.suffixButtonInteractive}:hover:not(:disabled) {
|
|
245
|
-
color: var(--ds-color-text-default, #2b2b2b);
|
|
246
|
-
background-color: var(--ds-color-surface-hover, #dadada);
|
|
243
|
+
color: var(--ds-color-neutral-text-default, #2b2b2b);
|
|
244
|
+
background-color: var(--ds-color-neutral-surface-hover, #dadada);
|
|
247
245
|
}
|
|
248
246
|
.${e.suffixButton}:disabled {
|
|
249
247
|
opacity: var(--ds-opacity-disabled, 0.3);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const t = "
|
|
2
|
+
const t = "_fieldset_1b5hv_7", r = "_description_1b5hv_19", e = "_error_1b5hv_26", n = "_inputWrapper_1b5hv_35", i = "_inputWrapperError_1b5hv_47", o = "_suffixButton_1b5hv_85", s = "_suffixButtonInteractive_1b5hv_105", p = {
|
|
3
3
|
fieldset: t,
|
|
4
4
|
description: r,
|
|
5
5
|
error: e,
|