@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfadocs/ui-kit-debug",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AlfaDocs shared design system — tokens, components, patterns, and translations for platform, booking, and alfascribe. (debug build — identical runtime to @alfadocs/ui-kit, ships source maps for symbolication).",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bmi-calculator-DuVSFDuw.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 * 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 /** 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 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 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","useGaugeColor","color","setColor","useState","useEffect","read","observer","round1","n","BmiCalculator","forwardRef","defaultUnitSystem","onResultChange","onInsert","insertVariant","onCopy","onError","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,MAAMA,KAAeC,EAAI,kDAAkD;AAAA,EACzE,UAAU;AAAA,IACR,OAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,IAAA;AAAA,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dln-y1k_.js","sources":["../../node_modules/lucide-react/dist/esm/icons/droplet.js","../../src/components/cycle-calculator/cycle.ts","../../src/components/cycle-calculator/cycle-calculator.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z\",\n key: \"c7niix\"\n }\n ]\n];\nconst Droplet = createLucideIcon(\"droplet\", __iconNode);\n\nexport { __iconNode, Droplet as default };\n//# sourceMappingURL=droplet.js.map\n","/* ------------------------------------------------------------------ */\n/* Menstrual-cycle prediction — pure, framework-free, unit-testable. */\n/* */\n/* Uses the standard fixed-luteal-phase model: ovulation falls ~14 days */\n/* before the next period, so on a cycle of length L ovulation is day */\n/* (L − 14). The fertile window spans the 5 days before ovulation */\n/* (sperm survival) through 1 day after (oocyte viability). */\n/* ------------------------------------------------------------------ */\n\nimport { addDays } from 'date-fns';\n\n/** Standard menstrual-cycle length. */\nexport const DEFAULT_CYCLE_LENGTH = 28;\n/** Luteal phase is biologically near-constant at ~14 days. */\nexport const LUTEAL_PHASE_DAYS = 14;\n/** Sperm survive up to ~5 days before ovulation. */\nexport const FERTILE_DAYS_BEFORE = 5;\n/** The oocyte is viable ~1 day after ovulation. */\nexport const FERTILE_DAYS_AFTER = 1;\n\nexport interface CycleInput {\n /** First day of the most recent period. */\n lastPeriodStart: Date;\n /** Average cycle length in days. Defaults to 28. */\n cycleLength?: number;\n /** Period (bleed) length in days. Optional — used for the period range. */\n periodLength?: number;\n}\n\nexport interface DateRange {\n start: Date;\n end: Date;\n}\n\nexport interface CyclePrediction {\n /** Start date of the next period. */\n nextPeriod: Date;\n /** Estimated ovulation date. */\n ovulation: Date;\n /** Fertile window (5 days before ovulation → 1 day after). */\n fertileWindow: DateRange;\n /** Start dates of the next few periods (length = `occurrences`). */\n upcomingPeriods: Date[];\n}\n\n/**\n * Predict ovulation, the fertile window and upcoming periods from the last\n * period's start date. `occurrences` controls how many future periods to\n * list (default 3).\n */\nexport function predictCycle(\n input: CycleInput,\n occurrences = 3,\n): CyclePrediction {\n const cycle = input.cycleLength ?? DEFAULT_CYCLE_LENGTH;\n const { lastPeriodStart } = input;\n\n const ovulation = addDays(lastPeriodStart, cycle - LUTEAL_PHASE_DAYS);\n const fertileWindow: DateRange = {\n start: addDays(ovulation, -FERTILE_DAYS_BEFORE),\n end: addDays(ovulation, FERTILE_DAYS_AFTER),\n };\n const nextPeriod = addDays(lastPeriodStart, cycle);\n const upcomingPeriods = Array.from({ length: occurrences }, (_, i) =>\n addDays(lastPeriodStart, cycle * (i + 1)),\n );\n\n return { nextPeriod, ovulation, fertileWindow, upcomingPeriods };\n}\n","/* ------------------------------------------------------------------ */\n/* CycleCalculator — predict ovulation, fertile window and upcoming */\n/* periods from the last period's start date. */\n/* */\n/* Maths lives in `./cycle` (pure, separately tested). */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useMemo, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { Heart, Check, Droplet } from 'lucide-react';\nimport { FormField } from '../form-field';\nimport { DatePicker } from '../date-picker';\nimport { NumberInput } from '../number-input';\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 CyclePrediction,\n predictCycle,\n DEFAULT_CYCLE_LENGTH,\n} from './cycle';\n\nconst rootVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]', {\n variants: {\n width: { full: 'ds:w-full', auto: 'ds:inline-flex' },\n },\n defaultVariants: { width: 'full' },\n});\n\nexport interface CycleCalculatorProps extends VariantProps<\n typeof rootVariants\n> {\n /** Initial cycle length in days. Defaults to 28. */\n defaultCycleLength?: number;\n /** Fires whenever a prediction can be computed (and `null` when it can't). */\n onResultChange?: (result: CyclePrediction | null) => void;\n /** When provided, shows the result-action buttons that emit / copy the result. */\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 /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\nexport const CycleCalculator = forwardRef<HTMLDivElement, CycleCalculatorProps>(\n (\n {\n defaultCycleLength = DEFAULT_CYCLE_LENGTH,\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n\n const [lastPeriod, setLastPeriod] = useState<Date | undefined>(undefined);\n const [cycleLength, setCycleLength] = useState<number | null>(\n defaultCycleLength,\n );\n\n const result = useMemo<CyclePrediction | null>(() => {\n if (!lastPeriod) return null;\n return predictCycle({\n lastPeriodStart: lastPeriod,\n cycleLength: cycleLength ?? DEFAULT_CYCLE_LENGTH,\n });\n }, [lastPeriod, cycleLength]);\n\n const dateFormatter = useMemo(\n () => new Intl.DateTimeFormat(i18n.language, { dateStyle: 'medium' }),\n [i18n.language],\n );\n\n useEffect(() => {\n onResultChange?.(result);\n }, [result, onResultChange]);\n\n const today = useMemo(() => new Date(), []);\n\n const fmt = (d: Date): string => dateFormatter.format(d);\n\n return (\n <div\n ref={ref}\n data-component=\"cycle-calculator\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <div className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2\">\n <FormField label={t('cycleCalculator.lastPeriod')}>\n <DatePicker\n value={lastPeriod}\n onChange={setLastPeriod}\n maxDate={today}\n />\n </FormField>\n <FormField\n label={t('cycleCalculator.cycleLength')}\n description={t('cycleCalculator.cycleLengthHint')}\n >\n <NumberInput\n mode=\"integer\"\n min={20}\n max={45}\n value={cycleLength}\n onChange={setCycleLength}\n />\n </FormField>\n </div>\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {result\n ? `${t('cycleCalculator.ovulation')}: ${fmt(result.ovulation)}. ${t(\n 'cycleCalculator.nextPeriod',\n )}: ${fmt(result.nextPeriod)}.`\n : ''}\n </p>\n\n {result ? (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n <dl className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-3\">\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.ovulation')}\n </dt>\n <dd>\n <Badge\n variant=\"success\"\n size=\"lg\"\n leading={<Check aria-hidden />}\n >\n {fmt(result.ovulation)}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.fertileWindow')}\n </dt>\n <dd>\n <Badge\n variant=\"accent\"\n size=\"lg\"\n leading={<Heart aria-hidden />}\n >\n {fmt(result.fertileWindow.start)} –{' '}\n {fmt(result.fertileWindow.end)}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.nextPeriod')}\n </dt>\n <dd>\n <Badge\n variant=\"error\"\n size=\"lg\"\n leading={<Droplet aria-hidden />}\n >\n {fmt(result.nextPeriod)}\n </Badge>\n </dd>\n </div>\n </dl>\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.cycle'),\n fields: [\n {\n label: t('cycleCalculator.ovulation'),\n value: fmt(result.ovulation),\n },\n {\n label: t('cycleCalculator.fertileWindow'),\n value: `${fmt(result.fertileWindow.start)} – ${fmt(\n result.fertileWindow.end,\n )}`,\n },\n {\n label: t('cycleCalculator.nextPeriod'),\n value: fmt(result.nextPeriod),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('cycleCalculator.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nCycleCalculator.displayName = 'CycleCalculator';\n"],"names":["__iconNode","Droplet","createLucideIcon","DEFAULT_CYCLE_LENGTH","LUTEAL_PHASE_DAYS","FERTILE_DAYS_AFTER","predictCycle","input","occurrences","cycle","lastPeriodStart","ovulation","addDays","fertileWindow","nextPeriod","upcomingPeriods","_","i","rootVariants","cva","CycleCalculator","forwardRef","defaultCycleLength","onResultChange","onInsert","insertVariant","onCopy","onError","id","width","className","ref","t","i18n","useTranslation","lastPeriod","setLastPeriod","useState","cycleLength","setCycleLength","result","useMemo","dateFormatter","useEffect","today","fmt","d","jsxs","jsx","FormField","DatePicker","NumberInput","Card","Badge","Check","Heart","InsertButton"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,IAAa;AAAA,EACjB;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AACA,GACMC,IAAUC,EAAiB,WAAWF,CAAU,GCNzCG,IAAuB,IAEvBC,IAAoB,IAIpBC,IAAqB;AAgC3B,SAASC,EACdC,GACAC,IAAc,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
|
2
|
-
import { useRef as R, useEffect as T, useMemo as O, forwardRef as d, useContext as j, createContext as E } from "react";
|
|
3
|
-
import * as t from "@radix-ui/react-dialog";
|
|
4
|
-
import { c as _ } from "./index-D2ZczOXr.js";
|
|
5
|
-
import { useTranslation as k } from "react-i18next";
|
|
6
|
-
import { I as z } from "./icon-button-CKEOrN37.js";
|
|
7
|
-
import { u as I } from "./use-controllable-state-BiY4xTzM.js";
|
|
8
|
-
import { u as B } from "./registry-nPAVE19X.js";
|
|
9
|
-
import { X as S } from "./x-CCcI3eJp.js";
|
|
10
|
-
const A = {
|
|
11
|
-
id: "dialog",
|
|
12
|
-
capabilities: ["open", "close", "dismiss"],
|
|
13
|
-
state: {
|
|
14
|
-
isOpen: {
|
|
15
|
-
type: "boolean",
|
|
16
|
-
description: "True when the dialog is currently open.",
|
|
17
|
-
read: (o) => o.getIsOpen()
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
actions: {
|
|
21
|
-
open: {
|
|
22
|
-
safety: "read",
|
|
23
|
-
description: "Open the dialog.",
|
|
24
|
-
invoke: (o) => {
|
|
25
|
-
o.open();
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
close: {
|
|
29
|
-
safety: "write",
|
|
30
|
-
description: "Close the dialog. Reversible by reopening.",
|
|
31
|
-
invoke: (o) => {
|
|
32
|
-
o.close();
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
dismiss: {
|
|
36
|
-
safety: "destructive",
|
|
37
|
-
description: "Dismiss the dialog. Loses any in-progress input that has not been committed.",
|
|
38
|
-
invoke: (o) => {
|
|
39
|
-
o.close();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
domHooks: {
|
|
44
|
-
root: { attr: "data-component", value: "dialog" },
|
|
45
|
-
instanceId: {
|
|
46
|
-
attr: "data-component-id",
|
|
47
|
-
sourceProp: "id",
|
|
48
|
-
description: "Sourced from the id prop on Dialog.Root."
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}, H = [
|
|
52
|
-
"ds-dialog__backdrop",
|
|
53
|
-
"ds:backdrop-blur-sm",
|
|
54
|
-
"ds:data-[state=open]:animate-in ds:data-[state=open]:fade-in-0",
|
|
55
|
-
"ds:data-[state=closed]:animate-out ds:data-[state=closed]:fade-out-0",
|
|
56
|
-
"ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none"
|
|
57
|
-
].join(" "), V = [
|
|
58
|
-
"ds-dialog",
|
|
59
|
-
"ds:fixed ds:z-[var(--z-modal)]",
|
|
60
|
-
"ds:bg-[var(--popover)] ds:text-[var(--popover-foreground)]",
|
|
61
|
-
"ds:shadow-[var(--shadow-xl)]",
|
|
62
|
-
"ds:p-[var(--spacing-lg)]",
|
|
63
|
-
"ds:focus-visible:outline-none",
|
|
64
|
-
"ds:data-[state=open]:animate-in ds:data-[state=open]:fade-in-0 ds:data-[state=open]:zoom-in-95",
|
|
65
|
-
"ds:data-[state=closed]:animate-out ds:data-[state=closed]:fade-out-0 ds:data-[state=closed]:zoom-out-95",
|
|
66
|
-
"ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none"
|
|
67
|
-
].join(" "), g = "ds:start-1/2 ds:top-1/2 ds:-translate-x-1/2 ds:-translate-y-1/2 ds:w-[calc(100%-var(--spacing-lg)*2)]", F = _(V, {
|
|
68
|
-
variants: {
|
|
69
|
-
size: {
|
|
70
|
-
sm: `${g} ds:max-w-[448px] ds:rounded-[var(--radius-lg)] ds:overflow-y-auto ds:max-h-[85dvh]`,
|
|
71
|
-
md: `${g} ds:max-w-[560px] ds:rounded-[var(--radius-lg)] ds:overflow-y-auto ds:max-h-[85dvh]`,
|
|
72
|
-
lg: `${g} ds:max-w-[720px] ds:rounded-[var(--radius-lg)] ds:overflow-y-auto ds:max-h-[85dvh]`,
|
|
73
|
-
fullscreen: "ds:start-0 ds:top-0 ds:w-[100dvw] ds:h-[100dvh] ds:max-w-none ds:rounded-none ds:overflow-y-auto"
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
defaultVariants: { size: "md" }
|
|
77
|
-
}), f = E(void 0), u = ({
|
|
78
|
-
children: o,
|
|
79
|
-
id: e,
|
|
80
|
-
open: a,
|
|
81
|
-
defaultOpen: r,
|
|
82
|
-
onOpenChange: c,
|
|
83
|
-
...p
|
|
84
|
-
}) => {
|
|
85
|
-
const [m, n] = I({
|
|
86
|
-
value: a,
|
|
87
|
-
defaultValue: r ?? !1,
|
|
88
|
-
onChange: c
|
|
89
|
-
}), i = m ?? !1, l = R(i);
|
|
90
|
-
T(() => {
|
|
91
|
-
l.current = i;
|
|
92
|
-
}, [i]);
|
|
93
|
-
const N = O(
|
|
94
|
-
() => ({
|
|
95
|
-
getIsOpen: () => l.current,
|
|
96
|
-
open: () => n(!0),
|
|
97
|
-
close: () => n(!1)
|
|
98
|
-
}),
|
|
99
|
-
[n]
|
|
100
|
-
);
|
|
101
|
-
return B(A, N, e), /* @__PURE__ */ s(f.Provider, { value: e, children: /* @__PURE__ */ s(t.Root, { open: i, onOpenChange: n, ...p, children: o }) });
|
|
102
|
-
};
|
|
103
|
-
u.displayName = "Dialog.Root";
|
|
104
|
-
const h = d(({ children: o, ...e }, a) => /* @__PURE__ */ s(t.Trigger, { ref: a, ...e, children: o }));
|
|
105
|
-
h.displayName = "Dialog.Trigger";
|
|
106
|
-
const x = d(({ children: o, ...e }, a) => /* @__PURE__ */ s(t.Close, { ref: a, ...e, children: o }));
|
|
107
|
-
x.displayName = "Dialog.Close";
|
|
108
|
-
const D = d(
|
|
109
|
-
({
|
|
110
|
-
size: o = "md",
|
|
111
|
-
variant: e = "default",
|
|
112
|
-
hideCloseButton: a = !0,
|
|
113
|
-
className: r,
|
|
114
|
-
children: c,
|
|
115
|
-
...p
|
|
116
|
-
}, m) => {
|
|
117
|
-
const { t: n } = k(), i = j(f), l = e === "alert" ? { role: "alertdialog" } : {};
|
|
118
|
-
return /* @__PURE__ */ v(t.Portal, { children: [
|
|
119
|
-
/* @__PURE__ */ s(
|
|
120
|
-
t.Overlay,
|
|
121
|
-
{
|
|
122
|
-
"data-component": "dialog-overlay",
|
|
123
|
-
className: H
|
|
124
|
-
}
|
|
125
|
-
),
|
|
126
|
-
/* @__PURE__ */ v(
|
|
127
|
-
t.Content,
|
|
128
|
-
{
|
|
129
|
-
ref: m,
|
|
130
|
-
...l,
|
|
131
|
-
"data-component": "dialog",
|
|
132
|
-
"data-component-id": i,
|
|
133
|
-
className: F({ size: o, className: r }),
|
|
134
|
-
...p,
|
|
135
|
-
children: [
|
|
136
|
-
c,
|
|
137
|
-
!a && // Positioning wrapper. The interactive close is an IconButton
|
|
138
|
-
// (ghost / sm) — same lucide `X` glyph, 32px target, 16px icon,
|
|
139
|
-
// hover wash and focus ring that the vanilla `.ds-dialog__close`
|
|
140
|
-
// contract reproduces from the same tokens, so the React and
|
|
141
|
-
// non-React close buttons render identically.
|
|
142
|
-
/* @__PURE__ */ s("div", { className: "ds:absolute ds:end-[var(--spacing-md)] ds:top-[var(--spacing-md)]", children: /* @__PURE__ */ s(t.Close, { asChild: !0, children: /* @__PURE__ */ s(
|
|
143
|
-
z,
|
|
144
|
-
{
|
|
145
|
-
icon: /* @__PURE__ */ s(S, {}),
|
|
146
|
-
intent: "ghost",
|
|
147
|
-
size: "sm",
|
|
148
|
-
"aria-label": n("common.close", "Close")
|
|
149
|
-
}
|
|
150
|
-
) }) })
|
|
151
|
-
]
|
|
152
|
-
}
|
|
153
|
-
)
|
|
154
|
-
] });
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
D.displayName = "Dialog.Content";
|
|
158
|
-
const y = d(
|
|
159
|
-
({ className: o, ...e }, a) => /* @__PURE__ */ s(
|
|
160
|
-
"div",
|
|
161
|
-
{
|
|
162
|
-
ref: a,
|
|
163
|
-
className: [
|
|
164
|
-
// `ds-dialog__header` is the shared vanilla contract (src/styles.css);
|
|
165
|
-
// the Tailwind utilities reproduce it for hosts that render through
|
|
166
|
-
// this component, keeping the two surfaces identical.
|
|
167
|
-
"ds-dialog__header",
|
|
168
|
-
"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:pe-[var(--spacing-xl)]",
|
|
169
|
-
o
|
|
170
|
-
].filter(Boolean).join(" "),
|
|
171
|
-
...e
|
|
172
|
-
}
|
|
173
|
-
)
|
|
174
|
-
);
|
|
175
|
-
y.displayName = "Dialog.Header";
|
|
176
|
-
const C = d(({ className: o, ...e }, a) => /* @__PURE__ */ s(
|
|
177
|
-
t.Title,
|
|
178
|
-
{
|
|
179
|
-
ref: a,
|
|
180
|
-
className: ["ds-dialog__title type-title-card ds:break-words", o].filter(Boolean).join(" "),
|
|
181
|
-
...e
|
|
182
|
-
}
|
|
183
|
-
));
|
|
184
|
-
C.displayName = "Dialog.Title";
|
|
185
|
-
const b = d(({ className: o, ...e }, a) => /* @__PURE__ */ s(
|
|
186
|
-
t.Description,
|
|
187
|
-
{
|
|
188
|
-
ref: a,
|
|
189
|
-
className: ["type-body-sm ds:text-[var(--muted-foreground)]", o].filter(Boolean).join(" "),
|
|
190
|
-
...e
|
|
191
|
-
}
|
|
192
|
-
));
|
|
193
|
-
b.displayName = "Dialog.Description";
|
|
194
|
-
const w = d(
|
|
195
|
-
({ className: o, divider: e = !1, ...a }, r) => /* @__PURE__ */ s(
|
|
196
|
-
"div",
|
|
197
|
-
{
|
|
198
|
-
ref: r,
|
|
199
|
-
className: [
|
|
200
|
-
"ds:flex ds:items-center ds:justify-end ds:gap-[var(--spacing-sm)]",
|
|
201
|
-
"ds:mt-[var(--spacing-md)]",
|
|
202
|
-
e && "ds:border-t ds:border-[color:var(--border)] ds:pt-[var(--spacing-md)]",
|
|
203
|
-
o
|
|
204
|
-
].filter(Boolean).join(" "),
|
|
205
|
-
...a
|
|
206
|
-
}
|
|
207
|
-
)
|
|
208
|
-
);
|
|
209
|
-
w.displayName = "Dialog.Footer";
|
|
210
|
-
const J = Object.assign(u, {
|
|
211
|
-
Root: u,
|
|
212
|
-
Trigger: h,
|
|
213
|
-
Content: D,
|
|
214
|
-
Header: y,
|
|
215
|
-
Title: C,
|
|
216
|
-
Description: b,
|
|
217
|
-
Footer: w,
|
|
218
|
-
Close: x
|
|
219
|
-
});
|
|
220
|
-
export {
|
|
221
|
-
J as D,
|
|
222
|
-
A as d
|
|
223
|
-
};
|
|
224
|
-
//# sourceMappingURL=dialog-DOYgd75U.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-DOYgd75U.js","sources":["../../src/components/dialog/dialog.agent.ts","../../src/components/dialog/dialog.tsx"],"sourcesContent":["import type { AgentAdapter } from '../../agent/types';\nimport type { DialogHandle } from './dialog';\n\n/**\n * Dialog wraps Radix Dialog. The curated handle (`DialogHandle`) bridges the\n * Radix controlled-or-uncontrolled `open` state so an agent can observe and\n * drive the dialog without owning the React state itself.\n */\nexport const dialogAgent: AgentAdapter<DialogHandle> = {\n id: 'dialog',\n capabilities: ['open', 'close', 'dismiss'],\n state: {\n isOpen: {\n type: 'boolean',\n description: 'True when the dialog is currently open.',\n read: (handle) => handle.getIsOpen(),\n },\n },\n actions: {\n open: {\n safety: 'read',\n description: 'Open the dialog.',\n invoke: (handle) => {\n handle.open();\n },\n },\n close: {\n safety: 'write',\n description: 'Close the dialog. Reversible by reopening.',\n invoke: (handle) => {\n handle.close();\n },\n },\n dismiss: {\n safety: 'destructive',\n description:\n 'Dismiss the dialog. Loses any in-progress input that has not been committed.',\n invoke: (handle) => {\n handle.close();\n },\n },\n },\n domHooks: {\n root: { attr: 'data-component', value: 'dialog' },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop on Dialog.Root.',\n },\n },\n};\n","import {\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useRef,\n type ComponentPropsWithoutRef,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport * as RadixDialog from '@radix-ui/react-dialog';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { X } from 'lucide-react';\nimport { IconButton } from '../button/icon-button';\nimport { useControllableState } from '../../hooks/use-controllable-state';\nimport { useAgentRegistration } from '../../agent';\nimport { dialogAgent } from './dialog.agent';\n\n// The `ds-dialog__*` class names below are the framework-agnostic contract\n// defined in src/styles.css (@layer ui-kit-components). The React component\n// renders them ALONGSIDE its Tailwind utilities so a vanilla (non-React)\n// host that hand-authors the same markup matches this component exactly and\n// the two surfaces can't drift. The Tailwind utilities still drive the\n// animation hooks and focus-management chrome Radix needs; the `ds-dialog__*`\n// classes carry the token-driven skin (scrim, radius, elevation, padding,\n// close-button sizing) so they work even without Tailwind utilities present.\nconst OVERLAY_CLASSES = [\n 'ds-dialog__backdrop',\n 'ds:backdrop-blur-sm',\n 'ds:data-[state=open]:animate-in ds:data-[state=open]:fade-in-0',\n 'ds:data-[state=closed]:animate-out ds:data-[state=closed]:fade-out-0',\n 'ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none',\n].join(' ');\n\nconst CONTENT_BASE = [\n 'ds-dialog',\n 'ds:fixed ds:z-[var(--z-modal)]',\n 'ds:bg-[var(--popover)] ds:text-[var(--popover-foreground)]',\n 'ds:shadow-[var(--shadow-xl)]',\n 'ds:p-[var(--spacing-lg)]',\n 'ds:focus-visible:outline-none',\n 'ds:data-[state=open]:animate-in ds:data-[state=open]:fade-in-0 ds:data-[state=open]:zoom-in-95',\n 'ds:data-[state=closed]:animate-out ds:data-[state=closed]:fade-out-0 ds:data-[state=closed]:zoom-out-95',\n 'ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none',\n].join(' ');\n\nconst CENTERED =\n 'ds:start-1/2 ds:top-1/2 ds:-translate-x-1/2 ds:-translate-y-1/2 ds:w-[calc(100%-var(--spacing-lg)*2)]';\n\nconst contentVariants = cva(CONTENT_BASE, {\n variants: {\n size: {\n sm: `${CENTERED} ds:max-w-[448px] ds:rounded-[var(--radius-lg)] ds:overflow-y-auto ds:max-h-[85dvh]`,\n md: `${CENTERED} ds:max-w-[560px] ds:rounded-[var(--radius-lg)] ds:overflow-y-auto ds:max-h-[85dvh]`,\n lg: `${CENTERED} ds:max-w-[720px] ds:rounded-[var(--radius-lg)] ds:overflow-y-auto ds:max-h-[85dvh]`,\n fullscreen:\n 'ds:start-0 ds:top-0 ds:w-[100dvw] ds:h-[100dvh] ds:max-w-none ds:rounded-none ds:overflow-y-auto',\n },\n },\n defaultVariants: { size: 'md' },\n});\n\n// Curated agent-readiness handle — see dialog.agent.ts.\nexport interface DialogHandle {\n getIsOpen: () => boolean;\n open: () => void;\n close: () => void;\n}\n\nexport interface DialogRootProps extends ComponentPropsWithoutRef<\n typeof RadixDialog.Root\n> {\n /** Opaque instance id — forwarded to Dialog.Content as `data-component-id`. */\n id?: string;\n}\n\nconst DialogIdContext = createContext<string | undefined>(undefined);\n\nconst DialogRoot = ({\n children,\n id,\n open: openProp,\n defaultOpen,\n onOpenChange,\n ...props\n}: DialogRootProps) => {\n const [openRaw, setOpen] = useControllableState<boolean>({\n value: openProp,\n defaultValue: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n const open = openRaw ?? false;\n\n const openRef = useRef(open);\n useEffect(() => {\n openRef.current = open;\n }, [open]);\n\n const handle = useMemo<DialogHandle>(\n () => ({\n getIsOpen: () => openRef.current,\n open: () => setOpen(true),\n close: () => setOpen(false),\n }),\n [setOpen],\n );\n useAgentRegistration(dialogAgent, handle, id);\n\n return (\n <DialogIdContext.Provider value={id}>\n <RadixDialog.Root open={open} onOpenChange={setOpen} {...props}>\n {children}\n </RadixDialog.Root>\n </DialogIdContext.Provider>\n );\n};\nDialogRoot.displayName = 'Dialog.Root';\n\nconst DialogTrigger = forwardRef<\n HTMLButtonElement,\n ComponentPropsWithoutRef<typeof RadixDialog.Trigger>\n>(({ children, ...props }, ref) => (\n <RadixDialog.Trigger ref={ref} {...props}>\n {children}\n </RadixDialog.Trigger>\n));\nDialogTrigger.displayName = 'Dialog.Trigger';\n\nconst DialogClose = forwardRef<\n HTMLButtonElement,\n ComponentPropsWithoutRef<typeof RadixDialog.Close>\n>(({ children, ...props }, ref) => (\n <RadixDialog.Close ref={ref} {...props}>\n {children}\n </RadixDialog.Close>\n));\nDialogClose.displayName = 'Dialog.Close';\n\nexport interface DialogContentProps\n extends\n Omit<ComponentPropsWithoutRef<typeof RadixDialog.Content>, 'role'>,\n VariantProps<typeof contentVariants> {\n size?: 'sm' | 'md' | 'lg' | 'fullscreen';\n variant?: 'default' | 'alert' | 'confirmation';\n hideCloseButton?: boolean;\n className?: string;\n children: ReactNode;\n}\n\nconst DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(\n (\n {\n size = 'md',\n variant = 'default',\n hideCloseButton = true,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const { t } = useTranslation();\n const instanceId = useContext(DialogIdContext);\n // Only forward `role` when we actually need to override Radix's default\n // (`role=\"dialog\"`). Passing `role={undefined}` explicitly wins over\n // Radix's internal assignment and strips the attribute entirely.\n const roleOverride =\n variant === 'alert' ? { role: 'alertdialog' as const } : {};\n\n return (\n <RadixDialog.Portal>\n <RadixDialog.Overlay\n data-component=\"dialog-overlay\"\n className={OVERLAY_CLASSES}\n />\n <RadixDialog.Content\n ref={ref}\n {...roleOverride}\n data-component=\"dialog\"\n data-component-id={instanceId}\n className={contentVariants({ size, className })}\n {...props}\n >\n {children}\n\n {!hideCloseButton && (\n // Positioning wrapper. The interactive close is an IconButton\n // (ghost / sm) — same lucide `X` glyph, 32px target, 16px icon,\n // hover wash and focus ring that the vanilla `.ds-dialog__close`\n // contract reproduces from the same tokens, so the React and\n // non-React close buttons render identically.\n <div className=\"ds:absolute ds:end-[var(--spacing-md)] ds:top-[var(--spacing-md)]\">\n <RadixDialog.Close asChild>\n <IconButton\n icon={<X />}\n intent=\"ghost\"\n size=\"sm\"\n aria-label={t('common.close', 'Close')}\n />\n </RadixDialog.Close>\n </div>\n )}\n </RadixDialog.Content>\n </RadixDialog.Portal>\n );\n },\n);\nDialogContent.displayName = 'Dialog.Content';\n\nconst DialogHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={[\n // `ds-dialog__header` is the shared vanilla contract (src/styles.css);\n // the Tailwind utilities reproduce it for hosts that render through\n // this component, keeping the two surfaces identical.\n 'ds-dialog__header',\n 'ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:pe-[var(--spacing-xl)]',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n {...props}\n />\n ),\n);\nDialogHeader.displayName = 'Dialog.Header';\n\nconst DialogTitle = forwardRef<\n HTMLHeadingElement,\n ComponentPropsWithoutRef<typeof RadixDialog.Title>\n>(({ className, ...props }, ref) => (\n <RadixDialog.Title\n ref={ref}\n className={['ds-dialog__title type-title-card ds:break-words', className]\n .filter(Boolean)\n .join(' ')}\n {...props}\n />\n));\nDialogTitle.displayName = 'Dialog.Title';\n\nconst DialogDescription = forwardRef<\n HTMLParagraphElement,\n ComponentPropsWithoutRef<typeof RadixDialog.Description>\n>(({ className, ...props }, ref) => (\n <RadixDialog.Description\n ref={ref}\n className={['type-body-sm ds:text-[var(--muted-foreground)]', className]\n .filter(Boolean)\n .join(' ')}\n {...props}\n />\n));\nDialogDescription.displayName = 'Dialog.Description';\n\ninterface DialogFooterProps extends HTMLAttributes<HTMLDivElement> {\n divider?: boolean;\n}\n\nconst DialogFooter = forwardRef<HTMLDivElement, DialogFooterProps>(\n ({ className, divider = false, ...props }, ref) => (\n <div\n ref={ref}\n className={[\n 'ds:flex ds:items-center ds:justify-end ds:gap-[var(--spacing-sm)]',\n 'ds:mt-[var(--spacing-md)]',\n divider &&\n 'ds:border-t ds:border-[color:var(--border)] ds:pt-[var(--spacing-md)]',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n {...props}\n />\n ),\n);\nDialogFooter.displayName = 'Dialog.Footer';\n\nexport const Dialog = Object.assign(DialogRoot, {\n Root: DialogRoot,\n Trigger: DialogTrigger,\n Content: DialogContent,\n Header: DialogHeader,\n Title: DialogTitle,\n Description: DialogDescription,\n Footer: DialogFooter,\n Close: DialogClose,\n});\n\nexport type { DialogFooterProps };\n"],"names":["dialogAgent","handle","OVERLAY_CLASSES","CONTENT_BASE","CENTERED","contentVariants","cva","DialogIdContext","createContext","DialogRoot","children","id","openProp","defaultOpen","onOpenChange","props","openRaw","setOpen","useControllableState","open","openRef","useRef","useEffect","useMemo","useAgentRegistration","jsx","RadixDialog","DialogTrigger","forwardRef","ref","DialogClose","DialogContent","size","variant","hideCloseButton","className","t","useTranslation","instanceId","useContext","roleOverride","jsxs","IconButton","X","DialogHeader","DialogTitle","DialogDescription","DialogFooter","divider","Dialog"],"mappings":";;;;;;;;;AAQO,MAAMA,IAA0C;AAAA,EACrD,IAAI;AAAA,EACJ,cAAc,CAAC,QAAQ,SAAS,SAAS;AAAA,EACzC,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,MACb,MAAM,CAACC,MAAWA,EAAO,UAAA;AAAA,IAAU;AAAA,EACrC;AAAA,EAEF,SAAS;AAAA,IACP,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,QAAQ,CAACA,MAAW;AAClB,QAAAA,EAAO,KAAA;AAAA,MACT;AAAA,IAAA;AAAA,IAEF,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,QAAQ,CAACA,MAAW;AAClB,QAAAA,EAAO,MAAA;AAAA,MACT;AAAA,IAAA;AAAA,IAEF,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,aACE;AAAA,MACF,QAAQ,CAACA,MAAW;AAClB,QAAAA,EAAO,MAAA;AAAA,MACT;AAAA,IAAA;AAAA,EACF;AAAA,EAEF,UAAU;AAAA,IACR,MAAM,EAAE,MAAM,kBAAkB,OAAO,SAAA;AAAA,IACvC,YAAY;AAAA,MACV,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,aAAa;AAAA,IA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EAAA;AACN,CACD;AACD+B,EAAkB,cAAc;AAMhC,MAAMC,IAAenB;AAAA,EACnB,CAAC,EAAE,WAAAO,GAAW,SAAAa,IAAU,IAAO,GAAGjC,EAAA,GAASc,MACzC,gBAAAJ;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAI;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACAmB,KACE;AAAA,QACFb;AAAA,MAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,MACV,GAAGpB;AAAA,IAAA;AAAA,EAAA;AAGV;AACAgC,EAAa,cAAc;AAEpB,MAAME,IAAS,OAAO,OAAOxC,GAAY;AAAA,EAC9C,MAAMA;AAAA,EACN,SAASkB;AAAA,EACT,SAASI;AAAA,EACT,QAAQa;AAAA,EACR,OAAOC;AAAA,EACP,aAAaC;AAAA,EACb,QAAQC;AAAA,EACR,OAAOjB;AACT,CAAC;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"due-date-calculator-Cc4dRqTI.js","sources":["../../src/components/due-date-calculator/due-date-calculator.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* DueDateCalculator — estimate the date of delivery from one of three */\n/* dating methods, with current gestational age + trimester. */\n/* */\n/* - Maths lives in `./gestation` (pure, separately tested). */\n/* - Three methods: LMP (Naegele, cycle-length adjustable), conception, */\n/* and IVF transfer (Day-3 vs Day-5 embryo). */\n/* - The reference date can't be in the future, so the DatePicker caps */\n/* at today. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, 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 { DatePicker } from '../date-picker';\nimport { NumberInput } from '../number-input';\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 DueDateMethod,\n type EmbryoAge,\n type Trimester,\n type DueDateResult,\n computeDueDate,\n DEFAULT_CYCLE_LENGTH,\n} from './gestation';\n\nconst rootVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]', {\n variants: {\n width: { full: 'ds:w-full', auto: 'ds:inline-flex' },\n },\n defaultVariants: { width: 'full' },\n});\n\nconst TRIMESTER_BADGE: Record<\n Trimester,\n 'neutral' | 'info' | 'success' | 'warning' | 'error'\n> = {\n preconception: 'neutral',\n first: 'info',\n second: 'success',\n third: 'warning',\n postterm: 'error',\n};\n\n/** Reference-date i18n key per method. */\nconst DATE_LABEL_KEY: Record<DueDateMethod, string> = {\n lmp: 'dueDateCalculator.lmpDate',\n conception: 'dueDateCalculator.conceptionDate',\n ivf: 'dueDateCalculator.transferDate',\n};\n\nexport interface DueDateCalculatorProps extends VariantProps<\n typeof rootVariants\n> {\n /** Initial dating method. Defaults to `'lmp'`. */\n defaultMethod?: DueDateMethod;\n /** Fires whenever a due date can be computed (and with `null` when it can't). */\n onResultChange?: (result: DueDateResult | 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 /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\nexport const DueDateCalculator = forwardRef<\n HTMLDivElement,\n DueDateCalculatorProps\n>(\n (\n {\n defaultMethod = 'lmp',\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n\n const [method, setMethod] = useState<DueDateMethod>(defaultMethod);\n const [refDate, setRefDate] = useState<Date | undefined>(undefined);\n const [cycleLength, setCycleLength] = useState<number | null>(\n DEFAULT_CYCLE_LENGTH,\n );\n const [embryoAge, setEmbryoAge] = useState<EmbryoAge>(5);\n\n // `today` is captured once per render; the result re-derives from it.\n const result = useMemo<DueDateResult | null>(() => {\n if (!refDate) return null;\n return computeDueDate(\n {\n method,\n date: refDate,\n cycleLength: cycleLength ?? DEFAULT_CYCLE_LENGTH,\n embryoAge,\n },\n new Date(),\n );\n }, [method, refDate, cycleLength, embryoAge]);\n\n const dateFormatter = useMemo(\n () => new Intl.DateTimeFormat(i18n.language, { dateStyle: 'long' }),\n [i18n.language],\n );\n\n useEffect(() => {\n onResultChange?.(result);\n }, [result, onResultChange]);\n\n const today = useMemo(() => new Date(), []);\n\n return (\n <div\n ref={ref}\n data-component=\"due-date-calculator\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <RadioGroup\n label={t('dueDateCalculator.method.label')}\n variant=\"horizontal\"\n value={method}\n onValueChange={(next) => setMethod(next as DueDateMethod)}\n >\n <Radio label={t('dueDateCalculator.method.lmp')} value=\"lmp\" />\n <Radio\n label={t('dueDateCalculator.method.conception')}\n value=\"conception\"\n />\n <Radio label={t('dueDateCalculator.method.ivf')} value=\"ivf\" />\n </RadioGroup>\n\n <div className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2\">\n <FormField label={t(DATE_LABEL_KEY[method])}>\n <DatePicker value={refDate} onChange={setRefDate} maxDate={today} />\n </FormField>\n\n {method === 'lmp' && (\n <FormField\n label={t('dueDateCalculator.cycleLength')}\n description={t('dueDateCalculator.cycleLengthHint')}\n >\n <NumberInput\n mode=\"integer\"\n min={20}\n max={45}\n value={cycleLength}\n onChange={setCycleLength}\n />\n </FormField>\n )}\n\n {method === 'ivf' && (\n <RadioGroup\n label={t('dueDateCalculator.embryoAge')}\n variant=\"horizontal\"\n value={String(embryoAge)}\n onValueChange={(next) => setEmbryoAge(Number(next) as EmbryoAge)}\n >\n <Radio label={t('dueDateCalculator.day3')} value=\"3\" />\n <Radio label={t('dueDateCalculator.day5')} value=\"5\" />\n </RadioGroup>\n )}\n </div>\n\n {/* Concise polite announcement when a due date resolves. */}\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {result\n ? `${t('dueDateCalculator.result.dueDateLabel')}: ${dateFormatter.format(\n result.dueDate,\n )}. ${t('dueDateCalculator.result.trimesterLabel')}: ${t(\n `dueDateCalculator.trimester.${result.trimester}`,\n )}.`\n : ''}\n </p>\n\n {result ? (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n <dl className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-3\">\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('dueDateCalculator.result.trimesterLabel')}\n </dt>\n <dd>\n <Badge\n variant={TRIMESTER_BADGE[result.trimester]}\n size=\"lg\"\n >\n {t(`dueDateCalculator.trimester.${result.trimester}`)}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('dueDateCalculator.result.gestationLabel')}\n </dt>\n <dd className=\"type-body ds:text-foreground\">\n {result.gestationalAge\n ? t('dueDateCalculator.result.gestation', {\n weeks: result.gestationalAge.weeks,\n days: result.gestationalAge.days,\n })\n : '—'}\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('dueDateCalculator.result.dueDateLabel')}\n </dt>\n <dd className=\"type-metric ds:text-foreground\">\n {dateFormatter.format(result.dueDate)}\n </dd>\n </div>\n </dl>\n {insertVariant === 'copy' || onInsert ? (\n <InsertButton\n variant={insertVariant}\n onInsert={onInsert}\n onCopy={onCopy}\n onError={onError}\n card={{\n title: t('insert.title.dueDate'),\n highlight: dateFormatter.format(result.dueDate),\n fields: [\n {\n label: t('dueDateCalculator.result.dueDateLabel'),\n value: dateFormatter.format(result.dueDate),\n },\n {\n label: t('dueDateCalculator.result.gestationLabel'),\n value: result.gestationalAge\n ? t('dueDateCalculator.result.gestation', {\n weeks: result.gestationalAge.weeks,\n days: result.gestationalAge.days,\n })\n : '—',\n },\n {\n label: t('dueDateCalculator.result.trimesterLabel'),\n value: t(\n `dueDateCalculator.trimester.${result.trimester}`,\n ),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('dueDateCalculator.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nDueDateCalculator.displayName = 'DueDateCalculator';\n"],"names":["rootVariants","cva","TRIMESTER_BADGE","DATE_LABEL_KEY","DueDateCalculator","forwardRef","defaultMethod","onResultChange","onInsert","insertVariant","onCopy","onError","id","width","className","ref","t","i18n","useTranslation","method","setMethod","useState","refDate","setRefDate","cycleLength","setCycleLength","DEFAULT_CYCLE_LENGTH","embryoAge","setEmbryoAge","result","useMemo","computeDueDate","dateFormatter","useEffect","today","jsxs","RadioGroup","next","jsx","Radio","FormField","DatePicker","NumberInput","Card","Badge","InsertButton"],"mappings":";;;;;;;;;;;;;AAmCA,MAAMA,IAAeC,EAAI,kDAAkD;AAAA,EACzE,UAAU;AAAA,IACR,OAAO,EAAE,MAAM,aAAa,MAAM,iBAAA;AAAA,EAAiB;AAAA,EAErD,iBAAiB,EAAE,OAAO,OAAA;AAC5B,CAAC,GAEKC,IAGF;AAAA,EACF,eAAe;AAAA,EACf,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AACZ,GAGMC,IAAgD;AAAA,EACpD,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,K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CAC9B;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAZ,EAAkB,cAAc;"}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { jsxs as s, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as T, useState as f, useMemo as m, useEffect as S } from "react";
|
|
3
|
-
import { c as k } from "./index-D2ZczOXr.js";
|
|
4
|
-
import { useTranslation as B } from "react-i18next";
|
|
5
|
-
import { R as h } from "./radio-TWf9Q-mp.js";
|
|
6
|
-
import { R as E } from "./radio-group-CLjK-SlK.js";
|
|
7
|
-
import { F } from "./form-field-BOm9hK35.js";
|
|
8
|
-
import { D as I } from "./date-picker-Bq7xhMA-.js";
|
|
9
|
-
import { C as x } from "./card-DPmk26CL.js";
|
|
10
|
-
import { B as A } from "./badge-zsf5i5bH.js";
|
|
11
|
-
import { I as M } from "./insert-result-DisOY2G-.js";
|
|
12
|
-
import { c as j, g as R, G as z } from "./gestation-mWF4AXea.js";
|
|
13
|
-
import { s as V } from "./subDays-Dv7q9S7u.js";
|
|
14
|
-
import { i as _ } from "./date-picker-variants-DLi1Va_e.js";
|
|
15
|
-
const O = k("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
16
|
-
variants: {
|
|
17
|
-
width: { full: "ds:w-full", auto: "ds:inline-flex" }
|
|
18
|
-
},
|
|
19
|
-
defaultVariants: { width: "full" }
|
|
20
|
-
}), P = {
|
|
21
|
-
preconception: "neutral",
|
|
22
|
-
first: "info",
|
|
23
|
-
second: "success",
|
|
24
|
-
third: "warning",
|
|
25
|
-
postterm: "error"
|
|
26
|
-
}, Y = T(
|
|
27
|
-
({
|
|
28
|
-
defaultMethod: v = "lmp",
|
|
29
|
-
onResultChange: d,
|
|
30
|
-
onInsert: g,
|
|
31
|
-
insertVariant: u = "insert",
|
|
32
|
-
onCopy: y,
|
|
33
|
-
onError: b,
|
|
34
|
-
id: C,
|
|
35
|
-
width: N,
|
|
36
|
-
className: D
|
|
37
|
-
}, w) => {
|
|
38
|
-
const { t: e, i18n: p } = B(), [o, $] = f(v), [i, G] = f(void 0), n = m(() => /* @__PURE__ */ new Date(), []), t = m(() => {
|
|
39
|
-
if (!i) return null;
|
|
40
|
-
const l = o === "lmp" ? i : V(i, z), r = j({ method: "lmp", date: l }, n);
|
|
41
|
-
return {
|
|
42
|
-
result: {
|
|
43
|
-
gestationalAge: r.gestationalAge,
|
|
44
|
-
trimester: r.trimester,
|
|
45
|
-
dueDate: r.dueDate
|
|
46
|
-
},
|
|
47
|
-
milestones: R(r.gestationalStart)
|
|
48
|
-
};
|
|
49
|
-
}, [o, i, n]), L = m(
|
|
50
|
-
() => new Intl.DateTimeFormat(p.language, { dateStyle: "medium" }),
|
|
51
|
-
[p.language]
|
|
52
|
-
);
|
|
53
|
-
S(() => {
|
|
54
|
-
d == null || d((t == null ? void 0 : t.result) ?? null);
|
|
55
|
-
}, [t, d]);
|
|
56
|
-
const c = (l) => l ? e("gestationalAgeCalculator.gestation", {
|
|
57
|
-
weeks: l.weeks,
|
|
58
|
-
days: l.days
|
|
59
|
-
}) : "—";
|
|
60
|
-
return /* @__PURE__ */ s(
|
|
61
|
-
"div",
|
|
62
|
-
{
|
|
63
|
-
ref: w,
|
|
64
|
-
"data-component": "gestational-age-calculator",
|
|
65
|
-
"data-component-id": C,
|
|
66
|
-
className: O({ width: N, className: D }),
|
|
67
|
-
children: [
|
|
68
|
-
/* @__PURE__ */ s(
|
|
69
|
-
E,
|
|
70
|
-
{
|
|
71
|
-
label: e("gestationalAgeCalculator.method.label"),
|
|
72
|
-
variant: "horizontal",
|
|
73
|
-
value: o,
|
|
74
|
-
onValueChange: (l) => $(l),
|
|
75
|
-
children: [
|
|
76
|
-
/* @__PURE__ */ a(h, { label: e("gestationalAgeCalculator.method.lmp"), value: "lmp" }),
|
|
77
|
-
/* @__PURE__ */ a(h, { label: e("gestationalAgeCalculator.method.edd"), value: "edd" })
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
),
|
|
81
|
-
/* @__PURE__ */ a(
|
|
82
|
-
F,
|
|
83
|
-
{
|
|
84
|
-
label: e(
|
|
85
|
-
o === "lmp" ? "gestationalAgeCalculator.lmpDate" : "gestationalAgeCalculator.eddDate"
|
|
86
|
-
),
|
|
87
|
-
children: /* @__PURE__ */ a(
|
|
88
|
-
I,
|
|
89
|
-
{
|
|
90
|
-
value: i,
|
|
91
|
-
onChange: G,
|
|
92
|
-
maxDate: o === "lmp" ? n : void 0
|
|
93
|
-
}
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
),
|
|
97
|
-
/* @__PURE__ */ a("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: t ? `${e("gestationalAgeCalculator.gestationLabel")}: ${c(
|
|
98
|
-
t.result.gestationalAge
|
|
99
|
-
)}. ${e("gestationalAgeCalculator.trimesterLabel")}: ${e(
|
|
100
|
-
`gestationalAgeCalculator.trimester.${t.result.trimester}`
|
|
101
|
-
)}.` : "" }),
|
|
102
|
-
t ? /* @__PURE__ */ a(x, { variant: "elevated", children: /* @__PURE__ */ s(x.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
|
|
103
|
-
/* @__PURE__ */ s("dl", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2", children: [
|
|
104
|
-
/* @__PURE__ */ s("div", { className: "ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-xs)]", children: [
|
|
105
|
-
/* @__PURE__ */ a("dt", { className: "type-label ds:text-muted-foreground", children: e("gestationalAgeCalculator.trimesterLabel") }),
|
|
106
|
-
/* @__PURE__ */ a("dd", { children: /* @__PURE__ */ a(
|
|
107
|
-
A,
|
|
108
|
-
{
|
|
109
|
-
variant: P[t.result.trimester],
|
|
110
|
-
size: "lg",
|
|
111
|
-
children: e(
|
|
112
|
-
`gestationalAgeCalculator.trimester.${t.result.trimester}`
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
) })
|
|
116
|
-
] }),
|
|
117
|
-
/* @__PURE__ */ s("div", { className: "ds:flex ds:flex-col ds:items-end ds:gap-[var(--spacing-xs)] ds:text-end", children: [
|
|
118
|
-
/* @__PURE__ */ a("dt", { className: "type-label ds:text-muted-foreground", children: e("gestationalAgeCalculator.gestationLabel") }),
|
|
119
|
-
/* @__PURE__ */ a("dd", { className: "type-metric ds:text-foreground", children: c(t.result.gestationalAge) })
|
|
120
|
-
] })
|
|
121
|
-
] }),
|
|
122
|
-
/* @__PURE__ */ s("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
|
|
123
|
-
/* @__PURE__ */ a("span", { className: "type-label ds:text-muted-foreground", children: e("gestationalAgeCalculator.milestonesLabel") }),
|
|
124
|
-
/* @__PURE__ */ a("ul", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: t.milestones.map((l) => {
|
|
125
|
-
const r = _(n, l.date);
|
|
126
|
-
return /* @__PURE__ */ s(
|
|
127
|
-
"li",
|
|
128
|
-
{
|
|
129
|
-
className: "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-md)]",
|
|
130
|
-
children: [
|
|
131
|
-
/* @__PURE__ */ a("span", { className: "type-body ds:text-foreground", children: e(`gestationalAgeCalculator.milestone.${l.key}`) }),
|
|
132
|
-
/* @__PURE__ */ s("span", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
|
|
133
|
-
/* @__PURE__ */ a("span", { className: "type-body ds:text-muted-foreground", children: L.format(l.date) }),
|
|
134
|
-
r ? /* @__PURE__ */ a(A, { variant: "success", children: e("gestationalAgeCalculator.reached") }) : null
|
|
135
|
-
] })
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
l.key
|
|
139
|
-
);
|
|
140
|
-
}) })
|
|
141
|
-
] }),
|
|
142
|
-
u === "copy" || g ? /* @__PURE__ */ a(
|
|
143
|
-
M,
|
|
144
|
-
{
|
|
145
|
-
onInsert: g,
|
|
146
|
-
variant: u,
|
|
147
|
-
onCopy: y,
|
|
148
|
-
onError: b,
|
|
149
|
-
card: {
|
|
150
|
-
title: e("insert.title.gestationalAge"),
|
|
151
|
-
highlight: e(
|
|
152
|
-
`gestationalAgeCalculator.trimester.${t.result.trimester}`
|
|
153
|
-
),
|
|
154
|
-
fields: [
|
|
155
|
-
{
|
|
156
|
-
label: e("gestationalAgeCalculator.gestationLabel"),
|
|
157
|
-
value: c(t.result.gestationalAge)
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
label: e("gestationalAgeCalculator.trimesterLabel"),
|
|
161
|
-
value: e(
|
|
162
|
-
`gestationalAgeCalculator.trimester.${t.result.trimester}`
|
|
163
|
-
)
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
) : null
|
|
169
|
-
] }) }) : /* @__PURE__ */ a("p", { className: "type-body ds:text-muted-foreground", children: e("gestationalAgeCalculator.empty") })
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
Y.displayName = "GestationalAgeCalculator";
|
|
176
|
-
export {
|
|
177
|
-
Y as G
|
|
178
|
-
};
|
|
179
|
-
//# sourceMappingURL=gestational-age-calculator-ZMSrzkRW.js.map
|