@jarllyng/nostromo 3.13.0 → 3.15.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/chunk-4UHGGKCS.cjs +3 -0
- package/dist/chunk-4UHGGKCS.cjs.map +1 -0
- package/dist/chunk-A4ODFRMS.js +3 -0
- package/dist/chunk-A4ODFRMS.js.map +1 -0
- package/dist/chunk-HCO4XKPM.js +3 -0
- package/dist/chunk-HCO4XKPM.js.map +1 -0
- package/dist/chunk-KASVYULP.cjs +3 -0
- package/dist/chunk-KASVYULP.cjs.map +1 -0
- package/dist/chunk-UC577SR4.cjs +3 -0
- package/dist/chunk-UC577SR4.cjs.map +1 -0
- package/dist/chunk-YC6ALHAZ.js +3 -0
- package/dist/chunk-YC6ALHAZ.js.map +1 -0
- package/dist/components/core/calendar.cjs +1 -1
- package/dist/components/core/calendar.d.cts +22 -1
- package/dist/components/core/calendar.d.ts +22 -1
- package/dist/components/core/calendar.js +1 -1
- package/dist/components/core/data-table.cjs +1 -1
- package/dist/components/core/data-table.d.cts +22 -1
- package/dist/components/core/data-table.d.ts +22 -1
- package/dist/components/core/data-table.js +1 -1
- package/dist/components/core/table.cjs +1 -1
- package/dist/components/core/table.d.cts +10 -0
- package/dist/components/core/table.d.ts +10 -0
- package/dist/components/core/table.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-35I2BJC3.js +0 -3
- package/dist/chunk-35I2BJC3.js.map +0 -1
- package/dist/chunk-AYEM2M4H.cjs +0 -3
- package/dist/chunk-AYEM2M4H.cjs.map +0 -1
- package/dist/chunk-JCETHQ55.cjs +0 -3
- package/dist/chunk-JCETHQ55.cjs.map +0 -1
- package/dist/chunk-UIEGBT4T.js +0 -3
- package/dist/chunk-UIEGBT4T.js.map +0 -1
- package/dist/chunk-VNDL67OG.cjs +0 -3
- package/dist/chunk-VNDL67OG.cjs.map +0 -1
- package/dist/chunk-XJJJEWSU.js +0 -3
- package/dist/chunk-XJJJEWSU.js.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var chunk5PVFLXPO_cjs=require('./chunk-5PVFLXPO.cjs'),chunkITRGJNWL_cjs=require('./chunk-ITRGJNWL.cjs'),a=require('react'),C=require('@radix-ui/react-popover'),classVarianceAuthority=require('class-variance-authority'),dateFns=require('date-fns');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var a__default=/*#__PURE__*/_interopDefault(a);var C__namespace=/*#__PURE__*/_interopNamespace(C);var Pe=classVarianceAuthority.cva("inline-block rounded-lg border bg-background shadow-lg",{variants:{variant:{default:"border-border bg-card",outline:"border-2 border-border",ghost:"border-transparent bg-transparent shadow-none"},size:{sm:"p-2",md:"p-3",lg:"p-4"}},defaultVariants:{variant:"default",size:"md"}}),R=classVarianceAuthority.cva("flex items-center justify-center rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"hover:bg-muted text-foreground",selected:"bg-primary text-primary-foreground hover:bg-primary/90 font-semibold",range:"bg-primary/10 text-primary hover:bg-primary/20 font-medium",today:"border-2 border-primary text-foreground font-semibold",outside:"text-muted-foreground",disabled:"text-muted-foreground/50 cursor-not-allowed"},size:{sm:"h-7 w-7 text-xs",md:"h-9 w-9 text-sm",lg:"h-11 w-11 text-base"}},defaultVariants:{variant:"default",size:"md"}}),ee=t=>dateFns.getDaysInMonth(t),Te=(t,r)=>{let o=dateFns.getDay(dateFns.startOfMonth(t));return r===1?o===0?6:o-1:o},x=(t,r)=>!t||!r?false:dateFns.isSameDay(t,r),Se=(t,r,o)=>!r&&!o?false:r&&o?dateFns.isWithinInterval(dateFns.startOfDay(t),{start:dateFns.startOfDay(r),end:dateFns.endOfDay(o)}):r?!dateFns.isBefore(dateFns.startOfDay(t),dateFns.startOfDay(r)):o?!dateFns.isAfter(dateFns.startOfDay(t),dateFns.endOfDay(o)):false,O=(t,r,o,g,m)=>!!(r&&dateFns.isBefore(dateFns.startOfDay(t),dateFns.startOfDay(r))||o&&dateFns.isAfter(dateFns.startOfDay(t),dateFns.endOfDay(o))||g?.some(p=>x(p,t))||m?.includes(dateFns.getDay(t))),P=(t,r="en-US")=>t?new Intl.DateTimeFormat(r,{year:"numeric",month:"short",day:"numeric"}).format(t):"",Le=(t,r,o="en-US")=>!t&&!r?"":t&&r?`${P(t,o)} - ${P(r,o)}`:t?P(t,o):r?P(r,o):"",Ee=(t,r="en-US",o=g=>`${g} dates selected`)=>t.length===0?"":t.length===1?P(t[0],r):o(t.length),Ie=(t,r)=>{let o=new Intl.DateTimeFormat(t,{weekday:"short"}),g=Array.from({length:7},(m,p)=>o.format(new Date(2024,0,7+p)));return r===1?[...g.slice(1),g[0]]:g},Ye={openCalendar:"Open calendar",placeholder:"Select date...",previousMonth:"Previous month",nextMonth:"Next month",today:"Today",selectEndDate:"Select end date",multipleSelected:t=>`${t} dates selected`},te=t=>{if(t)return t instanceof Date?t:Array.isArray(t)?t[0]:t.from??t.to},F=(t,r,o,g=366)=>{let m=new Date(t);for(let p=0;p<g;p++){if(!o(m))return new Date(m);m.setDate(m.getDate()+r);}},q=(t,r)=>{let o=new Date(t.getFullYear(),t.getMonth()+r,1),g=dateFns.getDaysInMonth(o);return o.setDate(Math.min(t.getDate(),g)),o},Ve=a__default.default.forwardRef(({mode:t="single",value:r,defaultValue:o,onChange:g,minDate:m,maxDate:p,disabledDates:I,disabledDays:Y,locale:v="en-US",placeholder:ie,label:U,error:H,helperText:W,className:le,inputClassName:de,calendarClassName:ue,variant:fe,size:K,showOutsideDays:T=true,firstDayOfWeek:V=1,labels:J,...ce},ge)=>{let y=a.useMemo(()=>({...Ye,...J}),[J]),[S,L]=a.useState(false),[c,$]=a.useState(()=>te(r??o)??new Date),[h,E]=a.useState(null),me=a.useRef(null),j=a.useRef(new Map),[De,pe]=a.useState(o),Q=r!==void 0,f=Q?r:De,M=a__default.default.useCallback(e=>O(e,m,p,I,Y),[m,p,I,Y]);a__default.default.useLayoutEffect(()=>{if(!S||h)return;let e=dateFns.startOfDay(new Date),s=[te(f),e].find(d=>!!d&&!M(d));if(s){E(dateFns.startOfDay(s));return}let i=dateFns.startOfMonth(c),l=F(i,1,M,dateFns.getDaysInMonth(c));l&&E(l);},[S,h,f,c,M]);let N=e=>{Q||pe(e),g?.(e);},_=e=>{if(!O(e,m,p,I,Y)){if(t==="single")N(e),L(false);else if(t==="range"){let n=f;if(!n?.from||n.from&&n.to)N({from:e});else {let s=n.from,i=e;i<s?N({from:i,to:s}):N({from:s,to:i}),L(false);}}else if(t==="multiple"){let n=f||[],s=n.findIndex(i=>x(i,e));s>=0?N(n.filter((i,l)=>l!==s)):N([...n,e]);}}},he=a.useMemo(()=>{if(!f)return "";if(t==="single")return P(f,v);if(t==="range"){let e=f;return Le(e.from,e.to,v)}else return Ee(f,v,y.multipleSelected)},[f,t,v,y.multipleSelected]),be=a.useMemo(()=>{let e=[],n=new Date;n.setHours(0,0,0,0);let s=Te(c,V),i=ee(c);if(s>0){let l=new Date(c.getFullYear(),c.getMonth()-1),d=ee(l);for(let D=d-s+1;D<=d;D++){let u=new Date(l.getFullYear(),l.getMonth(),D);e.push({date:u,isCurrentMonth:false,isToday:x(u,n),placeholder:!T});}}for(let l=1;l<=i;l++){let d=new Date(c.getFullYear(),c.getMonth(),l);e.push({date:d,isCurrentMonth:true,isToday:x(d,n)});}if(T){let l=42-e.length,d=new Date(c.getFullYear(),c.getMonth()+1);for(let D=1;D<=l;D++){let u=new Date(d.getFullYear(),d.getMonth(),D);e.push({date:u,isCurrentMonth:false,isToday:x(u,n)});}}return e},[c,T,V]),X=e=>{let n=new Date(c.getFullYear(),c.getMonth()+e,1);if($(n),!h)return;let s=q(h,e),i=F(s,1,M,dateFns.getDaysInMonth(n))??F(s,-1,M,dateFns.getDaysInMonth(n));i&&E(i);},ve=()=>X(-1),ye=()=>X(1),Me=()=>{let e=dateFns.startOfDay(new Date);$(e);let n=F(e,1,M,31)??F(e,-1,M,31);n&&E(n);},we=(e,n)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault(),_(n);return}let s=(l,d,D)=>{let u=F(l,d,M,D);u&&(E(u),(u.getMonth()!==c.getMonth()||u.getFullYear()!==c.getFullYear())&&$(new Date(u.getFullYear(),u.getMonth(),1)));},i=l=>{let d=new Date(n);d.setDate(d.getDate()+l),s(d,l>0?1:-1);};if(e.key==="ArrowRight"){e.preventDefault(),i(1);return}if(e.key==="ArrowLeft"){e.preventDefault(),i(-1);return}if(e.key==="ArrowDown"){e.preventDefault(),i(7);return}if(e.key==="ArrowUp"){e.preventDefault(),i(-7);return}if(e.key==="Home"){e.preventDefault(),s(new Date(n.getFullYear(),n.getMonth(),1),1,dateFns.getDaysInMonth(n));return}if(e.key==="End"){e.preventDefault(),s(new Date(n.getFullYear(),n.getMonth()+1,0),-1,dateFns.getDaysInMonth(n));return}if(e.key==="PageUp"){e.preventDefault(),s(q(n,-1),-1);return}if(e.key==="PageDown"){e.preventDefault(),s(q(n,1),1);return}if(e.key==="Escape"){e.preventDefault(),L(false);return}};a.useEffect(()=>{if(h&&S){let e=`${h.getFullYear()}-${h.getMonth()}-${h.getDate()}`,n=j.current.get(e);n&&n.focus();}},[h,S]);let xe=a.useMemo(()=>Ie(v,V),[v,V]),Ce=c.toLocaleDateString(v,{month:"long",year:"numeric"});return a__default.default.createElement("div",{ref:ge,className:chunkITRGJNWL_cjs.a("w-full",le),...ce},a__default.default.createElement(C__namespace.Root,{open:S,onOpenChange:L},a__default.default.createElement("div",{className:"space-y-2"},U&&a__default.default.createElement("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},U),a__default.default.createElement(C__namespace.Trigger,{asChild:true},a__default.default.createElement("button",{type:"button",className:chunkITRGJNWL_cjs.a("flex w-full rounded-md border bg-background px-3 py-2 text-sm ring-offset-background","placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-200 text-left",H?"border-error-500 shadow-sm hover:border-error-600 focus-visible:ring-error-500/20 focus-visible:border-error-500":"border-border shadow-sm hover:border-primary focus-visible:ring-ring/20 focus-visible:border-primary","h-10",de),onClick:()=>L(true),"aria-label":U||y.openCalendar,"aria-invalid":H},he||a__default.default.createElement("span",{className:"text-muted-foreground"},ie??y.placeholder))),W&&a__default.default.createElement("p",{className:chunkITRGJNWL_cjs.a("text-sm text-muted-foreground",H&&"text-error-600")},W)),a__default.default.createElement(C__namespace.Portal,null,a__default.default.createElement(C__namespace.Content,{className:chunkITRGJNWL_cjs.a("z-50 w-auto rounded-lg border bg-popover p-4 shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"),sideOffset:5,align:"start"},a__default.default.createElement("div",{ref:me,className:chunkITRGJNWL_cjs.a(Pe({variant:fe,size:K}),ue),role:"application","aria-label":"Calendar"},a__default.default.createElement("div",{className:"flex items-center justify-between mb-4"},a__default.default.createElement("div",{className:"flex items-center gap-2"},a__default.default.createElement(chunk5PVFLXPO_cjs.b,{variant:"ghost",size:"sm",onClick:ve,"aria-label":y.previousMonth},a__default.default.createElement("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},a__default.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"}))),a__default.default.createElement("h3",{className:"text-sm font-semibold text-popover-foreground","data-testid":"calendar-month-year"},Ce),a__default.default.createElement(chunk5PVFLXPO_cjs.b,{variant:"ghost",size:"sm",onClick:ye,"aria-label":y.nextMonth},a__default.default.createElement("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},a__default.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})))),a__default.default.createElement(chunk5PVFLXPO_cjs.b,{variant:"ghost",size:"sm",onClick:Me,className:"text-xs"},y.today)),a__default.default.createElement("div",{className:"grid grid-cols-7 gap-1 mb-2"},xe.map(e=>a__default.default.createElement("div",{key:e,className:"text-center text-xs font-medium text-muted-foreground"},e))),a__default.default.createElement("div",{className:"grid grid-cols-7 gap-1"},be.map((e,n)=>{let s=t==="single"?x(e.date,f):t==="range"?Se(e.date,f?.from,f?.to):f?.some(u=>x(u,e.date)),i=O(e.date,m,p,I,Y),l=t==="range"&&f?.from&&!f?.to&&e.date>=f.from,d=`${e.date.getFullYear()}-${e.date.getMonth()}-${e.date.getDate()}`,D=h&&x(e.date,h);return e.placeholder?a__default.default.createElement("div",{key:`placeholder-${n}`,"aria-hidden":"true","data-calendar-placeholder":"",className:chunkITRGJNWL_cjs.a(R({variant:"default",size:K}),"invisible")}):a__default.default.createElement("button",{key:`${e.date.getTime()}-${n}`,ref:u=>{u?j.current.set(d,u):j.current.delete(d);},type:"button",onClick:()=>{T&&!e.isCurrentMonth&&$(new Date(e.date.getFullYear(),e.date.getMonth(),1)),_(e.date);},onKeyDown:u=>we(u,e.date),disabled:i||(T?false:!e.isCurrentMonth),className:chunkITRGJNWL_cjs.a(R({variant:s?"selected":l?"range":e.isToday?"today":e.isCurrentMonth?i?"disabled":"default":"outside",size:K}),!e.isCurrentMonth&&"opacity-50",D&&"ring-2 ring-brand-500 ring-offset-2 z-10"),"aria-label":e.date.toLocaleDateString(v,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),"aria-selected":s,"aria-disabled":i,tabIndex:D?0:-1},e.date.getDate())})),t==="range"&&f?.from&&!f?.to&&a__default.default.createElement("div",{className:"mt-4 pt-4 border-t border-border"},a__default.default.createElement("p",{className:"text-xs text-muted-foreground text-center"},y.selectEndDate)))))))});Ve.displayName="Calendar";exports.a=Pe;exports.b=R;exports.c=Ve;//# sourceMappingURL=chunk-4UHGGKCS.cjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-4UHGGKCS.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/core/calendar.tsx"],"names":["calendarVariants","cva","calendarDayVariants","getDaysInMonth","date","dateFnsGetDaysInMonth","getFirstDayOfMonth","firstDayOfWeek","firstDay","getDay","startOfMonth","isSameDay","date1","date2","dateFnsIsSameDay","isDateInRange","from","to","isWithinInterval","startOfDay","endOfDay","isBefore","isAfter","isDateDisabled","minDate","maxDate","disabledDates","disabledDays","d","formatDate","locale","formatDateRange","formatMultipleDates","dates","multipleSelected","count","getDayNames","formatter","sundayFirst","_","index","DEFAULT_LABELS","anchorDate","value","findEnabledDate","start","step","isDisabled","limit","candidate","i","shiftMonth","months","target","lastDay","Calendar","React","mode","defaultValue","onChange","placeholder","label","error","helperText","className","inputClassName","calendarClassName","variant","size","showOutsideDays","labelOverrides","props","ref","labels","useMemo","open","setOpen","useState","currentMonth","setCurrentMonth","focusedDate","setFocusedDate","calendarRef","useRef","dayButtonRefs","internalValue","setInternalValue","isControlled","calendarValue","isDisabledDate","today","preferred","monthStart","firstEnabled","handleValueChange","newValue","handleDateClick","rangeValue","multipleValue","dateIndex","displayValue","range","calendarDays","days","daysInMonth","prevMonth","daysInPrevMonth","remainingDays","nextMonth","goToMonth","sameDayNextMonth","landing","goToPreviousMonth","goToNextMonth","goToToday","handleKeyDown","moveFocus","useEffect","dateKey","button","dayNames","monthYearDispl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ect } from \"react\";\nimport * as Popover from \"@radix-ui/react-popover\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport {\n getDaysInMonth as dateFnsGetDaysInMonth,\n startOfMonth,\n getDay,\n isSameDay as dateFnsIsSameDay,\n isWithinInterval,\n isBefore,\n isAfter,\n startOfDay,\n endOfDay,\n} from \"date-fns\";\nimport { cn } from \"../../lib/utils\";\nimport { Button } from \"./button\";\n\n// Calendar variants\nconst calendarVariants = cva(\n \"inline-block rounded-lg border bg-background shadow-lg\",\n {\n variants: {\n variant: {\n default: \"border-border bg-card\",\n outline: \"border-2 border-border\",\n ghost: \"border-transparent bg-transparent shadow-none\",\n },\n size: {\n sm: \"p-2\",\n md: \"p-3\",\n lg: \"p-4\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n);\n\nconst calendarDayVariants = cva(\n \"flex items-center justify-center rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\n {\n variants: {\n variant: {\n default: \"hover:bg-muted text-foreground\",\n selected:\n \"bg-primary text-primary-foreground hover:bg-primary/90 font-semibold\",\n range: \"bg-primary/10 text-primary hover:bg-primary/20 font-medium\",\n today: \"border-2 border-primary text-foreground font-semibold\",\n outside: \"text-muted-foreground\",\n disabled: \"text-muted-foreground/50 cursor-not-allowed\",\n },\n size: {\n sm: \"h-7 w-7 text-xs\",\n md: \"h-9 w-9 text-sm\",\n lg: \"h-11 w-11 text-base\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n);\n\nexport type CalendarMode = \"single\" | \"range\" | \"multiple\";\n\nexport interface CalendarProps extends VariantProps<typeof calendarVariants> {\n mode?: CalendarMode;\n value?: Date | Date[] | { from?: Date; to?: Date };\n defaultValue?: Date | Date[] | { from?: Date; to?: Date };\n onChange?: (\n value: Date | Date[] | { from?: Date; to?: Date } | undefined,\n ) => void;\n minDate?: Date;\n maxDate?: Date;\n disabledDates?: Date[];\n disabledDays?: number[]; // 0 = Sunday, 1 = Monday, etc.\n locale?: string;\n placeholder?: string;\n label?: string;\n error?: boolean;\n helperText?: string;\n className?: string;\n inputClassName?: string;\n calendarClassName?: string;\n showOutsideDays?: boolean;\n firstDayOfWeek?: 0 | 1; // 0 = Sunday, 1 = Monday\n /** Overrides for the calendar's own words. See {@link CalendarLabels}. */\n labels?: CalendarLabels;\n}\n\n// Helper functions using date-fns for robust date manipulation\nconst getDaysInMonth = (date: Date): number => {\n return dateFnsGetDaysInMonth(date);\n};\n\nconst getFirstDayOfMonth = (date: Date, firstDayOfWeek: 0 | 1): number => {\n // Use date-fns getDay for consistent day-of-week calculation\n const firstDay = getDay(startOfMonth(date));\n // Convert Sunday (0) to Monday-first (6) if needed\n // Sunday = 0, Monday = 1, ..., Saturday = 6\n // For Monday-first: Sunday becomes 6, Monday becomes 0, etc.\n return firstDayOfWeek === 1 ? (firstDay === 0 ? 6 : firstDay - 1) : firstDay;\n};\n\nconst isSameDay = (\n date1: Date | undefined,\n date2: Date | undefined,\n): boolean => {\n if (!date1 || !date2) return false;\n return dateFnsIsSameDay(date1, date2);\n};\n\nconst isDateInRange = (date: Date, from?: Date, to?: Date): boolean => {\n if (!from && !to) return false;\n if (from && to) {\n // Use date-fns isWithinInterval for proper date range checking\n return isWithinInterval(startOfDay(date), {\n start: startOfDay(from),\n end: endOfDay(to),\n });\n }\n if (from) return !isBefore(startOfDay(date), startOfDay(from));\n if (to) return !isAfter(startOfDay(date), endOfDay(to));\n return false;\n};\n\nconst isDateDisabled = (\n date: Date,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Date[],\n disabledDays?: number[],\n): boolean => {\n if (minDate && isBefore(startOfDay(date), startOfDay(minDate))) return true;\n if (maxDate && isAfter(startOfDay(date), endOfDay(maxDate))) return true;\n if (disabledDates?.some((d) => isSameDay(d, date))) return true;\n if (disabledDays?.includes(getDay(date))) return true;\n return false;\n};\n\n/**\n * Formats through Intl, which every browser and Node already carries a full set\n * of locales for.\n *\n * This used to be `dateFnsFormat(date, \"MMM d, yyyy\")` with the locale accepted\n * and ignored, so `locale=\"da-DK\"` produced \"Sep 14, 2026\" next to a Danish month\n * heading. date-fns needs a locale *object* imported per language, which would\n * mean either bundling all of them or asking the caller to pass one; Intl needs\n * neither.\n */\nconst formatDate = (\n date: Date | undefined,\n locale: string = \"en-US\",\n): string => {\n if (!date) return \"\";\n return new Intl.DateTimeFormat(locale, {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n }).format(date);\n};\n\nconst formatDateRange = (\n from?: Date,\n to?: Date,\n locale: string = \"en-US\",\n): string => {\n if (!from && !to) return \"\";\n if (from && to) {\n return `${formatDate(from, locale)} - ${formatDate(to, locale)}`;\n }\n if (from) return formatDate(from, locale);\n if (to) return formatDate(to, locale);\n return \"\";\n};\n\nconst formatMultipleDates = (\n dates: Date[],\n locale: string = \"en-US\",\n multipleSelected: (count: number) => string = (count) =>\n `${count} dates selected`,\n): string => {\n if (dates.length === 0) return \"\";\n if (dates.length === 1) return formatDate(dates[0], locale);\n return multipleSelected(dates.length);\n};\n\n/**\n * Weekday headings in the calendar's own language.\n *\n * They were the hardcoded strings Sun..Sat. 2024-01-07 is a Sunday, so seven days\n * from it is one full week in a known order, and Intl names them.\n */\nconst getDayNames = (locale: string, firstDayOfWeek: 0 | 1): string[] => {\n const formatter = new Intl.DateTimeFormat(locale, { weekday: \"short\" });\n const sundayFirst = Array.from({ length: 7 }, (_, index) =>\n formatter.format(new Date(2024, 0, 7 + index)),\n );\n return firstDayOfWeek === 1\n ? [...sundayFirst.slice(1), sundayFirst[0]!]\n : sundayFirst;\n};\n\n/**\n * Every string the calendar says on its own behalf.\n *\n * `locale` moves the dates; it cannot translate \"Today\". Without somewhere to put\n * these, a Danish calendar had Danish months and English buttons.\n */\nexport interface CalendarLabels {\n /** Accessible name of the trigger. Defaults to \"Open calendar\". */\n openCalendar?: string;\n /** Shown on the trigger when nothing is selected. The `placeholder` prop wins. */\n placeholder?: string;\n previousMonth?: string;\n nextMonth?: string;\n today?: string;\n /** Shown in range mode between picking the start and the end. */\n selectEndDate?: string;\n /** Trigger text for more than one date in multiple mode. */\n multipleSelected?: (count: number) => string;\n}\n\nconst DEFAULT_LABELS: Required<CalendarLabels> = {\n openCalendar: \"Open calendar\",\n placeholder: \"Select date...\",\n previousMonth: \"Previous month\",\n nextMonth: \"Next month\",\n today: \"Today\",\n selectEndDate: \"Select end date\",\n multipleSelected: (count) => `${count} dates selected`,\n};\n\n/** The date a selection is anchored on, whatever shape the selection has. */\nconst anchorDate = (\n value: Date | Date[] | { from?: Date; to?: Date } | undefined,\n): Date | undefined => {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n if (Array.isArray(value)) return value[0];\n return value.from ?? value.to;\n};\n\n/**\n * Walks from `start` in `step`-day increments until it finds a date that is not\n * disabled.\n *\n * Roving focus used to move one day and stop there whether or not that day could\n * be focused. A disabled day is a disabled button, and a disabled button cannot\n * take focus - but it was still the only cell with `tabIndex=0`, so a calendar\n * with Tuesdays disabled had zero reachable dates and ArrowRight could not get\n * past Monday.\n *\n * `limit` is what stops this searching forever when every date is disabled, which\n * `disabledDays={[0,1,2,3,4,5,6]}` or an empty min/max window can produce. On\n * giving up it returns undefined and the caller leaves focus where it was.\n */\nconst findEnabledDate = (\n start: Date,\n step: number,\n isDisabled: (date: Date) => boolean,\n limit = 366,\n): Date | undefined => {\n const candidate = new Date(start);\n for (let i = 0; i < limit; i++) {\n if (!isDisabled(candidate)) return new Date(candidate);\n candidate.setDate(candidate.getDate() + step);\n }\n return undefined;\n};\n\n/** Same day number in another month, clamped to that month's length. */\nconst shiftMonth = (date: Date, months: number): Date => {\n const target = new Date(date.getFullYear(), date.getMonth() + months, 1);\n const lastDay = dateFnsGetDaysInMonth(target);\n target.setDate(Math.min(date.getDate(), lastDay));\n return target;\n};\n\nexport const Calendar = React.forwardRef<HTMLDivElement, CalendarProps>(\n (\n {\n mode = \"single\",\n value,\n defaultValue,\n onChange,\n minDate,\n maxDate,\n disabledDates,\n disabledDays,\n locale = \"en-US\",\n placeholder,\n label,\n error,\n helperText,\n className,\n inputClassName,\n calendarClassName,\n variant,\n size,\n showOutsideDays = true,\n firstDayOfWeek = 1,\n labels: labelOverrides,\n ...props\n },\n ref,\n ) => {\n const labels = useMemo(\n () => ({ ...DEFAULT_LABELS, ...labelOverrides }),\n [labelOverrides],\n );\n\n const [open, setOpen] = useState(false);\n // Opening a calendar that already has a value used to land on the current\n // month: `value={new Date(2020, 0, 15)}` opened September 2026 and left the\n // reader to page back eighty months.\n const [currentMonth, setCurrentMonth] = useState(\n () => anchorDate(value ?? defaultValue) ?? new Date(),\n );\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n const calendarRef = useRef<HTMLDivElement>(null);\n const dayButtonRefs = useRef<Map<string, HTMLButtonElement>>(new Map());\n\n // Controlled vs uncontrolled\n const [internalValue, setInternalValue] = useState<\n Date | Date[] | { from?: Date; to?: Date } | undefined\n >(defaultValue);\n\n const isControlled = value !== undefined;\n const calendarValue = isControlled ? value : internalValue;\n\n const isDisabledDate = React.useCallback(\n (date: Date) =>\n isDateDisabled(date, minDate, maxDate, disabledDates, disabledDays),\n [minDate, maxDate, disabledDates, disabledDays],\n );\n\n /**\n * Where focus starts when the calendar opens.\n *\n * It used to be today, unconditionally. That is the wrong date twice over: it\n * ignores a selection the reader already made, and today may be disabled - in\n * which case the only cell with `tabIndex=0` was a disabled button, so the\n * grid had no tab stop at all.\n *\n * The order is: the selected date, then today, then the first enabled day of\n * the month on screen. If nothing in reach is enabled, focus stays unset and\n * the grid simply has no tab stop, which is the truth.\n */\n React.useLayoutEffect(() => {\n if (!open || focusedDate) return;\n\n const today = startOfDay(new Date());\n const selected = anchorDate(calendarValue);\n const preferred = [selected, today].find(\n (date): date is Date => !!date && !isDisabledDate(date),\n );\n if (preferred) {\n setFocusedDate(startOfDay(preferred));\n return;\n }\n\n const monthStart = startOfMonth(currentMonth);\n const firstEnabled = findEnabledDate(\n monthStart,\n 1,\n isDisabledDate,\n dateFnsGetDaysInMonth(currentMonth),\n );\n if (firstEnabled) setFocusedDate(firstEnabled);\n }, [open, focusedDate, calendarValue, currentMonth, isDisabledDate]);\n\n // Handle value changes\n const handleValueChange = (\n newValue: Date | Date[] | { from?: Date; to?: Date } | undefined,\n ) => {\n if (!isControlled) {\n setInternalValue(newValue);\n }\n onChange?.(newValue);\n };\n\n // Handle date selection\n const handleDateClick = (date: Date) => {\n if (isDateDisabled(date, minDate, maxDate, disabledDates, disabledDays)) {\n return;\n }\n\n if (mode === \"single\") {\n handleValueChange(date);\n setOpen(false);\n } else if (mode === \"range\") {\n const rangeValue = calendarValue as\n { from?: Date; to?: Date } | undefined;\n if (!rangeValue?.from || (rangeValue.from && rangeValue.to)) {\n // Start new range\n handleValueChange({ from: date });\n } else {\n // Complete range\n const from = rangeValue.from;\n const to = date;\n if (to < from) {\n handleValueChange({ from: to, to: from });\n } else {\n handleValueChange({ from, to });\n }\n setOpen(false);\n }\n } else if (mode === \"multiple\") {\n const multipleValue = (calendarValue as Date[]) || [];\n const dateIndex = multipleValue.findIndex((d) => isSameDay(d, date));\n if (dateIndex >= 0) {\n // Remove date\n handleValueChange(multipleValue.filter((_, i) => i !== dateIndex));\n } else {\n // Add date\n handleValueChange([...multipleValue, date]);\n }\n }\n };\n\n // Get display value\n const displayValue = useMemo(() => {\n if (!calendarValue) return \"\";\n\n if (mode === \"single\") {\n return formatDate(calendarValue as Date, locale);\n } else if (mode === \"range\") {\n const range = calendarValue as { from?: Date; to?: Date };\n return formatDateRange(range.from, range.to, locale);\n } else {\n return formatMultipleDates(\n calendarValue as Date[],\n locale,\n labels.multipleSelected,\n );\n }\n }, [calendarValue, mode, locale, labels.multipleSelected]);\n\n // Generate calendar days\n const calendarDays = useMemo(() => {\n const days: Array<{\n date: Date;\n isCurrentMonth: boolean;\n isToday: boolean;\n /** A spacer that holds a column open without showing a date. */\n placeholder?: boolean;\n }> = [];\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n\n const firstDay = getFirstDayOfMonth(currentMonth, firstDayOfWeek);\n const daysInMonth = getDaysInMonth(currentMonth);\n\n // Previous month days.\n //\n // The leading cells exist whether or not the dates in them are shown: they\n // are what puts the first of the month under the right weekday. Only adding\n // them when `showOutsideDays` was on meant a September starting on a\n // Tuesday rendered its 1st in the Monday column, with every date of the\n // month one heading out for the rest of the grid.\n //\n // With outside days hidden they become empty, non-interactive placeholders\n // instead - see the `placeholder` flag below.\n if (firstDay > 0) {\n const prevMonth = new Date(\n currentMonth.getFullYear(),\n currentMonth.getMonth() - 1,\n );\n const daysInPrevMonth = getDaysInMonth(prevMonth);\n for (\n let i = daysInPrevMonth - firstDay + 1;\n i <= daysInPrevMonth;\n i++\n ) {\n const date = new Date(\n prevMonth.getFullYear(),\n prevMonth.getMonth(),\n i,\n );\n days.push({\n date,\n isCurrentMonth: false,\n isToday: isSameDay(date, today),\n placeholder: !showOutsideDays,\n });\n }\n }\n\n // Current month days\n for (let i = 1; i <= daysInMonth; i++) {\n const date = new Date(\n currentMonth.getFullYear(),\n currentMonth.getMonth(),\n i,\n );\n days.push({\n date,\n isCurrentMonth: true,\n isToday: isSameDay(date, today),\n });\n }\n\n // Next month days\n if (showOutsideDays) {\n const remainingDays = 42 - days.length; // 6 weeks * 7 days\n const nextMonth = new Date(\n currentMonth.getFullYear(),\n currentMonth.getMonth() + 1,\n );\n for (let i = 1; i <= remainingDays; i++) {\n const date = new Date(\n nextMonth.getFullYear(),\n nextMonth.getMonth(),\n i,\n );\n days.push({\n date,\n isCurrentMonth: false,\n isToday: isSameDay(date, today),\n });\n }\n }\n\n return days;\n }, [currentMonth, showOutsideDays, firstDayOfWeek]);\n\n // Navigate months\n /**\n * Moves the grid, and brings focus with it.\n *\n * The header buttons only moved the month. Focus stayed on a date that was no\n * longer rendered, so the grid lost its tab stop and an arrow key jumped back\n * to the month you had just left.\n */\n const goToMonth = (months: number) => {\n const target = new Date(\n currentMonth.getFullYear(),\n currentMonth.getMonth() + months,\n 1,\n );\n setCurrentMonth(target);\n\n if (!focusedDate) return;\n const sameDayNextMonth = shiftMonth(focusedDate, months);\n const landing =\n findEnabledDate(\n sameDayNextMonth,\n 1,\n isDisabledDate,\n dateFnsGetDaysInMonth(target),\n ) ??\n findEnabledDate(\n sameDayNextMonth,\n -1,\n isDisabledDate,\n dateFnsGetDaysInMonth(target),\n );\n if (landing) setFocusedDate(landing);\n };\n\n const goToPreviousMonth = () => goToMonth(-1);\n const goToNextMonth = () => goToMonth(1);\n\n const goToToday = () => {\n const today = startOfDay(new Date());\n setCurrentMonth(today);\n // Today can be disabled, in which case focus goes to the nearest day of\n // that month that is not.\n const landing =\n findEnabledDate(today, 1, isDisabledDate, 31) ??\n findEnabledDate(today, -1, isDisabledDate, 31);\n if (landing) setFocusedDate(landing);\n };\n\n // Keyboard navigation\n const handleKeyDown = (e: React.KeyboardEvent, date: Date) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n handleDateClick(date);\n return;\n }\n\n /**\n * Every movement lands on a date that can actually take focus.\n *\n * Each key used to step once and stop, disabled or not. The resulting cell\n * got the grid's only `tabIndex=0` while being a disabled button, so\n * ArrowRight into a disabled Tuesday left the grid with no tab stop and no\n * way forward - pressing it again did the same thing from the same place.\n */\n const moveFocus = (\n candidate: Date,\n step: number,\n limit?: number,\n ): void => {\n const target = findEnabledDate(candidate, step, isDisabledDate, limit);\n // Nothing enabled in that direction: stay where we are rather than\n // moving focus onto something that cannot hold it.\n if (!target) return;\n\n setFocusedDate(target);\n if (\n target.getMonth() !== currentMonth.getMonth() ||\n target.getFullYear() !== currentMonth.getFullYear()\n ) {\n setCurrentMonth(new Date(target.getFullYear(), target.getMonth(), 1));\n }\n };\n\n const step = (days: number) => {\n const candidate = new Date(date);\n candidate.setDate(candidate.getDate() + days);\n moveFocus(candidate, days > 0 ? 1 : -1);\n };\n\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n step(1);\n return;\n }\n\n if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n step(-1);\n return;\n }\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n step(7);\n return;\n }\n\n if (e.key === \"ArrowUp\") {\n e.preventDefault();\n step(-7);\n return;\n }\n\n if (e.key === \"Home\") {\n e.preventDefault();\n // Forwards from the 1st: the first day of the month that is enabled.\n moveFocus(\n new Date(date.getFullYear(), date.getMonth(), 1),\n 1,\n dateFnsGetDaysInMonth(date),\n );\n return;\n }\n\n if (e.key === \"End\") {\n e.preventDefault();\n moveFocus(\n new Date(date.getFullYear(), date.getMonth() + 1, 0),\n -1,\n dateFnsGetDaysInMonth(date),\n );\n return;\n }\n\n if (e.key === \"PageUp\") {\n e.preventDefault();\n // `new Date(y, m - 1, 31)` from 31 March is 3 March, so a month-step from\n // the end of a long month used to skip the short month entirely.\n moveFocus(shiftMonth(date, -1), -1);\n return;\n }\n\n if (e.key === \"PageDown\") {\n e.preventDefault();\n moveFocus(shiftMonth(date, 1), 1);\n return;\n }\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n setOpen(false);\n return;\n }\n };\n\n // Focus management\n useEffect(() => {\n if (focusedDate && open) {\n const dateKey = `${focusedDate.getFullYear()}-${focusedDate.getMonth()}-${focusedDate.getDate()}`;\n const button = dayButtonRefs.current.get(dateKey);\n if (button) {\n button.focus();\n }\n }\n }, [focusedDate, open]);\n\n // Day names\n const dayNames = useMemo(\n () => getDayNames(locale, firstDayOfWeek),\n [locale, firstDayOfWeek],\n );\n\n // Month/year display\n const monthYearDisplay = currentMonth.toLocaleDateString(locale, {\n month: \"long\",\n year: \"numeric\",\n });\n\n return (\n <div ref={ref} className={cn(\"w-full\", className)} {...props}>\n <Popover.Root open={open} onOpenChange={setOpen}>\n <div className=\"space-y-2\">\n {label && (\n <label className=\"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\">\n {label}\n </label>\n )}\n <Popover.Trigger asChild>\n <button\n type=\"button\"\n className={cn(\n \"flex w-full rounded-md border bg-background px-3 py-2 text-sm ring-offset-background\",\n \"placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2\",\n \"disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-200 text-left\",\n error\n ? \"border-error-500 shadow-sm hover:border-error-600 focus-visible:ring-error-500/20 focus-visible:border-error-500\"\n : \"border-border shadow-sm hover:border-primary focus-visible:ring-ring/20 focus-visible:border-primary\",\n \"h-10\",\n inputClassName,\n )}\n // No onFocus handler here. Radix returns focus to the trigger\n // when the popover closes, so opening on focus meant selecting a\n // date closed it and immediately reopened it - the flicker. It\n // also popped the calendar open when tabbing past the field.\n onClick={() => setOpen(true)}\n aria-label={label || labels.openCalendar}\n aria-invalid={error}\n >\n {displayValue || (\n <span className=\"text-muted-foreground\">\n {placeholder ?? labels.placeholder}\n </span>\n )}\n </button>\n </Popover.Trigger>\n {helperText && (\n <p\n className={cn(\n \"text-sm text-muted-foreground\",\n error && \"text-error-600\",\n )}\n >\n {helperText}\n </p>\n )}\n </div>\n\n <Popover.Portal>\n <Popover.Content\n className={cn(\n \"z-50 w-auto rounded-lg border bg-popover p-4 shadow-lg\",\n \"data-[state=open]:animate-in data-[state=closed]:animate-out\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2\",\n \"data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\n )}\n sideOffset={5}\n align=\"start\"\n >\n <div\n ref={calendarRef}\n className={cn(\n calendarVariants({ variant, size }),\n calendarClassName,\n )}\n role=\"application\"\n aria-label=\"Calendar\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between mb-4\">\n <div className=\"flex items-center gap-2\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={goToPreviousMonth}\n aria-label={labels.previousMonth}\n >\n <svg\n className=\"h-4 w-4\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M15 19l-7-7 7-7\"\n />\n </svg>\n </Button>\n\n <h3\n className=\"text-sm font-semibold text-popover-foreground\"\n data-testid=\"calendar-month-year\"\n >\n {monthYearDisplay}\n </h3>\n\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={goToNextMonth}\n aria-label={labels.nextMonth}\n >\n <svg\n className=\"h-4 w-4\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 5l7 7-7 7\"\n />\n </svg>\n </Button>\n </div>\n\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={goToToday}\n className=\"text-xs\"\n >\n {labels.today}\n </Button>\n </div>\n\n {/* Day names */}\n <div className=\"grid grid-cols-7 gap-1 mb-2\">\n {dayNames.map((day) => (\n <div\n key={day}\n className=\"text-center text-xs font-medium text-muted-foreground\"\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid grid-cols-7 gap-1\">\n {calendarDays.map((day, index) => {\n const isSelected =\n mode === \"single\"\n ? isSameDay(day.date, calendarValue as Date | undefined)\n : mode === \"range\"\n ? isDateInRange(\n day.date,\n (calendarValue as { from?: Date; to?: Date })\n ?.from,\n (calendarValue as { from?: Date; to?: Date })?.to,\n )\n : (calendarValue as Date[])?.some((d) =>\n isSameDay(d, day.date),\n );\n\n const isDisabled = isDateDisabled(\n day.date,\n minDate,\n maxDate,\n disabledDates,\n disabledDays,\n );\n\n const isInRange =\n mode === \"range\" &&\n (calendarValue as { from?: Date; to?: Date })?.from &&\n !(calendarValue as { from?: Date; to?: Date })?.to &&\n day.date >=\n (calendarValue as { from?: Date; to?: Date }).from!;\n\n const dateKey = `${day.date.getFullYear()}-${day.date.getMonth()}-${day.date.getDate()}`;\n const isFocused =\n focusedDate && isSameDay(day.date, focusedDate);\n\n // A leading spacer: it holds the column open so the first\n // of the month lands under the right weekday, and it is not\n // a control, so it is out of the tab order and out of the\n // accessibility tree.\n if (day.placeholder) {\n return (\n <div\n key={`placeholder-${index}`}\n aria-hidden=\"true\"\n data-calendar-placeholder=\"\"\n className={cn(\n calendarDayVariants({ variant: \"default\", size }),\n \"invisible\",\n )}\n />\n );\n }\n\n return (\n <button\n key={`${day.date.getTime()}-${index}`}\n ref={(el) => {\n if (el) {\n dayButtonRefs.current.set(dateKey, el);\n } else {\n dayButtonRefs.current.delete(dateKey);\n }\n }}\n type=\"button\"\n onClick={() => {\n if (showOutsideDays && !day.isCurrentMonth) {\n // Navigate to the month of the clicked date\n setCurrentMonth(\n new Date(\n day.date.getFullYear(),\n day.date.getMonth(),\n 1,\n ),\n );\n // Synchronously: React batches both updates into one\n // render. Deferring the selection by a tick showed the\n // new month first and selected a frame later, which\n // read as a flash.\n handleDateClick(day.date);\n } else {\n handleDateClick(day.date);\n }\n }}\n onKeyDown={(e) => handleKeyDown(e, day.date)}\n disabled={\n isDisabled ||\n (showOutsideDays ? false : !day.isCurrentMonth)\n }\n className={cn(\n calendarDayVariants({\n variant: isSelected\n ? \"selected\"\n : isInRange\n ? \"range\"\n : day.isToday\n ? \"today\"\n : !day.isCurrentMonth\n ? \"outside\"\n : isDisabled\n ? \"disabled\"\n : \"default\",\n size,\n }),\n !day.isCurrentMonth && \"opacity-50\",\n isFocused &&\n \"ring-2 ring-brand-500 ring-offset-2 z-10\",\n )}\n aria-label={day.date.toLocaleDateString(locale, {\n weekday: \"long\",\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n })}\n aria-selected={isSelected}\n aria-disabled={isDisabled}\n tabIndex={isFocused ? 0 : -1}\n >\n {day.date.getDate()}\n </button>\n );\n })}\n </div>\n\n {/* Footer for range mode */}\n {mode === \"range\" &&\n (calendarValue as { from?: Date; to?: Date })?.from &&\n !(calendarValue as { from?: Date; to?: Date })?.to && (\n <div className=\"mt-4 pt-4 border-t border-border\">\n <p className=\"text-xs text-muted-foreground text-center\">\n {labels.selectEndDate}\n </p>\n </div>\n )}\n </div>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n </div>\n );\n },\n);\n\nCalendar.displayName = \"Calendar\";\n\nexport { calendarVariants, calendarDayVariants };\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {b}from'./chunk-AVTJE2O2.js';import {a as a$1}from'./chunk-AC2JBXHQ.js';import a,{useMemo,useState,useRef,useEffect}from'react';import*as C from'@radix-ui/react-popover';import {cva}from'class-variance-authority';import {startOfDay,startOfMonth,getDaysInMonth,isBefore,isAfter,endOfDay,getDay,isSameDay,isWithinInterval}from'date-fns';var Pe=cva("inline-block rounded-lg border bg-background shadow-lg",{variants:{variant:{default:"border-border bg-card",outline:"border-2 border-border",ghost:"border-transparent bg-transparent shadow-none"},size:{sm:"p-2",md:"p-3",lg:"p-4"}},defaultVariants:{variant:"default",size:"md"}}),R=cva("flex items-center justify-center rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"hover:bg-muted text-foreground",selected:"bg-primary text-primary-foreground hover:bg-primary/90 font-semibold",range:"bg-primary/10 text-primary hover:bg-primary/20 font-medium",today:"border-2 border-primary text-foreground font-semibold",outside:"text-muted-foreground",disabled:"text-muted-foreground/50 cursor-not-allowed"},size:{sm:"h-7 w-7 text-xs",md:"h-9 w-9 text-sm",lg:"h-11 w-11 text-base"}},defaultVariants:{variant:"default",size:"md"}}),ee=t=>getDaysInMonth(t),Te=(t,r)=>{let o=getDay(startOfMonth(t));return r===1?o===0?6:o-1:o},x=(t,r)=>!t||!r?false:isSameDay(t,r),Se=(t,r,o)=>!r&&!o?false:r&&o?isWithinInterval(startOfDay(t),{start:startOfDay(r),end:endOfDay(o)}):r?!isBefore(startOfDay(t),startOfDay(r)):o?!isAfter(startOfDay(t),endOfDay(o)):false,O=(t,r,o,g,m)=>!!(r&&isBefore(startOfDay(t),startOfDay(r))||o&&isAfter(startOfDay(t),endOfDay(o))||g?.some(p=>x(p,t))||m?.includes(getDay(t))),P=(t,r="en-US")=>t?new Intl.DateTimeFormat(r,{year:"numeric",month:"short",day:"numeric"}).format(t):"",Le=(t,r,o="en-US")=>!t&&!r?"":t&&r?`${P(t,o)} - ${P(r,o)}`:t?P(t,o):r?P(r,o):"",Ee=(t,r="en-US",o=g=>`${g} dates selected`)=>t.length===0?"":t.length===1?P(t[0],r):o(t.length),Ie=(t,r)=>{let o=new Intl.DateTimeFormat(t,{weekday:"short"}),g=Array.from({length:7},(m,p)=>o.format(new Date(2024,0,7+p)));return r===1?[...g.slice(1),g[0]]:g},Ye={openCalendar:"Open calendar",placeholder:"Select date...",previousMonth:"Previous month",nextMonth:"Next month",today:"Today",selectEndDate:"Select end date",multipleSelected:t=>`${t} dates selected`},te=t=>{if(t)return t instanceof Date?t:Array.isArray(t)?t[0]:t.from??t.to},F=(t,r,o,g=366)=>{let m=new Date(t);for(let p=0;p<g;p++){if(!o(m))return new Date(m);m.setDate(m.getDate()+r);}},q=(t,r)=>{let o=new Date(t.getFullYear(),t.getMonth()+r,1),g=getDaysInMonth(o);return o.setDate(Math.min(t.getDate(),g)),o},Ve=a.forwardRef(({mode:t="single",value:r,defaultValue:o,onChange:g,minDate:m,maxDate:p,disabledDates:I,disabledDays:Y,locale:v="en-US",placeholder:ie,label:U,error:H,helperText:W,className:le,inputClassName:de,calendarClassName:ue,variant:fe,size:K,showOutsideDays:T=true,firstDayOfWeek:V=1,labels:J,...ce},ge)=>{let y=useMemo(()=>({...Ye,...J}),[J]),[S,L]=useState(false),[c,$]=useState(()=>te(r??o)??new Date),[h,E]=useState(null),me=useRef(null),j=useRef(new Map),[De,pe]=useState(o),Q=r!==void 0,f=Q?r:De,M=a.useCallback(e=>O(e,m,p,I,Y),[m,p,I,Y]);a.useLayoutEffect(()=>{if(!S||h)return;let e=startOfDay(new Date),s=[te(f),e].find(d=>!!d&&!M(d));if(s){E(startOfDay(s));return}let i=startOfMonth(c),l=F(i,1,M,getDaysInMonth(c));l&&E(l);},[S,h,f,c,M]);let N=e=>{Q||pe(e),g?.(e);},_=e=>{if(!O(e,m,p,I,Y)){if(t==="single")N(e),L(false);else if(t==="range"){let n=f;if(!n?.from||n.from&&n.to)N({from:e});else {let s=n.from,i=e;i<s?N({from:i,to:s}):N({from:s,to:i}),L(false);}}else if(t==="multiple"){let n=f||[],s=n.findIndex(i=>x(i,e));s>=0?N(n.filter((i,l)=>l!==s)):N([...n,e]);}}},he=useMemo(()=>{if(!f)return "";if(t==="single")return P(f,v);if(t==="range"){let e=f;return Le(e.from,e.to,v)}else return Ee(f,v,y.multipleSelected)},[f,t,v,y.multipleSelected]),be=useMemo(()=>{let e=[],n=new Date;n.setHours(0,0,0,0);let s=Te(c,V),i=ee(c);if(s>0){let l=new Date(c.getFullYear(),c.getMonth()-1),d=ee(l);for(let D=d-s+1;D<=d;D++){let u=new Date(l.getFullYear(),l.getMonth(),D);e.push({date:u,isCurrentMonth:false,isToday:x(u,n),placeholder:!T});}}for(let l=1;l<=i;l++){let d=new Date(c.getFullYear(),c.getMonth(),l);e.push({date:d,isCurrentMonth:true,isToday:x(d,n)});}if(T){let l=42-e.length,d=new Date(c.getFullYear(),c.getMonth()+1);for(let D=1;D<=l;D++){let u=new Date(d.getFullYear(),d.getMonth(),D);e.push({date:u,isCurrentMonth:false,isToday:x(u,n)});}}return e},[c,T,V]),X=e=>{let n=new Date(c.getFullYear(),c.getMonth()+e,1);if($(n),!h)return;let s=q(h,e),i=F(s,1,M,getDaysInMonth(n))??F(s,-1,M,getDaysInMonth(n));i&&E(i);},ve=()=>X(-1),ye=()=>X(1),Me=()=>{let e=startOfDay(new Date);$(e);let n=F(e,1,M,31)??F(e,-1,M,31);n&&E(n);},we=(e,n)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault(),_(n);return}let s=(l,d,D)=>{let u=F(l,d,M,D);u&&(E(u),(u.getMonth()!==c.getMonth()||u.getFullYear()!==c.getFullYear())&&$(new Date(u.getFullYear(),u.getMonth(),1)));},i=l=>{let d=new Date(n);d.setDate(d.getDate()+l),s(d,l>0?1:-1);};if(e.key==="ArrowRight"){e.preventDefault(),i(1);return}if(e.key==="ArrowLeft"){e.preventDefault(),i(-1);return}if(e.key==="ArrowDown"){e.preventDefault(),i(7);return}if(e.key==="ArrowUp"){e.preventDefault(),i(-7);return}if(e.key==="Home"){e.preventDefault(),s(new Date(n.getFullYear(),n.getMonth(),1),1,getDaysInMonth(n));return}if(e.key==="End"){e.preventDefault(),s(new Date(n.getFullYear(),n.getMonth()+1,0),-1,getDaysInMonth(n));return}if(e.key==="PageUp"){e.preventDefault(),s(q(n,-1),-1);return}if(e.key==="PageDown"){e.preventDefault(),s(q(n,1),1);return}if(e.key==="Escape"){e.preventDefault(),L(false);return}};useEffect(()=>{if(h&&S){let e=`${h.getFullYear()}-${h.getMonth()}-${h.getDate()}`,n=j.current.get(e);n&&n.focus();}},[h,S]);let xe=useMemo(()=>Ie(v,V),[v,V]),Ce=c.toLocaleDateString(v,{month:"long",year:"numeric"});return a.createElement("div",{ref:ge,className:a$1("w-full",le),...ce},a.createElement(C.Root,{open:S,onOpenChange:L},a.createElement("div",{className:"space-y-2"},U&&a.createElement("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},U),a.createElement(C.Trigger,{asChild:true},a.createElement("button",{type:"button",className:a$1("flex w-full rounded-md border bg-background px-3 py-2 text-sm ring-offset-background","placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-200 text-left",H?"border-error-500 shadow-sm hover:border-error-600 focus-visible:ring-error-500/20 focus-visible:border-error-500":"border-border shadow-sm hover:border-primary focus-visible:ring-ring/20 focus-visible:border-primary","h-10",de),onClick:()=>L(true),"aria-label":U||y.openCalendar,"aria-invalid":H},he||a.createElement("span",{className:"text-muted-foreground"},ie??y.placeholder))),W&&a.createElement("p",{className:a$1("text-sm text-muted-foreground",H&&"text-error-600")},W)),a.createElement(C.Portal,null,a.createElement(C.Content,{className:a$1("z-50 w-auto rounded-lg border bg-popover p-4 shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"),sideOffset:5,align:"start"},a.createElement("div",{ref:me,className:a$1(Pe({variant:fe,size:K}),ue),role:"application","aria-label":"Calendar"},a.createElement("div",{className:"flex items-center justify-between mb-4"},a.createElement("div",{className:"flex items-center gap-2"},a.createElement(b,{variant:"ghost",size:"sm",onClick:ve,"aria-label":y.previousMonth},a.createElement("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"}))),a.createElement("h3",{className:"text-sm font-semibold text-popover-foreground","data-testid":"calendar-month-year"},Ce),a.createElement(b,{variant:"ghost",size:"sm",onClick:ye,"aria-label":y.nextMonth},a.createElement("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})))),a.createElement(b,{variant:"ghost",size:"sm",onClick:Me,className:"text-xs"},y.today)),a.createElement("div",{className:"grid grid-cols-7 gap-1 mb-2"},xe.map(e=>a.createElement("div",{key:e,className:"text-center text-xs font-medium text-muted-foreground"},e))),a.createElement("div",{className:"grid grid-cols-7 gap-1"},be.map((e,n)=>{let s=t==="single"?x(e.date,f):t==="range"?Se(e.date,f?.from,f?.to):f?.some(u=>x(u,e.date)),i=O(e.date,m,p,I,Y),l=t==="range"&&f?.from&&!f?.to&&e.date>=f.from,d=`${e.date.getFullYear()}-${e.date.getMonth()}-${e.date.getDate()}`,D=h&&x(e.date,h);return e.placeholder?a.createElement("div",{key:`placeholder-${n}`,"aria-hidden":"true","data-calendar-placeholder":"",className:a$1(R({variant:"default",size:K}),"invisible")}):a.createElement("button",{key:`${e.date.getTime()}-${n}`,ref:u=>{u?j.current.set(d,u):j.current.delete(d);},type:"button",onClick:()=>{T&&!e.isCurrentMonth&&$(new Date(e.date.getFullYear(),e.date.getMonth(),1)),_(e.date);},onKeyDown:u=>we(u,e.date),disabled:i||(T?false:!e.isCurrentMonth),className:a$1(R({variant:s?"selected":l?"range":e.isToday?"today":e.isCurrentMonth?i?"disabled":"default":"outside",size:K}),!e.isCurrentMonth&&"opacity-50",D&&"ring-2 ring-brand-500 ring-offset-2 z-10"),"aria-label":e.date.toLocaleDateString(v,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),"aria-selected":s,"aria-disabled":i,tabIndex:D?0:-1},e.date.getDate())})),t==="range"&&f?.from&&!f?.to&&a.createElement("div",{className:"mt-4 pt-4 border-t border-border"},a.createElement("p",{className:"text-xs text-muted-foreground text-center"},y.selectEndDate)))))))});Ve.displayName="Calendar";export{Pe as a,R as b,Ve as c};//# sourceMappingURL=chunk-A4ODFRMS.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-A4ODFRMS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/core/calendar.tsx"],"names":["calendarVariants","cva","calendarDayVariants","getDaysInMonth","date","dateFnsGetDaysInMonth","getFirstDayOfMonth","firstDayOfWeek","firstDay","getDay","startOfMonth","isSameDay","date1","date2","dateFnsIsSameDay","isDateInRange","from","to","isWithinInterval","startOfDay","endOfDay","isBefore","isAfter","isDateDisabled","minDate","maxDate","disabledDates","disabledDays","d","formatDate","locale","formatDateRange","formatMultipleDates","dates","multipleSelected","count","getDayNames","formatter","sundayFirst","_","index","DEFAULT_LABELS","anchorDate","value","findEnabledDate","start","step","isDisabled","limit","candidate","i","shiftMonth","months","target","lastDay","Calendar","React","mode","defaultValue","onChange","placeholder","label","error","helperText","className","inputClassName","calendarClassName","variant","size","showOutsideDays","labelOverrides","props","ref","labels","useMemo","open","setOpen","useState","currentMonth","setCurrentMonth","focusedDate","setFocusedDate","calendarRef","useRef","dayButtonRefs","internalValue","setInternalValue","isControlled","calendarValue","isDisabledDate","today","preferred","monthStart","firstEnabled","handleValueChange","newValue","handleDateClick","rangeValue","multipleValue","dateIndex","displayValue","range","calendarDays","days","daysInMonth","prevMonth","daysInPrevMonth","remainingDays","nextMonth","goToMonth","sameDayNextMonth","landing","goToPreviousMonth","goToNextMonth","goToToday","handleKeyDown","moveFocus","useEffect","dateKey","button","dayNames","monthYearDisplay","cn","Button","day","isSelected","isInRange","isFocused","el","e"],"mappings":"sVAkBA,IAAMA,EAAAA,CAAmBC,GAAAA,CACvB,wDAAA,CACA,CACE,QAAA,CAAU,CACR,OAAA,CAAS,CACP,OAAA,CAAS,uBAAA,CACT,OAAA,CAAS,wBAAA,CACT,KAAA,CAAO,+CACT,CAAA,CACA,IAAA,CAAM,CACJ,EAAA,CAAI,KAAA,CACJ,EAAA,CAAI,KAAA,CACJ,EAAA,CAAI,KACN,CACF,CAAA,CACA,eAAA,CAAiB,CACf,OAAA,CAAS,SAAA,CACT,IAAA,CAAM,IACR,CACF,CACF,CAAA,CAEMC,CAAAA,CAAsBD,GAAAA,CAC1B,gMAAA,CACA,CACE,QAAA,CAAU,CACR,OAAA,CAAS,CACP,OAAA,CAAS,gCAAA,CACT,QAAA,CACE,sEAAA,CACF,KAAA,CAAO,4DAAA,CACP,KAAA,CAAO,uDAAA,CACP,OAAA,CAAS,uBAAA,CACT,QAAA,CAAU,6CACZ,CAAA,CACA,IAAA,CAAM,CACJ,EA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AA,CAAI,EAAA,CAAA,CAEzBH,CAAAA,CAAI,IAAA,CAAK,OAAA,EACZ,CAEJ,CAAC,CACH,CAAA,CAGCnE,CAAAA,GAAS,OAAA,EACP+B,CAAAA,EAA8C,IAAA,EAC/C,CAAEA,CAAAA,EAA8C,EAAA,EAC9ChC,CAAAA,CAAA,aAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,kCAAA,CAAA,CACbA,CAAAA,CAAA,aAAA,CAAC,GAAA,CAAA,CAAE,SAAA,CAAU,2CAAA,CAAA,CACViB,CAAAA,CAAO,aACV,CACF,CAEN,CACF,CACF,CACF,CACF,CAEJ,CACF,EAEAlB,EAAAA,CAAS,WAAA,CAAc,UAAA","file":"chunk-A4ODFRMS.js","sourcesContent":["import React, { useState, useMemo, useRef, useEffect } from \"react\";\nimport * as Popover from \"@radix-ui/react-popover\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport {\n getDaysInMonth as dateFnsGetDaysInMonth,\n startOfMonth,\n getDay,\n isSameDay as dateFnsIsSameDay,\n isWithinInterval,\n isBefore,\n isAfter,\n startOfDay,\n endOfDay,\n} from \"date-fns\";\nimport { cn } from \"../../lib/utils\";\nimport { Button } from \"./button\";\n\n// Calendar variants\nconst calendarVariants = cva(\n \"inline-block rounded-lg border bg-background shadow-lg\",\n {\n variants: {\n variant: {\n default: \"border-border bg-card\",\n outline: \"border-2 border-border\",\n ghost: \"border-transparent bg-transparent shadow-none\",\n },\n size: {\n sm: \"p-2\",\n md: \"p-3\",\n lg: \"p-4\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n);\n\nconst calendarDayVariants = cva(\n \"flex items-center justify-center rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\n {\n variants: {\n variant: {\n default: \"hover:bg-muted text-foreground\",\n selected:\n \"bg-primary text-primary-foreground hover:bg-primary/90 font-semibold\",\n range: \"bg-primary/10 text-primary hover:bg-primary/20 font-medium\",\n today: \"border-2 border-primary text-foreground font-semibold\",\n outside: \"text-muted-foreground\",\n disabled: \"text-muted-foreground/50 cursor-not-allowed\",\n },\n size: {\n sm: \"h-7 w-7 text-xs\",\n md: \"h-9 w-9 text-sm\",\n lg: \"h-11 w-11 text-base\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n);\n\nexport type CalendarMode = \"single\" | \"range\" | \"multiple\";\n\nexport interface CalendarProps extends VariantProps<typeof calendarVariants> {\n mode?: CalendarMode;\n value?: Date | Date[] | { from?: Date; to?: Date };\n defaultValue?: Date | Date[] | { from?: Date; to?: Date };\n onChange?: (\n value: Date | Date[] | { from?: Date; to?: Date } | undefined,\n ) => void;\n minDate?: Date;\n maxDate?: Date;\n disabledDates?: Date[];\n disabledDays?: number[]; // 0 = Sunday, 1 = Monday, etc.\n locale?: string;\n placeholder?: string;\n label?: string;\n error?: boolean;\n helperText?: string;\n className?: string;\n inputClassName?: string;\n calendarClassName?: string;\n showOutsideDays?: boolean;\n firstDayOfWeek?: 0 | 1; // 0 = Sunday, 1 = Monday\n /** Overrides for the calendar's own words. See {@link CalendarLabels}. */\n labels?: CalendarLabels;\n}\n\n// Helper functions using date-fns for robust date manipulation\nconst getDaysInMonth = (date: Date): number => {\n return dateFnsGetDaysInMonth(date);\n};\n\nconst getFirstDayOfMonth = (date: Date, firstDayOfWeek: 0 | 1): number => {\n // Use date-fns getDay for consistent day-of-week calculation\n const firstDay = getDay(startOfMonth(date));\n // Convert Sunday (0) to Monday-first (6) if needed\n // Sunday = 0, Monday = 1, ..., Saturday = 6\n // For Monday-first: Sunday becomes 6, Monday becomes 0, etc.\n return firstDayOfWeek === 1 ? (firstDay === 0 ? 6 : firstDay - 1) : firstDay;\n};\n\nconst isSameDay = (\n date1: Date | undefined,\n date2: Date | undefined,\n): boolean => {\n if (!date1 || !date2) return false;\n return dateFnsIsSameDay(date1, date2);\n};\n\nconst isDateInRange = (date: Date, from?: Date, to?: Date): boolean => {\n if (!from && !to) return false;\n if (from && to) {\n // Use date-fns isWithinInterval for proper date range checking\n return isWithinInterval(startOfDay(date), {\n start: startOfDay(from),\n end: endOfDay(to),\n });\n }\n if (from) return !isBefore(startOfDay(date), startOfDay(from));\n if (to) return !isAfter(startOfDay(date), endOfDay(to));\n return false;\n};\n\nconst isDateDisabled = (\n date: Date,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Date[],\n disabledDays?: number[],\n): boolean => {\n if (minDate && isBefore(startOfDay(date), startOfDay(minDate))) return true;\n if (maxDate && isAfter(startOfDay(date), endOfDay(maxDate))) return true;\n if (disabledDates?.some((d) => isSameDay(d, date))) return true;\n if (disabledDays?.includes(getDay(date))) return true;\n return false;\n};\n\n/**\n * Formats through Intl, which every browser and Node already carries a full set\n * of locales for.\n *\n * This used to be `dateFnsFormat(date, \"MMM d, yyyy\")` with the locale accepted\n * and ignored, so `locale=\"da-DK\"` produced \"Sep 14, 2026\" next to a Danish month\n * heading. date-fns needs a locale *object* imported per language, which would\n * mean either bundling all of them or asking the caller to pass one; Intl needs\n * neither.\n */\nconst formatDate = (\n date: Date | undefined,\n locale: string = \"en-US\",\n): string => {\n if (!date) return \"\";\n return new Intl.DateTimeFormat(locale, {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n }).format(date);\n};\n\nconst formatDateRange = (\n from?: Date,\n to?: Date,\n locale: string = \"en-US\",\n): string => {\n if (!from && !to) return \"\";\n if (from && to) {\n return `${formatDate(from, locale)} - ${formatDate(to, locale)}`;\n }\n if (from) return formatDate(from, locale);\n if (to) return formatDate(to, locale);\n return \"\";\n};\n\nconst formatMultipleDates = (\n dates: Date[],\n locale: string = \"en-US\",\n multipleSelected: (count: number) => string = (count) =>\n `${count} dates selected`,\n): string => {\n if (dates.length === 0) return \"\";\n if (dates.length === 1) return formatDate(dates[0], locale);\n return multipleSelected(dates.length);\n};\n\n/**\n * Weekday headings in the calendar's own language.\n *\n * They were the hardcoded strings Sun..Sat. 2024-01-07 is a Sunday, so seven days\n * from it is one full week in a known order, and Intl names them.\n */\nconst getDayNames = (locale: string, firstDayOfWeek: 0 | 1): string[] => {\n const formatter = new Intl.DateTimeFormat(locale, { weekday: \"short\" });\n const sundayFirst = Array.from({ length: 7 }, (_, index) =>\n formatter.format(new Date(2024, 0, 7 + index)),\n );\n return firstDayOfWeek === 1\n ? [...sundayFirst.slice(1), sundayFirst[0]!]\n : sundayFirst;\n};\n\n/**\n * Every string the calendar says on its own behalf.\n *\n * `locale` moves the dates; it cannot translate \"Today\". Without somewhere to put\n * these, a Danish calendar had Danish months and English buttons.\n */\nexport interface CalendarLabels {\n /** Accessible name of the trigger. Defaults to \"Open calendar\". */\n openCalendar?: string;\n /** Shown on the trigger when nothing is selected. The `placeholder` prop wins. */\n placeholder?: string;\n previousMonth?: string;\n nextMonth?: string;\n today?: string;\n /** Shown in range mode between picking the start and the end. */\n selectEndDate?: string;\n /** Trigger text for more than one date in multiple mode. */\n multipleSelected?: (count: number) => string;\n}\n\nconst DEFAULT_LABELS: Required<CalendarLabels> = {\n openCalendar: \"Open calendar\",\n placeholder: \"Select date...\",\n previousMonth: \"Previous month\",\n nextMonth: \"Next month\",\n today: \"Today\",\n selectEndDate: \"Select end date\",\n multipleSelected: (count) => `${count} dates selected`,\n};\n\n/** The date a selection is anchored on, whatever shape the selection has. */\nconst anchorDate = (\n value: Date | Date[] | { from?: Date; to?: Date } | undefined,\n): Date | undefined => {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n if (Array.isArray(value)) return value[0];\n return value.from ?? value.to;\n};\n\n/**\n * Walks from `start` in `step`-day increments until it finds a date that is not\n * disabled.\n *\n * Roving focus used to move one day and stop there whether or not that day could\n * be focused. A disabled day is a disabled button, and a disabled button cannot\n * take focus - but it was still the only cell with `tabIndex=0`, so a calendar\n * with Tuesdays disabled had zero reachable dates and ArrowRight could not get\n * past Monday.\n *\n * `limit` is what stops this searching forever when every date is disabled, which\n * `disabledDays={[0,1,2,3,4,5,6]}` or an empty min/max window can produce. On\n * giving up it returns undefined and the caller leaves focus where it was.\n */\nconst findEnabledDate = (\n start: Date,\n step: number,\n isDisabled: (date: Date) => boolean,\n limit = 366,\n): Date | undefined => {\n const candidate = new Date(start);\n for (let i = 0; i < limit; i++) {\n if (!isDisabled(candidate)) return new Date(candidate);\n candidate.setDate(candidate.getDate() + step);\n }\n return undefined;\n};\n\n/** Same day number in another month, clamped to that month's length. */\nconst shiftMonth = (date: Date, months: number): Date => {\n const target = new Date(date.getFullYear(), date.getMonth() + months, 1);\n const lastDay = dateFnsGetDaysInMonth(target);\n target.setDate(Math.min(date.getDate(), lastDay));\n return target;\n};\n\nexport const Calendar = React.forwardRef<HTMLDivElement, CalendarProps>(\n (\n {\n mode = \"single\",\n value,\n defaultValue,\n onChange,\n minDate,\n maxDate,\n disabledDates,\n disabledDays,\n locale = \"en-US\",\n placeholder,\n label,\n error,\n helperText,\n className,\n inputClassName,\n calendarClassName,\n variant,\n size,\n showOutsideDays = true,\n firstDayOfWeek = 1,\n labels: labelOverrides,\n ...props\n },\n ref,\n ) => {\n const labels = useMemo(\n () => ({ ...DEFAULT_LABELS, ...labelOverrides }),\n [labelOverrides],\n );\n\n const [open, setOpen] = useState(false);\n // Opening a calendar that already has a value used to land on the current\n // month: `value={new Date(2020, 0, 15)}` opened September 2026 and left the\n // reader to page back eighty months.\n const [currentMonth, setCurrentMonth] = useState(\n () => anchorDate(value ?? defaultValue) ?? new Date(),\n );\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n const calendarRef = useRef<HTMLDivElement>(null);\n const dayButtonRefs = useRef<Map<string, HTMLButtonElement>>(new Map());\n\n // Controlled vs uncontrolled\n const [internalValue, setInternalValue] = useState<\n Date | Date[] | { from?: Date; to?: Date } | undefined\n >(defaultValue);\n\n const isControlled = value !== undefined;\n const calendarValue = isControlled ? value : internalValue;\n\n const isDisabledDate = React.useCallback(\n (date: Date) =>\n isDateDisabled(date, minDate, maxDate, disabledDates, disabledDays),\n [minDate, maxDate, disabledDates, disabledDays],\n );\n\n /**\n * Where focus starts when the calendar opens.\n *\n * It used to be today, unconditionally. That is the wrong date twice over: it\n * ignores a selection the reader already made, and today may be disabled - in\n * which case the only cell with `tabIndex=0` was a disabled button, so the\n * grid had no tab stop at all.\n *\n * The order is: the selected date, then today, then the first enabled day of\n * the month on screen. If nothing in reach is enabled, focus stays unset and\n * the grid simply has no tab stop, which is the truth.\n */\n React.useLayoutEffect(() => {\n if (!open || focusedDate) return;\n\n const today = startOfDay(new Date());\n const selected = anchorDate(calendarValue);\n const preferred = [selected, today].find(\n (date): date is Date => !!date && !isDisabledDate(date),\n );\n if (preferred) {\n setFocusedDate(startOfDay(preferred));\n return;\n }\n\n const monthStart = startOfMonth(currentMonth);\n const firstEnabled = findEnabledDate(\n monthStart,\n 1,\n isDisabledDate,\n dateFnsGetDaysInMonth(currentMonth),\n );\n if (firstEnabled) setFocusedDate(firstEnabled);\n }, [open, focusedDate, calendarValue, currentMonth, isDisabledDate]);\n\n // Handle value changes\n const handleValueChange = (\n newValue: Date | Date[] | { from?: Date; to?: Date } | undefined,\n ) => {\n if (!isControlled) {\n setInternalValue(newValue);\n }\n onChange?.(newValue);\n };\n\n // Handle date selection\n const handleDateClick = (date: Date) => {\n if (isDateDisabled(date, minDate, maxDate, disabledDates, disabledDays)) {\n return;\n }\n\n if (mode === \"single\") {\n handleValueChange(date);\n setOpen(false);\n } else if (mode === \"range\") {\n const rangeValue = calendarValue as\n { from?: Date; to?: Date } | undefined;\n if (!rangeValue?.from || (rangeValue.from && rangeValue.to)) {\n // Start new range\n handleValueChange({ from: date });\n } else {\n // Complete range\n const from = rangeValue.from;\n const to = date;\n if (to < from) {\n handleValueChange({ from: to, to: from });\n } else {\n handleValueChange({ from, to });\n }\n setOpen(false);\n }\n } else if (mode === \"multiple\") {\n const multipleValue = (calendarValue as Date[]) || [];\n const dateIndex = multipleValue.findIndex((d) => isSameDay(d, date));\n if (dateIndex >= 0) {\n // Remove date\n handleValueChange(multipleValue.filter((_, i) => i !== dateIndex));\n } else {\n // Add date\n handleValueChange([...multipleValue, date]);\n }\n }\n };\n\n // Get display value\n const displayValue = useMemo(() => {\n if (!calendarValue) return \"\";\n\n if (mode === \"single\") {\n return formatDate(calendarValue as Date, locale);\n } else if (mode === \"range\") {\n const range = calendarValue as { from?: Date; to?: Date };\n return formatDateRange(range.from, range.to, locale);\n } else {\n return formatMultipleDates(\n calendarValue as Date[],\n locale,\n labels.multipleSelected,\n );\n }\n }, [calendarValue, mode, locale, labels.multipleSelected]);\n\n // Generate calendar days\n const calendarDays = useMemo(() => {\n const days: Array<{\n date: Date;\n isCurrentMonth: boolean;\n isToday: boolean;\n /** A spacer that holds a column open without showing a date. */\n placeholder?: boolean;\n }> = [];\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n\n const firstDay = getFirstDayOfMonth(currentMonth, firstDayOfWeek);\n const daysInMonth = getDaysInMonth(currentMonth);\n\n // Previous month days.\n //\n // The leading cells exist whether or not the dates in them are shown: they\n // are what puts the first of the month under the right weekday. Only adding\n // them when `showOutsideDays` was on meant a September starting on a\n // Tuesday rendered its 1st in the Monday column, with every date of the\n // month one heading out for the rest of the grid.\n //\n // With outside days hidden they become empty, non-interactive placeholders\n // instead - see the `placeholder` flag below.\n if (firstDay > 0) {\n const prevMonth = new Date(\n currentMonth.getFullYear(),\n currentMonth.getMonth() - 1,\n );\n const daysInPrevMonth = getDaysInMonth(prevMonth);\n for (\n let i = daysInPrevMonth - firstDay + 1;\n i <= daysInPrevMonth;\n i++\n ) {\n const date = new Date(\n prevMonth.getFullYear(),\n prevMonth.getMonth(),\n i,\n );\n days.push({\n date,\n isCurrentMonth: false,\n isToday: isSameDay(date, today),\n placeholder: !showOutsideDays,\n });\n }\n }\n\n // Current month days\n for (let i = 1; i <= daysInMonth; i++) {\n const date = new Date(\n currentMonth.getFullYear(),\n currentMonth.getMonth(),\n i,\n );\n days.push({\n date,\n isCurrentMonth: true,\n isToday: isSameDay(date, today),\n });\n }\n\n // Next month days\n if (showOutsideDays) {\n const remainingDays = 42 - days.length; // 6 weeks * 7 days\n const nextMonth = new Date(\n currentMonth.getFullYear(),\n currentMonth.getMonth() + 1,\n );\n for (let i = 1; i <= remainingDays; i++) {\n const date = new Date(\n nextMonth.getFullYear(),\n nextMonth.getMonth(),\n i,\n );\n days.push({\n date,\n isCurrentMonth: false,\n isToday: isSameDay(date, today),\n });\n }\n }\n\n return days;\n }, [currentMonth, showOutsideDays, firstDayOfWeek]);\n\n // Navigate months\n /**\n * Moves the grid, and brings focus with it.\n *\n * The header buttons only moved the month. Focus stayed on a date that was no\n * longer rendered, so the grid lost its tab stop and an arrow key jumped back\n * to the month you had just left.\n */\n const goToMonth = (months: number) => {\n const target = new Date(\n currentMonth.getFullYear(),\n currentMonth.getMonth() + months,\n 1,\n );\n setCurrentMonth(target);\n\n if (!focusedDate) return;\n const sameDayNextMonth = shiftMonth(focusedDate, months);\n const landing =\n findEnabledDate(\n sameDayNextMonth,\n 1,\n isDisabledDate,\n dateFnsGetDaysInMonth(target),\n ) ??\n findEnabledDate(\n sameDayNextMonth,\n -1,\n isDisabledDate,\n dateFnsGetDaysInMonth(target),\n );\n if (landing) setFocusedDate(landing);\n };\n\n const goToPreviousMonth = () => goToMonth(-1);\n const goToNextMonth = () => goToMonth(1);\n\n const goToToday = () => {\n const today = startOfDay(new Date());\n setCurrentMonth(today);\n // Today can be disabled, in which case focus goes to the nearest day of\n // that month that is not.\n const landing =\n findEnabledDate(today, 1, isDisabledDate, 31) ??\n findEnabledDate(today, -1, isDisabledDate, 31);\n if (landing) setFocusedDate(landing);\n };\n\n // Keyboard navigation\n const handleKeyDown = (e: React.KeyboardEvent, date: Date) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n handleDateClick(date);\n return;\n }\n\n /**\n * Every movement lands on a date that can actually take focus.\n *\n * Each key used to step once and stop, disabled or not. The resulting cell\n * got the grid's only `tabIndex=0` while being a disabled button, so\n * ArrowRight into a disabled Tuesday left the grid with no tab stop and no\n * way forward - pressing it again did the same thing from the same place.\n */\n const moveFocus = (\n candidate: Date,\n step: number,\n limit?: number,\n ): void => {\n const target = findEnabledDate(candidate, step, isDisabledDate, limit);\n // Nothing enabled in that direction: stay where we are rather than\n // moving focus onto something that cannot hold it.\n if (!target) return;\n\n setFocusedDate(target);\n if (\n target.getMonth() !== currentMonth.getMonth() ||\n target.getFullYear() !== currentMonth.getFullYear()\n ) {\n setCurrentMonth(new Date(target.getFullYear(), target.getMonth(), 1));\n }\n };\n\n const step = (days: number) => {\n const candidate = new Date(date);\n candidate.setDate(candidate.getDate() + days);\n moveFocus(candidate, days > 0 ? 1 : -1);\n };\n\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n step(1);\n return;\n }\n\n if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n step(-1);\n return;\n }\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n step(7);\n return;\n }\n\n if (e.key === \"ArrowUp\") {\n e.preventDefault();\n step(-7);\n return;\n }\n\n if (e.key === \"Home\") {\n e.preventDefault();\n // Forwards from the 1st: the first day of the month that is enabled.\n moveFocus(\n new Date(date.getFullYear(), date.getMonth(), 1),\n 1,\n dateFnsGetDaysInMonth(date),\n );\n return;\n }\n\n if (e.key === \"End\") {\n e.preventDefault();\n moveFocus(\n new Date(date.getFullYear(), date.getMonth() + 1, 0),\n -1,\n dateFnsGetDaysInMonth(date),\n );\n return;\n }\n\n if (e.key === \"PageUp\") {\n e.preventDefault();\n // `new Date(y, m - 1, 31)` from 31 March is 3 March, so a month-step from\n // the end of a long month used to skip the short month entirely.\n moveFocus(shiftMonth(date, -1), -1);\n return;\n }\n\n if (e.key === \"PageDown\") {\n e.preventDefault();\n moveFocus(shiftMonth(date, 1), 1);\n return;\n }\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n setOpen(false);\n return;\n }\n };\n\n // Focus management\n useEffect(() => {\n if (focusedDate && open) {\n const dateKey = `${focusedDate.getFullYear()}-${focusedDate.getMonth()}-${focusedDate.getDate()}`;\n const button = dayButtonRefs.current.get(dateKey);\n if (button) {\n button.focus();\n }\n }\n }, [focusedDate, open]);\n\n // Day names\n const dayNames = useMemo(\n () => getDayNames(locale, firstDayOfWeek),\n [locale, firstDayOfWeek],\n );\n\n // Month/year display\n const monthYearDisplay = currentMonth.toLocaleDateString(locale, {\n month: \"long\",\n year: \"numeric\",\n });\n\n return (\n <div ref={ref} className={cn(\"w-full\", className)} {...props}>\n <Popover.Root open={open} onOpenChange={setOpen}>\n <div className=\"space-y-2\">\n {label && (\n <label className=\"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\">\n {label}\n </label>\n )}\n <Popover.Trigger asChild>\n <button\n type=\"button\"\n className={cn(\n \"flex w-full rounded-md border bg-background px-3 py-2 text-sm ring-offset-background\",\n \"placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2\",\n \"disabled:cursor-not-allowed disabled:opacity-50 transition-all duration-200 text-left\",\n error\n ? \"border-error-500 shadow-sm hover:border-error-600 focus-visible:ring-error-500/20 focus-visible:border-error-500\"\n : \"border-border shadow-sm hover:border-primary focus-visible:ring-ring/20 focus-visible:border-primary\",\n \"h-10\",\n inputClassName,\n )}\n // No onFocus handler here. Radix returns focus to the trigger\n // when the popover closes, so opening on focus meant selecting a\n // date closed it and immediately reopened it - the flicker. It\n // also popped the calendar open when tabbing past the field.\n onClick={() => setOpen(true)}\n aria-label={label || labels.openCalendar}\n aria-invalid={error}\n >\n {displayValue || (\n <span className=\"text-muted-foreground\">\n {placeholder ?? labels.placeholder}\n </span>\n )}\n </button>\n </Popover.Trigger>\n {helperText && (\n <p\n className={cn(\n \"text-sm text-muted-foreground\",\n error && \"text-error-600\",\n )}\n >\n {helperText}\n </p>\n )}\n </div>\n\n <Popover.Portal>\n <Popover.Content\n className={cn(\n \"z-50 w-auto rounded-lg border bg-popover p-4 shadow-lg\",\n \"data-[state=open]:animate-in data-[state=closed]:animate-out\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2\",\n \"data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\n )}\n sideOffset={5}\n align=\"start\"\n >\n <div\n ref={calendarRef}\n className={cn(\n calendarVariants({ variant, size }),\n calendarClassName,\n )}\n role=\"application\"\n aria-label=\"Calendar\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between mb-4\">\n <div className=\"flex items-center gap-2\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={goToPreviousMonth}\n aria-label={labels.previousMonth}\n >\n <svg\n className=\"h-4 w-4\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M15 19l-7-7 7-7\"\n />\n </svg>\n </Button>\n\n <h3\n className=\"text-sm font-semibold text-popover-foreground\"\n data-testid=\"calendar-month-year\"\n >\n {monthYearDisplay}\n </h3>\n\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={goToNextMonth}\n aria-label={labels.nextMonth}\n >\n <svg\n className=\"h-4 w-4\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 5l7 7-7 7\"\n />\n </svg>\n </Button>\n </div>\n\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={goToToday}\n className=\"text-xs\"\n >\n {labels.today}\n </Button>\n </div>\n\n {/* Day names */}\n <div className=\"grid grid-cols-7 gap-1 mb-2\">\n {dayNames.map((day) => (\n <div\n key={day}\n className=\"text-center text-xs font-medium text-muted-foreground\"\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid grid-cols-7 gap-1\">\n {calendarDays.map((day, index) => {\n const isSelected =\n mode === \"single\"\n ? isSameDay(day.date, calendarValue as Date | undefined)\n : mode === \"range\"\n ? isDateInRange(\n day.date,\n (calendarValue as { from?: Date; to?: Date })\n ?.from,\n (calendarValue as { from?: Date; to?: Date })?.to,\n )\n : (calendarValue as Date[])?.some((d) =>\n isSameDay(d, day.date),\n );\n\n const isDisabled = isDateDisabled(\n day.date,\n minDate,\n maxDate,\n disabledDates,\n disabledDays,\n );\n\n const isInRange =\n mode === \"range\" &&\n (calendarValue as { from?: Date; to?: Date })?.from &&\n !(calendarValue as { from?: Date; to?: Date })?.to &&\n day.date >=\n (calendarValue as { from?: Date; to?: Date }).from!;\n\n const dateKey = `${day.date.getFullYear()}-${day.date.getMonth()}-${day.date.getDate()}`;\n const isFocused =\n focusedDate && isSameDay(day.date, focusedDate);\n\n // A leading spacer: it holds the column open so the first\n // of the month lands under the right weekday, and it is not\n // a control, so it is out of the tab order and out of the\n // accessibility tree.\n if (day.placeholder) {\n return (\n <div\n key={`placeholder-${index}`}\n aria-hidden=\"true\"\n data-calendar-placeholder=\"\"\n className={cn(\n calendarDayVariants({ variant: \"default\", size }),\n \"invisible\",\n )}\n />\n );\n }\n\n return (\n <button\n key={`${day.date.getTime()}-${index}`}\n ref={(el) => {\n if (el) {\n dayButtonRefs.current.set(dateKey, el);\n } else {\n dayButtonRefs.current.delete(dateKey);\n }\n }}\n type=\"button\"\n onClick={() => {\n if (showOutsideDays && !day.isCurrentMonth) {\n // Navigate to the month of the clicked date\n setCurrentMonth(\n new Date(\n day.date.getFullYear(),\n day.date.getMonth(),\n 1,\n ),\n );\n // Synchronously: React batches both updates into one\n // render. Deferring the selection by a tick showed the\n // new month first and selected a frame later, which\n // read as a flash.\n handleDateClick(day.date);\n } else {\n handleDateClick(day.date);\n }\n }}\n onKeyDown={(e) => handleKeyDown(e, day.date)}\n disabled={\n isDisabled ||\n (showOutsideDays ? false : !day.isCurrentMonth)\n }\n className={cn(\n calendarDayVariants({\n variant: isSelected\n ? \"selected\"\n : isInRange\n ? \"range\"\n : day.isToday\n ? \"today\"\n : !day.isCurrentMonth\n ? \"outside\"\n : isDisabled\n ? \"disabled\"\n : \"default\",\n size,\n }),\n !day.isCurrentMonth && \"opacity-50\",\n isFocused &&\n \"ring-2 ring-brand-500 ring-offset-2 z-10\",\n )}\n aria-label={day.date.toLocaleDateString(locale, {\n weekday: \"long\",\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n })}\n aria-selected={isSelected}\n aria-disabled={isDisabled}\n tabIndex={isFocused ? 0 : -1}\n >\n {day.date.getDate()}\n </button>\n );\n })}\n </div>\n\n {/* Footer for range mode */}\n {mode === \"range\" &&\n (calendarValue as { from?: Date; to?: Date })?.from &&\n !(calendarValue as { from?: Date; to?: Date })?.to && (\n <div className=\"mt-4 pt-4 border-t border-border\">\n <p className=\"text-xs text-muted-foreground text-center\">\n {labels.selectEndDate}\n </p>\n </div>\n )}\n </div>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n </div>\n );\n },\n);\n\nCalendar.displayName = \"Calendar\";\n\nexport { calendarVariants, calendarDayVariants };\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {a}from'./chunk-AC2JBXHQ.js';import r,{useState}from'react';import {cva}from'class-variance-authority';var U=cva("w-full border-collapse transition-all duration-200",{variants:{variant:{default:"border border-border shadow-sm hover:shadow-md",striped:"border border-border shadow-sm hover:shadow-md",bordered:"border-2 border-border shadow-md hover:shadow-lg",hover:"border border-border shadow-sm hover:shadow-md",elevated:"border border-border shadow-lg hover:shadow-xl",interactive:"border border-border shadow-sm hover:shadow-md hover:border-primary"},size:{sm:"text-xs sm:text-sm",md:"text-sm sm:text-base",lg:"text-base sm:text-lg"}},defaultVariants:{variant:"default",size:"md"}}),W=cva("font-medium text-left transition-all duration-200",{variants:{variant:{default:"bg-muted text-foreground hover:bg-muted/80",striped:"bg-muted text-foreground hover:bg-muted/80",bordered:"bg-muted text-foreground hover:bg-muted/80",hover:"bg-muted text-foreground hover:bg-muted/80",elevated:"bg-muted text-foreground hover:bg-muted/80",interactive:"bg-muted text-foreground hover:bg-primary/10 hover:text-primary"},size:{sm:"px-2 py-1 sm:px-3 sm:py-2",md:"px-3 py-2 sm:px-4 sm:py-3",lg:"px-4 py-3 sm:px-6 sm:py-4"}},defaultVariants:{variant:"default",size:"md"}}),X=cva("border-b border-border transition-colors",{variants:{variant:{default:"hover:bg-muted/50",striped:"even:bg-muted/50 hover:bg-muted/80",bordered:"hover:bg-muted/50",hover:"hover:bg-muted/50",elevated:"hover:bg-muted/80",interactive:"hover:bg-primary/10 hover:text-primary"}},defaultVariants:{variant:"default"}}),w=cva("border-border transition-all duration-200",{variants:{variant:{default:"border-b border-border hover:bg-muted/50",striped:"border-b border-border hover:bg-muted/80",bordered:"border border-border hover:bg-muted/50",hover:"border-b border-border hover:bg-muted/50",elevated:"border-b border-border hover:bg-muted/80",interactive:"border-b border-border hover:bg-primary/10 hover:text-primary"},size:{sm:"px-2 py-1 sm:px-3 sm:py-2",md:"px-3 py-2 sm:px-4 sm:py-3",lg:"px-4 py-3 sm:px-6 sm:py-4"}},defaultVariants:{variant:"default",size:"md"}});function Y({data:l,columns:n,loading:b=false,emptyText:p="No data",className:u,variant:d,size:i,rowKey:c="id",onRowClick:E,onSort:L,sortColumn:N,sortDirection:B,pagination:t,selection:s,caption:k,...I},D){let[j,A]=useState(null),S=N!==void 0,g=S&&N?{column:N,direction:B||"asc"}:j,F=e=>{if(!e.sortable)return;let o=g?.column===e.key&&g?.direction==="asc"?"desc":"asc";S||A({column:e.key,direction:o}),L?.(e,o);},f=(e,o)=>typeof c=="function"?c(e):e[c]??o,P=e=>s?.getCheckboxProps?.(e).disabled===true,h=s?l.map((e,o)=>({record:e,key:f(e,o)})).filter(({record:e})=>!P(e)).map(({key:e})=>e):[],z=e=>l.filter((o,a)=>e.includes(f(o,a))),H=(e,o)=>{if(!s)return false;let a=f(e,o);return s.selectedRowKeys.includes(a)},G=(e,o,a)=>{if(!s||P(e))return;let x=f(e,o),V=a?s.selectedRowKeys.includes(x)?s.selectedRowKeys:[...s.selectedRowKeys,x]:s.selectedRowKeys.filter(Q=>Q!==x);s.onChange(V,z(V));},$=e=>{if(!s)return;let o=s.selectedRowKeys.filter(x=>!h.includes(x)),a=e?[...o,...h]:o;s.onChange(a,z(a));},C=h.filter(e=>s?.selectedRowKeys.includes(e)),J=s&&h.length>0&&C.length===h.length,O=s&&C.length>0&&C.length<h.length;return r.createElement("div",{className:"w-full overflow-x-auto"},r.createElement("div",{className:"min-w-full"},r.createElement("table",{ref:D,className:a(U({variant:d,size:i}),u),...I},k&&r.createElement("caption",{className:"sr-only"},k),r.createElement(K,null,r.createElement(v,null,s&&r.createElement("th",{className:a(w({variant:d,size:i})),scope:"col",role:"columnheader"},r.createElement("input",{type:"checkbox",checked:J,ref:e=>{e&&(e.indeterminate=O||false);},onChange:e=>$(e.target.checked),className:"rounded border-input text-primary focus:ring-ring","aria-label":"Select all rows"})),n.map(e=>r.createElement("th",{key:e.key,className:a(w({variant:d,size:i}),e.className,e.align==="center"&&"text-center",e.align==="right"&&"text-right"),scope:"col",role:"columnheader",...e.width&&{style:{width:e.width}}},r.createElement("div",{className:"flex items-center gap-2"},r.createElement("span",null,e.title),e.sortable&&r.createElement("button",{type:"button",onClick:()=>F(e),className:"flex flex-col text-muted-foreground hover:text-foreground","aria-label":`Sort by ${e.title}`},r.createElement("svg",{className:a("w-3 h-3",g?.column===e.key&&g?.direction==="asc"?"text-primary":"text-muted-foreground"),fill:"currentColor",viewBox:"0 0 20 20"},r.createElement("path",{d:"M5 8l5-5 5 5H5z"})),r.createElement("svg",{className:a("w-3 h-3 -mt-1",g?.column===e.key&&g?.direction==="desc"?"text-primary":"text-muted-foreground"),fill:"currentColor",viewBox:"0 0 20 20"},r.createElement("path",{d:"M5 12l5 5 5-5H5z"})))))))),r.createElement(M,null,b?r.createElement(v,null,r.createElement(y,{colSpan:n.length+(s?1:0),variant:d,size:i,className:"text-center py-8"},r.createElement("div",{className:"flex items-center justify-center gap-2"},r.createElement("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),r.createElement("span",null,"Loading...")))):l.length===0?r.createElement(v,null,r.createElement(y,{colSpan:n.length+(s?1:0),variant:d,size:i,className:"text-center py-8 text-muted-foreground"},p)):l.map((e,o)=>r.createElement(v,{key:f(e,o),variant:d,onClick:()=>E?.(e,o),selected:H(e,o)},s&&r.createElement(y,{variant:d,size:i},r.createElement("input",{type:"checkbox",checked:H(e,o),onChange:a=>G(e,o,a.target.checked),className:"rounded border-input text-primary focus:ring-ring","aria-label":`Select row ${o+1}`,...s.getCheckboxProps?.(e)})),n.map(a$1=>r.createElement(y,{key:a$1.key,variant:d,size:i,className:a(a$1.className,a$1.align==="center"&&"text-center",a$1.align==="right"&&"text-right")},a$1.render?a$1.render(a$1.dataIndex?e[a$1.dataIndex]:e,e,o):a$1.dataIndex?e[a$1.dataIndex]:e[a$1.key]))))))),t&&r.createElement("div",{className:"flex flex-col sm:flex-row items-center justify-between mt-4 px-2 sm:px-4 py-3 bg-card border-t border-border gap-2 sm:gap-0"},r.createElement("div",{className:"flex items-center gap-2"},r.createElement("span",{className:"text-sm text-muted-foreground"},"Showing ",(t.current-1)*t.pageSize+1," to"," ",Math.min(t.current*t.pageSize,t.total)," ","of ",t.total," results")),r.createElement("div",{className:"flex items-center gap-2"},t.showSizeChanger&&r.createElement("select",{value:t.pageSize,onChange:e=>t.onChange(1,Number(e.target.value)),className:"rounded border-input bg-background text-sm","aria-label":"Select page size"},r.createElement("option",{value:10},"10 / page"),r.createElement("option",{value:20},"20 / page"),r.createElement("option",{value:50},"50 / page"),r.createElement("option",{value:100},"100 / page")),r.createElement("div",{className:"flex items-center gap-1"},r.createElement("button",{type:"button",onClick:()=>t.onChange(t.current-1,t.pageSize),disabled:t.current<=1,className:"px-3 py-1 text-sm border border-input rounded hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Go to previous page"},"Previous"),r.createElement("span",{className:"px-3 py-1 text-sm"},"Page ",t.current," of"," ",Math.ceil(t.total/t.pageSize)),r.createElement("button",{type:"button",onClick:()=>t.onChange(t.current+1,t.pageSize),disabled:t.current>=Math.ceil(t.total/t.pageSize),className:"px-3 py-1 text-sm border border-input rounded hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Go to next page"},"Next")))))}var R=r.forwardRef(Y);R.displayName="Table";var te=R,K=r.forwardRef(({className:l,variant:n,size:b,children:p,...u},d)=>r.createElement("thead",{ref:d,className:a(W({variant:n,size:b}),l),...u},p));K.displayName="TableHeader";var M=r.forwardRef(({className:l,children:n,...b},p)=>r.createElement("tbody",{ref:p,className:a(l),...b},n));M.displayName="TableBody";var v=r.forwardRef(({className:l,children:n,onClick:b,selected:p,variant:u,...d},i)=>r.createElement("tr",{ref:i,className:a(X({variant:u}),p&&"bg-primary/10",b&&"cursor-pointer",l),onClick:b,...d},n));v.displayName="TableRow";var y=r.forwardRef(({className:l,children:n,variant:b,size:p,colSpan:u,rowSpan:d,...i},c)=>r.createElement("td",{ref:c,className:a(w({variant:b,size:p}),l),colSpan:u,rowSpan:d,...i},n));y.displayName="TableCell";var Z=r.forwardRef(({className:l,children:n,variant:b,size:p,colSpan:u,rowSpan:d,...i},c)=>r.createElement("th",{ref:c,className:a(w({variant:b,size:p}),"font-medium",l),colSpan:u,rowSpan:d,...i},n));Z.displayName="TableHead";export{U as a,W as b,w as c,te as d,K as e,M as f,v as g,y as h,Z as i};//# sourceMappingURL=chunk-HCO4XKPM.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-HCO4XKPM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/core/table.tsx"],"names":["tableVariants","cva","tableHeaderVariants","tableRowVariants","tableCellVariants","TableComponent","data","columns","loading","emptyText","className","variant","size","rowKey","onRowClick","onSort","controlledSortColumn","controlledSortDirection","pagination","selection","caption","props","ref","internalSortState","setInternalSortState","useState","isControlled","sortState","handleSort","column","newDirection","getRowKey","record","index","isRowDisabled","selectableKeys","key","recordsForKeys","keys","isRowSelected","handleRowSelection","checked","newSelectedKeys","k","handleSelectAll","others","selectedOnPage","isAllSelected","isIndeterminate","React","cn","TableHeader","TableRow","input","TableBody","TableCell","e","TableForwardRef","Table","children","onClick","selected","colSpan","rowSpan","TableHead"],"mappings":"8GAKA,IAAMA,CAAAA,CAAgBC,IACpB,oDAAA,CACA,CACE,QAAA,CAAU,CACR,QAAS,CACP,OAAA,CAAS,gDAAA,CACT,OAAA,CAAS,iDACT,QAAA,CAAU,kDAAA,CACV,KAAA,CAAO,gDAAA,CACP,SAAU,gDAAA,CACV,WAAA,CACE,qEACJ,CAAA,CACA,KAAM,CACJ,EAAA,CAAI,qBACJ,EAAA,CAAI,sBAAA,CACJ,GAAI,sBACN,CACF,CAAA,CACA,eAAA,CAAiB,CACf,OAAA,CAAS,SAAA,CACT,IAAA,CAAM,IACR,CACF,CACF,CAAA,CAEMC,CAAAA,CAAsBD,GAAAA,CAC1B,oDACA,CACE,QAAA,CAAU,CACR,OAAA,CAAS,CACP,OAAA,CAAS,4CAAA,CACT,OAAA,CAAS,4CAAA,CACT,SAAU,4CAAA,CACV,KAAA,CAAO,4CAAA,CACP,QAAA,CAAU,6CACV,WAAA,CACE,iEACJ,CAAA,CACA,IAAA,CAAM,CACJ,EAAA,CAAI,2BAAA,CACJ,GAAI,2BAAA,CACJ,EAAA,CAAI,2BACN,CACF,CAAA,CACA,eAAA,CAAiB,CACf,QAAS,SAAA,CACT,IAAA,CAAM,IACR,CACF,CACF,CAAA,CASME,CAAAA,CAAmBF,GAAAA,CAAI,0CAAA,CAA4C,CACvE,QAAA,CAAU,CACR,OAAA,CAAS,CACP,QAAS,mBAAA,CACT,OAAA,CAAS,oCAAA,CACT,QAAA,CAAU,oBACV,KAAA,CAAO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,CAAAA,CAAU,WAAA,CAAc,WAAA,CAEjB,IAAMS,EAAYf,CAAAA,CAAM,UAAA,CAC7B,CAAC,CAAE,SAAA,CAAAvC,EAAW,QAAA,CAAAiD,CAAAA,CAAU,OAAA,CAAAhD,CAAAA,CAAS,KAAAC,CAAAA,CAAM,OAAA,CAAAkD,CAAAA,CAAS,OAAA,CAAAC,EAAS,GAAG1C,CAAM,CAAA,CAAGC,CAAAA,GACnE2B,EAAA,aAAA,CAAC,IAAA,CAAA,CACC,IAAK3B,CAAAA,CACL,SAAA,CAAW4B,EACT9C,CAAAA,CAAkB,CAAE,OAAA,CAAAO,CAAAA,CAAS,KAAAC,CAAK,CAAC,CAAA,CACnC,aAAA,CACAF,CACF,CAAA,CACA,OAAA,CAASoD,CAAAA,CACT,OAAA,CAASC,EACR,GAAG1C,CAAAA,CAAAA,CAEHsC,CACH,CAEJ,EAEAK,EAAU,WAAA,CAAc,WAAA","file":"chunk-HCO4XKPM.js","sourcesContent":["import React, { useState } from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { cn } from \"../../lib/utils\";\n\n// Table variants\nconst tableVariants = cva(\n \"w-full border-collapse transition-all duration-200\",\n {\n variants: {\n variant: {\n default: \"border border-border shadow-sm hover:shadow-md\",\n striped: \"border border-border shadow-sm hover:shadow-md\",\n bordered: \"border-2 border-border shadow-md hover:shadow-lg\",\n hover: \"border border-border shadow-sm hover:shadow-md\",\n elevated: \"border border-border shadow-lg hover:shadow-xl\",\n interactive:\n \"border border-border shadow-sm hover:shadow-md hover:border-primary\",\n },\n size: {\n sm: \"text-xs sm:text-sm\",\n md: \"text-sm sm:text-base\",\n lg: \"text-base sm:text-lg\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n);\n\nconst tableHeaderVariants = cva(\n \"font-medium text-left transition-all duration-200\",\n {\n variants: {\n variant: {\n default: \"bg-muted text-foreground hover:bg-muted/80\",\n striped: \"bg-muted text-foreground hover:bg-muted/80\",\n bordered: \"bg-muted text-foreground hover:bg-muted/80\",\n hover: \"bg-muted text-foreground hover:bg-muted/80\",\n elevated: \"bg-muted text-foreground hover:bg-muted/80\",\n interactive:\n \"bg-muted text-foreground hover:bg-primary/10 hover:text-primary\",\n },\n size: {\n sm: \"px-2 py-1 sm:px-3 sm:py-2\",\n md: \"px-3 py-2 sm:px-4 sm:py-3\",\n lg: \"px-4 py-3 sm:px-6 sm:py-4\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n);\n\n/**\n * Row-level variants.\n *\n * `striped` has to live here, not on the cell: `even:` selects the even sibling\n * among *cells within a row*, so applying it there striped columns instead of\n * rows - and TableRow ignored the variant entirely, so nothing showed at all.\n */\nconst tableRowVariants = cva(\"border-b border-border transition-colors\", {\n variants: {\n variant: {\n default: \"hover:bg-muted/50\",\n striped: \"even:bg-muted/50 hover:bg-muted/80\",\n bordered: \"hover:bg-muted/50\",\n hover: \"hover:bg-muted/50\",\n elevated: \"hover:bg-muted/80\",\n interactive: \"hover:bg-primary/10 hover:text-primary\",\n },\n },\n defaultVariants: { variant: \"default\" },\n});\n\nconst tableCellVariants = cva(\"border-border transition-all duration-200\", {\n variants: {\n variant: {\n default: \"border-b border-border hover:bg-muted/50\",\n striped: \"border-b border-border hover:bg-muted/80\",\n bordered: \"border border-border hover:bg-muted/50\",\n hover: \"border-b border-border hover:bg-muted/50\",\n elevated: \"border-b border-border hover:bg-muted/80\",\n interactive:\n \"border-b border-border hover:bg-primary/10 hover:text-primary\",\n },\n size: {\n sm: \"px-2 py-1 sm:px-3 sm:py-2\",\n md: \"px-3 py-2 sm:px-4 sm:py-3\",\n lg: \"px-4 py-3 sm:px-6 sm:py-4\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n});\n\n// Types\nexport interface TableColumn<T = Record<string, unknown>> {\n key: string;\n title: string;\n dataIndex?: keyof T;\n render?: (value: unknown, record: T, index: number) => React.ReactNode;\n sortable?: boolean;\n width?: string | number;\n align?: \"left\" | \"center\" | \"right\";\n className?: string;\n}\n\nexport interface TableProps<T = Record<string, unknown>> extends VariantProps<\n typeof tableVariants\n> {\n data: T[];\n columns: TableColumn<T>[];\n loading?: boolean;\n emptyText?: string;\n caption?: string;\n className?: string;\n rowKey?: keyof T | ((record: T) => string | number);\n onRowClick?: (record: T, index: number) => void;\n onSort?: (column: TableColumn<T>, direction: \"asc\" | \"desc\") => void;\n sortColumn?: string;\n sortDirection?: \"asc\" | \"desc\";\n pagination?: {\n current: number;\n pageSize: number;\n total: number;\n onChange: (page: number, pageSize: number) => void;\n showSizeChanger?: boolean;\n showQuickJumper?: boolean;\n };\n selection?: {\n selectedRowKeys: (string | number)[];\n /**\n * `selectedRowKeys` is the complete selection, including keys for records on\n * other pages. `selectedRows` is only the subset present in `data`, because\n * the component has never been given the rest. Paginating server-side means\n * keeping your own key-to-record map and treating the keys as authoritative.\n */\n onChange: (selectedRowKeys: (string | number)[], selectedRows: T[]) => void;\n /**\n * A disabled row cannot be selected individually, and select-all skips it\n * rather than selecting it on the consumer's behalf.\n */\n getCheckboxProps?: (record: T) => { disabled?: boolean };\n };\n}\n\nexport interface TableHeaderProps extends VariantProps<\n typeof tableHeaderVariants\n> {\n className?: string;\n children: React.ReactNode;\n}\n\nexport interface TableBodyProps {\n className?: string;\n children: React.ReactNode;\n}\n\nexport interface TableRowProps extends VariantProps<typeof tableRowVariants> {\n className?: string;\n children: React.ReactNode;\n onClick?: () => void;\n selected?: boolean;\n}\n\nexport interface TableCellProps extends VariantProps<typeof tableCellVariants> {\n className?: string;\n children: React.ReactNode;\n colSpan?: number;\n rowSpan?: number;\n}\n\n// Table Components\nfunction TableComponent<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(\n {\n data,\n columns,\n loading = false,\n emptyText = \"No data\",\n className,\n variant,\n size,\n rowKey = \"id\",\n onRowClick,\n onSort,\n sortColumn: controlledSortColumn,\n sortDirection: controlledSortDirection,\n pagination,\n selection,\n caption,\n ...props\n }: TableProps<T>,\n ref: React.Ref<HTMLTableElement>,\n) {\n // Use controlled props if provided, otherwise use internal state\n const [internalSortState, setInternalSortState] = useState<{\n column: string;\n direction: \"asc\" | \"desc\";\n } | null>(null);\n\n // Determine current sort state (controlled takes precedence)\n const isControlled = controlledSortColumn !== undefined;\n const sortState =\n isControlled && controlledSortColumn\n ? {\n column: controlledSortColumn,\n direction: controlledSortDirection || \"asc\",\n }\n : internalSortState;\n\n // Sync internal state with controlled props when they change\n // Sync internal state with controlled props when they change\n // Note: unneeded re-render caused by resetting state. We derive sortState above so stale internal state is ignored.\n /* \n useEffect(() => {\n if (isControlled && controlledSortColumn) {\n setInternalSortState(null);\n }\n }, [isControlled, controlledSortColumn]); \n */\n\n const handleSort = (column: TableColumn<T>) => {\n if (!column.sortable) return;\n\n const newDirection =\n sortState?.column === column.key && sortState?.direction === \"asc\"\n ? \"desc\"\n : \"asc\";\n\n // Only update internal state if not controlled\n if (!isControlled) {\n setInternalSortState({ column: column.key, direction: newDirection });\n }\n\n // Always call onSort callback for controlled usage\n onSort?.(column, newDirection);\n };\n\n /**\n * Nullish, not falsy.\n *\n * `record[rowKey] || index` reads a record with `id: 0` as having no key and\n * falls back to its position, so a zero-keyed row at index 1 reported itself as\n * key `1` - which is a different record's id. Empty string is a legitimate key\n * for the same reason.\n */\n const getRowKey = (record: T, index: number): string | number => {\n if (typeof rowKey === \"function\") {\n return rowKey(record);\n }\n return (record[rowKey] as string | number | undefined) ?? index;\n };\n\n const isRowDisabled = (record: T): boolean =>\n selection?.getCheckboxProps?.(record).disabled === true;\n\n /**\n * The rows on this page that a checkbox can actually act on.\n *\n * Everything below is expressed in terms of these rather than in terms of\n * `data.length` or `selectedRowKeys.length`. Selection is a list of keys that\n * may name records on other pages, so comparing its length to the number of\n * visible rows answered a question nobody asked: with two rows on screen and\n * two rows selected elsewhere, \"select all\" showed as checked.\n */\n const selectableKeys = selection\n ? data\n .map((record, index) => ({ record, key: getRowKey(record, index) }))\n .filter(({ record }) => !isRowDisabled(record))\n .map(({ key }) => key)\n : [];\n\n /**\n * The records behind a set of keys, as far as this page can tell.\n *\n * A key belonging to another page cannot be resolved here, because the\n * component has only been given the current page. The keys are the complete\n * answer; the records are the subset that is on screen. Documented on the prop,\n * because a consumer paginating server-side has to keep its own map.\n */\n const recordsForKeys = (keys: (string | number)[]): T[] =>\n data.filter((record, index) => keys.includes(getRowKey(record, index)));\n\n const isRowSelected = (record: T, index: number): boolean => {\n if (!selection) return false;\n const key = getRowKey(record, index);\n return selection.selectedRowKeys.includes(key);\n };\n\n const handleRowSelection = (\n record: T,\n index: number,\n checked: boolean,\n ): void => {\n if (!selection || isRowDisabled(record)) return;\n\n const key = getRowKey(record, index);\n const newSelectedKeys = checked\n ? selection.selectedRowKeys.includes(key)\n ? selection.selectedRowKeys\n : [...selection.selectedRowKeys, key]\n : selection.selectedRowKeys.filter((k) => k !== key);\n\n selection.onChange(newSelectedKeys, recordsForKeys(newSelectedKeys));\n };\n\n /**\n * Adds or removes this page's selectable rows, and leaves every other key\n * alone.\n *\n * It used to replace the whole selection with either every visible key or\n * nothing, so paging through a table and pressing select-all on the second page\n * silently discarded the first page's selection - and it included rows the\n * consumer had disabled.\n */\n const handleSelectAll = (checked: boolean) => {\n if (!selection) return;\n\n const others = selection.selectedRowKeys.filter(\n (key) => !selectableKeys.includes(key),\n );\n const newSelectedKeys = checked ? [...others, ...selectableKeys] : others;\n\n selection.onChange(newSelectedKeys, recordsForKeys(newSelectedKeys));\n };\n\n const selectedOnPage = selectableKeys.filter((key) =>\n selection?.selectedRowKeys.includes(key),\n );\n\n const isAllSelected =\n selection &&\n selectableKeys.length > 0 &&\n selectedOnPage.length === selectableKeys.length;\n\n const isIndeterminate =\n selection &&\n selectedOnPage.length > 0 &&\n selectedOnPage.length < selectableKeys.length;\n\n return (\n <div className=\"w-full overflow-x-auto\">\n <div className=\"min-w-full\">\n <table\n ref={ref}\n className={cn(tableVariants({ variant, size }), className)}\n {...props}\n >\n {caption && <caption className=\"sr-only\">{caption}</caption>}\n <TableHeader>\n <TableRow>\n {selection && (\n <th\n className={cn(tableCellVariants({ variant, size }))}\n scope=\"col\"\n role=\"columnheader\"\n >\n <input\n type=\"checkbox\"\n checked={isAllSelected}\n ref={(input) => {\n if (input) input.indeterminate = isIndeterminate || false;\n }}\n onChange={(e) => handleSelectAll(e.target.checked)}\n className=\"rounded border-input text-primary focus:ring-ring\"\n aria-label=\"Select all rows\"\n />\n </th>\n )}\n {columns.map((column) => (\n <th\n key={column.key}\n className={cn(\n tableCellVariants({ variant, size }),\n column.className,\n column.align === \"center\" && \"text-center\",\n column.align === \"right\" && \"text-right\",\n )}\n scope=\"col\"\n role=\"columnheader\"\n {...(column.width && { style: { width: column.width } })}\n >\n <div className=\"flex items-center gap-2\">\n <span>{column.title}</span>\n {column.sortable && (\n <button\n type=\"button\"\n onClick={() => handleSort(column)}\n className=\"flex flex-col text-muted-foreground hover:text-foreground\"\n aria-label={`Sort by ${column.title}`}\n >\n <svg\n className={cn(\n \"w-3 h-3\",\n sortState?.column === column.key &&\n sortState?.direction === \"asc\"\n ? \"text-primary\"\n : \"text-muted-foreground\",\n )}\n fill=\"currentColor\"\n viewBox=\"0 0 20 20\"\n >\n <path d=\"M5 8l5-5 5 5H5z\" />\n </svg>\n <svg\n className={cn(\n \"w-3 h-3 -mt-1\",\n sortState?.column === column.key &&\n sortState?.direction === \"desc\"\n ? \"text-primary\"\n : \"text-muted-foreground\",\n )}\n fill=\"currentColor\"\n viewBox=\"0 0 20 20\"\n >\n <path d=\"M5 12l5 5 5-5H5z\" />\n </svg>\n </button>\n )}\n </div>\n </th>\n ))}\n </TableRow>\n </TableHeader>\n <TableBody>\n {loading ? (\n <TableRow>\n <TableCell\n colSpan={columns.length + (selection ? 1 : 0)}\n variant={variant}\n size={size}\n className=\"text-center py-8\"\n >\n <div className=\"flex items-center justify-center gap-2\">\n <div className=\"animate-spin rounded-full h-4 w-4 border-b-2 border-primary\"></div>\n <span>Loading...</span>\n </div>\n </TableCell>\n </TableRow>\n ) : data.length === 0 ? (\n <TableRow>\n <TableCell\n colSpan={columns.length + (selection ? 1 : 0)}\n variant={variant}\n size={size}\n className=\"text-center py-8 text-muted-foreground\"\n >\n {emptyText}\n </TableCell>\n </TableRow>\n ) : (\n data.map((record, index) => (\n <TableRow\n key={getRowKey(record, index)}\n variant={variant}\n onClick={() => onRowClick?.(record, index)}\n selected={isRowSelected(record, index)}\n >\n {selection && (\n <TableCell variant={variant} size={size}>\n <input\n type=\"checkbox\"\n checked={isRowSelected(record, index)}\n onChange={(e) =>\n handleRowSelection(record, index, e.target.checked)\n }\n className=\"rounded border-input text-primary focus:ring-ring\"\n aria-label={`Select row ${index + 1}`}\n {...selection.getCheckboxProps?.(record)}\n />\n </TableCell>\n )}\n {columns.map((column) => (\n <TableCell\n key={column.key}\n variant={variant}\n size={size}\n className={cn(\n column.className,\n column.align === \"center\" && \"text-center\",\n column.align === \"right\" && \"text-right\",\n )}\n >\n {column.render\n ? column.render(\n column.dataIndex\n ? record[column.dataIndex]\n : record,\n record,\n index,\n )\n : column.dataIndex\n ? (record[column.dataIndex] as React.ReactNode)\n : ((record as Record<string, unknown>)[\n column.key\n ] as React.ReactNode)}\n </TableCell>\n ))}\n </TableRow>\n ))\n )}\n </TableBody>\n </table>\n </div>\n\n {pagination && (\n <div className=\"flex flex-col sm:flex-row items-center justify-between mt-4 px-2 sm:px-4 py-3 bg-card border-t border-border gap-2 sm:gap-0\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-sm text-muted-foreground\">\n Showing {(pagination.current - 1) * pagination.pageSize + 1} to{\" \"}\n {Math.min(\n pagination.current * pagination.pageSize,\n pagination.total,\n )}{\" \"}\n of {pagination.total} results\n </span>\n </div>\n\n <div className=\"flex items-center gap-2\">\n {pagination.showSizeChanger && (\n <select\n value={pagination.pageSize}\n onChange={(e) => pagination.onChange(1, Number(e.target.value))}\n className=\"rounded border-input bg-background text-sm\"\n aria-label=\"Select page size\"\n >\n <option value={10}>10 / page</option>\n <option value={20}>20 / page</option>\n <option value={50}>50 / page</option>\n <option value={100}>100 / page</option>\n </select>\n )}\n\n <div className=\"flex items-center gap-1\">\n <button\n type=\"button\"\n onClick={() =>\n pagination.onChange(\n pagination.current - 1,\n pagination.pageSize,\n )\n }\n disabled={pagination.current <= 1}\n className=\"px-3 py-1 text-sm border border-input rounded hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed\"\n aria-label=\"Go to previous page\"\n >\n Previous\n </button>\n\n <span className=\"px-3 py-1 text-sm\">\n Page {pagination.current} of{\" \"}\n {Math.ceil(pagination.total / pagination.pageSize)}\n </span>\n\n <button\n type=\"button\"\n onClick={() =>\n pagination.onChange(\n pagination.current + 1,\n pagination.pageSize,\n )\n }\n disabled={\n pagination.current >=\n Math.ceil(pagination.total / pagination.pageSize)\n }\n className=\"px-3 py-1 text-sm border border-input rounded hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed\"\n aria-label=\"Go to next page\"\n >\n Next\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n );\n}\n\nconst TableForwardRef = React.forwardRef(TableComponent) as <\n T extends Record<string, unknown> = Record<string, unknown>,\n>(\n props: TableProps<T> & { ref?: React.Ref<HTMLTableElement> },\n) => React.ReactElement;\n\n(\n TableForwardRef as React.ComponentType<TableProps<unknown>> & {\n displayName?: string;\n }\n).displayName = \"Table\";\n\nexport const Table = TableForwardRef;\n\nexport const TableHeader = React.forwardRef<\n HTMLTableSectionElement,\n TableHeaderProps\n>(({ className, variant, size, children, ...props }, ref) => (\n <thead\n ref={ref}\n className={cn(tableHeaderVariants({ variant, size }), className)}\n {...props}\n >\n {children}\n </thead>\n));\n\nTableHeader.displayName = \"TableHeader\";\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, children, ...props }, ref) => (\n <tbody ref={ref} className={cn(className)} {...props}>\n {children}\n </tbody>\n));\n\nTableBody.displayName = \"TableBody\";\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n ({ className, children, onClick, selected, variant, ...props }, ref) => (\n <tr\n ref={ref}\n className={cn(\n tableRowVariants({ variant }),\n selected && \"bg-primary/10\",\n onClick && \"cursor-pointer\",\n className,\n )}\n onClick={onClick}\n {...props}\n >\n {children}\n </tr>\n ),\n);\n\nTableRow.displayName = \"TableRow\";\n\nexport const TableCell = React.forwardRef<HTMLTableCellElement, TableCellProps>(\n ({ className, children, variant, size, colSpan, rowSpan, ...props }, ref) => (\n <td\n ref={ref}\n className={cn(tableCellVariants({ variant, size }), className)}\n colSpan={colSpan}\n rowSpan={rowSpan}\n {...props}\n >\n {children}\n </td>\n ),\n);\n\nTableCell.displayName = \"TableCell\";\n\nexport const TableHead = React.forwardRef<HTMLTableCellElement, TableCellProps>(\n ({ className, children, variant, size, colSpan, rowSpan, ...props }, ref) => (\n <th\n ref={ref}\n className={cn(\n tableCellVariants({ variant, size }),\n \"font-medium\",\n className,\n )}\n colSpan={colSpan}\n rowSpan={rowSpan}\n {...props}\n >\n {children}\n </th>\n ),\n);\n\nTableHead.displayName = \"TableHead\";\n\n// Export variants for external use\nexport { tableVariants, tableHeaderVariants, tableCellVariants };\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var chunkUC577SR4_cjs=require('./chunk-UC577SR4.cjs'),chunkFUENXWR7_cjs=require('./chunk-FUENXWR7.cjs'),chunk7SPPGTBT_cjs=require('./chunk-7SPPGTBT.cjs'),chunkITRGJNWL_cjs=require('./chunk-ITRGJNWL.cjs'),t=require('react'),classVarianceAuthority=require('class-variance-authority');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var t__default=/*#__PURE__*/_interopDefault(t);function se(o){return typeof o=="boolean"?o:typeof o=="string"?o!=="false"&&o!=="":!!o}function ie(o){return o==null?"":String(o)}var Ie=classVarianceAuthority.cva("flex flex-wrap items-center gap-2 p-4 bg-muted border-b border-border",{variants:{variant:{default:"bg-muted",compact:"p-2 bg-card",minimal:"p-2 bg-transparent border-0"}},defaultVariants:{variant:"default"}});function ue({data:o,columns:C,searchable:D=true,searchPlaceholder:le="Search...",searchKeys:j,onSearch:P,searchTerm:E,onSearchTermChange:K,filterable:T=false,manualSearch:Y=false,manualFiltering:_=false,manualSorting:q=false,filters:b=[],onFilter:V,columnFilters:G,onColumnFiltersChange:H,defaultSortColumn:de,defaultSortDirection:ce="asc",sortColumn:J,sortDirection:ge,onSortChange:Q,defaultPageSize:me=10,showPagination:y=true,currentPage:U,pageSize:W,onPageChange:X,onPageSizeChange:z,totalItems:i,showSearch:Z=true,showFilters:R=true,filterBarClassName:fe,searchBarClassName:pe,rowKey:be="id",emptyText:ye="No data found",...he}){let B=E!==void 0,$=G!==void 0,w=J!==void 0,a=U!==void 0,[ke,xe]=t.useState(""),m=B?E:ke,ee=t.useMemo(()=>B?e=>K?.(e):xe,[B,K]),[Ce,ve]=t.useState({}),c=$?G:Ce,M=t.useMemo(()=>$?e=>H?.(e):ve,[$,H]),[Se,Te]=t.useState(de),[we,Ne]=t.useState(ce),v=w?J:Se,A=w?ge:we,ne=Te,re=Ne,[Fe,De]=t.useState(1),[Pe,Ve]=t.useState(me),f=a?U:Fe,s=W!==void 0?W:Pe,p=t.useMemo(()=>a?e=>X?.(e):De,[a,X]),te=t.useMemo(()=>z?e=>z(e):Ve,[z]),h=t.useMemo(()=>{if(Y||!D||!m.trim())return o;let e=m.toLowerCase(),r=j||C.map(n=>n.dataIndex||n.key).filter(Boolean);return o.filter(n=>r.some(u=>{let l=n[u];return l==null?false:String(l).toLowerCase().includes(e)}))},[o,m,D,j,C,Y]),k=t.useMemo(()=>_||!T||b.length===0||Object.keys(c).length===0?h:h.filter(e=>b.every(r=>{let n=c[r.key];if(n==null||n==="")return true;if(r.filterFn)return r.filterFn(n,e);let u=e[r.key];switch(r.type){case "text":return String(u).toLowerCase().includes(String(n).toLowerCase());case "number":{let l=Number(n);return Number.isNaN(l)?true:Number(u)===l}case "boolean":return !!u===se(n);case "select":return String(u)===String(n);default:return String(u).includes(String(n))}})),[h,c,T,b,_]),d=t.useMemo(()=>{if(q||!v)return k;let e=[...k],r=C.find(n=>n.key===v);return !r||!r.sortable||e.sort((n,u)=>{let l=r.dataIndex?n[r.dataIndex]:n[r.key],S=r.dataIndex?u[r.dataIndex]:u[r.key];if(l==null)return 1;if(S==null)return -1;let N=0;return typeof l=="number"&&typeof S=="number"?N=l-S:N=String(l).localeCompare(String(S)),A==="asc"?N:-N}),e},[k,v,A,C,q]),ze=t.useMemo(()=>{if(!y||a&&i!==void 0)return d;let e=(f-1)*s,r=e+s;return d.slice(e,r)},[d,f,s,y,a,i]);t.useMemo(()=>y?Math.ceil(a&&i!==void 0?i/s:d.length/s):1,[y,a,i,s,d.length]);let Be=t.useCallback(e=>{ee(e),a||p(1);},[ee,p,a]),I=t.useCallback((e,r)=>{let n={...c,[e]:r};M(n),a||p(1);},[c,M,p,a]),$e=t.useCallback((e,r)=>{if(w){Q?.(e.key,r);return}ne(e.key),re(r);},[w,Q,ne,re]),Me=t.useCallback((e,r)=>{p(e),r!==s&&(te(r),p(1));},[s,p,te]);return t__default.default.useEffect(()=>{P&&P(m,h);},[m,h,P]),t__default.default.useEffect(()=>{V&&V(c,k);},[c,k,V]),t__default.default.createElement("div",{className:"w-full"},(Z||R&&T&&b.length>0)&&t__default.default.createElement("div",{className:chunkITRGJNWL_cjs.a(Ie(),fe)},Z&&D&&t__default.default.createElement("div",{className:chunkITRGJNWL_cjs.a("flex-1 min-w-[200px]",pe)},t__default.default.createElement(chunkFUENXWR7_cjs.b,{type:"text",placeholder:le,value:m,onChange:e=>Be(e.target.value),className:"w-full","aria-label":"Search table"})),R&&T&&b.length>0&&t__default.default.createElement("div",{className:"flex flex-wrap items-center gap-2"},b.map(e=>{let r=c[e.key];return e.type==="boolean"?t__default.default.createElement("select",{key:e.key,value:r==null?"":se(r)?"true":"false",onChange:n=>I(e.key,n.target.value===""?void 0:n.target.value==="true"),className:"rounded-md border border-input px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:border-primary","aria-label":`Filter by ${e.key}`},t__default.default.createElement("option",{value:""},"All ",e.key),t__default.default.createElement("option",{value:"true"},e.placeholder?`${e.placeholder}: yes`:"Yes"),t__default.default.createElement("option",{value:"false"},e.placeholder?`${e.placeholder}: no`:"No")):e.type==="select"&&e.options?t__default.default.createElement("select",{key:e.key,value:ie(r),onChange:n=>I(e.key,n.target.value||void 0),className:"rounded-md border border-input px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:border-primary","aria-label":`Filter by ${e.key}`},t__default.default.createElement("option",{value:""},"All ",e.key),e.options.map(n=>t__default.default.createElement("option",{key:n.value,value:String(n.value)},n.label))):t__default.default.createElement(chunkFUENXWR7_cjs.b,{key:e.key,type:e.type==="number"?"number":"text",placeholder:e.placeholder||`Filter ${e.key}...`,value:ie(r),onChange:n=>I(e.key,n.target.value===""?void 0:e.type==="number"?Number(n.target.value):n.target.value),className:"min-w-[150px]","aria-label":`Filter by ${e.key}`})}),Object.keys(c).length>0&&t__default.default.createElement("button",{type:"button",onClick:()=>M({}),className:"px-3 py-2 text-sm text-muted-foreground hover:text-foreground underline","aria-label":"Clear all filters"},"Clear filters"))),t__default.default.createElement(chunkUC577SR4_cjs.d,{...he,data:ze,columns:C,rowKey:be,emptyText:ye,...v&&{sortColumn:v,sortDirection:A},onSort:$e,...y&&{pagination:{current:f,pageSize:s,total:a&&i!==void 0?i:d.length,onChange:Me,showSizeChanger:true}}}),y&&(a&&i!==void 0?i>0:d.length>0)&&t__default.default.createElement("div",{className:"mt-2 px-4 py-2 text-sm text-muted-foreground"},a&&i!==void 0?t__default.default.createElement(t__default.default.Fragment,null,"Showing ",(f-1)*s+1," to"," ",Math.min(f*s,i)," of ",i," ","results",m&&" (filtered)"):t__default.default.createElement(t__default.default.Fragment,null,"Showing ",(f-1)*s+1," to"," ",Math.min(f*s,d.length)," of"," ",d.length," results",m&&` (filtered from ${o.length} total)`)))}ue.displayName="DataTable";var He=chunk7SPPGTBT_cjs.a(ue);exports.a=ue;exports.b=He;//# sourceMappingURL=chunk-KASVYULP.cjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-KASVYULP.cjs.map
|