@entur/datepicker
Advanced tools
Comparing version 9.2.0-beta.0 to 9.2.0
@@ -298,3 +298,3 @@ 'use strict'; | ||
var CalendarCell = function CalendarCell(_ref) { | ||
var _ariaLabelForDate, _classNameForDate, _state$timeZone; | ||
var _ariaLabelForDate, _classNameForDate, _state$timeZone, _classNames; | ||
var state = _ref.state, | ||
@@ -327,8 +327,3 @@ date$1 = _ref.date, | ||
hidden: isOutsideVisibleRange, | ||
className: classNames('eds-datepicker__calendar__grid__cell', [(_classNameForDate = classNameForDate == null ? void 0 : classNameForDate(date$1)) != null ? _classNameForDate : ''], { | ||
'eds-datepicker__calendar__grid__cell--selected': isSelected, | ||
'eds-datepicker__calendar__grid__cell--disabled': isDisabled || isUnavailable, | ||
'eds-datepicker__calendar__grid__cell--outside-month': isOutsideVisibleRange, | ||
'eds-datepicker__calendar__grid__cell--today': date.isEqualDay(date$1, date.now((_state$timeZone = state.timeZone) != null ? _state$timeZone : date.getLocalTimeZone())) | ||
}) | ||
className: classNames('eds-datepicker__calendar__grid__cell', (_classNames = {}, _classNames[(_classNameForDate = classNameForDate == null ? void 0 : classNameForDate(date$1)) != null ? _classNameForDate : ''] = !isOutsideVisibleRange, _classNames['eds-datepicker__calendar__grid__cell--selected'] = isSelected, _classNames['eds-datepicker__calendar__grid__cell--disabled'] = isDisabled || isUnavailable, _classNames['eds-datepicker__calendar__grid__cell--outside-month'] = isOutsideVisibleRange, _classNames['eds-datepicker__calendar__grid__cell--today'] = date.isEqualDay(date$1, date.now((_state$timeZone = state.timeZone) != null ? _state$timeZone : date.getLocalTimeZone())), _classNames)) | ||
}, rest, { | ||
@@ -409,3 +404,3 @@ onClick: function onClick(e) { | ||
var _excluded$6 = ["selectedDate", "onChange", "locale", "minDate", "maxDate", "style", "children", "navigationDescription", "onSelectedCellClick", "classNameForDate", "ariaLabelForDate"]; | ||
var _excluded$6 = ["selectedDate", "onChange", "locale", "minDate", "maxDate", "style", "className", "children", "navigationDescription", "onSelectedCellClick", "classNameForDate", "ariaLabelForDate"]; | ||
var Calendar = /*#__PURE__*/React.forwardRef(function (_ref, ref) { | ||
@@ -418,2 +413,3 @@ var selectedDate = _ref.selectedDate, | ||
style = _ref.style, | ||
className = _ref.className, | ||
navigationDescription = _ref.navigationDescription, | ||
@@ -452,3 +448,3 @@ _ref$onSelectedCellCl = _ref.onSelectedCellClick, | ||
ref: ref, | ||
className: "eds-datepicker__calendar", | ||
className: classNames('eds-datepicker__calendar', className), | ||
style: style | ||
@@ -455,0 +451,0 @@ }), React.createElement("div", { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),a=require("react"),t=require("@react-stately/datepicker"),n=require("@react-aria/datepicker"),r=require("@react-aria/i18n"),l=require("classnames"),i=require("@entur/form"),o=require("@internationalized/date"),s=require("@react-aria/calendar"),d=require("@react-stately/calendar"),c=require("@entur/icons"),u=require("@react-aria/button"),m=require("@entur/button"),p=require("@entur/a11y"),f=require("@floating-ui/react-dom"),b=require("react-focus-lock"),v=require("@entur/tokens"),g=require("@entur/modal");function D(){return D=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},D.apply(this,arguments)}function h(e,a){if(null==e)return{};var t,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)a.indexOf(t=l[n])>=0||(r[t]=e[t]);return r}var k,y=["segment","state"],C=function(e){var t=e.segment,r=e.state,i=h(e,y),o=a.useRef(null),s=n.useDateSegment(t,r,o).segmentProps;return a.createElement("div",D({},s,{ref:o,className:l("eds-date-and-time-field__segment",{"eds-date-and-time-field__segment--placeholder":t.isPlaceholder,"eds-date-and-time-field__segment--dot-separator":"."===t.text}),tabIndex:r.isDisabled?-1:s.tabIndex},i),t.text)},T=function(e,a,t){return a?t?new o.ZonedDateTime(e.getFullYear(),e.getMonth()+1,e.getDate(),a,t,e.getHours(),e.getMinutes(),e.getSeconds()):o.parseAbsolute(e.toISOString(),a):new o.CalendarDateTime(e.getFullYear(),e.getMonth()+1,e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())},E=function(e){if(void 0===e&&(e="gregory"),"gregory"===e)return new o.GregorianCalendar;throw new Error("Unsupported calendar "+e)},_=function(e,a,t){return"no-no"!==a.toLowerCase()?t["aria-label"]:e},w=function(e){return o.toCalendarDateTime(e.add({days:1})).add({milliseconds:-1})},I=function(e){var a=e.value,t=e.timezone,n=void 0===t?"Europe/Oslo":t;if(null===a)return null;switch(e.type){case"CalendarDate":return"day"in a?o.toCalendarDate(a):o.today(n);case"CalendarDateTime":return"day"in a?o.toCalendarDateTime(a):o.toCalendarDateTime(o.today(n),a);case"ZonedDateTime":return o.toZoned("day"in a?a:o.toCalendarDateTime(o.today(n),a),n);case"Time":return"hour"in a?"day"in a?o.toTime(a):a:o.toTime(o.now(n));default:return a}},F=function(e,a){return(e%a+a)%a},S=function(e,a){if(e.current){var t=e.current.querySelectorAll(".eds-date-and-time-field__segment"),n=t[0],r=t[t.length-1];switch(a){case"first":return n.focus();case"last":return r.focus()}}},N=["selectedDate","onChange","label","locale","showTimeZone","showTime","granularity","disabled","isDisabled","variant","feedback","validationVariant","validationFeedback","labelTooltip","minDate","maxDate","style","className","labelProps","append"],L=a.forwardRef((function(o,s){var d=o.selectedDate,c=o.onChange,u=o.label,m=o.locale,p=o.showTimeZone,f=o.showTime,b=o.granularity,v=void 0===b?"day":b,g=o.disabled,k=o.isDisabled,y=o.variant,T=o.feedback,_=o.validationVariant,I=void 0===_?"error":_,F=o.validationFeedback,S=void 0===F?"Ugyldig dato":F,L=o.labelTooltip,P=o.minDate,x=o.maxDate,R=o.style,A=o.className,O=o.labelProps,V=o.append,M=h(o,N),Z=r.useLocale(),q=t.useDateFieldState(D({},M,{locale:null!=m?m:Z.locale,createCalendar:E,value:d,onChange:c,hideTimeZone:!p,granularity:f?"minute":v,minValue:P,maxValue:"hour"in(null!=x?x:{})?x:void 0!==x?w(x):void 0,isDisabled:k||g,shouldForceLeadingZeros:!0})),B=a.useRef(null),z=n.useDateField(D({},M,{label:u}),q,B),j=z.labelProps,W=z.fieldProps,U=e.useRandomId("datefield");return a.createElement(e.ConditionalWrapper,{condition:void 0!==m,wrapper:function(e){return a.createElement(r.I18nProvider,{locale:m},e)}},a.createElement(i.BaseFormControl,D({style:R,className:l("eds-datefield",A),labelId:U,ref:e.mergeRefs(B,s),disabled:k||g,disableLabelAnimation:!0,label:u,labelTooltip:L,labelProps:null!=O?O:j},W,{variant:null!=y?y:"invalid"===q.validationState?I:void 0,feedback:null!=T?T:"invalid"===q.validationState?S:void 0,append:V,ariaAlertOnFeedback:!0}),q.segments.map((function(e,t){return a.createElement(C,{segment:e,state:q,key:t})}))))})),P=["children","className","style"],x=function(e){var t=e.children,n=e.className,r=e.style,l=h(e,P),i=a.useRef(null),o=u.useButton(l,i);return a.createElement(m.IconButton,D({},o.buttonProps,{ref:i,className:n,style:r}),t)},R=["state","date","onSelectedCellClick","classNameForDate","ariaLabelForDate"],A=function(e){var t,n,r,i=e.state,d=e.date,c=e.onSelectedCellClick,u=void 0===c?function(){}:c,m=e.classNameForDate,p=e.ariaLabelForDate,f=h(e,R),b=a.useRef(null),v=s.useCalendarCell({date:d},i,b),g=v.cellProps,k=v.buttonProps,y=v.isSelected,C=v.isOutsideVisibleRange,T=v.isDisabled,E=v.isUnavailable,_=v.formattedDate,w=k["aria-label"]+" "+(null!=(t=null==p?void 0:p(d))?t:"");return a.createElement("td",D({},g,{className:"eds-datepicker__calendar__grid__cell__td"}),a.createElement("div",D({},k,{"aria-label":w,ref:b,hidden:C,className:l("eds-datepicker__calendar__grid__cell",[null!=(n=null==m?void 0:m(d))?n:""],{"eds-datepicker__calendar__grid__cell--selected":y,"eds-datepicker__calendar__grid__cell--disabled":T||E,"eds-datepicker__calendar__grid__cell--outside-month":C,"eds-datepicker__calendar__grid__cell--today":o.isEqualDay(d,o.now(null!=(r=i.timeZone)?r:o.getLocalTimeZone()))})},f,{onClick:function(e){k.onClick&&k.onClick(e),y&&u()},onKeyDown:function(e){k.onKeyDown&&k.onKeyDown(e),"Enter"!==e.key&&" "!==e.key||y&&u()}}),_))},O=["state","navigationDescription","onSelectedCellClick","classNameForDate","ariaLabelForDate"],V=function(t){var n=t.state,l=t.navigationDescription,i=t.onSelectedCellClick,d=void 0===i?function(){}:i,c=t.classNameForDate,u=t.ariaLabelForDate,m=h(t,O),f=e.useRandomId("eds-calendar"),b=r.useLocale().locale,v=s.useCalendarGrid(m,n),g=v.gridProps,k=v.headerProps,y=v.weekDays,C=o.getWeeksInMonth(n.visibleRange.start,b),T=Array.from(Array(C).keys());return a.createElement(a.Fragment,null,a.createElement("table",D({},g,{cellSpacing:"0",className:"eds-datepicker__calendar__grid"}),a.createElement("thead",D({},k),a.createElement("tr",null,function(){if(b.toLowerCase().includes("no"))return["ma","ti","on","to","fr","lø","sø"];if(b.toLowerCase().includes("en")){if("M"===y[0])return["Mo","Tu","We","Th","Fr","Sa","Su"];if("S"===y[0])return["Su","Mo","Tu","We","Th","Fr","Sa"]}return y.map((function(e){return e.toLowerCase()}))}().map((function(e,t){return a.createElement("th",{key:t},e)})))),a.createElement("tbody",null,T.map((function(e){return a.createElement("tr",{key:e},n.getDatesInWeek(e).map((function(e,t){return e?a.createElement(A,{key:t,state:n,date:e,"aria-describedby":f+"description",onSelectedCellClick:d,classNameForDate:c,ariaLabelForDate:u}):a.createElement("td",{key:t})})))})))),a.createElement(p.VisuallyHidden,{id:f+"description"},l||(b.toLowerCase().includes("en")?"Use the arrow keys to navigate between dates":"Bruk piltastene til å navigere mellom datoer")))},M=["selectedDate","onChange","locale","minDate","maxDate","style","children","navigationDescription","onSelectedCellClick","classNameForDate","ariaLabelForDate"],Z=a.forwardRef((function(t,n){var l=t.selectedDate,i=t.onChange,o=t.locale,u=t.minDate,m=t.maxDate,p=t.style,f=t.navigationDescription,b=t.onSelectedCellClick,v=void 0===b?function(){}:b,g=t.classNameForDate,k=t.ariaLabelForDate,y=h(t,M),C=r.useLocale().locale,T=D({},y,{value:l,onChange:i,locale:null!=o?o:C,createCalendar:E,minValue:u,maxValue:m}),w=d.useCalendarState(T),I=s.useCalendar(T,w),F=I.prevButtonProps,S=I.nextButtonProps,N=I.title;return a.createElement(e.ConditionalWrapper,{condition:o,wrapper:function(e){return a.createElement(r.I18nProvider,{locale:o},e)}},a.createElement("div",D({},I.calendarProps,{ref:n,className:"eds-datepicker__calendar",style:p}),a.createElement("div",{className:"eds-datepicker__calendar__header"},a.createElement(x,D({},F,{"aria-label":_("Forrige måned",C,F)}),a.createElement(c.LeftArrowIcon,{size:20})),a.createElement("h2",null,N),a.createElement(x,D({},S,{"aria-label":_("Neste måned",C,S)}),a.createElement(c.RightArrowIcon,{size:20}))),a.createElement(V,{state:w,navigationDescription:f,onSelectedCellClick:v,classNameForDate:g,ariaLabelForDate:k})))})),q=["selectedDate","onChange","locale","disabled","showTime","showTimeZone","classNameForDate","className","style","variant","feedback","validationVariant","validationFeedback","disableModal","labelTooltip","navigationDescription","minDate","maxDate","modalTreshold","forcedReturnType","ariaLabelForDate"],B=["className","style","label","onChange","feedback","variant","disableLabelAnimation","prepend"],z=["onChange","variant","value"],j=a.forwardRef((function(t,n){var r=t.className,l=t.style,o=t.label,s=t.onChange,d=t.feedback,u=t.variant,m=t.disableLabelAnimation,p=t.prepend,f=void 0===p?a.createElement(c.DateIcon,{inline:!0}):p,b=h(t,B),v=e.useRandomId("eds-nativetimepicker");return a.createElement(i.BaseFormControl,{style:l,className:r,prepend:f,label:o,feedback:d,variant:u,labelId:v,disableLabelAnimation:m,isFilled:!0},a.createElement(W,D({onChange:s,"aria-labelledby":v,ref:n,variant:u},b)))})),W=a.forwardRef((function(t,n){var r=t.onChange,l=t.variant,o=t.value,s=h(t,z),d=i.useVariant(),c=l||d,u=i.useInputGroupContext(),m=u.isFilled,p=u.setFilled;return e.useOnMount((function(){p&&!m&&p(!0)})),a.useEffect((function(){o?p&&!m&&p(!0):p&&m&&p(!1)}),[o,p,m]),a.createElement("input",D({ref:n,"aria-invalid":"error"===c,type:"date",className:"eds-form-control eds-native-date-picker",onChange:function(e){i.isFilled(e.target)?p&&!m&&p(!0):p&&m&&p(!1),r&&r(e)},value:o},s))})),U=["direction","onClick","disabled","aria-label"],H=function(e){var t=e.direction,n=e.onClick,r=e.disabled,i=e["aria-label"],o=h(e,U);return a.createElement(m.IconButton,D({className:l("eds-timepicker__arrowbutton","eds-timepicker__arrowbutton--"+t,{"eds-timepicker__arrowbutton--disabled":r}),type:"button",tabIndex:-1,onClick:n,"aria-label":i,disabled:r},o),a.createElement("left"===t?c.LeftArrowIcon:c.RightArrowIcon,null))},K=["selectedTime","onChange","disabled","className","style","label","labelTooltip","feedback","granularity","variant","locale","showTimeZone","showSeconds","minuteIncrementForArrowButtons","leftArrowButtonAriaLabel","rightArrowButtonAriaLabel","inputRef","forcedReturnType","forcedTimeZone"],G=["className","style","onChange","label","feedback","variant","prepend"],Y=["onChange","value"],$=a.forwardRef((function(t,n){var r=t.className,o=t.style,s=t.onChange,d=t.label,c=t.feedback,u=t.variant,m=t.prepend,p=h(t,G),f=e.useRandomId("eds-native-timepicker");return a.createElement(i.BaseFormControl,{style:o,className:l(r,"eds-native-timepicker"),prepend:m,label:d,feedback:c,variant:u,labelId:f,disableLabelAnimation:!0},a.createElement(J,D({onChange:s,"aria-labelledby":f,ref:n},p)))})),J=a.forwardRef((function(t,n){var r=t.onChange,l=t.value,o=h(t,Y),s=i.useVariant(),d=o.variant||s,c=i.useInputGroupContext(),u=c.isFilled,m=c.setFilled;return e.useOnMount((function(){m&&!u&&m(!0)})),a.useEffect((function(){l?m&&!u&&m(!0):m&&u&&m(!1)}),[l,m,u]),a.createElement("input",D({ref:n,"aria-invalid":"error"===d,type:"time",className:"eds-form-control",onChange:function(e){i.isFilled(e.target)?m&&!u&&m(!0):m&&u&&m(!1),r&&r(e)},value:l},o))})),Q=["append","className","disabled","feedback","showClockIcon","inputRef","label","labelTooltip","onChange","padding","prepend","readOnly","selectedTime","showSeconds","style","variant"],X=["onBlur","onClick","onDragStart","onFocus","onKeyDown","onKeyUp","onMouseDown","onPointerDown","onPointerUp"];!function(e){e[e.RESET_TIME=0]="RESET_TIME",e[e.INVALID=1]="INVALID"}(k||(k={})),e.warnAboutMissingStyles("datepicker","form","icons"),Object.defineProperty(exports,"CalendarDate",{enumerable:!0,get:function(){return o.CalendarDate}}),Object.defineProperty(exports,"CalendarDateTime",{enumerable:!0,get:function(){return o.CalendarDateTime}}),Object.defineProperty(exports,"Time",{enumerable:!0,get:function(){return o.Time}}),Object.defineProperty(exports,"ZonedDateTime",{enumerable:!0,get:function(){return o.ZonedDateTime}}),exports.Calendar=Z,exports.DateField=L,exports.DatePicker=function(i){var o=i.selectedDate,s=i.onChange,d=i.locale,u=i.disabled,m=i.showTime,p=i.showTimeZone,k=void 0!==p&&p,y=i.classNameForDate,C=i.className,T=i.variant,E=i.feedback,_=i.validationVariant,F=i.validationFeedback,S=i.disableModal,N=void 0!==S&&S,P=i.labelTooltip,R=i.navigationDescription,A=i.minDate,O=i.maxDate,V=i.modalTreshold,M=void 0===V?1e3:V,B=i.forcedReturnType,z=i.ariaLabelForDate,j=h(i,q),W=M,U=a.useRef(null),H=a.useRef(null),K=a.useRef(null),G=e.useWindowDimensions().width,Y=function(e){if(void 0!==B)return s(I({value:e,type:B,timezone:null!==e&&"timezone"in e?e.timezone:void 0}));s(e)},$=t.useDatePickerState(D({},j,{minValue:A,maxValue:"hour"in(null!=O?O:{})?O:void 0!==O?w(O):void 0,value:o,onChange:Y,granularity:m?"minute":j.granularity,isDisabled:u})),J=n.useDatePicker(D({},j),$,U),Q=J.groupProps,X=J.labelProps,ee=J.fieldProps,ae=J.buttonProps,te=J.dialogProps,ne=J.calendarProps,re=f.useFloating({whileElementsMounted:f.autoUpdate,placement:"bottom-start",middleware:[f.offset(v.space.extraSmall),f.flip(),f.shift({padding:v.space.extraSmall})]}),le=re.x,ie=re.y,oe=re.reference,se=re.floating,de=re.strategy;e.useOnClickOutside([H],(function(){$.setOpen(!1)})),e.useOnEscape(H,(function(){$.setOpen(!1)}));var ce=D({},te,ne,{disabled:u,navigationDescription:R,onSelectedCellClick:function(){return $.setOpen(!1)},selectedDate:o,onChange:Y,minDate:A,maxDate:O,ref:H,classNameForDate:y,ariaLabelForDate:z}),ue=void 0!==G&&G<=W&&!N,me=a.createElement("div",{style:{position:de,top:null!=ie?ie:0,left:null!=le?le:0,zIndex:v.zIndexes.popover},ref:function(e){se(e)}},a.createElement(b,{disabled:!$.isOpen||ue,returnFocus:!0},$.isOpen&&a.createElement(Z,D({},ce)))),pe=a.createElement(g.Modal,{size:"small",title:"",open:$.isOpen,onDismiss:function(){return $.setOpen(!1)},className:"eds-datepicker__calendar-modal"},a.createElement(Z,D({},ce)));return a.createElement(e.ConditionalWrapper,{condition:void 0!==d,wrapper:function(e){return a.createElement(r.I18nProvider,{locale:d},e)}},a.createElement("div",{className:l("eds-datepicker",C)},a.createElement("div",D({},Q,{ref:function(e){U.current=e,oe(e)},id:void 0,className:"eds-datepicker__datefield__wrapper"}),a.createElement(L,D({},ee,{selectedDate:o,onChange:Y,label:j.label,labelProps:X,disabled:u,minDate:A,maxDate:O,showTime:m,showTimeZone:k,ref:K,variant:T,feedback:E,validationVariant:_,validationFeedback:F,labelTooltip:P,className:l("eds-datepicker__datefield",{"eds-datepicker__datefield--disabled":u})})),!u&&a.createElement(x,D({},ae,{onPress:function(){return $.setOpen(!$.isOpen)},className:"eds-datepicker__open-calendar-button"}),a.createElement(c.CalendarIcon,null)),ue?pe:me)))},exports.NativeDatePicker=j,exports.NativeTimePicker=$,exports.SimpleTimePicker=function(s){var d=s.append,u=s.disabled,m=s.feedback,p=s.showClockIcon,f=void 0===p?"right":p,b=s.inputRef,v=s.label,g=s.labelTooltip,y=s.onChange,C=s.padding,T=void 0===C?"default":C,E=s.prepend,_=s.readOnly,w=s.selectedTime,I=s.showSeconds,F=s.style,S=s.variant,N=h(s,Q),L=a.useState(""),P=L[0],x=L[1],R=a.useRef(null),A=a.useState(null),O=A[0],V=A[1],M=r.useLocale().locale,Z=t.useTimeFieldState(D({onChange:y,label:v,locale:M,value:w,hideTimeZone:!0,isDisabled:u,isReadOnly:_},N)),q=n.useTimeField(D({},N,{label:v}),Z,R),B=q.labelProps,z=q.fieldProps;a.useEffect((function(){j(),null!==w&&V(w)}),[null==w?void 0:w.toString()]);var j=function(){var e=W(w);x(e);var a=document.activeElement===(null==R?void 0:R.current);""!==e||a||U()},W=function(e){if(null===e)return"";var a="day"in e?o.toTime(e):e;return I?a.toString().slice(0,8):a.toString().slice(0,5)},U=function(){x(I?"–– : –– : ––":"–– : ––")},H=function(){var e=K();if(e===k.INVALID)return j();(null==e?void 0:e.toString())!==(null==w?void 0:w.toString())&&(null==y||y(e))},K=function(){var e=G(P),a=Y(e);return a===k.INVALID?k.INVALID:a===k.RESET_TIME?null:$(a)},G=function(e){if(0===e.length)return k.RESET_TIME;if(e.length<3||e.length>8)return k.INVALID;var a=(e.match(new RegExp(":","g"))||[]).length,t=e.length;if(2===a&&t>=7)return e.padStart(8,"0");if(1===a)return e.padStart(5,"0");if(t>6)return k.INVALID;var n,r=t%2==0,l=e.slice(0,r?2:1),i=r?e.slice(2,4):e.slice(1,3),o=""===(n=r?e.slice(4,6):e.slice(3,5))?"00":n;return l.padStart(2,"0")+":"+i+(I?":"+o:"")},Y=function(e){if(e===k.INVALID)return k.INVALID;if(e===k.RESET_TIME)return k.RESET_TIME;var a=/^\d+$/,t=e.slice(0,2),n=e.slice(3,5),r=e.slice(6,8);if(t.match(a)&&n.match(a)&&(""===r||r.match(a)))try{return o.parseTime(e)}catch(e){return k.INVALID}return k.INVALID},$=function(e){return(null!=O?O:new o.Time).set({hour:e.hour,minute:e.minute,second:e.second})},J=h(z,X);return a.createElement(r.I18nProvider,{locale:M},a.createElement(i.TextField,D({append:d||(!0===f||"right"===f?a.createElement(c.ClockIcon,{onClick:function(){var e;return null==R||null==(e=R.current)?void 0:e.focus()}}):void 0),className:l("eds-simple-timepicker",{"eds-simple-timepicker--padding-large":"large"===T,"eds-simple-timepicker--show-seconds":I,"eds-simple-timepicker--hide-clock":!f}),disabled:u,disableLabelAnimation:!0,feedback:m,label:v,labelProps:B,labelTooltip:g,onBlur:function(){H(),null===w&&U()},onChange:function(e){return x(e.target.value)},onFocus:function(){null===w&&x("")},onKeyDown:function(e){"Enter"===e.key&&H()},placeholder:I?"–– : –– : ––":"–– : ––",prepend:E||("left"===f?a.createElement(c.ClockIcon,{onClick:function(){var e;return null==R||null==(e=R.current)?void 0:e.focus()}}):void 0),readOnly:_,ref:e.mergeRefs(R,b),style:F,value:P,variant:S},J)))},exports.TimePicker=function(s){var d=s.selectedTime,c=s.onChange,u=s.disabled,m=s.className,f=s.style,b=s.label,v=s.labelTooltip,g=s.feedback,k=s.granularity,y=s.variant,T=s.locale,E=s.showTimeZone,_=s.showSeconds,w=void 0!==_&&_,N=s.minuteIncrementForArrowButtons,L=void 0===N?30:N,P=s.leftArrowButtonAriaLabel,x=void 0===P?"Trekk fra "+L+" minutter":P,R=s.rightArrowButtonAriaLabel,A=void 0===R?"Legg til "+L+" minutter":R,O=s.inputRef,V=s.forcedReturnType,M=s.forcedTimeZone,Z=h(s,K),q=r.useLocale().locale;T&&(q=T);var B=e.useRandomId("eds-timepicker"),z=null!=M?M:null!==d&&"timezone"in d?d.timezone:"Europe/Oslo",j=function(e){if(void 0!==V)return c(I({value:e,type:V,timezone:z}));c(e)},W=t.useTimeFieldState(D({onChange:j,label:b,locale:q,value:d,granularity:(null!=k?k:w)?"second":"minute",hideTimeZone:!E,isDisabled:u,shouldForceLeadingZeros:!0},Z)),U=a.useRef(null),G=n.useTimeField(D({},Z,{label:b}),W,U),Y=G.labelProps,$=G.fieldProps,J=e.useRandomId("timepicker"),Q=function(e){if(null===d)return j(I({value:o.now(z),type:null!=V?V:"ZonedDateTime"}));switch(e){case"add":return j(d.add({minutes:L-F(d.minute,L)}));case"subtract":return j(d.subtract({minutes:F(d.minute-1,L)+1}))}};return a.createElement(r.I18nProvider,{locale:q},a.createElement("div",{className:l(m,"eds-timepicker__wrapper")},a.createElement(i.BaseFormControl,D({style:f,className:l("eds-timepicker",{"eds-timepicker--disabled":u}),labelId:J,label:b,labelProps:D({},Y,{"aria-describedby":B+"description"}),ref:e.mergeRefs(U,O),disabled:u,disableLabelAnimation:!0,labelTooltip:v},$,{variant:y,feedback:g,ariaAlertOnFeedback:!0,"aria-describedby":B+"description",prepend:a.createElement(H,{direction:"left",disabled:u,"aria-label":x,onClick:function(){return Q("subtract")},onFocus:function(){return S(U,"first")}}),append:a.createElement(H,{direction:"right",disabled:u,"aria-label":A,onClick:function(){return Q("add")},onFocus:function(){return S(U,"last")}})}),W.segments.map((function(e,t){return a.createElement(C,{segment:e,state:W,key:t,"aria-describedby":B+"description"})}))),a.createElement(p.VisuallyHidden,{id:B+"description"},null!==d?"valgt tid: "+d.hour.toString().padStart(2,"0")+":"+d.minute.toString().padStart(2,"0")+(w?":"+d.second.toString().padStart(2,"0"):""):"")))},exports.ariaLabelIfNorwegian=_,exports.convertValueToType=I,exports.createCalendar=E,exports.focusSegment=S,exports.lastMillisecondOfDay=w,exports.modulo=F,exports.nativeDateToDateValue=function(e,a,t,n){return void 0===a&&(a=!1),null===e?null:a?new o.CalendarDate(e.getFullYear(),e.getMonth()+1,e.getDate()):T(e,t,n)},exports.nativeDateToTimeValue=function(e,a,t,n){return void 0===a&&(a=!1),null===e?null:a?new o.Time(e.getHours(),e.getMinutes(),e.getSeconds(),0):T(e,t,n)},exports.timeOrDateValueToNativeDate=function(e,a){if(null===e)return null;if(!("day"in e)){var t=new Date;return t.setHours(e.hour),t.setMinutes(e.minute),t.setSeconds(e.second),t}return"hour"in e?"timeZone"in e?e.toDate():a?e.toDate(a):new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second):e.toDate(null!=a?a:o.getLocalTimeZone())}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),a=require("react"),t=require("@react-stately/datepicker"),n=require("@react-aria/datepicker"),r=require("@react-aria/i18n"),l=require("classnames"),i=require("@entur/form"),o=require("@internationalized/date"),s=require("@react-aria/calendar"),d=require("@react-stately/calendar"),c=require("@entur/icons"),u=require("@react-aria/button"),m=require("@entur/button"),p=require("@entur/a11y"),f=require("@floating-ui/react-dom"),b=require("react-focus-lock"),v=require("@entur/tokens"),g=require("@entur/modal");function D(){return D=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},D.apply(this,arguments)}function h(e,a){if(null==e)return{};var t,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)a.indexOf(t=l[n])>=0||(r[t]=e[t]);return r}var k,y=["segment","state"],C=function(e){var t=e.segment,r=e.state,i=h(e,y),o=a.useRef(null),s=n.useDateSegment(t,r,o).segmentProps;return a.createElement("div",D({},s,{ref:o,className:l("eds-date-and-time-field__segment",{"eds-date-and-time-field__segment--placeholder":t.isPlaceholder,"eds-date-and-time-field__segment--dot-separator":"."===t.text}),tabIndex:r.isDisabled?-1:s.tabIndex},i),t.text)},T=function(e,a,t){return a?t?new o.ZonedDateTime(e.getFullYear(),e.getMonth()+1,e.getDate(),a,t,e.getHours(),e.getMinutes(),e.getSeconds()):o.parseAbsolute(e.toISOString(),a):new o.CalendarDateTime(e.getFullYear(),e.getMonth()+1,e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())},E=function(e){if(void 0===e&&(e="gregory"),"gregory"===e)return new o.GregorianCalendar;throw new Error("Unsupported calendar "+e)},_=function(e,a,t){return"no-no"!==a.toLowerCase()?t["aria-label"]:e},w=function(e){return o.toCalendarDateTime(e.add({days:1})).add({milliseconds:-1})},I=function(e){var a=e.value,t=e.timezone,n=void 0===t?"Europe/Oslo":t;if(null===a)return null;switch(e.type){case"CalendarDate":return"day"in a?o.toCalendarDate(a):o.today(n);case"CalendarDateTime":return"day"in a?o.toCalendarDateTime(a):o.toCalendarDateTime(o.today(n),a);case"ZonedDateTime":return o.toZoned("day"in a?a:o.toCalendarDateTime(o.today(n),a),n);case"Time":return"hour"in a?"day"in a?o.toTime(a):a:o.toTime(o.now(n));default:return a}},F=function(e,a){return(e%a+a)%a},N=function(e,a){if(e.current){var t=e.current.querySelectorAll(".eds-date-and-time-field__segment"),n=t[0],r=t[t.length-1];switch(a){case"first":return n.focus();case"last":return r.focus()}}},S=["selectedDate","onChange","label","locale","showTimeZone","showTime","granularity","disabled","isDisabled","variant","feedback","validationVariant","validationFeedback","labelTooltip","minDate","maxDate","style","className","labelProps","append"],L=a.forwardRef((function(o,s){var d=o.selectedDate,c=o.onChange,u=o.label,m=o.locale,p=o.showTimeZone,f=o.showTime,b=o.granularity,v=void 0===b?"day":b,g=o.disabled,k=o.isDisabled,y=o.variant,T=o.feedback,_=o.validationVariant,I=void 0===_?"error":_,F=o.validationFeedback,N=void 0===F?"Ugyldig dato":F,L=o.labelTooltip,P=o.minDate,x=o.maxDate,R=o.style,A=o.className,O=o.labelProps,V=o.append,M=h(o,S),Z=r.useLocale(),q=t.useDateFieldState(D({},M,{locale:null!=m?m:Z.locale,createCalendar:E,value:d,onChange:c,hideTimeZone:!p,granularity:f?"minute":v,minValue:P,maxValue:"hour"in(null!=x?x:{})?x:void 0!==x?w(x):void 0,isDisabled:k||g,shouldForceLeadingZeros:!0})),B=a.useRef(null),z=n.useDateField(D({},M,{label:u}),q,B),j=z.labelProps,W=z.fieldProps,U=e.useRandomId("datefield");return a.createElement(e.ConditionalWrapper,{condition:void 0!==m,wrapper:function(e){return a.createElement(r.I18nProvider,{locale:m},e)}},a.createElement(i.BaseFormControl,D({style:R,className:l("eds-datefield",A),labelId:U,ref:e.mergeRefs(B,s),disabled:k||g,disableLabelAnimation:!0,label:u,labelTooltip:L,labelProps:null!=O?O:j},W,{variant:null!=y?y:"invalid"===q.validationState?I:void 0,feedback:null!=T?T:"invalid"===q.validationState?N:void 0,append:V,ariaAlertOnFeedback:!0}),q.segments.map((function(e,t){return a.createElement(C,{segment:e,state:q,key:t})}))))})),P=["children","className","style"],x=function(e){var t=e.children,n=e.className,r=e.style,l=h(e,P),i=a.useRef(null),o=u.useButton(l,i);return a.createElement(m.IconButton,D({},o.buttonProps,{ref:i,className:n,style:r}),t)},R=["state","date","onSelectedCellClick","classNameForDate","ariaLabelForDate"],A=function(e){var t,n,r,i,d=e.state,c=e.date,u=e.onSelectedCellClick,m=void 0===u?function(){}:u,p=e.classNameForDate,f=e.ariaLabelForDate,b=h(e,R),v=a.useRef(null),g=s.useCalendarCell({date:c},d,v),k=g.cellProps,y=g.buttonProps,C=g.isSelected,T=g.isOutsideVisibleRange,E=g.isDisabled,_=g.isUnavailable,w=g.formattedDate,I=y["aria-label"]+" "+(null!=(t=null==f?void 0:f(c))?t:"");return a.createElement("td",D({},k,{className:"eds-datepicker__calendar__grid__cell__td"}),a.createElement("div",D({},y,{"aria-label":I,ref:v,hidden:T,className:l("eds-datepicker__calendar__grid__cell",(i={},i[null!=(n=null==p?void 0:p(c))?n:""]=!T,i["eds-datepicker__calendar__grid__cell--selected"]=C,i["eds-datepicker__calendar__grid__cell--disabled"]=E||_,i["eds-datepicker__calendar__grid__cell--outside-month"]=T,i["eds-datepicker__calendar__grid__cell--today"]=o.isEqualDay(c,o.now(null!=(r=d.timeZone)?r:o.getLocalTimeZone())),i))},b,{onClick:function(e){y.onClick&&y.onClick(e),C&&m()},onKeyDown:function(e){y.onKeyDown&&y.onKeyDown(e),"Enter"!==e.key&&" "!==e.key||C&&m()}}),w))},O=["state","navigationDescription","onSelectedCellClick","classNameForDate","ariaLabelForDate"],V=function(t){var n=t.state,l=t.navigationDescription,i=t.onSelectedCellClick,d=void 0===i?function(){}:i,c=t.classNameForDate,u=t.ariaLabelForDate,m=h(t,O),f=e.useRandomId("eds-calendar"),b=r.useLocale().locale,v=s.useCalendarGrid(m,n),g=v.gridProps,k=v.headerProps,y=v.weekDays,C=o.getWeeksInMonth(n.visibleRange.start,b),T=Array.from(Array(C).keys());return a.createElement(a.Fragment,null,a.createElement("table",D({},g,{cellSpacing:"0",className:"eds-datepicker__calendar__grid"}),a.createElement("thead",D({},k),a.createElement("tr",null,function(){if(b.toLowerCase().includes("no"))return["ma","ti","on","to","fr","lø","sø"];if(b.toLowerCase().includes("en")){if("M"===y[0])return["Mo","Tu","We","Th","Fr","Sa","Su"];if("S"===y[0])return["Su","Mo","Tu","We","Th","Fr","Sa"]}return y.map((function(e){return e.toLowerCase()}))}().map((function(e,t){return a.createElement("th",{key:t},e)})))),a.createElement("tbody",null,T.map((function(e){return a.createElement("tr",{key:e},n.getDatesInWeek(e).map((function(e,t){return e?a.createElement(A,{key:t,state:n,date:e,"aria-describedby":f+"description",onSelectedCellClick:d,classNameForDate:c,ariaLabelForDate:u}):a.createElement("td",{key:t})})))})))),a.createElement(p.VisuallyHidden,{id:f+"description"},l||(b.toLowerCase().includes("en")?"Use the arrow keys to navigate between dates":"Bruk piltastene til å navigere mellom datoer")))},M=["selectedDate","onChange","locale","minDate","maxDate","style","className","children","navigationDescription","onSelectedCellClick","classNameForDate","ariaLabelForDate"],Z=a.forwardRef((function(t,n){var i=t.selectedDate,o=t.onChange,u=t.locale,m=t.minDate,p=t.maxDate,f=t.style,b=t.className,v=t.navigationDescription,g=t.onSelectedCellClick,k=void 0===g?function(){}:g,y=t.classNameForDate,C=t.ariaLabelForDate,T=h(t,M),w=r.useLocale().locale,I=D({},T,{value:i,onChange:o,locale:null!=u?u:w,createCalendar:E,minValue:m,maxValue:p}),F=d.useCalendarState(I),N=s.useCalendar(I,F),S=N.prevButtonProps,L=N.nextButtonProps,P=N.title;return a.createElement(e.ConditionalWrapper,{condition:u,wrapper:function(e){return a.createElement(r.I18nProvider,{locale:u},e)}},a.createElement("div",D({},N.calendarProps,{ref:n,className:l("eds-datepicker__calendar",b),style:f}),a.createElement("div",{className:"eds-datepicker__calendar__header"},a.createElement(x,D({},S,{"aria-label":_("Forrige måned",w,S)}),a.createElement(c.LeftArrowIcon,{size:20})),a.createElement("h2",null,P),a.createElement(x,D({},L,{"aria-label":_("Neste måned",w,L)}),a.createElement(c.RightArrowIcon,{size:20}))),a.createElement(V,{state:F,navigationDescription:v,onSelectedCellClick:k,classNameForDate:y,ariaLabelForDate:C})))})),q=["selectedDate","onChange","locale","disabled","showTime","showTimeZone","classNameForDate","className","style","variant","feedback","validationVariant","validationFeedback","disableModal","labelTooltip","navigationDescription","minDate","maxDate","modalTreshold","forcedReturnType","ariaLabelForDate"],B=["className","style","label","onChange","feedback","variant","disableLabelAnimation","prepend"],z=["onChange","variant","value"],j=a.forwardRef((function(t,n){var r=t.className,l=t.style,o=t.label,s=t.onChange,d=t.feedback,u=t.variant,m=t.disableLabelAnimation,p=t.prepend,f=void 0===p?a.createElement(c.DateIcon,{inline:!0}):p,b=h(t,B),v=e.useRandomId("eds-nativetimepicker");return a.createElement(i.BaseFormControl,{style:l,className:r,prepend:f,label:o,feedback:d,variant:u,labelId:v,disableLabelAnimation:m,isFilled:!0},a.createElement(W,D({onChange:s,"aria-labelledby":v,ref:n,variant:u},b)))})),W=a.forwardRef((function(t,n){var r=t.onChange,l=t.variant,o=t.value,s=h(t,z),d=i.useVariant(),c=l||d,u=i.useInputGroupContext(),m=u.isFilled,p=u.setFilled;return e.useOnMount((function(){p&&!m&&p(!0)})),a.useEffect((function(){o?p&&!m&&p(!0):p&&m&&p(!1)}),[o,p,m]),a.createElement("input",D({ref:n,"aria-invalid":"error"===c,type:"date",className:"eds-form-control eds-native-date-picker",onChange:function(e){i.isFilled(e.target)?p&&!m&&p(!0):p&&m&&p(!1),r&&r(e)},value:o},s))})),U=["direction","onClick","disabled","aria-label"],H=function(e){var t=e.direction,n=e.onClick,r=e.disabled,i=e["aria-label"],o=h(e,U);return a.createElement(m.IconButton,D({className:l("eds-timepicker__arrowbutton","eds-timepicker__arrowbutton--"+t,{"eds-timepicker__arrowbutton--disabled":r}),type:"button",tabIndex:-1,onClick:n,"aria-label":i,disabled:r},o),a.createElement("left"===t?c.LeftArrowIcon:c.RightArrowIcon,null))},K=["selectedTime","onChange","disabled","className","style","label","labelTooltip","feedback","granularity","variant","locale","showTimeZone","showSeconds","minuteIncrementForArrowButtons","leftArrowButtonAriaLabel","rightArrowButtonAriaLabel","inputRef","forcedReturnType","forcedTimeZone"],G=["className","style","onChange","label","feedback","variant","prepend"],Y=["onChange","value"],$=a.forwardRef((function(t,n){var r=t.className,o=t.style,s=t.onChange,d=t.label,c=t.feedback,u=t.variant,m=t.prepend,p=h(t,G),f=e.useRandomId("eds-native-timepicker");return a.createElement(i.BaseFormControl,{style:o,className:l(r,"eds-native-timepicker"),prepend:m,label:d,feedback:c,variant:u,labelId:f,disableLabelAnimation:!0},a.createElement(J,D({onChange:s,"aria-labelledby":f,ref:n},p)))})),J=a.forwardRef((function(t,n){var r=t.onChange,l=t.value,o=h(t,Y),s=i.useVariant(),d=o.variant||s,c=i.useInputGroupContext(),u=c.isFilled,m=c.setFilled;return e.useOnMount((function(){m&&!u&&m(!0)})),a.useEffect((function(){l?m&&!u&&m(!0):m&&u&&m(!1)}),[l,m,u]),a.createElement("input",D({ref:n,"aria-invalid":"error"===d,type:"time",className:"eds-form-control",onChange:function(e){i.isFilled(e.target)?m&&!u&&m(!0):m&&u&&m(!1),r&&r(e)},value:l},o))})),Q=["append","className","disabled","feedback","showClockIcon","inputRef","label","labelTooltip","onChange","padding","prepend","readOnly","selectedTime","showSeconds","style","variant"],X=["onBlur","onClick","onDragStart","onFocus","onKeyDown","onKeyUp","onMouseDown","onPointerDown","onPointerUp"];!function(e){e[e.RESET_TIME=0]="RESET_TIME",e[e.INVALID=1]="INVALID"}(k||(k={})),e.warnAboutMissingStyles("datepicker","form","icons"),Object.defineProperty(exports,"CalendarDate",{enumerable:!0,get:function(){return o.CalendarDate}}),Object.defineProperty(exports,"CalendarDateTime",{enumerable:!0,get:function(){return o.CalendarDateTime}}),Object.defineProperty(exports,"Time",{enumerable:!0,get:function(){return o.Time}}),Object.defineProperty(exports,"ZonedDateTime",{enumerable:!0,get:function(){return o.ZonedDateTime}}),exports.Calendar=Z,exports.DateField=L,exports.DatePicker=function(i){var o=i.selectedDate,s=i.onChange,d=i.locale,u=i.disabled,m=i.showTime,p=i.showTimeZone,k=void 0!==p&&p,y=i.classNameForDate,C=i.className,T=i.variant,E=i.feedback,_=i.validationVariant,F=i.validationFeedback,N=i.disableModal,S=void 0!==N&&N,P=i.labelTooltip,R=i.navigationDescription,A=i.minDate,O=i.maxDate,V=i.modalTreshold,M=void 0===V?1e3:V,B=i.forcedReturnType,z=i.ariaLabelForDate,j=h(i,q),W=M,U=a.useRef(null),H=a.useRef(null),K=a.useRef(null),G=e.useWindowDimensions().width,Y=function(e){if(void 0!==B)return s(I({value:e,type:B,timezone:null!==e&&"timezone"in e?e.timezone:void 0}));s(e)},$=t.useDatePickerState(D({},j,{minValue:A,maxValue:"hour"in(null!=O?O:{})?O:void 0!==O?w(O):void 0,value:o,onChange:Y,granularity:m?"minute":j.granularity,isDisabled:u})),J=n.useDatePicker(D({},j),$,U),Q=J.groupProps,X=J.labelProps,ee=J.fieldProps,ae=J.buttonProps,te=J.dialogProps,ne=J.calendarProps,re=f.useFloating({whileElementsMounted:f.autoUpdate,placement:"bottom-start",middleware:[f.offset(v.space.extraSmall),f.flip(),f.shift({padding:v.space.extraSmall})]}),le=re.x,ie=re.y,oe=re.reference,se=re.floating,de=re.strategy;e.useOnClickOutside([H],(function(){$.setOpen(!1)})),e.useOnEscape(H,(function(){$.setOpen(!1)}));var ce=D({},te,ne,{disabled:u,navigationDescription:R,onSelectedCellClick:function(){return $.setOpen(!1)},selectedDate:o,onChange:Y,minDate:A,maxDate:O,ref:H,classNameForDate:y,ariaLabelForDate:z}),ue=void 0!==G&&G<=W&&!S,me=a.createElement("div",{style:{position:de,top:null!=ie?ie:0,left:null!=le?le:0,zIndex:v.zIndexes.popover},ref:function(e){se(e)}},a.createElement(b,{disabled:!$.isOpen||ue,returnFocus:!0},$.isOpen&&a.createElement(Z,D({},ce)))),pe=a.createElement(g.Modal,{size:"small",title:"",open:$.isOpen,onDismiss:function(){return $.setOpen(!1)},className:"eds-datepicker__calendar-modal"},a.createElement(Z,D({},ce)));return a.createElement(e.ConditionalWrapper,{condition:void 0!==d,wrapper:function(e){return a.createElement(r.I18nProvider,{locale:d},e)}},a.createElement("div",{className:l("eds-datepicker",C)},a.createElement("div",D({},Q,{ref:function(e){U.current=e,oe(e)},id:void 0,className:"eds-datepicker__datefield__wrapper"}),a.createElement(L,D({},ee,{selectedDate:o,onChange:Y,label:j.label,labelProps:X,disabled:u,minDate:A,maxDate:O,showTime:m,showTimeZone:k,ref:K,variant:T,feedback:E,validationVariant:_,validationFeedback:F,labelTooltip:P,className:l("eds-datepicker__datefield",{"eds-datepicker__datefield--disabled":u})})),!u&&a.createElement(x,D({},ae,{onPress:function(){return $.setOpen(!$.isOpen)},className:"eds-datepicker__open-calendar-button"}),a.createElement(c.CalendarIcon,null)),ue?pe:me)))},exports.NativeDatePicker=j,exports.NativeTimePicker=$,exports.SimpleTimePicker=function(s){var d=s.append,u=s.disabled,m=s.feedback,p=s.showClockIcon,f=void 0===p?"right":p,b=s.inputRef,v=s.label,g=s.labelTooltip,y=s.onChange,C=s.padding,T=void 0===C?"default":C,E=s.prepend,_=s.readOnly,w=s.selectedTime,I=s.showSeconds,F=s.style,N=s.variant,S=h(s,Q),L=a.useState(""),P=L[0],x=L[1],R=a.useRef(null),A=a.useState(null),O=A[0],V=A[1],M=r.useLocale().locale,Z=t.useTimeFieldState(D({onChange:y,label:v,locale:M,value:w,hideTimeZone:!0,isDisabled:u,isReadOnly:_},S)),q=n.useTimeField(D({},S,{label:v}),Z,R),B=q.labelProps,z=q.fieldProps;a.useEffect((function(){j(),null!==w&&V(w)}),[null==w?void 0:w.toString()]);var j=function(){var e=W(w);x(e);var a=document.activeElement===(null==R?void 0:R.current);""!==e||a||U()},W=function(e){if(null===e)return"";var a="day"in e?o.toTime(e):e;return I?a.toString().slice(0,8):a.toString().slice(0,5)},U=function(){x(I?"–– : –– : ––":"–– : ––")},H=function(){var e=K();if(e===k.INVALID)return j();(null==e?void 0:e.toString())!==(null==w?void 0:w.toString())&&(null==y||y(e))},K=function(){var e=G(P),a=Y(e);return a===k.INVALID?k.INVALID:a===k.RESET_TIME?null:$(a)},G=function(e){if(0===e.length)return k.RESET_TIME;if(e.length<3||e.length>8)return k.INVALID;var a=(e.match(new RegExp(":","g"))||[]).length,t=e.length;if(2===a&&t>=7)return e.padStart(8,"0");if(1===a)return e.padStart(5,"0");if(t>6)return k.INVALID;var n,r=t%2==0,l=e.slice(0,r?2:1),i=r?e.slice(2,4):e.slice(1,3),o=""===(n=r?e.slice(4,6):e.slice(3,5))?"00":n;return l.padStart(2,"0")+":"+i+(I?":"+o:"")},Y=function(e){if(e===k.INVALID)return k.INVALID;if(e===k.RESET_TIME)return k.RESET_TIME;var a=/^\d+$/,t=e.slice(0,2),n=e.slice(3,5),r=e.slice(6,8);if(t.match(a)&&n.match(a)&&(""===r||r.match(a)))try{return o.parseTime(e)}catch(e){return k.INVALID}return k.INVALID},$=function(e){return(null!=O?O:new o.Time).set({hour:e.hour,minute:e.minute,second:e.second})},J=h(z,X);return a.createElement(r.I18nProvider,{locale:M},a.createElement(i.TextField,D({append:d||(!0===f||"right"===f?a.createElement(c.ClockIcon,{onClick:function(){var e;return null==R||null==(e=R.current)?void 0:e.focus()}}):void 0),className:l("eds-simple-timepicker",{"eds-simple-timepicker--padding-large":"large"===T,"eds-simple-timepicker--show-seconds":I,"eds-simple-timepicker--hide-clock":!f}),disabled:u,disableLabelAnimation:!0,feedback:m,label:v,labelProps:B,labelTooltip:g,onBlur:function(){H(),null===w&&U()},onChange:function(e){return x(e.target.value)},onFocus:function(){null===w&&x("")},onKeyDown:function(e){"Enter"===e.key&&H()},placeholder:I?"–– : –– : ––":"–– : ––",prepend:E||("left"===f?a.createElement(c.ClockIcon,{onClick:function(){var e;return null==R||null==(e=R.current)?void 0:e.focus()}}):void 0),readOnly:_,ref:e.mergeRefs(R,b),style:F,value:P,variant:N},J)))},exports.TimePicker=function(s){var d=s.selectedTime,c=s.onChange,u=s.disabled,m=s.className,f=s.style,b=s.label,v=s.labelTooltip,g=s.feedback,k=s.granularity,y=s.variant,T=s.locale,E=s.showTimeZone,_=s.showSeconds,w=void 0!==_&&_,S=s.minuteIncrementForArrowButtons,L=void 0===S?30:S,P=s.leftArrowButtonAriaLabel,x=void 0===P?"Trekk fra "+L+" minutter":P,R=s.rightArrowButtonAriaLabel,A=void 0===R?"Legg til "+L+" minutter":R,O=s.inputRef,V=s.forcedReturnType,M=s.forcedTimeZone,Z=h(s,K),q=r.useLocale().locale;T&&(q=T);var B=e.useRandomId("eds-timepicker"),z=null!=M?M:null!==d&&"timezone"in d?d.timezone:"Europe/Oslo",j=function(e){if(void 0!==V)return c(I({value:e,type:V,timezone:z}));c(e)},W=t.useTimeFieldState(D({onChange:j,label:b,locale:q,value:d,granularity:(null!=k?k:w)?"second":"minute",hideTimeZone:!E,isDisabled:u,shouldForceLeadingZeros:!0},Z)),U=a.useRef(null),G=n.useTimeField(D({},Z,{label:b}),W,U),Y=G.labelProps,$=G.fieldProps,J=e.useRandomId("timepicker"),Q=function(e){if(null===d)return j(I({value:o.now(z),type:null!=V?V:"ZonedDateTime"}));switch(e){case"add":return j(d.add({minutes:L-F(d.minute,L)}));case"subtract":return j(d.subtract({minutes:F(d.minute-1,L)+1}))}};return a.createElement(r.I18nProvider,{locale:q},a.createElement("div",{className:l(m,"eds-timepicker__wrapper")},a.createElement(i.BaseFormControl,D({style:f,className:l("eds-timepicker",{"eds-timepicker--disabled":u}),labelId:J,label:b,labelProps:D({},Y,{"aria-describedby":B+"description"}),ref:e.mergeRefs(U,O),disabled:u,disableLabelAnimation:!0,labelTooltip:v},$,{variant:y,feedback:g,ariaAlertOnFeedback:!0,"aria-describedby":B+"description",prepend:a.createElement(H,{direction:"left",disabled:u,"aria-label":x,onClick:function(){return Q("subtract")},onFocus:function(){return N(U,"first")}}),append:a.createElement(H,{direction:"right",disabled:u,"aria-label":A,onClick:function(){return Q("add")},onFocus:function(){return N(U,"last")}})}),W.segments.map((function(e,t){return a.createElement(C,{segment:e,state:W,key:t,"aria-describedby":B+"description"})}))),a.createElement(p.VisuallyHidden,{id:B+"description"},null!==d?"valgt tid: "+d.hour.toString().padStart(2,"0")+":"+d.minute.toString().padStart(2,"0")+(w?":"+d.second.toString().padStart(2,"0"):""):"")))},exports.ariaLabelIfNorwegian=_,exports.convertValueToType=I,exports.createCalendar=E,exports.focusSegment=N,exports.lastMillisecondOfDay=w,exports.modulo=F,exports.nativeDateToDateValue=function(e,a,t,n){return void 0===a&&(a=!1),null===e?null:a?new o.CalendarDate(e.getFullYear(),e.getMonth()+1,e.getDate()):T(e,t,n)},exports.nativeDateToTimeValue=function(e,a,t,n){return void 0===a&&(a=!1),null===e?null:a?new o.Time(e.getHours(),e.getMinutes(),e.getSeconds(),0):T(e,t,n)},exports.timeOrDateValueToNativeDate=function(e,a){if(null===e)return null;if(!("day"in e)){var t=new Date;return t.setHours(e.hour),t.setMinutes(e.minute),t.setSeconds(e.second),t}return"hour"in e?"timeZone"in e?e.toDate():a?e.toDate(a):new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second):e.toDate(null!=a?a:o.getLocalTimeZone())}; | ||
//# sourceMappingURL=datepicker.cjs.production.min.js.map |
@@ -295,3 +295,3 @@ import { useRandomId, ConditionalWrapper, mergeRefs, useWindowDimensions, useOnClickOutside, useOnEscape, useOnMount, warnAboutMissingStyles } from '@entur/utils'; | ||
var CalendarCell = function CalendarCell(_ref) { | ||
var _ariaLabelForDate, _classNameForDate, _state$timeZone; | ||
var _ariaLabelForDate, _classNameForDate, _state$timeZone, _classNames; | ||
var state = _ref.state, | ||
@@ -324,8 +324,3 @@ date = _ref.date, | ||
hidden: isOutsideVisibleRange, | ||
className: classNames('eds-datepicker__calendar__grid__cell', [(_classNameForDate = classNameForDate == null ? void 0 : classNameForDate(date)) != null ? _classNameForDate : ''], { | ||
'eds-datepicker__calendar__grid__cell--selected': isSelected, | ||
'eds-datepicker__calendar__grid__cell--disabled': isDisabled || isUnavailable, | ||
'eds-datepicker__calendar__grid__cell--outside-month': isOutsideVisibleRange, | ||
'eds-datepicker__calendar__grid__cell--today': isEqualDay(date, now((_state$timeZone = state.timeZone) != null ? _state$timeZone : getLocalTimeZone())) | ||
}) | ||
className: classNames('eds-datepicker__calendar__grid__cell', (_classNames = {}, _classNames[(_classNameForDate = classNameForDate == null ? void 0 : classNameForDate(date)) != null ? _classNameForDate : ''] = !isOutsideVisibleRange, _classNames['eds-datepicker__calendar__grid__cell--selected'] = isSelected, _classNames['eds-datepicker__calendar__grid__cell--disabled'] = isDisabled || isUnavailable, _classNames['eds-datepicker__calendar__grid__cell--outside-month'] = isOutsideVisibleRange, _classNames['eds-datepicker__calendar__grid__cell--today'] = isEqualDay(date, now((_state$timeZone = state.timeZone) != null ? _state$timeZone : getLocalTimeZone())), _classNames)) | ||
}, rest, { | ||
@@ -406,3 +401,3 @@ onClick: function onClick(e) { | ||
var _excluded$6 = ["selectedDate", "onChange", "locale", "minDate", "maxDate", "style", "children", "navigationDescription", "onSelectedCellClick", "classNameForDate", "ariaLabelForDate"]; | ||
var _excluded$6 = ["selectedDate", "onChange", "locale", "minDate", "maxDate", "style", "className", "children", "navigationDescription", "onSelectedCellClick", "classNameForDate", "ariaLabelForDate"]; | ||
var Calendar = /*#__PURE__*/React.forwardRef(function (_ref, ref) { | ||
@@ -415,2 +410,3 @@ var selectedDate = _ref.selectedDate, | ||
style = _ref.style, | ||
className = _ref.className, | ||
navigationDescription = _ref.navigationDescription, | ||
@@ -449,3 +445,3 @@ _ref$onSelectedCellCl = _ref.onSelectedCellClick, | ||
ref: ref, | ||
className: "eds-datepicker__calendar", | ||
className: classNames('eds-datepicker__calendar', className), | ||
style: style | ||
@@ -452,0 +448,0 @@ }), React.createElement("div", { |
@@ -9,2 +9,4 @@ import React from 'react'; | ||
style?: React.CSSProperties; | ||
/** Ekstra klassenavn */ | ||
className?: string; | ||
onSelectedCellClick?: () => void; | ||
@@ -11,0 +13,0 @@ /** Tidligste gyldige datovalg. |
{ | ||
"name": "@entur/datepicker", | ||
"version": "9.2.0-beta.0", | ||
"version": "9.2.0", | ||
"license": "EUPL-1.2", | ||
@@ -30,10 +30,10 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@entur/a11y": "^0.2.75", | ||
"@entur/button": "^3.2.10", | ||
"@entur/form": "^7.0.38-beta.0", | ||
"@entur/icons": "^6.15.0", | ||
"@entur/modal": "^1.7.31-beta.0", | ||
"@entur/tokens": "^3.12.0", | ||
"@entur/tooltip": "^2.6.47-beta.0", | ||
"@entur/typography": "^1.8.23", | ||
"@entur/a11y": "^0.2.76", | ||
"@entur/button": "^3.2.11", | ||
"@entur/form": "^7.0.38", | ||
"@entur/icons": "^6.15.1", | ||
"@entur/modal": "^1.7.31", | ||
"@entur/tokens": "^3.13.0", | ||
"@entur/tooltip": "^2.6.47", | ||
"@entur/typography": "^1.8.24", | ||
"@entur/utils": "^0.10.0", | ||
@@ -52,3 +52,3 @@ "@floating-ui/react-dom": "^1.0.0", | ||
}, | ||
"gitHead": "453c823f5b935959f701f0c777236a8e0c23601e" | ||
"gitHead": "907373a47cc81ae12be266bac1d10522033f8b49" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
464458
2
3069
Updated@entur/a11y@^0.2.76
Updated@entur/button@^3.2.11
Updated@entur/form@^7.0.38
Updated@entur/icons@^6.15.1
Updated@entur/modal@^1.7.31
Updated@entur/tokens@^3.13.0
Updated@entur/tooltip@^2.6.47
Updated@entur/typography@^1.8.24