@oslokommune/punkt-elements 13.5.13 → 13.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/{accordionitem-Csh7iSVG.cjs → accordionitem-BOmnm80g.cjs} +1 -1
- package/dist/{accordionitem-C9T3nlM0.js → accordionitem-B_h5XGCo.js} +4 -4
- package/dist/{alert-cUBtwi2k.js → alert-CTTm6ugp.js} +6 -6
- package/dist/{alert-7rUOhlNi.cjs → alert-ZP5-fqlt.cjs} +1 -1
- package/dist/{backlink-JbBNi3qg.cjs → backlink-BT7DO6rV.cjs} +1 -1
- package/dist/{backlink-C2jbzu0U.js → backlink-Bq8O2bt8.js} +3 -3
- package/dist/{button-B8rdtaHB.cjs → button-BfqxLnMT.cjs} +1 -1
- package/dist/{button-DhispFOY.js → button-x6Xw-5w0.js} +5 -5
- package/dist/{calendar-32W9p9uc.cjs → calendar-CL9O0tLP.cjs} +1 -1
- package/dist/{calendar-CJSxvwAq.js → calendar-ChphTIhk.js} +7 -7
- package/dist/{card-DBlFf1ry.cjs → card-BwLe5f50.cjs} +1 -1
- package/dist/{card-BDz4RWxK.js → card-DpUEM1tU.js} +7 -7
- package/dist/{checkbox-Gn7Wtk9h.cjs → checkbox-CH8xeK-0.cjs} +1 -1
- package/dist/{checkbox-ym7z6cpt.js → checkbox-DSAcMC-D.js} +4 -4
- package/dist/{class-map-BBG2gMX4.cjs → class-map-CG3vIaNm.cjs} +1 -1
- package/dist/{class-map-BpTj9gtz.js → class-map-Dw6Wrxwi.js} +1 -1
- package/dist/{combobox-D84REr9N.cjs → combobox-COuxR036.cjs} +1 -1
- package/dist/{combobox-BXP1PL0M.js → combobox-D3aPvdrE.js} +11 -11
- package/dist/{consent-BpcQFvbi.js → consent-CXp0bLvg.js} +3 -3
- package/dist/{consent-hYeFWNFr.cjs → consent-DFrsiYGQ.cjs} +1 -1
- package/dist/datepicker-CV73pLqD.cjs +169 -0
- package/dist/{datepicker-F3TwE9o7.js → datepicker-Ca552mbJ.js} +148 -111
- package/dist/{directive-helpers-BBbxqP2W.cjs → directive-helpers-_qHew-gi.cjs} +1 -1
- package/dist/{directive-helpers-r-kOS_Mf.js → directive-helpers-cAOIHg9K.js} +1 -1
- package/dist/element-D62wHiNU.cjs +27 -0
- package/dist/element-DJZPsA_J.js +722 -0
- package/dist/{heading-CNycsyMj.cjs → heading-BBzoDZGk.cjs} +1 -1
- package/dist/{heading-Bdh9absf.js → heading-CfxZa1QR.js} +1 -1
- package/dist/{helptext-B7eI0iBQ.js → helptext-8ykxyegi.js} +5 -5
- package/dist/{helptext-CzQX6YVE.cjs → helptext-D1fkGmfT.cjs} +1 -1
- package/dist/{icon-CC1js8eR.js → icon-B1-mkmwB.js} +1 -1
- package/dist/{icon-B_ryAy4Q.cjs → icon-__Hjt2XZ.cjs} +1 -1
- package/dist/{if-defined-Cni-RHLS.cjs → if-defined-CkVc_RJD.cjs} +1 -1
- package/dist/{if-defined-CmuO4Vz9.js → if-defined-D3lgJqT7.js} +1 -1
- package/dist/index.d.ts +24 -6
- package/dist/{input-element-NnrDmp4r.js → input-element-DQOVrqUZ.js} +2 -2
- package/dist/{input-element-C4xJoM-X.cjs → input-element-Y8sdrq9C.cjs} +1 -1
- package/dist/{input-wrapper-CZ-a00V7.cjs → input-wrapper-C9rZEgju.cjs} +1 -1
- package/dist/{input-wrapper-Dr__Sxql.js → input-wrapper-D_JdEqcO.js} +6 -6
- package/dist/{link-Cjl0xwSq.cjs → link-CyiVlb-7.cjs} +1 -1
- package/dist/{link-AIyVfcyH.js → link-DSSJYrtn.js} +4 -4
- package/dist/{linkcard-DqIvb54H.cjs → linkcard-fH9uydjS.cjs} +1 -1
- package/dist/{linkcard-9CNlyT0S.js → linkcard-g8JtooPU.js} +4 -4
- package/dist/{listbox-C4supLfR.cjs → listbox-BBO1d5Jd.cjs} +1 -1
- package/dist/{listbox-CLsSW32I.js → listbox-DJ7b3Wmc.js} +5 -5
- package/dist/{loader-h3d-3D7s.js → loader-Bzf1sPSg.js} +5 -5
- package/dist/{loader-DNidjwH-.cjs → loader-C-3l7kb9.cjs} +1 -1
- package/dist/{messagebox-CjPtPPrW.cjs → messagebox---xPIAwR.cjs} +1 -1
- package/dist/{messagebox-C8KQgCl_.js → messagebox-okJLeSpj.js} +5 -5
- package/dist/{modal-CRtxhCaP.cjs → modal-IjDRQfX1.cjs} +1 -1
- package/dist/{modal-Zj8yRX3K.js → modal-pohCsr_x.js} +5 -5
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +2 -2
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +3 -3
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +3 -3
- package/dist/pkt-index.js +55 -54
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +2 -2
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/{progressbar-DhMBXkww.cjs → progressbar-DJzEC7cx.cjs} +1 -1
- package/dist/{progressbar-Dj_mI_A6.js → progressbar-DjsupQ7Y.js} +5 -5
- package/dist/{radiobutton-CWxiIVfA.js → radiobutton-Bz_qApF3.js} +5 -5
- package/dist/{radiobutton-CdT6v1oq.cjs → radiobutton-DEboKECm.cjs} +1 -1
- package/dist/{ref-BBYSqgeW.js → ref-BCGCor-j.js} +2 -2
- package/dist/{ref-iJtiv3o2.cjs → ref-BfgcOXko.cjs} +1 -1
- package/dist/{repeat-C8BeHwYx.js → repeat-B6qPUgAq.js} +2 -2
- package/dist/{repeat-CDsZqct8.cjs → repeat-DzibMwhi.cjs} +1 -1
- package/dist/{select-Be--DBcR.cjs → select-Cf1RWSsI.cjs} +1 -1
- package/dist/{select-VpX_cjMM.js → select-D7OQaUrQ.js} +6 -6
- package/dist/{state-DPobt-Yz.cjs → state-BkE_Rxl7.cjs} +1 -1
- package/dist/{state-Bo2bck5_.js → state-CPQXJ4Ct.js} +1 -1
- package/dist/{tag-Bbs0U_Au.cjs → tag-BKq07hGI.cjs} +1 -1
- package/dist/{tag-DyXzTY68.js → tag-NZ5oeGfw.js} +6 -6
- package/dist/{textarea-BZL8Mkm0.js → textarea-C0vTWTov.js} +9 -9
- package/dist/{textarea-CPXsMFUq.cjs → textarea-CXu8UUsY.cjs} +1 -1
- package/dist/{textinput-aNI5kibM.cjs → textinput-C6wccDhZ.cjs} +1 -1
- package/dist/{textinput-DjPhmmkB.js → textinput-CmZrfH4A.js} +8 -8
- package/package.json +2 -3
- package/src/components/accordion/accordionitem.ts +1 -1
- package/src/components/datepicker/date-tags.test.ts +126 -0
- package/src/components/datepicker/date-tags.ts +59 -0
- package/src/components/datepicker/datepicker.ts +13 -35
- package/src/components/index.ts +1 -0
- package/dist/datepicker-DonUad47.cjs +0 -164
- package/dist/element-6DBpyGQm.cjs +0 -238
- package/dist/element-CgEWt74-.js +0 -21288
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const u=require("./class-map-
|
|
1
|
+
"use strict";const u=require("./class-map-CG3vIaNm.cjs"),t=require("./element-D62wHiNU.cjs"),k=require("./state-BkE_Rxl7.cjs"),g=require("./pkt-slot-controller-BzddBp7z.cjs"),c=require("./ref-BfgcOXko.cjs");require("./icon-__Hjt2XZ.cjs");const h=require("./if-defined-CkVc_RJD.cjs"),f={size:{default:"medium"},skin:{default:"blue"},closeTag:{default:!1},type:{default:"button"}},r={props:f};var d=Object.defineProperty,y=Object.getOwnPropertyDescriptor,i=(n,e,o,a)=>{for(var s=a>1?void 0:a?y(e,o):e,l=n.length-1,p;l>=0;l--)(p=n[l])&&(s=(a?p(e,o,s):p(s))||s);return a&&s&&d(e,o,s),s};exports.PktTag=class extends t.PktElement{constructor(){super(),this.defaultSlot=c.e(),this.closeTag=r.props.closeTag.default,this.size=r.props.size.default,this.skin=r.props.skin.default,this.textStyle=null,this.iconName=void 0,this.type=r.props.type.default,this.ariaLabel=null,this._isClosed=!1,this._ariaDescription=null,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:e},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:e},bubbles:!0,composed:!0}))},this.slotController=new g.PktSlotController(this,this.defaultSlot),this._isClosed=!1}firstUpdated(e){var o,a;if(super.firstUpdated(e),this.closeTag&&!this.ariaLabel){const s=(a=(o=this.defaultSlot.value)==null?void 0:o.textContent)==null?void 0:a.trim();s&&(this._ariaDescription=`Klikk for å fjerne ${s}`)}}render(){const e={"pkt-tag":!0,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,[`pkt-tag--${this.textStyle}`]:!!this.textStyle},o={"pkt-tag":!0,"pkt-btn":!0,"pkt-btn--tertiary":!0,[`pkt-tag--${this.textStyle}`]:!!this.textStyle,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,"pkt-btn--icons-right-and-left":this.closeTag&&!!this.iconName,"pkt-hide":this._isClosed};return this.closeTag?t.x`
|
|
2
2
|
<button
|
|
3
3
|
class=${u.e(o)}
|
|
4
4
|
type=${this.type}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { e as u } from "./class-map-
|
|
2
|
-
import { P as m, x as l, n as r, a as g } from "./element-
|
|
3
|
-
import { r as k } from "./state-
|
|
1
|
+
import { e as u } from "./class-map-Dw6Wrxwi.js";
|
|
2
|
+
import { P as m, x as l, n as r, a as g } from "./element-DJZPsA_J.js";
|
|
3
|
+
import { r as k } from "./state-CPQXJ4Ct.js";
|
|
4
4
|
import { P as y } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
5
|
-
import { e as b, n as f } from "./ref-
|
|
6
|
-
import "./icon-
|
|
7
|
-
import { o as d } from "./if-defined-
|
|
5
|
+
import { e as b, n as f } from "./ref-BCGCor-j.js";
|
|
6
|
+
import "./icon-B1-mkmwB.js";
|
|
7
|
+
import { o as d } from "./if-defined-D3lgJqT7.js";
|
|
8
8
|
const _ = {
|
|
9
9
|
size: {
|
|
10
10
|
default: "medium"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { T as l, E as $, x as f, n as d, a as g } from "./element-
|
|
2
|
-
import { o as u } from "./if-defined-
|
|
3
|
-
import { r as x } from "./state-
|
|
4
|
-
import { e as m, n as c } from "./ref-
|
|
5
|
-
import { e as v } from "./class-map-
|
|
1
|
+
import { T as l, E as $, x as f, n as d, a as g } from "./element-DJZPsA_J.js";
|
|
2
|
+
import { o as u } from "./if-defined-D3lgJqT7.js";
|
|
3
|
+
import { r as x } from "./state-CPQXJ4Ct.js";
|
|
4
|
+
import { e as m, n as c } from "./ref-BCGCor-j.js";
|
|
5
|
+
import { e as v } from "./class-map-Dw6Wrxwi.js";
|
|
6
6
|
import { e as T, i as b, t as a } from "./directive-oAbCiebi.js";
|
|
7
|
-
import { f as y, m as w } from "./directive-helpers-
|
|
8
|
-
import { P as C } from "./input-element-
|
|
7
|
+
import { f as y, m as w } from "./directive-helpers-cAOIHg9K.js";
|
|
8
|
+
import { P as C } from "./input-element-DQOVrqUZ.js";
|
|
9
9
|
import { P as E } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
10
|
-
import "./input-wrapper-
|
|
11
|
-
import "./icon-
|
|
10
|
+
import "./input-wrapper-D_JdEqcO.js";
|
|
11
|
+
import "./icon-B1-mkmwB.js";
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2020 Google LLC
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const s=require("./element-
|
|
1
|
+
"use strict";const s=require("./element-D62wHiNU.cjs"),p=require("./if-defined-CkVc_RJD.cjs"),c=require("./state-BkE_Rxl7.cjs"),l=require("./ref-BfgcOXko.cjs"),$=require("./class-map-CG3vIaNm.cjs"),a=require("./directive-C7oCP5Bh.cjs"),d=require("./directive-helpers-_qHew-gi.cjs"),x=require("./input-element-Y8sdrq9C.cjs"),T=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-C9rZEgju.cjs");require("./icon-__Hjt2XZ.cjs");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2020 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./element-
|
|
1
|
+
"use strict";const t=require("./element-D62wHiNU.cjs"),a=require("./if-defined-CkVc_RJD.cjs"),l=require("./state-BkE_Rxl7.cjs"),h=require("./ref-BfgcOXko.cjs"),c=require("./class-map-CG3vIaNm.cjs"),d=require("./input-element-Y8sdrq9C.cjs"),x=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-C9rZEgju.cjs");require("./icon-__Hjt2XZ.cjs");var $=Object.defineProperty,f=Object.getOwnPropertyDescriptor,r=(u,i,s,n)=>{for(var e=n>1?void 0:n?f(i,s):i,o=u.length-1,p;o>=0;o--)(p=u[o])&&(e=(n?p(i,s,e):p(e))||e);return n&&e&&$(i,s,e),e};exports.PktTextinput=class extends d.PktInputElement{constructor(){super(),this.inputRef=h.e(),this.helptextSlot=h.e(),this.value="",this.type="text",this.size=null,this.autocomplete=null,this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0,this.slotController=new x.PktSlotController(this,this.helptextSlot)}attributeChangedCallback(i,s,n){i==="value"&&this.value!==s&&(this.counterCurrent=n?n.length:0,this.valueChanged(n,s)),super.attributeChangedCallback(i,s,n)}updated(i){var s;super.updated(i),i.has("value")&&(this.counterCurrent=((s=this.value)==null?void 0:s.length)||0,this.valueChanged(this.value,i.get("value"))),i.has("id")&&!this.name&&this.id&&(this.name=this.id)}render(){const i=this.type==="search"&&!this.iconNameRight&&!this.omitSearchIcon,s=c.e({"pkt-input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":this.counter&&this.counterMaxLength&&this.value.length&&this.value.length>this.counterMaxLength}),n=this.ariaLabelledby||`${this.id}-input-label`;return t.x`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
label="${this.label}"
|
|
4
4
|
?counter=${this.counter}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { E as p, x as h, n as a, a as $ } from "./element-
|
|
2
|
-
import { o as u } from "./if-defined-
|
|
3
|
-
import { r as f } from "./state-
|
|
4
|
-
import { e as d, n as m } from "./ref-
|
|
5
|
-
import { e as g } from "./class-map-
|
|
6
|
-
import { P as x } from "./input-element-
|
|
1
|
+
import { E as p, x as h, n as a, a as $ } from "./element-DJZPsA_J.js";
|
|
2
|
+
import { o as u } from "./if-defined-D3lgJqT7.js";
|
|
3
|
+
import { r as f } from "./state-CPQXJ4Ct.js";
|
|
4
|
+
import { e as d, n as m } from "./ref-BCGCor-j.js";
|
|
5
|
+
import { e as g } from "./class-map-Dw6Wrxwi.js";
|
|
6
|
+
import { P as x } from "./input-element-DQOVrqUZ.js";
|
|
7
7
|
import { P as v } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
8
|
-
import "./input-wrapper-
|
|
9
|
-
import "./icon-
|
|
8
|
+
import "./input-wrapper-D_JdEqcO.js";
|
|
9
|
+
import "./icon-B1-mkmwB.js";
|
|
10
10
|
var y = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (i, e, r, t) => {
|
|
11
11
|
for (var n = t > 1 ? void 0 : t ? b(e, r) : e, l = i.length - 1, c; l >= 0; l--)
|
|
12
12
|
(c = i[l]) && (n = (t ? c(e, r, n) : c(n)) || n);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.6.1",
|
|
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",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"date-fns": "^4.1.0",
|
|
31
31
|
"dialog-polyfill": "^0.5.6",
|
|
32
32
|
"lit": "^3.3.0",
|
|
33
|
-
"react-dom": ">=18.2.22",
|
|
34
33
|
"urlpattern-polyfill": "^10.0.0",
|
|
35
34
|
"whatwg-fetch": "^3.6.19"
|
|
36
35
|
},
|
|
@@ -73,5 +72,5 @@
|
|
|
73
72
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
74
73
|
},
|
|
75
74
|
"license": "MIT",
|
|
76
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "3016e48a2ffc0729b356d8fcea8ac7a541396fb2"
|
|
77
76
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
2
|
+
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
3
|
+
import { vi } from 'vitest'
|
|
4
|
+
import { createElementTest, BaseTestConfig } from '../../tests/test-framework'
|
|
5
|
+
import './date-tags'
|
|
6
|
+
import { PktDateTags } from './date-tags'
|
|
7
|
+
|
|
8
|
+
expect.extend(toHaveNoViolations)
|
|
9
|
+
|
|
10
|
+
export interface IDateTagsTest extends BaseTestConfig {
|
|
11
|
+
dates?: string[]
|
|
12
|
+
idBase?: string
|
|
13
|
+
className?: string
|
|
14
|
+
dateformat?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const createDateTagsTest = async (config: IDateTagsTest = {}) => {
|
|
18
|
+
const { container, element } = await createElementTest('pkt-date-tags' as any, config)
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
container,
|
|
22
|
+
dateTags: element as PktDateTags,
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
document.body.innerHTML = ''
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
describe('PktDateTags', () => {
|
|
31
|
+
test('renders nothing when no dates provided', async () => {
|
|
32
|
+
const { dateTags } = await createDateTagsTest()
|
|
33
|
+
await dateTags.updateComplete
|
|
34
|
+
|
|
35
|
+
expect(dateTags.querySelectorAll('time').length).toBe(0)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
test('renders provided ISO dates and formats them', async () => {
|
|
39
|
+
const iso = '2025-09-17'
|
|
40
|
+
const { dateTags } = await createDateTagsTest()
|
|
41
|
+
|
|
42
|
+
dateTags.dates = [iso]
|
|
43
|
+
dateTags.idBase = 'base-'
|
|
44
|
+
await dateTags.updateComplete
|
|
45
|
+
|
|
46
|
+
const time = dateTags.querySelector('time')
|
|
47
|
+
expect(time).toBeTruthy()
|
|
48
|
+
expect(time?.getAttribute('datetime')).toBe(iso)
|
|
49
|
+
|
|
50
|
+
expect(time?.textContent?.trim()).toBe('17.09.2025')
|
|
51
|
+
|
|
52
|
+
const tag = dateTags.querySelector('pkt-tag')
|
|
53
|
+
expect(tag).toBeTruthy()
|
|
54
|
+
expect(tag?.id).toBe(`base-${iso}-tag`)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('applies custom unicode-style dateformat', async () => {
|
|
58
|
+
const iso = '2025-09-17'
|
|
59
|
+
const { dateTags } = await createDateTagsTest()
|
|
60
|
+
|
|
61
|
+
dateTags.dates = [iso]
|
|
62
|
+
dateTags.dateformat = 'yyyy/MM/dd'
|
|
63
|
+
await dateTags.updateComplete
|
|
64
|
+
|
|
65
|
+
const time = dateTags.querySelector('time')
|
|
66
|
+
expect(time).toBeTruthy()
|
|
67
|
+
expect(time?.textContent?.trim()).toBe('2025/09/17')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test('normalizes overflow ISO dates (e.g. 2025-02-30 -> 02.03.2025)', async () => {
|
|
71
|
+
const iso = '2025-02-30'
|
|
72
|
+
const { dateTags } = await createDateTagsTest()
|
|
73
|
+
|
|
74
|
+
dateTags.dates = [iso]
|
|
75
|
+
await dateTags.updateComplete
|
|
76
|
+
|
|
77
|
+
const time = dateTags.querySelector('time')
|
|
78
|
+
expect(time).toBeTruthy()
|
|
79
|
+
|
|
80
|
+
// JS Date normalizes invalid dates; 2025-02-30 becomes 02.03.2025
|
|
81
|
+
expect(time?.textContent?.trim()).toBe('02.03.2025')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('Moment-style tokens (DD.MM.YYYY) do not match date-fns tokens', async () => {
|
|
85
|
+
const iso = '2025-09-17'
|
|
86
|
+
const { dateTags } = await createDateTagsTest()
|
|
87
|
+
|
|
88
|
+
// Moment-style tokens are uppercase; date-fns expects lowercase (yyyy, dd)
|
|
89
|
+
dateTags.dates = [iso]
|
|
90
|
+
dateTags.dateformat = 'DD.MM.YYYY'
|
|
91
|
+
|
|
92
|
+
const spyWarn = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
93
|
+
try {
|
|
94
|
+
await expect(dateTags.updateComplete).rejects.toThrow(/Use `dd` instead of `DD`/)
|
|
95
|
+
} finally {
|
|
96
|
+
spyWarn.mockRestore()
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test('emits date-tag-removed when child pkt-tag dispatches close', async () => {
|
|
101
|
+
const iso = '2025-09-17'
|
|
102
|
+
const { dateTags } = await createDateTagsTest()
|
|
103
|
+
dateTags.dates = [iso]
|
|
104
|
+
await dateTags.updateComplete
|
|
105
|
+
|
|
106
|
+
const handler = vi.fn()
|
|
107
|
+
dateTags.addEventListener('date-tag-removed', (e: any) => handler(e.detail))
|
|
108
|
+
|
|
109
|
+
const tag = dateTags.querySelector('pkt-tag')
|
|
110
|
+
expect(tag).toBeTruthy()
|
|
111
|
+
|
|
112
|
+
// Simulate close event on child tag
|
|
113
|
+
tag?.dispatchEvent(new CustomEvent('close', { bubbles: true, composed: true }))
|
|
114
|
+
|
|
115
|
+
expect(handler).toHaveBeenCalledWith(iso)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
test('is accessible (WCAG) with dates', async () => {
|
|
119
|
+
const iso = '2025-09-17'
|
|
120
|
+
const { container } = await createDateTagsTest({ dates: [iso] })
|
|
121
|
+
|
|
122
|
+
// Run axe on the rendered container
|
|
123
|
+
const results = await axe(container)
|
|
124
|
+
expect(results).toHaveNoViolations()
|
|
125
|
+
})
|
|
126
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { PktElement } from '@/base-elements/element'
|
|
2
|
+
import { html, nothing } from 'lit'
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js'
|
|
5
|
+
import { repeat } from 'lit/directives/repeat.js'
|
|
6
|
+
|
|
7
|
+
import '@/components/tag'
|
|
8
|
+
import { fromISOtoLocal } from '@/utils/dateutils'
|
|
9
|
+
import { uuidish } from '@/utils/stringutils'
|
|
10
|
+
|
|
11
|
+
type TYear = `${number}${number}${number}${number}`
|
|
12
|
+
type TMonth = `${number}${number}`
|
|
13
|
+
type TDay = `${number}${number}`
|
|
14
|
+
export type TISODate = `${TYear}-${TMonth}-${TDay}`
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* OBS! `dateformat` er standard formatteringsstreng for visning av datoer.
|
|
18
|
+
* Denne brukes for å sette "menneskeleselig" format på datoene i tags.
|
|
19
|
+
*
|
|
20
|
+
* Følger denne unicode-standarden:
|
|
21
|
+
* https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
@customElement('pkt-date-tags')
|
|
25
|
+
export class PktDateTags extends PktElement {
|
|
26
|
+
@property({ type: Array }) dates: TISODate[] = []
|
|
27
|
+
@property({ type: String }) dateformat: string = 'dd.MM.yyyy' // se kommentar over
|
|
28
|
+
@property({ type: String, attribute: 'class' }) className: string = 'pkt-datepicker__tags'
|
|
29
|
+
@property({ type: String, attribute: 'id-base' }) idBase: string = uuidish()
|
|
30
|
+
|
|
31
|
+
render() {
|
|
32
|
+
this.classes = {
|
|
33
|
+
'pkt-date-tags': true,
|
|
34
|
+
[this.className]: true,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return html`
|
|
38
|
+
<div class=${classMap(this.classes)} aria-live="polite">
|
|
39
|
+
${Array.isArray(this.dates) && !!this.dates[0]
|
|
40
|
+
? repeat(
|
|
41
|
+
(this.dates ?? []).filter(Boolean).sort(),
|
|
42
|
+
(date) => date,
|
|
43
|
+
(date) =>
|
|
44
|
+
html` <pkt-tag
|
|
45
|
+
id=${this.idBase + date + '-tag'}
|
|
46
|
+
closeTag
|
|
47
|
+
@close=${() => {
|
|
48
|
+
this.dispatchEvent(new CustomEvent('date-tag-removed', { detail: date }))
|
|
49
|
+
}}
|
|
50
|
+
.ariaLabel=${`${this.strings?.calendar.deleteDate} ${fromISOtoLocal(date, this.dateformat)}`}
|
|
51
|
+
>
|
|
52
|
+
<time datetime=${date}>${fromISOtoLocal(date, this.dateformat)}</time>
|
|
53
|
+
</pkt-tag>`,
|
|
54
|
+
)
|
|
55
|
+
: nothing}
|
|
56
|
+
</div>
|
|
57
|
+
`
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import { classMap } from 'lit/directives/class-map.js'
|
|
2
2
|
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
4
|
-
import {
|
|
5
|
-
formatISODate,
|
|
6
|
-
fromISOToDate,
|
|
7
|
-
fromISOtoLocal,
|
|
8
|
-
newDate,
|
|
9
|
-
parseISODateString,
|
|
10
|
-
} from '@/utils/dateutils'
|
|
4
|
+
import { formatISODate, fromISOToDate, newDate, parseISODateString } from '@/utils/dateutils'
|
|
11
5
|
import { html, nothing, PropertyValues } from 'lit'
|
|
12
6
|
import { PktCalendar } from '@/components/calendar/calendar'
|
|
13
7
|
import { PktInputElement } from '@/base-elements/input-element'
|
|
14
8
|
import { Ref, createRef, ref } from 'lit/directives/ref.js'
|
|
15
|
-
import { repeat } from 'lit/directives/repeat.js'
|
|
16
9
|
import converters from '@/helpers/converters'
|
|
17
10
|
import specs from 'componentSpecs/datepicker.json'
|
|
18
11
|
import '@/components/calendar'
|
|
19
12
|
import '@/components/icon'
|
|
20
13
|
import '@/components/input-wrapper'
|
|
21
|
-
import '
|
|
14
|
+
import './date-tags'
|
|
22
15
|
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
23
16
|
|
|
24
17
|
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
@@ -527,31 +520,6 @@ export class PktDatepicker extends PktInputElement {
|
|
|
527
520
|
`
|
|
528
521
|
}
|
|
529
522
|
|
|
530
|
-
renderTags() {
|
|
531
|
-
return html`
|
|
532
|
-
<div class="pkt-datepicker__tags" aria-live="polite">
|
|
533
|
-
${!!this._value[0]
|
|
534
|
-
? repeat(
|
|
535
|
-
(this._value ?? []).filter(Boolean).sort(),
|
|
536
|
-
(date) => date,
|
|
537
|
-
(date) => html`
|
|
538
|
-
<pkt-tag
|
|
539
|
-
.id="${this.id + date + '-tag'}"
|
|
540
|
-
closeTag
|
|
541
|
-
ariaLabel="${this.strings.calendar.deleteDate} ${fromISOtoLocal(
|
|
542
|
-
date,
|
|
543
|
-
this.dateformat,
|
|
544
|
-
)}"
|
|
545
|
-
@close=${() => this.calRef.value?.handleDateSelect(fromISOToDate(date))}
|
|
546
|
-
><time datetime="${date}">${fromISOtoLocal(date, this.dateformat)}</time></pkt-tag
|
|
547
|
-
>
|
|
548
|
-
`,
|
|
549
|
-
)
|
|
550
|
-
: nothing}
|
|
551
|
-
</div>
|
|
552
|
-
`
|
|
553
|
-
}
|
|
554
|
-
|
|
555
523
|
renderCalendar() {
|
|
556
524
|
return html`<div
|
|
557
525
|
class="pkt-calendar-popup pkt-${this.calendarOpen ? 'show' : 'hide'}"
|
|
@@ -651,7 +619,17 @@ export class PktDatepicker extends PktInputElement {
|
|
|
651
619
|
class="pkt-datepicker"
|
|
652
620
|
>
|
|
653
621
|
<div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
654
|
-
${this.multiple
|
|
622
|
+
${this.multiple
|
|
623
|
+
? html`<pkt-date-tags
|
|
624
|
+
.dates=${this._value}
|
|
625
|
+
dateformat=${this.dateformat}
|
|
626
|
+
strings=${this.strings}
|
|
627
|
+
id-base=${this.id}
|
|
628
|
+
@date-tag-removed=${(e: CustomEvent) => {
|
|
629
|
+
this.calRef.value?.handleDateSelect(fromISOToDate(e.detail))
|
|
630
|
+
}}
|
|
631
|
+
></pkt-date-tags>`
|
|
632
|
+
: nothing}
|
|
655
633
|
<div
|
|
656
634
|
class="pkt-datepicker__inputs ${this.range && this.showRangeLabels
|
|
657
635
|
? 'pkt-input__range-inputs'
|
package/src/components/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { PktCombobox } from './combobox'
|
|
|
9
9
|
export { PktConsent } from './consent'
|
|
10
10
|
export { PktCheckbox } from '@/components/checkbox'
|
|
11
11
|
export { PktComponent } from '../base-elements/component-template.js'
|
|
12
|
+
export { PktDateTags } from '@/components/datepicker/date-tags.js'
|
|
12
13
|
export { PktDatepicker } from '@/components/datepicker/datepicker.js'
|
|
13
14
|
export { PktHelptext } from '@/components/helptext'
|
|
14
15
|
export { PktHeading } from '@/components/heading'
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";const d=require("./class-map-BBG2gMX4.cjs"),h=require("./if-defined-Cni-RHLS.cjs"),s=require("./element-6DBpyGQm.cjs"),v=require("./state-DPobt-Yz.cjs"),o=require("./calendar-32W9p9uc.cjs"),m=require("./input-element-C4xJoM-X.cjs"),r=require("./ref-iJtiv3o2.cjs"),y=require("./repeat-CDsZqct8.cjs");require("./icon-B_ryAy4Q.cjs");require("./input-wrapper-CZ-a00V7.cjs");require("./tag-Bbs0U_Au.cjs");const k=require("./pkt-slot-controller-BzddBp7z.cjs"),$={dateformat:{default:"dd.MM.yyyy"},min:{default:null},max:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},p={props:$};var b=Object.defineProperty,x=Object.getOwnPropertyDescriptor,n=(c,t,e,i)=>{for(var a=i>1?void 0:i?x(t,e):t,l=c.length-1,u;l>=0;l--)(u=c[l])&&(a=(i?u(t,e,a):u(a))||a);return i&&a&&b(t,e,a),a};const g=c=>new Promise(t=>setTimeout(t,c));exports.PktDatepicker=class extends m.PktInputElement{constructor(){super(),this._valueProperty="",this._value=[],this.label="Datovelger",this.dateformat=p.props.dateformat.default,this.multiple=p.props.multiple.default,this.maxlength=null,this.range=p.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=p.props.weeknumbers.default,this.withcontrols=p.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=r.e(),this.inputRefTo=r.e(),this.btnRef=r.e(),this.calRef=r.e(),this.popupRef=r.e(),this.helptextSlot=r.e(),this.addToSelected=t=>{const e=t.target;if(!e.value)return;const i=this.min?o.newDate(this.min):null,a=this.max?o.newDate(this.max):null,l=o.newDate(e.value.split(",")[0]);l&&!isNaN(l.getTime())&&(!i||l>=i)&&(!a||l<=a)&&this.calRef.value&&this.calRef.value.handleDateSelect(l),e.value=""},this.slotController=new k.PktSlotController(this,this.helptextSlot)}get value(){return this._valueProperty}set value(t){const e=this._valueProperty;this._valueProperty=Array.isArray(t)?t.join(","):t||"",this.valueChanged(this._valueProperty,e),this.requestUpdate("value",e)}async connectedCallback(){super.connectedCallback();const t=navigator.userAgent,e=/iP(hone|od|ad)/.test(t);this.inputType=e?"text":"date",document&&document.body.addEventListener("click",i=>{var a,l;(a=this.inputRef)!=null&&a.value&&((l=this.btnRef)!=null&&l.value)&&!this.inputRef.value.contains(i.target)&&!(this.inputRefTo.value&&this.inputRefTo.value.contains(i.target))&&!this.btnRef.value.contains(i.target)&&!i.target.closest(".pkt-calendar-popup")&&this.calendarOpen&&(this.onBlur(),this.hideCalendar())}),document&&document.body.addEventListener("keydown",i=>{i.key==="Escape"&&this.calendarOpen&&this.hideCalendar()}),this.value&&(this._value=Array.isArray(this.value)?this.value.filter(Boolean):this.value.split(",").filter(Boolean)),this.min=this.min||p.props.min.default,this.max=this.max||p.props.max.default,typeof this.excludedates=="string"&&(this.excludedates=this.excludedates.split(",")),typeof this.excludeweekdays=="string"&&(this.excludeweekdays=this.excludeweekdays.split(",")),(this.multiple||this.range)&&this.name&&!this.name.endsWith("[]")&&(this.name=this.name+"[]"),this.calendarOpen&&(await g(20),this.handleCalendarPosition())}disconnectedCallback(){super.disconnectedCallback(),document&&document.body.removeEventListener("click",t=>{var e,i;(e=this.inputRef)!=null&&e.value&&((i=this.btnRef)!=null&&i.value)&&!this.inputRef.value.contains(t.target)&&!this.btnRef.value.contains(t.target)&&this.hideCalendar()})}onInput(){this.dispatchEvent(new Event("input",{bubbles:!0}))}valueChanged(t,e){if(t===e)return;let i=[];t&&(typeof t=="string"?i=t.split(",").filter(Boolean):i=String(t).split(",").filter(Boolean)),this._value=i;const a=i.join(",");this._valueProperty!==a&&(this._valueProperty=a),super.valueChanged(a,e)}attributeChangedCallback(t,e,i){t==="value"&&this.value!==e&&this.valueChanged(i,e),t==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=(i==null?void 0:i.split(","))??[]),t==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=(i==null?void 0:i.split(","))??[]),super.attributeChangedCallback(t,e,i)}updated(t){if(t.has("value")){const e=Array.isArray(this.value)?this.value.join(","):this.value,i=t.get("value"),a=Array.isArray(i)?i.join(","):i;this.valueChanged(e,a)}t.has("multiple")&&(this.multiple&&!Array.isArray(this._value)?this._value=typeof this.value=="string"?this.value?this.value.split(",").filter(Boolean):[]:[]:!this.multiple&&Array.isArray(this._value)&&(this._value=this._value.filter(Boolean)),!this.multiple&&!this.range&&Array.isArray(this._value)&&(this._value=[this._value[0]??""])),super.updated(t)}renderInput(){return s.x`
|
|
2
|
-
<input
|
|
3
|
-
class="${d.e(this.inputClasses)}"
|
|
4
|
-
.type=${this.inputType}
|
|
5
|
-
id="${this.id}-input"
|
|
6
|
-
.value=${this._value[0]??""}
|
|
7
|
-
min=${h.o(this.min)}
|
|
8
|
-
max=${h.o(this.max)}
|
|
9
|
-
placeholder=${h.o(this.placeholder)}
|
|
10
|
-
?readonly=${this.readonly}
|
|
11
|
-
aria-describedby="${this.id}-helptext"
|
|
12
|
-
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
13
|
-
?disabled=${this.disabled}
|
|
14
|
-
@keydown=${t=>{var e,i;if(t.key===","&&((e=this.inputRef.value)==null||e.blur()),(t.key==="Space"||t.key===" ")&&(t.preventDefault(),this.toggleCalendar(t)),t.key==="Enter"){const a=this.internals.form;a?a.requestSubmit():(i=this.inputRef.value)==null||i.blur()}}}
|
|
15
|
-
@input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
|
|
16
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
17
|
-
@blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.manageValidity(t.target),this.value=t.target.value}}
|
|
18
|
-
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
19
|
-
${r.n(this.inputRef)}
|
|
20
|
-
/>
|
|
21
|
-
`}renderRangeInput(){const t={"pkt-input-prefix":this.showRangeLabels,"pkt-hide":!this.showRangeLabels};return s.x`
|
|
22
|
-
${this.showRangeLabels?s.x` <div class="pkt-input-prefix">${this.strings.generic.from}</div> `:s.E}
|
|
23
|
-
<input
|
|
24
|
-
class=${d.e(this.inputClasses)}
|
|
25
|
-
.type=${this.inputType}
|
|
26
|
-
id="${this.id}-input"
|
|
27
|
-
.value=${this._value[0]??""}
|
|
28
|
-
min=${h.o(this.min)}
|
|
29
|
-
max=${h.o(this.max)}
|
|
30
|
-
placeholder=${h.o(this.placeholder)}
|
|
31
|
-
?readonly=${this.readonly}
|
|
32
|
-
?disabled=${this.disabled}
|
|
33
|
-
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
34
|
-
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRef.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const l=this.internals.form;l?l.requestSubmit():(a=this.inputRefTo.value)==null||a.focus()}}}
|
|
35
|
-
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
36
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
37
|
-
@blur=${e=>{var i,a;if(e.target.value){this.manageValidity(e.target);const l=o.fromISOToDate(e.target.value);l&&this._value[0]!==e.target.value&&this._value[1]&&(this.clearInputValue(),(a=(i=this.calRef)==null?void 0:i.value)==null||a.handleDateSelect(l))}else this._value[0]&&this.clearInputValue()}}
|
|
38
|
-
@change=${e=>{e.stopImmediatePropagation()}}
|
|
39
|
-
${r.n(this.inputRef)}
|
|
40
|
-
/>
|
|
41
|
-
<div class="${d.e(t)}" id="${this.id}-to-label">
|
|
42
|
-
${this.strings.generic.to}
|
|
43
|
-
</div>
|
|
44
|
-
${this.showRangeLabels?s.E:s.x` <div class="pkt-input-separator">–</div> `}
|
|
45
|
-
<input
|
|
46
|
-
class=${d.e(this.inputClasses)}
|
|
47
|
-
.type=${this.inputType}
|
|
48
|
-
id="${this.id}-to"
|
|
49
|
-
aria-labelledby="${this.id}-to-label"
|
|
50
|
-
.value=${this._value[1]??""}
|
|
51
|
-
min=${h.o(this.min)}
|
|
52
|
-
max=${h.o(this.max)}
|
|
53
|
-
placeholder=${h.o(this.placeholder)}
|
|
54
|
-
?readonly=${this.readonly}
|
|
55
|
-
?disabled=${this.disabled}
|
|
56
|
-
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
57
|
-
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRefTo.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const l=this.internals.form;l?l.requestSubmit():(a=this.inputRefTo.value)==null||a.blur()}}}
|
|
58
|
-
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
59
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
60
|
-
@blur=${e=>{var i,a,l;if((i=this.calRef.value)!=null&&i.contains(e.relatedTarget)||this.onBlur(),e.target.value){this.manageValidity(e.target);const u=e.target.value;this.min&&this.min>u?this.internals.setValidity({rangeUnderflow:!0},this.strings.forms.messages.rangeUnderflow,e.target):this.max&&this.max<u&&this.internals.setValidity({rangeOverflow:!0},this.strings.forms.messages.rangeOverflow,e.target);const f=o.fromISOToDate(e.target.value);f&&this._value[1]!==o.formatISODate(f)&&((l=(a=this.calRef)==null?void 0:a.value)==null||l.handleDateSelect(f))}}}
|
|
61
|
-
@change=${e=>{this.touched=!0,e.stopImmediatePropagation()}}
|
|
62
|
-
${r.n(this.inputRefTo)}
|
|
63
|
-
/>
|
|
64
|
-
`}renderMultipleInput(){return s.x`
|
|
65
|
-
<input
|
|
66
|
-
class=${d.e(this.inputClasses)}
|
|
67
|
-
.type=${this.inputType}
|
|
68
|
-
id="${this.id}-input"
|
|
69
|
-
min=${h.o(this.min)}
|
|
70
|
-
max=${h.o(this.max)}
|
|
71
|
-
placeholder=${h.o(this.placeholder)}
|
|
72
|
-
?readonly=${this.readonly}
|
|
73
|
-
?disabled=${this.disabled||this.maxlength&&this._value.length>=this.maxlength}
|
|
74
|
-
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
75
|
-
@blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.addToSelected(t)}}
|
|
76
|
-
@input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
|
|
77
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
78
|
-
@keydown=${t=>{var e;if(t.key===","&&(t.preventDefault(),this.addToSelected(t)),(t.key==="Space"||t.key===" ")&&(t.preventDefault(),this.toggleCalendar(t)),t.key==="Enter"){const i=this.internals.form;i?i.requestSubmit():(e=this.inputRef.value)==null||e.blur()}}}
|
|
79
|
-
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
80
|
-
${r.n(this.inputRef)}
|
|
81
|
-
/>
|
|
82
|
-
`}renderTags(){return s.x`
|
|
83
|
-
<div class="pkt-datepicker__tags" aria-live="polite">
|
|
84
|
-
${this._value[0]?y.c((this._value??[]).filter(Boolean).sort(),t=>t,t=>s.x`
|
|
85
|
-
<pkt-tag
|
|
86
|
-
.id="${this.id+t+"-tag"}"
|
|
87
|
-
closeTag
|
|
88
|
-
ariaLabel="${this.strings.calendar.deleteDate} ${o.fromISOtoLocal(t,this.dateformat)}"
|
|
89
|
-
@close=${()=>{var e;return(e=this.calRef.value)==null?void 0:e.handleDateSelect(o.fromISOToDate(t))}}
|
|
90
|
-
><time datetime="${t}">${o.fromISOtoLocal(t,this.dateformat)}</time></pkt-tag
|
|
91
|
-
>
|
|
92
|
-
`):s.E}
|
|
93
|
-
</div>
|
|
94
|
-
`}renderCalendar(){return s.x`<div
|
|
95
|
-
class="pkt-calendar-popup pkt-${this.calendarOpen?"show":"hide"}"
|
|
96
|
-
@focusout=${t=>{this.calendarOpen&&this.handleFocusOut(t)}}
|
|
97
|
-
id="${this.id}-popup"
|
|
98
|
-
${r.n(this.popupRef)}
|
|
99
|
-
>
|
|
100
|
-
<pkt-calendar
|
|
101
|
-
id="${this.id}-calendar"
|
|
102
|
-
?multiple=${this.multiple}
|
|
103
|
-
?range=${this.range}
|
|
104
|
-
?weeknumbers=${this.weeknumbers}
|
|
105
|
-
?withcontrols=${this.withcontrols}
|
|
106
|
-
.maxMultiple=${this.maxlength}
|
|
107
|
-
.selected=${this._value}
|
|
108
|
-
.earliest=${this.min}
|
|
109
|
-
.latest=${this.max}
|
|
110
|
-
.excludedates=${Array.isArray(this.excludedates)?this.excludedates:this.excludedates.split(",")}
|
|
111
|
-
.excludeweekdays=${this.excludeweekdays}
|
|
112
|
-
.currentmonth=${this.currentmonth?o.parseISODateString(this.currentmonth):null}
|
|
113
|
-
@date-selected=${t=>{this.value=!this.multiple&&!this.range?t.detail[0]:Array.isArray(t.detail)?t.detail.join(","):t.detail,this._value=t.detail,this.inputRef.value&&(this.range&&this.inputRefTo.value?(this.inputRef.value.value=this._value[0]??"",this.inputRefTo.value.value=this._value[1]??"",this.manageValidity(this.inputRef.value),this.manageValidity(this.inputRefTo.value)):this.multiple||(this.inputRef.value.value=this._value.length?this._value[0]:"",this.manageValidity(this.inputRef.value)))}}
|
|
114
|
-
@close=${()=>{this.onBlur(),this.hideCalendar()}}
|
|
115
|
-
${r.n(this.calRef)}
|
|
116
|
-
></pkt-calendar>
|
|
117
|
-
</div>`}render(){return this.inputClasses={"pkt-input":!0,"pkt-datepicker__input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-datepicker--hasrangelabels":this.showRangeLabels,"pkt-datepicker--multiple":this.multiple,"pkt-datepicker--range":this.range},this.buttonClasses={"pkt-input-icon":!0,"pkt-btn":!0,"pkt-btn--icon-only":!0,"pkt-btn--tertiary":!0,"pkt-datepicker__calendar-button":!0},s.x`
|
|
118
|
-
<pkt-input-wrapper
|
|
119
|
-
label="${this.label}"
|
|
120
|
-
forId="${this.id}-input"
|
|
121
|
-
?counter=${this.multiple&&!!this.maxlength}
|
|
122
|
-
.counterCurrent=${this.value?this._value.length:0}
|
|
123
|
-
.counterMaxLength=${this.maxlength}
|
|
124
|
-
?disabled=${this.disabled}
|
|
125
|
-
?hasError=${this.hasError}
|
|
126
|
-
?hasFieldset=${this.hasFieldset}
|
|
127
|
-
?inline=${this.inline}
|
|
128
|
-
?required=${this.required}
|
|
129
|
-
?optionalTag=${this.optionalTag}
|
|
130
|
-
?requiredTag=${this.requiredTag}
|
|
131
|
-
?useWrapper=${this.useWrapper}
|
|
132
|
-
.optionalText=${this.optionalText}
|
|
133
|
-
.requiredText=${this.requiredText}
|
|
134
|
-
.tagText=${this.tagText}
|
|
135
|
-
.errorMessage=${this.errorMessage}
|
|
136
|
-
.helptext=${this.helptext}
|
|
137
|
-
.helptextDropdown=${this.helptextDropdown}
|
|
138
|
-
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
139
|
-
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
140
|
-
class="pkt-datepicker"
|
|
141
|
-
>
|
|
142
|
-
<div class="pkt-contents" ${r.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
143
|
-
${this.multiple?this.renderTags():s.E}
|
|
144
|
-
<div
|
|
145
|
-
class="pkt-datepicker__inputs ${this.range&&this.showRangeLabels?"pkt-input__range-inputs":""}"
|
|
146
|
-
>
|
|
147
|
-
<div class="pkt-input__container">
|
|
148
|
-
${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
|
|
149
|
-
<button
|
|
150
|
-
class="${d.e(this.buttonClasses)}"
|
|
151
|
-
type="button"
|
|
152
|
-
@click=${this.toggleCalendar}
|
|
153
|
-
@keydown=${t=>{(t.key==="Enter"||t.key===" "||t.key==="Space")&&(t.preventDefault(),this.toggleCalendar(t))}}
|
|
154
|
-
?disabled=${this.disabled}
|
|
155
|
-
${r.n(this.btnRef)}
|
|
156
|
-
>
|
|
157
|
-
<pkt-icon name="calendar"></pkt-icon>
|
|
158
|
-
<span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
|
|
159
|
-
</button>
|
|
160
|
-
</div>
|
|
161
|
-
</div>
|
|
162
|
-
</pkt-input-wrapper>
|
|
163
|
-
${this.renderCalendar()}
|
|
164
|
-
`}handleCalendarPosition(){var t;if(this.popupRef.value&&this.inputRef.value){const e=this.multiple&&!!this.maxlength,i=((t=this.inputRef.value.parentElement)==null?void 0:t.getBoundingClientRect())||this.inputRef.value.getBoundingClientRect(),a=e?i.height+30:i.height,l=this.popupRef.value.getBoundingClientRect().height;let u=e?"calc(100% - 30px)":"100%";i&&i.top+l>window.innerHeight&&i.top-l>0&&(u=`calc(100% - ${a}px - ${l}px)`),this.popupRef.value.style.top=u}}handleFocusOut(t){this.contains(t.target)||(this.onBlur(),this.hideCalendar())}async showCalendar(){var t;this.calendarOpen=!0,await g(20),this.handleCalendarPosition(),this.isMobileSafari&&((t=this.calRef.value)==null||t.focusOnCurrentDate())}hideCalendar(){this.calendarOpen=!1}async toggleCalendar(t){t.preventDefault(),this.calendarOpen?this.hideCalendar():this.showCalendar()}clearInputValue(){this._value=[],this.value=""}};n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",1);n([s.n({type:Array})],exports.PktDatepicker.prototype,"_value",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"label",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);n([s.n({type:Number,reflect:!0})],exports.PktDatepicker.prototype,"maxlength",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);n([s.n({type:Boolean})],exports.PktDatepicker.prototype,"showRangeLabels",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"min",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"max",2);n([s.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"withcontrols",2);n([s.n({converter:o.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);n([s.n({converter:o.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"timezone",2);n([v.r()],exports.PktDatepicker.prototype,"inputClasses",2);n([v.r()],exports.PktDatepicker.prototype,"buttonClasses",2);exports.PktDatepicker=n([s.t("pkt-datepicker")],exports.PktDatepicker);
|