@sbb-esta/lyne-elements-dev 5.14.0-dev.1795700814 → 5.14.0-dev.1795700861
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.js +1 -1
- package/calendar.pure.js +98 -128
- package/core.js +13 -13
- package/custom-elements.json +1821 -398
- package/development/calendar/calendar/calendar.component.d.ts +55 -21
- package/development/calendar/calendar-select-all/calendar-select-all.component.d.ts +18 -0
- package/development/calendar/calendar-weeknumber/calendar-weeknumber.component.d.ts +0 -1
- package/development/calendar/common/calendar-cell-base-element.d.ts +2 -2
- package/development/calendar.js +2 -1
- package/development/calendar.pure.d.ts +1 -0
- package/development/calendar.pure.js +304 -354
- package/development/core/datetime/date-adapter.d.ts +10 -0
- package/development/core/datetime/temporal-date-adapter.d.ts +5 -0
- package/development/core/i18n/i18n.d.ts +7 -0
- package/development/core.js +91 -1
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/package.json +2 -2
package/calendar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SbbCalendarDayElement as e,SbbCalendarElement as t,SbbCalendarMonthElement as n,
|
|
1
|
+
import{SbbCalendarDayElement as e,SbbCalendarElement as t,SbbCalendarMonthElement as n,SbbCalendarSelectAllElement as r,SbbCalendarWeekdayElement as i,SbbCalendarWeeknumberElement as a,SbbCalendarYearElement as o}from"./calendar.pure.js";export*from"./calendar.pure.js";t.define(),e.define(),n.define(),o.define(),i.define(),a.define(),r.define();
|
package/calendar.pure.js
CHANGED
|
@@ -1,147 +1,114 @@
|
|
|
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{
|
|
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{SbbButtonLikeBaseElement as c,SbbDisabledMixin as l,SbbElement as ee,SbbFormAssociatedMixin as te,SbbLanguageController as ne,SbbPropertyWatcherController as u,defaultDateAdapter as d,forceType as f,getNextElementIndex as re,handleDistinctChange as ie,i18nCalendarDateSelection as p,i18nCalendarDeselectAll as ae,i18nCalendarDeselectWeek as oe,i18nCalendarDeselectWeekday as se,i18nCalendarHeaderNavigationHint as ce,i18nCalendarSelectAll as le,i18nCalendarSelectWeek as ue,i18nCalendarSelectWeekday as de,i18nCalendarWeekNumber as fe,i18nNextMonth as pe,i18nNextYear as me,i18nNextYearRange as he,i18nPreviousMonth as ge,i18nPreviousYear as _e,i18nPreviousYearRange as ve,i18nYearMonthSelection as ye,isArrowKeyOrPageKeysPressed as m,plainDate as h,readConfig as g,screenReaderOnlyStyles as be}from"./core.js";import{ref as _}from"lit/directives/ref.js";import{SbbSecondaryButtonElement as xe}from"./button.pure.js";import{SbbIconElement as Se,SbbIconNameMixin as v}from"./icon.pure.js";var y=`: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-select-all)){--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,sbb-calendar-select-all)){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:var(--sbb-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
|
+
`,b=class extends l(c){static{this.styles=[a(y)]}constructor(){super(),this.dateAdapter=g().datetime?.dateAdapter??d,this.addController(new u(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){}},x=`.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 S=(()=>{let r=b,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(x)]}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
|
-
`,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(e){this._resetFocus=!0,this._focusCell(e)}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(e){this._resetFocus&&=(this._getFirstFocusable()?.focus(e),!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`
|
|
8
|
+
</span>`}}})(),C=(()=>{let r=b,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]}`}}})(),w=(()=>{let r=b,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}`}}})(),T=(()=>{let r=b,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)}get value(){return this._value}setSelectedState(){}setDisabledFilteredState(){}renderTemplate(){return n`${this.value?.narrow}`}}})(),E=(()=>{let r=b,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-weeknumber`}set value(e){e&&(this._value=String(e))}get value(){return this._value}setSelectedState(){}setDisabledFilteredState(){}renderTemplate(){return n`${this.value}`}}})();var D=class extends v(b){static{this.elementName=`sbb-calendar-select-all`}renderTemplate(){return this.renderIconSlot()}},Ce=`: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
|
+
`;const O=`sbb-calendar-weekday-hint`,k=`sbb-calendar-week-number-hint`;var A=class extends Event{get range(){return this._range}constructor(e){super(`monthchange`,{bubbles:!0,composed:!0}),this._range=Object.freeze(e||[])}},j=class extends Event{get dateSelected(){return this._dateSelected}constructor(e){super(`dateselected`,{bubbles:!0,composed:!0}),this._dateSelected=Object.freeze(e)}};let M=(()=>{let c=te(ee),l=[],u,v=[],y=[],b,x=[],M=[],we,N=[],P=[],F,I=[],L=[],R,z=[],B=[],V,H,U=[],W=[],G,K=[],q=[],J,Y,X,Z=[],Te=[],Ee,De=[],Oe=[],Q,ke=[],Ae=[],je,Me=[],Ne=[],Pe,Fe=[],$=[];return class extends c{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(c[Symbol.metadata]??null):void 0;u=[f(),o({type:Number})],b=[o()],we=[h(),o()],F=[h(),o()],R=[f(),ie((e,t)=>e._onMultipleChanged(t)),o({type:Boolean})],V=[o()],H=[s()],G=[o({attribute:`date-filter`})],J=[o({attribute:`fixed-month`})],Y=[o({attribute:`active-month`})],X=[o({reflect:!0})],Ee=[f(),o({attribute:`week-numbers`,type:Boolean})],Q=[s()],je=[s()],Pe=[s()],e(this,null,u,{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},v,y),e(this,null,b,{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},x,M),e(this,null,we,{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},I,L),e(this,null,R,{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},z,B),e(this,null,V,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,l),e(this,null,H,{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},U,W),e(this,null,G,{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},K,q),e(this,null,J,{kind:`setter`,name:`fixedMonth`,static:!1,private:!1,access:{has:e=>`fixedMonth`in e,set:(e,t)=>{e.fixedMonth=t}},metadata:t},null,l),e(this,null,Y,{kind:`setter`,name:`activeMonth`,static:!1,private:!1,access:{has:e=>`activeMonth`in e,set:(e,t)=>{e.activeMonth=t}},metadata:t},null,l),e(this,null,X,{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},Z,Te),e(this,null,Ee,{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},De,Oe),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},ke,Ae),e(this,null,je,{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},Me,Ne),e(this,null,Pe,{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},Fe,$),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-calendar`}static{this.elementDependencies=[S,C,D,T,E,w,Se,xe]}static{this.styles=[be,a(Ce)]}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}#d;get _initialized(){return this.#d}set _initialized(e){this.#d=e}constructor(){super(),this.#e=(t(this,l),t(this,v,1)),this.#t=(t(this,y),t(this,x,`day`)),this.#n=(t(this,M),t(this,N,null)),this.#r=(t(this,P),t(this,I,null)),this.#i=(t(this,L),t(this,z,!1)),this.#a=(t(this,B),t(this,U,null)),this.#o=(t(this,W),t(this,K,null)),this._fixedMonth=(t(this,q),null),this._activeMonth=null,this.#s=t(this,Z,`horizontal`),this.#c=(t(this,Te),t(this,De,!1)),this._dateAdapter=(t(this,Oe),g().datetime?.dateAdapter??d),this.#l=t(this,ke,this._dateAdapter.today()),this.#u=(t(this,Ae),t(this,Me,`day`)),this._weekdays=t(this,Ne),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,Fe,!1),this._language=(t(this,$),new ne(this).withHandler(()=>{this._monthNames=this._dateAdapter.getMonthNames(`long`),this._setWeekdays(),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),this.addEventListener(`click`,e=>{let t=this._resolveHeaderNavigationCell(e);t?.localName===`sbb-calendar-day`&&this._selectDate(t.value,e)}),this.addEventListener(`keydown`,e=>this._handleCellKeydown(e)),this.addEventListener(`blur`,()=>this._lastSelection=null)}_cells(){switch(this._calendarView){case`month`:return this._monthCells();case`year`:return this._yearCells();default:return this._dayCells()}}_yearCells(){return Array.from(this.shadowRoot?.querySelectorAll(`sbb-calendar-year`)??[])}_monthCells(){return Array.from(this.shadowRoot?.querySelectorAll(`sbb-calendar-month`)??[])}_dayCells(e=this.shadowRoot){return Array.from(e.querySelectorAll(`slot`)).flatMap(e=>e.assignedElements({flatten:!0})).filter(e=>e.localName===`sbb-calendar-day`)}_weekdayCells(){return Array.from(this.shadowRoot?.querySelectorAll(`sbb-calendar-weekday`)??[])}_weekNumberCells(){return Array.from(this.shadowRoot?.querySelectorAll(`sbb-calendar-weeknumber`)??[])}_selectAllButtons(){return Array.from(this.shadowRoot?.querySelectorAll(`sbb-calendar-select-all`)??[])}_resolveHeaderNavigationCell(e){return e.composedPath().find(e=>e instanceof HTMLElement&&[`sbb-calendar-day`,`sbb-calendar-weekday`,`sbb-calendar-weeknumber`,`sbb-calendar-select-all`].includes(e.localName))}_handleCellKeydown(e){let t=this._resolveHeaderNavigationCell(e),n=t?.closest(`table`)??t?.assignedSlot?.closest(`table`);if(!t||!n)return;let r=t.localName===`sbb-calendar-day`,i;e.key===`Tab`?r&&e.shiftKey?i=n.querySelector(`sbb-calendar-select-all`)??n.querySelector(`sbb-calendar-weekday`):!r&&!e.shiftKey?i=this._getDayTabStop(n):this.shadowRoot.querySelectorAll(`table [tabindex="0"]`).forEach(e=>e.tabIndex=-1):m(e)&&(r?this._handleKeyboardEvent(e,t):i=this._getNextNavigationHeaderCell(e,t)),i&&(e.preventDefault(),i.focus())}_getDayTabStop(e){let t=this._dayCells(e);return t.find(e=>e.tabIndex===0&&!e.disabled)??this._getFirstFocusableDay(t)}_getNextNavigationHeaderCell(e,t){let n=[`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key)===(this.orientation===`horizontal`),r=[...this._selectAllButtons(),...n?this._weekdayCells():this._weekNumberCells()].sort((e,t)=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),i=r.indexOf(t);if(i!==-1)return e.key===`Home`||e.key===`PageUp`?r[0]:e.key===`End`||e.key===`PageDown`?r.at(-1):r[re(e,i,r.length)]}_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(e){this._resetFocus=!0,this._focusCell(e)}willUpdate(e){super.willUpdate(e),this._initialized&&(e.has(`orientation`)&&(this._weeks=[]),(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(e){this._resetFocus&&=(this._getFirstFocusable()?.focus(e),!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){let t=this._dateAdapter.toIso8601(e),{week:n,year:r}=this._dateAdapter.getIsoWeek(e);return{value:t,dateValue:e,dayValue:String(this._dateAdapter.getDate(e)),monthValue:String(this._dateAdapter.getMonth(e)),yearValue:String(this._dateAdapter.getYear(e)),weekValue:n,weekYearValue:r,weekDayValue:this._dateAdapter.getDayOfWeek(e)}}_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 j(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 A(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`&&e?.localName!==`sbb-calendar-select-all`&&this._setTabIndex()}_setTabIndex(){Array.from(this._cells().filter(e=>e.tabIndex===0)??[]).forEach(e=>e.tabIndex=-1);let e=(e,t)=>e.tabIndex=t===0&&!this.weekNumbers?0:-1;this._weekdayCells().forEach(e),this._weekNumberCells().forEach(e),this._selectAllButtons().forEach((e,t)=>e.tabIndex=t===0?0:-1);let t=this._getFirstFocusable();t&&(t.tabIndex=0)}_getFirstFocusable(){let e=this._cells(),t=e.find(e=>e.matches(`:is(:state(selected),[state--selected])`))??e.find(e=>e.matches(`:is(:state(current),[state--current])`));return t&&!t.disabled?t:this._calendarView===`day`?this._getFirstFocusableDay(e):e.find(e=>!e.disabled)??null}_getFirstFocusableDay(e){return e.filter(e=>!e.disabled).sort((e,t)=>e.slot.localeCompare(t.slot))[0]??null}_handleKeyboardEvent(e,t){m(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),a!==n&&(n.tabIndex=-1,a.tabIndex=0,a.focus())}_navigateByKeyboardDayView(e,t,n,r){let i=this.orientation===`horizontal`?{leftRight:1,upDown:7}:{leftRight:7,upDown:1},a=n[t],o=(e,t)=>this._findEnabledDay(n,this._dateAdapter.addCalendarDays(r.dateValue,e),t,a);switch(e.key){case`ArrowUp`:return o(-i.upDown,-i.upDown);case`ArrowDown`:return o(i.upDown,i.upDown);case`ArrowLeft`:return o(-i.leftRight,-i.leftRight);case`ArrowRight`:return o(i.leftRight,i.leftRight);case`PageUp`:if(this.orientation===`horizontal`)return o((r.dayValue%7||7)-r.dayValue,i.upDown);{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue);return o((Math.ceil((+r.dayValue+e)/7)-1)*7-e+1-r.dayValue,i.upDown)}case`PageDown`:if(this.orientation===`horizontal`){let e=this._dateAdapter.getNumDaysInMonth(r.dateValue);return o(Math.trunc((e-+r.dayValue)/7)*7,-i.upDown)}{let e=this._dateAdapter.getFirstWeekOffset(r.dateValue);return o(Math.ceil((+r.dayValue+e)/7)*7-e-r.dayValue,-i.upDown)}case`Home`:return o(1-r.dayValue,1);case`End`:return o(this._dateAdapter.getNumDaysInMonth(r.dateValue)-+r.dayValue,-1);default:return a}}_isDayOutOfView(e){return e<this._firstVisibleDay||e>this._lastVisibleDay}_findEnabledDay(e,t,n,r){for(let i=t;;i=this._dateAdapter.addCalendarDays(i,n)){let t=this._dateAdapter.toIso8601(i);if(this._isDayOutOfView(t))return r;let n=e.find(e=>e.slot===t);if(n&&!n.disabled)return n}}_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();return n`
|
|
10
10
|
<div class="sbb-calendar__table-wrapper sbb-calendar__day-view">
|
|
11
11
|
<div class="sbb-calendar__table-header">
|
|
12
|
-
<span>${o}</span>
|
|
12
|
+
<span>${o}</span>
|
|
13
|
+
${r?this._createDayTableControls(o):i}
|
|
13
14
|
</div>
|
|
14
15
|
<table
|
|
15
16
|
class="sbb-calendar__table"
|
|
16
17
|
@focusout=${e=>this._handleTableBlur(e.relatedTarget)}
|
|
17
18
|
>
|
|
18
|
-
|
|
19
|
-
<tr>
|
|
20
|
-
${this.weekNumbers?n`<th class="sbb-calendar__table-header-cell"></th>`:i}
|
|
21
|
-
${this._weekdays.map((e,t)=>n`
|
|
22
|
-
<th class="sbb-calendar__table-header-cell">
|
|
23
|
-
${this.multiple?n`
|
|
24
|
-
<sbb-calendar-weekday
|
|
25
|
-
.value=${e}
|
|
26
|
-
@click=${()=>{let e=c.filter(e=>e.weekDayValue===(t+1)%7);this._selectMultipleDates(e)}}
|
|
27
|
-
></sbb-calendar-weekday>
|
|
28
|
-
`:n`
|
|
29
|
-
<span class="sbb-screen-reader-only">${e.long}</span>
|
|
30
|
-
<span aria-hidden="true">${e.narrow}</span>
|
|
31
|
-
`}
|
|
32
|
-
</th>
|
|
33
|
-
`)}
|
|
34
|
-
</tr>
|
|
35
|
-
</thead>
|
|
36
|
-
<tbody>
|
|
37
|
-
${e.map((e,r)=>{let a=7-e.length;return r===0&&a?n`
|
|
38
|
-
<tr>
|
|
39
|
-
${this.weekNumbers?n`
|
|
40
|
-
<td class="sbb-calendar__table-header-cell-vertical">
|
|
41
|
-
${this.multiple?n`
|
|
42
|
-
<sbb-calendar-weeknumber
|
|
43
|
-
.value=${t[0]}
|
|
44
|
-
@click=${()=>{let e=s.filter(e=>e.weekValue===t[0]);this._selectMultipleDates(e)}}
|
|
45
|
-
></sbb-calendar-weeknumber>
|
|
46
|
-
`:n`
|
|
47
|
-
<span class="sbb-screen-reader-only"
|
|
48
|
-
>${`${g[this._language.current]} ${t[0]}`}</span
|
|
49
|
-
>
|
|
50
|
-
<span aria-hidden="true">${t[0]}</span>
|
|
51
|
-
`}
|
|
52
|
-
</td>
|
|
53
|
-
`:i}
|
|
54
|
-
${[...Array(a).keys()].map(()=>n`<td class="sbb-calendar__table-data"></td>`)}
|
|
55
|
-
${this._createDayCells(e)}
|
|
56
|
-
</tr>
|
|
57
|
-
`:n`
|
|
58
|
-
<tr>
|
|
59
|
-
${this.weekNumbers?n`
|
|
60
|
-
<td class="sbb-calendar__table-header-cell-vertical">
|
|
61
|
-
${this.multiple?n`
|
|
62
|
-
<sbb-calendar-weeknumber
|
|
63
|
-
.value=${t[r]}
|
|
64
|
-
@click=${()=>{let e=s.filter(e=>e.weekValue===t[r]);this._selectMultipleDates(e)}}
|
|
65
|
-
></sbb-calendar-weeknumber>
|
|
66
|
-
`:n`
|
|
67
|
-
<span class="sbb-screen-reader-only"
|
|
68
|
-
>${`${g[this._language.current]} ${t[r]}`}</span
|
|
69
|
-
>
|
|
70
|
-
<span aria-hidden="true">${t[r]}</span>
|
|
71
|
-
`}
|
|
72
|
-
</td>
|
|
73
|
-
`:i}
|
|
74
|
-
${this._createDayCells(e)}
|
|
75
|
-
</tr>
|
|
76
|
-
`})}
|
|
77
|
-
</tbody>
|
|
19
|
+
${this.orientation===`horizontal`?this._createDayTableHorizontalContent(e,t,o,s):this._createDayTableVerticalContent(e,t,o,s)}
|
|
78
20
|
</table>
|
|
79
21
|
</div>
|
|
80
|
-
`}
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
`)}
|
|
108
|
-
</tr>
|
|
109
|
-
</thead>
|
|
110
|
-
`:i}
|
|
111
|
-
<tbody>
|
|
112
|
-
${e.map((e,t)=>{let r=this._weekdays[t];return n`
|
|
22
|
+
`}_createDayTableHorizontalContent(e,t,r,a){return n`
|
|
23
|
+
<thead>
|
|
24
|
+
<tr>
|
|
25
|
+
${this.weekNumbers?n`<th class="sbb-calendar__table-header-cell">
|
|
26
|
+
${this._selectAllButton(r,a)}
|
|
27
|
+
</th>`:i}
|
|
28
|
+
${this._weekdays.map((e,t)=>n`
|
|
29
|
+
<th class="sbb-calendar__table-header-cell">
|
|
30
|
+
${this._weekdayCell(e,r,a.filter(e=>e.weekDayValue===(t+1)%7))}
|
|
31
|
+
</th>
|
|
32
|
+
`)}
|
|
33
|
+
</tr>
|
|
34
|
+
</thead>
|
|
35
|
+
<tbody>
|
|
36
|
+
${e.map((e,r)=>n`
|
|
37
|
+
<tr>
|
|
38
|
+
${this.weekNumbers?n`<td class="sbb-calendar__table-header-cell-vertical">
|
|
39
|
+
${this._weekNumberCell(t[r],a)}
|
|
40
|
+
</td>`:i}
|
|
41
|
+
${r===0?Array.from({length:7-e.length},()=>n`<td class="sbb-calendar__table-data"></td>`):i}
|
|
42
|
+
${this._createDayCells(e)}
|
|
43
|
+
</tr>
|
|
44
|
+
`)}
|
|
45
|
+
</tbody>
|
|
46
|
+
`}_createDayTableVerticalContent(e,t,r,a){let o=this._dateAdapter.getFirstWeekOffset(e[0][0].dateValue);return n`
|
|
47
|
+
${this.weekNumbers?n`
|
|
48
|
+
<thead>
|
|
113
49
|
<tr>
|
|
114
|
-
<
|
|
115
|
-
${this.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
`:n`
|
|
123
|
-
<span class="sbb-screen-reader-only">${r.long}</span>
|
|
124
|
-
<span aria-hidden="true">${r.narrow}</span>
|
|
125
|
-
`}
|
|
126
|
-
</td>
|
|
127
|
-
${t<c?n`<td class="sbb-calendar__table-data"></td>`:i}
|
|
128
|
-
${this._createDayCells(e)}
|
|
50
|
+
<th class="sbb-calendar__table-data">
|
|
51
|
+
${this._selectAllButton(r,a)}
|
|
52
|
+
</th>
|
|
53
|
+
${t.map(e=>n`
|
|
54
|
+
<th class="sbb-calendar__table-header-cell">
|
|
55
|
+
${this._weekNumberCell(e,a)}
|
|
56
|
+
</th>
|
|
57
|
+
`)}
|
|
129
58
|
</tr>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
59
|
+
</thead>
|
|
60
|
+
`:i}
|
|
61
|
+
<tbody>
|
|
62
|
+
${e.map((e,t)=>n`
|
|
63
|
+
<tr>
|
|
64
|
+
<td class="sbb-calendar__table-header-cell-vertical">
|
|
65
|
+
${this._weekdayCell(this._weekdays[t],r,e)}
|
|
66
|
+
</td>
|
|
67
|
+
${t<o?n`<td class="sbb-calendar__table-data"></td>`:i}
|
|
68
|
+
${this._createDayCells(e)}
|
|
69
|
+
</tr>
|
|
70
|
+
`)}
|
|
71
|
+
</tbody>
|
|
72
|
+
`}_createDayTableControls(e){return this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentMonth(-1),ge[this._language.current],this._previousMonthDisabled()),this._getArrow(`right`,()=>this._goToDifferentMonth(1),pe[this._language.current],this._nextMonthDisabled()),this._getArrow(`up`,()=>{this._resetFocus=!0,this._calendarView=`year`},`${ye[this._language.current]} ${e}`)]}_createDayCells(e){return e.map(e=>n`
|
|
135
73
|
<td class="sbb-calendar__table-data sbb-calendar__day-cell">
|
|
136
74
|
<slot name=${e.value}>
|
|
137
75
|
<sbb-calendar-day slot=${e.value}></sbb-calendar-day>
|
|
138
76
|
</slot>
|
|
139
77
|
</td>
|
|
140
|
-
`)}
|
|
78
|
+
`)}_hasUnselectedDays(e){if(!Array.isArray(this._value))return!1;let t=new Set(this._value.map(e=>this._dateAdapter.toIso8601(e)));return e.some(e=>!t.has(e.value)&&this._isDayInRange(e.value)&&this._dateFilter(e.dateValue))}_weekdayCell(e,t,r){if(this.multiple){let i=this._hasUnselectedDays(r)?de(e.long,t):se(e.long,t);return n`
|
|
79
|
+
<sbb-calendar-weekday
|
|
80
|
+
.value=${e}
|
|
81
|
+
aria-describedby=${O}
|
|
82
|
+
${_(e=>this._applyElementInternalsAriaLabel(e,i[this._language.current]))}
|
|
83
|
+
@click=${()=>this._selectMultipleDates(r)}
|
|
84
|
+
></sbb-calendar-weekday>
|
|
85
|
+
`}return n`
|
|
86
|
+
<span class="sbb-screen-reader-only">${e.long}</span>
|
|
87
|
+
<span aria-hidden="true">${e.narrow}</span>
|
|
88
|
+
`}_weekNumberCell(e,t){if(this.multiple){let r=t.filter(t=>t.weekValue===e),i=r[0].weekYearValue,a=this._hasUnselectedDays(r)?ue(e,i):oe(e,i);return n`
|
|
89
|
+
<sbb-calendar-weeknumber
|
|
90
|
+
.value=${e}
|
|
91
|
+
aria-describedby=${k}
|
|
92
|
+
${_(e=>this._applyElementInternalsAriaLabel(e,a[this._language.current]))}
|
|
93
|
+
@click=${()=>this._selectMultipleDates(r)}
|
|
94
|
+
></sbb-calendar-weeknumber>
|
|
95
|
+
`}return n`
|
|
96
|
+
<span class="sbb-screen-reader-only">
|
|
97
|
+
${`${fe[this._language.current]} ${e}`}
|
|
98
|
+
</span>
|
|
99
|
+
<span aria-hidden="true">${e}</span>
|
|
100
|
+
`}_selectAllButton(e,t){if(this.multiple){let r=this.orientation===`horizontal`?`${O} ${k}`:`${k} ${O}`,i=this._hasUnselectedDays(t)?le(e):ae(e);return n`
|
|
101
|
+
<sbb-calendar-select-all
|
|
102
|
+
icon-name="four-squares-small"
|
|
103
|
+
${_(e=>this._applyElementInternalsAriaLabel(e,i[this._language.current]))}
|
|
104
|
+
aria-describedby=${r}
|
|
105
|
+
@click=${()=>this._selectMultipleDates(t)}
|
|
106
|
+
></sbb-calendar-select-all>
|
|
107
|
+
`}return n`${i}`}_renderMonthView(){return n`
|
|
141
108
|
<div class="sbb-calendar__table-wrapper sbb-calendar__month-view">
|
|
142
109
|
<div class="sbb-calendar__table-header">
|
|
143
110
|
<span>${this._chosenYear}</span>
|
|
144
|
-
${this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentYear(-1),
|
|
111
|
+
${this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentYear(-1),_e[this._language.current],this._previousYearDisabled()),this._getArrow(`right`,()=>this._goToDifferentYear(1),me[this._language.current],this._nextYearDisabled()),this._getArrow(`down`,()=>this._resetCalendarViewAndEmitMonthChange(),p[this._language.current])]}
|
|
145
112
|
<span class="sbb-screen-reader-only" role="status">${this._chosenYear}</span>
|
|
146
113
|
</div>
|
|
147
114
|
<table class="sbb-calendar__table">
|
|
@@ -167,12 +134,12 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
|
|
|
167
134
|
<div class="sbb-calendar__table-wrapper sbb-calendar__year-view">
|
|
168
135
|
<div class="sbb-calendar__table-header">
|
|
169
136
|
<span>${r}</span>
|
|
170
|
-
${this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentYearRange(-24),
|
|
137
|
+
${this._fixedMonth?[]:[this._getArrow(`left`,()=>this._goToDifferentYearRange(-24),ve(24)[this._language.current],this._previousYearRangeDisabled()),this._getArrow(`right`,()=>this._goToDifferentYearRange(24),he(24)[this._language.current],this._nextYearRangeDisabled()),this._getArrow(`down`,()=>this._resetCalendarViewAndEmitMonthChange(),p[this._language.current])]}
|
|
171
138
|
<span class="sbb-screen-reader-only" role="status">${r}</span>
|
|
172
139
|
</div>
|
|
173
140
|
<table class="sbb-calendar__table">
|
|
174
141
|
<tbody>
|
|
175
|
-
${this._years.map(e=>n
|
|
142
|
+
${this._years.map(e=>n`<tr>
|
|
176
143
|
${e.map(e=>n`
|
|
177
144
|
<td class="sbb-calendar__table-data">
|
|
178
145
|
<sbb-calendar-year
|
|
@@ -191,10 +158,13 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
|
|
|
191
158
|
class="sbb-calendar__control"
|
|
192
159
|
size="s"
|
|
193
160
|
icon-name="chevron-small-${e}-small"
|
|
194
|
-
|
|
161
|
+
${_(e=>this._applyElementInternalsAriaLabel(e,r))}
|
|
195
162
|
@click=${t}
|
|
196
163
|
?disabled=${i}
|
|
197
|
-
></sbb-secondary-button>`}_getView(){switch(this._calendarView){case`year`:return this._renderYearView();case`month`:return this._renderMonthView();default:return i}}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
164
|
+
></sbb-secondary-button>`}_getView(){switch(this._calendarView){case`year`:return this._renderYearView();case`month`:return this._renderMonthView();default:return i}}_applyElementInternalsAriaLabel(e,t){if(!e)return;let n=e.internals;n&&(n.ariaLabel=t)}_navigationHints(){let e=(e,t)=>n`<span id=${e} class="sbb-screen-reader-only" aria-hidden="true">
|
|
165
|
+
${ce(t,this.orientation)[this._language.current]}
|
|
166
|
+
</span>`;return n`${e(O,`weekdays`)}
|
|
167
|
+
${this.weekNumbers?e(k,`weekNumbers`):i}`}render(){return r||this.hydrationRequired?n`${i}`:n`<div class="sbb-calendar__wrapper">
|
|
168
|
+
${this._weeks.map((e,t)=>this._createDayTable(e,this._weekNumbers[t],t===0))}
|
|
169
|
+
${this._getView()} ${this.multiple?this._navigationHints():i}
|
|
170
|
+
</div>`}}})();export{b as SbbCalendarCellBaseElement,S as SbbCalendarDayElement,M as SbbCalendarElement,C as SbbCalendarMonthElement,D as SbbCalendarSelectAllElement,T as SbbCalendarWeekdayElement,E as SbbCalendarWeeknumberElement,w as SbbCalendarYearElement,j as SbbDateSelectedEvent,A as SbbMonthChangeEvent};
|