@alfadocs/ui-kit-debug 0.43.0 → 0.44.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/dist/_chunks/{bmi-calculator-DuVSFDuw.js → bmi-calculator-DFPWL2OJ.js} +92 -78
- package/dist/_chunks/bmi-calculator-DFPWL2OJ.js.map +1 -0
- package/dist/_chunks/{calculator-dialog-DdexHrTP.js → calculator-dialog-D-nfvteH.js} +2 -2
- package/dist/_chunks/{calculator-dialog-DdexHrTP.js.map → calculator-dialog-D-nfvteH.js.map} +1 -1
- package/dist/_chunks/{cycle-calculator-Dln-y1k_.js → cycle-calculator-ChHBcjet.js} +58 -50
- package/dist/_chunks/cycle-calculator-ChHBcjet.js.map +1 -0
- package/dist/_chunks/dialog-BTpZV6It.js +223 -0
- package/dist/_chunks/dialog-BTpZV6It.js.map +1 -0
- package/dist/_chunks/{due-date-calculator-Cc4dRqTI.js → due-date-calculator-CYXKLoof.js} +50 -38
- package/dist/_chunks/due-date-calculator-CYXKLoof.js.map +1 -0
- package/dist/_chunks/gestational-age-calculator-sRmoqgVr.js +190 -0
- package/dist/_chunks/gestational-age-calculator-sRmoqgVr.js.map +1 -0
- package/dist/_chunks/insert-result-CoC1oo6R.js +334 -0
- package/dist/_chunks/insert-result-CoC1oo6R.js.map +1 -0
- package/dist/_chunks/{pregnancy-weight-gain-zZL5Ir2-.js → pregnancy-weight-gain-C5YhfYnL.js} +66 -57
- package/dist/_chunks/pregnancy-weight-gain-C5YhfYnL.js.map +1 -0
- package/dist/_chunks/{unit-converter-CuXCXJhK.js → unit-converter-Ds9jalbN.js} +78 -67
- package/dist/_chunks/unit-converter-Ds9jalbN.js.map +1 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/_shared/index.d.ts +1 -1
- package/dist/components/_shared/index.d.ts.map +1 -1
- package/dist/components/_shared/insert-result.d.ts +100 -10
- package/dist/components/_shared/insert-result.d.ts.map +1 -1
- package/dist/components/bmi-calculator/bmi-calculator.d.ts +6 -0
- package/dist/components/bmi-calculator/bmi-calculator.d.ts.map +1 -1
- package/dist/components/bmi-calculator/index.js +1 -1
- package/dist/components/calculator-dialog/index.js +1 -1
- package/dist/components/cycle-calculator/cycle-calculator.d.ts +6 -0
- package/dist/components/cycle-calculator/cycle-calculator.d.ts.map +1 -1
- package/dist/components/cycle-calculator/index.js +1 -1
- package/dist/components/dialog/dialog.d.ts +1 -0
- package/dist/components/dialog/dialog.d.ts.map +1 -1
- package/dist/components/dialog/index.js +1 -1
- package/dist/components/due-date-calculator/due-date-calculator.d.ts +6 -0
- package/dist/components/due-date-calculator/due-date-calculator.d.ts.map +1 -1
- package/dist/components/due-date-calculator/index.js +1 -1
- package/dist/components/gestational-age-calculator/gestational-age-calculator.d.ts +6 -0
- package/dist/components/gestational-age-calculator/gestational-age-calculator.d.ts.map +1 -1
- package/dist/components/gestational-age-calculator/index.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/pregnancy-weight-gain/index.js +1 -1
- package/dist/components/pregnancy-weight-gain/pregnancy-weight-gain.d.ts +6 -0
- package/dist/components/pregnancy-weight-gain/pregnancy-weight-gain.d.ts.map +1 -1
- package/dist/components/unit-converter/index.js +1 -1
- package/dist/components/unit-converter/unit-converter.d.ts +6 -0
- package/dist/components/unit-converter/unit-converter.d.ts.map +1 -1
- package/dist/index.js +494 -493
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/bmi-calculator-DuVSFDuw.js.map +0 -1
- package/dist/_chunks/cycle-calculator-Dln-y1k_.js.map +0 -1
- package/dist/_chunks/dialog-DOYgd75U.js +0 -224
- package/dist/_chunks/dialog-DOYgd75U.js.map +0 -1
- package/dist/_chunks/due-date-calculator-Cc4dRqTI.js.map +0 -1
- package/dist/_chunks/gestational-age-calculator-ZMSrzkRW.js +0 -179
- package/dist/_chunks/gestational-age-calculator-ZMSrzkRW.js.map +0 -1
- package/dist/_chunks/insert-result-DisOY2G-.js +0 -243
- package/dist/_chunks/insert-result-DisOY2G-.js.map +0 -1
- package/dist/_chunks/pregnancy-weight-gain-zZL5Ir2-.js.map +0 -1
- package/dist/_chunks/unit-converter-CuXCXJhK.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { c as
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { R as
|
|
6
|
-
import { R as
|
|
7
|
-
import { F as
|
|
2
|
+
import { forwardRef as ee, useId as te, useState as c, useMemo as ae, useEffect as A } from "react";
|
|
3
|
+
import { c as M } from "./index-D2ZczOXr.js";
|
|
4
|
+
import { useTranslation as le } from "react-i18next";
|
|
5
|
+
import { R as G } from "./radio-TWf9Q-mp.js";
|
|
6
|
+
import { R as ie } from "./radio-group-CLjK-SlK.js";
|
|
7
|
+
import { F as k } from "./form-field-BOm9hK35.js";
|
|
8
8
|
import { N as C } from "./number-input-Dj5L3pXK.js";
|
|
9
|
-
import { C as
|
|
10
|
-
import { C as
|
|
11
|
-
import { B as
|
|
12
|
-
import { I as
|
|
13
|
-
import { a as
|
|
14
|
-
const
|
|
9
|
+
import { C as oe } from "./chart-Cg3e9EH9.js";
|
|
10
|
+
import { C as L } from "./card-DPmk26CL.js";
|
|
11
|
+
import { B as re } from "./badge-zsf5i5bH.js";
|
|
12
|
+
import { I as ne } from "./insert-result-CoC1oo6R.js";
|
|
13
|
+
import { a as S, b as se, e as ce, c as me, f as H, l as V, k as ue } from "./bmi-BxD-tFzU.js";
|
|
14
|
+
const de = M("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
15
15
|
variants: {
|
|
16
16
|
width: {
|
|
17
17
|
full: "ds:w-full",
|
|
@@ -19,12 +19,12 @@ const se = K("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
defaultVariants: { width: "full" }
|
|
22
|
-
}),
|
|
22
|
+
}), ge = {
|
|
23
23
|
underweight: "info",
|
|
24
24
|
normal: "success",
|
|
25
25
|
overweight: "warning",
|
|
26
26
|
obese: "error"
|
|
27
|
-
},
|
|
27
|
+
}, O = M("", {
|
|
28
28
|
variants: {
|
|
29
29
|
category: {
|
|
30
30
|
underweight: "--info",
|
|
@@ -33,85 +33,89 @@ const se = K("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
33
33
|
obese: "--destructive"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
}),
|
|
37
|
-
function
|
|
36
|
+
}), W = "--color-orange-600";
|
|
37
|
+
function be(i) {
|
|
38
38
|
if (typeof document > "u") return;
|
|
39
|
-
const
|
|
40
|
-
return
|
|
39
|
+
const o = document.documentElement, r = getComputedStyle(o), n = i === "overweight" && o.classList.contains("theme-light") && !o.classList.contains("theme-accessible") ? W : O({ category: i });
|
|
40
|
+
return r.getPropertyValue(n).trim() || void 0;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
function K(i) {
|
|
43
|
+
return typeof document < "u" && i === "overweight" && document.documentElement.classList.contains("theme-light") && !document.documentElement.classList.contains("theme-accessible") ? W : O({ category: i });
|
|
44
|
+
}
|
|
45
|
+
function he(i) {
|
|
46
|
+
const [o, r] = c(void 0);
|
|
47
|
+
return A(() => {
|
|
45
48
|
if (i === null) {
|
|
46
|
-
|
|
49
|
+
r(void 0);
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
49
|
-
const n = () =>
|
|
52
|
+
const n = () => r(be(i));
|
|
50
53
|
if (n(), typeof document > "u") return;
|
|
51
54
|
const f = new MutationObserver(n);
|
|
52
55
|
return f.observe(document.documentElement, {
|
|
53
56
|
attributes: !0,
|
|
54
57
|
attributeFilter: ["class"]
|
|
55
58
|
}), () => f.disconnect();
|
|
56
|
-
}, [i]),
|
|
59
|
+
}, [i]), o;
|
|
57
60
|
}
|
|
58
|
-
const y = (i) => Math.round(i * 10) / 10,
|
|
61
|
+
const y = (i) => Math.round(i * 10) / 10, fe = ee(
|
|
59
62
|
({
|
|
60
63
|
defaultUnitSystem: i = "metric",
|
|
61
|
-
onResultChange:
|
|
62
|
-
onInsert:
|
|
64
|
+
onResultChange: o,
|
|
65
|
+
onInsert: r,
|
|
63
66
|
insertVariant: n = "insert",
|
|
64
67
|
onCopy: f,
|
|
65
|
-
onError:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
onError: D,
|
|
69
|
+
insertBrand: _,
|
|
70
|
+
id: j,
|
|
71
|
+
width: z,
|
|
72
|
+
className: P
|
|
73
|
+
}, R) => {
|
|
74
|
+
const { t: e, i18n: w } = le(), N = te(), [m, U] = c(i), [p, T] = c(null), [v, F] = c(null), [u, $] = c(null), [d, I] = c(null), [g, B] = c(null), Y = (Q) => {
|
|
75
|
+
const x = Q;
|
|
72
76
|
if (x !== m) {
|
|
73
77
|
if (x === "imperial") {
|
|
74
|
-
if (
|
|
75
|
-
const { ft:
|
|
76
|
-
$(
|
|
78
|
+
if (p !== null) {
|
|
79
|
+
const { ft: X, in: Z } = me(p);
|
|
80
|
+
$(X), I(y(Z));
|
|
77
81
|
}
|
|
78
|
-
|
|
82
|
+
v !== null && B(y(ue(v)));
|
|
79
83
|
} else
|
|
80
|
-
(u !== null || d !== null) &&
|
|
81
|
-
|
|
84
|
+
(u !== null || d !== null) && T(y(H(u ?? 0, d ?? 0))), g !== null && F(y(V(g)));
|
|
85
|
+
U(x);
|
|
82
86
|
}
|
|
83
|
-
},
|
|
87
|
+
}, q = m === "metric" ? p : u !== null || d !== null ? H(u ?? 0, d ?? 0) : null, J = m === "metric" ? v : g !== null ? V(g) : null, l = ce(J, q), a = l !== null ? se(l) : null, E = he(a), b = ae(
|
|
84
88
|
() => new Intl.NumberFormat(w.language, {
|
|
85
89
|
minimumFractionDigits: 1,
|
|
86
90
|
maximumFractionDigits: 1
|
|
87
91
|
}),
|
|
88
92
|
[w.language]
|
|
89
93
|
);
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
A(() => {
|
|
95
|
+
o == null || o(
|
|
92
96
|
l !== null && a !== null ? { bmi: l, category: a } : null
|
|
93
97
|
);
|
|
94
|
-
}, [l, a,
|
|
95
|
-
const
|
|
98
|
+
}, [l, a, o]);
|
|
99
|
+
const h = m === "metric";
|
|
96
100
|
return /* @__PURE__ */ s(
|
|
97
101
|
"div",
|
|
98
102
|
{
|
|
99
|
-
ref:
|
|
103
|
+
ref: R,
|
|
100
104
|
"data-component": "bmi-calculator",
|
|
101
|
-
"data-component-id":
|
|
102
|
-
className:
|
|
105
|
+
"data-component-id": j,
|
|
106
|
+
className: de({ width: z, className: P }),
|
|
103
107
|
children: [
|
|
104
108
|
/* @__PURE__ */ s(
|
|
105
|
-
|
|
109
|
+
ie,
|
|
106
110
|
{
|
|
107
111
|
label: e("bmiCalculator.unitSystem.label"),
|
|
108
112
|
variant: "horizontal",
|
|
109
113
|
value: m,
|
|
110
|
-
onValueChange:
|
|
114
|
+
onValueChange: Y,
|
|
111
115
|
children: [
|
|
112
|
-
/* @__PURE__ */ t(
|
|
116
|
+
/* @__PURE__ */ t(G, { label: e("bmiCalculator.unitSystem.metric"), value: "metric" }),
|
|
113
117
|
/* @__PURE__ */ t(
|
|
114
|
-
|
|
118
|
+
G,
|
|
115
119
|
{
|
|
116
120
|
label: e("bmiCalculator.unitSystem.imperial"),
|
|
117
121
|
value: "imperial"
|
|
@@ -121,8 +125,8 @@ const y = (i) => Math.round(i * 10) / 10, be = q(
|
|
|
121
125
|
}
|
|
122
126
|
),
|
|
123
127
|
/* @__PURE__ */ s("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2", children: [
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
h ? /* @__PURE__ */ t(
|
|
129
|
+
k,
|
|
126
130
|
{
|
|
127
131
|
label: `${e("bmiCalculator.height")} (${e("bmiCalculator.units.cm")})`,
|
|
128
132
|
children: /* @__PURE__ */ t(
|
|
@@ -131,8 +135,8 @@ const y = (i) => Math.round(i * 10) / 10, be = q(
|
|
|
131
135
|
mode: "decimal",
|
|
132
136
|
min: 0,
|
|
133
137
|
step: 0.5,
|
|
134
|
-
value:
|
|
135
|
-
onChange:
|
|
138
|
+
value: p,
|
|
139
|
+
onChange: T
|
|
136
140
|
}
|
|
137
141
|
)
|
|
138
142
|
}
|
|
@@ -165,7 +169,7 @@ const y = (i) => Math.round(i * 10) / 10, be = q(
|
|
|
165
169
|
max: 11.9,
|
|
166
170
|
step: 0.5,
|
|
167
171
|
value: d,
|
|
168
|
-
onChange:
|
|
172
|
+
onChange: I,
|
|
169
173
|
"aria-label": e("bmiCalculator.inches")
|
|
170
174
|
}
|
|
171
175
|
),
|
|
@@ -173,32 +177,32 @@ const y = (i) => Math.round(i * 10) / 10, be = q(
|
|
|
173
177
|
] })
|
|
174
178
|
] }),
|
|
175
179
|
/* @__PURE__ */ t(
|
|
176
|
-
|
|
180
|
+
k,
|
|
177
181
|
{
|
|
178
182
|
label: `${e("bmiCalculator.weight")} (${e(
|
|
179
|
-
|
|
183
|
+
h ? "bmiCalculator.units.kg" : "bmiCalculator.units.lb"
|
|
180
184
|
)})`,
|
|
181
185
|
children: /* @__PURE__ */ t(
|
|
182
186
|
C,
|
|
183
187
|
{
|
|
184
188
|
mode: "decimal",
|
|
185
189
|
min: 0,
|
|
186
|
-
step:
|
|
187
|
-
value:
|
|
188
|
-
onChange:
|
|
190
|
+
step: h ? 0.1 : 0.5,
|
|
191
|
+
value: h ? v : g,
|
|
192
|
+
onChange: h ? F : B
|
|
189
193
|
}
|
|
190
194
|
)
|
|
191
195
|
}
|
|
192
196
|
)
|
|
193
197
|
] }),
|
|
194
198
|
/* @__PURE__ */ t("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: l !== null && a !== null ? e("bmiCalculator.gaugeAria", {
|
|
195
|
-
bmi:
|
|
199
|
+
bmi: b.format(l),
|
|
196
200
|
category: e(`bmiCalculator.category.${a}`)
|
|
197
201
|
}) : "" }),
|
|
198
|
-
l !== null && a !== null ? /* @__PURE__ */ t(
|
|
202
|
+
l !== null && a !== null ? /* @__PURE__ */ t(L, { variant: "elevated", children: /* @__PURE__ */ s(L.Body, { className: "ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-md)]", children: [
|
|
199
203
|
/* @__PURE__ */ s("div", { className: "ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center", children: [
|
|
200
204
|
/* @__PURE__ */ t("span", { className: "type-label ds:text-muted-foreground", children: e("bmiCalculator.category.label") }),
|
|
201
|
-
/* @__PURE__ */ t(
|
|
205
|
+
/* @__PURE__ */ t(re, { variant: ge[a], size: "lg", children: e(`bmiCalculator.category.${a}`) }),
|
|
202
206
|
/* @__PURE__ */ t("p", { className: "type-body ds:text-muted-foreground", children: e(`bmiCalculator.range.${a}`) })
|
|
203
207
|
] }),
|
|
204
208
|
/* @__PURE__ */ t(
|
|
@@ -207,36 +211,46 @@ const y = (i) => Math.round(i * 10) / 10, be = q(
|
|
|
207
211
|
"data-bmi-category": a,
|
|
208
212
|
className: "ds:w-[240px] ds:max-w-full",
|
|
209
213
|
children: /* @__PURE__ */ t(
|
|
210
|
-
|
|
214
|
+
oe,
|
|
211
215
|
{
|
|
212
216
|
type: "radialBar",
|
|
213
217
|
title: e("bmiCalculator.gaugeAria", {
|
|
214
|
-
bmi:
|
|
218
|
+
bmi: b.format(l),
|
|
215
219
|
category: e(`bmiCalculator.category.${a}`)
|
|
216
220
|
}),
|
|
217
|
-
series: [
|
|
221
|
+
series: [S(l)],
|
|
218
222
|
labels: [e(`bmiCalculator.category.${a}`)],
|
|
219
|
-
colors:
|
|
220
|
-
radialValueFormatter: () =>
|
|
223
|
+
colors: E ? [E] : void 0,
|
|
224
|
+
radialValueFormatter: () => b.format(l),
|
|
221
225
|
height: 240
|
|
222
226
|
}
|
|
223
227
|
)
|
|
224
228
|
}
|
|
225
229
|
),
|
|
226
|
-
n === "copy" ||
|
|
227
|
-
|
|
230
|
+
n === "copy" || r ? /* @__PURE__ */ t(
|
|
231
|
+
ne,
|
|
228
232
|
{
|
|
229
|
-
onInsert:
|
|
233
|
+
onInsert: r,
|
|
230
234
|
variant: n,
|
|
231
235
|
onCopy: f,
|
|
232
|
-
onError:
|
|
236
|
+
onError: D,
|
|
233
237
|
card: {
|
|
234
238
|
title: e("insert.title.bmi"),
|
|
235
239
|
highlight: e(`bmiCalculator.category.${a}`),
|
|
240
|
+
// Chip + gauge arc share the WHO-category semantic token so
|
|
241
|
+
// the inserted PNG matches the on-screen gauge.
|
|
242
|
+
highlightToken: K(a),
|
|
243
|
+
brand: _,
|
|
244
|
+
gauge: {
|
|
245
|
+
value: b.format(l),
|
|
246
|
+
fraction: S(l) / 100,
|
|
247
|
+
colorToken: K(a),
|
|
248
|
+
label: e(`bmiCalculator.category.${a}`)
|
|
249
|
+
},
|
|
236
250
|
fields: [
|
|
237
251
|
{
|
|
238
252
|
label: e("insert.title.bmi"),
|
|
239
|
-
value:
|
|
253
|
+
value: b.format(l)
|
|
240
254
|
},
|
|
241
255
|
{
|
|
242
256
|
label: e("bmiCalculator.category.label"),
|
|
@@ -252,8 +266,8 @@ const y = (i) => Math.round(i * 10) / 10, be = q(
|
|
|
252
266
|
);
|
|
253
267
|
}
|
|
254
268
|
);
|
|
255
|
-
|
|
269
|
+
fe.displayName = "BmiCalculator";
|
|
256
270
|
export {
|
|
257
|
-
|
|
271
|
+
fe as B
|
|
258
272
|
};
|
|
259
|
-
//# sourceMappingURL=bmi-calculator-
|
|
273
|
+
//# sourceMappingURL=bmi-calculator-DFPWL2OJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bmi-calculator-DFPWL2OJ.js","sources":["../../src/components/bmi-calculator/bmi-calculator.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* BmiCalculator — height + weight → WHO body-mass-index, shown on a */\n/* radialBar gauge. */\n/* */\n/* - Maths + unit conversion live in `./bmi` (pure, separately tested). */\n/* - Metric ⇄ imperial toggle persists the entered figures across the */\n/* switch by converting them (a patient measured in lb/ft doesn't */\n/* lose their numbers when a clinician flips to kg/cm). */\n/* - The gauge reuses the kit `Chart` (radialBar). Because ApexCharts */\n/* reads a radialBar series value as a 0–100 percent, the arc is fed */\n/* the BMI mapped onto the clinical 12–40 span and the true BMI is */\n/* printed in the centre via `radialValueFormatter`. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useId, useMemo, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { RadioGroup, Radio } from '../radio-group';\nimport { FormField } from '../form-field';\nimport { NumberInput } from '../number-input';\nimport { Chart } from '../chart';\nimport { Card } from '../card';\nimport { Badge } from '../badge';\nimport {\n InsertButton,\n type InsertPayload,\n type InsertVariant,\n type InsertMode,\n} from '../_shared/insert-result';\nimport {\n type UnitSystem,\n type BmiCategory,\n computeBmi,\n bmiCategory,\n bmiToGaugePercent,\n cmToFtIn,\n ftInToCm,\n kgToLb,\n lbToKg,\n} from './bmi';\n\n/* ------------------------------------------------------------------ */\n/* Result payload emitted to consumers */\n/* ------------------------------------------------------------------ */\n\nexport interface BmiResult {\n /** BMI in kg/m². */\n bmi: number;\n /** WHO category the BMI falls into. */\n category: BmiCategory;\n}\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst rootVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]', {\n variants: {\n width: {\n full: 'ds:w-full',\n auto: 'ds:inline-flex',\n },\n },\n defaultVariants: { width: 'full' },\n});\n\n/* ------------------------------------------------------------------ */\n/* Category → semantic intent for the Stat headline */\n/* ------------------------------------------------------------------ */\n\nconst CATEGORY_BADGE: Record<\n BmiCategory,\n 'info' | 'success' | 'warning' | 'error'\n> = {\n underweight: 'info',\n normal: 'success',\n overweight: 'warning',\n obese: 'error',\n};\n\n/* ------------------------------------------------------------------ */\n/* Gauge arc colour — semantic-token-per-WHO-category. */\n/* */\n/* The CVA below emits the *token NAME* (not a colour) for each */\n/* category. ApexCharts can't read `var(--…)`, so the component samples */\n/* the live token off the theme root with `getComputedStyle` and hands */\n/* the resolved string to `<Chart colors={[…]} />` — re-resolving on */\n/* every html-class change (theme switch) via a MutationObserver. */\n/* */\n/* underweight → --info · normal → --success · overweight → --warning · */\n/* obese → --destructive. */\n/* */\n/* Light-theme override: `--warning` is yellow-500, which only reaches */\n/* ~3.2:1 on white and fails the 3:1 non-text bar for the arc. In */\n/* light, non-accessible mode the overweight arc instead resolves */\n/* `--color-orange-600` (3.52:1 on white — passes). Dark and the */\n/* accessible themes keep `--warning`, whose deepened ramp already */\n/* clears the bar against their surfaces. */\n/* ------------------------------------------------------------------ */\n\nconst gaugeColorVariants = cva('', {\n variants: {\n category: {\n underweight: '--info',\n normal: '--success',\n overweight: '--warning',\n obese: '--destructive',\n },\n },\n});\n\n/** Token substituted for the overweight arc in light, non-accessible mode. */\nconst OVERWEIGHT_LIGHT_TOKEN = '--color-orange-600';\n\n/**\n * Read a CSS custom property off the theme root, resolved to a concrete\n * colour string ApexCharts can consume. Returns `undefined` outside a DOM.\n */\nfunction resolveGaugeColor(category: BmiCategory): string | undefined {\n if (typeof document === 'undefined') return undefined;\n const root = document.documentElement;\n const styles = getComputedStyle(root);\n // The overweight `--warning` yellow fails 3:1 on white — substitute the\n // orange token, but ONLY in light, non-accessible mode (the scope where the\n // contrast gap exists). Mirrors `.theme-light:not(.theme-accessible)`.\n const token =\n category === 'overweight' &&\n root.classList.contains('theme-light') &&\n !root.classList.contains('theme-accessible')\n ? OVERWEIGHT_LIGHT_TOKEN\n : gaugeColorVariants({ category });\n return styles.getPropertyValue(token).trim() || undefined;\n}\n\n/**\n * The DS token NAME for a category's gauge arc, mirroring `resolveGaugeColor`'s\n * theme-aware overweight override. Passed to the result card's `gauge.colorToken`\n * (and chip `highlightToken`) so the inserted PNG arc matches the on-screen one;\n * `InsertButton` resolves the name to a concrete colour at raster time.\n */\nfunction gaugeColorToken(category: BmiCategory): string {\n if (\n typeof document !== 'undefined' &&\n category === 'overweight' &&\n document.documentElement.classList.contains('theme-light') &&\n !document.documentElement.classList.contains('theme-accessible')\n ) {\n return OVERWEIGHT_LIGHT_TOKEN;\n }\n return gaugeColorVariants({ category });\n}\n\n/**\n * Resolve the gauge arc colour for the current category, re-sampling whenever\n * the html-class flips (theme switch). `null` category → no colour.\n */\nfunction useGaugeColor(category: BmiCategory | null): string | undefined {\n const [color, setColor] = useState<string | undefined>(undefined);\n useEffect(() => {\n if (category === null) {\n setColor(undefined);\n return undefined;\n }\n const read = () => setColor(resolveGaugeColor(category));\n read();\n if (typeof document === 'undefined') return undefined;\n const observer = new MutationObserver(read);\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class'],\n });\n return () => observer.disconnect();\n }, [category]);\n return color;\n}\n\nexport interface BmiCalculatorProps extends VariantProps<typeof rootVariants> {\n /** Initial unit system. Defaults to `'metric'`. */\n defaultUnitSystem?: UnitSystem;\n /** Fires whenever a valid BMI can be computed (and with `null` when it can't). */\n onResultChange?: (result: BmiResult | null) => void;\n /** When provided, shows an \"Insert\" button that emits the result for an editor. */\n onInsert?: (payload: InsertPayload) => void;\n /**\n * Which verb the result button performs. Defaults to `'insert'`.\n * Use `'copy'` in an app-shell surface (no editor to insert into) — the\n * button writes the result to the clipboard as a multi-format `ClipboardItem`.\n */\n insertVariant?: InsertVariant;\n /** `copy` variant only — fired after a successful clipboard write. */\n onCopy?: (mode: InsertMode) => void;\n /** `copy` variant only — fired if the clipboard write can't proceed. */\n onError?: (error: unknown) => void;\n /**\n * Brand wordmark printed in the inserted/copied result-card footer.\n * Omitted → the default `'AlfaDocs'` wordmark; a string overrides it;\n * `false` removes the brand line.\n */\n insertBrand?: string | false;\n /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\n/** Round to one decimal place — used when seeding a unit-switch. */\nconst round1 = (n: number): number => Math.round(n * 10) / 10;\n\nexport const BmiCalculator = forwardRef<HTMLDivElement, BmiCalculatorProps>(\n (\n {\n defaultUnitSystem = 'metric',\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n insertBrand,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const heightGroupId = useId();\n\n const [unitSystem, setUnitSystem] = useState<UnitSystem>(defaultUnitSystem);\n\n // Raw per-system inputs. Metric is canonical for cm/kg; imperial keeps\n // ft + in + lb so typing isn't fought by rounding round-trips.\n const [heightCm, setHeightCm] = useState<number | null>(null);\n const [weightKg, setWeightKg] = useState<number | null>(null);\n const [heightFt, setHeightFt] = useState<number | null>(null);\n const [heightIn, setHeightIn] = useState<number | null>(null);\n const [weightLb, setWeightLb] = useState<number | null>(null);\n\n const handleUnitChange = (next: string): void => {\n const target = next as UnitSystem;\n if (target === unitSystem) return;\n if (target === 'imperial') {\n if (heightCm !== null) {\n const { ft, in: inches } = cmToFtIn(heightCm);\n setHeightFt(ft);\n setHeightIn(round1(inches));\n }\n if (weightKg !== null) setWeightLb(round1(kgToLb(weightKg)));\n } else {\n if (heightFt !== null || heightIn !== null) {\n setHeightCm(round1(ftInToCm(heightFt ?? 0, heightIn ?? 0)));\n }\n if (weightLb !== null) setWeightKg(round1(lbToKg(weightLb)));\n }\n setUnitSystem(target);\n };\n\n /* Canonical metric figures for the active system. */\n const canonicalHeightCm =\n unitSystem === 'metric'\n ? heightCm\n : heightFt !== null || heightIn !== null\n ? ftInToCm(heightFt ?? 0, heightIn ?? 0)\n : null;\n const canonicalWeightKg =\n unitSystem === 'metric'\n ? weightKg\n : weightLb !== null\n ? lbToKg(weightLb)\n : null;\n\n const bmi = computeBmi(canonicalWeightKg, canonicalHeightCm);\n const category = bmi !== null ? bmiCategory(bmi) : null;\n\n // Resolved arc colour for the active category + theme (ApexCharts can't\n // read CSS vars, so we sample the token off the theme root).\n const gaugeColor = useGaugeColor(category);\n\n const bmiFormatter = useMemo(\n () =>\n new Intl.NumberFormat(i18n.language, {\n minimumFractionDigits: 1,\n maximumFractionDigits: 1,\n }),\n [i18n.language],\n );\n\n // Notify consumers without re-firing on unrelated re-renders.\n useEffect(() => {\n onResultChange?.(\n bmi !== null && category !== null ? { bmi, category } : null,\n );\n }, [bmi, category, onResultChange]);\n\n const isMetric = unitSystem === 'metric';\n\n return (\n <div\n ref={ref}\n data-component=\"bmi-calculator\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <RadioGroup\n label={t('bmiCalculator.unitSystem.label')}\n variant=\"horizontal\"\n value={unitSystem}\n onValueChange={handleUnitChange}\n >\n <Radio label={t('bmiCalculator.unitSystem.metric')} value=\"metric\" />\n <Radio\n label={t('bmiCalculator.unitSystem.imperial')}\n value=\"imperial\"\n />\n </RadioGroup>\n\n <div className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2\">\n {isMetric ? (\n <FormField\n label={`${t('bmiCalculator.height')} (${t('bmiCalculator.units.cm')})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n step={0.5}\n value={heightCm}\n onChange={setHeightCm}\n />\n </FormField>\n ) : (\n <div role=\"group\" aria-labelledby={heightGroupId}>\n <span\n id={heightGroupId}\n className=\"type-label ds:mb-[var(--spacing-xs)] ds:block ds:text-foreground\"\n >\n {t('bmiCalculator.height')}\n </span>\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <NumberInput\n mode=\"integer\"\n min={0}\n value={heightFt}\n onChange={setHeightFt}\n aria-label={t('bmiCalculator.feet')}\n />\n <span className=\"type-label ds:text-muted-foreground\">\n {t('bmiCalculator.units.ft')}\n </span>\n <NumberInput\n mode=\"decimal\"\n min={0}\n max={11.9}\n step={0.5}\n value={heightIn}\n onChange={setHeightIn}\n aria-label={t('bmiCalculator.inches')}\n />\n <span className=\"type-label ds:text-muted-foreground\">\n {t('bmiCalculator.units.in')}\n </span>\n </div>\n </div>\n )}\n\n <FormField\n label={`${t('bmiCalculator.weight')} (${t(\n isMetric ? 'bmiCalculator.units.kg' : 'bmiCalculator.units.lb',\n )})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n step={isMetric ? 0.1 : 0.5}\n value={isMetric ? weightKg : weightLb}\n onChange={isMetric ? setWeightKg : setWeightLb}\n />\n </FormField>\n </div>\n\n {/* Concise polite announcement when the result resolves — the gauge\n itself stays out of the live region to avoid re-reading on every\n keystroke. */}\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {bmi !== null && category !== null\n ? t('bmiCalculator.gaugeAria', {\n bmi: bmiFormatter.format(bmi),\n category: t(`bmiCalculator.category.${category}`),\n })\n : ''}\n </p>\n\n {bmi !== null && category !== null ? (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-md)]\">\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('bmiCalculator.category.label')}\n </span>\n <Badge variant={CATEGORY_BADGE[category]} size=\"lg\">\n {t(`bmiCalculator.category.${category}`)}\n </Badge>\n <p className=\"type-body ds:text-muted-foreground\">\n {t(`bmiCalculator.range.${category}`)}\n </p>\n </div>\n {/* `data-bmi-category` exposes the WHO band so the gauge arc's\n semantic colour is assertable without sampling the canvas. */}\n <div\n data-bmi-category={category}\n className=\"ds:w-[240px] ds:max-w-full\"\n >\n <Chart\n type=\"radialBar\"\n title={t('bmiCalculator.gaugeAria', {\n bmi: bmiFormatter.format(bmi),\n category: t(`bmiCalculator.category.${category}`),\n })}\n series={[bmiToGaugePercent(bmi)]}\n labels={[t(`bmiCalculator.category.${category}`)]}\n colors={gaugeColor ? [gaugeColor] : undefined}\n radialValueFormatter={() => bmiFormatter.format(bmi)}\n height={240}\n />\n </div>\n {insertVariant === 'copy' || onInsert ? (\n <InsertButton\n onInsert={onInsert}\n variant={insertVariant}\n onCopy={onCopy}\n onError={onError}\n card={{\n title: t('insert.title.bmi'),\n highlight: t(`bmiCalculator.category.${category}`),\n // Chip + gauge arc share the WHO-category semantic token so\n // the inserted PNG matches the on-screen gauge.\n highlightToken: gaugeColorToken(category),\n brand: insertBrand,\n gauge: {\n value: bmiFormatter.format(bmi),\n fraction: bmiToGaugePercent(bmi) / 100,\n colorToken: gaugeColorToken(category),\n label: t(`bmiCalculator.category.${category}`),\n },\n fields: [\n {\n label: t('insert.title.bmi'),\n value: bmiFormatter.format(bmi),\n },\n {\n label: t('bmiCalculator.category.label'),\n value: t(`bmiCalculator.category.${category}`),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('bmiCalculator.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nBmiCalculator.displayName = 'BmiCalculator';\n"],"names":["rootVariants","cva","CATEGORY_BADGE","gaugeColorVariants","OVERWEIGHT_LIGHT_TOKEN","resolveGaugeColor","category","root","styles","token","gaugeColorToken","useGaugeColor","color","setColor","useState","useEffect","read","observer","round1","n","BmiCalculator","forwardRef","defaultUnitSystem","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","id","width","className","ref","t","i18n","useTranslation","heightGroupId","useId","unitSystem","setUnitSystem","heightCm","setHeightCm","weightKg","setWeightKg","heightFt","setHeightFt","heightIn","setHeightIn","weightLb","setWeightLb","handleUnitChange","next","target","ft","inches","cmToFtIn","kgToLb","ftInToCm","lbToKg","canonicalHeightCm","canonicalWeightKg","bmi","computeBmi","bmiCategory","gaugeColor","bmiFormatter","useMemo","isMetric","jsxs","RadioGroup","jsx","Radio","FormField","NumberInput","Card","Badge","Chart","bmiToGaugePercent","InsertButton"],"mappings":";;;;;;;;;;;;;AAwDA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AQ;AAAA,oBACpC,OAAO2B,EAAE,0BAA0B3B,CAAQ,EAAE;AAAA,kBAAA;AAAA,kBAE/C,QAAQ;AAAA,oBACN;AAAA,sBACE,OAAO2B,EAAE,kBAAkB;AAAA,sBAC3B,OAAOgC,EAAa,OAAOJ,CAAG;AAAA,oBAAA;AAAA,oBAEhC;AAAA,sBACE,OAAO5B,EAAE,8BAA8B;AAAA,sBACvC,OAAOA,EAAE,0BAA0B3B,CAAQ,EAAE;AAAA,oBAAA;AAAA,kBAC/C;AAAA,gBACF;AAAA,cACF;AAAA,YAAA,IAEA;AAAA,UAAA,EAAA,CACN,EAAA,CACF,IAEA,gBAAAgE,EAAC,KAAA,EAAE,WAAU,sCACV,UAAArC,EAAE,qBAAqB,EAAA,CAC1B;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAb,GAAc,cAAc;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as a, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as p } from "react";
|
|
3
|
-
import { D as r } from "./dialog-
|
|
3
|
+
import { D as r } from "./dialog-BTpZV6It.js";
|
|
4
4
|
const u = p(
|
|
5
5
|
({
|
|
6
6
|
trigger: i,
|
|
@@ -37,4 +37,4 @@ u.displayName = "CalculatorDialog";
|
|
|
37
37
|
export {
|
|
38
38
|
u as C
|
|
39
39
|
};
|
|
40
|
-
//# sourceMappingURL=calculator-dialog-
|
|
40
|
+
//# sourceMappingURL=calculator-dialog-D-nfvteH.js.map
|
package/dist/_chunks/{calculator-dialog-DdexHrTP.js.map → calculator-dialog-D-nfvteH.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculator-dialog-
|
|
1
|
+
{"version":3,"file":"calculator-dialog-D-nfvteH.js","sources":["../../src/components/calculator-dialog/calculator-dialog.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* CalculatorDialog — shared modal wrapper for the calculator toolset. */\n/* */\n/* Rather than baking Dialog wiring into every calculator, this single */\n/* wrapper composes the kit `Dialog` and hosts ANY calculator (or any */\n/* content) as children. Every calculator therefore gains a modal */\n/* presentation for free: */\n/* */\n/* <CalculatorDialog */\n/* trigger={<Button>Open BMI calculator</Button>} */\n/* title=\"BMI calculator\"> */\n/* <BmiCalculator /> */\n/* </CalculatorDialog> */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, type ReactNode } from 'react';\nimport { Dialog, type DialogContentProps } from '../dialog';\n\nexport interface CalculatorDialogProps {\n /** The element that opens the modal (rendered via `Dialog.Trigger asChild`). */\n trigger: ReactNode;\n /** Modal heading — also names the dialog for assistive tech. */\n title: string;\n /** Optional supporting line under the title. */\n description?: string;\n /** The calculator (or any content) shown inside the modal. */\n children: ReactNode;\n /** Dialog size. Calculators default to `lg` to fit inputs + result. */\n size?: DialogContentProps['size'];\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n /** Open-state change handler. */\n onOpenChange?: (open: boolean) => void;\n /** Opaque instance id, forwarded to the dialog content. */\n id?: string;\n /** Extra class names on the modal body wrapper. */\n className?: string;\n}\n\nexport const CalculatorDialog = forwardRef<\n HTMLDivElement,\n CalculatorDialogProps\n>(\n (\n {\n trigger,\n title,\n description,\n children,\n size = 'lg',\n open,\n defaultOpen,\n onOpenChange,\n id,\n className,\n },\n ref,\n ) => {\n return (\n <Dialog\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n id={id}\n >\n <Dialog.Trigger asChild>{trigger}</Dialog.Trigger>\n <Dialog.Content ref={ref} size={size}>\n <Dialog.Header>\n <Dialog.Title>{title}</Dialog.Title>\n {description ? (\n <Dialog.Description>{description}</Dialog.Description>\n ) : null}\n </Dialog.Header>\n <div data-component=\"calculator-dialog\" className={className}>\n {children}\n </div>\n </Dialog.Content>\n </Dialog>\n );\n },\n);\n\nCalculatorDialog.displayName = 'CalculatorDialog';\n"],"names":["CalculatorDialog","forwardRef","trigger","title","description","children","size","open","defaultOpen","onOpenChange","id","className","ref","jsxs","Dialog","jsx"],"mappings":";;;AAyCO,MAAMA,IAAmBC;AAAA,EAI9B,CACE;AAAA,IACE,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,MAAAC;AAAA,IACA,aAAAC;AAAA,IACA,cAAAC;AAAA,IACA,IAAAC;AAAA,IACA,WAAAC;AAAA,EAAA,GAEFC,MAGE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAP;AAAA,MACA,aAAAC;AAAA,MACA,cAAAC;AAAA,MACA,IAAAC;AAAA,MAEA,UAAA;AAAA,QAAA,gBAAAK,EAACD,EAAO,SAAP,EAAe,SAAO,IAAE,UAAAZ,GAAQ;AAAA,QACjC,gBAAAW,EAACC,EAAO,SAAP,EAAe,KAAAF,GAAU,MAAAN,GACxB,UAAA;AAAA,UAAA,gBAAAO,EAACC,EAAO,QAAP,EACC,UAAA;AAAA,YAAA,gBAAAC,EAACD,EAAO,OAAP,EAAc,UAAAX,EAAA,CAAM;AAAA,YACpBC,IACC,gBAAAW,EAACD,EAAO,aAAP,EAAoB,aAAY,IAC/B;AAAA,UAAA,GACN;AAAA,UACA,gBAAAC,EAAC,OAAA,EAAI,kBAAe,qBAAoB,WAAAJ,GACrC,UAAAN,EAAA,CACH;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;AAEAL,EAAiB,cAAc;"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { c as
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { F as
|
|
6
|
-
import { D as
|
|
7
|
-
import { N as
|
|
8
|
-
import { C as
|
|
9
|
-
import { B as
|
|
10
|
-
import { I } from "./insert-result-
|
|
11
|
-
import { a as
|
|
2
|
+
import { forwardRef as F, useState as L, useMemo as h, useEffect as H } from "react";
|
|
3
|
+
import { c as $ } from "./index-D2ZczOXr.js";
|
|
4
|
+
import { useTranslation as A } from "react-i18next";
|
|
5
|
+
import { F as w } from "./form-field-BOm9hK35.js";
|
|
6
|
+
import { D as I } from "./date-picker-Bq7xhMA-.js";
|
|
7
|
+
import { N as S } from "./number-input-Dj5L3pXK.js";
|
|
8
|
+
import { C as P } from "./card-DPmk26CL.js";
|
|
9
|
+
import { B as v } from "./badge-zsf5i5bH.js";
|
|
10
|
+
import { I as k } from "./insert-result-CoC1oo6R.js";
|
|
11
|
+
import { a as s } from "./date-picker-variants-DLi1Va_e.js";
|
|
12
12
|
import { C as z } from "./check-DPdL_Sm7.js";
|
|
13
13
|
import { H as B } from "./heart-C0faivFf.js";
|
|
14
|
-
import { c as
|
|
14
|
+
import { c as G } from "./createLucideIcon-CrFbzy84.js";
|
|
15
15
|
/**
|
|
16
16
|
* @license lucide-react v1.8.0 - ISC
|
|
17
17
|
*
|
|
@@ -26,77 +26,78 @@ const Y = [
|
|
|
26
26
|
key: "c7niix"
|
|
27
27
|
}
|
|
28
28
|
]
|
|
29
|
-
], j =
|
|
30
|
-
function
|
|
31
|
-
const d = n.cycleLength ??
|
|
32
|
-
start:
|
|
33
|
-
end:
|
|
34
|
-
}, f = i
|
|
29
|
+
], j = G("droplet", Y), x = 28, M = 14, U = 1;
|
|
30
|
+
function K(n, c = 3) {
|
|
31
|
+
const d = n.cycleLength ?? x, { lastPeriodStart: i } = n, o = s(i, d - M), u = {
|
|
32
|
+
start: s(o, -5),
|
|
33
|
+
end: s(o, U)
|
|
34
|
+
}, f = s(i, d), p = Array.from(
|
|
35
35
|
{ length: c },
|
|
36
|
-
(C, g) => i
|
|
36
|
+
(C, g) => s(i, d * (g + 1))
|
|
37
37
|
);
|
|
38
38
|
return { nextPeriod: f, ovulation: o, fertileWindow: u, upcomingPeriods: p };
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const O = $("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
41
41
|
variants: {
|
|
42
42
|
width: { full: "ds:w-full", auto: "ds:inline-flex" }
|
|
43
43
|
},
|
|
44
44
|
defaultVariants: { width: "full" }
|
|
45
|
-
}), q =
|
|
45
|
+
}), V = "--accent", q = F(
|
|
46
46
|
({
|
|
47
|
-
defaultCycleLength: n =
|
|
47
|
+
defaultCycleLength: n = x,
|
|
48
48
|
onResultChange: c,
|
|
49
49
|
onInsert: d,
|
|
50
|
-
insertVariant:
|
|
50
|
+
insertVariant: i = "insert",
|
|
51
51
|
onCopy: o,
|
|
52
52
|
onError: u,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
insertBrand: f,
|
|
54
|
+
id: p,
|
|
55
|
+
width: C,
|
|
56
|
+
className: g
|
|
57
|
+
}, b) => {
|
|
58
|
+
const { t: a, i18n: N } = A(), [m, D] = L(void 0), [y, E] = L(
|
|
58
59
|
n
|
|
59
|
-
), t =
|
|
60
|
+
), t = h(() => m ? K({
|
|
60
61
|
lastPeriodStart: m,
|
|
61
|
-
cycleLength: y ??
|
|
62
|
-
}) : null, [m, y]),
|
|
62
|
+
cycleLength: y ?? x
|
|
63
|
+
}) : null, [m, y]), T = h(
|
|
63
64
|
() => new Intl.DateTimeFormat(N.language, { dateStyle: "medium" }),
|
|
64
65
|
[N.language]
|
|
65
66
|
);
|
|
66
|
-
|
|
67
|
+
H(() => {
|
|
67
68
|
c == null || c(t);
|
|
68
69
|
}, [t, c]);
|
|
69
|
-
const _ =
|
|
70
|
+
const _ = h(() => /* @__PURE__ */ new Date(), []), l = (W) => T.format(W);
|
|
70
71
|
return /* @__PURE__ */ r(
|
|
71
72
|
"div",
|
|
72
73
|
{
|
|
73
|
-
ref:
|
|
74
|
+
ref: b,
|
|
74
75
|
"data-component": "cycle-calculator",
|
|
75
|
-
"data-component-id":
|
|
76
|
-
className:
|
|
76
|
+
"data-component-id": p,
|
|
77
|
+
className: O({ width: C, className: g }),
|
|
77
78
|
children: [
|
|
78
79
|
/* @__PURE__ */ r("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2", children: [
|
|
79
|
-
/* @__PURE__ */ e(
|
|
80
|
-
|
|
80
|
+
/* @__PURE__ */ e(w, { label: a("cycleCalculator.lastPeriod"), children: /* @__PURE__ */ e(
|
|
81
|
+
I,
|
|
81
82
|
{
|
|
82
83
|
value: m,
|
|
83
|
-
onChange:
|
|
84
|
+
onChange: D,
|
|
84
85
|
maxDate: _
|
|
85
86
|
}
|
|
86
87
|
) }),
|
|
87
88
|
/* @__PURE__ */ e(
|
|
88
|
-
|
|
89
|
+
w,
|
|
89
90
|
{
|
|
90
91
|
label: a("cycleCalculator.cycleLength"),
|
|
91
92
|
description: a("cycleCalculator.cycleLengthHint"),
|
|
92
93
|
children: /* @__PURE__ */ e(
|
|
93
|
-
|
|
94
|
+
S,
|
|
94
95
|
{
|
|
95
96
|
mode: "integer",
|
|
96
97
|
min: 20,
|
|
97
98
|
max: 45,
|
|
98
99
|
value: y,
|
|
99
|
-
onChange:
|
|
100
|
+
onChange: E
|
|
100
101
|
}
|
|
101
102
|
)
|
|
102
103
|
}
|
|
@@ -105,12 +106,12 @@ const V = T("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
105
106
|
/* @__PURE__ */ e("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: t ? `${a("cycleCalculator.ovulation")}: ${l(t.ovulation)}. ${a(
|
|
106
107
|
"cycleCalculator.nextPeriod"
|
|
107
108
|
)}: ${l(t.nextPeriod)}.` : "" }),
|
|
108
|
-
t ? /* @__PURE__ */ e(
|
|
109
|
+
t ? /* @__PURE__ */ e(P, { variant: "elevated", children: /* @__PURE__ */ r(P.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
|
|
109
110
|
/* @__PURE__ */ r("dl", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-3", children: [
|
|
110
111
|
/* @__PURE__ */ r("div", { className: "ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center", children: [
|
|
111
112
|
/* @__PURE__ */ e("dt", { className: "type-label ds:text-muted-foreground", children: a("cycleCalculator.ovulation") }),
|
|
112
113
|
/* @__PURE__ */ e("dd", { children: /* @__PURE__ */ e(
|
|
113
|
-
|
|
114
|
+
v,
|
|
114
115
|
{
|
|
115
116
|
variant: "success",
|
|
116
117
|
size: "lg",
|
|
@@ -122,7 +123,7 @@ const V = T("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
122
123
|
/* @__PURE__ */ r("div", { className: "ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center", children: [
|
|
123
124
|
/* @__PURE__ */ e("dt", { className: "type-label ds:text-muted-foreground", children: a("cycleCalculator.fertileWindow") }),
|
|
124
125
|
/* @__PURE__ */ e("dd", { children: /* @__PURE__ */ r(
|
|
125
|
-
|
|
126
|
+
v,
|
|
126
127
|
{
|
|
127
128
|
variant: "accent",
|
|
128
129
|
size: "lg",
|
|
@@ -139,7 +140,7 @@ const V = T("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
139
140
|
/* @__PURE__ */ r("div", { className: "ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center", children: [
|
|
140
141
|
/* @__PURE__ */ e("dt", { className: "type-label ds:text-muted-foreground", children: a("cycleCalculator.nextPeriod") }),
|
|
141
142
|
/* @__PURE__ */ e("dd", { children: /* @__PURE__ */ e(
|
|
142
|
-
|
|
143
|
+
v,
|
|
143
144
|
{
|
|
144
145
|
variant: "error",
|
|
145
146
|
size: "lg",
|
|
@@ -149,15 +150,22 @@ const V = T("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
149
150
|
) })
|
|
150
151
|
] })
|
|
151
152
|
] }),
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
i === "copy" || d ? /* @__PURE__ */ e(
|
|
154
|
+
k,
|
|
154
155
|
{
|
|
155
156
|
onInsert: d,
|
|
156
|
-
variant:
|
|
157
|
+
variant: i,
|
|
157
158
|
onCopy: o,
|
|
158
159
|
onError: u,
|
|
159
160
|
card: {
|
|
160
161
|
title: a("insert.title.cycle"),
|
|
162
|
+
highlight: `${l(t.fertileWindow.start)} – ${l(
|
|
163
|
+
t.fertileWindow.end
|
|
164
|
+
)}`,
|
|
165
|
+
// Chip reuses the on-screen fertile-window badge's accent
|
|
166
|
+
// token so the inserted PNG chip matches the screen.
|
|
167
|
+
highlightToken: V,
|
|
168
|
+
brand: f,
|
|
161
169
|
fields: [
|
|
162
170
|
{
|
|
163
171
|
label: a("cycleCalculator.ovulation"),
|
|
@@ -187,6 +195,6 @@ q.displayName = "CycleCalculator";
|
|
|
187
195
|
export {
|
|
188
196
|
q as C,
|
|
189
197
|
M as L,
|
|
190
|
-
|
|
198
|
+
K as p
|
|
191
199
|
};
|
|
192
|
-
//# sourceMappingURL=cycle-calculator-
|
|
200
|
+
//# sourceMappingURL=cycle-calculator-ChHBcjet.js.map
|