scb-wc-test 0.1.330 → 0.1.331

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.
@@ -1,57 +1,57 @@
1
- import{a as j,n as v,i as q,x as w,t as H}from"../../vendor/vendor.js";import"./scb-calendar-event.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-dialog/scb-dialog.js";import"../scb-list/scb-list.js";import"../../vendor/vendor-material.js";import"../../vendor/preload-helper.js";import"../scb-button/scb-button.js";import"../scb-textfield/scb-textfield.js";import"../scb-datepicker/scb-datepicker.js";import"../scb-divider/scb-divider.js";import"../scb-checkbox/scb-checkbox.js";import"../scb-checkbox/scb-checkbox-group.js";import"../scb-radio-button/scb-radio-button.js";import"../scb-radio-button/scb-radio-group.js";import"../scb-switch/scb-switch.js";import"../scb-chip/scb-chip.js";import"../scb-list/scb-list-item.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(s,a,i){try{customElements.get(s)||e(s,a,i)}catch(l){var n=String(l||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var W=Object.defineProperty,R=Object.getOwnPropertyDescriptor,Y=t=>{throw TypeError(t)},f=(t,e,s,a)=>{for(var i=a>1?void 0:a?R(e,s):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(i=(a?l(e,s,i):l(i))||i);return a&&i&&W(e,s,i),i},z=(t,e,s)=>e.has(t)||Y("Cannot "+s),K=(t,e,s)=>e.has(t)?Y("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),I=(t,e,s)=>(z(t,e,"access private method"),s),A,J;let y=class extends q{constructor(){super(...arguments),K(this,A),this._lastActiveDay=null,this.lang="sv",this.disableWeekend=!1,this.publicHolidays=!0,this.displayYear=new Date().getFullYear(),this.displayMonth=new Date().getMonth()+1,this.selectedDate="",this.eventsJson=void 0,this._eventsFromJson=null,this._eventsJsonLast=void 0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._mutationObserver=null,this._syncingDisplay=!1,this._onCalendarKeyDown=t=>{const s=Array.from(this.shadowRoot?.querySelectorAll(".calendar-day.has-event")??[]),a=this.shadowRoot?.activeElement,i=a&&s.includes(a)?a:document.activeElement,n=s.indexOf(i);if(n===-1)return;let l=n;const c=this.disableWeekend?5:7;switch(t.key){case"ArrowRight":l=n+1<s.length?n+1:n;break;case"ArrowLeft":l=n-1>=0?n-1:n;break;case"ArrowDown":l=n+c<s.length?n+c:n;break;case"ArrowUp":l=n-c>=0?n-c:n;break;default:return}l!==n&&(t.preventDefault(),s[l].focus())},this._onEventChanged=()=>{this.requestUpdate()},this._today=new Date,this._current=new Date,this._popupEvent=null,this._handleDialogClose=()=>{this._popupEvent=null,this.requestUpdate(),this._restoreDayFocus()},this._restoreDayFocus=()=>{this._lastActiveDay&&setTimeout(()=>{this._lastActiveDay?.focus(),this._lastActiveDay=null},0)},this._easterDateCalculated={}}get value(){return this.selectedDate}set value(t){const e=(t??"")+"";e!==this.selectedDate&&(this.selectedDate=e)}static get observedAttributes(){return[...super.observedAttributes??[],"value"]}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),t==="value"&&(this.value=s??"")}connectedCallback(){super.connectedCallback(),I(this,A,J).call(this);const t=Number(this.displayYear),e=Number(this.displayMonth);!Number.isNaN(t)&&!Number.isNaN(e)&&e>=1&&e<=12&&(this._current=new Date(t,e-1,1)),this._syncDisplayFromCurrent(!1),this.addEventListener("change",this._onEventChanged),this._mutationObserver=new MutationObserver(()=>{this.requestUpdate()}),this._mutationObserver.observe(this,{childList:!0}),this.addEventListener("keydown",this._onCalendarKeyDown)}disconnectedCallback(){this.removeEventListener("change",this._onEventChanged),super.disconnectedCallback(),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),this.removeEventListener("keydown",this._onCalendarKeyDown)}mapSpacingToken(t){if(!t)return;const e=String(t).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}updated(t){if(super.updated?.(t),t.has("eventsJson")&&(this._eventsJsonLast=void 0,this._eventsFromJson=null),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&I(this,A,J).call(this),!this._syncingDisplay&&(t.has("displayYear")||t.has("displayMonth"))){const e=Number(this.displayYear),s=Number(this.displayMonth);if(!Number.isNaN(e)&&!Number.isNaN(s)&&s>=1&&s<=12){const a=this._current.getFullYear(),i=this._current.getMonth()+1;(a!==e||i!==s)&&(this._current=new Date(e,s-1,1),this._dispatchMonthChange(e,s),this.requestUpdate())}}}_ensureEventsFromJson(){const t=(this.eventsJson??"").trim();if(!t){this._eventsFromJson=null,this._eventsJsonLast=t;return}if(!(this._eventsJsonLast===t&&this._eventsFromJson!==null)){this._eventsJsonLast=t;try{const e=JSON.parse(t);Array.isArray(e)?this._eventsFromJson=e:this._eventsFromJson=[]}catch{this._eventsFromJson=[]}}}_getEventInputs(){return Array.isArray(this.events)?this.events:(this._ensureEventsFromJson(),this._eventsFromJson!==null?this._eventsFromJson:null)}_normalizeEventInput(t){const e=t.title??"",s=t.description??"",a=t.href??"",i=t.startDate??t["start-date"]??t.start??t.date??"",n=t.endDate??t["end-date"]??t.end??"";return{title:e+"",description:s?s+"":void 0,href:a?a+"":void 0,start:i?i+"":void 0,end:n?n+"":void 0}}_buildEventMapFromInputs(t){const e=new Map;for(const s of t){const a=this._normalizeEventInput(s),i=a.start||"",n=a.end||"";if(!(!i||!a.title))if(i&&n){const l=new Date(i),c=new Date(n);for(let p=new Date(l);p<=c;p.setDate(p.getDate()+1)){const T=p.toISOString().split("T")[0],E=e.get(T)||[];E.push({title:a.title,description:a.description,href:a.href,start:i,end:n}),e.set(T,E)}}else{const l=i.split("T")[0],c=e.get(l)||[];c.push({title:a.title,description:a.description,href:a.href,start:i}),e.set(l,c)}}return e}_buildEventMapFromChildren(){const t=Array.from(this.querySelectorAll("scb-calendar-event")),e=new Map;for(const s of t){const a=s,i=(a.startDate??a.date??"")+""||s.getAttribute("start-date")||s.getAttribute("date")||"",n=(a.endDate??"")+""||s.getAttribute("end-date")||"";if(i&&n){const l=new Date(i),c=new Date(n);for(let p=new Date(l);p<=c;p.setDate(p.getDate()+1)){const T=p.toISOString().split("T")[0],E=e.get(T)||[];E.push({title:s.title??"",description:s.description,href:a.href||s.getAttribute("href")||void 0,start:i,end:n}),e.set(T,E)}}else if(i&&s.title){const l=i.split("T")[0],c=e.get(l)||[];c.push({title:s.title,description:s.description,href:a.href||s.getAttribute("href")||void 0,start:i}),e.set(l,c)}}return e}_syncDisplayFromCurrent(t=!0){const e=this._current.getFullYear(),s=this._current.getMonth()+1;this._syncingDisplay=!0;try{this.displayYear=e,this.displayMonth=s}finally{this._syncingDisplay=!1}t&&this._dispatchMonthChange(e,s)}_dispatchMonthChange(t,e){const s={displayYear:t,displayMonth:e};this.dispatchEvent(new CustomEvent("scb-calendar-month-change",{bubbles:!0,composed:!0,detail:s})),this.dispatchEvent(new CustomEvent("scbcalendarmonthchange",{bubbles:!0,composed:!0,detail:s}))}_dispatchSelect(t){const e={selectedDate:t};this.dispatchEvent(new CustomEvent("scb-calendar-select",{bubbles:!0,composed:!0,detail:e})),this.dispatchEvent(new CustomEvent("scbcalendarselect",{bubbles:!0,composed:!0,detail:e}))}_daysInMonth(t,e){return new Date(t,e+1,0).getDate()}_firstDayOfWeek(t,e){const s=new Date(t,e,1).getDay();return s===0?6:s-1}_prevMonth(){this._current=new Date(this._current.getFullYear(),this._current.getMonth()-1,1),this.selectedDate="",this._popupEvent=null,this._syncDisplayFromCurrent(),this.requestUpdate()}_nextMonth(){this._current=new Date(this._current.getFullYear(),this._current.getMonth()+1,1),this.selectedDate="",this._popupEvent=null,this._syncDisplayFromCurrent(),this.requestUpdate()}_showEventPopup(t){this._popupEvent=t,this.selectedDate=t.date,this._dispatchSelect(t.date),this._lastActiveDay=this.shadowRoot?.activeElement||document.activeElement,this.requestUpdate(),this.updateComplete.then(()=>{const e=this.shadowRoot?.querySelector("scb-dialog");e&&(document.activeElement&&(e.__lastTriggerEl=document.activeElement),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.open=!0})}),e.addEventListener("close",this._handleDialogClose,{once:!0}))})}_addDays(t,e){const s=new Date(t.valueOf());return s.setDate(s.getDate()+e),s}_easterDay(t){if(typeof this._easterDateCalculated["Ar"+t]<"u")return new Date(this._easterDateCalculated["Ar"+t]);let e=t;e<100&&(e=e+1900),e<1950&&(e=e+100);const s=e%19,a=e%4,i=e%7,n=(19*s+24)%30,l=(2*a+4*i+6*n+5)%7;let c=22+n+l,p=0;c==57&&(c-=7),c==56&&n==28&&l==6&&s>10&&(c-=7),c>31?(c-=31,p=4):p=3;const T=new Date(e,p-1,c);return this._easterDateCalculated["Ar"+t]=T,new Date(this._easterDateCalculated["Ar"+t])}_swedishHolidayName(t){const e=t.getMonth();if(e===1||e===6||e===7||e===8)return null;const s=t.getMonth()+1,a=t.getDate(),i=t.getFullYear(),n=this._easterDay(i),l=this.lang==="en",c=[["Nyårsdagen","New Year's Day",s===1&&a===1],["Trettondedag jul","Epiphany",s===1&&a===6],["Långfredag","Good Friday",+t==+this._addDays(n,-2)],["Påskdagen","Easter Sunday",+t==+n],["Annandag påsk","Easter Monday",+t==+this._addDays(n,1)],["Kristi himmelsfärdsdag","Ascension Day",+t==+this._addDays(n,39)],["Pingstdagen","Pentecost",+t==+this._addDays(n,50)&&i<2005],["Första maj","May Day",s===5&&a===1],["Nationaldagen","National Day",s===6&&a===6&&i>=2005],["Midsommarafton","Midsummer's Eve",s===6&&a>=19&&a<=25&&t.getDay()===5],["Midsommardagen","Midsummer's Day",s===6&&a>=20&&a<=26&&t.getDay()===6],["Julafton","Christmas Eve",s===12&&a===24],["Juldagen","Christmas Day",s===12&&a===25],["Annandag jul","Boxing Day",s===12&&a===26],["Alla helgons dag","All Saints' Day",s===10&&a>=31&&t.getDay()===6||s===11&&a<=6&&t.getDay()===6]];for(const p of c){const[T,E,$]=p;if($)return l?E:T}return null}render(){const t=this._current.getFullYear(),e=this._current.getMonth(),s=this._daysInMonth(t,e),a=this._firstDayOfWeek(t,e),i=this._today,n=this.lang==="en",l=n?["January","February","March","April","May","June","July","August","September","October","November","December"]:["Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December"];let c=n?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]:["Mån","Tis","Ons","Tor","Fre","Lör","Sön"];this.disableWeekend&&(c=c.slice(0,5));const p=this._getEventInputs(),T=p?this._buildEventMapFromInputs(p):this._buildEventMapFromChildren(),E=[];let $=1;for(let r=0;r<6;r++){const h=[],g=this.disableWeekend?[0,1,2,3,4]:[0,1,2,3,4,5,6];let d=$;for(let _=0;_<g.length;_++){const b=g[_];if(r===0&&b<a){if(!this.disableWeekend||b<5){const k=e===0?11:e-1,F=e===0?t-1:t,N=this._daysInMonth(F,k)-(a-b-1);h.push(w`
1
+ import{a as P,n as D,i as j,x as T,t as q}from"../../vendor/vendor.js";import"./scb-calendar-event.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-dialog/scb-dialog.js";import"../scb-list/scb-list.js";import"../../vendor/vendor-material.js";import"../../vendor/preload-helper.js";import"../scb-button/scb-button.js";import"../scb-textfield/scb-textfield.js";import"../scb-datepicker/scb-datepicker.js";import"../scb-divider/scb-divider.js";import"../scb-checkbox/scb-checkbox.js";import"../scb-checkbox/scb-checkbox-group.js";import"../scb-radio-button/scb-radio-button.js";import"../scb-radio-button/scb-radio-group.js";import"../scb-switch/scb-switch.js";import"../scb-chip/scb-chip.js";import"../scb-list/scb-list-item.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(s,a,i){try{customElements.get(s)||e(s,a,i)}catch(r){var n=String(r||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw r}}}}catch{}})();var H=Object.defineProperty,W=Object.getOwnPropertyDescriptor,I=t=>{throw TypeError(t)},b=(t,e,s,a)=>{for(var i=a>1?void 0:a?W(e,s):e,n=t.length-1,r;n>=0;n--)(r=t[n])&&(i=(a?r(e,s,i):r(i))||i);return a&&i&&H(e,s,i),i},R=(t,e,s)=>e.has(t)||I("Cannot "+s),z=(t,e,s)=>e.has(t)?I("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),Y=(t,e,s)=>(R(t,e,"access private method"),s),x,J;let g=class extends j{constructor(){super(...arguments),z(this,x),this._lastActiveDay=null,this.lang="sv",this.disableWeekend=!1,this.publicHolidays=!0,this.displayYear=new Date().getFullYear(),this.displayMonth=new Date().getMonth()+1,this.selectedDate="",this.eventsJson=void 0,this._eventsFromJson=null,this._eventsJsonLast=void 0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._mutationObserver=null,this._syncingDisplay=!1,this._onCalendarKeyDown=t=>{const s=Array.from(this.shadowRoot?.querySelectorAll(".calendar-day.has-event")??[]),a=this.shadowRoot?.activeElement,i=a&&s.includes(a)?a:document.activeElement,n=s.indexOf(i);if(n===-1)return;let r=n;const c=this.disableWeekend?5:7;switch(t.key){case"ArrowRight":r=n+1<s.length?n+1:n;break;case"ArrowLeft":r=n-1>=0?n-1:n;break;case"ArrowDown":r=n+c<s.length?n+c:n;break;case"ArrowUp":r=n-c>=0?n-c:n;break;default:return}r!==n&&(t.preventDefault(),s[r].focus())},this._onEventChanged=()=>{this.requestUpdate()},this._today=new Date,this._current=new Date,this._popupEvent=null,this._handleDialogClose=()=>{this._popupEvent=null,this.requestUpdate(),this._restoreDayFocus()},this._restoreDayFocus=()=>{this._lastActiveDay&&setTimeout(()=>{this._lastActiveDay?.focus(),this._lastActiveDay=null},0)},this._easterDateCalculated={}}get value(){return this.selectedDate}set value(t){const e=(t??"")+"";e!==this.selectedDate&&(this.selectedDate=e)}static get observedAttributes(){return[...super.observedAttributes??[],"value"]}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),t==="value"&&(this.value=s??"")}connectedCallback(){super.connectedCallback(),Y(this,x,J).call(this);const t=Number(this.displayYear),e=Number(this.displayMonth);!Number.isNaN(t)&&!Number.isNaN(e)&&e>=1&&e<=12&&(this._current=new Date(t,e-1,1)),this._syncDisplayFromCurrent(!1),this.addEventListener("change",this._onEventChanged),this._mutationObserver=new MutationObserver(()=>{this.requestUpdate()}),this._mutationObserver.observe(this,{childList:!0}),this.addEventListener("keydown",this._onCalendarKeyDown)}disconnectedCallback(){this.removeEventListener("change",this._onEventChanged),super.disconnectedCallback(),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),this.removeEventListener("keydown",this._onCalendarKeyDown)}mapSpacingToken(t){if(!t)return;const e=String(t).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}updated(t){if(super.updated?.(t),t.has("eventsJson")&&(this._eventsJsonLast=void 0,this._eventsFromJson=null),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&Y(this,x,J).call(this),!this._syncingDisplay&&(t.has("displayYear")||t.has("displayMonth"))){const e=Number(this.displayYear),s=Number(this.displayMonth);if(!Number.isNaN(e)&&!Number.isNaN(s)&&s>=1&&s<=12){const a=this._current.getFullYear(),i=this._current.getMonth()+1;(a!==e||i!==s)&&(this._current=new Date(e,s-1,1),this._dispatchMonthChange(e,s),this.requestUpdate())}}}_ensureEventsFromJson(){const t=(this.eventsJson??"").trim();if(!t){this._eventsFromJson=null,this._eventsJsonLast=t;return}if(!(this._eventsJsonLast===t&&this._eventsFromJson!==null)){this._eventsJsonLast=t;try{const e=JSON.parse(t);Array.isArray(e)?this._eventsFromJson=e:this._eventsFromJson=[]}catch{this._eventsFromJson=[]}}}_getEventInputs(){return Array.isArray(this.events)?this.events:(this._ensureEventsFromJson(),this._eventsFromJson!==null?this._eventsFromJson:null)}_normalizeEventInput(t){const e=t.title??"",s=t.description??"",a=t.href??"",i=t.startDate??t["start-date"]??t.start??t.date??"",n=t.endDate??t["end-date"]??t.end??"";return{title:e+"",description:s?s+"":void 0,href:a?a+"":void 0,start:i?i+"":void 0,end:n?n+"":void 0}}_toLocalEventDate(t,e){const s=(t??"").trim();if(!s)return null;if(!s.includes("T")){const i=s.split("-").map(d=>Number(d));if(i.length!==3||i.some(d=>Number.isNaN(d)))return null;const[n,r,c]=i;return e?new Date(n,r-1,c,23,59,59,999):new Date(n,r-1,c,0,0,0,0)}const a=new Date(s);return Number.isNaN(a.getTime())?null:a}_toDateKey(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}_buildEventMapFromInputs(t){const e=new Map;for(const s of t){const a=this._normalizeEventInput(s),i=a.start||"",n=a.end||"";if(!(!i||!a.title))if(i&&n){const r=this._toLocalEventDate(i,!1),c=this._toLocalEventDate(n,!0);if(!r||!c)continue;if(c<r){const d=i.split("T")[0],y=e.get(d)||[];y.push({title:a.title,description:a.description,href:a.href,start:i,end:n}),e.set(d,y);continue}for(let d=new Date(r);d<=c;d.setDate(d.getDate()+1)){const y=this._toDateKey(d),E=e.get(y)||[];E.push({title:a.title,description:a.description,href:a.href,start:i,end:n}),e.set(y,E)}}else{const r=i.split("T")[0],c=e.get(r)||[];c.push({title:a.title,description:a.description,href:a.href,start:i}),e.set(r,c)}}return e}_buildEventMapFromChildren(){const t=Array.from(this.querySelectorAll("scb-calendar-event")),e=new Map;for(const s of t){const a=s,i=(a.startDate??a.date??"")+""||s.getAttribute("start-date")||s.getAttribute("date")||"",n=(a.endDate??"")+""||s.getAttribute("end-date")||"";if(i&&n){const r=this._toLocalEventDate(i,!1),c=this._toLocalEventDate(n,!0);if(!r||!c)continue;if(c<r){const d=i.split("T")[0],y=e.get(d)||[];y.push({title:s.title??"",description:s.description,href:a.href||s.getAttribute("href")||void 0,start:i,end:n}),e.set(d,y);continue}for(let d=new Date(r);d<=c;d.setDate(d.getDate()+1)){const y=this._toDateKey(d),E=e.get(y)||[];E.push({title:s.title??"",description:s.description,href:a.href||s.getAttribute("href")||void 0,start:i,end:n}),e.set(y,E)}}else if(i&&s.title){const r=i.split("T")[0],c=e.get(r)||[];c.push({title:s.title,description:s.description,href:a.href||s.getAttribute("href")||void 0,start:i}),e.set(r,c)}}return e}_syncDisplayFromCurrent(t=!0){const e=this._current.getFullYear(),s=this._current.getMonth()+1;this._syncingDisplay=!0;try{this.displayYear=e,this.displayMonth=s}finally{this._syncingDisplay=!1}t&&this._dispatchMonthChange(e,s)}_dispatchMonthChange(t,e){const s={displayYear:t,displayMonth:e};this.dispatchEvent(new CustomEvent("scb-calendar-month-change",{bubbles:!0,composed:!0,detail:s})),this.dispatchEvent(new CustomEvent("scbcalendarmonthchange",{bubbles:!0,composed:!0,detail:s}))}_dispatchSelect(t){const e={selectedDate:t};this.dispatchEvent(new CustomEvent("scb-calendar-select",{bubbles:!0,composed:!0,detail:e})),this.dispatchEvent(new CustomEvent("scbcalendarselect",{bubbles:!0,composed:!0,detail:e}))}_daysInMonth(t,e){return new Date(t,e+1,0).getDate()}_firstDayOfWeek(t,e){const s=new Date(t,e,1).getDay();return s===0?6:s-1}_prevMonth(){this._current=new Date(this._current.getFullYear(),this._current.getMonth()-1,1),this.selectedDate="",this._popupEvent=null,this._syncDisplayFromCurrent(),this.requestUpdate()}_nextMonth(){this._current=new Date(this._current.getFullYear(),this._current.getMonth()+1,1),this.selectedDate="",this._popupEvent=null,this._syncDisplayFromCurrent(),this.requestUpdate()}_showEventPopup(t){this._popupEvent=t,this.selectedDate=t.date,this._dispatchSelect(t.date),this._lastActiveDay=this.shadowRoot?.activeElement||document.activeElement,this.requestUpdate(),this.updateComplete.then(()=>{const e=this.shadowRoot?.querySelector("scb-dialog");e&&(document.activeElement&&(e.__lastTriggerEl=document.activeElement),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.open=!0})}),e.addEventListener("close",this._handleDialogClose,{once:!0}))})}_addDays(t,e){const s=new Date(t.valueOf());return s.setDate(s.getDate()+e),s}_easterDay(t){if(typeof this._easterDateCalculated["Ar"+t]<"u")return new Date(this._easterDateCalculated["Ar"+t]);let e=t;e<100&&(e=e+1900),e<1950&&(e=e+100);const s=e%19,a=e%4,i=e%7,n=(19*s+24)%30,r=(2*a+4*i+6*n+5)%7;let c=22+n+r,d=0;c==57&&(c-=7),c==56&&n==28&&r==6&&s>10&&(c-=7),c>31?(c-=31,d=4):d=3;const y=new Date(e,d-1,c);return this._easterDateCalculated["Ar"+t]=y,new Date(this._easterDateCalculated["Ar"+t])}_swedishHolidayName(t){const e=t.getMonth();if(e===1||e===6||e===7||e===8)return null;const s=t.getMonth()+1,a=t.getDate(),i=t.getFullYear(),n=this._easterDay(i),r=this.lang==="en",c=[["Nyårsdagen","New Year's Day",s===1&&a===1],["Trettondedag jul","Epiphany",s===1&&a===6],["Långfredag","Good Friday",+t==+this._addDays(n,-2)],["Påskdagen","Easter Sunday",+t==+n],["Annandag påsk","Easter Monday",+t==+this._addDays(n,1)],["Kristi himmelsfärdsdag","Ascension Day",+t==+this._addDays(n,39)],["Pingstdagen","Pentecost",+t==+this._addDays(n,50)&&i<2005],["Första maj","May Day",s===5&&a===1],["Nationaldagen","National Day",s===6&&a===6&&i>=2005],["Midsommarafton","Midsummer's Eve",s===6&&a>=19&&a<=25&&t.getDay()===5],["Midsommardagen","Midsummer's Day",s===6&&a>=20&&a<=26&&t.getDay()===6],["Julafton","Christmas Eve",s===12&&a===24],["Juldagen","Christmas Day",s===12&&a===25],["Annandag jul","Boxing Day",s===12&&a===26],["Alla helgons dag","All Saints' Day",s===10&&a>=31&&t.getDay()===6||s===11&&a<=6&&t.getDay()===6]];for(const d of c){const[y,E,A]=d;if(A)return r?E:y}return null}render(){const t=this._current.getFullYear(),e=this._current.getMonth(),s=this._daysInMonth(t,e),a=this._firstDayOfWeek(t,e),i=this._today,n=this.lang==="en",r=n?["January","February","March","April","May","June","July","August","September","October","November","December"]:["Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December"];let c=n?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]:["Mån","Tis","Ons","Tor","Fre","Lör","Sön"];this.disableWeekend&&(c=c.slice(0,5));const d=this._getEventInputs(),y=d?this._buildEventMapFromInputs(d):this._buildEventMapFromChildren(),E=[];let A=1;for(let o=0;o<6;o++){const h=[],f=this.disableWeekend?[0,1,2,3,4]:[0,1,2,3,4,5,6];let p=A;for(let w=0;w<f.length;w++){const v=f[w];if(o===0&&v<a){if(!this.disableWeekend||v<5){const k=e===0?11:e-1,F=e===0?t-1:t,N=this._daysInMonth(F,k)-(a-v-1);h.push(T`
2
2
  <div class="calendar-day calendar-day--other">
3
3
  <span class="calendar-day-number">${N}</span>
4
4
  </div>
5
- `)}}else if(d>s)h.push(w`<div></div>`);else{let k=new Date(t,e,d);if(this.disableWeekend)for(;k.getDay()===0||k.getDay()===6;)d++,k=new Date(t,e,d);if(d>s){h.push(w`<div></div>`);continue}const F=i.getFullYear()===t&&i.getMonth()===e&&i.getDate()===d,D=`${t}-${String(e+1).padStart(2,"0")}-${String(d).padStart(2,"0")}`,N=new Date(t,e,d);let O=!1,M=null;this.publicHolidays&&(M=this._swedishHolidayName(N),O=!!M);let u=T.get(D)||[];u=[...u].sort((o,m)=>{const C=o.start&&D===o.start.split("T")[0]?o.start:o.end&&D===o.end.split("T")[0]?o.end:"",S=m.start&&D===m.start.split("T")[0]?m.start:m.end&&m.end.split("T")[0]?m.end:"",x=C&&C.includes("T"),L=S&&S.includes("T");return x&&L?C.localeCompare(S):x?-1:L?1:o.title.localeCompare(m.title)});const P=[...u].map(o=>{let m="",C="";if(o.start&&o.end){const S=o.start.split("T")[0],x=o.end.split("T")[0];D===S&&D===x&&o.start.includes("T")&&o.end.includes("T")?m=o.start.split("T")[1].substring(0,5)+"–"+o.end.split("T")[1].substring(0,5):D===S&&o.start.includes("T")?m=o.start.split("T")[1].substring(0,5):D===x&&o.end.includes("T")?(m=o.end.split("T")[1].substring(0,5),C=n?"cont. ":"fort. "):D!==S&&(m="",C=n?"cont. ":"fort. ")}else o.start&&o.start.includes("T")&&(m=o.start.split("T")[1].substring(0,5));return{...o,time:m,prefix:C}});h.push(w`
5
+ `)}}else if(p>s)h.push(T`<div></div>`);else{let k=new Date(t,e,p);if(this.disableWeekend)for(;k.getDay()===0||k.getDay()===6;)p++,k=new Date(t,e,p);if(p>s){h.push(T`<div></div>`);continue}const F=i.getFullYear()===t&&i.getMonth()===e&&i.getDate()===p,_=`${t}-${String(e+1).padStart(2,"0")}-${String(p).padStart(2,"0")}`,N=new Date(t,e,p);let L=!1,M=null;this.publicHolidays&&(M=this._swedishHolidayName(N),L=!!M);let u=y.get(_)||[];u=[...u].sort((l,m)=>{const C=l.start&&_===l.start.split("T")[0]?l.start:l.end&&_===l.end.split("T")[0]?l.end:"",$=m.start&&_===m.start.split("T")[0]?m.start:m.end&&m.end.split("T")[0]?m.end:"",S=C&&C.includes("T"),O=$&&$.includes("T");return S&&O?C.localeCompare($):S?-1:O?1:l.title.localeCompare(m.title)});const K=[...u].map(l=>{let m="",C="";if(l.start&&l.end){const $=l.start.split("T")[0],S=l.end.split("T")[0];_===$&&_===S&&l.start.includes("T")&&l.end.includes("T")?m=l.start.split("T")[1].substring(0,5)+"–"+l.end.split("T")[1].substring(0,5):_===$&&l.start.includes("T")?m=l.start.split("T")[1].substring(0,5):_===S&&l.end.includes("T")&&$!==S?(m=l.end.split("T")[1].substring(0,5),C=n?"cont. ":"fort. "):_===S&&l.end.includes("T")?m=l.end.split("T")[1].substring(0,5):_!==$&&(m="",C=n?"cont. ":"fort. ")}else l.start&&l.start.includes("T")&&(m=l.start.split("T")[1].substring(0,5));return{...l,time:m,prefix:C}});h.push(T`
6
6
  <div
7
- class="calendar-day${F?" today":""}${u.length?" has-event":""}${O?" calendar-day--holiday":""}"
7
+ class="calendar-day${F?" today":""}${u.length?" has-event":""}${L?" calendar-day--holiday":""}"
8
8
  tabindex=${u.length?"0":void 0}
9
- @click=${u.length?()=>this._showEventPopup({date:D,events:u}):null}
10
- @keydown=${u.length?o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),this._showEventPopup({date:D,events:u}))}:null}
11
- title=${M||(u.length===1?u[0].title:u.length>1?u.map(o=>o.title).join(", "):"")}
9
+ @click=${u.length?()=>this._showEventPopup({date:_,events:u}):null}
10
+ @keydown=${u.length?l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),this._showEventPopup({date:_,events:u}))}:null}
11
+ title=${M||(u.length===1?u[0].title:u.length>1?u.map(l=>l.title).join(", "):"")}
12
12
  role=${u.length?"button":void 0}
