@alfadocs/ui-kit 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/{calculator-dialog-DdexHrTP.js → calculator-dialog-D-nfvteH.js} +2 -2
- package/dist/_chunks/{cycle-calculator-Dln-y1k_.js → cycle-calculator-ChHBcjet.js} +58 -50
- package/dist/_chunks/dialog-BTpZV6It.js +223 -0
- package/dist/_chunks/{due-date-calculator-Cc4dRqTI.js → due-date-calculator-CYXKLoof.js} +50 -38
- package/dist/_chunks/gestational-age-calculator-sRmoqgVr.js +190 -0
- package/dist/_chunks/insert-result-CoC1oo6R.js +334 -0
- package/dist/_chunks/{pregnancy-weight-gain-zZL5Ir2-.js → pregnancy-weight-gain-C5YhfYnL.js} +66 -57
- package/dist/_chunks/{unit-converter-CuXCXJhK.js → unit-converter-Ds9jalbN.js} +78 -67
- package/dist/agent-catalog.json +1 -1
- package/dist/components/_shared/index.d.ts +1 -1
- package/dist/components/_shared/insert-result.d.ts +100 -10
- package/dist/components/bmi-calculator/bmi-calculator.d.ts +6 -0
- 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/index.js +1 -1
- package/dist/components/dialog/dialog.d.ts +1 -0
- 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/index.js +1 -1
- package/dist/components/gestational-age-calculator/gestational-age-calculator.d.ts +6 -0
- package/dist/components/gestational-age-calculator/index.js +1 -1
- package/dist/components/index.d.ts +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/unit-converter/index.js +1 -1
- package/dist/components/unit-converter/unit-converter.d.ts +6 -0
- package/dist/index.js +494 -493
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/dialog-DOYgd75U.js +0 -224
- package/dist/_chunks/gestational-age-calculator-ZMSrzkRW.js +0 -179
- package/dist/_chunks/insert-result-DisOY2G-.js +0 -243
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { jsxs as E, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as J, useRef as Q } from "react";
|
|
3
|
+
import { useTranslation as Z } from "react-i18next";
|
|
4
|
+
import { c as tt } from "./index-D2ZczOXr.js";
|
|
5
|
+
import { B as et } from "./button-DD_0Xdmr.js";
|
|
6
|
+
import { c as L } from "./createLucideIcon-CrFbzy84.js";
|
|
7
|
+
import { I as nt } from "./image-C6RM5hfF.js";
|
|
8
|
+
/**
|
|
9
|
+
* @license lucide-react v1.8.0 - ISC
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the ISC license.
|
|
12
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/
|
|
14
|
+
const ot = [
|
|
15
|
+
[
|
|
16
|
+
"path",
|
|
17
|
+
{
|
|
18
|
+
d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
|
|
19
|
+
key: "zw3jo"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"path",
|
|
24
|
+
{
|
|
25
|
+
d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
|
|
26
|
+
key: "1wduqc"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
"path",
|
|
31
|
+
{
|
|
32
|
+
d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
|
|
33
|
+
key: "kqbvx6"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
], at = L("layers", ot);
|
|
37
|
+
/**
|
|
38
|
+
* @license lucide-react v1.8.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/
|
|
43
|
+
const it = [
|
|
44
|
+
["path", { d: "M12 4v16", key: "1654pz" }],
|
|
45
|
+
["path", { d: "M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2", key: "e0r10z" }],
|
|
46
|
+
["path", { d: "M9 20h6", key: "s66wpe" }]
|
|
47
|
+
], rt = L("type", it), st = ["fg", "muted", "accent", "border", "bg"], N = "--primary", D = 380, H = (t) => t.trim().replace(/^--/, "");
|
|
48
|
+
function R(t) {
|
|
49
|
+
const e = /* @__PURE__ */ new Set();
|
|
50
|
+
if (t.highlight) {
|
|
51
|
+
const o = t.highlightToken ?? N;
|
|
52
|
+
e.add(o), e.add(`${o}-foreground`);
|
|
53
|
+
}
|
|
54
|
+
return t.gauge && e.add(t.gauge.colorToken), [...e];
|
|
55
|
+
}
|
|
56
|
+
function M(t, e = []) {
|
|
57
|
+
const o = {
|
|
58
|
+
fg: "currentColor",
|
|
59
|
+
muted: "currentColor",
|
|
60
|
+
accent: "currentColor",
|
|
61
|
+
border: "currentColor",
|
|
62
|
+
bg: "transparent",
|
|
63
|
+
font: "sans-serif",
|
|
64
|
+
tokens: {}
|
|
65
|
+
};
|
|
66
|
+
if (!t) return o;
|
|
67
|
+
const n = (a) => {
|
|
68
|
+
const r = t.querySelector(`[data-k="${a}"]`);
|
|
69
|
+
return r && getComputedStyle(r).color || "currentColor";
|
|
70
|
+
}, i = {};
|
|
71
|
+
for (const a of e) {
|
|
72
|
+
const r = t.querySelector(
|
|
73
|
+
`[data-token="${H(a)}"]`
|
|
74
|
+
);
|
|
75
|
+
if (r) {
|
|
76
|
+
const u = getComputedStyle(r).color;
|
|
77
|
+
u && (i[a] = u);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
fg: n("fg"),
|
|
82
|
+
muted: n("muted"),
|
|
83
|
+
accent: n("accent"),
|
|
84
|
+
border: n("border"),
|
|
85
|
+
bg: n("bg"),
|
|
86
|
+
font: getComputedStyle(t).fontFamily || "sans-serif",
|
|
87
|
+
tokens: i
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function _(t, e, o) {
|
|
91
|
+
var n;
|
|
92
|
+
return e ? ((n = t.tokens) == null ? void 0 : n[e]) ?? o : o;
|
|
93
|
+
}
|
|
94
|
+
const f = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
95
|
+
function O(t) {
|
|
96
|
+
const e = [t.title];
|
|
97
|
+
t.highlight && e.push(t.highlight);
|
|
98
|
+
for (const o of t.fields) e.push(`• ${o.label}: ${o.value}`);
|
|
99
|
+
return e.join(`
|
|
100
|
+
`);
|
|
101
|
+
}
|
|
102
|
+
function Y(t) {
|
|
103
|
+
const e = t.fields.map((n) => `<li>${f(n.label)}: ${f(n.value)}</li>`).join(""), o = t.highlight ? `<p><strong>${f(t.highlight)}</strong></p>` : "";
|
|
104
|
+
return `<p><strong>${f(t.title)}</strong></p>${o}<ul>${e}</ul>`;
|
|
105
|
+
}
|
|
106
|
+
const z = "AlfaDocs", m = 20, y = m + 18, T = 22, lt = 10, B = 22, S = 16, F = 12, ct = 12, V = 34, U = 9, k = (V + U) * 2;
|
|
107
|
+
function A(t, e) {
|
|
108
|
+
const o = e !== void 0 ? e : t.brand;
|
|
109
|
+
return o === !1 ? !1 : typeof o == "string" ? o : z;
|
|
110
|
+
}
|
|
111
|
+
function ut(t) {
|
|
112
|
+
if (typeof t.fraction == "number")
|
|
113
|
+
return Math.min(1, Math.max(0, t.fraction));
|
|
114
|
+
const e = parseFloat(t.value);
|
|
115
|
+
return Number.isFinite(e) && typeof t.max == "number" && t.max > 0 ? Math.min(1, Math.max(0, e / t.max)) : 1;
|
|
116
|
+
}
|
|
117
|
+
function W(t, e) {
|
|
118
|
+
const o = !!t.highlight, n = y + lt, i = (o ? n + T + S : y + S) + B - 6, a = i + Math.max(0, t.fields.length - 1) * B, r = o ? n : y, u = t.gauge ? r + k : 0, l = Math.max(a, u), c = e ? l + F + ct - 4 : l, d = Math.round(c + (e ? F : m));
|
|
119
|
+
return { hasChip: o, chipY: n, firstFieldY: i, fieldsEndY: a, footerY: c, height: d };
|
|
120
|
+
}
|
|
121
|
+
function q(t, e) {
|
|
122
|
+
return W(t, e !== !1).height;
|
|
123
|
+
}
|
|
124
|
+
function dt(t, e, o, n, i) {
|
|
125
|
+
const a = V, r = 2 * Math.PI * a, u = ut(t), l = _(e, t.colorToken, e.accent), c = typeof t.segments == "number" && t.segments > 1 ? t.segments : 0, d = c ? 3 : 0, g = c ? r / c - d : r, $ = c ? `${g} ${d}` : "", v = `${r * u} ${r}`, w = `transform="rotate(-90 ${n} ${i})"`, s = f(
|
|
126
|
+
t.label ? `${t.value} — ${t.label}` : t.value
|
|
127
|
+
), x = `<circle cx="${n}" cy="${i}" r="${a}" fill="none" stroke="${e.border}" stroke-width="${U}"${$ ? ` stroke-dasharray="${$}"` : ""} ${w}/>`, h = `<circle cx="${n}" cy="${i}" r="${a}" fill="none" stroke="${l}" stroke-width="${U}" stroke-linecap="round" stroke-dasharray="${v}" ${w}/>`, b = `<text x="${n}" y="${i + 1}" text-anchor="middle" dominant-baseline="middle" font-family="${o}" font-size="16" font-weight="700" fill="${e.fg}">${f(
|
|
128
|
+
t.value
|
|
129
|
+
)}</text>`, C = t.label ? `<text x="${n}" y="${i + 15}" text-anchor="middle" dominant-baseline="middle" font-family="${o}" font-size="9" fill="${e.muted}">${f(
|
|
130
|
+
t.label
|
|
131
|
+
)}</text>` : "";
|
|
132
|
+
return `<g role="img" aria-label="${s}"><title>${s}</title>${x}${h}${b}${C}</g>`;
|
|
133
|
+
}
|
|
134
|
+
function ft(t, e, o, n) {
|
|
135
|
+
const i = t.highlight, a = t.highlightToken ?? N, r = _(e, a, e.accent), u = _(e, `${a}-foreground`, e.bg), l = Math.round(i.length * 7.2 + 28), c = m + l / 2, d = n + T / 2 + 1;
|
|
136
|
+
return `<rect x="${m}" y="${n}" width="${l}" height="${T}" rx="${T / 2}" fill="${r}"/><text x="${c}" y="${d}" text-anchor="middle" dominant-baseline="middle" font-family="${o}" font-size="12" font-weight="600" fill="${u}">${f(
|
|
137
|
+
i
|
|
138
|
+
)}</text>`;
|
|
139
|
+
}
|
|
140
|
+
function P(t, e, o = z) {
|
|
141
|
+
const n = D, i = W(t, o !== !1), a = i.height, r = f(e.font);
|
|
142
|
+
t.gauge ? n - m - k - 12 : n - m;
|
|
143
|
+
const u = t.fields.map((g, $) => {
|
|
144
|
+
const v = i.firstFieldY + $ * B;
|
|
145
|
+
return `<text x="${m}" y="${v}" font-family="${r}" font-size="13"><tspan fill="${e.muted}">${f(
|
|
146
|
+
g.label
|
|
147
|
+
)}: </tspan><tspan fill="${e.fg}">${f(g.value)}</tspan></text>`;
|
|
148
|
+
}).join(""), l = i.hasChip ? ft(t, e, r, i.chipY) : "", c = t.gauge ? dt(
|
|
149
|
+
t.gauge,
|
|
150
|
+
e,
|
|
151
|
+
r,
|
|
152
|
+
n - m - k / 2,
|
|
153
|
+
(i.hasChip ? i.chipY : y) + k / 2
|
|
154
|
+
) : "", d = o !== !1 ? `<text x="${m}" y="${i.footerY}" font-family="${r}" font-size="10" fill="${e.muted}">${f(
|
|
155
|
+
o
|
|
156
|
+
)}</text>` : "";
|
|
157
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${a}" viewBox="0 0 ${n} ${a}" role="img" aria-label="${f(
|
|
158
|
+
t.title
|
|
159
|
+
)}"><rect x="0.5" y="0.5" width="${n - 1}" height="${a - 1}" rx="12" fill="${e.bg}" stroke="${e.border}"/><text x="${m}" y="${y}" font-family="${r}" font-size="16" font-weight="700" fill="${e.fg}">${f(
|
|
160
|
+
t.title
|
|
161
|
+
)}</text>${l}${c}${u}${d}</svg>`;
|
|
162
|
+
}
|
|
163
|
+
function mt() {
|
|
164
|
+
var t;
|
|
165
|
+
return typeof navigator < "u" && typeof ((t = navigator.clipboard) == null ? void 0 : t.write) == "function" && typeof ClipboardItem < "u";
|
|
166
|
+
}
|
|
167
|
+
function j(t, e, o) {
|
|
168
|
+
return new Promise((n, i) => {
|
|
169
|
+
const a = new Image();
|
|
170
|
+
a.decoding = "async", a.onload = () => {
|
|
171
|
+
const r = document.createElement("canvas");
|
|
172
|
+
r.width = e, r.height = o;
|
|
173
|
+
const u = r.getContext("2d");
|
|
174
|
+
if (!u) {
|
|
175
|
+
i(new Error("2D canvas context unavailable"));
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
u.drawImage(a, 0, 0, e, o), r.toBlob((l) => {
|
|
179
|
+
l ? n(l) : i(new Error("canvas.toBlob produced no PNG"));
|
|
180
|
+
}, "image/png");
|
|
181
|
+
}, a.onerror = () => i(new Error("SVG failed to decode as an image")), a.src = t;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function K() {
|
|
185
|
+
const t = typeof window < "u" && typeof window.devicePixelRatio == "number" ? window.devicePixelRatio : 1;
|
|
186
|
+
return Math.max(2, t);
|
|
187
|
+
}
|
|
188
|
+
async function Mt(t, e = {}) {
|
|
189
|
+
return (await X(t, e)).dataUri;
|
|
190
|
+
}
|
|
191
|
+
async function X(t, e = {}) {
|
|
192
|
+
const { colours: o, scale: n = K() } = e, i = o ?? M(null), a = A(t, e.brand), r = P(t, i, a), u = `data:image/svg+xml,${encodeURIComponent(r)}`, l = D, c = q(t, a), d = await j(
|
|
193
|
+
u,
|
|
194
|
+
Math.round(l * n),
|
|
195
|
+
Math.round(c * n)
|
|
196
|
+
);
|
|
197
|
+
return { dataUri: await gt(d), width: l, height: c };
|
|
198
|
+
}
|
|
199
|
+
function gt(t) {
|
|
200
|
+
return new Promise((e, o) => {
|
|
201
|
+
const n = new FileReader();
|
|
202
|
+
n.onload = () => e(String(n.result)), n.onerror = () => o(n.error ?? new Error("FileReader error")), n.readAsDataURL(t);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
async function ht(t, e, o) {
|
|
206
|
+
const n = O(e), i = new Blob([n], { type: "text/plain" });
|
|
207
|
+
if (t === "text")
|
|
208
|
+
return new ClipboardItem({ "text/plain": i });
|
|
209
|
+
const a = A(e, void 0), r = P(e, o, a), u = `data:image/svg+xml,${encodeURIComponent(r)}`, l = K(), c = await j(
|
|
210
|
+
u,
|
|
211
|
+
Math.round(D * l),
|
|
212
|
+
Math.round(q(e, a) * l)
|
|
213
|
+
);
|
|
214
|
+
if (t === "image")
|
|
215
|
+
return new ClipboardItem({ "image/png": c, "text/plain": i });
|
|
216
|
+
const d = new Blob([Y(e)], { type: "text/html" });
|
|
217
|
+
return new ClipboardItem({
|
|
218
|
+
"text/html": d,
|
|
219
|
+
"image/png": c,
|
|
220
|
+
"text/plain": i
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
const pt = tt(
|
|
224
|
+
"ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]",
|
|
225
|
+
{
|
|
226
|
+
variants: {
|
|
227
|
+
variant: {
|
|
228
|
+
insert: "",
|
|
229
|
+
copy: ""
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
defaultVariants: { variant: "insert" }
|
|
233
|
+
}
|
|
234
|
+
), $t = ["text", "image", "text-image"], xt = {
|
|
235
|
+
text: /* @__PURE__ */ p(rt, { "aria-hidden": !0 }),
|
|
236
|
+
image: /* @__PURE__ */ p(nt, { "aria-hidden": !0 }),
|
|
237
|
+
"text-image": /* @__PURE__ */ p(at, { "aria-hidden": !0 })
|
|
238
|
+
}, G = {
|
|
239
|
+
insert: {
|
|
240
|
+
text: "insert.text",
|
|
241
|
+
image: "insert.image",
|
|
242
|
+
"text-image": "insert.textImage"
|
|
243
|
+
},
|
|
244
|
+
copy: {
|
|
245
|
+
text: "insert.copyText",
|
|
246
|
+
image: "insert.copyImage",
|
|
247
|
+
"text-image": "insert.copyTextImage"
|
|
248
|
+
}
|
|
249
|
+
}, bt = J(
|
|
250
|
+
function({
|
|
251
|
+
card: e,
|
|
252
|
+
variant: o = "insert",
|
|
253
|
+
onInsert: n,
|
|
254
|
+
onCopy: i,
|
|
255
|
+
onError: a,
|
|
256
|
+
size: r = "sm",
|
|
257
|
+
intent: u = "primary"
|
|
258
|
+
}, l) {
|
|
259
|
+
const { t: c } = Z(), d = Q(null), g = (s) => {
|
|
260
|
+
const x = O(e), h = Y(e);
|
|
261
|
+
let b = "", C = "";
|
|
262
|
+
const I = s === "text" ? null : M(d.current, R(e));
|
|
263
|
+
return I && (b = P(e, I, A(e, void 0)), C = `data:image/svg+xml,${encodeURIComponent(b)}`), { mode: s, text: x, html: h, svg: b, imageDataUri: C, pngDataUri: () => I ? X(e, { colours: I }) : Promise.resolve({ dataUri: "", width: 0, height: 0 }) };
|
|
264
|
+
}, w = o === "copy" ? (s) => {
|
|
265
|
+
if (!mt()) {
|
|
266
|
+
a == null || a(new Error("Clipboard write unavailable in this context"));
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const x = M(
|
|
270
|
+
d.current,
|
|
271
|
+
R(e)
|
|
272
|
+
);
|
|
273
|
+
(async () => {
|
|
274
|
+
try {
|
|
275
|
+
const h = await ht(s, e, x);
|
|
276
|
+
await navigator.clipboard.write([h]), i == null || i(s);
|
|
277
|
+
} catch (h) {
|
|
278
|
+
a == null || a(h);
|
|
279
|
+
}
|
|
280
|
+
})();
|
|
281
|
+
} : (s) => {
|
|
282
|
+
n == null || n(g(s));
|
|
283
|
+
};
|
|
284
|
+
return /* @__PURE__ */ E(
|
|
285
|
+
"div",
|
|
286
|
+
{
|
|
287
|
+
ref: l,
|
|
288
|
+
"data-component": "insert-result",
|
|
289
|
+
"data-variant": o,
|
|
290
|
+
className: pt({ variant: o }),
|
|
291
|
+
children: [
|
|
292
|
+
/* @__PURE__ */ E("span", { ref: d, "aria-hidden": !0, className: "ds:sr-only", children: [
|
|
293
|
+
st.map((s) => /* @__PURE__ */ p(
|
|
294
|
+
"span",
|
|
295
|
+
{
|
|
296
|
+
"data-k": s,
|
|
297
|
+
className: s === "fg" ? "ds:text-foreground" : s === "muted" ? "ds:text-muted-foreground" : s === "accent" ? "ds:text-[color:var(--primary)]" : s === "border" ? "ds:text-[color:var(--border)]" : "ds:text-[color:var(--card)]"
|
|
298
|
+
},
|
|
299
|
+
s
|
|
300
|
+
)),
|
|
301
|
+
R(e).map((s) => /* @__PURE__ */ p(
|
|
302
|
+
"span",
|
|
303
|
+
{
|
|
304
|
+
"data-token": H(s),
|
|
305
|
+
className: `ds:text-[color:var(${s})]`
|
|
306
|
+
},
|
|
307
|
+
s
|
|
308
|
+
))
|
|
309
|
+
] }),
|
|
310
|
+
$t.map((s) => /* @__PURE__ */ p(
|
|
311
|
+
et,
|
|
312
|
+
{
|
|
313
|
+
type: "button",
|
|
314
|
+
intent: u,
|
|
315
|
+
size: r,
|
|
316
|
+
startIcon: xt[s],
|
|
317
|
+
"aria-label": c(G[o][s]),
|
|
318
|
+
onClick: () => w(s),
|
|
319
|
+
children: c(G[o][s])
|
|
320
|
+
},
|
|
321
|
+
s
|
|
322
|
+
))
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
bt.displayName = "InsertButton";
|
|
329
|
+
export {
|
|
330
|
+
bt as I,
|
|
331
|
+
Mt as a,
|
|
332
|
+
X as s
|
|
333
|
+
};
|
|
334
|
+
//# sourceMappingURL=insert-result-CoC1oo6R.js.map
|
package/dist/_chunks/{pregnancy-weight-gain-zZL5Ir2-.js → pregnancy-weight-gain-C5YhfYnL.js}
RENAMED
|
@@ -1,89 +1,94 @@
|
|
|
1
1
|
import { jsxs as s, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as A, useState as f, useMemo as
|
|
3
|
-
import { c as
|
|
4
|
-
import { useTranslation as
|
|
2
|
+
import { forwardRef as A, useState as f, useMemo as w, useEffect as F } from "react";
|
|
3
|
+
import { c as R } from "./index-D2ZczOXr.js";
|
|
4
|
+
import { useTranslation as k } from "react-i18next";
|
|
5
5
|
import { F as y } from "./form-field-BOm9hK35.js";
|
|
6
6
|
import { N as x } from "./number-input-Dj5L3pXK.js";
|
|
7
|
-
import { C as
|
|
8
|
-
import { B as
|
|
9
|
-
import { I as
|
|
7
|
+
import { C as $ } from "./card-DPmk26CL.js";
|
|
8
|
+
import { B as C } from "./badge-zsf5i5bH.js";
|
|
9
|
+
import { I as H } from "./insert-result-CoC1oo6R.js";
|
|
10
10
|
import { b as M, e as j } from "./bmi-BxD-tFzU.js";
|
|
11
|
-
const
|
|
11
|
+
const L = {
|
|
12
12
|
underweight: { min: 12.5, max: 18 },
|
|
13
13
|
normal: { min: 11.5, max: 16 },
|
|
14
14
|
overweight: { min: 7, max: 11.5 },
|
|
15
15
|
obese: { min: 5, max: 9 }
|
|
16
|
-
},
|
|
16
|
+
}, O = {
|
|
17
17
|
underweight: { min: 0.44, max: 0.58 },
|
|
18
18
|
normal: { min: 0.35, max: 0.5 },
|
|
19
19
|
overweight: { min: 0.23, max: 0.33 },
|
|
20
20
|
obese: { min: 0.17, max: 0.27 }
|
|
21
21
|
}, G = { min: 0.5, max: 2 }, v = 13;
|
|
22
|
-
function
|
|
22
|
+
function U(t, i) {
|
|
23
23
|
if (i <= 0) return { min: 0, max: 0 };
|
|
24
24
|
if (i <= v) {
|
|
25
|
-
const
|
|
25
|
+
const c = i / v;
|
|
26
26
|
return {
|
|
27
|
-
min: G.min *
|
|
28
|
-
max: G.max *
|
|
27
|
+
min: G.min * c,
|
|
28
|
+
max: G.max * c
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const l = Math.min(i, 40) - v, r = O[t];
|
|
32
32
|
return {
|
|
33
|
-
min: G.min + r.min *
|
|
34
|
-
max: G.max + r.max *
|
|
33
|
+
min: G.min + r.min * l,
|
|
34
|
+
max: G.max + r.max * l
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
const i = M(t.prePregnancyBmi),
|
|
37
|
+
function z(t) {
|
|
38
|
+
const i = M(t.prePregnancyBmi), l = L[i], r = U(
|
|
39
39
|
i,
|
|
40
40
|
t.gestationalWeeks
|
|
41
|
-
),
|
|
42
|
-
return { category: i, totalRange:
|
|
41
|
+
), c = t.currentWeightKg - t.prePregnancyWeightKg, W = c < r.min ? "below" : c > r.max ? "above" : "within";
|
|
42
|
+
return { category: i, totalRange: l, recommendedToDate: r, actualGainKg: c, status: W };
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const V = R("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
45
45
|
variants: {
|
|
46
46
|
width: { full: "ds:w-full", auto: "ds:inline-flex" }
|
|
47
47
|
},
|
|
48
48
|
defaultVariants: { width: "full" }
|
|
49
|
-
}),
|
|
49
|
+
}), q = {
|
|
50
50
|
below: "warning",
|
|
51
51
|
within: "success",
|
|
52
52
|
above: "warning"
|
|
53
|
-
},
|
|
53
|
+
}, J = {
|
|
54
|
+
below: "--warning",
|
|
55
|
+
within: "--success",
|
|
56
|
+
above: "--warning"
|
|
57
|
+
}, Q = A(
|
|
54
58
|
({
|
|
55
59
|
onResultChange: t,
|
|
56
60
|
onInsert: i,
|
|
57
|
-
insertVariant:
|
|
61
|
+
insertVariant: l = "insert",
|
|
58
62
|
onCopy: r,
|
|
59
|
-
onError:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
onError: c,
|
|
64
|
+
insertBrand: W,
|
|
65
|
+
id: K,
|
|
66
|
+
width: P,
|
|
67
|
+
className: S
|
|
63
68
|
}, B) => {
|
|
64
|
-
const { t: e, i18n:
|
|
69
|
+
const { t: e, i18n: b } = k(), [N, D] = f(null), [m, I] = f(null), [g, E] = f(null), [u, _] = f(null), p = j(m, N), n = w(() => p === null || m === null || g === null || u === null ? null : z({
|
|
65
70
|
prePregnancyBmi: p,
|
|
66
|
-
prePregnancyWeightKg:
|
|
71
|
+
prePregnancyWeightKg: m,
|
|
67
72
|
currentWeightKg: g,
|
|
68
73
|
gestationalWeeks: u
|
|
69
|
-
}), [p,
|
|
70
|
-
() => new Intl.NumberFormat(
|
|
74
|
+
}), [p, m, g, u]), d = w(
|
|
75
|
+
() => new Intl.NumberFormat(b.language, {
|
|
71
76
|
minimumFractionDigits: 1,
|
|
72
77
|
maximumFractionDigits: 1
|
|
73
78
|
}),
|
|
74
|
-
[
|
|
79
|
+
[b.language]
|
|
75
80
|
);
|
|
76
81
|
F(() => {
|
|
77
82
|
t == null || t(n);
|
|
78
83
|
}, [n, t]);
|
|
79
|
-
const
|
|
84
|
+
const o = e("pregnancyWeightGain.units.kg"), h = (T) => `${d.format(T.min)} – ${d.format(T.max)} ${o}`;
|
|
80
85
|
return /* @__PURE__ */ s(
|
|
81
86
|
"div",
|
|
82
87
|
{
|
|
83
88
|
ref: B,
|
|
84
89
|
"data-component": "pregnancy-weight-gain",
|
|
85
|
-
"data-component-id":
|
|
86
|
-
className:
|
|
90
|
+
"data-component-id": K,
|
|
91
|
+
className: V({ width: P, className: S }),
|
|
87
92
|
children: [
|
|
88
93
|
/* @__PURE__ */ s("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2", children: [
|
|
89
94
|
/* @__PURE__ */ a(
|
|
@@ -96,7 +101,7 @@ const U = _("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
96
101
|
mode: "decimal",
|
|
97
102
|
min: 0,
|
|
98
103
|
step: 0.5,
|
|
99
|
-
value:
|
|
104
|
+
value: N,
|
|
100
105
|
onChange: D
|
|
101
106
|
}
|
|
102
107
|
)
|
|
@@ -105,15 +110,15 @@ const U = _("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
105
110
|
/* @__PURE__ */ a(
|
|
106
111
|
y,
|
|
107
112
|
{
|
|
108
|
-
label: `${e("pregnancyWeightGain.prePregnancyWeight")} (${
|
|
113
|
+
label: `${e("pregnancyWeightGain.prePregnancyWeight")} (${o})`,
|
|
109
114
|
children: /* @__PURE__ */ a(
|
|
110
115
|
x,
|
|
111
116
|
{
|
|
112
117
|
mode: "decimal",
|
|
113
118
|
min: 0,
|
|
114
119
|
step: 0.1,
|
|
115
|
-
value:
|
|
116
|
-
onChange:
|
|
120
|
+
value: m,
|
|
121
|
+
onChange: I
|
|
117
122
|
}
|
|
118
123
|
)
|
|
119
124
|
}
|
|
@@ -121,7 +126,7 @@ const U = _("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
121
126
|
/* @__PURE__ */ a(
|
|
122
127
|
y,
|
|
123
128
|
{
|
|
124
|
-
label: `${e("pregnancyWeightGain.currentWeight")} (${
|
|
129
|
+
label: `${e("pregnancyWeightGain.currentWeight")} (${o})`,
|
|
125
130
|
children: /* @__PURE__ */ a(
|
|
126
131
|
x,
|
|
127
132
|
{
|
|
@@ -141,14 +146,14 @@ const U = _("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
141
146
|
min: 0,
|
|
142
147
|
max: 42,
|
|
143
148
|
value: u,
|
|
144
|
-
onChange:
|
|
149
|
+
onChange: _
|
|
145
150
|
}
|
|
146
151
|
) })
|
|
147
152
|
] }),
|
|
148
153
|
/* @__PURE__ */ a("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: n ? `${e("pregnancyWeightGain.actualGain")}: ${d.format(
|
|
149
154
|
n.actualGainKg
|
|
150
|
-
)} ${
|
|
151
|
-
n ? /* @__PURE__ */ a(
|
|
155
|
+
)} ${o}. ${e(`pregnancyWeightGain.status.${n.status}`)}.` : "" }),
|
|
156
|
+
n ? /* @__PURE__ */ a($, { variant: "elevated", children: /* @__PURE__ */ s($.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
|
|
152
157
|
/* @__PURE__ */ s("dl", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2", children: [
|
|
153
158
|
/* @__PURE__ */ s("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
|
|
154
159
|
/* @__PURE__ */ a("dt", { className: "type-label ds:text-muted-foreground", children: e("pregnancyWeightGain.prePregnancyBmi") }),
|
|
@@ -165,9 +170,9 @@ const U = _("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
165
170
|
/* @__PURE__ */ s("span", { className: "type-metric ds:text-foreground", children: [
|
|
166
171
|
d.format(n.actualGainKg),
|
|
167
172
|
" ",
|
|
168
|
-
|
|
173
|
+
o
|
|
169
174
|
] }),
|
|
170
|
-
/* @__PURE__ */ a(
|
|
175
|
+
/* @__PURE__ */ a(C, { variant: q[n.status], size: "lg", children: e(`pregnancyWeightGain.status.${n.status}`) })
|
|
171
176
|
] })
|
|
172
177
|
] }),
|
|
173
178
|
/* @__PURE__ */ s("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
|
|
@@ -180,20 +185,24 @@ const U = _("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
180
185
|
] })
|
|
181
186
|
] }),
|
|
182
187
|
/* @__PURE__ */ a("p", { className: "type-body-sm ds:text-muted-foreground", children: e("pregnancyWeightGain.disclaimer") }),
|
|
183
|
-
|
|
184
|
-
|
|
188
|
+
l === "copy" || i ? /* @__PURE__ */ a(
|
|
189
|
+
H,
|
|
185
190
|
{
|
|
186
191
|
onInsert: i,
|
|
187
|
-
variant:
|
|
192
|
+
variant: l,
|
|
188
193
|
onCopy: r,
|
|
189
|
-
onError:
|
|
194
|
+
onError: c,
|
|
190
195
|
card: {
|
|
191
196
|
title: e("insert.title.weightGain"),
|
|
192
197
|
highlight: e(`pregnancyWeightGain.status.${n.status}`),
|
|
198
|
+
// Chip shares the gain-status semantic token so the
|
|
199
|
+
// inserted PNG chip matches the on-screen status badge.
|
|
200
|
+
highlightToken: J[n.status],
|
|
201
|
+
brand: W,
|
|
193
202
|
fields: [
|
|
194
203
|
{
|
|
195
204
|
label: e("pregnancyWeightGain.actualGain"),
|
|
196
|
-
value: `${d.format(n.actualGainKg)} ${
|
|
205
|
+
value: `${d.format(n.actualGainKg)} ${o}`
|
|
197
206
|
},
|
|
198
207
|
{
|
|
199
208
|
label: e("pregnancyWeightGain.recommendedToDate"),
|
|
@@ -213,12 +222,12 @@ const U = _("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
|
213
222
|
);
|
|
214
223
|
}
|
|
215
224
|
);
|
|
216
|
-
|
|
225
|
+
Q.displayName = "PregnancyWeightGain";
|
|
217
226
|
export {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
227
|
+
Q as P,
|
|
228
|
+
O as R,
|
|
229
|
+
L as T,
|
|
230
|
+
z as a,
|
|
231
|
+
U as r
|
|
223
232
|
};
|
|
224
|
-
//# sourceMappingURL=pregnancy-weight-gain-
|
|
233
|
+
//# sourceMappingURL=pregnancy-weight-gain-C5YhfYnL.js.map
|