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