@sbb-esta/lyne-elements-dev 5.9.0-dev.1790158785 → 5.9.0-dev.1790159051
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/calendar.pure.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isServer as r,nothing as i,unsafeCSS as a}from"lit";import{property as o,state as s}from"lit/decorators.js";import{MONDAY as c,SbbButtonLikeBaseElement as l,SbbDisabledMixin as u,SbbElement as ee,SbbFormAssociatedMixin as te,SbbLanguageController as d,SbbPropertyWatcherController as f,THURSDAY as ne,TUESDAY as re,WEDNESDAY as ie,buttonResetStyles as ae,defaultDateAdapter as p,forceType as m,
|
|
2
|
-
`,
|
|
3
|
-
`;let
|
|
1
|
+
import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isServer as r,nothing as i,unsafeCSS as a}from"lit";import{property as o,state as s}from"lit/decorators.js";import{MONDAY as c,SbbButtonLikeBaseElement as l,SbbDisabledMixin as u,SbbElement as ee,SbbFormAssociatedMixin as te,SbbLanguageController as d,SbbPropertyWatcherController as f,THURSDAY as ne,TUESDAY as re,WEDNESDAY as ie,buttonResetStyles as ae,defaultDateAdapter as p,forceType as m,getNextElementIndex as oe,handleDistinctChange as se,i18nCalendarDateSelection as h,i18nCalendarWeekNumber as g,i18nNextMonth as ce,i18nNextYear as le,i18nNextYearRange as ue,i18nPreviousMonth as de,i18nPreviousYear as fe,i18nPreviousYearRange as pe,i18nYearMonthSelection as me,isArrowKeyOrPageKeysPressed as _,plainDate as v,readConfig as y,screenReaderOnlyStyles as he}from"./core.js";import{SbbSecondaryButtonElement as ge}from"./button.pure.js";import{SbbIconElement as _e}from"./icon.pure.js";var b=`:host{--sbb-focus-outline-offset:.125rem;--sbb-calendar-cell-transition-duration:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-2x));font-size:var(--sbb-calendar-cell-font-size);letter-spacing:var(--sbb-letter-spacing-text);cursor:var(--sbb-calendar-cell-cursor);color:var(--sbb-calendar-cell-color);border-radius:calc(var(--sbb-border-radius-4x) + var(--sbb-calendar-cell-border-width));margin:var(--sbb-calendar-cell-margin);padding:var(--sbb-calendar-cell-border-width);transition-duration:var(--sbb-calendar-cell-transition-duration);transition-timing-function:var(--sbb-calendar-cell-transition-easing-function);background-clip:content-box;transition-property:background-color;display:block}:host(:is(sbb-calendar-weekday,sbb-calendar-weeknumber)){--sbb-calendar-cell-font-size:var(--sbb-text-font-size-xs);--sbb-calendar-day-height:var(--sbb-calendar-day-size);color:var(--sbb-calendar-header-color);margin-inline:auto}:host(:is(sbb-calendar-day,sbb-calendar-weekday,sbb-calendar-weeknumber)){height:var(--sbb-calendar-day-height);width:var(--sbb-calendar-day-width)}:host(:is(:state(current),[state--current])){font-weight:700}:host(:is(:state(selected),[state--selected])){border:var(--sbb-calendar-cell-border-width) solid var(--sbb-calendar-cell-border-color-selected);padding:0}:host(:disabled){--sbb-calendar-cell-color:var(--sbb-calendar-cell-disabled-color);--sbb-calendar-cell-cursor:default}:host(:disabled:is(:state(crossed-out),[state--crossed-out])){--sbb-calendar-cell-color:var(--sbb-calendar-cell-disabled-crossed-out-color)}:host(:focus-visible){outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style,solid) var(--sbb-focus-outline-width)}@media (any-hover:hover){:host(:not(:disabled,:where(:is(:state(active),[state--active]),:active)):hover){background-color:var(--sbb-calendar-cell-background-color-hover)}}@media (any-hover:hover) and (forced-colors:active){:host(:not(:disabled):hover){outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style,solid) var(--sbb-focus-outline-width);--sbb-focus-outline-style:initial}}:host(:not(:disabled):where(:is(:state(active),[state--active]),:active)){background-color:var(--sbb-calendar-cell-background-color-active)}.sbb-action-base{flex-direction:column;justify-content:center;width:100%;height:100%;display:flex}.sbb-calendar-year,.sbb-calendar-month{height:var(--sbb-calendar-cell-year-month-height);min-width:var(--sbb-calendar-cell-year-month-width);justify-content:center;width:100%}:host(:is(:state(crossed-out),[state--crossed-out])) :is(.sbb-calendar-year,.sbb-calendar-month,.sbb-calendar-day__value):after{content:"";height:var(--sbb-calendar-cell-disabled-height);width:var(--sbb-calendar-cell-disabled-width);background-color:var(--sbb-calendar-cell-disabled-crossed-out-color);position:absolute;top:50%;left:50%;translate:-50% -50%;rotate:-45deg}
|
|
2
|
+
`,x=class extends u(l){static{this.styles=[a(b)]}constructor(){super(),this.dateAdapter=y().datetime?.dateAdapter??p,this.addController(new f(this,()=>this.getParent(),{dateFilter:e=>this.setDisabledFilteredState(e),min:e=>this.setDisabledFilteredState(e),max:e=>this.setDisabledFilteredState(e),value:e=>this.setSelectedState(e)}))}getParent(){return this.getRootNode?.()?.host?.closest(`sbb-calendar`)}formResetCallback(){}formStateRestoreCallback(e,t){}},S=`.sbb-calendar-day{justify-content:var(--sbb-calendar-day-justify-content)}.sbb-calendar-day__value{height:var(--sbb-calendar-day-value-height);justify-content:center;align-items:center;display:flex;position:relative}.sbb-calendar-day__extra{display:var(--sbb-calendar-day-extra-display);height:var(--sbb-calendar-day-extra-height)}::slotted(*){height:var(--sbb-calendar-day-extra-height)}
|
|
3
|
+
`;let C=(()=>{let r=x,i=[],c,l;return class extends r{constructor(){super(...arguments),this._value=(t(this,i),null)}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(r[Symbol.metadata]??null):void 0;c=[o()],l=[s()],e(this,null,c,{kind:`setter`,name:`slot`,static:!1,private:!1,access:{has:e=>`slot`in e,set:(e,t)=>{e.slot=t}},metadata:t},null,i),e(this,null,l,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,i),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar-day`}static{this.styles=[a(S)]}set slot(e){super.slot=e,this.value=this.dateAdapter.deserialize(e)}get slot(){return super.slot}set value(e){let t=this.dateAdapter.getValidDateOrNull(this.dateAdapter.deserialize(e));if(t){this._value=t;let e=this.dateAdapter.sameDate(t,this.dateAdapter.today());this.toggleState(`current`,e),this.internals.ariaCurrent=e?`date`:null,this.internals.ariaLabel=this.dateAdapter.getAccessibilityFormatDate(t);let n=this.getParent();n&&(this.setDisabledFilteredState(n),this.setSelectedState(n))}}get value(){return this._value}connectedCallback(){super.connectedCallback(),this.tabIndex=-1}getParent(){return this.closest?.(`sbb-calendar`)??this.getRootNode?.()?.host?.closest(`sbb-calendar`)}setSelectedState(e){let t=this.dateAdapter.isValid(this.value)&&(e.multiple?e.value.some(e=>this.dateAdapter.sameDate(this.value,e)):!!e.value&&this.dateAdapter.compareDate(this.value,e.value)===0);this.toggleState(`selected`,t),this.internals.ariaPressed=String(t)}setDisabledFilteredState(e){let t=!this._isActiveDate(e.dateFilter),n=!this._isDayInRange(e.min,e.max);this.disabled=t||n,this.internals.ariaDisabled=String(this.disabled),this.toggleState(`crossed-out`,t&&!n)}_isActiveDate(e){return e&&this.dateAdapter.isValid(this.value)?e(this.value):!0}_isDayInRange(e,t){return!this.dateAdapter.isValid(this.value)||!e&&!t||this.dateAdapter.sameDate(this.value,this.dateAdapter.clampDate(this.value,e,t))}_handleSlotchange(e){this.internals.ariaDescribedByElements=e.target.assignedElements()}renderTemplate(){return n` <span class="sbb-calendar-day__value" aria-hidden="true">
|
|
4
4
|
${this.value?this.dateAdapter.getDate(this.value):``}
|
|
5
5
|
</span>
|
|
6
6
|
<span class="sbb-calendar-day__extra">
|
|
7
7
|
<slot @slotchange=${e=>this._handleSlotchange(e)}></slot>
|
|
8
|
-
</span>`}}})(),
|
|
9
|
-
`,D=class extends Event{get range(){return this._range}constructor(e){super(`monthchange`,{bubbles:!0,composed:!0}),this._range=Object.freeze(e||[])}},O=class extends Event{get dateSelected(){return this._dateSelected}constructor(e){super(`dateselected`,{bubbles:!0,composed:!0}),this._dateSelected=Object.freeze(e)}};let k=(()=>{let l=te(ee),u=[],f,y=[],b=[],x,k=[],A=[],j,M=[],N=[],P,F=[],ye=[],I,L=[],R=[],z,B,V=[],H=[],U,W=[],G=[],K,q,J,Y=[],X=[],Z,be=[],xe=[],Q,Se=[],Ce=[],we,Te=[],Ee=[],De,Oe=[],$=[];return class extends l{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(l[Symbol.metadata]??null):void 0;f=[m(),o({type:Number})],x=[o()],j=[_(),o()],P=[_(),o()],I=[m(),oe((e,t)=>e._onMultipleChanged(t)),o({type:Boolean})],z=[o()],B=[s()],U=[o({attribute:`date-filter`})],K=[o({attribute:`fixed-month`})],q=[o({attribute:`active-month`})],J=[o({reflect:!0})],Z=[m(),o({attribute:`week-numbers`,type:Boolean})],Q=[s()],we=[s()],De=[s()],e(this,null,f,{kind:`accessor`,name:`amount`,static:!1,private:!1,access:{has:e=>`amount`in e,get:e=>e.amount,set:(e,t)=>{e.amount=t}},metadata:t},y,b),e(this,null,x,{kind:`accessor`,name:`view`,static:!1,private:!1,access:{has:e=>`view`in e,get:e=>e.view,set:(e,t)=>{e.view=t}},metadata:t},k,A),e(this,null,j,{kind:`accessor`,name:`min`,static:!1,private:!1,access:{has:e=>`min`in e,get:e=>e.min,set:(e,t)=>{e.min=t}},metadata:t},M,N),e(this,null,P,{kind:`accessor`,name:`max`,static:!1,private:!1,access:{has:e=>`max`in e,get:e=>e.max,set:(e,t)=>{e.max=t}},metadata:t},F,ye),e(this,null,I,{kind:`accessor`,name:`multiple`,static:!1,private:!1,access:{has:e=>`multiple`in e,get:e=>e.multiple,set:(e,t)=>{e.multiple=t}},metadata:t},L,R),e(this,null,z,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,u),e(this,null,B,{kind:`accessor`,name:`_value`,static:!1,private:!1,access:{has:e=>`_value`in e,get:e=>e._value,set:(e,t)=>{e._value=t}},metadata:t},V,H),e(this,null,U,{kind:`accessor`,name:`dateFilter`,static:!1,private:!1,access:{has:e=>`dateFilter`in e,get:e=>e.dateFilter,set:(e,t)=>{e.dateFilter=t}},metadata:t},W,G),e(this,null,K,{kind:`setter`,name:`fixedMonth`,static:!1,private:!1,access:{has:e=>`fixedMonth`in e,set:(e,t)=>{e.fixedMonth=t}},metadata:t},null,u),e(this,null,q,{kind:`setter`,name:`activeMonth`,static:!1,private:!1,access:{has:e=>`activeMonth`in e,set:(e,t)=>{e.activeMonth=t}},metadata:t},null,u),e(this,null,J,{kind:`accessor`,name:`orientation`,static:!1,private:!1,access:{has:e=>`orientation`in e,get:e=>e.orientation,set:(e,t)=>{e.orientation=t}},metadata:t},Y,X),e(this,null,Z,{kind:`accessor`,name:`weekNumbers`,static:!1,private:!1,access:{has:e=>`weekNumbers`in e,get:e=>e.weekNumbers,set:(e,t)=>{e.weekNumbers=t}},metadata:t},be,xe),e(this,null,Q,{kind:`accessor`,name:`_activeDate`,static:!1,private:!1,access:{has:e=>`_activeDate`in e,get:e=>e._activeDate,set:(e,t)=>{e._activeDate=t}},metadata:t},Se,Ce),e(this,null,we,{kind:`accessor`,name:`_calendarView`,static:!1,private:!1,access:{has:e=>`_calendarView`in e,get:e=>e._calendarView,set:(e,t)=>{e._calendarView=t}},metadata:t},Te,Ee),e(this,null,De,{kind:`accessor`,name:`_initialized`,static:!1,private:!1,access:{has:e=>`_initialized`in e,get:e=>e._initialized,set:(e,t)=>{e._initialized=t}},metadata:t},Oe,$),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar`}static{this.elementDependencies=[S,C,T,E,w,_e,ge]}static{this.styles=[ae,he,a(ve)]}static{this.events={dateselected:`dateselected`,monthchange:`monthchange`}}#e;get amount(){return this.#e}set amount(e){this.#e=e}#t;get view(){return this.#t}set view(e){this.#t=e}#n;get min(){return this.#n}set min(e){this.#n=e}#r;get max(){return this.#r}set max(e){this.#r=e}#i;get multiple(){return this.#i}set multiple(e){this.#i=e}set value(e){if(Array.isArray(e))this._value=e.map(e=>this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e))).filter(e=>e!==null).filter(e=>!this._isDayInRange(this._dateAdapter.toIso8601(e))||this._dateFilter(e)).sort(this._sortDate);else{let t=this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));this._value=t&&(!this._isDayInRange(this._dateAdapter.toIso8601(t))||this._dateFilter(t))?t:null}}get value(){return this._value}#a;get _value(){return this.#a}set _value(e){this.#a=e}#o;get dateFilter(){return this.#o}set dateFilter(e){this.#o=e}set fixedMonth(e){this._fixedMonth=this._parseMonth(e)}get fixedMonth(){return this._fixedMonth?this._toMonthIsoString(this._fixedMonth):``}set activeMonth(e){this._activeMonth=this._parseMonth(e),this._resetCalendarView()}get activeMonth(){return this._activeMonth?this._toMonthIsoString(this._activeMonth):``}#s;get orientation(){return this.#s}set orientation(e){this.#s=e}#c;get weekNumbers(){return this.#c}set weekNumbers(e){this.#c=e}#l;get _activeDate(){return this.#l}set _activeDate(e){this.#l=e}#u;get _calendarView(){return this.#u}set _calendarView(e){this.#u=e}get _cells(){return Array.from((this._calendarView===`day`?Array.from(this.shadowRoot.querySelectorAll(`slot`)).flatMap(e=>e.assignedElements({flatten:!0})):this.shadowRoot?.querySelectorAll(`sbb-calendar-${this._calendarView}`))??[])}#d;get _initialized(){return this.#d}set _initialized(e){this.#d=e}constructor(){super(),this.#e=(t(this,u),t(this,y,1)),this.#t=(t(this,b),t(this,k,`day`)),this.#n=(t(this,A),t(this,M,null)),this.#r=(t(this,N),t(this,F,null)),this.#i=(t(this,ye),t(this,L,!1)),this.#a=(t(this,R),t(this,V,null)),this.#o=(t(this,H),t(this,W,null)),this._fixedMonth=(t(this,G),null),this._activeMonth=null,this.#s=t(this,Y,`horizontal`),this.#c=(t(this,X),t(this,be,!1)),this._dateAdapter=(t(this,xe),v().datetime?.dateAdapter??p),this.#l=t(this,Se,this._dateAdapter.today()),this.#u=(t(this,Ce),t(this,Te,`day`)),this._weekdays=t(this,Ee),this._weeks=[],this._firstVisibleDay=``,this._lastVisibleDay=``,this._monthNames=this._dateAdapter.getMonthNames(`long`),this._enhancedVariant=!1,this._resetFocus=!1,this._containingFocus=!1,this._lastSelection=null,this.#d=t(this,Oe,!1),this._language=(t(this,$),new d(this).withHandler(()=>{this._monthNames=this._dateAdapter.getMonthNames(`long`),this._createMonthRows()})),this._sortDate=(e,t)=>this._dateAdapter.compareDate(e,t),this._onSlotChange=()=>{this._enhancedVariant=Array.from(this.children).some(e=>e.localName===`sbb-calendar-day`),this.toggleState(`enhanced`,this._enhancedVariant),this._setTabIndex()},this._createMonthRows(),this._setWeekdays(),this.addEventListener(`focusin`,()=>this._containingFocus=!0),this.addEventListener(`focusout`,()=>this._containingFocus=!1);let e=e=>e.target.closest(`sbb-calendar-day`)??e.composedPath().find(e=>e.localName===`sbb-calendar-day`)??null;this.addEventListener(`click`,t=>{let n=e(t);n&&this._selectDate(n.value,t)}),this.addEventListener(`keydown`,t=>{let n=e(t);n&&this._handleKeyboardEvent(t,n)}),this.addEventListener(`blur`,()=>this._lastSelection=null)}_dateFilter(e){return this.dateFilter?.(e)??!0}_parseMonth(e){if(typeof e==`string`){let t=e?e.match(/^(\d{4})-(\d{2})$/):null;return t?this._dateAdapter.createDate(Number(t[1]),Number(t[2]),1):null}return e instanceof Date?this._dateAdapter.createDate(e.getFullYear(),e.getMonth()+1,1):this._dateAdapter.isDateInstance(e)&&this._dateAdapter.isValid(e)?this._dateAdapter.clone(e):null}_toMonthIsoString(e){return this._dateAdapter.toIso8601(e).split(`-`).slice(0,2).join(`-`)}resetPosition(){this._resetCalendarView()}connectedCallback(){super.connectedCallback(),this.resetPosition(),this.shadowRoot?.addEventListener(`slotchange`,this._onSlotChange,{capture:!0})}disconnectedCallback(){super.disconnectedCallback(),this.shadowRoot?.removeEventListener(`slotchange`,this._onSlotChange,{capture:!0})}visibleDays(){return this._weeks.flat(2).sort((e,t)=>e.value.localeCompare(t.value))}formResetCallback(){}formStateRestoreCallback(e,t){if(t===`autocomplete`||e==null)return;let n=e=>this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));if(typeof e==`string`)this.value=n(e);else if(e instanceof FormData){if(this.multiple){this._readFormData(e).then(e=>this.value=e.map(n).filter(e=>e!=null));return}let t=e.get(this.name);t instanceof Blob?t.text().then(e=>this.value=n(JSON.parse(e))):this.value=n(t)}}async _readFormData(e){return Promise.all(e.getAll(this.name).map(async e=>e instanceof Blob?JSON.parse(await e.text()):e))}focus(){this._resetFocus=!0,this._focusCell()}willUpdate(e){super.willUpdate(e),this._initialized&&((e.has(`amount`)||e.has(`orientation`)||e.has(`fixedMonth`))&&this.resetPosition(),e.has(`view`)&&(this._setChosenYear(),this._chosenMonth=void 0,this._calendarView=this.view))}requestUpdate(e,t,n){super.requestUpdate(e,t,n),e===`_calendarView`?(this.internals.states.delete(`view-${t}`),this.internals.states.add(`view-${this._calendarView}`),this._containingFocus&&(this._resetFocus=!0)):e===`amount`&&this.toggleState(`single-month`,this.amount===1)}updated(e){super.updated(e),this._setTabIndex(),this._focusCell()}firstUpdated(e){super.firstUpdated(e),this._emitMonthChange()}_onMultipleChanged(e){e&&!Array.isArray(this._value)&&(this._value=this._value?[this._value]:[]),!e&&Array.isArray(this._value)&&(this._value=this._value.length?this._value[0]:null)}_createCalendarState(e){if(r)return;if(this.hydrationRequired){this.hydrationComplete.then(()=>this._createCalendarState());return}e&&this._assignActiveDate(e);let t=this._fixedMonth??this._activeDate,n=this.amount<1?1:this.amount;if(this._weeks.length===n&&this._isSameMonth(this._weeks[0][0][0].dateValue,t))return;this._weeks=Array.from({length:n},(e,n)=>this._createWeekRows(this._dateAdapter.addCalendarMonths(t,n)));let i=this._weeks[0][0][0].dateValue;this._firstVisibleDay=this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(i),this._dateAdapter.getMonth(i),1));let a=this._weeks[n-1][0][0].dateValue;this._lastVisibleDay=this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(a),this._dateAdapter.getMonth(a),this._dateAdapter.getNumDaysInMonth(a))),this._years=this._createYearRows(),this._weekNumbers=this._weeks.map(e=>e.flat().sort((e,t)=>e.value.localeCompare(t.value)).map(e=>e.weekValue).filter((e,t,n)=>n.indexOf(e)===t)),this._initialized=!0}_isSameMonth(e,t){return this._dateAdapter.getYear(e)===this._dateAdapter.getYear(t)&&this._dateAdapter.getMonth(e)===this._dateAdapter.getMonth(t)}_focusCell(){this._resetFocus&&=(this._getFirstFocusable()?.focus(),!1)}_setWeekdays(){let e=this._dateAdapter.getDayOfWeekNames(`narrow`),t=this._dateAdapter.getDayOfWeekNames(`long`).map((t,n)=>({long:t,narrow:e[n]})),n=this._dateAdapter.getFirstDayOfWeek();this._weekdays=t.slice(n).concat(t.slice(0,n))}_createWeekRows(e){let t=this._dateAdapter.getNumDaysInMonth(e),n=this._dateAdapter.getFirstWeekOffset(e);return this.orientation===`horizontal`?this._createWeekRowsHorizontal(e,t,n):this._createWeekRowsVertical(e,t,n)}_createWeekRowsHorizontal(e,t,n){let r=[[]];for(let i=0,a=n;i<t;i++,a++){a===7&&(r.push([]),a=0);let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),i+1);r[r.length-1].push(this._mapDateToDay(t))}return r}_createWeekRowsVertical(e,t,n){let r=Array.from({length:7},()=>[]);for(let i=0,a=n;i<t;i++,a++){a===7&&(a=0);let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),i+1);r[a].push(this._mapDateToDay(t))}return r}_mapDateToDay(e){return{value:this._dateAdapter.toIso8601(e),dateValue:e,dayValue:String(this._dateAdapter.getDate(e)),monthValue:String(this._dateAdapter.getMonth(e)),yearValue:String(this._dateAdapter.getYear(e)),weekValue:this._getWeek(e),weekDayValue:this._dateAdapter.getDayOfWeek(e)}}_getWeek(e){let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),1,1),n=this._dateAdapter.getDayOfWeek(t),r=+!![c,re,ie,ne].includes(n),i=this._dateAdapter.addCalendarDays(t,this._dateAdapter.getFirstWeekOffset(t)*-1);for(;this._dateAdapter.compareDate(i,e)<=0;){let n=this._dateAdapter.addCalendarDays(i,6);if(this._dateAdapter.compareDate(e,n)<=0)return r>0?r:this._getWeek(this._dateAdapter.addCalendarDays(t,-1));i=this._dateAdapter.addCalendarDays(i,7),r++}throw Error(`The provided date is invalid`)}_mapValueToISODate(e){return typeof e==`string`?e:this._dateAdapter.toIso8601(e)}_createMonthRows(){let e=Array(12).fill(null).map((e,t)=>({value:String(t+1).padStart(2,`0`),monthValue:t+1})),t=[];for(let n=0;n<3;n++)t.push(e.slice(4*n,4*(n+1)));this._months=t}_createYearRows(){let e=this._getStartValueYearView(),t=Array(24).fill(0).map((t,n)=>e+n),n=[];for(let e=0;e<6;e++)n.push(t.slice(4*e,4*(e+1)));return n}_getStartValueYearView(){let e=0;this.max?e=this._dateAdapter.getYear(this.max)-24+1:this.min&&(e=this._dateAdapter.getYear(this.min));let t=this._dateAdapter.getYear(this._activeDate);return t-((t-e)%24+24)%24}_isDayInRange(e){if(!this.min&&!this.max)return!0;let t=this._dateAdapter.deserialize(e);return this._dateAdapter.sameDate(t,this._dateAdapter.clampDate(t,this.min,this.max))}_selectDate(e,t){if(this._chosenMonth=void 0,this._setChosenYear(),this.multiple){window.getSelection()?.removeAllRanges();let n=this._value?Array.isArray(this._value)?this._value:[this._value]:[],r=n.map(e=>this._dateAdapter.toIso8601(e));if(t.shiftKey&&this._lastSelection&&r.includes(this._dateAdapter.toIso8601(this._lastSelection))&&!r.includes(this._dateAdapter.toIso8601(e))){let t=this._dateAdapter.compareDate(this._lastSelection,e)<0?1:-1,i=[],a=this._lastSelection;for(;!this._dateAdapter.sameDate(a,e);){a=this._dateAdapter.addCalendarDays(a,t);let e=this._dateAdapter.toIso8601(a);r.includes(e)||i.push(e)}n=this._mergeDates(i,r)}else n=n.some(t=>this._dateAdapter.sameDate(t,e))?n.filter(t=>!this._dateAdapter.sameDate(t,e)):[...n,e].sort(this._sortDate);this._lastSelection=e,this._value=n,this._emitDateSelectedEvent(this._value.map(e=>this._dateAdapter.deserialize(e)))}else(!this._value||this._dateAdapter.compareDate(this._value,e)!==0)&&(this._value=e,this._emitDateSelectedEvent(this._dateAdapter.deserialize(e)))}_selectMultipleDates(e){this._value=this._mergeDates(e.map(e=>e.value)),this._emitDateSelectedEvent(this._value.map(e=>this._dateAdapter.deserialize(e)))}_mergeDates(e,t){t??=this._value.map(e=>this._dateAdapter.toIso8601(e));let n=this._cells.filter(e=>!e.disabled).map(e=>this._mapValueToISODate(e.value)),r=e.filter(e=>n.includes(e));return t=r.every(e=>t.includes(e))?t.filter(e=>!r.includes(e)):[...t,...r].filter((e,t,n)=>n.indexOf(e)===t),t.map(e=>this._dateAdapter.deserialize(e)).sort(this._sortDate)}_emitDateSelectedEvent(e){this.dispatchEvent(new O(e)),this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_emitMonthChange(){let e=this.visibleDays();this.dispatchEvent(new D(e))}_setChosenYear(){if(this.view===`month`){let e;e=this.multiple?this.value.at(-1):this.value,this._chosenYear=this._dateAdapter.getYear(e??this._dateAdapter.today())}else this._chosenYear=void 0}_assignActiveDate(e){this._activeDate=this._dateAdapter.clampDate(e,this.min,this.max)}_goToDifferentMonth(e){this._createCalendarState(this._dateAdapter.addCalendarMonths(this._activeDate,e)),this._emitMonthChange()}_goToDifferentYear(e){this._chosenYear+=e,this._activeDate=this._dateAdapter.createDate(this._chosenYear,this._dateAdapter.getMonth(this._activeDate),1),this._createCalendarState()}_goToDifferentYearRange(e){this._createCalendarState(this._dateAdapter.addCalendarYears(this._activeDate,e))}_prevDisabled(e){return this.min?this._dateAdapter.compareDate(e,this.min)<0:!1}_nextDisabled(e){return this.max?this._dateAdapter.compareDate(e,this.max)>0:!1}_previousMonthDisabled(){let e=this._dateAdapter.addCalendarDays(this._activeDate,this._dateAdapter.getDate(this._activeDate)*-1);return this._prevDisabled(e)}_nextMonthDisabled(){let e=this._dateAdapter.addCalendarMonths(this._activeDate,this.amount<1?1:this.amount);return e=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),1),this._nextDisabled(e)}_previousYearDisabled(){let e=this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate)-1,12,31);return this._prevDisabled(e)}_nextYearDisabled(){let e=this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate)+(this.amount<1?1:this.amount),1,1);return this._nextDisabled(e)}_previousYearRangeDisabled(){let e=this._dateAdapter.createDate(this._years[0][0]-1,12,31);return this._prevDisabled(e)}_nextYearRangeDisabled(){let e=this._years.flat(2).at(-1),t=this._dateAdapter.createDate(e+1,1,1);return this._nextDisabled(t)}_handleTableBlur(e){e?.localName!==`sbb-calendar-day`&&this._setTabIndex()}_setTabIndex(){Array.from(this._cells.filter(e=>e.tabIndex===0)??[]).forEach(e=>e.tabIndex=-1);let e=this._getFirstFocusable();e&&(e.tabIndex=0)}_getFirstFocusable(){if(this._calendarView===`day`){let e=this._cells.find(e=>e.matches(`:is(:state(selected),[state--selected])`))??this._cells.find(e=>e.matches(`:is(:state(current),[state--current])`));return e&&!e.disabled?e:this._getFirstFocusableDay()}{let e=this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(selected),[state--selected])`)??this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(current),[state--current])`);return e&&!e.disabled?e:this.shadowRoot.querySelector(`sbb-calendar-${this._calendarView}:not([disabled])`)}}_getFirstFocusableDay(){let e=this._cells,t=e.filter(e=>!e.disabled);if(!t||t.length===0)return null;{let n=t.map(e=>this._dateAdapter.toIso8601(e.value)).sort()[0];return e.find(e=>e.matches(`[slot="${n}"]`))??null}}_handleKeyboardEvent(e,t){me(e)&&e.preventDefault();let n=t??e.target,r=this._cells,i=r.indexOf(n),a;a=t?this._navigateByKeyboardDayView(e,i,r,this._mapDateToDay(t.value)):this._navigateByKeyboard(e,i,r);let o=(this._enhancedVariant?document:this.shadowRoot).activeElement;a!==o&&(a.tabIndex=0,a.focus(),r.includes(o)&&(o.tabIndex=-1))}_navigateByKeyboardDayView(e,t,n,r){let i=this.orientation===`horizontal`?{leftRight:1,upDown:7}:{leftRight:7,upDown:1};switch(e.key){case`ArrowUp`:return this._findDayArrows(n,t,r.dateValue,-i.upDown);case`ArrowDown`:return this._findDayArrows(n,t,r.dateValue,i.upDown);case`ArrowLeft`:return this._findDayArrows(n,t,r.dateValue,-i.leftRight);case`ArrowRight`:return this._findDayArrows(n,t,r.dateValue,i.leftRight);case`PageUp`:if(this.orientation===`horizontal`){let e=(r.dayValue%7||7)-r.dayValue;return this._findDayPageUpDown(n,t,r,e,i.upDown)}{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue),a=(Math.ceil((+r.dayValue+e)/7)-1)*7-e+1-r.dayValue;return this._findDayPageUpDown(n,t,r,a,i.upDown)}case`PageDown`:if(this.orientation===`horizontal`){let e=+r.monthValue+1>12?1:+r.monthValue+1,a=+r.monthValue+1>12?+r.yearValue+1:+r.yearValue,o=this._dateAdapter.createDate(a,e,1),s=this._dateAdapter.getDate(this._dateAdapter.addCalendarDays(o,-1)),c=Math.trunc((s-+r.dayValue)/7)*7;return this._findDayPageUpDown(n,t,r,c,-i.upDown)}{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue),a=Math.ceil((+r.dayValue+e)/7)*7-e-r.dayValue;return this._findDayPageUpDown(n,t,r,a,-i.upDown)}case`Home`:return this._findDayFirst(n,t,r,1);case`End`:{let e=+r.monthValue+1>12?1:+r.monthValue+1,i=+r.monthValue+1>12?+r.yearValue+1:+r.yearValue,a=this._dateAdapter.createDate(i,e,1);return this._findDayLast(n,t,a)}default:return n[t]}}_isDayOutOfView(e){return e<this._firstVisibleDay||e>this._lastVisibleDay}_findDayArrows(e,t,n,r){let i=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n,r));if(this._isDayOutOfView(i))return e[t];let a=e.find(e=>this._mapValueToISODate(e.value)===i);return!a||a.disabled?this._findDayArrows(e,t,this._dateAdapter.deserialize(i),r):a}_findDayPageUpDown(e,t,n,r,i){let a=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n.dateValue,r));if(this._isDayOutOfView(a))return e[t];let o=e.find(e=>this._mapValueToISODate(e.value)===a);return!o||o.disabled?this._findDayPageUpDown(e,t,n,r+i,i):o}_findDayFirst(e,t,n,r){let i=this._dateAdapter.toIso8601(this._dateAdapter.createDate(+n.yearValue,+n.monthValue,r));if(this._isDayOutOfView(i))return e[t];let a=e.find(e=>this._mapValueToISODate(e.value)===i);return!a||a.disabled?this._findDayFirst(e,t,n,r+1):a}_findDayLast(e,t,n){let r=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n,-1));if(this._isDayOutOfView(r))return e[t];let i=e.find(e=>this._mapValueToISODate(e.value)===r);return!i||i.disabled?this._findDayLast(e,t,this._dateAdapter.deserialize(r)):i}_navigateByKeyboard(e,t,n){let{elementIndexForWideMode:r,offsetForWideMode:i,lastElementIndexForWideMode:a,verticalOffset:o}=this._calculateParametersForKeyboardNavigation(t,this._calendarView===`year`);switch(e.key){case`ArrowUp`:return this._findNext(n,t,-o);case`ArrowDown`:return this._findNext(n,t,o);case`ArrowLeft`:return this._findNext(n,t,-1);case`ArrowRight`:return this._findNext(n,t,1);case`Home`:return this._findFirst(n,i);case`PageUp`:return this._findFirstOnColumn(n,r,i,o);case`PageDown`:return this._findLastOnColumn(n,t,a,o);case`End`:return this._findLast(n,a-1);default:return n[t]}}_calculateParametersForKeyboardNavigation(e,t){let n=t?24:12,r=Math.trunc(e/n)*n,i=r===0?e:e-n;return{verticalOffset:4,elementIndexForWideMode:i,offsetForWideMode:e-i,lastElementIndexForWideMode:r===0?n:n*2}}_findNext(e,t,n){let r=t+n;for(;r<e.length&&e[r]?.disabled;)r+=n;return e[r]??e[t]}_findFirst(e,t){return e[t].disabled?this._findNext(e,t,1):e[t]}_findLast(e,t){return e[t].disabled?this._findNext(e,t,-1):e[t]}_findFirstOnColumn(e,t,n,r){let i=t%r+n;return e[i].disabled?this._findNext(e,i,r):e[i]}_findLastOnColumn(e,t,n,r){let i=t+Math.trunc((n-t-1)/r)*r;return e[i].disabled?this._findNext(e,i,-r):e[i]}_resetCalendarViewAndEmitMonthChange(){this._resetCalendarView(),this._emitMonthChange()}_resetCalendarView(){this._containingFocus&&(this._resetFocus=!0),this._activeDate=this._activeMonth??(this.multiple?this._value.at(-1):this._value)??this._dateAdapter.today(),this._setChosenYear(),this._chosenMonth=void 0,this._createCalendarState(),this._calendarView=this.view}_createDayTable(e,t,r){let a=e[0][0].dateValue,o=`${this._monthNames[this._dateAdapter.getMonth(a)-1]} ${this._dateAdapter.getYear(a)}`,s=e.flat(),c=e.flat();return n`
|
|
8
|
+
</span>`}}})(),w=(()=>{let r=x,i=[],a;return class o extends r{constructor(){super(...arguments),this._monthShortNames=(t(this,i),this.dateAdapter.getMonthNames(`short`)),this._monthLongNames=this.dateAdapter.getMonthNames(`long`),this._monthValue=null,this._yearValue=null,this._value=null}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(r[Symbol.metadata]??null):void 0;a=[s()],e(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,i),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar-month`}static{this._monthFormatRegex=/^\d{4}-(0[1-9]|1[0-2])$/}set value(e){if(!e||!o._monthFormatRegex.test(e))return;this._value=e;let t=e.split(`-`);this._yearValue=Number(t[0]),this._monthValue=Number(t[1]);let n=this._yearValue===this.dateAdapter.getYear(this.dateAdapter.today())&&this._monthValue===this.dateAdapter.getMonth(this.dateAdapter.today());this.toggleState(`current`,n),this.internals.ariaLabel=`${this._monthLongNames[this._monthValue-1]} ${this._yearValue}`;let r=this.getParent();r&&(this.setDisabledFilteredState(r),this.setSelectedState(r))}get value(){return this._value}connectedCallback(){super.connectedCallback(),this.tabIndex=-1}setSelectedState(e){let t=!!this.value&&(e.multiple?e.value?.some(e=>this._yearValue===this.dateAdapter.getYear(e)&&this._monthValue===this.dateAdapter.getMonth(e))??!1:!!e.value&&this.dateAdapter.getYear(e.value)===this._yearValue&&this.dateAdapter.getMonth(e.value)===this._monthValue);this.toggleState(`selected`,t),this.internals.ariaPressed=String(t)}setDisabledFilteredState(e){let t=!this._isActiveMonth(e),n=!this._isMonthInRange(e.min,e.max);this.disabled=t||n,this.internals.ariaDisabled=String(this.disabled),this.toggleState(`crossed-out`,t&&!n)}_isActiveMonth(e){if(!e.dateFilter||!this._yearValue||!this._monthValue)return!0;let t=this.dateAdapter.createDate(this._yearValue,this._monthValue,1);for(let n=t;this.dateAdapter.getMonth(n)==this._monthValue;n=this.dateAdapter.addCalendarDays(n,1))if(e.dateFilter(n))return!0;return!1}_isMonthInRange(e,t){if(!e&&!t||!this._yearValue||!this._monthValue)return!0;let n=this.dateAdapter.isValid(e)&&(this._yearValue<this.dateAdapter.getYear(e)||this._yearValue===this.dateAdapter.getYear(e)&&this._monthValue<this.dateAdapter.getMonth(e)),r=this.dateAdapter.isValid(t)&&(this._yearValue>this.dateAdapter.getYear(t)||this._yearValue===this.dateAdapter.getYear(t)&&this._monthValue>this.dateAdapter.getMonth(t));return!(n||r)}renderTemplate(){return n`${this._monthShortNames[this._monthValue-1]}`}}})(),T=(()=>{let r=x,i=[],a;return class extends r{constructor(){super(...arguments),this._value=(t(this,i),null)}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(r[Symbol.metadata]??null):void 0;a=[s()],e(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,i),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar-year`}set value(e){let t=Number(e);if(isNaN(t))return;this._value=e;let n=this.dateAdapter.getYear(this.dateAdapter.today())===t;this.toggleState(`current`,n),this.internals.ariaLabel=String(t);let r=this.getParent();r&&(this.setDisabledFilteredState(r),this.setSelectedState(r))}get value(){return this._value}connectedCallback(){super.connectedCallback(),this.tabIndex=-1}setSelectedState(e){let t=!!this.value&&(e.multiple?e.value?.some(e=>Number(this.value)===this.dateAdapter.getYear(e))??!1:!!e.value&&this.dateAdapter.getYear(e.value)===Number(this.value));this.toggleState(`selected`,t),this.internals.ariaPressed=String(t)}setDisabledFilteredState(e){let t=!this._isActiveYear(e),n=!this._isYearInRange(e.min,e.max);this.disabled=t||n,this.internals.ariaDisabled=String(this.disabled),this.toggleState(`crossed-out`,t&&!n)}_isActiveYear(e){if(!e.dateFilter||!this.value)return!0;let t=this.dateAdapter.createDate(Number(this.value),1,1);for(let n=t;this.dateAdapter.getYear(n)==Number(this.value);n=this.dateAdapter.addCalendarDays(n,1))if(e.dateFilter(n))return!0;return!1}_isYearInRange(e,t){if(!e&&!t||!this.value)return!0;let n=this.dateAdapter.isValid(e)&&this.dateAdapter.getYear(e)>Number(this.value),r=this.dateAdapter.isValid(t)&&this.dateAdapter.getYear(t)<Number(this.value);return!(n||r)}renderTemplate(){return n`${this.value}`}}})(),E=(()=>{let r=x,i=[],a;return class extends r{constructor(){super(...arguments),this._value=(t(this,i),null)}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(r[Symbol.metadata]??null):void 0;a=[s()],e(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,i),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar-weekday`}set value(e){e&&(this._value=e,this.internals.ariaLabel=e.long)}get value(){return this._value}setSelectedState(){}setDisabledFilteredState(){}renderTemplate(){return n`${this.value?.narrow}`}}})(),D=(()=>{let r=x,i=[],a;return class extends r{constructor(){super(...arguments),this._language=(t(this,i),new d(this)),this._value=null}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(r[Symbol.metadata]??null):void 0;a=[s()],e(this,null,a,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,i),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar-weeknumber`}set value(e){e&&(this._value=String(e),this.internals.ariaLabel=`${g[this._language.current]} ${e}`)}get value(){return this._value}setSelectedState(){}setDisabledFilteredState(){}renderTemplate(){return n`${this.value}`}}})();var ve=`:host{width:max-content;max-width:100%;line-height:var(--sbb-typo-line-height-text);display:block}:host(:is(:state(enhanced),[state--enhanced])){--sbb-calendar-cell-padding-block-end:var(--sbb-spacing-fixed-3x)}.sbb-calendar__wrapper{gap:var(--sbb-calendar-tables-gap);flex-wrap:wrap;width:100%;display:flex;position:relative}:host(:is(:state(single-month),[state--single-month])) .sbb-calendar__table-wrapper{width:100%;min-width:fit-content}.sbb-calendar__table-data>slot{justify-content:center;display:flex}:is(.sbb-calendar__year-view,.sbb-calendar__month-view){position:absolute;inset-block-start:0;inset-inline-start:0}:host(:not(:is(:state(view-day),[state--view-day]))) .sbb-calendar__day-view{visibility:hidden}.sbb-calendar__table-header{align-items:center;gap:var(--sbb-calendar-control-gap);height:var(--sbb-size-element-xs);margin-block-end:var(--sbb-spacing-fixed-4x);display:flex}.sbb-calendar__table-header span{color:var(--sbb-calendar-control-view-change-color);flex:auto;padding-inline-start:var(--sbb-spacing-fixed-3x)}.sbb-calendar__control{-webkit-tap-highlight-color:transparent}.sbb-calendar__table{border-collapse:collapse;flex:0 0;width:100%;height:max-content}.sbb-calendar__table :is(thead,tbody){text-align:center}.sbb-calendar__table-header-cell,.sbb-calendar__table-header-cell-vertical{width:var(--sbb-calendar-cell-size);min-width:var(--sbb-calendar-cell-size);color:var(--sbb-calendar-header-color);font-size:var(--sbb-text-font-size-xs);letter-spacing:var(--sbb-letter-spacing-text);justify-content:center;padding:0;font-weight:400}:host(:not([multiple])) .sbb-calendar__table-header-cell,:host(:not([multiple])) .sbb-calendar__table-header-cell-vertical{height:var(--sbb-calendar-cell-size)}.sbb-calendar__table-header-cell-vertical{padding-block-end:var(--sbb-calendar-cell-padding-block-end)}.sbb-calendar__table-data{text-align:center;padding:0;position:relative}.sbb-calendar__day-cell{padding-block-end:var(--sbb-calendar-cell-padding-block-end)}:host(:not(:is(:state(enhanced),[state--enhanced]))) sbb-calendar-day{--sbb-calendar-day-justify-content:center;--sbb-calendar-day-height:var(--sbb-calendar-day-size);--sbb-calendar-day-extra-display:none;--sbb-calendar-day-value-height:unset}
|
|
9
|
+
`,O=class extends Event{get range(){return this._range}constructor(e){super(`monthchange`,{bubbles:!0,composed:!0}),this._range=Object.freeze(e||[])}},k=class extends Event{get dateSelected(){return this._dateSelected}constructor(e){super(`dateselected`,{bubbles:!0,composed:!0}),this._dateSelected=Object.freeze(e)}};let A=(()=>{let l=te(ee),u=[],f,b=[],x=[],S,A=[],j=[],M,N=[],P=[],F,ye=[],I=[],L,R=[],z=[],B,V,H=[],U=[],W,G=[],K=[],q,J,Y,X=[],Z=[],be,xe=[],Q=[],Se,Ce=[],we=[],Te,Ee=[],De=[],Oe,ke=[],$=[];return class extends l{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(l[Symbol.metadata]??null):void 0;f=[m(),o({type:Number})],S=[o()],M=[v(),o()],F=[v(),o()],L=[m(),se((e,t)=>e._onMultipleChanged(t)),o({type:Boolean})],B=[o()],V=[s()],W=[o({attribute:`date-filter`})],q=[o({attribute:`fixed-month`})],J=[o({attribute:`active-month`})],Y=[o({reflect:!0})],be=[m(),o({attribute:`week-numbers`,type:Boolean})],Se=[s()],Te=[s()],Oe=[s()],e(this,null,f,{kind:`accessor`,name:`amount`,static:!1,private:!1,access:{has:e=>`amount`in e,get:e=>e.amount,set:(e,t)=>{e.amount=t}},metadata:t},b,x),e(this,null,S,{kind:`accessor`,name:`view`,static:!1,private:!1,access:{has:e=>`view`in e,get:e=>e.view,set:(e,t)=>{e.view=t}},metadata:t},A,j),e(this,null,M,{kind:`accessor`,name:`min`,static:!1,private:!1,access:{has:e=>`min`in e,get:e=>e.min,set:(e,t)=>{e.min=t}},metadata:t},N,P),e(this,null,F,{kind:`accessor`,name:`max`,static:!1,private:!1,access:{has:e=>`max`in e,get:e=>e.max,set:(e,t)=>{e.max=t}},metadata:t},ye,I),e(this,null,L,{kind:`accessor`,name:`multiple`,static:!1,private:!1,access:{has:e=>`multiple`in e,get:e=>e.multiple,set:(e,t)=>{e.multiple=t}},metadata:t},R,z),e(this,null,B,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,u),e(this,null,V,{kind:`accessor`,name:`_value`,static:!1,private:!1,access:{has:e=>`_value`in e,get:e=>e._value,set:(e,t)=>{e._value=t}},metadata:t},H,U),e(this,null,W,{kind:`accessor`,name:`dateFilter`,static:!1,private:!1,access:{has:e=>`dateFilter`in e,get:e=>e.dateFilter,set:(e,t)=>{e.dateFilter=t}},metadata:t},G,K),e(this,null,q,{kind:`setter`,name:`fixedMonth`,static:!1,private:!1,access:{has:e=>`fixedMonth`in e,set:(e,t)=>{e.fixedMonth=t}},metadata:t},null,u),e(this,null,J,{kind:`setter`,name:`activeMonth`,static:!1,private:!1,access:{has:e=>`activeMonth`in e,set:(e,t)=>{e.activeMonth=t}},metadata:t},null,u),e(this,null,Y,{kind:`accessor`,name:`orientation`,static:!1,private:!1,access:{has:e=>`orientation`in e,get:e=>e.orientation,set:(e,t)=>{e.orientation=t}},metadata:t},X,Z),e(this,null,be,{kind:`accessor`,name:`weekNumbers`,static:!1,private:!1,access:{has:e=>`weekNumbers`in e,get:e=>e.weekNumbers,set:(e,t)=>{e.weekNumbers=t}},metadata:t},xe,Q),e(this,null,Se,{kind:`accessor`,name:`_activeDate`,static:!1,private:!1,access:{has:e=>`_activeDate`in e,get:e=>e._activeDate,set:(e,t)=>{e._activeDate=t}},metadata:t},Ce,we),e(this,null,Te,{kind:`accessor`,name:`_calendarView`,static:!1,private:!1,access:{has:e=>`_calendarView`in e,get:e=>e._calendarView,set:(e,t)=>{e._calendarView=t}},metadata:t},Ee,De),e(this,null,Oe,{kind:`accessor`,name:`_initialized`,static:!1,private:!1,access:{has:e=>`_initialized`in e,get:e=>e._initialized,set:(e,t)=>{e._initialized=t}},metadata:t},ke,$),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar`}static{this.elementDependencies=[C,w,E,D,T,_e,ge]}static{this.styles=[ae,he,a(ve)]}static{this.events={dateselected:`dateselected`,monthchange:`monthchange`}}#e;get amount(){return this.#e}set amount(e){this.#e=e}#t;get view(){return this.#t}set view(e){this.#t=e}#n;get min(){return this.#n}set min(e){this.#n=e}#r;get max(){return this.#r}set max(e){this.#r=e}#i;get multiple(){return this.#i}set multiple(e){this.#i=e}set value(e){if(Array.isArray(e))this._value=e.map(e=>this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e))).filter(e=>e!==null).filter(e=>!this._isDayInRange(this._dateAdapter.toIso8601(e))||this._dateFilter(e)).sort(this._sortDate);else{let t=this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));this._value=t&&(!this._isDayInRange(this._dateAdapter.toIso8601(t))||this._dateFilter(t))?t:null}}get value(){return this._value}#a;get _value(){return this.#a}set _value(e){this.#a=e}#o;get dateFilter(){return this.#o}set dateFilter(e){this.#o=e}set fixedMonth(e){this._fixedMonth=this._parseMonth(e)}get fixedMonth(){return this._fixedMonth?this._toMonthIsoString(this._fixedMonth):``}set activeMonth(e){this._activeMonth=this._parseMonth(e),this._resetCalendarView()}get activeMonth(){return this._activeMonth?this._toMonthIsoString(this._activeMonth):``}#s;get orientation(){return this.#s}set orientation(e){this.#s=e}#c;get weekNumbers(){return this.#c}set weekNumbers(e){this.#c=e}#l;get _activeDate(){return this.#l}set _activeDate(e){this.#l=e}#u;get _calendarView(){return this.#u}set _calendarView(e){this.#u=e}get _cells(){return Array.from((this._calendarView===`day`?Array.from(this.shadowRoot.querySelectorAll(`slot`)).flatMap(e=>e.assignedElements({flatten:!0})):this.shadowRoot?.querySelectorAll(`sbb-calendar-${this._calendarView}`))??[])}get _weekdayCells(){return Array.from(this.shadowRoot?.querySelectorAll(`sbb-calendar-weekday`)??[])}get _weekNumberCells(){return Array.from(this.shadowRoot?.querySelectorAll(`sbb-calendar-weeknumber`)??[])}#d;get _initialized(){return this.#d}set _initialized(e){this.#d=e}get _tabbableGroups(){let e={key:`weekdays`,value:()=>this._weekdayCells},t={key:`weekNumbers`,value:()=>this._weekNumberCells},n={key:`days`,value:()=>this._cells};return this.orientation===`vertical`?[t,e,n]:[e,t,n]}constructor(){super(),this.#e=(t(this,u),t(this,b,1)),this.#t=(t(this,x),t(this,A,`day`)),this.#n=(t(this,j),t(this,N,null)),this.#r=(t(this,P),t(this,ye,null)),this.#i=(t(this,I),t(this,R,!1)),this.#a=(t(this,z),t(this,H,null)),this.#o=(t(this,U),t(this,G,null)),this._fixedMonth=(t(this,K),null),this._activeMonth=null,this.#s=t(this,X,`horizontal`),this.#c=(t(this,Z),t(this,xe,!1)),this._dateAdapter=(t(this,Q),y().datetime?.dateAdapter??p),this.#l=t(this,Ce,this._dateAdapter.today()),this.#u=(t(this,we),t(this,Ee,`day`)),this._weekdays=t(this,De),this._weeks=[],this._firstVisibleDay=``,this._lastVisibleDay=``,this._monthNames=this._dateAdapter.getMonthNames(`long`),this._enhancedVariant=!1,this._resetFocus=!1,this._containingFocus=!1,this._lastSelection=null,this.#d=t(this,ke,!1),this._language=(t(this,$),new d(this).withHandler(()=>{this._monthNames=this._dateAdapter.getMonthNames(`long`),this._createMonthRows()})),this._sortDate=(e,t)=>this._dateAdapter.compareDate(e,t),this._onSlotChange=()=>{this._enhancedVariant=Array.from(this.children).some(e=>e.localName===`sbb-calendar-day`),this.toggleState(`enhanced`,this._enhancedVariant),this._setTabIndex()},this._createMonthRows(),this._setWeekdays(),this.addEventListener(`focusin`,()=>this._containingFocus=!0),this.addEventListener(`focusout`,()=>this._containingFocus=!1);let e=e=>e.target.closest(`sbb-calendar-day`)??e.composedPath().find(e=>e.localName===`sbb-calendar-day`)??null,n=e=>e.composedPath().find(e=>e.localName===`sbb-calendar-weekday`)??null,r=e=>e.composedPath().find(e=>e.localName===`sbb-calendar-weeknumber`)??null;this.addEventListener(`click`,t=>{let n=e(t);n&&this._selectDate(n.value,t)}),this.addEventListener(`keydown`,t=>{let i=e(t),a=n(t),o=r(t);if(i||a||o){if(t.key===`Tab`){let e=a?`weekdays`:o?`weekNumbers`:`days`,n=this._tabbableGroups.filter(e=>e.value().length>0),r=n.findIndex(t=>t.key===e),i=t.shiftKey?r-1:r+1;if(r===-1||i<0||i>=n.length)return;let s=n[i].value().find(e=>e.tabIndex===0);if(!s)return;t.preventDefault(),s.focus()}_(t)&&(i?this._handleKeyboardEvent(t,i):a?this._handleKeyboardEventWeek(t,a,this._weekdayCells):o&&this._handleKeyboardEventWeek(t,o,this._weekNumberCells))}}),this.addEventListener(`blur`,()=>this._lastSelection=null)}_dateFilter(e){return this.dateFilter?.(e)??!0}_parseMonth(e){if(typeof e==`string`){let t=e?e.match(/^(\d{4})-(\d{2})$/):null;return t?this._dateAdapter.createDate(Number(t[1]),Number(t[2]),1):null}return e instanceof Date?this._dateAdapter.createDate(e.getFullYear(),e.getMonth()+1,1):this._dateAdapter.isDateInstance(e)&&this._dateAdapter.isValid(e)?this._dateAdapter.clone(e):null}_toMonthIsoString(e){return this._dateAdapter.toIso8601(e).split(`-`).slice(0,2).join(`-`)}resetPosition(){this._resetCalendarView()}connectedCallback(){super.connectedCallback(),this.resetPosition(),this.shadowRoot?.addEventListener(`slotchange`,this._onSlotChange,{capture:!0})}disconnectedCallback(){super.disconnectedCallback(),this.shadowRoot?.removeEventListener(`slotchange`,this._onSlotChange,{capture:!0})}visibleDays(){return this._weeks.flat(2).sort((e,t)=>e.value.localeCompare(t.value))}formResetCallback(){}formStateRestoreCallback(e,t){if(t===`autocomplete`||e==null)return;let n=e=>this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));if(typeof e==`string`)this.value=n(e);else if(e instanceof FormData){if(this.multiple){this._readFormData(e).then(e=>this.value=e.map(n).filter(e=>e!=null));return}let t=e.get(this.name);t instanceof Blob?t.text().then(e=>this.value=n(JSON.parse(e))):this.value=n(t)}}async _readFormData(e){return Promise.all(e.getAll(this.name).map(async e=>e instanceof Blob?JSON.parse(await e.text()):e))}focus(){this._resetFocus=!0,this._focusCell()}willUpdate(e){super.willUpdate(e),this._initialized&&((e.has(`amount`)||e.has(`orientation`)||e.has(`fixedMonth`))&&this.resetPosition(),e.has(`view`)&&(this._setChosenYear(),this._chosenMonth=void 0,this._calendarView=this.view))}requestUpdate(e,t,n){super.requestUpdate(e,t,n),e===`_calendarView`?(this.internals.states.delete(`view-${t}`),this.internals.states.add(`view-${this._calendarView}`),this._containingFocus&&(this._resetFocus=!0)):e===`amount`&&this.toggleState(`single-month`,this.amount===1)}updated(e){super.updated(e),this._setTabIndex(),this._focusCell()}firstUpdated(e){super.firstUpdated(e),this._emitMonthChange()}_onMultipleChanged(e){e&&!Array.isArray(this._value)&&(this._value=this._value?[this._value]:[]),!e&&Array.isArray(this._value)&&(this._value=this._value.length?this._value[0]:null)}_createCalendarState(e){if(r)return;if(this.hydrationRequired){this.hydrationComplete.then(()=>this._createCalendarState());return}e&&this._assignActiveDate(e);let t=this._fixedMonth??this._activeDate,n=this.amount<1?1:this.amount;if(this._weeks.length===n&&this._isSameMonth(this._weeks[0][0][0].dateValue,t))return;this._weeks=Array.from({length:n},(e,n)=>this._createWeekRows(this._dateAdapter.addCalendarMonths(t,n)));let i=this._weeks[0][0][0].dateValue;this._firstVisibleDay=this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(i),this._dateAdapter.getMonth(i),1));let a=this._weeks[n-1][0][0].dateValue;this._lastVisibleDay=this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(a),this._dateAdapter.getMonth(a),this._dateAdapter.getNumDaysInMonth(a))),this._years=this._createYearRows(),this._weekNumbers=this._weeks.map(e=>e.flat().sort((e,t)=>e.value.localeCompare(t.value)).map(e=>e.weekValue).filter((e,t,n)=>n.indexOf(e)===t)),this._initialized=!0}_isSameMonth(e,t){return this._dateAdapter.getYear(e)===this._dateAdapter.getYear(t)&&this._dateAdapter.getMonth(e)===this._dateAdapter.getMonth(t)}_focusCell(){this._resetFocus&&=(this._getFirstFocusable()?.focus(),!1)}_setWeekdays(){let e=this._dateAdapter.getDayOfWeekNames(`narrow`),t=this._dateAdapter.getDayOfWeekNames(`long`).map((t,n)=>({long:t,narrow:e[n]})),n=this._dateAdapter.getFirstDayOfWeek();this._weekdays=t.slice(n).concat(t.slice(0,n))}_createWeekRows(e){let t=this._dateAdapter.getNumDaysInMonth(e),n=this._dateAdapter.getFirstWeekOffset(e);return this.orientation===`horizontal`?this._createWeekRowsHorizontal(e,t,n):this._createWeekRowsVertical(e,t,n)}_createWeekRowsHorizontal(e,t,n){let r=[[]];for(let i=0,a=n;i<t;i++,a++){a===7&&(r.push([]),a=0);let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),i+1);r[r.length-1].push(this._mapDateToDay(t))}return r}_createWeekRowsVertical(e,t,n){let r=Array.from({length:7},()=>[]);for(let i=0,a=n;i<t;i++,a++){a===7&&(a=0);let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),i+1);r[a].push(this._mapDateToDay(t))}return r}_mapDateToDay(e){return{value:this._dateAdapter.toIso8601(e),dateValue:e,dayValue:String(this._dateAdapter.getDate(e)),monthValue:String(this._dateAdapter.getMonth(e)),yearValue:String(this._dateAdapter.getYear(e)),weekValue:this._getWeek(e),weekDayValue:this._dateAdapter.getDayOfWeek(e)}}_getWeek(e){let t=this._dateAdapter.createDate(this._dateAdapter.getYear(e),1,1),n=this._dateAdapter.getDayOfWeek(t),r=+!![c,re,ie,ne].includes(n),i=this._dateAdapter.addCalendarDays(t,this._dateAdapter.getFirstWeekOffset(t)*-1);for(;this._dateAdapter.compareDate(i,e)<=0;){let n=this._dateAdapter.addCalendarDays(i,6);if(this._dateAdapter.compareDate(e,n)<=0)return r>0?r:this._getWeek(this._dateAdapter.addCalendarDays(t,-1));i=this._dateAdapter.addCalendarDays(i,7),r++}throw Error(`The provided date is invalid`)}_mapValueToISODate(e){return typeof e==`string`?e:this._dateAdapter.toIso8601(e)}_createMonthRows(){let e=Array(12).fill(null).map((e,t)=>({value:String(t+1).padStart(2,`0`),monthValue:t+1})),t=[];for(let n=0;n<3;n++)t.push(e.slice(4*n,4*(n+1)));this._months=t}_createYearRows(){let e=this._getStartValueYearView(),t=Array(24).fill(0).map((t,n)=>e+n),n=[];for(let e=0;e<6;e++)n.push(t.slice(4*e,4*(e+1)));return n}_getStartValueYearView(){let e=0;this.max?e=this._dateAdapter.getYear(this.max)-24+1:this.min&&(e=this._dateAdapter.getYear(this.min));let t=this._dateAdapter.getYear(this._activeDate);return t-((t-e)%24+24)%24}_isDayInRange(e){if(!this.min&&!this.max)return!0;let t=this._dateAdapter.deserialize(e);return this._dateAdapter.sameDate(t,this._dateAdapter.clampDate(t,this.min,this.max))}_selectDate(e,t){if(this._chosenMonth=void 0,this._setChosenYear(),this.multiple){window.getSelection()?.removeAllRanges();let n=this._value?Array.isArray(this._value)?this._value:[this._value]:[],r=n.map(e=>this._dateAdapter.toIso8601(e));if(t.shiftKey&&this._lastSelection&&r.includes(this._dateAdapter.toIso8601(this._lastSelection))&&!r.includes(this._dateAdapter.toIso8601(e))){let t=this._dateAdapter.compareDate(this._lastSelection,e)<0?1:-1,i=[],a=this._lastSelection;for(;!this._dateAdapter.sameDate(a,e);){a=this._dateAdapter.addCalendarDays(a,t);let e=this._dateAdapter.toIso8601(a);r.includes(e)||i.push(e)}n=this._mergeDates(i,r)}else n=n.some(t=>this._dateAdapter.sameDate(t,e))?n.filter(t=>!this._dateAdapter.sameDate(t,e)):[...n,e].sort(this._sortDate);this._lastSelection=e,this._value=n,this._emitDateSelectedEvent(this._value.map(e=>this._dateAdapter.deserialize(e)))}else(!this._value||this._dateAdapter.compareDate(this._value,e)!==0)&&(this._value=e,this._emitDateSelectedEvent(this._dateAdapter.deserialize(e)))}_selectMultipleDates(e){this._value=this._mergeDates(e.map(e=>e.value)),this._emitDateSelectedEvent(this._value.map(e=>this._dateAdapter.deserialize(e)))}_mergeDates(e,t){t??=this._value.map(e=>this._dateAdapter.toIso8601(e));let n=this._cells.filter(e=>!e.disabled).map(e=>this._mapValueToISODate(e.value)),r=e.filter(e=>n.includes(e));return t=r.every(e=>t.includes(e))?t.filter(e=>!r.includes(e)):[...t,...r].filter((e,t,n)=>n.indexOf(e)===t),t.map(e=>this._dateAdapter.deserialize(e)).sort(this._sortDate)}_emitDateSelectedEvent(e){this.dispatchEvent(new k(e)),this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_emitMonthChange(){let e=this.visibleDays();this.dispatchEvent(new O(e))}_setChosenYear(){if(this.view===`month`){let e;e=this.multiple?this.value.at(-1):this.value,this._chosenYear=this._dateAdapter.getYear(e??this._dateAdapter.today())}else this._chosenYear=void 0}_assignActiveDate(e){this._activeDate=this._dateAdapter.clampDate(e,this.min,this.max)}_goToDifferentMonth(e){this._createCalendarState(this._dateAdapter.addCalendarMonths(this._activeDate,e)),this._emitMonthChange()}_goToDifferentYear(e){this._chosenYear+=e,this._activeDate=this._dateAdapter.createDate(this._chosenYear,this._dateAdapter.getMonth(this._activeDate),1),this._createCalendarState()}_goToDifferentYearRange(e){this._createCalendarState(this._dateAdapter.addCalendarYears(this._activeDate,e))}_prevDisabled(e){return this.min?this._dateAdapter.compareDate(e,this.min)<0:!1}_nextDisabled(e){return this.max?this._dateAdapter.compareDate(e,this.max)>0:!1}_previousMonthDisabled(){let e=this._dateAdapter.addCalendarDays(this._activeDate,this._dateAdapter.getDate(this._activeDate)*-1);return this._prevDisabled(e)}_nextMonthDisabled(){let e=this._dateAdapter.addCalendarMonths(this._activeDate,this.amount<1?1:this.amount);return e=this._dateAdapter.createDate(this._dateAdapter.getYear(e),this._dateAdapter.getMonth(e),1),this._nextDisabled(e)}_previousYearDisabled(){let e=this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate)-1,12,31);return this._prevDisabled(e)}_nextYearDisabled(){let e=this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate)+(this.amount<1?1:this.amount),1,1);return this._nextDisabled(e)}_previousYearRangeDisabled(){let e=this._dateAdapter.createDate(this._years[0][0]-1,12,31);return this._prevDisabled(e)}_nextYearRangeDisabled(){let e=this._years.flat(2).at(-1),t=this._dateAdapter.createDate(e+1,1,1);return this._nextDisabled(t)}_handleTableBlur(e){e?.localName!==`sbb-calendar-day`&&e?.localName!==`sbb-calendar-weeknumber`&&e?.localName!==`sbb-calendar-weekday`&&this._setTabIndex()}_setTabIndex(){Array.from(this._cells.filter(e=>e.tabIndex===0)??[]).forEach(e=>e.tabIndex=-1),this._setWeekFocus();let e=this._getFirstFocusable();e&&(e.tabIndex=0)}_setWeekFocus(){this._weekdayCells.forEach((e,t)=>e.tabIndex=t===0?0:-1),this._weekNumberCells.forEach((e,t)=>e.tabIndex=t===0?0:-1)}_getFirstFocusable(){if(this._calendarView===`day`){let e=this._cells.find(e=>e.matches(`:is(:state(selected),[state--selected])`))??this._cells.find(e=>e.matches(`:is(:state(current),[state--current])`));return e&&!e.disabled?e:this._getFirstFocusableDay()}{let e=this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(selected),[state--selected])`)??this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(current),[state--current])`);return e&&!e.disabled?e:this.shadowRoot.querySelector(`sbb-calendar-${this._calendarView}:not([disabled])`)}}_getFirstFocusableDay(){let e=this._cells,t=e.filter(e=>!e.disabled);if(!t||t.length===0)return null;{let n=t.map(e=>this._dateAdapter.toIso8601(e.value)).sort()[0];return e.find(e=>e.matches(`[slot="${n}"]`))??null}}_handleKeyboardEventWeek(e,t,n){e.preventDefault();let r;switch(e.key){case`ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:r=n[oe(e,n.indexOf(t),n.length)];break;case`PageUp`:case`Home`:r=n[0];break;case`PageDown`:case`End`:r=n[n.length-1];break;default:r=t}r!==t&&(r.tabIndex=0,r.focus(),t.tabIndex=-1)}_handleKeyboardEvent(e,t){_(e)&&e.preventDefault();let n=t??e.target,r=this._cells,i=r.indexOf(n),a;a=t?this._navigateByKeyboardDayView(e,i,r,this._mapDateToDay(t.value)):this._navigateByKeyboard(e,i,r);let o=(this._enhancedVariant?document:this.shadowRoot).activeElement;a!==o&&(a.tabIndex=0,a.focus(),r.includes(o)&&(o.tabIndex=-1))}_navigateByKeyboardDayView(e,t,n,r){let i=this.orientation===`horizontal`?{leftRight:1,upDown:7}:{leftRight:7,upDown:1};switch(e.key){case`ArrowUp`:return this._findDayArrows(n,t,r.dateValue,-i.upDown);case`ArrowDown`:return this._findDayArrows(n,t,r.dateValue,i.upDown);case`ArrowLeft`:return this._findDayArrows(n,t,r.dateValue,-i.leftRight);case`ArrowRight`:return this._findDayArrows(n,t,r.dateValue,i.leftRight);case`PageUp`:if(this.orientation===`horizontal`){let e=(r.dayValue%7||7)-r.dayValue;return this._findDayPageUpDown(n,t,r,e,i.upDown)}{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue),a=(Math.ceil((+r.dayValue+e)/7)-1)*7-e+1-r.dayValue;return this._findDayPageUpDown(n,t,r,a,i.upDown)}case`PageDown`:if(this.orientation===`horizontal`){let e=+r.monthValue+1>12?1:+r.monthValue+1,a=+r.monthValue+1>12?+r.yearValue+1:+r.yearValue,o=this._dateAdapter.createDate(a,e,1),s=this._dateAdapter.getDate(this._dateAdapter.addCalendarDays(o,-1)),c=Math.trunc((s-+r.dayValue)/7)*7;return this._findDayPageUpDown(n,t,r,c,-i.upDown)}{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue),a=Math.ceil((+r.dayValue+e)/7)*7-e-r.dayValue;return this._findDayPageUpDown(n,t,r,a,-i.upDown)}case`Home`:return this._findDayFirst(n,t,r,1);case`End`:{let e=+r.monthValue+1>12?1:+r.monthValue+1,i=+r.monthValue+1>12?+r.yearValue+1:+r.yearValue,a=this._dateAdapter.createDate(i,e,1);return this._findDayLast(n,t,a)}default:return n[t]}}_isDayOutOfView(e){return e<this._firstVisibleDay||e>this._lastVisibleDay}_findDayArrows(e,t,n,r){let i=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n,r));if(this._isDayOutOfView(i))return e[t];let a=e.find(e=>this._mapValueToISODate(e.value)===i);return!a||a.disabled?this._findDayArrows(e,t,this._dateAdapter.deserialize(i),r):a}_findDayPageUpDown(e,t,n,r,i){let a=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n.dateValue,r));if(this._isDayOutOfView(a))return e[t];let o=e.find(e=>this._mapValueToISODate(e.value)===a);return!o||o.disabled?this._findDayPageUpDown(e,t,n,r+i,i):o}_findDayFirst(e,t,n,r){let i=this._dateAdapter.toIso8601(this._dateAdapter.createDate(+n.yearValue,+n.monthValue,r));if(this._isDayOutOfView(i))return e[t];let a=e.find(e=>this._mapValueToISODate(e.value)===i);return!a||a.disabled?this._findDayFirst(e,t,n,r+1):a}_findDayLast(e,t,n){let r=this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n,-1));if(this._isDayOutOfView(r))return e[t];let i=e.find(e=>this._mapValueToISODate(e.value)===r);return!i||i.disabled?this._findDayLast(e,t,this._dateAdapter.deserialize(r)):i}_navigateByKeyboard(e,t,n){let{elementIndexForWideMode:r,offsetForWideMode:i,lastElementIndexForWideMode:a,verticalOffset:o}=this._calculateParametersForKeyboardNavigation(t,this._calendarView===`year`);switch(e.key){case`ArrowUp`:return this._findNext(n,t,-o);case`ArrowDown`:return this._findNext(n,t,o);case`ArrowLeft`:return this._findNext(n,t,-1);case`ArrowRight`:return this._findNext(n,t,1);case`Home`:return this._findFirst(n,i);case`PageUp`:return this._findFirstOnColumn(n,r,i,o);case`PageDown`:return this._findLastOnColumn(n,t,a,o);case`End`:return this._findLast(n,a-1);default:return n[t]}}_calculateParametersForKeyboardNavigation(e,t){let n=t?24:12,r=Math.trunc(e/n)*n,i=r===0?e:e-n;return{verticalOffset:4,elementIndexForWideMode:i,offsetForWideMode:e-i,lastElementIndexForWideMode:r===0?n:n*2}}_findNext(e,t,n){let r=t+n;for(;r<e.length&&e[r]?.disabled;)r+=n;return e[r]??e[t]}_findFirst(e,t){return e[t].disabled?this._findNext(e,t,1):e[t]}_findLast(e,t){return e[t].disabled?this._findNext(e,t,-1):e[t]}_findFirstOnColumn(e,t,n,r){let i=t%r+n;return e[i].disabled?this._findNext(e,i,r):e[i]}_findLastOnColumn(e,t,n,r){let i=t+Math.trunc((n-t-1)/r)*r;return e[i].disabled?this._findNext(e,i,-r):e[i]}_resetCalendarViewAndEmitMonthChange(){this._resetCalendarView(),this._emitMonthChange()}_resetCalendarView(){this._containingFocus&&(this._resetFocus=!0),this._activeDate=this._activeMonth??(this.multiple?this._value.at(-1):this._value)??this._dateAdapter.today(),this._setChosenYear(),this._chosenMonth=void 0,this._createCalendarState(),this._calendarView=this.view}_createDayTable(e,t,r){let a=e[0][0].dateValue,o=`${this._monthNames[this._dateAdapter.getMonth(a)-1]} ${this._dateAdapter.getYear(a)}`,s=e.flat(),c=e.flat();return n`
|
|
10
10
|
<div class="sbb-calendar__table-wrapper sbb-calendar__day-view">
|
|
11
11
|
<div class="sbb-calendar__table-header">
|
|
12
12
|
<span>${o}</span> ${r?this._createDayTableControls(o):i}
|
|
@@ -131,7 +131,7 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
|
|
|
131
131
|
</tbody>
|
|
132
132
|
</table>
|
|
133
133
|
</div>
|
|
134
|
-
`}_createDayTableControls(e){return this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentMonth(-1),
|
|
134
|
+
`}_createDayTableControls(e){return this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentMonth(-1),de[this._language.current],this._previousMonthDisabled()),this._getArrow(`right`,()=>this._goToDifferentMonth(1),ce[this._language.current],this._nextMonthDisabled()),this._getArrow(`up`,()=>{this._resetFocus=!0,this._calendarView=`year`},`${me[this._language.current]} ${e}`)]}_createDayCells(e){return e.map(e=>n`
|
|
135
135
|
<td class="sbb-calendar__table-data sbb-calendar__day-cell">
|
|
136
136
|
<slot name=${e.value}>
|
|
137
137
|
<sbb-calendar-day slot=${e.value}></sbb-calendar-day>
|
|
@@ -141,7 +141,7 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
|
|
|
141
141
|
<div class="sbb-calendar__table-wrapper sbb-calendar__month-view">
|
|
142
142
|
<div class="sbb-calendar__table-header">
|
|
143
143
|
<span>${this._chosenYear}</span>
|
|
144
|
-
${this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentYear(-1),
|
|
144
|
+
${this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentYear(-1),fe[this._language.current],this._previousYearDisabled()),this._getArrow(`right`,()=>this._goToDifferentYear(1),le[this._language.current],this._nextYearDisabled()),this._getArrow(`down`,()=>this._resetCalendarViewAndEmitMonthChange(),h[this._language.current])]}
|
|
145
145
|
<span class="sbb-screen-reader-only" role="status">${this._chosenYear}</span>
|
|
146
146
|
</div>
|
|
147
147
|
<table class="sbb-calendar__table">
|
|
@@ -167,7 +167,7 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
|
|
|
167
167
|
<div class="sbb-calendar__table-wrapper sbb-calendar__year-view">
|
|
168
168
|
<div class="sbb-calendar__table-header">
|
|
169
169
|
<span>${r}</span>
|
|
170
|
-
${this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentYearRange(-24),
|
|
170
|
+
${this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentYearRange(-24),pe(24)[this._language.current],this._previousYearRangeDisabled()),this._getArrow(`right`,()=>this._goToDifferentYearRange(24),ue(24)[this._language.current],this._nextYearRangeDisabled()),this._getArrow(`down`,()=>this._resetCalendarViewAndEmitMonthChange(),h[this._language.current])]}
|
|
171
171
|
<span class="sbb-screen-reader-only" role="status">${r}</span>
|
|
172
172
|
</div>
|
|
173
173
|
<table class="sbb-calendar__table">
|
|
@@ -197,4 +197,4 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
|
|
|
197
197
|
></sbb-secondary-button>`}_getView(){switch(this._calendarView){case`year`:return this._renderYearView();case`month`:return this._renderMonthView();default:return i}}render(){return r||this.hydrationRequired?n`${i}`:n`<div class="sbb-calendar__wrapper">
|
|
198
198
|
${this.orientation===`horizontal`?this._weeks.map((e,t)=>this._createDayTable(e,this._weekNumbers[t],t===0)):this._weeks.map((e,t)=>this._createDayTableVertical(e,this._weekNumbers[t],t===0))}
|
|
199
199
|
${this._getView()}
|
|
200
|
-
</div>`}}})();export{
|
|
200
|
+
</div>`}}})();export{x as SbbCalendarCellBaseElement,C as SbbCalendarDayElement,A as SbbCalendarElement,w as SbbCalendarMonthElement,E as SbbCalendarWeekdayElement,D as SbbCalendarWeeknumberElement,T as SbbCalendarYearElement,k as SbbDateSelectedEvent,O as SbbMonthChangeEvent};
|
package/custom-elements.json
CHANGED
|
@@ -75684,6 +75684,26 @@
|
|
|
75684
75684
|
"description": "A list of calendar's cells corresponding to days, months or years depending on the view.",
|
|
75685
75685
|
"readonly": true
|
|
75686
75686
|
},
|
|
75687
|
+
{
|
|
75688
|
+
"kind": "field",
|
|
75689
|
+
"name": "_weekdayCells",
|
|
75690
|
+
"type": {
|
|
75691
|
+
"text": "SbbCalendarWeekdayElement[]"
|
|
75692
|
+
},
|
|
75693
|
+
"privacy": "private",
|
|
75694
|
+
"description": "A list of calendar's weekday cells.",
|
|
75695
|
+
"readonly": true
|
|
75696
|
+
},
|
|
75697
|
+
{
|
|
75698
|
+
"kind": "field",
|
|
75699
|
+
"name": "_weekNumberCells",
|
|
75700
|
+
"type": {
|
|
75701
|
+
"text": "SbbCalendarWeeknumberElement[]"
|
|
75702
|
+
},
|
|
75703
|
+
"privacy": "private",
|
|
75704
|
+
"description": "A list of calendar's weeknumber cells.",
|
|
75705
|
+
"readonly": true
|
|
75706
|
+
},
|
|
75687
75707
|
{
|
|
75688
75708
|
"kind": "field",
|
|
75689
75709
|
"name": "_chosenYear",
|
|
@@ -75745,6 +75765,15 @@
|
|
|
75745
75765
|
"name": "_language",
|
|
75746
75766
|
"privacy": "private"
|
|
75747
75767
|
},
|
|
75768
|
+
{
|
|
75769
|
+
"kind": "field",
|
|
75770
|
+
"name": "_tabbableGroups",
|
|
75771
|
+
"type": {
|
|
75772
|
+
"text": "{ key: string; value: () => SbbCalendarTabbableCell[] }[]"
|
|
75773
|
+
},
|
|
75774
|
+
"privacy": "private",
|
|
75775
|
+
"readonly": true
|
|
75776
|
+
},
|
|
75748
75777
|
{
|
|
75749
75778
|
"kind": "field",
|
|
75750
75779
|
"name": "_sortDate",
|
|
@@ -76434,6 +76463,16 @@
|
|
|
76434
76463
|
}
|
|
76435
76464
|
}
|
|
76436
76465
|
},
|
|
76466
|
+
{
|
|
76467
|
+
"kind": "method",
|
|
76468
|
+
"name": "_setWeekFocus",
|
|
76469
|
+
"privacy": "private",
|
|
76470
|
+
"return": {
|
|
76471
|
+
"type": {
|
|
76472
|
+
"text": "void"
|
|
76473
|
+
}
|
|
76474
|
+
}
|
|
76475
|
+
},
|
|
76437
76476
|
{
|
|
76438
76477
|
"kind": "method",
|
|
76439
76478
|
"name": "_getFirstFocusable",
|
|
@@ -76456,6 +76495,36 @@
|
|
|
76456
76495
|
},
|
|
76457
76496
|
"description": "In `day` view in `vertical` orientation,\nif the first of the month is not a Monday, it is not the first rendered element in the table,\nso `this.shadowRoot!.querySelector('sbb-calendar-day:not([disabled])')` will return a wrong value.\n\nTo solve this, the element with the lowest `value` is taken (ISO String are ordered)."
|
|
76458
76497
|
},
|
|
76498
|
+
{
|
|
76499
|
+
"kind": "method",
|
|
76500
|
+
"name": "_handleKeyboardEventWeek",
|
|
76501
|
+
"privacy": "private",
|
|
76502
|
+
"return": {
|
|
76503
|
+
"type": {
|
|
76504
|
+
"text": "void"
|
|
76505
|
+
}
|
|
76506
|
+
},
|
|
76507
|
+
"parameters": [
|
|
76508
|
+
{
|
|
76509
|
+
"name": "event",
|
|
76510
|
+
"type": {
|
|
76511
|
+
"text": "KeyboardEvent"
|
|
76512
|
+
}
|
|
76513
|
+
},
|
|
76514
|
+
{
|
|
76515
|
+
"name": "cell",
|
|
76516
|
+
"type": {
|
|
76517
|
+
"text": "TCell"
|
|
76518
|
+
}
|
|
76519
|
+
},
|
|
76520
|
+
{
|
|
76521
|
+
"name": "cellArray",
|
|
76522
|
+
"type": {
|
|
76523
|
+
"text": "TCell[]"
|
|
76524
|
+
}
|
|
76525
|
+
}
|
|
76526
|
+
]
|
|
76527
|
+
},
|
|
76459
76528
|
{
|
|
76460
76529
|
"kind": "method",
|
|
76461
76530
|
"name": "_handleKeyboardEvent",
|
|
@@ -111,6 +111,10 @@ export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_bas
|
|
|
111
111
|
private _enhancedVariant;
|
|
112
112
|
/** A list of calendar's cells corresponding to days, months or years depending on the view. */
|
|
113
113
|
private get _cells();
|
|
114
|
+
/** A list of calendar's weekday cells. */
|
|
115
|
+
private get _weekdayCells();
|
|
116
|
+
/** A list of calendar's weeknumber cells. */
|
|
117
|
+
private get _weekNumberCells();
|
|
114
118
|
/** The chosen year in the year selection view. */
|
|
115
119
|
private _chosenYear?;
|
|
116
120
|
/** The chosen month in the year selection view. */
|
|
@@ -122,6 +126,7 @@ export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_bas
|
|
|
122
126
|
private _lastSelection;
|
|
123
127
|
private accessor _initialized;
|
|
124
128
|
private _language;
|
|
129
|
+
private get _tabbableGroups();
|
|
125
130
|
constructor();
|
|
126
131
|
private readonly _sortDate;
|
|
127
132
|
private _dateFilter;
|
|
@@ -248,6 +253,7 @@ export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_bas
|
|
|
248
253
|
private _nextYearRangeDisabled;
|
|
249
254
|
private _handleTableBlur;
|
|
250
255
|
private _setTabIndex;
|
|
256
|
+
private _setWeekFocus;
|
|
251
257
|
/** Get the element in the calendar to assign focus. */
|
|
252
258
|
private _getFirstFocusable;
|
|
253
259
|
/**
|
|
@@ -258,6 +264,7 @@ export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_bas
|
|
|
258
264
|
* To solve this, the element with the lowest `value` is taken (ISO String are ordered).
|
|
259
265
|
*/
|
|
260
266
|
private _getFirstFocusableDay;
|
|
267
|
+
private _handleKeyboardEventWeek;
|
|
261
268
|
private _handleKeyboardEvent;
|
|
262
269
|
private _navigateByKeyboardDayView;
|
|
263
270
|
private _isDayOutOfView;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
2
|
import { html, isServer, nothing, unsafeCSS } from "lit";
|
|
3
3
|
import { property, state } from "lit/decorators.js";
|
|
4
|
-
import { MONDAY, SbbButtonLikeBaseElement, SbbDisabledMixin, SbbElement, SbbFormAssociatedMixin, SbbLanguageController, SbbPropertyWatcherController, THURSDAY, TUESDAY, WEDNESDAY, buttonResetStyles, defaultDateAdapter, forceType, handleDistinctChange, i18nCalendarDateSelection, i18nCalendarWeekNumber, i18nNextMonth, i18nNextYear, i18nNextYearRange, i18nPreviousMonth, i18nPreviousYear, i18nPreviousYearRange, i18nYearMonthSelection, isArrowKeyOrPageKeysPressed, plainDate, readConfig, screenReaderOnlyStyles } from "./core.js";
|
|
4
|
+
import { MONDAY, SbbButtonLikeBaseElement, SbbDisabledMixin, SbbElement, SbbFormAssociatedMixin, SbbLanguageController, SbbPropertyWatcherController, THURSDAY, TUESDAY, WEDNESDAY, buttonResetStyles, defaultDateAdapter, forceType, getNextElementIndex, handleDistinctChange, i18nCalendarDateSelection, i18nCalendarWeekNumber, i18nNextMonth, i18nNextYear, i18nNextYearRange, i18nPreviousMonth, i18nPreviousYear, i18nPreviousYearRange, i18nYearMonthSelection, isArrowKeyOrPageKeysPressed, plainDate, readConfig, screenReaderOnlyStyles } from "./core.js";
|
|
5
5
|
import { SbbSecondaryButtonElement } from "./button.pure.js";
|
|
6
6
|
import { SbbIconElement } from "./icon.pure.js";
|
|
7
7
|
|
|
@@ -966,6 +966,14 @@ let SbbCalendarElement = (() => {
|
|
|
966
966
|
get _cells() {
|
|
967
967
|
return Array.from((this._calendarView === "day" ? Array.from(this.shadowRoot.querySelectorAll("slot")).flatMap((e) => e.assignedElements({ flatten: true })) : this.shadowRoot?.querySelectorAll(`sbb-calendar-${this._calendarView}`)) ?? []);
|
|
968
968
|
}
|
|
969
|
+
/** A list of calendar's weekday cells. */
|
|
970
|
+
get _weekdayCells() {
|
|
971
|
+
return Array.from(this.shadowRoot?.querySelectorAll(`sbb-calendar-weekday`) ?? []);
|
|
972
|
+
}
|
|
973
|
+
/** A list of calendar's weeknumber cells. */
|
|
974
|
+
get _weekNumberCells() {
|
|
975
|
+
return Array.from(this.shadowRoot?.querySelectorAll(`sbb-calendar-weeknumber`) ?? []);
|
|
976
|
+
}
|
|
969
977
|
#_initialized_accessor_storage;
|
|
970
978
|
get _initialized() {
|
|
971
979
|
return this.#_initialized_accessor_storage;
|
|
@@ -973,6 +981,29 @@ let SbbCalendarElement = (() => {
|
|
|
973
981
|
set _initialized(value) {
|
|
974
982
|
this.#_initialized_accessor_storage = value;
|
|
975
983
|
}
|
|
984
|
+
get _tabbableGroups() {
|
|
985
|
+
const weekdays = {
|
|
986
|
+
key: "weekdays",
|
|
987
|
+
value: () => this._weekdayCells
|
|
988
|
+
};
|
|
989
|
+
const weekNumbers = {
|
|
990
|
+
key: "weekNumbers",
|
|
991
|
+
value: () => this._weekNumberCells
|
|
992
|
+
};
|
|
993
|
+
const days = {
|
|
994
|
+
key: "days",
|
|
995
|
+
value: () => this._cells
|
|
996
|
+
};
|
|
997
|
+
return this.orientation === "vertical" ? [
|
|
998
|
+
weekNumbers,
|
|
999
|
+
weekdays,
|
|
1000
|
+
days
|
|
1001
|
+
] : [
|
|
1002
|
+
weekdays,
|
|
1003
|
+
weekNumbers,
|
|
1004
|
+
days
|
|
1005
|
+
];
|
|
1006
|
+
}
|
|
976
1007
|
constructor() {
|
|
977
1008
|
super();
|
|
978
1009
|
this.#amount_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _amount_initializers, 1));
|
|
@@ -1021,13 +1052,33 @@ let SbbCalendarElement = (() => {
|
|
|
1021
1052
|
this.addEventListener("focusin", () => this._containingFocus = true);
|
|
1022
1053
|
this.addEventListener("focusout", () => this._containingFocus = false);
|
|
1023
1054
|
const resolveDay = (event) => event.target.closest("sbb-calendar-day") ?? event.composedPath().find((e) => e.localName === "sbb-calendar-day") ?? null;
|
|
1055
|
+
const resolveWeekday = (event) => event.composedPath().find((e) => e.localName === "sbb-calendar-weekday") ?? null;
|
|
1056
|
+
const resolveWeekNumber = (event) => event.composedPath().find((e) => e.localName === "sbb-calendar-weeknumber") ?? null;
|
|
1024
1057
|
this.addEventListener("click", (event) => {
|
|
1025
1058
|
const day = resolveDay(event);
|
|
1026
1059
|
if (day) this._selectDate(day.value, event);
|
|
1027
1060
|
});
|
|
1028
1061
|
this.addEventListener("keydown", (event) => {
|
|
1029
1062
|
const day = resolveDay(event);
|
|
1030
|
-
|
|
1063
|
+
const weekday = resolveWeekday(event);
|
|
1064
|
+
const weekNumber = resolveWeekNumber(event);
|
|
1065
|
+
if (!(day || weekday || weekNumber)) return;
|
|
1066
|
+
if (event.key === "Tab") {
|
|
1067
|
+
const currentKey = weekday ? "weekdays" : weekNumber ? "weekNumbers" : "days";
|
|
1068
|
+
const availableGroups = this._tabbableGroups.filter((tg) => tg.value().length > 0);
|
|
1069
|
+
const groupId = availableGroups.findIndex((tg) => tg.key === currentKey);
|
|
1070
|
+
const nextIdx = event.shiftKey ? groupId - 1 : groupId + 1;
|
|
1071
|
+
if (groupId === -1 || nextIdx < 0 || nextIdx >= availableGroups.length) return;
|
|
1072
|
+
const next = availableGroups[nextIdx].value().find((e) => e.tabIndex === 0);
|
|
1073
|
+
if (!next) return;
|
|
1074
|
+
event.preventDefault();
|
|
1075
|
+
next.focus();
|
|
1076
|
+
}
|
|
1077
|
+
if (isArrowKeyOrPageKeysPressed(event)) {
|
|
1078
|
+
if (day) this._handleKeyboardEvent(event, day);
|
|
1079
|
+
else if (weekday) this._handleKeyboardEventWeek(event, weekday, this._weekdayCells);
|
|
1080
|
+
else if (weekNumber) this._handleKeyboardEventWeek(event, weekNumber, this._weekNumberCells);
|
|
1081
|
+
}
|
|
1031
1082
|
});
|
|
1032
1083
|
this.addEventListener("blur", () => this._lastSelection = null);
|
|
1033
1084
|
}
|
|
@@ -1428,13 +1479,18 @@ let SbbCalendarElement = (() => {
|
|
|
1428
1479
|
return this._nextDisabled(nextYear);
|
|
1429
1480
|
}
|
|
1430
1481
|
_handleTableBlur(eventTarget) {
|
|
1431
|
-
if (eventTarget?.localName !== "sbb-calendar-day") this._setTabIndex();
|
|
1482
|
+
if (eventTarget?.localName !== "sbb-calendar-day" && eventTarget?.localName !== "sbb-calendar-weeknumber" && eventTarget?.localName !== "sbb-calendar-weekday") this._setTabIndex();
|
|
1432
1483
|
}
|
|
1433
1484
|
_setTabIndex() {
|
|
1434
1485
|
Array.from(this._cells.filter((e) => e.tabIndex === 0) ?? []).forEach((day) => day.tabIndex = -1);
|
|
1486
|
+
this._setWeekFocus();
|
|
1435
1487
|
const firstFocusable = this._getFirstFocusable();
|
|
1436
1488
|
if (firstFocusable) firstFocusable.tabIndex = 0;
|
|
1437
1489
|
}
|
|
1490
|
+
_setWeekFocus() {
|
|
1491
|
+
this._weekdayCells.forEach((e, i) => e.tabIndex = i === 0 ? 0 : -1);
|
|
1492
|
+
this._weekNumberCells.forEach((e, i) => e.tabIndex = i === 0 ? 0 : -1);
|
|
1493
|
+
}
|
|
1438
1494
|
/** Get the element in the calendar to assign focus. */
|
|
1439
1495
|
_getFirstFocusable() {
|
|
1440
1496
|
if (this._calendarView === "day") {
|
|
@@ -1461,6 +1517,32 @@ let SbbCalendarElement = (() => {
|
|
|
1461
1517
|
return cells.find((e) => e.matches(`[slot="${firstElement}"]`)) ?? null;
|
|
1462
1518
|
}
|
|
1463
1519
|
}
|
|
1520
|
+
_handleKeyboardEventWeek(event, cell, cellArray) {
|
|
1521
|
+
event.preventDefault();
|
|
1522
|
+
let nextEl;
|
|
1523
|
+
switch (event.key) {
|
|
1524
|
+
case "ArrowUp":
|
|
1525
|
+
case "ArrowDown":
|
|
1526
|
+
case "ArrowLeft":
|
|
1527
|
+
case "ArrowRight":
|
|
1528
|
+
nextEl = cellArray[getNextElementIndex(event, cellArray.indexOf(cell), cellArray.length)];
|
|
1529
|
+
break;
|
|
1530
|
+
case "PageUp":
|
|
1531
|
+
case "Home":
|
|
1532
|
+
nextEl = cellArray[0];
|
|
1533
|
+
break;
|
|
1534
|
+
case "PageDown":
|
|
1535
|
+
case "End":
|
|
1536
|
+
nextEl = cellArray[cellArray.length - 1];
|
|
1537
|
+
break;
|
|
1538
|
+
default: nextEl = cell;
|
|
1539
|
+
}
|
|
1540
|
+
if (nextEl !== cell) {
|
|
1541
|
+
nextEl.tabIndex = 0;
|
|
1542
|
+
nextEl.focus();
|
|
1543
|
+
cell.tabIndex = -1;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1464
1546
|
_handleKeyboardEvent(event, day) {
|
|
1465
1547
|
if (isArrowKeyOrPageKeysPressed(event)) event.preventDefault();
|
|
1466
1548
|
const origin = day ?? event.target;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sbb-esta/lyne-elements-dev",
|
|
3
|
-
"version": "5.9.0-dev.
|
|
3
|
+
"version": "5.9.0-dev.1790159051",
|
|
4
4
|
"description": "Lyne Design System",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design system",
|
|
7
7
|
"web components",
|
|
8
8
|
"lit",
|
|
9
|
-
"https://github.com/sbb-design-systems/lyne-components/commit/
|
|
9
|
+
"https://github.com/sbb-design-systems/lyne-components/commit/ab70bdf2f848db77286f1b142c2c9a3486568a6d"
|
|
10
10
|
],
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|