@tedi-design-system/react 19.0.0-rc.11 → 19.0.0-rc.13
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/bundle-stats.html +1 -1
- package/package.json +1 -1
- package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field.d.ts +6 -0
- package/src/tedi/components/form/date-field/date-field.es.js +163 -162
- package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -1
- package/src/tedi/components/form/date-time-field/date-time-field.d.ts +6 -0
- package/src/tedi/components/form/date-time-field/date-time-field.es.js +101 -100
- package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
- package/src/tedi/components/form/time-field/time-field.d.ts +6 -0
- package/src/tedi/components/form/time-field/time-field.es.js +37 -36
- package/src/tedi/helpers/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tedi-design-system/react",
|
|
3
|
-
"version": "19.0.0-rc.
|
|
3
|
+
"version": "19.0.0-rc.13",
|
|
4
4
|
"description": "TEDI Design System React component library — accessible, reusable UI components. Docs & live examples: https://storybook.tedi.ee/react/rc/",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),A=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),I=require("../../../../../external/classnames/index.cjs.js"),a=require("react"),Ct=require("../../content/calendar/calendar.cjs.js"),At=require("../multi-value-field/multi-value-field.cjs.js"),Ft=require("../textfield/textfield.cjs.js"),D=require("./date-field.module.scss.cjs.js"),v=require("./date-field-helpers.cjs.js"),kt=require("./date-picker-modal/date-picker-modal.cjs.js"),vt=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),Pt=require("../../../providers/label-provider/use-labels.cjs.js"),wt=require("../../../../../external/react-day-picker/dist/esm/locale/et.cjs.js"),me=require("../../../helpers/hooks/use-breakpoint.cjs.js"),Nt=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),G=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),Et=require("../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.cjs.js"),Le=a.forwardRef((P,w)=>{const{getCurrentBreakpointProps:$e}=vt.useBreakpointProps(P.defaultServerBreakpoint),{getLabel:z}=Pt.useLabels(),{useNativePicker:He=!1,enableCalendar:h=!0,calendarTrigger:T="button",numberOfMonths:X}=$e(P),{id:pe,mode:l="single",label:he,selected:j,onSelect:i,disabled:N,disabledMatchers:E,placeholder:Ye,className:Ue,formatDate:c,required:S,showOutsideDays:ge=!0,parseDate:We,monthYearSelectType:be,minYear:ye,maxYear:De,dayStatus:_e,tagsDirection:Ge,showNavigation:xe=!0,selectionLevel:O="days",initialView:L,locale:Me=wt.et,localeCode:$="et-EE",initialMonth:H,closeOnSelect:ze,footer:Ce,defaultValue:Y,minDate:J,maxDate:K,disablePast:Ae,disableFuture:Fe,shouldDisableMonth:Q,shouldDisableYear:Z,readOnly:R,availableDays:ke,inputProps:n,modal:ee=!1,modalProps:Xe,modalTitle:Je,disabledDateErrorMessage:Ke=z("dateField.disabledDateError"),invalidDateErrorMessage:Qe=z("dateField.invalidDateError"),useNativePicker:Ot,enableCalendar:Rt,calendarTrigger:Vt,numberOfMonths:qt,defaultServerBreakpoint:Bt,sm:It,md:Tt,lg:jt,xl:St,xxl:Lt,...ve}=P,f=He&&l==="single",Pe=me.default(P.defaultServerBreakpoint),F=me.isBreakpointBelow(Pe,"md"),[Ze,g]=a.useState(j??Y),[b,V]=a.useState(!1),[te,we]=a.useState(!1),[et,Ne]=a.useState(L??O),[re,_]=a.useState(""),[Ee,m]=a.useState(!1),[Oe,ae]=a.useState(!1),y=h&&!f&&!R&&(ee===!0||typeof ee=="string"&&me.isBreakpointBelow(Pe,ee)),Re=F&&!y&&typeof X=="number"&&X>1?1:X,{current:u}=a.useRef("selected"in P),s=u?j:Ze,ie=a.useRef(null),Ve=a.useRef(null),tt=a.useCallback(e=>{ie.current=e,typeof w=="function"?w(e):w&&(w.current=e)},[w]),rt=e=>{if(!e)return"";const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${o}`},at=f&&s instanceof Date?rt(s):"",ne=a.useCallback((e,t)=>e instanceof Date?e:Array.isArray(e)&&e.length>0?[...e].sort((r,o)=>r.getTime()-o.getTime())[0]:e&&typeof e=="object"&&"from"in e&&e.from instanceof Date?e.from:e&&typeof e=="object"&&"to"in e&&e.to instanceof Date?e.to:t??new Date,[]),[it,se]=a.useState(()=>ne(s,H));a.useEffect(()=>{b||se(ne(s,H))},[s,H,b,ne]),a.useEffect(()=>{b&&Ne(L??O)},[b,O,L]),a.useEffect(()=>{u&&g(j)},[j,u]);const x=a.useMemo(()=>new Intl.DateTimeFormat($,{day:"2-digit",month:"2-digit",year:"numeric"}),[$]),M=a.useCallback(e=>{if(!e)return"";if(e instanceof Date)return x.format(e);if(Array.isArray(e))return e.map(t=>x.format(t)).join(", ");if(e.from){const t=x.format(e.from);return e.to?`${t} – ${x.format(e.to)}`:t}return""},[x]),oe=ze??l==="single",qe=l==="multiple"&&Array.isArray(s)?s.map((e,t)=>({id:t,label:c?c(e):M(e),date:e})):[],U=a.useMemo(()=>{const e=[];return N&&(Array.isArray(N)?e.push(...N):e.push(N)),E&&(Array.isArray(E)?e.push(...E):e.push(E)),J&&e.push({before:J}),K&&e.push({after:K}),Ae&&e.push({before:new Date}),Fe&&e.push({after:new Date}),Q&&e.push(t=>Q(t)),Z&&e.push(t=>Z(t)),e},[N,E,J,K,Ae,Fe,Q,Z]),k=a.useCallback(e=>Et.dateMatchModifiers(e,U),[U]),nt=(e,t,r,o)=>{const d=l==="range"?v.resolveRangeSelection(e,s,t):e;if(m(!1),u||g(d),i==null||i(d,t,r,o),d){const C=c?c(d):M(d);_(C)}else _("");oe&&V(!1)},st=e=>{if(k(e))return;const t=l==="range"?{from:e,to:void 0}:l==="multiple"?[...Array.isArray(s)?s:[],e]:e;m(!1),u||g(t),i==null||i(t,e,{},{});const r=c?c(t):M(t);_(r),oe&&V(!1)},ot=a.useMemo(()=>{const e=v.getLocaleDateParts(x),t=new RegExp(`^${v.buildDateRegexSource(e)}$`),{fieldOrder:r}=e;return o=>{const d=o.match(t);if(!d)return;const C={};r.forEach((xt,Mt)=>{C[xt]=Number(d[Mt+1])});const{day:ue,month:ce,year:fe}=C;if(ue===void 0||ce===void 0||fe===void 0)return;const B=new Date(fe,ce-1,ue);if(!(isNaN(B.getTime())||B.getFullYear()!==fe||B.getMonth()!==ce-1||B.getDate()!==ue))return B}},[x]),Be=e=>(We??(l==="single"?ot:()=>{}))(e),Ie=e=>l==="single"&&e instanceof Date||l==="multiple"&&Array.isArray(e)||l==="range"&&!!e&&!Array.isArray(e)&&"from"in e,lt=e=>{if(_(e),ae(!1),e.trim()===""){m(!1),s!==void 0&&(u||g(void 0),i==null||i(void 0,void 0,{},{}));return}const t=Be(e);if(!Ie(t)){m(!1);return}const o=t&&!Array.isArray(t)&&"from"in t?t:null;if(t instanceof Date&&k(t)||Array.isArray(t)&&t.some(C=>C instanceof Date&&k(C))||!!o&&(o.from&&k(o.from)||o.to&&k(o.to))){m(!0);return}m(!1),u||g(t),i==null||i(t,t,{},{}),t instanceof Date&&se(t),oe&&V(!1)},dt=()=>{if(re.trim()===""){ae(!1);return}ae(!Ie(Be(re)))};a.useEffect(()=>{if(u){const e=c?c(s):M(s);_(e)}},[s,u,c,M]),a.useEffect(()=>{if(!u&&Y){const e=c?c(Y):M(Y);_(e)}},[]);const ut=A.useFloating({open:b,onOpenChange:V,placement:T==="input"?"bottom-start":"bottom-end",middleware:[G.offset(v.CALENDAR_POPOVER_OFFSET),G.flip(),G.shift({padding:v.CALENDAR_POPOVER_PADDING}),G.size({padding:v.CALENDAR_POPOVER_PADDING,apply({availableWidth:e,elements:t}){const r=t.floating;if(r.style.width="",r.style.maxWidth="",r.style.overflowX="",F)return;r.style.width="max-content",r.getBoundingClientRect().width>e&&(r.style.width="min-content",r.style.maxWidth=`${e}px`)}})],whileElementsMounted:Nt.autoUpdate}),{refs:q,context:W,x:ct,y:ft,strategy:mt}=ut,pt=A.useClick(W),Te=A.useInteractions([...h&&!f&&T==="input"&&!y?[pt]:[],A.useDismiss(W,{outsidePress:e=>{const t=e.target;return!(t!=null&&t.closest('[role="menu"], [role="listbox"]'))}}),A.useRole(W,{role:"dialog"})]);a.useEffect(()=>{var t,r;const e=l==="multiple"?((t=Ve.current)==null?void 0:t.wrapper)??null:((r=ie.current)==null?void 0:r.input)??null;q.setPositionReference(e??q.reference.current)},[l,b,q]);const ht=()=>{var t;const e=(t=ie.current)==null?void 0:t.input;if(e){if(typeof e.showPicker=="function")try{e.showPicker();return}catch{}e.focus()}},le=()=>{!h||R||(f?ht():y?we(!0):V(e=>!e))},gt=e=>{if(m(!1),u||g(e),i==null||i(e,e,{},{}),e){const t=c?c(e):M(e);_(t)}else _("")},bt=e=>{if(!e){m(!1),u||g(void 0),i==null||i(void 0,void 0,{},{});return}const[t,r,o]=e.split("-").map(Number);if(!t||!r||!o)return;const d=new Date(t,r-1,o);if(!Number.isNaN(d.getTime())){if(k(d)){m(!0);return}m(!1),u||g(d),i==null||i(d,d,{},{})}},yt=Te.getReferenceProps(y&&T==="input"?{onClick:()=>le()}:void 0),{role:$t,"aria-expanded":Ht,"aria-haspopup":Yt,"aria-controls":Dt,..._t}=yt,je=y?void 0:Dt,de=z("dateField.openCalendar"),Se={"aria-label":de,"aria-expanded":y?te:b,"aria-haspopup":"dialog","aria-controls":je};return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:I.default(D.default["tedi-date-field__container"],Ue),..._t,ref:q.setReference,children:l==="multiple"?p.jsx(At.MultiValueField,{...n,ref:Ve,id:pe,label:he,tagsDirection:Ge,values:qe.map(e=>e.label),icon:"calendar_today",onIconClick:le,iconButtonProps:h?Se:{"aria-label":de},isClearable:!0,required:S,onChange:e=>{if(!Array.isArray(s))return;const t=qe.filter(r=>e.includes(r.label)).map(r=>r.date);u||g(t),i==null||i(t,{},{},{})},className:I.default(D.default["tedi-date-field__textfield"],{[D.default["tedi-date-field__icon--disabled"]]:!h||R})}):p.jsx(Ft.TextField,{...n,ref:tt,id:pe,label:he,readOnly:R,value:f?at:re,placeholder:Ye,icon:"calendar_today",isClearable:!0,onIconClick:le,iconButtonProps:h&&!f?Se:{"aria-label":de},onChange:e=>f?bt(e):lt(e),onBlur:e=>{var t;f||dt(),(t=n==null?void 0:n.onBlur)==null||t.call(n,e)},required:S,invalid:Ee||Oe||(n==null?void 0:n.invalid),helper:(()=>{const e=n==null?void 0:n.helper,t=Ee?Ke:Oe?Qe:null,r=t?{text:t,type:"error"}:null;return r?e?Array.isArray(e)?[...e,r]:[e,r]:r:e})(),className:I.default(D.default["tedi-date-field__textfield"],{[D.default["tedi-date-field__textfield--disabled"]]:n==null?void 0:n.disabled,[D.default["tedi-date-field__icon--disabled"]]:!h||R}),input:{...n==null?void 0:n.input,...f&&{type:"date"},...h&&!f&&T==="input"?{role:"combobox","aria-haspopup":"dialog","aria-expanded":y?te:b,"aria-controls":je}:{}}})}),y&&p.jsx(kt.DatePickerModal,{open:te,onOpenChange:we,value:s,onConfirm:gt,mode:l,numberOfMonths:Re,locale:Me,localeCode:$,showOutsideDays:ge,disabledMatchers:U,required:S,availableDays:ke,footer:Ce,monthYearSelectType:be,minYear:ye,maxYear:De,dayStatus:_e,showNavigation:xe,selectionLevel:O,initialView:L,initialMonth:H,modalProps:Xe,...ve,title:Je}),h&&!f&&!y&&p.jsx(A.FloatingPortal,{children:b&&p.jsx(A.FloatingFocusManager,{context:W,modal:!1,initialFocus:-1,children:p.jsx("div",{ref:q.setFloating,className:I.default({[D.default["tedi-date-field__calendar-popover--fullwidth"]]:F}),...Te.getFloatingProps({style:{position:mt,top:ft??0,left:F?0:ct??0,right:F?0:void 0}}),children:p.jsx(Ct.Calendar,{...ve,numberOfMonths:Re,view:et,selectionLevel:O,currentMonth:it,setCurrentMonth:se,setView:Ne,mode:l,value:s,locale:Me,localeCode:$,showOutsideDays:ge,disabledMatchers:U,required:S,availableDays:ke,footer:Ce,monthYearSelectType:be,minYear:ye,maxYear:De,dayStatus:_e,showNavigation:xe,handleSelect:nt,applyValue:st,className:I.default(D.default["tedi-date-field__calendar"],{[D.default["tedi-date-field__calendar--fullwidth"]]:F})})})})})]})});Le.displayName="DateField";exports.DateField=Le;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),A=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),I=require("../../../../../external/classnames/index.cjs.js"),a=require("react"),At=require("../../content/calendar/calendar.cjs.js"),Ft=require("../multi-value-field/multi-value-field.cjs.js"),kt=require("../textfield/textfield.cjs.js"),D=require("./date-field.module.scss.cjs.js"),v=require("./date-field-helpers.cjs.js"),vt=require("./date-picker-modal/date-picker-modal.cjs.js"),Pt=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),wt=require("../../../providers/label-provider/use-labels.cjs.js"),Nt=require("../../../../../external/react-day-picker/dist/esm/locale/et.cjs.js"),me=require("../../../helpers/hooks/use-breakpoint.cjs.js"),Et=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),G=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),Ot=require("../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.cjs.js"),$e=a.forwardRef((P,w)=>{const{getCurrentBreakpointProps:He}=Pt.useBreakpointProps(P.defaultServerBreakpoint),{getLabel:z}=wt.useLabels(),{useNativePicker:Ye=!1,enableCalendar:h=!0,calendarTrigger:T="button",numberOfMonths:X,clearable:pe=!0}=He(P),{id:he,mode:l="single",label:ge,selected:j,onSelect:i,disabled:N,disabledMatchers:E,placeholder:Ue,className:We,formatDate:c,required:S,showOutsideDays:be=!0,parseDate:Ge,monthYearSelectType:ye,minYear:De,maxYear:_e,dayStatus:xe,tagsDirection:ze,showNavigation:Me=!0,selectionLevel:O="days",initialView:L,locale:Ce=Nt.et,localeCode:$="et-EE",initialMonth:H,closeOnSelect:Xe,footer:Ae,defaultValue:Y,minDate:J,maxDate:K,disablePast:Fe,disableFuture:ke,shouldDisableMonth:Q,shouldDisableYear:Z,readOnly:R,availableDays:ve,inputProps:n,modal:ee=!1,modalProps:Je,modalTitle:Ke,disabledDateErrorMessage:Qe=z("dateField.disabledDateError"),invalidDateErrorMessage:Ze=z("dateField.invalidDateError"),useNativePicker:Rt,enableCalendar:Vt,calendarTrigger:qt,numberOfMonths:Bt,defaultServerBreakpoint:It,sm:Tt,md:jt,lg:St,xl:Lt,xxl:$t,...Pe}=P,f=Ye&&l==="single",we=me.default(P.defaultServerBreakpoint),F=me.isBreakpointBelow(we,"md"),[et,g]=a.useState(j??Y),[b,V]=a.useState(!1),[te,Ne]=a.useState(!1),[tt,Ee]=a.useState(L??O),[re,_]=a.useState(""),[Oe,m]=a.useState(!1),[Re,ae]=a.useState(!1),y=h&&!f&&!R&&(ee===!0||typeof ee=="string"&&me.isBreakpointBelow(we,ee)),Ve=F&&!y&&typeof X=="number"&&X>1?1:X,{current:u}=a.useRef("selected"in P),s=u?j:et,ie=a.useRef(null),qe=a.useRef(null),rt=a.useCallback(e=>{ie.current=e,typeof w=="function"?w(e):w&&(w.current=e)},[w]),at=e=>{if(!e)return"";const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${o}`},it=f&&s instanceof Date?at(s):"",ne=a.useCallback((e,t)=>e instanceof Date?e:Array.isArray(e)&&e.length>0?[...e].sort((r,o)=>r.getTime()-o.getTime())[0]:e&&typeof e=="object"&&"from"in e&&e.from instanceof Date?e.from:e&&typeof e=="object"&&"to"in e&&e.to instanceof Date?e.to:t??new Date,[]),[nt,se]=a.useState(()=>ne(s,H));a.useEffect(()=>{b||se(ne(s,H))},[s,H,b,ne]),a.useEffect(()=>{b&&Ee(L??O)},[b,O,L]),a.useEffect(()=>{u&&g(j)},[j,u]);const x=a.useMemo(()=>new Intl.DateTimeFormat($,{day:"2-digit",month:"2-digit",year:"numeric"}),[$]),M=a.useCallback(e=>{if(!e)return"";if(e instanceof Date)return x.format(e);if(Array.isArray(e))return e.map(t=>x.format(t)).join(", ");if(e.from){const t=x.format(e.from);return e.to?`${t} – ${x.format(e.to)}`:t}return""},[x]),oe=Xe??l==="single",Be=l==="multiple"&&Array.isArray(s)?s.map((e,t)=>({id:t,label:c?c(e):M(e),date:e})):[],U=a.useMemo(()=>{const e=[];return N&&(Array.isArray(N)?e.push(...N):e.push(N)),E&&(Array.isArray(E)?e.push(...E):e.push(E)),J&&e.push({before:J}),K&&e.push({after:K}),Fe&&e.push({before:new Date}),ke&&e.push({after:new Date}),Q&&e.push(t=>Q(t)),Z&&e.push(t=>Z(t)),e},[N,E,J,K,Fe,ke,Q,Z]),k=a.useCallback(e=>Ot.dateMatchModifiers(e,U),[U]),st=(e,t,r,o)=>{const d=l==="range"?v.resolveRangeSelection(e,s,t):e;if(m(!1),u||g(d),i==null||i(d,t,r,o),d){const C=c?c(d):M(d);_(C)}else _("");oe&&V(!1)},ot=e=>{if(k(e))return;const t=l==="range"?{from:e,to:void 0}:l==="multiple"?[...Array.isArray(s)?s:[],e]:e;m(!1),u||g(t),i==null||i(t,e,{},{});const r=c?c(t):M(t);_(r),oe&&V(!1)},lt=a.useMemo(()=>{const e=v.getLocaleDateParts(x),t=new RegExp(`^${v.buildDateRegexSource(e)}$`),{fieldOrder:r}=e;return o=>{const d=o.match(t);if(!d)return;const C={};r.forEach((Mt,Ct)=>{C[Mt]=Number(d[Ct+1])});const{day:ue,month:ce,year:fe}=C;if(ue===void 0||ce===void 0||fe===void 0)return;const B=new Date(fe,ce-1,ue);if(!(isNaN(B.getTime())||B.getFullYear()!==fe||B.getMonth()!==ce-1||B.getDate()!==ue))return B}},[x]),Ie=e=>(Ge??(l==="single"?lt:()=>{}))(e),Te=e=>l==="single"&&e instanceof Date||l==="multiple"&&Array.isArray(e)||l==="range"&&!!e&&!Array.isArray(e)&&"from"in e,dt=e=>{if(_(e),ae(!1),e.trim()===""){m(!1),s!==void 0&&(u||g(void 0),i==null||i(void 0,void 0,{},{}));return}const t=Ie(e);if(!Te(t)){m(!1);return}const o=t&&!Array.isArray(t)&&"from"in t?t:null;if(t instanceof Date&&k(t)||Array.isArray(t)&&t.some(C=>C instanceof Date&&k(C))||!!o&&(o.from&&k(o.from)||o.to&&k(o.to))){m(!0);return}m(!1),u||g(t),i==null||i(t,t,{},{}),t instanceof Date&&se(t),oe&&V(!1)},ut=()=>{if(re.trim()===""){ae(!1);return}ae(!Te(Ie(re)))};a.useEffect(()=>{if(u){const e=c?c(s):M(s);_(e)}},[s,u,c,M]),a.useEffect(()=>{if(!u&&Y){const e=c?c(Y):M(Y);_(e)}},[]);const ct=A.useFloating({open:b,onOpenChange:V,placement:T==="input"?"bottom-start":"bottom-end",middleware:[G.offset(v.CALENDAR_POPOVER_OFFSET),G.flip(),G.shift({padding:v.CALENDAR_POPOVER_PADDING}),G.size({padding:v.CALENDAR_POPOVER_PADDING,apply({availableWidth:e,elements:t}){const r=t.floating;if(r.style.width="",r.style.maxWidth="",r.style.overflowX="",F)return;r.style.width="max-content",r.getBoundingClientRect().width>e&&(r.style.width="min-content",r.style.maxWidth=`${e}px`)}})],whileElementsMounted:Et.autoUpdate}),{refs:q,context:W,x:ft,y:mt,strategy:pt}=ct,ht=A.useClick(W),je=A.useInteractions([...h&&!f&&T==="input"&&!y?[ht]:[],A.useDismiss(W,{outsidePress:e=>{const t=e.target;return!(t!=null&&t.closest('[role="menu"], [role="listbox"]'))}}),A.useRole(W,{role:"dialog"})]);a.useEffect(()=>{var t,r;const e=l==="multiple"?((t=qe.current)==null?void 0:t.wrapper)??null:((r=ie.current)==null?void 0:r.input)??null;q.setPositionReference(e??q.reference.current)},[l,b,q]);const gt=()=>{var t;const e=(t=ie.current)==null?void 0:t.input;if(e){if(typeof e.showPicker=="function")try{e.showPicker();return}catch{}e.focus()}},le=()=>{!h||R||(f?gt():y?Ne(!0):V(e=>!e))},bt=e=>{if(m(!1),u||g(e),i==null||i(e,e,{},{}),e){const t=c?c(e):M(e);_(t)}else _("")},yt=e=>{if(!e){m(!1),u||g(void 0),i==null||i(void 0,void 0,{},{});return}const[t,r,o]=e.split("-").map(Number);if(!t||!r||!o)return;const d=new Date(t,r-1,o);if(!Number.isNaN(d.getTime())){if(k(d)){m(!0);return}m(!1),u||g(d),i==null||i(d,d,{},{})}},Dt=je.getReferenceProps(y&&T==="input"?{onClick:()=>le()}:void 0),{role:Ht,"aria-expanded":Yt,"aria-haspopup":Ut,"aria-controls":_t,...xt}=Dt,Se=y?void 0:_t,de=z("dateField.openCalendar"),Le={"aria-label":de,"aria-expanded":y?te:b,"aria-haspopup":"dialog","aria-controls":Se};return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:I.default(D.default["tedi-date-field__container"],We),...xt,ref:q.setReference,children:l==="multiple"?p.jsx(Ft.MultiValueField,{...n,ref:qe,id:he,label:ge,tagsDirection:ze,values:Be.map(e=>e.label),icon:"calendar_today",onIconClick:le,iconButtonProps:h?Le:{"aria-label":de},isClearable:pe,required:S,onChange:e=>{if(!Array.isArray(s))return;const t=Be.filter(r=>e.includes(r.label)).map(r=>r.date);u||g(t),i==null||i(t,{},{},{})},className:I.default(D.default["tedi-date-field__textfield"],{[D.default["tedi-date-field__icon--disabled"]]:!h||R})}):p.jsx(kt.TextField,{...n,ref:rt,id:he,label:ge,readOnly:R,value:f?it:re,placeholder:Ue,icon:"calendar_today",isClearable:pe,onIconClick:le,iconButtonProps:h&&!f?Le:{"aria-label":de},onChange:e=>f?yt(e):dt(e),onBlur:e=>{var t;f||ut(),(t=n==null?void 0:n.onBlur)==null||t.call(n,e)},required:S,invalid:Oe||Re||(n==null?void 0:n.invalid),helper:(()=>{const e=n==null?void 0:n.helper,t=Oe?Qe:Re?Ze:null,r=t?{text:t,type:"error"}:null;return r?e?Array.isArray(e)?[...e,r]:[e,r]:r:e})(),className:I.default(D.default["tedi-date-field__textfield"],{[D.default["tedi-date-field__textfield--disabled"]]:n==null?void 0:n.disabled,[D.default["tedi-date-field__icon--disabled"]]:!h||R}),input:{...n==null?void 0:n.input,...f&&{type:"date"},...h&&!f&&T==="input"?{role:"combobox","aria-haspopup":"dialog","aria-expanded":y?te:b,"aria-controls":Se}:{}}})}),y&&p.jsx(vt.DatePickerModal,{open:te,onOpenChange:Ne,value:s,onConfirm:bt,mode:l,numberOfMonths:Ve,locale:Ce,localeCode:$,showOutsideDays:be,disabledMatchers:U,required:S,availableDays:ve,footer:Ae,monthYearSelectType:ye,minYear:De,maxYear:_e,dayStatus:xe,showNavigation:Me,selectionLevel:O,initialView:L,initialMonth:H,modalProps:Je,...Pe,title:Ke}),h&&!f&&!y&&p.jsx(A.FloatingPortal,{children:b&&p.jsx(A.FloatingFocusManager,{context:W,modal:!1,initialFocus:-1,children:p.jsx("div",{ref:q.setFloating,className:I.default({[D.default["tedi-date-field__calendar-popover--fullwidth"]]:F}),...je.getFloatingProps({style:{position:pt,top:mt??0,left:F?0:ft??0,right:F?0:void 0}}),children:p.jsx(At.Calendar,{...Pe,numberOfMonths:Ve,view:tt,selectionLevel:O,currentMonth:nt,setCurrentMonth:se,setView:Ee,mode:l,value:s,locale:Ce,localeCode:$,showOutsideDays:be,disabledMatchers:U,required:S,availableDays:ve,footer:Ae,monthYearSelectType:ye,minYear:De,maxYear:_e,dayStatus:xe,showNavigation:Me,handleSelect:st,applyValue:ot,className:I.default(D.default["tedi-date-field__calendar"],{[D.default["tedi-date-field__calendar--fullwidth"]]:F})})})})})]})});$e.displayName="DateField";exports.DateField=$e;
|
|
@@ -38,6 +38,12 @@ type DateFieldBreakpointProps = {
|
|
|
38
38
|
* count is kept: the months wrap to a vertical stack and the modal body scrolls.
|
|
39
39
|
*/
|
|
40
40
|
numberOfMonths?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the field shows a clear button to reset the value. Disable it
|
|
43
|
+
* when the field is required or the value should not be cleared.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
clearable?: boolean;
|
|
41
47
|
};
|
|
42
48
|
export interface DateFieldProps extends BreakpointSupport<DateFieldBreakpointProps>, Omit<DayPickerProps, 'mode' | 'selected' | 'onSelect' | 'numberOfMonths'> {
|
|
43
49
|
/**
|
|
@@ -1,93 +1,94 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useFloating as
|
|
1
|
+
import { jsxs as vt, Fragment as Ft, jsx as D } from "react/jsx-runtime";
|
|
2
|
+
import { useFloating as wt, useClick as Nt, useInteractions as kt, useDismiss as Pt, useRole as Et, FloatingPortal as Ot, FloatingFocusManager as Rt } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
|
|
3
3
|
import B from "../../../../../external/classnames/index.es.js";
|
|
4
4
|
import F, { useState as _, useCallback as ue, useEffect as T, useMemo as me } from "react";
|
|
5
|
-
import { Calendar as
|
|
6
|
-
import { MultiValueField as
|
|
7
|
-
import { TextField as
|
|
5
|
+
import { Calendar as It } from "../../content/calendar/calendar.es.js";
|
|
6
|
+
import { MultiValueField as Vt } from "../multi-value-field/multi-value-field.es.js";
|
|
7
|
+
import { TextField as Bt } from "../textfield/textfield.es.js";
|
|
8
8
|
import y from "./date-field.module.scss.es.js";
|
|
9
|
-
import { getLocaleDateParts as
|
|
10
|
-
import { DatePickerModal as
|
|
11
|
-
import { useBreakpointProps as
|
|
12
|
-
import { useLabels as
|
|
13
|
-
import { et as
|
|
14
|
-
import
|
|
15
|
-
import { autoUpdate as
|
|
16
|
-
import { offset as
|
|
17
|
-
import { dateMatchModifiers as
|
|
18
|
-
const
|
|
19
|
-
const { getCurrentBreakpointProps:
|
|
20
|
-
useNativePicker:
|
|
9
|
+
import { getLocaleDateParts as Tt, buildDateRegexSource as $t, resolveRangeSelection as Lt, CALENDAR_POPOVER_OFFSET as Yt, CALENDAR_POPOVER_PADDING as He } from "./date-field-helpers.es.js";
|
|
10
|
+
import { DatePickerModal as jt } from "./date-picker-modal/date-picker-modal.es.js";
|
|
11
|
+
import { useBreakpointProps as Ht } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
12
|
+
import { useLabels as Wt } from "../../../providers/label-provider/use-labels.es.js";
|
|
13
|
+
import { et as St } from "../../../../../external/react-day-picker/dist/esm/locale/et.es.js";
|
|
14
|
+
import Ut, { isBreakpointBelow as We } from "../../../helpers/hooks/use-breakpoint.es.js";
|
|
15
|
+
import { autoUpdate as qt } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
|
|
16
|
+
import { offset as zt, flip as Gt, shift as Xt, size as Jt } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
|
|
17
|
+
import { dateMatchModifiers as Kt } from "../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.es.js";
|
|
18
|
+
const Qt = F.forwardRef((w, N) => {
|
|
19
|
+
const { getCurrentBreakpointProps: Se } = Ht(w.defaultServerBreakpoint), { getLabel: z } = Wt(), {
|
|
20
|
+
useNativePicker: Ue = !1,
|
|
21
21
|
enableCalendar: m = !0,
|
|
22
22
|
calendarTrigger: $ = "button",
|
|
23
|
-
numberOfMonths: G
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
numberOfMonths: G,
|
|
24
|
+
clearable: pe = !0
|
|
25
|
+
} = Se(w), {
|
|
26
|
+
id: he,
|
|
26
27
|
mode: s = "single",
|
|
27
|
-
label:
|
|
28
|
+
label: ge,
|
|
28
29
|
selected: L,
|
|
29
30
|
onSelect: a,
|
|
30
31
|
disabled: k,
|
|
31
32
|
disabledMatchers: P,
|
|
32
|
-
placeholder:
|
|
33
|
-
className:
|
|
33
|
+
placeholder: qe,
|
|
34
|
+
className: ze,
|
|
34
35
|
formatDate: d,
|
|
35
36
|
required: Y,
|
|
36
|
-
showOutsideDays:
|
|
37
|
-
parseDate:
|
|
38
|
-
monthYearSelectType:
|
|
39
|
-
minYear:
|
|
40
|
-
maxYear:
|
|
41
|
-
dayStatus:
|
|
42
|
-
tagsDirection:
|
|
43
|
-
showNavigation:
|
|
37
|
+
showOutsideDays: ye = !0,
|
|
38
|
+
parseDate: Ge,
|
|
39
|
+
monthYearSelectType: be,
|
|
40
|
+
minYear: De,
|
|
41
|
+
maxYear: _e,
|
|
42
|
+
dayStatus: Ce,
|
|
43
|
+
tagsDirection: Xe,
|
|
44
|
+
showNavigation: Me = !0,
|
|
44
45
|
selectionLevel: E = "days",
|
|
45
46
|
initialView: j,
|
|
46
|
-
locale:
|
|
47
|
+
locale: xe = St,
|
|
47
48
|
localeCode: H = "et-EE",
|
|
48
49
|
initialMonth: W,
|
|
49
|
-
closeOnSelect:
|
|
50
|
-
footer:
|
|
50
|
+
closeOnSelect: Je,
|
|
51
|
+
footer: Ae,
|
|
51
52
|
defaultValue: S,
|
|
52
53
|
minDate: X,
|
|
53
54
|
maxDate: J,
|
|
54
|
-
disablePast:
|
|
55
|
-
disableFuture:
|
|
55
|
+
disablePast: ve,
|
|
56
|
+
disableFuture: Fe,
|
|
56
57
|
shouldDisableMonth: K,
|
|
57
58
|
shouldDisableYear: Q,
|
|
58
59
|
readOnly: O,
|
|
59
|
-
availableDays:
|
|
60
|
+
availableDays: we,
|
|
60
61
|
inputProps: i,
|
|
61
62
|
modal: Z = !1,
|
|
62
|
-
modalProps:
|
|
63
|
-
modalTitle:
|
|
64
|
-
disabledDateErrorMessage:
|
|
65
|
-
invalidDateErrorMessage:
|
|
66
|
-
useNativePicker:
|
|
67
|
-
enableCalendar:
|
|
68
|
-
calendarTrigger:
|
|
69
|
-
numberOfMonths:
|
|
70
|
-
defaultServerBreakpoint:
|
|
71
|
-
sm:
|
|
72
|
-
md:
|
|
73
|
-
lg:
|
|
74
|
-
xl:
|
|
75
|
-
xxl:
|
|
76
|
-
...
|
|
77
|
-
} = w, c =
|
|
63
|
+
modalProps: Ke,
|
|
64
|
+
modalTitle: Qe,
|
|
65
|
+
disabledDateErrorMessage: Ze = z("dateField.disabledDateError"),
|
|
66
|
+
invalidDateErrorMessage: et = z("dateField.invalidDateError"),
|
|
67
|
+
useNativePicker: Zt,
|
|
68
|
+
enableCalendar: er,
|
|
69
|
+
calendarTrigger: tr,
|
|
70
|
+
numberOfMonths: rr,
|
|
71
|
+
defaultServerBreakpoint: ar,
|
|
72
|
+
sm: ir,
|
|
73
|
+
md: or,
|
|
74
|
+
lg: nr,
|
|
75
|
+
xl: sr,
|
|
76
|
+
xxl: lr,
|
|
77
|
+
...Ne
|
|
78
|
+
} = w, c = Ue && s === "single", ke = Ut(w.defaultServerBreakpoint), A = We(ke, "md"), [tt, p] = _(L ?? S), [h, R] = _(!1), [ee, Pe] = _(!1), [rt, Ee] = _(j ?? E), [te, b] = _(""), [Oe, u] = _(!1), [Re, re] = _(!1), g = m && !c && !O && (Z === !0 || typeof Z == "string" && We(ke, Z)), Ie = A && !g && typeof G == "number" && G > 1 ? 1 : G, { current: f } = F.useRef("selected" in w), o = f ? L : tt, ae = F.useRef(null), Ve = F.useRef(null), at = F.useCallback(
|
|
78
79
|
(e) => {
|
|
79
80
|
ae.current = e, typeof N == "function" ? N(e) : N && (N.current = e);
|
|
80
81
|
},
|
|
81
82
|
[N]
|
|
82
|
-
),
|
|
83
|
+
), it = (e) => {
|
|
83
84
|
if (!e) return "";
|
|
84
85
|
const t = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), n = String(e.getDate()).padStart(2, "0");
|
|
85
86
|
return `${t}-${r}-${n}`;
|
|
86
|
-
},
|
|
87
|
+
}, ot = c && o instanceof Date ? it(o) : "", ie = ue((e, t) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [...e].sort((r, n) => r.getTime() - n.getTime())[0] : e && typeof e == "object" && "from" in e && e.from instanceof Date ? e.from : e && typeof e == "object" && "to" in e && e.to instanceof Date ? e.to : t ?? /* @__PURE__ */ new Date(), []), [nt, oe] = _(() => ie(o, W));
|
|
87
88
|
T(() => {
|
|
88
89
|
h || oe(ie(o, W));
|
|
89
90
|
}, [o, W, h, ie]), T(() => {
|
|
90
|
-
h &&
|
|
91
|
+
h && Ee(j ?? E);
|
|
91
92
|
}, [h, E, j]), T(() => {
|
|
92
93
|
f && p(L);
|
|
93
94
|
}, [L, f]);
|
|
@@ -110,47 +111,47 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
110
111
|
return "";
|
|
111
112
|
},
|
|
112
113
|
[C]
|
|
113
|
-
), ne =
|
|
114
|
+
), ne = Je ?? s === "single", Be = s === "multiple" && Array.isArray(o) ? o.map((e, t) => ({
|
|
114
115
|
id: t,
|
|
115
116
|
label: d ? d(e) : M(e),
|
|
116
117
|
date: e
|
|
117
118
|
})) : [], U = me(() => {
|
|
118
119
|
const e = [];
|
|
119
|
-
return k && (Array.isArray(k) ? e.push(...k) : e.push(k)), P && (Array.isArray(P) ? e.push(...P) : e.push(P)), X && e.push({ before: X }), J && e.push({ after: J }),
|
|
120
|
+
return k && (Array.isArray(k) ? e.push(...k) : e.push(k)), P && (Array.isArray(P) ? e.push(...P) : e.push(P)), X && e.push({ before: X }), J && e.push({ after: J }), ve && e.push({ before: /* @__PURE__ */ new Date() }), Fe && e.push({ after: /* @__PURE__ */ new Date() }), K && e.push((t) => K(t)), Q && e.push((t) => Q(t)), e;
|
|
120
121
|
}, [
|
|
121
122
|
k,
|
|
122
123
|
P,
|
|
123
124
|
X,
|
|
124
125
|
J,
|
|
125
|
-
Ae,
|
|
126
126
|
ve,
|
|
127
|
+
Fe,
|
|
127
128
|
K,
|
|
128
129
|
Q
|
|
129
130
|
]), v = ue(
|
|
130
|
-
(e) =>
|
|
131
|
+
(e) => Kt(e, U),
|
|
131
132
|
[U]
|
|
132
|
-
),
|
|
133
|
-
const l = s === "range" ?
|
|
133
|
+
), st = (e, t, r, n) => {
|
|
134
|
+
const l = s === "range" ? Lt(e, o, t) : e;
|
|
134
135
|
if (u(!1), f || p(l), a == null || a(l, t, r, n), l) {
|
|
135
136
|
const x = d ? d(l) : M(l);
|
|
136
137
|
b(x);
|
|
137
138
|
} else
|
|
138
139
|
b("");
|
|
139
140
|
ne && R(!1);
|
|
140
|
-
},
|
|
141
|
+
}, lt = (e) => {
|
|
141
142
|
if (v(e)) return;
|
|
142
143
|
const t = s === "range" ? { from: e, to: void 0 } : s === "multiple" ? [...Array.isArray(o) ? o : [], e] : e;
|
|
143
144
|
u(!1), f || p(t), a == null || a(t, e, {}, {});
|
|
144
145
|
const r = d ? d(t) : M(t);
|
|
145
146
|
b(r), ne && R(!1);
|
|
146
|
-
},
|
|
147
|
-
const e =
|
|
147
|
+
}, ft = me(() => {
|
|
148
|
+
const e = Tt(C), t = new RegExp(`^${$t(e)}$`), { fieldOrder: r } = e;
|
|
148
149
|
return (n) => {
|
|
149
150
|
const l = n.match(t);
|
|
150
151
|
if (!l) return;
|
|
151
152
|
const x = {};
|
|
152
|
-
r.forEach((
|
|
153
|
-
x[
|
|
153
|
+
r.forEach((xt, At) => {
|
|
154
|
+
x[xt] = Number(l[At + 1]);
|
|
154
155
|
});
|
|
155
156
|
const { day: fe, month: de, year: ce } = x;
|
|
156
157
|
if (fe === void 0 || de === void 0 || ce === void 0) return;
|
|
@@ -158,14 +159,14 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
158
159
|
if (!(isNaN(V.getTime()) || V.getFullYear() !== ce || V.getMonth() !== de - 1 || V.getDate() !== fe))
|
|
159
160
|
return V;
|
|
160
161
|
};
|
|
161
|
-
}, [C]),
|
|
162
|
-
}))(e),
|
|
162
|
+
}, [C]), Te = (e) => (Ge ?? (s === "single" ? ft : () => {
|
|
163
|
+
}))(e), $e = (e) => s === "single" && e instanceof Date || s === "multiple" && Array.isArray(e) || s === "range" && !!e && !Array.isArray(e) && "from" in e, dt = (e) => {
|
|
163
164
|
if (b(e), re(!1), e.trim() === "") {
|
|
164
165
|
u(!1), o !== void 0 && (f || p(void 0), a == null || a(void 0, void 0, {}, {}));
|
|
165
166
|
return;
|
|
166
167
|
}
|
|
167
|
-
const t =
|
|
168
|
-
if (
|
|
168
|
+
const t = Te(e);
|
|
169
|
+
if (!$e(t)) {
|
|
169
170
|
u(!1);
|
|
170
171
|
return;
|
|
171
172
|
}
|
|
@@ -175,12 +176,12 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
177
178
|
u(!1), f || p(t), a == null || a(t, t, {}, {}), t instanceof Date && oe(t), ne && R(!1);
|
|
178
|
-
},
|
|
179
|
+
}, ct = () => {
|
|
179
180
|
if (te.trim() === "") {
|
|
180
181
|
re(!1);
|
|
181
182
|
return;
|
|
182
183
|
}
|
|
183
|
-
re(
|
|
184
|
+
re(!$e(Te(te)));
|
|
184
185
|
};
|
|
185
186
|
T(() => {
|
|
186
187
|
if (f) {
|
|
@@ -193,16 +194,16 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
193
194
|
b(e);
|
|
194
195
|
}
|
|
195
196
|
}, []);
|
|
196
|
-
const
|
|
197
|
+
const ut = wt({
|
|
197
198
|
open: h,
|
|
198
199
|
onOpenChange: R,
|
|
199
200
|
placement: $ === "input" ? "bottom-start" : "bottom-end",
|
|
200
201
|
middleware: [
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
padding:
|
|
202
|
+
zt(Yt),
|
|
203
|
+
Gt(),
|
|
204
|
+
Xt({ padding: He }),
|
|
205
|
+
Jt({
|
|
206
|
+
padding: He,
|
|
206
207
|
apply({ availableWidth: e, elements: t }) {
|
|
207
208
|
const r = t.floating;
|
|
208
209
|
if (r.style.width = "", r.style.maxWidth = "", r.style.overflowX = "", A) return;
|
|
@@ -210,23 +211,23 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
210
211
|
}
|
|
211
212
|
})
|
|
212
213
|
],
|
|
213
|
-
whileElementsMounted:
|
|
214
|
-
}), { refs: I, context: q, x:
|
|
215
|
-
...m && !c && $ === "input" && !g ? [
|
|
216
|
-
|
|
214
|
+
whileElementsMounted: qt
|
|
215
|
+
}), { refs: I, context: q, x: mt, y: pt, strategy: ht } = ut, gt = Nt(q), Le = kt([
|
|
216
|
+
...m && !c && $ === "input" && !g ? [gt] : [],
|
|
217
|
+
Pt(q, {
|
|
217
218
|
outsidePress: (e) => {
|
|
218
219
|
const t = e.target;
|
|
219
220
|
return !(t != null && t.closest('[role="menu"], [role="listbox"]'));
|
|
220
221
|
}
|
|
221
222
|
}),
|
|
222
|
-
|
|
223
|
+
Et(q, { role: "dialog" })
|
|
223
224
|
]);
|
|
224
225
|
F.useEffect(() => {
|
|
225
226
|
var t, r;
|
|
226
|
-
const e = s === "multiple" ? ((t =
|
|
227
|
+
const e = s === "multiple" ? ((t = Ve.current) == null ? void 0 : t.wrapper) ?? null : ((r = ae.current) == null ? void 0 : r.input) ?? null;
|
|
227
228
|
I.setPositionReference(e ?? I.reference.current);
|
|
228
229
|
}, [s, h, I]);
|
|
229
|
-
const
|
|
230
|
+
const yt = () => {
|
|
230
231
|
var t;
|
|
231
232
|
const e = (t = ae.current) == null ? void 0 : t.input;
|
|
232
233
|
if (e) {
|
|
@@ -239,14 +240,14 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
239
240
|
e.focus();
|
|
240
241
|
}
|
|
241
242
|
}, se = () => {
|
|
242
|
-
!m || O || (c ?
|
|
243
|
-
},
|
|
243
|
+
!m || O || (c ? yt() : g ? Pe(!0) : R((e) => !e));
|
|
244
|
+
}, bt = (e) => {
|
|
244
245
|
if (u(!1), f || p(e), a == null || a(e, e, {}, {}), e) {
|
|
245
246
|
const t = d ? d(e) : M(e);
|
|
246
247
|
b(t);
|
|
247
248
|
} else
|
|
248
249
|
b("");
|
|
249
|
-
},
|
|
250
|
+
}, Dt = (e) => {
|
|
250
251
|
if (!e) {
|
|
251
252
|
u(!1), f || p(void 0), a == null || a(void 0, void 0, {}, {});
|
|
252
253
|
return;
|
|
@@ -261,44 +262,44 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
261
262
|
}
|
|
262
263
|
u(!1), f || p(l), a == null || a(l, l, {}, {});
|
|
263
264
|
}
|
|
264
|
-
},
|
|
265
|
+
}, _t = Le.getReferenceProps(
|
|
265
266
|
g && $ === "input" ? { onClick: () => se() } : void 0
|
|
266
267
|
), {
|
|
267
|
-
role:
|
|
268
|
-
"aria-expanded":
|
|
269
|
-
"aria-haspopup":
|
|
270
|
-
"aria-controls":
|
|
271
|
-
...
|
|
272
|
-
} =
|
|
268
|
+
role: fr,
|
|
269
|
+
"aria-expanded": dr,
|
|
270
|
+
"aria-haspopup": cr,
|
|
271
|
+
"aria-controls": Ct,
|
|
272
|
+
...Mt
|
|
273
|
+
} = _t, Ye = g ? void 0 : Ct, le = z("dateField.openCalendar"), je = {
|
|
273
274
|
"aria-label": le,
|
|
274
275
|
"aria-expanded": g ? ee : h,
|
|
275
276
|
"aria-haspopup": "dialog",
|
|
276
|
-
"aria-controls":
|
|
277
|
+
"aria-controls": Ye
|
|
277
278
|
};
|
|
278
|
-
return /* @__PURE__ */
|
|
279
|
+
return /* @__PURE__ */ vt(Ft, { children: [
|
|
279
280
|
/* @__PURE__ */ D(
|
|
280
281
|
"div",
|
|
281
282
|
{
|
|
282
|
-
className: B(y["tedi-date-field__container"],
|
|
283
|
-
...
|
|
283
|
+
className: B(y["tedi-date-field__container"], ze),
|
|
284
|
+
...Mt,
|
|
284
285
|
ref: I.setReference,
|
|
285
286
|
children: s === "multiple" ? /* @__PURE__ */ D(
|
|
286
|
-
|
|
287
|
+
Vt,
|
|
287
288
|
{
|
|
288
289
|
...i,
|
|
289
|
-
ref:
|
|
290
|
-
id:
|
|
291
|
-
label:
|
|
292
|
-
tagsDirection:
|
|
293
|
-
values:
|
|
290
|
+
ref: Ve,
|
|
291
|
+
id: he,
|
|
292
|
+
label: ge,
|
|
293
|
+
tagsDirection: Xe,
|
|
294
|
+
values: Be.map((e) => e.label),
|
|
294
295
|
icon: "calendar_today",
|
|
295
296
|
onIconClick: se,
|
|
296
|
-
iconButtonProps: m ?
|
|
297
|
-
isClearable:
|
|
297
|
+
iconButtonProps: m ? je : { "aria-label": le },
|
|
298
|
+
isClearable: pe,
|
|
298
299
|
required: Y,
|
|
299
300
|
onChange: (e) => {
|
|
300
301
|
if (!Array.isArray(o)) return;
|
|
301
|
-
const t =
|
|
302
|
+
const t = Be.filter((r) => e.includes(r.label)).map((r) => r.date);
|
|
302
303
|
f || p(t), a == null || a(t, {}, {}, {});
|
|
303
304
|
},
|
|
304
305
|
className: B(y["tedi-date-field__textfield"], {
|
|
@@ -306,28 +307,28 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
306
307
|
})
|
|
307
308
|
}
|
|
308
309
|
) : /* @__PURE__ */ D(
|
|
309
|
-
|
|
310
|
+
Bt,
|
|
310
311
|
{
|
|
311
312
|
...i,
|
|
312
|
-
ref:
|
|
313
|
-
id:
|
|
314
|
-
label:
|
|
313
|
+
ref: at,
|
|
314
|
+
id: he,
|
|
315
|
+
label: ge,
|
|
315
316
|
readOnly: O,
|
|
316
|
-
value: c ?
|
|
317
|
-
placeholder:
|
|
317
|
+
value: c ? ot : te,
|
|
318
|
+
placeholder: qe,
|
|
318
319
|
icon: "calendar_today",
|
|
319
|
-
isClearable:
|
|
320
|
+
isClearable: pe,
|
|
320
321
|
onIconClick: se,
|
|
321
|
-
iconButtonProps: m && !c ?
|
|
322
|
-
onChange: (e) => c ?
|
|
322
|
+
iconButtonProps: m && !c ? je : { "aria-label": le },
|
|
323
|
+
onChange: (e) => c ? Dt(e) : dt(e),
|
|
323
324
|
onBlur: (e) => {
|
|
324
325
|
var t;
|
|
325
|
-
c ||
|
|
326
|
+
c || ct(), (t = i == null ? void 0 : i.onBlur) == null || t.call(i, e);
|
|
326
327
|
},
|
|
327
328
|
required: Y,
|
|
328
|
-
invalid:
|
|
329
|
+
invalid: Oe || Re || (i == null ? void 0 : i.invalid),
|
|
329
330
|
helper: (() => {
|
|
330
|
-
const e = i == null ? void 0 : i.helper, t =
|
|
331
|
+
const e = i == null ? void 0 : i.helper, t = Oe ? Ze : Re ? et : null, r = t ? { text: t, type: "error" } : null;
|
|
331
332
|
return r ? e ? Array.isArray(e) ? [...e, r] : [e, r] : r : e;
|
|
332
333
|
})(),
|
|
333
334
|
className: B(y["tedi-date-field__textfield"], {
|
|
@@ -341,7 +342,7 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
341
342
|
role: "combobox",
|
|
342
343
|
"aria-haspopup": "dialog",
|
|
343
344
|
"aria-expanded": g ? ee : h,
|
|
344
|
-
"aria-controls":
|
|
345
|
+
"aria-controls": Ye
|
|
345
346
|
} : {}
|
|
346
347
|
}
|
|
347
348
|
}
|
|
@@ -349,75 +350,75 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
349
350
|
}
|
|
350
351
|
),
|
|
351
352
|
g && /* @__PURE__ */ D(
|
|
352
|
-
|
|
353
|
+
jt,
|
|
353
354
|
{
|
|
354
355
|
open: ee,
|
|
355
|
-
onOpenChange:
|
|
356
|
+
onOpenChange: Pe,
|
|
356
357
|
value: o,
|
|
357
|
-
onConfirm:
|
|
358
|
+
onConfirm: bt,
|
|
358
359
|
mode: s,
|
|
359
|
-
numberOfMonths:
|
|
360
|
-
locale:
|
|
360
|
+
numberOfMonths: Ie,
|
|
361
|
+
locale: xe,
|
|
361
362
|
localeCode: H,
|
|
362
|
-
showOutsideDays:
|
|
363
|
+
showOutsideDays: ye,
|
|
363
364
|
disabledMatchers: U,
|
|
364
365
|
required: Y,
|
|
365
|
-
availableDays:
|
|
366
|
-
footer:
|
|
367
|
-
monthYearSelectType:
|
|
368
|
-
minYear:
|
|
369
|
-
maxYear:
|
|
370
|
-
dayStatus:
|
|
371
|
-
showNavigation:
|
|
366
|
+
availableDays: we,
|
|
367
|
+
footer: Ae,
|
|
368
|
+
monthYearSelectType: be,
|
|
369
|
+
minYear: De,
|
|
370
|
+
maxYear: _e,
|
|
371
|
+
dayStatus: Ce,
|
|
372
|
+
showNavigation: Me,
|
|
372
373
|
selectionLevel: E,
|
|
373
374
|
initialView: j,
|
|
374
375
|
initialMonth: W,
|
|
375
|
-
modalProps:
|
|
376
|
-
...
|
|
377
|
-
title:
|
|
376
|
+
modalProps: Ke,
|
|
377
|
+
...Ne,
|
|
378
|
+
title: Qe
|
|
378
379
|
}
|
|
379
380
|
),
|
|
380
|
-
m && !c && !g && /* @__PURE__ */ D(
|
|
381
|
+
m && !c && !g && /* @__PURE__ */ D(Ot, { children: h && /* @__PURE__ */ D(Rt, { context: q, modal: !1, initialFocus: -1, children: /* @__PURE__ */ D(
|
|
381
382
|
"div",
|
|
382
383
|
{
|
|
383
384
|
ref: I.setFloating,
|
|
384
385
|
className: B({
|
|
385
386
|
[y["tedi-date-field__calendar-popover--fullwidth"]]: A
|
|
386
387
|
}),
|
|
387
|
-
|
|
388
|
+
...Le.getFloatingProps({
|
|
388
389
|
style: {
|
|
389
|
-
position:
|
|
390
|
-
top:
|
|
391
|
-
left: A ? 0 :
|
|
390
|
+
position: ht,
|
|
391
|
+
top: pt ?? 0,
|
|
392
|
+
left: A ? 0 : mt ?? 0,
|
|
392
393
|
right: A ? 0 : void 0
|
|
393
394
|
}
|
|
394
395
|
}),
|
|
395
396
|
children: /* @__PURE__ */ D(
|
|
396
|
-
|
|
397
|
+
It,
|
|
397
398
|
{
|
|
398
|
-
...
|
|
399
|
-
numberOfMonths:
|
|
400
|
-
view:
|
|
399
|
+
...Ne,
|
|
400
|
+
numberOfMonths: Ie,
|
|
401
|
+
view: rt,
|
|
401
402
|
selectionLevel: E,
|
|
402
|
-
currentMonth:
|
|
403
|
+
currentMonth: nt,
|
|
403
404
|
setCurrentMonth: oe,
|
|
404
|
-
setView:
|
|
405
|
+
setView: Ee,
|
|
405
406
|
mode: s,
|
|
406
407
|
value: o,
|
|
407
|
-
locale:
|
|
408
|
+
locale: xe,
|
|
408
409
|
localeCode: H,
|
|
409
|
-
showOutsideDays:
|
|
410
|
+
showOutsideDays: ye,
|
|
410
411
|
disabledMatchers: U,
|
|
411
412
|
required: Y,
|
|
412
|
-
availableDays:
|
|
413
|
-
footer:
|
|
414
|
-
monthYearSelectType:
|
|
415
|
-
minYear:
|
|
416
|
-
maxYear:
|
|
417
|
-
dayStatus:
|
|
418
|
-
showNavigation:
|
|
419
|
-
handleSelect:
|
|
420
|
-
applyValue:
|
|
413
|
+
availableDays: we,
|
|
414
|
+
footer: Ae,
|
|
415
|
+
monthYearSelectType: be,
|
|
416
|
+
minYear: De,
|
|
417
|
+
maxYear: _e,
|
|
418
|
+
dayStatus: Ce,
|
|
419
|
+
showNavigation: Me,
|
|
420
|
+
handleSelect: st,
|
|
421
|
+
applyValue: lt,
|
|
421
422
|
className: B(y["tedi-date-field__calendar"], {
|
|
422
423
|
[y["tedi-date-field__calendar--fullwidth"]]: A
|
|
423
424
|
})
|
|
@@ -427,7 +428,7 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
427
428
|
) }) })
|
|
428
429
|
] });
|
|
429
430
|
});
|
|
430
|
-
|
|
431
|
+
Qt.displayName = "DateField";
|
|
431
432
|
export {
|
|
432
|
-
|
|
433
|
+
Qt as DateField
|
|
433
434
|
};
|