scb-wc-test 0.1.129 → 0.1.130
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,13 +1,13 @@
|
|
|
1
|
-
import{a as j,n as $,i as P,x as v,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,r,d){try{customElements.get(s)||e(s,r,d)}catch(c){var a=String(c||"");if(a.indexOf("already been used")===-1&&a.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var q=Object.defineProperty,L=Object.getOwnPropertyDescriptor,k=(t,e,s,r)=>{for(var d=r>1?void 0:r?L(e,s):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(d=(r?c(e,s,d):c(d))||d);return r&&d&&q(e,s,d),d};let D=class extends P{constructor(){super(...arguments),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._mutationObserver=null,this._syncingDisplay=!1,this._onCalendarKeyDown=t=>{const s=Array.from(this.shadowRoot?.querySelectorAll(".calendar-day.has-event")??[]),r=this.shadowRoot?.activeElement,d=r&&s.includes(r)?r:document.activeElement,a=s.indexOf(d);if(a===-1)return;let c=a;const p=this.disableWeekend?5:7;switch(t.key){case"ArrowRight":c=a+1<s.length?a+1:a;break;case"ArrowLeft":c=a-1>=0?a-1:a;break;case"ArrowDown":c=a+p<s.length?a+p:a;break;case"ArrowUp":c=a-p>=0?a-p:a;break;default:return}c!==a&&(t.preventDefault(),s[c].focus())},this._onEventChanged=()=>{this.requestUpdate()},this._today=new Date,this._current=new Date,this._popupEvent=null,this._restoreDayFocus=()=>{this._lastActiveDay&&setTimeout(()=>{this._lastActiveDay?.focus(),this._lastActiveDay=null},0)},this._easterDateCalculated={}}connectedCallback(){super.connectedCallback();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)}updated(t){if(super.updated?.(t),!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 r=this._current.getFullYear(),d=this._current.getMonth()+1;(r!==e||d!==s)&&(this._current=new Date(e,s-1,1),this.dispatchEvent(new CustomEvent("scb-calendar-month-change",{bubbles:!0,composed:!0,detail:{displayYear:e,displayMonth:s}})),this.requestUpdate())}}}_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.dispatchEvent(new CustomEvent("scb-calendar-month-change",{bubbles:!0,composed:!0,detail:{displayYear:e,displayMonth:s}}))}_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.dispatchEvent(new CustomEvent("scb-calendar-select",{bubbles:!0,composed:!0,detail:{selectedDate:t.date}})),this._lastActiveDay=this.shadowRoot?.activeElement||document.activeElement,this.requestUpdate(),setTimeout(()=>{const e=this.shadowRoot?.querySelector("scb-dialog");e&&(document.activeElement&&(e.__lastTriggerEl=document.activeElement),e.open=!0,e.addEventListener("close",this._restoreDayFocus,{once:!0}));const s=r=>{r.target?.closest(".event-popup")||this._closePopup()};window.addEventListener("mousedown",s,{once:!0})},0)}_closePopup(){const t=this.shadowRoot?.querySelector("scb-dialog");t&&t.removeAttribute("open"),this._popupEvent=null,this.requestUpdate()}_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,r=e%4,d=e%7,a=(19*s+24)%30,c=(2*r+4*d+6*a+5)%7;let p=22+a+c,T=0;p==57&&(p-=7),p==56&&a==28&&c==6&&s>10&&(p-=7),p>31?(p-=31,T=4):T=3;const _=new Date(e,T-1,p);return this._easterDateCalculated["Ar"+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,r=t.getDate(),d=t.getFullYear(),a=this._easterDay(d),c=this.lang==="en",p=[["Nyårsdagen","New Year's Day",s===1&&r===1],["Trettondedag jul","Epiphany",s===1&&r===6],["Långfredag","Good Friday",+t==+this._addDays(a,-2)],["Påskdagen","Easter Sunday",+t==+a],["Annandag påsk","Easter Monday",+t==+this._addDays(a,1)],["Kristi himmelsfärdsdag","Ascension Day",+t==+this._addDays(a,39)],["Pingstdagen","Pentecost",+t==+this._addDays(a,50)&&d<2005],["Första maj","May Day",s===5&&r===1],["Nationaldagen","National Day",s===6&&r===6&&d>=2005],["Midsommarafton","Midsummer's Eve",s===6&&r>=19&&r<=25&&t.getDay()===5],["Midsommardagen","Midsummer's Day",s===6&&r>=20&&r<=26&&t.getDay()===6],["Julafton","Christmas Eve",s===12&&r===24],["Juldagen","Christmas Day",s===12&&r===25],["Annandag jul","Boxing Day",s===12&&r===26],["Alla helgons dag","All Saints' Day",s===10&&r>=31&&t.getDay()===6||s===11&&r<=6&&t.getDay()===6]];for(const T of p){const[_,N,A]=T;if(A)return c?N:_}return null}render(){const t=this._current.getFullYear(),e=this._current.getMonth(),s=this._daysInMonth(t,e),r=this._firstDayOfWeek(t,e),d=this._today,a=this.lang==="en",c=a?["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 p=a?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]:["Mån","Tis","Ons","Tor","Fre","Lör","Sön"];this.disableWeekend&&(p=p.slice(0,5));const T=Array.from(this.querySelectorAll("scb-calendar-event")),_=new Map;for(const n of T){const l=n.getAttribute("start-date")||"",y=n.getAttribute("end-date")||"";if(l&&y){const o=new Date(l),m=new Date(y);for(let u=new Date(o);u<=m;u.setDate(u.getDate()+1)){const
|
|
1
|
+
import{a as j,n as $,i as P,x as v,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,r,d){try{customElements.get(s)||e(s,r,d)}catch(c){var a=String(c||"");if(a.indexOf("already been used")===-1&&a.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var q=Object.defineProperty,L=Object.getOwnPropertyDescriptor,k=(t,e,s,r)=>{for(var d=r>1?void 0:r?L(e,s):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(d=(r?c(e,s,d):c(d))||d);return r&&d&&q(e,s,d),d};let D=class extends P{constructor(){super(...arguments),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._mutationObserver=null,this._syncingDisplay=!1,this._onCalendarKeyDown=t=>{const s=Array.from(this.shadowRoot?.querySelectorAll(".calendar-day.has-event")??[]),r=this.shadowRoot?.activeElement,d=r&&s.includes(r)?r:document.activeElement,a=s.indexOf(d);if(a===-1)return;let c=a;const p=this.disableWeekend?5:7;switch(t.key){case"ArrowRight":c=a+1<s.length?a+1:a;break;case"ArrowLeft":c=a-1>=0?a-1:a;break;case"ArrowDown":c=a+p<s.length?a+p:a;break;case"ArrowUp":c=a-p>=0?a-p:a;break;default:return}c!==a&&(t.preventDefault(),s[c].focus())},this._onEventChanged=()=>{this.requestUpdate()},this._today=new Date,this._current=new Date,this._popupEvent=null,this._restoreDayFocus=()=>{this._lastActiveDay&&setTimeout(()=>{this._lastActiveDay?.focus(),this._lastActiveDay=null},0)},this._easterDateCalculated={}}connectedCallback(){super.connectedCallback();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)}updated(t){if(super.updated?.(t),!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 r=this._current.getFullYear(),d=this._current.getMonth()+1;(r!==e||d!==s)&&(this._current=new Date(e,s-1,1),this.dispatchEvent(new CustomEvent("scb-calendar-month-change",{bubbles:!0,composed:!0,detail:{displayYear:e,displayMonth:s}})),this.requestUpdate())}}}_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.dispatchEvent(new CustomEvent("scb-calendar-month-change",{bubbles:!0,composed:!0,detail:{displayYear:e,displayMonth:s}}))}_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.dispatchEvent(new CustomEvent("scb-calendar-select",{bubbles:!0,composed:!0,detail:{selectedDate:t.date}})),this._lastActiveDay=this.shadowRoot?.activeElement||document.activeElement,this.requestUpdate(),setTimeout(()=>{const e=this.shadowRoot?.querySelector("scb-dialog");e&&(document.activeElement&&(e.__lastTriggerEl=document.activeElement),e.open=!0,e.addEventListener("close",this._restoreDayFocus,{once:!0}));const s=r=>{r.target?.closest(".event-popup")||this._closePopup()};window.addEventListener("mousedown",s,{once:!0})},0)}_closePopup(){const t=this.shadowRoot?.querySelector("scb-dialog");t&&t.removeAttribute("open"),this._popupEvent=null,this.requestUpdate()}_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,r=e%4,d=e%7,a=(19*s+24)%30,c=(2*r+4*d+6*a+5)%7;let p=22+a+c,T=0;p==57&&(p-=7),p==56&&a==28&&c==6&&s>10&&(p-=7),p>31?(p-=31,T=4):T=3;const _=new Date(e,T-1,p);return this._easterDateCalculated["Ar"+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,r=t.getDate(),d=t.getFullYear(),a=this._easterDay(d),c=this.lang==="en",p=[["Nyårsdagen","New Year's Day",s===1&&r===1],["Trettondedag jul","Epiphany",s===1&&r===6],["Långfredag","Good Friday",+t==+this._addDays(a,-2)],["Påskdagen","Easter Sunday",+t==+a],["Annandag påsk","Easter Monday",+t==+this._addDays(a,1)],["Kristi himmelsfärdsdag","Ascension Day",+t==+this._addDays(a,39)],["Pingstdagen","Pentecost",+t==+this._addDays(a,50)&&d<2005],["Första maj","May Day",s===5&&r===1],["Nationaldagen","National Day",s===6&&r===6&&d>=2005],["Midsommarafton","Midsummer's Eve",s===6&&r>=19&&r<=25&&t.getDay()===5],["Midsommardagen","Midsummer's Day",s===6&&r>=20&&r<=26&&t.getDay()===6],["Julafton","Christmas Eve",s===12&&r===24],["Juldagen","Christmas Day",s===12&&r===25],["Annandag jul","Boxing Day",s===12&&r===26],["Alla helgons dag","All Saints' Day",s===10&&r>=31&&t.getDay()===6||s===11&&r<=6&&t.getDay()===6]];for(const T of p){const[_,N,A]=T;if(A)return c?N:_}return null}render(){const t=this._current.getFullYear(),e=this._current.getMonth(),s=this._daysInMonth(t,e),r=this._firstDayOfWeek(t,e),d=this._today,a=this.lang==="en",c=a?["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 p=a?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]:["Mån","Tis","Ons","Tor","Fre","Lör","Sön"];this.disableWeekend&&(p=p.slice(0,5));const T=Array.from(this.querySelectorAll("scb-calendar-event")),_=new Map;for(const n of T){const l=n.getAttribute("start-date")||"",y=n.getAttribute("end-date")||"";if(l&&y){const o=new Date(l),m=new Date(y);for(let u=new Date(o);u<=m;u.setDate(u.getDate()+1)){const f=u.toISOString().split("T")[0],x=_.get(f)||[];x.push({title:n.title,description:n.description,start:l,end:y}),_.set(f,x)}}else if(l&&n.title){const o=l.split("T")[0],m=_.get(o)||[];m.push({title:n.title,description:n.description,start:l}),_.set(o,m)}}const N=[];let A=1;for(let n=0;n<6;n++){const l=[],y=this.disableWeekend?[0,1,2,3,4]:[0,1,2,3,4,5,6];let o=A;for(let m=0;m<y.length;m++){const u=y[m];if(n===0&&u<r){if(!this.disableWeekend||u<5){const f=e===0?11:e-1,x=e===0?t-1:t,S=this._daysInMonth(x,f)-(r-u-1);l.push(v`
|
|
2
2
|
<div class="calendar-day calendar-day--other">
|
|
3
3
|
<span class="calendar-day-number">${S}</span>
|
|
4
4
|
</div>
|
|
5
|
-
`)}}else if(o>s)l.push(v`<div></div>`);else{let
|
|
5
|
+
`)}}else if(o>s)l.push(v`<div></div>`);else{let f=new Date(t,e,o);if(this.disableWeekend)for(;f.getDay()===0||f.getDay()===6;)o++,f=new Date(t,e,o);if(o>s){l.push(v`<div></div>`);continue}const x=d.getFullYear()===t&&d.getMonth()===e&&d.getDate()===o,b=`${t}-${String(e+1).padStart(2,"0")}-${String(o).padStart(2,"0")}`,S=new Date(t,e,o);let F=!1,w=null;this.publicHolidays&&(w=this._swedishHolidayName(S),F=!!w);let h=_.get(b)||[];h=[...h].sort((i,g)=>{const E=i.start&&b===i.start.split("T")[0]?i.start:i.end&&b===i.end.split("T")[0]?i.end:"",M=g.start&&b===g.start.split("T")[0]?g.start:g.end&&g.end.split("T")[0]?g.end:"",C=E&&E.includes("T"),O=M&&M.includes("T");return C&&O?E.localeCompare(M):C?-1:O?1:i.title.localeCompare(g.title)});const Y=[...h].map(i=>{let g="",E="";if(i.start&&i.end){const M=i.start.split("T")[0],C=i.end.split("T")[0];b===M&&b===C&&i.start.includes("T")&&i.end.includes("T")?g=i.start.split("T")[1].substring(0,5)+"–"+i.end.split("T")[1].substring(0,5):b===M&&i.start.includes("T")?g=i.start.split("T")[1].substring(0,5):b===C&&i.end.includes("T")?(g=i.end.split("T")[1].substring(0,5),E=a?"cont. ":"fort. "):b!==M&&(g="",E=a?"cont. ":"fort. ")}else i.start&&i.start.includes("T")&&(g=i.start.split("T")[1].substring(0,5));return{...i,time:g,prefix:E}});l.push(v`
|
|
6
6
|
<div
|
|
7
7
|
class="calendar-day${x?" today":""}${h.length?" has-event":""}${F?" calendar-day--holiday":""}"
|
|
8
8
|
tabindex=${h.length?"0":void 0}
|
|
9
|
-
@click=${h.length?()=>this._showEventPopup({date:
|
|
10
|
-
@keydown=${h.length?i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),this._showEventPopup({date:
|
|
9
|
+
@click=${h.length?()=>this._showEventPopup({date:b,events:h}):null}
|
|
10
|
+
@keydown=${h.length?i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),this._showEventPopup({date:b,events:h}))}:null}
|
|
11
11
|
title=${w||(h.length===1?h[0].title:h.length>1?h.map(i=>i.title).join(", "):"")}
|
|
12
12
|
role=${h.length?"button":void 0}
|
|
13
13
|
aria-label=${w||(h.length?h.length===1?h[0].title:h.map(i=>i.title).join(", "):void 0)}
|
|
@@ -33,7 +33,7 @@ import{a as j,n as $,i as P,x as v,t as H}from"../../vendor/vendor.js";import"./
|
|
|
33
33
|
${this._popupEvent&&Array.isArray(this._popupEvent.events)?v`
|
|
34
34
|
<scb-dialog variant="floating" open label="${a?"Events":"Händelser"} ${this._popupEvent.date}">
|
|
35
35
|
<scb-list>
|
|
36
|
-
${[...this._popupEvent.events].sort((n,l)=>{const y=n.start&&n.start.includes("T")?n.start:n.end&&n.end.includes("T")?n.end:"",o=l.start&&l.start.includes("T")?l.start:l.end&&l.end.includes("T")?l.end:"",m=y&&y.includes("T"),u=o&&o.includes("T");return m&&u?y.localeCompare(o):m?-1:u?1:n.title.localeCompare(l.title)}).map(n=>{const l=this._popupEvent?.date??"";let y="",o="",m="";if(n.start&&n.end){const u=n.start.split("T")[0],
|
|
36
|
+
${[...this._popupEvent.events].sort((n,l)=>{const y=n.start&&n.start.includes("T")?n.start:n.end&&n.end.includes("T")?n.end:"",o=l.start&&l.start.includes("T")?l.start:l.end&&l.end.includes("T")?l.end:"",m=y&&y.includes("T"),u=o&&o.includes("T");return m&&u?y.localeCompare(o):m?-1:u?1:n.title.localeCompare(l.title)}).map(n=>{const l=this._popupEvent?.date??"";let y="",o="",m="";if(n.start&&n.end){const u=n.start.split("T")[0],f=n.end.split("T")[0];u===f&&n.start.includes("T")&&n.end.includes("T")?y=n.start.split("T")[1].substring(0,5)+" – "+n.end.split("T")[1].substring(0,5):l===u&&n.start.includes("T")&&(y="Start: "+n.start.split("T")[1].substring(0,5)+(a?" (Extended event) ":" (Flerdagsevenemang) ")),l===f&&n.end.includes("T")&&u!==f&&(m=(a?"End: ":"Slut: ")+n.end.split("T")[1].substring(0,5)),l!==u&&(o=a?"cont. ":"fort. ")}else n.start&&n.start.includes("T")&&(y=n.start.split("T")[1].substring(0,5));return v`
|
|
37
37
|
<scb-list-item label="${o}${n.title}" supporting-text="${n.description?n.description:""}" overline="${y||""}${m||""}">
|
|
38
38
|
</scb-list-item>`})}
|
|
39
39
|
</scb-list>
|
|
@@ -46,6 +46,7 @@ import{a as j,n as $,i as P,x as v,t as H}from"../../vendor/vendor.js";import"./
|
|
|
46
46
|
padding: var(--spacing-5);
|
|
47
47
|
border-radius: var(--md-sys-shape-corner-large);
|
|
48
48
|
background: var(--md-sys-color-surface);
|
|
49
|
+
font-family: var(--brand-font);
|
|
49
50
|
}
|
|
50
51
|
.calendar-header {
|
|
51
52
|
display: flex;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.130",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -365,5 +365,5 @@
|
|
|
365
365
|
},
|
|
366
366
|
"./mvc/*": "./mvc/*"
|
|
367
367
|
},
|
|
368
|
-
"buildHash": "
|
|
368
|
+
"buildHash": "061F4A217571154EADA9203928D0933063F15EBF8C1DDCD5E81A63C7C619C838"
|
|
369
369
|
}
|
|
@@ -5,20 +5,20 @@ 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 q = Object.defineProperty, L = Object.getOwnPropertyDescriptor, x = (
|
|
9
|
-
for (var o = i > 1 ? void 0 : i ? L(
|
|
10
|
-
(c =
|
|
11
|
-
return i && o && q(
|
|
8
|
+
var q = Object.defineProperty, L = Object.getOwnPropertyDescriptor, x = (t, e, s, i) => {
|
|
9
|
+
for (var o = i > 1 ? void 0 : i ? L(e, s) : e, a = t.length - 1, c; a >= 0; a--)
|
|
10
|
+
(c = t[a]) && (o = (i ? c(e, s, o) : c(o)) || o);
|
|
11
|
+
return i && o && q(e, s, o), o;
|
|
12
12
|
};
|
|
13
13
|
let T = class extends P {
|
|
14
14
|
constructor() {
|
|
15
|
-
super(...arguments), 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._mutationObserver = null, this._syncingDisplay = !1, this._onCalendarKeyDown = (
|
|
15
|
+
super(...arguments), 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._mutationObserver = null, this._syncingDisplay = !1, this._onCalendarKeyDown = (t) => {
|
|
16
16
|
var _, f;
|
|
17
17
|
const s = Array.from(((_ = this.shadowRoot) == null ? void 0 : _.querySelectorAll(".calendar-day.has-event")) ?? []), i = (f = this.shadowRoot) == null ? void 0 : f.activeElement, o = i && s.includes(i) ? i : document.activeElement, a = s.indexOf(o);
|
|
18
18
|
if (a === -1) return;
|
|
19
19
|
let c = a;
|
|
20
20
|
const p = this.disableWeekend ? 5 : 7;
|
|
21
|
-
switch (
|
|
21
|
+
switch (t.key) {
|
|
22
22
|
case "ArrowRight":
|
|
23
23
|
c = a + 1 < s.length ? a + 1 : a;
|
|
24
24
|
break;
|
|
@@ -34,29 +34,29 @@ let T = class extends P {
|
|
|
34
34
|
default:
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
c !== a && (
|
|
37
|
+
c !== a && (t.preventDefault(), s[c].focus());
|
|
38
38
|
}, this._onEventChanged = () => {
|
|
39
39
|
this.requestUpdate();
|
|
40
40
|
}, this._today = /* @__PURE__ */ new Date(), this._current = /* @__PURE__ */ new Date(), this._popupEvent = null, this._restoreDayFocus = () => {
|
|
41
41
|
this._lastActiveDay && setTimeout(() => {
|
|
42
|
-
var
|
|
43
|
-
(
|
|
42
|
+
var t;
|
|
43
|
+
(t = this._lastActiveDay) == null || t.focus(), this._lastActiveDay = null;
|
|
44
44
|
}, 0);
|
|
45
45
|
}, this._easterDateCalculated = {};
|
|
46
46
|
}
|
|
47
47
|
connectedCallback() {
|
|
48
48
|
super.connectedCallback();
|
|
49
|
-
const
|
|
50
|
-
!Number.isNaN(
|
|
49
|
+
const t = Number(this.displayYear), e = Number(this.displayMonth);
|
|
50
|
+
!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(() => {
|
|
51
51
|
this.requestUpdate();
|
|
52
52
|
}), this._mutationObserver.observe(this, { childList: !0 }), this.addEventListener("keydown", this._onCalendarKeyDown);
|
|
53
53
|
}
|
|
54
54
|
disconnectedCallback() {
|
|
55
55
|
this.removeEventListener("change", this._onEventChanged), super.disconnectedCallback(), this._mutationObserver && (this._mutationObserver.disconnect(), this._mutationObserver = null), this.removeEventListener("keydown", this._onCalendarKeyDown);
|
|
56
56
|
}
|
|
57
|
-
updated(
|
|
58
|
-
var
|
|
59
|
-
if ((
|
|
57
|
+
updated(t) {
|
|
58
|
+
var e;
|
|
59
|
+
if ((e = super.updated) == null || e.call(this, t), !this._syncingDisplay && (t.has("displayYear") || t.has("displayMonth"))) {
|
|
60
60
|
const s = Number(this.displayYear), i = Number(this.displayMonth);
|
|
61
61
|
if (!Number.isNaN(s) && !Number.isNaN(i) && i >= 1 && i <= 12) {
|
|
62
62
|
const o = this._current.getFullYear(), a = this._current.getMonth() + 1;
|
|
@@ -70,27 +70,27 @@ let T = class extends P {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
_syncDisplayFromCurrent(
|
|
74
|
-
const
|
|
73
|
+
_syncDisplayFromCurrent(t = !0) {
|
|
74
|
+
const e = this._current.getFullYear(), s = this._current.getMonth() + 1;
|
|
75
75
|
this._syncingDisplay = !0;
|
|
76
76
|
try {
|
|
77
|
-
this.displayYear =
|
|
77
|
+
this.displayYear = e, this.displayMonth = s;
|
|
78
78
|
} finally {
|
|
79
79
|
this._syncingDisplay = !1;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
t && this.dispatchEvent(
|
|
82
82
|
new CustomEvent("scb-calendar-month-change", {
|
|
83
83
|
bubbles: !0,
|
|
84
84
|
composed: !0,
|
|
85
|
-
detail: { displayYear:
|
|
85
|
+
detail: { displayYear: e, displayMonth: s }
|
|
86
86
|
})
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
|
-
_daysInMonth(
|
|
90
|
-
return new Date(
|
|
89
|
+
_daysInMonth(t, e) {
|
|
90
|
+
return new Date(t, e + 1, 0).getDate();
|
|
91
91
|
}
|
|
92
|
-
_firstDayOfWeek(
|
|
93
|
-
const s = new Date(
|
|
92
|
+
_firstDayOfWeek(t, e) {
|
|
93
|
+
const s = new Date(t, e, 1).getDay();
|
|
94
94
|
return s === 0 ? 6 : s - 1;
|
|
95
95
|
}
|
|
96
96
|
_prevMonth() {
|
|
@@ -99,15 +99,15 @@ let T = class extends P {
|
|
|
99
99
|
_nextMonth() {
|
|
100
100
|
this._current = new Date(this._current.getFullYear(), this._current.getMonth() + 1, 1), this.selectedDate = "", this._popupEvent = null, this._syncDisplayFromCurrent(), this.requestUpdate();
|
|
101
101
|
}
|
|
102
|
-
_showEventPopup(
|
|
103
|
-
var
|
|
104
|
-
this._popupEvent =
|
|
102
|
+
_showEventPopup(t) {
|
|
103
|
+
var e;
|
|
104
|
+
this._popupEvent = t, this.selectedDate = t.date, this.dispatchEvent(
|
|
105
105
|
new CustomEvent("scb-calendar-select", {
|
|
106
106
|
bubbles: !0,
|
|
107
107
|
composed: !0,
|
|
108
|
-
detail: { selectedDate:
|
|
108
|
+
detail: { selectedDate: t.date }
|
|
109
109
|
})
|
|
110
|
-
), this._lastActiveDay = ((
|
|
110
|
+
), this._lastActiveDay = ((e = this.shadowRoot) == null ? void 0 : e.activeElement) || document.activeElement, this.requestUpdate(), setTimeout(() => {
|
|
111
111
|
var o;
|
|
112
112
|
const s = (o = this.shadowRoot) == null ? void 0 : o.querySelector("scb-dialog");
|
|
113
113
|
s && (document.activeElement && (s.__lastTriggerEl = document.activeElement), s.open = !0, s.addEventListener("close", this._restoreDayFocus, { once: !0 }));
|
|
@@ -119,48 +119,48 @@ let T = class extends P {
|
|
|
119
119
|
}, 0);
|
|
120
120
|
}
|
|
121
121
|
_closePopup() {
|
|
122
|
-
var
|
|
123
|
-
const
|
|
124
|
-
|
|
122
|
+
var e;
|
|
123
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("scb-dialog");
|
|
124
|
+
t && t.removeAttribute("open"), this._popupEvent = null, this.requestUpdate();
|
|
125
125
|
}
|
|
126
|
-
_addDays(
|
|
127
|
-
const s = new Date(
|
|
128
|
-
return s.setDate(s.getDate() +
|
|
126
|
+
_addDays(t, e) {
|
|
127
|
+
const s = new Date(t.valueOf());
|
|
128
|
+
return s.setDate(s.getDate() + e), s;
|
|
129
129
|
}
|
|
130
|
-
_easterDay(
|
|
131
|
-
if (typeof this._easterDateCalculated["Ar" +
|
|
132
|
-
return new Date(this._easterDateCalculated["Ar" +
|
|
133
|
-
let
|
|
134
|
-
|
|
135
|
-
const s =
|
|
130
|
+
_easterDay(t) {
|
|
131
|
+
if (typeof this._easterDateCalculated["Ar" + t] < "u")
|
|
132
|
+
return new Date(this._easterDateCalculated["Ar" + t]);
|
|
133
|
+
let e = t;
|
|
134
|
+
e < 100 && (e = e + 1900), e < 1950 && (e = e + 100);
|
|
135
|
+
const s = e % 19, i = e % 4, o = e % 7, a = (19 * s + 24) % 30, c = (2 * i + 4 * o + 6 * a + 5) % 7;
|
|
136
136
|
let p = 22 + a + c, _ = 0;
|
|
137
137
|
p == 57 && (p -= 7), p == 56 && a == 28 && c == 6 && s > 10 && (p -= 7), p > 31 ? (p -= 31, _ = 4) : _ = 3;
|
|
138
|
-
const f = new Date(
|
|
139
|
-
return this._easterDateCalculated["Ar" +
|
|
138
|
+
const f = new Date(e, _ - 1, p);
|
|
139
|
+
return this._easterDateCalculated["Ar" + t] = f, new Date(this._easterDateCalculated["Ar" + t]);
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* Returnerar namnet på svensk helgdag eller null om det inte är en helgdag
|
|
143
143
|
*/
|
|
144
|
-
_swedishHolidayName(
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
147
|
-
const s =
|
|
144
|
+
_swedishHolidayName(t) {
|
|
145
|
+
const e = t.getMonth();
|
|
146
|
+
if (e === 1 || e === 6 || e === 7 || e === 8) return null;
|
|
147
|
+
const s = t.getMonth() + 1, i = t.getDate(), o = t.getFullYear(), a = this._easterDay(o), c = this.lang === "en", p = [
|
|
148
148
|
// [svenska, engelska, villkor]
|
|
149
149
|
["Nyårsdagen", "New Year's Day", s === 1 && i === 1],
|
|
150
150
|
["Trettondedag jul", "Epiphany", s === 1 && i === 6],
|
|
151
|
-
["Långfredag", "Good Friday", +
|
|
152
|
-
["Påskdagen", "Easter Sunday", +
|
|
153
|
-
["Annandag påsk", "Easter Monday", +
|
|
154
|
-
["Kristi himmelsfärdsdag", "Ascension Day", +
|
|
155
|
-
["Pingstdagen", "Pentecost", +
|
|
151
|
+
["Långfredag", "Good Friday", +t == +this._addDays(a, -2)],
|
|
152
|
+
["Påskdagen", "Easter Sunday", +t == +a],
|
|
153
|
+
["Annandag påsk", "Easter Monday", +t == +this._addDays(a, 1)],
|
|
154
|
+
["Kristi himmelsfärdsdag", "Ascension Day", +t == +this._addDays(a, 39)],
|
|
155
|
+
["Pingstdagen", "Pentecost", +t == +this._addDays(a, 50) && o < 2005],
|
|
156
156
|
["Första maj", "May Day", s === 5 && i === 1],
|
|
157
157
|
["Nationaldagen", "National Day", s === 6 && i === 6 && o >= 2005],
|
|
158
|
-
["Midsommarafton", "Midsummer's Eve", s === 6 && i >= 19 && i <= 25 &&
|
|
159
|
-
["Midsommardagen", "Midsummer's Day", s === 6 && i >= 20 && i <= 26 &&
|
|
158
|
+
["Midsommarafton", "Midsummer's Eve", s === 6 && i >= 19 && i <= 25 && t.getDay() === 5],
|
|
159
|
+
["Midsommardagen", "Midsummer's Day", s === 6 && i >= 20 && i <= 26 && t.getDay() === 6],
|
|
160
160
|
["Julafton", "Christmas Eve", s === 12 && i === 24],
|
|
161
161
|
["Juldagen", "Christmas Day", s === 12 && i === 25],
|
|
162
162
|
["Annandag jul", "Boxing Day", s === 12 && i === 26],
|
|
163
|
-
["Alla helgons dag", "All Saints' Day", s === 10 && i >= 31 &&
|
|
163
|
+
["Alla helgons dag", "All Saints' Day", s === 10 && i >= 31 && t.getDay() === 6 || s === 11 && i <= 6 && t.getDay() === 6]
|
|
164
164
|
];
|
|
165
165
|
for (const _ of p) {
|
|
166
166
|
const [f, N, A] = _;
|
|
@@ -169,7 +169,7 @@ let T = class extends P {
|
|
|
169
169
|
return null;
|
|
170
170
|
}
|
|
171
171
|
render() {
|
|
172
|
-
const
|
|
172
|
+
const t = this._current.getFullYear(), e = this._current.getMonth(), s = this._daysInMonth(t, e), i = this._firstDayOfWeek(t, e), o = this._today, a = this.lang === "en", c = a ? [
|
|
173
173
|
"January",
|
|
174
174
|
"February",
|
|
175
175
|
"March",
|
|
@@ -226,7 +226,7 @@ let T = class extends P {
|
|
|
226
226
|
const g = h[y];
|
|
227
227
|
if (n === 0 && g < i) {
|
|
228
228
|
if (!this.disableWeekend || g < 5) {
|
|
229
|
-
const m =
|
|
229
|
+
const m = e === 0 ? 11 : e - 1, w = e === 0 ? t - 1 : t, S = this._daysInMonth(w, m) - (i - g - 1);
|
|
230
230
|
l.push(D`
|
|
231
231
|
<div class="calendar-day calendar-day--other">
|
|
232
232
|
<span class="calendar-day-number">${S}</span>
|
|
@@ -236,15 +236,15 @@ let T = class extends P {
|
|
|
236
236
|
} else if (d > s)
|
|
237
237
|
l.push(D`<div></div>`);
|
|
238
238
|
else {
|
|
239
|
-
let m = new Date(
|
|
239
|
+
let m = new Date(t, e, d);
|
|
240
240
|
if (this.disableWeekend)
|
|
241
241
|
for (; m.getDay() === 0 || m.getDay() === 6; )
|
|
242
|
-
d++, m = new Date(
|
|
242
|
+
d++, m = new Date(t, e, d);
|
|
243
243
|
if (d > s) {
|
|
244
244
|
l.push(D`<div></div>`);
|
|
245
245
|
continue;
|
|
246
246
|
}
|
|
247
|
-
const w = o.getFullYear() ===
|
|
247
|
+
const w = o.getFullYear() === t && o.getMonth() === e && o.getDate() === d, v = `${t}-${String(e + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`, S = new Date(t, e, d);
|
|
248
248
|
let F = !1, E = null;
|
|
249
249
|
this.publicHolidays && (E = this._swedishHolidayName(S), F = !!E);
|
|
250
250
|
let u = f.get(v) || [];
|
|
@@ -286,7 +286,7 @@ let T = class extends P {
|
|
|
286
286
|
return D`
|
|
287
287
|
<div class="calendar-header">
|
|
288
288
|
<scb-icon-button @click=${this._prevMonth} icon="chevron_left" aria-label="${a ? "Previous month" : "Föregående månad"}"></scb-icon-button>
|
|
289
|
-
<span>${c[
|
|
289
|
+
<span>${c[e]} ${t}</span>
|
|
290
290
|
<scb-icon-button @click=${this._nextMonth} icon="chevron_right" aria-label="${a ? "Next month" : "Nästa månad"}"></scb-icon-button>
|
|
291
291
|
</div>
|
|
292
292
|
<div class="calendar-grid calendar-grid-days">
|
|
@@ -326,6 +326,7 @@ T.styles = j`
|
|
|
326
326
|
padding: var(--spacing-5);
|
|
327
327
|
border-radius: var(--md-sys-shape-corner-large);
|
|
328
328
|
background: var(--md-sys-color-surface);
|
|
329
|
+
font-family: var(--brand-font);
|
|
329
330
|
}
|
|
330
331
|
.calendar-header {
|
|
331
332
|
display: flex;
|
package/scb-wc-test.bundle.js
CHANGED