@oslokommune/punkt-react 12.6.2 → 12.6.4

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 CHANGED
@@ -5,6 +5,24 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [12.6.4](https://github.com/oslokommune/punkt/compare/12.6.3...12.6.4) (2024-11-07)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+ Ingen
12
+
13
+ ### Features
14
+ Ingen
15
+
16
+ ### Bug Fixes
17
+ * Datepicker trigger mangler `type=button` (#2001 A Punkt Odyssey). Pluss tastaturnavigering i måned- og årvelger i kalenderen funket ikke. Og flere inputs manglet label.
18
+
19
+
20
+ ### Chores
21
+ Ingen
22
+
23
+ ---
24
+
25
+
8
26
  ## [12.6.2](https://github.com/oslokommune/punkt/compare/12.6.1...12.6.2) (2024-11-05)
9
27
 
10
28
  ### ⚠ BREAKING CHANGES
@@ -1334,6 +1334,8 @@ const kg = {
1334
1334
  }, wg = {
1335
1335
  buttonAltText: "Åpne kalender"
1336
1336
  }, Cg = {
1337
+ month: "Måned",
1338
+ year: "År",
1337
1339
  days: [
1338
1340
  "Mandag",
1339
1341
  "Tirsdag",
@@ -2227,19 +2229,21 @@ let xe = class extends Pt {
2227
2229
  }
2228
2230
  }
2229
2231
  handleArrowKey(t, n) {
2232
+ var r, i, o;
2233
+ if (((r = t.target) == null ? void 0 : r.nodeName) === "INPUT" || ((i = t.target) == null ? void 0 : i.nodeName) === "SELECT" || ((o = t.target) == null ? void 0 : o.nodeName) === "BUTTON") return;
2230
2234
  t.preventDefault(), this.focusedDate || this.focusOnCurrentDate();
2231
- const r = this.focusedDate ? new Date(this.focusedDate) : new Date(this.year, this.month, 1);
2232
- let i = new Date(r.setDate(r.getDate() + n));
2233
- if (i) {
2234
- let o = this.querySelector(`div[data-date="${this.formatISODate(i)}"]`);
2235
- if (o instanceof HTMLDivElement) {
2236
- if (o.dataset.disabled) {
2237
- let u = new Date(r.setDate(r.getDate() + n)), c = this.querySelector(`div[data-date="${this.formatISODate(u)}"]`);
2238
- for (; c && c instanceof HTMLDivElement && c.dataset.disabled; )
2239
- u = new Date(u.setDate(u.getDate() + n)), c = this.querySelector(`div[data-date="${this.formatISODate(u)}"]`);
2240
- o = c;
2235
+ const u = this.focusedDate ? new Date(this.focusedDate) : new Date(this.year, this.month, 1);
2236
+ let c = new Date(u.setDate(u.getDate() + n));
2237
+ if (c) {
2238
+ let d = this.querySelector(`div[data-date="${this.formatISODate(c)}"]`);
2239
+ if (d instanceof HTMLDivElement) {
2240
+ if (d.dataset.disabled) {
2241
+ let h = new Date(u.setDate(u.getDate() + n)), m = this.querySelector(`div[data-date="${this.formatISODate(h)}"]`);
2242
+ for (; m && m instanceof HTMLDivElement && m.dataset.disabled; )
2243
+ h = new Date(h.setDate(h.getDate() + n)), m = this.querySelector(`div[data-date="${this.formatISODate(h)}"]`);
2244
+ d = m;
2241
2245
  }
2242
- o instanceof HTMLDivElement && !o.dataset.disabled && (this.focusedDate = this.formatISODate(i), o.focus());
2246
+ d instanceof HTMLDivElement && !d.dataset.disabled && (this.focusedDate = this.formatISODate(c), d.focus());
2243
2247
  }
2244
2248
  }
2245
2249
  }
@@ -2257,7 +2261,8 @@ let xe = class extends Pt {
2257
2261
  >
2258
2262
  <nav class="pkt-cal-month-nav">
2259
2263
  <div>
2260
- <div
2264
+ <button
2265
+ type="button"
2261
2266
  @click=${this.isPrevMonthAllowed() && this.prevMonth}
2262
2267
  @keydown=${(t) => {
2263
2268
  (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.isNextMonthAllowed() && this.prevMonth());
@@ -2269,11 +2274,12 @@ let xe = class extends Pt {
2269
2274
  >
2270
2275
  <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
2271
2276
  <span class="pkt-btn__text">${this.prevMonthString}</span>
2272
- </div>
2277
+ </button>
2273
2278
  </div>
2274
2279
  ${this.renderMonthNav()}
2275
2280
  <div>
2276
- <div
2281
+ <button
2282
+ type="button"
2277
2283
  @click=${this.isNextMonthAllowed() && this.nextMonth}
2278
2284
  @keydown=${(t) => {
2279
2285
  (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.isNextMonthAllowed() && this.nextMonth());
@@ -2285,7 +2291,7 @@ let xe = class extends Pt {
2285
2291
  >
2286
2292
  <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
2287
2293
  <span class="pkt-btn__text">${this.nextMonthString}</span>
2288
- </div>
2294
+ </button>
2289
2295
  </div>
2290
2296
  </nav>
2291
2297
  <table
@@ -2311,8 +2317,10 @@ let xe = class extends Pt {
2311
2317
  let t = [];
2312
2318
  return this.withcontrols ? t.push(
2313
2319
  Y`<div class="pkt-cal-month-picker">
2320
+ <label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
2314
2321
  <select
2315
2322
  class="pkt-input pkt-input-compact"
2323
+ id="${this.id}-monthnav"
2316
2324
  @change=${(n) => {
2317
2325
  this.changeMonth(this.year, n.target.value);
2318
2326
  }}
@@ -2321,8 +2329,10 @@ let xe = class extends Pt {
2321
2329
  (n, r) => Y`<option value=${r} ?selected=${this.month === r}>${n}</option>`
2322
2330
  )}
2323
2331
  </select>
2332
+ <label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
2324
2333
  <input
2325
2334
  class="pkt-input pkt-cal-input-year pkt-input-compact"
2335
+ id="${this.id}-yearnav"
2326
2336
  type="number"
2327
2337
  size="4"
2328
2338
  placeholder="0000"
@@ -4835,11 +4845,12 @@ let qe = class extends Ye {
4835
4845
  }}
4836
4846
  ${st(this.inputRef)}
4837
4847
  />
4838
- <div class="pkt-input-prefix">Til</div>
4848
+ <div class="pkt-input-prefix" id="${this.id}-to-label">Til</div>
4839
4849
  <input
4840
4850
  class=${ze(this.inputClasses)}
4841
4851
  .type=${this.inputType}
4842
4852
  id="${this.id}-to"
4853
+ aria-labelledby="${this.id}-to-label"
4843
4854
  .value=${this._value[1] ?? ""}
4844
4855
  min=${this.min}
4845
4856
  max=${this.max}
@@ -4945,6 +4956,7 @@ let qe = class extends Ye {
4945
4956
  ${st(this.popupRef)}
4946
4957
  >
4947
4958
  <pkt-calendar
4959
+ id="${this.id}-calendar"
4948
4960
  ?multiple=${this.multiple}
4949
4961
  ?range=${this.range}
4950
4962
  ?weeknumbers=${this.weeknumbers}
@@ -4994,6 +5006,7 @@ let qe = class extends Ye {
4994
5006
  ${this.range ? this.renderRangeInput() : this.multiple ? this.renderMultipleInput() : this.renderInput()}
4995
5007
  <button
4996
5008
  class="${ze(this.buttonClasses)}"
5009
+ type="button"
4997
5010
  @click=${this.toggleCalendar}
4998
5011
  ?disabled=${this.disabled}
4999
5012
  ${st(this.btnRef)}
@@ -92,7 +92,7 @@ React keys must be passed directly to JSX without using spread:
92
92
  * @license
93
93
  * Copyright 2017 Google LLC
94
94
  * SPDX-License-Identifier: BSD-3-Clause
95
- */function Yt(e){return O({...e,state:!0,attribute:!1})}for(var Je=[],Zi=0;Zi<256;++Zi)Je.push((Zi+256).toString(16).slice(1));function kh(e,t=0){return(Je[e[t+0]]+Je[e[t+1]]+Je[e[t+2]]+Je[e[t+3]]+"-"+Je[e[t+4]]+Je[e[t+5]]+"-"+Je[e[t+6]]+Je[e[t+7]]+"-"+Je[e[t+8]]+Je[e[t+9]]+"-"+Je[e[t+10]]+Je[e[t+11]]+Je[e[t+12]]+Je[e[t+13]]+Je[e[t+14]]+Je[e[t+15]]).toLowerCase()}var Na,wh=new Uint8Array(16);function Ch(){if(!Na&&(Na=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Na))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Na(wh)}var _h=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Tl={randomUUID:_h};function Bl(e,t,n){if(Tl.randomUUID&&!t&&!e)return Tl.randomUUID();e=e||{};var r=e.random||(e.rng||Ch)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,kh(r)}const xh={hi:"Hei!"},Sh={buttonAltText:"Åpne kalender"},Eh={days:["Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag","Søndag"],daysShort:["Man","Tir","Ons","Tor","Fre","Lør","Søn"],months:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],monthsShort:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],week:"Uke",prevMonth:"Forrige måned",nextMonth:"Neste måned"},Fh={labels:{optional:"Valgfritt",required:"Må fylles ut"},messages:{required:"Dette feltet er påkrevd",invalid:"Ugyldig verdi",invalidPattern:"Ugyldig format",tooShort:"For kort",tooLong:"For lang",rangeUnderflow:"For lav verdi",rangeOverflow:"For høy verdi",dateUnderflow:"For tidlig dato",dateOverflow:"For sen dato"},date:{multiple:"Her kan du velge flere datoer. Trykk komma eller enter når du har skrevet inn en dato."}},Tt={example:xh,calendar:Sh,dates:Eh,forms:Fh};var Ah=Object.defineProperty,ze=(e,t,n,r)=>{for(var i=void 0,o=e.length-1,u;o>=0;o--)(u=e[o])&&(i=u(t,n,i)||i);return i&&Ah(t,n,i),i};let Bt=class extends Ir{constructor(){super(),this.strings=Tt}connectedCallback(){super.connectedCallback()}createRenderRoot(){return this}hotReplacedCallback(){this.requestUpdate()}};ze([O({type:Object})],Bt.prototype,"strings");let Ge=class extends Bt{constructor(){super(),this.id=Bl(),this.name=this.id,this.required=!1,this.disabled=!1,this.placeholder="",this.min=null,this.max=null,this.minlength=0,this.maxlength=0,this.pattern="",this.optionalTag=!1,this.optionalText=Tt.forms.labels.optional,this.requiredTag=!1,this.requiredText=Tt.forms.labels.required,this.hasError=!1,this.errorMessage="",this.touched=!1,this.internals=this.attachInternals()}static get formAssociated(){return!0}manageValidity(t){this.required&&!this.value?this.internals.setValidity({valueMissing:!0},Tt.forms.messages.required,t):t.validity.typeMismatch||t.validity.badInput?this.internals.setValidity({typeMismatch:!0},Tt.forms.messages.invalid,t):t.validity.patternMismatch?this.internals.setValidity({patternMismatch:!0},Tt.forms.messages.invalidPattern,t):t.validity.tooShort||this.minLength>0&&this.value.length<this.minLength?this.internals.setValidity({tooShort:!0},Tt.forms.messages.tooShort,t):t.validity.tooLong||this.maxLength>0&&this.value.length>this.maxLength?this.internals.setValidity({tooLong:!0},Tt.forms.messages.tooLong,t):t.validity.rangeUnderflow?this.internals.setValidity({rangeUnderflow:!0},Tt.forms.messages.rangeUnderflow,t):t.validity.rangeOverflow?this.internals.setValidity({rangeOverflow:!0},Tt.forms.messages.rangeOverflow,t):t.validity.customError?this.internals.setValidity({customError:!0},t.validationMessage,t):this.internals.setValidity({})}setFormValue(t){if(this.internals)if(Array.isArray(t)){const n=new FormData;t.forEach(r=>{n.append(this.name,r)}),this.internals.setFormValue(n)}else this.internals.setFormValue(t)}valueChanged(t,n){typeof t=="string"?((this.multiple||this.range)&&t.includes(",")&&(t=t.split(",")),this.value=t,this._value=Array.isArray(t)?t:[t]):Array.isArray(t)?(this.value=t,this._value=t):(this.value="",this._value=[]),(!this.value||this.value.length===0)&&n&&n.length!==0?this.clearInputValue():this.value&&this.value.toString()!==(n==null?void 0:n.toString())&&this.onChange(this.value),this.updateComplete.then(()=>this.requestUpdate())}clearInputValue(){const t=this.multiple||this.range?[]:"";this.value=t,this.internals.setFormValue(t),this.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("value-change",{detail:t,bubbles:!0,composed:!0}))}onFocus(){this.dispatchEvent(new FocusEvent("focus"))}onBlur(){this.dispatchEvent(new FocusEvent("blur"))}onInput(){this.dispatchEvent(new InputEvent("input"))}onChange(t){if(!this.touched){this.touched=!0,t&&this.setFormValue(t);return}typeof t!="string"&&!Array.isArray(t)||((this.range||this.multiple)&&!Array.isArray(t)&&t.includes(",")&&(t=t.split(",")),!this.multiple&&!this.range&&Array.isArray(t)&&(t=t[0]),this.setFormValue(t),this.manageValidity(this.inputRef.value),this.inputRef2&&this.manageValidity(this.inputRef2.value),this.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("value-change",{detail:t,bubbles:!0,composed:!0})),this.internals.reportValidity())}firstUpdated(t){super.firstUpdated(t),this.required&&(this.internals.ariaRequired=!0),this.disabled&&(this.internals.disabled=!0,this.internals.ariaDisabled=!0),this.internals.setFormValue(this.value),this.manageValidity(this.inputRef.value)}};ze([O({type:String,reflect:!0})],Ge.prototype,"id"),ze([O({type:String,reflect:!0})],Ge.prototype,"name"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"required"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"disabled"),ze([O({type:String,reflect:!0})],Ge.prototype,"placeholder"),ze([O({type:Number,reflect:!0})],Ge.prototype,"min"),ze([O({type:Number,reflect:!0})],Ge.prototype,"max"),ze([O({type:Number,reflect:!0})],Ge.prototype,"minlength"),ze([O({type:Number,reflect:!0})],Ge.prototype,"maxlength"),ze([O({type:String,reflect:!0})],Ge.prototype,"pattern"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"optionalTag"),ze([O({type:String,reflect:!0})],Ge.prototype,"optionalText"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"requiredTag"),ze([O({type:String,reflect:!0})],Ge.prototype,"requiredText"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"hasError"),ze([O({type:String,reflect:!0})],Ge.prototype,"errorMessage"),ze([Yt()],Ge.prototype,"touched");/**
95
+ */function Yt(e){return O({...e,state:!0,attribute:!1})}for(var Je=[],Zi=0;Zi<256;++Zi)Je.push((Zi+256).toString(16).slice(1));function kh(e,t=0){return(Je[e[t+0]]+Je[e[t+1]]+Je[e[t+2]]+Je[e[t+3]]+"-"+Je[e[t+4]]+Je[e[t+5]]+"-"+Je[e[t+6]]+Je[e[t+7]]+"-"+Je[e[t+8]]+Je[e[t+9]]+"-"+Je[e[t+10]]+Je[e[t+11]]+Je[e[t+12]]+Je[e[t+13]]+Je[e[t+14]]+Je[e[t+15]]).toLowerCase()}var Na,wh=new Uint8Array(16);function Ch(){if(!Na&&(Na=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Na))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Na(wh)}var _h=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Tl={randomUUID:_h};function Bl(e,t,n){if(Tl.randomUUID&&!t&&!e)return Tl.randomUUID();e=e||{};var r=e.random||(e.rng||Ch)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,kh(r)}const xh={hi:"Hei!"},Sh={buttonAltText:"Åpne kalender"},Eh={month:"Måned",year:"År",days:["Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag","Søndag"],daysShort:["Man","Tir","Ons","Tor","Fre","Lør","Søn"],months:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],monthsShort:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],week:"Uke",prevMonth:"Forrige måned",nextMonth:"Neste måned"},Fh={labels:{optional:"Valgfritt",required:"Må fylles ut"},messages:{required:"Dette feltet er påkrevd",invalid:"Ugyldig verdi",invalidPattern:"Ugyldig format",tooShort:"For kort",tooLong:"For lang",rangeUnderflow:"For lav verdi",rangeOverflow:"For høy verdi",dateUnderflow:"For tidlig dato",dateOverflow:"For sen dato"},date:{multiple:"Her kan du velge flere datoer. Trykk komma eller enter når du har skrevet inn en dato."}},Tt={example:xh,calendar:Sh,dates:Eh,forms:Fh};var Ah=Object.defineProperty,ze=(e,t,n,r)=>{for(var i=void 0,o=e.length-1,u;o>=0;o--)(u=e[o])&&(i=u(t,n,i)||i);return i&&Ah(t,n,i),i};let Bt=class extends Ir{constructor(){super(),this.strings=Tt}connectedCallback(){super.connectedCallback()}createRenderRoot(){return this}hotReplacedCallback(){this.requestUpdate()}};ze([O({type:Object})],Bt.prototype,"strings");let Ge=class extends Bt{constructor(){super(),this.id=Bl(),this.name=this.id,this.required=!1,this.disabled=!1,this.placeholder="",this.min=null,this.max=null,this.minlength=0,this.maxlength=0,this.pattern="",this.optionalTag=!1,this.optionalText=Tt.forms.labels.optional,this.requiredTag=!1,this.requiredText=Tt.forms.labels.required,this.hasError=!1,this.errorMessage="",this.touched=!1,this.internals=this.attachInternals()}static get formAssociated(){return!0}manageValidity(t){this.required&&!this.value?this.internals.setValidity({valueMissing:!0},Tt.forms.messages.required,t):t.validity.typeMismatch||t.validity.badInput?this.internals.setValidity({typeMismatch:!0},Tt.forms.messages.invalid,t):t.validity.patternMismatch?this.internals.setValidity({patternMismatch:!0},Tt.forms.messages.invalidPattern,t):t.validity.tooShort||this.minLength>0&&this.value.length<this.minLength?this.internals.setValidity({tooShort:!0},Tt.forms.messages.tooShort,t):t.validity.tooLong||this.maxLength>0&&this.value.length>this.maxLength?this.internals.setValidity({tooLong:!0},Tt.forms.messages.tooLong,t):t.validity.rangeUnderflow?this.internals.setValidity({rangeUnderflow:!0},Tt.forms.messages.rangeUnderflow,t):t.validity.rangeOverflow?this.internals.setValidity({rangeOverflow:!0},Tt.forms.messages.rangeOverflow,t):t.validity.customError?this.internals.setValidity({customError:!0},t.validationMessage,t):this.internals.setValidity({})}setFormValue(t){if(this.internals)if(Array.isArray(t)){const n=new FormData;t.forEach(r=>{n.append(this.name,r)}),this.internals.setFormValue(n)}else this.internals.setFormValue(t)}valueChanged(t,n){typeof t=="string"?((this.multiple||this.range)&&t.includes(",")&&(t=t.split(",")),this.value=t,this._value=Array.isArray(t)?t:[t]):Array.isArray(t)?(this.value=t,this._value=t):(this.value="",this._value=[]),(!this.value||this.value.length===0)&&n&&n.length!==0?this.clearInputValue():this.value&&this.value.toString()!==(n==null?void 0:n.toString())&&this.onChange(this.value),this.updateComplete.then(()=>this.requestUpdate())}clearInputValue(){const t=this.multiple||this.range?[]:"";this.value=t,this.internals.setFormValue(t),this.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("value-change",{detail:t,bubbles:!0,composed:!0}))}onFocus(){this.dispatchEvent(new FocusEvent("focus"))}onBlur(){this.dispatchEvent(new FocusEvent("blur"))}onInput(){this.dispatchEvent(new InputEvent("input"))}onChange(t){if(!this.touched){this.touched=!0,t&&this.setFormValue(t);return}typeof t!="string"&&!Array.isArray(t)||((this.range||this.multiple)&&!Array.isArray(t)&&t.includes(",")&&(t=t.split(",")),!this.multiple&&!this.range&&Array.isArray(t)&&(t=t[0]),this.setFormValue(t),this.manageValidity(this.inputRef.value),this.inputRef2&&this.manageValidity(this.inputRef2.value),this.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("value-change",{detail:t,bubbles:!0,composed:!0})),this.internals.reportValidity())}firstUpdated(t){super.firstUpdated(t),this.required&&(this.internals.ariaRequired=!0),this.disabled&&(this.internals.disabled=!0,this.internals.ariaDisabled=!0),this.internals.setFormValue(this.value),this.manageValidity(this.inputRef.value)}};ze([O({type:String,reflect:!0})],Ge.prototype,"id"),ze([O({type:String,reflect:!0})],Ge.prototype,"name"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"required"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"disabled"),ze([O({type:String,reflect:!0})],Ge.prototype,"placeholder"),ze([O({type:Number,reflect:!0})],Ge.prototype,"min"),ze([O({type:Number,reflect:!0})],Ge.prototype,"max"),ze([O({type:Number,reflect:!0})],Ge.prototype,"minlength"),ze([O({type:Number,reflect:!0})],Ge.prototype,"maxlength"),ze([O({type:String,reflect:!0})],Ge.prototype,"pattern"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"optionalTag"),ze([O({type:String,reflect:!0})],Ge.prototype,"optionalText"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"requiredTag"),ze([O({type:String,reflect:!0})],Ge.prototype,"requiredText"),ze([O({type:Boolean,reflect:!0})],Ge.prototype,"hasError"),ze([O({type:String,reflect:!0})],Ge.prototype,"errorMessage"),ze([Yt()],Ge.prototype,"touched");/**
96
96
  * @license
97
97
  * Copyright 2017 Google LLC
98
98
  * SPDX-License-Identifier: BSD-3-Clause
@@ -150,7 +150,7 @@ React keys must be passed directly to JSX without using spread:
150
150
 
151
151
  ${this.date?K`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>`:ne}
152
152
  </div>
153
- `}};pn([O({type:Boolean,reflect:!1})],It.prototype,"compact",2),pn([O({type:String,reflect:!0})],It.prototype,"title",2),pn([O({type:String,reflect:!0})],It.prototype,"skin",2),pn([O({type:String,reflect:!0})],It.prototype,"ariaLive",2),pn([O({type:Boolean,reflect:!0})],It.prototype,"closeAlert",2),pn([O({type:String,reflect:!0})],It.prototype,"date",2),pn([Yt()],It.prototype,"_isClosed",2),It=pn([Ot("pkt-alert")],It);const Ll=e=>{if(Array.isArray(e))return e;if(typeof e=="string")return e.split(",")},Xh=e=>e?new Date(e):null,Qh=e=>{if(typeof e=="string")return e.split(",").map(t=>new Date(t));if(Array.isArray(e))return e.map(t=>new Date(t))},rr={csvToArray:Ll,stringToDate:Xh,stringsToDate:Qh};function ot(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function jn(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}const Ol=6048e5,Zh=864e5;let ef={};function qa(){return ef}function Ur(e,t){var n,r,i,o;const u=qa(),c=(t==null?void 0:t.weekStartsOn)??((r=(n=t==null?void 0:t.locale)==null?void 0:n.options)==null?void 0:r.weekStartsOn)??u.weekStartsOn??((o=(i=u.locale)==null?void 0:i.options)==null?void 0:o.weekStartsOn)??0,d=ot(e),h=d.getDay(),m=(h<c?7:0)+h-c;return d.setDate(d.getDate()-m),d.setHours(0,0,0,0),d}function as(e,t){const n=ot(e.start),r=ot(e.end);let i=+n>+r;const o=i?+n:+r,u=i?r:n;u.setHours(0,0,0,0);let c=1;const d=[];for(;+u<=o;)d.push(ot(u)),u.setDate(u.getDate()+c),u.setHours(0,0,0,0);return i?d.reverse():d}function Il(e,t){var n,r,i,o;const u=ot(e),c=u.getFullYear(),d=qa(),h=(t==null?void 0:t.firstWeekContainsDate)??((r=(n=t==null?void 0:t.locale)==null?void 0:n.options)==null?void 0:r.firstWeekContainsDate)??d.firstWeekContainsDate??((o=(i=d.locale)==null?void 0:i.options)==null?void 0:o.firstWeekContainsDate)??1,m=jn(e,0);m.setFullYear(c+1,0,h),m.setHours(0,0,0,0);const v=Ur(m,t),y=jn(e,0);y.setFullYear(c,0,h),y.setHours(0,0,0,0);const b=Ur(y,t);return u.getTime()>=v.getTime()?c+1:u.getTime()>=b.getTime()?c:c-1}function tf(e,t){var n,r,i,o;const u=qa(),c=(t==null?void 0:t.firstWeekContainsDate)??((r=(n=t==null?void 0:t.locale)==null?void 0:n.options)==null?void 0:r.firstWeekContainsDate)??u.firstWeekContainsDate??((o=(i=u.locale)==null?void 0:i.options)==null?void 0:o.firstWeekContainsDate)??1,d=Il(e,t),h=jn(e,0);return h.setFullYear(d,0,c),h.setHours(0,0,0,0),Ur(h,t)}function Ml(e,t){const n=ot(e),r=+Ur(n,t)-+tf(n,t);return Math.round(r/Ol)+1}function nf(e){let t=ot(e).getDay();return t===0&&(t=7),t}const rf="pkt-calendar",af={id:{type:"string",name:"ID",description:"Unique identifier for the calendar"},currentmonth:{type:"date",converter:"stringToDate",description:"The current month to display"},selected:{type:"array",converter:"csvToArray",reflect:!0,items:{type:"date"},description:"Array of selected dates"},excludeweekdays:{type:"array",converter:"csvToArray",items:{type:"string"},description:"Array of weekdays (1-7) to exclude"},excludedates:{type:"array",converter:"stringsToDate",items:{type:"date"},description:"Array of specific dates to exclude"},earliest:{type:"date",converter:"stringToDate",default:null,description:"Earliest selectable date"},latest:{type:"date",converter:"stringToDate",default:null,description:"Latest selectable date"},weeknumbers:{type:"boolean",reflect:!0,default:!1,description:"Show week numbers in calendar"},withcontrols:{type:"boolean",reflect:!0,default:!1,description:"Show month and year navigation controls"},multiple:{type:"boolean",reflect:!0,default:!1,description:"Allow multiple date selection"},maxMultiple:{type:"number",default:4,description:"Maximum number of dates that can be selected"},range:{type:"boolean",reflect:!0,default:!1,description:"Allow date range selection"}},sf={"date-selected":{description:"Returns ISO formatted date string"}},Pn={name:rf,"css-class":"pkt-calendar",props:af,events:sf};var of=Object.defineProperty,lf=Object.getOwnPropertyDescriptor,Se=(e,t,n,r)=>{for(var i=r>1?void 0:r?lf(t,n):t,o=e.length-1,u;o>=0;o--)(u=e[o])&&(i=(r?u(t,n,i):u(i))||i);return r&&i&&of(t,n,i),i};let xe=class extends Bt{constructor(){super(...arguments),this.multiple=Pn.props.multiple.default,this.maxMultiple=Pn.props.maxMultiple.default,this.range=Pn.props.range.default,this.weeknumbers=Pn.props.weeknumbers.default,this.withcontrols=Pn.props.withcontrols.default,this.selected=[],this.earliest=Pn.props.earliest.default,this.latest=Pn.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.dayStrings=this.strings.dates.daysShort,this.monthStrings=this.strings.dates.months,this.weekString=this.strings.dates.week,this.prevMonthString=this.strings.dates.prevMonth,this.nextMonthString=this.strings.dates.nextMonth,this._selected=[],this.year=0,this.month=0,this.week=0,this.rangeHovered=null,this.inRange={},this.focusedDate=null,this.selectableDates=[],this.currentmonthtouched=!1,this.tabIndexSet=0}connectedCallback(){super.connectedCallback()}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}attributeChangedCallback(t,n,r){t==="selected"&&r&&this.convertSelected(),super.attributeChangedCallback(t,n,r)}updated(t){t.has("selected")&&this.convertSelected(),super.updated(t)}firstUpdated(t){this.addEventListener("keydown",this.handleKeydown)}convertSelected(){if(typeof this.selected=="string"&&(this.selected=this.selected.split(",")),this.selected.length===1&&this.selected[0]===""&&(this.selected=[]),this._selected=this.selected.map(t=>new Date(t)),this.range&&this.selected.length===2){const t=as({start:new Date(this.selected[0]),end:new Date(this.selected[1])});if(this.inRange={},Array.isArray(t)&&t.length){const n={};for(let r=0;r<t.length;r++)n[this.formatISODate(t[r])]=this.isInRange(t[r]);this.inRange=n}}this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched){this.currentmonthtouched=!0;return}this.selected.length&&this.selected[0]!==""?this.currentmonth=new Date(this.selected[this.selected.length-1]):this.currentmonth===null&&(this.currentmonth=new Date),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(t){switch(t.key){case"ArrowLeft":this.handleArrowKey(t,-1);break;case"ArrowRight":this.handleArrowKey(t,1);break;case"ArrowUp":this.handleArrowKey(t,-7);break;case"ArrowDown":this.handleArrowKey(t,7);break}}handleArrowKey(t,n){t.preventDefault(),this.focusedDate||this.focusOnCurrentDate();const r=this.focusedDate?new Date(this.focusedDate):new Date(this.year,this.month,1);let i=new Date(r.setDate(r.getDate()+n));if(i){let o=this.querySelector(`div[data-date="${this.formatISODate(i)}"]`);if(o instanceof HTMLDivElement){if(o.dataset.disabled){let u=new Date(r.setDate(r.getDate()+n)),c=this.querySelector(`div[data-date="${this.formatISODate(u)}"]`);for(;c&&c instanceof HTMLDivElement&&c.dataset.disabled;)u=new Date(u.setDate(u.getDate()+n)),c=this.querySelector(`div[data-date="${this.formatISODate(u)}"]`);o=c}o instanceof HTMLDivElement&&!o.dataset.disabled&&(this.focusedDate=this.formatISODate(i),o.focus())}}}render(){return K`
153
+ `}};pn([O({type:Boolean,reflect:!1})],It.prototype,"compact",2),pn([O({type:String,reflect:!0})],It.prototype,"title",2),pn([O({type:String,reflect:!0})],It.prototype,"skin",2),pn([O({type:String,reflect:!0})],It.prototype,"ariaLive",2),pn([O({type:Boolean,reflect:!0})],It.prototype,"closeAlert",2),pn([O({type:String,reflect:!0})],It.prototype,"date",2),pn([Yt()],It.prototype,"_isClosed",2),It=pn([Ot("pkt-alert")],It);const Ll=e=>{if(Array.isArray(e))return e;if(typeof e=="string")return e.split(",")},Xh=e=>e?new Date(e):null,Qh=e=>{if(typeof e=="string")return e.split(",").map(t=>new Date(t));if(Array.isArray(e))return e.map(t=>new Date(t))},rr={csvToArray:Ll,stringToDate:Xh,stringsToDate:Qh};function ot(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function jn(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}const Ol=6048e5,Zh=864e5;let ef={};function qa(){return ef}function Ur(e,t){var n,r,i,o;const u=qa(),c=(t==null?void 0:t.weekStartsOn)??((r=(n=t==null?void 0:t.locale)==null?void 0:n.options)==null?void 0:r.weekStartsOn)??u.weekStartsOn??((o=(i=u.locale)==null?void 0:i.options)==null?void 0:o.weekStartsOn)??0,d=ot(e),h=d.getDay(),m=(h<c?7:0)+h-c;return d.setDate(d.getDate()-m),d.setHours(0,0,0,0),d}function as(e,t){const n=ot(e.start),r=ot(e.end);let i=+n>+r;const o=i?+n:+r,u=i?r:n;u.setHours(0,0,0,0);let c=1;const d=[];for(;+u<=o;)d.push(ot(u)),u.setDate(u.getDate()+c),u.setHours(0,0,0,0);return i?d.reverse():d}function Il(e,t){var n,r,i,o;const u=ot(e),c=u.getFullYear(),d=qa(),h=(t==null?void 0:t.firstWeekContainsDate)??((r=(n=t==null?void 0:t.locale)==null?void 0:n.options)==null?void 0:r.firstWeekContainsDate)??d.firstWeekContainsDate??((o=(i=d.locale)==null?void 0:i.options)==null?void 0:o.firstWeekContainsDate)??1,m=jn(e,0);m.setFullYear(c+1,0,h),m.setHours(0,0,0,0);const v=Ur(m,t),y=jn(e,0);y.setFullYear(c,0,h),y.setHours(0,0,0,0);const b=Ur(y,t);return u.getTime()>=v.getTime()?c+1:u.getTime()>=b.getTime()?c:c-1}function tf(e,t){var n,r,i,o;const u=qa(),c=(t==null?void 0:t.firstWeekContainsDate)??((r=(n=t==null?void 0:t.locale)==null?void 0:n.options)==null?void 0:r.firstWeekContainsDate)??u.firstWeekContainsDate??((o=(i=u.locale)==null?void 0:i.options)==null?void 0:o.firstWeekContainsDate)??1,d=Il(e,t),h=jn(e,0);return h.setFullYear(d,0,c),h.setHours(0,0,0,0),Ur(h,t)}function Ml(e,t){const n=ot(e),r=+Ur(n,t)-+tf(n,t);return Math.round(r/Ol)+1}function nf(e){let t=ot(e).getDay();return t===0&&(t=7),t}const rf="pkt-calendar",af={id:{type:"string",name:"ID",description:"Unique identifier for the calendar"},currentmonth:{type:"date",converter:"stringToDate",description:"The current month to display"},selected:{type:"array",converter:"csvToArray",reflect:!0,items:{type:"date"},description:"Array of selected dates"},excludeweekdays:{type:"array",converter:"csvToArray",items:{type:"string"},description:"Array of weekdays (1-7) to exclude"},excludedates:{type:"array",converter:"stringsToDate",items:{type:"date"},description:"Array of specific dates to exclude"},earliest:{type:"date",converter:"stringToDate",default:null,description:"Earliest selectable date"},latest:{type:"date",converter:"stringToDate",default:null,description:"Latest selectable date"},weeknumbers:{type:"boolean",reflect:!0,default:!1,description:"Show week numbers in calendar"},withcontrols:{type:"boolean",reflect:!0,default:!1,description:"Show month and year navigation controls"},multiple:{type:"boolean",reflect:!0,default:!1,description:"Allow multiple date selection"},maxMultiple:{type:"number",default:4,description:"Maximum number of dates that can be selected"},range:{type:"boolean",reflect:!0,default:!1,description:"Allow date range selection"}},sf={"date-selected":{description:"Returns ISO formatted date string"}},Pn={name:rf,"css-class":"pkt-calendar",props:af,events:sf};var of=Object.defineProperty,lf=Object.getOwnPropertyDescriptor,Se=(e,t,n,r)=>{for(var i=r>1?void 0:r?lf(t,n):t,o=e.length-1,u;o>=0;o--)(u=e[o])&&(i=(r?u(t,n,i):u(i))||i);return r&&i&&of(t,n,i),i};let xe=class extends Bt{constructor(){super(...arguments),this.multiple=Pn.props.multiple.default,this.maxMultiple=Pn.props.maxMultiple.default,this.range=Pn.props.range.default,this.weeknumbers=Pn.props.weeknumbers.default,this.withcontrols=Pn.props.withcontrols.default,this.selected=[],this.earliest=Pn.props.earliest.default,this.latest=Pn.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.dayStrings=this.strings.dates.daysShort,this.monthStrings=this.strings.dates.months,this.weekString=this.strings.dates.week,this.prevMonthString=this.strings.dates.prevMonth,this.nextMonthString=this.strings.dates.nextMonth,this._selected=[],this.year=0,this.month=0,this.week=0,this.rangeHovered=null,this.inRange={},this.focusedDate=null,this.selectableDates=[],this.currentmonthtouched=!1,this.tabIndexSet=0}connectedCallback(){super.connectedCallback()}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}attributeChangedCallback(t,n,r){t==="selected"&&r&&this.convertSelected(),super.attributeChangedCallback(t,n,r)}updated(t){t.has("selected")&&this.convertSelected(),super.updated(t)}firstUpdated(t){this.addEventListener("keydown",this.handleKeydown)}convertSelected(){if(typeof this.selected=="string"&&(this.selected=this.selected.split(",")),this.selected.length===1&&this.selected[0]===""&&(this.selected=[]),this._selected=this.selected.map(t=>new Date(t)),this.range&&this.selected.length===2){const t=as({start:new Date(this.selected[0]),end:new Date(this.selected[1])});if(this.inRange={},Array.isArray(t)&&t.length){const n={};for(let r=0;r<t.length;r++)n[this.formatISODate(t[r])]=this.isInRange(t[r]);this.inRange=n}}this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched){this.currentmonthtouched=!0;return}this.selected.length&&this.selected[0]!==""?this.currentmonth=new Date(this.selected[this.selected.length-1]):this.currentmonth===null&&(this.currentmonth=new Date),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(t){switch(t.key){case"ArrowLeft":this.handleArrowKey(t,-1);break;case"ArrowRight":this.handleArrowKey(t,1);break;case"ArrowUp":this.handleArrowKey(t,-7);break;case"ArrowDown":this.handleArrowKey(t,7);break}}handleArrowKey(t,n){var r,i,o;if(((r=t.target)==null?void 0:r.nodeName)==="INPUT"||((i=t.target)==null?void 0:i.nodeName)==="SELECT"||((o=t.target)==null?void 0:o.nodeName)==="BUTTON")return;t.preventDefault(),this.focusedDate||this.focusOnCurrentDate();const u=this.focusedDate?new Date(this.focusedDate):new Date(this.year,this.month,1);let c=new Date(u.setDate(u.getDate()+n));if(c){let d=this.querySelector(`div[data-date="${this.formatISODate(c)}"]`);if(d instanceof HTMLDivElement){if(d.dataset.disabled){let h=new Date(u.setDate(u.getDate()+n)),m=this.querySelector(`div[data-date="${this.formatISODate(h)}"]`);for(;m&&m instanceof HTMLDivElement&&m.dataset.disabled;)h=new Date(h.setDate(h.getDate()+n)),m=this.querySelector(`div[data-date="${this.formatISODate(h)}"]`);d=m}d instanceof HTMLDivElement&&!d.dataset.disabled&&(this.focusedDate=this.formatISODate(c),d.focus())}}}render(){return K`
154
154
  <div
155
155
  class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":ne}"
156
156
  @focusout=${this.closeEvent}
@@ -158,7 +158,8 @@ React keys must be passed directly to JSX without using spread:
158
158
  >
159
159
  <nav class="pkt-cal-month-nav">
160
160
  <div>
161
- <div
161
+ <button
162
+ type="button"
162
163
  @click=${this.isPrevMonthAllowed()&&this.prevMonth}
163
164
  @keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isNextMonthAllowed()&&this.prevMonth())}}
164
165
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isPrevMonthAllowed()?"":"pkt-hide"}"
@@ -168,11 +169,12 @@ React keys must be passed directly to JSX without using spread:
168
169
  >
169
170
  <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
170
171
  <span class="pkt-btn__text">${this.prevMonthString}</span>
171
- </div>
172
+ </button>
172
173
  </div>
173
174
  ${this.renderMonthNav()}
174
175
  <div>
175
- <div
176
+ <button
177
+ type="button"
176
178
  @click=${this.isNextMonthAllowed()&&this.nextMonth}
177
179
  @keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isNextMonthAllowed()&&this.nextMonth())}}
178
180
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isNextMonthAllowed()?"":"pkt-hide"}"
@@ -182,7 +184,7 @@ React keys must be passed directly to JSX without using spread:
182
184
  >
183
185
  <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
184
186
  <span class="pkt-btn__text">${this.nextMonthString}</span>
185
- </div>
187
+ </button>
186
188
  </div>
187
189
  </nav>
188
190
  <table
@@ -196,14 +198,18 @@ React keys must be passed directly to JSX without using spread:
196
198
  `}renderDayNames(){const t=[];this.weeknumbers&&t.push(K`<td><div>${this.weekString}<div></td>`);for(let n=0;n<this.dayStrings.length;n++)t.push(K`<td><div>${this.dayStrings[n]}</div></td>`);return K`<tr class="pkt-cal-week-row" role="presentation">
197
199
  ${t}
198
200
  </tr>`}renderMonthNav(){let t=[];return this.withcontrols?t.push(K`<div class="pkt-cal-month-picker">
201
+ <label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
199
202
  <select
200
203
  class="pkt-input pkt-input-compact"
204
+ id="${this.id}-monthnav"
201
205
  @change=${n=>{this.changeMonth(this.year,n.target.value)}}
202
206
  >
203
207
  ${this.monthStrings.map((n,r)=>K`<option value=${r} ?selected=${this.month===r}>${n}</option>`)}
204
208
  </select>
209
+ <label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
205
210
  <input
206
211
  class="pkt-input pkt-cal-input-year pkt-input-compact"
212
+ id="${this.id}-yearnav"
207
213
  type="number"
208
214
  size="4"
209
215
  placeholder="0000"
@@ -406,11 +412,12 @@ React keys must be passed directly to JSX without using spread:
406
412
  @change=${e=>{e.stopImmediatePropagation()}}
407
413
  ${rt(this.inputRef)}
408
414
  />
409
- <div class="pkt-input-prefix">Til</div>
415
+ <div class="pkt-input-prefix" id="${this.id}-to-label">Til</div>
410
416
  <input
411
417
  class=${He(this.inputClasses)}
412
418
  .type=${this.inputType}
413
419
  id="${this.id}-to"
420
+ aria-labelledby="${this.id}-to-label"
414
421
  .value=${this._value[1]??""}
415
422
  min=${this.min}
416
423
  max=${this.max}
@@ -457,6 +464,7 @@ React keys must be passed directly to JSX without using spread:
457
464
  ${rt(this.popupRef)}
458
465
  >
459
466
  <pkt-calendar
467
+ id="${this.id}-calendar"
460
468
  ?multiple=${this.multiple}
461
469
  ?range=${this.range}
462
470
  ?weeknumbers=${this.weeknumbers}
@@ -499,6 +507,7 @@ React keys must be passed directly to JSX without using spread:
499
507
  ${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
500
508
  <button
501
509
  class="${He(this.buttonClasses)}"
510
+ type="button"
502
511
  @click=${this.toggleCalendar}
503
512
  ?disabled=${this.disabled}
504
513
  ${rt(this.btnRef)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "12.6.2",
3
+ "version": "12.6.4",
4
4
  "description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo Origo",
@@ -47,8 +47,8 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@oslokommune/punkt-assets": "^12.4.0",
50
- "@oslokommune/punkt-css": "^12.5.2",
51
- "@oslokommune/punkt-elements": "^12.6.1",
50
+ "@oslokommune/punkt-css": "^12.6.3",
51
+ "@oslokommune/punkt-elements": "^12.6.4",
52
52
  "@testing-library/jest-dom": "^6.5.0",
53
53
  "@testing-library/react": "^16.0.1",
54
54
  "@testing-library/user-event": "^14.5.2",
@@ -111,5 +111,5 @@
111
111
  "url": "https://github.com/oslokommune/punkt/issues"
112
112
  },
113
113
  "license": "MIT",
114
- "gitHead": "3da397ade0b2e70292f9f120b8b0e5b374d9ddf1"
114
+ "gitHead": "e365aa2a36162a15aaa55bb5b404132a54b989a2"
115
115
  }