@oslokommune/punkt-elements 13.6.5 → 13.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/{calendar-ChphTIhk.js → calendar-CodWwTHM.js} +503 -471
- package/dist/calendar-DH-fCGyW.cjs +115 -0
- package/dist/{combobox-COuxR036.cjs → combobox-CNH-j9Za.cjs} +7 -7
- package/dist/{combobox-D3aPvdrE.js → combobox-C_pTRtsQ.js} +181 -180
- package/dist/datepicker-BEMo4X9s.js +770 -0
- package/dist/datepicker-n49TAIAt.cjs +169 -0
- package/dist/index.d.ts +7 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +4 -4
- package/package.json +2 -2
- package/src/components/calendar/calendar.ts +26 -28
- package/src/components/combobox/combobox.test.ts +22 -0
- package/src/components/combobox/combobox.ts +19 -8
- package/src/components/datepicker/date-tags.ts +2 -1
- package/src/components/datepicker/datepicker-utils.ts +475 -0
- package/src/components/datepicker/datepicker.selection.test.ts +62 -1
- package/src/components/datepicker/datepicker.ts +157 -271
- package/dist/calendar-CL9O0tLP.cjs +0 -115
- package/dist/datepicker-CV73pLqD.cjs +0 -169
- package/dist/datepicker-Ca552mbJ.js +0 -531
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";const j=require("./class-map-CG3vIaNm.cjs"),c=require("./element-D62wHiNU.cjs"),A=require("./state-BkE_Rxl7.cjs");require("./icon-__Hjt2XZ.cjs");const nt=6048e5,ut=864e5,G=Symbol.for("constructDateFrom");function v(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&G in n?n[G](t):n instanceof Date?new n.constructor(t):new Date(t)}function k(n,t){return v(t||n,n)}function L(n,t,e){const r=k(n,e==null?void 0:e.in);return isNaN(t)?v(n,NaN):(t&&r.setDate(r.getDate()+t),r)}let ht={};function I(){return ht}function Y(n,t){var o,l,u,d;const e=I(),r=(t==null?void 0:t.weekStartsOn)??((l=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:l.weekStartsOn)??e.weekStartsOn??((d=(u=e.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,a=k(n,t==null?void 0:t.in),s=a.getDay(),i=(s<r?7:0)+s-r;return a.setDate(a.getDate()-i),a.setHours(0,0,0,0),a}function H(n,t){return Y(n,{...t,weekStartsOn:1})}function rt(n,t){const e=k(n,t==null?void 0:t.in),r=e.getFullYear(),a=v(e,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const s=H(a),i=v(e,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const o=H(i);return e.getTime()>=s.getTime()?r+1:e.getTime()>=o.getTime()?r:r-1}function X(n){const t=k(n),e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),+n-+e}function at(n,...t){const e=v.bind(null,t.find(r=>typeof r=="object"));return t.map(e)}function z(n,t){const e=k(n,t==null?void 0:t.in);return e.setHours(0,0,0,0),e}function dt(n,t,e){const[r,a]=at(e==null?void 0:e.in,n,t),s=z(r),i=z(a),o=+s-X(s),l=+i-X(i);return Math.round((o-l)/ut)}function ft(n,t){const e=rt(n,t),r=v(n,0);return r.setFullYear(e,0,4),r.setHours(0,0,0,0),H(r)}function mt(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function gt(n){return!(!mt(n)&&typeof n!="number"||isNaN(+k(n)))}function yt(n,t){const e=k(n,t==null?void 0:t.in);return e.setHours(23,59,59,999),e}function pt(n,t){const[e,r]=at(n,t.start,t.end);return{start:e,end:r}}function R(n,t){const{start:e,end:r}=pt(t==null?void 0:t.in,n);let a=+e>+r;const s=a?+e:+r,i=a?r:e;i.setHours(0,0,0,0);let o=1;const l=[];for(;+i<=s;)l.push(v(e,i)),i.setDate(i.getDate()+o),i.setHours(0,0,0,0);return a?l.reverse():l}function wt(n,t){const e=k(n,t==null?void 0:t.in);return e.setFullYear(e.getFullYear(),0,1),e.setHours(0,0,0,0),e}const bt={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},kt=(n,t,e)=>{let r;const a=bt[n];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"in "+r:r+" ago":r};function U(n){return(t={})=>{const e=t.width?String(t.width):n.defaultWidth;return n.formats[e]||n.formats[n.defaultWidth]}}const Dt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},St={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},vt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Mt={date:U({formats:Dt,defaultWidth:"full"}),time:U({formats:St,defaultWidth:"full"}),dateTime:U({formats:vt,defaultWidth:"full"})},xt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Tt=(n,t,e,r)=>xt[n];function N(n){return(t,e)=>{const r=e!=null&&e.context?String(e.context):"standalone";let a;if(r==="formatting"&&n.formattingValues){const i=n.defaultFormattingWidth||n.defaultWidth,o=e!=null&&e.width?String(e.width):i;a=n.formattingValues[o]||n.formattingValues[i]}else{const i=n.defaultWidth,o=e!=null&&e.width?String(e.width):n.defaultWidth;a=n.values[o]||n.values[i]}const s=n.argumentCallback?n.argumentCallback(t):t;return a[s]}}const Pt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Ot={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ct={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},$t={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Nt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},_t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Et=(n,t)=>{const e=Number(n),r=e%100;if(r>20||r<10)switch(r%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},Wt={ordinalNumber:Et,era:N({values:Pt,defaultWidth:"wide"}),quarter:N({values:Ot,defaultWidth:"wide",argumentCallback:n=>n-1}),month:N({values:Ct,defaultWidth:"wide"}),day:N({values:$t,defaultWidth:"wide"}),dayPeriod:N({values:Nt,defaultWidth:"wide",formattingValues:_t,defaultFormattingWidth:"wide"})};function _(n){return(t,e={})=>{const r=e.width,a=r&&n.matchPatterns[r]||n.matchPatterns[n.defaultMatchWidth],s=t.match(a);if(!s)return null;const i=s[0],o=r&&n.parsePatterns[r]||n.parsePatterns[n.defaultParseWidth],l=Array.isArray(o)?At(o,g=>g.test(i)):Yt(o,g=>g.test(i));let u;u=n.valueCallback?n.valueCallback(l):l,u=e.valueCallback?e.valueCallback(u):u;const d=t.slice(i.length);return{value:u,rest:d}}}function Yt(n,t){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&t(n[e]))return e}function At(n,t){for(let e=0;e<n.length;e++)if(t(n[e]))return e}function Ft(n){return(t,e={})=>{const r=t.match(n.matchPattern);if(!r)return null;const a=r[0],s=t.match(n.parsePattern);if(!s)return null;let i=n.valueCallback?n.valueCallback(s[0]):s[0];i=e.valueCallback?e.valueCallback(i):i;const o=t.slice(a.length);return{value:i,rest:o}}}const Ht=/^(\d+)(th|st|nd|rd)?/i,It=/\d+/i,qt={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Lt={any:[/^b/i,/^(a|c)/i]},Rt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Ut={any:[/1/i,/2/i,/3/i,/4/i]},Bt={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},zt={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Qt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},jt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Gt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Xt={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Vt={ordinalNumber:Ft({matchPattern:Ht,parsePattern:It,valueCallback:n=>parseInt(n,10)}),era:_({matchPatterns:qt,defaultMatchWidth:"wide",parsePatterns:Lt,defaultParseWidth:"any"}),quarter:_({matchPatterns:Rt,defaultMatchWidth:"wide",parsePatterns:Ut,defaultParseWidth:"any",valueCallback:n=>n+1}),month:_({matchPatterns:Bt,defaultMatchWidth:"wide",parsePatterns:zt,defaultParseWidth:"any"}),day:_({matchPatterns:Qt,defaultMatchWidth:"wide",parsePatterns:jt,defaultParseWidth:"any"}),dayPeriod:_({matchPatterns:Gt,defaultMatchWidth:"any",parsePatterns:Xt,defaultParseWidth:"any"})},Jt={code:"en-US",formatDistance:kt,formatLong:Mt,formatRelative:Tt,localize:Wt,match:Vt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Kt(n,t){const e=k(n,t==null?void 0:t.in);return dt(e,wt(e))+1}function Zt(n,t){const e=k(n,t==null?void 0:t.in),r=+H(e)-+ft(e);return Math.round(r/nt)+1}function st(n,t){var d,g,p,w;const e=k(n,t==null?void 0:t.in),r=e.getFullYear(),a=I(),s=(t==null?void 0:t.firstWeekContainsDate)??((g=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:g.firstWeekContainsDate)??a.firstWeekContainsDate??((w=(p=a.locale)==null?void 0:p.options)==null?void 0:w.firstWeekContainsDate)??1,i=v((t==null?void 0:t.in)||n,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const o=Y(i,t),l=v((t==null?void 0:t.in)||n,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const u=Y(l,t);return+e>=+o?r+1:+e>=+u?r:r-1}function te(n,t){var o,l,u,d;const e=I(),r=(t==null?void 0:t.firstWeekContainsDate)??((l=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:l.firstWeekContainsDate)??e.firstWeekContainsDate??((d=(u=e.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,a=st(n,t),s=v((t==null?void 0:t.in)||n,0);return s.setFullYear(a,0,r),s.setHours(0,0,0,0),Y(s,t)}function it(n,t){const e=k(n,t==null?void 0:t.in),r=+Y(e,t)-+te(e,t);return Math.round(r/nt)+1}function h(n,t){const e=n<0?"-":"",r=Math.abs(n).toString().padStart(t,"0");return e+r}const M={y(n,t){const e=n.getFullYear(),r=e>0?e:1-e;return h(t==="yy"?r%100:r,t.length)},M(n,t){const e=n.getMonth();return t==="M"?String(e+1):h(e+1,2)},d(n,t){return h(n.getDate(),t.length)},a(n,t){const e=n.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.toUpperCase();case"aaa":return e;case"aaaaa":return e[0];case"aaaa":default:return e==="am"?"a.m.":"p.m."}},h(n,t){return h(n.getHours()%12||12,t.length)},H(n,t){return h(n.getHours(),t.length)},m(n,t){return h(n.getMinutes(),t.length)},s(n,t){return h(n.getSeconds(),t.length)},S(n,t){const e=t.length,r=n.getMilliseconds(),a=Math.trunc(r*Math.pow(10,e-3));return h(a,t.length)}},C={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},V={G:function(n,t,e){const r=n.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return e.era(r,{width:"abbreviated"});case"GGGGG":return e.era(r,{width:"narrow"});case"GGGG":default:return e.era(r,{width:"wide"})}},y:function(n,t,e){if(t==="yo"){const r=n.getFullYear(),a=r>0?r:1-r;return e.ordinalNumber(a,{unit:"year"})}return M.y(n,t)},Y:function(n,t,e,r){const a=st(n,r),s=a>0?a:1-a;if(t==="YY"){const i=s%100;return h(i,2)}return t==="Yo"?e.ordinalNumber(s,{unit:"year"}):h(s,t.length)},R:function(n,t){const e=rt(n);return h(e,t.length)},u:function(n,t){const e=n.getFullYear();return h(e,t.length)},Q:function(n,t,e){const r=Math.ceil((n.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return h(r,2);case"Qo":return e.ordinalNumber(r,{unit:"quarter"});case"QQQ":return e.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return e.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return e.quarter(r,{width:"wide",context:"formatting"})}},q:function(n,t,e){const r=Math.ceil((n.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return h(r,2);case"qo":return e.ordinalNumber(r,{unit:"quarter"});case"qqq":return e.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return e.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return e.quarter(r,{width:"wide",context:"standalone"})}},M:function(n,t,e){const r=n.getMonth();switch(t){case"M":case"MM":return M.M(n,t);case"Mo":return e.ordinalNumber(r+1,{unit:"month"});case"MMM":return e.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return e.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return e.month(r,{width:"wide",context:"formatting"})}},L:function(n,t,e){const r=n.getMonth();switch(t){case"L":return String(r+1);case"LL":return h(r+1,2);case"Lo":return e.ordinalNumber(r+1,{unit:"month"});case"LLL":return e.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return e.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return e.month(r,{width:"wide",context:"standalone"})}},w:function(n,t,e,r){const a=it(n,r);return t==="wo"?e.ordinalNumber(a,{unit:"week"}):h(a,t.length)},I:function(n,t,e){const r=Zt(n);return t==="Io"?e.ordinalNumber(r,{unit:"week"}):h(r,t.length)},d:function(n,t,e){return t==="do"?e.ordinalNumber(n.getDate(),{unit:"date"}):M.d(n,t)},D:function(n,t,e){const r=Kt(n);return t==="Do"?e.ordinalNumber(r,{unit:"dayOfYear"}):h(r,t.length)},E:function(n,t,e){const r=n.getDay();switch(t){case"E":case"EE":case"EEE":return e.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return e.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return e.day(r,{width:"short",context:"formatting"});case"EEEE":default:return e.day(r,{width:"wide",context:"formatting"})}},e:function(n,t,e,r){const a=n.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return h(s,2);case"eo":return e.ordinalNumber(s,{unit:"day"});case"eee":return e.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return e.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return e.day(a,{width:"short",context:"formatting"});case"eeee":default:return e.day(a,{width:"wide",context:"formatting"})}},c:function(n,t,e,r){const a=n.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return h(s,t.length);case"co":return e.ordinalNumber(s,{unit:"day"});case"ccc":return e.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return e.day(a,{width:"narrow",context:"standalone"});case"cccccc":return e.day(a,{width:"short",context:"standalone"});case"cccc":default:return e.day(a,{width:"wide",context:"standalone"})}},i:function(n,t,e){const r=n.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return h(a,t.length);case"io":return e.ordinalNumber(a,{unit:"day"});case"iii":return e.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return e.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return e.day(r,{width:"short",context:"formatting"});case"iiii":default:return e.day(r,{width:"wide",context:"formatting"})}},a:function(n,t,e){const a=n.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return e.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return e.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(n,t,e){const r=n.getHours();let a;switch(r===12?a=C.noon:r===0?a=C.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return e.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return e.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(n,t,e){const r=n.getHours();let a;switch(r>=17?a=C.evening:r>=12?a=C.afternoon:r>=4?a=C.morning:a=C.night,t){case"B":case"BB":case"BBB":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return e.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return e.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(n,t,e){if(t==="ho"){let r=n.getHours()%12;return r===0&&(r=12),e.ordinalNumber(r,{unit:"hour"})}return M.h(n,t)},H:function(n,t,e){return t==="Ho"?e.ordinalNumber(n.getHours(),{unit:"hour"}):M.H(n,t)},K:function(n,t,e){const r=n.getHours()%12;return t==="Ko"?e.ordinalNumber(r,{unit:"hour"}):h(r,t.length)},k:function(n,t,e){let r=n.getHours();return r===0&&(r=24),t==="ko"?e.ordinalNumber(r,{unit:"hour"}):h(r,t.length)},m:function(n,t,e){return t==="mo"?e.ordinalNumber(n.getMinutes(),{unit:"minute"}):M.m(n,t)},s:function(n,t,e){return t==="so"?e.ordinalNumber(n.getSeconds(),{unit:"second"}):M.s(n,t)},S:function(n,t){return M.S(n,t)},X:function(n,t,e){const r=n.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return K(r);case"XXXX":case"XX":return O(r);case"XXXXX":case"XXX":default:return O(r,":")}},x:function(n,t,e){const r=n.getTimezoneOffset();switch(t){case"x":return K(r);case"xxxx":case"xx":return O(r);case"xxxxx":case"xxx":default:return O(r,":")}},O:function(n,t,e){const r=n.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+J(r,":");case"OOOO":default:return"GMT"+O(r,":")}},z:function(n,t,e){const r=n.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+J(r,":");case"zzzz":default:return"GMT"+O(r,":")}},t:function(n,t,e){const r=Math.trunc(+n/1e3);return h(r,t.length)},T:function(n,t,e){return h(+n,t.length)}};function J(n,t=""){const e=n>0?"-":"+",r=Math.abs(n),a=Math.trunc(r/60),s=r%60;return s===0?e+String(a):e+String(a)+t+h(s,2)}function K(n,t){return n%60===0?(n>0?"-":"+")+h(Math.abs(n)/60,2):O(n,t)}function O(n,t=""){const e=n>0?"-":"+",r=Math.abs(n),a=h(Math.trunc(r/60),2),s=h(r%60,2);return e+a+t+s}const Z=(n,t)=>{switch(n){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},ot=(n,t)=>{switch(n){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},ee=(n,t)=>{const e=n.match(/(P+)(p+)?/)||[],r=e[1],a=e[2];if(!a)return Z(n,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",Z(r,t)).replace("{{time}}",ot(a,t))},ne={p:ot,P:ee},re=/^D+$/,ae=/^Y+$/,se=["D","DD","YY","YYYY"];function ie(n){return re.test(n)}function oe(n){return ae.test(n)}function ce(n,t,e){const r=le(n,t,e);if(console.warn(r),se.includes(n))throw new RangeError(r)}function le(n,t,e){const r=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${t}\`) for formatting ${r} to the input \`${e}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const ue=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,he=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,de=/^'([^]*?)'?$/,fe=/''/g,me=/[a-zA-Z]/;function ge(n,t,e){var d,g,p,w;const r=I(),a=r.locale??Jt,s=r.firstWeekContainsDate??((g=(d=r.locale)==null?void 0:d.options)==null?void 0:g.firstWeekContainsDate)??1,i=r.weekStartsOn??((w=(p=r.locale)==null?void 0:p.options)==null?void 0:w.weekStartsOn)??0,o=k(n,e==null?void 0:e.in);if(!gt(o))throw new RangeError("Invalid time value");let l=t.match(he).map(m=>{const b=m[0];if(b==="p"||b==="P"){const q=ne[b];return q(m,a.formatLong)}return m}).join("").match(ue).map(m=>{if(m==="''")return{isToken:!1,value:"'"};const b=m[0];if(b==="'")return{isToken:!1,value:ye(m)};if(V[b])return{isToken:!0,value:m};if(b.match(me))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:m}});a.localize.preprocessor&&(l=a.localize.preprocessor(o,l));const u={firstWeekContainsDate:s,weekStartsOn:i,locale:a};return l.map(m=>{if(!m.isToken)return m.value;const b=m.value;(oe(b)||ie(b))&&ce(b,t,String(n));const q=V[b[0]];return q(o,b,a.localize,u)}).join("")}function ye(n){const t=n.match(de);return t?t[1].replace(fe,"'"):n}function pe(n,t){const e=k(n,t==null?void 0:t.in).getDay();return e===0?7:e}const B={},E={};function W(n,t){try{const r=(B[n]||(B[n]=new Intl.DateTimeFormat("en-GB",{timeZone:n,hour:"numeric",timeZoneName:"longOffset"}).format))(t).split("GMT")[1]||"";return r in E?E[r]:tt(r,r.split(":"))}catch{if(n in E)return E[n];const e=n==null?void 0:n.match(we);return e?tt(n,e.slice(1)):NaN}}const we=/([+-]\d\d):?(\d\d)?/;function tt(n,t){const e=+t[0],r=+(t[1]||0);return E[n]=e>0?e*60+r:e*60-r}class S extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(W(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),ct(this),Q(this)):this.setTime(Date.now())}static tz(t,...e){return e.length?new S(...e,t):new S(Date.now(),t)}withTimeZone(t){return new S(+this,t)}getTimezoneOffset(){return-W(this.timeZone,this)}setTime(t){return Date.prototype.setTime.apply(this,arguments),Q(this),+this}[Symbol.for("constructDateFrom")](t){return new S(+new Date(t),this.timeZone)}}const et=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(n=>{if(!et.test(n))return;const t=n.replace(et,"$1UTC");S.prototype[t]&&(n.startsWith("get")?S.prototype[n]=function(){return this.internal[t]()}:(S.prototype[n]=function(){return Date.prototype[t].apply(this.internal,arguments),be(this),+this},S.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),Q(this),+this}))});function Q(n){n.internal.setTime(+n),n.internal.setUTCMinutes(n.internal.getUTCMinutes()-n.getTimezoneOffset())}function be(n){Date.prototype.setFullYear.call(n,n.internal.getUTCFullYear(),n.internal.getUTCMonth(),n.internal.getUTCDate()),Date.prototype.setHours.call(n,n.internal.getUTCHours(),n.internal.getUTCMinutes(),n.internal.getUTCSeconds(),n.internal.getUTCMilliseconds()),ct(n)}function ct(n){const t=W(n.timeZone,n),e=new Date(+n);e.setUTCHours(e.getUTCHours()-1);const r=-new Date(+n).getTimezoneOffset(),a=-new Date(+e).getTimezoneOffset(),s=r-a,i=Date.prototype.getHours.apply(n)!==n.internal.getUTCHours();s&&i&&n.internal.setUTCMinutes(n.internal.getUTCMinutes()+s);const o=r-t;o&&Date.prototype.setUTCMinutes.call(n,Date.prototype.getUTCMinutes.call(n)+o);const l=W(n.timeZone,n),d=-new Date(+n).getTimezoneOffset()-l,g=l!==t,p=d-o;if(g&&p){Date.prototype.setUTCMinutes.call(n,Date.prototype.getUTCMinutes.call(n)+p);const w=W(n.timeZone,n),m=l-w;m&&(n.internal.setUTCMinutes(n.internal.getUTCMinutes()+m),Date.prototype.setUTCMinutes.call(n,Date.prototype.getUTCMinutes.call(n)+m))}}class $ extends S{static tz(t,...e){return e.length?new $(...e,t):new $(Date.now(),t)}toISOString(){const[t,e,r]=this.tzComponents(),a=`${t}${e}:${r}`;return this.internal.toISOString().slice(0,-1)+a}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,e,r,a]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${e} ${a}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[e,r,a]=this.tzComponents();return`${t} GMT${e}${r}${a} (${ke(this.timeZone,this)})`}toLocaleString(t,e){return Date.prototype.toLocaleString.call(this,t,{...e,timeZone:(e==null?void 0:e.timeZone)||this.timeZone})}toLocaleDateString(t,e){return Date.prototype.toLocaleDateString.call(this,t,{...e,timeZone:(e==null?void 0:e.timeZone)||this.timeZone})}toLocaleTimeString(t,e){return Date.prototype.toLocaleTimeString.call(this,t,{...e,timeZone:(e==null?void 0:e.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),e=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),a=String(Math.abs(t)%60).padStart(2,"0");return[e,r,a]}withTimeZone(t){return new $(+this,t)}[Symbol.for("constructDateFrom")](t){return new $(+new Date(t),this.timeZone)}}function ke(n,t){return new Intl.DateTimeFormat("en-GB",{timeZone:n,timeZoneName:"long"}).format(t).slice(12)}window.pktTz=window.pktTz===void 0?"Europe/Oslo":window.pktTz;const De=(n=window.pktTz)=>{const t=new $(new Date().toISOString(),n);return t.setHours(0,0,0,0),isNaN(t.getTime())?new Date:new Date(t.getFullYear(),t.getMonth(),t.getDate())};function T(n){if(!n||n==="")return new Date;if(/^\d{4}-\d{2}-\d{2}$/.test(n)){const[t,e,r]=n.split("-").map(Number);return new Date(t,e-1,r)}if(/^\d{4}-\d{2}$/.test(n)){const[t,e]=n.split("-").map(Number);return new Date(t,e-1,1)}return/^\d{4}$/.test(n)?new Date(Number(n),0,1):new Date(n)}const y=n=>{if(!n||isNaN(n.getTime()))return"";const t=n.getFullYear(),e=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0");return`${t}-${e}-${r}`},Se=n=>{if(!n)return null;const t=T(n);return isNaN(t.getTime())?null:t},ve=(n,t)=>{const e=D(n);return isNaN(e.getTime())?"":ge(e,t)},D=(n="",t)=>{const e=typeof n=="string"?T(n):n;return!e||isNaN(e.getTime())?new Date:t?t==="end"?yt(e):z(e):e},x=(n,t,e=1)=>{if(typeof n!="number"||typeof t!="number"||typeof e!="number"||isNaN(n)||isNaN(t)||isNaN(e))return new Date;const r=new Date(n,t,e);return isNaN(r.getTime())?new Date:r},Me=n=>!n||isNaN(n.getTime())?"":new Intl.DateTimeFormat("no",{dateStyle:"full",timeZone:window.pktTz}).format(n),lt=n=>{if(Array.isArray(n))return n;if(typeof n=="string")return n.split(",")},xe=n=>n?T(n):null,Te=n=>{if(typeof n=="string")return n.split(",").map(t=>T(t));if(Array.isArray(n))return n.map(t=>T(t))},F={csvToArray:lt,stringToDate:xe,stringsToDate:Te},Pe={earliest:{default:null},latest:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},maxMultiple:{default:4},range:{default:!1}},P={props:Pe};var Oe=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,f=(n,t,e,r)=>{for(var a=r>1?void 0:r?Ce(t,e):t,s=n.length-1,i;s>=0;s--)(i=n[s])&&(a=(r?i(t,e,a):i(a))||a);return r&&a&&Oe(t,e,a),a};exports.PktCalendar=class extends c.PktElement{constructor(){super(...arguments),this.multiple=P.props.multiple.default,this.maxMultiple=P.props.maxMultiple.default,this.range=P.props.range.default,this.weeknumbers=P.props.weeknumbers.default,this.withcontrols=P.props.withcontrols.default,this.selected=[],this.earliest=P.props.earliest.default,this.latest=P.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.dayStrings=this.strings.dates.daysShort,this.dayStringsLong=this.strings.dates.days,this.monthStrings=this.strings.dates.months,this.weekString=this.strings.dates.week,this.prevMonthString=this.strings.dates.prevMonth,this.nextMonthString=this.strings.dates.nextMonth,this._selected=[],this.year=0,this.month=0,this.week=0,this.rangeHovered=null,this.inRange={},this.focusedDate=null,this.selectableDates=[],this.currentmonthtouched=!1,this.tabIndexSet=0}connectedCallback(){super.connectedCallback()}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}attributeChangedCallback(t,e,r){t==="selected"&&r&&this.convertSelected(),super.attributeChangedCallback(t,e,r)}updated(t){super.updated(t),t.has("selected")&&this.convertSelected()}firstUpdated(t){this.addEventListener("keydown",this.handleKeydown)}convertSelected(){if(typeof this.selected=="string"&&(this.selected=this.selected.split(",")),this.selected.length===1&&this.selected[0]===""&&(this.selected=[]),this._selected=this.selected.map(t=>T(t)),this.range&&this.selected.length===2){const t=R({start:this._selected[0],end:this._selected[1]});if(this.inRange={},Array.isArray(t)&&t.length){const e={};for(let r=0;r<t.length;r++){const a=t[r],s=a>this._selected[0]&&a<this._selected[1];e[y(a)]=s}this.inRange=e}}this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched&&(this.currentmonthtouched=!0),this.selected.length&&this.selected[0]!==""){const t=T(this.selected[this.selected.length-1]);this.currentmonth=isNaN(t.getTime())?new Date:t}else this.currentmonth===null&&(this.currentmonth=new Date);(!this.currentmonth||isNaN(this.currentmonth.getTime()))&&(this.currentmonth=new Date),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(t){switch(t.key){case"ArrowLeft":this.handleArrowKey(t,-1);break;case"ArrowRight":this.handleArrowKey(t,1);break;case"ArrowUp":this.handleArrowKey(t,-7);break;case"ArrowDown":this.handleArrowKey(t,7);break}}handleArrowKey(t,e){var s,i,o,l,u;if(((s=t.target)==null?void 0:s.nodeName)==="INPUT"||((i=t.target)==null?void 0:i.nodeName)==="SELECT"||((o=t.target)==null?void 0:o.nodeName)==="BUTTON"&&!((u=(l=t.target)==null?void 0:l.dataset)!=null&&u.date))return;t.preventDefault(),this.focusedDate||this.focusOnCurrentDate();const r=this.focusedDate?D(this.focusedDate):x(this.year,this.month,1);let a=L(r,e);if(a){let d=this.querySelector(`button[data-date="${y(a)}"]`);if(d instanceof HTMLButtonElement){if(d.dataset.disabled){a=L(a,e);let g=this.querySelector(`button[data-date="${y(a)}"]`);for(;g&&g instanceof HTMLButtonElement&&g.dataset.disabled;)a=L(a,e),g=this.querySelector(`button[data-date="${y(a)}"]`);d=g}d instanceof HTMLButtonElement&&!d.dataset.disabled&&(this.focusedDate=y(a),d.focus())}}}render(){return c.x`
|
|
2
|
-
<div
|
|
3
|
-
class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":""}"
|
|
4
|
-
@focusout=${this.closeEvent}
|
|
5
|
-
@keydown=${t=>{t.key==="Escape"&&(t.preventDefault(),this.close())}}
|
|
6
|
-
>
|
|
7
|
-
<nav class="pkt-cal-month-nav">
|
|
8
|
-
<div>
|
|
9
|
-
<button
|
|
10
|
-
type="button"
|
|
11
|
-
aria-label="${this.prevMonthString}"
|
|
12
|
-
@click=${()=>this.isPrevMonthAllowed()&&this.prevMonth()}
|
|
13
|
-
@keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isPrevMonthAllowed()&&this.prevMonth())}}
|
|
14
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only pkt-calendar__prev-month ${this.isPrevMonthAllowed()?"":"pkt-hide"}"
|
|
15
|
-
.data-disabled=${this.isPrevMonthAllowed()?c.E:"disabled"}
|
|
16
|
-
?aria-disabled=${!this.isPrevMonthAllowed()}
|
|
17
|
-
tabindex=${this.isPrevMonthAllowed()?"0":"-1"}
|
|
18
|
-
>
|
|
19
|
-
<pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
|
|
20
|
-
<span class="pkt-btn__text">${this.prevMonthString}</span>
|
|
21
|
-
</button>
|
|
22
|
-
</div>
|
|
23
|
-
${this.renderMonthNav()}
|
|
24
|
-
<div>
|
|
25
|
-
<button
|
|
26
|
-
type="button"
|
|
27
|
-
aria-label="${this.nextMonthString}"
|
|
28
|
-
@click=${()=>this.isNextMonthAllowed()&&this.nextMonth()}
|
|
29
|
-
@keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isNextMonthAllowed()&&this.nextMonth())}}
|
|
30
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only pkt-calendar__next-month ${this.isNextMonthAllowed()?"":"pkt-hide"}"
|
|
31
|
-
.data-disabled=${this.isNextMonthAllowed()?c.E:"disabled"}
|
|
32
|
-
?aria-disabled=${!this.isNextMonthAllowed()}
|
|
33
|
-
tabindex=${this.isNextMonthAllowed()?"0":"-1"}
|
|
34
|
-
>
|
|
35
|
-
<pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
|
|
36
|
-
<span class="pkt-btn__text">${this.nextMonthString}</span>
|
|
37
|
-
</button>
|
|
38
|
-
</div>
|
|
39
|
-
</nav>
|
|
40
|
-
<table
|
|
41
|
-
class="pkt-cal-days pkt-txt-12-medium pkt-calendar__body"
|
|
42
|
-
role="grid"
|
|
43
|
-
?aria-multiselectable=${this.range||this.multiple}
|
|
44
|
-
>
|
|
45
|
-
<thead>
|
|
46
|
-
${this.renderDayNames()}
|
|
47
|
-
</thead>
|
|
48
|
-
<tbody>
|
|
49
|
-
${this.renderCalendarBody()}
|
|
50
|
-
</tbody>
|
|
51
|
-
</table>
|
|
52
|
-
</div>
|
|
53
|
-
`}renderDayNames(){const t=[];this.weeknumbers&&t.push(c.x`<th><div class="pkt-calendar__week-number">${this.weekString}</div></th>`);for(let e=0;e<this.dayStrings.length;e++)t.push(c.x`<th>
|
|
54
|
-
<div class="pkt-calendar__day-name" aria-label="${this.dayStringsLong[e]}">
|
|
55
|
-
${this.dayStrings[e]}
|
|
56
|
-
</div>
|
|
57
|
-
</th>`);return c.x`<tr class="pkt-cal-week-row">
|
|
58
|
-
${t}
|
|
59
|
-
</tr>`}renderMonthNav(){let t=[];return this.withcontrols?t.push(c.x`<div class="pkt-cal-month-picker">
|
|
60
|
-
<label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
|
|
61
|
-
<select
|
|
62
|
-
aria-label="${this.strings.dates.month}"
|
|
63
|
-
class="pkt-input pkt-input-compact"
|
|
64
|
-
id="${this.id}-monthnav"
|
|
65
|
-
@change=${e=>{e.stopImmediatePropagation(),this.changeMonth(this.year,e.target.value)}}
|
|
66
|
-
>
|
|
67
|
-
${this.monthStrings.map((e,r)=>c.x`<option value=${r} ?selected=${this.month===r}>${e}</option>`)}
|
|
68
|
-
</select>
|
|
69
|
-
<label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
|
|
70
|
-
<input
|
|
71
|
-
aria-label="${this.strings.dates.year}"
|
|
72
|
-
class="pkt-input pkt-cal-input-year pkt-input-compact"
|
|
73
|
-
id="${this.id}-yearnav"
|
|
74
|
-
type="number"
|
|
75
|
-
size="4"
|
|
76
|
-
placeholder="0000"
|
|
77
|
-
@change=${e=>{e.stopImmediatePropagation(),this.changeMonth(e.target.value,this.month)}}
|
|
78
|
-
.value=${this.year}
|
|
79
|
-
/>
|
|
80
|
-
</div> `):t.push(c.x`<div class="pkt-txt-16-medium pkt-calendar__month-title" aria-live="polite">
|
|
81
|
-
${this.monthStrings[this.month]} ${this.year}
|
|
82
|
-
</div>`),t}renderDayView(t,e,r){var w;const a=x(this.year,this.month,t),s=y(a),i=s===y(e),o=this.selected.includes(s),l=Me(a),u=this.isExcluded(r,a)||!o&&this.multiple&&this.maxMultiple>0&&this.selected.length>=this.maxMultiple,d=this.focusedDate?this.focusedDate===s&&!u?"0":"-1":!u&&this.tabIndexSet===0||this.tabIndexSet===t?"0":"-1";d==="0"&&(this.tabIndexSet=t),this.selectableDates.push({currentDateISO:s,isDisabled:u,tabindex:d});const g={"pkt-cal-today":i,"pkt-cal-selected":o,"pkt-cal-in-range":this.inRange[s],"pkt-cal-excluded":this.isExcluded(r,a),"pkt-cal-in-range-first":this.range&&(this.selected.length===2||this.rangeHovered!==null)&&s===this.selected[0],"pkt-cal-in-range-last":this.range&&this.selected.length===2&&s===this.selected[1],"pkt-cal-range-hover":this.rangeHovered!==null&&s===y(this.rangeHovered)},p={"pkt-calendar__date":!0,"pkt-calendar__date--today":i,"pkt-calendar__date--selected":o,"pkt-calendar__date--disabled":u,"pkt-calendar__date--in-range":this.inRange[s],"pkt-calendar__date--in-range-hover":this.rangeHovered!==null&&s===y(this.rangeHovered),"pkt-calendar__date--range-start":this.range&&(this.selected.length===2||this.rangeHovered!==null)&&s===this.selected[0],"pkt-calendar__date--range-end":this.range&&this.selected.length===2&&s===this.selected[1]};return c.x`<td class=${j.e(g)}>
|
|
83
|
-
<button
|
|
84
|
-
type="button"
|
|
85
|
-
aria-pressed=${o?"true":"false"}
|
|
86
|
-
?disabled=${u}
|
|
87
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only ${j.e(p)}"
|
|
88
|
-
@mouseover=${()=>this.range&&!this.isExcluded(r,a)&&this.handleRangeHover(a)}
|
|
89
|
-
@focus=${()=>{this.range&&!this.isExcluded(r,a)&&this.handleRangeHover(a),this.focusedDate=s}}
|
|
90
|
-
aria-label="${l}"
|
|
91
|
-
tabindex=${(w=this.selectableDates.find(m=>m.currentDateISO===s))==null?void 0:w.tabindex}
|
|
92
|
-
data-disabled=${u?"disabled":c.E}
|
|
93
|
-
data-date=${s}
|
|
94
|
-
@keydown=${m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),this.handleDateSelect(a))}}
|
|
95
|
-
@click=${m=>{u||(m.preventDefault(),this.handleDateSelect(a))}}
|
|
96
|
-
>
|
|
97
|
-
<span class="pkt-btn__text pkt-txt-14-light">${t}</span>
|
|
98
|
-
</button>
|
|
99
|
-
</td>`}renderCalendarBody(){const t=De(),e=x(this.year,this.month,1),r=x(this.year,this.month+1,0),a=(e.getDay()+6)%7,s=r.getDate(),i=Math.ceil((s+a)/7),l=x(this.year,this.month,0).getDate();let u=1;this.week=it(x(this.year,this.month,1));const d=[];for(let g=0;g<i;g++){const p=[];this.weeknumbers&&p.push(c.x`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let w=1;w<8;w++)if(g===0&&w<a+1){const m=l-(a-w);p.push(c.x`<td class="pkt-cal-other">
|
|
100
|
-
<div
|
|
101
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
|
|
102
|
-
data-disabled="disabled"
|
|
103
|
-
>
|
|
104
|
-
<span class="pkt-btn__text pkt-txt-14-light">${m}</span>
|
|
105
|
-
</div>
|
|
106
|
-
</td>`)}else u>s?(p.push(c.x`<td class="pkt-cal-other">
|
|
107
|
-
<div
|
|
108
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
|
|
109
|
-
data-disabled="disabled"
|
|
110
|
-
>
|
|
111
|
-
<span class="pkt-btn__text pkt-txt-14-light">${u-s}</span>
|
|
112
|
-
</div>
|
|
113
|
-
</td>`),u++):(p.push(this.renderDayView(u,t,w)),u++);d.push(c.x`<tr class="pkt-cal-week-row" role="row">
|
|
114
|
-
${p}
|
|
115
|
-
</tr>`)}return d}isExcluded(t,e){return this.excludeweekdays.includes(t.toString())||this.earliest&&D(e,"end")<D(this.earliest,"start")||this.latest&&D(e,"start")>D(this.latest,"end")?!0:this.excludedates.some(r=>typeof r=="string"?r===y(e):r.toDateString()===e.toDateString())}isPrevMonthAllowed(){const t=x(this.year,this.month,0);return!(this.earliest&&D(this.earliest)>t)}prevMonth(){const t=this.month===0?11:this.month-1,e=this.month===0?this.year-1:this.year;this.changeMonth(e,t)}isNextMonthAllowed(){const t=x(this.month===11?this.year+1:this.year,this.month===11?0:this.month+1,1);return!(this.latest&&D(this.latest)<t)}nextMonth(){const t=this.month===11?0:this.month+1,e=this.month===11?this.year+1:this.year;this.changeMonth(e,t)}changeMonth(t,e){this.year=typeof t=="string"?parseInt(t):t,this.month=typeof e=="string"?parseInt(e):e,this.currentmonth=new Date(this.year,this.month,1),this.tabIndexSet=0,this.focusedDate=null,this.selectableDates=[]}isRangeAllowed(t){let e=!0;if(this._selected.length===1){const r=R({start:this._selected[0],end:t});if(Array.isArray(r)&&r.length)for(let a=0;a<r.length;a++)this.excludedates.forEach(s=>{s>this._selected[0]&&s<t&&(e=!1)}),this.excludeweekdays.includes(pe(r[a]).toString())&&(e=!1)}return e}emptySelected(){this.selected=[],this._selected=[],this.inRange={}}addToSelected(t){this.selected.includes(y(t))||(this.selected=[...this.selected,y(t)],this._selected=[...this._selected,t],this.range&&this.selected.length===2&&(this.convertSelected(),this.close()))}removeFromSelected(t){if(this.selected.length===1)this.emptySelected();else{const e=this.selected.indexOf(y(t)),r=[...this.selected],a=[...this._selected];r.splice(e,1),a.splice(e,1),this.selected=r,this._selected=a}}toggleSelected(t){const e=y(t);this.selected.includes(e)?this.removeFromSelected(t):this.maxMultiple&&this.selected.length>=this.maxMultiple||this.addToSelected(t)}handleRangeSelect(t){const e=y(t);return this.selected.includes(e)?this.selected.indexOf(e)===0?this.emptySelected():this.removeFromSelected(t):this.selected.length>1?(this.emptySelected(),this.addToSelected(t)):(this.selected.length===1&&!this.isRangeAllowed(t)&&this.emptySelected(),this.selected.length===1&&this._selected[0]>t&&this.emptySelected(),this.addToSelected(t)),Promise.resolve()}handleRangeHover(t){if(this.range&&this._selected.length===1&&this.isRangeAllowed(t)&&this._selected[0]<t){this.rangeHovered=t,this.inRange={};const e=R({start:this._selected[0],end:t});if(Array.isArray(e)&&e.length)for(let r=0;r<e.length;r++){const a=e[r],s=a>this._selected[0]&&a<t;this.inRange[y(a)]=s}}else this.rangeHovered=null}handleDateSelect(t){if(t)return this.range?this.handleRangeSelect(t):this.multiple?this.toggleSelected(t):(this.selected.includes(y(t))?this.emptySelected():(this.emptySelected(),this.addToSelected(t)),this.close()),this.dispatchEvent(new CustomEvent("date-selected",{detail:this.selected,bubbles:!0,composed:!0})),Promise.resolve()}focusOnCurrentDate(){const t=y(D()),e=this.querySelector(`button[data-date="${t}"]`);if(e instanceof HTMLButtonElement)this.focusedDate=t,e.focus();else{const r=this.selectableDates.find(a=>!a.isDisabled);if(r){const a=this.querySelector(`button[data-date="${r.currentDateISO}"]`);a instanceof HTMLButtonElement&&(this.focusedDate=r.currentDateISO,a.focus())}}}closeEvent(t){!this.contains(t.relatedTarget)&&!t.target.classList.contains("pkt-hide")&&this.close()}close(){this.dispatchEvent(new CustomEvent("close",{detail:!0,bubbles:!0,composed:!0}))}};f([c.n({type:Boolean})],exports.PktCalendar.prototype,"multiple",2);f([c.n({type:Number})],exports.PktCalendar.prototype,"maxMultiple",2);f([c.n({type:Boolean})],exports.PktCalendar.prototype,"range",2);f([c.n({type:Boolean})],exports.PktCalendar.prototype,"weeknumbers",2);f([c.n({type:Boolean})],exports.PktCalendar.prototype,"withcontrols",2);f([c.n({converter:F.csvToArray})],exports.PktCalendar.prototype,"selected",2);f([c.n({type:String})],exports.PktCalendar.prototype,"earliest",2);f([c.n({type:String})],exports.PktCalendar.prototype,"latest",2);f([c.n({converter:F.stringsToDate})],exports.PktCalendar.prototype,"excludedates",2);f([c.n({converter:F.csvToArray})],exports.PktCalendar.prototype,"excludeweekdays",2);f([c.n({converter:F.stringToDate})],exports.PktCalendar.prototype,"currentmonth",2);f([c.n({type:Array})],exports.PktCalendar.prototype,"dayStrings",2);f([c.n({type:Array})],exports.PktCalendar.prototype,"dayStringsLong",2);f([c.n({type:Array})],exports.PktCalendar.prototype,"monthStrings",2);f([c.n({type:String})],exports.PktCalendar.prototype,"weekString",2);f([c.n({type:String})],exports.PktCalendar.prototype,"prevMonthString",2);f([c.n({type:String})],exports.PktCalendar.prototype,"nextMonthString",2);f([c.n({type:Array})],exports.PktCalendar.prototype,"_selected",2);f([c.n({type:Number})],exports.PktCalendar.prototype,"year",2);f([c.n({type:Number})],exports.PktCalendar.prototype,"month",2);f([c.n({type:Number})],exports.PktCalendar.prototype,"week",2);f([c.n({type:Date})],exports.PktCalendar.prototype,"rangeHovered",2);f([A.r()],exports.PktCalendar.prototype,"inRange",2);f([A.r()],exports.PktCalendar.prototype,"focusedDate",2);f([A.r()],exports.PktCalendar.prototype,"selectableDates",2);f([A.r()],exports.PktCalendar.prototype,"currentmonthtouched",2);f([A.r()],exports.PktCalendar.prototype,"tabIndexSet",2);exports.PktCalendar=f([c.t("pkt-calendar")],exports.PktCalendar);exports.converters=F;exports.csvToArray=lt;exports.formatISODate=y;exports.fromISOToDate=Se;exports.fromISOtoLocal=ve;exports.newDate=D;exports.parseISODateString=T;
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";const c=require("./class-map-CG3vIaNm.cjs"),o=require("./if-defined-CkVc_RJD.cjs"),s=require("./element-D62wHiNU.cjs"),m=require("./state-BkE_Rxl7.cjs"),u=require("./calendar-CL9O0tLP.cjs"),y=require("./input-element-Y8sdrq9C.cjs"),n=require("./ref-BfgcOXko.cjs");require("./icon-__Hjt2XZ.cjs");require("./input-wrapper-C9rZEgju.cjs");const k=require("./repeat-DzibMwhi.cjs");require("./tag-BKq07hGI.cjs");const $=require("./stringutils-CkVRq4jP.cjs"),b=require("./pkt-slot-controller-BzddBp7z.cjs");var x=Object.defineProperty,D=Object.getOwnPropertyDescriptor,f=(p,t,e,i)=>{for(var a=i>1?void 0:i?D(t,e):t,l=p.length-1,h;l>=0;l--)(h=p[l])&&(a=(i?h(t,e,a):h(a))||a);return i&&a&&x(t,e,a),a};exports.PktDateTags=class extends s.PktElement{constructor(){super(...arguments),this.dates=[],this.dateformat="dd.MM.yyyy",this.className="pkt-datepicker__tags",this.idBase=$.uuidish()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},s.x`
|
|
2
|
-
<div class=${c.e(this.classes)} aria-live="polite">
|
|
3
|
-
${Array.isArray(this.dates)&&this.dates[0]?k.c((this.dates??[]).filter(Boolean).sort(),t=>t,t=>{var e;return s.x` <pkt-tag
|
|
4
|
-
id=${this.idBase+t+"-tag"}
|
|
5
|
-
closeTag
|
|
6
|
-
@close=${()=>{this.dispatchEvent(new CustomEvent("date-tag-removed",{detail:t}))}}
|
|
7
|
-
.ariaLabel=${`${(e=this.strings)==null?void 0:e.calendar.deleteDate} ${u.fromISOtoLocal(t,this.dateformat)}`}
|
|
8
|
-
>
|
|
9
|
-
<time datetime=${t}>${u.fromISOtoLocal(t,this.dateformat)}</time>
|
|
10
|
-
</pkt-tag>`}):s.E}
|
|
11
|
-
</div>
|
|
12
|
-
`}};f([s.n({type:Array})],exports.PktDateTags.prototype,"dates",2);f([s.n({type:String})],exports.PktDateTags.prototype,"dateformat",2);f([s.n({type:String,attribute:"class"})],exports.PktDateTags.prototype,"className",2);f([s.n({type:String,attribute:"id-base"})],exports.PktDateTags.prototype,"idBase",2);exports.PktDateTags=f([s.t("pkt-date-tags")],exports.PktDateTags);const w={dateformat:{default:"dd.MM.yyyy"},min:{default:null},max:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},d={props:w};var R=Object.defineProperty,C=Object.getOwnPropertyDescriptor,r=(p,t,e,i)=>{for(var a=i>1?void 0:i?C(t,e):t,l=p.length-1,h;l>=0;l--)(h=p[l])&&(a=(i?h(t,e,a):h(a))||a);return i&&a&&R(t,e,a),a};const v=p=>new Promise(t=>setTimeout(t,p));exports.PktDatepicker=class extends y.PktInputElement{constructor(){super(),this._valueProperty="",this._value=[],this.label="Datovelger",this.dateformat=d.props.dateformat.default,this.multiple=d.props.multiple.default,this.maxlength=null,this.range=d.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=d.props.weeknumbers.default,this.withcontrols=d.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=n.e(),this.inputRefTo=n.e(),this.btnRef=n.e(),this.calRef=n.e(),this.popupRef=n.e(),this.helptextSlot=n.e(),this.addToSelected=t=>{const e=t.target;if(!e.value)return;const i=this.min?u.newDate(this.min):null,a=this.max?u.newDate(this.max):null,l=u.newDate(e.value.split(",")[0]);l&&!isNaN(l.getTime())&&(!i||l>=i)&&(!a||l<=a)&&this.calRef.value&&this.calRef.value.handleDateSelect(l),e.value=""},this.slotController=new b.PktSlotController(this,this.helptextSlot)}get value(){return this._valueProperty}set value(t){const e=this._valueProperty;this._valueProperty=Array.isArray(t)?t.join(","):t||"",this.valueChanged(this._valueProperty,e),this.requestUpdate("value",e)}async connectedCallback(){super.connectedCallback();const t=navigator.userAgent,e=/iP(hone|od|ad)/.test(t);this.inputType=e?"text":"date",document&&document.body.addEventListener("click",i=>{var a,l;(a=this.inputRef)!=null&&a.value&&((l=this.btnRef)!=null&&l.value)&&!this.inputRef.value.contains(i.target)&&!(this.inputRefTo.value&&this.inputRefTo.value.contains(i.target))&&!this.btnRef.value.contains(i.target)&&!i.target.closest(".pkt-calendar-popup")&&this.calendarOpen&&(this.onBlur(),this.hideCalendar())}),document&&document.body.addEventListener("keydown",i=>{i.key==="Escape"&&this.calendarOpen&&this.hideCalendar()}),this.value&&(this._value=Array.isArray(this.value)?this.value.filter(Boolean):this.value.split(",").filter(Boolean)),this.min=this.min||d.props.min.default,this.max=this.max||d.props.max.default,typeof this.excludedates=="string"&&(this.excludedates=this.excludedates.split(",")),typeof this.excludeweekdays=="string"&&(this.excludeweekdays=this.excludeweekdays.split(",")),(this.multiple||this.range)&&this.name&&!this.name.endsWith("[]")&&(this.name=this.name+"[]"),this.calendarOpen&&(await v(20),this.handleCalendarPosition())}disconnectedCallback(){super.disconnectedCallback(),document&&document.body.removeEventListener("click",t=>{var e,i;(e=this.inputRef)!=null&&e.value&&((i=this.btnRef)!=null&&i.value)&&!this.inputRef.value.contains(t.target)&&!this.btnRef.value.contains(t.target)&&this.hideCalendar()})}onInput(){this.dispatchEvent(new Event("input",{bubbles:!0}))}valueChanged(t,e){if(t===e)return;let i=[];t&&(typeof t=="string"?i=t.split(",").filter(Boolean):i=String(t).split(",").filter(Boolean)),this._value=i;const a=i.join(",");this._valueProperty!==a&&(this._valueProperty=a),super.valueChanged(a,e)}attributeChangedCallback(t,e,i){t==="value"&&this.value!==e&&this.valueChanged(i,e),t==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=(i==null?void 0:i.split(","))??[]),t==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=(i==null?void 0:i.split(","))??[]),super.attributeChangedCallback(t,e,i)}updated(t){if(t.has("value")){const e=Array.isArray(this.value)?this.value.join(","):this.value,i=t.get("value"),a=Array.isArray(i)?i.join(","):i;this.valueChanged(e,a)}t.has("multiple")&&(this.multiple&&!Array.isArray(this._value)?this._value=typeof this.value=="string"?this.value?this.value.split(",").filter(Boolean):[]:[]:!this.multiple&&Array.isArray(this._value)&&(this._value=this._value.filter(Boolean)),!this.multiple&&!this.range&&Array.isArray(this._value)&&(this._value=[this._value[0]??""])),super.updated(t)}renderInput(){return s.x`
|
|
13
|
-
<input
|
|
14
|
-
class="${c.e(this.inputClasses)}"
|
|
15
|
-
.type=${this.inputType}
|
|
16
|
-
id="${this.id}-input"
|
|
17
|
-
.value=${this._value[0]??""}
|
|
18
|
-
min=${o.o(this.min)}
|
|
19
|
-
max=${o.o(this.max)}
|
|
20
|
-
placeholder=${o.o(this.placeholder)}
|
|
21
|
-
?readonly=${this.readonly}
|
|
22
|
-
aria-describedby="${this.id}-helptext"
|
|
23
|
-
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
24
|
-
?disabled=${this.disabled}
|
|
25
|
-
@keydown=${t=>{var e,i;if(t.key===","&&((e=this.inputRef.value)==null||e.blur()),(t.key==="Space"||t.key===" ")&&(t.preventDefault(),this.toggleCalendar(t)),t.key==="Enter"){const a=this.internals.form;a?a.requestSubmit():(i=this.inputRef.value)==null||i.blur()}}}
|
|
26
|
-
@input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
|
|
27
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
28
|
-
@blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.manageValidity(t.target),this.value=t.target.value}}
|
|
29
|
-
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
30
|
-
${n.n(this.inputRef)}
|
|
31
|
-
/>
|
|
32
|
-
`}renderRangeInput(){const t={"pkt-input-prefix":this.showRangeLabels,"pkt-hide":!this.showRangeLabels};return s.x`
|
|
33
|
-
${this.showRangeLabels?s.x` <div class="pkt-input-prefix">${this.strings.generic.from}</div> `:s.E}
|
|
34
|
-
<input
|
|
35
|
-
class=${c.e(this.inputClasses)}
|
|
36
|
-
.type=${this.inputType}
|
|
37
|
-
id="${this.id}-input"
|
|
38
|
-
.value=${this._value[0]??""}
|
|
39
|
-
min=${o.o(this.min)}
|
|
40
|
-
max=${o.o(this.max)}
|
|
41
|
-
placeholder=${o.o(this.placeholder)}
|
|
42
|
-
?readonly=${this.readonly}
|
|
43
|
-
?disabled=${this.disabled}
|
|
44
|
-
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
45
|
-
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRef.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const l=this.internals.form;l?l.requestSubmit():(a=this.inputRefTo.value)==null||a.focus()}}}
|
|
46
|
-
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
47
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
48
|
-
@blur=${e=>{var i,a;if(e.target.value){this.manageValidity(e.target);const l=u.fromISOToDate(e.target.value);l&&this._value[0]!==e.target.value&&this._value[1]&&(this.clearInputValue(),(a=(i=this.calRef)==null?void 0:i.value)==null||a.handleDateSelect(l))}else this._value[0]&&this.clearInputValue()}}
|
|
49
|
-
@change=${e=>{e.stopImmediatePropagation()}}
|
|
50
|
-
${n.n(this.inputRef)}
|
|
51
|
-
/>
|
|
52
|
-
<div class="${c.e(t)}" id="${this.id}-to-label">
|
|
53
|
-
${this.strings.generic.to}
|
|
54
|
-
</div>
|
|
55
|
-
${this.showRangeLabels?s.E:s.x` <div class="pkt-input-separator">–</div> `}
|
|
56
|
-
<input
|
|
57
|
-
class=${c.e(this.inputClasses)}
|
|
58
|
-
.type=${this.inputType}
|
|
59
|
-
id="${this.id}-to"
|
|
60
|
-
aria-labelledby="${this.id}-to-label"
|
|
61
|
-
.value=${this._value[1]??""}
|
|
62
|
-
min=${o.o(this.min)}
|
|
63
|
-
max=${o.o(this.max)}
|
|
64
|
-
placeholder=${o.o(this.placeholder)}
|
|
65
|
-
?readonly=${this.readonly}
|
|
66
|
-
?disabled=${this.disabled}
|
|
67
|
-
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
68
|
-
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRefTo.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const l=this.internals.form;l?l.requestSubmit():(a=this.inputRefTo.value)==null||a.blur()}}}
|
|
69
|
-
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
70
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
71
|
-
@blur=${e=>{var i,a,l;if((i=this.calRef.value)!=null&&i.contains(e.relatedTarget)||this.onBlur(),e.target.value){this.manageValidity(e.target);const h=e.target.value;this.min&&this.min>h?this.internals.setValidity({rangeUnderflow:!0},this.strings.forms.messages.rangeUnderflow,e.target):this.max&&this.max<h&&this.internals.setValidity({rangeOverflow:!0},this.strings.forms.messages.rangeOverflow,e.target);const g=u.fromISOToDate(e.target.value);g&&this._value[1]!==u.formatISODate(g)&&((l=(a=this.calRef)==null?void 0:a.value)==null||l.handleDateSelect(g))}}}
|
|
72
|
-
@change=${e=>{this.touched=!0,e.stopImmediatePropagation()}}
|
|
73
|
-
${n.n(this.inputRefTo)}
|
|
74
|
-
/>
|
|
75
|
-
`}renderMultipleInput(){return s.x`
|
|
76
|
-
<input
|
|
77
|
-
class=${c.e(this.inputClasses)}
|
|
78
|
-
.type=${this.inputType}
|
|
79
|
-
id="${this.id}-input"
|
|
80
|
-
min=${o.o(this.min)}
|
|
81
|
-
max=${o.o(this.max)}
|
|
82
|
-
placeholder=${o.o(this.placeholder)}
|
|
83
|
-
?readonly=${this.readonly}
|
|
84
|
-
?disabled=${this.disabled||this.maxlength&&this._value.length>=this.maxlength}
|
|
85
|
-
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
86
|
-
@blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.addToSelected(t)}}
|
|
87
|
-
@input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
|
|
88
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
89
|
-
@keydown=${t=>{var e;if(t.key===","&&(t.preventDefault(),this.addToSelected(t)),(t.key==="Space"||t.key===" ")&&(t.preventDefault(),this.toggleCalendar(t)),t.key==="Enter"){const i=this.internals.form;i?i.requestSubmit():(e=this.inputRef.value)==null||e.blur()}}}
|
|
90
|
-
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
91
|
-
${n.n(this.inputRef)}
|
|
92
|
-
/>
|
|
93
|
-
`}renderCalendar(){return s.x`<div
|
|
94
|
-
class="pkt-calendar-popup pkt-${this.calendarOpen?"show":"hide"}"
|
|
95
|
-
@focusout=${t=>{this.calendarOpen&&this.handleFocusOut(t)}}
|
|
96
|
-
id="${this.id}-popup"
|
|
97
|
-
${n.n(this.popupRef)}
|
|
98
|
-
>
|
|
99
|
-
<pkt-calendar
|
|
100
|
-
id="${this.id}-calendar"
|
|
101
|
-
?multiple=${this.multiple}
|
|
102
|
-
?range=${this.range}
|
|
103
|
-
?weeknumbers=${this.weeknumbers}
|
|
104
|
-
?withcontrols=${this.withcontrols}
|
|
105
|
-
.maxMultiple=${this.maxlength}
|
|
106
|
-
.selected=${this._value}
|
|
107
|
-
.earliest=${this.min}
|
|
108
|
-
.latest=${this.max}
|
|
109
|
-
.excludedates=${Array.isArray(this.excludedates)?this.excludedates:this.excludedates.split(",")}
|
|
110
|
-
.excludeweekdays=${this.excludeweekdays}
|
|
111
|
-
.currentmonth=${this.currentmonth?u.parseISODateString(this.currentmonth):null}
|
|
112
|
-
@date-selected=${t=>{this.value=!this.multiple&&!this.range?t.detail[0]:Array.isArray(t.detail)?t.detail.join(","):t.detail,this._value=t.detail,this.inputRef.value&&(this.range&&this.inputRefTo.value?(this.inputRef.value.value=this._value[0]??"",this.inputRefTo.value.value=this._value[1]??"",this.manageValidity(this.inputRef.value),this.manageValidity(this.inputRefTo.value)):this.multiple||(this.inputRef.value.value=this._value.length?this._value[0]:"",this.manageValidity(this.inputRef.value)))}}
|
|
113
|
-
@close=${()=>{this.onBlur(),this.hideCalendar()}}
|
|
114
|
-
${n.n(this.calRef)}
|
|
115
|
-
></pkt-calendar>
|
|
116
|
-
</div>`}render(){return this.inputClasses={"pkt-input":!0,"pkt-datepicker__input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-datepicker--hasrangelabels":this.showRangeLabels,"pkt-datepicker--multiple":this.multiple,"pkt-datepicker--range":this.range},this.buttonClasses={"pkt-input-icon":!0,"pkt-btn":!0,"pkt-btn--icon-only":!0,"pkt-btn--tertiary":!0,"pkt-datepicker__calendar-button":!0},s.x`
|
|
117
|
-
<pkt-input-wrapper
|
|
118
|
-
label="${this.label}"
|
|
119
|
-
forId="${this.id}-input"
|
|
120
|
-
?counter=${this.multiple&&!!this.maxlength}
|
|
121
|
-
.counterCurrent=${this.value?this._value.length:0}
|
|
122
|
-
.counterMaxLength=${this.maxlength}
|
|
123
|
-
?disabled=${this.disabled}
|
|
124
|
-
?hasError=${this.hasError}
|
|
125
|
-
?hasFieldset=${this.hasFieldset}
|
|
126
|
-
?inline=${this.inline}
|
|
127
|
-
?required=${this.required}
|
|
128
|
-
?optionalTag=${this.optionalTag}
|
|
129
|
-
?requiredTag=${this.requiredTag}
|
|
130
|
-
?useWrapper=${this.useWrapper}
|
|
131
|
-
.optionalText=${this.optionalText}
|
|
132
|
-
.requiredText=${this.requiredText}
|
|
133
|
-
.tagText=${this.tagText}
|
|
134
|
-
.errorMessage=${this.errorMessage}
|
|
135
|
-
.helptext=${this.helptext}
|
|
136
|
-
.helptextDropdown=${this.helptextDropdown}
|
|
137
|
-
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
138
|
-
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
139
|
-
class="pkt-datepicker"
|
|
140
|
-
>
|
|
141
|
-
<div class="pkt-contents" ${n.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
142
|
-
${this.multiple?s.x`<pkt-date-tags
|
|
143
|
-
.dates=${this._value}
|
|
144
|
-
dateformat=${this.dateformat}
|
|
145
|
-
strings=${this.strings}
|
|
146
|
-
id-base=${this.id}
|
|
147
|
-
@date-tag-removed=${t=>{var e;(e=this.calRef.value)==null||e.handleDateSelect(u.fromISOToDate(t.detail))}}
|
|
148
|
-
></pkt-date-tags>`:s.E}
|
|
149
|
-
<div
|
|
150
|
-
class="pkt-datepicker__inputs ${this.range&&this.showRangeLabels?"pkt-input__range-inputs":""}"
|
|
151
|
-
>
|
|
152
|
-
<div class="pkt-input__container">
|
|
153
|
-
${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
|
|
154
|
-
<button
|
|
155
|
-
class="${c.e(this.buttonClasses)}"
|
|
156
|
-
type="button"
|
|
157
|
-
@click=${this.toggleCalendar}
|
|
158
|
-
@keydown=${t=>{(t.key==="Enter"||t.key===" "||t.key==="Space")&&(t.preventDefault(),this.toggleCalendar(t))}}
|
|
159
|
-
?disabled=${this.disabled}
|
|
160
|
-
${n.n(this.btnRef)}
|
|
161
|
-
>
|
|
162
|
-
<pkt-icon name="calendar"></pkt-icon>
|
|
163
|
-
<span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
|
|
164
|
-
</button>
|
|
165
|
-
</div>
|
|
166
|
-
</div>
|
|
167
|
-
</pkt-input-wrapper>
|
|
168
|
-
${this.renderCalendar()}
|
|
169
|
-
`}handleCalendarPosition(){var t;if(this.popupRef.value&&this.inputRef.value){const e=this.multiple&&!!this.maxlength,i=((t=this.inputRef.value.parentElement)==null?void 0:t.getBoundingClientRect())||this.inputRef.value.getBoundingClientRect(),a=e?i.height+30:i.height,l=this.popupRef.value.getBoundingClientRect().height;let h=e?"calc(100% - 30px)":"100%";i&&i.top+l>window.innerHeight&&i.top-l>0&&(h=`calc(100% - ${a}px - ${l}px)`),this.popupRef.value.style.top=h}}handleFocusOut(t){this.contains(t.target)||(this.onBlur(),this.hideCalendar())}async showCalendar(){var t;this.calendarOpen=!0,await v(20),this.handleCalendarPosition(),this.isMobileSafari&&((t=this.calRef.value)==null||t.focusOnCurrentDate())}hideCalendar(){this.calendarOpen=!1}async toggleCalendar(t){t.preventDefault(),this.calendarOpen?this.hideCalendar():this.showCalendar()}clearInputValue(){this._value=[],this.value=""}};r([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",1);r([s.n({type:Array})],exports.PktDatepicker.prototype,"_value",2);r([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"label",2);r([s.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);r([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);r([s.n({type:Number,reflect:!0})],exports.PktDatepicker.prototype,"maxlength",2);r([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);r([s.n({type:Boolean})],exports.PktDatepicker.prototype,"showRangeLabels",2);r([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"min",2);r([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"max",2);r([s.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);r([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"withcontrols",2);r([s.n({converter:u.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);r([s.n({converter:u.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);r([s.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);r([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);r([s.n({type:String})],exports.PktDatepicker.prototype,"timezone",2);r([m.r()],exports.PktDatepicker.prototype,"inputClasses",2);r([m.r()],exports.PktDatepicker.prototype,"buttonClasses",2);exports.PktDatepicker=r([s.t("pkt-datepicker")],exports.PktDatepicker);
|