13
- aria-label=${M||(u.length?u.length===1?u[0].title:u.map(o=>o.title).join(", "):void 0)}
13
+ aria-label=${M||(u.length?u.length===1?u[0].title:u.map(l=>l.title).join(", "):void 0)}
14
14
  >
15
15
  <md-focus-ring inward></md-focus-ring>
16
- <span class="calendar-day-number">${d} ${M?w`<span class="calendar-day-holiday-name">${M}</span>`:""}</span>
16
+ <span class="calendar-day-number">${p} ${M?T`<span class="calendar-day-holiday-name">${M}</span>`:""}</span>
17
17
  <div class="calendar-titles-wrapper">
18
- ${P.map(o=>w`<span class="calendar-day-event-title">${o.prefix||""}${o.title}</span>`)}
18
+ ${K.map(l=>T`<span class="calendar-day-event-title">${l.prefix||""}${l.title}</span>`)}
19
19
  </div>
20
20
  </div>
21
- `),d++}}if($=d,E.push(w`<div class="calendar-grid">${h}</div>`),$>s)break}return w`
21
+ `),p++}}if(A=p,E.push(T`<div class="calendar-grid">${h}</div>`),A>s)break}return T`
22
22
  <div class="calendar-header">
23
23
  <scb-icon-button @click=${this._prevMonth} icon="chevron_left" aria-label="${n?"Previous month":"Föregående månad"}"></scb-icon-button>
