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,115 +1,113 @@
1
1
  "use client";
2
- import { jsxs as S, jsx as g } from "react/jsx-runtime";
3
- import pe, { forwardRef as be, useEffect as O, useRef as P, useCallback as k, useState as me, useId as ve } from "react";
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 a from "./styles.module.css.js";
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 n = e.slice(0, 2), h = e.slice(2, 4), o = e.slice(4, 8);
9
- return e.length > 4 ? `${n}.${h}.${o}` : e.length > 2 ? `${n}.${h}` : e.length > 0 ? n : "";
10
- }, N = (e) => (e || "").replace(/\D/g, "").slice(0, 8), q = (e) => {
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 n = ge(x(e), "dd.MM.yyyy", /* @__PURE__ */ new Date());
13
- return xe(n);
12
+ const a = ge(x(e), "dd.MM.yyyy", /* @__PURE__ */ new Date());
13
+ return xe(a);
14
14
  }, ye = be(
15
- (e, n) => {
15
+ (e, a) => {
16
16
  const { t: h } = he();
17
- O(() => {
17
+ M(() => {
18
18
  const r = "rk-dateinput-inline-styles";
19
19
  if (typeof document > "u" || document.getElementById(r)) return;
20
- const t = Ie(a), m = document.createElement("style");
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: o,
24
+ label: s,
25
25
  suffixIcon: V,
26
- onSuffixClick: c,
27
- className: A,
28
- inputWrapperClassName: H,
29
- inputClassName: G,
26
+ onSuffixClick: u,
27
+ className: P,
28
+ inputWrapperClassName: q,
29
+ inputClassName: H,
30
30
  value: y,
31
- defaultValue: J,
31
+ defaultValue: A,
32
32
  onChange: I,
33
33
  onValidationChange: $,
34
- readOnly: K,
35
- placeholder: Q = "dd.mm.åååå",
36
- id: T,
37
- name: U,
38
- required: X,
34
+ readOnly: G,
35
+ placeholder: J = "dd.mm.åååå",
36
+ id: K,
37
+ name: Q,
38
+ required: T,
39
39
  disabled: w,
40
- onClick: Y,
41
- onFocus: Z,
40
+ onClick: U,
41
+ onFocus: X,
42
42
  onBlur: z,
43
- autoComplete: _ = "off",
44
- "aria-label": j,
45
- "aria-labelledby": W,
43
+ autoComplete: Y = "off",
44
+ "aria-label": Z,
45
+ "aria-labelledby": _,
46
46
  description: C,
47
- error: u,
47
+ error: c,
48
48
  "data-color": ee,
49
49
  "data-size": re,
50
50
  ...te
51
- } = e, B = y !== void 0, f = P(null);
51
+ } = e, B = y !== void 0, f = S(null);
52
52
  pe.useImperativeHandle(
53
- n,
53
+ a,
54
54
  () => f.current
55
55
  );
56
- const R = P(null), i = k(
56
+ const j = S(null), l = k(
57
57
  (r, t) => {
58
- r !== R.current && (R.current = r, $ == null || $(r, t));
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, E] = me(
65
- () => D(y ?? J)
64
+ ), [p, W] = me(
65
+ () => D(y ?? A)
66
66
  );
67
- O(() => {
67
+ M(() => {
68
68
  if (B) {
69
69
  const r = D(y);
70
- r !== p && (E(r), f.current && f.current.value !== r && (f.current.value = r));
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, s = N(t.value), d = x(s);
76
- let l = 0;
77
- const v = s.length;
78
- v <= 2 ? l = v : v <= 4 ? l = v + 1 : l = v + 2, l = Math.min(l, d.length), E(d), t.value = d, t.setSelectionRange(l, l), (d !== m || B) && (I == null || I(r, d));
79
- const fe = q(s);
80
- (s.length === 0 || s.length === 8) && i(s.length === 0 ? null : fe, d);
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, 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 ? i(null, "") : t.length < 8 ? i(!1, x(t)) : i(q(t), x(t)), z == null || z(r);
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, i]
89
- ), ne = [a.fieldset, A].filter(Boolean).join(" "), le = [
90
- a.inputWrapper,
91
- H,
92
- u ? a.inputWrapperError : ""
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
- G
95
- ].filter(Boolean).join(" "), se = [
96
- a.suffixButton,
97
- c ? a.suffixButtonInteractive : ""
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__ */ S(
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
- o && typeof o == "string" ? /* @__PURE__ */ g("label", { id: F, htmlFor: b, children: o }) : o,
111
- C && /* @__PURE__ */ g("p", { id: L, className: a.description, children: C }),
112
- /* @__PURE__ */ S("div", { className: le, children: [
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: K,
123
- placeholder: Q,
120
+ readOnly: G,
121
+ placeholder: J,
124
122
  id: b,
125
- name: U,
126
- required: X,
123
+ name: Q,
124
+ required: T,
127
125
  disabled: w,
128
- onClick: Y,
126
+ onClick: U,
129
127
  onChange: oe,
130
- onFocus: Z,
128
+ onFocus: X,
131
129
  onBlur: ae,
132
- autoComplete: _,
133
- "aria-label": j,
134
- "aria-labelledby": ue,
135
- "aria-describedby": ce,
136
- "aria-invalid": !!u,
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: se,
146
- onClick: w ? void 0 : c,
147
- tabIndex: c && !w ? 0 : -1,
148
- "aria-hidden": !c,
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": c ? h("dateInput.openDatePicker") : void 0,
148
+ "aria-label": u ? h("dateInput.openDatePicker") : void 0,
151
149
  children: V
152
150
  }
153
151
  )
154
152
  ] }),
155
- u && /* @__PURE__ */ g("p", { id: M, className: a.error, role: "alert", children: u })
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 = "_fieldset_1d1ez_2", r = "_description_1d1ez_14", e = "_error_1d1ez_21", n = "_inputWrapper_1d1ez_30", i = "_inputWrapperError_1d1ez_42", o = "_suffixButton_1d1ez_80", s = "_suffixButtonInteractive_1d1ez_100", p = {
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,