UNPKG

laif-ds

Version:

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

174 lines (173 loc) 6.73 kB
"use client"; import { jsx as d } from "react/jsx-runtime"; import * as g from "react"; import { cn as e } from "../../lib/utils.js"; import { buttonVariants as m, Button as b } from "./button.js"; import { getDefaultClassNames as f } from "../../node_modules/react-day-picker/dist/esm/helpers/getDefaultClassNames.js"; import { DayPicker as w } from "../../node_modules/react-day-picker/dist/esm/DayPicker.js"; import _ from "../../node_modules/lucide-react/dist/esm/icons/chevron-left.js"; import h from "../../node_modules/lucide-react/dist/esm/icons/chevron-right.js"; import y from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.js"; function B({ className: c, classNames: i, showOutsideDays: r = !0, captionLayout: l = "label", buttonVariant: s = "ghost", formatters: u, components: p, ...x }) { const t = f(); return /* @__PURE__ */ d( w, { showOutsideDays: r, className: e( "bg-d-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent", String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`, String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`, c ), captionLayout: l, formatters: { formatMonthDropdown: (a) => a.toLocaleString("default", { month: "short" }), ...u }, classNames: { root: e("w-fit", t.root), months: e( "flex gap-4 flex-col md:flex-row relative", t.months ), month: e("flex flex-col w-full gap-4", t.month), nav: e( "flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", t.nav ), button_previous: e( m({ variant: s }), "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none", t.button_previous ), button_next: e( m({ variant: s }), "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none", t.button_next ), month_caption: e( "flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)", t.month_caption ), dropdowns: e( "w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5", t.dropdowns ), dropdown_root: e( "relative has-focus:border-ring border border-d-input shadow-xs has-focus:ring-d-ring/50 has-focus:ring-[3px] rounded-md", t.dropdown_root ), dropdown: e("absolute inset-0 opacity-0", t.dropdown), caption_label: e( "select-none font-medium", l === "label" ? "text-sm" : "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-d-muted-foreground [&>svg]:size-3.5", t.caption_label ), table: "w-full border-collapse", weekdays: e("flex", t.weekdays), weekday: e( "text-d-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none", t.weekday ), week: e("flex w-full mt-2", t.week), week_number_header: e( "select-none w-(--cell-size)", t.week_number_header ), week_number: e( "text-[0.8rem] select-none text-d-muted-foreground", t.week_number ), day: e( "relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none", t.day ), range_start: e( "rounded-l-md bg-d-accent", t.range_start ), range_middle: e("rounded-none", t.range_middle), range_end: e("rounded-r-md bg-d-accent", t.range_end), today: e( "bg-d-accent text-d-accent-foreground rounded-md data-[selected=true]:rounded-none", t.today ), outside: e( "text-d-muted-foreground aria-selected:text-d-muted-foreground", t.outside ), disabled: e( "text-d-muted-foreground opacity-50", t.disabled ), hidden: e("invisible", t.hidden), ...i }, components: { Root: ({ className: a, rootRef: n, ...o }) => /* @__PURE__ */ d( "div", { "data-slot": "calendar", ref: n, className: e(a), ...o } ), Chevron: ({ className: a, orientation: n, ...o }) => n === "left" ? /* @__PURE__ */ d(_, { className: e("size-4", a), ...o }) : n === "right" ? /* @__PURE__ */ d( h, { className: e("size-4", a), ...o } ) : /* @__PURE__ */ d(y, { className: e("size-4", a), ...o }), DayButton: v, WeekNumber: ({ children: a, ...n }) => /* @__PURE__ */ d("td", { ...n, children: /* @__PURE__ */ d("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children: a }) }), ...p }, ...x } ); } function v({ className: c, day: i, modifiers: r, ...l }) { const s = f(), u = g.useRef(null); return g.useEffect(() => { r.focused && u.current?.focus(); }, [r.focused]), /* @__PURE__ */ d( b, { ref: u, variant: "ghost", size: "icon", "data-day": i.date.toLocaleDateString(), "data-selected-single": r.selected && !r.range_start && !r.range_end && !r.range_middle, "data-range-start": r.range_start, "data-range-end": r.range_end, "data-range-middle": r.range_middle, className: e( "data-[selected-single=true]:bg-d-primary data-[selected-single=true]:text-d-primary-foreground data-[range-middle=true]:bg-d-accent data-[range-middle=true]:text-d-accent-foreground data-[range-start=true]:bg-d-primary data-[range-start=true]:text-d-primary-foreground data-[range-end=true]:bg-d-primary data-[range-end=true]:text-d-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-d-ring/50 dark:hover:text-d-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[1px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70", s.day, c ), ...l } ); } export { B as Calendar, v as CalendarDayButton };