@oslokommune/punkt-elements 12.11.6 → 12.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  * @license
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
- */const R=(o,e,t)=>{const i=new Map;for(let a=e;a<=t;a++)i.set(o[a],a);return i},P=b.e(class extends b.i{constructor(o){if(super(o),o.type!==b.t$1.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);const a=[],n=[];let l=0;for(const c of o)a[l]=i?i(c,l):l,n[l]=t(c,l),l++;return{values:n,keys:a}}render(o,e,t){return this.dt(o,e,t).values}update(o,[e,t,i]){const a=r.p(o),{values:n,keys:l}=this.dt(e,t,i);if(!Array.isArray(a))return this.ut=l,n;const c=this.ut??(this.ut=[]),g=[];let $,w,u=0,h=a.length-1,d=0,f=n.length-1;for(;u<=h&&d<=f;)if(a[u]===null)u++;else if(a[h]===null)h--;else if(c[u]===l[d])g[d]=r.v(a[u],n[d]),u++,d++;else if(c[h]===l[f])g[f]=r.v(a[h],n[f]),h--,f--;else if(c[u]===l[f])g[f]=r.v(a[u],n[f]),r.r(o,g[f+1],a[u]),u++,f--;else if(c[h]===l[d])g[d]=r.v(a[h],n[d]),r.r(o,a[u],a[h]),h--,d++;else if($===void 0&&($=R(l,d,f),w=R(c,u,h)),$.has(c[u]))if($.has(c[h])){const v=w.get(l[d]),x=v!==void 0?a[v]:null;if(x===null){const D=r.r(o,a[u]);r.v(D,n[d]),g[d]=D}else g[d]=r.v(x,n[d]),r.r(o,a[u],x),a[v]=null;d++}else r.M(a[h]),h--;else r.M(a[u]),u++;for(;d<=f;){const v=r.r(o,g[f+1]);r.v(v,n[d]),g[d++]=v}for(;u<=h;){const v=a[u++];v!==null&&r.M(v)}return this.ut=l,r.m(o,g),s.T}}),S="pkt-datepicker",I=!0,_={name:{type:"string",name:"Navn",description:"Navn som sendes brukes i skjema ved innsending"},label:{type:"string",name:"Etikett",description:"Tekst som vises over datovelgeren"},helptext:{type:"string",name:"Hjelpetekst",description:"Hjelpetekst som vises over datovelgeren"},helptextDropdown:{type:"string",name:"Utvidet hjelpetekst",description:"Hjelpetekst som vises i en lukket boks man kan åpne"},helptextDropdownButton:{type:"string",name:"Knappetekst for hjelpetekst",description:"Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst",default:"Les mer"},dateformat:{name:"Datoformat",description:"Datoformat for valgte datoer i flervalgsmodus",type:"string",default:"dd.MM.yyyy"},currentmonth:{name:"Nåværende måned",type:"ISOdatestring",description:"Måneden som skal vises i datovelgeren"},value:{name:"Verdi",type:"ISOdatestring",variant:"multiple",reflect:!0,description:"Kommaseparert liste av valgte datoer"},excludeweekdays:{name:"Utelat ukedager",type:"string",description:"Kommaseparert liste over ukedager (1-7) som skal ekskluderes"},excludedates:{name:"Utelat datoer",type:"ISOdatestring",variant:"multiple",description:"Kommaseparert liste over datoer som skal ekskluderes"},min:{name:"Tidligst tillatt",type:"ISOdatestring",default:null,description:"Første tillate dato i datovelgeren"},max:{name:"Senest tillatt",type:"ISOdatestring",default:null,description:"Siste tillate dato i datovelgeren"},weeknumbers:{name:"Vis ukenummer",type:"boolean",reflect:!0,default:!1,description:"Vis ukedager i datovelgerens kalender"},withcontrols:{name:"Med kontroller",type:"boolean",reflect:!0,default:!1,description:"Vis avanserte velgere for måned og år"},multiple:{name:"Flervalg",type:"boolean",reflect:!0,default:!1,description:"Tillat valg av flere enn én dato i samme velger"},maxlength:{name:"Maks antall",description:"Maks valgte datoer i flervalgsmodus",type:"number",default:4},range:{name:"Datotidsrom",type:"boolean",reflect:!0,default:!1,description:"Tillat å velge et tidsrom mellom to datoer i samme velger"},hasError:{type:"boolean",name:"Feil",description:"Viser feiltilstand for datovelgeren"},errorMessage:{type:"string",name:"Feilmelding",description:"Tekst som vises under datovelgeren ved feiltilstand"},disabled:{type:"boolean",name:"Deaktivert",default:!1,reflect:!0,description:"Er datovelgeren deaktivert?"},fullwidth:{type:"boolean",name:"Full bredde",default:!1,reflect:!0,description:"Skal datovelgeren ta opp hele bredden?"},required:{type:"boolean",name:"Påkrevd",default:!1,reflect:!0,description:"Er datovelgeren påkrevd?"},requiredTag:{type:"boolean",name:"Vise påkrevd-merking",default:!1,description:"Viser en merking som indikerer at datovelgeren er påkrevd"},requiredText:{type:"string",name:"Påkrevd-tekst",default:"Må fylles ut",description:"Tekst som vises i påkrevd-merkingen"},optionalTag:{type:"boolean",name:"Vise valgfritt-merking",default:!1,description:"Viser en merking som indikerer at datovelgeren er valgfri"},optionalText:{type:"string",name:"Valgfritt-tekst",default:"Valgfritt",description:"Tekst som vises i valgfritt-merkingen"},useWrapper:{type:"boolean",name:"Bruk wrapper",description:"Indikerer at feltet skal ha synlig label og hjelpetekst",default:!0},id:{type:"string",name:"ID",description:"Unik identifikasjon for datovelgeren"}},O={change:{type:"Event",description:"Returnerer valgt dato som streng i ISO-format"},"value-change":{type:"CustomEvent",description:"Returnerer en <code>array</code> med valgte datoer i ISO-format"},toggleHelpText:{type:"CustomEvent",description:"Returnerer <code>event.detail { isOpen: true }</code> eller <code>event.detail { isOpen: false }</code> når hjelpeteksten åpnes eller lukkes"}},k={name:S,"css-class":"pkt-datepicker",isElement:I,props:_,events:O};var E=Object.defineProperty,M=Object.getOwnPropertyDescriptor,p=(o,e,t,i)=>{for(var a=i>1?void 0:i?M(e,t):e,n=o.length-1,l;n>=0;n--)(l=o[n])&&(a=(i?l(e,t,a):l(a))||a);return i&&a&&E(e,t,a),a};const C=o=>new Promise(e=>setTimeout(e,o));exports.PktDatepicker=class extends s.PktInputElement{constructor(){super(...arguments),this.value="",this._value=this.value?Array.isArray(this.value)?this.value:this.value.split(","):[],this.label="Datovelger",this.dateformat=k.props.dateformat.default,this.multiple=k.props.multiple.default,this.maxlength=k.props.maxlength.default,this.range=k.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=k.props.weeknumbers.default,this.withcontrols=k.props.withcontrols.default,this.fullwidth=!1,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.useWrapper=!0,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=r.e(),this.inputRefTo=r.e(),this.btnRef=r.e(),this.calRef=r.e(),this.popupRef=r.e(),this.addToSelected=e=>{const t=e.target;if(!t.value)return;const i=this.min?m.newDate(this.min):null,a=this.max?m.newDate(this.max):null,n=m.newDate(t.value.split(",")[0]);n&&!isNaN(n.getTime())&&(!i||n>=i)&&(!a||n<=a)&&this.calRef.value&&this.calRef.value.handleDateSelect(n),t.value=""}}async connectedCallback(){super.connectedCallback(),this.isMobileSafari=/iP(ad|od|hone)/i.test(window.navigator.userAgent)&&!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/),this.inputType=this.isMobileSafari?"text":"date",document&&document.body.addEventListener("click",e=>{var t,i;(t=this.inputRef)!=null&&t.value&&((i=this.btnRef)!=null&&i.value)&&!this.inputRef.value.contains(e.target)&&!(this.inputRefTo.value&&this.inputRefTo.value.contains(e.target))&&!this.btnRef.value.contains(e.target)&&!e.target.closest(".pkt-calendar-popup")&&this.calendarOpen&&(this.onBlur(),this.hideCalendar())}),this.value.length&&this._value.length===0&&(this._value=Array.isArray(this.value)?this.value:this.value.split(",")),this.min=this.min||k.props.min.default,this.max=this.max||k.props.max.default,typeof this.excludedates=="string"&&(this.excludedates=this.excludedates.split(",")),typeof this.excludeweekdays=="string"&&(this.excludeweekdays=this.excludeweekdays.split(",")),(this.multiple||this.range)&&this.name&&!this.name.endsWith("[]")&&(this.name=this.name+"[]"),this.calendarOpen&&(await C(20),this.handleCalendarPosition())}disconnectedCallback(){super.disconnectedCallback(),document&&document.body.removeEventListener("click",e=>{var t,i;(t=this.inputRef)!=null&&t.value&&((i=this.btnRef)!=null&&i.value)&&!this.inputRef.value.contains(e.target)&&!this.btnRef.value.contains(e.target)&&this.hideCalendar()})}attributeChangedCallback(e,t,i){e==="value"&&this.valueChanged(this.value,t),e==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=(i==null?void 0:i.split(","))??[]),e==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=(i==null?void 0:i.split(","))??[]),super.attributeChangedCallback(e,t,i)}firstUpdated(e){super.firstUpdated(e)}updated(e){if(super.updated(e),e.has("value")){if(this.range&&this._value.length===1)return;this.valueChanged(this.value,e.get("value"))}}renderInput(){return s.x`
5
+ */const R=(o,e,t)=>{const i=new Map;for(let a=e;a<=t;a++)i.set(o[a],a);return i},P=b.e(class extends b.i{constructor(o){if(super(o),o.type!==b.t$1.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);const a=[],n=[];let l=0;for(const c of o)a[l]=i?i(c,l):l,n[l]=t(c,l),l++;return{values:n,keys:a}}render(o,e,t){return this.dt(o,e,t).values}update(o,[e,t,i]){const a=r.p(o),{values:n,keys:l}=this.dt(e,t,i);if(!Array.isArray(a))return this.ut=l,n;const c=this.ut??(this.ut=[]),g=[];let $,w,u=0,h=a.length-1,d=0,f=n.length-1;for(;u<=h&&d<=f;)if(a[u]===null)u++;else if(a[h]===null)h--;else if(c[u]===l[d])g[d]=r.v(a[u],n[d]),u++,d++;else if(c[h]===l[f])g[f]=r.v(a[h],n[f]),h--,f--;else if(c[u]===l[f])g[f]=r.v(a[u],n[f]),r.r(o,g[f+1],a[u]),u++,f--;else if(c[h]===l[d])g[d]=r.v(a[h],n[d]),r.r(o,a[u],a[h]),h--,d++;else if($===void 0&&($=R(l,d,f),w=R(c,u,h)),$.has(c[u]))if($.has(c[h])){const v=w.get(l[d]),x=v!==void 0?a[v]:null;if(x===null){const D=r.r(o,a[u]);r.v(D,n[d]),g[d]=D}else g[d]=r.v(x,n[d]),r.r(o,a[u],x),a[v]=null;d++}else r.M(a[h]),h--;else r.M(a[u]),u++;for(;d<=f;){const v=r.r(o,g[f+1]);r.v(v,n[d]),g[d++]=v}for(;u<=h;){const v=a[u++];v!==null&&r.M(v)}return this.ut=l,r.m(o,g),s.T}}),S="pkt-datepicker",I=!0,_={name:{type:"string",name:"Navn",description:"Navn som sendes brukes i skjema ved innsending"},label:{type:"string",name:"Etikett",description:"Tekst som vises over datovelgeren"},helptext:{type:"string",name:"Hjelpetekst",description:"Hjelpetekst som vises over datovelgeren"},helptextDropdown:{type:"string",name:"Utvidet hjelpetekst",description:"Hjelpetekst som vises i en lukket boks man kan åpne"},helptextDropdownButton:{type:"string",name:"Knappetekst for hjelpetekst",description:"Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst",default:"Les mer"},dateformat:{name:"Datoformat",description:"Datoformat for valgte datoer i flervalgsmodus",type:"string",default:"dd.MM.yyyy"},currentmonth:{name:"Nåværende måned",type:"ISOdatestring",description:"Måneden som skal vises i datovelgeren"},value:{name:"Verdi",type:"ISOdatestring",variant:"multiple",reflect:!0,description:"Kommaseparert liste av valgte datoer"},excludeweekdays:{name:"Utelat ukedager",type:"string",description:"Kommaseparert liste over ukedager (1-7) som skal ekskluderes"},excludedates:{name:"Utelat datoer",type:"ISOdatestring",variant:"multiple",description:"Kommaseparert liste over datoer som skal ekskluderes"},min:{name:"Tidligst tillatt",type:"ISOdatestring",default:null,description:"Første tillate dato i datovelgeren"},max:{name:"Senest tillatt",type:"ISOdatestring",default:null,description:"Siste tillate dato i datovelgeren"},weeknumbers:{name:"Vis ukenummer",type:"boolean",reflect:!0,default:!1,description:"Vis ukedager i datovelgerens kalender"},withcontrols:{name:"Med kontroller",type:"boolean",reflect:!0,default:!1,description:"Vis avanserte velgere for måned og år"},multiple:{name:"Flervalg",type:"boolean",reflect:!0,default:!1,description:"Tillat valg av flere enn én dato i samme velger"},maxlength:{name:"Maks antall",description:"Maks valgte datoer i flervalgsmodus",type:"number",default:4},range:{name:"Datotidsrom",type:"boolean",reflect:!0,default:!1,description:"Tillat å velge et tidsrom mellom to datoer i samme velger"},hasError:{type:"boolean",name:"Feil",description:"Viser feiltilstand for datovelgeren"},errorMessage:{type:"string",name:"Feilmelding",description:"Tekst som vises under datovelgeren ved feiltilstand"},disabled:{type:"boolean",name:"Deaktivert",default:!1,reflect:!0,description:"Er datovelgeren deaktivert?"},fullwidth:{type:"boolean",name:"Full bredde",default:!1,reflect:!0,description:"Skal datovelgeren ta opp hele bredden?"},required:{type:"boolean",name:"Påkrevd",default:!1,reflect:!0,description:"Er datovelgeren påkrevd?"},requiredTag:{type:"boolean",name:"Vise påkrevd-merking",default:!1,description:"Viser en merking som indikerer at datovelgeren er påkrevd"},requiredText:{type:"string",name:"Påkrevd-tekst",default:"Må fylles ut",description:"Tekst som vises i påkrevd-merkingen"},optionalTag:{type:"boolean",name:"Vise valgfritt-merking",default:!1,description:"Viser en merking som indikerer at datovelgeren er valgfri"},optionalText:{type:"string",name:"Valgfritt-tekst",default:"Valgfritt",description:"Tekst som vises i valgfritt-merkingen"},useWrapper:{type:"boolean",name:"Bruk wrapper",description:"Indikerer at feltet skal ha synlig label og hjelpetekst",default:!0},id:{type:"string",name:"ID",description:"Unik identifikasjon for datovelgeren"}},O={change:{type:"Event",description:"Returnerer valgt dato som streng i ISO-format"},"value-change":{type:"CustomEvent",description:"Returnerer en <code>array</code> med valgte datoer i ISO-format"},toggleHelpText:{type:"CustomEvent",description:"Returnerer <code>event.detail { isOpen: true }</code> eller <code>event.detail { isOpen: false }</code> når hjelpeteksten åpnes eller lukkes"}},k={name:S,"css-class":"pkt-datepicker",isElement:I,props:_,events:O};var E=Object.defineProperty,M=Object.getOwnPropertyDescriptor,p=(o,e,t,i)=>{for(var a=i>1?void 0:i?M(e,t):e,n=o.length-1,l;n>=0;n--)(l=o[n])&&(a=(i?l(e,t,a):l(a))||a);return i&&a&&E(e,t,a),a};const C=o=>new Promise(e=>setTimeout(e,o));exports.PktDatepicker=class extends s.PktInputElement{constructor(){super(...arguments),this.value="",this._value=this.value?Array.isArray(this.value)?this.value:this.value.split(","):[],this.label="Datovelger",this.dateformat=k.props.dateformat.default,this.multiple=k.props.multiple.default,this.maxlength=k.props.maxlength.default,this.range=k.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=k.props.weeknumbers.default,this.withcontrols=k.props.withcontrols.default,this.fullwidth=!1,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.useWrapper=!0,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=r.e(),this.inputRefTo=r.e(),this.btnRef=r.e(),this.calRef=r.e(),this.popupRef=r.e(),this.addToSelected=e=>{const t=e.target;if(!t.value)return;const i=this.min?m.newDate(this.min):null,a=this.max?m.newDate(this.max):null,n=m.newDate(t.value.split(",")[0]);n&&!isNaN(n.getTime())&&(!i||n>=i)&&(!a||n<=a)&&this.calRef.value&&this.calRef.value.handleDateSelect(n),t.value=""}}async connectedCallback(){super.connectedCallback(),this.isMobileSafari=/iP(ad|od|hone)/i.test(window.navigator.userAgent)&&!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/),this.inputType=this.isMobileSafari?"text":"date",document&&document.body.addEventListener("click",e=>{var t,i;(t=this.inputRef)!=null&&t.value&&((i=this.btnRef)!=null&&i.value)&&!this.inputRef.value.contains(e.target)&&!(this.inputRefTo.value&&this.inputRefTo.value.contains(e.target))&&!this.btnRef.value.contains(e.target)&&!e.target.closest(".pkt-calendar-popup")&&this.calendarOpen&&(this.onBlur(),this.hideCalendar())}),this.value.length&&this._value.length===0&&(this._value=Array.isArray(this.value)?this.value:this.value.split(",")),this.min=this.min||k.props.min.default,this.max=this.max||k.props.max.default,typeof this.excludedates=="string"&&(this.excludedates=this.excludedates.split(",")),typeof this.excludeweekdays=="string"&&(this.excludeweekdays=this.excludeweekdays.split(",")),(this.multiple||this.range)&&this.name&&!this.name.endsWith("[]")&&(this.name=this.name+"[]"),this.calendarOpen&&(await C(20),this.handleCalendarPosition())}disconnectedCallback(){super.disconnectedCallback(),document&&document.body.removeEventListener("click",e=>{var t,i;(t=this.inputRef)!=null&&t.value&&((i=this.btnRef)!=null&&i.value)&&!this.inputRef.value.contains(e.target)&&!this.btnRef.value.contains(e.target)&&this.hideCalendar()})}attributeChangedCallback(e,t,i){if(e==="value"){if(this.range&&(i==null?void 0:i.split(",").length)===1)return;this.value!==t&&this.valueChanged(i,t)}e==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=(i==null?void 0:i.split(","))??[]),e==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=(i==null?void 0:i.split(","))??[]),super.attributeChangedCallback(e,t,i)}firstUpdated(e){super.firstUpdated(e)}updated(e){if(super.updated(e),e.has("value")){if((this.range||this.multiple)&&typeof this.value=="string"&&(this.value=this.value.split(",")),this.range&&this.value.length===1)return;this.valueChanged(this.value,e.get("value"))}}renderInput(){return s.x`
6
6
  <input
7
7
  class="${y.e(this.inputClasses)}"
8
8
  .type=${this.inputType}
@@ -58,7 +58,7 @@
58
58
  @change=${t=>{t.stopImmediatePropagation()}}
59
59
  ${r.n(this.inputRefTo)}
60
60
  />
61
- `}renderMultipleInput(){return console.log("renderMultipleInput",this.inputClasses,this.multiple),s.x`
61
+ `}renderMultipleInput(){return s.x`
62
62
  <input
63
63
  class=${y.e(this.inputClasses)}
64
64
  .type=${this.inputType}
@@ -82,7 +82,7 @@
82
82
  closeTag
83
83
  ariaLabel="${this.strings.calendar.deleteDate} ${m.fromISOtoLocal(e,this.dateformat)}"
84
84
  @close=${()=>{var t;return(t=this.calRef.value)==null?void 0:t.handleDateSelect(m.fromISOToDate(e))}}
85
- >${m.fromISOtoLocal(e,this.dateformat)}</pkt-tag
85
+ ><time datetime="${e}">${m.fromISOtoLocal(e,this.dateformat)}</time></pkt-tag
86
86
  >
87
87
  `):s.E}
88
88
  </div>
@@ -1,9 +1,9 @@
1
- import { T as A, r as P, a as L, x as v, E as b, n as d } from "./index-BQ9BMXel.js";
1
+ import { T as A, r as P, a as L, x as v, E as b, n as u } from "./index-BQ9BMXel.js";
2
2
  import { e as j, i as F, a as q, t as H } from "./custom-element-CWfU4dcr.js";
3
- import { p as U, v as y, r as w, M as _, m as N, e as R, n as $ } from "./ref-BjO0bKwt.js";
3
+ import { p as U, v as y, r as w, M as D, m as N, e as R, n as $ } from "./ref-BjO0bKwt.js";
4
4
  import { e as x } from "./class-map-BQ3-MseA.js";
5
5
  import { a as V } from "./converters-DNCwIFwr.js";
6
- import { n as T, f as D, a as W, b as M } from "./index-BR7EVgX9.js";
6
+ import { n as T, f as _, a as W, b as M } from "./index-BR7EVgX9.js";
7
7
  import "./pkt-input-wrapper.js";
8
8
  import "./index-BfUPq43a.js";
9
9
  import "./pkt-tag.js";
@@ -12,52 +12,52 @@ import "./pkt-tag.js";
12
12
  * Copyright 2017 Google LLC
13
13
  * SPDX-License-Identifier: BSD-3-Clause
14
14
  */
15
- const E = (e, t, s) => {
15
+ const E = (e, t, i) => {
16
16
  const a = /* @__PURE__ */ new Map();
17
- for (let i = t; i <= s; i++) a.set(e[i], i);
17
+ for (let s = t; s <= i; s++) a.set(e[s], s);
18
18
  return a;
19
19
  }, K = j(class extends F {
20
20
  constructor(e) {
21
21
  if (super(e), e.type !== q.CHILD) throw Error("repeat() can only be used in text expressions");
22
22
  }
23
- dt(e, t, s) {
23
+ dt(e, t, i) {
24
24
  let a;
25
- s === void 0 ? s = t : t !== void 0 && (a = t);
26
- const i = [], r = [];
25
+ i === void 0 ? i = t : t !== void 0 && (a = t);
26
+ const s = [], r = [];
27
27
  let n = 0;
28
- for (const f of e) i[n] = a ? a(f, n) : n, r[n] = s(f, n), n++;
29
- return { values: r, keys: i };
28
+ for (const f of e) s[n] = a ? a(f, n) : n, r[n] = i(f, n), n++;
29
+ return { values: r, keys: s };
30
30
  }
31
- render(e, t, s) {
32
- return this.dt(e, t, s).values;
31
+ render(e, t, i) {
32
+ return this.dt(e, t, i).values;
33
33
  }
34
- update(e, [t, s, a]) {
35
- const i = U(e), { values: r, keys: n } = this.dt(t, s, a);
36
- if (!Array.isArray(i)) return this.ut = n, r;
34
+ update(e, [t, i, a]) {
35
+ const s = U(e), { values: r, keys: n } = this.dt(t, i, a);
36
+ if (!Array.isArray(s)) return this.ut = n, r;
37
37
  const f = this.ut ?? (this.ut = []), m = [];
38
- let C, I, p = 0, h = i.length - 1, u = 0, c = r.length - 1;
39
- for (; p <= h && u <= c; ) if (i[p] === null) p++;
40
- else if (i[h] === null) h--;
41
- else if (f[p] === n[u]) m[u] = y(i[p], r[u]), p++, u++;
42
- else if (f[h] === n[c]) m[c] = y(i[h], r[c]), h--, c--;
43
- else if (f[p] === n[c]) m[c] = y(i[p], r[c]), w(e, m[c + 1], i[p]), p++, c--;
44
- else if (f[h] === n[u]) m[u] = y(i[h], r[u]), w(e, i[p], i[h]), h--, u++;
45
- else if (C === void 0 && (C = E(n, u, c), I = E(f, p, h)), C.has(f[p])) if (C.has(f[h])) {
46
- const g = I.get(n[u]), S = g !== void 0 ? i[g] : null;
38
+ let C, I, p = 0, h = s.length - 1, d = 0, c = r.length - 1;
39
+ for (; p <= h && d <= c; ) if (s[p] === null) p++;
40
+ else if (s[h] === null) h--;
41
+ else if (f[p] === n[d]) m[d] = y(s[p], r[d]), p++, d++;
42
+ else if (f[h] === n[c]) m[c] = y(s[h], r[c]), h--, c--;
43
+ else if (f[p] === n[c]) m[c] = y(s[p], r[c]), w(e, m[c + 1], s[p]), p++, c--;
44
+ else if (f[h] === n[d]) m[d] = y(s[h], r[d]), w(e, s[p], s[h]), h--, d++;
45
+ else if (C === void 0 && (C = E(n, d, c), I = E(f, p, h)), C.has(f[p])) if (C.has(f[h])) {
46
+ const g = I.get(n[d]), S = g !== void 0 ? s[g] : null;
47
47
  if (S === null) {
48
- const O = w(e, i[p]);
49
- y(O, r[u]), m[u] = O;
50
- } else m[u] = y(S, r[u]), w(e, i[p], S), i[g] = null;
51
- u++;
52
- } else _(i[h]), h--;
53
- else _(i[p]), p++;
54
- for (; u <= c; ) {
48
+ const O = w(e, s[p]);
49
+ y(O, r[d]), m[d] = O;
50
+ } else m[d] = y(S, r[d]), w(e, s[p], S), s[g] = null;
51
+ d++;
52
+ } else D(s[h]), h--;
53
+ else D(s[p]), p++;
54
+ for (; d <= c; ) {
55
55
  const g = w(e, m[c + 1]);
56
- y(g, r[u]), m[u++] = g;
56
+ y(g, r[d]), m[d++] = g;
57
57
  }
58
58
  for (; p <= h; ) {
59
- const g = i[p++];
60
- g !== null && _(g);
59
+ const g = s[p++];
60
+ g !== null && D(g);
61
61
  }
62
62
  return this.ut = n, N(e, m), A;
63
63
  }
@@ -249,10 +249,10 @@ const E = (e, t, s) => {
249
249
  props: J,
250
250
  events: Q
251
251
  };
252
- var X = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, o = (e, t, s, a) => {
253
- for (var i = a > 1 ? void 0 : a ? Y(t, s) : t, r = e.length - 1, n; r >= 0; r--)
254
- (n = e[r]) && (i = (a ? n(t, s, i) : n(i)) || i);
255
- return a && i && X(t, s, i), i;
252
+ var X = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, o = (e, t, i, a) => {
253
+ for (var s = a > 1 ? void 0 : a ? Y(t, i) : t, r = e.length - 1, n; r >= 0; r--)
254
+ (n = e[r]) && (s = (a ? n(t, i, s) : n(s)) || s);
255
+ return a && s && X(t, i, s), s;
256
256
  };
257
257
  const B = (e) => new Promise((t) => setTimeout(t, e));
258
258
  let l = class extends L {
@@ -260,8 +260,8 @@ let l = class extends L {
260
260
  super(...arguments), this.value = "", this._value = this.value ? Array.isArray(this.value) ? this.value : this.value.split(",") : [], this.label = "Datovelger", this.dateformat = k.props.dateformat.default, this.multiple = k.props.multiple.default, this.maxlength = k.props.maxlength.default, this.range = k.props.range.default, this.showRangeLabels = !1, this.min = null, this.max = null, this.weeknumbers = k.props.weeknumbers.default, this.withcontrols = k.props.withcontrols.default, this.fullwidth = !1, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.useWrapper = !0, this.calendarOpen = !1, this.timezone = "Europe/Oslo", this.inputClasses = {}, this.buttonClasses = {}, this.inputRef = R(), this.inputRefTo = R(), this.btnRef = R(), this.calRef = R(), this.popupRef = R(), this.addToSelected = (e) => {
261
261
  const t = e.target;
262
262
  if (!t.value) return;
263
- const s = this.min ? T(this.min) : null, a = this.max ? T(this.max) : null, i = T(t.value.split(",")[0]);
264
- i && !isNaN(i.getTime()) && (!s || i >= s) && (!a || i <= a) && this.calRef.value && this.calRef.value.handleDateSelect(i), t.value = "";
263
+ const i = this.min ? T(this.min) : null, a = this.max ? T(this.max) : null, s = T(t.value.split(",")[0]);
264
+ s && !isNaN(s.getTime()) && (!i || s >= i) && (!a || s <= a) && this.calRef.value && this.calRef.value.handleDateSelect(s), t.value = "";
265
265
  };
266
266
  }
267
267
  /**
@@ -269,25 +269,29 @@ let l = class extends L {
269
269
  */
270
270
  async connectedCallback() {
271
271
  super.connectedCallback(), this.isMobileSafari = /iP(ad|od|hone)/i.test(window.navigator.userAgent) && !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/), this.inputType = this.isMobileSafari ? "text" : "date", document && document.body.addEventListener("click", (e) => {
272
- var t, s;
273
- (t = this.inputRef) != null && t.value && ((s = this.btnRef) != null && s.value) && !this.inputRef.value.contains(e.target) && !(this.inputRefTo.value && this.inputRefTo.value.contains(e.target)) && !this.btnRef.value.contains(e.target) && !e.target.closest(".pkt-calendar-popup") && this.calendarOpen && (this.onBlur(), this.hideCalendar());
272
+ var t, i;
273
+ (t = this.inputRef) != null && t.value && ((i = this.btnRef) != null && i.value) && !this.inputRef.value.contains(e.target) && !(this.inputRefTo.value && this.inputRefTo.value.contains(e.target)) && !this.btnRef.value.contains(e.target) && !e.target.closest(".pkt-calendar-popup") && this.calendarOpen && (this.onBlur(), this.hideCalendar());
274
274
  }), this.value.length && this._value.length === 0 && (this._value = Array.isArray(this.value) ? this.value : this.value.split(",")), this.min = this.min || k.props.min.default, this.max = this.max || k.props.max.default, typeof this.excludedates == "string" && (this.excludedates = this.excludedates.split(",")), typeof this.excludeweekdays == "string" && (this.excludeweekdays = this.excludeweekdays.split(",")), (this.multiple || this.range) && this.name && !this.name.endsWith("[]") && (this.name = this.name + "[]"), this.calendarOpen && (await B(20), this.handleCalendarPosition());
275
275
  }
276
276
  disconnectedCallback() {
277
277
  super.disconnectedCallback(), document && document.body.removeEventListener("click", (e) => {
278
- var t, s;
279
- (t = this.inputRef) != null && t.value && ((s = this.btnRef) != null && s.value) && !this.inputRef.value.contains(e.target) && !this.btnRef.value.contains(e.target) && this.hideCalendar();
278
+ var t, i;
279
+ (t = this.inputRef) != null && t.value && ((i = this.btnRef) != null && i.value) && !this.inputRef.value.contains(e.target) && !this.btnRef.value.contains(e.target) && this.hideCalendar();
280
280
  });
281
281
  }
282
- attributeChangedCallback(e, t, s) {
283
- e === "value" && this.valueChanged(this.value, t), e === "excludedates" && typeof this.excludedates == "string" && (this.excludedates = (s == null ? void 0 : s.split(",")) ?? []), e === "excludeweekdays" && typeof this.excludeweekdays == "string" && (this.excludeweekdays = (s == null ? void 0 : s.split(",")) ?? []), super.attributeChangedCallback(e, t, s);
282
+ attributeChangedCallback(e, t, i) {
283
+ if (e === "value") {
284
+ if (this.range && (i == null ? void 0 : i.split(",").length) === 1) return;
285
+ this.value !== t && this.valueChanged(i, t);
286
+ }
287
+ e === "excludedates" && typeof this.excludedates == "string" && (this.excludedates = (i == null ? void 0 : i.split(",")) ?? []), e === "excludeweekdays" && typeof this.excludeweekdays == "string" && (this.excludeweekdays = (i == null ? void 0 : i.split(",")) ?? []), super.attributeChangedCallback(e, t, i);
284
288
  }
285
289
  firstUpdated(e) {
286
290
  super.firstUpdated(e);
287
291
  }
288
292
  updated(e) {
289
293
  if (super.updated(e), e.has("value")) {
290
- if (this.range && this._value.length === 1) return;
294
+ if ((this.range || this.multiple) && typeof this.value == "string" && (this.value = this.value.split(",")), this.range && this.value.length === 1) return;
291
295
  this.valueChanged(this.value, e.get("value"));
292
296
  }
293
297
  }
@@ -347,8 +351,8 @@ let l = class extends L {
347
351
  }}
348
352
  ?disabled=${this.disabled}
349
353
  @keydown=${(t) => {
350
- var s;
351
- (t.key === "," || t.key === "Enter") && ((s = this.inputRef.value) == null || s.blur()), (t.key === "Space" || t.key === " ") && (t.preventDefault(), this.toggleCalendar(t));
354
+ var i;
355
+ (t.key === "," || t.key === "Enter") && ((i = this.inputRef.value) == null || i.blur()), (t.key === "Space" || t.key === " ") && (t.preventDefault(), this.toggleCalendar(t));
352
356
  }}
353
357
  @input=${(t) => {
354
358
  this.onInput(), t.stopImmediatePropagation();
@@ -357,11 +361,11 @@ let l = class extends L {
357
361
  this.onFocus(), this.isMobileSafari && this.showCalendar();
358
362
  }}
359
363
  @blur=${(t) => {
360
- var s, a;
364
+ var i, a;
361
365
  if (t.target.value) {
362
366
  this.manageValidity(t.target);
363
- const i = D(t.target.value);
364
- i && this._value[0] !== t.target.value && this._value[1] && (this.clearInputValue(), (a = (s = this.calRef) == null ? void 0 : s.value) == null || a.handleDateSelect(i));
367
+ const s = _(t.target.value);
368
+ s && this._value[0] !== t.target.value && this._value[1] && (this.clearInputValue(), (a = (i = this.calRef) == null ? void 0 : i.value) == null || a.handleDateSelect(s));
365
369
  } else this._value[0] && this.clearInputValue();
366
370
  }}
367
371
  @change=${(t) => {
@@ -386,8 +390,8 @@ let l = class extends L {
386
390
  }}
387
391
  ?disabled=${this.disabled}
388
392
  @keydown=${(t) => {
389
- var s;
390
- (t.key === "," || t.key === "Enter") && ((s = this.inputRefTo.value) == null || s.blur()), (t.key === "Space" || t.key === " ") && (t.preventDefault(), this.toggleCalendar(t));
393
+ var i;
394
+ (t.key === "," || t.key === "Enter") && ((i = this.inputRefTo.value) == null || i.blur()), (t.key === "Space" || t.key === " ") && (t.preventDefault(), this.toggleCalendar(t));
391
395
  }}
392
396
  @input=${(t) => {
393
397
  this.onInput(), t.stopImmediatePropagation();
@@ -396,8 +400,8 @@ let l = class extends L {
396
400
  this.onFocus(), this.isMobileSafari && this.showCalendar();
397
401
  }}
398
402
  @blur=${(t) => {
399
- var s, a, i;
400
- if ((s = this.calRef.value) != null && s.contains(t.relatedTarget) || this.onBlur(), t.target.value) {
403
+ var i, a, s;
404
+ if ((i = this.calRef.value) != null && i.contains(t.relatedTarget) || this.onBlur(), t.target.value) {
401
405
  this.manageValidity(t.target);
402
406
  const r = t.target.value;
403
407
  this.min && this.min > r ? this.internals.setValidity(
@@ -409,8 +413,8 @@ let l = class extends L {
409
413
  this.strings.forms.messages.rangeOverflow,
410
414
  t.target
411
415
  );
412
- const n = D(t.target.value);
413
- n && this._value[1] !== W(n) && ((i = (a = this.calRef) == null ? void 0 : a.value) == null || i.handleDateSelect(n));
416
+ const n = _(t.target.value);
417
+ n && this._value[1] !== W(n) && ((s = (a = this.calRef) == null ? void 0 : a.value) == null || s.handleDateSelect(n));
414
418
  }
415
419
  }}
416
420
  @change=${(t) => {
@@ -421,7 +425,7 @@ let l = class extends L {
421
425
  `;
422
426
  }
