@oslokommune/punkt-elements 13.4.1 → 13.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/calendar-32W9p9uc.cjs +115 -0
- package/dist/{calendar-DevQhOup.js → calendar-CJSxvwAq.js} +353 -340
- package/dist/{card-uccD6Pnv.cjs → card-BUITGoqX.cjs} +10 -10
- package/dist/{card-BI1NZONj.js → card-Dtw26f7i.js} +96 -76
- package/dist/checkbox-Gn7Wtk9h.cjs +31 -0
- package/dist/checkbox-ym7z6cpt.js +142 -0
- package/dist/{combobox-BhcqC30d.cjs → combobox-DjO0RMUB.cjs} +1 -1
- package/dist/{combobox-D9dGKWuZ.js → combobox-yE4aYhTi.js} +1 -1
- package/dist/{datepicker-CYOn3tRm.js → datepicker-BJKJBoy_.js} +102 -59
- package/dist/datepicker-CmTrG5GE.cjs +164 -0
- package/dist/index.d.ts +9 -2
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-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-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +6 -6
- package/package.json +3 -3
- package/src/components/calendar/calendar.accessibility.test.ts +111 -0
- package/src/components/calendar/calendar.constraints.test.ts +110 -0
- package/src/components/calendar/calendar.core.test.ts +367 -0
- package/src/components/calendar/calendar.interaction.test.ts +139 -0
- package/src/components/calendar/calendar.selection.test.ts +273 -0
- package/src/components/calendar/calendar.ts +74 -42
- package/src/components/card/card.test.ts +606 -0
- package/src/components/card/card.ts +24 -1
- package/src/components/checkbox/checkbox.test.ts +535 -0
- package/src/components/checkbox/checkbox.ts +44 -1
- package/src/components/combobox/combobox.test.ts +737 -0
- package/src/components/combobox/combobox.ts +1 -1
- package/src/components/datepicker/datepicker.accessibility.test.ts +193 -0
- package/src/components/datepicker/datepicker.core.test.ts +322 -0
- package/src/components/datepicker/datepicker.input.test.ts +268 -0
- package/src/components/datepicker/datepicker.selection.test.ts +286 -0
- package/src/components/datepicker/datepicker.ts +121 -19
- package/src/components/datepicker/datepicker.validation.test.ts +176 -0
- package/dist/calendar-BZe2D4Sr.cjs +0 -108
- package/dist/checkbox-CTRbpbye.js +0 -120
- package/dist/checkbox-wJ26voZd.cjs +0 -30
- package/dist/datepicker-B9rhz_AF.cjs +0 -154
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { E as n, x as c, n as i, a as d } from "./element-CgEWt74-.js";
|
|
2
|
-
import { P as k } from "./input-element-NnrDmp4r.js";
|
|
3
|
-
import { e as b, n as f } from "./ref-BBYSqgeW.js";
|
|
4
|
-
import { e as u } from "./class-map-BpTj9gtz.js";
|
|
5
|
-
var g = Object.defineProperty, y = Object.getOwnPropertyDescriptor, e = (s, h, p, a) => {
|
|
6
|
-
for (var l = a > 1 ? void 0 : a ? y(h, p) : h, o = s.length - 1, r; o >= 0; o--)
|
|
7
|
-
(r = s[o]) && (l = (a ? r(h, p, l) : r(l)) || l);
|
|
8
|
-
return a && l && g(h, p, l), l;
|
|
9
|
-
};
|
|
10
|
-
let t = class extends k {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(...arguments), this.inputRef = b(), this.value = "", this.checkHelptext = null, this.defaultChecked = !1, this.hasTile = !1, this.isSwitch = !1, this.labelPosition = "right", this.hideLabel = !1, this.checked = null, this.type = "checkbox", this.tagText = null, this.optionalTag = !1, this.optionalText = "Valgfritt", this.requiredTag = !1, this.requiredText = "Må fylles ut";
|
|
13
|
-
}
|
|
14
|
-
connectedCallback() {
|
|
15
|
-
super.connectedCallback();
|
|
16
|
-
}
|
|
17
|
-
attributeChangedCallback(s, h, p) {
|
|
18
|
-
s === "defaultChecked" && !this.checked && (this.checked = this.defaultChecked), s === "checked" && (this.checked = this.checked === "" || this.checked === "true" || this.checked === !0), super.attributeChangedCallback(s, h, p);
|
|
19
|
-
}
|
|
20
|
-
firstUpdated(s) {
|
|
21
|
-
s.has("defaultChecked") && !this.checked && (this.checked = this.defaultChecked), super.firstUpdated(s);
|
|
22
|
-
}
|
|
23
|
-
render() {
|
|
24
|
-
const s = u({
|
|
25
|
-
"pkt-input-check__input": !0,
|
|
26
|
-
"pkt-input-check__input--tile": this.hasTile,
|
|
27
|
-
"pkt-input-check__input--tile-disabled": this.disabled && this.hasTile
|
|
28
|
-
}), h = u({
|
|
29
|
-
"pkt-input-check__input-checkbox": !0,
|
|
30
|
-
"pkt-input-check__input-checkbox--error": this.hasError
|
|
31
|
-
}), p = u({
|
|
32
|
-
"pkt-input-check__input-label": !0,
|
|
33
|
-
"pkt-input-check__input-label--disabled": this.disabled,
|
|
34
|
-
"pkt-input-check__input-label--left": this.labelPosition === "left",
|
|
35
|
-
"pkt-input-check__input-label--right": this.labelPosition === "right",
|
|
36
|
-
"pkt-sr-only": this.hideLabel
|
|
37
|
-
}), a = "pkt-tag pkt-tag--small pkt-tag--thin-text", l = () => c`
|
|
38
|
-
${this.tagText ? c`<span class=${a + " pkt-tag--gray"}>${this.tagText}</span>` : n}
|
|
39
|
-
${this.optionalTag ? c`<span class=${a + " pkt-tag--blue-light"}>${this.optionalText}</span>` : n}
|
|
40
|
-
${this.requiredTag ? c`<span class=${a + " pkt-tag--beige"}>${this.requiredText}</span>` : n}
|
|
41
|
-
`, o = () => c`
|
|
42
|
-
<label class=${p} for=${this.id + "-internal"}>
|
|
43
|
-
${this.label} ${l()}
|
|
44
|
-
${this.checkHelptext ? c`<div class="pkt-input-check__input-helptext">${this.checkHelptext}</div>` : n}
|
|
45
|
-
</label>
|
|
46
|
-
`;
|
|
47
|
-
return c`
|
|
48
|
-
<div class="pkt-input-check">
|
|
49
|
-
<div class=${s}>
|
|
50
|
-
${this.labelPosition === "left" ? o() : n}
|
|
51
|
-
<input
|
|
52
|
-
id=${this.id + "-internal"}
|
|
53
|
-
class=${h}
|
|
54
|
-
type="checkbox"
|
|
55
|
-
?disabled=${this.disabled}
|
|
56
|
-
name=${this.name + "-internal"}
|
|
57
|
-
${f(this.inputRef)}
|
|
58
|
-
@change=${this.toggleChecked}
|
|
59
|
-
@blur=${this.onBlur}
|
|
60
|
-
@focus=${this.onFocus}
|
|
61
|
-
?checked=${this.checked}
|
|
62
|
-
role=${this.isSwitch ? "switch" : "checkbox"}
|
|
63
|
-
/>
|
|
64
|
-
${this.labelPosition === "right" ? o() : n}
|
|
65
|
-
</div>
|
|
66
|
-
</div>
|
|
67
|
-
`;
|
|
68
|
-
}
|
|
69
|
-
toggleChecked(s) {
|
|
70
|
-
s.stopImmediatePropagation(), this.touched = !0, this.inputRef.value && (this.checked = this.inputRef.value.matches(":checked"), this.valueChecked(this.checked));
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
e([
|
|
74
|
-
i({ type: String, reflect: !0 })
|
|
75
|
-
], t.prototype, "value", 2);
|
|
76
|
-
e([
|
|
77
|
-
i({ type: String })
|
|
78
|
-
], t.prototype, "checkHelptext", 2);
|
|
79
|
-
e([
|
|
80
|
-
i({ type: Boolean })
|
|
81
|
-
], t.prototype, "defaultChecked", 2);
|
|
82
|
-
e([
|
|
83
|
-
i({ type: Boolean })
|
|
84
|
-
], t.prototype, "hasTile", 2);
|
|
85
|
-
e([
|
|
86
|
-
i({ type: Boolean })
|
|
87
|
-
], t.prototype, "isSwitch", 2);
|
|
88
|
-
e([
|
|
89
|
-
i({ type: String })
|
|
90
|
-
], t.prototype, "labelPosition", 2);
|
|
91
|
-
e([
|
|
92
|
-
i({ type: Boolean })
|
|
93
|
-
], t.prototype, "hideLabel", 2);
|
|
94
|
-
e([
|
|
95
|
-
i({ type: Boolean, reflect: !0 })
|
|
96
|
-
], t.prototype, "checked", 2);
|
|
97
|
-
e([
|
|
98
|
-
i({ type: String, reflect: !0 })
|
|
99
|
-
], t.prototype, "type", 2);
|
|
100
|
-
e([
|
|
101
|
-
i({ type: String })
|
|
102
|
-
], t.prototype, "tagText", 2);
|
|
103
|
-
e([
|
|
104
|
-
i({ type: Boolean })
|
|
105
|
-
], t.prototype, "optionalTag", 2);
|
|
106
|
-
e([
|
|
107
|
-
i({ type: String })
|
|
108
|
-
], t.prototype, "optionalText", 2);
|
|
109
|
-
e([
|
|
110
|
-
i({ type: Boolean })
|
|
111
|
-
], t.prototype, "requiredTag", 2);
|
|
112
|
-
e([
|
|
113
|
-
i({ type: String })
|
|
114
|
-
], t.prototype, "requiredText", 2);
|
|
115
|
-
t = e([
|
|
116
|
-
d("pkt-checkbox")
|
|
117
|
-
], t);
|
|
118
|
-
export {
|
|
119
|
-
t as P
|
|
120
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("./element-6DBpyGQm.cjs"),k=require("./input-element-C4xJoM-X.cjs"),n=require("./ref-iJtiv3o2.cjs"),o=require("./class-map-BBG2gMX4.cjs");var r=Object.defineProperty,u=Object.getOwnPropertyDescriptor,i=(p,e,c,h)=>{for(var s=h>1?void 0:h?u(e,c):e,a=p.length-1,l;a>=0;a--)(l=p[a])&&(s=(h?l(e,c,s):l(s))||s);return h&&s&&r(e,c,s),s};exports.PktCheckbox=class extends k.PktInputElement{constructor(){super(...arguments),this.inputRef=n.e(),this.value="",this.checkHelptext=null,this.defaultChecked=!1,this.hasTile=!1,this.isSwitch=!1,this.labelPosition="right",this.hideLabel=!1,this.checked=null,this.type="checkbox",this.tagText=null,this.optionalTag=!1,this.optionalText="Valgfritt",this.requiredTag=!1,this.requiredText="Må fylles ut"}connectedCallback(){super.connectedCallback()}attributeChangedCallback(e,c,h){e==="defaultChecked"&&!this.checked&&(this.checked=this.defaultChecked),e==="checked"&&(this.checked=this.checked===""||this.checked==="true"||this.checked===!0),super.attributeChangedCallback(e,c,h)}firstUpdated(e){e.has("defaultChecked")&&!this.checked&&(this.checked=this.defaultChecked),super.firstUpdated(e)}render(){const e=o.e({"pkt-input-check__input":!0,"pkt-input-check__input--tile":this.hasTile,"pkt-input-check__input--tile-disabled":this.disabled&&this.hasTile}),c=o.e({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError}),h=o.e({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.disabled,"pkt-input-check__input-label--left":this.labelPosition==="left","pkt-input-check__input-label--right":this.labelPosition==="right","pkt-sr-only":this.hideLabel}),s="pkt-tag pkt-tag--small pkt-tag--thin-text",a=()=>t.x`
|
|
2
|
-
${this.tagText?t.x`<span class=${s+" pkt-tag--gray"}>${this.tagText}</span>`:t.E}
|
|
3
|
-
${this.optionalTag?t.x`<span class=${s+" pkt-tag--blue-light"}>${this.optionalText}</span>`:t.E}
|
|
4
|
-
${this.requiredTag?t.x`<span class=${s+" pkt-tag--beige"}>${this.requiredText}</span>`:t.E}
|
|
5
|
-
`,l=()=>t.x`
|
|
6
|
-
<label class=${h} for=${this.id+"-internal"}>
|
|
7
|
-
${this.label} ${a()}
|
|
8
|
-
${this.checkHelptext?t.x`<div class="pkt-input-check__input-helptext">${this.checkHelptext}</div>`:t.E}
|
|
9
|
-
</label>
|
|
10
|
-
`;return t.x`
|
|
11
|
-
<div class="pkt-input-check">
|
|
12
|
-
<div class=${e}>
|
|
13
|
-
${this.labelPosition==="left"?l():t.E}
|
|
14
|
-
<input
|
|
15
|
-
id=${this.id+"-internal"}
|
|
16
|
-
class=${c}
|
|
17
|
-
type="checkbox"
|
|
18
|
-
?disabled=${this.disabled}
|
|
19
|
-
name=${this.name+"-internal"}
|
|
20
|
-
${n.n(this.inputRef)}
|
|
21
|
-
@change=${this.toggleChecked}
|
|
22
|
-
@blur=${this.onBlur}
|
|
23
|
-
@focus=${this.onFocus}
|
|
24
|
-
?checked=${this.checked}
|
|
25
|
-
role=${this.isSwitch?"switch":"checkbox"}
|
|
26
|
-
/>
|
|
27
|
-
${this.labelPosition==="right"?l():t.E}
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
`}toggleChecked(e){e.stopImmediatePropagation(),this.touched=!0,this.inputRef.value&&(this.checked=this.inputRef.value.matches(":checked"),this.valueChecked(this.checked))}};i([t.n({type:String,reflect:!0})],exports.PktCheckbox.prototype,"value",2);i([t.n({type:String})],exports.PktCheckbox.prototype,"checkHelptext",2);i([t.n({type:Boolean})],exports.PktCheckbox.prototype,"defaultChecked",2);i([t.n({type:Boolean})],exports.PktCheckbox.prototype,"hasTile",2);i([t.n({type:Boolean})],exports.PktCheckbox.prototype,"isSwitch",2);i([t.n({type:String})],exports.PktCheckbox.prototype,"labelPosition",2);i([t.n({type:Boolean})],exports.PktCheckbox.prototype,"hideLabel",2);i([t.n({type:Boolean,reflect:!0})],exports.PktCheckbox.prototype,"checked",2);i([t.n({type:String,reflect:!0})],exports.PktCheckbox.prototype,"type",2);i([t.n({type:String})],exports.PktCheckbox.prototype,"tagText",2);i([t.n({type:Boolean})],exports.PktCheckbox.prototype,"optionalTag",2);i([t.n({type:String})],exports.PktCheckbox.prototype,"optionalText",2);i([t.n({type:Boolean})],exports.PktCheckbox.prototype,"requiredTag",2);i([t.n({type:String})],exports.PktCheckbox.prototype,"requiredText",2);exports.PktCheckbox=i([t.t("pkt-checkbox")],exports.PktCheckbox);
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";const d=require("./class-map-BBG2gMX4.cjs"),o=require("./if-defined-Cni-RHLS.cjs"),s=require("./element-6DBpyGQm.cjs"),m=require("./state-DPobt-Yz.cjs"),h=require("./calendar-BZe2D4Sr.cjs"),v=require("./input-element-C4xJoM-X.cjs"),r=require("./ref-iJtiv3o2.cjs"),k=require("./repeat-CDsZqct8.cjs");require("./icon-B_ryAy4Q.cjs");require("./input-wrapper-CZ-a00V7.cjs");require("./tag-Bbs0U_Au.cjs");const $=require("./pkt-slot-controller-BzddBp7z.cjs"),y={dateformat:{default:"dd.MM.yyyy"},min:{default:null},max:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},p={props:y};var b=Object.defineProperty,x=Object.getOwnPropertyDescriptor,n=(c,t,e,i)=>{for(var a=i>1?void 0:i?x(t,e):t,l=c.length-1,u;l>=0;l--)(u=c[l])&&(a=(i?u(t,e,a):u(a))||a);return i&&a&&b(t,e,a),a};const g=c=>new Promise(t=>setTimeout(t,c));exports.PktDatepicker=class extends v.PktInputElement{constructor(){super(),this.value="",this._value=this.value?Array.isArray(this.value)?this.value:this.value.split(","):[],this.label="Datovelger",this.dateformat=p.props.dateformat.default,this.multiple=p.props.multiple.default,this.maxlength=null,this.range=p.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=p.props.weeknumbers.default,this.withcontrols=p.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=r.e(),this.inputRefTo=r.e(),this.btnRef=r.e(),this.calRef=r.e(),this.popupRef=r.e(),this.helptextSlot=r.e(),this.addToSelected=t=>{const e=t.target;if(!e.value)return;const i=this.min?h.newDate(this.min):null,a=this.max?h.newDate(this.max):null,l=h.newDate(e.value.split(",")[0]);l&&!isNaN(l.getTime())&&(!i||l>=i)&&(!a||l<=a)&&this.calRef.value&&this.calRef.value.handleDateSelect(l),e.value=""},this.slotController=new $.PktSlotController(this,this.helptextSlot)}async connectedCallback(){super.connectedCallback();const t=navigator.userAgent,e=/iP(hone|od|ad)/.test(t);this.inputType=e?"text":"date",document&&document.body.addEventListener("click",i=>{var a,l;(a=this.inputRef)!=null&&a.value&&((l=this.btnRef)!=null&&l.value)&&!this.inputRef.value.contains(i.target)&&!(this.inputRefTo.value&&this.inputRefTo.value.contains(i.target))&&!this.btnRef.value.contains(i.target)&&!i.target.closest(".pkt-calendar-popup")&&this.calendarOpen&&(this.onBlur(),this.hideCalendar())}),this.value.length&&this._value.length===0&&(this._value=Array.isArray(this.value)?this.value:this.value.split(",")),this.min=this.min||p.props.min.default,this.max=this.max||p.props.max.default,typeof this.excludedates=="string"&&(this.excludedates=this.excludedates.split(",")),typeof this.excludeweekdays=="string"&&(this.excludeweekdays=this.excludeweekdays.split(",")),(this.multiple||this.range)&&this.name&&!this.name.endsWith("[]")&&(this.name=this.name+"[]"),this.calendarOpen&&(await g(20),this.handleCalendarPosition())}disconnectedCallback(){super.disconnectedCallback(),document&&document.body.removeEventListener("click",t=>{var e,i;(e=this.inputRef)!=null&&e.value&&((i=this.btnRef)!=null&&i.value)&&!this.inputRef.value.contains(t.target)&&!this.btnRef.value.contains(t.target)&&this.hideCalendar()})}attributeChangedCallback(t,e,i){if(t==="value"){if(this.range&&(i==null?void 0:i.split(",").length)===1)return;this.value!==e&&this.valueChanged(i,e)}t==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=(i==null?void 0:i.split(","))??[]),t==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=(i==null?void 0:i.split(","))??[]),super.attributeChangedCallback(t,e,i)}updated(t){t.has("multiple")&&(this.multiple&&!Array.isArray(this._value)?this._value=typeof this.value=="string"?this.value?this.value.split(",").filter(Boolean):[]:[]:!this.multiple&&Array.isArray(this._value)&&(this._value=this._value.filter(Boolean)),!this.multiple&&Array.isArray(this._value)&&(this._value=[this._value[0]??""])),super.updated(t)}renderInput(){return s.x`
|
|
2
|
-
<input
|
|
3
|
-
class="${d.e(this.inputClasses)}"
|
|
4
|
-
.type=${this.inputType}
|
|
5
|
-
id="${this.id}-input"
|
|
6
|
-
.value=${this._value[0]??""}
|
|
7
|
-
min=${o.o(this.min)}
|
|
8
|
-
max=${o.o(this.max)}
|
|
9
|
-
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
10
|
-
?disabled=${this.disabled}
|
|
11
|
-
@keydown=${t=>{var e,i;if(t.key===","&&((e=this.inputRef.value)==null||e.blur()),(t.key==="Space"||t.key===" ")&&(t.preventDefault(),this.toggleCalendar(t)),t.key==="Enter"){const a=this.internals.form;a?a.requestSubmit():(i=this.inputRef.value)==null||i.blur()}}}
|
|
12
|
-
@input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
|
|
13
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
14
|
-
@blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.manageValidity(t.target),this.value=t.target.value}}
|
|
15
|
-
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
16
|
-
${r.n(this.inputRef)}
|
|
17
|
-
/>
|
|
18
|
-
`}renderRangeInput(){const t={"pkt-input-prefix":this.showRangeLabels,"pkt-hide":!this.showRangeLabels};return s.x`
|
|
19
|
-
${this.showRangeLabels?s.x` <div class="pkt-input-prefix">${this.strings.generic.from}</div> `:s.E}
|
|
20
|
-
<input
|
|
21
|
-
class=${d.e(this.inputClasses)}
|
|
22
|
-
.type=${this.inputType}
|
|
23
|
-
id="${this.id}-input"
|
|
24
|
-
.value=${this._value[0]??""}
|
|
25
|
-
min=${o.o(this.min)}
|
|
26
|
-
max=${o.o(this.max)}
|
|
27
|
-
?disabled=${this.disabled}
|
|
28
|
-
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
29
|
-
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRef.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const l=this.internals.form;l?l.requestSubmit():(a=this.inputRefTo.value)==null||a.focus()}}}
|
|
30
|
-
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
31
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
32
|
-
@blur=${e=>{var i,a;if(e.target.value){this.manageValidity(e.target);const l=h.fromISOToDate(e.target.value);l&&this._value[0]!==e.target.value&&this._value[1]&&(this.clearInputValue(),(a=(i=this.calRef)==null?void 0:i.value)==null||a.handleDateSelect(l))}else this._value[0]&&this.clearInputValue()}}
|
|
33
|
-
@change=${e=>{e.stopImmediatePropagation()}}
|
|
34
|
-
${r.n(this.inputRef)}
|
|
35
|
-
/>
|
|
36
|
-
<div class="${d.e(t)}" id="${this.id}-to-label">
|
|
37
|
-
${this.strings.generic.to}
|
|
38
|
-
</div>
|
|
39
|
-
${this.showRangeLabels?s.E:s.x` <div class="pkt-input-separator">–</div> `}
|
|
40
|
-
<input
|
|
41
|
-
class=${d.e(this.inputClasses)}
|
|
42
|
-
.type=${this.inputType}
|
|
43
|
-
id="${this.id}-to"
|
|
44
|
-
aria-labelledby="${this.id}-to-label"
|
|
45
|
-
.value=${this._value[1]??""}
|
|
46
|
-
min=${o.o(this.min)}
|
|
47
|
-
max=${o.o(this.max)}
|
|
48
|
-
?disabled=${this.disabled}
|
|
49
|
-
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
50
|
-
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRefTo.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const l=this.internals.form;l?l.requestSubmit():(a=this.inputRefTo.value)==null||a.blur()}}}
|
|
51
|
-
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
52
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
53
|
-
@blur=${e=>{var i,a,l;if((i=this.calRef.value)!=null&&i.contains(e.relatedTarget)||this.onBlur(),e.target.value){this.manageValidity(e.target);const u=e.target.value;this.min&&this.min>u?this.internals.setValidity({rangeUnderflow:!0},this.strings.forms.messages.rangeUnderflow,e.target):this.max&&this.max<u&&this.internals.setValidity({rangeOverflow:!0},this.strings.forms.messages.rangeOverflow,e.target);const f=h.fromISOToDate(e.target.value);f&&this._value[1]!==h.formatISODate(f)&&((l=(a=this.calRef)==null?void 0:a.value)==null||l.handleDateSelect(f))}}}
|
|
54
|
-
@change=${e=>{this.touched=!0,e.stopImmediatePropagation()}}
|
|
55
|
-
${r.n(this.inputRefTo)}
|
|
56
|
-
/>
|
|
57
|
-
`}renderMultipleInput(){return console.log("range",this.range,"multiple",this.multiple),s.x`
|
|
58
|
-
<input
|
|
59
|
-
class=${d.e(this.inputClasses)}
|
|
60
|
-
.type=${this.inputType}
|
|
61
|
-
id="${this.id}-input"
|
|
62
|
-
min=${o.o(this.min)}
|
|
63
|
-
max=${o.o(this.max)}
|
|
64
|
-
?disabled=${this.disabled||this.maxlength&&this._value.length>=this.maxlength}
|
|
65
|
-
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
66
|
-
@blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.addToSelected(t)}}
|
|
67
|
-
@input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
|
|
68
|
-
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
69
|
-
@keydown=${t=>{var e;if(t.key===","&&(t.preventDefault(),this.addToSelected(t)),(t.key==="Space"||t.key===" ")&&(t.preventDefault(),this.toggleCalendar(t)),t.key==="Enter"){const i=this.internals.form;i?i.requestSubmit():(e=this.inputRef.value)==null||e.blur()}}}
|
|
70
|
-
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
71
|
-
${r.n(this.inputRef)}
|
|
72
|
-
/>
|
|
73
|
-
`}renderTags(){return s.x`
|
|
74
|
-
<div class="pkt-datepicker__tags" aria-live="polite">
|
|
75
|
-
${this._value[0]?k.c((this._value??[]).filter(Boolean),t=>t,t=>s.x`
|
|
76
|
-
<pkt-tag
|
|
77
|
-
.id="${this.id+t+"-tag"}"
|
|
78
|
-
closeTag
|
|
79
|
-
ariaLabel="${this.strings.calendar.deleteDate} ${h.fromISOtoLocal(t,this.dateformat)}"
|
|
80
|
-
@close=${()=>{var e;return(e=this.calRef.value)==null?void 0:e.handleDateSelect(h.fromISOToDate(t))}}
|
|
81
|
-
><time datetime="${t}">${h.fromISOtoLocal(t,this.dateformat)}</time></pkt-tag
|
|
82
|
-
>
|
|
83
|
-
`):s.E}
|
|
84
|
-
</div>
|
|
85
|
-
`}renderCalendar(){return s.x`<div
|
|
86
|
-
class="pkt-calendar-popup pkt-${this.calendarOpen?"show":"hide"}"
|
|
87
|
-
@focusout=${t=>{this.calendarOpen&&this.handleFocusOut(t)}}
|
|
88
|
-
id="${this.id}-popup"
|
|
89
|
-
${r.n(this.popupRef)}
|
|
90
|
-
>
|
|
91
|
-
<pkt-calendar
|
|
92
|
-
id="${this.id}-calendar"
|
|
93
|
-
?multiple=${this.multiple}
|
|
94
|
-
?range=${this.range}
|
|
95
|
-
?weeknumbers=${this.weeknumbers}
|
|
96
|
-
?withcontrols=${this.withcontrols}
|
|
97
|
-
.maxMultiple=${this.maxlength}
|
|
98
|
-
.selected=${this._value}
|
|
99
|
-
.earliest=${this.min}
|
|
100
|
-
.latest=${this.max}
|
|
101
|
-
.excludedates=${Array.isArray(this.excludedates)?this.excludedates:this.excludedates.split(",")}
|
|
102
|
-
.excludeweekdays=${this.excludeweekdays}
|
|
103
|
-
.currentmonth=${this.currentmonth?h.newDate(this.currentmonth):null}
|
|
104
|
-
@date-selected=${t=>{this.value=!this.multiple&&!this.range?t.detail[0]:t.detail,this._value=t.detail,this.inputRef.value&&(this.range&&this.inputRefTo.value?(this.inputRef.value.value=this._value[0]??"",this.inputRefTo.value.value=this._value[1]??""):this.multiple||(this.inputRef.value.value=this._value.length?this._value[0]:""))}}
|
|
105
|
-
@close=${()=>{this.onBlur(),this.hideCalendar()}}
|
|
106
|
-
${r.n(this.calRef)}
|
|
107
|
-
></pkt-calendar>
|
|
108
|
-
</div>`}render(){return console.log("multiple",this.multiple,"value",this.value,"_value",this._value),this.inputClasses={"pkt-input":!0,"pkt-datepicker__input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-datepicker--hasrangelabels":this.showRangeLabels,"pkt-datepicker--multiple":this.multiple,"pkt-datepicker--range":this.range},this.buttonClasses={"pkt-input-icon":!0,"pkt-btn":!0,"pkt-btn--icon-only":!0,"pkt-btn--tertiary":!0},s.x`
|
|
109
|
-
<pkt-input-wrapper
|
|
110
|
-
label="${this.label}"
|
|
111
|
-
forId="${this.id}-input"
|
|
112
|
-
?counter=${this.multiple&&!!this.maxlength}
|
|
113
|
-
.counterCurrent=${this.value?this._value.length:0}
|
|
114
|
-
.counterMaxLength=${this.maxlength}
|
|
115
|
-
?disabled=${this.disabled}
|
|
116
|
-
?hasError=${this.hasError}
|
|
117
|
-
?hasFieldset=${this.hasFieldset}
|
|
118
|
-
?inline=${this.inline}
|
|
119
|
-
?required=${this.required}
|
|
120
|
-
?optionalTag=${this.optionalTag}
|
|
121
|
-
?requiredTag=${this.requiredTag}
|
|
122
|
-
?useWrapper=${this.useWrapper}
|
|
123
|
-
.optionalText=${this.optionalText}
|
|
124
|
-
.requiredText=${this.requiredText}
|
|
125
|
-
.tagText=${this.tagText}
|
|
126
|
-
.errorMessage=${this.errorMessage}
|
|
127
|
-
.helptext=${this.helptext}
|
|
128
|
-
.helptextDropdown=${this.helptextDropdown}
|
|
129
|
-
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
130
|
-
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
131
|
-
class="pkt-datepicker"
|
|
132
|
-
>
|
|
133
|
-
<div class="pkt-contents" ${r.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
134
|
-
${this.multiple?this.renderTags():s.E}
|
|
135
|
-
<div
|
|
136
|
-
class="pkt-datepicker__inputs ${this.range&&this.showRangeLabels?"pkt-input__range-inputs":""}"
|
|
137
|
-
>
|
|
138
|
-
<div class="pkt-input__container">
|
|
139
|
-
${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
|
|
140
|
-
<button
|
|
141
|
-
class="${d.e(this.buttonClasses)}"
|
|
142
|
-
type="button"
|
|
143
|
-
@click=${this.toggleCalendar}
|
|
144
|
-
?disabled=${this.disabled}
|
|
145
|
-
${r.n(this.btnRef)}
|
|
146
|
-
>
|
|
147
|
-
<pkt-icon name="calendar"></pkt-icon>
|
|
148
|
-
<span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
|
|
149
|
-
</button>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
</pkt-input-wrapper>
|
|
153
|
-
${this.renderCalendar()}
|
|
154
|
-
`}handleCalendarPosition(){var t;if(this.popupRef.value&&this.inputRef.value){const e=this.multiple&&!!this.maxlength,i=((t=this.inputRef.value.parentElement)==null?void 0:t.getBoundingClientRect())||this.inputRef.value.getBoundingClientRect(),a=e?i.height+30:i.height,l=this.popupRef.value.getBoundingClientRect().height;let u=e?"calc(100% - 30px)":"100%";i&&i.top+l>window.innerHeight&&i.top-l>0&&(u=`calc(100% - ${a}px - ${l}px)`),this.popupRef.value.style.top=u}}handleFocusOut(t){this.contains(t.target)||(this.onBlur(),this.hideCalendar())}async showCalendar(){var t;this.calendarOpen=!0,await g(20),this.handleCalendarPosition(),this.isMobileSafari&&((t=this.calRef.value)==null||t.focusOnCurrentDate())}hideCalendar(){this.calendarOpen=!1}async toggleCalendar(t){t.preventDefault(),this.calendarOpen?this.hideCalendar():this.showCalendar()}};n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",2);n([s.n({type:Array})],exports.PktDatepicker.prototype,"_value",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"label",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);n([s.n({type:Number,reflect:!0})],exports.PktDatepicker.prototype,"maxlength",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);n([s.n({type:Boolean})],exports.PktDatepicker.prototype,"showRangeLabels",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"min",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"max",2);n([s.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"withcontrols",2);n([s.n({converter:h.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);n([s.n({converter:h.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"timezone",2);n([m.r()],exports.PktDatepicker.prototype,"inputClasses",2);n([m.r()],exports.PktDatepicker.prototype,"buttonClasses",2);exports.PktDatepicker=n([s.t("pkt-datepicker")],exports.PktDatepicker);
|