@oslokommune/punkt-elements 16.0.0 → 16.0.3
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-DjbO2g5L.cjs → calendar-43Y_6FD8.cjs} +3 -3
- package/dist/{calendar-DTnx3DDH.js → calendar-B5Xwl8mV.js} +64 -53
- package/dist/{combobox-Bv37b6cI.cjs → combobox-DX2BLzIm.cjs} +1 -1
- package/dist/{combobox-CoO8T-F-.js → combobox-TKTemUxN.js} +1 -1
- package/dist/{datepicker-CrvQ5Y5w.cjs → datepicker-CPNcXd-o.cjs} +1 -1
- package/dist/{datepicker-DbsIuC5Z.js → datepicker-MuQYeXhL.js} +1 -1
- package/dist/{listbox-OdkIn9_A.js → listbox-CS4WQOuf.js} +14 -7
- package/dist/{listbox-Dm2mKp6_.cjs → listbox-OAVh_U7u.cjs} +9 -4
- 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 +2 -2
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +3 -3
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/package.json +2 -2
- package/src/components/listbox/listbox.ts +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,40 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [16.1.0](https://github.com/oslokommune/punkt/compare/16.0.2...16.1.0) (2026-03-12)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
Ingen
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
Ingen
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
Ingen
|
|
18
|
+
|
|
19
|
+
### Chores
|
|
20
|
+
Ingen
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [16.0.2](https://github.com/oslokommune/punkt/compare/16.0.1...16.0.2) (2026-03-09)
|
|
26
|
+
|
|
27
|
+
### ⚠ BREAKING CHANGES
|
|
28
|
+
Ingen
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
Ingen
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
Ingen
|
|
35
|
+
|
|
36
|
+
### Chores
|
|
37
|
+
Ingen
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
|
|
8
42
|
## [16.0.0](https://github.com/oslokommune/punkt/compare/15.4.7...16.0.0) (2026-03-06)
|
|
9
43
|
|
|
10
44
|
### ⚠ BREAKING CHANGES
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const et=require("./class-map-Bokp1SoS.cjs"),u=require("./element-CMTfByxQ.cjs"),K=require("./state-BNgpvY-A.cjs");require("./icon-Dj0oZZSa.cjs");const ft=6048e5,Ot=864e5,nt=Symbol.for("constructDateFrom");function k(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&nt in e?e[nt](t):e instanceof Date?new e.constructor(t):new Date(t)}function b(e,t){return k(t||e,e)}function rt(e,t,n){const r=b(e,n==null?void 0:n.in);return isNaN(t)?k(e,NaN):(t&&r.setDate(r.getDate()+t),r)}let xt={};function U(){return xt}function H(e,t){var o,c,d,f;const n=U(),r=(t==null?void 0:t.weekStartsOn)??((c=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.weekStartsOn)??0,a=b(e,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 L(e,t){return H(e,{...t,weekStartsOn:1})}function mt(e,t){const n=b(e,t==null?void 0:t.in),r=n.getFullYear(),a=k(n,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const s=L(a),i=k(n,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const o=L(i);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function at(e){const t=b(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function gt(e,...t){const n=k.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function G(e,t){const n=b(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function Pt(e,t,n){const[r,a]=gt(n==null?void 0:n.in,e,t),s=G(r),i=G(a),o=+s-at(s),c=+i-at(i);return Math.round((o-c)/Ot)}function Ct(e,t){const n=mt(e,t),r=k(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),L(r)}function Nt(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function $t(e){return!(!Nt(e)&&typeof e!="number"||isNaN(+b(e)))}function Et(e,t){const n=b(e,t==null?void 0:t.in);return n.setHours(23,59,59,999),n}function _t(e,t){const[n,r]=gt(e,t.start,t.end);return{start:n,end:r}}function yt(e,t){const{start:n,end:r}=_t(t==null?void 0:t.in,e);let a=+n>+r;const s=a?+n:+r,i=a?r:n;i.setHours(0,0,0,0);let o=1;const c=[];for(;+i<=s;)c.push(k(n,i)),i.setDate(i.getDate()+o),i.setHours(0,0,0,0);return a?c.reverse():c}function Wt(e,t){const n=b(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Yt={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"}},It=(e,t,n)=>{let r;const a=Yt[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function j(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Ft={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},At={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Ht={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Rt={date:j({formats:Ft,defaultWidth:"full"}),time:j({formats:At,defaultWidth:"full"}),dateTime:j({formats:Ht,defaultWidth:"full"})},qt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Lt=(e,t,n,r)=>qt[e];function Y(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,o=n!=null&&n.width?String(n.width):i;a=e.formattingValues[o]||e.formattingValues[i]}else{const i=e.defaultWidth,o=n!=null&&n.width?String(n.width):e.defaultWidth;a=e.values[o]||e.values[i]}const s=e.argumentCallback?e.argumentCallback(t):t;return a[s]}}const Ut={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Bt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},zt={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"]},jt={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"]},Qt={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"}},Xt={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"}},Gt=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Vt={ordinalNumber:Gt,era:Y({values:Ut,defaultWidth:"wide"}),quarter:Y({values:Bt,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Y({values:zt,defaultWidth:"wide"}),day:Y({values:jt,defaultWidth:"wide"}),dayPeriod:Y({values:Qt,defaultWidth:"wide",formattingValues:Xt,defaultFormattingWidth:"wide"})};function I(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(a);if(!s)return null;const i=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(o)?Jt(o,y=>y.test(i)):Kt(o,y=>y.test(i));let d;d=e.valueCallback?e.valueCallback(c):c,d=n.valueCallback?n.valueCallback(d):d;const f=t.slice(i.length);return{value:d,rest:f}}}function Kt(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Jt(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function Zt(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;const o=t.slice(a.length);return{value:i,rest:o}}}const te=/^(\d+)(th|st|nd|rd)?/i,ee=/\d+/i,ne={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},re={any:[/^b/i,/^(a|c)/i]},ae={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},se={any:[/1/i,/2/i,/3/i,/4/i]},ie={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},oe={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]},ce={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},ue={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]},le={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},he={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}},de={ordinalNumber:Zt({matchPattern:te,parsePattern:ee,valueCallback:e=>parseInt(e,10)}),era:I({matchPatterns:ne,defaultMatchWidth:"wide",parsePatterns:re,defaultParseWidth:"any"}),quarter:I({matchPatterns:ae,defaultMatchWidth:"wide",parsePatterns:se,defaultParseWidth:"any",valueCallback:e=>e+1}),month:I({matchPatterns:ie,defaultMatchWidth:"wide",parsePatterns:oe,defaultParseWidth:"any"}),day:I({matchPatterns:ce,defaultMatchWidth:"wide",parsePatterns:ue,defaultParseWidth:"any"}),dayPeriod:I({matchPatterns:le,defaultMatchWidth:"any",parsePatterns:he,defaultParseWidth:"any"})},fe={code:"en-US",formatDistance:It,formatLong:Rt,formatRelative:Lt,localize:Vt,match:de,options:{weekStartsOn:0,firstWeekContainsDate:1}};function me(e,t){const n=b(e,t==null?void 0:t.in);return Pt(n,Wt(n))+1}function ge(e,t){const n=b(e,t==null?void 0:t.in),r=+L(n)-+Ct(n);return Math.round(r/ft)+1}function pt(e,t){var f,y,p,S;const n=b(e,t==null?void 0:t.in),r=n.getFullYear(),a=U(),s=(t==null?void 0:t.firstWeekContainsDate)??((y=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:y.firstWeekContainsDate)??a.firstWeekContainsDate??((S=(p=a.locale)==null?void 0:p.options)==null?void 0:S.firstWeekContainsDate)??1,i=k((t==null?void 0:t.in)||e,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const o=H(i,t),c=k((t==null?void 0:t.in)||e,0);c.setFullYear(r,0,s),c.setHours(0,0,0,0);const d=H(c,t);return+n>=+o?r+1:+n>=+d?r:r-1}function ye(e,t){var o,c,d,f;const n=U(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??1,a=pt(e,t),s=k((t==null?void 0:t.in)||e,0);return s.setFullYear(a,0,r),s.setHours(0,0,0,0),H(s,t)}function wt(e,t){const n=b(e,t==null?void 0:t.in),r=+H(n,t)-+ye(n,t);return Math.round(r/ft)+1}function l(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const M={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return l(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):l(n+1,2)},d(e,t){return l(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return l(e.getHours()%12||12,t.length)},H(e,t){return l(e.getHours(),t.length)},m(e,t){return l(e.getMinutes(),t.length)},s(e,t){return l(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return l(a,t.length)}},$={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},st={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return M.y(e,t)},Y:function(e,t,n,r){const a=pt(e,r),s=a>0?a:1-a;if(t==="YY"){const i=s%100;return l(i,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):l(s,t.length)},R:function(e,t){const n=mt(e);return l(n,t.length)},u:function(e,t){const n=e.getFullYear();return l(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return l(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return l(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return M.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return l(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const a=wt(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):l(a,t.length)},I:function(e,t,n){const r=ge(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):l(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):M.d(e,t)},D:function(e,t,n){const r=me(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):l(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const a=e.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return l(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const a=e.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return l(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return l(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=$.noon:r===0?a=$.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=$.evening:r>=12?a=$.afternoon:r>=4?a=$.morning:a=$.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return M.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):M.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):l(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):l(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):M.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):M.s(e,t)},S:function(e,t){return M.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return ot(r);case"XXXX":case"XX":return x(r);case"XXXXX":case"XXX":default:return x(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return ot(r);case"xxxx":case"xx":return x(r);case"xxxxx":case"xxx":default:return x(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+it(r,":");case"OOOO":default:return"GMT"+x(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+it(r,":");case"zzzz":default:return"GMT"+x(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return l(r,t.length)},T:function(e,t,n){return l(+e,t.length)}};function it(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),s=r%60;return s===0?n+String(a):n+String(a)+t+l(s,2)}function ot(e,t){return e%60===0?(e>0?"-":"+")+l(Math.abs(e)/60,2):x(e,t)}function x(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=l(Math.trunc(r/60),2),s=l(r%60,2);return n+a+t+s}const ct=(e,t)=>{switch(e){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"})}},bt=(e,t)=>{switch(e){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"})}},pe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return ct(e,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}}",ct(r,t)).replace("{{time}}",bt(a,t))},we={p:bt,P:pe},be=/^D+$/,De=/^Y+$/,ke=["D","DD","YY","YYYY"];function Se(e){return be.test(e)}function ve(e){return De.test(e)}function Me(e,t,n){const r=Te(e,t,n);if(console.warn(r),ke.includes(e))throw new RangeError(r)}function Te(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Oe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,xe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Pe=/^'([^]*?)'?$/,Ce=/''/g,Ne=/[a-zA-Z]/;function $e(e,t,n){var f,y,p,S;const r=U(),a=r.locale??fe,s=r.firstWeekContainsDate??((y=(f=r.locale)==null?void 0:f.options)==null?void 0:y.firstWeekContainsDate)??1,i=r.weekStartsOn??((S=(p=r.locale)==null?void 0:p.options)==null?void 0:S.weekStartsOn)??0,o=b(e,n==null?void 0:n.in);if(!$t(o))throw new RangeError("Invalid time value");let c=t.match(xe).map(w=>{const g=w[0];if(g==="p"||g==="P"){const W=we[g];return W(w,a.formatLong)}return w}).join("").match(Oe).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const g=w[0];if(g==="'")return{isToken:!1,value:Ee(w)};if(st[g])return{isToken:!0,value:w};if(g.match(Ne))throw new RangeError("Format string contains an unescaped latin alphabet character `"+g+"`");return{isToken:!1,value:w}});a.localize.preprocessor&&(c=a.localize.preprocessor(o,c));const d={firstWeekContainsDate:s,weekStartsOn:i,locale:a};return c.map(w=>{if(!w.isToken)return w.value;const g=w.value;(ve(g)||Se(g))&&Me(g,t,String(e));const W=st[g[0]];return W(o,g,a.localize,d)}).join("")}function Ee(e){const t=e.match(Pe);return t?t[1].replace(Ce,"'"):e}function _e(e,t){const n=b(e,t==null?void 0:t.in).getDay();return n===0?7:n}function We(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const Q={},A={};function P(e,t){try{const r=(Q[e]||(Q[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return r in A?A[r]:ut(r,r.split(":"))}catch{if(e in A)return A[e];const n=e==null?void 0:e.match(Ye);return n?ut(e,n.slice(1)):NaN}}const Ye=/([+-]\d\d):?(\d\d)?/;function ut(e,t){const n=+(t[0]||0),r=+(t[1]||0),a=+(t[2]||0)/60;return A[e]=n*60+r>0?n*60+r+a:n*60-r-a}class D extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(P(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)),Dt(this),V(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new D(...n,t):new D(Date.now(),t)}withTimeZone(t){return new D(+this,t)}getTimezoneOffset(){const t=-P(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),V(this),+this}[Symbol.for("constructDateFrom")](t){return new D(+new Date(t),this.timeZone)}}const lt=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!lt.test(e))return;const t=e.replace(lt,"$1UTC");D.prototype[t]&&(e.startsWith("get")?D.prototype[e]=function(){return this.internal[t]()}:(D.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),Ie(this),+this},D.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),V(this),+this}))});function V(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-P(e.timeZone,e)*60))}function Ie(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),Dt(e)}function Dt(e){const t=P(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const a=-new Date(+e).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),i=a-s,o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const c=a-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const d=new Date(+e);d.setUTCSeconds(0);const f=a>0?d.getSeconds():(d.getSeconds()-60)%60,y=Math.round(-(P(e.timeZone,e)*60))%60;(y||f)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+y),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+y+f));const p=P(e.timeZone,e),S=p>0?Math.floor(p):Math.ceil(p),g=-new Date(+e).getTimezoneOffset()-S,W=S!==n,tt=g-c;if(W&&tt){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+tt);const B=P(e.timeZone,e),Tt=B>0?Math.floor(B):Math.ceil(B),z=S-Tt;z&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+z),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+z))}}class T extends D{static tz(t,...n){return n.length?new T(...n,t):new T(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),a=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+a}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,a]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${n} ${a}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,a]=this.tzComponents();return`${t} GMT${n}${r}${a} (${We(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),a=String(Math.abs(t)%60).padStart(2,"0");return[n,r,a]}withTimeZone(t){return new T(+this,t)}[Symbol.for("constructDateFrom")](t){return new T(+new Date(t),this.timeZone)}}window.pktTz=window.pktTz===void 0?"Europe/Oslo":window.pktTz;const Fe=(e=window.pktTz)=>{const t=new T(new Date().toISOString(),e);return t.setHours(0,0,0,0),isNaN(t.getTime())?new Date:new Date(t.getFullYear(),t.getMonth(),t.getDate())};function v(e){if(!e||e==="")return new Date;if(/^\d{4}-\d{2}-\d{2}$/.test(e)){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r)}if(/^\d{4}-\d{2}$/.test(e)){const[t,n]=e.split("-").map(Number);return new Date(t,n-1,1)}return/^\d{4}$/.test(e)?new Date(Number(e),0,1):new Date(e)}const m=e=>{if(!e||isNaN(e.getTime()))return"";const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`},_=e=>{if(!e)return null;const t=v(e);return isNaN(t.getTime())?null:t},Ae=(e,t)=>{const n=N(e);return isNaN(n.getTime())?"":$e(n,t)},N=(e="",t)=>{const n=typeof e=="string"?v(e):e;return!n||isNaN(n.getTime())?new Date:t?t==="end"?Et(n):G(n):n},C=(e,t,n=1)=>{if(typeof e!="number"||typeof t!="number"||typeof n!="number"||isNaN(e)||isNaN(t)||isNaN(n))return new Date;const r=new Date(e,t,n);return isNaN(r.getTime())?new Date:r},F=e=>{let t;return typeof e=="number"?t=new T(e,window.pktTz):t=new T(e,window.pktTz),t.setHours(12,0,0,0),t};let X=null,ht;const He=e=>{if(!e||isNaN(e.getTime()))return"";const t=typeof window<"u"?window.pktTz:void 0;return(!X||ht!==t)&&(X=new Intl.DateTimeFormat("no",{dateStyle:"full",timeZone:t}),ht=t),X.format(e)},Re=(e,t,n)=>{if(!e||isNaN(e.getTime()))return!1;const r=t?N(t):null,a=n?N(n):null;return!(r&&e<r||a&&e>a)},qe=(e,t)=>{if(!e||isNaN(e.getTime())||!Array.isArray(t))return!1;const n=m(e);return t.includes(n)},Le=(e,t)=>{if(!e||isNaN(e.getTime())||!Array.isArray(t))return!1;const n=e.getDay().toString();return t.includes(n)},kt=(e,t,n,r,a)=>!(!e||isNaN(e.getTime())||!Re(e,t,n)||r&&qe(e,r)||a&&Le(e,a)),Ue=(e,t,n,r,a)=>e.filter(s=>{const i=_(s);return i&&kt(i,t,n,r,a)}),Be=e=>e.slice().sort((t,n)=>{const r=_(t),a=_(n);return!r||!a?0:r.getTime()-a.getTime()}),ze=(e,t)=>{const n=_(e),r=_(t);return!n||!r?!1:n<=r},St=e=>e?Array.isArray(e)?e.filter(Boolean):String(e).split(",").map(t=>t.trim()).filter(Boolean):[],je=e=>e.join(","),Qe=e=>St(e),Xe=e=>e?v(e):null,Ge=e=>{if(typeof e=="string")return e.split(",").map(t=>v(t));if(Array.isArray(e))return e.map(t=>v(t))},q={csvToArray:Qe,stringToDate:Xe,stringsToDate:Ge},Ve={earliest:{default:null},latest:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},maxMultiple:{default:4},range:{default:!1}},O={props:Ve};function vt(e,t){const n=(t.excludedates??[]).map(r=>typeof r=="string"?r:m(r));return!kt(e,t.earliest,t.latest,n,t.excludeweekdays??[])}function Ke(e,t,n,r){return!!(vt(e,n)||!t&&r.multiple&&r.maxMultiple>0&&r.selectedCount>=r.maxMultiple)}function Je(e,t,n){const r=C(e,t,0);return!(n&&N(n)>r)}function Ze(e,t,n){const r=C(t===11?e+1:e,t===11?0:t+1,1);return!(n&&N(n)<r)}const R=7,tn=6;function en(e,t){const n=C(e,t,1),r=C(e,t+1,0),a=(n.getDay()+tn)%R,s=r.getDate(),i=Math.ceil((s+a)/R),c=C(e,t,0).getDate(),d=wt(n);return{firstDayOfMonth:n,lastDayOfMonth:r,startingDay:a,numDays:s,numRows:i,numDaysPrevMonth:c,initialWeek:d}}function nn(e,t,n,r){const{startingDay:a,numDays:s}=r;return e===0&&t<a?"prev-month":n>s?"next-month":"current-month"}function rn(e,t,n,r){const{startingDay:a,numDaysPrevMonth:s,numDays:i}=r;return e==="prev-month"?s-(a-t-1):e==="next-month"?n-i:n}function E(e){return typeof e=="string"&&(e=e.split(",")),e.length===1&&e[0]===""?[]:e.map(t=>v(t))}function dt(e,t){const n=yt({start:e,end:t}),r={};if(Array.isArray(n)&&n.length)for(let a=0;a<n.length;a++){const s=n[a],i=s>e&&s<t;r[m(s)]=i}return r}function Mt(e,t,n,r){if(t.length!==1)return!0;const a=yt({start:t[0],end:e});if(!Array.isArray(a)||!a.length)return!0;for(let s=0;s<a.length;s++){for(const i of n??[])if(i>t[0]&&i<e)return!1;if((r??[]).includes(_e(a[s]).toString()))return!1}return!0}function J(e,t){const n=m(e);return t.includes(n)?t:[...t,n]}function Z(e,t){const n=m(e),r=t.indexOf(n);if(r===-1)return t;if(t.length===1)return[];const a=[...t];return a.splice(r,1),a}function an(e,t,n){const r=m(e);return t.includes(r)?Z(e,t):n>0&&t.length>=n?t:J(e,t)}function sn(e,t,n){const r=m(e),a=E(t);if(t.includes(r))return t.indexOf(r)===0?[]:Z(e,t);if(t.length>1)return[r];if(t.length===1){if(!Mt(e,a,n.excludedates,n.excludeweekdays))return[r];if(a[0]>e)return[r]}return J(e,t)}const on={ArrowLeft:-1,ArrowRight:1,ArrowUp:-R,ArrowDown:R};function cn(e){var n;const t=e.nodeName;return t==="INPUT"||t==="SELECT"||t==="BUTTON"&&!((n=e.dataset)!=null&&n.date)}function un(e,t,n){let r=rt(e,t);if(!r)return null;let a=n(`button[data-date="${m(r)}"]`);for(;a instanceof HTMLButtonElement&&a.dataset.disabled;)if(r=rt(r,t),a=n(`button[data-date="${m(r)}"]`),!a)return null;return r}function ln(e){return on[e]??null}var hn=Object.defineProperty,dn=Object.getOwnPropertyDescriptor,h=(e,t,n,r)=>{for(var a=r>1?void 0:r?dn(t,n):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(r?i(t,n,a):i(a))||a);return r&&a&&hn(t,n,a),a};exports.PktCalendar=class extends u.PktElement{constructor(){super(...arguments),this.selected=[],this.multiple=O.props.multiple.default,this.maxMultiple=O.props.maxMultiple.default,this.range=O.props.range.default,this.earliest=O.props.earliest.default,this.latest=O.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.weeknumbers=O.props.weeknumbers.default,this.withcontrols=O.props.withcontrols.default,this.currentmonth=null,this.today=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.inRange={},this.rangeHovered=null,this.year=0,this.month=0,this.week=0,this.currentmonthtouched=!1,this.focusedDate=null,this.selectableDates=[],this.tabIndexSet=0}get todayDate(){return this.today?v(this.today):Fe()}firstUpdated(t){this.addEventListener("keydown",this.handleKeydown)}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}updated(t){super.updated(t),t.has("selected")&&this.convertSelected()}convertSelected(){typeof this.selected=="string"&&(this.selected=this.selected.split(",")),this.selected.length===1&&this.selected[0]===""&&(this.selected=[]),this._selected=E(this.selected),this.range&&this.selected.length===2&&(this.inRange=dt(this._selected[0],this._selected[1])),this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched&&(this.currentmonthtouched=!0),this.selected.length&&this.selected[0]!==""){const t=v(this.selected[this.selected.length-1]);this.currentmonth=isNaN(t.getTime())?F(this.todayDate):t}else this.currentmonth===null&&(this.currentmonth=F(this.todayDate));(!this.currentmonth||isNaN(this.currentmonth.getTime()))&&(this.currentmonth=F(this.todayDate)),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(t){const n=ln(t.key);n!==null&&this.handleArrowKey(t,n)}handleArrowKey(t,n){const r=t.target;if(cn(r))return;if(t.preventDefault(),!this.focusedDate){this.focusOnCurrentDate();return}const a=this.focusedDate?N(this.focusedDate):C(this.year,this.month,1),s=un(a,n,this.querySelector.bind(this));if(s){const i=this.querySelector(`button[data-date="${m(s)}"]`);i instanceof HTMLButtonElement&&!i.dataset.disabled&&(this.focusedDate=m(s),i.focus())}}render(){return u.b`
|
|
1
|
+
"use strict";const et=require("./class-map-Bokp1SoS.cjs"),u=require("./element-CMTfByxQ.cjs"),J=require("./state-BNgpvY-A.cjs");require("./icon-Dj0oZZSa.cjs");const ft=6048e5,Ot=864e5,nt=Symbol.for("constructDateFrom");function k(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&nt in e?e[nt](t):e instanceof Date?new e.constructor(t):new Date(t)}function b(e,t){return k(t||e,e)}function rt(e,t,n){const r=b(e,n==null?void 0:n.in);return isNaN(t)?k(e,NaN):(t&&r.setDate(r.getDate()+t),r)}let xt={};function U(){return xt}function H(e,t){var o,c,d,f;const n=U(),r=(t==null?void 0:t.weekStartsOn)??((c=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.weekStartsOn)??0,a=b(e,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 L(e,t){return H(e,{...t,weekStartsOn:1})}function mt(e,t){const n=b(e,t==null?void 0:t.in),r=n.getFullYear(),a=k(n,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const s=L(a),i=k(n,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const o=L(i);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function at(e){const t=b(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function gt(e,...t){const n=k.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function G(e,t){const n=b(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function Pt(e,t,n){const[r,a]=gt(n==null?void 0:n.in,e,t),s=G(r),i=G(a),o=+s-at(s),c=+i-at(i);return Math.round((o-c)/Ot)}function Ct(e,t){const n=mt(e,t),r=k(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),L(r)}function Nt(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function $t(e){return!(!Nt(e)&&typeof e!="number"||isNaN(+b(e)))}function Et(e,t){const n=b(e,t==null?void 0:t.in);return n.setHours(23,59,59,999),n}function Wt(e,t){const[n,r]=gt(e,t.start,t.end);return{start:n,end:r}}function yt(e,t){const{start:n,end:r}=Wt(t==null?void 0:t.in,e);let a=+n>+r;const s=a?+n:+r,i=a?r:n;i.setHours(0,0,0,0);let o=1;const c=[];for(;+i<=s;)c.push(k(n,i)),i.setDate(i.getDate()+o),i.setHours(0,0,0,0);return a?c.reverse():c}function _t(e,t){const n=b(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Yt={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"}},It=(e,t,n)=>{let r;const a=Yt[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function j(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Ft={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},At={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Ht={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Rt={date:j({formats:Ft,defaultWidth:"full"}),time:j({formats:At,defaultWidth:"full"}),dateTime:j({formats:Ht,defaultWidth:"full"})},qt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Lt=(e,t,n,r)=>qt[e];function Y(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,o=n!=null&&n.width?String(n.width):i;a=e.formattingValues[o]||e.formattingValues[i]}else{const i=e.defaultWidth,o=n!=null&&n.width?String(n.width):e.defaultWidth;a=e.values[o]||e.values[i]}const s=e.argumentCallback?e.argumentCallback(t):t;return a[s]}}const Ut={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Bt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},zt={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"]},jt={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"]},Qt={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"}},Xt={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"}},Gt=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Vt={ordinalNumber:Gt,era:Y({values:Ut,defaultWidth:"wide"}),quarter:Y({values:Bt,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Y({values:zt,defaultWidth:"wide"}),day:Y({values:jt,defaultWidth:"wide"}),dayPeriod:Y({values:Qt,defaultWidth:"wide",formattingValues:Xt,defaultFormattingWidth:"wide"})};function I(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(a);if(!s)return null;const i=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(o)?Kt(o,y=>y.test(i)):Jt(o,y=>y.test(i));let d;d=e.valueCallback?e.valueCallback(c):c,d=n.valueCallback?n.valueCallback(d):d;const f=t.slice(i.length);return{value:d,rest:f}}}function Jt(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Kt(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function Zt(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;const o=t.slice(a.length);return{value:i,rest:o}}}const te=/^(\d+)(th|st|nd|rd)?/i,ee=/\d+/i,ne={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},re={any:[/^b/i,/^(a|c)/i]},ae={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},se={any:[/1/i,/2/i,/3/i,/4/i]},ie={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},oe={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]},ce={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},ue={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]},le={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},he={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}},de={ordinalNumber:Zt({matchPattern:te,parsePattern:ee,valueCallback:e=>parseInt(e,10)}),era:I({matchPatterns:ne,defaultMatchWidth:"wide",parsePatterns:re,defaultParseWidth:"any"}),quarter:I({matchPatterns:ae,defaultMatchWidth:"wide",parsePatterns:se,defaultParseWidth:"any",valueCallback:e=>e+1}),month:I({matchPatterns:ie,defaultMatchWidth:"wide",parsePatterns:oe,defaultParseWidth:"any"}),day:I({matchPatterns:ce,defaultMatchWidth:"wide",parsePatterns:ue,defaultParseWidth:"any"}),dayPeriod:I({matchPatterns:le,defaultMatchWidth:"any",parsePatterns:he,defaultParseWidth:"any"})},fe={code:"en-US",formatDistance:It,formatLong:Rt,formatRelative:Lt,localize:Vt,match:de,options:{weekStartsOn:0,firstWeekContainsDate:1}};function me(e,t){const n=b(e,t==null?void 0:t.in);return Pt(n,_t(n))+1}function ge(e,t){const n=b(e,t==null?void 0:t.in),r=+L(n)-+Ct(n);return Math.round(r/ft)+1}function pt(e,t){var f,y,p,S;const n=b(e,t==null?void 0:t.in),r=n.getFullYear(),a=U(),s=(t==null?void 0:t.firstWeekContainsDate)??((y=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:y.firstWeekContainsDate)??a.firstWeekContainsDate??((S=(p=a.locale)==null?void 0:p.options)==null?void 0:S.firstWeekContainsDate)??1,i=k((t==null?void 0:t.in)||e,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const o=H(i,t),c=k((t==null?void 0:t.in)||e,0);c.setFullYear(r,0,s),c.setHours(0,0,0,0);const d=H(c,t);return+n>=+o?r+1:+n>=+d?r:r-1}function ye(e,t){var o,c,d,f;const n=U(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((f=(d=n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??1,a=pt(e,t),s=k((t==null?void 0:t.in)||e,0);return s.setFullYear(a,0,r),s.setHours(0,0,0,0),H(s,t)}function wt(e,t){const n=b(e,t==null?void 0:t.in),r=+H(n,t)-+ye(n,t);return Math.round(r/ft)+1}function l(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const M={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return l(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):l(n+1,2)},d(e,t){return l(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return l(e.getHours()%12||12,t.length)},H(e,t){return l(e.getHours(),t.length)},m(e,t){return l(e.getMinutes(),t.length)},s(e,t){return l(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return l(a,t.length)}},$={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},st={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return M.y(e,t)},Y:function(e,t,n,r){const a=pt(e,r),s=a>0?a:1-a;if(t==="YY"){const i=s%100;return l(i,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):l(s,t.length)},R:function(e,t){const n=mt(e);return l(n,t.length)},u:function(e,t){const n=e.getFullYear();return l(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return l(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return l(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return M.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return l(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const a=wt(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):l(a,t.length)},I:function(e,t,n){const r=ge(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):l(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):M.d(e,t)},D:function(e,t,n){const r=me(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):l(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const a=e.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return l(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const a=e.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return l(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return l(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=$.noon:r===0?a=$.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=$.evening:r>=12?a=$.afternoon:r>=4?a=$.morning:a=$.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return M.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):M.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):l(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):l(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):M.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):M.s(e,t)},S:function(e,t){return M.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return ot(r);case"XXXX":case"XX":return x(r);case"XXXXX":case"XXX":default:return x(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return ot(r);case"xxxx":case"xx":return x(r);case"xxxxx":case"xxx":default:return x(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+it(r,":");case"OOOO":default:return"GMT"+x(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+it(r,":");case"zzzz":default:return"GMT"+x(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return l(r,t.length)},T:function(e,t,n){return l(+e,t.length)}};function it(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),s=r%60;return s===0?n+String(a):n+String(a)+t+l(s,2)}function ot(e,t){return e%60===0?(e>0?"-":"+")+l(Math.abs(e)/60,2):x(e,t)}function x(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=l(Math.trunc(r/60),2),s=l(r%60,2);return n+a+t+s}const ct=(e,t)=>{switch(e){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"})}},bt=(e,t)=>{switch(e){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"})}},pe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return ct(e,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}}",ct(r,t)).replace("{{time}}",bt(a,t))},we={p:bt,P:pe},be=/^D+$/,De=/^Y+$/,ke=["D","DD","YY","YYYY"];function Se(e){return be.test(e)}function ve(e){return De.test(e)}function Me(e,t,n){const r=Te(e,t,n);if(console.warn(r),ke.includes(e))throw new RangeError(r)}function Te(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Oe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,xe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Pe=/^'([^]*?)'?$/,Ce=/''/g,Ne=/[a-zA-Z]/;function $e(e,t,n){var f,y,p,S;const r=U(),a=r.locale??fe,s=r.firstWeekContainsDate??((y=(f=r.locale)==null?void 0:f.options)==null?void 0:y.firstWeekContainsDate)??1,i=r.weekStartsOn??((S=(p=r.locale)==null?void 0:p.options)==null?void 0:S.weekStartsOn)??0,o=b(e,n==null?void 0:n.in);if(!$t(o))throw new RangeError("Invalid time value");let c=t.match(xe).map(w=>{const g=w[0];if(g==="p"||g==="P"){const _=we[g];return _(w,a.formatLong)}return w}).join("").match(Oe).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const g=w[0];if(g==="'")return{isToken:!1,value:Ee(w)};if(st[g])return{isToken:!0,value:w};if(g.match(Ne))throw new RangeError("Format string contains an unescaped latin alphabet character `"+g+"`");return{isToken:!1,value:w}});a.localize.preprocessor&&(c=a.localize.preprocessor(o,c));const d={firstWeekContainsDate:s,weekStartsOn:i,locale:a};return c.map(w=>{if(!w.isToken)return w.value;const g=w.value;(ve(g)||Se(g))&&Me(g,t,String(e));const _=st[g[0]];return _(o,g,a.localize,d)}).join("")}function Ee(e){const t=e.match(Pe);return t?t[1].replace(Ce,"'"):e}function We(e,t){const n=b(e,t==null?void 0:t.in).getDay();return n===0?7:n}function _e(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const Q={},A={};function P(e,t){try{const r=(Q[e]||(Q[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return r in A?A[r]:ut(r,r.split(":"))}catch{if(e in A)return A[e];const n=e==null?void 0:e.match(Ye);return n?ut(e,n.slice(1)):NaN}}const Ye=/([+-]\d\d):?(\d\d)?/;function ut(e,t){const n=+(t[0]||0),r=+(t[1]||0),a=+(t[2]||0)/60;return A[e]=n*60+r>0?n*60+r+a:n*60-r-a}class D extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(P(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)),Dt(this),V(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new D(...n,t):new D(Date.now(),t)}withTimeZone(t){return new D(+this,t)}getTimezoneOffset(){const t=-P(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),V(this),+this}[Symbol.for("constructDateFrom")](t){return new D(+new Date(t),this.timeZone)}}const lt=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!lt.test(e))return;const t=e.replace(lt,"$1UTC");D.prototype[t]&&(e.startsWith("get")?D.prototype[e]=function(){return this.internal[t]()}:(D.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),Ie(this),+this},D.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),V(this),+this}))});function V(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-P(e.timeZone,e)*60))}function Ie(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),Dt(e)}function Dt(e){const t=P(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const a=-new Date(+e).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),i=a-s,o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const c=a-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const d=new Date(+e);d.setUTCSeconds(0);const f=a>0?d.getSeconds():(d.getSeconds()-60)%60,y=Math.round(-(P(e.timeZone,e)*60))%60;(y||f)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+y),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+y+f));const p=P(e.timeZone,e),S=p>0?Math.floor(p):Math.ceil(p),g=-new Date(+e).getTimezoneOffset()-S,_=S!==n,tt=g-c;if(_&&tt){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+tt);const B=P(e.timeZone,e),Tt=B>0?Math.floor(B):Math.ceil(B),z=S-Tt;z&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+z),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+z))}}class T extends D{static tz(t,...n){return n.length?new T(...n,t):new T(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),a=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+a}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,a]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${n} ${a}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,a]=this.tzComponents();return`${t} GMT${n}${r}${a} (${_e(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),a=String(Math.abs(t)%60).padStart(2,"0");return[n,r,a]}withTimeZone(t){return new T(+this,t)}[Symbol.for("constructDateFrom")](t){return new T(+new Date(t),this.timeZone)}}window.pktTz=window.pktTz===void 0?"Europe/Oslo":window.pktTz;const Fe=(e=window.pktTz)=>{const t=new T(new Date().toISOString(),e);return t.setHours(0,0,0,0),isNaN(t.getTime())?new Date:new Date(t.getFullYear(),t.getMonth(),t.getDate())};function v(e){if(!e||e==="")return new Date;if(/^\d{4}-\d{2}-\d{2}$/.test(e)){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r)}if(/^\d{4}-\d{2}$/.test(e)){const[t,n]=e.split("-").map(Number);return new Date(t,n-1,1)}return/^\d{4}$/.test(e)?new Date(Number(e),0,1):new Date(e)}const m=e=>{if(!e||isNaN(e.getTime()))return"";const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`},W=e=>{if(!e)return null;const t=v(e);return isNaN(t.getTime())?null:t},Ae=(e,t)=>{const n=N(e);return isNaN(n.getTime())?"":$e(n,t)},N=(e="",t)=>{const n=typeof e=="string"?v(e):e;return!n||isNaN(n.getTime())?new Date:t?t==="end"?Et(n):G(n):n},C=(e,t,n=1)=>{if(typeof e!="number"||typeof t!="number"||typeof n!="number"||isNaN(e)||isNaN(t)||isNaN(n))return new Date;const r=new Date(e,t,n);return isNaN(r.getTime())?new Date:r},F=e=>{let t;return typeof e=="number"?t=new T(e,window.pktTz):t=new T(e,window.pktTz),t.setHours(12,0,0,0),t};let X=null,ht;const He=e=>{if(!e||isNaN(e.getTime()))return"";const t=typeof window<"u"?window.pktTz:void 0;return(!X||ht!==t)&&(X=new Intl.DateTimeFormat("no",{dateStyle:"full",timeZone:t}),ht=t),X.format(e)},Re=(e,t,n)=>{if(!e||isNaN(e.getTime()))return!1;const r=t?N(t):null,a=n?N(n):null;return!(r&&e<r||a&&e>a)},qe=(e,t)=>{if(!e||isNaN(e.getTime())||!Array.isArray(t))return!1;const n=m(e);return t.includes(n)},Le=(e,t)=>{if(!e||isNaN(e.getTime())||!Array.isArray(t))return!1;const n=e.getDay().toString();return t.includes(n)},kt=(e,t,n,r,a)=>!(!e||isNaN(e.getTime())||!Re(e,t,n)||r&&qe(e,r)||a&&Le(e,a)),Ue=(e,t,n,r,a)=>e.filter(s=>{const i=W(s);return i&&kt(i,t,n,r,a)}),Be=e=>e.slice().sort((t,n)=>{const r=W(t),a=W(n);return!r||!a?0:r.getTime()-a.getTime()}),ze=(e,t)=>{const n=W(e),r=W(t);return!n||!r?!1:n<=r},St=e=>{if(!e)return[];if(Array.isArray(e))return e.filter(Boolean);if(typeof e=="string"&&e.trimStart().startsWith("["))try{const t=JSON.parse(e);if(Array.isArray(t))return t.filter(Boolean)}catch{}return String(e).split(",").map(t=>t.trim()).filter(Boolean)},je=e=>e.join(","),Qe=e=>St(e),Xe=e=>e?v(e):null,Ge=e=>{if(typeof e=="string")return e.split(",").map(t=>v(t));if(Array.isArray(e))return e.map(t=>v(t))},q={csvToArray:Qe,stringToDate:Xe,stringsToDate:Ge},Ve={earliest:{default:null},latest:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},maxMultiple:{default:4},range:{default:!1}},O={props:Ve};function vt(e,t){const n=(t.excludedates??[]).map(r=>typeof r=="string"?r:m(r));return!kt(e,t.earliest,t.latest,n,t.excludeweekdays??[])}function Je(e,t,n,r){return!!(vt(e,n)||!t&&r.multiple&&r.maxMultiple>0&&r.selectedCount>=r.maxMultiple)}function Ke(e,t,n){const r=C(e,t,0);return!(n&&N(n)>r)}function Ze(e,t,n){const r=C(t===11?e+1:e,t===11?0:t+1,1);return!(n&&N(n)<r)}const R=7,tn=6;function en(e,t){const n=C(e,t,1),r=C(e,t+1,0),a=(n.getDay()+tn)%R,s=r.getDate(),i=Math.ceil((s+a)/R),c=C(e,t,0).getDate(),d=wt(n);return{firstDayOfMonth:n,lastDayOfMonth:r,startingDay:a,numDays:s,numRows:i,numDaysPrevMonth:c,initialWeek:d}}function nn(e,t,n,r){const{startingDay:a,numDays:s}=r;return e===0&&t<a?"prev-month":n>s?"next-month":"current-month"}function rn(e,t,n,r){const{startingDay:a,numDaysPrevMonth:s,numDays:i}=r;return e==="prev-month"?s-(a-t-1):e==="next-month"?n-i:n}function E(e){return typeof e=="string"&&(e=e.split(",")),e.length===1&&e[0]===""?[]:e.map(t=>v(t))}function dt(e,t){const n=yt({start:e,end:t}),r={};if(Array.isArray(n)&&n.length)for(let a=0;a<n.length;a++){const s=n[a],i=s>e&&s<t;r[m(s)]=i}return r}function Mt(e,t,n,r){if(t.length!==1)return!0;const a=yt({start:t[0],end:e});if(!Array.isArray(a)||!a.length)return!0;for(let s=0;s<a.length;s++){for(const i of n??[])if(i>t[0]&&i<e)return!1;if((r??[]).includes(We(a[s]).toString()))return!1}return!0}function K(e,t){const n=m(e);return t.includes(n)?t:[...t,n]}function Z(e,t){const n=m(e),r=t.indexOf(n);if(r===-1)return t;if(t.length===1)return[];const a=[...t];return a.splice(r,1),a}function an(e,t,n){const r=m(e);return t.includes(r)?Z(e,t):n>0&&t.length>=n?t:K(e,t)}function sn(e,t,n){const r=m(e),a=E(t);if(t.includes(r))return t.indexOf(r)===0?[]:Z(e,t);if(t.length>1)return[r];if(t.length===1){if(!Mt(e,a,n.excludedates,n.excludeweekdays))return[r];if(a[0]>e)return[r]}return K(e,t)}const on={ArrowLeft:-1,ArrowRight:1,ArrowUp:-R,ArrowDown:R};function cn(e){var n;const t=e.nodeName;return t==="INPUT"||t==="SELECT"||t==="BUTTON"&&!((n=e.dataset)!=null&&n.date)}function un(e,t,n){let r=rt(e,t);if(!r)return null;let a=n(`button[data-date="${m(r)}"]`);for(;a instanceof HTMLButtonElement&&a.dataset.disabled;)if(r=rt(r,t),a=n(`button[data-date="${m(r)}"]`),!a)return null;return r}function ln(e){return on[e]??null}var hn=Object.defineProperty,dn=Object.getOwnPropertyDescriptor,h=(e,t,n,r)=>{for(var a=r>1?void 0:r?dn(t,n):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(r?i(t,n,a):i(a))||a);return r&&a&&hn(t,n,a),a};exports.PktCalendar=class extends u.PktElement{constructor(){super(...arguments),this.selected=[],this.multiple=O.props.multiple.default,this.maxMultiple=O.props.maxMultiple.default,this.range=O.props.range.default,this.earliest=O.props.earliest.default,this.latest=O.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.weeknumbers=O.props.weeknumbers.default,this.withcontrols=O.props.withcontrols.default,this.currentmonth=null,this.today=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.inRange={},this.rangeHovered=null,this.year=0,this.month=0,this.week=0,this.currentmonthtouched=!1,this.focusedDate=null,this.selectableDates=[],this.tabIndexSet=0}get todayDate(){return this.today?v(this.today):Fe()}firstUpdated(t){this.addEventListener("keydown",this.handleKeydown)}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}updated(t){super.updated(t),t.has("selected")&&this.convertSelected()}convertSelected(){typeof this.selected=="string"&&(this.selected=this.selected.split(",")),this.selected.length===1&&this.selected[0]===""&&(this.selected=[]),this._selected=E(this.selected),this.range&&this.selected.length===2&&(this.inRange=dt(this._selected[0],this._selected[1])),this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched&&(this.currentmonthtouched=!0),this.selected.length&&this.selected[0]!==""){const t=v(this.selected[this.selected.length-1]);this.currentmonth=isNaN(t.getTime())?F(this.todayDate):t}else this.currentmonth===null&&(this.currentmonth=F(this.todayDate));(!this.currentmonth||isNaN(this.currentmonth.getTime()))&&(this.currentmonth=F(this.todayDate)),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(t){const n=ln(t.key);n!==null&&this.handleArrowKey(t,n)}handleArrowKey(t,n){const r=t.target;if(cn(r))return;if(t.preventDefault(),!this.focusedDate){this.focusOnCurrentDate();return}const a=this.focusedDate?N(this.focusedDate):C(this.year,this.month,1),s=un(a,n,this.querySelector.bind(this));if(s){const i=this.querySelector(`button[data-date="${m(s)}"]`);i instanceof HTMLButtonElement&&!i.dataset.disabled&&(this.focusedDate=m(s),i.focus())}}render(){return u.b`
|
|
2
2
|
<div
|
|
3
3
|
class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":""}"
|
|
4
4
|
@focusout=${this.closeEvent}
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
/>
|
|
64
64
|
</div>`:u.b`<div class="pkt-txt-16-medium pkt-calendar__month-title" aria-live="polite">
|
|
65
65
|
${this.monthStrings[this.month]} ${this.year}
|
|
66
|
-
</div>`}getDayViewData(t,n){const r=C(this.year,this.month,t),a=m(r),s=a===m(n),i=this.selected.includes(a),o=this.isDayDisabled(r,i),c=this.calculateTabIndex(a,o,t);return{currentDate:r,currentDateISO:a,isToday:s,isSelected:i,isDisabled:o,ariaLabel:He(r),tabindex:c}}getDateConstraints(){return{earliest:this.earliest,latest:this.latest,excludedates:this.excludedates,excludeweekdays:this.excludeweekdays}}isDayDisabled(t,n){return
|
|
66
|
+
</div>`}getDayViewData(t,n){const r=C(this.year,this.month,t),a=m(r),s=a===m(n),i=this.selected.includes(a),o=this.isDayDisabled(r,i),c=this.calculateTabIndex(a,o,t);return{currentDate:r,currentDateISO:a,isToday:s,isSelected:i,isDisabled:o,ariaLabel:He(r),tabindex:c}}getDateConstraints(){return{earliest:this.earliest,latest:this.latest,excludedates:this.excludedates,excludeweekdays:this.excludeweekdays}}isDayDisabled(t,n){return Je(t,n,this.getDateConstraints(),{multiple:this.multiple,maxMultiple:this.maxMultiple,selectedCount:this.selected.length})}calculateTabIndex(t,n,r){return this.focusedDate?this.focusedDate===t&&!n?"0":"-1":!n&&this.tabIndexSet===0?(this.tabIndexSet=r,"0"):this.tabIndexSet===r?"0":"-1"}getDayCellClasses(t){const{currentDateISO:n,isToday:r,isSelected:a}=t,s=this.range&&(this.selected.length===2||this.rangeHovered!==null)&&n===this.selected[0],i=this.range&&this.selected.length===2&&n===this.selected[1];return{"pkt-cal-today":r,"pkt-cal-selected":a,"pkt-cal-in-range":this.inRange[n],"pkt-cal-excluded":this.isExcluded(t.currentDate),"pkt-cal-in-range-first":s,"pkt-cal-in-range-last":i,"pkt-cal-range-hover":this.rangeHovered!==null&&n===m(this.rangeHovered)}}getDayButtonClasses(t){const{currentDateISO:n,isToday:r,isSelected:a,isDisabled:s}=t,i=this.range&&(this.selected.length===2||this.rangeHovered!==null)&&n===this.selected[0],o=this.range&&this.selected.length===2&&n===this.selected[1];return{"pkt-calendar__date":!0,"pkt-calendar__date--today":r,"pkt-calendar__date--selected":a,"pkt-calendar__date--disabled":s,"pkt-calendar__date--in-range":this.inRange[n],"pkt-calendar__date--in-range-hover":this.rangeHovered!==null&&n===m(this.rangeHovered),"pkt-calendar__date--range-start":i,"pkt-calendar__date--range-end":o}}handleDayFocus(t,n){this.range&&!this.isExcluded(t)&&this.handleRangeHover(t),this.focusedDate=n}renderDayView(t,n){const r=this.getDayViewData(t,n),{currentDate:a,currentDateISO:s,isSelected:i,isDisabled:o,ariaLabel:c,tabindex:d}=r;this.selectableDates.push({currentDateISO:s,isDisabled:o,tabindex:d});const f=this.getDayCellClasses(r),y=this.getDayButtonClasses(r);return u.b`<td class=${et.e(f)}>
|
|
67
67
|
<button
|
|
68
68
|
type="button"
|
|
69
69
|
aria-pressed=${i?"true":"false"}
|
|
@@ -87,4 +87,4 @@
|
|
|
87
87
|
>
|
|
88
88
|
<span class="pkt-btn__text pkt-txt-14-light">${t}</span>
|
|
89
89
|
</div>
|
|
90
|
-
</td>`}renderWeekRow(t){return u.b`<tr class="pkt-cal-week-row" role="row">${t}</tr>`}renderCalendarBody(){const t=this.todayDate,n=en(this.year,this.month);this.selectableDates=[],this.tabIndexSet=0;let r=1;this.week=n.initialWeek;const a=[];for(let s=0;s<n.numRows;s++){const i=[];this.weeknumbers&&i.push(u.b`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let o=0;o<R;o++){const c=nn(s,o,r,n);if(c==="current-month")i.push(this.renderDayView(r,t)),r++;else{const d=rn(c,o,r,n);i.push(this.renderEmptyDayCell(d)),c==="next-month"&&r++}}a.push(this.renderWeekRow(i))}return a}isExcluded(t){return vt(t,this.getDateConstraints())}isPrevMonthAllowed(){return
|
|
90
|
+
</td>`}renderWeekRow(t){return u.b`<tr class="pkt-cal-week-row" role="row">${t}</tr>`}renderCalendarBody(){const t=this.todayDate,n=en(this.year,this.month);this.selectableDates=[],this.tabIndexSet=0;let r=1;this.week=n.initialWeek;const a=[];for(let s=0;s<n.numRows;s++){const i=[];this.weeknumbers&&i.push(u.b`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let o=0;o<R;o++){const c=nn(s,o,r,n);if(c==="current-month")i.push(this.renderDayView(r,t)),r++;else{const d=rn(c,o,r,n);i.push(this.renderEmptyDayCell(d)),c==="next-month"&&r++}}a.push(this.renderWeekRow(i))}return a}isExcluded(t){return vt(t,this.getDateConstraints())}isPrevMonthAllowed(){return Ke(this.year,this.month,this.earliest)}prevMonth(){const t=this.month===0?11:this.month-1,n=this.month===0?this.year-1:this.year;this.changeMonth(n,t)}isNextMonthAllowed(){return Ze(this.year,this.month,this.latest)}nextMonth(){const t=this.month===11?0:this.month+1,n=this.month===11?this.year+1:this.year;this.changeMonth(n,t)}changeMonth(t,n){this.year=typeof t=="string"?parseInt(t):t,this.month=typeof n=="string"?parseInt(n):n,this.currentmonth=F(new Date(this.year,this.month,1)),this.tabIndexSet=0,this.focusedDate=null,this.selectableDates=[]}emptySelected(){this.selected=[],this._selected=[],this.inRange={}}normalizeSelected(){return typeof this.selected=="string"?this.selected.split(","):this.selected}addToSelected(t){this.selected=K(t,this.normalizeSelected()),this._selected=E(this.selected),this.range&&this.selected.length===2&&(this.convertSelected(),this.close())}removeFromSelected(t){this.selected=Z(t,this.normalizeSelected()),this._selected=E(this.selected)}toggleSelected(t){this.selected=an(t,this.normalizeSelected(),this.maxMultiple),this._selected=E(this.selected)}isRangeAllowed(t){return Mt(t,this._selected,this.excludedates,this.excludeweekdays)}handleRangeSelect(t){return this.selected=sn(t,this.normalizeSelected(),{excludedates:this.excludedates,excludeweekdays:this.excludeweekdays}),this._selected=E(this.selected),this.selected.length===2?(this.convertSelected(),this.close()):this.selected.length===1&&(this.inRange={}),Promise.resolve()}handleRangeHover(t){if(!this.range||this._selected.length!==1||!this.isRangeAllowed(t)||this._selected[0]>=t){this.rangeHovered=null;return}this.rangeHovered=t,this.inRange=dt(this._selected[0],t)}handleDateSelect(t){return t&&(this.range?this.handleRangeSelect(t):this.multiple?this.toggleSelected(t):(this.selected.includes(m(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=m(F(this.todayDate)),n=this.querySelector(`button[data-date="${t}"]`);if(n instanceof HTMLButtonElement){this.focusedDate=t,n.focus();return}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-invisible")&&this.close()}close(){this.dispatchEvent(new CustomEvent("close",{detail:!0,bubbles:!0,composed:!0}))}};h([u.n({converter:q.csvToArray})],exports.PktCalendar.prototype,"selected",2);h([u.n({type:Boolean})],exports.PktCalendar.prototype,"multiple",2);h([u.n({type:Number,attribute:"max-multiple"})],exports.PktCalendar.prototype,"maxMultiple",2);h([u.n({type:Boolean})],exports.PktCalendar.prototype,"range",2);h([u.n({type:String})],exports.PktCalendar.prototype,"earliest",2);h([u.n({type:String})],exports.PktCalendar.prototype,"latest",2);h([u.n({converter:q.stringsToDate})],exports.PktCalendar.prototype,"excludedates",2);h([u.n({converter:q.csvToArray})],exports.PktCalendar.prototype,"excludeweekdays",2);h([u.n({type:Boolean})],exports.PktCalendar.prototype,"weeknumbers",2);h([u.n({type:Boolean})],exports.PktCalendar.prototype,"withcontrols",2);h([u.n({converter:q.stringToDate})],exports.PktCalendar.prototype,"currentmonth",2);h([u.n({type:String})],exports.PktCalendar.prototype,"today",2);h([u.n({type:Array,attribute:"day-strings"})],exports.PktCalendar.prototype,"dayStrings",2);h([u.n({type:Array,attribute:"day-strings-long"})],exports.PktCalendar.prototype,"dayStringsLong",2);h([u.n({type:Array,attribute:"month-strings"})],exports.PktCalendar.prototype,"monthStrings",2);h([u.n({type:String,attribute:"week-string"})],exports.PktCalendar.prototype,"weekString",2);h([u.n({type:String,attribute:"prev-month-string"})],exports.PktCalendar.prototype,"prevMonthString",2);h([u.n({type:String,attribute:"next-month-string"})],exports.PktCalendar.prototype,"nextMonthString",2);h([u.n({type:Array})],exports.PktCalendar.prototype,"_selected",2);h([J.r()],exports.PktCalendar.prototype,"inRange",2);h([u.n({type:Date})],exports.PktCalendar.prototype,"rangeHovered",2);h([u.n({type:Number})],exports.PktCalendar.prototype,"year",2);h([u.n({type:Number})],exports.PktCalendar.prototype,"month",2);h([u.n({type:Number})],exports.PktCalendar.prototype,"week",2);h([J.r()],exports.PktCalendar.prototype,"currentmonthtouched",2);h([J.r()],exports.PktCalendar.prototype,"focusedDate",2);exports.PktCalendar=h([u.t("pkt-calendar")],exports.PktCalendar);exports.arrayToCsv=je;exports.converters=q;exports.filterSelectableDates=Ue;exports.formatISODate=m;exports.fromISOToDate=W;exports.fromISOtoLocal=Ae;exports.isValidDateRange=ze;exports.newDate=N;exports.parseISODateString=v;exports.sortDateStrings=Be;exports.valueToArray=St;
|
|
@@ -14,23 +14,23 @@ function it(t, e, n) {
|
|
|
14
14
|
return isNaN(e) ? k(t, NaN) : (e && r.setDate(r.getDate() + e), r);
|
|
15
15
|
}
|
|
16
16
|
let $t = {};
|
|
17
|
-
function
|
|
17
|
+
function q() {
|
|
18
18
|
return $t;
|
|
19
19
|
}
|
|
20
20
|
function R(t, e) {
|
|
21
21
|
var o, c, d, g;
|
|
22
|
-
const n =
|
|
22
|
+
const n = q(), r = (e == null ? void 0 : e.weekStartsOn) ?? ((c = (o = e == null ? void 0 : e.locale) == null ? void 0 : o.options) == null ? void 0 : c.weekStartsOn) ?? n.weekStartsOn ?? ((g = (d = n.locale) == null ? void 0 : d.options) == null ? void 0 : g.weekStartsOn) ?? 0, a = b(t, e == null ? void 0 : e.in), s = a.getDay(), i = (s < r ? 7 : 0) + s - r;
|
|
23
23
|
return a.setDate(a.getDate() - i), a.setHours(0, 0, 0, 0), a;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function B(t, e) {
|
|
26
26
|
return R(t, { ...e, weekStartsOn: 1 });
|
|
27
27
|
}
|
|
28
28
|
function pt(t, e) {
|
|
29
29
|
const n = b(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = k(n, 0);
|
|
30
30
|
a.setFullYear(r + 1, 0, 4), a.setHours(0, 0, 0, 0);
|
|
31
|
-
const s =
|
|
31
|
+
const s = B(a), i = k(n, 0);
|
|
32
32
|
i.setFullYear(r, 0, 4), i.setHours(0, 0, 0, 0);
|
|
33
|
-
const o =
|
|
33
|
+
const o = B(i);
|
|
34
34
|
return n.getTime() >= s.getTime() ? r + 1 : n.getTime() >= o.getTime() ? r : r - 1;
|
|
35
35
|
}
|
|
36
36
|
function ot(t) {
|
|
@@ -54,7 +54,7 @@ function wt(t, ...e) {
|
|
|
54
54
|
);
|
|
55
55
|
return e.map(n);
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function J(t, e) {
|
|
58
58
|
const n = b(t, e == null ? void 0 : e.in);
|
|
59
59
|
return n.setHours(0, 0, 0, 0), n;
|
|
60
60
|
}
|
|
@@ -63,18 +63,18 @@ function Et(t, e, n) {
|
|
|
63
63
|
n == null ? void 0 : n.in,
|
|
64
64
|
t,
|
|
65
65
|
e
|
|
66
|
-
), s =
|
|
66
|
+
), s = J(r), i = J(a), o = +s - ot(s), c = +i - ot(i);
|
|
67
67
|
return Math.round((o - c) / Ct);
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function Wt(t, e) {
|
|
70
70
|
const n = pt(t, e), r = k(t, 0);
|
|
71
|
-
return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0),
|
|
71
|
+
return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0), B(r);
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function _t(t) {
|
|
74
74
|
return t instanceof Date || typeof t == "object" && Object.prototype.toString.call(t) === "[object Date]";
|
|
75
75
|
}
|
|
76
76
|
function Yt(t) {
|
|
77
|
-
return !(!
|
|
77
|
+
return !(!_t(t) && typeof t != "number" || isNaN(+b(t)));
|
|
78
78
|
}
|
|
79
79
|
function Ft(t, e) {
|
|
80
80
|
const n = b(t, e == null ? void 0 : e.in);
|
|
@@ -182,12 +182,12 @@ const Ut = {
|
|
|
182
182
|
long: "h:mm:ss a z",
|
|
183
183
|
medium: "h:mm:ss a",
|
|
184
184
|
short: "h:mm a"
|
|
185
|
-
},
|
|
185
|
+
}, Bt = {
|
|
186
186
|
full: "{{date}} 'at' {{time}}",
|
|
187
187
|
long: "{{date}} 'at' {{time}}",
|
|
188
188
|
medium: "{{date}}, {{time}}",
|
|
189
189
|
short: "{{date}}, {{time}}"
|
|
190
|
-
},
|
|
190
|
+
}, qt = {
|
|
191
191
|
date: X({
|
|
192
192
|
formats: Ut,
|
|
193
193
|
defaultWidth: "full"
|
|
@@ -197,7 +197,7 @@ const Ut = {
|
|
|
197
197
|
defaultWidth: "full"
|
|
198
198
|
}),
|
|
199
199
|
dateTime: X({
|
|
200
|
-
formats:
|
|
200
|
+
formats: Bt,
|
|
201
201
|
defaultWidth: "full"
|
|
202
202
|
})
|
|
203
203
|
}, zt = {
|
|
@@ -274,7 +274,7 @@ const Qt = {
|
|
|
274
274
|
"Friday",
|
|
275
275
|
"Saturday"
|
|
276
276
|
]
|
|
277
|
-
},
|
|
277
|
+
}, Jt = {
|
|
278
278
|
narrow: {
|
|
279
279
|
am: "a",
|
|
280
280
|
pm: "p",
|
|
@@ -305,7 +305,7 @@ const Qt = {
|
|
|
305
305
|
evening: "evening",
|
|
306
306
|
night: "night"
|
|
307
307
|
}
|
|
308
|
-
},
|
|
308
|
+
}, Kt = {
|
|
309
309
|
narrow: {
|
|
310
310
|
am: "a",
|
|
311
311
|
pm: "p",
|
|
@@ -368,9 +368,9 @@ const Qt = {
|
|
|
368
368
|
defaultWidth: "wide"
|
|
369
369
|
}),
|
|
370
370
|
dayPeriod: F({
|
|
371
|
-
values:
|
|
371
|
+
values: Jt,
|
|
372
372
|
defaultWidth: "wide",
|
|
373
|
-
formattingValues:
|
|
373
|
+
formattingValues: Kt,
|
|
374
374
|
defaultFormattingWidth: "wide"
|
|
375
375
|
})
|
|
376
376
|
};
|
|
@@ -521,7 +521,7 @@ const ae = /^(\d+)(th|st|nd|rd)?/i, se = /\d+/i, ie = {
|
|
|
521
521
|
}, pe = {
|
|
522
522
|
code: "en-US",
|
|
523
523
|
formatDistance: Rt,
|
|
524
|
-
formatLong:
|
|
524
|
+
formatLong: qt,
|
|
525
525
|
formatRelative: jt,
|
|
526
526
|
localize: te,
|
|
527
527
|
match: ye,
|
|
@@ -535,12 +535,12 @@ function we(t, e) {
|
|
|
535
535
|
return Et(n, At(n)) + 1;
|
|
536
536
|
}
|
|
537
537
|
function be(t, e) {
|
|
538
|
-
const n = b(t, e == null ? void 0 : e.in), r = +
|
|
538
|
+
const n = b(t, e == null ? void 0 : e.in), r = +B(n) - +Wt(n);
|
|
539
539
|
return Math.round(r / yt) + 1;
|
|
540
540
|
}
|
|
541
541
|
function Dt(t, e) {
|
|
542
542
|
var g, m, v, M;
|
|
543
|
-
const n = b(t, e == null ? void 0 : e.in), r = n.getFullYear(), a =
|
|
543
|
+
const n = b(t, e == null ? void 0 : e.in), r = n.getFullYear(), a = q(), s = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((m = (g = e == null ? void 0 : e.locale) == null ? void 0 : g.options) == null ? void 0 : m.firstWeekContainsDate) ?? a.firstWeekContainsDate ?? ((M = (v = a.locale) == null ? void 0 : v.options) == null ? void 0 : M.firstWeekContainsDate) ?? 1, i = k((e == null ? void 0 : e.in) || t, 0);
|
|
544
544
|
i.setFullYear(r + 1, 0, s), i.setHours(0, 0, 0, 0);
|
|
545
545
|
const o = R(i, e), c = k((e == null ? void 0 : e.in) || t, 0);
|
|
546
546
|
c.setFullYear(r, 0, s), c.setHours(0, 0, 0, 0);
|
|
@@ -549,7 +549,7 @@ function Dt(t, e) {
|
|
|
549
549
|
}
|
|
550
550
|
function De(t, e) {
|
|
551
551
|
var o, c, d, g;
|
|
552
|
-
const n =
|
|
552
|
+
const n = q(), r = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((c = (o = e == null ? void 0 : e.locale) == null ? void 0 : o.options) == null ? void 0 : c.firstWeekContainsDate) ?? n.firstWeekContainsDate ?? ((g = (d = n.locale) == null ? void 0 : d.options) == null ? void 0 : g.firstWeekContainsDate) ?? 1, a = Dt(t, e), s = k((e == null ? void 0 : e.in) || t, 0);
|
|
553
553
|
return s.setFullYear(a, 0, r), s.setHours(0, 0, 0, 0), R(s, e);
|
|
554
554
|
}
|
|
555
555
|
function St(t, e) {
|
|
@@ -1250,10 +1250,10 @@ function Ne(t, e, n) {
|
|
|
1250
1250
|
const r = t[0] === "Y" ? "years" : "days of the month";
|
|
1251
1251
|
return `Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
|
|
1252
1252
|
}
|
|
1253
|
-
const Ce = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, $e = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Ee = /^'([^]*?)'?$/,
|
|
1253
|
+
const Ce = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, $e = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Ee = /^'([^]*?)'?$/, We = /''/g, _e = /[a-zA-Z]/;
|
|
1254
1254
|
function Ye(t, e, n) {
|
|
1255
1255
|
var g, m, v, M;
|
|
1256
|
-
const r =
|
|
1256
|
+
const r = q(), a = r.locale ?? pe, s = r.firstWeekContainsDate ?? ((m = (g = r.locale) == null ? void 0 : g.options) == null ? void 0 : m.firstWeekContainsDate) ?? 1, i = r.weekStartsOn ?? ((M = (v = r.locale) == null ? void 0 : v.options) == null ? void 0 : M.weekStartsOn) ?? 0, o = b(t, n == null ? void 0 : n.in);
|
|
1257
1257
|
if (!Yt(o))
|
|
1258
1258
|
throw new RangeError("Invalid time value");
|
|
1259
1259
|
let c = e.match($e).map((w) => {
|
|
@@ -1271,7 +1271,7 @@ function Ye(t, e, n) {
|
|
|
1271
1271
|
return { isToken: !1, value: Fe(w) };
|
|
1272
1272
|
if (ct[p])
|
|
1273
1273
|
return { isToken: !0, value: w };
|
|
1274
|
-
if (p.match(
|
|
1274
|
+
if (p.match(_e))
|
|
1275
1275
|
throw new RangeError(
|
|
1276
1276
|
"Format string contains an unescaped latin alphabet character `" + p + "`"
|
|
1277
1277
|
);
|
|
@@ -1293,7 +1293,7 @@ function Ye(t, e, n) {
|
|
|
1293
1293
|
}
|
|
1294
1294
|
function Fe(t) {
|
|
1295
1295
|
const e = t.match(Ee);
|
|
1296
|
-
return e ? e[1].replace(
|
|
1296
|
+
return e ? e[1].replace(We, "'") : t;
|
|
1297
1297
|
}
|
|
1298
1298
|
function Ie(t, e) {
|
|
1299
1299
|
const n = b(t, e == null ? void 0 : e.in).getDay();
|
|
@@ -1329,7 +1329,7 @@ function dt(t, e) {
|
|
|
1329
1329
|
class S extends Date {
|
|
1330
1330
|
//#region static
|
|
1331
1331
|
constructor(...e) {
|
|
1332
|
-
super(), e.length > 1 && typeof e[e.length - 1] == "string" && (this.timeZone = e.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(C(this.timeZone, this)) ? this.setTime(NaN) : e.length ? typeof e[0] == "number" && (e.length === 1 || e.length === 2 && typeof e[1] != "number") ? this.setTime(e[0]) : typeof e[0] == "string" ? this.setTime(+new Date(e[0])) : e[0] instanceof Date ? this.setTime(+e[0]) : (this.setTime(+new Date(...e)), vt(this),
|
|
1332
|
+
super(), e.length > 1 && typeof e[e.length - 1] == "string" && (this.timeZone = e.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(C(this.timeZone, this)) ? this.setTime(NaN) : e.length ? typeof e[0] == "number" && (e.length === 1 || e.length === 2 && typeof e[1] != "number") ? this.setTime(e[0]) : typeof e[0] == "string" ? this.setTime(+new Date(e[0])) : e[0] instanceof Date ? this.setTime(+e[0]) : (this.setTime(+new Date(...e)), vt(this), K(this)) : this.setTime(Date.now());
|
|
1333
1333
|
}
|
|
1334
1334
|
static tz(e, ...n) {
|
|
1335
1335
|
return n.length ? new S(...n, e) : new S(Date.now(), e);
|
|
@@ -1346,7 +1346,7 @@ class S extends Date {
|
|
|
1346
1346
|
//#endregion
|
|
1347
1347
|
//#region time
|
|
1348
1348
|
setTime(e) {
|
|
1349
|
-
return Date.prototype.setTime.apply(this, arguments),
|
|
1349
|
+
return Date.prototype.setTime.apply(this, arguments), K(this), +this;
|
|
1350
1350
|
}
|
|
1351
1351
|
//#endregion
|
|
1352
1352
|
//#region date-fns integration
|
|
@@ -1364,10 +1364,10 @@ Object.getOwnPropertyNames(Date.prototype).forEach((t) => {
|
|
|
1364
1364
|
} : (S.prototype[t] = function() {
|
|
1365
1365
|
return Date.prototype[e].apply(this.internal, arguments), Re(this), +this;
|
|
1366
1366
|
}, S.prototype[e] = function() {
|
|
1367
|
-
return Date.prototype[e].apply(this, arguments),
|
|
1367
|
+
return Date.prototype[e].apply(this, arguments), K(this), +this;
|
|
1368
1368
|
}));
|
|
1369
1369
|
});
|
|
1370
|
-
function
|
|
1370
|
+
function K(t) {
|
|
1371
1371
|
t.internal.setTime(+t), t.internal.setUTCSeconds(t.internal.getUTCSeconds() - Math.round(-C(t.timeZone, t) * 60));
|
|
1372
1372
|
}
|
|
1373
1373
|
function Re(t) {
|
|
@@ -1474,11 +1474,11 @@ const y = (t) => {
|
|
|
1474
1474
|
const e = O(t);
|
|
1475
1475
|
return isNaN(e.getTime()) ? null : e;
|
|
1476
1476
|
}, pn = (t, e) => {
|
|
1477
|
-
const n =
|
|
1477
|
+
const n = _(t);
|
|
1478
1478
|
return isNaN(n.getTime()) ? "" : Ye(n, e);
|
|
1479
|
-
},
|
|
1479
|
+
}, _ = (t = "", e) => {
|
|
1480
1480
|
const n = typeof t == "string" ? O(t) : t;
|
|
1481
|
-
return !n || isNaN(n.getTime()) ? /* @__PURE__ */ new Date() : e ? e === "end" ? Ft(n) :
|
|
1481
|
+
return !n || isNaN(n.getTime()) ? /* @__PURE__ */ new Date() : e ? e === "end" ? Ft(n) : J(n) : n;
|
|
1482
1482
|
}, $ = (t, e, n = 1) => {
|
|
1483
1483
|
if (typeof t != "number" || typeof e != "number" || typeof n != "number" || isNaN(t) || isNaN(e) || isNaN(n))
|
|
1484
1484
|
return /* @__PURE__ */ new Date();
|
|
@@ -1493,11 +1493,11 @@ const Le = (t) => {
|
|
|
1493
1493
|
if (!t || isNaN(t.getTime())) return "";
|
|
1494
1494
|
const e = typeof window < "u" ? window.pktTz : void 0;
|
|
1495
1495
|
return (!V || mt !== e) && (V = new Intl.DateTimeFormat("no", { dateStyle: "full", timeZone: e }), mt = e), V.format(t);
|
|
1496
|
-
},
|
|
1496
|
+
}, Be = (t, e, n) => {
|
|
1497
1497
|
if (!t || isNaN(t.getTime())) return !1;
|
|
1498
|
-
const r = e ?
|
|
1498
|
+
const r = e ? _(e) : null, a = n ? _(n) : null;
|
|
1499
1499
|
return !(r && t < r || a && t > a);
|
|
1500
|
-
},
|
|
1500
|
+
}, qe = (t, e) => {
|
|
1501
1501
|
if (!t || isNaN(t.getTime()) || !Array.isArray(e)) return !1;
|
|
1502
1502
|
const n = y(t);
|
|
1503
1503
|
return e.includes(n);
|
|
@@ -1505,7 +1505,7 @@ const Le = (t) => {
|
|
|
1505
1505
|
if (!t || isNaN(t.getTime()) || !Array.isArray(e)) return !1;
|
|
1506
1506
|
const n = t.getDay().toString();
|
|
1507
1507
|
return e.includes(n);
|
|
1508
|
-
}, Mt = (t, e, n, r, a) => !(!t || isNaN(t.getTime()) || !
|
|
1508
|
+
}, Mt = (t, e, n, r, a) => !(!t || isNaN(t.getTime()) || !Be(t, e, n) || r && qe(t, r) || a && ze(t, a)), wn = (t, e, n, r, a) => t.filter((s) => {
|
|
1509
1509
|
const i = U(s);
|
|
1510
1510
|
return i && Mt(i, e, n, r, a);
|
|
1511
1511
|
}), bn = (t) => t.slice().sort((e, n) => {
|
|
@@ -1514,7 +1514,18 @@ const Le = (t) => {
|
|
|
1514
1514
|
}), Dn = (t, e) => {
|
|
1515
1515
|
const n = U(t), r = U(e);
|
|
1516
1516
|
return !n || !r ? !1 : n <= r;
|
|
1517
|
-
}, je = (t) =>
|
|
1517
|
+
}, je = (t) => {
|
|
1518
|
+
if (!t) return [];
|
|
1519
|
+
if (Array.isArray(t)) return t.filter(Boolean);
|
|
1520
|
+
if (typeof t == "string" && t.trimStart().startsWith("["))
|
|
1521
|
+
try {
|
|
1522
|
+
const e = JSON.parse(t);
|
|
1523
|
+
if (Array.isArray(e))
|
|
1524
|
+
return e.filter(Boolean);
|
|
1525
|
+
} catch {
|
|
1526
|
+
}
|
|
1527
|
+
return String(t).split(",").map((e) => e.trim()).filter(Boolean);
|
|
1528
|
+
}, Sn = (t) => t.join(","), Qe = (t) => je(t), Xe = (t) => t ? O(t) : null, Ge = (t) => {
|
|
1518
1529
|
if (typeof t == "string")
|
|
1519
1530
|
return t.split(",").map((e) => O(e));
|
|
1520
1531
|
if (Array.isArray(t))
|
|
@@ -1538,12 +1549,12 @@ function Tt(t, e) {
|
|
|
1538
1549
|
e.excludeweekdays ?? []
|
|
1539
1550
|
);
|
|
1540
1551
|
}
|
|
1541
|
-
function
|
|
1552
|
+
function Je(t, e, n, r) {
|
|
1542
1553
|
return !!(Tt(t, n) || !e && r.multiple && r.maxMultiple > 0 && r.selectedCount >= r.maxMultiple);
|
|
1543
1554
|
}
|
|
1544
|
-
function
|
|
1555
|
+
function Ke(t, e, n) {
|
|
1545
1556
|
const r = $(t, e, 0);
|
|
1546
|
-
return !(n &&
|
|
1557
|
+
return !(n && _(n) > r);
|
|
1547
1558
|
}
|
|
1548
1559
|
function Ze(t, e, n) {
|
|
1549
1560
|
const r = $(
|
|
@@ -1551,7 +1562,7 @@ function Ze(t, e, n) {
|
|
|
1551
1562
|
e === 11 ? 0 : e + 1,
|
|
1552
1563
|
1
|
|
1553
1564
|
);
|
|
1554
|
-
return !(n &&
|
|
1565
|
+
return !(n && _(n) < r);
|
|
1555
1566
|
}
|
|
1556
1567
|
const L = 7, tn = 6;
|
|
1557
1568
|
function en(t, e) {
|
|
@@ -1574,7 +1585,7 @@ function rn(t, e, n, r) {
|
|
|
1574
1585
|
const { startingDay: a, numDaysPrevMonth: s, numDays: i } = r;
|
|
1575
1586
|
return t === "prev-month" ? s - (a - e - 1) : t === "next-month" ? n - i : n;
|
|
1576
1587
|
}
|
|
1577
|
-
function
|
|
1588
|
+
function W(t) {
|
|
1578
1589
|
return typeof t == "string" && (t = t.split(",")), t.length === 1 && t[0] === "" ? [] : t.map((e) => O(e));
|
|
1579
1590
|
}
|
|
1580
1591
|
function gt(t, e) {
|
|
@@ -1618,7 +1629,7 @@ function an(t, e, n) {
|
|
|
1618
1629
|
return e.includes(r) ? et(t, e) : n > 0 && e.length >= n ? e : tt(t, e);
|
|
1619
1630
|
}
|
|
1620
1631
|
function sn(t, e, n) {
|
|
1621
|
-
const r = y(t), a =
|
|
1632
|
+
const r = y(t), a = W(e);
|
|
1622
1633
|
if (e.includes(r))
|
|
1623
1634
|
return e.indexOf(r) === 0 ? [] : et(t, e);
|
|
1624
1635
|
if (e.length > 1)
|
|
@@ -1681,7 +1692,7 @@ let l = class extends Pt {
|
|
|
1681
1692
|
* Date and selection management
|
|
1682
1693
|
*/
|
|
1683
1694
|
convertSelected() {
|
|
1684
|
-
typeof this.selected == "string" && (this.selected = this.selected.split(",")), this.selected.length === 1 && this.selected[0] === "" && (this.selected = []), this._selected =
|
|
1695
|
+
typeof this.selected == "string" && (this.selected = this.selected.split(",")), this.selected.length === 1 && this.selected[0] === "" && (this.selected = []), this._selected = W(this.selected), this.range && this.selected.length === 2 && (this.inRange = gt(this._selected[0], this._selected[1])), this.setCurrentMonth();
|
|
1685
1696
|
}
|
|
1686
1697
|
setCurrentMonth() {
|
|
1687
1698
|
if (this.currentmonth === null && !this.currentmonthtouched && (this.currentmonthtouched = !0), this.selected.length && this.selected[0] !== "") {
|
|
@@ -1704,7 +1715,7 @@ let l = class extends Pt {
|
|
|
1704
1715
|
this.focusOnCurrentDate();
|
|
1705
1716
|
return;
|
|
1706
1717
|
}
|
|
1707
|
-
const r = this.focusedDate ?
|
|
1718
|
+
const r = this.focusedDate ? _(this.focusedDate) : $(this.year, this.month, 1), a = un(r, e, this.querySelector.bind(this));
|
|
1708
1719
|
if (a) {
|
|
1709
1720
|
const s = this.querySelector(`button[data-date="${y(a)}"]`);
|
|
1710
1721
|
s instanceof HTMLButtonElement && !s.dataset.disabled && (this.focusedDate = y(a), s.focus());
|
|
@@ -1832,7 +1843,7 @@ let l = class extends Pt {
|
|
|
1832
1843
|
};
|
|
1833
1844
|
}
|
|
1834
1845
|
isDayDisabled(t, e) {
|
|
1835
|
-
return
|
|
1846
|
+
return Je(t, e, this.getDateConstraints(), {
|
|
1836
1847
|
multiple: this.multiple,
|
|
1837
1848
|
maxMultiple: this.maxMultiple,
|
|
1838
1849
|
selectedCount: this.selected.length
|
|
@@ -1941,7 +1952,7 @@ let l = class extends Pt {
|
|
|
1941
1952
|
* Month navigation
|
|
1942
1953
|
*/
|
|
1943
1954
|
isPrevMonthAllowed() {
|
|
1944
|
-
return
|
|
1955
|
+
return Ke(this.year, this.month, this.earliest);
|
|
1945
1956
|
}
|
|
1946
1957
|
prevMonth() {
|
|
1947
1958
|
const t = this.month === 0 ? 11 : this.month - 1, e = this.month === 0 ? this.year - 1 : this.year;
|
|
@@ -1967,13 +1978,13 @@ let l = class extends Pt {
|
|
|
1967
1978
|
return typeof this.selected == "string" ? this.selected.split(",") : this.selected;
|
|
1968
1979
|
}
|
|
1969
1980
|
addToSelected(t) {
|
|
1970
|
-
this.selected = tt(t, this.normalizeSelected()), this._selected =
|
|
1981
|
+
this.selected = tt(t, this.normalizeSelected()), this._selected = W(this.selected), this.range && this.selected.length === 2 && (this.convertSelected(), this.close());
|
|
1971
1982
|
}
|
|
1972
1983
|
removeFromSelected(t) {
|
|
1973
|
-
this.selected = et(t, this.normalizeSelected()), this._selected =
|
|
1984
|
+
this.selected = et(t, this.normalizeSelected()), this._selected = W(this.selected);
|
|
1974
1985
|
}
|
|
1975
1986
|
toggleSelected(t) {
|
|
1976
|
-
this.selected = an(t, this.normalizeSelected(), this.maxMultiple), this._selected =
|
|
1987
|
+
this.selected = an(t, this.normalizeSelected(), this.maxMultiple), this._selected = W(this.selected);
|
|
1977
1988
|
}
|
|
1978
1989
|
isRangeAllowed(t) {
|
|
1979
1990
|
return xt(t, this._selected, this.excludedates, this.excludeweekdays);
|
|
@@ -1982,7 +1993,7 @@ let l = class extends Pt {
|
|
|
1982
1993
|
return this.selected = sn(t, this.normalizeSelected(), {
|
|
1983
1994
|
excludedates: this.excludedates,
|
|
1984
1995
|
excludeweekdays: this.excludeweekdays
|
|
1985
|
-
}), this._selected =
|
|
1996
|
+
}), this._selected = W(this.selected), this.selected.length === 2 ? (this.convertSelected(), this.close()) : this.selected.length === 1 && (this.inRange = {}), Promise.resolve();
|
|
1986
1997
|
}
|
|
1987
1998
|
handleRangeHover(t) {
|
|
1988
1999
|
if (!this.range || this._selected.length !== 1 || !this.isRangeAllowed(t) || this._selected[0] >= t) {
|
|
@@ -2120,7 +2131,7 @@ export {
|
|
|
2120
2131
|
z as e,
|
|
2121
2132
|
pn as f,
|
|
2122
2133
|
Dn as i,
|
|
2123
|
-
|
|
2134
|
+
_ as n,
|
|
2124
2135
|
O as p,
|
|
2125
2136
|
bn as s,
|
|
2126
2137
|
je as v
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const o=require("./element-CMTfByxQ.cjs"),d=require("./if-defined-hKKmbsI8.cjs"),f=require("./ref-CxLwrCxt.cjs"),V=require("./class-map-Bokp1SoS.cjs"),T=require("./repeat-C-FJ2vfy.cjs"),u=require("./listbox-Dm2mKp6_.cjs"),b=require("./state-BNgpvY-A.cjs"),w=require("./input-element-CSDVA3Y6.cjs"),R=require("./pkt-options-controller-BogGk-6J.cjs"),C=require("./pkt-slot-controller-D4nKlom5.cjs");require("./input-wrapper-JU4D2TGu.cjs");require("./icon-Dj0oZZSa.cjs");require("./tag-DmbgBCKu.cjs");const F=(a,t,e)=>{switch(a){case",":return e?"addValue":null;case"Enter":return"addValue";case"Tab":case"ArrowDown":return t?null:"focusListbox";case"Escape":return"closeOptions";default:return null}},M=(a,t,e,s,i)=>{if(!a)return{action:"none",value:null};const l=u.findOptionByValue(e,a);return!t.includes(a)&&!l?s?{action:"addUserValue",value:a}:i?{action:"none",value:null}:{action:"removeValue",value:t[0]}:l&&!t.includes(l.value)?{action:"selectOption",value:l.value}:{action:"none",value:null}},U=(a,t,e,s,i)=>a.trim().toLowerCase()?{...u.getSearchInfoMessage(a,t,e,s),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:"",shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},O=(a,t,e)=>{const s=u.findOptionByValue(t,a);return e==="label"&&(s!=null&&s.label)?s.label:a},m={markOptionSelected(a,t){if(t){for(const e of a)if(e.value===t){e.selected=!0;break}}},markOptionDeselected(a,t){if(t){for(const e of a)if(e.value===t){e.selected=!1;break}}},markAllSelected(a){for(const t of a)t.selected=!0},markAllDeselected(a){for(const t of a)t.selected=!1},removeUserAddedOptions(a){return a.filter(t=>!t.userAdded)}},A={parseOptionsFromSlot(a){const t=[];return a.forEach(e=>{if(!e.textContent&&!e.getAttribute("value"))return;const s={value:e.getAttribute("value")||e.textContent||"",label:e.textContent||e.getAttribute("value")||""};e.getAttribute("data-prefix")&&(s.prefix=e.getAttribute("data-prefix")||void 0),e.getAttribute("tagskincolor")&&(s.tagSkinColor=e.getAttribute("tagskincolor")),e.getAttribute("description")&&(s.description=e.getAttribute("description")||void 0),s.fulltext=u.buildFulltext(s),t.push(s)}),t}},k={syncOptionsWithValues(a,t){const e=[...t];return a.forEach(s=>{s.value&&!s.label&&(s.label=s.value),s.selected&&!e.includes(s.value)&&e.push(s.value),s.fulltext=u.buildFulltext(s),s.selected=s.selected||e.includes(s.value)}),{options:a,newValues:e}},mergeWithUserAdded(a,t){return[...t.filter(i=>(i==null?void 0:i.userAdded)&&i.selected).filter(i=>!(Array.isArray(a)?a:[]).some(l=>l.value===i.value)),...a]}},D={displayValueAs:{default:"label"}},P={props:D};var q=Object.defineProperty,r=(a,t,e,s)=>{for(var i=void 0,l=a.length-1,n;l>=0;l--)(n=a[l])&&(i=n(t,e,i)||i);return i&&q(t,e,i),i};class h extends w.PktInputElement{constructor(){super(),this.helptextSlot=f.e(),this.value="",this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder="",this.multiple=!1,this.maxlength=null,this.displayValueAs=P.props.displayValueAs.default,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage="",this._addValueText=null,this._maxIsReached=!1,this._search="",this._inputFocus=!1,this._internalValueSync=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=f.e(),this.triggerRef=f.e(),this.listboxRef=f.e(),this.optionsController=new R.PktOptionsSlotController(this),this.slotController=new C.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}get _hasTextInput(){return this.typeahead||this.allowUserInput}get _selectionDescription(){if(!(!this.multiple||this._value.length===0))return`${this._value.length} valgt`}focusTrigger(){var t,e;this._hasTextInput?(t=this.inputRef.value)==null||t.focus():(e=this.triggerRef.value)==null||e.focus()}parseValue(){return Array.isArray(this.value)?this.multiple?this.value:this.value.length>0?[this.value[0]]:[]:this.value&&this.multiple?this.value.split(","):this.value?[this.value]:[]}updateMaxReached(){this._maxIsReached=u.isMaxSelectionReached(this._value.length,this.maxlength)}syncValueAndDispatch(t){const e=this._value,s=this.multiple?e.join(","):e[0]||"",i=Array.isArray(this.value)?this.value.join(","):String(this.value||"");if(s!==i&&(this._internalValueSync=!0,this.value=s),(t==null?void 0:t.join(","))!==e.join(",")){const l=this.multiple?[...e]:e[0]||"";this.onChange(l)}else e.length===0&&t&&t.length>0&&this.clearInputValue()}onChange(t){this.touched=!0,super.onChange(t)}valueChanged(){}}r([o.n({type:String,reflect:!0})],h.prototype,"value");r([o.n({type:Array})],h.prototype,"options");r([o.n({type:Array,attribute:"default-options"})],h.prototype,"defaultOptions");r([o.n({type:Boolean,attribute:"allow-user-input"})],h.prototype,"allowUserInput");r([o.n({type:Boolean})],h.prototype,"typeahead");r([o.n({type:Boolean,attribute:"include-search"})],h.prototype,"includeSearch");r([o.n({type:String,attribute:"search-placeholder"})],h.prototype,"searchPlaceholder");r([o.n({type:Boolean})],h.prototype,"multiple");r([o.n({type:Number})],h.prototype,"maxlength");r([o.n({type:String,attribute:"display-value-as"})],h.prototype,"displayValueAs");r([o.n({type:String,attribute:"tag-placement"})],h.prototype,"tagPlacement");r([o.n({type:Boolean,attribute:"open"})],h.prototype,"isOpen");r([b.r()],h.prototype,"_options");r([b.r()],h.prototype,"_value");r([b.r()],h.prototype,"_isOptionsOpen");r([b.r()],h.prototype,"_userInfoMessage");r([b.r()],h.prototype,"_addValueText");r([b.r()],h.prototype,"_maxIsReached");r([b.r()],h.prototype,"_search");r([b.r()],h.prototype,"_inputFocus");class B extends h{toggleValue(t){var $,I;if(this.disabled)return;this.touched=!0,this._userInfoMessage="",this._addValueText=null;const e=(($=u.findOptionByValue(this.options,t))==null?void 0:$.value)||null,s=this._value.includes(t||e||""),i=!!e,l=((I=this._options.find(S=>S.value===t))==null?void 0:I.disabled)||!1,n=!(t!=null&&t.trim()),p=!this.multiple,_=this.multiple,v=u.isMaxSelectionReached(this._value.length,this.maxlength);let c=!1,x=!0,g="",y="";l||(!i&&this.allowUserInput&&!n?(this.addNewUserValue(t),g="Ny verdi lagt til",c=_):!i&&!this.allowUserInput?(p&&this._value[0]&&this.removeValue(this._value[0]),x=!1,c=!0,g="Ingen treff i søket"):s?(this.removeValue(e),c=!0,p&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value="")):n&&p?(this.removeAllSelected(),c=!0):p?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(e),c=!1):_&&!v?(this.setSelected(e),c=!0):_&&v?(g="Maks antall valg nådd",x=!1,y=t):(p&&this.removeAllSelected(),g="Ingen gyldig verdi valgt",x=!1,c=!0,y=t),this._isOptionsOpen=c,c||(p&&this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this._userInfoMessage=g,this._search=y||"",this.resetComboboxInput(x),_&&this.updateMaxReached())}setSelected(t){if(!this._value.includes(t)){if(this.multiple&&u.isMaxSelectionReached(this._value.length,this.maxlength)){this._userInfoMessage="Maks antall valg nådd";return}!this.multiple&&this.removeAllSelected(),this._value=t?[...this._value,t]:this._value,m.markOptionSelected(this._options,t),this.resetComboboxInput(!0)}}removeSelected(t){if(!t)return;this._value=this._value.filter(s=>s!==t);const e=u.findOptionByValue(this.options,t);e&&(m.markOptionDeselected(this.options,t),e.userAdded?(this._options=[...this._options.filter(s=>s.value!==t)],this.options=[...this.options.filter(s=>s.value!==t)]):this._options.some(s=>s.value===t)||(this._options=[...this._options,e]))}addAllOptions(){if(this.multiple){if(this.maxlength&&this._options.length>this.maxlength){this._userInfoMessage="For mange valgt";return}this._value=this._options.map(t=>t.value),m.markAllSelected(this._options),this.requestUpdate()}}removeAllSelected(){this._value=[],m.markAllDeselected(this._options),this._options=m.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){var e;const t=((e=this.inputRef.value)==null?void 0:e.value.trim())||"";if(this._search=t,t&&this._value.includes(t)){this.resetComboboxInput(!0),this._userInfoMessage="Verdien er allerede valgt";return}this.toggleValue(t)}removeValue(t){this._value=this.multiple?this._value.filter(e=>e!==t):[],this.removeSelected(t)}addNewUserValue(t){if(!t||t.trim()==="")return;if(!this.multiple)this._value[0]&&this.removeSelected(this._value[0]),this._value=[t];else if(!u.findOptionByValue(this.options,t)){if(u.isMaxSelectionReached(this._value.length,this.maxlength))return;this._value=[...this._value,t]}const e={value:t,label:t,userAdded:!0,selected:!0};this.options=[e,...this.options],this._options=[e,...this._options],this.resetComboboxInput(!0),this.multiple||(this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this.requestUpdate()}resetComboboxInput(t=!0){this._addValueText=null,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&t&&(this._search="",this.multiple?this.inputRef.value.value="":(this.inputRef.value.value=this._value[0]?O(this._value[0],this.options,this.displayValueAs):"",this._userInfoMessage="")),this._options=[...this.options]}removeLastValue(t){if(this._value.length===0)return;t.preventDefault();const e=this._value[this._value.length-1];e&&this.removeSelected(e),this.updateMaxReached()}}class E extends B{handleInput(t){if(t.stopPropagation(),t.stopImmediatePropagation(),this.disabled)return;this.touched=!0;const e=t.target;if(this._search=e.value,this.checkForMatches(),this.typeahead)if(this._search){const{filtered:s,suggestion:i}=u.findTypeaheadMatches(this.options,this._search);this._options=s,t.inputType!=="deleteContentBackward"&&(i!=null&&i.label)&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(e.value=i.label,window.setTimeout(()=>e.setSelectionRange(this._search.length,e.value.length),0),e.selectionDirection="backward")}else this._options=[...this.options]}handleFocus(){if(!this.disabled){if(this._suppressNextOpen){this._suppressNextOpen=!1,this._inputFocus=!0,this.requestUpdate();return}!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value=O(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search="",this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(t){var i,l;if(this.disabled||!this._isOptionsOpen)return;const e=t.relatedTarget;((i=e==null?void 0:e.closest("pkt-combobox"))==null?void 0:i.id)===this.id||((l=t.target)==null?void 0:l.getAttribute("data-focusfix"))===this.id||e===this.inputRef.value||e===this.triggerRef.value||this.closeAndProcessInput()}closeAndProcessInput(){if(this._inputFocus=!1,this._addValueText=null,this._userInfoMessage="",this._search="",this.inputRef.value&&this.inputRef.value.type!=="hidden"){const t=this.inputRef.value.value;if(this.multiple){if(t!==""){const{action:e,value:s}=M(t,this._value,this.options,this.allowUserInput,this.multiple);switch(e){case"addUserValue":this.addNewUserValue(s);break;case"selectOption":this.setSelected(s);break;case"removeValue":this.removeValue(s);break}}}else if(!t)this._value[0]&&this.removeSelected(this._value[0]);else{const e=u.findOptionByValue(this.options,t);e&&e.value!==this._value[0]?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(e.value)):!e&&this.allowUserInput&&(this._value[0]&&this.removeSelected(this._value[0]),this.addNewUserValue(t))}!this.multiple&&this._value[0]?this.inputRef.value.value=O(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=""}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(t){var e,s;if(this.disabled){t.preventDefault(),t.stopImmediatePropagation();return}this._hasTextInput?((e=this.inputRef.value)==null||e.focus(),this.requestUpdate()):(t.stopImmediatePropagation(),t.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen&&((s=this.listboxRef.value)==null||s.focusFirstOrSelectedOption()))}handlePlaceholderClick(t){this.disabled||(t.stopPropagation(),this._hasTextInput&&this.inputRef.value?(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()):(this._isOptionsOpen=!this._isOptionsOpen,this.requestUpdate()))}handleSelectOnlyKeydown(t){var e,s;if(!this.disabled)switch(t.key){case"Enter":case" ":case"ArrowDown":case"ArrowUp":t.preventDefault(),this._isOptionsOpen?this._isOptionsOpen=!1:(this._isOptionsOpen=!0,(e=this.listboxRef.value)==null||e.focusFirstOrSelectedOption());break;case"Escape":this._isOptionsOpen&&(t.preventDefault(),this._isOptionsOpen=!1);break;case"Home":case"End":t.preventDefault(),this._isOptionsOpen||(this._isOptionsOpen=!0),(s=this.listboxRef.value)==null||s.focusFirstOrSelectedOption();break;case"ArrowLeft":this.multiple&&this._value.length>0&&(t.preventDefault(),this.focusTag(this._value.length-1));break;case"Backspace":case"Delete":this.multiple&&this._value.length>0&&(t.preventDefault(),this.removeSelected(this._value[this._value.length-1]));break}}handleOptionToggled(t){this.toggleValue(t.detail)}handleSearch(t){t.stopPropagation(),this._search=t.detail.toLowerCase(),this.checkForMatches()}handleInputKeydown(t){var s,i,l;if(t.key==="Backspace"){const n=!((s=this.inputRef.value)!=null&&s.value);!this._search&&n&&this.multiple&&this._value.length>0&&this.removeLastValue(t);return}if(t.key==="ArrowLeft"&&this.multiple&&this._value.length>0){const n=this.inputRef.value;if(n&&n.selectionStart===0&&!n.value){t.preventDefault(),this.focusTag(this._value.length-1);return}}const e=F(t.key,t.shiftKey,this.multiple);if(e&&!(t.key==="Tab"&&!this._isOptionsOpen)){if(e==="focusListbox"&&t.key==="Tab"&&!((i=this.listboxRef.value)==null?void 0:i.querySelector('[role="option"]:not([data-disabled]), [data-type="new-option"]'))){this.closeAndProcessInput();return}switch(t.preventDefault(),e){case"addValue":this.addValue();break;case"focusListbox":(l=this.listboxRef.value)==null||l.focusFirstOrSelectedOption();break;case"closeOptions":this._isOptionsOpen=!1;break}}}handleTagRemove(t){this.removeSelected(t),this._hasTextInput&&this.inputRef.value&&(this._inputFocus=!0,this.inputRef.value.focus(),this.requestUpdate())}getInsideTags(){return Array.from(this.querySelectorAll(".pkt-combobox__input .pkt-combobox__tag-list pkt-tag"))}focusTag(t){var i;const e=this.getInsideTags();e.forEach((l,n)=>{l.buttonTabindex=n===t?0:-1});const s=(i=e[t])==null?void 0:i.querySelector("button");s==null||s.focus()}resetTagTabindices(){this.getInsideTags().forEach(e=>{e.buttonTabindex=-1})}handleTagKeydown(t,e){t.stopPropagation();const s=()=>{var i;this.resetTagTabindices(),this._hasTextInput&&this.inputRef.value?this.inputRef.value.focus():(i=this.triggerRef.value)==null||i.focus()};switch(t.key){case"ArrowLeft":t.preventDefault(),e>0&&this.focusTag(e-1);break;case"ArrowRight":t.preventDefault(),e<this._value.length-1?this.focusTag(e+1):s();break;case"Backspace":case"Delete":t.preventDefault();{const i=this._value[e],l=e>=this._value.length-1?e-1:e;this.removeSelected(i),l>=0?(this.requestUpdate(),this.updateComplete.then(()=>this.focusTag(l))):s()}break;case"Tab":this.resetTagTabindices();break;case"Escape":t.preventDefault(),s();break}}checkForMatches(){var s;const t=((s=this.inputRef.value)==null?void 0:s.value)||this._search||"",e=U(t,this._value,this.options,this.allowUserInput,this.multiple);if(e.shouldRemoveValue&&this.removeValue(this._value[0]),e.shouldResetInput){this.resetComboboxInput(!1);return}this._addValueText=e.addValueText,this._userInfoMessage=e.userInfoMessage}}var N=Object.getOwnPropertyDescriptor,L=(a,t,e,s)=>{for(var i=s>1?void 0:s?N(t,e):t,l=a.length-1,n;l>=0;l--)(n=a[l])&&(i=n(i)||i);return i};exports.PktCombobox=class extends E{constructor(){super(...arguments),this.handleBodyClick=t=>{this._isOptionsOpen&&!this.contains(t.target)&&this.closeAndProcessInput()}}connectedCallback(){var t,e;if(super.connectedCallback(),document==null||document.body.addEventListener("click",this.handleBodyClick),this._options=[],this.defaultOptions&&this.defaultOptions.length){const s=((t=this.options)==null?void 0:t.filter(i=>i.userAdded))||[];this.options=[...s,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if((e=this.optionsController)!=null&&e.nodes&&this.optionsController.nodes.length){const s=A.parseOptionsFromSlot(this.optionsController.nodes);s.length&&(this.options=[...s],this._options=[...s],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}willUpdate(t){if(this._optionsFromSlot&&this.optionsController){const e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;const s=A.parseOptionsFromSlot(this.optionsController.nodes),i=this._options.filter(l=>l.userAdded);this.options=[...i,...s]}}super.willUpdate(t)}disconnectedCallback(){super.disconnectedCallback(),document==null||document.body.removeEventListener("click",this.handleBodyClick)}firstUpdated(t){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(t)}updated(t){t.has("isOpen")&&(this._isOptionsOpen=this.isOpen);const e=t.has("value"),s=t.has("_value");if(e&&this._internalValueSync)this._internalValueSync=!1,s&&this.syncValueAndDispatch(t.get("_value"));else if(e){const l=[...this._value],n=this.parseValue();n.join(",")!==this._value.join(",")&&(this._value=n),this.updateMaxReached(),this.syncValueAndDispatch(l)}else s&&this.syncValueAndDispatch(t.get("_value"));if(t.has("defaultOptions")&&this.defaultOptions.length){const l=(Array.isArray(this.options)?this.options:[]).filter(n=>n.userAdded)||[];this.options=[...l,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(t.has("options")){const l=t.get("options")||this._options||[],n=k.mergeWithUserAdded(this.options,l);this._options=n,n.length>this.options.length&&(this.options=n);const p=k.syncOptionsWithValues(this._options,this._value);if(this._options=p.options,p.newValues.length>this._value.length){const _=[...this._value];this._value=p.newValues,this.syncValueAndDispatch(_)}}if(t.has("_search")&&this.dispatchEvent(new CustomEvent("search",{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&!this.multiple&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const l=this._value[0]?O(this._value[0],this.options,this.displayValueAs):"";this.inputRef.value.value!==l&&(this.inputRef.value.value=l)}super.updated(t)}formResetCallback(){this.touched=!1;const t=this.defaultValue||(this.multiple,"");this.value=t,this._value=this.parseValue(),this._options=this._options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this.options=this.options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this._search="",this._isOptionsOpen=!1,this._userInfoMessage="",this._addValueText=null,this._inputFocus=!1,this.updateMaxReached(),this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value=""),this.internals.setFormValue(""),this.internals.ariaInvalid="false",this.requestUpdate()}attributeChangedCallback(t,e,s){if(t==="options"){this._options=Array.isArray(this.options)?[...this.options]:[];const i=k.syncOptionsWithValues(this._options,this._value);this._options=i.options,i.newValues.length>this._value.length&&(this._value=i.newValues),this._search=""}super.attributeChangedCallback(t,e,s)}render(){return o.b`
|
|
1
|
+
"use strict";const o=require("./element-CMTfByxQ.cjs"),d=require("./if-defined-hKKmbsI8.cjs"),f=require("./ref-CxLwrCxt.cjs"),V=require("./class-map-Bokp1SoS.cjs"),T=require("./repeat-C-FJ2vfy.cjs"),u=require("./listbox-OAVh_U7u.cjs"),b=require("./state-BNgpvY-A.cjs"),w=require("./input-element-CSDVA3Y6.cjs"),R=require("./pkt-options-controller-BogGk-6J.cjs"),C=require("./pkt-slot-controller-D4nKlom5.cjs");require("./input-wrapper-JU4D2TGu.cjs");require("./icon-Dj0oZZSa.cjs");require("./tag-DmbgBCKu.cjs");const F=(a,t,e)=>{switch(a){case",":return e?"addValue":null;case"Enter":return"addValue";case"Tab":case"ArrowDown":return t?null:"focusListbox";case"Escape":return"closeOptions";default:return null}},M=(a,t,e,s,i)=>{if(!a)return{action:"none",value:null};const l=u.findOptionByValue(e,a);return!t.includes(a)&&!l?s?{action:"addUserValue",value:a}:i?{action:"none",value:null}:{action:"removeValue",value:t[0]}:l&&!t.includes(l.value)?{action:"selectOption",value:l.value}:{action:"none",value:null}},U=(a,t,e,s,i)=>a.trim().toLowerCase()?{...u.getSearchInfoMessage(a,t,e,s),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:"",shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},O=(a,t,e)=>{const s=u.findOptionByValue(t,a);return e==="label"&&(s!=null&&s.label)?s.label:a},m={markOptionSelected(a,t){if(t){for(const e of a)if(e.value===t){e.selected=!0;break}}},markOptionDeselected(a,t){if(t){for(const e of a)if(e.value===t){e.selected=!1;break}}},markAllSelected(a){for(const t of a)t.selected=!0},markAllDeselected(a){for(const t of a)t.selected=!1},removeUserAddedOptions(a){return a.filter(t=>!t.userAdded)}},A={parseOptionsFromSlot(a){const t=[];return a.forEach(e=>{if(!e.textContent&&!e.getAttribute("value"))return;const s={value:e.getAttribute("value")||e.textContent||"",label:e.textContent||e.getAttribute("value")||""};e.getAttribute("data-prefix")&&(s.prefix=e.getAttribute("data-prefix")||void 0),e.getAttribute("tagskincolor")&&(s.tagSkinColor=e.getAttribute("tagskincolor")),e.getAttribute("description")&&(s.description=e.getAttribute("description")||void 0),s.fulltext=u.buildFulltext(s),t.push(s)}),t}},k={syncOptionsWithValues(a,t){const e=[...t];return a.forEach(s=>{s.value&&!s.label&&(s.label=s.value),s.selected&&!e.includes(s.value)&&e.push(s.value),s.fulltext=u.buildFulltext(s),s.selected=s.selected||e.includes(s.value)}),{options:a,newValues:e}},mergeWithUserAdded(a,t){return[...t.filter(i=>(i==null?void 0:i.userAdded)&&i.selected).filter(i=>!(Array.isArray(a)?a:[]).some(l=>l.value===i.value)),...a]}},D={displayValueAs:{default:"label"}},P={props:D};var q=Object.defineProperty,r=(a,t,e,s)=>{for(var i=void 0,l=a.length-1,n;l>=0;l--)(n=a[l])&&(i=n(t,e,i)||i);return i&&q(t,e,i),i};class h extends w.PktInputElement{constructor(){super(),this.helptextSlot=f.e(),this.value="",this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder="",this.multiple=!1,this.maxlength=null,this.displayValueAs=P.props.displayValueAs.default,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage="",this._addValueText=null,this._maxIsReached=!1,this._search="",this._inputFocus=!1,this._internalValueSync=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=f.e(),this.triggerRef=f.e(),this.listboxRef=f.e(),this.optionsController=new R.PktOptionsSlotController(this),this.slotController=new C.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}get _hasTextInput(){return this.typeahead||this.allowUserInput}get _selectionDescription(){if(!(!this.multiple||this._value.length===0))return`${this._value.length} valgt`}focusTrigger(){var t,e;this._hasTextInput?(t=this.inputRef.value)==null||t.focus():(e=this.triggerRef.value)==null||e.focus()}parseValue(){return Array.isArray(this.value)?this.multiple?this.value:this.value.length>0?[this.value[0]]:[]:this.value&&this.multiple?this.value.split(","):this.value?[this.value]:[]}updateMaxReached(){this._maxIsReached=u.isMaxSelectionReached(this._value.length,this.maxlength)}syncValueAndDispatch(t){const e=this._value,s=this.multiple?e.join(","):e[0]||"",i=Array.isArray(this.value)?this.value.join(","):String(this.value||"");if(s!==i&&(this._internalValueSync=!0,this.value=s),(t==null?void 0:t.join(","))!==e.join(",")){const l=this.multiple?[...e]:e[0]||"";this.onChange(l)}else e.length===0&&t&&t.length>0&&this.clearInputValue()}onChange(t){this.touched=!0,super.onChange(t)}valueChanged(){}}r([o.n({type:String,reflect:!0})],h.prototype,"value");r([o.n({type:Array})],h.prototype,"options");r([o.n({type:Array,attribute:"default-options"})],h.prototype,"defaultOptions");r([o.n({type:Boolean,attribute:"allow-user-input"})],h.prototype,"allowUserInput");r([o.n({type:Boolean})],h.prototype,"typeahead");r([o.n({type:Boolean,attribute:"include-search"})],h.prototype,"includeSearch");r([o.n({type:String,attribute:"search-placeholder"})],h.prototype,"searchPlaceholder");r([o.n({type:Boolean})],h.prototype,"multiple");r([o.n({type:Number})],h.prototype,"maxlength");r([o.n({type:String,attribute:"display-value-as"})],h.prototype,"displayValueAs");r([o.n({type:String,attribute:"tag-placement"})],h.prototype,"tagPlacement");r([o.n({type:Boolean,attribute:"open"})],h.prototype,"isOpen");r([b.r()],h.prototype,"_options");r([b.r()],h.prototype,"_value");r([b.r()],h.prototype,"_isOptionsOpen");r([b.r()],h.prototype,"_userInfoMessage");r([b.r()],h.prototype,"_addValueText");r([b.r()],h.prototype,"_maxIsReached");r([b.r()],h.prototype,"_search");r([b.r()],h.prototype,"_inputFocus");class B extends h{toggleValue(t){var $,I;if(this.disabled)return;this.touched=!0,this._userInfoMessage="",this._addValueText=null;const e=(($=u.findOptionByValue(this.options,t))==null?void 0:$.value)||null,s=this._value.includes(t||e||""),i=!!e,l=((I=this._options.find(S=>S.value===t))==null?void 0:I.disabled)||!1,n=!(t!=null&&t.trim()),p=!this.multiple,_=this.multiple,v=u.isMaxSelectionReached(this._value.length,this.maxlength);let c=!1,x=!0,g="",y="";l||(!i&&this.allowUserInput&&!n?(this.addNewUserValue(t),g="Ny verdi lagt til",c=_):!i&&!this.allowUserInput?(p&&this._value[0]&&this.removeValue(this._value[0]),x=!1,c=!0,g="Ingen treff i søket"):s?(this.removeValue(e),c=!0,p&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value="")):n&&p?(this.removeAllSelected(),c=!0):p?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(e),c=!1):_&&!v?(this.setSelected(e),c=!0):_&&v?(g="Maks antall valg nådd",x=!1,y=t):(p&&this.removeAllSelected(),g="Ingen gyldig verdi valgt",x=!1,c=!0,y=t),this._isOptionsOpen=c,c||(p&&this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this._userInfoMessage=g,this._search=y||"",this.resetComboboxInput(x),_&&this.updateMaxReached())}setSelected(t){if(!this._value.includes(t)){if(this.multiple&&u.isMaxSelectionReached(this._value.length,this.maxlength)){this._userInfoMessage="Maks antall valg nådd";return}!this.multiple&&this.removeAllSelected(),this._value=t?[...this._value,t]:this._value,m.markOptionSelected(this._options,t),this.resetComboboxInput(!0)}}removeSelected(t){if(!t)return;this._value=this._value.filter(s=>s!==t);const e=u.findOptionByValue(this.options,t);e&&(m.markOptionDeselected(this.options,t),e.userAdded?(this._options=[...this._options.filter(s=>s.value!==t)],this.options=[...this.options.filter(s=>s.value!==t)]):this._options.some(s=>s.value===t)||(this._options=[...this._options,e]))}addAllOptions(){if(this.multiple){if(this.maxlength&&this._options.length>this.maxlength){this._userInfoMessage="For mange valgt";return}this._value=this._options.map(t=>t.value),m.markAllSelected(this._options),this.requestUpdate()}}removeAllSelected(){this._value=[],m.markAllDeselected(this._options),this._options=m.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){var e;const t=((e=this.inputRef.value)==null?void 0:e.value.trim())||"";if(this._search=t,t&&this._value.includes(t)){this.resetComboboxInput(!0),this._userInfoMessage="Verdien er allerede valgt";return}this.toggleValue(t)}removeValue(t){this._value=this.multiple?this._value.filter(e=>e!==t):[],this.removeSelected(t)}addNewUserValue(t){if(!t||t.trim()==="")return;if(!this.multiple)this._value[0]&&this.removeSelected(this._value[0]),this._value=[t];else if(!u.findOptionByValue(this.options,t)){if(u.isMaxSelectionReached(this._value.length,this.maxlength))return;this._value=[...this._value,t]}const e={value:t,label:t,userAdded:!0,selected:!0};this.options=[e,...this.options],this._options=[e,...this._options],this.resetComboboxInput(!0),this.multiple||(this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this.requestUpdate()}resetComboboxInput(t=!0){this._addValueText=null,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&t&&(this._search="",this.multiple?this.inputRef.value.value="":(this.inputRef.value.value=this._value[0]?O(this._value[0],this.options,this.displayValueAs):"",this._userInfoMessage="")),this._options=[...this.options]}removeLastValue(t){if(this._value.length===0)return;t.preventDefault();const e=this._value[this._value.length-1];e&&this.removeSelected(e),this.updateMaxReached()}}class E extends B{handleInput(t){if(t.stopPropagation(),t.stopImmediatePropagation(),this.disabled)return;this.touched=!0;const e=t.target;if(this._search=e.value,this.checkForMatches(),this.typeahead)if(this._search){const{filtered:s,suggestion:i}=u.findTypeaheadMatches(this.options,this._search);this._options=s,t.inputType!=="deleteContentBackward"&&(i!=null&&i.label)&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(e.value=i.label,window.setTimeout(()=>e.setSelectionRange(this._search.length,e.value.length),0),e.selectionDirection="backward")}else this._options=[...this.options]}handleFocus(){if(!this.disabled){if(this._suppressNextOpen){this._suppressNextOpen=!1,this._inputFocus=!0,this.requestUpdate();return}!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value=O(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search="",this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(t){var i,l;if(this.disabled||!this._isOptionsOpen)return;const e=t.relatedTarget;((i=e==null?void 0:e.closest("pkt-combobox"))==null?void 0:i.id)===this.id||((l=t.target)==null?void 0:l.getAttribute("data-focusfix"))===this.id||e===this.inputRef.value||e===this.triggerRef.value||this.closeAndProcessInput()}closeAndProcessInput(){if(this._inputFocus=!1,this._addValueText=null,this._userInfoMessage="",this._search="",this.inputRef.value&&this.inputRef.value.type!=="hidden"){const t=this.inputRef.value.value;if(this.multiple){if(t!==""){const{action:e,value:s}=M(t,this._value,this.options,this.allowUserInput,this.multiple);switch(e){case"addUserValue":this.addNewUserValue(s);break;case"selectOption":this.setSelected(s);break;case"removeValue":this.removeValue(s);break}}}else if(!t)this._value[0]&&this.removeSelected(this._value[0]);else{const e=u.findOptionByValue(this.options,t);e&&e.value!==this._value[0]?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(e.value)):!e&&this.allowUserInput&&(this._value[0]&&this.removeSelected(this._value[0]),this.addNewUserValue(t))}!this.multiple&&this._value[0]?this.inputRef.value.value=O(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=""}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(t){var e,s;if(this.disabled){t.preventDefault(),t.stopImmediatePropagation();return}this._hasTextInput?((e=this.inputRef.value)==null||e.focus(),this.requestUpdate()):(t.stopImmediatePropagation(),t.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen&&((s=this.listboxRef.value)==null||s.focusFirstOrSelectedOption()))}handlePlaceholderClick(t){this.disabled||(t.stopPropagation(),this._hasTextInput&&this.inputRef.value?(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()):(this._isOptionsOpen=!this._isOptionsOpen,this.requestUpdate()))}handleSelectOnlyKeydown(t){var e,s;if(!this.disabled)switch(t.key){case"Enter":case" ":case"ArrowDown":case"ArrowUp":t.preventDefault(),this._isOptionsOpen?this._isOptionsOpen=!1:(this._isOptionsOpen=!0,(e=this.listboxRef.value)==null||e.focusFirstOrSelectedOption());break;case"Escape":this._isOptionsOpen&&(t.preventDefault(),this._isOptionsOpen=!1);break;case"Home":case"End":t.preventDefault(),this._isOptionsOpen||(this._isOptionsOpen=!0),(s=this.listboxRef.value)==null||s.focusFirstOrSelectedOption();break;case"ArrowLeft":this.multiple&&this._value.length>0&&(t.preventDefault(),this.focusTag(this._value.length-1));break;case"Backspace":case"Delete":this.multiple&&this._value.length>0&&(t.preventDefault(),this.removeSelected(this._value[this._value.length-1]));break}}handleOptionToggled(t){this.toggleValue(t.detail)}handleSearch(t){t.stopPropagation(),this._search=t.detail.toLowerCase(),this.checkForMatches()}handleInputKeydown(t){var s,i,l;if(t.key==="Backspace"){const n=!((s=this.inputRef.value)!=null&&s.value);!this._search&&n&&this.multiple&&this._value.length>0&&this.removeLastValue(t);return}if(t.key==="ArrowLeft"&&this.multiple&&this._value.length>0){const n=this.inputRef.value;if(n&&n.selectionStart===0&&!n.value){t.preventDefault(),this.focusTag(this._value.length-1);return}}const e=F(t.key,t.shiftKey,this.multiple);if(e&&!(t.key==="Tab"&&!this._isOptionsOpen)){if(e==="focusListbox"&&t.key==="Tab"&&!((i=this.listboxRef.value)==null?void 0:i.querySelector('[role="option"]:not([data-disabled]), [data-type="new-option"]'))){this.closeAndProcessInput();return}switch(t.preventDefault(),e){case"addValue":this.addValue();break;case"focusListbox":(l=this.listboxRef.value)==null||l.focusFirstOrSelectedOption();break;case"closeOptions":this._isOptionsOpen=!1;break}}}handleTagRemove(t){this.removeSelected(t),this._hasTextInput&&this.inputRef.value&&(this._inputFocus=!0,this.inputRef.value.focus(),this.requestUpdate())}getInsideTags(){return Array.from(this.querySelectorAll(".pkt-combobox__input .pkt-combobox__tag-list pkt-tag"))}focusTag(t){var i;const e=this.getInsideTags();e.forEach((l,n)=>{l.buttonTabindex=n===t?0:-1});const s=(i=e[t])==null?void 0:i.querySelector("button");s==null||s.focus()}resetTagTabindices(){this.getInsideTags().forEach(e=>{e.buttonTabindex=-1})}handleTagKeydown(t,e){t.stopPropagation();const s=()=>{var i;this.resetTagTabindices(),this._hasTextInput&&this.inputRef.value?this.inputRef.value.focus():(i=this.triggerRef.value)==null||i.focus()};switch(t.key){case"ArrowLeft":t.preventDefault(),e>0&&this.focusTag(e-1);break;case"ArrowRight":t.preventDefault(),e<this._value.length-1?this.focusTag(e+1):s();break;case"Backspace":case"Delete":t.preventDefault();{const i=this._value[e],l=e>=this._value.length-1?e-1:e;this.removeSelected(i),l>=0?(this.requestUpdate(),this.updateComplete.then(()=>this.focusTag(l))):s()}break;case"Tab":this.resetTagTabindices();break;case"Escape":t.preventDefault(),s();break}}checkForMatches(){var s;const t=((s=this.inputRef.value)==null?void 0:s.value)||this._search||"",e=U(t,this._value,this.options,this.allowUserInput,this.multiple);if(e.shouldRemoveValue&&this.removeValue(this._value[0]),e.shouldResetInput){this.resetComboboxInput(!1);return}this._addValueText=e.addValueText,this._userInfoMessage=e.userInfoMessage}}var N=Object.getOwnPropertyDescriptor,L=(a,t,e,s)=>{for(var i=s>1?void 0:s?N(t,e):t,l=a.length-1,n;l>=0;l--)(n=a[l])&&(i=n(i)||i);return i};exports.PktCombobox=class extends E{constructor(){super(...arguments),this.handleBodyClick=t=>{this._isOptionsOpen&&!this.contains(t.target)&&this.closeAndProcessInput()}}connectedCallback(){var t,e;if(super.connectedCallback(),document==null||document.body.addEventListener("click",this.handleBodyClick),this._options=[],this.defaultOptions&&this.defaultOptions.length){const s=((t=this.options)==null?void 0:t.filter(i=>i.userAdded))||[];this.options=[...s,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if((e=this.optionsController)!=null&&e.nodes&&this.optionsController.nodes.length){const s=A.parseOptionsFromSlot(this.optionsController.nodes);s.length&&(this.options=[...s],this._options=[...s],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}willUpdate(t){if(this._optionsFromSlot&&this.optionsController){const e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;const s=A.parseOptionsFromSlot(this.optionsController.nodes),i=this._options.filter(l=>l.userAdded);this.options=[...i,...s]}}super.willUpdate(t)}disconnectedCallback(){super.disconnectedCallback(),document==null||document.body.removeEventListener("click",this.handleBodyClick)}firstUpdated(t){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(t)}updated(t){t.has("isOpen")&&(this._isOptionsOpen=this.isOpen);const e=t.has("value"),s=t.has("_value");if(e&&this._internalValueSync)this._internalValueSync=!1,s&&this.syncValueAndDispatch(t.get("_value"));else if(e){const l=[...this._value],n=this.parseValue();n.join(",")!==this._value.join(",")&&(this._value=n),this.updateMaxReached(),this.syncValueAndDispatch(l)}else s&&this.syncValueAndDispatch(t.get("_value"));if(t.has("defaultOptions")&&this.defaultOptions.length){const l=(Array.isArray(this.options)?this.options:[]).filter(n=>n.userAdded)||[];this.options=[...l,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(t.has("options")){const l=t.get("options")||this._options||[],n=k.mergeWithUserAdded(this.options,l);this._options=n,n.length>this.options.length&&(this.options=n);const p=k.syncOptionsWithValues(this._options,this._value);if(this._options=p.options,p.newValues.length>this._value.length){const _=[...this._value];this._value=p.newValues,this.syncValueAndDispatch(_)}}if(t.has("_search")&&this.dispatchEvent(new CustomEvent("search",{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&!this.multiple&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const l=this._value[0]?O(this._value[0],this.options,this.displayValueAs):"";this.inputRef.value.value!==l&&(this.inputRef.value.value=l)}super.updated(t)}formResetCallback(){this.touched=!1;const t=this.defaultValue||(this.multiple,"");this.value=t,this._value=this.parseValue(),this._options=this._options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this.options=this.options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this._search="",this._isOptionsOpen=!1,this._userInfoMessage="",this._addValueText=null,this._inputFocus=!1,this.updateMaxReached(),this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value=""),this.internals.setFormValue(""),this.internals.ariaInvalid="false",this.requestUpdate()}attributeChangedCallback(t,e,s){if(t==="options"){this._options=Array.isArray(this.options)?[...this.options]:[];const i=k.syncOptionsWithValues(this._options,this._value);this._options=i.options,i.newValues.length>this._value.length&&(this._value=i.newValues),this._search=""}super.attributeChangedCallback(t,e,s)}render(){return o.b`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
.label=${this.label}
|
|
4
4
|
.helptext=${this.helptext}
|
|
@@ -3,7 +3,7 @@ import { o as u } from "./if-defined-rXcLNTzN.js";
|
|
|
3
3
|
import { e as y, n as b } from "./ref-Dma3n3i8.js";
|
|
4
4
|
import { e as w } from "./class-map-3ADKve8g.js";
|
|
5
5
|
import { c as P } from "./repeat-DnlRNf63.js";
|
|
6
|
-
import { f, g as B, b as U, i as k, a as E, c as R } from "./listbox-
|
|
6
|
+
import { f, g as B, b as U, i as k, a as E, c as R } from "./listbox-CS4WQOuf.js";
|
|
7
7
|
import { r as v } from "./state-l4hGZdFJ.js";
|
|
8
8
|
import { P as q } from "./input-element-BGNbdzy2.js";
|
|
9
9
|
import { P as N } from "./pkt-options-controller-Z-bPox7n.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const l=require("./element-CMTfByxQ.cjs"),I=require("./state-BNgpvY-A.cjs"),u=require("./calendar-
|
|
1
|
+
"use strict";const l=require("./element-CMTfByxQ.cjs"),I=require("./state-BNgpvY-A.cjs"),u=require("./calendar-43Y_6FD8.cjs"),A=require("./input-element-CSDVA3Y6.cjs"),o=require("./ref-CxLwrCxt.cjs");require("./icon-Dj0oZZSa.cjs");require("./input-wrapper-JU4D2TGu.cjs");const m=require("./class-map-Bokp1SoS.cjs"),M=require("./repeat-C-FJ2vfy.cjs");require("./tag-DmbgBCKu.cjs");const O=require("./utils-byXsEz1u.cjs"),g=require("./if-defined-hKKmbsI8.cjs"),F=require("./pkt-slot-controller-D4nKlom5.cjs"),B={calendar:{buttonAltText:"Åpne kalender"}},j={calendar:{buttonAltText:"Åpne kalender"},generic:{from:"Fra",to:"Til"}};var q=Object.defineProperty,L=Object.getOwnPropertyDescriptor,b=(s,e,t,a)=>{for(var i=a>1?void 0:a?L(e,t):e,r=s.length-1,n;r>=0;r--)(n=s[r])&&(i=(a?n(e,t,i):n(i))||i);return a&&i&&q(e,t,i),i};exports.PktDateTags=class extends l.PktElement{constructor(){super(...arguments),this.dates=[],this.dateformat="dd.MM.yyyy",this.className="pkt-datepicker__tags",this.idBase=O.uuidish()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},l.b`
|
|
2
2
|
<div class=${m.e(this.classes)} aria-live="polite">
|
|
3
3
|
${Array.isArray(this.dates)&&this.dates[0]?M.c(u.sortDateStrings((this.dates??[]).filter(Boolean)),e=>e,e=>{var t;return l.b` <pkt-tag
|
|
4
4
|
id=${this.idBase+e+"-tag"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as L, A as D, b as h, n as r, t as x } from "./element-CV9utnHJ.js";
|
|
2
2
|
import { r as z } from "./state-l4hGZdFJ.js";
|
|
3
|
-
import { s as H, f as N, a as Q, i as X, n as k, b as j, c as W, v as P, d as Y, p as Z, e as G } from "./calendar-
|
|
3
|
+
import { s as H, f as N, a as Q, i as X, n as k, b as j, c as W, v as P, d as Y, p as Z, e as G } from "./calendar-B5Xwl8mV.js";
|
|
4
4
|
import { P as ee } from "./input-element-BGNbdzy2.js";
|
|
5
5
|
import { e as f, n as v } from "./ref-Dma3n3i8.js";
|
|
6
6
|
import "./icon-D0IQAVwS.js";
|
|
@@ -2,7 +2,7 @@ import { P as v, b as d, A as h, s as _, n as o, t as O } from "./element-CV9utn
|
|
|
2
2
|
import { r as w } from "./state-l4hGZdFJ.js";
|
|
3
3
|
import { o as m } from "./if-defined-rXcLNTzN.js";
|
|
4
4
|
import { c as $ } from "./repeat-DnlRNf63.js";
|
|
5
|
-
import { e as
|
|
5
|
+
import { e as g } from "./class-map-3ADKve8g.js";
|
|
6
6
|
import { u as S } from "./utils-DznhwRXm.js";
|
|
7
7
|
const F = (e, t) => t && (e.find((s) => s.value === t) || e.find((s) => s.label === t)) || null, H = (e, t) => {
|
|
8
8
|
if (!t) return -1;
|
|
@@ -68,7 +68,7 @@ const F = (e, t) => t && (e.find((s) => s.value === t) || e.find((s) => s.label
|
|
|
68
68
|
}, x = (e) => {
|
|
69
69
|
const t = f(e);
|
|
70
70
|
t[0] && u(t[0]);
|
|
71
|
-
},
|
|
71
|
+
}, k = (e) => {
|
|
72
72
|
const t = f(e), s = t[t.length - 1];
|
|
73
73
|
s && u(s);
|
|
74
74
|
}, U = (e, t) => {
|
|
@@ -124,7 +124,7 @@ let n = class extends v {
|
|
|
124
124
|
render() {
|
|
125
125
|
return d`
|
|
126
126
|
<div
|
|
127
|
-
class=${
|
|
127
|
+
class=${g({
|
|
128
128
|
"pkt-listbox": !0,
|
|
129
129
|
"pkt-listbox__open": this.isOpen,
|
|
130
130
|
"pkt-txt-16-light": !0
|
|
@@ -154,6 +154,9 @@ let n = class extends v {
|
|
|
154
154
|
role="presentation"
|
|
155
155
|
tabindex="-1"
|
|
156
156
|
value=${e.value}
|
|
157
|
+
@change=${(s) => {
|
|
158
|
+
s.stopPropagation();
|
|
159
|
+
}}
|
|
157
160
|
.checked=${e.selected}
|
|
158
161
|
aria-labelledby=${this.id + "-option-label-" + t}
|
|
159
162
|
?disabled=${this.disabled || e.disabled || this.maxIsReached && !e.selected}
|
|
@@ -162,7 +165,11 @@ let n = class extends v {
|
|
|
162
165
|
}
|
|
163
166
|
renderEmptyMessage() {
|
|
164
167
|
return this.options.length > 0 || this._filteredOptions.length > 0 || this.userMessage ? h : d`<div class="pkt-listbox__banner pkt-listbox__banner--empty">
|
|
165
|
-
<pkt-icon
|
|
168
|
+
<pkt-icon
|
|
169
|
+
class="pkt-listbox__banner-icon"
|
|
170
|
+
name="exclamation-mark-circle"
|
|
171
|
+
size="large"
|
|
172
|
+
></pkt-icon>
|
|
166
173
|
Tom liste
|
|
167
174
|
</div>`;
|
|
168
175
|
}
|
|
@@ -178,7 +185,7 @@ let n = class extends v {
|
|
|
178
185
|
}}
|
|
179
186
|
aria-selected=${e.selected ? "true" : "false"}
|
|
180
187
|
@keydown=${this.handleOptionKeydown}
|
|
181
|
-
class=${
|
|
188
|
+
class=${g({
|
|
182
189
|
"pkt-listbox__option": !0,
|
|
183
190
|
"pkt-listbox__option--selected": !!(!this.isMultiSelect && e.selected),
|
|
184
191
|
"pkt-listbox__option--checkBox": this.isMultiSelect
|
|
@@ -307,7 +314,7 @@ let n = class extends v {
|
|
|
307
314
|
this.tabClose();
|
|
308
315
|
break;
|
|
309
316
|
case "ArrowDown":
|
|
310
|
-
e.altKey ?
|
|
317
|
+
e.altKey ? k(this) : i === "searchbox" || i === "new-option" ? x(this) : E(t), e.preventDefault();
|
|
311
318
|
break;
|
|
312
319
|
case "ArrowUp":
|
|
313
320
|
if (e.altKey)
|
|
@@ -326,7 +333,7 @@ let n = class extends v {
|
|
|
326
333
|
x(this), e.preventDefault();
|
|
327
334
|
break;
|
|
328
335
|
case "End":
|
|
329
|
-
|
|
336
|
+
k(this), e.preventDefault();
|
|
330
337
|
break;
|
|
331
338
|
default:
|
|
332
339
|
(e.metaKey || e.ctrlKey) && e.key === "a" && (this.selectAll(), e.preventDefault()), C(e.key) && (this.handleTypeAhead(e.key), e.preventDefault());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const n=require("./element-CMTfByxQ.cjs"),
|
|
1
|
+
"use strict";const n=require("./element-CMTfByxQ.cjs"),g=require("./state-BNgpvY-A.cjs"),p=require("./if-defined-hKKmbsI8.cjs"),m=require("./repeat-C-FJ2vfy.cjs"),f=require("./class-map-Bokp1SoS.cjs"),y=require("./utils-byXsEz1u.cjs"),v=(s,e)=>e&&(s.find(t=>t.value===e)||s.find(t=>t.label===e))||null,O=(s,e)=>{if(!e)return-1;const t=s.findIndex(i=>i.value===e);return t>=0?t:s.findIndex(i=>i.label===e)},_=(s,e)=>{if(!e)return[...s];const t=e.toLowerCase();return s.filter(i=>(i.fulltext||i.value+(i.label||"")+(i.prefix||"")).toLowerCase().includes(t))},w=s=>s.value+(s.label||"")+(s.prefix||""),$=(s,e)=>e!==null&&s>=e,L=(s,e)=>{if(!e)return{filtered:[...s],suggestion:null};const t=e.toLowerCase(),i=s.filter(o=>{var l;return(l=o.fulltext)==null?void 0:l.toLowerCase().includes(t)}),a=i.find(o=>{var l;return!o.selected&&((l=o.label)==null?void 0:l.toLowerCase().startsWith(t))})||null;return{filtered:i,suggestion:a}},S=(s,e,t,i)=>{if(!s.trim())return{addValueText:null,userInfoMessage:""};const a=s.trim().toLowerCase(),o=e.find(u=>u.toLowerCase()===a),l=t.filter(u=>{var d;return((d=u.label)==null?void 0:d.toLowerCase().includes(a))||u.value.toLowerCase().includes(a)}),k=l.find(u=>{var d;return((d=u.label)==null?void 0:d.toLowerCase())===a||u.value.toLowerCase()===a});return(l.length===0||!k)&&i?{addValueText:s,userInfoMessage:""}:l.length===0&&!i?{addValueText:null,userInfoMessage:"Ingen treff i søket"}:o?{addValueText:null,userInfoMessage:"Verdien er allerede valgt"}:{addValueText:null,userInfoMessage:""}},I=s=>/^[\p{L} ]$/u.test(s),C=(s=500)=>{let e="",t;return{append:o=>(e+=o.toLowerCase(),t!==void 0&&clearTimeout(t),t=setTimeout(()=>{e=""},s),e),reset:()=>{e="",t!==void 0&&(clearTimeout(t),t=void 0)},getBuffer:()=>e}},M=(s,e)=>{const t=e.toLowerCase();return s.findIndex(i=>{var a;return(a=i.textContent)==null?void 0:a.trim().toLowerCase().startsWith(t)})},c=s=>{s.scrollIntoView({block:"nearest"}),window.setTimeout(()=>s.focus(),0)},h=s=>Array.from(s.querySelectorAll('[role="option"]:not([data-disabled])')||[]),P=s=>{const e=s.nextElementSibling;e&&c(e)},E=(s,e,t)=>{const i=s.previousElementSibling;if(s.dataset.index==="0"&&t){const a=e.querySelector('[role="searchbox"]');a&&c(a)}else i&&c(i)},b=s=>{const e=h(s);e[0]&&c(e[0])},x=s=>{const e=h(s),t=e[e.length-1];t&&c(t)},T=(s,e)=>{if(e.disabled)return;const t=h(s);if(e.allowUserInput&&e.customUserInput){const a=s.querySelector('[data-type="new-option"]');if(a){c(a);return}}const i=t.find(a=>a.dataset.selected==="true");if(i){c(i);return}if(e.includeSearch&&!(document.activeElement instanceof HTMLInputElement)){const a=s.querySelector('[role="searchbox"]');if(a){window.setTimeout(()=>a.focus(),0);return}}t[0]&&c(t[0])};var U=Object.defineProperty,A=Object.getOwnPropertyDescriptor,r=(s,e,t,i)=>{for(var a=i>1?void 0:i?A(e,t):e,o=s.length-1,l;o>=0;o--)(l=s[o])&&(a=(i?l(e,t,a):l(a))||a);return i&&a&&U(e,t,a),a};exports.PktListbox=class extends n.PktElement{constructor(){super(...arguments),this.id=y.uuidish(),this.label=null,this.options=[],this.isOpen=!1,this.disabled=!1,this.includeSearch=!1,this.isMultiSelect=!1,this.allowUserInput=!1,this.maxIsReached=!1,this.customUserInput=null,this.searchPlaceholder=null,this.searchValue=null,this.maxLength=0,this.userMessage=null,this._selectedOptions=0,this.typeahead=C(),this._filteredOptions=[]}connectedCallback(){super.connectedCallback(),this.includeSearch&&!this.searchValue&&(this.searchValue=""),this.options.length>0&&this.filterOptions(),this.setAttribute("tabindex","-1"),this.addEventListener("focus",this.focusFirstOrSelectedOption)}disconnectedCallback(){super.disconnectedCallback(),this.typeahead.reset()}updated(e){(e.has("options")||e.has("searchValue"))&&this.filterOptions(),super.updated(e)}attributeChangedCallback(e,t,i){(e==="options"||e==="search-value")&&this.filterOptions(),super.attributeChangedCallback(e,t,i)}get _hasOptions(){return this._filteredOptions.length>0||this.options.length>0}render(){return n.b`
|
|
2
2
|
<div
|
|
3
3
|
class=${f.e({"pkt-listbox":!0,"pkt-listbox__open":this.isOpen,"pkt-txt-16-light":!0})}
|
|
4
4
|
role=${p.o(this._hasOptions?"listbox":void 0)}
|
|
@@ -21,15 +21,20 @@
|
|
|
21
21
|
role="presentation"
|
|
22
22
|
tabindex="-1"
|
|
23
23
|
value=${e.value}
|
|
24
|
+
@change=${i=>{i.stopPropagation()}}
|
|
24
25
|
.checked=${e.selected}
|
|
25
26
|
aria-labelledby=${this.id+"-option-label-"+t}
|
|
26
27
|
?disabled=${this.disabled||e.disabled||this.maxIsReached&&!e.selected}
|
|
27
28
|
/>
|
|
28
29
|
`:e.selected?n.b`<pkt-icon name="check-big"></pkt-icon>`:n.A}renderEmptyMessage(){return this.options.length>0||this._filteredOptions.length>0||this.userMessage?n.A:n.b`<div class="pkt-listbox__banner pkt-listbox__banner--empty">
|
|
29
|
-
<pkt-icon
|
|
30
|
+
<pkt-icon
|
|
31
|
+
class="pkt-listbox__banner-icon"
|
|
32
|
+
name="exclamation-mark-circle"
|
|
33
|
+
size="large"
|
|
34
|
+
></pkt-icon>
|
|
30
35
|
Tom liste
|
|
31
36
|
</div>`}renderList(){return n.b`
|
|
32
|
-
${
|
|
37
|
+
${m.c(this._filteredOptions,e=>e.value,(e,t)=>n.b`
|
|
33
38
|
<li
|
|
34
39
|
@click=${()=>{this.toggleOption(e)}}
|
|
35
40
|
aria-selected=${e.selected?"true":"false"}
|
|
@@ -98,4 +103,4 @@
|
|
|
98
103
|
role="searchbox"
|
|
99
104
|
/>
|
|
100
105
|
</div>
|
|
101
|
-
`:n.A}handleSearchInput(e){this.searchValue=e.target.value,this.dispatchEvent(new CustomEvent("search",{detail:this.searchValue,bubbles:!1}))}handleSearchKeydown(e){switch(e.key){case"Enter":e.preventDefault();break;case"ArrowUp":case"Escape":this.closeOptions(),e.preventDefault();break;case"ArrowDown":this.focusFirstOrSelectedOption();break;case"Tab":this.tabClose();break}}handleOptionKeydown(e){const t=e.currentTarget,
|
|
106
|
+
`:n.A}handleSearchInput(e){this.searchValue=e.target.value,this.dispatchEvent(new CustomEvent("search",{detail:this.searchValue,bubbles:!1}))}handleSearchKeydown(e){switch(e.key){case"Enter":e.preventDefault();break;case"ArrowUp":case"Escape":this.closeOptions(),e.preventDefault();break;case"ArrowDown":this.focusFirstOrSelectedOption();break;case"Tab":this.tabClose();break}}handleOptionKeydown(e){const t=e.currentTarget,i=t.dataset.value,a=t.dataset.type,o=t.dataset.selected==="true";if(!(!h(this).length&&(!this.customUserInput||!this.allowUserInput&&this.customUserInput)&&a!=="new-option"&&a!=="searchbox"))switch(e.key){case" ":case"Enter":this.toggleOption(t),e.preventDefault();break;case"Backspace":i&&(o?this.toggleOption(t):this.closeOptions()),e.preventDefault();break;case"Escape":this.closeOptions(),e.preventDefault();break;case"Tab":this.tabClose();break;case"ArrowDown":e.altKey?x(this):a==="searchbox"||a==="new-option"?b(this):P(t),e.preventDefault();break;case"ArrowUp":if(e.altKey)b(this);else if(t.dataset.index==="0"&&this.includeSearch){const l=this.querySelector('[role="searchbox"]');l&&l.focus()}else if(t.dataset.index==="0"&&this.customUserInput){const l=this.querySelector('[data-type="new-option"]');l&&l.focus()}else E(t,this,this.includeSearch);e.preventDefault();break;case"Home":b(this),e.preventDefault();break;case"End":x(this),e.preventDefault();break;default:(e.metaKey||e.ctrlKey)&&e.key==="a"&&(this.selectAll(),e.preventDefault()),I(e.key)&&(this.handleTypeAhead(e.key),e.preventDefault());break}}focusFirstOrSelectedOption(){T(this,{disabled:this.disabled,allowUserInput:this.allowUserInput,customUserInput:this.customUserInput,includeSearch:this.includeSearch})}toggleOption(e){const t=e instanceof HTMLElement?e.dataset.disabled:e.disabled;if(this.disabled||t)return;const i=e instanceof HTMLElement?e.dataset.value:e.value;this.dispatchEvent(new CustomEvent("option-toggle",{detail:i,bubbles:!1}))}selectAll(){this.dispatchEvent(new CustomEvent("select-all",{bubbles:!1}))}closeOptions(){this.dispatchEvent(new CustomEvent("close-options",{bubbles:!1}))}tabClose(){this.dispatchEvent(new CustomEvent("tab-close",{bubbles:!1}))}filterOptions(){this._filteredOptions=_(this.options,this.searchValue)}handleTypeAhead(e){const t=this.typeahead.append(e),i=h(this),a=M(i,t);a>=0&&c(i[a])}};r([n.n({type:String})],exports.PktListbox.prototype,"id",2);r([n.n({type:String})],exports.PktListbox.prototype,"label",2);r([n.n({type:Array})],exports.PktListbox.prototype,"options",2);r([n.n({type:Boolean,reflect:!0,attribute:"is-open"})],exports.PktListbox.prototype,"isOpen",2);r([n.n({type:Boolean})],exports.PktListbox.prototype,"disabled",2);r([n.n({type:Boolean,attribute:"include-search"})],exports.PktListbox.prototype,"includeSearch",2);r([n.n({type:Boolean,attribute:"is-multi-select"})],exports.PktListbox.prototype,"isMultiSelect",2);r([n.n({type:Boolean,attribute:"allow-user-input"})],exports.PktListbox.prototype,"allowUserInput",2);r([n.n({type:Boolean,attribute:"max-is-reached"})],exports.PktListbox.prototype,"maxIsReached",2);r([n.n({type:String,attribute:"custom-user-input"})],exports.PktListbox.prototype,"customUserInput",2);r([n.n({type:String,attribute:"search-placeholder"})],exports.PktListbox.prototype,"searchPlaceholder",2);r([n.n({type:String,attribute:"search-value"})],exports.PktListbox.prototype,"searchValue",2);r([n.n({type:Number,attribute:"max-length"})],exports.PktListbox.prototype,"maxLength",2);r([n.n({type:String,attribute:"user-message"})],exports.PktListbox.prototype,"userMessage",2);r([g.r()],exports.PktListbox.prototype,"_filteredOptions",2);exports.PktListbox=r([n.t("pkt-listbox")],exports.PktListbox);exports.buildFulltext=w;exports.findOptionByValue=v;exports.findOptionIndex=O;exports.findTypeaheadMatches=L;exports.getSearchInfoMessage=S;exports.isMaxSelectionReached=$;
|
package/dist/pkt-calendar.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./calendar-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./calendar-43Y_6FD8.cjs"),t=e.PktCalendar;Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>e.PktCalendar});exports.default=t;
|
package/dist/pkt-calendar.js
CHANGED
package/dist/pkt-combobox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./combobox-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./combobox-DX2BLzIm.cjs"),o=e.PktCombobox;Object.defineProperty(exports,"PktCombobox",{enumerable:!0,get:()=>e.PktCombobox});exports.default=o;
|
package/dist/pkt-combobox.js
CHANGED
package/dist/pkt-datepicker.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./datepicker-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./datepicker-CPNcXd-o.cjs"),t=e.PktDatepicker;Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>e.PktDatepicker});Object.defineProperty(exports,"PktDatepickerMultiple",{enumerable:!0,get:()=>e.PktDatepickerMultiple});Object.defineProperty(exports,"PktDatepickerRange",{enumerable:!0,get:()=>e.PktDatepickerRange});Object.defineProperty(exports,"PktDatepickerSingle",{enumerable:!0,get:()=>e.PktDatepickerSingle});exports.default=t;
|
package/dist/pkt-datepicker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as e } from "./datepicker-
|
|
2
|
-
import { b as p, c as i, d as c } from "./datepicker-
|
|
1
|
+
import { a as e } from "./datepicker-MuQYeXhL.js";
|
|
2
|
+
import { b as p, c as i, d as c } from "./datepicker-MuQYeXhL.js";
|
|
3
3
|
const a = e;
|
|
4
4
|
export {
|
|
5
5
|
e as PktDatepicker,
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./alert-BDXWFRcf.cjs"),t=require("./accordionitem-To95GT6b.cjs"),a=require("./backlink-CQoNgoa-.cjs"),P=require("./button-VWxZW89G.cjs"),i=require("./calendar-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./alert-BDXWFRcf.cjs"),t=require("./accordionitem-To95GT6b.cjs"),a=require("./backlink-CQoNgoa-.cjs"),P=require("./button-VWxZW89G.cjs"),i=require("./calendar-43Y_6FD8.cjs"),c=require("./card-Db9QSEqh.cjs"),b=require("./combobox-DX2BLzIm.cjs"),k=require("./consent-BQLkfN3d.cjs"),d=require("./checkbox-Cpyay9_l.cjs"),r=require("./datepicker-CPNcXd-o.cjs"),e=require("./pkt-header.cjs"),l=require("./helptext-BjW1WdOn.cjs"),s=require("./heading-B0XRE0lq.cjs"),p=require("./icon-Dj0oZZSa.cjs"),g=require("./input-wrapper-JU4D2TGu.cjs"),m=require("./link-CDuv1jxx.cjs"),f=require("./linkcard-3WUL0CpY.cjs"),y=require("./loader-C1LI8Q4z.cjs"),j=require("./messagebox-Dmot5szX.cjs"),O=require("./modal-S9MOKOaz.cjs"),q=require("./progressbar-Bxh335uT.cjs"),n=require("./radiobutton-CNHCpKn0.cjs"),x=require("./tag-DmbgBCKu.cjs"),o=require("./tabitem-BKv4eN0a.cjs"),T=require("./textarea-CO7Ikug5.cjs"),C=require("./textinput-DRFZU3dA.cjs"),H=require("./select-PWPy5gTB.cjs");Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>u.PktAlert});exports.PktAccordion=t.PktAccordion;exports.PktAccordionItem=t.PktAccordionItem_default;Object.defineProperty(exports,"PktBackLink",{enumerable:!0,get:()=>a.PktBackLink});Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>P.PktButton});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>i.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>c.PktCard});Object.defineProperty(exports,"PktCombobox",{enumerable:!0,get:()=>b.PktCombobox});Object.defineProperty(exports,"PktConsent",{enumerable:!0,get:()=>k.PktConsent});Object.defineProperty(exports,"PktCheckbox",{enumerable:!0,get:()=>d.PktCheckbox});Object.defineProperty(exports,"PktDateTags",{enumerable:!0,get:()=>r.PktDateTags});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>r.PktDatepicker});Object.defineProperty(exports,"PktHeader",{enumerable:!0,get:()=>e.PktHeader});Object.defineProperty(exports,"PktHeaderService",{enumerable:!0,get:()=>e.PktHeaderService});Object.defineProperty(exports,"PktHeaderUserMenu",{enumerable:!0,get:()=>e.PktHeaderUserMenu});Object.defineProperty(exports,"PktHelptext",{enumerable:!0,get:()=>l.PktHelptext});Object.defineProperty(exports,"PktHeading",{enumerable:!0,get:()=>s.PktHeading});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>p.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>g.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>m.PktLink});Object.defineProperty(exports,"PktLinkCard",{enumerable:!0,get:()=>f.PktLinkCard});Object.defineProperty(exports,"PktLoader",{enumerable:!0,get:()=>y.PktLoader});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>j.PktMessagebox});Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>O.PktModal});Object.defineProperty(exports,"PktProgressbar",{enumerable:!0,get:()=>q.PktProgressbar});Object.defineProperty(exports,"PktRadioButton",{enumerable:!0,get:()=>n.PktRadioButton});Object.defineProperty(exports,"PktRadiobutton",{enumerable:!0,get:()=>n.PktRadioButton});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>x.PktTag});exports.PktTabItem=o.PktTabItem_default;exports.PktTabs=o.PktTabs;Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>T.PktTextarea});Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>C.PktTextinput});Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>H.PktSelect});
|
package/dist/pkt-index.js
CHANGED
|
@@ -2,12 +2,12 @@ import { P as r } from "./alert-BHSd2Vpj.js";
|
|
|
2
2
|
import { P as e, a } from "./accordionitem-CHXGzgLv.js";
|
|
3
3
|
import { P as s } from "./backlink-C68H4Z3b.js";
|
|
4
4
|
import { P as x } from "./button-CHUuxLQV.js";
|
|
5
|
-
import { P as f } from "./calendar-
|
|
5
|
+
import { P as f } from "./calendar-B5Xwl8mV.js";
|
|
6
6
|
import { P as d } from "./card-CmfUyl_s.js";
|
|
7
|
-
import { P as c } from "./combobox-
|
|
7
|
+
import { P as c } from "./combobox-TKTemUxN.js";
|
|
8
8
|
import { P as u } from "./consent-knPF4PS_.js";
|
|
9
9
|
import { P as T } from "./checkbox-D6nltMuc.js";
|
|
10
|
-
import { P as l, a as H } from "./datepicker-
|
|
10
|
+
import { P as l, a as H } from "./datepicker-MuQYeXhL.js";
|
|
11
11
|
import { PktHeader as L, PktHeaderService as A, PktHeaderUserMenu as B } from "./pkt-header.js";
|
|
12
12
|
import { P as D } from "./helptext-TFpeGJ1P.js";
|
|
13
13
|
import { P as S } from "./heading-D9R5UBcv.js";
|
package/dist/pkt-listbox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./listbox-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./listbox-OAVh_U7u.cjs"),t=e.PktListbox;Object.defineProperty(exports,"PktListbox",{enumerable:!0,get:()=>e.PktListbox});exports.default=t;
|
package/dist/pkt-listbox.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.3",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
80
80
|
},
|
|
81
81
|
"license": "MIT",
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "771b0f317610ac826f4307e518d74f36cf6245cf"
|
|
83
83
|
}
|
|
@@ -139,6 +139,9 @@ export class PktListbox extends PktElement implements IPktListbox {
|
|
|
139
139
|
role="presentation"
|
|
140
140
|
tabindex="-1"
|
|
141
141
|
value=${option.value}
|
|
142
|
+
@change=${(e: Event) => {
|
|
143
|
+
e.stopPropagation()
|
|
144
|
+
}}
|
|
142
145
|
.checked=${option.selected}
|
|
143
146
|
aria-labelledby=${this.id + '-option-label-' + index}
|
|
144
147
|
?disabled=${this.disabled || option.disabled || (this.maxIsReached && !option.selected)}
|
|
@@ -154,7 +157,11 @@ export class PktListbox extends PktElement implements IPktListbox {
|
|
|
154
157
|
return nothing
|
|
155
158
|
}
|
|
156
159
|
return html`<div class="pkt-listbox__banner pkt-listbox__banner--empty">
|
|
157
|
-
<pkt-icon
|
|
160
|
+
<pkt-icon
|
|
161
|
+
class="pkt-listbox__banner-icon"
|
|
162
|
+
name="exclamation-mark-circle"
|
|
163
|
+
size="large"
|
|
164
|
+
></pkt-icon>
|
|
158
165
|
Tom liste
|
|
159
166
|
</div>`
|
|
160
167
|
}
|