24
- <span>${l[e]} ${t}</span>
24
+ <span>${r[e]} ${t}</span>
25
25
  <scb-icon-button @click=${this._nextMonth} icon="chevron_right" aria-label="${n?"Next month":"Nästa månad"}"></scb-icon-button>
26
26
  </div>
27
27
  <div class="calendar-grid calendar-grid-days">
28
- ${c.map(r=>w`<div>${r}</div>`)}
28
+ ${c.map(o=>T`<div>${o}</div>`)}
29
29
  </div>
30
30
  <div class="calendar-weeks">
31
31
  ${E}
32
32
  </div>
33
- ${this._popupEvent&&Array.isArray(this._popupEvent.events)?w`
33
+ ${this._popupEvent&&Array.isArray(this._popupEvent.events)?T`
34
34
  <scb-dialog variant="floating" open label="${n?"Events":"Händelser"} ${this._popupEvent.date}">
35
35
  <scb-list>
36
- ${[...this._popupEvent.events].sort((r,h)=>{const g=r.start&&r.start.includes("T")?r.start:r.end&&r.end.includes("T")?r.end:"",d=h.start&&h.start.includes("T")?h.start:h.end&&h.end.includes("T")?h.end:"",_=g&&g.includes("T"),b=d&&d.includes("T");return _&&b?g.localeCompare(d):_?-1:b?1:r.title.localeCompare(h.title)}).map(r=>{const h=this._popupEvent?.date??"";let g="",d="",_="";if(r.start&&r.end){const b=r.start.split("T")[0],k=r.end.split("T")[0];b===k&&r.start.includes("T")&&r.end.includes("T")?g=r.start.split("T")[1].substring(0,5)+" – "+r.end.split("T")[1].substring(0,5):h===b&&r.start.includes("T")&&(g="Start: "+r.start.split("T")[1].substring(0,5)+(n?" (Extended event) ":" (Flerdagsevenemang) ")),h===k&&r.end.includes("T")&&b!==k&&(_=(n?"End: ":"Slut: ")+r.end.split("T")[1].substring(0,5)),h!==b&&(d=n?"cont. ":"fort. ")}else r.start&&r.start.includes("T")&&(g=r.start.split("T")[1].substring(0,5));return r.href?w`
36
+ ${[...this._popupEvent.events].sort((o,h)=>{const f=o.start&&o.start.includes("T")?o.start:o.end&&o.end.includes("T")?o.end:"",p=h.start&&h.start.includes("T")?h.start:h.end&&h.end.includes("T")?h.end:"",w=f&&f.includes("T"),v=p&&p.includes("T");return w&&v?f.localeCompare(p):w?-1:v?1:o.title.localeCompare(h.title)}).map(o=>{const h=this._popupEvent?.date??"";let f="",p="",w="";if(o.start&&o.end){const v=o.start.split("T")[0],k=o.end.split("T")[0];v===k&&o.start.includes("T")&&o.end.includes("T")?f=o.start.split("T")[1].substring(0,5)+" – "+o.end.split("T")[1].substring(0,5):h===v&&o.start.includes("T")&&(f="Start: "+o.start.split("T")[1].substring(0,5)+(n?" (Extended event) ":" (Flerdagsevenemang) ")),h===k&&o.end.includes("T")&&v!==k&&(w=(n?"End: ":"Slut: ")+o.end.split("T")[1].substring(0,5)),h!==v&&(p=n?"cont. ":"fort. ")}else o.start&&o.start.includes("T")&&(f=o.start.split("T")[1].substring(0,5));return o.href?T`
37
37
  <scb-list-item
38
38
  type="link"
39
- item-href="${r.href}"
40
- label="${d}${r.title}"
41
- supporting-text="${r.description?r.description:""}"
42
- overline="${g||""}${_||""}"
39
+ item-href="${o.href}"
40
+ label="${p}${o.title}"
41
+ supporting-text="${o.description?o.description:""}"
42
+ overline="${f||""}${w||""}"
43
43
  >
44
- </scb-list-item>`:w`
44
+ </scb-list-item>`:T`
45
45
  <scb-list-item
46
- label="${d}${r.title}"
47
- supporting-text="${r.description?r.description:""}"
48
- overline="${g||""}${_||""}"
46
+ label="${p}${o.title}"
47
+ supporting-text="${o.description?o.description:""}"
48
+ overline="${f||""}${w||""}"
49
49
  >
50
50
  </scb-list-item>`})}
51
51
  </scb-list>
52
52
  </scb-dialog>
53
53
  `:""}
54
- `}};A=new WeakSet;J=function(){const t=this.mapSpacingToken(this.spacing),e=this.mapSpacingToken(this.spacingTop)??t,s=this.mapSpacingToken(this.spacingBottom)??t,a=this.mapSpacingToken(this.spacingLeft),i=this.mapSpacingToken(this.spacingRight);e?this.style.setProperty("--scb-calendar-spacing-block-start",e):this.style.removeProperty("--scb-calendar-spacing-block-start"),s?this.style.setProperty("--scb-calendar-spacing-block-end",s):this.style.removeProperty("--scb-calendar-spacing-block-end"),a?this.style.setProperty("--scb-calendar-spacing-inline-start",a):this.style.removeProperty("--scb-calendar-spacing-inline-start"),i?this.style.setProperty("--scb-calendar-spacing-inline-end",i):this.style.removeProperty("--scb-calendar-spacing-inline-end")};y.styles=j`
54
+ `}};x=new WeakSet;J=function(){const t=this.mapSpacingToken(this.spacing),e=this.mapSpacingToken(this.spacingTop)??t,s=this.mapSpacingToken(this.spacingBottom)??t,a=this.mapSpacingToken(this.spacingLeft),i=this.mapSpacingToken(this.spacingRight);e?this.style.setProperty("--scb-calendar-spacing-block-start",e):this.style.removeProperty("--scb-calendar-spacing-block-start"),s?this.style.setProperty("--scb-calendar-spacing-block-end",s):this.style.removeProperty("--scb-calendar-spacing-block-end"),a?this.style.setProperty("--scb-calendar-spacing-inline-start",a):this.style.removeProperty("--scb-calendar-spacing-inline-start"),i?this.style.setProperty("--scb-calendar-spacing-inline-end",i):this.style.removeProperty("--scb-calendar-spacing-inline-end")};g.styles=P`
55
55
  :host {
56
56
  display: block;
57
57
  margin-block-start: var(--scb-calendar-spacing-block-start, 0);
@@ -165,4 +165,4 @@ import{a as j,n as v,i as q,x as w,t as H}from"../../vendor/vendor.js";import"./
165
165
  gap: var(--spacing-4);
166
166
  }
167
167
 
168
- `;f([v({type:String})],y.prototype,"lang",2);f([v({type:Boolean,attribute:"disable-weekend"})],y.prototype,"disableWeekend",2);f([v({type:Boolean,attribute:"public-holidays"})],y.prototype,"publicHolidays",2);f([v({type:Number,attribute:"display-year",reflect:!0})],y.prototype,"displayYear",2);f([v({type:Number,attribute:"display-month",reflect:!0})],y.prototype,"displayMonth",2);f([v({type:String,attribute:"selected-date",reflect:!0})],y.prototype,"selectedDate",2);f([v({attribute:!1})],y.prototype,"events",2);f([v({type:String,attribute:"events-json"})],y.prototype,"eventsJson",2);f([v({type:String,reflect:!0})],y.prototype,"spacing",2);f([v({type:String,attribute:"spacing-top",reflect:!0})],y.prototype,"spacingTop",2);f([v({type:String,attribute:"spacing-bottom",reflect:!0})],y.prototype,"spacingBottom",2);f([v({type:String,attribute:"spacing-left",reflect:!0})],y.prototype,"spacingLeft",2);f([v({type:String,attribute:"spacing-right",reflect:!0})],y.prototype,"spacingRight",2);y=f([H("scb-calendar")],y);
168
+ `;b([D({type:String})],g.prototype,"lang",2);b([D({type:Boolean,attribute:"disable-weekend"})],g.prototype,"disableWeekend",2);b([D({type:Boolean,attribute:"public-holidays"})],g.prototype,"publicHolidays",2);b([D({type:Number,attribute:"display-year",reflect:!0})],g.prototype,"displayYear",2);b([D({type:Number,attribute:"display-month",reflect:!0})],g.prototype,"displayMonth",2);b([D({type:String,attribute:"selected-date",reflect:!0})],g.prototype,"selectedDate",2);b([D({attribute:!1})],g.prototype,"events",2);b([D({type:String,attribute:"events-json"})],g.prototype,"eventsJson",2);b([D({type:String,reflect:!0})],g.prototype,"spacing",2);b([D({type:String,attribute:"spacing-top",reflect:!0})],g.prototype,"spacingTop",2);b([D({type:String,attribute:"spacing-bottom",reflect:!0})],g.prototype,"spacingBottom",2);b([D({type:String,attribute:"spacing-left",reflect:!0})],g.prototype,"spacingLeft",2);b([D({type:String,attribute:"spacing-right",reflect:!0})],g.prototype,"spacingRight",2);g=b([q("scb-calendar")],g);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scb-wc-test",
3
- "version": "0.1.330",
3
+ "version": "0.1.331",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -394,5 +394,5 @@
394
394
  },
395
395
  "./mvc/*": "./mvc/*"
396
396
  },
397
- "buildHash": "F068CC8D316C2108912A83E2A97307CB028A76CAC4900FB5B3CCB28A0B98CBDF"
397
+ "buildHash": "1133C9F2C6098DE3FC2062413588C9F4430804DF7575F5B4ECEAF5C14516568D"
398
398
  }
