@sbb-esta/lyne-elements-dev 5.14.0-dev.1795574509 → 5.14.0-dev.1795649508

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
@@ -6,7 +6,7 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
6
6
  <span class="sbb-calendar-day__extra">
7
7
  <slot @slotchange=${e=>this._handleSlotchange(e)}></slot>
8
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`
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`
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}
package/core.js CHANGED
@@ -1,4 +1,4 @@
1
- import{LitElement as e,defaultConverter as t,html as n,isServer as r,nothing as i,unsafeCSS as a}from"lit";import{__esDecorate as o,__runInitializers as s}from"tslib";import{eventOptions as c,property as l,state as u}from"lit/decorators.js";import{MutationController as d}from"@lit-labs/observers/mutation-controller.js";function f(){return document.documentElement.matches(`:dir(rtl)`)?{prevKey:`ArrowRight`,nextKey:`ArrowLeft`}:{prevKey:`ArrowLeft`,nextKey:`ArrowRight`}}function p(e){return[`ArrowRight`,`ArrowLeft`,`ArrowUp`,`ArrowDown`].includes(e.key)}function m(e){return e.key===`ArrowUp`||e.key===f().prevKey}function h(e){return e.key===`ArrowDown`||e.key===f().nextKey}function g(e){return p(e)||[`PageUp`,`PageDown`,`Home`,`End`].includes(e.key)}function _(e,t,n){return(e+n+t)%t}function v(e){return e-1}function y(e,t,n){let{prevKey:r,nextKey:i}=f();return!e||e.key===i||e.key===`ArrowDown`?t>=n?0:_(t,n,1):e.key===r||e.key===`ArrowUp`?t<0?v(n):_(t,n,-1):t}function b(e){return e.buttons===0||e.detail===0}function x(e){let t=e.touches&&e.touches[0]||e.changedTouches&&e.changedTouches[0];return!!t&&t.identifier===-1&&(t.radiusX==null||t.radiusX===1)&&(t.radiusY==null||t.radiusY===1)}function S(e){return e.composedPath?e.composedPath()[0]:e.target}const C={ignoreKeys:[18,17,224,91,16]},w={passive:!0,capture:!0},T=new class{get mostRecentModality(){return this._mostRecentModality}get mostRecentTarget(){return this._mostRecentTarget}constructor(){this._mostRecentModality=`mouse`,this._mostRecentTarget=null,this._options={...C},this._lastTouchMs=0,this._onKeydown=e=>{this._options?.ignoreKeys?.some(t=>t===e.keyCode)||this._updateState(`keyboard`,e)},this._onMousedown=e=>{Date.now()-this._lastTouchMs<650||this._updateState(b(e)?`keyboard`:`mouse`,e)},this._onTouchstart=e=>{x(e)?this._updateState(`keyboard`,e):(this._lastTouchMs=Date.now(),this._updateState(`touch`,e))},r||(document.addEventListener(`keydown`,this._onKeydown,w),document.addEventListener(`mousedown`,this._onMousedown,w),document.addEventListener(`touchstart`,this._onTouchstart,w))}reset(){this._updateState(`mouse`,null),this._lastTouchMs=0}_updateState(e,t){this._mostRecentModality&&document.documentElement.classList.remove(`sbb-focus-modality-${this._mostRecentModality}`),this._mostRecentModality=e,this._mostRecentTarget=t?S(t):null,document.documentElement.classList.add(`sbb-focus-modality-${this._mostRecentModality}`)}};var ee=class{constructor(e){this._host=e,this._focusinHandler=()=>{this._host.toggleState?.(`has-visible-focus-within`,T.mostRecentModality===`keyboard`)},this._focusoutHandler=()=>{this._host.toggleState?.(`has-visible-focus-within`,!1)},this._host.addController(this)}hostConnected(){this._host.addEventListener(`focusin`,this._focusinHandler),this._host.addEventListener(`focusout`,this._focusoutHandler)}hostDisconnected(){this._host.removeEventListener(`focusin`,this._focusinHandler),this._host.removeEventListener(`focusout`,this._focusoutHandler)}};const te=[`button`,`[href]`,`input`,`select`,`textarea`,`details`,`summary`,`[tabindex]`].map(e=>`${e}:not([disabled],:disabled,[tabindex="-1"],[inert])`).join(`,`);let E;try{E=typeof Intl<`u`&&Intl.v8BreakIterator}catch{E=!1}const D=!r&&/(edge)/i.test(navigator.userAgent),O=!r&&/(msie|trident)/i.test(navigator.userAgent),k=!r&&!!(window.chrome||E)&&typeof CSS<`u`&&!D&&!O,A=!r&&/AppleWebKit/i.test(navigator.userAgent)&&!k&&!D&&!O,j=!r&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(`MSStream`in window),ne=!r&&/(Mac)/i.test(navigator.platform),re=!r&&/(firefox|minefield)/i.test(navigator.userAgent),ie=!r&&/android/i.test(navigator.userAgent)&&!O,ae=!r&&/safari/i.test(navigator.userAgent)&&A,oe=k,se=()=>!!globalThis.next;
1
+ import{LitElement as e,defaultConverter as t,html as n,isServer as r,nothing as i,unsafeCSS as a}from"lit";import{__esDecorate as o,__runInitializers as s}from"tslib";import{eventOptions as c,property as l,state as u}from"lit/decorators.js";import{MutationController as d}from"@lit-labs/observers/mutation-controller.js";function f(){return document.documentElement.matches(`:dir(rtl)`)?{prevKey:`ArrowRight`,nextKey:`ArrowLeft`}:{prevKey:`ArrowLeft`,nextKey:`ArrowRight`}}function p(e){return[`ArrowRight`,`ArrowLeft`,`ArrowUp`,`ArrowDown`].includes(e.key)}function m(e){return e.key===`ArrowUp`||e.key===f().prevKey}function h(e){return e.key===`ArrowDown`||e.key===f().nextKey}function g(e){return p(e)||[`PageUp`,`PageDown`,`Home`,`End`].includes(e.key)}function _(e,t,n){return(e+n+t)%t}function v(e){return e-1}function y(e,t,n){let{prevKey:r,nextKey:i}=f();return!e||e.key===i||e.key===`ArrowDown`?t>=n?0:_(t,n,1):e.key===r||e.key===`ArrowUp`?t<0?v(n):_(t,n,-1):t}function b(e){return e.buttons===0||e.detail===0}function x(e){let t=e.touches&&e.touches[0]||e.changedTouches&&e.changedTouches[0];return!!t&&t.identifier===-1&&(t.radiusX==null||t.radiusX===1)&&(t.radiusY==null||t.radiusY===1)}function S(e){return e.composedPath?e.composedPath()[0]:e.target}const C={ignoreKeys:[18,17,224,91,16]},w={passive:!0,capture:!0},T=new class{get mostRecentModality(){return this._mostRecentModality}get mostRecentTarget(){return this._mostRecentTarget}constructor(){this._mostRecentModality=`mouse`,this._mostRecentTarget=null,this._options={...C},this._lastTouchMs=0,this._onKeydown=e=>{this._options?.ignoreKeys?.some(t=>t===e.keyCode)||this._updateState(`keyboard`,e)},this._onMousedown=e=>{Date.now()-this._lastTouchMs<650||this._updateState(b(e)?`keyboard`:`mouse`,e)},this._onTouchstart=e=>{x(e)?this._updateState(`keyboard`,e):(this._lastTouchMs=Date.now(),this._updateState(`touch`,e))},r||(document.addEventListener(`keydown`,this._onKeydown,w),document.addEventListener(`mousedown`,this._onMousedown,w),document.addEventListener(`touchstart`,this._onTouchstart,w))}reset(){this._updateState(`mouse`,null),this._lastTouchMs=0}forceState(e){this._updateState(e,null)}_updateState(e,t){this._mostRecentModality&&document.documentElement.classList.remove(`sbb-focus-modality-${this._mostRecentModality}`),this._mostRecentModality=e,this._mostRecentTarget=t?S(t):null,document.documentElement.classList.add(`sbb-focus-modality-${this._mostRecentModality}`)}};var ee=class{constructor(e){this._host=e,this._focusinHandler=()=>{this._host.toggleState?.(`has-visible-focus-within`,T.mostRecentModality===`keyboard`)},this._focusoutHandler=()=>{this._host.toggleState?.(`has-visible-focus-within`,!1)},this._host.addController(this)}hostConnected(){this._host.addEventListener(`focusin`,this._focusinHandler),this._host.addEventListener(`focusout`,this._focusoutHandler)}hostDisconnected(){this._host.removeEventListener(`focusin`,this._focusinHandler),this._host.removeEventListener(`focusout`,this._focusoutHandler)}};const te=[`button`,`[href]`,`input`,`select`,`textarea`,`details`,`summary`,`[tabindex]`].map(e=>`${e}:not([disabled],:disabled,[tabindex="-1"],[inert])`).join(`,`);let E;try{E=typeof Intl<`u`&&Intl.v8BreakIterator}catch{E=!1}const D=!r&&/(edge)/i.test(navigator.userAgent),O=!r&&/(msie|trident)/i.test(navigator.userAgent),k=!r&&!!(window.chrome||E)&&typeof CSS<`u`&&!D&&!O,A=!r&&/AppleWebKit/i.test(navigator.userAgent)&&!k&&!D&&!O,j=!r&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(`MSStream`in window),ne=!r&&/(Mac)/i.test(navigator.platform),re=!r&&/(firefox|minefield)/i.test(navigator.userAgent),ie=!r&&/android/i.test(navigator.userAgent)&&!O,ae=!r&&/safari/i.test(navigator.userAgent)&&A,oe=k,se=()=>!!globalThis.next;
2
2
  /**
3
3
  * @license
4
4
  * Copyright Google LLC All Rights Reserved.
@@ -14903,25 +14903,6 @@
14903
14903
  "module": "core/mixins/disabled-mixin.js"
14904
14904
  }
14905
14905
  },
14906
- {
14907
- "kind": "method",
14908
- "name": "focus",
14909
- "privacy": "public",
14910
- "return": {
14911
- "type": {
14912
- "text": "void"
14913
- }
14914
- },
14915
- "parameters": [
14916
- {
14917
- "name": "options",
14918
- "optional": true,
14919
- "type": {
14920
- "text": "FocusOptions"
14921
- }
14922
- }
14923
- ]
14924
- },
14925
14906
  {
14926
14907
  "kind": "method",
14927
14908
  "name": "select",
@@ -77553,6 +77534,15 @@
77553
77534
  "text": "void"
77554
77535
  }
77555
77536
  },
77537
+ "parameters": [
77538
+ {
77539
+ "name": "options",
77540
+ "optional": true,
77541
+ "type": {
77542
+ "text": "FocusOptions"
77543
+ }
77544
+ }
77545
+ ],
77556
77546
  "description": "Focuses on a day cell prioritizing the selected day, the current day, and lastly, the first selectable day."
77557
77547
  },
77558
77548
  {
@@ -102952,29 +102942,6 @@
102952
102942
  "module": "core/mixins/disabled-mixin.js"
102953
102943
  }
102954
102944
  },
102955
- {
102956
- "kind": "method",
102957
- "name": "focus",
102958
- "privacy": "public",
102959
- "return": {
102960
- "type": {
102961
- "text": "void"
102962
- }
102963
- },
102964
- "parameters": [
102965
- {
102966
- "name": "options",
102967
- "optional": true,
102968
- "type": {
102969
- "text": "FocusOptions"
102970
- }
102971
- }
102972
- ],
102973
- "inheritedFrom": {
102974
- "name": "SbbFormAssociatedInputMixin",
102975
- "module": "core/mixins/form-associated-input-mixin.js"
102976
- }
102977
- },
102978
102945
  {
102979
102946
  "kind": "method",
102980
102947
  "name": "select",
@@ -152069,7 +152036,7 @@
152069
152036
  "kind": "field",
152070
152037
  "name": "_rangeInput",
152071
152038
  "type": {
152072
- "text": "HTMLInputElement"
152039
+ "text": "HTMLInputElement | undefined"
152073
152040
  },
152074
152041
  "privacy": "private",
152075
152042
  "description": "Reference to the inner HTMLInputElement with type='range'."
@@ -166059,29 +166026,6 @@
166059
166026
  "module": "core/mixins/disabled-mixin.js"
166060
166027
  }
166061
166028
  },
166062
- {
166063
- "kind": "method",
166064
- "name": "focus",
166065
- "privacy": "public",
166066
- "return": {
166067
- "type": {
166068
- "text": "void"
166069
- }
166070
- },
166071
- "parameters": [
166072
- {
166073
- "name": "options",
166074
- "optional": true,
166075
- "type": {
166076
- "text": "FocusOptions"
166077
- }
166078
- }
166079
- ],
166080
- "inheritedFrom": {
166081
- "name": "SbbFormAssociatedInputMixin",
166082
- "module": "core/mixins/form-associated-input-mixin.js"
166083
- }
166084
- },
166085
166029
  {
166086
166030
  "kind": "method",
166087
166031
  "name": "select",
@@ -146,7 +146,7 @@ export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_bas
146
146
  formStateRestoreCallback(state: FormRestoreState | null, reason: FormRestoreReason): void;
147
147
  private _readFormData;
148
148
  /** @internal */
149
- focus(): void;
149
+ focus(options?: FocusOptions): void;
150
150
  protected willUpdate(changedProperties: PropertyValues<this>): void;
151
151
  requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration): void;
152
152
  protected updated(changedProperties: PropertyValues<this>): void;
