UNPKG

laif-ds

Version:

Design System di Laif con componenti React basati su principi di Atomic Design

72 lines (71 loc) 2.35 kB
"use client"; import { jsxs as d, jsx as e } from "react/jsx-runtime"; import * as c from "react"; import { cn as g } from "../../lib/utils.js"; import { buttonVariants as x } from "./button.js"; import { Icon as h } from "./icon.js"; import { Calendar as v } from "./calendar.js"; import { Popover as w, PopoverTrigger as P, PopoverContent as b } from "./popover.js"; import { formatDate as C } from "../../node_modules/date-fns/format.js"; function E({ value: n, onChange: a, placeholder: l = "Seleziona data", dateFormat: m = "PPP", className: f, buttonVariant: u = "default", disabled: t = !1, size: o = "default" }) { const [r, i] = c.useState(n); c.useEffect(() => { i(n); }, [n]); const p = (s) => { i(s), a && a(s); }; return /* @__PURE__ */ d(w, { open: t ? !1 : void 0, children: [ /* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ e( "div", { className: g( x({ variant: u, size: o }), "border-d-input text-d-foreground hover:bg-d-accent bg-d-input ring-offset-background data-[placeholder]:text-d-muted-foreground focus:ring-d-ring flex items-center justify-between border px-3 py-2 font-normal whitespace-nowrap shadow-sm focus:ring-1 focus:outline-none [&>span]:line-clamp-1", !r && "text-d-muted-foreground", t && "cursor-not-allowed opacity-50", f, o === "sm" && "text-xs", o === "lg" && "text-lg" ), "aria-disabled": t, role: "button", tabIndex: t ? -1 : 0, onClick: t ? void 0 : () => { }, children: /* @__PURE__ */ d("div", { className: "flex w-full items-center justify-between gap-2", children: [ /* @__PURE__ */ e( h, { name: "Calendar", size: o === "default" ? "md" : o === "sm" ? "xs" : "sm" } ), r ? /* @__PURE__ */ e("span", { children: C(r, m) }) : /* @__PURE__ */ e("span", { className: "text-d-muted-foreground", children: l }) ] }) } ) }), /* @__PURE__ */ e(b, { className: "w-auto p-0", children: /* @__PURE__ */ e( v, { mode: "single", selected: r, onSelect: p, initialFocus: !0, disabled: t } ) }) ] }); } export { E as DatePicker };