@@ -43,6 +43,8 @@ export declare class ScbCalendar extends LitElement {
43
43
  private _ensureEventsFromJson;
44
44
  private _getEventInputs;
45
45
  private _normalizeEventInput;
46
+ private _toLocalEventDate;
47
+ private _toDateKey;
46
48
  private _buildEventMapFromInputs;
47
49
  private _buildEventMapFromChildren;
48
50
  private _syncDisplayFromCurrent;
@@ -1,22 +1,22 @@
1
- import { css as j, LitElement as q, html as T } from "lit";
2
- import { property as b, customElement as H } from "lit/decorators.js";
1
+ import { css as P, LitElement as j, html as T } from "lit";
2
+ import { property as _, customElement as q } from "lit/decorators.js";
3
3
  import "./scb-calendar-event.js";
4
4
  import "../scb-icon-button/scb-icon-button.js";
5
5
  import "../scb-dialog/scb-dialog.js";
6
6
  import "../scb-list/scb-list.js";
7
7
  import "@material/web/focus/md-focus-ring.js";
8
- var W = Object.defineProperty, R = Object.getOwnPropertyDescriptor, Y = (t) => {
8
+ var H = Object.defineProperty, W = Object.getOwnPropertyDescriptor, I = (t) => {
9
9
  throw TypeError(t);
10
10
  }, v = (t, e, s, n) => {
11
- for (var i = n > 1 ? void 0 : n ? R(e, s) : e, a = t.length - 1, c; a >= 0; a--)
11
+ for (var i = n > 1 ? void 0 : n ? W(e, s) : e, a = t.length - 1, c; a >= 0; a--)
12
12
  (c = t[a]) && (i = (n ? c(e, s, i) : c(i)) || i);
13
- return n && i && W(e, s, i), i;
14
- }, z = (t, e, s) => e.has(t) || Y("Cannot " + s), K = (t, e, s) => e.has(t) ? Y("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), I = (t, e, s) => (z(t, e, "access private method"), s), F, J;
15
- let y = class extends q {
13
+ return n && i && H(e, s, i), i;
14
+ }, R = (t, e, s) => e.has(t) || I("Cannot " + s), z = (t, e, s) => e.has(t) ? I("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), Y = (t, e, s) => (R(t, e, "access private method"), s), x, J;
15
+ let g = class extends j {
16
16
  constructor() {
17
- super(...arguments), K(this, F), this._lastActiveDay = null, this.lang = "sv", this.disableWeekend = !1, this.publicHolidays = !0, this.displayYear = (/* @__PURE__ */ new Date()).getFullYear(), this.displayMonth = (/* @__PURE__ */ new Date()).getMonth() + 1, this.selectedDate = "", this.eventsJson = void 0, this._eventsFromJson = null, this._eventsJsonLast = void 0, this.spacing = void 0, this.spacingTop = void 0, this.spacingBottom = void 0, this.spacingLeft = void 0, this.spacingRight = void 0, this._mutationObserver = null, this._syncingDisplay = !1, this._onCalendarKeyDown = (t) => {
18
- var d, g;
19
- const s = Array.from(((d = this.shadowRoot) == null ? void 0 : d.querySelectorAll(".calendar-day.has-event")) ?? []), n = (g = this.shadowRoot) == null ? void 0 : g.activeElement, i = n && s.includes(n) ? n : document.activeElement, a = s.indexOf(i);
17
+ super(...arguments), z(this, x), this._lastActiveDay = null, this.lang = "sv", this.disableWeekend = !1, this.publicHolidays = !0, this.displayYear = (/* @__PURE__ */ new Date()).getFullYear(), this.displayMonth = (/* @__PURE__ */ new Date()).getMonth() + 1, this.selectedDate = "", this.eventsJson = void 0, this._eventsFromJson = null, this._eventsJsonLast = void 0, this.spacing = void 0, this.spacingTop = void 0, this.spacingBottom = void 0, this.spacingLeft = void 0, this.spacingRight = void 0, this._mutationObserver = null, this._syncingDisplay = !1, this._onCalendarKeyDown = (t) => {
18
+ var d, p;
19
+ const s = Array.from(((d = this.shadowRoot) == null ? void 0 : d.querySelectorAll(".calendar-day.has-event")) ?? []), n = (p = this.shadowRoot) == null ? void 0 : p.activeElement, i = n && s.includes(n) ? n : document.activeElement, a = s.indexOf(i);
20
20
  if (a === -1) return;
21
21
  let c = a;
22
22
  const l = this.disableWeekend ? 5 : 7;
@@ -63,7 +63,7 @@ let y = class extends q {
63
63
  super.attributeChangedCallback(t, e, s), t === "value" && (this.value = s ?? "");
64
64
  }
65
65
  connectedCallback() {
66
- super.connectedCallback(), I(this, F, J).call(this);
66
+ super.connectedCallback(), Y(this, x, J).call(this);
67
67
  const t = Number(this.displayYear), e = Number(this.displayMonth);
68
68
  !Number.isNaN(t) && !Number.isNaN(e) && e >= 1 && e <= 12 && (this._current = new Date(t, e - 1, 1)), this._syncDisplayFromCurrent(!1), this.addEventListener("change", this._onEventChanged), this._mutationObserver = new MutationObserver(() => {
69
69
  this.requestUpdate();
@@ -80,7 +80,7 @@ let y = class extends q {
80
80
  }
81
81
  updated(t) {
82
82
  var e;
83
- if ((e = super.updated) == null || e.call(this, t), t.has("eventsJson") && (this._eventsJsonLast = void 0, this._eventsFromJson = null), (t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom") || t.has("spacingLeft") || t.has("spacingRight")) && I(this, F, J).call(this), !this._syncingDisplay && (t.has("displayYear") || t.has("displayMonth"))) {
83
+ if ((e = super.updated) == null || e.call(this, t), t.has("eventsJson") && (this._eventsJsonLast = void 0, this._eventsFromJson = null), (t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom") || t.has("spacingLeft") || t.has("spacingRight")) && Y(this, x, J).call(this), !this._syncingDisplay && (t.has("displayYear") || t.has("displayMonth"))) {
84
84
  const s = Number(this.displayYear), n = Number(this.displayMonth);
85
85
  if (!Number.isNaN(s) && !Number.isNaN(n) && n >= 1 && n <= 12) {
86
86
  const i = this._current.getFullYear(), a = this._current.getMonth() + 1;
@@ -117,22 +117,49 @@ let y = class extends q {
117
117
  end: a ? a + "" : void 0
118
118
  };
119
119
  }
120
+ _toLocalEventDate(t, e) {
121
+ const s = (t ?? "").trim();
122
+ if (!s) return null;
123
+ if (!s.includes("T")) {
124
+ const i = s.split("-").map((d) => Number(d));
125
+ if (i.length !== 3 || i.some((d) => Number.isNaN(d))) return null;
126
+ const [a, c, l] = i;
127
+ return e ? new Date(a, c - 1, l, 23, 59, 59, 999) : new Date(a, c - 1, l, 0, 0, 0, 0);
128
+ }
129
+ const n = new Date(s);
130
+ return Number.isNaN(n.getTime()) ? null : n;
131
+ }
132
+ _toDateKey(t) {
133
+ return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}-${String(t.getDate()).padStart(2, "0")}`;
134
+ }
120
135
  _buildEventMapFromInputs(t) {
121
136
  const e = /* @__PURE__ */ new Map();
122
137
  for (const s of t) {
123
138
  const n = this._normalizeEventInput(s), i = n.start || "", a = n.end || "";
124
139
  if (!(!i || !n.title))
125
140
  if (i && a) {
126
- const c = new Date(i), l = new Date(a);
141
+ const c = this._toLocalEventDate(i, !1), l = this._toLocalEventDate(a, !0);
142
+ if (!c || !l) continue;
143
+ if (l < c) {
144
+ const d = i.split("T")[0], p = e.get(d) || [];
145
+ p.push({
146
+ title: n.title,
147
+ description: n.description,
148
+ href: n.href,
149
+ start: i,
150
+ end: a
151
+ }), e.set(d, p);
152
+ continue;
153
+ }
127
154
  for (let d = new Date(c); d <= l; d.setDate(d.getDate() + 1)) {
128
- const g = d.toISOString().split("T")[0], E = e.get(g) || [];
155
+ const p = this._toDateKey(d), E = e.get(p) || [];
129
156
  E.push({
130
157
  title: n.title,
131
158
  description: n.description,
132
159
  href: n.href,
133
160
  start: i,
134
161
  end: a
135
- }), e.set(g, E);
162
+ }), e.set(p, E);
136
163
  }
137
164
  } else {
138
165
  const c = i.split("T")[0], l = e.get(c) || [];
@@ -153,16 +180,28 @@ let y = class extends q {
153
180
  for (const s of t) {
154
181
  const n = s, i = (n.startDate ?? n.date ?? "") + "" || s.getAttribute("start-date") || s.getAttribute("date") || "", a = (n.endDate ?? "") + "" || s.getAttribute("end-date") || "";
155
182
  if (i && a) {
156
- const c = new Date(i), l = new Date(a);
183
+ const c = this._toLocalEventDate(i, !1), l = this._toLocalEventDate(a, !0);
184
+ if (!c || !l) continue;
185
+ if (l < c) {
186
+ const d = i.split("T")[0], p = e.get(d) || [];
187
+ p.push({
188
+ title: s.title ?? "",
189
+ description: s.description,
190
+ href: n.href || s.getAttribute("href") || void 0,
191
+ start: i,
192
+ end: a
193
+ }), e.set(d, p);
194
+ continue;
195
+ }
157
196
  for (let d = new Date(c); d <= l; d.setDate(d.getDate() + 1)) {
158
- const g = d.toISOString().split("T")[0], E = e.get(g) || [];
197
+ const p = this._toDateKey(d), E = e.get(p) || [];
159
198
  E.push({
160
199
  title: s.title ?? "",
161
200
  description: s.description,
162
201
  href: n.href || s.getAttribute("href") || void 0,
163
202
  start: i,
164
203
  end: a
165
- }), e.set(g, E);
204
+ }), e.set(p, E);
166
205
  }
167
206
  } else if (i && s.title) {
168
207
  const c = i.split("T")[0], l = e.get(c) || [];
@@ -255,8 +294,8 @@ let y = class extends q {
255
294
  const s = e % 19, n = e % 4, i = e % 7, a = (19 * s + 24) % 30, c = (2 * n + 4 * i + 6 * a + 5) % 7;
256
295
  let l = 22 + a + c, d = 0;
257
296
  l == 57 && (l -= 7), l == 56 && a == 28 && c == 6 && s > 10 && (l -= 7), l > 31 ? (l -= 31, d = 4) : d = 3;
258
- const g = new Date(e, d - 1, l);
259
- return this._easterDateCalculated["Ar" + t] = g, new Date(this._easterDateCalculated["Ar" + t]);
297
+ const p = new Date(e, d - 1, l);
298
+ return this._easterDateCalculated["Ar" + t] = p, new Date(this._easterDateCalculated["Ar" + t]);
260
299
  }
261
300
  /**
262
301
  * Returnerar namnet på svensk helgdag eller null om det inte är en helgdag
@@ -283,8 +322,8 @@ let y = class extends q {
283
322
  ["Alla helgons dag", "All Saints' Day", s === 10 && n >= 31 && t.getDay() === 6 || s === 11 && n <= 6 && t.getDay() === 6]
284
323
  ];
285
324
  for (const d of l) {
286
- const [g, E, A] = d;
287
- if (A) return c ? E : g;
325
+ const [p, E, F] = d;
326
+ if (F) return c ? E : p;
288
327
  }
289
328
  return null;
290
329
  }
@@ -318,71 +357,71 @@ let y = class extends q {
318
357
  ];
319
358
  let l = a ? ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] : ["Mån", "Tis", "Ons", "Tor", "Fre", "Lör", "Sön"];
320
359
  this.disableWeekend && (l = l.slice(0, 5));
321
- const d = this._getEventInputs(), g = d ? this._buildEventMapFromInputs(d) : this._buildEventMapFromChildren(), E = [];
322
- let A = 1;
360
+ const d = this._getEventInputs(), p = d ? this._buildEventMapFromInputs(d) : this._buildEventMapFromChildren(), E = [];
361
+ let F = 1;
323
362
  for (let r = 0; r < 6; r++) {
324
- const h = [], m = this.disableWeekend ? [0, 1, 2, 3, 4] : [0, 1, 2, 3, 4, 5, 6];
325
- let p = A;
326
- for (let _ = 0; _ < m.length; _++) {
327
- const k = m[_];
363
+ const u = [], f = this.disableWeekend ? [0, 1, 2, 3, 4] : [0, 1, 2, 3, 4, 5, 6];
364
+ let h = F;
365
+ for (let D = 0; D < f.length; D++) {
366
+ const k = f[D];
328
367
  if (r === 0 && k < n) {
329
368
  if (!this.disableWeekend || k < 5) {
330
- const D = e === 0 ? 11 : e - 1, C = e === 0 ? t - 1 : t, N = this._daysInMonth(C, D) - (n - k - 1);
331
- h.push(T`
369
+ const w = e === 0 ? 11 : e - 1, C = e === 0 ? t - 1 : t, N = this._daysInMonth(C, w) - (n - k - 1);
370
+ u.push(T`
332
371
  <div class="calendar-day calendar-day--other">
333
372
  <span class="calendar-day-number">${N}</span>
334
373
  </div>
335
374
  `);
336
375
  }
337
- } else if (p > s)
338
- h.push(T`<div></div>`);
376
+ } else if (h > s)
377
+ u.push(T`<div></div>`);
339
378
  else {
340
- let D = new Date(t, e, p);
379
+ let w = new Date(t, e, h);
341
380
  if (this.disableWeekend)
342
- for (; D.getDay() === 0 || D.getDay() === 6; )
343
- p++, D = new Date(t, e, p);
344
- if (p > s) {
345
- h.push(T`<div></div>`);
381
+ for (; w.getDay() === 0 || w.getDay() === 6; )
382
+ h++, w = new Date(t, e, h);
383
+ if (h > s) {
384
+ u.push(T`<div></div>`);
346
385
  continue;
347
386
  }
348
- const C = i.getFullYear() === t && i.getMonth() === e && i.getDate() === p, w = `${t}-${String(e + 1).padStart(2, "0")}-${String(p).padStart(2, "0")}`, N = new Date(t, e, p);
349
- let O = !1, M = null;
350
- this.publicHolidays && (M = this._swedishHolidayName(N), O = !!M);
351
- let u = g.get(w) || [];
352
- u = [...u].sort((o, f) => {
353
- const S = o.start && w === o.start.split("T")[0] ? o.start : o.end && w === o.end.split("T")[0] ? o.end : "", $ = f.start && w === f.start.split("T")[0] ? f.start : f.end && f.end.split("T")[0] ? f.end : "", x = S && S.includes("T"), L = $ && $.includes("T");
354
- return x && L ? S.localeCompare($) : x ? -1 : L ? 1 : o.title.localeCompare(f.title);
387
+ const C = i.getFullYear() === t && i.getMonth() === e && i.getDate() === h, b = `${t}-${String(e + 1).padStart(2, "0")}-${String(h).padStart(2, "0")}`, N = new Date(t, e, h);
388
+ let L = !1, M = null;
389
+ this.publicHolidays && (M = this._swedishHolidayName(N), L = !!M);
390
+ let y = p.get(b) || [];
391
+ y = [...y].sort((o, m) => {
392
+ const S = o.start && b === o.start.split("T")[0] ? o.start : o.end && b === o.end.split("T")[0] ? o.end : "", $ = m.start && b === m.start.split("T")[0] ? m.start : m.end && m.end.split("T")[0] ? m.end : "", A = S && S.includes("T"), O = $ && $.includes("T");
393
+ return A && O ? S.localeCompare($) : A ? -1 : O ? 1 : o.title.localeCompare(m.title);
355
394
  });
356
- const P = [...u].map((o) => {
357
- let f = "", S = "";
395
+ const K = [...y].map((o) => {
396
+ let m = "", S = "";
358
397
  if (o.start && o.end) {
359
- const $ = o.start.split("T")[0], x = o.end.split("T")[0];
360
- w === $ && w === x && o.start.includes("T") && o.end.includes("T") ? f = o.start.split("T")[1].substring(0, 5) + "–" + o.end.split("T")[1].substring(0, 5) : w === $ && o.start.includes("T") ? f = o.start.split("T")[1].substring(0, 5) : w === x && o.end.includes("T") ? (f = o.end.split("T")[1].substring(0, 5), S = a ? "cont. " : "fort. ") : w !== $ && (f = "", S = a ? "cont. " : "fort. ");
361
- } else o.start && o.start.includes("T") && (f = o.start.split("T")[1].substring(0, 5));
362
- return { ...o, time: f, prefix: S };
398
+ const $ = o.start.split("T")[0], A = o.end.split("T")[0];
399
+ b === $ && b === A && o.start.includes("T") && o.end.includes("T") ? m = o.start.split("T")[1].substring(0, 5) + "–" + o.end.split("T")[1].substring(0, 5) : b === $ && o.start.includes("T") ? m = o.start.split("T")[1].substring(0, 5) : b === A && o.end.includes("T") && $ !== A ? (m = o.end.split("T")[1].substring(0, 5), S = a ? "cont. " : "fort. ") : b === A && o.end.includes("T") ? m = o.end.split("T")[1].substring(0, 5) : b !== $ && (m = "", S = a ? "cont. " : "fort. ");
400
+ } else o.start && o.start.includes("T") && (m = o.start.split("T")[1].substring(0, 5));
401
+ return { ...o, time: m, prefix: S };
363
402
  });
364
- h.push(T`
403
+ u.push(T`
365
404
  <div
366
- class="calendar-day${C ? " today" : ""}${u.length ? " has-event" : ""}${O ? " calendar-day--holiday" : ""}"
367
- tabindex=${u.length ? "0" : void 0}
368
- @click=${u.length ? () => this._showEventPopup({ date: w, events: u }) : null}
369
- @keydown=${u.length ? (o) => {
370
- (o.key === "Enter" || o.key === " ") && (o.preventDefault(), this._showEventPopup({ date: w, events: u }));
405
+ class="calendar-day${C ? " today" : ""}${y.length ? " has-event" : ""}${L ? " calendar-day--holiday" : ""}"
406
+ tabindex=${y.length ? "0" : void 0}
407
+ @click=${y.length ? () => this._showEventPopup({ date: b, events: y }) : null}
408
+ @keydown=${y.length ? (o) => {
409
+ (o.key === "Enter" || o.key === " ") && (o.preventDefault(), this._showEventPopup({ date: b, events: y }));
371
410
  } : null}
372
- title=${M || (u.length === 1 ? u[0].title : u.length > 1 ? u.map((o) => o.title).join(", ") : "")}
373
- role=${u.length ? "button" : void 0}
374
- aria-label=${M || (u.length ? u.length === 1 ? u[0].title : u.map((o) => o.title).join(", ") : void 0)}
411
+ title=${M || (y.length === 1 ? y[0].title : y.length > 1 ? y.map((o) => o.title).join(", ") : "")}
412
+ role=${y.length ? "button" : void 0}
413
+ aria-label=${M || (y.length ? y.length === 1 ? y[0].title : y.map((o) => o.title).join(", ") : void 0)}
375
414
  >
376
415
  <md-focus-ring inward></md-focus-ring>
377
- <span class="calendar-day-number">${p} ${M ? T`<span class="calendar-day-holiday-name">${M}</span>` : ""}</span>
416
+ <span class="calendar-day-number">${h} ${M ? T`<span class="calendar-day-holiday-name">${M}</span>` : ""}</span>
378
417
  <div class="calendar-titles-wrapper">
379
- ${P.map((o) => T`<span class="calendar-day-event-title">${o.prefix || ""}${o.title}</span>`)}
418
+ ${K.map((o) => T`<span class="calendar-day-event-title">${o.prefix || ""}${o.title}</span>`)}
380
419
  </div>
381
420
  </div>
382
- `), p++;
421
+ `), h++;
383
422
  }
384
423
  }
385
- if (A = p, E.push(T`<div class="calendar-grid">${h}</div>`), A > s) break;
424
+ if (F = h, E.push(T`<div class="calendar-grid">${u}</div>`), F > s) break;
386
425
  }
387
426
  return T`
388
427
  <div class="calendar-header">
@@ -399,30 +438,30 @@ let y = class extends q {
399
438
  ${this._popupEvent && Array.isArray(this._popupEvent.events) ? T`
400
439
  <scb-dialog variant="floating" open label="${a ? "Events" : "Händelser"} ${this._popupEvent.date}">
401
440
  <scb-list>
402
- ${[...this._popupEvent.events].sort((r, h) => {
403
- const m = r.start && r.start.includes("T") ? r.start : r.end && r.end.includes("T") ? r.end : "", p = h.start && h.start.includes("T") ? h.start : h.end && h.end.includes("T") ? h.end : "", _ = m && m.includes("T"), k = p && p.includes("T");
404
- return _ && k ? m.localeCompare(p) : _ ? -1 : k ? 1 : r.title.localeCompare(h.title);
441
+ ${[...this._popupEvent.events].sort((r, u) => {
442
+ const f = r.start && r.start.includes("T") ? r.start : r.end && r.end.includes("T") ? r.end : "", h = u.start && u.start.includes("T") ? u.start : u.end && u.end.includes("T") ? u.end : "", D = f && f.includes("T"), k = h && h.includes("T");
443
+ return D && k ? f.localeCompare(h) : D ? -1 : k ? 1 : r.title.localeCompare(u.title);
405
444
  }).map((r) => {
406
445
  var k;
407
- const h = ((k = this._popupEvent) == null ? void 0 : k.date) ?? "";
408
- let m = "", p = "", _ = "";
446
+ const u = ((k = this._popupEvent) == null ? void 0 : k.date) ?? "";
447
+ let f = "", h = "", D = "";
409
448
  if (r.start && r.end) {
410
- const D = r.start.split("T")[0], C = r.end.split("T")[0];
411
- D === C && r.start.includes("T") && r.end.includes("T") ? m = r.start.split("T")[1].substring(0, 5) + " – " + r.end.split("T")[1].substring(0, 5) : h === D && r.start.includes("T") && (m = "Start: " + r.start.split("T")[1].substring(0, 5) + (a ? " (Extended event) " : " (Flerdagsevenemang) ")), h === C && r.end.includes("T") && D !== C && (_ = (a ? "End: " : "Slut: ") + r.end.split("T")[1].substring(0, 5)), h !== D && (p = a ? "cont. " : "fort. ");
412
- } else r.start && r.start.includes("T") && (m = r.start.split("T")[1].substring(0, 5));
449
+ const w = r.start.split("T")[0], C = r.end.split("T")[0];
450
+ w === C && r.start.includes("T") && r.end.includes("T") ? f = r.start.split("T")[1].substring(0, 5) + " – " + r.end.split("T")[1].substring(0, 5) : u === w && r.start.includes("T") && (f = "Start: " + r.start.split("T")[1].substring(0, 5) + (a ? " (Extended event) " : " (Flerdagsevenemang) ")), u === C && r.end.includes("T") && w !== C && (D = (a ? "End: " : "Slut: ") + r.end.split("T")[1].substring(0, 5)), u !== w && (h = a ? "cont. " : "fort. ");
451
+ } else r.start && r.start.includes("T") && (f = r.start.split("T")[1].substring(0, 5));
413
452
  return r.href ? T`
414
453
  <scb-list-item
415
454
  type="link"
416
455
  item-href="${r.href}"
417
- label="${p}${r.title}"
456
+ label="${h}${r.title}"
418
457
  supporting-text="${r.description ? r.description : ""}"
419
- overline="${m || ""}${_ || ""}"
458
+ overline="${f || ""}${D || ""}"
420
459
  >
421
460
  </scb-list-item>` : T`
422
461
  <scb-list-item
423
- label="${p}${r.title}"
462
+ label="${h}${r.title}"
424
463
  supporting-text="${r.description ? r.description : ""}"
425
- overline="${m || ""}${_ || ""}"
464
+ overline="${f || ""}${D || ""}"
426
465
  >
427
466
  </scb-list-item>`;
428
467
  })}
@@ -432,12 +471,12 @@ let y = class extends q {
432
471
  `;
433
472
  }
434
473
  };
435
- F = /* @__PURE__ */ new WeakSet();
474
+ x = /* @__PURE__ */ new WeakSet();
436
475
  J = function() {
437
476
  const t = this.mapSpacingToken(this.spacing), e = this.mapSpacingToken(this.spacingTop) ?? t, s = this.mapSpacingToken(this.spacingBottom) ?? t, n = this.mapSpacingToken(this.spacingLeft), i = this.mapSpacingToken(this.spacingRight);
438
477
  e ? this.style.setProperty("--scb-calendar-spacing-block-start", e) : this.style.removeProperty("--scb-calendar-spacing-block-start"), s ? this.style.setProperty("--scb-calendar-spacing-block-end", s) : this.style.removeProperty("--scb-calendar-spacing-block-end"), n ? this.style.setProperty("--scb-calendar-spacing-inline-start", n) : this.style.removeProperty("--scb-calendar-spacing-inline-start"), i ? this.style.setProperty("--scb-calendar-spacing-inline-end", i) : this.style.removeProperty("--scb-calendar-spacing-inline-end");
439
478
  };
440
- y.styles = j`
479
+ g.styles = P`
441
480
  :host {
442
481
  display: block;
443
482
  margin-block-start: var(--scb-calendar-spacing-block-start, 0);
@@ -553,47 +592,47 @@ y.styles = j`
553
592
 
554
593
  `;
555
594
  v([
556
- b({ type: String })
557
- ], y.prototype, "lang", 2);
595
+ _({ type: String })
596
+ ], g.prototype, "lang", 2);
558
597
  v([
559
- b({ type: Boolean, attribute: "disable-weekend" })
560
- ], y.prototype, "disableWeekend", 2);
598
+ _({ type: Boolean, attribute: "disable-weekend" })
599
+ ], g.prototype, "disableWeekend", 2);
561
600
  v([
562
- b({ type: Boolean, attribute: "public-holidays" })
563
- ], y.prototype, "publicHolidays", 2);
601
+ _({ type: Boolean, attribute: "public-holidays" })
602
+ ], g.prototype, "publicHolidays", 2);
564
603
  v([
565
- b({ type: Number, attribute: "display-year", reflect: !0 })
566
- ], y.prototype, "displayYear", 2);
604
+ _({ type: Number, attribute: "display-year", reflect: !0 })
605
+ ], g.prototype, "displayYear", 2);
567
606
  v([
568
- b({ type: Number, attribute: "display-month", reflect: !0 })
569
- ], y.prototype, "displayMonth", 2);
607
+ _({ type: Number, attribute: "display-month", reflect: !0 })
608
+ ], g.prototype, "displayMonth", 2);
570
609
  v([
571
- b({ type: String, attribute: "selected-date", reflect: !0 })
572
- ], y.prototype, "selectedDate", 2);
610
+ _({ type: String, attribute: "selected-date", reflect: !0 })
611
+ ], g.prototype, "selectedDate", 2);
573
612
  v([
574
- b({ attribute: !1 })
575
- ], y.prototype, "events", 2);
613
+ _({ attribute: !1 })
614
+ ], g.prototype, "events", 2);
576
615
  v([
577
- b({ type: String, attribute: "events-json" })
578
- ], y.prototype, "eventsJson", 2);
616
+ _({ type: String, attribute: "events-json" })
617
+ ], g.prototype, "eventsJson", 2);
579
618
  v([
580
- b({ type: String, reflect: !0 })
581
- ], y.prototype, "spacing", 2);
619
+ _({ type: String, reflect: !0 })
620
+ ], g.prototype, "spacing", 2);
582
621
  v([
583
- b({ type: String, attribute: "spacing-top", reflect: !0 })
584
- ], y.prototype, "spacingTop", 2);
622
+ _({ type: String, attribute: "spacing-top", reflect: !0 })
623
+ ], g.prototype, "spacingTop", 2);
585
624
  v([
586
- b({ type: String, attribute: "spacing-bottom", reflect: !0 })
587
- ], y.prototype, "spacingBottom", 2);
625
+ _({ type: String, attribute: "spacing-bottom", reflect: !0 })
626
+ ], g.prototype, "spacingBottom", 2);
588
627
  v([
589
- b({ type: String, attribute: "spacing-left", reflect: !0 })
590
- ], y.prototype, "spacingLeft", 2);
628
+ _({ type: String, attribute: "spacing-left", reflect: !0 })
629
+ ], g.prototype, "spacingLeft", 2);
591
630
  v([
592
- b({ type: String, attribute: "spacing-right", reflect: !0 })
593
- ], y.prototype, "spacingRight", 2);
594
- y = v([
595
- H("scb-calendar")
596
- ], y);
631
+ _({ type: String, attribute: "spacing-right", reflect: !0 })
632
+ ], g.prototype, "spacingRight", 2);
633
+ g = v([
634
+ q("scb-calendar")
635
+ ], g);
597
636
  export {
598
- y as ScbCalendar
637
+ g as ScbCalendar
599
638
  };