@@ -1127,9 +1127,9 @@ let SbbCalendarElement = (() => {
1127
1127
  return Promise.all(formData.getAll(this.name).map(async (entry) => entry instanceof Blob ? JSON.parse(await entry.text()) : entry));
1128
1128
  }
1129
1129
  /** @internal */
1130
- focus() {
1130
+ focus(options) {
1131
1131
  this._resetFocus = true;
1132
- this._focusCell();
1132
+ this._focusCell(options);
1133
1133
  }
1134
1134
  willUpdate(changedProperties) {
1135
1135
  super.willUpdate(changedProperties);
@@ -1191,9 +1191,9 @@ let SbbCalendarElement = (() => {
1191
1191
  return this._dateAdapter.getYear(a) === this._dateAdapter.getYear(b) && this._dateAdapter.getMonth(a) === this._dateAdapter.getMonth(b);
1192
1192
  }
1193
1193
  /** Focuses on a day cell prioritizing the selected day, the current day, and lastly, the first selectable day. */
1194
- _focusCell() {
1194
+ _focusCell(options) {
1195
1195
  if (this._resetFocus) {
1196
- this._getFirstFocusable()?.focus();
1196
+ this._getFirstFocusable()?.focus(options);
1197
1197
  this._resetFocus = false;
1198
1198
  }
1199
1199
  }
@@ -36,6 +36,10 @@ declare class SbbInputModalityDetector {
36
36
  private _lastTouchMs;
37
37
  constructor();
38
38
  reset(): void;
39
+ /**
40
+ * Forces the input modality to the specified value. This is useful for testing scenarios.
41
+ */
42
+ forceState(modality: SbbInputModality): void;
39
43
  /**
40
44
  * Handles keydown events. Must be an arrow function in order to preserve the context when it gets
41
45
  * bound.
@@ -19,7 +19,7 @@ export declare abstract class SbbLinkBaseElement extends SbbActionBaseElement {
19
19
  protected readonly anchorRole: string | null;
20
20
  constructor();
21
21
  /** @internal */
22
- focus(options?: FocusOptions | undefined): void;
22
+ focus(options?: FocusOptions): void;
23
23
  /** @internal */
24
24
  blur(): void;
25
25
  /** @internal */
@@ -216,6 +216,12 @@ var SbbInputModalityDetector = class {
216
216
  this._updateState("mouse", null);
217
217
  this._lastTouchMs = 0;
218
218
  }
219
+ /**
220
+ * Forces the input modality to the specified value. This is useful for testing scenarios.
221
+ */
222
+ forceState(modality) {
223
+ this._updateState(modality, null);
224
+ }
219
225
  _updateState(modality, event) {
220
226
  if (this._mostRecentModality) document.documentElement.classList.remove(`sbb-focus-modality-${this._mostRecentModality}`);
221
227
  this._mostRecentModality = modality;
@@ -5288,6 +5294,7 @@ const SbbFormAssociatedInputMixin = (superClass) => {
5288
5294
  this._updateContenteditable();
5289
5295
  this._assignValue(this.value);
5290
5296
  }
5297
+ /** @internal */
5291
5298
  focus(options) {
5292
5299
  super.focus(options);
5293
5300
  if (this._canSelect()) {
@@ -5535,9 +5542,7 @@ const SbbFormAssociatedRadioButtonMixin = (superClass) => {
5535
5542
  this._tabindexState = SbbFormAssociatedRadioButtonElement._tabindexState;
5536
5543
  this.addEventListener?.("keydown", (e) => this._handleArrowKeyDown(e));
5537
5544
  }
5538
- /**
5539
- * @internal
5540
- */
5545
+ /** @internal */
5541
5546
  focus(options) {
5542
5547
  if (!this.hasAttribute("tabindex")) this.addController(new SbbTemporaryFocusController(this));
5543
5548
  super.focus(options);
@@ -252,6 +252,10 @@ const SbbFileSelectorCommonElementMixin = (superclass) => {
252
252
  get type() {
253
253
  return "file";
254
254
  }
255
+ /** @internal */
256
+ focus(options) {
257
+ this._hiddenInput.focus(options);
258
+ }
255
259
  formResetCallback() {
256
260
  this.files = [];
257
261
  }
@@ -38,6 +38,8 @@ export declare class SbbFlipCardElement extends SbbElement {
38
38
  toggle(): void;
39
39
  private _setCardDetailsHeight;
40
40
  private _accessibilityLabel;
41
+ /** @internal */
42
+ focus(options?: FocusOptions): void;
41
43
  protected render(): TemplateResult;
42
44
  }
43
45
  declare global {
@@ -287,6 +287,10 @@ let SbbFlipCardElement = (() => {
287
287
  await this.hydrationComplete;
288
288
  return !this._flipped ? `${(this.accessibilityLabel ? this.accessibilityLabel : this.summary?.textContent?.trim()) ?? ""}, ${i18nFlipCard[this._language.current]}` : i18nReverseCard[this._language.current];
289
289
  }
290
+ /** @internal */
291
+ focus(options) {
292
+ this.shadowRoot?.querySelector(".sbb-flip-card-button")?.focus(options);
293
+ }
290
294
  render() {
291
295
  return html`
292
296
  <div class="sbb-flip-card">
@@ -23,7 +23,7 @@ export declare class SbbMiniCalendarElement<T = Date> extends SbbElement {
23
23
  private _handleSlotchange;
24
24
  private _setupKeydownListener;
25
25
  /** @internal */
26
- focus(): void;
26
+ focus(options?: FocusOptions): void;
27
27
  connectedCallback(): void;
28
28
  disconnectedCallback(): void;
29
29
  protected render(): TemplateResult;
@@ -383,8 +383,8 @@ let SbbMiniCalendarElement = (() => {
383
383
  });
384
384
  }
385
385
  /** @internal */
386
- focus() {
387
- this._getMiniCalendarDays()?.find((e) => e.tabIndex === 0)?.focus();
386
+ focus(options) {
387
+ this._getMiniCalendarDays()?.find((e) => e.tabIndex === 0)?.focus(options);
388
388
  }
389
389
  connectedCallback() {
390
390
  super.connectedCallback();
@@ -105,7 +105,7 @@ export declare class SbbSelectElement<T = string> extends SbbSelectElement_base
105
105
  private _closeOnDisabledReadonlyChanged;
106
106
  protected firstUpdated(changedProperties: PropertyValues<this>): void;
107
107
  /** @internal */
108
- focus(): void;
108
+ focus(options?: FocusOptions): void;
109
109
  /** @internal */
110
110
  blur(): void;
111
111
  /**
@@ -468,8 +468,8 @@ let SbbSelectElement = (() => {
468
468
  }
469
469
  }
470
470
  /** @internal */
471
- focus() {
472
- this._triggerElement?.focus();
471
+ focus(options) {
472
+ this._triggerElement?.focus(options);
473
473
  }
474
474
  /** @internal */
475
475
  blur() {
@@ -44,7 +44,7 @@ export declare class SbbSliderElement extends SbbSliderElement_base {
44
44
  */
45
45
  get type(): string;
46
46
  /** Reference to the inner HTMLInputElement with type='range'. */
47
- private _rangeInput;
47
+ private _rangeInput?;
48
48
  constructor();
49
49
  connectedCallback(): void;
50
50
  protected willUpdate(changedProperties: PropertyValues<this>): void;
@@ -265,7 +265,7 @@ let SbbSliderElement = (() => {
265
265
  }
266
266
  async _handleKeydown(event) {
267
267
  if (event.key !== "Tab") event.preventDefault();
268
- if (this.readOnly) return;
268
+ if (this.readOnly || !this._rangeInput) return;
269
269
  if (event.key === "Home") this._rangeInput.value = this.min;
270
270
  else if (event.key === "End") this._rangeInput.value = this.max;
271
271
  else if (event.key === "ArrowLeft" || event.key === "ArrowDown") this._rangeInput.stepDown();
@@ -34,6 +34,8 @@ export declare class SbbToggleElement<T = string> extends SbbToggleElement_base
34
34
  /** The child instances of sbb-toggle-option as an array. */
35
35
  get options(): SbbToggleOptionElement<T>[];
36
36
  constructor();
37
+ /** @internal */
38
+ focus(options?: FocusOptions): void;
37
39
  protected willUpdate(changedProperties: PropertyValues): void;
38
40
  /**
39
41
  * Called whenever the value changes, both programmatically or by user interaction.
@@ -293,6 +293,12 @@ let SbbToggleElement = (() => {
293
293
  this.addEventListener?.("input", () => this._handleInput(), { passive: true });
294
294
  this.addEventListener?.("keydown", (e) => this._handleKeyDown(e));
295
295
  }
296
+ /** @internal */
297
+ focus(options) {
298
+ if (this.disabled || this.formDisabled) return;
299
+ const enabledOptions = this.options.filter((option) => !option.disabled);
300
+ (enabledOptions.find((option) => option.checked) ?? enabledOptions[0])?.focus(options);
301
+ }
296
302
  willUpdate(changedProperties) {
297
303
  super.willUpdate(changedProperties);
298
304
  if (changedProperties.has("disabled") || changedProperties.has("formDisabled")) this._updateDisabled();
@@ -1,5 +1,5 @@
1
1
  import{__esDecorate as e,__runInitializers as t}from"tslib";import{nothing as n,unsafeCSS as r}from"lit";import{property as i}from"lit/decorators.js";import{ref as a}from"lit/directives/ref.js";import{html as o,unsafeStatic as s}from"lit/static-html.js";import{SbbSecondaryButtonElement as c,SbbSecondaryButtonStaticElement as l}from"./button.pure.js";import{SbbDisabledMixin as u,SbbElement as d,SbbFormAssociatedMixin as f,SbbLanguageController as p,forceType as m,forwardEvent as h,i18nFileSelectorButtonLabel as g,i18nFileSelectorButtonLabelMultiple as _,i18nFileSelectorCurrentlySelected as v,i18nFileSelectorDeleteFile as y,i18nFileSelectorSubtitleLabel as b,i18nFileSelectorSubtitleLabelMultiple as x,sbbInputModalityDetector as S,screenReaderOnlyStyles as C,ɵstateController as w}from"./core.js";import{SbbIconElement as T}from"./icon.pure.js";var E=`:host{--sbb-file-selector-transition-duration:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-2x));width:20rem;display:block}@media (forced-colors:active){:host(:disabled){--sbb-file-selector-color:GrayText;--sbb-file-selector-subtitle-color:GrayText;--sbb-file-selector-border-color:GrayText}}:host(:is(:state(active),[state--active])){--sbb-file-selector-background-color:var(--sbb-background-color-3);--sbb-file-selector-border-color:light-dark(var(--sbb-color-storm),var(--sbb-color-anthracite))}@media (forced-colors:active){:host(:is(:state(active),[state--active])){--sbb-file-selector-border-color:Highlight}}.sbb-file-selector__input-container{-webkit-tap-highlight-color:transparent;flex-direction:column;display:flex}.sbb-file-selector__file-list{row-gap:var(--sbb-spacing-fixed-3x);padding-inline:0;padding-block:var(--sbb-spacing-fixed-6x) var(--sbb-spacing-fixed-1x);flex-direction:column;margin-block:0;display:flex}.sbb-file-selector__file{gap:var(--sbb-spacing-fixed-4x);line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-letter-spacing-text);font-size:var(--sbb-text-font-size-s);justify-content:space-between;align-items:center;display:flex}.sbb-file-selector__file-details{justify-content:space-between;gap:var(--sbb-spacing-fixed-4x);flex:1;display:flex;overflow:auto}.sbb-file-selector__file-name{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.sbb-file-selector__file-size{white-space:nowrap;color:light-dark(var(--sbb-color-metal),var(--sbb-color-smoke))}:host(:not(:is(:state(slotted-error),[state--slotted-error]))) .sbb-file-selector__error{display:none}
2
- `,D=class extends Event{get files(){return this._files}constructor(e){super(`filechanged`,{bubbles:!0,composed:!0}),this._files=Object.freeze(e||[])}};const O=l=>(()=>{let d=u(f(l)),b=[],x,T=[],O=[],k,A=[],j=[],M,N=[],P=[],F,I=[],L=[],R,z=[],B=[],V,H;return class extends d{constructor(){super(...arguments),this.#e=(t(this,b),t(this,T,null)),this.#t=(t(this,O),t(this,A,!1)),this.#n=(t(this,j),t(this,N,`default`)),this.#r=(t(this,P),t(this,I,``)),this.#i=(t(this,L),t(this,z,``)),this._files=(t(this,B),[]),this._suffixes=[`B`,`kB`,`MB`,`GB`,`TB`],this.language=new p(this),this._counter=0}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(d[Symbol.metadata]??null):void 0;x=[i({reflect:!0})],k=[m(),i({type:Boolean})],M=[i({attribute:`multiple-mode`})],F=[m(),i()],R=[m(),i({attribute:`accessibility-label`})],V=[i({attribute:!1})],H=[i({attribute:!1})],e(this,null,x,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:t},T,O),e(this,null,k,{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},A,j),e(this,null,M,{kind:`accessor`,name:`multipleMode`,static:!1,private:!1,access:{has:e=>`multipleMode`in e,get:e=>e.multipleMode,set:(e,t)=>{e.multipleMode=t}},metadata:t},N,P),e(this,null,F,{kind:`accessor`,name:`accept`,static:!1,private:!1,access:{has:e=>`accept`in e,get:e=>e.accept,set:(e,t)=>{e.accept=t}},metadata:t},I,L),e(this,null,R,{kind:`accessor`,name:`accessibilityLabel`,static:!1,private:!1,access:{has:e=>`accessibilityLabel`in e,get:e=>e.accessibilityLabel,set:(e,t)=>{e.accessibilityLabel=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,b),e(this,null,H,{kind:`setter`,name:`files`,static:!1,private:!1,access:{has:e=>`files`in e,set:(e,t)=>{e.files=t}},metadata:t},null,b),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementDependencies=[c]}static{this.events={filechanged:`filechanged`}}static{this.styles=[C,r(E)]}#e;get size(){return this.#e}set size(e){this.#e=e}#t;get multiple(){return this.#t}set multiple(e){this.#t=e}#n;get multipleMode(){return this.#n}set multipleMode(e){this.#n=e}#r;get accept(){return this.#r}set accept(e){this.#r=e}#i;get accessibilityLabel(){return this.#i}set accessibilityLabel(e){this.#i=e}set value(e){this._hiddenInput.value=e??``,e||(this.files=[])}get value(){return this._hiddenInput?.value}set files(e){this._files=e??[];let t=new DataTransfer;this.files.forEach(e=>t.items.add(e)),this._hiddenInput.files=t.files,this.updateFormValue()}get files(){return this._files}get type(){return`file`}formResetCallback(){this.files=[]}formStateRestoreCallback(e,t){e&&(this.files=e.getAll(this.name))}updateFormValue(){let e=new FormData;this.files.forEach(t=>e.append(this.name,t)),this.internals.setFormValue(e)}_checkFileEquality(e,t){return e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}_onFocus(){S.mostRecentModality===`keyboard`&&w(this.loadButton).add(`focus-visible`)}_onBlur(){w(this.loadButton).delete(`focus-visible`)}_readFiles(e){let t=e.target;t.files&&this.createFileList(t.files),h(e,this)}createFileList(e,t=!1){let n=Array.from(e);!this.multiple&&e.length>1||this.accept&&n.some(e=>!this.accept.split(`,`).some(t=>e.name.endsWith(t.trim())))||(this.files=!this.multiple||this.multipleMode!==`persistent`||this.files.length===0?n:n.filter(e=>this.files.findIndex(t=>this._checkFileEquality(e,t))===-1).concat(this.files),this._updateA11yLiveRegion(),this._dispatchFileChangedEvent(),t&&this._dispatchNativeEvents())}getButtonLabel(){return this.multiple?_[this.language.current]:g[this.language.current]}_removeFile(e){this.files=this.files.filter(t=>!this._checkFileEquality(e,t)),this._updateA11yLiveRegion(),this._dispatchNativeEvents(),this._dispatchFileChangedEvent()}_dispatchNativeEvents(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_dispatchFileChangedEvent(){let e=this.files;this.dispatchEvent(new D(e))}_formatFileSize(e){let t=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**t).toFixed(0)} ${this._suffixes[t]}`}_updateA11yLiveRegion(){this._liveRegion.innerText=v(this.files.map(e=>e.name))[this.language.current]}_renderFileList(){let e=this.files.length>1?{WRAPPER:`ul`,ELEMENT:`li`}:{WRAPPER:`div`,ELEMENT:`span`};return o`
2
+ `,D=class extends Event{get files(){return this._files}constructor(e){super(`filechanged`,{bubbles:!0,composed:!0}),this._files=Object.freeze(e||[])}};const O=l=>(()=>{let d=u(f(l)),b=[],x,T=[],O=[],k,A=[],j=[],M,N=[],P=[],F,I=[],L=[],R,z=[],B=[],V,H;return class extends d{constructor(){super(...arguments),this.#e=(t(this,b),t(this,T,null)),this.#t=(t(this,O),t(this,A,!1)),this.#n=(t(this,j),t(this,N,`default`)),this.#r=(t(this,P),t(this,I,``)),this.#i=(t(this,L),t(this,z,``)),this._files=(t(this,B),[]),this._suffixes=[`B`,`kB`,`MB`,`GB`,`TB`],this.language=new p(this),this._counter=0}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(d[Symbol.metadata]??null):void 0;x=[i({reflect:!0})],k=[m(),i({type:Boolean})],M=[i({attribute:`multiple-mode`})],F=[m(),i()],R=[m(),i({attribute:`accessibility-label`})],V=[i({attribute:!1})],H=[i({attribute:!1})],e(this,null,x,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:t},T,O),e(this,null,k,{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},A,j),e(this,null,M,{kind:`accessor`,name:`multipleMode`,static:!1,private:!1,access:{has:e=>`multipleMode`in e,get:e=>e.multipleMode,set:(e,t)=>{e.multipleMode=t}},metadata:t},N,P),e(this,null,F,{kind:`accessor`,name:`accept`,static:!1,private:!1,access:{has:e=>`accept`in e,get:e=>e.accept,set:(e,t)=>{e.accept=t}},metadata:t},I,L),e(this,null,R,{kind:`accessor`,name:`accessibilityLabel`,static:!1,private:!1,access:{has:e=>`accessibilityLabel`in e,get:e=>e.accessibilityLabel,set:(e,t)=>{e.accessibilityLabel=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,b),e(this,null,H,{kind:`setter`,name:`files`,static:!1,private:!1,access:{has:e=>`files`in e,set:(e,t)=>{e.files=t}},metadata:t},null,b),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementDependencies=[c]}static{this.events={filechanged:`filechanged`}}static{this.styles=[C,r(E)]}#e;get size(){return this.#e}set size(e){this.#e=e}#t;get multiple(){return this.#t}set multiple(e){this.#t=e}#n;get multipleMode(){return this.#n}set multipleMode(e){this.#n=e}#r;get accept(){return this.#r}set accept(e){this.#r=e}#i;get accessibilityLabel(){return this.#i}set accessibilityLabel(e){this.#i=e}set value(e){this._hiddenInput.value=e??``,e||(this.files=[])}get value(){return this._hiddenInput?.value}set files(e){this._files=e??[];let t=new DataTransfer;this.files.forEach(e=>t.items.add(e)),this._hiddenInput.files=t.files,this.updateFormValue()}get files(){return this._files}get type(){return`file`}focus(e){this._hiddenInput.focus(e)}formResetCallback(){this.files=[]}formStateRestoreCallback(e,t){e&&(this.files=e.getAll(this.name))}updateFormValue(){let e=new FormData;this.files.forEach(t=>e.append(this.name,t)),this.internals.setFormValue(e)}_checkFileEquality(e,t){return e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}_onFocus(){S.mostRecentModality===`keyboard`&&w(this.loadButton).add(`focus-visible`)}_onBlur(){w(this.loadButton).delete(`focus-visible`)}_readFiles(e){let t=e.target;t.files&&this.createFileList(t.files),h(e,this)}createFileList(e,t=!1){let n=Array.from(e);!this.multiple&&e.length>1||this.accept&&n.some(e=>!this.accept.split(`,`).some(t=>e.name.endsWith(t.trim())))||(this.files=!this.multiple||this.multipleMode!==`persistent`||this.files.length===0?n:n.filter(e=>this.files.findIndex(t=>this._checkFileEquality(e,t))===-1).concat(this.files),this._updateA11yLiveRegion(),this._dispatchFileChangedEvent(),t&&this._dispatchNativeEvents())}getButtonLabel(){return this.multiple?_[this.language.current]:g[this.language.current]}_removeFile(e){this.files=this.files.filter(t=>!this._checkFileEquality(e,t)),this._updateA11yLiveRegion(),this._dispatchNativeEvents(),this._dispatchFileChangedEvent()}_dispatchNativeEvents(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_dispatchFileChangedEvent(){let e=this.files;this.dispatchEvent(new D(e))}_formatFileSize(e){let t=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**t).toFixed(0)} ${this._suffixes[t]}`}_updateA11yLiveRegion(){this._liveRegion.innerText=v(this.files.map(e=>e.name))[this.language.current]}_renderFileList(){let e=this.files.length>1?{WRAPPER:`ul`,ELEMENT:`li`}:{WRAPPER:`div`,ELEMENT:`span`};return o`
3
3
  <${s(e.WRAPPER)} class="sbb-file-selector__file-list">
4
4
  ${this.files.map(t=>o`
5
5
  <${s(e.ELEMENT)} class="sbb-file-selector__file">
package/flip-card.pure.js CHANGED
@@ -10,7 +10,7 @@ import{MutationController as e}from"@lit-labs/observers/mutation-controller.js";
10
10
  <slot name="image"></slot>
11
11
  </div>
12
12
  `}constructor(){super(...arguments),g(this,a)}}})();var E=`:host{--sbb-flip-card-summary-transition-duration:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-5x));--sbb-flip-card-summary-transition-delay:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-2x));--sbb-flip-card-details-transition-duration:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-4x));display:block;position:relative}@media (any-hover:hover){:host(:hover){--sbb-flip-card-background-color:light-dark(color-mix(in srgb, var(--sbb-color-cloud) 80%, transparent),var(--sbb-color-iron));--sbb-flip-card-translate-title-y-hover:-.0625rem}}:host(:is(:state(flipped),[state--flipped])){--sbb-flip-card-toggle-icon-transform:rotate(45deg);--sbb-flip-card-details-transition-duration:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-2x));--sbb-flip-card-summary-transition-delay:0s}:host(:is(:state(flipped),[state--flipped])) ::slotted(sbb-flip-card-summary){--sbb-flip-card-summary-opacity:0;--sbb-flip-card-summary-pointer-events:none}:host(:is(:state(flipped),[state--flipped])) ::slotted(sbb-flip-card-details){--sbb-flip-card-details-opacity:1;--sbb-flip-card-details-translate-y:0}@media (width>=37.5rem) and (width<64rem){:host(:is(:state(image-alignment-after),[state--image-alignment-after])){--sbb-flip-card-min-height:15rem}}@media (width>=90rem){:host(:is(:state(image-alignment-after),[state--image-alignment-after])){--sbb-flip-card-min-height:25rem}}.sbb-flip-card{height:100%;min-height:var(--sbb-flip-card-min-height);background-color:var(--sbb-flip-card-background-color);border-radius:var(--sbb-flip-card-border-radius);transition:all var(--sbb-flip-card-summary-transition-duration) ease-out, min-height var(--sbb-flip-card-details-transition-duration);transition-delay:var(--sbb-flip-card-summary-transition-delay);cursor:var(--sbb-cursor-pointer);flex-flow:column wrap;display:flex;position:relative}:host(:is(:state(flipped),[state--flipped])) .sbb-flip-card{min-height:max(var(--sbb-flip-card-min-height), var(--sbb-flip-card-details-height))}@media (forced-colors:active){.sbb-flip-card:after{content:"";border:var(--sbb-flip-card-border) solid CanvasText;border-radius:var(--sbb-flip-card-border-radius);pointer-events:none;position:absolute;inset:0}}@media (forced-colors:active) and (any-hover:hover){:host(:hover) .sbb-flip-card:after{border-color:highlight}}.sbb-flip-card:before{content:"";opacity:0;pointer-events:none;background-color:var(--sbb-color-midnight);background-color:light-dark(var(--sbb-color-midnight),var(--sbb-color-iron));width:var(--sbb-flip-card-button-dimensions);height:var(--sbb-flip-card-button-dimensions);transition:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-3x)) ease-out;border-radius:16rem;position:absolute;inset-block-end:var(--sbb-flip-card-padding);inset-inline-start:var(--sbb-flip-card-padding)}:host(:is(:state(flipped),[state--flipped])) .sbb-flip-card:before{opacity:1;border-radius:var(--sbb-flip-card-border-radius);width:100%;height:100%;transition-duration:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-5x));inset-block-end:0;inset-inline-start:0}.sbb-flip-card--toggle-button{position:absolute;inset-block-end:var(--sbb-flip-card-padding);inset-inline-start:var(--sbb-flip-card-padding)}:host(:is(:state(flipped),[state--flipped])) .sbb-flip-card--toggle-button{--sbb-focus-outline-color:var(--sbb-focus-outline-color-dark)}.sbb-flip-card--toggle-button-icon{transform:var(--sbb-flip-card-toggle-icon-transform,none);transition:transform var(--sbb-flip-card-summary-transition-duration) ease-out}.sbb-flip-card-button{border-radius:var(--sbb-flip-card-border-radius);width:100%;cursor:var(--sbb-cursor-pointer);position:absolute;inset:0}.sbb-flip-card-button: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)}
13
- `;let D=(()=>{let e=o,S,C=[],w=[],T,D=[],O=[];return class extends e{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;S=[u(),_({attribute:`accessibility-label`})],T=[v()],h(this,null,S,{kind:`accessor`,name:`accessibilityLabel`,static:!1,private:!1,access:{has:e=>`accessibilityLabel`in e,get:e=>e.accessibilityLabel,set:(e,t)=>{e.accessibilityLabel=t}},metadata:t},C,w),h(this,null,T,{kind:`accessor`,name:`_flipped`,static:!1,private:!1,access:{has:e=>`_flipped`in e,get:e=>e._flipped,set:(e,t)=>{e._flipped=t}},metadata:t},D,O),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-flip-card`}static{this.elementDependencies=[x]}static{this.styles=[l,p,i(E)]}static{this.events={flip:`flip`}}#e;get accessibilityLabel(){return this.#e}set accessibilityLabel(e){this.#e=e}get summary(){return this.querySelector?.(`sbb-flip-card-summary`)}get details(){return this.querySelector?.(`sbb-flip-card-details`)}get _detailsContentElement(){return this.details?.shadowRoot?.querySelector(`.sbb-flip-card-details`)??null}get isFlipped(){return this._flipped}#t;get _flipped(){return this.#t}set _flipped(e){this.#t=e}constructor(){super(),this.#e=g(this,C,``),this.#t=(g(this,w),g(this,D,!1)),this._language=(g(this,O),new s(this)),this._cardDetailsResizeObserver=new y(this,{target:null,skipInitial:!0,callback:()=>this._setCardDetailsHeight()}),this.addEventListener?.(`click`,e=>{e.target!==this&&e.target?.matches?.(a)||this.toggle()}),this.addController(new c(this,()=>this.summary,{imageAlignment:e=>{this._previousImageAlignment&&this.internals.states.delete(`image-alignment-${this._previousImageAlignment}`),this._previousImageAlignment=e.imageAlignment,this._previousImageAlignment&&this.internals.states.add(`image-alignment-${this._previousImageAlignment}`)}}))}toggle(){this._flipped=!this._flipped;let e=this._detailsContentElement;this._flipped&&e?(this._setCardDetailsHeight(),this._cardDetailsResizeObserver.observe(e)):e&&this._cardDetailsResizeObserver.unobserve(e),this.toggleState(`flipped`,this._flipped),m(this.details)?.toggle(`flipped`,this._flipped),this.summary.inert=this._flipped,this.details.inert=!this._flipped,this.dispatchEvent(new Event(`flip`,{bubbles:!0,composed:!0}))}_setCardDetailsHeight(){let e=Math.floor(this._detailsContentElement.offsetHeight);this.style?.setProperty(`--sbb-flip-card-details-height`,`${e}px`)}async _accessibilityLabel(){return n?``:(await this.hydrationComplete,this._flipped?f[this._language.current]:`${(this.accessibilityLabel?this.accessibilityLabel:this.summary?.textContent?.trim())??``}, ${d[this._language.current]}`)}render(){return t`
13
+ `;let D=(()=>{let e=o,S,C=[],w=[],T,D=[],O=[];return class extends e{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;S=[u(),_({attribute:`accessibility-label`})],T=[v()],h(this,null,S,{kind:`accessor`,name:`accessibilityLabel`,static:!1,private:!1,access:{has:e=>`accessibilityLabel`in e,get:e=>e.accessibilityLabel,set:(e,t)=>{e.accessibilityLabel=t}},metadata:t},C,w),h(this,null,T,{kind:`accessor`,name:`_flipped`,static:!1,private:!1,access:{has:e=>`_flipped`in e,get:e=>e._flipped,set:(e,t)=>{e._flipped=t}},metadata:t},D,O),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-flip-card`}static{this.elementDependencies=[x]}static{this.styles=[l,p,i(E)]}static{this.events={flip:`flip`}}#e;get accessibilityLabel(){return this.#e}set accessibilityLabel(e){this.#e=e}get summary(){return this.querySelector?.(`sbb-flip-card-summary`)}get details(){return this.querySelector?.(`sbb-flip-card-details`)}get _detailsContentElement(){return this.details?.shadowRoot?.querySelector(`.sbb-flip-card-details`)??null}get isFlipped(){return this._flipped}#t;get _flipped(){return this.#t}set _flipped(e){this.#t=e}constructor(){super(),this.#e=g(this,C,``),this.#t=(g(this,w),g(this,D,!1)),this._language=(g(this,O),new s(this)),this._cardDetailsResizeObserver=new y(this,{target:null,skipInitial:!0,callback:()=>this._setCardDetailsHeight()}),this.addEventListener?.(`click`,e=>{e.target!==this&&e.target?.matches?.(a)||this.toggle()}),this.addController(new c(this,()=>this.summary,{imageAlignment:e=>{this._previousImageAlignment&&this.internals.states.delete(`image-alignment-${this._previousImageAlignment}`),this._previousImageAlignment=e.imageAlignment,this._previousImageAlignment&&this.internals.states.add(`image-alignment-${this._previousImageAlignment}`)}}))}toggle(){this._flipped=!this._flipped;let e=this._detailsContentElement;this._flipped&&e?(this._setCardDetailsHeight(),this._cardDetailsResizeObserver.observe(e)):e&&this._cardDetailsResizeObserver.unobserve(e),this.toggleState(`flipped`,this._flipped),m(this.details)?.toggle(`flipped`,this._flipped),this.summary.inert=this._flipped,this.details.inert=!this._flipped,this.dispatchEvent(new Event(`flip`,{bubbles:!0,composed:!0}))}_setCardDetailsHeight(){let e=Math.floor(this._detailsContentElement.offsetHeight);this.style?.setProperty(`--sbb-flip-card-details-height`,`${e}px`)}async _accessibilityLabel(){return n?``:(await this.hydrationComplete,this._flipped?f[this._language.current]:`${(this.accessibilityLabel?this.accessibilityLabel:this.summary?.textContent?.trim())??``}, ${d[this._language.current]}`)}focus(e){this.shadowRoot?.querySelector(`.sbb-flip-card-button`)?.focus(e)}render(){return t`
14
14
  <div class="sbb-flip-card">
15
15
  <button
16
16
  class="sbb-flip-card-button"
@@ -7,4 +7,4 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,uns
7
7
  </div>
8
8
  <div class="sbb-mini-calendar-month-label-month">${this._monthLabel}</div>
9
9
  `}}})();var y=`:host{gap:var(--sbb-spacing-fixed-2x) var(--sbb-spacing-fixed-1x);flex-wrap:wrap;display:flex}
10
- `;let b=(()=>{let a=o,s,l=[],d=[];return class extends a{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(a[Symbol.metadata]??null):void 0;s=[i({reflect:!0})],e(this,null,s,{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},l,d),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-mini-calendar`}static{this.styles=[r(y)]}#e;get orientation(){return this.#e}set orientation(e){this.#e=e}constructor(){super(),this.#e=t(this,l,`horizontal`),this._keydownAbortController=(t(this,d),null),this._dateAdapter=f().datetime?.dateAdapter??c,this.addController(new m(this,{config:{childList:!0,subtree:!0},callback:()=>this._setMonthsShowYear()}))}_getMiniCalendarMonths(){return Array.from(this.querySelectorAll?.(`sbb-mini-calendar-month`)??[])}_getMiniCalendarDays(){return Array.from(this._getMiniCalendarMonths().flatMap(e=>Array.from(e.querySelectorAll?.(`sbb-mini-calendar-day`)??[])))}_setMonthsShowYear(){this._getMiniCalendarMonths().forEach((e,t)=>{let n=e.date.split(`-`);n.length>0&&(t===0||+n[1]==1?p(e).add(`show-year`):p(e).delete(`show-year`))})}_handleKeydownCalendarDay(e){u(e)&&e.preventDefault();let t=this._getMiniCalendarDays(),n=t.find(t=>t===e.target),r=this._navigateByKeyboardDayView(t,n,e),i=document.activeElement;r!==i&&(r.tabIndex=0,r?.focus(),i.tabIndex=-1)}_navigateByKeyboardDayView(e,t,n){let r=this.orientation===`horizontal`?{leftRight:1,upDown:7}:{leftRight:7,upDown:1},i=this._dateAdapter.parse(t.date),a=this._dateAdapter.getDate(i),o=this._dateAdapter.getFirstWeekOffset(i);switch(n.key){case`ArrowUp`:return this._findDayArrowKeys(e,t,-r.upDown);case`ArrowDown`:return this._findDayArrowKeys(e,t,r.upDown);case`ArrowLeft`:return this._findDayArrowKeys(e,t,-r.leftRight);case`ArrowRight`:return this._findDayArrowKeys(e,t,r.leftRight);case`PageUp`:if(this.orientation===`horizontal`){let n=a-(a%7||7);return this._findDaySpecialKeys(e,t,-n,r.upDown)}{let n=(Math.ceil((a+o)/7)-1)*7-o+1-a;return this._findDaySpecialKeys(e,t,n,r.upDown)}case`PageDown`:if(this.orientation===`horizontal`){let n=this._dateAdapter.getNumDaysInMonth(i),o=n-a-(n-a)%7;return this._findDaySpecialKeys(e,t,o,-r.upDown)}{let n=Math.ceil((a+o)/7)*7-o-a;return this._findDaySpecialKeys(e,t,n,-r.upDown)}case`Home`:{let n=a-1;return this._findDaySpecialKeys(e,t,-n,1)}case`End`:{let n=this._dateAdapter.getNumDaysInMonth(i);return this._findDaySpecialKeys(e,t,n-a,-1)}default:return t}}_findDayArrowKeys(e,t,n){let r=this._dateAdapter.addCalendarDays(this._dateAdapter.deserialize(t.date),n),i=this._dateAdapter.toIso8601(r);return e.find(e=>e.date===i)||t}_findDaySpecialKeys(e,t,n,r){let i=this._dateAdapter.addCalendarDays(this._dateAdapter.deserialize(t.date),n),a=this._dateAdapter.toIso8601(i);return e.find(e=>e.date===a)||this._findDaySpecialKeys(e,t,n+r,r)}_handleSlotchange(){this._setupKeydownListener()}_setupKeydownListener(){this._keydownAbortController?.abort(),this._keydownAbortController=new AbortController,this._getMiniCalendarDays().forEach((e,t)=>{e.addEventListener(`keydown`,e=>this._handleKeydownCalendarDay(e),{signal:this._keydownAbortController.signal}),t!==0&&(e.tabIndex=-1)})}focus(){this._getMiniCalendarDays()?.find(e=>e.tabIndex===0)?.focus()}connectedCallback(){super.connectedCallback(),this._setupKeydownListener()}disconnectedCallback(){super.disconnectedCallback(),this._keydownAbortController?.abort()}render(){return n`<slot @slotchange=${this._handleSlotchange}></slot>`}}})();export{g as SbbMiniCalendarDayElement,b as SbbMiniCalendarElement,v as SbbMiniCalendarMonthElement};
10
+ `;let b=(()=>{let a=o,s,l=[],d=[];return class extends a{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(a[Symbol.metadata]??null):void 0;s=[i({reflect:!0})],e(this,null,s,{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},l,d),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-mini-calendar`}static{this.styles=[r(y)]}#e;get orientation(){return this.#e}set orientation(e){this.#e=e}constructor(){super(),this.#e=t(this,l,`horizontal`),this._keydownAbortController=(t(this,d),null),this._dateAdapter=f().datetime?.dateAdapter??c,this.addController(new m(this,{config:{childList:!0,subtree:!0},callback:()=>this._setMonthsShowYear()}))}_getMiniCalendarMonths(){return Array.from(this.querySelectorAll?.(`sbb-mini-calendar-month`)??[])}_getMiniCalendarDays(){return Array.from(this._getMiniCalendarMonths().flatMap(e=>Array.from(e.querySelectorAll?.(`sbb-mini-calendar-day`)??[])))}_setMonthsShowYear(){this._getMiniCalendarMonths().forEach((e,t)=>{let n=e.date.split(`-`);n.length>0&&(t===0||+n[1]==1?p(e).add(`show-year`):p(e).delete(`show-year`))})}_handleKeydownCalendarDay(e){u(e)&&e.preventDefault();let t=this._getMiniCalendarDays(),n=t.find(t=>t===e.target),r=this._navigateByKeyboardDayView(t,n,e),i=document.activeElement;r!==i&&(r.tabIndex=0,r?.focus(),i.tabIndex=-1)}_navigateByKeyboardDayView(e,t,n){let r=this.orientation===`horizontal`?{leftRight:1,upDown:7}:{leftRight:7,upDown:1},i=this._dateAdapter.parse(t.date),a=this._dateAdapter.getDate(i),o=this._dateAdapter.getFirstWeekOffset(i);switch(n.key){case`ArrowUp`:return this._findDayArrowKeys(e,t,-r.upDown);case`ArrowDown`:return this._findDayArrowKeys(e,t,r.upDown);case`ArrowLeft`:return this._findDayArrowKeys(e,t,-r.leftRight);case`ArrowRight`:return this._findDayArrowKeys(e,t,r.leftRight);case`PageUp`:if(this.orientation===`horizontal`){let n=a-(a%7||7);return this._findDaySpecialKeys(e,t,-n,r.upDown)}{let n=(Math.ceil((a+o)/7)-1)*7-o+1-a;return this._findDaySpecialKeys(e,t,n,r.upDown)}case`PageDown`:if(this.orientation===`horizontal`){let n=this._dateAdapter.getNumDaysInMonth(i),o=n-a-(n-a)%7;return this._findDaySpecialKeys(e,t,o,-r.upDown)}{let n=Math.ceil((a+o)/7)*7-o-a;return this._findDaySpecialKeys(e,t,n,-r.upDown)}case`Home`:{let n=a-1;return this._findDaySpecialKeys(e,t,-n,1)}case`End`:{let n=this._dateAdapter.getNumDaysInMonth(i);return this._findDaySpecialKeys(e,t,n-a,-1)}default:return t}}_findDayArrowKeys(e,t,n){let r=this._dateAdapter.addCalendarDays(this._dateAdapter.deserialize(t.date),n),i=this._dateAdapter.toIso8601(r);return e.find(e=>e.date===i)||t}_findDaySpecialKeys(e,t,n,r){let i=this._dateAdapter.addCalendarDays(this._dateAdapter.deserialize(t.date),n),a=this._dateAdapter.toIso8601(i);return e.find(e=>e.date===a)||this._findDaySpecialKeys(e,t,n+r,r)}_handleSlotchange(){this._setupKeydownListener()}_setupKeydownListener(){this._keydownAbortController?.abort(),this._keydownAbortController=new AbortController,this._getMiniCalendarDays().forEach((e,t)=>{e.addEventListener(`keydown`,e=>this._handleKeydownCalendarDay(e),{signal:this._keydownAbortController.signal}),t!==0&&(e.tabIndex=-1)})}focus(e){this._getMiniCalendarDays()?.find(e=>e.tabIndex===0)?.focus(e)}connectedCallback(){super.connectedCallback(),this._setupKeydownListener()}disconnectedCallback(){super.disconnectedCallback(),this._keydownAbortController?.abort()}render(){return n`<slot @slotchange=${this._handleSlotchange}></slot>`}}})();export{g as SbbMiniCalendarDayElement,b as SbbMiniCalendarElement,v as SbbMiniCalendarMonthElement};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sbb-esta/lyne-elements-dev",
3
- "version": "5.14.0-dev.1795574509",
3
+ "version": "5.14.0-dev.1795649508",
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/fbcf02c65d01791c66a81e5f6e95e5a5e94c6d58"
9
+ "https://github.com/sbb-design-systems/lyne-components/commit/7be6705f7d99d946de538a2bb7fddbc180d799b3"
10
10
  ],
11
11
  "type": "module",
12
12
  "exports": {
package/select.pure.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import{__esDecorate as e,__runInitializers as t}from"tslib";import{ResizeController as n}from"@lit-labs/observers/resize-controller.js";import{html as r,isServer as i,nothing as a,unsafeCSS as o}from"lit";import{property as s}from"lit/decorators.js";import{ref as c}from"lit/directives/ref.js";import{SbbDisabledMixin as l,SbbElement as u,SbbEscapableOverlayController as d,SbbFormAssociatedMixin as f,SbbLanguageController as p,SbbNegativeMixin as m,SbbOpenCloseBaseElement as h,SbbPropertyWatcherController as g,SbbReadonlyMixin as _,SbbRequiredMixin as v,SbbUpdateSchedulerMixin as y,forceType as b,getNextElementIndex as x,getOverride as S,handleDistinctChange as C,i18nMultipleSelectionPossible as w,i18nSelectionRequired as T,isEventOnElement as E,isNextjs as D,isZeroAnimationDuration as O,popoverResetStyles as k,scrollbarStyles as A,setOrRemoveAttribute as j,setOverlayPosition as M}from"./core.js";import{optionPanelStyles as N}from"./option.pure.js";var P=`:host{display:block;width:100%!important;height:var(--sbb-size-element-xs)!important}:host(:is(:state(in-form-field),[state--in-form-field])){top:0}
2
2
  `,F=class extends u{static{this.elementName=`sbb-select-trigger`}static{this.role=`combobox`}static{this.styles=[o(P)]}set select(e){if(e===this._select||(this._selectPropertyWatcher&&this.removeController(this._selectPropertyWatcher),this.internals.ariaControlsElements=null,this._select=e,!this._select))return;this._selectPropertyWatcher=new g(this,()=>this._select,{required:e=>this.internals.ariaRequired=e.required?`${e.required}`:null});let t=this._select.shadowRoot.querySelector(`.sbb-option-panel__overlay`);this.internals.ariaControlsElements=[t]}get select(){return this._select}constructor(){super(),this._select=null,this._selectPropertyWatcher=null,this.internals.ariaExpanded=`false`}connectedCallback(){super.connectedCallback(),this.toggleState(`in-form-field`,!!this.closest(`sbb-form-field`))}render(){return r`<slot></slot>`}},I=`:host{--sbb-select-placeholder-fallback-color:light-dark(var(--sbb-color-metal),var(--sbb-color-smoke));--sbb-options-panel-internal-z-index:var(--sbb-select-z-index,var(--sbb-overlay-default-z-index));display:block}:host([negative]){--sbb-select-placeholder-fallback-color:var(--sbb-color-5)}.sbb-select__trigger{white-space:nowrap;text-overflow:ellipsis;cursor:var(--sbb-cursor-default);height:calc(1em * var(--sbb-typo-line-height-text));overflow:hidden}:host(:not(:is(:state(has-display-value),[state--has-display-value]))) .sbb-select__trigger{color:var(--sbb-select-placeholder-color,var(--sbb-select-placeholder-fallback-color));-webkit-text-fill-color:var(--sbb-select-placeholder-color,var(--sbb-select-placeholder-fallback-color))}
3
- `;let L=(()=>{let u=y(l(m(v(_(f(h)))))),P=[],L,R=[],z=[],B,V=[],H=[],U,W=[],G=[],K,q=[],J=[],Y,X,Z=[],Q=[];return class extends u{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(u[Symbol.metadata]??null):void 0;L=[b(),s()],B=[b(),C((e,t)=>e._onMultipleChanged(t)),s({reflect:!0,type:Boolean})],U=[s({attribute:!1})],K=[b(),C((e,t)=>e._closeOnDisabledReadonlyChanged(t)),s({reflect:!0,type:Boolean}),S((e,t)=>t||e.isDisabledExternally())],Y=[s()],X=[s({reflect:!0})],e(this,null,L,{kind:`accessor`,name:`placeholder`,static:!1,private:!1,access:{has:e=>`placeholder`in e,get:e=>e.placeholder,set:(e,t)=>{e.placeholder=t}},metadata:t},R,z),e(this,null,B,{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},V,H),e(this,null,U,{kind:`accessor`,name:`compareWith`,static:!1,private:!1,access:{has:e=>`compareWith`in e,get:e=>e.compareWith,set:(e,t)=>{e.compareWith=t}},metadata:t},W,G),e(this,null,K,{kind:`accessor`,name:`disabled`,static:!1,private:!1,access:{has:e=>`disabled`in e,get:e=>e.disabled,set:(e,t)=>{e.disabled=t}},metadata:t},q,J),e(this,null,Y,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,P),e(this,null,X,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:t},Z,Q),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-select`}static{this.styles=[k,A,N,o(I)]}static{this.elementDependencies=[F]}static{this.events={change:`change`,input:`input`,displayvaluechange:`displayvaluechange`,beforeopen:`beforeopen`,open:`open`,beforeclose:`beforeclose`,close:`close`}}static get observedAttributes(){return super.observedAttributes.concat(`aria-label`,`aria-labelledby`,`aria-describedby`)}#e;get placeholder(){return this.#e}set placeholder(e){this.#e=e}#t;get multiple(){return this.#t}set multiple(e){this.#t=e}#n;get compareWith(){return this.#n}set compareWith(e){this.#n=e}#r;get disabled(){return this.#r}set disabled(e){this.#r=e}set value(e){this._value=e,this._isValueManuallyAssigned=!0,this._updateOptionsFromValue()}get value(){return this._value}#i;get size(){return this.#i}set size(e){this.#i=e}get type(){return this.multiple?`select-multiple`:`select-one`}get inputElement(){return this._triggerElement??null}get options(){let e=[];return this.querySelectorAll?.(`sbb-option`).forEach(t=>{customElements.upgrade(t),e.push(t)}),e}constructor(){super(),this.#e=(t(this,P),t(this,R,``)),this.#t=(t(this,z),t(this,V,!1)),this.#n=(t(this,H),t(this,W,(e,t)=>e===t)),this.#r=(t(this,G),t(this,q,!1)),this._value=(t(this,J),null),this.#i=t(this,Z,null),this._displayValue=(t(this,Q),null),this._resizeObserver=new n(this,{target:null,skipInitial:!0,callback:(()=>{let e;return()=>{clearTimeout(e),e=setTimeout(()=>{this.state!==`closed`&&this._setOverlayPosition()},10)}})()}),this._originElement=null,this._escapableOverlayController=new d(this),this._activeItemIndex=-1,this._searchString=``,this._didLoad=!1,this._isPointerDownEventOnMenu=!1,this._languageController=new p(this),this._isValueManuallyAssigned=!1,this._restoreFocusOnClose=!1,this._pointerDownListener=e=>{this._isPointerDownEventOnMenu=E(this._overlay,e)},this._closeOnBackdropClick=e=>{this._isPointerDownEventOnMenu||E(this._overlay,e)||E(this._originElement,e)||this.close()},this.addEventListener?.(`optionselectionchange`,e=>this._onOptionChanged(e)),this.addEventListener?.(`optionLabelChanged`,e=>this._onOptionLabelChanged(e)),this.addEventListener?.(`ɵoptionvaluechange`,()=>this._updateValueOptionState()),this.addEventListener?.(`ɵoptgroupslotchange`,()=>this._handleSlotchange(),{capture:!0}),this.addEventListener?.(`focusin`,e=>this._onFocusIn(e)),this.addEventListener?.(`click`,e=>{let t=e.target;t.localName===`sbb-option`?!this.multiple&&!t.disabled&&this._close(!0):this._toggleOpening()}),this.addController(new g(this,()=>this.closest(`sbb-form-field`),{negative:e=>{this.negative=e.negative,this._syncNegative()}})),this.addEventListener(`keydown`,e=>this._onKeyDown(e))}attributeChangedCallback(e,t,n){e===`aria-label`||e===`aria-labelledby`||e===`aria-describedby`?this._syncAriaLabels():super.attributeChangedCallback(e,t,n)}_syncAriaLabels(){this._triggerElement&&!i&&(j(this._triggerElement,`aria-labelledby`,this.getAttribute(`aria-labelledby`)),j(this._triggerElement,`aria-label`,this.getAttribute(`aria-label`)),j(this._triggerElement,`aria-describedby`,this.getAttribute(`aria-describedby`)),!this.getAttribute(`aria-label`)&&!this.getAttribute(`aria-labelledby`)&&this.internals.labels.length&&this._triggerElement?.setAttribute(`aria-label`,Array.from(this.internals.labels,e=>e.textContent).join(`, `)))}open(){this.state!==`opening`&&this.state!==`opened`&&this._overlay&&this.options.length!==0&&!this.disabled&&!this.formDisabled&&this.dispatchBeforeOpenEvent()&&(this.shadowRoot?.querySelector(`[popover]`)?.showPopover?.(),this.state=`opening`,this._triggerElement&&(this._triggerElement.internals.ariaExpanded=`true`),this.internals.states.add(`expanded`),this._setOverlayPosition(),this._escapableOverlayController.connect(),this._attachOpenPanelEvents(),this._isZeroAnimationDuration()&&this._handleOpening())}close(){this._close()}_close(e=!1){this.state!==`closing`&&this.state!==`closed`&&this.dispatchBeforeCloseEvent()&&(this._restoreFocusOnClose=e,this.state=`closing`,this.internals.states.delete(`expanded`),this._openPanelEventsController?.abort(),this._originElement&&this._resizeObserver.unobserve(this._originElement),this._isZeroAnimationDuration()&&this._handleClosing())}_isZeroAnimationDuration(){return O(this,`--sbb-options-panel-animation-duration`)}getDisplayValue(){return this._displayValue??``}_onOptionChanged(e){let t=e.target;t.selected?this._onOptionSelected(t):this._onOptionDeselected(t)}_onOptionLabelChanged(e){let t=e.target,n=this._getSelected();!Array.isArray(n)&&t!==n||Array.isArray(n)&&!n.includes(t)||this._updateDisplayValue()}async _updateDisplayValue(){let e=this._getSelected();this._displayValue=Array.isArray(e)?e.map(e=>e.textContent?.trim()).join(`, `)||null:e&&e?.textContent?.trim()||null,this.toggleState(`has-display-value`,!!this._displayValue),this.dispatchEvent(new Event(`displayvaluechange`,{bubbles:!0,composed:!0})),this.hydrationRequired&&await this.hydrationComplete;let t=[this._triggerElement?.querySelector?.(`span`),this.shadowRoot?.querySelector?.(`.sbb-select__trigger`)];for(let e of t)e&&(e.textContent=this._displayValue??this.placeholder)}_onMultipleChanged(e){e?this._value=this._isValueManuallyAssigned||this.value!=null?[this.value]:[]:Array.isArray(this.value)&&(this._value=this.value.length?this.value[0]:null),this._updateDisplayValue()}_closeOnDisabledReadonlyChanged(e){(this.state===`opening`||this.state===`opened`)&&e&&this.close()}firstUpdated(e){super.firstUpdated(e),this._updateValueOptionState(),this._triggerElement&&(this._syncAriaLabels(),this._triggerElement.select=this),D()||(this.startUpdate(),this._setupSelect())}focus(){this._triggerElement?.focus()}blur(){this._triggerElement?.blur()}removeAttribute(e){D()&&e===`defer-hydration`&&!this._didLoad&&this.updateComplete.then(()=>this._setupSelect()),super.removeAttribute(e)}connectedCallback(){super.connectedCallback(),this._syncNegative(),this._syncAriaLabels(),this._didLoad&&(this._setupOrigin(),this._setupTrigger())}requestUpdate(e,t,n){super.requestUpdate(e,t,n),!e&&this.hasUpdated&&setTimeout(()=>this._syncAriaLabels())}willUpdate(e){super.willUpdate(e),e.has(`negative`)&&this._syncNegative(),e.has(`readOnly`)&&this._closeOnDisabledReadonlyChanged(this.readOnly)}disconnectedCallback(){this._triggerElement&&this.prepend(this._triggerElement),super.disconnectedCallback(),this._openPanelEventsController?.abort()}formResetCallback(){this.value=this.hasAttribute(`value`)?this.getAttribute(`value`):null}formStateRestoreCallback(e,t){try{let{value:t,manuallyAssigned:n}=JSON.parse(e);this._isValueManuallyAssigned=n,this._value=t,this._updateOptionsFromValue()}catch{console.warn(`Failed to restore sbb-select with state ${e}`)}}formState(){return JSON.stringify({value:this.value,manuallyAssigned:this._isValueManuallyAssigned})}_syncNegative(){this.querySelectorAll?.(`sbb-divider, sbb-option-hint`).forEach(e=>e.negative=this.negative)}shouldValidate(e){return super.shouldValidate(e)||e===`value`||e===`required`}validate(){super.validate();let e=Array.isArray(this.value)?this.value:this.value===null?[]:[this.value];this.required&&(this.options.every(t=>e.every(e=>!this.compareWith(e,t.value)))||!this._isValueManuallyAssigned&&this.value==null)?this.setValidityFlag(`valueMissing`,T[this._languageController.current]):this.removeValidityFlag(`valueMissing`)}_setupSelect(){this._setupOrigin(),this._setupTrigger(),this._didLoad=!0,this.completeUpdate()}_setupOrigin(){let e=this.closest?.(`sbb-form-field`);this._originElement&&this._resizeObserver.unobserve(this._originElement),this._originElement=e?.shadowRoot?.querySelector?.(`#overlay-anchor`)??this.parentElement,this._originElement&&(this.toggleState(`option-panel-origin-borderless`,e?.hasAttribute?.(`borderless`)),this.isOpen&&this._resizeObserver.observe(this._originElement))}_setupTrigger(){this.parentElement&&this._triggerElement&&this.parentElement.insertBefore?.(this._triggerElement,this)}_setOverlayPosition(){this._originElement&&this._overlay&&M(this._overlay,this._originElement,this._overlay,this.shadowRoot.querySelector(`.sbb-option-panel__overlay-container`),this)}_onAnimationEnd(e){e.animationName===`open`&&this.state===`opening`?this._handleOpening():e.animationName===`close`&&this.state===`closing`&&this._handleClosing()}_handleOpening(){this.state=`opened`,this._originElement&&this._resizeObserver.observe(this._originElement),this.dispatchOpenEvent()}_handleClosing(){let e=this._restoreFocusOnClose||this._isFocusWithin();this._restoreFocusOnClose=!1,this.state=`closed`,this.shadowRoot?.querySelector(`[popover]`)?.hidePopover?.(),this._triggerElement&&(this._triggerElement.internals.ariaExpanded=`false`),this._resetActiveElement(),e&&this.focus(),this._overlay&&(this._overlay.scrollTop=0),this._escapableOverlayController.disconnect(),this.dispatchCloseEvent()}_isFocusWithin(){let e=this.getRootNode().activeElement;return!!e&&(e===this._triggerElement||this.contains(e))}_onOptionSelected(e){this.multiple?this.value?Array.isArray(this.value)&&!this.value.some(t=>this.compareWith(t,e.value))&&(this._value=[...this.value,e.value]):this._value=[e.value]:this._value=e.value,this._updateOptionsFromValue(),this._dispatchInputEvents()}_onOptionDeselected(e){this.multiple&&Array.isArray(this.value)&&(this._value=this.value.filter(t=>!this.compareWith(t,e.value)),this._updateOptionsFromValue(),this._dispatchInputEvents())}_dispatchInputEvents(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_attachOpenPanelEvents(){this._openPanelEventsController=new AbortController,document.addEventListener(`scroll`,()=>this._setOverlayPosition(),{passive:!0,signal:this._openPanelEventsController.signal,capture:!0}),window.addEventListener(`resize`,()=>this._setOverlayPosition(),{passive:!0,signal:this._openPanelEventsController.signal}),window.addEventListener(`pointerdown`,e=>this._pointerDownListener(e),{signal:this._openPanelEventsController.signal}),window.addEventListener(`pointerup`,e=>this._closeOnBackdropClick(e),{signal:this._openPanelEventsController.signal})}_onKeyDown(e){this.readOnly||(this.state===`opening`||this.state===`opened`?this._openedPanelKeyboardInteraction(e):(this.state===`closed`||this.state===`closing`)&&this._closedPanelKeyboardInteraction(e))}_closedPanelKeyboardInteraction(e){if(this._checkForLetterSelection(e))return this._setNextActiveOptionByText(e);switch(e.key){case`Enter`:case` `:case`ArrowDown`:case`ArrowUp`:e.preventDefault(),this.open()}}_openedPanelKeyboardInteraction(e){if(!this.readOnly){if(this._checkForLetterSelection(e))return this._setNextActiveOptionByText(e);switch(e.key){case`Tab`:this.close();break;case`Enter`:case` `:e.preventDefault(),this._selectByKeyboard();break;case`ArrowDown`:case`ArrowUp`:e.preventDefault(),this._setNextActiveOption(e);break;case`Home`:case`PageUp`:e.preventDefault(),this._setNextActiveOption(e,0);break;case`End`:case`PageDown`:e.preventDefault(),this._setNextActiveOption(e,this.options.length-1)}}}_checkForLetterSelection(e){return e.key===`Backspace`||e.key===`Clear`||e.key.length===1&&e.key!==` `&&!e.altKey&&!e.ctrlKey&&!e.metaKey}_setNextActiveOptionByText(e){typeof this._searchTimeout==typeof setTimeout&&clearTimeout(this._searchTimeout),this._searchTimeout=setTimeout(()=>this._searchString=``,1e3),this._searchString+=e.key;let t=this._activeItemIndex+1,n=this.options,r=[...n.slice(t),...n.slice(0,t)],i=r.find(e=>e.textContent?.toLowerCase().indexOf(this._searchString.toLowerCase())===0);if(i)this._setNextActiveOption(e,n.indexOf(i));else if(this._searchString.length>1&&RegExp(`^${this._searchString.charAt(0)}*$`).test(this._searchString)){let t=r.find(e=>e.textContent?.toLowerCase().indexOf(this._searchString[0].toLowerCase())===0);t&&this._setNextActiveOption(e,n.indexOf(t))}else clearTimeout(this._searchTimeout),this._searchString=``}_selectByKeyboard(){let e=this.options[this._activeItemIndex];e&&!e.disabled&&(this.multiple?e.selectViaUserInteraction(!e.selected):(e.selected||e.selectViaUserInteraction(!0),this.close()))}_setNextActiveOption(e,t){let n=this.options,r=t??x(e,this._activeItemIndex,n.length),i=n[this._activeItemIndex],a=n[r];this._activeItemIndex=r,this._setActiveElement(a,i),a.disabled||(this.multiple?e.shiftKey&&a.selectViaUserInteraction(!a.selected):a.selectViaUserInteraction(!0))}_setActiveElement(e,t=null){e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`}),e.setActive(!0),t&&t!==e&&t.setActive(!1)}_onFocusIn(e){let t=e.target;if(t?.localName!==`sbb-option`)return;let n=this.options,r=t,i=n.indexOf(r);i!==-1&&(this._activeItemIndex=i,n.forEach(e=>e.setActive(!1)))}_resetActiveElement(){let e=this.options[this._activeItemIndex];e&&e.setActive(!1),this._activeItemIndex=-1}_updateOptionsFromValue(){let e=Array.isArray(this.value)?this.value:[this.value],t=[];for(let n of this.options)n.selected=e.some(e=>this.compareWith(e,n.value)),n.selected&&t.push(n);if(this._updateDisplayValue(),!Array.isArray(this.value)){let e=this.value;this._activeItemIndex=this.options.findIndex(t=>this.compareWith(t.value,e))}}_updateValueFromOptions(){let e=this._getSelected();if(Array.isArray(e)){if(e&&e.length>0){let t=[];for(let n of e)t.push(n.value);this._value=t}}else e&&(this._activeItemIndex=this.options.findIndex(t=>t===e),this._value=e.value);this._updateDisplayValue()}_handleSlotchange(){this.options.forEach(e=>e.tabIndex=-1),this._updateValueOptionState()}_updateValueOptionState(){this._isValueManuallyAssigned?this._updateOptionsFromValue():this._updateValueFromOptions()}_getSelected(){return this.multiple?this.options.filter(e=>e.selected):this.options.find(e=>e.selected)??null}_toggleOpening(){if(!(this.disabled||this.formDisabled||this.readOnly))switch(this.state){case`opening`:case`opened`:this.close();break;case`closing`:case`closed`:this.focus(),this.open()}}render(){return r`
3
+ `;let L=(()=>{let u=y(l(m(v(_(f(h)))))),P=[],L,R=[],z=[],B,V=[],H=[],U,W=[],G=[],K,q=[],J=[],Y,X,Z=[],Q=[];return class extends u{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(u[Symbol.metadata]??null):void 0;L=[b(),s()],B=[b(),C((e,t)=>e._onMultipleChanged(t)),s({reflect:!0,type:Boolean})],U=[s({attribute:!1})],K=[b(),C((e,t)=>e._closeOnDisabledReadonlyChanged(t)),s({reflect:!0,type:Boolean}),S((e,t)=>t||e.isDisabledExternally())],Y=[s()],X=[s({reflect:!0})],e(this,null,L,{kind:`accessor`,name:`placeholder`,static:!1,private:!1,access:{has:e=>`placeholder`in e,get:e=>e.placeholder,set:(e,t)=>{e.placeholder=t}},metadata:t},R,z),e(this,null,B,{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},V,H),e(this,null,U,{kind:`accessor`,name:`compareWith`,static:!1,private:!1,access:{has:e=>`compareWith`in e,get:e=>e.compareWith,set:(e,t)=>{e.compareWith=t}},metadata:t},W,G),e(this,null,K,{kind:`accessor`,name:`disabled`,static:!1,private:!1,access:{has:e=>`disabled`in e,get:e=>e.disabled,set:(e,t)=>{e.disabled=t}},metadata:t},q,J),e(this,null,Y,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,P),e(this,null,X,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:t},Z,Q),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-select`}static{this.styles=[k,A,N,o(I)]}static{this.elementDependencies=[F]}static{this.events={change:`change`,input:`input`,displayvaluechange:`displayvaluechange`,beforeopen:`beforeopen`,open:`open`,beforeclose:`beforeclose`,close:`close`}}static get observedAttributes(){return super.observedAttributes.concat(`aria-label`,`aria-labelledby`,`aria-describedby`)}#e;get placeholder(){return this.#e}set placeholder(e){this.#e=e}#t;get multiple(){return this.#t}set multiple(e){this.#t=e}#n;get compareWith(){return this.#n}set compareWith(e){this.#n=e}#r;get disabled(){return this.#r}set disabled(e){this.#r=e}set value(e){this._value=e,this._isValueManuallyAssigned=!0,this._updateOptionsFromValue()}get value(){return this._value}#i;get size(){return this.#i}set size(e){this.#i=e}get type(){return this.multiple?`select-multiple`:`select-one`}get inputElement(){return this._triggerElement??null}get options(){let e=[];return this.querySelectorAll?.(`sbb-option`).forEach(t=>{customElements.upgrade(t),e.push(t)}),e}constructor(){super(),this.#e=(t(this,P),t(this,R,``)),this.#t=(t(this,z),t(this,V,!1)),this.#n=(t(this,H),t(this,W,(e,t)=>e===t)),this.#r=(t(this,G),t(this,q,!1)),this._value=(t(this,J),null),this.#i=t(this,Z,null),this._displayValue=(t(this,Q),null),this._resizeObserver=new n(this,{target:null,skipInitial:!0,callback:(()=>{let e;return()=>{clearTimeout(e),e=setTimeout(()=>{this.state!==`closed`&&this._setOverlayPosition()},10)}})()}),this._originElement=null,this._escapableOverlayController=new d(this),this._activeItemIndex=-1,this._searchString=``,this._didLoad=!1,this._isPointerDownEventOnMenu=!1,this._languageController=new p(this),this._isValueManuallyAssigned=!1,this._restoreFocusOnClose=!1,this._pointerDownListener=e=>{this._isPointerDownEventOnMenu=E(this._overlay,e)},this._closeOnBackdropClick=e=>{this._isPointerDownEventOnMenu||E(this._overlay,e)||E(this._originElement,e)||this.close()},this.addEventListener?.(`optionselectionchange`,e=>this._onOptionChanged(e)),this.addEventListener?.(`optionLabelChanged`,e=>this._onOptionLabelChanged(e)),this.addEventListener?.(`ɵoptionvaluechange`,()=>this._updateValueOptionState()),this.addEventListener?.(`ɵoptgroupslotchange`,()=>this._handleSlotchange(),{capture:!0}),this.addEventListener?.(`focusin`,e=>this._onFocusIn(e)),this.addEventListener?.(`click`,e=>{let t=e.target;t.localName===`sbb-option`?!this.multiple&&!t.disabled&&this._close(!0):this._toggleOpening()}),this.addController(new g(this,()=>this.closest(`sbb-form-field`),{negative:e=>{this.negative=e.negative,this._syncNegative()}})),this.addEventListener(`keydown`,e=>this._onKeyDown(e))}attributeChangedCallback(e,t,n){e===`aria-label`||e===`aria-labelledby`||e===`aria-describedby`?this._syncAriaLabels():super.attributeChangedCallback(e,t,n)}_syncAriaLabels(){this._triggerElement&&!i&&(j(this._triggerElement,`aria-labelledby`,this.getAttribute(`aria-labelledby`)),j(this._triggerElement,`aria-label`,this.getAttribute(`aria-label`)),j(this._triggerElement,`aria-describedby`,this.getAttribute(`aria-describedby`)),!this.getAttribute(`aria-label`)&&!this.getAttribute(`aria-labelledby`)&&this.internals.labels.length&&this._triggerElement?.setAttribute(`aria-label`,Array.from(this.internals.labels,e=>e.textContent).join(`, `)))}open(){this.state!==`opening`&&this.state!==`opened`&&this._overlay&&this.options.length!==0&&!this.disabled&&!this.formDisabled&&this.dispatchBeforeOpenEvent()&&(this.shadowRoot?.querySelector(`[popover]`)?.showPopover?.(),this.state=`opening`,this._triggerElement&&(this._triggerElement.internals.ariaExpanded=`true`),this.internals.states.add(`expanded`),this._setOverlayPosition(),this._escapableOverlayController.connect(),this._attachOpenPanelEvents(),this._isZeroAnimationDuration()&&this._handleOpening())}close(){this._close()}_close(e=!1){this.state!==`closing`&&this.state!==`closed`&&this.dispatchBeforeCloseEvent()&&(this._restoreFocusOnClose=e,this.state=`closing`,this.internals.states.delete(`expanded`),this._openPanelEventsController?.abort(),this._originElement&&this._resizeObserver.unobserve(this._originElement),this._isZeroAnimationDuration()&&this._handleClosing())}_isZeroAnimationDuration(){return O(this,`--sbb-options-panel-animation-duration`)}getDisplayValue(){return this._displayValue??``}_onOptionChanged(e){let t=e.target;t.selected?this._onOptionSelected(t):this._onOptionDeselected(t)}_onOptionLabelChanged(e){let t=e.target,n=this._getSelected();!Array.isArray(n)&&t!==n||Array.isArray(n)&&!n.includes(t)||this._updateDisplayValue()}async _updateDisplayValue(){let e=this._getSelected();this._displayValue=Array.isArray(e)?e.map(e=>e.textContent?.trim()).join(`, `)||null:e&&e?.textContent?.trim()||null,this.toggleState(`has-display-value`,!!this._displayValue),this.dispatchEvent(new Event(`displayvaluechange`,{bubbles:!0,composed:!0})),this.hydrationRequired&&await this.hydrationComplete;let t=[this._triggerElement?.querySelector?.(`span`),this.shadowRoot?.querySelector?.(`.sbb-select__trigger`)];for(let e of t)e&&(e.textContent=this._displayValue??this.placeholder)}_onMultipleChanged(e){e?this._value=this._isValueManuallyAssigned||this.value!=null?[this.value]:[]:Array.isArray(this.value)&&(this._value=this.value.length?this.value[0]:null),this._updateDisplayValue()}_closeOnDisabledReadonlyChanged(e){(this.state===`opening`||this.state===`opened`)&&e&&this.close()}firstUpdated(e){super.firstUpdated(e),this._updateValueOptionState(),this._triggerElement&&(this._syncAriaLabels(),this._triggerElement.select=this),D()||(this.startUpdate(),this._setupSelect())}focus(e){this._triggerElement?.focus(e)}blur(){this._triggerElement?.blur()}removeAttribute(e){D()&&e===`defer-hydration`&&!this._didLoad&&this.updateComplete.then(()=>this._setupSelect()),super.removeAttribute(e)}connectedCallback(){super.connectedCallback(),this._syncNegative(),this._syncAriaLabels(),this._didLoad&&(this._setupOrigin(),this._setupTrigger())}requestUpdate(e,t,n){super.requestUpdate(e,t,n),!e&&this.hasUpdated&&setTimeout(()=>this._syncAriaLabels())}willUpdate(e){super.willUpdate(e),e.has(`negative`)&&this._syncNegative(),e.has(`readOnly`)&&this._closeOnDisabledReadonlyChanged(this.readOnly)}disconnectedCallback(){this._triggerElement&&this.prepend(this._triggerElement),super.disconnectedCallback(),this._openPanelEventsController?.abort()}formResetCallback(){this.value=this.hasAttribute(`value`)?this.getAttribute(`value`):null}formStateRestoreCallback(e,t){try{let{value:t,manuallyAssigned:n}=JSON.parse(e);this._isValueManuallyAssigned=n,this._value=t,this._updateOptionsFromValue()}catch{console.warn(`Failed to restore sbb-select with state ${e}`)}}formState(){return JSON.stringify({value:this.value,manuallyAssigned:this._isValueManuallyAssigned})}_syncNegative(){this.querySelectorAll?.(`sbb-divider, sbb-option-hint`).forEach(e=>e.negative=this.negative)}shouldValidate(e){return super.shouldValidate(e)||e===`value`||e===`required`}validate(){super.validate();let e=Array.isArray(this.value)?this.value:this.value===null?[]:[this.value];this.required&&(this.options.every(t=>e.every(e=>!this.compareWith(e,t.value)))||!this._isValueManuallyAssigned&&this.value==null)?this.setValidityFlag(`valueMissing`,T[this._languageController.current]):this.removeValidityFlag(`valueMissing`)}_setupSelect(){this._setupOrigin(),this._setupTrigger(),this._didLoad=!0,this.completeUpdate()}_setupOrigin(){let e=this.closest?.(`sbb-form-field`);this._originElement&&this._resizeObserver.unobserve(this._originElement),this._originElement=e?.shadowRoot?.querySelector?.(`#overlay-anchor`)??this.parentElement,this._originElement&&(this.toggleState(`option-panel-origin-borderless`,e?.hasAttribute?.(`borderless`)),this.isOpen&&this._resizeObserver.observe(this._originElement))}_setupTrigger(){this.parentElement&&this._triggerElement&&this.parentElement.insertBefore?.(this._triggerElement,this)}_setOverlayPosition(){this._originElement&&this._overlay&&M(this._overlay,this._originElement,this._overlay,this.shadowRoot.querySelector(`.sbb-option-panel__overlay-container`),this)}_onAnimationEnd(e){e.animationName===`open`&&this.state===`opening`?this._handleOpening():e.animationName===`close`&&this.state===`closing`&&this._handleClosing()}_handleOpening(){this.state=`opened`,this._originElement&&this._resizeObserver.observe(this._originElement),this.dispatchOpenEvent()}_handleClosing(){let e=this._restoreFocusOnClose||this._isFocusWithin();this._restoreFocusOnClose=!1,this.state=`closed`,this.shadowRoot?.querySelector(`[popover]`)?.hidePopover?.(),this._triggerElement&&(this._triggerElement.internals.ariaExpanded=`false`),this._resetActiveElement(),e&&this.focus(),this._overlay&&(this._overlay.scrollTop=0),this._escapableOverlayController.disconnect(),this.dispatchCloseEvent()}_isFocusWithin(){let e=this.getRootNode().activeElement;return!!e&&(e===this._triggerElement||this.contains(e))}_onOptionSelected(e){this.multiple?this.value?Array.isArray(this.value)&&!this.value.some(t=>this.compareWith(t,e.value))&&(this._value=[...this.value,e.value]):this._value=[e.value]:this._value=e.value,this._updateOptionsFromValue(),this._dispatchInputEvents()}_onOptionDeselected(e){this.multiple&&Array.isArray(this.value)&&(this._value=this.value.filter(t=>!this.compareWith(t,e.value)),this._updateOptionsFromValue(),this._dispatchInputEvents())}_dispatchInputEvents(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_attachOpenPanelEvents(){this._openPanelEventsController=new AbortController,document.addEventListener(`scroll`,()=>this._setOverlayPosition(),{passive:!0,signal:this._openPanelEventsController.signal,capture:!0}),window.addEventListener(`resize`,()=>this._setOverlayPosition(),{passive:!0,signal:this._openPanelEventsController.signal}),window.addEventListener(`pointerdown`,e=>this._pointerDownListener(e),{signal:this._openPanelEventsController.signal}),window.addEventListener(`pointerup`,e=>this._closeOnBackdropClick(e),{signal:this._openPanelEventsController.signal})}_onKeyDown(e){this.readOnly||(this.state===`opening`||this.state===`opened`?this._openedPanelKeyboardInteraction(e):(this.state===`closed`||this.state===`closing`)&&this._closedPanelKeyboardInteraction(e))}_closedPanelKeyboardInteraction(e){if(this._checkForLetterSelection(e))return this._setNextActiveOptionByText(e);switch(e.key){case`Enter`:case` `:case`ArrowDown`:case`ArrowUp`:e.preventDefault(),this.open()}}_openedPanelKeyboardInteraction(e){if(!this.readOnly){if(this._checkForLetterSelection(e))return this._setNextActiveOptionByText(e);switch(e.key){case`Tab`:this.close();break;case`Enter`:case` `:e.preventDefault(),this._selectByKeyboard();break;case`ArrowDown`:case`ArrowUp`:e.preventDefault(),this._setNextActiveOption(e);break;case`Home`:case`PageUp`:e.preventDefault(),this._setNextActiveOption(e,0);break;case`End`:case`PageDown`:e.preventDefault(),this._setNextActiveOption(e,this.options.length-1)}}}_checkForLetterSelection(e){return e.key===`Backspace`||e.key===`Clear`||e.key.length===1&&e.key!==` `&&!e.altKey&&!e.ctrlKey&&!e.metaKey}_setNextActiveOptionByText(e){typeof this._searchTimeout==typeof setTimeout&&clearTimeout(this._searchTimeout),this._searchTimeout=setTimeout(()=>this._searchString=``,1e3),this._searchString+=e.key;let t=this._activeItemIndex+1,n=this.options,r=[...n.slice(t),...n.slice(0,t)],i=r.find(e=>e.textContent?.toLowerCase().indexOf(this._searchString.toLowerCase())===0);if(i)this._setNextActiveOption(e,n.indexOf(i));else if(this._searchString.length>1&&RegExp(`^${this._searchString.charAt(0)}*$`).test(this._searchString)){let t=r.find(e=>e.textContent?.toLowerCase().indexOf(this._searchString[0].toLowerCase())===0);t&&this._setNextActiveOption(e,n.indexOf(t))}else clearTimeout(this._searchTimeout),this._searchString=``}_selectByKeyboard(){let e=this.options[this._activeItemIndex];e&&!e.disabled&&(this.multiple?e.selectViaUserInteraction(!e.selected):(e.selected||e.selectViaUserInteraction(!0),this.close()))}_setNextActiveOption(e,t){let n=this.options,r=t??x(e,this._activeItemIndex,n.length),i=n[this._activeItemIndex],a=n[r];this._activeItemIndex=r,this._setActiveElement(a,i),a.disabled||(this.multiple?e.shiftKey&&a.selectViaUserInteraction(!a.selected):a.selectViaUserInteraction(!0))}_setActiveElement(e,t=null){e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`}),e.setActive(!0),t&&t!==e&&t.setActive(!1)}_onFocusIn(e){let t=e.target;if(t?.localName!==`sbb-option`)return;let n=this.options,r=t,i=n.indexOf(r);i!==-1&&(this._activeItemIndex=i,n.forEach(e=>e.setActive(!1)))}_resetActiveElement(){let e=this.options[this._activeItemIndex];e&&e.setActive(!1),this._activeItemIndex=-1}_updateOptionsFromValue(){let e=Array.isArray(this.value)?this.value:[this.value],t=[];for(let n of this.options)n.selected=e.some(e=>this.compareWith(e,n.value)),n.selected&&t.push(n);if(this._updateDisplayValue(),!Array.isArray(this.value)){let e=this.value;this._activeItemIndex=this.options.findIndex(t=>this.compareWith(t.value,e))}}_updateValueFromOptions(){let e=this._getSelected();if(Array.isArray(e)){if(e&&e.length>0){let t=[];for(let n of e)t.push(n.value);this._value=t}}else e&&(this._activeItemIndex=this.options.findIndex(t=>t===e),this._value=e.value);this._updateDisplayValue()}_handleSlotchange(){this.options.forEach(e=>e.tabIndex=-1),this._updateValueOptionState()}_updateValueOptionState(){this._isValueManuallyAssigned?this._updateOptionsFromValue():this._updateValueFromOptions()}_getSelected(){return this.multiple?this.options.filter(e=>e.selected):this.options.find(e=>e.selected)??null}_toggleOpening(){if(!(this.disabled||this.formDisabled||this.readOnly))switch(this.state){case`opening`:case`opened`:this.close();break;case`closing`:case`closed`:this.focus(),this.open()}}render(){return r`
4
4
  <!-- This element is visually hidden and will be appended to the light DOM to allow screen
5
5
  readers to work properly -->
6
6
  <sbb-select-trigger
package/slider.pure.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,nothing as r,unsafeCSS as i}from"lit";import{property as a}from"lit/decorators.js";import{ref as o}from"lit/directives/ref.js";import{SbbDisabledMixin as s,SbbElement as c,SbbFormAssociatedMixin as l,SbbReadonlyMixin as u,forceType as d}from"./core.js";import{SbbIconElement as f}from"./icon.pure.js";var p=`:host{--_sbb-slider-value-fraction:0;min-width:var(--sbb-slider-min-width);width:min(var(--sbb-slider-width), 100%);display:inline-block;outline:none!important}:host(:disabled){--sbb-slider-icon-color:light-dark(var(--sbb-color-graphite),var(--sbb-color-smoke));--sbb-slider-knob-border-color:var(--sbb-border-color-5);--sbb-slider-knob-border-size:var(--sbb-border-width-2x);--sbb-slider-knob-border-style:dashed}:host([readonly]){--sbb-slider-icon-color:var(--sbb-color-5);--sbb-slider-knob-border-color:var(--sbb-slider-selected-line-disabled-color)}:host(:disabled),:host([readonly]){--sbb-slider-line-color:var(--sbb-slider-line-disabled-color);--sbb-slider-selected-line-color:var(--sbb-slider-selected-line-disabled-color)}@media (forced-colors:active){:host(:disabled),:host([readonly]){--sbb-slider-icon-color:GrayText;--sbb-slider-selected-line-disabled-color:GrayText;--sbb-slider-line-disabled-color:GrayText}}.sbb-slider__height-container{flex-direction:column;display:flex}.sbb-slider__height-container:before{content:"​";user-select:none;width:0;height:0}.sbb-slider__wrapper{gap:var(--sbb-slider-gap);padding-block:var(--sbb-slider-padding-block);color:var(--sbb-slider-icon-color);display:flex}.sbb-slider__container{min-height:var(--sbb-size-icon-ui-small);flex-grow:1;position:relative}.sbb-slider__range-input{opacity:0;width:100%;margin:0;position:absolute;inset:0}.sbb-slider__line{height:var(--sbb-slider-line-height);background-color:var(--sbb-slider-line-color);border-radius:var(--sbb-slider-line-height);pointer-events:none;width:100%;position:absolute;top:50%;overflow:hidden;translate:0 -50%}.sbb-slider__selected-line{background-color:var(--sbb-slider-selected-line-color);height:100%;width:calc(var(--_sbb-slider-value-fraction) * 100%);position:relative}.sbb-slider__knob{box-shadow:var(--sbb-box-shadow-level-5-hard);width:var(--sbb-slider-knob-size);height:var(--sbb-slider-knob-size);top:50%;transition-property:width,height;transition-duration:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-1x));background-color:var(--sbb-slider-knob-color);border:var(--sbb-slider-knob-border-size) var(--sbb-slider-knob-border-style) var(--sbb-slider-knob-border-color);pointer-events:none;border-radius:50%;transition-timing-function:ease-in;position:absolute;inset-inline-start:calc(var(--_sbb-slider-value-fraction) * 100% - var(--sbb-slider-knob-size) * var(--_sbb-slider-value-fraction));translate:0 -50%}:host(:focus-visible) .sbb-slider__knob{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-slider-knob-size:var(--sbb-slider-knob-size-active)}:host(:not(:is(:disabled,[readonly]))) .sbb-slider__range-input:active~.sbb-slider__knob{--sbb-slider-knob-size:var(--sbb-slider-knob-size-active)}
2
- `;let m=(()=>{let m=s(u(l(c))),h=[],g,_,v,y,b,x=[],S=[],C,w=[],T=[];return class extends m{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(m[Symbol.metadata]??null):void 0;g=[a()],_=[a({attribute:`value-as-number`,type:Number})],v=[a()],y=[a()],b=[d(),a({attribute:`start-icon`})],C=[d(),a({attribute:`end-icon`})],e(this,null,g,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,h),e(this,null,_,{kind:`setter`,name:`valueAsNumber`,static:!1,private:!1,access:{has:e=>`valueAsNumber`in e,set:(e,t)=>{e.valueAsNumber=t}},metadata:t},null,h),e(this,null,v,{kind:`setter`,name:`min`,static:!1,private:!1,access:{has:e=>`min`in e,set:(e,t)=>{e.min=t}},metadata:t},null,h),e(this,null,y,{kind:`setter`,name:`max`,static:!1,private:!1,access:{has:e=>`max`in e,set:(e,t)=>{e.max=t}},metadata:t},null,h),e(this,null,b,{kind:`accessor`,name:`startIcon`,static:!1,private:!1,access:{has:e=>`startIcon`in e,get:e=>e.startIcon,set:(e,t)=>{e.startIcon=t}},metadata:t},x,S),e(this,null,C,{kind:`accessor`,name:`endIcon`,static:!1,private:!1,access:{has:e=>`endIcon`in e,get:e=>e.endIcon,set:(e,t)=>{e.endIcon=t}},metadata:t},w,T),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-slider`}static{this.elementDependencies=[f]}static{this.role=`slider`}static{this.styles=[i(p)]}static{this.events={didChange:`didChange`}}set value(e){this._value=this._isValidNumber(e)?this._boundBetweenMinMax(e):null,this.internals.ariaValueNow=this.value}get value(){return this._value??this._defaultValue()}set valueAsNumber(e){this.value=e?.toString()??null}get valueAsNumber(){return Number(this.value)}set min(e){if(!this._isValidNumber(e))return;this._min=e,this.internals.ariaValueMin=this.min;let t=this._boundBetweenMinMax(this.value);this.value!==t&&(this.value=t)}get min(){return this._min}set max(e){if(!this._isValidNumber(e))return;this._max=e,this.internals.ariaValueMax=this.max;let t=this._boundBetweenMinMax(this.value);this.value!==t&&(this.value=t)}get max(){return this._max}#e;get startIcon(){return this.#e}set startIcon(e){this.#e=e}#t;get endIcon(){return this.#t}set endIcon(e){this.#t=e}get type(){return`range`}constructor(){super(),this._value=(t(this,h),null),this._min=`0`,this._max=`100`,this.#e=t(this,x,``),this.#t=(t(this,S),t(this,w,``)),this._rangeInput=t(this,T),this.addEventListener?.(`keydown`,e=>this._handleKeydown(e))}connectedCallback(){super.connectedCallback(),this.tabIndex=0}willUpdate(e){super.willUpdate(e),e.has(`readOnly`)&&(this.internals.ariaReadOnly=(!!this.readOnly).toString()),this.style?.setProperty(`--_sbb-slider-value-fraction`,this._valueFraction().toString())}formResetCallback(){this.value=this.getAttribute(`value`)??this._defaultValue()}formStateRestoreCallback(e,t){this.value=e}_defaultValue(){return(+this.min+(+this.max-this.min)/2).toString()}_isValidNumber(e){return e!=null&&!isNaN(Number(e))}_boundBetweenMinMax(e){return Math.max(+this.min,Math.min(+this.max,+e)).toString()}_valueFraction(){let e=this.valueAsNumber,t=+this.min,n=+this.max,r=(e-t)/(n-t);return isNaN(r)?0:Math.max(0,Math.min(1,r))}async _handleKeydown(e){if(e.key!==`Tab`&&e.preventDefault(),!this.readOnly){if(e.key===`Home`)this._rangeInput.value=this.min;else if(e.key===`End`)this._rangeInput.value=this.max;else if(e.key===`ArrowLeft`||e.key===`ArrowDown`)this._rangeInput.stepDown();else if(e.key===`ArrowRight`||e.key===`ArrowUp`)this._rangeInput.stepUp();else if(e.key===`PageDown`)this._rangeInput.stepDown((+this.max-this.min)/10);else if(e.key===`PageUp`)this._rangeInput.stepUp((+this.max-this.min)/10);else return;this._rangeInput.dispatchEvent(new InputEvent(`input`,{bubbles:!0,cancelable:!0,composed:!0})),this._rangeInput.dispatchEvent(new Event(`change`,{bubbles:!0}))}}_dispatchChangeEvent(){this.dispatchEvent(new Event(`change`,{bubbles:!0})),this.dispatchEvent(new Event(`didChange`,{bubbles:!0}))}render(){return n`
2
+ `;let m=(()=>{let m=s(u(l(c))),h=[],g,_,v,y,b,x=[],S=[],C,w=[],T=[];return class extends m{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(m[Symbol.metadata]??null):void 0;g=[a()],_=[a({attribute:`value-as-number`,type:Number})],v=[a()],y=[a()],b=[d(),a({attribute:`start-icon`})],C=[d(),a({attribute:`end-icon`})],e(this,null,g,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,h),e(this,null,_,{kind:`setter`,name:`valueAsNumber`,static:!1,private:!1,access:{has:e=>`valueAsNumber`in e,set:(e,t)=>{e.valueAsNumber=t}},metadata:t},null,h),e(this,null,v,{kind:`setter`,name:`min`,static:!1,private:!1,access:{has:e=>`min`in e,set:(e,t)=>{e.min=t}},metadata:t},null,h),e(this,null,y,{kind:`setter`,name:`max`,static:!1,private:!1,access:{has:e=>`max`in e,set:(e,t)=>{e.max=t}},metadata:t},null,h),e(this,null,b,{kind:`accessor`,name:`startIcon`,static:!1,private:!1,access:{has:e=>`startIcon`in e,get:e=>e.startIcon,set:(e,t)=>{e.startIcon=t}},metadata:t},x,S),e(this,null,C,{kind:`accessor`,name:`endIcon`,static:!1,private:!1,access:{has:e=>`endIcon`in e,get:e=>e.endIcon,set:(e,t)=>{e.endIcon=t}},metadata:t},w,T),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-slider`}static{this.elementDependencies=[f]}static{this.role=`slider`}static{this.styles=[i(p)]}static{this.events={didChange:`didChange`}}set value(e){this._value=this._isValidNumber(e)?this._boundBetweenMinMax(e):null,this.internals.ariaValueNow=this.value}get value(){return this._value??this._defaultValue()}set valueAsNumber(e){this.value=e?.toString()??null}get valueAsNumber(){return Number(this.value)}set min(e){if(!this._isValidNumber(e))return;this._min=e,this.internals.ariaValueMin=this.min;let t=this._boundBetweenMinMax(this.value);this.value!==t&&(this.value=t)}get min(){return this._min}set max(e){if(!this._isValidNumber(e))return;this._max=e,this.internals.ariaValueMax=this.max;let t=this._boundBetweenMinMax(this.value);this.value!==t&&(this.value=t)}get max(){return this._max}#e;get startIcon(){return this.#e}set startIcon(e){this.#e=e}#t;get endIcon(){return this.#t}set endIcon(e){this.#t=e}get type(){return`range`}constructor(){super(),this._value=(t(this,h),null),this._min=`0`,this._max=`100`,this.#e=t(this,x,``),this.#t=(t(this,S),t(this,w,``)),this._rangeInput=t(this,T),this.addEventListener?.(`keydown`,e=>this._handleKeydown(e))}connectedCallback(){super.connectedCallback(),this.tabIndex=0}willUpdate(e){super.willUpdate(e),e.has(`readOnly`)&&(this.internals.ariaReadOnly=(!!this.readOnly).toString()),this.style?.setProperty(`--_sbb-slider-value-fraction`,this._valueFraction().toString())}formResetCallback(){this.value=this.getAttribute(`value`)??this._defaultValue()}formStateRestoreCallback(e,t){this.value=e}_defaultValue(){return(+this.min+(+this.max-this.min)/2).toString()}_isValidNumber(e){return e!=null&&!isNaN(Number(e))}_boundBetweenMinMax(e){return Math.max(+this.min,Math.min(+this.max,+e)).toString()}_valueFraction(){let e=this.valueAsNumber,t=+this.min,n=+this.max,r=(e-t)/(n-t);return isNaN(r)?0:Math.max(0,Math.min(1,r))}async _handleKeydown(e){if(e.key!==`Tab`&&e.preventDefault(),!this.readOnly&&this._rangeInput){if(e.key===`Home`)this._rangeInput.value=this.min;else if(e.key===`End`)this._rangeInput.value=this.max;else if(e.key===`ArrowLeft`||e.key===`ArrowDown`)this._rangeInput.stepDown();else if(e.key===`ArrowRight`||e.key===`ArrowUp`)this._rangeInput.stepUp();else if(e.key===`PageDown`)this._rangeInput.stepDown((+this.max-this.min)/10);else if(e.key===`PageUp`)this._rangeInput.stepUp((+this.max-this.min)/10);else return;this._rangeInput.dispatchEvent(new InputEvent(`input`,{bubbles:!0,cancelable:!0,composed:!0})),this._rangeInput.dispatchEvent(new Event(`change`,{bubbles:!0}))}}_dispatchChangeEvent(){this.dispatchEvent(new Event(`change`,{bubbles:!0})),this.dispatchEvent(new Event(`didChange`,{bubbles:!0}))}render(){return n`
3
3
  <div class="sbb-slider__height-container">
4
4
  <div class="sbb-slider__wrapper">
5
5
  <slot name="prefix">
package/toggle.pure.js CHANGED
@@ -5,4 +5,4 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{ResizeControl
5
5
  <slot></slot>
6
6
  </span>
7
7
  `}}})();var h=`:host{--_sbb-toggle-min-width:calc(var(--sbb-toggle-padding-inline) * 4 + var(--sbb-size-icon-ui-small));--sbb-toggle-animation-duration:var(--sbb-disable-animation-duration,var(--sbb-animation-duration-6x));grid-template-columns:var(--sbb-toggle-grid-template-columns);height:var(--sbb-toggle-height);width:var(--sbb-toggle-width,fit-content);min-width:var(--_sbb-toggle-min-width);border-radius:var(--sbb-toggle-border-radius);max-width:100%;font-size:var(--sbb-toggle-font-size);letter-spacing:var(--sbb-letter-spacing-text);user-select:none;-webkit-tap-highlight-color:transparent;line-height:var(--sbb-typo-line-height-text);grid-template-areas:"start end";align-items:center;display:grid}:host:before{content:"";margin-inline:var(--sbb-toggle-option-left,0) var(--sbb-toggle-option-right,0);background-color:var(--sbb-toggle-selected-option-background-color);border-radius:var(--sbb-toggle-border-radius);border:var(--sbb-toggle-selected-option-border-width) var(--sbb-toggle-selected-option-border-style) var(--sbb-toggle-selected-option-border-color);max-width:100%;height:100%;transition-duration:var(--sbb-toggle-animation-duration);grid-area:start/start/end/end;transition-property:margin-inline-start,margin-inline-end;transition-timing-function:ease;display:block}:host:after{content:"";background:var(--sbb-toggle-background-color);margin-inline:var(--sbb-toggle-background-inset);height:calc(100% - 2 * var(--sbb-toggle-background-inset));border-radius:var(--sbb-toggle-border-radius);order:-1;grid-area:start/start/end/end}@media (forced-colors:active){:host:after{border:var(--sbb-border-width-1x) solid CanvasText}}:host([even]){--sbb-toggle-width:100%;--sbb-toggle-grid-template-columns:50% 50%}:host(:disabled){--sbb-toggle-selected-option-border-color:light-dark(var(--sbb-color-graphite),var(--sbb-color-smoke));--sbb-toggle-selected-option-border-style:dashed}@media (forced-colors:active){:host(:disabled){--sbb-toggle-selected-option-border-style:solid;--sbb-toggle-selected-option-border-color:GrayText}}:host([size=s]){--sbb-toggle-padding-inline:var(--sbb-toggle-padding-inline-s);--sbb-toggle-height:var(--sbb-toggle-height-s)}:host([size=m]){--sbb-toggle-padding-inline:var(--sbb-toggle-padding-inline-m);--sbb-toggle-height:var(--sbb-toggle-height-m)}:host(:is(:not(:is(:state(initialized),[state--initialized])),:is(:state(disable-animation-on-resizing),[state--disable-animation-on-resizing]))){--sbb-disable-animation-duration:0s}::slotted(sbb-toggle-option:first-of-type){grid-area:start}::slotted(sbb-toggle-option:last-of-type){grid-area:end}
8
- `;let g=(()=>{let n=s(l(c)),f=[],p,m=[],g=[],_,v=[],y=[],b;return class extends n{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(n[Symbol.metadata]??null):void 0;p=[u(),o({reflect:!0,type:Boolean})],_=[o({reflect:!0})],b=[o()],e(this,null,p,{kind:`accessor`,name:`even`,static:!1,private:!1,access:{has:e=>`even`in e,get:e=>e.even,set:(e,t)=>{e.even=t}},metadata:t},m,g),e(this,null,_,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:t},v,y),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,f),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-toggle`}static{this.role=`radiogroup`}static{this.styles=[a(h)]}static{this.events={change:`change`}}#e;get even(){return this.#e}set even(e){this.#e=e}#t;get size(){return this.#t}set size(e){this.#t=e}set value(e){i||!this.hasUpdated?this._fallbackValue=e:this._valueChanged(e)}get value(){return i?this._fallbackValue??null:this.options.find(e=>e.checked)?.value??this.options[0]?.value??null}get options(){return Array.from(this.querySelectorAll?.(`sbb-toggle-option`)??[])}constructor(){super(),this.#e=(t(this,f),t(this,m,!1)),this.#t=(t(this,g),t(this,v,null)),this._fallbackValue=(t(this,y),null),this.addEventListener?.(`input`,()=>this._handleInput(),{passive:!0}),this.addEventListener?.(`keydown`,e=>this._handleKeyDown(e))}willUpdate(e){super.willUpdate(e),(e.has(`disabled`)||e.has(`formDisabled`))&&this._updateDisabled(),this.hasUpdated||this._valueChanged(this._fallbackValue)}statusChanged(){this.updateFormValue(),this.updatePillPosition()}formResetCallback(){this.value=this.hasAttribute(`value`)?this.getAttribute(`value`):null}formStateRestoreCallback(e,t){typeof e==`string`||e==null?this.value=e??null:e instanceof FormData&&this._readFormData(e).then(e=>{this.value=e})}async _readFormData(e){let t=e.get(this.name);return t instanceof Blob?JSON.parse(await t.text()):t}updatePillPosition(e=!1){let t=this.options;if(t.length<2||t.every(e=>!e.checked)||t.every(e=>!e.clientWidth))return;this.toggleState(`disable-animation-on-resizing`,e);let n=t[0],r=n.checked,i=r?`0px`:`${n.clientWidth}px`,a=r?`${this.clientWidth-n.clientWidth}px`:`0px`;(a!==`0px`||i!==`0px`)&&(this.style?.setProperty(`--sbb-toggle-option-left`,i),this.style?.setProperty(`--sbb-toggle-option-right`,a),this.offsetWidth,this.internals.states.add(`initialized`))}_updateToggle(){this._valueChanged(this.value),this._updateDisabled()}_valueChanged(e){let t=this.options,n=t.find(t=>e===t.value)??t.find(e=>e.checked)??t[0];n&&(n.checked=!0,this.statusChanged())}_updateDisabled(){for(let e of this.options)e.disabled=this.disabled||this.formDisabled}_handleInput(){this.statusChanged(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_handleKeyDown(e){if(!this.options.filter(e=>!e.disabled&&d.isVisible(e))||e.target!==this&&e.target.parentElement!==this)return;let t=this.options,n=this.matches(`:dir(rtl)`),r=t.findIndex(e=>e.checked)??t[0],i=t.slice(r+1).concat(t.slice(0,r)).filter(e=>!e.disabled&&d.isVisible(e));(n?e.key===`ArrowLeft`:e.key===` `||e.key===`ArrowRight`)?(this._selectAndFocusOption(i[0]),e.preventDefault()):(n?e.key===` `||e.key===`ArrowRight`:e.key===`ArrowLeft`)&&(this._selectAndFocusOption(i.at(-1)),e.preventDefault())}_selectAndFocusOption(e){!e||e.disabled||e.checked||(e.checked=!0,e.focus(),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})))}render(){return r` <slot @slotchange=${this._updateToggle}></slot> `}}})();export{g as SbbToggleElement,m as SbbToggleOptionElement};
8
+ `;let g=(()=>{let n=s(l(c)),f=[],p,m=[],g=[],_,v=[],y=[],b;return class extends n{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(n[Symbol.metadata]??null):void 0;p=[u(),o({reflect:!0,type:Boolean})],_=[o({reflect:!0})],b=[o()],e(this,null,p,{kind:`accessor`,name:`even`,static:!1,private:!1,access:{has:e=>`even`in e,get:e=>e.even,set:(e,t)=>{e.even=t}},metadata:t},m,g),e(this,null,_,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:t},v,y),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,f),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-toggle`}static{this.role=`radiogroup`}static{this.styles=[a(h)]}static{this.events={change:`change`}}#e;get even(){return this.#e}set even(e){this.#e=e}#t;get size(){return this.#t}set size(e){this.#t=e}set value(e){i||!this.hasUpdated?this._fallbackValue=e:this._valueChanged(e)}get value(){return i?this._fallbackValue??null:this.options.find(e=>e.checked)?.value??this.options[0]?.value??null}get options(){return Array.from(this.querySelectorAll?.(`sbb-toggle-option`)??[])}constructor(){super(),this.#e=(t(this,f),t(this,m,!1)),this.#t=(t(this,g),t(this,v,null)),this._fallbackValue=(t(this,y),null),this.addEventListener?.(`input`,()=>this._handleInput(),{passive:!0}),this.addEventListener?.(`keydown`,e=>this._handleKeyDown(e))}focus(e){if(this.disabled||this.formDisabled)return;let t=this.options.filter(e=>!e.disabled);(t.find(e=>e.checked)??t[0])?.focus(e)}willUpdate(e){super.willUpdate(e),(e.has(`disabled`)||e.has(`formDisabled`))&&this._updateDisabled(),this.hasUpdated||this._valueChanged(this._fallbackValue)}statusChanged(){this.updateFormValue(),this.updatePillPosition()}formResetCallback(){this.value=this.hasAttribute(`value`)?this.getAttribute(`value`):null}formStateRestoreCallback(e,t){typeof e==`string`||e==null?this.value=e??null:e instanceof FormData&&this._readFormData(e).then(e=>{this.value=e})}async _readFormData(e){let t=e.get(this.name);return t instanceof Blob?JSON.parse(await t.text()):t}updatePillPosition(e=!1){let t=this.options;if(t.length<2||t.every(e=>!e.checked)||t.every(e=>!e.clientWidth))return;this.toggleState(`disable-animation-on-resizing`,e);let n=t[0],r=n.checked,i=r?`0px`:`${n.clientWidth}px`,a=r?`${this.clientWidth-n.clientWidth}px`:`0px`;(a!==`0px`||i!==`0px`)&&(this.style?.setProperty(`--sbb-toggle-option-left`,i),this.style?.setProperty(`--sbb-toggle-option-right`,a),this.offsetWidth,this.internals.states.add(`initialized`))}_updateToggle(){this._valueChanged(this.value),this._updateDisabled()}_valueChanged(e){let t=this.options,n=t.find(t=>e===t.value)??t.find(e=>e.checked)??t[0];n&&(n.checked=!0,this.statusChanged())}_updateDisabled(){for(let e of this.options)e.disabled=this.disabled||this.formDisabled}_handleInput(){this.statusChanged(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}_handleKeyDown(e){if(!this.options.filter(e=>!e.disabled&&d.isVisible(e))||e.target!==this&&e.target.parentElement!==this)return;let t=this.options,n=this.matches(`:dir(rtl)`),r=t.findIndex(e=>e.checked)??t[0],i=t.slice(r+1).concat(t.slice(0,r)).filter(e=>!e.disabled&&d.isVisible(e));(n?e.key===`ArrowLeft`:e.key===` `||e.key===`ArrowRight`)?(this._selectAndFocusOption(i[0]),e.preventDefault()):(n?e.key===` `||e.key===`ArrowRight`:e.key===`ArrowLeft`)&&(this._selectAndFocusOption(i.at(-1)),e.preventDefault())}_selectAndFocusOption(e){!e||e.disabled||e.checked||(e.checked=!0,e.focus(),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0})))}render(){return r` <slot @slotchange=${this._updateToggle}></slot> `}}})();export{g as SbbToggleElement,m as SbbToggleOptionElement};