@oslokommune/punkt-elements 13.4.2 → 13.5.1
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 +35 -0
- package/dist/calendar-32W9p9uc.cjs +115 -0
- package/dist/{calendar-DevQhOup.js → calendar-CJSxvwAq.js} +353 -340
- package/dist/{card-Dtw26f7i.js → card-BDz4RWxK.js} +1 -1
- package/dist/{card-BUITGoqX.cjs → card-DBlFf1ry.cjs} +1 -1
- package/dist/{datepicker-CYOn3tRm.js → datepicker-BJKJBoy_.js} +102 -59
- package/dist/datepicker-CmTrG5GE.cjs +164 -0
- package/dist/{heading-D6jXE_Mz.js → heading-Bdh9absf.js} +22 -22
- package/dist/heading-CNycsyMj.cjs +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +5 -5
- package/package.json +3 -3
- package/src/components/calendar/calendar.accessibility.test.ts +111 -0
- package/src/components/calendar/calendar.constraints.test.ts +110 -0
- package/src/components/calendar/calendar.core.test.ts +367 -0
- package/src/components/calendar/calendar.interaction.test.ts +139 -0
- package/src/components/calendar/calendar.selection.test.ts +273 -0
- package/src/components/calendar/calendar.ts +74 -42
- package/src/components/card/card.test.ts +19 -5
- package/src/components/consent/consent.test.ts +436 -0
- package/src/components/datepicker/datepicker.accessibility.test.ts +193 -0
- package/src/components/datepicker/datepicker.core.test.ts +322 -0
- package/src/components/datepicker/datepicker.input.test.ts +268 -0
- package/src/components/datepicker/datepicker.selection.test.ts +286 -0
- package/src/components/datepicker/datepicker.ts +121 -19
- package/src/components/datepicker/datepicker.validation.test.ts +176 -0
- package/src/components/heading/heading.test.ts +458 -0
- package/src/components/heading/heading.ts +3 -0
- package/src/components/helptext/helptext.test.ts +474 -0
- package/dist/calendar-BZe2D4Sr.cjs +0 -108
- package/dist/datepicker-B9rhz_AF.cjs +0 -154
- package/dist/heading-BRE_iFtR.cjs +0 -1
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";const lt=require("./class-map-BBG2gMX4.cjs"),o=require("./element-6DBpyGQm.cjs"),F=require("./state-DPobt-Yz.cjs");require("./icon-B_ryAy4Q.cjs");const et=6048e5,ut=864e5,j=Symbol.for("constructDateFrom");function S(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&j in n?n[j](t):n instanceof Date?new n.constructor(t):new Date(t)}function k(n,t){return S(t||n,n)}function L(n,t,e){const r=k(n,e==null?void 0:e.in);return isNaN(t)?S(n,NaN):(t&&r.setDate(r.getDate()+t),r)}let ht={};function I(){return ht}function A(n,t){var c,l,u,f;const e=I(),r=(t==null?void 0:t.weekStartsOn)??((l=(c=t==null?void 0:t.locale)==null?void 0:c.options)==null?void 0:l.weekStartsOn)??e.weekStartsOn??((f=(u=e.locale)==null?void 0:u.options)==null?void 0:f.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 A(n,{...t,weekStartsOn:1})}function nt(n,t){const e=k(n,t==null?void 0:t.in),r=e.getFullYear(),a=S(e,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const s=H(a),i=S(e,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const c=H(i);return e.getTime()>=s.getTime()?r+1:e.getTime()>=c.getTime()?r:r-1}function G(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 rt(n,...t){const e=S.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]=rt(e==null?void 0:e.in,n,t),s=z(r),i=z(a),c=+s-G(s),l=+i-G(i);return Math.round((c-l)/ut)}function ft(n,t){const e=nt(n,t),r=S(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]=rt(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 c=1;const l=[];for(;+i<=s;)l.push(S(e,i)),i.setDate(i.getDate()+c),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"},vt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},St={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Mt={date:U({formats:Dt,defaultWidth:"full"}),time:U({formats:vt,defaultWidth:"full"}),dateTime:U({formats:St,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){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,c=e!=null&&e.width?String(e.width):i;a=n.formattingValues[c]||n.formattingValues[i]}else{const i=n.defaultWidth,c=e!=null&&e.width?String(e.width):n.defaultWidth;a=n.values[c]||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"]},Nt={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"]},$t={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"}},Et={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"}},Wt=(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"},Yt={ordinalNumber:Wt,era:$({values:Pt,defaultWidth:"wide"}),quarter:$({values:Ot,defaultWidth:"wide",argumentCallback:n=>n-1}),month:$({values:Ct,defaultWidth:"wide"}),day:$({values:Nt,defaultWidth:"wide"}),dayPeriod:$({values:$t,defaultWidth:"wide",formattingValues:Et,defaultFormattingWidth:"wide"})};function E(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],c=r&&n.parsePatterns[r]||n.parsePatterns[n.defaultParseWidth],l=Array.isArray(c)?Ft(c,p=>p.test(i)):At(c,p=>p.test(i));let u;u=n.valueCallback?n.valueCallback(l):l,u=e.valueCallback?e.valueCallback(u):u;const f=t.slice(i.length);return{value:u,rest:f}}}function At(n,t){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&t(n[e]))return e}function Ft(n,t){for(let e=0;e<n.length;e++)if(t(n[e]))return e}function _t(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 c=t.slice(a.length);return{value:i,rest:c}}}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:_t({matchPattern:Ht,parsePattern:It,valueCallback:n=>parseInt(n,10)}),era:E({matchPatterns:qt,defaultMatchWidth:"wide",parsePatterns:Lt,defaultParseWidth:"any"}),quarter:E({matchPatterns:Rt,defaultMatchWidth:"wide",parsePatterns:Ut,defaultParseWidth:"any",valueCallback:n=>n+1}),month:E({matchPatterns:Bt,defaultMatchWidth:"wide",parsePatterns:zt,defaultParseWidth:"any"}),day:E({matchPatterns:Qt,defaultMatchWidth:"wide",parsePatterns:jt,defaultParseWidth:"any"}),dayPeriod:E({matchPatterns:Gt,defaultMatchWidth:"any",parsePatterns:Xt,defaultParseWidth:"any"})},Jt={code:"en-US",formatDistance:kt,formatLong:Mt,formatRelative:Tt,localize:Yt,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/et)+1}function at(n,t){var f,p,w,m;const e=k(n,t==null?void 0:t.in),r=e.getFullYear(),a=I(),s=(t==null?void 0:t.firstWeekContainsDate)??((p=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??a.firstWeekContainsDate??((m=(w=a.locale)==null?void 0:w.options)==null?void 0:m.firstWeekContainsDate)??1,i=S((t==null?void 0:t.in)||n,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const c=A(i,t),l=S((t==null?void 0:t.in)||n,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const u=A(l,t);return+e>=+c?r+1:+e>=+u?r:r-1}function te(n,t){var c,l,u,f;const e=I(),r=(t==null?void 0:t.firstWeekContainsDate)??((l=(c=t==null?void 0:t.locale)==null?void 0:c.options)==null?void 0:l.firstWeekContainsDate)??e.firstWeekContainsDate??((f=(u=e.locale)==null?void 0:u.options)==null?void 0:f.firstWeekContainsDate)??1,a=at(n,t),s=S((t==null?void 0:t.in)||n,0);return s.setFullYear(a,0,r),s.setHours(0,0,0,0),A(s,t)}function st(n,t){const e=k(n,t==null?void 0:t.in),r=+A(e,t)-+te(e,t);return Math.round(r/et)+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"},X={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=at(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=nt(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=st(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 J(r);case"XXXX":case"XX":return P(r);case"XXXXX":case"XXX":default:return P(r,":")}},x:function(n,t,e){const r=n.getTimezoneOffset();switch(t){case"x":return J(r);case"xxxx":case"xx":return P(r);case"xxxxx":case"xxx":default:return P(r,":")}},O:function(n,t,e){const r=n.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+V(r,":");case"OOOO":default:return"GMT"+P(r,":")}},z:function(n,t,e){const r=n.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+V(r,":");case"zzzz":default:return"GMT"+P(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 V(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 J(n,t){return n%60===0?(n>0?"-":"+")+h(Math.abs(n)/60,2):P(n,t)}function P(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 K=(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"})}},it=(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 K(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}}",K(r,t)).replace("{{time}}",it(a,t))},ne={p:it,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 f,p,w,m;const r=I(),a=r.locale??Jt,s=r.firstWeekContainsDate??((p=(f=r.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,i=r.weekStartsOn??((m=(w=r.locale)==null?void 0:w.options)==null?void 0:m.weekStartsOn)??0,c=k(n,e==null?void 0:e.in);if(!gt(c))throw new RangeError("Invalid time value");let l=t.match(he).map(g=>{const b=g[0];if(b==="p"||b==="P"){const q=ne[b];return q(g,a.formatLong)}return g}).join("").match(ue).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const b=g[0];if(b==="'")return{isToken:!1,value:ye(g)};if(X[b])return{isToken:!0,value:g};if(b.match(me))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:g}});a.localize.preprocessor&&(l=a.localize.preprocessor(c,l));const u={firstWeekContainsDate:s,weekStartsOn:i,locale:a};return l.map(g=>{if(!g.isToken)return g.value;const b=g.value;(oe(b)||ie(b))&&ce(b,t,String(n));const q=X[b[0]];return q(c,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={},W={};function Y(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 W?W[r]:Z(r,r.split(":"))}catch{if(n in W)return W[n];const e=n==null?void 0:n.match(we);return e?Z(n,e.slice(1)):NaN}}const we=/([+-]\d\d):?(\d\d)?/;function Z(n,t){const e=+t[0],r=+(t[1]||0);return W[n]=e>0?e*60+r:e*60-r}class v extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Y(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)),ot(this),Q(this)):this.setTime(Date.now())}static tz(t,...e){return e.length?new v(...e,t):new v(Date.now(),t)}withTimeZone(t){return new v(+this,t)}getTimezoneOffset(){return-Y(this.timeZone,this)}setTime(t){return Date.prototype.setTime.apply(this,arguments),Q(this),+this}[Symbol.for("constructDateFrom")](t){return new v(+new Date(t),this.timeZone)}}const tt=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(n=>{if(!tt.test(n))return;const t=n.replace(tt,"$1UTC");v.prototype[t]&&(n.startsWith("get")?v.prototype[n]=function(){return this.internal[t]()}:(v.prototype[n]=function(){return Date.prototype[t].apply(this.internal,arguments),be(this),+this},v.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()),ot(n)}function ot(n){const t=Y(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 c=r-t;c&&Date.prototype.setUTCMinutes.call(n,Date.prototype.getUTCMinutes.call(n)+c);const l=Y(n.timeZone,n),f=-new Date(+n).getTimezoneOffset()-l,p=l!==t,w=f-c;if(p&&w){Date.prototype.setUTCMinutes.call(n,Date.prototype.getUTCMinutes.call(n)+w);const m=Y(n.timeZone,n),g=l-m;g&&(n.internal.setUTCMinutes(n.internal.getUTCMinutes()+g),Date.prototype.setUTCMinutes.call(n,Date.prototype.getUTCMinutes.call(n)+g))}}class N extends v{static tz(t,...e){return e.length?new N(...e,t):new N(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 N(+this,t)}[Symbol.for("constructDateFrom")](t){return new N(+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 N(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 O(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}`},ve=n=>{if(!n)return null;const t=O(n);return isNaN(t.getTime())?null:t},Se=(n,t)=>{const e=D(n);return isNaN(e.getTime())?"":ge(e,t)},D=(n="",t)=>{const e=typeof n=="string"?O(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),ct=n=>{if(Array.isArray(n))return n;if(typeof n=="string")return n.split(",")},xe=n=>n?O(n):null,Te=n=>{if(typeof n=="string")return n.split(",").map(t=>O(t));if(Array.isArray(n))return n.map(t=>O(t))},_={csvToArray:ct,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}},T={props:Pe};var Oe=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,d=(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 o.PktElement{constructor(){super(...arguments),this.multiple=T.props.multiple.default,this.maxMultiple=T.props.maxMultiple.default,this.range=T.props.range.default,this.weeknumbers=T.props.weeknumbers.default,this.withcontrols=T.props.withcontrols.default,this.selected=[],this.earliest=T.props.earliest.default,this.latest=T.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=>O(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++)e[y(t[r])]=this.isInRange(t[r]);this.inRange=e}}this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched){this.currentmonthtouched=!0;return}if(this.selected.length&&this.selected[0]!==""){const t=O(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,c;if(((s=t.target)==null?void 0:s.nodeName)==="INPUT"||((i=t.target)==null?void 0:i.nodeName)==="SELECT"||((c=t.target)==null?void 0:c.nodeName)==="BUTTON")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 l=this.querySelector(`div[data-date="${y(a)}"]`);if(l instanceof HTMLDivElement){if(l.dataset.disabled){a=L(a,e);let u=this.querySelector(`div[data-date="${y(a)}"]`);for(;u&&u instanceof HTMLDivElement&&u.dataset.disabled;)a=L(a,e),u=this.querySelector(`div[data-date="${y(a)}"]`);l=u}l instanceof HTMLDivElement&&!l.dataset.disabled&&(this.focusedDate=y(a),l.focus())}}}render(){return o.x`
|
|
2
|
-
<div
|
|
3
|
-
class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":o.E}"
|
|
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
|
-
@click=${this.isPrevMonthAllowed()&&this.prevMonth}
|
|
12
|
-
@keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isNextMonthAllowed()&&this.prevMonth())}}
|
|
13
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isPrevMonthAllowed()?"":"pkt-hide"}"
|
|
14
|
-
.data-disabled=${this.isPrevMonthAllowed()?o.E:"disabled"}
|
|
15
|
-
?aria-disabled=${!this.isPrevMonthAllowed()}
|
|
16
|
-
tabindex=${this.isPrevMonthAllowed()?"0":"-1"}
|
|
17
|
-
>
|
|
18
|
-
<pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
|
|
19
|
-
<span class="pkt-btn__text">${this.prevMonthString}</span>
|
|
20
|
-
</button>
|
|
21
|
-
</div>
|
|
22
|
-
${this.renderMonthNav()}
|
|
23
|
-
<div>
|
|
24
|
-
<button
|
|
25
|
-
type="button"
|
|
26
|
-
@click=${this.isNextMonthAllowed()&&this.nextMonth}
|
|
27
|
-
@keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isNextMonthAllowed()&&this.nextMonth())}}
|
|
28
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isNextMonthAllowed()?"":"pkt-hide"}"
|
|
29
|
-
.data-disabled=${this.isNextMonthAllowed()?o.E:"disabled"}
|
|
30
|
-
?aria-disabled=${!this.isNextMonthAllowed()}
|
|
31
|
-
tabindex=${this.isNextMonthAllowed()?"0":"-1"}
|
|
32
|
-
>
|
|
33
|
-
<pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
|
|
34
|
-
<span class="pkt-btn__text">${this.nextMonthString}</span>
|
|
35
|
-
</button>
|
|
36
|
-
</div>
|
|
37
|
-
</nav>
|
|
38
|
-
<table
|
|
39
|
-
class="pkt-cal-days pkt-txt-12-medium"
|
|
40
|
-
role="grid"
|
|
41
|
-
?aria-multiselectable=${this.range||this.multiple}
|
|
42
|
-
>
|
|
43
|
-
<thead>
|
|
44
|
-
${this.renderDayNames()}
|
|
45
|
-
</thead>
|
|
46
|
-
<tbody>
|
|
47
|
-
${this.renderCalendarBody()}
|
|
48
|
-
</tbody>
|
|
49
|
-
</table>
|
|
50
|
-
</div>
|
|
51
|
-
`}renderDayNames(){const t=[];this.weeknumbers&&t.push(o.x`<th><div>${this.weekString}</div></th>`);for(let e=0;e<this.dayStrings.length;e++)t.push(o.x`<th><div aria-label="${this.dayStringsLong[e]}">${this.dayStrings[e]}</div></th>`);return o.x`<tr class="pkt-cal-week-row">
|
|
52
|
-
${t}
|
|
53
|
-
</tr>`}renderMonthNav(){let t=[];return this.withcontrols?t.push(o.x`<div class="pkt-cal-month-picker">
|
|
54
|
-
<label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
|
|
55
|
-
<select
|
|
56
|
-
aria-label="${this.strings.dates.month}"
|
|
57
|
-
class="pkt-input pkt-input-compact"
|
|
58
|
-
id="${this.id}-monthnav"
|
|
59
|
-
@change=${e=>{e.stopImmediatePropagation(),this.changeMonth(this.year,e.target.value)}}
|
|
60
|
-
>
|
|
61
|
-
${this.monthStrings.map((e,r)=>o.x`<option value=${r} ?selected=${this.month===r}>${e}</option>`)}
|
|
62
|
-
</select>
|
|
63
|
-
<label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
|
|
64
|
-
<input
|
|
65
|
-
aria-label="${this.strings.dates.year}"
|
|
66
|
-
class="pkt-input pkt-cal-input-year pkt-input-compact"
|
|
67
|
-
id="${this.id}-yearnav"
|
|
68
|
-
type="number"
|
|
69
|
-
size="4"
|
|
70
|
-
placeholder="0000"
|
|
71
|
-
@change=${e=>{e.stopImmediatePropagation(),this.changeMonth(e.target.value,this.month)}}
|
|
72
|
-
.value=${this.year}
|
|
73
|
-
/>
|
|
74
|
-
</div> `):t.push(o.x`<div class="pkt-txt-16-medium" aria-live="polite">
|
|
75
|
-
${this.monthStrings[this.month]} ${this.year}
|
|
76
|
-
</div>`),t}renderDayView(t,e,r){var w;const a=x(this.year,this.month,t),s=y(a),i=s===y(e),c=this.selected.includes(s),l=Me(a),u=this.isExcluded(r,a)||!c&&this.multiple&&this.maxMultiple>0&&this.selected.length>=this.maxMultiple,f=this.focusedDate?this.focusedDate===s&&!u?"0":"-1":!u&&this.tabIndexSet===0||this.tabIndexSet===t?"0":"-1";f==="0"&&(this.tabIndexSet=t),this.selectableDates.push({currentDateISO:s,isDisabled:u,tabindex:f});const p={"pkt-cal-today":i,"pkt-cal-selected":c,"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)};return o.x`<td class=${lt.e(p)}>
|
|
77
|
-
<div
|
|
78
|
-
?aria-selected=${c}
|
|
79
|
-
role="gridcell"
|
|
80
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
|
|
81
|
-
@mouseover=${()=>this.range&&!this.isExcluded(r,a)&&this.handleRangeHover(a)}
|
|
82
|
-
@focus=${()=>{this.range&&!this.isExcluded(r,a)&&this.handleRangeHover(a),this.focusedDate=s}}
|
|
83
|
-
aria-label="${l}"
|
|
84
|
-
tabindex=${(w=this.selectableDates.find(m=>m.currentDateISO===s))==null?void 0:w.tabindex}
|
|
85
|
-
data-disabled=${u?"disabled":o.E}
|
|
86
|
-
data-date=${s}
|
|
87
|
-
@keydown=${m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),this.handleDateSelect(a))}}
|
|
88
|
-
@click=${m=>{u||(m.preventDefault(),this.handleDateSelect(a))}}
|
|
89
|
-
>
|
|
90
|
-
<span class="pkt-btn__text pkt-txt-14-light">${t}</span>
|
|
91
|
-
</div>
|
|
92
|
-
</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=st(x(this.year,this.month,1));const f=[];for(let p=0;p<i;p++){const w=[];this.weeknumbers&&w.push(o.x`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let m=1;m<8;m++)if(p===0&&m<a+1){const g=l-(a-m);w.push(o.x`<td class="pkt-cal-other">
|
|
93
|
-
<div
|
|
94
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
|
|
95
|
-
data-disabled="disabled"
|
|
96
|
-
>
|
|
97
|
-
<span class="pkt-btn__text pkt-txt-14-light">${g}</span>
|
|
98
|
-
</div>
|
|
99
|
-
</td>`)}else u>s?(w.push(o.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">${u-s}</span>
|
|
105
|
-
</div>
|
|
106
|
-
</td>`),u++):(w.push(this.renderDayView(u,t,m)),u++);f.push(o.x`<tr class="pkt-cal-week-row" role="row">
|
|
107
|
-
${w}
|
|
108
|
-
</tr>`)}return f}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.tabIndexSet=0,this.focusedDate=null,this.selectableDates=[]}isInRange(t){if(this.range&&this.selected.length===2){if(t>D(this.selected[0])&&t<D(this.selected[1]))return!0}else if(this.range&&this.selected.length===1&&this.rangeHovered&&t>D(this.selected[0])&&t<this.rangeHovered)return!0;return!1}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.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++)this.inRange[y(e[r])]=this.isInRange(e[r])}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(`div[data-date="${t}"]`);if(e instanceof HTMLDivElement)this.focusedDate=t,e.focus();else{const r=this.selectableDates.find(a=>!a.isDisabled);if(r){const a=this.querySelector(`div[data-date="${r.currentDateISO}"]`);a instanceof HTMLDivElement&&(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}))}};d([o.n({type:Boolean})],exports.PktCalendar.prototype,"multiple",2);d([o.n({type:Number})],exports.PktCalendar.prototype,"maxMultiple",2);d([o.n({type:Boolean})],exports.PktCalendar.prototype,"range",2);d([o.n({type:Boolean})],exports.PktCalendar.prototype,"weeknumbers",2);d([o.n({type:Boolean})],exports.PktCalendar.prototype,"withcontrols",2);d([o.n({converter:_.csvToArray})],exports.PktCalendar.prototype,"selected",2);d([o.n({type:String})],exports.PktCalendar.prototype,"earliest",2);d([o.n({type:String})],exports.PktCalendar.prototype,"latest",2);d([o.n({converter:_.stringsToDate})],exports.PktCalendar.prototype,"excludedates",2);d([o.n({converter:_.csvToArray})],exports.PktCalendar.prototype,"excludeweekdays",2);d([o.n({converter:_.stringToDate})],exports.PktCalendar.prototype,"currentmonth",2);d([o.n({type:Array})],exports.PktCalendar.prototype,"dayStrings",2);d([o.n({type:Array})],exports.PktCalendar.prototype,"dayStringsLong",2);d([o.n({type:Array})],exports.PktCalendar.prototype,"monthStrings",2);d([o.n({type:String})],exports.PktCalendar.prototype,"weekString",2);d([o.n({type:String})],exports.PktCalendar.prototype,"prevMonthString",2);d([o.n({type:String})],exports.PktCalendar.prototype,"nextMonthString",2);d([o.n({type:Array})],exports.PktCalendar.prototype,"_selected",2);d([o.n({type:Number})],exports.PktCalendar.prototype,"year",2);d([o.n({type:Number})],exports.PktCalendar.prototype,"month",2);d([o.n({type:Number})],exports.PktCalendar.prototype,"week",2);d([o.n({type:Date})],exports.PktCalendar.prototype,"rangeHovered",2);d([F.r()],exports.PktCalendar.prototype,"inRange",2);d([F.r()],exports.PktCalendar.prototype,"focusedDate",2);d([F.r()],exports.PktCalendar.prototype,"selectableDates",2);d([F.r()],exports.PktCalendar.prototype,"currentmonthtouched",2);d([F.r()],exports.PktCalendar.prototype,"tabIndexSet",2);exports.PktCalendar=d([o.t("pkt-calendar")],exports.PktCalendar);exports.converters=_;exports.csvToArray=ct;exports.formatISODate=y;exports.fromISOToDate=ve;exports.fromISOtoLocal=Se;exports.newDate=D;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";const d=require("./class-map-BBG2gMX4.cjs"),o=require("./if-defined-Cni-RHLS.cjs"),s=require("./element-6DBpyGQm.cjs"),m=require("./state-DPobt-Yz.cjs"),h=require("./calendar-BZe2D4Sr.cjs"),v=require("./input-element-C4xJoM-X.cjs"),r=require("./ref-iJtiv3o2.cjs"),k=require("./repeat-CDsZqct8.cjs");require("./icon-B_ryAy4Q.cjs");require("./input-wrapper-CZ-a00V7.cjs");require("./tag-Bbs0U_Au.cjs");const $=require("./pkt-slot-controller-BzddBp7z.cjs"),y={dateformat:{default:"dd.MM.yyyy"},min:{default:null},max:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},p={props:y};var b=Object.defineProperty,x=Object.getOwnPropertyDescriptor,n=(c,t,e,i)=>{for(var a=i>1?void 0:i?x(t,e):t,l=c.length-1,u;l>=0;l--)(u=c[l])&&(a=(i?u(t,e,a):u(a))||a);return i&&a&&b(t,e,a),a};const g=c=>new Promise(t=>setTimeout(t,c));exports.PktDatepicker=class extends v.PktInputElement{constructor(){super(),this.value="",this._value=this.value?Array.isArray(this.value)?this.value:this.value.split(","):[],this.label="Datovelger",this.dateformat=p.props.dateformat.default,this.multiple=p.props.multiple.default,this.maxlength=null,this.range=p.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=p.props.weeknumbers.default,this.withcontrols=p.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=r.e(),this.inputRefTo=r.e(),this.btnRef=r.e(),this.calRef=r.e(),this.popupRef=r.e(),this.helptextSlot=r.e(),this.addToSelected=t=>{const e=t.target;if(!e.value)return;const i=this.min?h.newDate(this.min):null,a=this.max?h.newDate(this.max):null,l=h.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 $.PktSlotController(this,this.helptextSlot)}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())}),this.value.length&&this._value.length===0&&(this._value=Array.isArray(this.value)?this.value:this.value.split(",")),this.min=this.min||p.props.min.default,this.max=this.max||p.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 g(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()})}attributeChangedCallback(t,e,i){if(t==="value"){if(this.range&&(i==null?void 0:i.split(",").length)===1)return;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){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&&Array.isArray(this._value)&&(this._value=[this._value[0]??""])),super.updated(t)}renderInput(){return s.x`
|
|
2
|
-
<input
|
|
3
|
-
class="${d.e(this.inputClasses)}"
|
|
4
|
-
.type=${this.inputType}
|
|
5
|
-
id="${this.id}-input"
|
|
6
|
-
.value=${this._value[0]??""}
|
|
7
|
-
min=${o.o(this.min)}
|
|
8
|
-
max=${o.o(this.max)}
|
|
9
|
-
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
10
|
-
?disabled=${this.disabled}
|
|
11
|
-
@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()}}}
|
|
12
|
-
@input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
|
|
13
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
14
|
-
@blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.manageValidity(t.target),this.value=t.target.value}}
|
|
15
|
-
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
16
|
-
${r.n(this.inputRef)}
|
|
17
|
-
/>
|
|
18
|
-
`}renderRangeInput(){const t={"pkt-input-prefix":this.showRangeLabels,"pkt-hide":!this.showRangeLabels};return s.x`
|
|
19
|
-
${this.showRangeLabels?s.x` <div class="pkt-input-prefix">${this.strings.generic.from}</div> `:s.E}
|
|
20
|
-
<input
|
|
21
|
-
class=${d.e(this.inputClasses)}
|
|
22
|
-
.type=${this.inputType}
|
|
23
|
-
id="${this.id}-input"
|
|
24
|
-
.value=${this._value[0]??""}
|
|
25
|
-
min=${o.o(this.min)}
|
|
26
|
-
max=${o.o(this.max)}
|
|
27
|
-
?disabled=${this.disabled}
|
|
28
|
-
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
29
|
-
@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()}}}
|
|
30
|
-
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
31
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
32
|
-
@blur=${e=>{var i,a;if(e.target.value){this.manageValidity(e.target);const l=h.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()}}
|
|
33
|
-
@change=${e=>{e.stopImmediatePropagation()}}
|
|
34
|
-
${r.n(this.inputRef)}
|
|
35
|
-
/>
|
|
36
|
-
<div class="${d.e(t)}" id="${this.id}-to-label">
|
|
37
|
-
${this.strings.generic.to}
|
|
38
|
-
</div>
|
|
39
|
-
${this.showRangeLabels?s.E:s.x` <div class="pkt-input-separator">–</div> `}
|
|
40
|
-
<input
|
|
41
|
-
class=${d.e(this.inputClasses)}
|
|
42
|
-
.type=${this.inputType}
|
|
43
|
-
id="${this.id}-to"
|
|
44
|
-
aria-labelledby="${this.id}-to-label"
|
|
45
|
-
.value=${this._value[1]??""}
|
|
46
|
-
min=${o.o(this.min)}
|
|
47
|
-
max=${o.o(this.max)}
|
|
48
|
-
?disabled=${this.disabled}
|
|
49
|
-
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
50
|
-
@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()}}}
|
|
51
|
-
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
52
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
53
|
-
@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 u=e.target.value;this.min&&this.min>u?this.internals.setValidity({rangeUnderflow:!0},this.strings.forms.messages.rangeUnderflow,e.target):this.max&&this.max<u&&this.internals.setValidity({rangeOverflow:!0},this.strings.forms.messages.rangeOverflow,e.target);const f=h.fromISOToDate(e.target.value);f&&this._value[1]!==h.formatISODate(f)&&((l=(a=this.calRef)==null?void 0:a.value)==null||l.handleDateSelect(f))}}}
|
|
54
|
-
@change=${e=>{this.touched=!0,e.stopImmediatePropagation()}}
|
|
55
|
-
${r.n(this.inputRefTo)}
|
|
56
|
-
/>
|
|
57
|
-
`}renderMultipleInput(){return console.log("range",this.range,"multiple",this.multiple),s.x`
|
|
58
|
-
<input
|
|
59
|
-
class=${d.e(this.inputClasses)}
|
|
60
|
-
.type=${this.inputType}
|
|
61
|
-
id="${this.id}-input"
|
|
62
|
-
min=${o.o(this.min)}
|
|
63
|
-
max=${o.o(this.max)}
|
|
64
|
-
?disabled=${this.disabled||this.maxlength&&this._value.length>=this.maxlength}
|
|
65
|
-
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
66
|
-
@blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.addToSelected(t)}}
|
|
67
|
-
@input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
|
|
68
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
69
|
-
@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()}}}
|
|
70
|
-
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
71
|
-
${r.n(this.inputRef)}
|
|
72
|
-
/>
|
|
73
|
-
`}renderTags(){return s.x`
|
|
74
|
-
<div class="pkt-datepicker__tags" aria-live="polite">
|
|
75
|
-
${this._value[0]?k.c((this._value??[]).filter(Boolean),t=>t,t=>s.x`
|
|
76
|
-
<pkt-tag
|
|
77
|
-
.id="${this.id+t+"-tag"}"
|
|
78
|
-
closeTag
|
|
79
|
-
ariaLabel="${this.strings.calendar.deleteDate} ${h.fromISOtoLocal(t,this.dateformat)}"
|
|
80
|
-
@close=${()=>{var e;return(e=this.calRef.value)==null?void 0:e.handleDateSelect(h.fromISOToDate(t))}}
|
|
81
|
-
><time datetime="${t}">${h.fromISOtoLocal(t,this.dateformat)}</time></pkt-tag
|
|
82
|
-
>
|
|
83
|
-
`):s.E}
|
|
84
|
-
</div>
|
|
85
|
-
`}renderCalendar(){return s.x`<div
|
|
86
|
-
class="pkt-calendar-popup pkt-${this.calendarOpen?"show":"hide"}"
|
|
87
|
-
@focusout=${t=>{this.calendarOpen&&this.handleFocusOut(t)}}
|
|
88
|
-
id="${this.id}-popup"
|
|
89
|
-
${r.n(this.popupRef)}
|
|
90
|
-
>
|
|
91
|
-
<pkt-calendar
|
|
92
|
-
id="${this.id}-calendar"
|
|
93
|
-
?multiple=${this.multiple}
|
|
94
|
-
?range=${this.range}
|
|
95
|
-
?weeknumbers=${this.weeknumbers}
|
|
96
|
-
?withcontrols=${this.withcontrols}
|
|
97
|
-
.maxMultiple=${this.maxlength}
|
|
98
|
-
.selected=${this._value}
|
|
99
|
-
.earliest=${this.min}
|
|
100
|
-
.latest=${this.max}
|
|
101
|
-
.excludedates=${Array.isArray(this.excludedates)?this.excludedates:this.excludedates.split(",")}
|
|
102
|
-
.excludeweekdays=${this.excludeweekdays}
|
|
103
|
-
.currentmonth=${this.currentmonth?h.newDate(this.currentmonth):null}
|
|
104
|
-
@date-selected=${t=>{this.value=!this.multiple&&!this.range?t.detail[0]: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.multiple||(this.inputRef.value.value=this._value.length?this._value[0]:""))}}
|
|
105
|
-
@close=${()=>{this.onBlur(),this.hideCalendar()}}
|
|
106
|
-
${r.n(this.calRef)}
|
|
107
|
-
></pkt-calendar>
|
|
108
|
-
</div>`}render(){return console.log("multiple",this.multiple,"value",this.value,"_value",this._value),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},s.x`
|
|
109
|
-
<pkt-input-wrapper
|
|
110
|
-
label="${this.label}"
|
|
111
|
-
forId="${this.id}-input"
|
|
112
|
-
?counter=${this.multiple&&!!this.maxlength}
|
|
113
|
-
.counterCurrent=${this.value?this._value.length:0}
|
|
114
|
-
.counterMaxLength=${this.maxlength}
|
|
115
|
-
?disabled=${this.disabled}
|
|
116
|
-
?hasError=${this.hasError}
|
|
117
|
-
?hasFieldset=${this.hasFieldset}
|
|
118
|
-
?inline=${this.inline}
|
|
119
|
-
?required=${this.required}
|
|
120
|
-
?optionalTag=${this.optionalTag}
|
|
121
|
-
?requiredTag=${this.requiredTag}
|
|
122
|
-
?useWrapper=${this.useWrapper}
|
|
123
|
-
.optionalText=${this.optionalText}
|
|
124
|
-
.requiredText=${this.requiredText}
|
|
125
|
-
.tagText=${this.tagText}
|
|
126
|
-
.errorMessage=${this.errorMessage}
|
|
127
|
-
.helptext=${this.helptext}
|
|
128
|
-
.helptextDropdown=${this.helptextDropdown}
|
|
129
|
-
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
130
|
-
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
131
|
-
class="pkt-datepicker"
|
|
132
|
-
>
|
|
133
|
-
<div class="pkt-contents" ${r.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
134
|
-
${this.multiple?this.renderTags():s.E}
|
|
135
|
-
<div
|
|
136
|
-
class="pkt-datepicker__inputs ${this.range&&this.showRangeLabels?"pkt-input__range-inputs":""}"
|
|
137
|
-
>
|
|
138
|
-
<div class="pkt-input__container">
|
|
139
|
-
${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
|
|
140
|
-
<button
|
|
141
|
-
class="${d.e(this.buttonClasses)}"
|
|
142
|
-
type="button"
|
|
143
|
-
@click=${this.toggleCalendar}
|
|
144
|
-
?disabled=${this.disabled}
|
|
145
|
-
${r.n(this.btnRef)}
|
|
146
|
-
>
|
|
147
|
-
<pkt-icon name="calendar"></pkt-icon>
|
|
148
|
-
<span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
|
|
149
|
-
</button>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
</pkt-input-wrapper>
|
|
153
|
-
${this.renderCalendar()}
|
|
154
|
-
`}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 u=e?"calc(100% - 30px)":"100%";i&&i.top+l>window.innerHeight&&i.top-l>0&&(u=`calc(100% - ${a}px - ${l}px)`),this.popupRef.value.style.top=u}}handleFocusOut(t){this.contains(t.target)||(this.onBlur(),this.hideCalendar())}async showCalendar(){var t;this.calendarOpen=!0,await g(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()}};n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",2);n([s.n({type:Array})],exports.PktDatepicker.prototype,"_value",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"label",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);n([s.n({type:Number,reflect:!0})],exports.PktDatepicker.prototype,"maxlength",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);n([s.n({type:Boolean})],exports.PktDatepicker.prototype,"showRangeLabels",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"min",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"max",2);n([s.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"withcontrols",2);n([s.n({converter:h.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);n([s.n({converter:h.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"timezone",2);n([m.r()],exports.PktDatepicker.prototype,"inputClasses",2);n([m.r()],exports.PktDatepicker.prototype,"buttonClasses",2);exports.PktDatepicker=n([s.t("pkt-datepicker")],exports.PktDatepicker);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("./element-6DBpyGQm.cjs");var h=Object.defineProperty,p=Object.getOwnPropertyDescriptor,l=(n,t,a,e)=>{for(var s=e>1?void 0:e?p(t,a):t,d=n.length-1,r;d>=0;d--)(r=n[d])&&(s=(e?r(t,a,s):r(s))||s);return e&&s&&h(t,a,s),s};exports.PktHeading=class extends i.PktShadowElement{constructor(){super(...arguments),this.size="medium",this.level=2,this.visuallyHidden=!1,this.align="start"}connectedCallback(){super.connectedCallback(),this.setAttribute("role","heading"),this.setAttribute("aria-level",String(this.level)),this.updateHostClasses()}attributeChangedCallback(t,a,e){super.attributeChangedCallback(t,a,e),t==="level"&&e&&this.setLevel(Number(e)),(t==="size"||t==="visuallyHidden"||t==="align")&&this.updateHostClasses()}updated(t){super.updated(t),t.has("level")&&this.setLevel(this.level),(t.has("size")||t.has("visuallyHidden")||t.has("align"))&&this.updateHostClasses()}setLevel(t){t>=1&&t<=6?(this.level=t,this.setAttribute("aria-level",String(t))):console.warn(`Invalid heading level: ${t}. Must be between 1 and 6.`)}updateHostClasses(){this.classList.remove("pkt-heading","pkt-heading--xsmall","pkt-heading--small","pkt-heading--medium","pkt-heading--large","pkt-heading--xlarge","pkt-sr-only","pkt-heading--start","pkt-heading--center","pkt-heading--end"),this.classList.add("pkt-heading"),this.size&&this.classList.add(`pkt-heading--${this.size}`),this.visuallyHidden&&this.classList.add("pkt-sr-only"),this.align&&this.classList.add(`pkt-heading--${this.align}`)}render(){return i.x`<slot></slot>`}};l([i.n({type:String,reflect:!0})],exports.PktHeading.prototype,"size",2);l([i.n({type:Number,reflect:!0})],exports.PktHeading.prototype,"level",2);l([i.n({type:Boolean,reflect:!0})],exports.PktHeading.prototype,"visuallyHidden",2);l([i.n({type:String,reflect:!0})],exports.PktHeading.prototype,"align",2);exports.PktHeading=l([i.t("pkt-heading")],exports.PktHeading);
|