@stoa-dev/kit 0.1.3 → 1.0.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/CHANGELOG.md +64 -0
- package/README.md +23 -2
- package/dist/display/BarChart/index.js +70 -0
- package/dist/display/BarChart/index.js.map +1 -0
- package/dist/display/Marginalia/index.js +16 -0
- package/dist/display/Marginalia/index.js.map +1 -0
- package/dist/display/MarginaliaFramed/index.js +19 -0
- package/dist/display/MarginaliaFramed/index.js.map +1 -0
- package/dist/display/MarginaliaPair/index.js +32 -0
- package/dist/display/MarginaliaPair/index.js.map +1 -0
- package/dist/display/ProgressBar/index.js +72 -0
- package/dist/display/ProgressBar/index.js.map +1 -0
- package/dist/display/TimeMeasured/index.js +38 -0
- package/dist/display/TimeMeasured/index.js.map +1 -0
- package/dist/display/index.js +16 -0
- package/dist/display/index.js.map +1 -0
- package/dist/i18n/locales/at.json.js +8 -4
- package/dist/i18n/locales/at.json.js.map +1 -1
- package/dist/i18n/locales/de.json.js +8 -4
- package/dist/i18n/locales/de.json.js.map +1 -1
- package/dist/i18n/locales/en.json.js +8 -4
- package/dist/i18n/locales/en.json.js.map +1 -1
- package/dist/i18n/locales/it.json.js +10 -6
- package/dist/i18n/locales/it.json.js.map +1 -1
- package/dist/shell/AnimatedSwap/index.js +61 -0
- package/dist/shell/AnimatedSwap/index.js.map +1 -0
- package/dist/shell/AppNavigation/index.js +62 -43
- package/dist/shell/AppNavigation/index.js.map +1 -1
- package/dist/shell/BrandLines/index.js +14 -12
- package/dist/shell/BrandLines/index.js.map +1 -1
- package/dist/shell/DatePicker/index.js +134 -127
- package/dist/shell/DatePicker/index.js.map +1 -1
- package/dist/shell/ExternalLink/index.js +30 -0
- package/dist/shell/ExternalLink/index.js.map +1 -0
- package/dist/shell/PageHeading/index.js +15 -8
- package/dist/shell/PageHeading/index.js.map +1 -1
- package/dist/shell/SaveStatus/index.js +61 -0
- package/dist/shell/SaveStatus/index.js.map +1 -0
- package/dist/shell/SectionNavigation/index.js +29 -27
- package/dist/shell/SectionNavigation/index.js.map +1 -1
- package/dist/shell/StartupAnimation/index.js +88 -0
- package/dist/shell/StartupAnimation/index.js.map +1 -0
- package/dist/shell/StartupProvider/index.js +37 -0
- package/dist/shell/StartupProvider/index.js.map +1 -0
- package/dist/shell/TagInput/index.js +93 -0
- package/dist/shell/TagInput/index.js.map +1 -0
- package/dist/shell/ValidatedInput/index.js +31 -0
- package/dist/shell/ValidatedInput/index.js.map +1 -0
- package/dist/shell/index.js +41 -24
- package/dist/shell/index.js.map +1 -1
- package/dist/types/display/BarChart/index.d.ts +25 -0
- package/dist/types/display/BarChart/index.d.ts.map +1 -0
- package/dist/types/display/Marginalia/index.d.ts +8 -0
- package/dist/types/display/Marginalia/index.d.ts.map +1 -0
- package/dist/types/display/MarginaliaFramed/index.d.ts +8 -0
- package/dist/types/display/MarginaliaFramed/index.d.ts.map +1 -0
- package/dist/types/display/MarginaliaPair/index.d.ts +9 -0
- package/dist/types/display/MarginaliaPair/index.d.ts.map +1 -0
- package/dist/types/display/ProgressBar/index.d.ts +19 -0
- package/dist/types/display/ProgressBar/index.d.ts.map +1 -0
- package/dist/types/display/TimeMeasured/index.d.ts +16 -0
- package/dist/types/display/TimeMeasured/index.d.ts.map +1 -0
- package/dist/types/display/index.d.ts +7 -0
- package/dist/types/display/index.d.ts.map +1 -0
- package/dist/types/i18n/index.d.ts +44 -0
- package/dist/types/i18n/index.d.ts.map +1 -1
- package/dist/types/shell/AnimatedSwap/index.d.ts +13 -0
- package/dist/types/shell/AnimatedSwap/index.d.ts.map +1 -0
- package/dist/types/shell/AppNavigation/index.d.ts.map +1 -1
- package/dist/types/shell/BrandLines/index.d.ts.map +1 -1
- package/dist/types/shell/DatePicker/index.d.ts +5 -1
- package/dist/types/shell/DatePicker/index.d.ts.map +1 -1
- package/dist/types/shell/ErrorBoundary/index.d.ts +1 -1
- package/dist/types/shell/ExternalLink/index.d.ts +10 -0
- package/dist/types/shell/ExternalLink/index.d.ts.map +1 -0
- package/dist/types/shell/PageHeading/index.d.ts.map +1 -1
- package/dist/types/shell/SaveStatus/index.d.ts +15 -0
- package/dist/types/shell/SaveStatus/index.d.ts.map +1 -0
- package/dist/types/shell/SectionNavigation/index.d.ts.map +1 -1
- package/dist/types/shell/StartupAnimation/index.d.ts +26 -0
- package/dist/types/shell/StartupAnimation/index.d.ts.map +1 -0
- package/dist/types/shell/StartupProvider/index.d.ts +22 -0
- package/dist/types/shell/StartupProvider/index.d.ts.map +1 -0
- package/dist/types/shell/TagInput/index.d.ts +20 -0
- package/dist/types/shell/TagInput/index.d.ts.map +1 -0
- package/dist/types/shell/ValidatedInput/index.d.ts +17 -0
- package/dist/types/shell/ValidatedInput/index.d.ts.map +1 -0
- package/dist/types/shell/index.d.ts +7 -0
- package/dist/types/shell/index.d.ts.map +1 -1
- package/dist/types/ui/field/index.d.ts +1 -1
- package/dist/types/ui/input-group/index.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/saveFeedback.d.ts +35 -0
- package/dist/types/utils/saveFeedback.d.ts.map +1 -0
- package/dist/ui/input-group/index.js +25 -24
- package/dist/ui/input-group/index.js.map +1 -1
- package/dist/utils/index.js +5 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/saveFeedback.js +54 -0
- package/dist/utils/saveFeedback.js.map +1 -0
- package/package.json +8 -2
- package/styles/instrument.css +705 -0
- package/styles/theme.css +1 -0
|
@@ -1,208 +1,215 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { it as
|
|
3
|
-
import { CalendarIcon as
|
|
4
|
-
import * as
|
|
5
|
-
import { useTranslation as
|
|
6
|
-
import { STOA_NS as
|
|
7
|
-
import { Button as
|
|
8
|
-
import { Calendar as
|
|
9
|
-
import { Field as
|
|
10
|
-
import { InputGroup as
|
|
11
|
-
import { Popover as
|
|
12
|
-
import { formatDate as
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsxs as y, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { it as G, enUS as R, deAT as _, de as C } from "date-fns/locale";
|
|
3
|
+
import { CalendarIcon as K, Target as H } from "lucide-react";
|
|
4
|
+
import * as w from "react";
|
|
5
|
+
import { useTranslation as U } from "react-i18next";
|
|
6
|
+
import { STOA_NS as W } from "../../i18n/namespace.js";
|
|
7
|
+
import { Button as q } from "../../ui/button/index.js";
|
|
8
|
+
import { Calendar as J } from "../../ui/calendar/index.js";
|
|
9
|
+
import { Field as Q, FieldLabel as X } from "../../ui/field/index.js";
|
|
10
|
+
import { InputGroup as Z, InputGroupInput as ee, InputGroupAddon as te, InputGroupButton as ne } from "../../ui/input-group/index.js";
|
|
11
|
+
import { Popover as oe, PopoverTrigger as ae, PopoverContent as re } from "../../ui/popover/index.js";
|
|
12
|
+
import { formatDate as P, isValidDate as T, getRuntimeLocale as x } from "../../utils/dates.js";
|
|
13
|
+
const ie = 100, le = 10;
|
|
14
|
+
function L(t) {
|
|
15
|
+
return Y(t);
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
const o = new Date(
|
|
18
|
-
if (o.getFullYear() ===
|
|
17
|
+
function F(t, r, i) {
|
|
18
|
+
const o = new Date(t, r - 1, i);
|
|
19
|
+
if (o.getFullYear() === t && o.getMonth() === r - 1 && o.getDate() === i)
|
|
19
20
|
return o;
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
22
|
+
function A(t) {
|
|
23
|
+
return t.trim().toLocaleLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
25
|
+
function ce(t) {
|
|
26
|
+
return A(t).match(/[a-z0-9]+/g) ?? [];
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
28
|
+
function se(t) {
|
|
29
|
+
const i = new Intl.DateTimeFormat(x(), {
|
|
29
30
|
day: "2-digit",
|
|
30
31
|
month: "long",
|
|
31
32
|
year: "numeric"
|
|
32
33
|
}).formatToParts(new Date(2026, 4, 11)).filter(
|
|
33
|
-
(
|
|
34
|
-
).map((
|
|
35
|
-
if (o.length !==
|
|
34
|
+
(n) => n.type === "day" || n.type === "month" || n.type === "year"
|
|
35
|
+
).map((n) => n.type), o = ce(t);
|
|
36
|
+
if (o.length !== i.length)
|
|
36
37
|
return;
|
|
37
|
-
const
|
|
38
|
-
for (let
|
|
39
|
-
const s = new Date(2026,
|
|
38
|
+
const h = /* @__PURE__ */ new Map();
|
|
39
|
+
for (let n = 0; n < 12; n += 1) {
|
|
40
|
+
const s = new Date(2026, n, 1), l = new Intl.DateTimeFormat(x(), {
|
|
40
41
|
month: "long"
|
|
41
|
-
}).format(s),
|
|
42
|
+
}).format(s), p = new Intl.DateTimeFormat(x(), {
|
|
42
43
|
month: "short"
|
|
43
44
|
}).format(s);
|
|
44
|
-
|
|
45
|
+
h.set(A(l), n + 1), h.set(A(p), n + 1);
|
|
45
46
|
}
|
|
46
|
-
let
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
}), !(!
|
|
51
|
-
return
|
|
47
|
+
let m, f, a;
|
|
48
|
+
if (i.forEach((n, s) => {
|
|
49
|
+
const l = o[s];
|
|
50
|
+
n === "day" && (m = Number(l)), n === "month" && (f = h.get(l) ?? Number(l)), n === "year" && (a = Number(l));
|
|
51
|
+
}), !(!m || !f || !a))
|
|
52
|
+
return F(a, f, m);
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
-
const r =
|
|
54
|
+
function Y(t) {
|
|
55
|
+
const r = t.trim();
|
|
55
56
|
if (!r)
|
|
56
57
|
return;
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
const [,
|
|
60
|
-
return
|
|
58
|
+
const i = r.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
59
|
+
if (i) {
|
|
60
|
+
const [, f, a, n] = i, s = Number(f), l = Number(a), p = Number(n);
|
|
61
|
+
return F(s, l, p);
|
|
61
62
|
}
|
|
62
63
|
const o = r.match(
|
|
63
64
|
/^(\d{1,2})[./-](\d{1,2})[./-](\d{4})$/
|
|
64
65
|
);
|
|
65
66
|
if (o) {
|
|
66
|
-
const [,
|
|
67
|
-
return
|
|
67
|
+
const [, f, a, n] = o, s = Number(n), l = Number(a), p = Number(f);
|
|
68
|
+
return F(s, l, p);
|
|
68
69
|
}
|
|
69
70
|
if (!/\d{4}/.test(r))
|
|
70
71
|
return;
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
return
|
|
74
|
-
const
|
|
75
|
-
return
|
|
72
|
+
const h = se(r);
|
|
73
|
+
if (T(h))
|
|
74
|
+
return h;
|
|
75
|
+
const m = new Date(r);
|
|
76
|
+
return T(m) ? m : void 0;
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
-
if (!
|
|
78
|
+
function b(t) {
|
|
79
|
+
if (!t)
|
|
79
80
|
return "";
|
|
80
|
-
const r =
|
|
81
|
-
return `${r}-${
|
|
81
|
+
const r = t.getFullYear(), i = String(t.getMonth() + 1).padStart(2, "0"), o = String(t.getDate()).padStart(2, "0");
|
|
82
|
+
return `${r}-${i}-${o}`;
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
-
id:
|
|
84
|
+
function Pe({
|
|
85
|
+
id: t,
|
|
85
86
|
label: r,
|
|
86
|
-
hideLabel:
|
|
87
|
+
hideLabel: i = !1,
|
|
87
88
|
value: o,
|
|
88
|
-
onChange:
|
|
89
|
-
invalid:
|
|
90
|
-
required:
|
|
91
|
-
disabled: a = !1
|
|
89
|
+
onChange: h,
|
|
90
|
+
invalid: m = !1,
|
|
91
|
+
required: f = !1,
|
|
92
|
+
disabled: a = !1,
|
|
93
|
+
startMonth: n,
|
|
94
|
+
endMonth: s
|
|
92
95
|
}) {
|
|
93
|
-
const { t:
|
|
94
|
-
() =>
|
|
95
|
-
), [$,
|
|
96
|
-
|
|
97
|
-
a &&
|
|
96
|
+
const l = (/* @__PURE__ */ new Date()).getFullYear(), p = n ?? new Date(l - ie, 0, 1), z = s ?? new Date(l + le, 11, 1), { t: u, i18n: E } = U(W), V = E.resolvedLanguage ?? "de", B = { de: C, "de-AT": _, en: R, it: G }[V] ?? C, [O, D] = w.useState(!1), [M, v] = w.useState(
|
|
97
|
+
() => L(o)
|
|
98
|
+
), [$, N] = w.useState(M), [I, g] = w.useState(P(M) || o);
|
|
99
|
+
w.useEffect(() => {
|
|
100
|
+
a && D(!1);
|
|
98
101
|
}, [a]);
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
+
const k = (e) => {
|
|
103
|
+
e !== o && h(e);
|
|
104
|
+
}, j = () => {
|
|
102
105
|
if (a) return;
|
|
103
|
-
const
|
|
104
|
-
v(
|
|
105
|
-
},
|
|
106
|
+
const e = /* @__PURE__ */ new Date();
|
|
107
|
+
v(e), N(e), g(P(e)), k(b(e)), D(!1);
|
|
108
|
+
}, S = (e) => {
|
|
106
109
|
if (a) return;
|
|
107
|
-
if (!
|
|
108
|
-
v(void 0),
|
|
110
|
+
if (!e.trim()) {
|
|
111
|
+
v(void 0), N(void 0), g(""), k("");
|
|
109
112
|
return;
|
|
110
113
|
}
|
|
111
|
-
const c =
|
|
112
|
-
|
|
114
|
+
const c = Y(e);
|
|
115
|
+
T(c) && (v(c), N(c), g(P(c)), k(b(c)));
|
|
113
116
|
};
|
|
114
|
-
return
|
|
115
|
-
const
|
|
116
|
-
v(
|
|
117
|
-
}, [o,
|
|
118
|
-
!
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
|
|
117
|
+
return w.useEffect(() => {
|
|
118
|
+
const e = L(o);
|
|
119
|
+
v(e), N(e), g(P(e, { locale: V }) || o);
|
|
120
|
+
}, [o, V]), /* @__PURE__ */ y(Q, { className: "w-full", children: [
|
|
121
|
+
!i && /* @__PURE__ */ d(X, { htmlFor: t, children: r }),
|
|
122
|
+
/* @__PURE__ */ y(Z, { "aria-invalid": m, children: [
|
|
123
|
+
/* @__PURE__ */ d(
|
|
124
|
+
ee,
|
|
122
125
|
{
|
|
123
|
-
id:
|
|
124
|
-
"aria-label":
|
|
125
|
-
"aria-invalid":
|
|
126
|
-
value:
|
|
126
|
+
id: t,
|
|
127
|
+
"aria-label": i ? r : void 0,
|
|
128
|
+
"aria-invalid": m,
|
|
129
|
+
value: I,
|
|
127
130
|
placeholder: void 0,
|
|
128
|
-
required:
|
|
131
|
+
required: f,
|
|
129
132
|
disabled: a,
|
|
130
|
-
onChange: (
|
|
131
|
-
const c =
|
|
132
|
-
|
|
133
|
+
onChange: (e) => {
|
|
134
|
+
const c = e.target.value;
|
|
135
|
+
g(c), S(c);
|
|
133
136
|
},
|
|
134
137
|
onBlur: () => {
|
|
135
|
-
I
|
|
138
|
+
S(I);
|
|
136
139
|
},
|
|
137
|
-
onKeyDown: (
|
|
138
|
-
|
|
140
|
+
onKeyDown: (e) => {
|
|
141
|
+
e.key === "Enter" && (e.preventDefault(), S(I), D(!1)), e.key === "ArrowDown" && (e.preventDefault(), D(!0));
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
),
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
-
/* @__PURE__ */
|
|
144
|
-
|
|
145
|
+
/* @__PURE__ */ d(te, { align: "inline-end", children: /* @__PURE__ */ y(oe, { open: O && !a, onOpenChange: D, children: [
|
|
146
|
+
/* @__PURE__ */ d(ae, { asChild: !0, children: /* @__PURE__ */ y(
|
|
147
|
+
ne,
|
|
145
148
|
{
|
|
146
|
-
id: `${
|
|
149
|
+
id: `${t}-picker`,
|
|
147
150
|
disabled: a,
|
|
148
151
|
variant: "ghost",
|
|
149
152
|
size: "icon-xs",
|
|
150
|
-
"aria-label":
|
|
153
|
+
"aria-label": u("datePicker.selectDate"),
|
|
151
154
|
children: [
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
/* @__PURE__ */
|
|
155
|
+
/* @__PURE__ */ d(K, {}),
|
|
156
|
+
/* @__PURE__ */ d("span", { className: "sr-only", children: u("datePicker.selectDate") })
|
|
154
157
|
]
|
|
155
158
|
}
|
|
156
159
|
) }),
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
|
|
160
|
+
/* @__PURE__ */ y(
|
|
161
|
+
re,
|
|
159
162
|
{
|
|
160
163
|
className: "w-auto overflow-hidden p-0",
|
|
161
164
|
align: "end",
|
|
162
165
|
alignOffset: -8,
|
|
163
166
|
sideOffset: 10,
|
|
164
167
|
children: [
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
|
|
168
|
+
/* @__PURE__ */ d("div", { className: "flex items-center justify-center px-1 py-2 mb-1 border-b", children: /* @__PURE__ */ y(
|
|
169
|
+
q,
|
|
167
170
|
{
|
|
168
171
|
type: "button",
|
|
169
172
|
variant: "ghost",
|
|
170
173
|
size: "sm",
|
|
171
|
-
onClick:
|
|
174
|
+
onClick: j,
|
|
172
175
|
disabled: a,
|
|
173
176
|
className: "w-fit",
|
|
174
177
|
children: [
|
|
175
|
-
/* @__PURE__ */
|
|
178
|
+
/* @__PURE__ */ d(H, {}),
|
|
176
179
|
" ",
|
|
177
|
-
|
|
180
|
+
u("datePicker.today")
|
|
178
181
|
]
|
|
179
182
|
}
|
|
180
183
|
) }),
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
|
|
184
|
+
/* @__PURE__ */ d(
|
|
185
|
+
J,
|
|
183
186
|
{
|
|
184
187
|
mode: "single",
|
|
188
|
+
captionLayout: "dropdown",
|
|
189
|
+
fixedWeeks: !0,
|
|
190
|
+
startMonth: p,
|
|
191
|
+
endMonth: z,
|
|
185
192
|
disabled: a,
|
|
186
|
-
locale:
|
|
193
|
+
locale: B,
|
|
187
194
|
labels: {
|
|
188
|
-
labelNext: () =>
|
|
189
|
-
labelPrevious: () =>
|
|
190
|
-
labelMonthDropdown: () =>
|
|
191
|
-
labelYearDropdown: () =>
|
|
192
|
-
labelNav: () =>
|
|
193
|
-
labelDayButton: (
|
|
194
|
-
c.today ?
|
|
195
|
-
new Intl.DateTimeFormat(
|
|
195
|
+
labelNext: () => u("datePicker.nextMonth"),
|
|
196
|
+
labelPrevious: () => u("datePicker.previousMonth"),
|
|
197
|
+
labelMonthDropdown: () => u("datePicker.chooseMonth"),
|
|
198
|
+
labelYearDropdown: () => u("datePicker.chooseYear"),
|
|
199
|
+
labelNav: () => u("datePicker.navigation"),
|
|
200
|
+
labelDayButton: (e, c) => [
|
|
201
|
+
c.today ? u("datePicker.today") : "",
|
|
202
|
+
new Intl.DateTimeFormat(V, {
|
|
196
203
|
dateStyle: "full"
|
|
197
|
-
}).format(
|
|
198
|
-
c.selected ?
|
|
204
|
+
}).format(e),
|
|
205
|
+
c.selected ? u("datePicker.selected") : ""
|
|
199
206
|
].filter(Boolean).join(", ")
|
|
200
207
|
},
|
|
201
|
-
selected:
|
|
208
|
+
selected: M,
|
|
202
209
|
month: $,
|
|
203
|
-
onMonthChange:
|
|
204
|
-
onSelect: (
|
|
205
|
-
a || (v(
|
|
210
|
+
onMonthChange: N,
|
|
211
|
+
onSelect: (e) => {
|
|
212
|
+
a || (v(e), g(P(e)), k(b(e)), D(!1));
|
|
206
213
|
}
|
|
207
214
|
}
|
|
208
215
|
)
|
|
@@ -214,6 +221,6 @@ function pe({
|
|
|
214
221
|
] });
|
|
215
222
|
}
|
|
216
223
|
export {
|
|
217
|
-
|
|
224
|
+
Pe as DatePickerInput
|
|
218
225
|
};
|
|
219
226
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/shell/DatePicker/index.tsx"],"sourcesContent":["import { de, deAT, enUS, it } from 'date-fns/locale'\nimport { CalendarIcon, Target } from 'lucide-react'\nimport * as React from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { Button } from '../../ui/button'\nimport { Calendar } from '../../ui/calendar'\nimport { Field, FieldLabel } from '../../ui/field'\nimport {\n\tInputGroup,\n\tInputGroupAddon,\n\tInputGroupButton,\n\tInputGroupInput,\n} from '../../ui/input-group'\nimport { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'\nimport { formatDate, getRuntimeLocale, isValidDate } from '../../utils/dates'\n\ntype DatePickerInputProps = {\n\tid: string\n\tlabel: string\n\thideLabel?: boolean\n\tvalue: string\n\tonChange: (value: string) => void\n\tinvalid?: boolean\n\trequired?: boolean\n\tdisabled?: boolean\n}\n\nfunction parseDateValue(value: string) {\n\treturn parseTypedDateValue(value)\n}\n\nfunction createDateIfValid(year: number, month: number, day: number) {\n\tconst date = new Date(year, month - 1, day)\n\n\tif (\n\t\tdate.getFullYear() === year &&\n\t\tdate.getMonth() === month - 1 &&\n\t\tdate.getDate() === day\n\t) {\n\t\treturn date\n\t}\n\n\treturn undefined\n}\n\nfunction normalizeTextValue(value: string) {\n\treturn value\n\t\t.trim()\n\t\t.toLocaleLowerCase()\n\t\t.normalize('NFD')\n\t\t.replace(/[\\u0300-\\u036f]/g, '')\n}\n\nfunction tokenizeDateText(value: string) {\n\treturn normalizeTextValue(value).match(/[a-z0-9]+/g) ?? []\n}\n\nfunction parseLocaleDateValue(value: string) {\n\tconst dateParts = new Intl.DateTimeFormat(getRuntimeLocale(), {\n\t\tday: '2-digit',\n\t\tmonth: 'long',\n\t\tyear: 'numeric',\n\t}).formatToParts(new Date(2026, 4, 11))\n\tconst partOrder = dateParts\n\t\t.filter(\n\t\t\t(part) =>\n\t\t\t\tpart.type === 'day' || part.type === 'month' || part.type === 'year',\n\t\t)\n\t\t.map((part) => part.type)\n\tconst normalizedParts = tokenizeDateText(value)\n\n\tif (normalizedParts.length !== partOrder.length) {\n\t\treturn undefined\n\t}\n\n\tconst monthNames = new Map<string, number>()\n\n\tfor (let monthIndex = 0; monthIndex < 12; monthIndex += 1) {\n\t\tconst monthDate = new Date(2026, monthIndex, 1)\n\t\tconst longMonth = new Intl.DateTimeFormat(getRuntimeLocale(), {\n\t\t\tmonth: 'long',\n\t\t}).format(monthDate)\n\t\tconst shortMonth = new Intl.DateTimeFormat(getRuntimeLocale(), {\n\t\t\tmonth: 'short',\n\t\t}).format(monthDate)\n\n\t\tmonthNames.set(normalizeTextValue(longMonth), monthIndex + 1)\n\t\tmonthNames.set(normalizeTextValue(shortMonth), monthIndex + 1)\n\t}\n\n\tlet day: number | undefined\n\tlet month: number | undefined\n\tlet year: number | undefined\n\n\tpartOrder.forEach((partType, index) => {\n\t\tconst partValue = normalizedParts[index]\n\n\t\tif (partType === 'day') {\n\t\t\tday = Number(partValue)\n\t\t}\n\n\t\tif (partType === 'month') {\n\t\t\tmonth = monthNames.get(partValue) ?? Number(partValue)\n\t\t}\n\n\t\tif (partType === 'year') {\n\t\t\tyear = Number(partValue)\n\t\t}\n\t})\n\n\tif (!day || !month || !year) {\n\t\treturn undefined\n\t}\n\n\treturn createDateIfValid(year, month, day)\n}\n\nfunction parseTypedDateValue(value: string) {\n\tconst trimmedValue = value.trim()\n\n\tif (!trimmedValue) {\n\t\treturn undefined\n\t}\n\n\tconst isoDateMatch = trimmedValue.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/)\n\n\tif (isoDateMatch) {\n\t\tconst [, yearValue, monthValue, dayValue] = isoDateMatch\n\t\tconst year = Number(yearValue)\n\t\tconst month = Number(monthValue)\n\t\tconst day = Number(dayValue)\n\n\t\treturn createDateIfValid(year, month, day)\n\t}\n\n\tconst numericDateMatch = trimmedValue.match(\n\t\t/^(\\d{1,2})[./-](\\d{1,2})[./-](\\d{4})$/,\n\t)\n\n\tif (numericDateMatch) {\n\t\tconst [, dayValue, monthValue, yearValue] = numericDateMatch\n\t\tconst year = Number(yearValue)\n\t\tconst month = Number(monthValue)\n\t\tconst day = Number(dayValue)\n\n\t\treturn createDateIfValid(year, month, day)\n\t}\n\n\tif (!/\\d{4}/.test(trimmedValue)) {\n\t\treturn undefined\n\t}\n\n\tconst localeDate = parseLocaleDateValue(trimmedValue)\n\n\tif (isValidDate(localeDate)) {\n\t\treturn localeDate\n\t}\n\n\tconst date = new Date(trimmedValue)\n\n\treturn isValidDate(date) ? date : undefined\n}\n\nfunction toDateValue(date: Date | undefined) {\n\tif (!date) {\n\t\treturn ''\n\t}\n\n\tconst year = date.getFullYear()\n\tconst month = String(date.getMonth() + 1).padStart(2, '0')\n\tconst day = String(date.getDate()).padStart(2, '0')\n\n\treturn `${year}-${month}-${day}`\n}\n\nexport function DatePickerInput({\n\tid,\n\tlabel,\n\thideLabel = false,\n\tvalue,\n\tonChange,\n\tinvalid = false,\n\trequired = false,\n\tdisabled = false,\n}: DatePickerInputProps) {\n\tconst { t, i18n } = useTranslation(STOA_NS)\n\tconst language = i18n.resolvedLanguage ?? 'de'\n\tconst calendarLocales = { de, 'de-AT': deAT, en: enUS, it }\n\tconst calendarLocale =\n\t\tcalendarLocales[language as keyof typeof calendarLocales] ?? de\n\tconst [open, setOpen] = React.useState(false)\n\tconst [date, setDate] = React.useState<Date | undefined>(() =>\n\t\tparseDateValue(value),\n\t)\n\tconst [month, setMonth] = React.useState<Date | undefined>(date)\n\tconst [inputValue, setInputValue] = React.useState(formatDate(date) || value)\n\n\tReact.useEffect(() => {\n\t\tif (disabled) setOpen(false)\n\t}, [disabled])\n\n\tconst updateValue = (nextValue: string) => {\n\t\tif (nextValue !== value) onChange(nextValue)\n\t}\n\n\tconst handleSetToday = () => {\n\t\tif (disabled) return\n\t\tconst today = new Date()\n\t\tsetDate(today)\n\t\tsetMonth(today)\n\t\tsetInputValue(formatDate(today))\n\t\tupdateValue(toDateValue(today))\n\t\tsetOpen(false)\n\t}\n\n\tconst commitInputValue = (valueToCommit: string) => {\n\t\tif (disabled) return\n\t\tif (!valueToCommit.trim()) {\n\t\t\tsetDate(undefined)\n\t\t\tsetMonth(undefined)\n\t\t\tsetInputValue('')\n\t\t\tupdateValue('')\n\t\t\treturn\n\t\t}\n\n\t\tconst nextDate = parseTypedDateValue(valueToCommit)\n\n\t\tif (!isValidDate(nextDate)) {\n\t\t\treturn\n\t\t}\n\n\t\tsetDate(nextDate)\n\t\tsetMonth(nextDate)\n\t\tsetInputValue(formatDate(nextDate))\n\t\tupdateValue(toDateValue(nextDate))\n\t}\n\n\tReact.useEffect(() => {\n\t\tconst nextDate = parseDateValue(value)\n\n\t\tsetDate(nextDate)\n\t\tsetMonth(nextDate)\n\t\tsetInputValue(formatDate(nextDate, { locale: language }) || value)\n\t}, [value, language])\n\n\treturn (\n\t\t<Field className='w-full'>\n\t\t\t{!hideLabel && <FieldLabel htmlFor={id}>{label}</FieldLabel>}\n\t\t\t<InputGroup aria-invalid={invalid}>\n\t\t\t\t<InputGroupInput\n\t\t\t\t\tid={id}\n\t\t\t\t\taria-label={hideLabel ? label : undefined}\n\t\t\t\t\taria-invalid={invalid}\n\t\t\t\t\tvalue={inputValue}\n\t\t\t\t\t// placeholder={formatDate(new Date())}\n\t\t\t\t\tplaceholder={undefined}\n\t\t\t\t\trequired={required}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonChange={(e) => {\n\t\t\t\t\t\tconst nextInputValue = e.target.value\n\t\t\t\t\t\tsetInputValue(nextInputValue)\n\t\t\t\t\t\tcommitInputValue(nextInputValue)\n\t\t\t\t\t}}\n\t\t\t\t\tonBlur={() => {\n\t\t\t\t\t\tcommitInputValue(inputValue)\n\t\t\t\t\t}}\n\t\t\t\t\tonKeyDown={(e) => {\n\t\t\t\t\t\tif (e.key === 'Enter') {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\tcommitInputValue(inputValue)\n\t\t\t\t\t\t\tsetOpen(false)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (e.key === 'ArrowDown') {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\tsetOpen(true)\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t<InputGroupAddon align='inline-end'>\n\t\t\t\t\t<Popover open={open && !disabled} onOpenChange={setOpen}>\n\t\t\t\t\t\t<PopoverTrigger asChild>\n\t\t\t\t\t\t\t<InputGroupButton\n\t\t\t\t\t\t\t\tid={`${id}-picker`}\n\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\tvariant='ghost'\n\t\t\t\t\t\t\t\tsize='icon-xs'\n\t\t\t\t\t\t\t\taria-label={t('datePicker.selectDate')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<CalendarIcon />\n\t\t\t\t\t\t\t\t<span className='sr-only'>{t('datePicker.selectDate')}</span>\n\t\t\t\t\t\t\t</InputGroupButton>\n\t\t\t\t\t\t</PopoverTrigger>\n\t\t\t\t\t\t<PopoverContent\n\t\t\t\t\t\t\tclassName='w-auto overflow-hidden p-0'\n\t\t\t\t\t\t\talign='end'\n\t\t\t\t\t\t\talignOffset={-8}\n\t\t\t\t\t\t\tsideOffset={10}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className='flex items-center justify-center px-1 py-2 mb-1 border-b'>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\ttype='button'\n\t\t\t\t\t\t\t\t\tvariant='ghost'\n\t\t\t\t\t\t\t\t\tsize='sm'\n\t\t\t\t\t\t\t\t\tonClick={handleSetToday}\n\t\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\t\tclassName='w-fit'\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Target /> {t('datePicker.today')}\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<Calendar\n\t\t\t\t\t\t\t\tmode='single'\n\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\tlocale={calendarLocale}\n\t\t\t\t\t\t\t\tlabels={{\n\t\t\t\t\t\t\t\t\tlabelNext: () => t('datePicker.nextMonth'),\n\t\t\t\t\t\t\t\t\tlabelPrevious: () => t('datePicker.previousMonth'),\n\t\t\t\t\t\t\t\t\tlabelMonthDropdown: () => t('datePicker.chooseMonth'),\n\t\t\t\t\t\t\t\t\tlabelYearDropdown: () => t('datePicker.chooseYear'),\n\t\t\t\t\t\t\t\t\tlabelNav: () => t('datePicker.navigation'),\n\t\t\t\t\t\t\t\t\tlabelDayButton: (day, modifiers) =>\n\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\tmodifiers.today ? t('datePicker.today') : '',\n\t\t\t\t\t\t\t\t\t\t\tnew Intl.DateTimeFormat(language, {\n\t\t\t\t\t\t\t\t\t\t\t\tdateStyle: 'full',\n\t\t\t\t\t\t\t\t\t\t\t}).format(day),\n\t\t\t\t\t\t\t\t\t\t\tmodifiers.selected ? t('datePicker.selected') : '',\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t\t\t\t\t.join(', '),\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tselected={date}\n\t\t\t\t\t\t\t\tmonth={month}\n\t\t\t\t\t\t\t\tonMonthChange={setMonth}\n\t\t\t\t\t\t\t\tonSelect={(date) => {\n\t\t\t\t\t\t\t\t\tif (disabled) return\n\t\t\t\t\t\t\t\t\tsetDate(date)\n\t\t\t\t\t\t\t\t\tsetInputValue(formatDate(date))\n\t\t\t\t\t\t\t\t\tupdateValue(toDateValue(date))\n\t\t\t\t\t\t\t\t\tsetOpen(false)\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</PopoverContent>\n\t\t\t\t\t</Popover>\n\t\t\t\t</InputGroupAddon>\n\t\t\t</InputGroup>\n\t\t</Field>\n\t)\n}\n"],"names":["parseDateValue","value","parseTypedDateValue","createDateIfValid","year","month","day","date","normalizeTextValue","tokenizeDateText","parseLocaleDateValue","partOrder","getRuntimeLocale","part","normalizedParts","monthNames","monthIndex","monthDate","longMonth","shortMonth","partType","index","partValue","trimmedValue","isoDateMatch","yearValue","monthValue","dayValue","numericDateMatch","localeDate","isValidDate","toDateValue","DatePickerInput","id","label","hideLabel","onChange","invalid","required","disabled","t","i18n","useTranslation","STOA_NS","language","calendarLocale","de","deAT","enUS","it","open","setOpen","React","setDate","setMonth","inputValue","setInputValue","formatDate","updateValue","nextValue","handleSetToday","today","commitInputValue","valueToCommit","nextDate","jsxs","Field","jsx","FieldLabel","InputGroup","InputGroupInput","e","nextInputValue","InputGroupAddon","Popover","PopoverTrigger","InputGroupButton","CalendarIcon","PopoverContent","Button","Target","Calendar","modifiers"],"mappings":";;;;;;;;;;;;AA4BA,SAASA,EAAeC,GAAe;AACtC,SAAOC,EAAoBD,CAAK;AACjC;AAEA,SAASE,EAAkBC,GAAcC,GAAeC,GAAa;AACpE,QAAMC,IAAO,IAAI,KAAKH,GAAMC,IAAQ,GAAGC,CAAG;AAE1C,MACCC,EAAK,kBAAkBH,KACvBG,EAAK,eAAeF,IAAQ,KAC5BE,EAAK,QAAA,MAAcD;AAEnB,WAAOC;AAIT;AAEA,SAASC,EAAmBP,GAAe;AAC1C,SAAOA,EACL,KAAA,EACA,kBAAA,EACA,UAAU,KAAK,EACf,QAAQ,oBAAoB,EAAE;AACjC;AAEA,SAASQ,GAAiBR,GAAe;AACxC,SAAOO,EAAmBP,CAAK,EAAE,MAAM,YAAY,KAAK,CAAA;AACzD;AAEA,SAASS,GAAqBT,GAAe;AAM5C,QAAMU,IALY,IAAI,KAAK,eAAeC,KAAoB;AAAA,IAC7D,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,EAAA,CACN,EAAE,cAAc,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,EAEpC;AAAA,IACA,CAACC,MACAA,EAAK,SAAS,SAASA,EAAK,SAAS,WAAWA,EAAK,SAAS;AAAA,EAAA,EAE/D,IAAI,CAACA,MAASA,EAAK,IAAI,GACnBC,IAAkBL,GAAiBR,CAAK;AAE9C,MAAIa,EAAgB,WAAWH,EAAU;AAC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iD,EAAcC,EAAWlD,CAAI,CAAC,GAC9BmD,EAAY3B,EAAYxB,CAAI,CAAC,GAC7B4C,EAAQ,EAAK;AAAA,kBACd;AAAA,gBAAA;AAAA,cAAA;AAAA,YACD;AAAA,UAAA;AAAA,QAAA;AAAA,MACD,EAAA,CACD,EAAA,CACD;AAAA,IAAA,EAAA,CACD;AAAA,EAAA,GACD;AAEF;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/shell/DatePicker/index.tsx"],"sourcesContent":["import { de, deAT, enUS, it } from 'date-fns/locale'\nimport { CalendarIcon, Target } from 'lucide-react'\nimport * as React from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { Button } from '../../ui/button'\nimport { Calendar } from '../../ui/calendar'\nimport { Field, FieldLabel } from '../../ui/field'\nimport {\n\tInputGroup,\n\tInputGroupAddon,\n\tInputGroupButton,\n\tInputGroupInput,\n} from '../../ui/input-group'\nimport { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'\nimport { formatDate, getRuntimeLocale, isValidDate } from '../../utils/dates'\n\ntype DatePickerInputProps = {\n\tid: string\n\tlabel: string\n\thideLabel?: boolean\n\tvalue: string\n\tonChange: (value: string) => void\n\tinvalid?: boolean\n\trequired?: boolean\n\tdisabled?: boolean\n\t/** First month reachable in the calendar. Defaults to January, 100 years ago. */\n\tstartMonth?: Date\n\t/** Last month reachable in the calendar. Defaults to December, 10 years ahead. */\n\tendMonth?: Date\n}\n\nconst YEARS_BACK = 100\nconst YEARS_AHEAD = 10\n\nfunction parseDateValue(value: string) {\n\treturn parseTypedDateValue(value)\n}\n\nfunction createDateIfValid(year: number, month: number, day: number) {\n\tconst date = new Date(year, month - 1, day)\n\n\tif (\n\t\tdate.getFullYear() === year &&\n\t\tdate.getMonth() === month - 1 &&\n\t\tdate.getDate() === day\n\t) {\n\t\treturn date\n\t}\n\n\treturn undefined\n}\n\nfunction normalizeTextValue(value: string) {\n\treturn value\n\t\t.trim()\n\t\t.toLocaleLowerCase()\n\t\t.normalize('NFD')\n\t\t.replace(/[\\u0300-\\u036f]/g, '')\n}\n\nfunction tokenizeDateText(value: string) {\n\treturn normalizeTextValue(value).match(/[a-z0-9]+/g) ?? []\n}\n\nfunction parseLocaleDateValue(value: string) {\n\tconst dateParts = new Intl.DateTimeFormat(getRuntimeLocale(), {\n\t\tday: '2-digit',\n\t\tmonth: 'long',\n\t\tyear: 'numeric',\n\t}).formatToParts(new Date(2026, 4, 11))\n\tconst partOrder = dateParts\n\t\t.filter(\n\t\t\t(part) =>\n\t\t\t\tpart.type === 'day' || part.type === 'month' || part.type === 'year',\n\t\t)\n\t\t.map((part) => part.type)\n\tconst normalizedParts = tokenizeDateText(value)\n\n\tif (normalizedParts.length !== partOrder.length) {\n\t\treturn undefined\n\t}\n\n\tconst monthNames = new Map<string, number>()\n\n\tfor (let monthIndex = 0; monthIndex < 12; monthIndex += 1) {\n\t\tconst monthDate = new Date(2026, monthIndex, 1)\n\t\tconst longMonth = new Intl.DateTimeFormat(getRuntimeLocale(), {\n\t\t\tmonth: 'long',\n\t\t}).format(monthDate)\n\t\tconst shortMonth = new Intl.DateTimeFormat(getRuntimeLocale(), {\n\t\t\tmonth: 'short',\n\t\t}).format(monthDate)\n\n\t\tmonthNames.set(normalizeTextValue(longMonth), monthIndex + 1)\n\t\tmonthNames.set(normalizeTextValue(shortMonth), monthIndex + 1)\n\t}\n\n\tlet day: number | undefined\n\tlet month: number | undefined\n\tlet year: number | undefined\n\n\tpartOrder.forEach((partType, index) => {\n\t\tconst partValue = normalizedParts[index]\n\n\t\tif (partType === 'day') {\n\t\t\tday = Number(partValue)\n\t\t}\n\n\t\tif (partType === 'month') {\n\t\t\tmonth = monthNames.get(partValue) ?? Number(partValue)\n\t\t}\n\n\t\tif (partType === 'year') {\n\t\t\tyear = Number(partValue)\n\t\t}\n\t})\n\n\tif (!day || !month || !year) {\n\t\treturn undefined\n\t}\n\n\treturn createDateIfValid(year, month, day)\n}\n\nfunction parseTypedDateValue(value: string) {\n\tconst trimmedValue = value.trim()\n\n\tif (!trimmedValue) {\n\t\treturn undefined\n\t}\n\n\tconst isoDateMatch = trimmedValue.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/)\n\n\tif (isoDateMatch) {\n\t\tconst [, yearValue, monthValue, dayValue] = isoDateMatch\n\t\tconst year = Number(yearValue)\n\t\tconst month = Number(monthValue)\n\t\tconst day = Number(dayValue)\n\n\t\treturn createDateIfValid(year, month, day)\n\t}\n\n\tconst numericDateMatch = trimmedValue.match(\n\t\t/^(\\d{1,2})[./-](\\d{1,2})[./-](\\d{4})$/,\n\t)\n\n\tif (numericDateMatch) {\n\t\tconst [, dayValue, monthValue, yearValue] = numericDateMatch\n\t\tconst year = Number(yearValue)\n\t\tconst month = Number(monthValue)\n\t\tconst day = Number(dayValue)\n\n\t\treturn createDateIfValid(year, month, day)\n\t}\n\n\tif (!/\\d{4}/.test(trimmedValue)) {\n\t\treturn undefined\n\t}\n\n\tconst localeDate = parseLocaleDateValue(trimmedValue)\n\n\tif (isValidDate(localeDate)) {\n\t\treturn localeDate\n\t}\n\n\tconst date = new Date(trimmedValue)\n\n\treturn isValidDate(date) ? date : undefined\n}\n\nfunction toDateValue(date: Date | undefined) {\n\tif (!date) {\n\t\treturn ''\n\t}\n\n\tconst year = date.getFullYear()\n\tconst month = String(date.getMonth() + 1).padStart(2, '0')\n\tconst day = String(date.getDate()).padStart(2, '0')\n\n\treturn `${year}-${month}-${day}`\n}\n\nexport function DatePickerInput({\n\tid,\n\tlabel,\n\thideLabel = false,\n\tvalue,\n\tonChange,\n\tinvalid = false,\n\trequired = false,\n\tdisabled = false,\n\tstartMonth,\n\tendMonth,\n}: DatePickerInputProps) {\n\tconst currentYear = new Date().getFullYear()\n\tconst firstMonth = startMonth ?? new Date(currentYear - YEARS_BACK, 0, 1)\n\tconst lastMonth = endMonth ?? new Date(currentYear + YEARS_AHEAD, 11, 1)\n\tconst { t, i18n } = useTranslation(STOA_NS)\n\tconst language = i18n.resolvedLanguage ?? 'de'\n\tconst calendarLocales = { de, 'de-AT': deAT, en: enUS, it }\n\tconst calendarLocale =\n\t\tcalendarLocales[language as keyof typeof calendarLocales] ?? de\n\tconst [open, setOpen] = React.useState(false)\n\tconst [date, setDate] = React.useState<Date | undefined>(() =>\n\t\tparseDateValue(value),\n\t)\n\tconst [month, setMonth] = React.useState<Date | undefined>(date)\n\tconst [inputValue, setInputValue] = React.useState(formatDate(date) || value)\n\n\tReact.useEffect(() => {\n\t\tif (disabled) setOpen(false)\n\t}, [disabled])\n\n\tconst updateValue = (nextValue: string) => {\n\t\tif (nextValue !== value) onChange(nextValue)\n\t}\n\n\tconst handleSetToday = () => {\n\t\tif (disabled) return\n\t\tconst today = new Date()\n\t\tsetDate(today)\n\t\tsetMonth(today)\n\t\tsetInputValue(formatDate(today))\n\t\tupdateValue(toDateValue(today))\n\t\tsetOpen(false)\n\t}\n\n\tconst commitInputValue = (valueToCommit: string) => {\n\t\tif (disabled) return\n\t\tif (!valueToCommit.trim()) {\n\t\t\tsetDate(undefined)\n\t\t\tsetMonth(undefined)\n\t\t\tsetInputValue('')\n\t\t\tupdateValue('')\n\t\t\treturn\n\t\t}\n\n\t\tconst nextDate = parseTypedDateValue(valueToCommit)\n\n\t\tif (!isValidDate(nextDate)) {\n\t\t\treturn\n\t\t}\n\n\t\tsetDate(nextDate)\n\t\tsetMonth(nextDate)\n\t\tsetInputValue(formatDate(nextDate))\n\t\tupdateValue(toDateValue(nextDate))\n\t}\n\n\tReact.useEffect(() => {\n\t\tconst nextDate = parseDateValue(value)\n\n\t\tsetDate(nextDate)\n\t\tsetMonth(nextDate)\n\t\tsetInputValue(formatDate(nextDate, { locale: language }) || value)\n\t}, [value, language])\n\n\treturn (\n\t\t<Field className='w-full'>\n\t\t\t{!hideLabel && <FieldLabel htmlFor={id}>{label}</FieldLabel>}\n\t\t\t<InputGroup aria-invalid={invalid}>\n\t\t\t\t<InputGroupInput\n\t\t\t\t\tid={id}\n\t\t\t\t\taria-label={hideLabel ? label : undefined}\n\t\t\t\t\taria-invalid={invalid}\n\t\t\t\t\tvalue={inputValue}\n\t\t\t\t\t// placeholder={formatDate(new Date())}\n\t\t\t\t\tplaceholder={undefined}\n\t\t\t\t\trequired={required}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonChange={(e) => {\n\t\t\t\t\t\tconst nextInputValue = e.target.value\n\t\t\t\t\t\tsetInputValue(nextInputValue)\n\t\t\t\t\t\tcommitInputValue(nextInputValue)\n\t\t\t\t\t}}\n\t\t\t\t\tonBlur={() => {\n\t\t\t\t\t\tcommitInputValue(inputValue)\n\t\t\t\t\t}}\n\t\t\t\t\tonKeyDown={(e) => {\n\t\t\t\t\t\tif (e.key === 'Enter') {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\tcommitInputValue(inputValue)\n\t\t\t\t\t\t\tsetOpen(false)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (e.key === 'ArrowDown') {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\tsetOpen(true)\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t<InputGroupAddon align='inline-end'>\n\t\t\t\t\t<Popover open={open && !disabled} onOpenChange={setOpen}>\n\t\t\t\t\t\t<PopoverTrigger asChild>\n\t\t\t\t\t\t\t<InputGroupButton\n\t\t\t\t\t\t\t\tid={`${id}-picker`}\n\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\tvariant='ghost'\n\t\t\t\t\t\t\t\tsize='icon-xs'\n\t\t\t\t\t\t\t\taria-label={t('datePicker.selectDate')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<CalendarIcon />\n\t\t\t\t\t\t\t\t<span className='sr-only'>{t('datePicker.selectDate')}</span>\n\t\t\t\t\t\t\t</InputGroupButton>\n\t\t\t\t\t\t</PopoverTrigger>\n\t\t\t\t\t\t<PopoverContent\n\t\t\t\t\t\t\tclassName='w-auto overflow-hidden p-0'\n\t\t\t\t\t\t\talign='end'\n\t\t\t\t\t\t\talignOffset={-8}\n\t\t\t\t\t\t\tsideOffset={10}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className='flex items-center justify-center px-1 py-2 mb-1 border-b'>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\ttype='button'\n\t\t\t\t\t\t\t\t\tvariant='ghost'\n\t\t\t\t\t\t\t\t\tsize='sm'\n\t\t\t\t\t\t\t\t\tonClick={handleSetToday}\n\t\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\t\tclassName='w-fit'\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Target /> {t('datePicker.today')}\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<Calendar\n\t\t\t\t\t\t\t\tmode='single'\n\t\t\t\t\t\t\t\tcaptionLayout='dropdown'\n\t\t\t\t\t\t\t\t// Always six week rows: the popover keeps its height, so the\n\t\t\t\t\t\t\t\t// month chevrons never jump away from the pointer.\n\t\t\t\t\t\t\t\tfixedWeeks\n\t\t\t\t\t\t\t\tstartMonth={firstMonth}\n\t\t\t\t\t\t\t\tendMonth={lastMonth}\n\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\tlocale={calendarLocale}\n\t\t\t\t\t\t\t\tlabels={{\n\t\t\t\t\t\t\t\t\tlabelNext: () => t('datePicker.nextMonth'),\n\t\t\t\t\t\t\t\t\tlabelPrevious: () => t('datePicker.previousMonth'),\n\t\t\t\t\t\t\t\t\tlabelMonthDropdown: () => t('datePicker.chooseMonth'),\n\t\t\t\t\t\t\t\t\tlabelYearDropdown: () => t('datePicker.chooseYear'),\n\t\t\t\t\t\t\t\t\tlabelNav: () => t('datePicker.navigation'),\n\t\t\t\t\t\t\t\t\tlabelDayButton: (day, modifiers) =>\n\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\tmodifiers.today ? t('datePicker.today') : '',\n\t\t\t\t\t\t\t\t\t\t\tnew Intl.DateTimeFormat(language, {\n\t\t\t\t\t\t\t\t\t\t\t\tdateStyle: 'full',\n\t\t\t\t\t\t\t\t\t\t\t}).format(day),\n\t\t\t\t\t\t\t\t\t\t\tmodifiers.selected ? t('datePicker.selected') : '',\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t\t\t\t\t.join(', '),\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tselected={date}\n\t\t\t\t\t\t\t\tmonth={month}\n\t\t\t\t\t\t\t\tonMonthChange={setMonth}\n\t\t\t\t\t\t\t\tonSelect={(date) => {\n\t\t\t\t\t\t\t\t\tif (disabled) return\n\t\t\t\t\t\t\t\t\tsetDate(date)\n\t\t\t\t\t\t\t\t\tsetInputValue(formatDate(date))\n\t\t\t\t\t\t\t\t\tupdateValue(toDateValue(date))\n\t\t\t\t\t\t\t\t\tsetOpen(false)\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</PopoverContent>\n\t\t\t\t\t</Popover>\n\t\t\t\t</InputGroupAddon>\n\t\t\t</InputGroup>\n\t\t</Field>\n\t)\n}\n"],"names":["YEARS_BACK","YEARS_AHEAD","parseDateValue","value","parseTypedDateValue","createDateIfValid","year","month","day","date","normalizeTextValue","tokenizeDateText","parseLocaleDateValue","partOrder","getRuntimeLocale","part","normalizedParts","monthNames","monthIndex","monthDate","longMonth","shortMonth","partType","index","partValue","trimmedValue","isoDateMatch","yearValue","monthValue","dayValue","numericDateMatch","localeDate","isValidDate","toDateValue","DatePickerInput","id","label","hideLabel","onChange","invalid","required","disabled","startMonth","endMonth","currentYear","firstMonth","lastMonth","t","i18n","useTranslation","STOA_NS","language","calendarLocale","de","deAT","enUS","it","open","setOpen","React","setDate","setMonth","inputValue","setInputValue","formatDate","updateValue","nextValue","handleSetToday","today","commitInputValue","valueToCommit","nextDate","jsxs","Field","jsx","FieldLabel","InputGroup","InputGroupInput","nextInputValue","InputGroupAddon","Popover","PopoverTrigger","InputGroupButton","CalendarIcon","PopoverContent","Button","Target","Calendar","modifiers"],"mappings":";;;;;;;;;;;;AAgCA,MAAMA,KAAa,KACbC,KAAc;AAEpB,SAASC,EAAeC,GAAe;AACtC,SAAOC,EAAoBD,CAAK;AACjC;AAEA,SAASE,EAAkBC,GAAcC,GAAeC,GAAa;AACpE,QAAMC,IAAO,IAAI,KAAKH,GAAMC,IAAQ,GAAGC,CAAG;AAE1C,MACCC,EAAK,kBAAkBH,KACvBG,EAAK,eAAeF,IAAQ,KAC5BE,EAAK,QAAA,MAAcD;AAEnB,WAAOC;AAIT;AAEA,SAASC,EAAmBP,GAAe;AAC1C,SAAOA,EACL,KAAA,EACA,kBAAA,EACA,UAAU,KAAK,EACf,QAAQ,oBAAoB,EAAE;AACjC;AAEA,SAASQ,GAAiBR,GAAe;AACxC,SAAOO,EAAmBP,CAAK,EAAE,MAAM,YAAY,KAAK,CAAA;AACzD;AAEA,SAASS,GAAqBT,GAAe;AAM5C,QAAMU,IALY,IAAI,KAAK,eAAeC,KAAoB;AAAA,IAC7D,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,EAAA,CACN,EAAE,cAAc,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,EAEpC;AAAA,IACA,CAACC,MACAA,EAAK,SAAS,SAASA,EAAK,SAAS,WAAWA,EAAK,SAAS;AAAA,EAAA,EAE/D,IAAI,CAACA,MAASA,EAAK,IAAI,GACnBC,IAAkBL,GAAiBR,CAAK;AAE9C,MAAIa,EAAgB,WAAWH,EAAU;AACxC;AAGD,QAAMI,wBAAiB,IAAA;AAEvB,WAASC,IAAa,GAAGA,IAAa,IAAIA,KAAc,GAAG;AAC1D,UAAMC,IAAY,IAAI,KAAK,MAA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AAAA,kBAAA;AAAA,kBAEb,UAAUtC;AAAA,kBACV,OAAAF;AAAA,kBACA,eAAesD;AAAA,kBACf,UAAU,CAACpD,MAAS;AACnB,oBAAIgC,MACJmB,EAAQnD,CAAI,GACZsD,EAAcC,EAAWvD,CAAI,CAAC,GAC9BwD,EAAYhC,EAAYxB,CAAI,CAAC,GAC7BiD,EAAQ,EAAK;AAAA,kBACd;AAAA,gBAAA;AAAA,cAAA;AAAA,YACD;AAAA,UAAA;AAAA,QAAA;AAAA,MACD,EAAA,CACD,EAAA,CACD;AAAA,IAAA,EAAA,CACD;AAAA,EAAA,GACD;AAEF;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { isTauri as a, invoke as u } from "@tauri-apps/api/core";
|
|
3
|
+
import { cn as f } from "../../utils/cn.js";
|
|
4
|
+
function s({
|
|
5
|
+
href: e,
|
|
6
|
+
className: n,
|
|
7
|
+
onClick: o,
|
|
8
|
+
children: t,
|
|
9
|
+
...i
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ l(
|
|
12
|
+
"a",
|
|
13
|
+
{
|
|
14
|
+
...i,
|
|
15
|
+
href: e,
|
|
16
|
+
target: "_blank",
|
|
17
|
+
rel: "noreferrer",
|
|
18
|
+
"data-slot": "external-link",
|
|
19
|
+
className: f("underline underline-offset-2", n),
|
|
20
|
+
onClick: (r) => {
|
|
21
|
+
o?.(r), !(r.defaultPrevented || !a()) && (r.preventDefault(), u("plugin:opener|open_url", { url: e }));
|
|
22
|
+
},
|
|
23
|
+
children: t
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
s as ExternalLink
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/shell/ExternalLink/index.tsx"],"sourcesContent":["import { invoke, isTauri } from '@tauri-apps/api/core'\nimport type { ComponentProps } from 'react'\nimport { cn } from '../../utils/cn'\n\nexport type ExternalLinkProps = ComponentProps<'a'> & { href: string }\n\n/**\n * Opens http(s) links in the system browser inside Tauri (needs the opener\n * plugin on the Rust side) and in a new tab in the browser preview.\n */\nexport function ExternalLink({\n\thref,\n\tclassName,\n\tonClick,\n\tchildren,\n\t...props\n}: ExternalLinkProps) {\n\treturn (\n\t\t<a\n\t\t\t{...props}\n\t\t\thref={href}\n\t\t\ttarget='_blank'\n\t\t\trel='noreferrer'\n\t\t\tdata-slot='external-link'\n\t\t\tclassName={cn('underline underline-offset-2', className)}\n\t\t\tonClick={(event) => {\n\t\t\t\tonClick?.(event)\n\t\t\t\tif (event.defaultPrevented || !isTauri()) return\n\t\t\t\tevent.preventDefault()\n\t\t\t\tvoid invoke('plugin:opener|open_url', { url: href })\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</a>\n\t)\n}\n"],"names":["ExternalLink","href","className","onClick","children","props","jsx","cn","event","isTauri","invoke"],"mappings":";;;AAUO,SAASA,EAAa;AAAA,EAC5B,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACJ,GAAsB;AACrB,SACC,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,GAAGD;AAAA,MACJ,MAAAJ;AAAA,MACA,QAAO;AAAA,MACP,KAAI;AAAA,MACJ,aAAU;AAAA,MACV,WAAWM,EAAG,gCAAgCL,CAAS;AAAA,MACvD,SAAS,CAACM,MAAU;AAEnB,QADAL,IAAUK,CAAK,GACX,EAAAA,EAAM,oBAAoB,CAACC,SAC/BD,EAAM,eAAA,GACDE,EAAO,0BAA0B,EAAE,KAAKT,GAAM;AAAA,MACpD;AAAA,MAEC,UAAAG;AAAA,IAAA;AAAA,EAAA;AAGJ;"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { cn as
|
|
1
|
+
import { jsxs as i, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { cn as o } from "../../utils/cn.js";
|
|
3
3
|
import { BrandLines as s } from "../BrandLines/index.js";
|
|
4
4
|
import t from "./PageHeading.module.scss.js";
|
|
5
|
-
function
|
|
6
|
-
return /* @__PURE__ */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
function f({ children: r, className: e, plain: a }) {
|
|
6
|
+
return /* @__PURE__ */ i(
|
|
7
|
+
"h2",
|
|
8
|
+
{
|
|
9
|
+
"data-slot": "page-heading",
|
|
10
|
+
className: o(t.pageHeading, "shrink-0", e),
|
|
11
|
+
children: [
|
|
12
|
+
!a && /* @__PURE__ */ n(s, {}),
|
|
13
|
+
r
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
);
|
|
10
17
|
}
|
|
11
18
|
export {
|
|
12
|
-
|
|
19
|
+
f as PageHeading
|
|
13
20
|
};
|
|
14
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/shell/PageHeading/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { cn } from '../../utils/cn'\nimport { BrandLines } from '../BrandLines'\nimport styles from './PageHeading.module.scss'\n\nexport interface PageHeadingProps {\n\tchildren: ReactNode\n\tclassName?: string\n\t/** Hide the brand accent in front of the heading. */\n\tplain?: boolean\n}\n\nexport function PageHeading({ children, className, plain }: PageHeadingProps) {\n\treturn (\n\t\t<h2
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/shell/PageHeading/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { cn } from '../../utils/cn'\nimport { BrandLines } from '../BrandLines'\nimport styles from './PageHeading.module.scss'\n\nexport interface PageHeadingProps {\n\tchildren: ReactNode\n\tclassName?: string\n\t/** Hide the brand accent in front of the heading. */\n\tplain?: boolean\n}\n\nexport function PageHeading({ children, className, plain }: PageHeadingProps) {\n\treturn (\n\t\t<h2\n\t\t\tdata-slot='page-heading'\n\t\t\tclassName={cn(styles.pageHeading, 'shrink-0', className)}\n\t\t>\n\t\t\t{!plain && <BrandLines />}\n\t\t\t{children}\n\t\t</h2>\n\t)\n}\n"],"names":["PageHeading","children","className","plain","jsxs","cn","styles","BrandLines"],"mappings":";;;;AAYO,SAASA,EAAY,EAAE,UAAAC,GAAU,WAAAC,GAAW,OAAAC,KAA2B;AAC7E,SACC,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,aAAU;AAAA,MACV,WAAWC,EAAGC,EAAO,aAAa,YAAYJ,CAAS;AAAA,MAEtD,UAAA;AAAA,QAAA,CAACC,uBAAUI,GAAA,EAAW;AAAA,QACtBN;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGJ;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation as u } from "react-i18next";
|
|
3
|
+
import { STOA_NS as m } from "../../i18n/namespace.js";
|
|
4
|
+
import { Button as f } from "../../ui/button/index.js";
|
|
5
|
+
import { cn as o } from "../../utils/cn.js";
|
|
6
|
+
function N({
|
|
7
|
+
status: r,
|
|
8
|
+
message: e,
|
|
9
|
+
onRetry: n,
|
|
10
|
+
floating: a = !0,
|
|
11
|
+
className: i
|
|
12
|
+
}) {
|
|
13
|
+
const { t: l } = u(m);
|
|
14
|
+
if (!r && !e) return null;
|
|
15
|
+
const c = !!e || r === "error", d = /* @__PURE__ */ s(
|
|
16
|
+
"div",
|
|
17
|
+
{
|
|
18
|
+
"data-slot": "save-status",
|
|
19
|
+
"data-status": r ?? void 0,
|
|
20
|
+
className: o(
|
|
21
|
+
"flex items-center gap-2 text-xs text-muted-foreground",
|
|
22
|
+
!a && i
|
|
23
|
+
),
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ t(
|
|
26
|
+
"span",
|
|
27
|
+
{
|
|
28
|
+
role: c ? "alert" : "status",
|
|
29
|
+
"aria-live": "polite",
|
|
30
|
+
className: o(r === "error" && !e && "text-destructive"),
|
|
31
|
+
children: e ?? (r ? l(`autosave.${r}`) : null)
|
|
32
|
+
}
|
|
33
|
+
),
|
|
34
|
+
r === "error" && n && /* @__PURE__ */ t(f, { size: "sm", variant: "ghost", onClick: n, children: l("actions.retry") })
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
return a ? /* @__PURE__ */ s(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
className: o(
|
|
42
|
+
"fixed bottom-5 left-1/2 z-50 isolate max-w-[calc(100vw-2rem)] -translate-x-1/2 rounded-full px-4 py-2",
|
|
43
|
+
i
|
|
44
|
+
),
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ t(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
"aria-hidden": "true",
|
|
50
|
+
className: "pointer-events-none absolute inset-0 -z-10 rounded-full bg-background/25 shadow-sm backdrop-blur-xs"
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
d
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
) : d;
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
N as SaveStatus
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/shell/SaveStatus/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { Button } from '../../ui/button'\nimport { cn } from '../../utils/cn'\nimport type { VisibleSaveStatus } from '../../utils/saveFeedback'\n\nexport interface SaveStatusProps {\n\tstatus: VisibleSaveStatus\n\t/** Replaces the status text, e.g. a validation hint. Shown as an alert. */\n\tmessage?: ReactNode\n\t/** Shows a retry button next to an error. */\n\tonRetry?: () => void\n\t/** Floating pill at the bottom centre (default) or inline text. */\n\tfloating?: boolean\n\tclassName?: string\n}\n\n/** Autosave feedback: \"Saving …\", \"Changes saved\" or an error with retry. */\nexport function SaveStatus({\n\tstatus,\n\tmessage,\n\tonRetry,\n\tfloating = true,\n\tclassName,\n}: SaveStatusProps) {\n\tconst { t } = useTranslation(STOA_NS)\n\tif (!status && !message) return null\n\tconst alert = Boolean(message) || status === 'error'\n\n\tconst content = (\n\t\t<div\n\t\t\tdata-slot='save-status'\n\t\t\tdata-status={status ?? undefined}\n\t\t\tclassName={cn(\n\t\t\t\t'flex items-center gap-2 text-xs text-muted-foreground',\n\t\t\t\t!floating && className,\n\t\t\t)}\n\t\t>\n\t\t\t<span\n\t\t\t\trole={alert ? 'alert' : 'status'}\n\t\t\t\taria-live='polite'\n\t\t\t\tclassName={cn(status === 'error' && !message && 'text-destructive')}\n\t\t\t>\n\t\t\t\t{message ?? (status ? t(`autosave.${status}`) : null)}\n\t\t\t</span>\n\t\t\t{status === 'error' && onRetry && (\n\t\t\t\t<Button size='sm' variant='ghost' onClick={onRetry}>\n\t\t\t\t\t{t('actions.retry')}\n\t\t\t\t</Button>\n\t\t\t)}\n\t\t</div>\n\t)\n\n\tif (!floating) return content\n\treturn (\n\t\t<div\n\t\t\tclassName={cn(\n\t\t\t\t'fixed bottom-5 left-1/2 z-50 isolate max-w-[calc(100vw-2rem)] -translate-x-1/2 rounded-full px-4 py-2',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t<div\n\t\t\t\taria-hidden='true'\n\t\t\t\tclassName='pointer-events-none absolute inset-0 -z-10 rounded-full bg-background/25 shadow-sm backdrop-blur-xs'\n\t\t\t/>\n\t\t\t{content}\n\t\t</div>\n\t)\n}\n"],"names":["SaveStatus","status","message","onRetry","floating","className","t","useTranslation","STOA_NS","alert","content","jsxs","cn","jsx","Button"],"mappings":";;;;;AAmBO,SAASA,EAAW;AAAA,EAC1B,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC;AACD,GAAoB;AACnB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAeC,CAAO;AACpC,MAAI,CAACP,KAAU,CAACC,EAAS,QAAO;AAChC,QAAMO,IAAQ,EAAQP,KAAYD,MAAW,SAEvCS,IACL,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,aAAU;AAAA,MACV,eAAaV,KAAU;AAAA,MACvB,WAAWW;AAAA,QACV;AAAA,QACA,CAACR,KAAYC;AAAA,MAAA;AAAA,MAGd,UAAA;AAAA,QAAA,gBAAAQ;AAAA,UAAC;AAAA,UAAA;AAAA,YACA,MAAMJ,IAAQ,UAAU;AAAA,YACxB,aAAU;AAAA,YACV,WAAWG,EAAGX,MAAW,WAAW,CAACC,KAAW,kBAAkB;AAAA,YAEjE,gBAAYD,IAASK,EAAE,YAAYL,CAAM,EAAE,IAAI;AAAA,UAAA;AAAA,QAAA;AAAA,QAEhDA,MAAW,WAAWE,KACtB,gBAAAU,EAACC,GAAA,EAAO,MAAK,MAAK,SAAQ,SAAQ,SAASX,GACzC,UAAAG,EAAE,eAAe,EAAA,CACnB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAKH,SAAKF,IAEJ,gBAAAO;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,WAAWC;AAAA,QACV;AAAA,QACAP;AAAA,MAAA;AAAA,MAGD,UAAA;AAAA,QAAA,gBAAAQ;AAAA,UAAC;AAAA,UAAA;AAAA,YACA,eAAY;AAAA,YACZ,WAAU;AAAA,UAAA;AAAA,QAAA;AAAA,QAEVH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAZmBA;AAevB;"}
|