@mortenbrudvik/waveui 0.8.0 → 0.9.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/README.md +231 -85
- package/dist/components/data-display/InfoButton.cjs +2 -0
- package/dist/components/data-display/InfoButton.cjs.map +1 -0
- package/dist/components/data-display/InfoButton.mjs +173 -0
- package/dist/components/data-display/InfoButton.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +39 -96
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/input/Checkbox.cjs +1 -1
- package/dist/components/input/Checkbox.cjs.map +1 -1
- package/dist/components/input/Checkbox.mjs +91 -75
- package/dist/components/input/Checkbox.mjs.map +1 -1
- package/dist/components/input/ColorPicker.parts.cjs +1 -1
- package/dist/components/input/ColorPicker.parts.cjs.map +1 -1
- package/dist/components/input/ColorPicker.parts.mjs +1 -1
- package/dist/components/input/ColorPicker.parts.mjs.map +1 -1
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.cjs +1 -1
- package/dist/components/input/Combobox.expand.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.mjs +20 -20
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +143 -138
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +213 -209
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +80 -74
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Field.cjs +1 -1
- package/dist/components/input/Field.cjs.map +1 -1
- package/dist/components/input/Field.mjs +99 -66
- package/dist/components/input/Field.mjs.map +1 -1
- package/dist/components/input/Input.cjs +1 -1
- package/dist/components/input/Input.cjs.map +1 -1
- package/dist/components/input/Input.mjs +79 -55
- package/dist/components/input/Input.mjs.map +1 -1
- package/dist/components/input/Label.cjs +1 -1
- package/dist/components/input/Label.cjs.map +1 -1
- package/dist/components/input/Label.mjs +19 -13
- package/dist/components/input/Label.mjs.map +1 -1
- package/dist/components/input/Rating.cjs +1 -1
- package/dist/components/input/Rating.cjs.map +1 -1
- package/dist/components/input/Rating.item.cjs +2 -0
- package/dist/components/input/Rating.item.cjs.map +1 -0
- package/dist/components/input/Rating.item.mjs +255 -0
- package/dist/components/input/Rating.item.mjs.map +1 -0
- package/dist/components/input/Rating.mjs +150 -151
- package/dist/components/input/Rating.mjs.map +1 -1
- package/dist/components/input/SearchBox.cjs +1 -1
- package/dist/components/input/SearchBox.cjs.map +1 -1
- package/dist/components/input/SearchBox.mjs +146 -115
- package/dist/components/input/SearchBox.mjs.map +1 -1
- package/dist/components/input/Select.cjs +1 -1
- package/dist/components/input/Select.cjs.map +1 -1
- package/dist/components/input/Select.mjs +34 -25
- package/dist/components/input/Select.mjs.map +1 -1
- package/dist/components/input/Slider.cjs +1 -1
- package/dist/components/input/Slider.cjs.map +1 -1
- package/dist/components/input/Slider.mjs +77 -54
- package/dist/components/input/Slider.mjs.map +1 -1
- package/dist/components/input/SpinButton.cjs +1 -1
- package/dist/components/input/SpinButton.cjs.map +1 -1
- package/dist/components/input/SpinButton.mjs +198 -96
- package/dist/components/input/SpinButton.mjs.map +1 -1
- package/dist/components/input/Switch.cjs +1 -1
- package/dist/components/input/Switch.cjs.map +1 -1
- package/dist/components/input/Switch.mjs +71 -55
- package/dist/components/input/Switch.mjs.map +1 -1
- package/dist/components/input/TagPicker.cjs +1 -1
- package/dist/components/input/TagPicker.cjs.map +1 -1
- package/dist/components/input/TagPicker.mjs +142 -116
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/Textarea.cjs +1 -1
- package/dist/components/input/Textarea.cjs.map +1 -1
- package/dist/components/input/Textarea.mjs +28 -21
- package/dist/components/input/Textarea.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +189 -184
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/input/fieldLabel.cjs +2 -0
- package/dist/components/input/fieldLabel.cjs.map +1 -0
- package/dist/components/input/fieldLabel.mjs +17 -0
- package/dist/components/input/fieldLabel.mjs.map +1 -0
- package/dist/components/input/inputLook.cjs +2 -0
- package/dist/components/input/inputLook.cjs.map +1 -0
- package/dist/components/input/inputLook.mjs +28 -0
- package/dist/components/input/inputLook.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +1 -1
- package/dist/components/input/pickerStyles.cjs.map +1 -1
- package/dist/components/input/pickerStyles.mjs +42 -4
- package/dist/components/input/pickerStyles.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +10 -10
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +10 -10
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +203 -208
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/Popover.shared.cjs +1 -1
- package/dist/components/overlays/Popover.shared.cjs.map +1 -1
- package/dist/components/overlays/Popover.shared.mjs +82 -77
- package/dist/components/overlays/Popover.shared.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +25 -19
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/hooks/useFieldControl.cjs.map +1 -1
- package/dist/hooks/useFieldControl.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +805 -99
- package/dist/index.d.ts +805 -99
- package/dist/index.mjs +101 -99
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +74 -66
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/styles.cjs +1 -1
- package/dist/lib/styles.cjs.map +1 -1
- package/dist/lib/styles.mjs +21 -4
- package/dist/lib/styles.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +13 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useControllable.cjs"),o=require("../../hooks/useId.cjs"),ee=require("../../lib/direction.cjs"),te=require("../../lib/focus.cjs"),ne=require("../../hooks/useMergedRefs.cjs"),re=require("../../hooks/useIsClient.cjs"),s=require("../../lib/aria.cjs"),ie=require("../../hooks/useFieldControl.cjs"),ae=require("../../hooks/useDismiss.cjs"),oe=require("../portal/Portal.cjs"),c=require("../../lib/styles.cjs"),l=require("../../lib/icons.cjs"),se=require("./Input.cjs"),ce=require("../../hooks/useFormReset.cjs"),le=require("../internal/HiddenInput.cjs"),ue=require("../../hooks/usePopupPosition.cjs"),u=require("./dateUtils.cjs"),de=require("../../hooks/useFocusTrap.cjs"),fe=require("../../hooks/useRestoreFocus.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime"),pe=require("react-dom");var me=e=>e?`Enter a date in the format ${e}.`:`Enter a valid date.`,he=(e,t)=>e!==void 0&&t!==void 0?`Enter a date between ${e} and ${t}.`:e===void 0?`Enter a date on or before ${t}.`:`Enter a date on or after ${e}.`,ge=`absolute flex h-6 w-6 items-center justify-center rounded bg-transparent p-0 text-muted-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:hover:text-foreground`,_e=`flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`,ve=`flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-caption-1 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover data-[outside]:text-muted-foreground data-[today]:border data-[today]:border-primary data-[today]:font-semibold data-[selected]:bg-primary data-[selected]:font-semibold data-[selected]:text-primary-foreground not-disabled:not-aria-disabled:data-[selected]:hover:bg-primary-hover aria-disabled:line-through`;function ye(e){let t=[];for(let n=0;n<e.length;n+=7)t.push(e.slice(n,n+7));return t}var p=e=>{let{value:p,defaultValue:be,onValueChange:xe,onChange:Se,formatDate:m,parseDate:h,locale:g,minDate:_,maxDate:v,disabledDates:Ce,placeholder:we=`Select a date`,disabled:y=!1,readOnly:b,clearable:Te=!1,firstDayOfWeek:x=0,open:Ee,defaultOpen:De,onOpenChange:Oe,onInvalidInput:ke,labels:S,name:Ae,form:je,required:Me,autoComplete:Ne=`off`,autoCapitalize:Pe,autoCorrect:Fe,enterKeyHint:Ie,inputMode:Le,spellCheck:Re,autoFocus:ze,tabIndex:Be,id:Ve,"aria-label":He,"aria-labelledby":Ue,"aria-describedby":We,"aria-invalid":Ge,"aria-required":Ke,"aria-errormessage":qe,"aria-details":Je,onFocus:Ye,onBlur:Xe,onKeyDown:Ze,onKeyUp:Qe,controlRef:$e,className:et,ref:tt,...nt}=e;Se!==void 0&&n.warnDeprecated(`DatePicker`,`onChange`,`onValueChange`);let rt=m!==void 0,C=h!==void 0;d.useEffect(()=>{rt&&!C&&n.warnOnce(`DatePicker:formatDate-without-parseDate`,"DatePicker: `formatDate` is set without `parseDate`. Typed dates are parsed with the default parser for `locale` (its numeric format or yyyy-mm-dd), which may not read your format; pass `parseDate` as the inverse of `formatDate`.")},[rt,C]),d.useEffect(()=>{g!==void 0&&!u.isValidLocaleTag(g)&&n.warnOnce(`DatePicker:invalid-locale:${g}`,`DatePicker: \`locale\` "${g}" is not a valid BCP 47 language tag (use hyphens, as in "en-US"). The runtime default locale formats and parses the dates instead, so the server and the browser may render different text.`)},[g]);let[w,it]=a.useControllable(p,be??null,e=>{xe?.(e),Se?.(e)}),T=!y&&!b,[E,D]=a.useControllable(Ee,(De??!1)&&T,Oe),at=re.useIsClient(),O=E&&T&&at,ot=Ee!==void 0;d.useEffect(()=>{!T&&E&&!ot&&D(!1)},[T,E,ot,D]);let k=e=>m?m(e):u.formatDate(e,g),st=e=>h?h(e):u.parseDate(e,g),[A,j]=d.useState(null),[M,N]=d.useState(null),[ct,lt]=d.useState(T);ct!==T&&(lt(T),T||(j(null),N(null)));let P=w?u.formatISODate(w):``,[ut,dt]=d.useState(P);ut!==P&&(dt(P),M!==null&&(j(null),N(null)));let ft=e=>!u.isDateInRange(e,_,v)||!!Ce?.(u.startOfDay(e)),F=e=>{let t=e?u.startOfDay(e):null;(t?u.isSameDay(t,w):w===null)||it(t),j(null),N(null)},I=e=>{if(!e.trim())return F(null),!0;let t=st(e),n=null;if(!t||Number.isNaN(t.getTime())?n=`unparseable`:u.isDateInRange(t,_,v)?Ce?.(u.startOfDay(t))&&(n=`disabled`):n=`out-of-range`,n||!t){let t=n??`unparseable`;return N(t),ke?.(e,t),!1}return F(t),!0},L=u.startOfDay(new Date),pt=()=>u.startOfMonth(u.clampDate(w??L,_,v)),[R,z]=d.useState(pt),[mt,B]=d.useState(null),[V,H]=d.useState(!1),[ht,gt]=d.useState(O);ht!==O&&(gt(O),O&&(z(pt()),B(null))),V&&!O&&H(!1);let U=d.useMemo(()=>ye(u.getCalendarDays(R,x)),[R,x]),W=e=>!!e&&u.isSameMonth(e,R),_t=e=>!!e&&e>=U[0][0]&&e<=U[U.length-1][6],vt=u.clampDate(L,_,v),yt=u.clampDate(R,_,v),G=_t(mt)?mt:W(w)?u.startOfDay(w):W(vt)?vt:W(yt)?yt:R,K=u.formatISODate(G),bt=e=>{let t=u.clampDate(e,_,v);B(t),u.isSameMonth(t,R)||z(u.startOfMonth(t))},xt=e=>{let t=u.addMonths(R,e),n=u.clampDate(u.addMonths(G,e),_,v);z(t),B(u.isSameMonth(n,t)?n:null)},St=e=>{u.isSameDay(e,G)||B(e)},Ct=!!_&&u.addDays(R,-1)<u.startOfDay(_),wt=!!v&&u.addMonths(R,1)>u.startOfDay(v),Tt=d.useMemo(()=>u.getWeekdayNames(g,x),[g,x]),q=d.useRef(null),J=d.useRef(null),Y=d.useRef(null),Et=d.useRef(null),X=d.useRef(null),[Dt,Ot]=d.useState(null),kt=ne.useMergedRefs($e,q),At=o.useId(`datepicker-dialog`),Z=o.useId(`datepicker-heading`),Q=o.useId(`datepicker-grid`),jt=o.useId(`datepicker-error`),Mt=e=>{X.current=e,D(!1)},{layerId:Nt}=ae.useDismiss({open:O,onDismiss:(e,t)=>{let n=e===`outside-press`&&t.target instanceof Element?t.target.closest(te.FOCUSABLE_SELECTOR):null;Mt(n??(V?q.current:null))},refs:[Et,J],anchorRef:J,kind:`modal`}),{setReference:Pt,setFloating:Ft,floatingProps:It}=ue.usePopupPosition({open:O,side:`bottom`,align:`start`}),Lt=ne.useMergedRefs(Et,Ot,Ft);de.useFocusTrap(Dt,{enabled:O,layerId:Nt,initialFocus:()=>Y.current?.querySelector(`button[tabindex="0"]`)??null}),fe.useRestoreFocus({enabled:O,container:Dt,triggerRef:J,finalFocusRef:X,onlyIfFocusInside:!0}),d.useLayoutEffect(()=>{O&&(X.current=null)},[O]),d.useLayoutEffect(()=>{let e=Y.current;if(!e)return;let t=e.ownerDocument.activeElement;if(!t||!e.contains(t))return;let n=e.querySelector(`button[data-date="${K}"]`);n&&n!==t&&n.focus()},[K]);let Rt=ie.useFieldContext(),zt=(Me??Rt?.required??!1)&&!b,Bt=M!==null&&!Rt?.hasErrorMessage,Vt=ie.useFieldControl({id:Ve,"aria-label":He,"aria-labelledby":Ue,"aria-describedby":s.joinIds(We,Bt?jt:void 0),"aria-invalid":M!==null||Ge,"aria-required":Ke??Me}),Ht=se.isInvalidLook(!1,Vt[`aria-invalid`]);ce.useFormReset(q,()=>F(be??null),je);let Ut=Te&&!b&&w!==null,Wt=e=>{T&&(j(e.target.value),N(null))},Gt=r.composeEventHandlers(Ze,e=>{T&&!e.nativeEvent.isComposing&&(e.key===`Enter`&&A!==null?(e.preventDefault(),I(A)):e.key===`Tab`&&!e.shiftKey&&Ut&&A!==null&&!A.trim()?(0,pe.flushSync)(()=>I(A)):e.key===`ArrowDown`&&e.altKey&&!O&&(e.preventDefault(),A!==null&&M===null&&I(A),H(!0),D(!0)))}),Kt=r.composeEventHandlers(Xe,()=>{T&&A!==null&&M===null&&I(A)}),qt=()=>{T&&(X.current=null,H(!1),D(!O))},Jt=()=>{T&&(F(null),q.current?.focus())},Yt=e=>{e.preventDefault()},Xt=e=>{T&&!ft(e)&&(F(e),Mt(q.current))},Zt=e=>{e.key!==`Escape`||e.defaultPrevented||e.nativeEvent.isComposing||(e.preventDefault(),Mt(V?q.current:null))},Qt=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=(G.getDay()-x+7)%7,n;switch(e.key){case`ArrowLeft`:case`ArrowRight`:{let t=ee.getArrowIntent(e.key,{orientation:`horizontal`,dir:ee.getDirection(e.currentTarget)});n=u.addDays(G,t===`next`?1:-1);break}case`ArrowDown`:n=u.addDays(G,7);break;case`ArrowUp`:n=u.addDays(G,-7);break;case`PageDown`:n=u.addMonths(G,e.shiftKey?12:1);break;case`PageUp`:n=u.addMonths(G,e.shiftKey?-12:-1);break;case`Home`:n=u.addDays(G,-t);break;case`End`:n=u.addDays(G,6-t);break;default:return}e.preventDefault(),bt(n)},$t=A??(w?k(w):``),$=``;return M===`unparseable`?$=(S?.invalidDate??me)(C?void 0:u.getLocaleDateFormat(g).pattern):M===`out-of-range`&&(_||v)?$=(S?.outOfRange??he)(_?k(u.startOfDay(_)):void 0,v?k(u.startOfDay(v)):void 0):M===`disabled`&&($=S?.unavailableDate??`This date is not available.`),(0,f.jsxs)(`div`,{...nt,ref:tt,className:t.cn(i.datePickerClassNames.root,`relative inline-flex flex-col`,et),children:[(0,f.jsxs)(`div`,{ref:Pt,className:`relative flex items-center`,children:[(0,f.jsx)(`input`,{ref:kt,type:`text`,...Vt,"aria-errormessage":qe,"aria-details":Je,value:$t,onChange:Wt,onFocus:Ye,onBlur:Kt,onKeyDown:Gt,onKeyUp:Qe,placeholder:we,disabled:y,readOnly:b,autoComplete:Ne,autoCapitalize:Pe,autoCorrect:Fe,enterKeyHint:Ie,inputMode:Le,spellCheck:Re,autoFocus:ze,tabIndex:Be,className:t.cn(i.datePickerClassNames.input,c.inputBase,`border-b-stroke-accessible`,c.inputFocus,c.disabledStyles,Ht&&`border-destructive focus:border-b-destructive`,Ut?`pe-14`:`pe-8`)}),Ut&&(0,f.jsx)(`button`,{type:`button`,"aria-label":S?.clear??`Clear date`,disabled:y,onMouseDown:Yt,onClick:Jt,className:t.cn(i.datePickerClassNames.clearButton,ge,`end-7`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,`disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`),children:(0,f.jsx)(l.DismissIcon,{})}),(0,f.jsx)(`button`,{ref:J,type:`button`,"aria-label":S?.openCalendar??`Open calendar`,"aria-haspopup":`dialog`,"aria-expanded":O,"aria-controls":O?At:void 0,disabled:y||b,onClick:qt,className:t.cn(i.datePickerClassNames.openCalendarButton,ge,`end-1`,c.focusRing,c.disabledStyles),children:(0,f.jsx)(l.CalendarIcon,{})})]}),Bt&&(0,f.jsx)(`p`,{id:jt,role:`alert`,className:t.cn(i.datePickerClassNames.errorMessage,`mt-1 text-caption-1 text-error`),children:$}),(0,f.jsx)(le.HiddenInput,{name:Ae,form:je,disabled:y,value:w?u.formatISODate(w):``,type:`text`,required:zt,onInvalid:()=>q.current?.focus()}),O&&(0,f.jsx)(oe.Portal,{layerId:Nt,children:(0,f.jsxs)(`div`,{ref:Lt,id:At,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Z,...It,"data-state":`open`,onKeyDown:Zt,className:t.cn(i.datePickerClassNames.surface,`rounded-md border border-border bg-background p-3 text-foreground shadow-16`),children:[(0,f.jsxs)(`div`,{className:t.cn(i.datePickerClassNames.header,`mb-2 flex items-center justify-between gap-2`),children:[(0,f.jsx)(`button`,{type:`button`,"aria-label":S?.previousMonth??`Previous month`,"aria-controls":Q,...s.focusableDisabledProps(Ct),onClick:s.preventIfDisabled(Ct,()=>xt(-1)),className:t.cn(i.datePickerClassNames.previousMonthButton,_e,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,`disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`),children:(0,f.jsx)(l.ChevronLeftIcon,{className:`wave-rtl:-scale-x-100`})}),(0,f.jsx)(`h2`,{id:Z,"aria-live":`polite`,className:t.cn(i.datePickerClassNames.heading,`text-body-1 font-semibold`),children:u.formatMonthYear(R,g)}),(0,f.jsx)(`button`,{type:`button`,"aria-label":S?.nextMonth??`Next month`,"aria-controls":Q,...s.focusableDisabledProps(wt),onClick:s.preventIfDisabled(wt,()=>xt(1)),className:t.cn(i.datePickerClassNames.nextMonthButton,_e,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,`disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`),children:(0,f.jsx)(l.ChevronRightIcon,{className:`wave-rtl:-scale-x-100`})})]}),(0,f.jsxs)(`table`,{ref:Y,id:Q,role:`grid`,"aria-labelledby":Z,onKeyDown:Qt,className:t.cn(i.datePickerClassNames.grid,`border-collapse`),children:[(0,f.jsx)(`thead`,{children:(0,f.jsx)(`tr`,{children:Tt.map(e=>(0,f.jsxs)(`th`,{scope:`col`,abbr:e.long,"aria-label":e.long,className:t.cn(i.datePickerClassNames.weekday,`h-8 w-8 text-center text-caption-1 font-normal text-muted-foreground`),children:[(0,f.jsx)(`span`,{"aria-hidden":`true`,children:e.short}),(0,f.jsx)(`span`,{className:`sr-only`,children:e.long})]},e.long))})}),(0,f.jsx)(`tbody`,{children:U.map((e,n)=>(0,f.jsx)(`tr`,{children:e.map((e,n)=>{let r=u.formatISODate(e),a=u.isSameDay(e,w),o=u.isSameDay(e,L),ee=r===K,te=ft(e);return(0,f.jsx)(`td`,{role:`gridcell`,"aria-selected":a,className:`p-0`,children:(0,f.jsx)(`button`,{type:`button`,tabIndex:ee?0:-1,"aria-label":u.formatDayLabel(e,g),"aria-pressed":a||void 0,"aria-current":o?`date`:void 0,...s.focusableDisabledProps(te),"data-date":r,"data-selected":a?``:void 0,"data-today":o?``:void 0,"data-outside":u.isSameMonth(e,R)?void 0:``,onFocus:()=>St(e),onClick:()=>Xt(e),className:t.cn(i.datePickerClassNames.day,ve,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,`disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`,a&&c.forcedColors.selectedLeaf),children:u.formatDayNumber(e,g)})},n)})},n))})]})]})})]})};p.displayName=`DatePicker`,exports.DatePicker=p;
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useControllable.cjs"),o=require("../../hooks/useId.cjs"),s=require("../../lib/direction.cjs"),ee=require("../../lib/focus.cjs"),te=require("../../hooks/useMergedRefs.cjs"),ne=require("../../hooks/useIsClient.cjs"),c=require("../../lib/aria.cjs"),re=require("../../hooks/useFieldControl.cjs"),ie=require("../../hooks/useDismiss.cjs"),ae=require("../portal/Portal.cjs"),l=require("../../lib/styles.cjs"),u=require("../../lib/icons.cjs"),oe=require("./inputLook.cjs"),se=require("./Input.cjs"),ce=require("../../hooks/useFormReset.cjs"),le=require("../internal/HiddenInput.cjs"),d=require("./pickerStyles.cjs"),ue=require("../../hooks/usePopupPosition.cjs"),f=require("./dateUtils.cjs"),de=require("../../hooks/useFocusTrap.cjs"),fe=require("../../hooks/useRestoreFocus.cjs");let p=require("react");p=e.__toESM(p,1);let m=require("react/jsx-runtime"),pe=require("react-dom");var me=e=>e?`Enter a date in the format ${e}.`:`Enter a valid date.`,he=(e,t)=>e!==void 0&&t!==void 0?`Enter a date between ${e} and ${t}.`:e===void 0?`Enter a date on or before ${t}.`:`Enter a date on or after ${e}.`,ge=`flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`,_e=`flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-caption-1 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover data-[outside]:text-muted-foreground data-[today]:border data-[today]:border-primary data-[today]:font-semibold data-[selected]:bg-primary data-[selected]:font-semibold data-[selected]:text-primary-foreground not-disabled:not-aria-disabled:data-[selected]:hover:bg-primary-hover aria-disabled:line-through`;function ve(e){let t=[];for(let n=0;n<e.length;n+=7)t.push(e.slice(n,n+7));return t}var h=e=>{let{value:h,defaultValue:ye,onValueChange:be,onChange:xe,formatDate:g,parseDate:_,locale:v,minDate:y,maxDate:b,disabledDates:Se,placeholder:Ce=`Select a date`,disabled:x=!1,size:we,appearance:Te,readOnly:S,clearable:Ee=!1,firstDayOfWeek:C=0,open:De,defaultOpen:Oe,onOpenChange:ke,onInvalidInput:Ae,labels:w,name:je,form:Me,required:Ne,autoComplete:Pe=`off`,autoCapitalize:Fe,autoCorrect:Ie,enterKeyHint:Le,inputMode:Re,spellCheck:ze,autoFocus:Be,tabIndex:Ve,id:He,"aria-label":Ue,"aria-labelledby":We,"aria-describedby":Ge,"aria-invalid":Ke,"aria-required":qe,"aria-errormessage":Je,"aria-details":Ye,onFocus:Xe,onBlur:Ze,onKeyDown:Qe,onKeyUp:$e,controlRef:et,className:tt,ref:nt,...rt}=e;xe!==void 0&&n.warnDeprecated(`DatePicker`,`onChange`,`onValueChange`);let{size:T,appearance:E}=oe.useInputLook(we,Te),it=g!==void 0,at=_!==void 0;p.useEffect(()=>{it&&!at&&n.warnOnce(`DatePicker:formatDate-without-parseDate`,"DatePicker: `formatDate` is set without `parseDate`. Typed dates are parsed with the default parser for `locale` (its numeric format or yyyy-mm-dd), which may not read your format; pass `parseDate` as the inverse of `formatDate`.")},[it,at]),p.useEffect(()=>{v!==void 0&&!f.isValidLocaleTag(v)&&n.warnOnce(`DatePicker:invalid-locale:${v}`,`DatePicker: \`locale\` "${v}" is not a valid BCP 47 language tag (use hyphens, as in "en-US"). The runtime default locale formats and parses the dates instead, so the server and the browser may render different text.`)},[v]);let[D,ot]=a.useControllable(h,ye??null,e=>{be?.(e),xe?.(e)}),O=!x&&!S,[k,A]=a.useControllable(De,(Oe??!1)&&O,ke),st=ne.useIsClient(),j=k&&O&&st,ct=De!==void 0;p.useEffect(()=>{!O&&k&&!ct&&A(!1)},[O,k,ct,A]);let M=e=>g?g(e):f.formatDate(e,v),lt=e=>_?_(e):f.parseDate(e,v),[N,P]=p.useState(null),[F,I]=p.useState(null),[ut,dt]=p.useState(O);ut!==O&&(dt(O),O||(P(null),I(null)));let L=D?f.formatISODate(D):``,[ft,pt]=p.useState(L);ft!==L&&(pt(L),F!==null&&(P(null),I(null)));let mt=e=>!f.isDateInRange(e,y,b)||!!Se?.(f.startOfDay(e)),R=e=>{let t=e?f.startOfDay(e):null;(t?f.isSameDay(t,D):D===null)||ot(t),P(null),I(null)},z=e=>{if(!e.trim())return R(null),!0;let t=lt(e),n=null;if(!t||Number.isNaN(t.getTime())?n=`unparseable`:f.isDateInRange(t,y,b)?Se?.(f.startOfDay(t))&&(n=`disabled`):n=`out-of-range`,n||!t){let t=n??`unparseable`;return I(t),Ae?.(e,t),!1}return R(t),!0},B=f.startOfDay(new Date),ht=()=>f.startOfMonth(f.clampDate(D??B,y,b)),[V,H]=p.useState(ht),[gt,U]=p.useState(null),[W,G]=p.useState(!1),[_t,vt]=p.useState(j);_t!==j&&(vt(j),j&&(H(ht()),U(null))),W&&!j&&G(!1);let K=p.useMemo(()=>ve(f.getCalendarDays(V,C)),[V,C]),q=e=>!!e&&f.isSameMonth(e,V),yt=e=>!!e&&e>=K[0][0]&&e<=K[K.length-1][6],bt=f.clampDate(B,y,b),xt=f.clampDate(V,y,b),J=yt(gt)?gt:q(D)?f.startOfDay(D):q(bt)?bt:q(xt)?xt:V,Y=f.formatISODate(J),St=e=>{let t=f.clampDate(e,y,b);U(t),f.isSameMonth(t,V)||H(f.startOfMonth(t))},Ct=e=>{let t=f.addMonths(V,e),n=f.clampDate(f.addMonths(J,e),y,b);H(t),U(f.isSameMonth(n,t)?n:null)},wt=e=>{f.isSameDay(e,J)||U(e)},Tt=!!y&&f.addDays(V,-1)<f.startOfDay(y),Et=!!b&&f.addMonths(V,1)>f.startOfDay(b),Dt=p.useMemo(()=>f.getWeekdayNames(v,C),[v,C]),X=p.useRef(null),Z=p.useRef(null),Ot=p.useRef(null),kt=p.useRef(null),Q=p.useRef(null),[At,jt]=p.useState(null),Mt=te.useMergedRefs(et,X),Nt=o.useId(`datepicker-dialog`),Pt=o.useId(`datepicker-heading`),Ft=o.useId(`datepicker-grid`),It=o.useId(`datepicker-error`),Lt=e=>{Q.current=e,A(!1)},{layerId:Rt}=ie.useDismiss({open:j,onDismiss:(e,t)=>{let n=e===`outside-press`&&t.target instanceof Element?t.target.closest(ee.FOCUSABLE_SELECTOR):null;Lt(n??(W?X.current:null))},refs:[kt,Z],anchorRef:Z,kind:`modal`}),{setReference:zt,setFloating:Bt,floatingProps:Vt}=ue.usePopupPosition({open:j,side:`bottom`,align:`start`}),Ht=te.useMergedRefs(kt,jt,Bt);de.useFocusTrap(At,{enabled:j,layerId:Rt,initialFocus:()=>Ot.current?.querySelector(`button[tabindex="0"]`)??null}),fe.useRestoreFocus({enabled:j,container:At,triggerRef:Z,finalFocusRef:Q,onlyIfFocusInside:!0}),p.useLayoutEffect(()=>{j&&(Q.current=null)},[j]),p.useLayoutEffect(()=>{let e=Ot.current;if(!e)return;let t=e.ownerDocument.activeElement;if(!t||!e.contains(t))return;let n=e.querySelector(`button[data-date="${Y}"]`);n&&n!==t&&n.focus()},[Y]);let Ut=re.useFieldContext(),Wt=(Ne??Ut?.required??!1)&&!S,Gt=F!==null&&!Ut?.hasErrorMessage,Kt=re.useFieldControl({id:He,"aria-label":Ue,"aria-labelledby":We,"aria-describedby":c.joinIds(Ge,Gt?It:void 0),"aria-invalid":F!==null||Ke,"aria-required":qe??Ne}),qt=se.isInvalidLook(!1,Kt[`aria-invalid`]);ce.useFormReset(X,()=>R(ye??null),Me);let Jt=Ee&&!S&&D!==null,Yt=e=>{O&&(P(e.target.value),I(null))},Xt=r.composeEventHandlers(Qe,e=>{O&&!e.nativeEvent.isComposing&&(e.key===`Enter`&&N!==null?(e.preventDefault(),z(N)):e.key===`Tab`&&!e.shiftKey&&Jt&&N!==null&&!N.trim()?(0,pe.flushSync)(()=>z(N)):e.key===`ArrowDown`&&e.altKey&&!j&&(e.preventDefault(),N!==null&&F===null&&z(N),G(!0),A(!0)))}),Zt=r.composeEventHandlers(Ze,()=>{O&&N!==null&&F===null&&z(N)}),Qt=()=>{O&&(Q.current=null,G(!1),A(!j))},$t=()=>{O&&(R(null),X.current?.focus())},en=e=>{e.preventDefault()},tn=e=>{O&&!mt(e)&&(R(e),Lt(X.current))},nn=e=>{e.key!==`Escape`||e.defaultPrevented||e.nativeEvent.isComposing||(e.preventDefault(),Lt(W?X.current:null))},rn=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=(J.getDay()-C+7)%7,n;switch(e.key){case`ArrowLeft`:case`ArrowRight`:{let t=s.getArrowIntent(e.key,{orientation:`horizontal`,dir:s.getDirection(e.currentTarget)});n=f.addDays(J,t===`next`?1:-1);break}case`ArrowDown`:n=f.addDays(J,7);break;case`ArrowUp`:n=f.addDays(J,-7);break;case`PageDown`:n=f.addMonths(J,e.shiftKey?12:1);break;case`PageUp`:n=f.addMonths(J,e.shiftKey?-12:-1);break;case`Home`:n=f.addDays(J,-t);break;case`End`:n=f.addDays(J,6-t);break;default:return}e.preventDefault(),St(n)},an=N??(D?M(D):``),$=``;return F===`unparseable`?$=(w?.invalidDate??me)(at?void 0:f.getLocaleDateFormat(v).pattern):F===`out-of-range`&&(y||b)?$=(w?.outOfRange??he)(y?M(f.startOfDay(y)):void 0,b?M(f.startOfDay(b)):void 0):F===`disabled`&&($=w?.unavailableDate??`This date is not available.`),(0,m.jsxs)(`div`,{"data-size":T,"data-appearance":E,...rt,ref:nt,className:t.cn(i.datePickerClassNames.root,`relative inline-flex flex-col`,tt),children:[(0,m.jsxs)(`div`,{ref:zt,className:`relative flex items-center`,children:[(0,m.jsx)(`input`,{ref:Mt,type:`text`,...Kt,"aria-errormessage":Je,"aria-details":Ye,value:an,onChange:Yt,onFocus:Xe,onBlur:Zt,onKeyDown:Xt,onKeyUp:$e,placeholder:Ce,disabled:x,readOnly:S,autoComplete:Pe,autoCapitalize:Fe,autoCorrect:Ie,enterKeyHint:Le,inputMode:Re,spellCheck:ze,autoFocus:Be,tabIndex:Ve,className:t.cn(i.datePickerClassNames.input,l.inputHeightClasses[T],`w-full`,l.inputPaddingClasses[T],l.inputTextClasses[T],l.inputAppearanceClasses[E],`text-foreground placeholder:text-muted-foreground`,l.inputFocus,l.disabledStyles,qt&&`border-destructive`,d.pickerEndPadding(Jt?2:1,T))}),Jt&&(0,m.jsx)(`button`,{type:`button`,"aria-label":w?.clear??`Clear date`,disabled:x,onMouseDown:en,onClick:$t,className:t.cn(i.datePickerClassNames.clearButton,d.pickerIconButtonClasses(T,E),d.pickerButtonOffset(T,2),`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,`disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`),children:(0,m.jsx)(u.DismissIcon,{size:d.pickerGlyphSize(T,`icon`)})}),(0,m.jsx)(`button`,{ref:Z,type:`button`,"aria-label":w?.openCalendar??`Open calendar`,"aria-haspopup":`dialog`,"aria-expanded":j,"aria-controls":j?Nt:void 0,disabled:x||S,onClick:Qt,className:t.cn(i.datePickerClassNames.openCalendarButton,d.pickerIconButtonClasses(T,E),d.pickerButtonOffset(T,1),l.focusRing,l.disabledStyles),children:(0,m.jsx)(u.CalendarIcon,{size:d.pickerGlyphSize(T,`icon`)})})]}),Gt&&(0,m.jsx)(`p`,{id:It,role:`alert`,className:t.cn(i.datePickerClassNames.errorMessage,`mt-1 text-caption-1 text-error`),children:$}),(0,m.jsx)(le.HiddenInput,{name:je,form:Me,disabled:x,value:D?f.formatISODate(D):``,type:`text`,required:Wt,onInvalid:()=>X.current?.focus()}),j&&(0,m.jsx)(ae.Portal,{layerId:Rt,children:(0,m.jsxs)(`div`,{ref:Ht,id:Nt,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Pt,...Vt,"data-state":`open`,onKeyDown:nn,className:t.cn(i.datePickerClassNames.surface,`rounded-md border border-border bg-background p-3 text-foreground shadow-16`),children:[(0,m.jsxs)(`div`,{className:t.cn(i.datePickerClassNames.header,`mb-2 flex items-center justify-between gap-2`),children:[(0,m.jsx)(`button`,{type:`button`,"aria-label":w?.previousMonth??`Previous month`,"aria-controls":Ft,...c.focusableDisabledProps(Tt),onClick:c.preventIfDisabled(Tt,()=>Ct(-1)),className:t.cn(i.datePickerClassNames.previousMonthButton,ge,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,`disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`),children:(0,m.jsx)(u.ChevronLeftIcon,{className:`wave-rtl:-scale-x-100`})}),(0,m.jsx)(`h2`,{id:Pt,"aria-live":`polite`,className:t.cn(i.datePickerClassNames.heading,`text-body-1 font-semibold`),children:f.formatMonthYear(V,v)}),(0,m.jsx)(`button`,{type:`button`,"aria-label":w?.nextMonth??`Next month`,"aria-controls":Ft,...c.focusableDisabledProps(Et),onClick:c.preventIfDisabled(Et,()=>Ct(1)),className:t.cn(i.datePickerClassNames.nextMonthButton,ge,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,`disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`),children:(0,m.jsx)(u.ChevronRightIcon,{className:`wave-rtl:-scale-x-100`})})]}),(0,m.jsxs)(`table`,{ref:Ot,id:Ft,role:`grid`,"aria-labelledby":Pt,onKeyDown:rn,className:t.cn(i.datePickerClassNames.grid,`border-collapse`),children:[(0,m.jsx)(`thead`,{children:(0,m.jsx)(`tr`,{children:Dt.map(e=>(0,m.jsxs)(`th`,{scope:`col`,abbr:e.long,"aria-label":e.long,className:t.cn(i.datePickerClassNames.weekday,`h-8 w-8 text-center text-caption-1 font-normal text-muted-foreground`),children:[(0,m.jsx)(`span`,{"aria-hidden":`true`,children:e.short}),(0,m.jsx)(`span`,{className:`sr-only`,children:e.long})]},e.long))})}),(0,m.jsx)(`tbody`,{children:K.map((e,n)=>(0,m.jsx)(`tr`,{children:e.map((e,n)=>{let r=f.formatISODate(e),a=f.isSameDay(e,D),o=f.isSameDay(e,B),s=r===Y,ee=mt(e);return(0,m.jsx)(`td`,{role:`gridcell`,"aria-selected":a,className:`p-0`,children:(0,m.jsx)(`button`,{type:`button`,tabIndex:s?0:-1,"aria-label":f.formatDayLabel(e,v),"aria-pressed":a||void 0,"aria-current":o?`date`:void 0,...c.focusableDisabledProps(ee),"data-date":r,"data-selected":a?``:void 0,"data-today":o?``:void 0,"data-outside":f.isSameMonth(e,V)?void 0:``,onFocus:()=>wt(e),onClick:()=>tn(e),className:t.cn(i.datePickerClassNames.day,_e,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,`disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`,a&&l.forcedColors.selectedLeaf),children:f.formatDayNumber(e,v)})},n)})},n))})]})]})})]})};h.displayName=`DatePicker`,exports.DatePicker=h;
|
|
2
2
|
//# sourceMappingURL=DatePicker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.cjs","names":["isValidLocaleTag","useControllable","useIsClient","formatLocaleDate","parseLocaleDate","React","formatISODate","isDateInRange","startOfDay","isSameDay","startOfMonth","clampDate","getCalendarDays","isSameMonth","addMonths","addDays","getWeekdayNames","useMergedRefs","useId","useDismiss","FOCUSABLE_SELECTOR","usePopupPosition","useFieldContext","useFieldControl","joinIds","isInvalidLook","composeEventHandlers","getArrowIntent","getDirection","getLocaleDateFormat","cn","datePickerClassNames","inputBase","inputFocus","disabledStyles","DismissIcon","focusRing","CalendarIcon","HiddenInput","Portal","focusableDisabledProps","preventIfDisabled","ChevronLeftIcon","formatMonthYear","ChevronRightIcon","formatDayLabel","forcedColors","formatDayNumber","require_runtime","require_cn","require_dev","require_composeEventHandlers","require_classNames","require_useControllable","require_useId","require_direction","require_focus","require_useMergedRefs","require_useIsClient","require_aria","require_useFieldControl","require_useDismiss","require_Portal","require_styles","require_icons","require_Input","require_useFormReset","require_HiddenInput","require_usePopupPosition","require_dateUtils","require_useFocusTrap","require_useRestoreFocus","react","react_jsx_runtime","react_dom","defaultInvalidDateLabel","pattern","defaultOutOfRangeLabel","min","max","ICON_BUTTON_CLASSES","NAV_BUTTON_CLASSES","DAY_CLASSES","toWeeks","weeks","i","days","DatePicker","valueProp","formatDateProp","parseDateProp","openProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","props","onChange","hasCustomFormat","hasCustomParse","locale","selectedDate","setSelectedDate","defaultValue","onValueChange","next","interactive","disabled","readOnly","openState","setOpen","defaultOpen","onOpenChange","isClient","isOpen","openControlled","format","date","parse","text","draft","setDraft","invalid","setInvalid","wasInteractive","setWasInteractive","selectedDay","seenDay","setSeenDay","isUnavailable","minDate","maxDate","disabledDates","commitDate","normalized","commitDraft","parsed","reason","rejected","onInvalidInput","today","initialView","viewMonth","setViewMonth","focusedDay","setFocusedDay","openedFromInput","setOpenedFromInput","openSeen","setOpenSeen","firstDayOfWeek","inView","inGrid","clampedToday","firstInRange","focusTarget","focusIso","moveFocus","target","navigateMonth","nextView","delta","moved","handleDayFocus","day","previousDisabled","nextDisabled","weekdays","inputRef","toggleRef","gridRef","surfaceRef","restoreTargetRef","surface","setSurface","inputRefs","controlRef","dialogId","headingId","gridId","errorId","close","restoreTo","event","surfaceRefs","setFloating","grid","active","button","field","validates","required","showOwnError","fieldProps","invalidLook","form","showClear","clearable","handleInputChange","handleInputKeyDown","onKeyDown","handleInputBlur","onBlur","handleToggle","handleClear","handleClearMouseDown","selectDate","handleDialogKeyDown","handleGridKeyDown","weekOffset","intent","inputText","errorMessage","labels","className","setReference","floatingProps","weekday","week","iso","isSelected","isToday","isFocused","unavailable","column","row"],"sources":["../../../src/components/input/DatePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flushSync } from 'react-dom';\nimport { cn } from '../../lib/cn';\nimport { focusableDisabledProps, joinIds, preventIfDisabled } from '../../lib/aria';\nimport { datePickerClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { FOCUSABLE_SELECTOR } from '../../lib/focus';\nimport { CalendarIcon, ChevronLeftIcon, ChevronRightIcon, DismissIcon } from '../../lib/icons';\nimport {\n disabledStyles,\n focusRing,\n forcedColors,\n inputBase,\n inputFocus,\n inputInvalid,\n} from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFocusTrap } from '../../hooks/useFocusTrap';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { Portal } from '../portal/Portal';\nimport {\n addDays,\n addMonths,\n clampDate,\n formatDate as formatLocaleDate,\n formatDayLabel,\n formatDayNumber,\n formatISODate,\n formatMonthYear,\n getCalendarDays,\n getLocaleDateFormat,\n getWeekdayNames,\n isDateInRange,\n isSameDay,\n isSameMonth,\n isValidLocaleTag,\n parseDate as parseLocaleDate,\n startOfDay,\n startOfMonth,\n} from './dateUtils';\nimport { isInvalidLook } from './Input';\nimport type { RoutedHandlers } from './routedHandlers';\n\n/** Why typed text was not accepted (see {@link DatePickerProps.onInvalidInput}). */\nexport type DatePickerInvalidReason = 'unparseable' | 'out-of-range' | 'disabled';\n\n/**\n * The DatePicker's built-in button names and error texts, for localization. Each member is\n * optional and falls back to its English default. Month and weekday names and the day labels\n * follow `locale`.\n */\nexport interface DatePickerLabels {\n /** Name of the clear button.\n * @default 'Clear date'\n */\n clear?: string;\n /** Name of the button that opens the calendar.\n * @default 'Open calendar'\n */\n openCalendar?: string;\n /** Name of the calendar's previous-month button.\n * @default 'Previous month'\n */\n previousMonth?: string;\n /** Name of the calendar's next-month button.\n * @default 'Next month'\n */\n nextMonth?: string;\n /**\n * Error text for typed text that is not a date. `pattern` is the default format of `locale`\n * written with English field letters (`'MM/DD/YYYY'`, `'DD.MM.YYYY'`), or `undefined` with a\n * custom `parseDate` (its format is unknown to the picker).\n * @default (pattern) => pattern ? `Enter a date in the format ${pattern}.` : 'Enter a valid date.'\n */\n invalidDate?: (pattern: string | undefined) => string;\n /**\n * Error text for a typed date outside `minDate`/`maxDate`. The bounds are passed as the input\n * shows dates (`formatDate`); a bound that is not set is `undefined`.\n * @default (min, max) => `Enter a date between ${min} and ${max}.` (only `min`: `Enter a date on\n * or after ${min}.`; only `max`: `Enter a date on or before ${max}.`)\n */\n outOfRange?: (min: string | undefined, max: string | undefined) => string;\n /** Error text for a typed date that `disabledDates` excludes.\n * @default 'This date is not available.'\n */\n unavailableDate?: string;\n}\n\nconst defaultInvalidDateLabel = (pattern: string | undefined) =>\n pattern ? `Enter a date in the format ${pattern}.` : 'Enter a valid date.';\n\nconst defaultOutOfRangeLabel = (min: string | undefined, max: string | undefined) => {\n if (min !== undefined && max !== undefined) return `Enter a date between ${min} and ${max}.`;\n if (min !== undefined) return `Enter a date on or after ${min}.`;\n return `Enter a date on or before ${max}.`;\n};\n\n/** Properties for the DatePicker component. */\nexport interface DatePickerProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | 'placeholder' | RoutedHandlers\n> {\n /** Controlled selected date (`null` for none). Emitted dates are always local midnight. */\n value?: Date | null;\n /**\n * Initial date for uncontrolled usage.\n * @default null\n */\n defaultValue?: Date | null;\n /** Called with the new date (local midnight) or `null` whenever the selected day changes. */\n onValueChange?: (date: Date | null) => void;\n /**\n * @deprecated Use `onValueChange`. Still called with the new date (warns once in development).\n */\n onChange?: (date: Date | null) => void;\n /**\n * Formats the selected date for the input. Supply `parseDate` as its inverse: without it, typed\n * text is parsed with the default parser for `locale` (development warning).\n * @default Intl.DateTimeFormat(locale, { year: 'numeric', month: '2-digit', day: '2-digit' }),\n * in the Gregorian calendar when the locale's own has other months (see `locale`)\n */\n formatDate?: (date: Date) => string;\n /**\n * Parses typed text into a date (`null` when it is not one); the result is normalized to local\n * midnight. The default is the exact inverse of the default format for `locale` and also\n * accepts ISO `yyyy-mm-dd`.\n */\n parseDate?: (text: string) => Date | null;\n /**\n * BCP 47 locale of the default format/parse, the month and weekday names and the day labels\n * (runtime default when omitted). Pass it explicitly when rendering on the server, so the server\n * and the browser format the same text. The grid is Gregorian: a locale calendar with other\n * months or eras (the Persian default of `fa-IR`, `-u-ca-islamic`, `-u-ca-japanese`) is replaced\n * by the Gregorian one in the locale's language and digits; the Buddhist years of `th-TH` stay.\n * A tag `Intl` rejects (the POSIX `de_DE`, a typo) falls back to the runtime default locale\n * (development warning).\n */\n locale?: string;\n /** Earliest selectable day (the whole day is included). */\n minDate?: Date;\n /** Latest selectable day (the whole day is included). */\n maxDate?: Date;\n /** Returns `true` for days that cannot be selected (called with local-midnight dates). */\n disabledDates?: (date: Date) => boolean;\n /**\n * Placeholder text shown when no date is selected.\n * @default 'Select a date'\n */\n placeholder?: string;\n /**\n * Whether the date picker is disabled and non-interactive (the calendar is not shown).\n * @default false\n */\n disabled?: boolean;\n /**\n * Makes the input read-only: the calendar does not open and the value cannot change. Turning it\n * (or `disabled`) on while the user is typing drops the typed text.\n */\n readOnly?: boolean;\n /**\n * Whether to show a clear button when a date is selected (not shown while `readOnly`). Tab from\n * erased text clears the value before focus moves, so focus goes on to the calendar button, past\n * the clear button that disappears with it.\n * @default false\n */\n clearable?: boolean;\n /**\n * First day of the week (0 = Sunday, 1 = Monday, etc.).\n * @default 0\n */\n firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n /**\n * Controlled open state of the calendar. The calendar renders only in the browser: an open\n * picker is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state for uncontrolled usage. A picker that starts disabled or read-only starts\n * closed. The calendar renders only in the browser: it is closed in the server HTML and opens\n * once the picker has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /** Called when the calendar opens or closes (only when the state changes). */\n onOpenChange?: (open: boolean) => void;\n /**\n * Called when typed text is not accepted on Enter, Alt+ArrowDown or blur (once per edit): it\n * cannot be parsed (`'unparseable'`), lies outside `minDate`/`maxDate` (`'out-of-range'`) or is\n * excluded by `disabledDates` (`'disabled'`). The text stays in the input, which is marked\n * `aria-invalid` and described by an error message (left to the surrounding `Field` when it\n * shows an error). Enter reports it again when pressed again.\n */\n onInvalidInput?: (text: string, reason: DatePickerInvalidReason) => void;\n /**\n * Names of the clear, calendar and month buttons and the error texts of rejected typed text, for\n * localization. Unset members keep their English defaults.\n */\n labels?: DatePickerLabels;\n /** Form field name: the date is submitted as ISO `yyyy-mm-dd` (hidden input). */\n name?: string;\n /** Id of the `<form>` the value belongs to, when the picker is outside it. */\n form?: string;\n /**\n * Blocks form submission while no date is selected; sets `aria-required` on the input. Like a\n * native readonly input, a `readOnly` DatePicker does not block submission.\n */\n required?: boolean;\n /** Native `autocomplete` of the input. @default 'off' */\n autoComplete?: string;\n /** Focus handler of the text input (the root keeps the other handlers). */\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n /** Blur handler of the text input. */\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n /** Key handler of the text input; `preventDefault()` skips the picker's own keys. */\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Key handler of the text input. */\n onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Ref to the text input; `ref` stays on the root. */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// Every button sets its own padding and background (C-NATIVE): an app-wide `button` rule would\n// otherwise pad and fill them.\nconst ICON_BUTTON_CLASSES =\n 'absolute flex h-6 w-6 items-center justify-center rounded bg-transparent p-0 text-muted-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:hover:text-foreground';\n\nconst NAV_BUTTON_CLASSES =\n 'flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover';\n\n// An unavailable day stays focusable in the roving grid (`aria-disabled`); the day button adds\n// `disabledStyles`, whose dimmed look lifts while the focus ring shows (opacity would dim the ring).\nconst DAY_CLASSES =\n 'flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-caption-1 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover data-[outside]:text-muted-foreground data-[today]:border data-[today]:border-primary data-[today]:font-semibold data-[selected]:bg-primary data-[selected]:font-semibold data-[selected]:text-primary-foreground not-disabled:not-aria-disabled:data-[selected]:hover:bg-primary-hover aria-disabled:line-through';\n\n/** The 42 grid days as 6 weeks. */\nfunction toWeeks(days: Date[]): Date[][] {\n const weeks: Date[][] = [];\n for (let i = 0; i < days.length; i += 7) weeks.push(days.slice(i, i + 7));\n return weeks;\n}\n\n/**\n * A date input with a calendar dialog (APG date picker dialog).\n *\n * - **Typing**: the input accepts the default display format of `locale` (`Intl` numeric\n * year/month/day, e.g. `03/04/2025` for `en-GB`, `04/03/2025` for `en-US`) and ISO\n * `yyyy-mm-dd`. Text is committed on Enter, on Alt+ArrowDown (before the calendar opens) or when\n * the field loses focus — only when it was edited, and only when it names a different day. Text\n * that is not an available date is kept, the input is marked invalid and an error message\n * describes it (`onInvalidInput`, reported once per edit) until the text is edited or replaced\n * (a day picked in the calendar, the clear button, a form reset, a new day from the parent).\n * - **Calendar**: the toggle (`aria-haspopup=\"dialog\"`) or Alt+ArrowDown in the input opens a\n * modal dialog labelled by the month heading. Focus moves to the selected day (else today, else\n * the first available day of the month) and Tab stays inside. Arrow keys move by day/week\n * (mirrored in RTL), PageUp/PageDown by month, Shift+PageUp/PageDown by year (the day is clamped\n * to the month), Home/End to the start/end of the week, Enter/Space select. Escape closes and\n * returns focus to where the calendar was opened from (the toggle, or the input after\n * Alt+ArrowDown); a press outside closes it too. Unavailable days stay focusable\n * (`aria-disabled`); a day focused by pointer becomes the starting point of the arrow keys. The\n * selected day is `aria-selected` on its gridcell and `aria-pressed` on its focusable button, so\n * the state is announced when focus lands on it; today is `aria-current=\"date\"`.\n * - The calendar closes when the picker becomes disabled or read-only (uncontrolled `open`: it\n * stays closed when the picker is enabled again), and the text typed until then is dropped.\n * - `clearable` shows a clear button while a date is selected (not while read-only). Tab from\n * erased text clears the value first, so focus moves on to the calendar button instead of to the\n * clear button that disappears.\n * - Every emitted date is local midnight. The calendar opens on the month of the selected date or\n * today, clamped into `minDate`/`maxDate`.\n * - The input (`controlRef`) receives `id`, `aria-label`, `aria-labelledby`, `aria-describedby`,\n * `aria-invalid`, `aria-required`, `aria-errormessage`, `aria-details`, `tabIndex`,\n * `autoFocus`, `onFocus`/`onBlur`/`onKeyDown`/`onKeyUp` and the text input attributes\n * `autoComplete`, `autoCapitalize`, `autoCorrect`, `inputMode`, `spellCheck` and\n * `enterKeyHint`. `ref`, `className`, `style`, other `aria-*` attributes and the remaining props\n * stay on the root `<div>`. Inside a `Field`, the input is labelled and described by it.\n * - `name`/`required` add a hidden input for native forms (ISO `yyyy-mm-dd`); the value resets\n * with its form.\n * - The built-in button names and error texts are English; `labels` localizes them.\n * - Pass `locale` explicitly when rendering on the server (see `locale`). The calendar renders only\n * in the browser: an open calendar (`defaultOpen`, `open`) is closed in the server HTML and opens\n * once the picker has hydrated.\n */\nexport const DatePicker = (props: DatePickerProps) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n formatDate: formatDateProp,\n parseDate: parseDateProp,\n locale,\n minDate,\n maxDate,\n disabledDates,\n placeholder = 'Select a date',\n disabled = false,\n readOnly,\n clearable = false,\n firstDayOfWeek = 0,\n open: openProp,\n defaultOpen,\n onOpenChange,\n onInvalidInput,\n labels,\n name,\n form,\n required,\n autoComplete = 'off',\n autoCapitalize,\n autoCorrect,\n enterKeyHint,\n inputMode,\n spellCheck,\n autoFocus,\n tabIndex,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n ref,\n ...rest\n } = props;\n\n if (onChange !== undefined) warnDeprecated('DatePicker', 'onChange', 'onValueChange');\n\n const hasCustomFormat = formatDateProp !== undefined;\n const hasCustomParse = parseDateProp !== undefined;\n React.useEffect(() => {\n if (hasCustomFormat && !hasCustomParse) {\n warnOnce(\n 'DatePicker:formatDate-without-parseDate',\n 'DatePicker: `formatDate` is set without `parseDate`. Typed dates are parsed with the ' +\n 'default parser for `locale` (its numeric format or yyyy-mm-dd), which may not read ' +\n 'your format; pass `parseDate` as the inverse of `formatDate`.',\n );\n }\n }, [hasCustomFormat, hasCustomParse]);\n React.useEffect(() => {\n if (locale !== undefined && !isValidLocaleTag(locale)) {\n warnOnce(\n `DatePicker:invalid-locale:${locale}`,\n `DatePicker: \\`locale\\` \"${locale}\" is not a valid BCP 47 language tag (use hyphens, as ` +\n 'in \"en-US\"). The runtime default locale formats and parses the dates instead, so the ' +\n 'server and the browser may render different text.',\n );\n }\n }, [locale]);\n\n const [selectedDate, setSelectedDate] = useControllable<Date | null>(\n valueProp,\n defaultValue ?? null,\n (next) => {\n onValueChange?.(next);\n onChange?.(next);\n },\n );\n const interactive = !disabled && !readOnly;\n const [openState, setOpen] = useControllable<boolean>(\n openProp,\n // A picker that starts disabled or read-only never shows its calendar, so it starts closed\n // (no close to report later).\n (defaultOpen ?? false) && interactive,\n onOpenChange,\n );\n // The calendar lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the picker reports it closed, so no reference names a missing element.\n const isClient = useIsClient();\n const isOpen = openState && interactive && isClient;\n const openControlled = openProp !== undefined;\n\n // A calendar hidden because the picker became disabled or read-only is closed for good\n // (uncontrolled), so enabling the picker again does not bring it back and take focus.\n // onOpenChange(false) reports it; a controlled `open` stays the parent's.\n React.useEffect(() => {\n if (!interactive && openState && !openControlled) setOpen(false);\n }, [interactive, openState, openControlled, setOpen]);\n\n const format = (date: Date) =>\n formatDateProp ? formatDateProp(date) : formatLocaleDate(date, locale);\n const parse = (text: string) =>\n parseDateProp ? parseDateProp(text) : parseLocaleDate(text, locale);\n\n /* ---- draft text and validation ---------------------------------- */\n\n /** Typed text; `null` shows the formatted selected date (draft model). */\n const [draft, setDraft] = React.useState<string | null>(null);\n const [invalid, setInvalid] = React.useState<DatePickerInvalidReason | null>(null);\n\n // Adjusted during render (C-HOOKS). Locking the picker (readOnly/disabled) while the user types\n // drops the typed text and its error, so no later blur commits it (the value cannot change).\n const [wasInteractive, setWasInteractive] = React.useState(interactive);\n if (wasInteractive !== interactive) {\n setWasInteractive(interactive);\n if (!interactive) {\n setDraft(null);\n setInvalid(null);\n }\n }\n // A selected day the parent changes replaces rejected text (commits clear it themselves), so the\n // input never shows an error next to a valid value. Text the user is still typing stays.\n const selectedDay = selectedDate ? formatISODate(selectedDate) : '';\n const [seenDay, setSeenDay] = React.useState(selectedDay);\n if (seenDay !== selectedDay) {\n setSeenDay(selectedDay);\n if (invalid !== null) {\n setDraft(null);\n setInvalid(null);\n }\n }\n\n const isUnavailable = (date: Date) =>\n !isDateInRange(date, minDate, maxDate) || !!disabledDates?.(startOfDay(date));\n\n /** Commits a day (or `null`); nothing is emitted when it is the same day. */\n const commitDate = (next: Date | null) => {\n const normalized = next ? startOfDay(next) : null;\n const unchanged = normalized ? isSameDay(normalized, selectedDate) : selectedDate === null;\n if (!unchanged) setSelectedDate(normalized);\n setDraft(null);\n setInvalid(null);\n };\n\n /** Validates and commits the typed text; `false` when it was rejected (the text is kept). */\n const commitDraft = (text: string): boolean => {\n if (!text.trim()) {\n commitDate(null);\n return true;\n }\n const parsed = parse(text);\n let reason: DatePickerInvalidReason | null = null;\n if (!parsed || Number.isNaN(parsed.getTime())) reason = 'unparseable';\n else if (!isDateInRange(parsed, minDate, maxDate)) reason = 'out-of-range';\n else if (disabledDates?.(startOfDay(parsed))) reason = 'disabled';\n if (reason || !parsed) {\n const rejected = reason ?? 'unparseable';\n setInvalid(rejected);\n onInvalidInput?.(text, rejected);\n return false;\n }\n commitDate(parsed);\n return true;\n };\n\n /* ---- calendar view and focused day ------------------------------- */\n\n const today = startOfDay(new Date());\n const initialView = () => startOfMonth(clampDate(selectedDate ?? today, minDate, maxDate));\n const [viewMonth, setViewMonth] = React.useState<Date>(initialView);\n const [focusedDay, setFocusedDay] = React.useState<Date | null>(null);\n\n /** Opened with Alt+ArrowDown in the input: Escape returns focus there instead of the toggle. */\n const [openedFromInput, setOpenedFromInput] = React.useState(false);\n\n // Every opening shows the selected (or current) month again: adjusted during render (C-HOOKS).\n const [openSeen, setOpenSeen] = React.useState(isOpen);\n if (openSeen !== isOpen) {\n setOpenSeen(isOpen);\n if (isOpen) {\n setViewMonth(initialView());\n setFocusedDay(null);\n }\n }\n // A closed calendar forgets where it was opened from. This also drops an Alt+ArrowDown whose\n // opening a controlled parent declined (it renders in the same update, still closed), so a later\n // opening by the parent returns focus to the toggle, not the input.\n if (openedFromInput && !isOpen) setOpenedFromInput(false);\n\n const weeks = React.useMemo(\n () => toWeeks(getCalendarDays(viewMonth, firstDayOfWeek)),\n [viewMonth, firstDayOfWeek],\n );\n\n // The focused day is derived: the day moved to while it is shown (a pointer-focused day of the\n // previous/next month counts too), else the selected day of the month, else today (clamped into\n // the range), else the first available day of the month.\n const inView = (date: Date | null | undefined): date is Date =>\n !!date && isSameMonth(date, viewMonth);\n const inGrid = (date: Date | null | undefined): date is Date =>\n !!date && date >= weeks[0][0] && date <= weeks[weeks.length - 1][6];\n const clampedToday = clampDate(today, minDate, maxDate);\n const firstInRange = clampDate(viewMonth, minDate, maxDate);\n const focusTarget = inGrid(focusedDay)\n ? focusedDay\n : inView(selectedDate)\n ? startOfDay(selectedDate)\n : inView(clampedToday)\n ? clampedToday\n : inView(firstInRange)\n ? firstInRange\n : viewMonth;\n const focusIso = formatISODate(focusTarget);\n\n const moveFocus = (next: Date) => {\n const target = clampDate(next, minDate, maxDate);\n setFocusedDay(target);\n if (!isSameMonth(target, viewMonth)) setViewMonth(startOfMonth(target));\n };\n\n const navigateMonth = (delta: number) => {\n const nextView = addMonths(viewMonth, delta);\n const moved = clampDate(addMonths(focusTarget, delta), minDate, maxDate);\n setViewMonth(nextView);\n // From a day of the previous/next month the moved day may fall outside the new month: the\n // focused day is then derived again (selected, today or the first day of the month).\n setFocusedDay(isSameMonth(moved, nextView) ? moved : null);\n };\n\n /** Pointer (or assistive technology) focus on a day makes it the roving day; the month stays. */\n const handleDayFocus = (day: Date) => {\n if (!isSameDay(day, focusTarget)) setFocusedDay(day);\n };\n\n const previousDisabled = !!minDate && addDays(viewMonth, -1) < startOfDay(minDate);\n const nextDisabled = !!maxDate && addMonths(viewMonth, 1) > startOfDay(maxDate);\n\n const weekdays = React.useMemo(\n () => getWeekdayNames(locale, firstDayOfWeek),\n [locale, firstDayOfWeek],\n );\n\n /* ---- elements, popup primitives ---------------------------------- */\n\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n const toggleRef = React.useRef<HTMLButtonElement | null>(null);\n const gridRef = React.useRef<HTMLTableElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n /** Where focus goes when the calendar closes (`null`: back to the toggle). */\n const restoreTargetRef = React.useRef<HTMLElement | null>(null);\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n const inputRefs = useMergedRefs<HTMLInputElement>(controlRef, inputRef);\n\n const dialogId = useId('datepicker-dialog');\n const headingId = useId('datepicker-heading');\n const gridId = useId('datepicker-grid');\n const errorId = useId('datepicker-error');\n\n const close = (restoreTo: HTMLElement | null) => {\n restoreTargetRef.current = restoreTo;\n setOpen(false);\n };\n\n const { layerId } = useDismiss({\n open: isOpen,\n onDismiss: (reason, event) => {\n // An outside press on another control hands focus to it (the trap held it until now);\n // otherwise focus returns to where the calendar was opened from.\n const target =\n reason === 'outside-press' && event.target instanceof Element\n ? event.target.closest<HTMLElement>(FOCUSABLE_SELECTOR)\n : null;\n close(target ?? (openedFromInput ? inputRef.current : null));\n },\n refs: [surfaceRef, toggleRef],\n anchorRef: toggleRef,\n kind: 'modal',\n });\n\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open: isOpen,\n side: 'bottom',\n align: 'start',\n });\n const surfaceRefs = useMergedRefs<HTMLDivElement>(surfaceRef, setSurface, setFloating);\n\n useFocusTrap(surface, {\n enabled: isOpen,\n layerId,\n initialFocus: () => gridRef.current?.querySelector<HTMLElement>('button[tabindex=\"0\"]') ?? null,\n });\n\n useRestoreFocus({\n enabled: isOpen,\n container: surface,\n triggerRef: toggleRef,\n finalFocusRef: restoreTargetRef,\n onlyIfFocusInside: true,\n });\n\n // A new opening starts without a restore target (the toggle returns focus to itself, Escape to\n // where the calendar was opened from).\n React.useLayoutEffect(() => {\n if (isOpen) restoreTargetRef.current = null;\n }, [isOpen]);\n\n // Roving focus: while the grid holds focus, focus follows the focused day.\n React.useLayoutEffect(() => {\n const grid = gridRef.current;\n if (!grid) return;\n const active = grid.ownerDocument.activeElement;\n if (!active || !grid.contains(active)) return;\n const button = grid.querySelector<HTMLElement>(`button[data-date=\"${focusIso}\"]`);\n if (button && button !== active) button.focus();\n }, [focusIso]);\n\n /* ---- forms and Field --------------------------------------------- */\n\n const field = useFieldContext();\n const isRequired = required ?? field?.required ?? false;\n // Like a native readonly input, a read-only picker is barred from constraint validation (the\n // user could not fix it); its value is still submitted.\n const validates = isRequired && !readOnly;\n const showOwnError = invalid !== null && !field?.hasErrorMessage;\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': joinIds(ariaDescribedBy, showOwnError ? errorId : undefined),\n 'aria-invalid': invalid !== null ? true : ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required matches\n // `isRequired`.\n 'aria-required': ariaRequired ?? required,\n });\n const invalidLook = isInvalidLook(false, fieldProps['aria-invalid']);\n\n // Through the commit path: the default is emitted as local midnight, and only when it names\n // another day; the typed text and its error are dropped.\n useFormReset(inputRef, () => commitDate(defaultValue ?? null), form);\n\n // Read-only pickers offer no clear action (the value cannot change).\n const showClear = clearable && !readOnly && selectedDate !== null;\n\n /* ---- handlers ---------------------------------------------------- */\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (!interactive) return;\n setDraft(event.target.value);\n setInvalid(null);\n };\n\n const handleInputKeyDown = composeEventHandlers(\n onKeyDown,\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n // Keys that belong to an IME composition (its confirming Enter) are left to the IME.\n if (!interactive || event.nativeEvent.isComposing) return;\n if (event.key === 'Enter' && draft !== null) {\n // An edit is committed instead of submitting the form; untouched text lets Enter submit.\n event.preventDefault();\n commitDraft(draft);\n } else if (\n event.key === 'Tab' &&\n !event.shiftKey &&\n showClear &&\n draft !== null &&\n !draft.trim()\n ) {\n // Erased text clears the value, and with it the clear button, the next tab stop. It is\n // settled before Tab moves focus (the blur would settle it while focus moves to that\n // button), so focus moves on to the calendar button instead of dropping to <body> with\n // the clear button (C-DISABLED).\n flushSync(() => commitDraft(draft));\n } else if (event.key === 'ArrowDown' && event.altKey && !isOpen) {\n event.preventDefault();\n // The edit is committed first, so the calendar opens on the typed month; rejected text is\n // kept and reported once (the blur that follows does not report it again).\n if (draft !== null && invalid === null) commitDraft(draft);\n setOpenedFromInput(true);\n setOpen(true);\n }\n },\n );\n\n const handleInputBlur = composeEventHandlers(onBlur, () => {\n // Text already rejected (Enter, Alt+ArrowDown) is kept without being reported again.\n if (interactive && draft !== null && invalid === null) commitDraft(draft);\n });\n\n const handleToggle = () => {\n if (!interactive) return;\n restoreTargetRef.current = null;\n setOpenedFromInput(false);\n setOpen(!isOpen);\n };\n\n const handleClear = () => {\n if (!interactive) return;\n commitDate(null);\n inputRef.current?.focus();\n };\n\n // The clear button keeps focus on the input: its blur would otherwise commit (or reject) the\n // edited text just before the clear, emitting twice for one click.\n const handleClearMouseDown = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n };\n\n const selectDate = (day: Date) => {\n if (!interactive || isUnavailable(day)) return;\n commitDate(day);\n close(inputRef.current);\n };\n\n const handleDialogKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Escape' || event.defaultPrevented || event.nativeEvent.isComposing) return;\n // Consumed here, so enclosing layers (a Dialog around the picker) ignore it.\n event.preventDefault();\n close(openedFromInput ? inputRef.current : null);\n };\n\n const handleGridKeyDown = (event: React.KeyboardEvent<HTMLTableElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const weekOffset = (focusTarget.getDay() - firstDayOfWeek + 7) % 7;\n let next: Date;\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowRight': {\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n next = addDays(focusTarget, intent === 'next' ? 1 : -1);\n break;\n }\n case 'ArrowDown':\n next = addDays(focusTarget, 7);\n break;\n case 'ArrowUp':\n next = addDays(focusTarget, -7);\n break;\n case 'PageDown':\n next = addMonths(focusTarget, event.shiftKey ? 12 : 1);\n break;\n case 'PageUp':\n next = addMonths(focusTarget, event.shiftKey ? -12 : -1);\n break;\n case 'Home':\n next = addDays(focusTarget, -weekOffset);\n break;\n case 'End':\n next = addDays(focusTarget, 6 - weekOffset);\n break;\n default:\n // Enter and Space activate the focused day button natively (click).\n return;\n }\n event.preventDefault();\n moveFocus(next);\n };\n\n /* ---- render ------------------------------------------------------ */\n\n const inputText = draft ?? (selectedDate ? format(selectedDate) : '');\n\n let errorMessage = '';\n if (invalid === 'unparseable') {\n errorMessage = (labels?.invalidDate ?? defaultInvalidDateLabel)(\n hasCustomParse ? undefined : getLocaleDateFormat(locale).pattern,\n );\n } else if (invalid === 'out-of-range' && (minDate || maxDate)) {\n errorMessage = (labels?.outOfRange ?? defaultOutOfRangeLabel)(\n minDate ? format(startOfDay(minDate)) : undefined,\n maxDate ? format(startOfDay(maxDate)) : undefined,\n );\n } else if (invalid === 'disabled') {\n errorMessage = labels?.unavailableDate ?? 'This date is not available.';\n }\n\n return (\n <div\n {...rest}\n ref={ref}\n className={cn(datePickerClassNames.root, 'relative inline-flex flex-col', className)}\n >\n <div ref={setReference} className=\"relative flex items-center\">\n <input\n ref={inputRefs}\n type=\"text\"\n {...fieldProps}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n value={inputText}\n onChange={handleInputChange}\n onFocus={onFocus}\n onBlur={handleInputBlur}\n onKeyDown={handleInputKeyDown}\n onKeyUp={onKeyUp}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n autoComplete={autoComplete}\n autoCapitalize={autoCapitalize}\n autoCorrect={autoCorrect}\n enterKeyHint={enterKeyHint}\n inputMode={inputMode}\n spellCheck={spellCheck}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n className={cn(\n datePickerClassNames.input,\n inputBase,\n 'border-b-stroke-accessible',\n inputFocus,\n disabledStyles,\n invalidLook && inputInvalid,\n showClear ? 'pe-14' : 'pe-8',\n )}\n />\n {showClear && (\n <button\n type=\"button\"\n aria-label={labels?.clear ?? 'Clear date'}\n disabled={disabled}\n onMouseDown={handleClearMouseDown}\n onClick={handleClear}\n className={cn(\n datePickerClassNames.clearButton,\n ICON_BUTTON_CLASSES,\n 'end-7',\n focusRing,\n disabledStyles,\n )}\n >\n <DismissIcon />\n </button>\n )}\n <button\n ref={toggleRef}\n type=\"button\"\n aria-label={labels?.openCalendar ?? 'Open calendar'}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? dialogId : undefined}\n disabled={disabled || readOnly}\n onClick={handleToggle}\n className={cn(\n datePickerClassNames.openCalendarButton,\n ICON_BUTTON_CLASSES,\n 'end-1',\n focusRing,\n disabledStyles,\n )}\n >\n <CalendarIcon />\n </button>\n </div>\n {showOwnError && (\n <p\n id={errorId}\n role=\"alert\"\n className={cn(datePickerClassNames.errorMessage, 'mt-1 text-caption-1 text-error')}\n >\n {errorMessage}\n </p>\n )}\n <HiddenInput\n name={name}\n form={form}\n disabled={disabled}\n value={selectedDate ? formatISODate(selectedDate) : ''}\n type=\"text\"\n required={validates}\n onInvalid={() => inputRef.current?.focus()}\n />\n {isOpen && (\n <Portal layerId={layerId}>\n <div\n ref={surfaceRefs}\n id={dialogId}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={headingId}\n {...floatingProps}\n data-state=\"open\"\n onKeyDown={handleDialogKeyDown}\n className={cn(\n datePickerClassNames.surface,\n 'rounded-md border border-border bg-background p-3 text-foreground shadow-16',\n )}\n >\n <div\n className={cn(\n datePickerClassNames.header,\n 'mb-2 flex items-center justify-between gap-2',\n )}\n >\n <button\n type=\"button\"\n aria-label={labels?.previousMonth ?? 'Previous month'}\n aria-controls={gridId}\n {...focusableDisabledProps(previousDisabled)}\n onClick={preventIfDisabled(previousDisabled, () => navigateMonth(-1))}\n className={cn(\n datePickerClassNames.previousMonthButton,\n NAV_BUTTON_CLASSES,\n focusRing,\n disabledStyles,\n )}\n >\n <ChevronLeftIcon className=\"wave-rtl:-scale-x-100\" />\n </button>\n <h2\n id={headingId}\n aria-live=\"polite\"\n className={cn(datePickerClassNames.heading, 'text-body-1 font-semibold')}\n >\n {formatMonthYear(viewMonth, locale)}\n </h2>\n <button\n type=\"button\"\n aria-label={labels?.nextMonth ?? 'Next month'}\n aria-controls={gridId}\n {...focusableDisabledProps(nextDisabled)}\n onClick={preventIfDisabled(nextDisabled, () => navigateMonth(1))}\n className={cn(\n datePickerClassNames.nextMonthButton,\n NAV_BUTTON_CLASSES,\n focusRing,\n disabledStyles,\n )}\n >\n <ChevronRightIcon className=\"wave-rtl:-scale-x-100\" />\n </button>\n </div>\n <table\n ref={gridRef}\n id={gridId}\n role=\"grid\"\n aria-labelledby={headingId}\n onKeyDown={handleGridKeyDown}\n className={cn(datePickerClassNames.grid, 'border-collapse')}\n >\n <thead>\n <tr>\n {weekdays.map((weekday) => (\n <th\n key={weekday.long}\n scope=\"col\"\n abbr={weekday.long}\n aria-label={weekday.long}\n className={cn(\n datePickerClassNames.weekday,\n 'h-8 w-8 text-center text-caption-1 font-normal text-muted-foreground',\n )}\n >\n <span aria-hidden=\"true\">{weekday.short}</span>\n <span className=\"sr-only\">{weekday.long}</span>\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {weeks.map((week, row) => (\n // Rows and cells are keyed by position, so the focused button survives a\n // month change and focus stays in the grid while it moves to the new day.\n <tr key={row}>\n {week.map((day, column) => {\n const iso = formatISODate(day);\n const isSelected = isSameDay(day, selectedDate);\n const isToday = isSameDay(day, today);\n const isFocused = iso === focusIso;\n const unavailable = isUnavailable(day);\n return (\n <td key={column} role=\"gridcell\" aria-selected={isSelected} className=\"p-0\">\n {/* Focus rests on the button, and screen readers do not reliably\n announce the gridcell's aria-selected from inside it: the selected\n day's button is also pressed. */}\n <button\n type=\"button\"\n tabIndex={isFocused ? 0 : -1}\n aria-label={formatDayLabel(day, locale)}\n aria-pressed={isSelected || undefined}\n aria-current={isToday ? 'date' : undefined}\n {...focusableDisabledProps(unavailable)}\n data-date={iso}\n data-selected={isSelected ? '' : undefined}\n data-today={isToday ? '' : undefined}\n data-outside={isSameMonth(day, viewMonth) ? undefined : ''}\n onFocus={() => handleDayFocus(day)}\n onClick={() => selectDate(day)}\n className={cn(\n datePickerClassNames.day,\n DAY_CLASSES,\n focusRing,\n disabledStyles,\n isSelected && forcedColors.selectedLeaf,\n )}\n >\n {formatDayNumber(day, locale)}\n </button>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </Portal>\n )}\n </div>\n );\n};\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":"0hCAkGA,IAAM2E,GAA2B,GAC/BC,EAAU,8BAA8BA,EAAQ,GAAK,sBAEjDC,IAA0B,EAAyB,IACnDC,IAAQ,IAAA,IAAaC,IAAQ,IAAA,GAAkB,wBAAwBD,EAAI,OAAOC,EAAI,GACtFD,IAAQ,IAAA,GACL,6BAA6BC,EAAI,GADV,4BAA4BD,EAAI,GAoI1DE,GACJ,+MAEIC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AAI,IAAA,GAAY,GACxD,YAAeqB,GAAeC,CAAG,EACjC,YAAe0C,GAAW1C,CAAG,EAC7B,UAAW1I,EAAAA,GACTC,EAAAA,qBAAqB,IACrBmD,GAAA,oFAAA,oJAGA8I,GAAclL,EAAAA,aAAa,YAC7B,EAEC,SAAAC,EAAAA,gBAAgByH,EAAKhE,CAAM,CACtB,CAAA,CACN,EA3BK4H,CA2BL,CAER,CAAC,CACC,EAtCKC,CAsCL,CACL,CACI,CAAA,CACF,CACJ,CAAA,CAAA,GACC,CAAA,CAEP,GAET,EAEA,EAAW,YAAc"}
|
|
1
|
+
{"version":3,"file":"DatePicker.cjs","names":["useInputLook","isValidLocaleTag","useControllable","useIsClient","formatLocaleDate","parseLocaleDate","React","formatISODate","isDateInRange","startOfDay","isSameDay","startOfMonth","clampDate","getCalendarDays","isSameMonth","addMonths","addDays","getWeekdayNames","useMergedRefs","useId","useDismiss","FOCUSABLE_SELECTOR","usePopupPosition","useFieldContext","useFieldControl","joinIds","isInvalidLook","composeEventHandlers","getArrowIntent","getDirection","getLocaleDateFormat","cn","datePickerClassNames","inputHeightClasses","inputPaddingClasses","inputTextClasses","inputAppearanceClasses","inputFocus","disabledStyles","pickerEndPadding","pickerIconButtonClasses","pickerButtonOffset","DismissIcon","pickerGlyphSize","focusRing","CalendarIcon","HiddenInput","Portal","focusableDisabledProps","preventIfDisabled","ChevronLeftIcon","formatMonthYear","ChevronRightIcon","formatDayLabel","forcedColors","formatDayNumber","require_runtime","require_cn","require_dev","require_composeEventHandlers","require_classNames","require_useControllable","require_useId","require_direction","require_focus","require_useMergedRefs","require_useIsClient","require_aria","require_useFieldControl","require_useDismiss","require_Portal","require_styles","require_icons","require_inputLook","require_Input","require_useFormReset","require_HiddenInput","require_pickerStyles","require_usePopupPosition","require_dateUtils","require_useFocusTrap","require_useRestoreFocus","react","react_jsx_runtime","react_dom","defaultInvalidDateLabel","pattern","defaultOutOfRangeLabel","min","max","NAV_BUTTON_CLASSES","DAY_CLASSES","toWeeks","weeks","i","days","DatePicker","valueProp","formatDateProp","parseDateProp","sizeProp","appearanceProp","openProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","props","onChange","hasCustomFormat","hasCustomParse","locale","selectedDate","setSelectedDate","defaultValue","onValueChange","next","interactive","disabled","readOnly","openState","setOpen","defaultOpen","onOpenChange","isClient","isOpen","openControlled","format","date","parse","text","draft","setDraft","invalid","setInvalid","wasInteractive","setWasInteractive","selectedDay","seenDay","setSeenDay","isUnavailable","minDate","maxDate","disabledDates","commitDate","normalized","commitDraft","parsed","reason","rejected","onInvalidInput","today","initialView","viewMonth","setViewMonth","focusedDay","setFocusedDay","openedFromInput","setOpenedFromInput","openSeen","setOpenSeen","firstDayOfWeek","inView","inGrid","clampedToday","firstInRange","focusTarget","focusIso","moveFocus","target","navigateMonth","nextView","delta","moved","handleDayFocus","day","previousDisabled","nextDisabled","weekdays","inputRef","toggleRef","gridRef","surfaceRef","restoreTargetRef","surface","setSurface","inputRefs","controlRef","dialogId","headingId","gridId","errorId","close","restoreTo","event","surfaceRefs","setFloating","grid","active","button","field","validates","required","showOwnError","fieldProps","invalidLook","form","showClear","clearable","handleInputChange","handleInputKeyDown","onKeyDown","handleInputBlur","onBlur","handleToggle","handleClear","handleClearMouseDown","selectDate","handleDialogKeyDown","handleGridKeyDown","weekOffset","intent","inputText","errorMessage","labels","size","appearance","className","setReference","floatingProps","weekday","week","iso","isSelected","isToday","isFocused","unavailable","column","row"],"sources":["../../../src/components/input/DatePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flushSync } from 'react-dom';\nimport { cn } from '../../lib/cn';\nimport { focusableDisabledProps, joinIds, preventIfDisabled } from '../../lib/aria';\nimport { datePickerClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { FOCUSABLE_SELECTOR } from '../../lib/focus';\nimport { CalendarIcon, ChevronLeftIcon, ChevronRightIcon, DismissIcon } from '../../lib/icons';\nimport {\n disabledStyles,\n focusRing,\n forcedColors,\n inputAppearanceClasses,\n inputFocus,\n inputHeightClasses,\n inputInvalid,\n inputPaddingClasses,\n inputTextClasses,\n} from '../../lib/styles';\nimport type { CoreSize, InputAppearance } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFocusTrap } from '../../hooks/useFocusTrap';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { Portal } from '../portal/Portal';\nimport {\n addDays,\n addMonths,\n clampDate,\n formatDate as formatLocaleDate,\n formatDayLabel,\n formatDayNumber,\n formatISODate,\n formatMonthYear,\n getCalendarDays,\n getLocaleDateFormat,\n getWeekdayNames,\n isDateInRange,\n isSameDay,\n isSameMonth,\n isValidLocaleTag,\n parseDate as parseLocaleDate,\n startOfDay,\n startOfMonth,\n} from './dateUtils';\nimport { useInputLook } from './inputLook';\nimport { isInvalidLook } from './Input';\nimport {\n pickerButtonOffset,\n pickerEndPadding,\n pickerGlyphSize,\n pickerIconButtonClasses,\n} from './pickerStyles';\nimport type { RoutedHandlers } from './routedHandlers';\n\n/** Why typed text was not accepted (see {@link DatePickerProps.onInvalidInput}). */\nexport type DatePickerInvalidReason = 'unparseable' | 'out-of-range' | 'disabled';\n\n/**\n * The DatePicker's built-in button names and error texts, for localization. Each member is\n * optional and falls back to its English default. Month and weekday names and the day labels\n * follow `locale`.\n */\nexport interface DatePickerLabels {\n /** Name of the clear button.\n * @default 'Clear date'\n */\n clear?: string;\n /** Name of the button that opens the calendar.\n * @default 'Open calendar'\n */\n openCalendar?: string;\n /** Name of the calendar's previous-month button.\n * @default 'Previous month'\n */\n previousMonth?: string;\n /** Name of the calendar's next-month button.\n * @default 'Next month'\n */\n nextMonth?: string;\n /**\n * Error text for typed text that is not a date. `pattern` is the default format of `locale`\n * written with English field letters (`'MM/DD/YYYY'`, `'DD.MM.YYYY'`), or `undefined` with a\n * custom `parseDate` (its format is unknown to the picker).\n * @default (pattern) => pattern ? `Enter a date in the format ${pattern}.` : 'Enter a valid date.'\n */\n invalidDate?: (pattern: string | undefined) => string;\n /**\n * Error text for a typed date outside `minDate`/`maxDate`. The bounds are passed as the input\n * shows dates (`formatDate`); a bound that is not set is `undefined`.\n * @default (min, max) => `Enter a date between ${min} and ${max}.` (only `min`: `Enter a date on\n * or after ${min}.`; only `max`: `Enter a date on or before ${max}.`)\n */\n outOfRange?: (min: string | undefined, max: string | undefined) => string;\n /** Error text for a typed date that `disabledDates` excludes.\n * @default 'This date is not available.'\n */\n unavailableDate?: string;\n}\n\nconst defaultInvalidDateLabel = (pattern: string | undefined) =>\n pattern ? `Enter a date in the format ${pattern}.` : 'Enter a valid date.';\n\nconst defaultOutOfRangeLabel = (min: string | undefined, max: string | undefined) => {\n if (min !== undefined && max !== undefined) return `Enter a date between ${min} and ${max}.`;\n if (min !== undefined) return `Enter a date on or after ${min}.`;\n return `Enter a date on or before ${max}.`;\n};\n\n/** Properties for the DatePicker component. */\nexport interface DatePickerProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | 'placeholder' | RoutedHandlers\n> {\n /** Controlled selected date (`null` for none). Emitted dates are always local midnight. */\n value?: Date | null;\n /**\n * Initial date for uncontrolled usage.\n * @default null\n */\n defaultValue?: Date | null;\n /** Called with the new date (local midnight) or `null` whenever the selected day changes. */\n onValueChange?: (date: Date | null) => void;\n /**\n * @deprecated Use `onValueChange`. Still called with the new date (warns once in development).\n */\n onChange?: (date: Date | null) => void;\n /**\n * Formats the selected date for the input. Supply `parseDate` as its inverse: without it, typed\n * text is parsed with the default parser for `locale` (development warning).\n * @default Intl.DateTimeFormat(locale, { year: 'numeric', month: '2-digit', day: '2-digit' }),\n * in the Gregorian calendar when the locale's own has other months (see `locale`)\n */\n formatDate?: (date: Date) => string;\n /**\n * Parses typed text into a date (`null` when it is not one); the result is normalized to local\n * midnight. The default is the exact inverse of the default format for `locale` and also\n * accepts ISO `yyyy-mm-dd`.\n */\n parseDate?: (text: string) => Date | null;\n /**\n * BCP 47 locale of the default format/parse, the month and weekday names and the day labels\n * (runtime default when omitted). Pass it explicitly when rendering on the server, so the server\n * and the browser format the same text. The grid is Gregorian: a locale calendar with other\n * months or eras (the Persian default of `fa-IR`, `-u-ca-islamic`, `-u-ca-japanese`) is replaced\n * by the Gregorian one in the locale's language and digits; the Buddhist years of `th-TH` stay.\n * A tag `Intl` rejects (the POSIX `de_DE`, a typo) falls back to the runtime default locale\n * (development warning).\n */\n locale?: string;\n /** Earliest selectable day (the whole day is included). */\n minDate?: Date;\n /** Latest selectable day (the whole day is included). */\n maxDate?: Date;\n /** Returns `true` for days that cannot be selected (called with local-midnight dates). */\n disabledDates?: (date: Date) => boolean;\n /**\n * Placeholder text shown when no date is selected.\n * @default 'Select a date'\n */\n placeholder?: string;\n /**\n * Whether the date picker is disabled and non-interactive (the calendar is not shown).\n * @default false\n */\n disabled?: boolean;\n /**\n * Size of the field: `small` (24px tall), `medium` (32px) or `large` (40px). Default: the\n * surrounding Field's `size`, else `WaveProvider inputDefaults.size`, else `'medium'`. The\n * calendar keeps its size.\n */\n size?: CoreSize;\n /**\n * Look of the field: `outline` (a full border), `underline` (a bottom stroke only),\n * `filled-darker` or `filled-lighter` (a fill without a visible stroke: give the field a visible\n * label). Default: `WaveProvider inputDefaults.appearance`, else `'outline'`.\n */\n appearance?: InputAppearance;\n /**\n * Makes the input read-only: the calendar does not open and the value cannot change. Turning it\n * (or `disabled`) on while the user is typing drops the typed text.\n */\n readOnly?: boolean;\n /**\n * Whether to show a clear button when a date is selected (not shown while `readOnly`). Tab from\n * erased text clears the value before focus moves, so focus goes on to the calendar button, past\n * the clear button that disappears with it.\n * @default false\n */\n clearable?: boolean;\n /**\n * First day of the week (0 = Sunday, 1 = Monday, etc.).\n * @default 0\n */\n firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n /**\n * Controlled open state of the calendar. The calendar renders only in the browser: an open\n * picker is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state for uncontrolled usage. A picker that starts disabled or read-only starts\n * closed. The calendar renders only in the browser: it is closed in the server HTML and opens\n * once the picker has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /** Called when the calendar opens or closes (only when the state changes). */\n onOpenChange?: (open: boolean) => void;\n /**\n * Called when typed text is not accepted on Enter, Alt+ArrowDown or blur (once per edit): it\n * cannot be parsed (`'unparseable'`), lies outside `minDate`/`maxDate` (`'out-of-range'`) or is\n * excluded by `disabledDates` (`'disabled'`). The text stays in the input, which is marked\n * `aria-invalid` and described by an error message (left to the surrounding `Field` when it\n * shows an error). Enter reports it again when pressed again.\n */\n onInvalidInput?: (text: string, reason: DatePickerInvalidReason) => void;\n /**\n * Names of the clear, calendar and month buttons and the error texts of rejected typed text, for\n * localization. Unset members keep their English defaults.\n */\n labels?: DatePickerLabels;\n /** Form field name: the date is submitted as ISO `yyyy-mm-dd` (hidden input). */\n name?: string;\n /** Id of the `<form>` the value belongs to, when the picker is outside it. */\n form?: string;\n /**\n * Blocks form submission while no date is selected; sets `aria-required` on the input. Like a\n * native readonly input, a `readOnly` DatePicker does not block submission.\n */\n required?: boolean;\n /** Native `autocomplete` of the input. @default 'off' */\n autoComplete?: string;\n /** Focus handler of the text input (the root keeps the other handlers). */\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n /** Blur handler of the text input. */\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n /** Key handler of the text input; `preventDefault()` skips the picker's own keys. */\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Key handler of the text input. */\n onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Ref to the text input; `ref` stays on the root. */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// Every button sets its own padding and background (C-NATIVE): an app-wide `button` rule would\n// otherwise pad and fill them.\nconst NAV_BUTTON_CLASSES =\n 'flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover';\n\n// An unavailable day stays focusable in the roving grid (`aria-disabled`); the day button adds\n// `disabledStyles`, whose dimmed look lifts while the focus ring shows (opacity would dim the ring).\nconst DAY_CLASSES =\n 'flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-caption-1 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover data-[outside]:text-muted-foreground data-[today]:border data-[today]:border-primary data-[today]:font-semibold data-[selected]:bg-primary data-[selected]:font-semibold data-[selected]:text-primary-foreground not-disabled:not-aria-disabled:data-[selected]:hover:bg-primary-hover aria-disabled:line-through';\n\n/** The 42 grid days as 6 weeks. */\nfunction toWeeks(days: Date[]): Date[][] {\n const weeks: Date[][] = [];\n for (let i = 0; i < days.length; i += 7) weeks.push(days.slice(i, i + 7));\n return weeks;\n}\n\n/**\n * A date input with a calendar dialog (APG date picker dialog).\n *\n * - **Typing**: the input accepts the default display format of `locale` (`Intl` numeric\n * year/month/day, e.g. `03/04/2025` for `en-GB`, `04/03/2025` for `en-US`) and ISO\n * `yyyy-mm-dd`. Text is committed on Enter, on Alt+ArrowDown (before the calendar opens) or when\n * the field loses focus — only when it was edited, and only when it names a different day. Text\n * that is not an available date is kept, the input is marked invalid and an error message\n * describes it (`onInvalidInput`, reported once per edit) until the text is edited or replaced\n * (a day picked in the calendar, the clear button, a form reset, a new day from the parent).\n * - **Calendar**: the toggle (`aria-haspopup=\"dialog\"`) or Alt+ArrowDown in the input opens a\n * modal dialog labelled by the month heading. Focus moves to the selected day (else today, else\n * the first available day of the month) and Tab stays inside. Arrow keys move by day/week\n * (mirrored in RTL), PageUp/PageDown by month, Shift+PageUp/PageDown by year (the day is clamped\n * to the month), Home/End to the start/end of the week, Enter/Space select. Escape closes and\n * returns focus to where the calendar was opened from (the toggle, or the input after\n * Alt+ArrowDown); a press outside closes it too. Unavailable days stay focusable\n * (`aria-disabled`); a day focused by pointer becomes the starting point of the arrow keys. The\n * selected day is `aria-selected` on its gridcell and `aria-pressed` on its focusable button, so\n * the state is announced when focus lands on it; today is `aria-current=\"date\"`.\n * - The calendar closes when the picker becomes disabled or read-only (uncontrolled `open`: it\n * stays closed when the picker is enabled again), and the text typed until then is dropped.\n * - `clearable` shows a clear button while a date is selected (not while read-only). Tab from\n * erased text clears the value first, so focus moves on to the calendar button instead of to the\n * clear button that disappears.\n * - Every emitted date is local midnight. The calendar opens on the month of the selected date or\n * today, clamped into `minDate`/`maxDate`.\n * - **Size and appearance**: `size` resolves from its own prop, then the surrounding `Field`'s\n * `size`, then `WaveProvider inputDefaults.size`, else `'medium'`; `appearance` from its own\n * prop, then `WaveProvider inputDefaults.appearance`, else `'outline'`; both render as\n * `data-size` and `data-appearance` on the root `<div>`. The calendar keeps its size.\n * - The input (`controlRef`) receives `id`, `aria-label`, `aria-labelledby`, `aria-describedby`,\n * `aria-invalid`, `aria-required`, `aria-errormessage`, `aria-details`, `tabIndex`,\n * `autoFocus`, `onFocus`/`onBlur`/`onKeyDown`/`onKeyUp` and the text input attributes\n * `autoComplete`, `autoCapitalize`, `autoCorrect`, `inputMode`, `spellCheck` and\n * `enterKeyHint`. `ref`, `className`, `style`, other `aria-*` attributes and the remaining props\n * stay on the root `<div>`. Inside a `Field`, the input is labelled and described by it.\n * - `name`/`required` add a hidden input for native forms (ISO `yyyy-mm-dd`); the value resets\n * with its form.\n * - The built-in button names and error texts are English; `labels` localizes them.\n * - Pass `locale` explicitly when rendering on the server (see `locale`). The calendar renders only\n * in the browser: an open calendar (`defaultOpen`, `open`) is closed in the server HTML and opens\n * once the picker has hydrated.\n */\nexport const DatePicker = (props: DatePickerProps) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n formatDate: formatDateProp,\n parseDate: parseDateProp,\n locale,\n minDate,\n maxDate,\n disabledDates,\n placeholder = 'Select a date',\n disabled = false,\n size: sizeProp,\n appearance: appearanceProp,\n readOnly,\n clearable = false,\n firstDayOfWeek = 0,\n open: openProp,\n defaultOpen,\n onOpenChange,\n onInvalidInput,\n labels,\n name,\n form,\n required,\n autoComplete = 'off',\n autoCapitalize,\n autoCorrect,\n enterKeyHint,\n inputMode,\n spellCheck,\n autoFocus,\n tabIndex,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n ref,\n ...rest\n } = props;\n\n if (onChange !== undefined) warnDeprecated('DatePicker', 'onChange', 'onValueChange');\n\n const { size, appearance } = useInputLook(sizeProp, appearanceProp);\n\n const hasCustomFormat = formatDateProp !== undefined;\n const hasCustomParse = parseDateProp !== undefined;\n React.useEffect(() => {\n if (hasCustomFormat && !hasCustomParse) {\n warnOnce(\n 'DatePicker:formatDate-without-parseDate',\n 'DatePicker: `formatDate` is set without `parseDate`. Typed dates are parsed with the ' +\n 'default parser for `locale` (its numeric format or yyyy-mm-dd), which may not read ' +\n 'your format; pass `parseDate` as the inverse of `formatDate`.',\n );\n }\n }, [hasCustomFormat, hasCustomParse]);\n React.useEffect(() => {\n if (locale !== undefined && !isValidLocaleTag(locale)) {\n warnOnce(\n `DatePicker:invalid-locale:${locale}`,\n `DatePicker: \\`locale\\` \"${locale}\" is not a valid BCP 47 language tag (use hyphens, as ` +\n 'in \"en-US\"). The runtime default locale formats and parses the dates instead, so the ' +\n 'server and the browser may render different text.',\n );\n }\n }, [locale]);\n\n const [selectedDate, setSelectedDate] = useControllable<Date | null>(\n valueProp,\n defaultValue ?? null,\n (next) => {\n onValueChange?.(next);\n onChange?.(next);\n },\n );\n const interactive = !disabled && !readOnly;\n const [openState, setOpen] = useControllable<boolean>(\n openProp,\n // A picker that starts disabled or read-only never shows its calendar, so it starts closed\n // (no close to report later).\n (defaultOpen ?? false) && interactive,\n onOpenChange,\n );\n // The calendar lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the picker reports it closed, so no reference names a missing element.\n const isClient = useIsClient();\n const isOpen = openState && interactive && isClient;\n const openControlled = openProp !== undefined;\n\n // A calendar hidden because the picker became disabled or read-only is closed for good\n // (uncontrolled), so enabling the picker again does not bring it back and take focus.\n // onOpenChange(false) reports it; a controlled `open` stays the parent's.\n React.useEffect(() => {\n if (!interactive && openState && !openControlled) setOpen(false);\n }, [interactive, openState, openControlled, setOpen]);\n\n const format = (date: Date) =>\n formatDateProp ? formatDateProp(date) : formatLocaleDate(date, locale);\n const parse = (text: string) =>\n parseDateProp ? parseDateProp(text) : parseLocaleDate(text, locale);\n\n /* ---- draft text and validation ---------------------------------- */\n\n /** Typed text; `null` shows the formatted selected date (draft model). */\n const [draft, setDraft] = React.useState<string | null>(null);\n const [invalid, setInvalid] = React.useState<DatePickerInvalidReason | null>(null);\n\n // Adjusted during render (C-HOOKS). Locking the picker (readOnly/disabled) while the user types\n // drops the typed text and its error, so no later blur commits it (the value cannot change).\n const [wasInteractive, setWasInteractive] = React.useState(interactive);\n if (wasInteractive !== interactive) {\n setWasInteractive(interactive);\n if (!interactive) {\n setDraft(null);\n setInvalid(null);\n }\n }\n // A selected day the parent changes replaces rejected text (commits clear it themselves), so the\n // input never shows an error next to a valid value. Text the user is still typing stays.\n const selectedDay = selectedDate ? formatISODate(selectedDate) : '';\n const [seenDay, setSeenDay] = React.useState(selectedDay);\n if (seenDay !== selectedDay) {\n setSeenDay(selectedDay);\n if (invalid !== null) {\n setDraft(null);\n setInvalid(null);\n }\n }\n\n const isUnavailable = (date: Date) =>\n !isDateInRange(date, minDate, maxDate) || !!disabledDates?.(startOfDay(date));\n\n /** Commits a day (or `null`); nothing is emitted when it is the same day. */\n const commitDate = (next: Date | null) => {\n const normalized = next ? startOfDay(next) : null;\n const unchanged = normalized ? isSameDay(normalized, selectedDate) : selectedDate === null;\n if (!unchanged) setSelectedDate(normalized);\n setDraft(null);\n setInvalid(null);\n };\n\n /** Validates and commits the typed text; `false` when it was rejected (the text is kept). */\n const commitDraft = (text: string): boolean => {\n if (!text.trim()) {\n commitDate(null);\n return true;\n }\n const parsed = parse(text);\n let reason: DatePickerInvalidReason | null = null;\n if (!parsed || Number.isNaN(parsed.getTime())) reason = 'unparseable';\n else if (!isDateInRange(parsed, minDate, maxDate)) reason = 'out-of-range';\n else if (disabledDates?.(startOfDay(parsed))) reason = 'disabled';\n if (reason || !parsed) {\n const rejected = reason ?? 'unparseable';\n setInvalid(rejected);\n onInvalidInput?.(text, rejected);\n return false;\n }\n commitDate(parsed);\n return true;\n };\n\n /* ---- calendar view and focused day ------------------------------- */\n\n const today = startOfDay(new Date());\n const initialView = () => startOfMonth(clampDate(selectedDate ?? today, minDate, maxDate));\n const [viewMonth, setViewMonth] = React.useState<Date>(initialView);\n const [focusedDay, setFocusedDay] = React.useState<Date | null>(null);\n\n /** Opened with Alt+ArrowDown in the input: Escape returns focus there instead of the toggle. */\n const [openedFromInput, setOpenedFromInput] = React.useState(false);\n\n // Every opening shows the selected (or current) month again: adjusted during render (C-HOOKS).\n const [openSeen, setOpenSeen] = React.useState(isOpen);\n if (openSeen !== isOpen) {\n setOpenSeen(isOpen);\n if (isOpen) {\n setViewMonth(initialView());\n setFocusedDay(null);\n }\n }\n // A closed calendar forgets where it was opened from. This also drops an Alt+ArrowDown whose\n // opening a controlled parent declined (it renders in the same update, still closed), so a later\n // opening by the parent returns focus to the toggle, not the input.\n if (openedFromInput && !isOpen) setOpenedFromInput(false);\n\n const weeks = React.useMemo(\n () => toWeeks(getCalendarDays(viewMonth, firstDayOfWeek)),\n [viewMonth, firstDayOfWeek],\n );\n\n // The focused day is derived: the day moved to while it is shown (a pointer-focused day of the\n // previous/next month counts too), else the selected day of the month, else today (clamped into\n // the range), else the first available day of the month.\n const inView = (date: Date | null | undefined): date is Date =>\n !!date && isSameMonth(date, viewMonth);\n const inGrid = (date: Date | null | undefined): date is Date =>\n !!date && date >= weeks[0][0] && date <= weeks[weeks.length - 1][6];\n const clampedToday = clampDate(today, minDate, maxDate);\n const firstInRange = clampDate(viewMonth, minDate, maxDate);\n const focusTarget = inGrid(focusedDay)\n ? focusedDay\n : inView(selectedDate)\n ? startOfDay(selectedDate)\n : inView(clampedToday)\n ? clampedToday\n : inView(firstInRange)\n ? firstInRange\n : viewMonth;\n const focusIso = formatISODate(focusTarget);\n\n const moveFocus = (next: Date) => {\n const target = clampDate(next, minDate, maxDate);\n setFocusedDay(target);\n if (!isSameMonth(target, viewMonth)) setViewMonth(startOfMonth(target));\n };\n\n const navigateMonth = (delta: number) => {\n const nextView = addMonths(viewMonth, delta);\n const moved = clampDate(addMonths(focusTarget, delta), minDate, maxDate);\n setViewMonth(nextView);\n // From a day of the previous/next month the moved day may fall outside the new month: the\n // focused day is then derived again (selected, today or the first day of the month).\n setFocusedDay(isSameMonth(moved, nextView) ? moved : null);\n };\n\n /** Pointer (or assistive technology) focus on a day makes it the roving day; the month stays. */\n const handleDayFocus = (day: Date) => {\n if (!isSameDay(day, focusTarget)) setFocusedDay(day);\n };\n\n const previousDisabled = !!minDate && addDays(viewMonth, -1) < startOfDay(minDate);\n const nextDisabled = !!maxDate && addMonths(viewMonth, 1) > startOfDay(maxDate);\n\n const weekdays = React.useMemo(\n () => getWeekdayNames(locale, firstDayOfWeek),\n [locale, firstDayOfWeek],\n );\n\n /* ---- elements, popup primitives ---------------------------------- */\n\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n const toggleRef = React.useRef<HTMLButtonElement | null>(null);\n const gridRef = React.useRef<HTMLTableElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n /** Where focus goes when the calendar closes (`null`: back to the toggle). */\n const restoreTargetRef = React.useRef<HTMLElement | null>(null);\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n const inputRefs = useMergedRefs<HTMLInputElement>(controlRef, inputRef);\n\n const dialogId = useId('datepicker-dialog');\n const headingId = useId('datepicker-heading');\n const gridId = useId('datepicker-grid');\n const errorId = useId('datepicker-error');\n\n const close = (restoreTo: HTMLElement | null) => {\n restoreTargetRef.current = restoreTo;\n setOpen(false);\n };\n\n const { layerId } = useDismiss({\n open: isOpen,\n onDismiss: (reason, event) => {\n // An outside press on another control hands focus to it (the trap held it until now);\n // otherwise focus returns to where the calendar was opened from.\n const target =\n reason === 'outside-press' && event.target instanceof Element\n ? event.target.closest<HTMLElement>(FOCUSABLE_SELECTOR)\n : null;\n close(target ?? (openedFromInput ? inputRef.current : null));\n },\n refs: [surfaceRef, toggleRef],\n anchorRef: toggleRef,\n kind: 'modal',\n });\n\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open: isOpen,\n side: 'bottom',\n align: 'start',\n });\n const surfaceRefs = useMergedRefs<HTMLDivElement>(surfaceRef, setSurface, setFloating);\n\n useFocusTrap(surface, {\n enabled: isOpen,\n layerId,\n initialFocus: () => gridRef.current?.querySelector<HTMLElement>('button[tabindex=\"0\"]') ?? null,\n });\n\n useRestoreFocus({\n enabled: isOpen,\n container: surface,\n triggerRef: toggleRef,\n finalFocusRef: restoreTargetRef,\n onlyIfFocusInside: true,\n });\n\n // A new opening starts without a restore target (the toggle returns focus to itself, Escape to\n // where the calendar was opened from).\n React.useLayoutEffect(() => {\n if (isOpen) restoreTargetRef.current = null;\n }, [isOpen]);\n\n // Roving focus: while the grid holds focus, focus follows the focused day.\n React.useLayoutEffect(() => {\n const grid = gridRef.current;\n if (!grid) return;\n const active = grid.ownerDocument.activeElement;\n if (!active || !grid.contains(active)) return;\n const button = grid.querySelector<HTMLElement>(`button[data-date=\"${focusIso}\"]`);\n if (button && button !== active) button.focus();\n }, [focusIso]);\n\n /* ---- forms and Field --------------------------------------------- */\n\n const field = useFieldContext();\n const isRequired = required ?? field?.required ?? false;\n // Like a native readonly input, a read-only picker is barred from constraint validation (the\n // user could not fix it); its value is still submitted.\n const validates = isRequired && !readOnly;\n const showOwnError = invalid !== null && !field?.hasErrorMessage;\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': joinIds(ariaDescribedBy, showOwnError ? errorId : undefined),\n 'aria-invalid': invalid !== null ? true : ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required matches\n // `isRequired`.\n 'aria-required': ariaRequired ?? required,\n });\n const invalidLook = isInvalidLook(false, fieldProps['aria-invalid']);\n\n // Through the commit path: the default is emitted as local midnight, and only when it names\n // another day; the typed text and its error are dropped.\n useFormReset(inputRef, () => commitDate(defaultValue ?? null), form);\n\n // Read-only pickers offer no clear action (the value cannot change).\n const showClear = clearable && !readOnly && selectedDate !== null;\n\n /* ---- handlers ---------------------------------------------------- */\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (!interactive) return;\n setDraft(event.target.value);\n setInvalid(null);\n };\n\n const handleInputKeyDown = composeEventHandlers(\n onKeyDown,\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n // Keys that belong to an IME composition (its confirming Enter) are left to the IME.\n if (!interactive || event.nativeEvent.isComposing) return;\n if (event.key === 'Enter' && draft !== null) {\n // An edit is committed instead of submitting the form; untouched text lets Enter submit.\n event.preventDefault();\n commitDraft(draft);\n } else if (\n event.key === 'Tab' &&\n !event.shiftKey &&\n showClear &&\n draft !== null &&\n !draft.trim()\n ) {\n // Erased text clears the value, and with it the clear button, the next tab stop. It is\n // settled before Tab moves focus (the blur would settle it while focus moves to that\n // button), so focus moves on to the calendar button instead of dropping to <body> with\n // the clear button (C-DISABLED).\n flushSync(() => commitDraft(draft));\n } else if (event.key === 'ArrowDown' && event.altKey && !isOpen) {\n event.preventDefault();\n // The edit is committed first, so the calendar opens on the typed month; rejected text is\n // kept and reported once (the blur that follows does not report it again).\n if (draft !== null && invalid === null) commitDraft(draft);\n setOpenedFromInput(true);\n setOpen(true);\n }\n },\n );\n\n const handleInputBlur = composeEventHandlers(onBlur, () => {\n // Text already rejected (Enter, Alt+ArrowDown) is kept without being reported again.\n if (interactive && draft !== null && invalid === null) commitDraft(draft);\n });\n\n const handleToggle = () => {\n if (!interactive) return;\n restoreTargetRef.current = null;\n setOpenedFromInput(false);\n setOpen(!isOpen);\n };\n\n const handleClear = () => {\n if (!interactive) return;\n commitDate(null);\n inputRef.current?.focus();\n };\n\n // The clear button keeps focus on the input: its blur would otherwise commit (or reject) the\n // edited text just before the clear, emitting twice for one click.\n const handleClearMouseDown = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n };\n\n const selectDate = (day: Date) => {\n if (!interactive || isUnavailable(day)) return;\n commitDate(day);\n close(inputRef.current);\n };\n\n const handleDialogKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Escape' || event.defaultPrevented || event.nativeEvent.isComposing) return;\n // Consumed here, so enclosing layers (a Dialog around the picker) ignore it.\n event.preventDefault();\n close(openedFromInput ? inputRef.current : null);\n };\n\n const handleGridKeyDown = (event: React.KeyboardEvent<HTMLTableElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const weekOffset = (focusTarget.getDay() - firstDayOfWeek + 7) % 7;\n let next: Date;\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowRight': {\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n next = addDays(focusTarget, intent === 'next' ? 1 : -1);\n break;\n }\n case 'ArrowDown':\n next = addDays(focusTarget, 7);\n break;\n case 'ArrowUp':\n next = addDays(focusTarget, -7);\n break;\n case 'PageDown':\n next = addMonths(focusTarget, event.shiftKey ? 12 : 1);\n break;\n case 'PageUp':\n next = addMonths(focusTarget, event.shiftKey ? -12 : -1);\n break;\n case 'Home':\n next = addDays(focusTarget, -weekOffset);\n break;\n case 'End':\n next = addDays(focusTarget, 6 - weekOffset);\n break;\n default:\n // Enter and Space activate the focused day button natively (click).\n return;\n }\n event.preventDefault();\n moveFocus(next);\n };\n\n /* ---- render ------------------------------------------------------ */\n\n const inputText = draft ?? (selectedDate ? format(selectedDate) : '');\n\n let errorMessage = '';\n if (invalid === 'unparseable') {\n errorMessage = (labels?.invalidDate ?? defaultInvalidDateLabel)(\n hasCustomParse ? undefined : getLocaleDateFormat(locale).pattern,\n );\n } else if (invalid === 'out-of-range' && (minDate || maxDate)) {\n errorMessage = (labels?.outOfRange ?? defaultOutOfRangeLabel)(\n minDate ? format(startOfDay(minDate)) : undefined,\n maxDate ? format(startOfDay(maxDate)) : undefined,\n );\n } else if (invalid === 'disabled') {\n errorMessage = labels?.unavailableDate ?? 'This date is not available.';\n }\n\n return (\n <div\n data-size={size}\n data-appearance={appearance}\n {...rest}\n ref={ref}\n className={cn(datePickerClassNames.root, 'relative inline-flex flex-col', className)}\n >\n <div ref={setReference} className=\"relative flex items-center\">\n <input\n ref={inputRefs}\n type=\"text\"\n {...fieldProps}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n value={inputText}\n onChange={handleInputChange}\n onFocus={onFocus}\n onBlur={handleInputBlur}\n onKeyDown={handleInputKeyDown}\n onKeyUp={onKeyUp}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n autoComplete={autoComplete}\n autoCapitalize={autoCapitalize}\n autoCorrect={autoCorrect}\n enterKeyHint={enterKeyHint}\n inputMode={inputMode}\n spellCheck={spellCheck}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n className={cn(\n datePickerClassNames.input,\n inputHeightClasses[size],\n 'w-full',\n inputPaddingClasses[size],\n inputTextClasses[size],\n inputAppearanceClasses[appearance],\n 'text-foreground placeholder:text-muted-foreground',\n inputFocus,\n disabledStyles,\n invalidLook && inputInvalid,\n pickerEndPadding(showClear ? 2 : 1, size),\n )}\n />\n {showClear && (\n <button\n type=\"button\"\n aria-label={labels?.clear ?? 'Clear date'}\n disabled={disabled}\n onMouseDown={handleClearMouseDown}\n onClick={handleClear}\n className={cn(\n datePickerClassNames.clearButton,\n pickerIconButtonClasses(size, appearance),\n pickerButtonOffset(size, 2),\n focusRing,\n disabledStyles,\n )}\n >\n <DismissIcon size={pickerGlyphSize(size, 'icon')} />\n </button>\n )}\n <button\n ref={toggleRef}\n type=\"button\"\n aria-label={labels?.openCalendar ?? 'Open calendar'}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? dialogId : undefined}\n disabled={disabled || readOnly}\n onClick={handleToggle}\n className={cn(\n datePickerClassNames.openCalendarButton,\n pickerIconButtonClasses(size, appearance),\n pickerButtonOffset(size, 1),\n focusRing,\n disabledStyles,\n )}\n >\n <CalendarIcon size={pickerGlyphSize(size, 'icon')} />\n </button>\n </div>\n {showOwnError && (\n <p\n id={errorId}\n role=\"alert\"\n className={cn(datePickerClassNames.errorMessage, 'mt-1 text-caption-1 text-error')}\n >\n {errorMessage}\n </p>\n )}\n <HiddenInput\n name={name}\n form={form}\n disabled={disabled}\n value={selectedDate ? formatISODate(selectedDate) : ''}\n type=\"text\"\n required={validates}\n onInvalid={() => inputRef.current?.focus()}\n />\n {isOpen && (\n <Portal layerId={layerId}>\n <div\n ref={surfaceRefs}\n id={dialogId}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={headingId}\n {...floatingProps}\n data-state=\"open\"\n onKeyDown={handleDialogKeyDown}\n className={cn(\n datePickerClassNames.surface,\n 'rounded-md border border-border bg-background p-3 text-foreground shadow-16',\n )}\n >\n <div\n className={cn(\n datePickerClassNames.header,\n 'mb-2 flex items-center justify-between gap-2',\n )}\n >\n <button\n type=\"button\"\n aria-label={labels?.previousMonth ?? 'Previous month'}\n aria-controls={gridId}\n {...focusableDisabledProps(previousDisabled)}\n onClick={preventIfDisabled(previousDisabled, () => navigateMonth(-1))}\n className={cn(\n datePickerClassNames.previousMonthButton,\n NAV_BUTTON_CLASSES,\n focusRing,\n disabledStyles,\n )}\n >\n <ChevronLeftIcon className=\"wave-rtl:-scale-x-100\" />\n </button>\n <h2\n id={headingId}\n aria-live=\"polite\"\n className={cn(datePickerClassNames.heading, 'text-body-1 font-semibold')}\n >\n {formatMonthYear(viewMonth, locale)}\n </h2>\n <button\n type=\"button\"\n aria-label={labels?.nextMonth ?? 'Next month'}\n aria-controls={gridId}\n {...focusableDisabledProps(nextDisabled)}\n onClick={preventIfDisabled(nextDisabled, () => navigateMonth(1))}\n className={cn(\n datePickerClassNames.nextMonthButton,\n NAV_BUTTON_CLASSES,\n focusRing,\n disabledStyles,\n )}\n >\n <ChevronRightIcon className=\"wave-rtl:-scale-x-100\" />\n </button>\n </div>\n <table\n ref={gridRef}\n id={gridId}\n role=\"grid\"\n aria-labelledby={headingId}\n onKeyDown={handleGridKeyDown}\n className={cn(datePickerClassNames.grid, 'border-collapse')}\n >\n <thead>\n <tr>\n {weekdays.map((weekday) => (\n <th\n key={weekday.long}\n scope=\"col\"\n abbr={weekday.long}\n aria-label={weekday.long}\n className={cn(\n datePickerClassNames.weekday,\n 'h-8 w-8 text-center text-caption-1 font-normal text-muted-foreground',\n )}\n >\n <span aria-hidden=\"true\">{weekday.short}</span>\n <span className=\"sr-only\">{weekday.long}</span>\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {weeks.map((week, row) => (\n // Rows and cells are keyed by position, so the focused button survives a\n // month change and focus stays in the grid while it moves to the new day.\n <tr key={row}>\n {week.map((day, column) => {\n const iso = formatISODate(day);\n const isSelected = isSameDay(day, selectedDate);\n const isToday = isSameDay(day, today);\n const isFocused = iso === focusIso;\n const unavailable = isUnavailable(day);\n return (\n <td key={column} role=\"gridcell\" aria-selected={isSelected} className=\"p-0\">\n {/* Focus rests on the button, and screen readers do not reliably\n announce the gridcell's aria-selected from inside it: the selected\n day's button is also pressed. */}\n <button\n type=\"button\"\n tabIndex={isFocused ? 0 : -1}\n aria-label={formatDayLabel(day, locale)}\n aria-pressed={isSelected || undefined}\n aria-current={isToday ? 'date' : undefined}\n {...focusableDisabledProps(unavailable)}\n data-date={iso}\n data-selected={isSelected ? '' : undefined}\n data-today={isToday ? '' : undefined}\n data-outside={isSameMonth(day, viewMonth) ? undefined : ''}\n onFocus={() => handleDayFocus(day)}\n onClick={() => selectDate(day)}\n className={cn(\n datePickerClassNames.day,\n DAY_CLASSES,\n focusRing,\n disabledStyles,\n isSelected && forcedColors.selectedLeaf,\n )}\n >\n {formatDayNumber(day, locale)}\n </button>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </Portal>\n )}\n </div>\n );\n};\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":"ulCA6GA,IAAMqF,GAA2B,GAC/BC,EAAU,8BAA8BA,EAAQ,GAAK,sBAEjDC,IAA0B,EAAyB,IACnDC,IAAQ,IAAA,IAAaC,IAAQ,IAAA,GAAkB,wBAAwBD,EAAI,OAAOC,EAAI,GACtFD,IAAQ,IAAA,GACL,6BAA6BC,EAAI,GADV,4BAA4BD,EAAI,GAgJ1DE,GACJ,2IAIIC,GACJ,4cAGF,SAASC,GAAQ,EAAwB,CACvC,IAAMC,EAAkB,CAAC,EACzB,IAAK,IAAIC,EAAI,EAAGA,EAAIC,EAAK,OAAQ,GAAK,EAAGF,EAAM,KAAKE,EAAK,MAAMD,EAAGA,EAAI,CAAC,CAAC,EACxE,OAAOD,CACT,CA8CA,IAAaG,EAAc,GAA2B,CACpD,GAAM,CACJ,MAAOC,EACP,gBACA,iBACA,YACA,WAAYC,EACZ,UAAWC,EACX,SACA,UACA,UACA,iBACA,eAAc,gBACd,WAAW,GACX,KAAMC,GACN,WAAY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