rk-designsystem 1.3.0 → 1.3.2
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 +14 -7
- package/dist/assets/images/ChevronLeftIcon.js +31 -0
- package/dist/assets/images/ChevronRightIcon.js +31 -0
- package/dist/components/Alert/index.js +16 -0
- package/dist/components/Avatar/index.js +9 -0
- package/dist/components/Badge/index.js +11 -0
- package/dist/components/Breadcrumbs/index.js +9 -0
- package/dist/components/Button/index.js +11 -0
- package/dist/components/Card/index.js +8 -0
- package/dist/components/Carousel/index.js +379 -0
- package/dist/components/Carousel/styles.module.css.js +38 -0
- package/dist/components/Checkbox/index.js +10 -0
- package/dist/components/Chip/index.js +6 -0
- package/dist/components/DateInput/index.js +258 -0
- package/dist/components/DateInput/styles.module.css.js +20 -0
- package/dist/components/DatePicker/index.js +360 -0
- package/dist/components/DatePicker/styles.module.css.js +30 -0
- package/dist/components/Details/index.js +6 -0
- package/dist/components/Dialog/index.js +6 -0
- package/dist/components/Divider/index.js +6 -0
- package/dist/components/Donor/index.js +382 -0
- package/dist/components/Donor/styles.module.css.js +42 -0
- package/dist/components/Dropdown/index.js +12 -0
- package/dist/components/ErrorSummary/index.js +6 -0
- package/dist/components/Field/index.js +10 -0
- package/dist/components/Fieldset/index.js +6 -0
- package/dist/components/Footer/index.js +722 -0
- package/dist/components/Footer/styles.module.css.js +138 -0
- package/dist/components/GraphicElement/index.js +317 -0
- package/dist/components/GraphicElement/styles.module.css.js +16 -0
- package/dist/components/Header/index.js +677 -0
- package/dist/components/Header/styles.module.css.js +114 -0
- package/dist/components/Heading/index.js +9 -0
- package/dist/components/Input/index.js +7 -0
- package/dist/components/Label/index.js +9 -0
- package/dist/components/Link/index.js +6 -0
- package/dist/components/List/index.js +6 -0
- package/dist/components/Pagination/index.js +11 -0
- package/dist/components/Paragraph/index.js +11 -0
- package/dist/components/Popover/index.js +6 -0
- package/dist/components/Radio/index.js +7 -0
- package/dist/components/Search/index.js +10 -0
- package/dist/components/Select/index.js +6 -0
- package/dist/components/SkeletonLoader/index.js +6 -0
- package/dist/components/SkipLink/index.js +6 -0
- package/dist/components/SpinnerLoader/index.js +6 -0
- package/dist/components/Suggestion/index.js +7 -0
- package/dist/components/Switch/index.js +6 -0
- package/dist/components/Table/index.js +6 -0
- package/dist/components/Tabs/index.js +6 -0
- package/dist/components/Tag/index.js +14 -0
- package/dist/components/Textarea/index.js +6 -0
- package/dist/components/Textfield/index.js +6 -0
- package/dist/components/ToggleGroup/index.js +6 -0
- package/dist/components/Tooltip/index.js +6 -0
- package/dist/components/ValidationMessage/index.js +9 -0
- package/dist/context/LanguageContext.js +91 -0
- package/dist/index.d.ts +170 -147
- package/dist/index.js +118 -0
- package/dist/rk-designsystem.css +1 -1
- package/dist/{componentlibrary.es.js → translations/index.js} +267 -3904
- package/dist/utils/search-index.js +106 -0
- package/package.json +21 -35
- package/dist/componentlibrary.umd.js +0 -1266
|
@@ -0,0 +1,258 @@
|
|
|
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";
|
|
4
|
+
import { parse as ge, isValid as xe } from "date-fns";
|
|
5
|
+
import a from "./styles.module.css.js";
|
|
6
|
+
import { useLanguageOptional as he } from "../../context/LanguageContext.js";
|
|
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) => {
|
|
11
|
+
if (e.length < 8) return null;
|
|
12
|
+
const n = ge(x(e), "dd.MM.yyyy", /* @__PURE__ */ new Date());
|
|
13
|
+
return xe(n);
|
|
14
|
+
}, ye = be(
|
|
15
|
+
(e, n) => {
|
|
16
|
+
const { t: h } = he();
|
|
17
|
+
O(() => {
|
|
18
|
+
const r = "rk-dateinput-inline-styles";
|
|
19
|
+
if (typeof document > "u" || document.getElementById(r)) return;
|
|
20
|
+
const t = Ie(a), m = document.createElement("style");
|
|
21
|
+
m.id = r, m.textContent = t, document.head.prepend(m);
|
|
22
|
+
}, []);
|
|
23
|
+
const {
|
|
24
|
+
label: o,
|
|
25
|
+
suffixIcon: V,
|
|
26
|
+
onSuffixClick: c,
|
|
27
|
+
className: A,
|
|
28
|
+
inputWrapperClassName: H,
|
|
29
|
+
inputClassName: G,
|
|
30
|
+
value: y,
|
|
31
|
+
defaultValue: J,
|
|
32
|
+
onChange: I,
|
|
33
|
+
onValidationChange: $,
|
|
34
|
+
readOnly: K,
|
|
35
|
+
placeholder: Q = "dd.mm.åååå",
|
|
36
|
+
id: T,
|
|
37
|
+
name: U,
|
|
38
|
+
required: X,
|
|
39
|
+
disabled: w,
|
|
40
|
+
onClick: Y,
|
|
41
|
+
onFocus: Z,
|
|
42
|
+
onBlur: z,
|
|
43
|
+
autoComplete: _ = "off",
|
|
44
|
+
"aria-label": j,
|
|
45
|
+
"aria-labelledby": W,
|
|
46
|
+
description: C,
|
|
47
|
+
error: u,
|
|
48
|
+
"data-color": ee,
|
|
49
|
+
"data-size": re,
|
|
50
|
+
...te
|
|
51
|
+
} = e, B = y !== void 0, f = P(null);
|
|
52
|
+
pe.useImperativeHandle(
|
|
53
|
+
n,
|
|
54
|
+
() => f.current
|
|
55
|
+
);
|
|
56
|
+
const R = P(null), i = k(
|
|
57
|
+
(r, t) => {
|
|
58
|
+
r !== R.current && (R.current = r, $ == null || $(r, t));
|
|
59
|
+
},
|
|
60
|
+
[$]
|
|
61
|
+
), D = k(
|
|
62
|
+
(r) => x(N(r)),
|
|
63
|
+
[]
|
|
64
|
+
), [p, E] = me(
|
|
65
|
+
() => D(y ?? J)
|
|
66
|
+
);
|
|
67
|
+
O(() => {
|
|
68
|
+
if (B) {
|
|
69
|
+
const r = D(y);
|
|
70
|
+
r !== p && (E(r), f.current && f.current.value !== r && (f.current.value = r));
|
|
71
|
+
}
|
|
72
|
+
}, [y, B, p, D]);
|
|
73
|
+
const oe = k(
|
|
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);
|
|
81
|
+
},
|
|
82
|
+
[p, B, I, i]
|
|
83
|
+
), ae = k(
|
|
84
|
+
(r) => {
|
|
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);
|
|
87
|
+
},
|
|
88
|
+
[z, i]
|
|
89
|
+
), ne = [a.fieldset, A].filter(Boolean).join(" "), le = [
|
|
90
|
+
a.inputWrapper,
|
|
91
|
+
H,
|
|
92
|
+
u ? a.inputWrapperError : ""
|
|
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;
|
|
101
|
+
return (
|
|
102
|
+
// --- Bruk data-color og data-size på den ytre wrapperen ---
|
|
103
|
+
/* @__PURE__ */ S(
|
|
104
|
+
"div",
|
|
105
|
+
{
|
|
106
|
+
className: ne,
|
|
107
|
+
"data-color": ee,
|
|
108
|
+
"data-size": re,
|
|
109
|
+
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: [
|
|
113
|
+
/* @__PURE__ */ g(
|
|
114
|
+
"input",
|
|
115
|
+
{
|
|
116
|
+
ref: f,
|
|
117
|
+
type: "text",
|
|
118
|
+
inputMode: "numeric",
|
|
119
|
+
pattern: "\\d{2}\\.\\d{2}\\.\\d{4}",
|
|
120
|
+
maxLength: 10,
|
|
121
|
+
value: p,
|
|
122
|
+
readOnly: K,
|
|
123
|
+
placeholder: Q,
|
|
124
|
+
id: b,
|
|
125
|
+
name: U,
|
|
126
|
+
required: X,
|
|
127
|
+
disabled: w,
|
|
128
|
+
onClick: Y,
|
|
129
|
+
onChange: oe,
|
|
130
|
+
onFocus: Z,
|
|
131
|
+
onBlur: ae,
|
|
132
|
+
autoComplete: _,
|
|
133
|
+
"aria-label": j,
|
|
134
|
+
"aria-labelledby": ue,
|
|
135
|
+
"aria-describedby": ce,
|
|
136
|
+
"aria-invalid": !!u,
|
|
137
|
+
className: ie,
|
|
138
|
+
...te
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
V && /* @__PURE__ */ g(
|
|
142
|
+
"button",
|
|
143
|
+
{
|
|
144
|
+
type: "button",
|
|
145
|
+
className: se,
|
|
146
|
+
onClick: w ? void 0 : c,
|
|
147
|
+
tabIndex: c && !w ? 0 : -1,
|
|
148
|
+
"aria-hidden": !c,
|
|
149
|
+
disabled: w,
|
|
150
|
+
"aria-label": c ? h("dateInput.openDatePicker") : void 0,
|
|
151
|
+
children: V
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
] }),
|
|
155
|
+
u && /* @__PURE__ */ g("p", { id: M, className: a.error, role: "alert", children: u })
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
ye.displayName = "DateInput";
|
|
163
|
+
function Ie(e) {
|
|
164
|
+
return `
|
|
165
|
+
.${e.fieldset} {
|
|
166
|
+
margin-bottom: var(--ds-size-4, 16px);
|
|
167
|
+
}
|
|
168
|
+
.${e.fieldset} label {
|
|
169
|
+
display: block;
|
|
170
|
+
margin-bottom: var(--ds-size-1, 4px);
|
|
171
|
+
font-weight: var(--ds-font-weight-medium, 500);
|
|
172
|
+
color: var(--ds-color-text-default, #2b2b2b);
|
|
173
|
+
}
|
|
174
|
+
.${e.description} {
|
|
175
|
+
font-size: var(--ds-font-size-2, 14px);
|
|
176
|
+
color: var(--ds-color-text-subtle, #5d5d5d);
|
|
177
|
+
margin-top: var(--ds-size-1, 4px);
|
|
178
|
+
margin-bottom: var(--ds-size-2, 8px);
|
|
179
|
+
}
|
|
180
|
+
.${e.error} {
|
|
181
|
+
font-size: var(--ds-font-size-2, 14px);
|
|
182
|
+
color: var(--ds-color-danger-text-default, #c30000);
|
|
183
|
+
margin-top: var(--ds-size-1, 4px);
|
|
184
|
+
}
|
|
185
|
+
.${e.inputWrapper} {
|
|
186
|
+
display: flex;
|
|
187
|
+
align-items: stretch;
|
|
188
|
+
width: 100%;
|
|
189
|
+
position: relative;
|
|
190
|
+
border: var(--ds-border-width-default, 1px) solid var(--ds-color-border-default, #797979);
|
|
191
|
+
border-radius: var(--ds-border-radius-md, 4px);
|
|
192
|
+
overflow: hidden;
|
|
193
|
+
transition: border-color 0.1s ease-out, outline 0.1s ease-out;
|
|
194
|
+
}
|
|
195
|
+
.${e.inputWrapperError} {
|
|
196
|
+
border-color: var(--ds-color-danger-border-default, #c30000);
|
|
197
|
+
}
|
|
198
|
+
.${e.inputWrapper}:focus-within {
|
|
199
|
+
outline: var(--ds-border-width-focus, 3px) solid var(--ds-color-focus-outer, #2B2B2B);
|
|
200
|
+
outline-offset: var(--ds-border-width-focus, 2px);
|
|
201
|
+
}
|
|
202
|
+
.${e.inputWrapper} input {
|
|
203
|
+
box-sizing: border-box;
|
|
204
|
+
flex-grow: 1;
|
|
205
|
+
width: auto;
|
|
206
|
+
min-width: 0;
|
|
207
|
+
background-color: var(--ds-color-background-default, #fff);
|
|
208
|
+
color: var(--ds-color-text-default, #2b2b2b);
|
|
209
|
+
border: none;
|
|
210
|
+
border-radius: 0;
|
|
211
|
+
outline: none;
|
|
212
|
+
padding: var(--ds-size-2, 8px) var(--ds-size-3, 12px);
|
|
213
|
+
font-family: inherit;
|
|
214
|
+
font-size: inherit;
|
|
215
|
+
appearance: none;
|
|
216
|
+
-webkit-appearance: none;
|
|
217
|
+
}
|
|
218
|
+
.${e.inputWrapper} input:disabled {
|
|
219
|
+
opacity: var(--ds-opacity-disabled, 0.5);
|
|
220
|
+
cursor: not-allowed;
|
|
221
|
+
background-color: var(--ds-color-neutral-surface-tinted, #f0f0f0);
|
|
222
|
+
color: var(--ds-color-neutral-text-subtle, #5d5d5d);
|
|
223
|
+
}
|
|
224
|
+
.${e.suffixButton} {
|
|
225
|
+
display: inline-flex;
|
|
226
|
+
align-items: center;
|
|
227
|
+
justify-content: center;
|
|
228
|
+
flex-shrink: 0;
|
|
229
|
+
padding: 0 var(--ds-size-3, 12px);
|
|
230
|
+
margin: 0;
|
|
231
|
+
border: none;
|
|
232
|
+
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);
|
|
236
|
+
font-size: 1.25rem;
|
|
237
|
+
box-sizing: border-box;
|
|
238
|
+
cursor: default;
|
|
239
|
+
transition: background-color 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
|
|
240
|
+
}
|
|
241
|
+
.${e.suffixButtonInteractive} {
|
|
242
|
+
cursor: pointer;
|
|
243
|
+
}
|
|
244
|
+
.${e.suffixButtonInteractive}:hover:not(:disabled) {
|
|
245
|
+
color: var(--ds-color-text-default, #2b2b2b);
|
|
246
|
+
background-color: var(--ds-color-surface-hover, #dadada);
|
|
247
|
+
}
|
|
248
|
+
.${e.suffixButton}:disabled {
|
|
249
|
+
opacity: var(--ds-opacity-disabled, 0.3);
|
|
250
|
+
cursor: not-allowed;
|
|
251
|
+
background-color: var(--ds-color-neutral-surface-tinted, #e8e8e8);
|
|
252
|
+
border-left-color: var(--ds-color-neutral-border-default, #797979);
|
|
253
|
+
}
|
|
254
|
+
`;
|
|
255
|
+
}
|
|
256
|
+
export {
|
|
257
|
+
ye as DateInput
|
|
258
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
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 = {
|
|
3
|
+
fieldset: t,
|
|
4
|
+
description: r,
|
|
5
|
+
error: e,
|
|
6
|
+
inputWrapper: n,
|
|
7
|
+
inputWrapperError: i,
|
|
8
|
+
suffixButton: o,
|
|
9
|
+
suffixButtonInteractive: s
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
p as default,
|
|
13
|
+
r as description,
|
|
14
|
+
e as error,
|
|
15
|
+
t as fieldset,
|
|
16
|
+
n as inputWrapper,
|
|
17
|
+
i as inputWrapperError,
|
|
18
|
+
o as suffixButton,
|
|
19
|
+
s as suffixButtonInteractive
|
|
20
|
+
};
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as y, jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect as N, useState as B, useRef as R, useMemo as D, useCallback as b, useId as te } from "react";
|
|
4
|
+
import { Button as A } from "@digdir/designsystemet-react";
|
|
5
|
+
import { startOfMonth as f, isValid as w, isSameMonth as C, format as u, startOfWeek as I, addDays as g, subMonths as S, addMonths as W, endOfWeek as L, isSameDay as F, isToday as re, endOfMonth as oe, eachDayOfInterval as ae, getDaysInMonth as ne, setDate as ie } from "date-fns";
|
|
6
|
+
import { nb as d } from "date-fns/locale";
|
|
7
|
+
import { ChevronLeftIcon as se } from "../../assets/images/ChevronLeftIcon.js";
|
|
8
|
+
import { ChevronRightIcon as de } from "../../assets/images/ChevronRightIcon.js";
|
|
9
|
+
import n from "./styles.module.css.js";
|
|
10
|
+
import { useLanguageOptional as le } from "../../context/LanguageContext.js";
|
|
11
|
+
const ce = (t) => {
|
|
12
|
+
const o = f(t), l = I(o, { locale: d }), z = L(oe(t), { locale: d });
|
|
13
|
+
return ae({ start: l, end: z });
|
|
14
|
+
}, H = (t) => t && t.charAt(0).toUpperCase() + t.slice(1), v = (t, o) => {
|
|
15
|
+
const l = Math.min(t.getDate(), ne(o));
|
|
16
|
+
return ie(f(o), l);
|
|
17
|
+
}, ue = ({
|
|
18
|
+
initialDate: t = /* @__PURE__ */ new Date(),
|
|
19
|
+
selectedDate: o = null,
|
|
20
|
+
onDateSelect: l,
|
|
21
|
+
"data-color": z,
|
|
22
|
+
"data-size": Y
|
|
23
|
+
}) => {
|
|
24
|
+
const { t: E } = le();
|
|
25
|
+
N(() => {
|
|
26
|
+
const r = "rk-datepicker-inline-styles";
|
|
27
|
+
if (typeof document > "u" || document.getElementById(r)) return;
|
|
28
|
+
const e = fe(n), a = document.createElement("style");
|
|
29
|
+
a.id = r, a.textContent = e, document.head.prepend(a);
|
|
30
|
+
}, []);
|
|
31
|
+
const [c, x] = B(
|
|
32
|
+
f(o && w(o) ? o : t)
|
|
33
|
+
), [h, p] = B(
|
|
34
|
+
() => o && w(o) ? o : t
|
|
35
|
+
), P = R(null), $ = R(!1);
|
|
36
|
+
N(() => {
|
|
37
|
+
if (o && w(o)) {
|
|
38
|
+
p(o);
|
|
39
|
+
const r = f(o);
|
|
40
|
+
x(
|
|
41
|
+
(e) => C(r, e) ? e : r
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}, [o]), N(() => {
|
|
45
|
+
var e;
|
|
46
|
+
if (!$.current) return;
|
|
47
|
+
$.current = !1;
|
|
48
|
+
const r = (e = P.current) == null ? void 0 : e.querySelector(
|
|
49
|
+
`[data-date="${u(h, "yyyy-MM-dd")}"]`
|
|
50
|
+
);
|
|
51
|
+
r == null || r.focus();
|
|
52
|
+
}, [h, c]);
|
|
53
|
+
const M = D(
|
|
54
|
+
() => ce(c),
|
|
55
|
+
[c]
|
|
56
|
+
), U = D(() => {
|
|
57
|
+
const r = [];
|
|
58
|
+
for (let e = 0; e < M.length; e += 7)
|
|
59
|
+
r.push(M.slice(e, e + 7));
|
|
60
|
+
return r;
|
|
61
|
+
}, [M]), K = D(() => {
|
|
62
|
+
const r = I(/* @__PURE__ */ new Date(), { locale: d });
|
|
63
|
+
return Array.from({ length: 7 }).map((e, a) => {
|
|
64
|
+
const m = u(g(r, a), "EEEEEE", { locale: d });
|
|
65
|
+
return H(m);
|
|
66
|
+
});
|
|
67
|
+
}, []), T = b(() => {
|
|
68
|
+
x((r) => {
|
|
69
|
+
const e = f(S(r, 1));
|
|
70
|
+
return p((a) => v(a, e)), e;
|
|
71
|
+
});
|
|
72
|
+
}, []), q = b(() => {
|
|
73
|
+
x((r) => {
|
|
74
|
+
const e = f(W(r, 1));
|
|
75
|
+
return p((a) => v(a, e)), e;
|
|
76
|
+
});
|
|
77
|
+
}, []), k = b(
|
|
78
|
+
(r) => {
|
|
79
|
+
p(r), l == null || l(r);
|
|
80
|
+
},
|
|
81
|
+
[l]
|
|
82
|
+
), s = b((r) => {
|
|
83
|
+
$.current = !0, p(r), x(
|
|
84
|
+
(e) => C(r, e) ? e : f(r)
|
|
85
|
+
);
|
|
86
|
+
}, []), V = b(
|
|
87
|
+
(r, e) => {
|
|
88
|
+
switch (r.key) {
|
|
89
|
+
case "Enter":
|
|
90
|
+
case " ":
|
|
91
|
+
r.preventDefault(), k(e);
|
|
92
|
+
return;
|
|
93
|
+
case "ArrowLeft":
|
|
94
|
+
r.preventDefault(), s(g(e, -1));
|
|
95
|
+
return;
|
|
96
|
+
case "ArrowRight":
|
|
97
|
+
r.preventDefault(), s(g(e, 1));
|
|
98
|
+
return;
|
|
99
|
+
case "ArrowUp":
|
|
100
|
+
r.preventDefault(), s(g(e, -7));
|
|
101
|
+
return;
|
|
102
|
+
case "ArrowDown":
|
|
103
|
+
r.preventDefault(), s(g(e, 7));
|
|
104
|
+
return;
|
|
105
|
+
case "Home":
|
|
106
|
+
r.preventDefault(), s(I(e, { locale: d }));
|
|
107
|
+
return;
|
|
108
|
+
case "End":
|
|
109
|
+
r.preventDefault(), s(L(e, { locale: d }));
|
|
110
|
+
return;
|
|
111
|
+
case "PageUp":
|
|
112
|
+
r.preventDefault(), s(v(e, S(e, 1)));
|
|
113
|
+
return;
|
|
114
|
+
case "PageDown":
|
|
115
|
+
r.preventDefault(), s(v(e, W(e, 1)));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
[k, s]
|
|
120
|
+
), _ = u(c, "MMMM", { locale: d }), G = u(c, "yyyy", { locale: d }), J = `${H(_)} ${G}`, O = te(), Q = C(h, c) ? h : v(h, c);
|
|
121
|
+
return /* @__PURE__ */ y(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
className: n.calendarContainer,
|
|
125
|
+
"data-color": z,
|
|
126
|
+
"data-size": Y,
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ y("div", { className: n.calendarHeader, children: [
|
|
129
|
+
/* @__PURE__ */ i("span", { className: n.monthYear, id: O, "aria-live": "polite", children: J }),
|
|
130
|
+
/* @__PURE__ */ y("div", { className: n.navigationButtons, children: [
|
|
131
|
+
/* @__PURE__ */ i(
|
|
132
|
+
A,
|
|
133
|
+
{
|
|
134
|
+
variant: "tertiary",
|
|
135
|
+
icon: !0,
|
|
136
|
+
onClick: T,
|
|
137
|
+
"aria-label": E("datePicker.previousMonth"),
|
|
138
|
+
children: /* @__PURE__ */ i(se, {})
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ i(
|
|
142
|
+
A,
|
|
143
|
+
{
|
|
144
|
+
variant: "tertiary",
|
|
145
|
+
icon: !0,
|
|
146
|
+
onClick: q,
|
|
147
|
+
"aria-label": E("datePicker.nextMonth"),
|
|
148
|
+
children: /* @__PURE__ */ i(de, {})
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] })
|
|
152
|
+
] }),
|
|
153
|
+
/* @__PURE__ */ y("div", { role: "grid", "aria-labelledby": O, className: n.gridWrapper, ref: P, children: [
|
|
154
|
+
/* @__PURE__ */ i("div", { role: "row", className: n.gridRow, children: K.map((r) => /* @__PURE__ */ i("div", { role: "columnheader", className: n.dayNameCell, children: r }, r)) }),
|
|
155
|
+
U.map((r) => /* @__PURE__ */ i("div", { role: "row", className: n.gridRow, children: r.map((e) => {
|
|
156
|
+
const a = C(e, c), m = o && w(o) && F(e, o), j = re(e), X = a && F(e, Q), Z = [
|
|
157
|
+
n.dateCell,
|
|
158
|
+
a ? "" : n.otherMonth,
|
|
159
|
+
m ? n.selectedDate : "",
|
|
160
|
+
j && !m ? n.todayDate : ""
|
|
161
|
+
].filter(Boolean).join(" ");
|
|
162
|
+
return /* @__PURE__ */ i(
|
|
163
|
+
"div",
|
|
164
|
+
{
|
|
165
|
+
role: "gridcell",
|
|
166
|
+
className: Z,
|
|
167
|
+
"data-date": u(e, "yyyy-MM-dd"),
|
|
168
|
+
onClick: a ? () => k(e) : void 0,
|
|
169
|
+
onKeyDown: a ? (ee) => V(ee, e) : void 0,
|
|
170
|
+
tabIndex: a ? X ? 0 : -1 : void 0,
|
|
171
|
+
"aria-selected": a ? !!m : void 0,
|
|
172
|
+
"aria-disabled": !a || void 0,
|
|
173
|
+
"aria-current": j ? "date" : void 0,
|
|
174
|
+
"aria-label": u(e, "PPP", { locale: d }),
|
|
175
|
+
children: /* @__PURE__ */ i("span", { className: n.dateNumberContainer, children: u(e, "d") })
|
|
176
|
+
},
|
|
177
|
+
e.toISOString()
|
|
178
|
+
);
|
|
179
|
+
}) }, r[0].toISOString()))
|
|
180
|
+
] })
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
ue.displayName = "DatePicker";
|
|
186
|
+
function fe(t) {
|
|
187
|
+
return `
|
|
188
|
+
.${t.calendarContainer} {
|
|
189
|
+
display: inline-flex;
|
|
190
|
+
padding: var(--ds-size-8, 32px);
|
|
191
|
+
flex-direction: column;
|
|
192
|
+
align-items: flex-start;
|
|
193
|
+
gap: var(--ds-size-3, 12px);
|
|
194
|
+
border: 1px solid var(--ds-color-border-subtle, #ccc);
|
|
195
|
+
border-radius: var(--ds-border-radius-md, 4px);
|
|
196
|
+
background-color: var(--ds-color-background-default, #fff);
|
|
197
|
+
font-family: var(--ds-font-family, sans-serif);
|
|
198
|
+
color: var(--ds-color-text-default, #2b2b2b);
|
|
199
|
+
max-width: 100%;
|
|
200
|
+
box-sizing: border-box;
|
|
201
|
+
}
|
|
202
|
+
.${t.calendarHeader} {
|
|
203
|
+
display: flex;
|
|
204
|
+
justify-content: space-between;
|
|
205
|
+
align-items: center;
|
|
206
|
+
align-self: stretch;
|
|
207
|
+
}
|
|
208
|
+
.${t.monthYear} {
|
|
209
|
+
color: var(--ds-color-text-default, #2b2b2b);
|
|
210
|
+
font-family: var(--ds-font-family, sans-serif);
|
|
211
|
+
font-size: var(--ds-heading-sm-font-size, 1.5rem);
|
|
212
|
+
font-weight: var(--ds-heading-sm-font-weight, 500);
|
|
213
|
+
line-height: var(--ds-heading-sm-line-height, 1.3);
|
|
214
|
+
margin: 0;
|
|
215
|
+
}
|
|
216
|
+
.${t.navigationButtons} {
|
|
217
|
+
display: flex;
|
|
218
|
+
gap: var(--ds-size-1, 4px);
|
|
219
|
+
}
|
|
220
|
+
.${t.navigationButtons} > button:disabled svg {
|
|
221
|
+
opacity: var(--ds-opacity-disabled, 0.3);
|
|
222
|
+
}
|
|
223
|
+
.${t.gridWrapper} {
|
|
224
|
+
width: 100%;
|
|
225
|
+
overflow: hidden;
|
|
226
|
+
}
|
|
227
|
+
.${t.gridRow} {
|
|
228
|
+
display: grid;
|
|
229
|
+
grid-template-columns: repeat(7, 1fr);
|
|
230
|
+
width: 100%;
|
|
231
|
+
text-align: center;
|
|
232
|
+
}
|
|
233
|
+
.${t.dayNameCell} {
|
|
234
|
+
display: flex;
|
|
235
|
+
padding: var(--ds-size-2, 8px);
|
|
236
|
+
flex-direction: column;
|
|
237
|
+
justify-content: center;
|
|
238
|
+
align-items: center;
|
|
239
|
+
color: var(--ds-color-text-default, #2b2b2b);
|
|
240
|
+
text-align: center;
|
|
241
|
+
font-family: var(--ds-font-family, sans-serif);
|
|
242
|
+
font-size: var(--ds-body-xs-font-size, 14px);
|
|
243
|
+
font-weight: var(--ds-font-weight-semibold, 600);
|
|
244
|
+
line-height: var(--ds-body-short-xs-line-height, 1.3);
|
|
245
|
+
box-sizing: border-box;
|
|
246
|
+
min-width: 0;
|
|
247
|
+
}
|
|
248
|
+
.${t.dateCell} {
|
|
249
|
+
display: flex;
|
|
250
|
+
padding: var(--ds-size-5, 22px);
|
|
251
|
+
flex-direction: column;
|
|
252
|
+
justify-content: center;
|
|
253
|
+
align-items: center;
|
|
254
|
+
border: var(--ds-border-width-default, 1px) solid var(--ds-color-border-subtle, #bcbcbc);
|
|
255
|
+
box-sizing: border-box;
|
|
256
|
+
margin: -0.5px;
|
|
257
|
+
font-family: var(--ds-font-family, sans-serif);
|
|
258
|
+
color: var(--ds-color-text-default, #2b2b2b);
|
|
259
|
+
text-align: center;
|
|
260
|
+
font-size: var(--ds-body-xs-font-size, 14px);
|
|
261
|
+
font-weight: var(--ds-body-xs-font-weight, 400);
|
|
262
|
+
line-height: var(--ds-body-short-xs-line-height, 1.3);
|
|
263
|
+
cursor: pointer;
|
|
264
|
+
transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
|
|
265
|
+
user-select: none;
|
|
266
|
+
min-width: 0;
|
|
267
|
+
}
|
|
268
|
+
.${t.dateCell}:focus-visible {
|
|
269
|
+
outline: var(--ds-border-width-focus, 3px) solid var(--ds-color-focus-outer, #2b2b2b);
|
|
270
|
+
outline-offset: calc(-1 * var(--ds-border-width-focus, 3px));
|
|
271
|
+
position: relative;
|
|
272
|
+
z-index: 2;
|
|
273
|
+
}
|
|
274
|
+
.${t.dateNumberContainer} {
|
|
275
|
+
display: flex;
|
|
276
|
+
justify-content: center;
|
|
277
|
+
align-items: center;
|
|
278
|
+
width: 24px;
|
|
279
|
+
height: 24px;
|
|
280
|
+
border-radius: 50%;
|
|
281
|
+
transition: color 0.15s ease-in-out, font-weight 0.15s ease-in-out;
|
|
282
|
+
line-height: 1;
|
|
283
|
+
box-sizing: border-box;
|
|
284
|
+
background-color: transparent;
|
|
285
|
+
}
|
|
286
|
+
.${t.dateCell}:hover:not(.${t.otherMonth}):not(.${t.disabled}) {
|
|
287
|
+
background-color: var(--ds-color-surface-hover, #eee);
|
|
288
|
+
position: relative;
|
|
289
|
+
z-index: 1;
|
|
290
|
+
}
|
|
291
|
+
.${t.otherMonth} {
|
|
292
|
+
/* Neutral-scoped tokens on purpose: under the red color scope the
|
|
293
|
+
scope-relative tints turn pink, which emphasized the outside days
|
|
294
|
+
instead of muting them. */
|
|
295
|
+
color: var(--ds-color-neutral-text-subtle, #aaa);
|
|
296
|
+
cursor: default;
|
|
297
|
+
pointer-events: none;
|
|
298
|
+
background-color: var(--ds-color-neutral-surface-tinted, #e8e8e8);
|
|
299
|
+
border: var(--ds-border-width-default, 1px) solid var(--ds-color-neutral-border-subtle, #bcbcbc);
|
|
300
|
+
margin: -0.5px;
|
|
301
|
+
}
|
|
302
|
+
.${t.selectedDate} {
|
|
303
|
+
background-color: var(--ds-color-base-default, #C30000);
|
|
304
|
+
border-color: var(--ds-color-base-default, #C30000);
|
|
305
|
+
color: var(--ds-color-base-contrast-default, #fff);
|
|
306
|
+
position: relative;
|
|
307
|
+
z-index: 1;
|
|
308
|
+
}
|
|
309
|
+
.${t.selectedDate} .${t.dateNumberContainer} {
|
|
310
|
+
color: var(--ds-color-base-contrast-default, #fff);
|
|
311
|
+
font-weight: var(--ds-font-weight-semibold, 600);
|
|
312
|
+
background-color: transparent;
|
|
313
|
+
}
|
|
314
|
+
.${t.todayDate} .${t.dateNumberContainer} {
|
|
315
|
+
font-weight: var(--ds-font-weight-semibold, 600);
|
|
316
|
+
}
|
|
317
|
+
@media (max-width: 480px) {
|
|
318
|
+
.${t.calendarContainer} {
|
|
319
|
+
padding: var(--ds-size-4, 16px);
|
|
320
|
+
gap: var(--ds-size-2, 8px);
|
|
321
|
+
width: 100%;
|
|
322
|
+
}
|
|
323
|
+
.${t.monthYear} {
|
|
324
|
+
font-size: var(--ds-heading-xs-font-size, 1.125rem);
|
|
325
|
+
}
|
|
326
|
+
.${t.dayNameCell} {
|
|
327
|
+
padding: var(--ds-size-1, 4px);
|
|
328
|
+
font-size: var(--ds-font-size-1, 12px);
|
|
329
|
+
}
|
|
330
|
+
.${t.dateCell} {
|
|
331
|
+
padding: var(--ds-size-2, 8px);
|
|
332
|
+
font-size: var(--ds-font-size-1, 12px);
|
|
333
|
+
}
|
|
334
|
+
.${t.dateNumberContainer} {
|
|
335
|
+
width: 20px;
|
|
336
|
+
height: 20px;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
@media (max-width: 360px) {
|
|
340
|
+
.${t.calendarContainer} {
|
|
341
|
+
padding: var(--ds-size-2, 8px);
|
|
342
|
+
}
|
|
343
|
+
.${t.dayNameCell} {
|
|
344
|
+
padding: 2px;
|
|
345
|
+
font-size: 10px;
|
|
346
|
+
}
|
|
347
|
+
.${t.dateCell} {
|
|
348
|
+
padding: var(--ds-size-1, 4px);
|
|
349
|
+
font-size: 11px;
|
|
350
|
+
}
|
|
351
|
+
.${t.dateNumberContainer} {
|
|
352
|
+
width: 16px;
|
|
353
|
+
height: 16px;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
`;
|
|
357
|
+
}
|
|
358
|
+
export {
|
|
359
|
+
ue as DatePicker
|
|
360
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const e = "_calendarContainer_1xn54_1", n = "_calendarHeader_1xn54_16", a = "_monthYear_1xn54_23", t = "_navigationButtons_1xn54_34", o = "_gridWrapper_1xn54_43", r = "_gridRow_1xn54_48", _ = "_dayNameCell_1xn54_55", d = "_dateCell_1xn54_73", l = "_dateNumberContainer_1xn54_106", s = "_otherMonth_1xn54_119", c = "_disabled_1xn54_119", i = "_selectedDate_1xn54_148", x = {
|
|
3
|
+
calendarContainer: e,
|
|
4
|
+
calendarHeader: n,
|
|
5
|
+
monthYear: a,
|
|
6
|
+
navigationButtons: t,
|
|
7
|
+
gridWrapper: o,
|
|
8
|
+
gridRow: r,
|
|
9
|
+
dayNameCell: _,
|
|
10
|
+
dateCell: d,
|
|
11
|
+
dateNumberContainer: l,
|
|
12
|
+
otherMonth: s,
|
|
13
|
+
disabled: c,
|
|
14
|
+
selectedDate: i
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
e as calendarContainer,
|
|
18
|
+
n as calendarHeader,
|
|
19
|
+
d as dateCell,
|
|
20
|
+
l as dateNumberContainer,
|
|
21
|
+
_ as dayNameCell,
|
|
22
|
+
x as default,
|
|
23
|
+
c as disabled,
|
|
24
|
+
r as gridRow,
|
|
25
|
+
o as gridWrapper,
|
|
26
|
+
a as monthYear,
|
|
27
|
+
t as navigationButtons,
|
|
28
|
+
s as otherMonth,
|
|
29
|
+
i as selectedDate
|
|
30
|
+
};
|