@openrails/contentkit-ui 0.101.1 → 0.102.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-date-picker.js","names":[],"sources":["../../../src/components/content/release-date-picker.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport { cn } from \"cn\";\nimport { Button } from \"#ckui/ui/button\";\nimport { Input } from \"#ckui/ui/input\";\nimport { useMessages } from \"../../i18n/context.js\";\nimport type { ContentKitUiAppearance } from \"../../appearance.js\";\nimport { ContentKitUiRoot } from \"../../scope.js\";\n\n/** Today's YYYY-MM-DD in the browser's local calendar, without a UTC shift. */\nexport function localReleaseDate(now = new Date()): string {\n return `${String(now.getFullYear()).padStart(4, \"0\")}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}`;\n}\n\n/** A real calendar date on or before max; empty selects the latest window. */\nexport function isReleaseDate(value: string, max = localReleaseDate()): boolean {\n if (!value) return true;\n if (!/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.test(value) || value.startsWith(\"0000\") || value > max) return false;\n const at = new Date(`${value}T12:00:00Z`);\n return Number.isFinite(at.getTime()) && at.toISOString().slice(0, 10) === value;\n}\n\nexport interface ReleaseDatePickerProps {\n /** Inclusive end_date of a DailyReleases query; empty means latest. */\n value?: string;\n onValueChange: (value: string) => void;\n /** YYYY-MM-DD in the listing's calendar. Browser-local today by default. */\n max?: string;\n className?: string;\n appearance?: ContentKitUiAppearance;\n}\n\n/** Native calendar with an editable year, so old dates need no month-by-month paging. */\nexport function ReleaseDatePicker({ value = \"\", onValueChange, max = localReleaseDate(), className, appearance }: ReleaseDatePickerProps) {\n const id = useId();\n const { t } = useMessages();\n const valid = isReleaseDate(value, max);\n return <ContentKitUiRoot appearance={appearance} className={cn(\"grid justify-items-start gap-2\", className)} data-ckui=\"release-date-picker\">\n <div className=\"flex flex-wrap items-center gap-3\">\n <label htmlFor={id} className=\"text-base font-medium\">{t(\"releases.throughDate\")}</label>\n <Input id={id} type=\"date\" min=\"0001-01-01\" max={max} value={valid ? value : \"\"} className=\"h-11 w-auto min-w-40 text-base\" aria-invalid={!valid || undefined} aria-describedby={!valid ? `${id}-error` : undefined} onChange={(event) => {\n const next = event.currentTarget.value;\n if (isReleaseDate(next, max)) onValueChange(next);\n }} />\n <Button type=\"button\" variant=\"outline\" disabled={!value} onClick={() => onValueChange(\"\")}>{t(\"releases.latest\")}</Button>\n </div>\n {!valid && <p id={`${id}-error`} role=\"alert\" className=\"text-sm text-destructive\">{t(\"releases.invalidDate\")}</p>}\n </ContentKitUiRoot>;\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,EAAiB,oBAAM,IAAI,KAAK,GAAW;CACzD,OAAO,GAAG,OAAO,EAAI,YAAY,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,EAAI,SAAS,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,EAAI,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;AAC9I;AAGA,SAAgB,EAAc,GAAe,IAAM,EAAiB,GAAY;CAC9E,IAAI,CAAC,GAAO,OAAO;CACnB,IAAI,CAAC,+BAA+B,KAAK,CAAK,KAAK,EAAM,WAAW,MAAM,KAAK,IAAQ,GAAK,OAAO;CACnG,IAAM,oBAAK,IAAI,KAAK,GAAG,EAAM,WAAW;CACxC,OAAO,OAAO,SAAS,EAAG,QAAQ,CAAC,KAAK,EAAG,YAAY,CAAC,CAAC,MAAM,GAAG,EAAE,MAAM;AAC5E;AAaA,SAAgB,EAAkB,EAAE,WAAQ,IAAI,kBAAe,SAAM,EAAiB,GAAG,cAAW,iBAAsC;CACxI,IAAM,IAAK,EAAM,GACX,EAAE,SAAM,EAAY,GACpB,IAAQ,EAAc,GAAO,CAAG;CACtC,OAAO,kBAAC,GAAD;EAA8B;EAAY,WAAW,EAAG,kC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