423
427
  renderMultipleInput() {
424
- return console.log("renderMultipleInput", this.inputClasses, this.multiple), v`
428
+ return v`
425
429
  <input
426
430
  class=${x(this.inputClasses)}
427
431
  .type=${this.inputType}
@@ -468,9 +472,9 @@ let l = class extends L {
468
472
  )}"
469
473
  @close=${() => {
470
474
  var t;
471
- return (t = this.calRef.value) == null ? void 0 : t.handleDateSelect(D(e));
475
+ return (t = this.calRef.value) == null ? void 0 : t.handleDateSelect(_(e));
472
476
  }}
473
- >${M(e, this.dateformat)}</pkt-tag
477
+ ><time datetime="${e}">${M(e, this.dateformat)}</time></pkt-tag
474
478
  >
475
479
  `
476
480
  ) : b}
@@ -571,9 +575,9 @@ let l = class extends L {
571
575
  handleCalendarPosition() {
572
576
  var e;
573
577
  if (this.popupRef.value && this.inputRef.value) {
574
- const t = this.multiple && !!this.maxlength, s = ((e = this.inputRef.value.parentElement) == null ? void 0 : e.getBoundingClientRect()) || this.inputRef.value.getBoundingClientRect(), a = t ? s.height + 30 : s.height, i = this.popupRef.value.getBoundingClientRect().height;
578
+ const t = this.multiple && !!this.maxlength, i = ((e = this.inputRef.value.parentElement) == null ? void 0 : e.getBoundingClientRect()) || this.inputRef.value.getBoundingClientRect(), a = t ? i.height + 30 : i.height, s = this.popupRef.value.getBoundingClientRect().height;
575
579
  let r = t ? "calc(100% - 30px)" : "100%";
576
- s && s.top + i > window.innerHeight && s.top - i > 0 && (r = `calc(100% - ${a}px - ${i}px)`), this.popupRef.value.style.top = r;
580
+ i && i.top + s > window.innerHeight && i.top - s > 0 && (r = `calc(100% - ${a}px - ${s}px)`), this.popupRef.value.style.top = r;
577
581
  }
578
582
  }
579
583
  handleFocusOut(e) {
@@ -591,61 +595,61 @@ let l = class extends L {
591
595
  }
592
596
  };
593
597
  o([
594
- d({ type: String, reflect: !0 })
598
+ u({ type: String, reflect: !0 })
595
599
  ], l.prototype, "value", 2);
596
600
  o([
597
- d({ type: Array })
601
+ u({ type: Array })
598
602
  ], l.prototype, "_value", 2);
599
603
  o([
600
- d({ type: String })
604
+ u({ type: String })
601
605
  ], l.prototype, "label", 2);
602
606
  o([
603
- d({ type: String })
607
+ u({ type: String })
604
608
  ], l.prototype, "dateformat", 2);
605
609
  o([
606
- d({ type: Boolean, reflect: !0 })
610
+ u({ type: Boolean, reflect: !0 })
607
611
  ], l.prototype, "multiple", 2);
608
612
  o([
609
- d({ type: Number })
613
+ u({ type: Number })
610
614
  ], l.prototype, "maxlength", 2);
611
615
  o([
612
- d({ type: Boolean, reflect: !0 })
616
+ u({ type: Boolean, reflect: !0 })
613
617
  ], l.prototype, "range", 2);
614
618
  o([
615
- d({ type: Boolean })
619
+ u({ type: Boolean })
616
620
  ], l.prototype, "showRangeLabels", 2);
617
621
  o([
618
- d({ type: String })
622
+ u({ type: String })
619
623
  ], l.prototype, "min", 2);
620
624
  o([
621
- d({ type: String })
625
+ u({ type: String })
622
626
  ], l.prototype, "max", 2);
623
627
  o([
624
- d({ type: Boolean })
628
+ u({ type: Boolean })
625
629
  ], l.prototype, "weeknumbers", 2);
626
630
  o([
627
- d({ type: Boolean })
631
+ u({ type: Boolean })
628
632
  ], l.prototype, "withcontrols", 2);
629
633
  o([
630
- d({ type: Boolean })
634
+ u({ type: Boolean })
631
635
  ], l.prototype, "fullwidth", 2);
632
636
  o([
633
- d({ converter: V.csvToArray })
637
+ u({ converter: V.csvToArray })
634
638
  ], l.prototype, "excludedates", 2);
635
639
  o([
636
- d({ converter: V.csvToArray })
640
+ u({ converter: V.csvToArray })
637
641
  ], l.prototype, "excludeweekdays", 2);
638
642
  o([
639
- d({ type: String })
643
+ u({ type: String })
640
644
  ], l.prototype, "currentmonth", 2);
641
645
  o([
642
- d({ type: Boolean })
646
+ u({ type: Boolean })
643
647
  ], l.prototype, "useWrapper", 2);
644
648
  o([
645
- d({ type: Boolean, reflect: !0 })
649
+ u({ type: Boolean, reflect: !0 })
646
650
  ], l.prototype, "calendarOpen", 2);
647
651
  o([
648
- d({ type: String })
652
+ u({ type: String })
649
653
  ], l.prototype, "timezone", 2);
650
654
  o([
651
655
  P()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "12.11.6",
3
+ "version": "12.11.7",
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",
@@ -56,5 +56,5 @@
56
56
  "url": "https://github.com/oslokommune/punkt/issues"
57
57
  },
58
58
  "license": "MIT",
59
- "gitHead": "1f2843f20720079501fe7cff70d009fdbf1b013a"
59
+ "gitHead": "9054944531153cdbd74dbd5d45b0457ae4674a3b"
60
60
  }
@@ -152,7 +152,8 @@ export class PktDatepicker extends PktInputElement {
152
152
 
153
153
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
154
154
  if (name === 'value') {
155
- this.valueChanged(this.value, _old)
155
+ if (this.range && value?.split(',').length === 1) return
156
+ if (this.value !== _old) this.valueChanged(value, _old)
156
157
  }
157
158
 
158
159
  if (name === 'excludedates' && typeof this.excludedates === 'string') {
@@ -172,7 +173,10 @@ export class PktDatepicker extends PktInputElement {
172
173
  updated(changedProperties: PropertyValues): void {
173
174
  super.updated(changedProperties)
174
175
  if (changedProperties.has('value')) {
175
- if (this.range && this._value.length === 1) return
176
+ if ((this.range || this.multiple) && typeof this.value === 'string') {
177
+ this.value = this.value.split(',')
178
+ }
179
+ if (this.range && this.value.length === 1) return
176
180
  this.valueChanged(this.value, changedProperties.get('value'))
177
181
  }
178
182
  }
@@ -371,7 +375,6 @@ export class PktDatepicker extends PktInputElement {
371
375
  }
372
376
 
373
377
  renderMultipleInput() {
374
- console.log('renderMultipleInput', this.inputClasses, this.multiple)
375
378
  return html`
376
379
  <input
377
380
  class=${classMap(this.inputClasses)}
@@ -434,7 +437,7 @@ export class PktDatepicker extends PktInputElement {
434
437
  this.dateformat,
435
438
  )}"
436
439
  @close=${() => this.calRef.value?.handleDateSelect(fromISOToDate(date))}
437
- >${fromISOtoLocal(date, this.dateformat)}</pkt-tag
440
+ ><time datetime="${date}">${fromISOtoLocal(date, this.dateformat)}</time></pkt-tag
438
441
  >
439
442
  `,
440
443
  )