@oslokommune/punkt-elements 12.31.2 → 12.32.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/dist/{alert-BDxxRqgi.cjs → alert-D5G5UJuo.cjs} +1 -1
- package/dist/{alert-D0S57u0r.js → alert-gERpVuB7.js} +6 -6
- package/dist/alert.d.ts +32 -0
- package/dist/{backlink-CzpB-ih9.js → backlink-DdNgqA56.js} +2 -2
- package/dist/{backlink-Dn4DfWVR.cjs → backlink-Q2HTG9jm.cjs} +1 -1
- package/dist/backlink.d.ts +32 -0
- package/dist/{button-Beo3c7cx.cjs → button-BPyZeW73.cjs} +1 -1
- package/dist/{button-9NwGr-OS.js → button-rArIL0-j.js} +3 -3
- package/dist/button.d.ts +32 -0
- package/dist/{calendar-BbZNxsKY.js → calendar-1ryAEdX3.js} +4 -4
- package/dist/{calendar-CxBo98iI.cjs → calendar-2DqPLXdD.cjs} +1 -1
- package/dist/calendar.d.ts +32 -0
- package/dist/{card-DQfNKnKl.js → card-BbMBpvJt.js} +7 -7
- package/dist/{card-C63x_nll.cjs → card-ZX09f_ka.cjs} +1 -1
- package/dist/card.d.ts +32 -0
- package/dist/{checkbox-9Zjy_NU7.cjs → checkbox-BnDG6wIO.cjs} +1 -1
- package/dist/{checkbox-CzDpR6_8.js → checkbox-Ceui2TLp.js} +4 -4
- package/dist/checkbox.d.ts +32 -0
- package/dist/{class-map-DWtqmIRS.js → class-map-ChuDQU5C.js} +1 -1
- package/dist/{class-map-Dj5mbCUg.cjs → class-map-D4rXyUxT.cjs} +1 -1
- package/dist/combobox-DH-YlbNh.cjs +115 -0
- package/dist/combobox-DbO6I0GT.js +694 -0
- package/dist/combobox.d.ts +47 -0
- package/dist/{datepicker-CYUvRGhE.js → datepicker-8MOgQsyL.js} +144 -196
- package/dist/datepicker-BRH-59Q9.cjs +153 -0
- package/dist/datepicker.d.ts +32 -0
- package/dist/directive-helpers-D7XIyCQ_.js +45 -0
- package/dist/directive-helpers-mGjAtADc.cjs +5 -0
- package/dist/{element-CzFXQBoS.cjs → element-BBo3JZk5.cjs} +1 -1
- package/dist/{element-C7XjZtLU.js → element-G8JoS0Lj.js} +6 -0
- package/dist/{helptext-B9kxDc2b.cjs → helptext-B4Uc-d56.cjs} +2 -2
- package/dist/{helptext-CqnoPodd.js → helptext-Y4cSgTkd.js} +10 -10
- package/dist/helptext.d.ts +32 -0
- package/dist/{icon-BEUgV9Wo.js → icon-BJnwW0eh.js} +1 -1
- package/dist/{icon-BOKusjAA.cjs → icon-BTUCDPN5.cjs} +1 -1
- package/dist/icon.d.ts +32 -0
- package/dist/{if-defined-CpIkv1A4.cjs → if-defined-C1ZDVzYn.cjs} +1 -1
- package/dist/{if-defined-eRX4e5zO.js → if-defined-rCqT8Od1.js} +1 -1
- package/dist/index.d.ts +208 -14
- package/dist/input-element-AhnBdCb8.cjs +1 -0
- package/dist/{input-element-BK8UkQli.js → input-element-DM2uSYaW.js} +22 -19
- package/dist/input-wrapper-BdZxmQyO.cjs +52 -0
- package/dist/input-wrapper-DQmYzhcy.js +185 -0
- package/dist/input-wrapper.d.ts +32 -0
- package/dist/{link-D3U0Jkz8.js → link-C3lW3z8X.js} +5 -5
- package/dist/{link-1iq0Pmuf.cjs → link-DOVlsg2S.cjs} +1 -1
- package/dist/link.d.ts +32 -0
- package/dist/{linkcard-CRpo3tiw.js → linkcard-CvqqyHVW.js} +4 -4
- package/dist/{linkcard-2WzDJPZz.cjs → linkcard-DDD92XfD.cjs} +1 -1
- package/dist/linkcard.d.ts +32 -0
- package/dist/listbox-BTVnrHWv.cjs +95 -0
- package/dist/listbox-DX-Euxdm.js +360 -0
- package/dist/listbox.d.ts +47 -0
- package/dist/{loader-B1edLWTg.js → loader-BudoV0yd.js} +6 -6
- package/dist/{loader-DI74pe25.cjs → loader-Csq0Yd1k.cjs} +1 -1
- package/dist/loader.d.ts +32 -0
- package/dist/{messagebox-DQpEMkS2.cjs → messagebox-8GwnNqb0.cjs} +1 -1
- package/dist/{messagebox-KP-8-tA9.js → messagebox-D6uexEhg.js} +6 -6
- package/dist/messagebox.d.ts +32 -0
- package/dist/{modal-ytIJwfr3.cjs → modal-CLixB4Dz.cjs} +1 -1
- package/dist/{modal-kPX8nO_L.js → modal-DnYn2Rlg.js} +6 -6
- package/dist/modal.d.ts +32 -0
- 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 -0
- package/dist/pkt-combobox.js +6 -0
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.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 +45 -43
- 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 -0
- package/dist/pkt-listbox.js +6 -0
- 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-options-controller-BtU1zEtG.cjs +1 -0
- package/dist/pkt-options-controller-CZplGTgu.js +38 -0
- 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-slot-controller-CqNvEpFd.cjs +1 -0
- package/dist/{pkt-slot-controller-Clbye6cM.js → pkt-slot-controller-D1DakVrU.js} +17 -7
- 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-B6A9UVXS.cjs → progressbar-BW_icNId.cjs} +1 -1
- package/dist/{progressbar-D0nxLqHu.js → progressbar-czvExwTL.js} +5 -5
- package/dist/progressbar.d.ts +32 -0
- package/dist/{radiobutton-BWyQgR_x.cjs → radiobutton-BeSuCrbp.cjs} +1 -1
- package/dist/{radiobutton-DLWjvLBO.js → radiobutton-DKo27Stm.js} +5 -5
- package/dist/radiobutton.d.ts +32 -0
- package/dist/ref-DsoUUoPU.cjs +9 -0
- package/dist/ref-cRTOoM4R.js +102 -0
- package/dist/repeat-CArTw6-s.js +61 -0
- package/dist/repeat-kruY8poV.cjs +5 -0
- package/dist/select-DxHhPEgD.js +118 -0
- package/dist/select-lvFnhEVg.cjs +49 -0
- package/dist/select.d.ts +32 -0
- package/dist/{state-HNj0_316.cjs → state-BILlRnrD.cjs} +1 -1
- package/dist/{state-CDQk0DFQ.js → state-gfUuUqVg.js} +1 -1
- package/dist/{tag-CmFcSdOV.js → tag-CWx1XsGR.js} +7 -7
- package/dist/{tag-BeLSOjNh.cjs → tag-DThwKsrg.cjs} +1 -1
- package/dist/tag.d.ts +32 -0
- package/dist/{textarea-BPqWCymU.js → textarea-BNNDbxxO.js} +18 -17
- package/dist/{textarea-VG-UTMLP.cjs → textarea-CDsLbogK.cjs} +6 -6
- package/dist/textarea.d.ts +32 -0
- package/dist/{textinput-CEP7QA3E.cjs → textinput-C3C088Ki.cjs} +5 -4
- package/dist/{textinput-VD74aGzx.js → textinput-M8I4dfoP.js} +25 -24
- package/dist/textinput.d.ts +32 -0
- package/package.json +3 -3
- package/src/components/combobox/combobox.ts +873 -0
- package/src/components/combobox/countrycodes.json +927 -0
- package/src/components/combobox/index.ts +6 -0
- package/src/components/datepicker/datepicker.ts +2 -0
- package/src/components/helptext/helptext.ts +1 -1
- package/src/components/index.ts +7 -0
- package/src/components/input-wrapper/input-wrapper.ts +42 -34
- package/src/components/listbox/index.ts +4 -0
- package/src/components/listbox/listbox.ts +474 -0
- package/src/components/select/select.ts +7 -0
- package/src/components/textinput/textinput.ts +3 -2
- package/dist/datepicker-FuAL0uNU.cjs +0 -155
- package/dist/input-element-Dtyuf6s8.cjs +0 -1
- package/dist/input-wrapper-Bo2_t6pA.cjs +0 -50
- package/dist/input-wrapper-DaZZq8c0.js +0 -172
- package/dist/pkt-slot-controller-Oc32unDk.cjs +0 -1
- package/dist/ref-2anvRHT4.cjs +0 -13
- package/dist/ref-DbOSDQbk.js +0 -143
- package/dist/select-CzuxXKll.js +0 -150
- package/dist/select-DZL6aa2s.cjs +0 -48
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { P as m, E as s, x as p, n as r, a as k } from "./element-G8JoS0Lj.js";
|
|
2
|
+
import { P as v } from "./pkt-slot-controller-D1DakVrU.js";
|
|
3
|
+
import { e as f, n as g } from "./ref-cRTOoM4R.js";
|
|
4
|
+
import { o as w } from "./icon-BJnwW0eh.js";
|
|
5
|
+
import { e as b } from "./class-map-ChuDQU5C.js";
|
|
6
|
+
import { r as S } from "./state-gfUuUqVg.js";
|
|
7
|
+
import { u as T } from "./stringutils-DJjRa8dG.js";
|
|
8
|
+
import { s as i } from "./input-wrapper-Bw9tARAD.js";
|
|
9
|
+
import "./helptext-Y4cSgTkd.js";
|
|
10
|
+
var E = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, e = (o, h, a, n) => {
|
|
11
|
+
for (var l = n > 1 ? void 0 : n ? _(h, a) : h, u = o.length - 1, d; u >= 0; u--)
|
|
12
|
+
(d = o[u]) && (l = (n ? d(h, a, l) : d(l)) || l);
|
|
13
|
+
return n && l && E(h, a, l), l;
|
|
14
|
+
};
|
|
15
|
+
let t = class extends m {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(), this.defaultSlot = f(), this.helptextSlot = f(), this.hasHelptextSlot = !0, this.forId = T(), this.label = "", this.helptext = null, this.helptextDropdown = null, this.helptextDropdownButton = null, this.counter = i.props.counter.default, this.counterCurrent = 0, this.counterMaxLength = 0, this.counterError = null, this.counterPosition = "bottom", this.optionalTag = i.props.optionalTag.default, this.optionalText = i.props.optionalText.default, this.requiredTag = i.props.requiredTag.default, this.requiredText = i.props.requiredText.default, this.hasError = i.props.hasError.default, this.errorMessage = "", this.disabled = i.props.disabled.default, this.inline = i.props.inline.default, this.ariaDescribedby = void 0, this.hasFieldset = i.props.hasFieldset.default, this.useWrapper = i.props.useWrapper.default, this.role = "group", this.slotController = new v(this, this.defaultSlot, this.helptextSlot);
|
|
18
|
+
}
|
|
19
|
+
updateSlots(o) {
|
|
20
|
+
this.hasHelptextSlot = o.has("helptext"), this.requestUpdate();
|
|
21
|
+
}
|
|
22
|
+
updated(o) {
|
|
23
|
+
super.updated(o);
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
const o = {
|
|
27
|
+
"pkt-inputwrapper": !0,
|
|
28
|
+
"pkt-inputwrapper--error": this.hasError,
|
|
29
|
+
"pkt-inputwrapper--disabled": this.disabled,
|
|
30
|
+
"pkt-inputwrapper--inline": this.inline
|
|
31
|
+
}, h = {
|
|
32
|
+
"pkt-tag": !0,
|
|
33
|
+
"pkt-tag--small": !0,
|
|
34
|
+
"pkt-tag--thin-text": !0,
|
|
35
|
+
"pkt-tag--blue-light": this.optionalTag,
|
|
36
|
+
"pkt-tag--beige": !this.optionalTag && this.requiredTag
|
|
37
|
+
}, a = this.ariaDescribedby ? this.ariaDescribedby : this.helptext ? `${this.forId}-helptext` : s, n = () => this.optionalTag || this.requiredTag ? p`<span class=${b(h)}
|
|
38
|
+
>${this.optionalTag ? this.optionalText : this.requiredTag ? this.requiredText : s}</span
|
|
39
|
+
>` : s, l = () => this.useWrapper ? this.hasFieldset ? p`<legend
|
|
40
|
+
class="pkt-inputwrapper__legend"
|
|
41
|
+
id="${this.forId}-label"
|
|
42
|
+
@click=${this.handleLabelClick}
|
|
43
|
+
>
|
|
44
|
+
${this.label} ${n()}
|
|
45
|
+
</legend>` : p`<label
|
|
46
|
+
class="pkt-inputwrapper__label"
|
|
47
|
+
for="${this.forId}"
|
|
48
|
+
aria-describedby="${a}"
|
|
49
|
+
id="${this.forId}-label"
|
|
50
|
+
@click=${this.handleLabelClick}
|
|
51
|
+
>${this.label}${n()}</label
|
|
52
|
+
>` : p`<label
|
|
53
|
+
for="${this.forId}"
|
|
54
|
+
class="pkt-sr-only"
|
|
55
|
+
aria-describedby="${a}"
|
|
56
|
+
id="${this.forId}-label"
|
|
57
|
+
>
|
|
58
|
+
${this.label}
|
|
59
|
+
</label>`, u = () => !this.helptext && !this.hasHelptextSlot && !this.helptextDropdown ? s : p`
|
|
60
|
+
<pkt-helptext
|
|
61
|
+
.forId=${this.forId}
|
|
62
|
+
.helptext=${this.helptext}
|
|
63
|
+
.helptextDropdown=${this.helptextDropdown}
|
|
64
|
+
.helptextDropdownButton=${this.helptextDropdownButton || i.props.helptextDropdownButton.default}
|
|
65
|
+
@toggleHelpText=${($) => {
|
|
66
|
+
this.toggleDropdown($);
|
|
67
|
+
}}
|
|
68
|
+
${g(this.helptextSlot)}
|
|
69
|
+
name="helptext"
|
|
70
|
+
></pkt-helptext>
|
|
71
|
+
`, d = () => this.counter ? p`<div class="pkt-input__counter" aria-live="polite" aria-atomic="true">
|
|
72
|
+
${this.counterError ? this.counterError : s} ${this.counterCurrent || 0}
|
|
73
|
+
${this.counterMaxLength ? `/${this.counterMaxLength}` : s}
|
|
74
|
+
</div>` : s, y = () => this.hasError && this.errorMessage ? p`<div
|
|
75
|
+
role="alert"
|
|
76
|
+
class="pkt-alert pkt-alert--error pkt-alert--compact"
|
|
77
|
+
aria-live="assertive"
|
|
78
|
+
aria-atomic="true"
|
|
79
|
+
id="${this.forId}-error"
|
|
80
|
+
>
|
|
81
|
+
<pkt-icon name="alert-error" class="pkt-alert__icon"></pkt-icon>
|
|
82
|
+
<div class="pkt-alert__text">${w(this.errorMessage)}</div>
|
|
83
|
+
</div>` : s, c = () => p`
|
|
84
|
+
${l()} ${u()}
|
|
85
|
+
${this.counterPosition === "top" ? d() : s}
|
|
86
|
+
<div class="pkt-contents" ${g(this.defaultSlot)}></div>
|
|
87
|
+
${this.counterPosition === "bottom" ? d() : s} ${y()}
|
|
88
|
+
`, x = () => this.hasFieldset ? p`<fieldset class="pkt-inputwrapper__fieldset" aria-describedby="${a}">
|
|
89
|
+
${c()}
|
|
90
|
+
</fieldset>` : p`<div class="pkt-inputwrapper__fieldset">${c()}</div>`;
|
|
91
|
+
return p`<div class=${b(o)}>${x()}</div> `;
|
|
92
|
+
}
|
|
93
|
+
toggleDropdown(o) {
|
|
94
|
+
this.dispatchEvent(
|
|
95
|
+
new CustomEvent("toggleHelpText", {
|
|
96
|
+
bubbles: !1,
|
|
97
|
+
detail: { isOpen: o.detail.isOpen }
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
handleLabelClick(o) {
|
|
102
|
+
this.disabled && (o.preventDefault(), o.stopImmediatePropagation()), this.dispatchEvent(
|
|
103
|
+
new CustomEvent("labelClick", {
|
|
104
|
+
bubbles: !0,
|
|
105
|
+
composed: !0,
|
|
106
|
+
detail: "label clicked"
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
e([
|
|
112
|
+
S()
|
|
113
|
+
], t.prototype, "hasHelptextSlot", 2);
|
|
114
|
+
e([
|
|
115
|
+
r({ type: String })
|
|
116
|
+
], t.prototype, "forId", 2);
|
|
117
|
+
e([
|
|
118
|
+
r({ type: String })
|
|
119
|
+
], t.prototype, "label", 2);
|
|
120
|
+
e([
|
|
121
|
+
r({ type: String })
|
|
122
|
+
], t.prototype, "helptext", 2);
|
|
123
|
+
e([
|
|
124
|
+
r({ type: String })
|
|
125
|
+
], t.prototype, "helptextDropdown", 2);
|
|
126
|
+
e([
|
|
127
|
+
r({ type: String })
|
|
128
|
+
], t.prototype, "helptextDropdownButton", 2);
|
|
129
|
+
e([
|
|
130
|
+
r({ type: Boolean })
|
|
131
|
+
], t.prototype, "counter", 2);
|
|
132
|
+
e([
|
|
133
|
+
r({ type: Number })
|
|
134
|
+
], t.prototype, "counterCurrent", 2);
|
|
135
|
+
e([
|
|
136
|
+
r({ type: Number })
|
|
137
|
+
], t.prototype, "counterMaxLength", 2);
|
|
138
|
+
e([
|
|
139
|
+
r({ type: String })
|
|
140
|
+
], t.prototype, "counterError", 2);
|
|
141
|
+
e([
|
|
142
|
+
r({ type: String, reflect: !1 })
|
|
143
|
+
], t.prototype, "counterPosition", 2);
|
|
144
|
+
e([
|
|
145
|
+
r({ type: Boolean })
|
|
146
|
+
], t.prototype, "optionalTag", 2);
|
|
147
|
+
e([
|
|
148
|
+
r({ type: String })
|
|
149
|
+
], t.prototype, "optionalText", 2);
|
|
150
|
+
e([
|
|
151
|
+
r({ type: Boolean })
|
|
152
|
+
], t.prototype, "requiredTag", 2);
|
|
153
|
+
e([
|
|
154
|
+
r({ type: String })
|
|
155
|
+
], t.prototype, "requiredText", 2);
|
|
156
|
+
e([
|
|
157
|
+
r({ type: Boolean })
|
|
158
|
+
], t.prototype, "hasError", 2);
|
|
159
|
+
e([
|
|
160
|
+
r({ type: String })
|
|
161
|
+
], t.prototype, "errorMessage", 2);
|
|
162
|
+
e([
|
|
163
|
+
r({ type: Boolean })
|
|
164
|
+
], t.prototype, "disabled", 2);
|
|
165
|
+
e([
|
|
166
|
+
r({ type: Boolean })
|
|
167
|
+
], t.prototype, "inline", 2);
|
|
168
|
+
e([
|
|
169
|
+
r({ type: String })
|
|
170
|
+
], t.prototype, "ariaDescribedby", 2);
|
|
171
|
+
e([
|
|
172
|
+
r({ type: Boolean })
|
|
173
|
+
], t.prototype, "hasFieldset", 2);
|
|
174
|
+
e([
|
|
175
|
+
r({ type: Boolean })
|
|
176
|
+
], t.prototype, "useWrapper", 2);
|
|
177
|
+
e([
|
|
178
|
+
r({ type: String, reflect: !0 })
|
|
179
|
+
], t.prototype, "role", 2);
|
|
180
|
+
t = e([
|
|
181
|
+
k("pkt-input-wrapper")
|
|
182
|
+
], t);
|
|
183
|
+
export {
|
|
184
|
+
t as P
|
|
185
|
+
};
|
package/dist/input-wrapper.d.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
export { }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Pkt Select is a wrapper for the native select element using the pkt-input-wrapper component.
|
|
6
|
+
*
|
|
7
|
+
* The component will prioritize options passed as a prop over options passed as children if both are provided.
|
|
8
|
+
* This is to allow for dynamic options that might change in the case of both children/slot and props are provided.
|
|
9
|
+
*
|
|
10
|
+
* @slot (default) - Options to be rendered as children
|
|
11
|
+
* @prop {TSelectOption[]} options - Options to be rendered as children
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
declare global {
|
|
16
|
+
interface HTMLElementTagNameMap {
|
|
17
|
+
'pkt-select': PktSelect & HTMLSelectElement;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
interface HTMLElementTagNameMap {
|
|
24
|
+
'pkt-combobox': PktCombobox & HTMLSelectElement;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
4
29
|
declare global {
|
|
5
30
|
interface HTMLElementTagNameMap {
|
|
6
31
|
'pkt-icon': PktIcon;
|
|
@@ -8,6 +33,13 @@ declare global {
|
|
|
8
33
|
}
|
|
9
34
|
|
|
10
35
|
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
'pkt-listbox': PktListbox;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
11
43
|
declare global {
|
|
12
44
|
interface Window {
|
|
13
45
|
pktTz: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as f, x as k, E as h, n as i, a as m } from "./element-
|
|
2
|
-
import { P as d } from "./pkt-slot-controller-
|
|
3
|
-
import { e as u, n as P } from "./ref-
|
|
4
|
-
import { e as y } from "./class-map-
|
|
5
|
-
import "./icon-
|
|
1
|
+
import { P as f, x as k, E as h, n as i, a as m } from "./element-G8JoS0Lj.js";
|
|
2
|
+
import { P as d } from "./pkt-slot-controller-D1DakVrU.js";
|
|
3
|
+
import { e as u, n as P } from "./ref-cRTOoM4R.js";
|
|
4
|
+
import { e as y } from "./class-map-ChuDQU5C.js";
|
|
5
|
+
import "./icon-BJnwW0eh.js";
|
|
6
6
|
const g = "pkt-link", v = !0, _ = {
|
|
7
7
|
href: {
|
|
8
8
|
name: "URL",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const e=require("./element-
|
|
1
|
+
"use strict";const e=require("./element-BBo3JZk5.cjs"),k=require("./pkt-slot-controller-CqNvEpFd.cjs"),p=require("./ref-DsoUUoPU.cjs"),h=require("./class-map-D4rXyUxT.cjs");require("./icon-BTUCDPN5.cjs");const f="pkt-link",u=!0,d={href:{name:"URL",description:"URL til lenken",type:"string",default:"#"},target:{name:"Mål",description:"Mål for lenken",type:["_blank","_self","_parent","_top"],default:"_self"},iconName:{name:"Ikon",description:"Ikon som skal vises ved siden av lenketeksten",type:"icon"},iconPosition:{name:"Ikonposisjon",description:"Posisjonen til ikonet i forhold til lenketeksten",type:["left","right"]},external:{name:"Ekstern lenke",description:"Vis ikon for ekstern lenke",type:"boolean",default:!1}},m={default:{description:"Innholdet i lenken"}},c={name:f,"css-class":"pkt-link","dark-mode":!0,isElement:u,props:d,slots:m};var P=Object.defineProperty,y=Object.getOwnPropertyDescriptor,i=(s,n,r,o)=>{for(var t=o>1?void 0:o?y(n,r):n,l=s.length-1,a;l>=0;l--)(a=s[l])&&(t=(o?a(n,r,t):a(t))||t);return o&&t&&P(n,r,t),t};exports.PktLink=class extends e.PktElement{constructor(){super(),this.defaultSlot=p.e(),this.href=c.props.href.default,this.iconName=void 0,this.iconPosition=void 0,this.external=c.props.external.default,this.target=c.props.target.default,this.slotController=new k.PktSlotController(this,this.defaultSlot)}render(){const n={"pkt-link":!0,"pkt-link--icon-left":!!this.iconName&&this.iconPosition==="left"||!!(this.iconName&&!this.iconPosition),"pkt-link--icon-right":!!this.iconName&&this.iconPosition==="right","pkt-link--external":this.external};return e.x`<a
|
|
2
2
|
class=${h.e(n)}
|
|
3
3
|
href=${this.href}
|
|
4
4
|
@click=${this.handleClick}
|
package/dist/link.d.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
export { }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Pkt Select is a wrapper for the native select element using the pkt-input-wrapper component.
|
|
6
|
+
*
|
|
7
|
+
* The component will prioritize options passed as a prop over options passed as children if both are provided.
|
|
8
|
+
* This is to allow for dynamic options that might change in the case of both children/slot and props are provided.
|
|
9
|
+
*
|
|
10
|
+
* @slot (default) - Options to be rendered as children
|
|
11
|
+
* @prop {TSelectOption[]} options - Options to be rendered as children
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
declare global {
|
|
16
|
+
interface HTMLElementTagNameMap {
|
|
17
|
+
'pkt-select': PktSelect & HTMLSelectElement;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
interface HTMLElementTagNameMap {
|
|
24
|
+
'pkt-combobox': PktCombobox & HTMLSelectElement;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
4
29
|
declare global {
|
|
5
30
|
interface HTMLElementTagNameMap {
|
|
6
31
|
'pkt-icon': PktIcon;
|
|
@@ -8,6 +33,13 @@ declare global {
|
|
|
8
33
|
}
|
|
9
34
|
|
|
10
35
|
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
'pkt-listbox': PktListbox;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
11
43
|
declare global {
|
|
12
44
|
interface Window {
|
|
13
45
|
pktTz: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as f, x as c, n, a as h } from "./element-
|
|
2
|
-
import { e as k, n as m } from "./ref-
|
|
3
|
-
import { P as u } from "./pkt-slot-controller-
|
|
4
|
-
import "./icon-
|
|
1
|
+
import { P as f, x as c, n, a as h } from "./element-G8JoS0Lj.js";
|
|
2
|
+
import { e as k, n as m } from "./ref-cRTOoM4R.js";
|
|
3
|
+
import { P as u } from "./pkt-slot-controller-D1DakVrU.js";
|
|
4
|
+
import "./icon-BJnwW0eh.js";
|
|
5
5
|
var _ = Object.defineProperty, d = Object.getOwnPropertyDescriptor, r = (l, i, s, o) => {
|
|
6
6
|
for (var e = o > 1 ? void 0 : o ? d(i, s) : i, a = l.length - 1, p; a >= 0; a--)
|
|
7
7
|
(p = l[a]) && (e = (o ? p(i, s, e) : p(e)) || e);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./element-
|
|
1
|
+
"use strict";const t=require("./element-BBo3JZk5.cjs"),k=require("./ref-DsoUUoPU.cjs"),p=require("./pkt-slot-controller-CqNvEpFd.cjs");require("./icon-BTUCDPN5.cjs");var c=Object.defineProperty,h=Object.getOwnPropertyDescriptor,r=(s,n,i,l)=>{for(var e=l>1?void 0:l?h(n,i):n,o=s.length-1,a;o>=0;o--)(a=s[o])&&(e=(l?a(n,i,e):a(e))||e);return l&&e&&c(n,i,e),e};exports.PktLinkCard=class extends t.PktElement{constructor(){super(),this.defaultSlot=k.e(),this.title="",this.href="#",this.iconName="",this.external=!1,this.openInNewTab=!1,this.skin="normal",this.slotController=new p.PktSlotController(this,this.defaultSlot)}render(){const n=["pkt-linkcard",this.skin&&`pkt-linkcard--${this.skin}`].filter(Boolean).join(" "),i=["pkt-linkcard__title",this.external&&"pkt-link pkt-link--external"].filter(Boolean).join(" ");return t.x`
|
|
2
2
|
<a
|
|
3
3
|
href=${this.href}
|
|
4
4
|
class=${n}
|
package/dist/linkcard.d.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
export { }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Pkt Select is a wrapper for the native select element using the pkt-input-wrapper component.
|
|
6
|
+
*
|
|
7
|
+
* The component will prioritize options passed as a prop over options passed as children if both are provided.
|
|
8
|
+
* This is to allow for dynamic options that might change in the case of both children/slot and props are provided.
|
|
9
|
+
*
|
|
10
|
+
* @slot (default) - Options to be rendered as children
|
|
11
|
+
* @prop {TSelectOption[]} options - Options to be rendered as children
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
declare global {
|
|
16
|
+
interface HTMLElementTagNameMap {
|
|
17
|
+
'pkt-select': PktSelect & HTMLSelectElement;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
interface HTMLElementTagNameMap {
|
|
24
|
+
'pkt-combobox': PktCombobox & HTMLSelectElement;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
4
29
|
declare global {
|
|
5
30
|
interface HTMLElementTagNameMap {
|
|
6
31
|
'pkt-icon': PktIcon;
|
|
@@ -8,6 +33,13 @@ declare global {
|
|
|
8
33
|
}
|
|
9
34
|
|
|
10
35
|
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
'pkt-listbox': PktListbox;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
11
43
|
declare global {
|
|
12
44
|
interface Window {
|
|
13
45
|
pktTz: string;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";const s=require("./element-BBo3JZk5.cjs"),p=require("./state-BILlRnrD.cjs"),h=require("./if-defined-C1ZDVzYn.cjs"),u=require("./repeat-kruY8poV.cjs"),c=require("./class-map-D4rXyUxT.cjs"),d=require("./stringutils-CkVRq4jP.cjs");var b=Object.defineProperty,f=Object.getOwnPropertyDescriptor,n=(r,e,t,i)=>{for(var a=i>1?void 0:i?f(e,t):e,o=r.length-1,l;o>=0;o--)(l=r[o])&&(a=(i?l(e,t,a):l(a))||a);return i&&a&&b(e,t,a),a};exports.PktListbox=class extends s.PktElement{constructor(){super(...arguments),this.id=d.uuidish(),this.label=null,this.options=[],this.isOpen=!1,this.disabled=!1,this.includeSearch=!1,this.isMultiSelect=!1,this.allowUserInput=!1,this.maxIsReached=!1,this.customUserInput=null,this.searchPlaceholder=null,this.searchValue=null,this.maxLength=0,this.userMessage=null,this._selectedOptions=0,this._filteredOptions=[]}connectedCallback(){super.connectedCallback(),this.includeSearch&&!this.searchValue&&(this.searchValue=""),this.options.length>0&&this.filterOptions(),this.setAttribute("tabindex","-1"),this.addEventListener("focus",this.focusFirstOrSelectedOption)}updated(e){(e.has("options")||e.has("searchValue"))&&this.filterOptions(),super.updated(e)}attributeChangedCallback(e,t,i){(e==="options"||e==="searchValue"||e==="search-value")&&this.filterOptions(),super.attributeChangedCallback(e,t,i)}render(){return s.x`
|
|
2
|
+
<div
|
|
3
|
+
class=${c.e({"pkt-listbox":!0,"pkt-listbox__open":this.isOpen,"pkt-txt-16-light":!0})}
|
|
4
|
+
role="listbox"
|
|
5
|
+
aria-label=${h.o(this.label)}
|
|
6
|
+
>
|
|
7
|
+
<div class="pkt-listbox__banners">
|
|
8
|
+
${this.renderMaximumReachedBanner()} ${this.renderUserMessage()}
|
|
9
|
+
${this.renderNewOptionBanner()} ${this.renderSearch()}
|
|
10
|
+
</div>
|
|
11
|
+
<ul class="pkt-listbox__options" role="presentation">
|
|
12
|
+
${this.renderList()}
|
|
13
|
+
</ul>
|
|
14
|
+
</div>
|
|
15
|
+
`}renderCheckboxOrCheckIcon(e,t){return this.isMultiSelect?s.x`
|
|
16
|
+
<input
|
|
17
|
+
class="pkt-input-check__input-checkbox"
|
|
18
|
+
type="checkbox"
|
|
19
|
+
role="presentation"
|
|
20
|
+
tabindex="-1"
|
|
21
|
+
value=${e.value}
|
|
22
|
+
.checked=${e.selected}
|
|
23
|
+
aria-labelledby=${this.id+"-option-label-"+t}
|
|
24
|
+
?disabled=${this.disabled||e.disabled||this.maxIsReached&&!e.selected}
|
|
25
|
+
/>
|
|
26
|
+
`:e.selected?s.x`<pkt-icon name="check-big"></pkt-icon>`:s.E}renderList(){return s.x`
|
|
27
|
+
${u.c(this._filteredOptions,e=>e.value,(e,t)=>s.x`
|
|
28
|
+
<li
|
|
29
|
+
@click=${()=>{this.toggleOption(e)}}
|
|
30
|
+
aria-selected=${e.selected?"true":"false"}
|
|
31
|
+
@keydown=${this.handleOptionKeydown}
|
|
32
|
+
class=${c.e({"pkt-listbox__option":!0,"pkt-listbox__option--selected":!!(!this.isMultiSelect&&e.selected),"pkt-listbox__option--checkBox":this.isMultiSelect})}
|
|
33
|
+
tabindex="${this.disabled||e.disabled?"-1":"0"}"
|
|
34
|
+
data-index=${t}
|
|
35
|
+
data-value=${e.value}
|
|
36
|
+
data-selected=${e.selected?"true":"false"}
|
|
37
|
+
?data-disabled=${this.disabled||e.disabled||this.maxIsReached&&!e.selected}
|
|
38
|
+
role="option"
|
|
39
|
+
id=${`${this.id}-${t}`}
|
|
40
|
+
>
|
|
41
|
+
${this.renderCheckboxOrCheckIcon(e,t)}
|
|
42
|
+
<span class="pkt-listbox__option-label" id=${this.id+"-option-label-"+t}>
|
|
43
|
+
${e.prefix?s.x`<span class="pkt-listbox__option-prefix">${e.prefix}</span>`:s.E}
|
|
44
|
+
${e.label||e.value}
|
|
45
|
+
</span>
|
|
46
|
+
${e.description?s.x`<span class="pkt-listbox__option-description pkt-txt-14-light"
|
|
47
|
+
>${e.description}</span
|
|
48
|
+
>`:s.E}
|
|
49
|
+
</li>
|
|
50
|
+
`)}
|
|
51
|
+
`}renderNewOptionBanner(){return this.allowUserInput&&this.customUserInput?s.x`
|
|
52
|
+
<div
|
|
53
|
+
class="pkt-listbox__banner pkt-listbox__banner--new-option pkt-listbox__option"
|
|
54
|
+
data-type="new-option"
|
|
55
|
+
data-value=${this.customUserInput}
|
|
56
|
+
data-selected="false"
|
|
57
|
+
tabindex="0"
|
|
58
|
+
@click=${()=>this.toggleOption({value:this.customUserInput||""})}
|
|
59
|
+
@keydown=${this.handleOptionKeydown}
|
|
60
|
+
>
|
|
61
|
+
<pkt-icon class="pkt-listbox__banner-icon" name="plus-sign" size="large"></pkt-icon>
|
|
62
|
+
Legg til “${this.customUserInput}”
|
|
63
|
+
</div>
|
|
64
|
+
`:s.E}renderMaximumReachedBanner(){return this._selectedOptions=this.options.filter(e=>e.selected).length,this.isMultiSelect&&this._selectedOptions>0&&this.maxLength>0?s.x`
|
|
65
|
+
<div class="pkt-listbox__banner pkt-listbox__banner--maximum-reached">
|
|
66
|
+
${this._selectedOptions} av maks ${this.maxLength} mulige er valgt.
|
|
67
|
+
</div>
|
|
68
|
+
`:s.E}renderUserMessage(){return this.userMessage?s.x`<div class="pkt-listbox__banner pkt-listbox__banner--user-message">
|
|
69
|
+
<pkt-icon
|
|
70
|
+
class="pkt-listbox__banner-icon"
|
|
71
|
+
name="exclamation-mark-circle"
|
|
72
|
+
size="large"
|
|
73
|
+
></pkt-icon>
|
|
74
|
+
${this.userMessage}
|
|
75
|
+
</div>`:s.E}renderSearch(){return this.includeSearch?s.x`
|
|
76
|
+
<div class="pkt-listbox__search">
|
|
77
|
+
<span class="pkt-listbox__search-icon">
|
|
78
|
+
<pkt-icon name="magnifying-glass-small" size="large"></pkt-icon>
|
|
79
|
+
</span>
|
|
80
|
+
<input
|
|
81
|
+
class="pkt-txt-16-light"
|
|
82
|
+
type="text"
|
|
83
|
+
aria-label="Søk i listen"
|
|
84
|
+
form=""
|
|
85
|
+
placeholder=${this.searchPlaceholder||s.translations.forms.search.placeholder}
|
|
86
|
+
@input=${this.handleSearchInput}
|
|
87
|
+
@keydown=${this.handleSearchKeydown}
|
|
88
|
+
.value=${this.searchValue}
|
|
89
|
+
data-type="searchbox"
|
|
90
|
+
?disabled=${this.disabled}
|
|
91
|
+
?readonly=${this.disabled}
|
|
92
|
+
role="searchbox"
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
`:s.E}handleSearchInput(e){this.searchValue=e.target.value,this.dispatchEvent(new CustomEvent("search",{detail:this.searchValue,bubbles:!1}))}handleSearchKeydown(e){switch(e.key){case"Enter":e.preventDefault();break;case"ArrowUp":case"Escape":this.closeOptions(),e.preventDefault();break;case"ArrowDown":case"Tab":this.focusFirstOrSelectedOption();break}}handleOptionKeydown(e){const t=e.currentTarget,i=t.dataset.value,a=t.dataset.type,o=t.dataset.selected==="true";if(!(!this.getOptionElements().length&&(!this.customUserInput||!this.allowUserInput&&this.customUserInput)&&a!=="new-option"&&a!=="searchbox"))switch(e.key){case" ":case"Enter":this.toggleOption(t),e.preventDefault();break;case"Backspace":i&&(o?this.toggleOption(t):this.closeOptions()),e.preventDefault();break;case"Escape":case"Tab":this.closeOptions();break;case"ArrowDown":e.altKey?this.focusLastOption():a==="searchbox"||a==="new-option"?this.focusFirstOption():this.focusNextOption(t),e.preventDefault();break;case"ArrowUp":if(e.altKey)this.focusFirstOption();else if(t.dataset.index==="0"&&this.includeSearch){const l=this.querySelector('[role="searchbox"]');l&&l.focus()}else if(t.dataset.index==="0"&&this.customUserInput){const l=this.querySelector('[data-type="new-option"]');l&&l.focus()}else this.focusPreviousOption(t);e.preventDefault();break;case"Home":this.focusFirstOption(),e.preventDefault();break;case"End":this.focusLastOption(),e.preventDefault();break;default:(e.metaKey||e.ctrlKey)&&e.key==="a"&&(this.selectAll(),e.preventDefault()),this.isLetterOrSpace(e.key)&&(this.handleTypeAhead(e.key),e.preventDefault());break}}focusAndScrollIntoView(e){e.scrollIntoView({block:"nearest"}),window.setTimeout(()=>e.focus(),0)}focusNextOption(e){const t=e.nextElementSibling;t&&this.focusAndScrollIntoView(t)}focusPreviousOption(e){const t=e.previousElementSibling;if(e.dataset.index==="0"&&this.includeSearch){const i=this.querySelector('[role="searchbox"]');i&&this.focusAndScrollIntoView(i)}else t&&this.focusAndScrollIntoView(t)}focusFirstOption(){const e=this.getOptionElements()[0];e&&this.focusAndScrollIntoView(e)}focusLastOption(){const e=this.getOptionElements().pop();e&&this.focusAndScrollIntoView(e)}focusFirstOrSelectedOption(){if(this.disabled)return;const e=this.getOptionElements().find(t=>t.dataset.selected==="true");if(this.allowUserInput&&this.customUserInput){const t=this.querySelector('[data-type="new-option"]');this.focusAndScrollIntoView(t)}else if(e)this.focusAndScrollIntoView(e);else if(this.includeSearch&&!(document.activeElement instanceof HTMLInputElement)){const t=this.querySelector('[role="searchbox"]');window.setTimeout(()=>t.focus(),0)}else this.focusFirstOption()}toggleOption(e){const t=e instanceof HTMLElement?e.dataset.disabled:e.disabled;if(this.disabled||t)return;const i=e instanceof HTMLElement?e.dataset.value:e.value;this.dispatchEvent(new CustomEvent("option-toggle",{detail:i,bubbles:!1}))}selectAll(){this.dispatchEvent(new CustomEvent("select-all",{bubbles:!1}))}closeOptions(){this.dispatchEvent(new CustomEvent("close-options",{bubbles:!1}))}filterOptions(){this.searchValue?this._filteredOptions=this.options.filter(e=>{var i;return(e.label+e.value).toLowerCase().includes(((i=this.searchValue)==null?void 0:i.toLowerCase())||"")}):this._filteredOptions=[...this.options]}isLetterOrSpace(e){return/^[\p{L} ]$/u.test(e)}handleTypeAhead(e){this.typeAheadString+=e.toLowerCase(),this.typeAheadTimeout&&clearTimeout(this.typeAheadTimeout),this.typeAheadTimeout=window.setTimeout(()=>{this.typeAheadString=""},500);const i=this.getOptionElements().find(a=>{var o;return(o=a.textContent)==null?void 0:o.trim().toLowerCase().startsWith(this.typeAheadString)});i&&this.focusAndScrollIntoView(i)}getOptionElements(){return this._filteredOptions.length?Array.from(this.querySelectorAll('[role="option"]:not([data-disabled])')||[]):[]}};n([s.n({type:String})],exports.PktListbox.prototype,"id",2);n([s.n({type:String})],exports.PktListbox.prototype,"label",2);n([s.n({type:Array})],exports.PktListbox.prototype,"options",2);n([s.n({type:Boolean,reflect:!0})],exports.PktListbox.prototype,"isOpen",2);n([s.n({type:Boolean})],exports.PktListbox.prototype,"disabled",2);n([s.n({type:Boolean})],exports.PktListbox.prototype,"includeSearch",2);n([s.n({type:Boolean})],exports.PktListbox.prototype,"isMultiSelect",2);n([s.n({type:Boolean})],exports.PktListbox.prototype,"allowUserInput",2);n([s.n({type:Boolean})],exports.PktListbox.prototype,"maxIsReached",2);n([s.n({type:String})],exports.PktListbox.prototype,"customUserInput",2);n([s.n({type:String})],exports.PktListbox.prototype,"searchPlaceholder",2);n([s.n({type:String})],exports.PktListbox.prototype,"searchValue",2);n([s.n({type:Number})],exports.PktListbox.prototype,"maxLength",2);n([s.n({type:String})],exports.PktListbox.prototype,"userMessage",2);n([p.r()],exports.PktListbox.prototype,"_filteredOptions",2);exports.PktListbox=n([s.t("pkt-listbox")],exports.PktListbox);
|