mirror of
https://github.com/bitbaum/whenkit.git
synced 2026-12-03 22:47:23 +01:00
Same props and onChange(event) as the native input, so a call site changes its tag and nothing else. The value shows in words in the app's OWN styling (className lands on the visible box); the real input stays on top, transparent, so the picker, keyboard, autofill, validation and form submission keep working. Controlled or uncontrolled; locale and empty-state words follow <html lang>. The look is in @layer base so an app's classes win: unlayered defaults would have beaten Tailwind v4's layered utilities. A browser check proves both a plain class and a layered utility win, and fails without the layer. DateField is now a labelled wrapper on DateInput. Signed-off-by: Cato <41178744+catomean@users.noreply.github.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
19 lines
1.3 KiB
JavaScript
19 lines
1.3 KiB
JavaScript
"use client";
|
||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||
/**
|
||
* A labelled date (or date + time) field: `DateInput` with its own label and
|
||
* an optional hint, for places that do not already have a form-field wrapper.
|
||
* Apps that do (most) use `DateInput` directly.
|
||
*
|
||
* Values are `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM` wall-clock strings — exactly
|
||
* what the native input speaks — never instants.
|
||
*/
|
||
import { useId } from "react";
|
||
import { DateInput, describeValue } from "./DateInput.js";
|
||
/** Kept for callers of 0.1–0.2: the words for a value, or "" if invalid. */
|
||
export const describeFieldValue = describeValue;
|
||
export function DateField({ label, value, onChange, withTime = false, min, max, required, name, placeholder, locale, hint, className, }) {
|
||
const id = useId();
|
||
return (_jsxs("div", { className: ["wk-field", className].filter(Boolean).join(" "), children: [_jsx("label", { className: "wk-label", htmlFor: id, children: label }), _jsx(DateInput, { id: id, type: withTime ? "datetime-local" : "date", value: value, onChange: (e) => onChange(e.target.value), min: min, max: max, required: required, name: name, placeholder: placeholder, locale: locale, "aria-describedby": hint ? `${id}-hint` : undefined }), hint && (_jsx("p", { className: "wk-hint", id: `${id}-hint`, children: hint }))] }));
|
||
}
|
||
//# sourceMappingURL=DateField.js.map
|