@oslokommune/punkt-elements 15.4.5 → 16.0.2
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/{card-CnPjrdre.js → card-CmfUyl_s.js} +1 -1
- package/dist/{card-5S2r9UD1.cjs → card-Db9QSEqh.cjs} +1 -1
- package/dist/{checkbox-D98_NjcU.cjs → checkbox-Cpyay9_l.cjs} +1 -1
- package/dist/{checkbox-BSz71IeT.js → checkbox-D6nltMuc.js} +1 -1
- package/dist/combobox-Bv37b6cI.cjs +135 -0
- package/dist/combobox-CoO8T-F-.js +818 -0
- package/dist/{datepicker-SEKblnRR.cjs → datepicker-CrvQ5Y5w.cjs} +1 -1
- package/dist/{datepicker-nnyTW0vf.js → datepicker-DbsIuC5Z.js} +2 -2
- package/dist/index.d.ts +157 -90
- package/dist/{input-element-Bkv6Yxld.js → input-element-BGNbdzy2.js} +1 -1
- package/dist/{input-element-DM0tY799.cjs → input-element-CSDVA3Y6.cjs} +1 -1
- package/dist/listbox-Dm2mKp6_.cjs +101 -0
- package/dist/listbox-OdkIn9_A.js +431 -0
- 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 +2 -2
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +9 -9
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-options-controller-BogGk-6J.cjs +1 -0
- package/dist/{pkt-options-controller-BcGywCmf.js → pkt-options-controller-Z-bPox7n.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/{radiobutton-95wp024h.cjs → radiobutton-CNHCpKn0.cjs} +1 -1
- package/dist/{radiobutton-CTFAV5GU.js → radiobutton-DgC27mb0.js} +1 -1
- package/dist/{select-YLvYAQX6.js → select-7VuYtPZv.js} +2 -2
- package/dist/{select-CZ_Lx5W6.cjs → select-PWPy5gTB.cjs} +1 -1
- package/dist/{tag-68q0_Sn0.js → tag-DZPqFiem.js} +37 -33
- package/dist/tag-DmbgBCKu.cjs +27 -0
- package/dist/{textarea-CuTsE1WX.cjs → textarea-CO7Ikug5.cjs} +1 -1
- package/dist/{textarea-DhWH99qN.js → textarea-VpCEjVFx.js} +1 -1
- package/dist/{textinput-BCi9p0Du.js → textinput-C2AZ9ss2.js} +1 -1
- package/dist/{textinput-st4Vml5J.cjs → textinput-DRFZU3dA.cjs} +1 -1
- package/package.json +4 -4
- package/src/components/card/card.ts +1 -0
- package/src/components/combobox/combobox-base.ts +158 -0
- package/src/components/combobox/combobox-handlers.ts +419 -0
- package/src/components/combobox/combobox-types.ts +10 -0
- package/src/components/combobox/combobox-utils.ts +135 -0
- package/src/components/combobox/combobox-value.ts +248 -0
- package/src/components/combobox/combobox.accessibility.test.ts +243 -0
- package/src/components/combobox/{combobox.test.ts → combobox.core.test.ts} +104 -46
- package/src/components/combobox/combobox.interaction.test.ts +436 -0
- package/src/components/combobox/combobox.selection.test.ts +543 -0
- package/src/components/combobox/combobox.ts +260 -734
- package/src/components/listbox/index.ts +2 -0
- package/src/components/listbox/listbox.interaction.test.ts +580 -0
- package/src/components/listbox/listbox.test.ts +32 -6
- package/src/components/listbox/listbox.ts +109 -126
- package/src/components/tag/tag.ts +3 -0
- package/dist/combobox-C5YcNVSZ.cjs +0 -128
- package/dist/combobox-cer7PLSE.js +0 -533
- package/dist/listbox-C7NEa9SU.cjs +0 -96
- package/dist/listbox-Cykec1bj.js +0 -361
- package/dist/pkt-options-controller-BnTmkl3g.cjs +0 -1
- package/dist/tag-BnT5onW2.cjs +0 -26
package/dist/listbox-Cykec1bj.js
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { P as b, b as r, A as p, s as f, n as a, t as m } from "./element-CV9utnHJ.js";
|
|
2
|
-
import { r as y } from "./state-l4hGZdFJ.js";
|
|
3
|
-
import { o as u } from "./if-defined-rXcLNTzN.js";
|
|
4
|
-
import { c as k } from "./repeat-DnlRNf63.js";
|
|
5
|
-
import { e as d } from "./class-map-3ADKve8g.js";
|
|
6
|
-
import { u as x } from "./utils-DznhwRXm.js";
|
|
7
|
-
var O = Object.defineProperty, g = Object.getOwnPropertyDescriptor, l = (e, t, s, o) => {
|
|
8
|
-
for (var n = o > 1 ? void 0 : o ? g(t, s) : t, c = e.length - 1, h; c >= 0; c--)
|
|
9
|
-
(h = e[c]) && (n = (o ? h(t, s, n) : h(n)) || n);
|
|
10
|
-
return o && n && O(t, s, n), n;
|
|
11
|
-
};
|
|
12
|
-
let i = class extends b {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments), this.id = x(), 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 = [];
|
|
15
|
-
}
|
|
16
|
-
// Lifecycle methods
|
|
17
|
-
connectedCallback() {
|
|
18
|
-
super.connectedCallback(), this.includeSearch && !this.searchValue && (this.searchValue = ""), this.options.length > 0 && this.filterOptions(), this.setAttribute("tabindex", "-1"), this.addEventListener("focus", this.focusFirstOrSelectedOption);
|
|
19
|
-
}
|
|
20
|
-
updated(e) {
|
|
21
|
-
(e.has("options") || e.has("searchValue")) && this.filterOptions(), super.updated(e);
|
|
22
|
-
}
|
|
23
|
-
attributeChangedCallback(e, t, s) {
|
|
24
|
-
(e === "options" || e === "searchValue" || e === "search-value") && this.filterOptions(), super.attributeChangedCallback(e, t, s);
|
|
25
|
-
}
|
|
26
|
-
// Render methods
|
|
27
|
-
render() {
|
|
28
|
-
return r`
|
|
29
|
-
<div
|
|
30
|
-
class=${d({
|
|
31
|
-
"pkt-listbox": !0,
|
|
32
|
-
"pkt-listbox__open": this.isOpen,
|
|
33
|
-
"pkt-txt-16-light": !0
|
|
34
|
-
})}
|
|
35
|
-
role="listbox"
|
|
36
|
-
aria-multiselectable=${u(this.isMultiSelect ? "true" : void 0)}
|
|
37
|
-
aria-label=${u(this.label)}
|
|
38
|
-
>
|
|
39
|
-
<div class="pkt-listbox__banners">
|
|
40
|
-
${this.renderMaximumReachedBanner()} ${this.renderUserMessage()}
|
|
41
|
-
${this.renderNewOptionBanner()} ${this.renderSearch()}
|
|
42
|
-
</div>
|
|
43
|
-
<ul class="pkt-listbox__options" role="presentation">
|
|
44
|
-
${this.renderList()}
|
|
45
|
-
</ul>
|
|
46
|
-
</div>
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
49
|
-
renderCheckboxOrCheckIcon(e, t) {
|
|
50
|
-
return this.isMultiSelect ? r`
|
|
51
|
-
<input
|
|
52
|
-
class="pkt-input-check__input-checkbox"
|
|
53
|
-
type="checkbox"
|
|
54
|
-
role="presentation"
|
|
55
|
-
tabindex="-1"
|
|
56
|
-
value=${e.value}
|
|
57
|
-
.checked=${e.selected}
|
|
58
|
-
aria-labelledby=${this.id + "-option-label-" + t}
|
|
59
|
-
?disabled=${this.disabled || e.disabled || this.maxIsReached && !e.selected}
|
|
60
|
-
/>
|
|
61
|
-
` : e.selected ? r`<pkt-icon name="check-big"></pkt-icon>` : p;
|
|
62
|
-
}
|
|
63
|
-
renderList() {
|
|
64
|
-
return r`
|
|
65
|
-
${k(
|
|
66
|
-
this._filteredOptions,
|
|
67
|
-
(e) => e.value,
|
|
68
|
-
(e, t) => r`
|
|
69
|
-
<li
|
|
70
|
-
@click=${() => {
|
|
71
|
-
this.toggleOption(e);
|
|
72
|
-
}}
|
|
73
|
-
aria-selected=${e.selected ? "true" : "false"}
|
|
74
|
-
@keydown=${this.handleOptionKeydown}
|
|
75
|
-
class=${d({
|
|
76
|
-
"pkt-listbox__option": !0,
|
|
77
|
-
"pkt-listbox__option--selected": !!(!this.isMultiSelect && e.selected),
|
|
78
|
-
"pkt-listbox__option--checkBox": this.isMultiSelect
|
|
79
|
-
})}
|
|
80
|
-
tabindex="${this.disabled || e.disabled ? "-1" : "0"}"
|
|
81
|
-
data-index=${t}
|
|
82
|
-
data-value=${e.value}
|
|
83
|
-
data-selected=${e.selected ? "true" : "false"}
|
|
84
|
-
?data-disabled=${this.disabled || e.disabled || this.maxIsReached && !e.selected}
|
|
85
|
-
role="option"
|
|
86
|
-
id=${`${this.id}-${t}`}
|
|
87
|
-
>
|
|
88
|
-
${this.renderCheckboxOrCheckIcon(e, t)}
|
|
89
|
-
<span class="pkt-listbox__option-label" id=${this.id + "-option-label-" + t}>
|
|
90
|
-
${e.prefix ? r`<span class="pkt-listbox__option-prefix">${e.prefix}</span>` : p}
|
|
91
|
-
${e.label || e.value}
|
|
92
|
-
</span>
|
|
93
|
-
${e.description ? r`<span class="pkt-listbox__option-description pkt-txt-14-light"
|
|
94
|
-
>${e.description}</span
|
|
95
|
-
>` : p}
|
|
96
|
-
</li>
|
|
97
|
-
`
|
|
98
|
-
)}
|
|
99
|
-
`;
|
|
100
|
-
}
|
|
101
|
-
renderNewOptionBanner() {
|
|
102
|
-
return this.allowUserInput && this.customUserInput ? r`
|
|
103
|
-
<div
|
|
104
|
-
class="pkt-listbox__banner pkt-listbox__banner--new-option pkt-listbox__option"
|
|
105
|
-
data-type="new-option"
|
|
106
|
-
data-value=${this.customUserInput}
|
|
107
|
-
data-selected="false"
|
|
108
|
-
tabindex="0"
|
|
109
|
-
@click=${() => this.toggleOption({
|
|
110
|
-
value: this.customUserInput || ""
|
|
111
|
-
})}
|
|
112
|
-
@keydown=${this.handleOptionKeydown}
|
|
113
|
-
>
|
|
114
|
-
<pkt-icon class="pkt-listbox__banner-icon" name="plus-sign" size="large"></pkt-icon>
|
|
115
|
-
Legg til “${this.customUserInput}”
|
|
116
|
-
</div>
|
|
117
|
-
` : p;
|
|
118
|
-
}
|
|
119
|
-
renderMaximumReachedBanner() {
|
|
120
|
-
return this._selectedOptions = this.options.filter((e) => e.selected).length, this.isMultiSelect && this._selectedOptions > 0 && this.maxLength > 0 ? r`
|
|
121
|
-
<div class="pkt-listbox__banner pkt-listbox__banner--maximum-reached">
|
|
122
|
-
${this._selectedOptions} av maks ${this.maxLength} mulige er valgt.
|
|
123
|
-
</div>
|
|
124
|
-
` : p;
|
|
125
|
-
}
|
|
126
|
-
renderUserMessage() {
|
|
127
|
-
return this.userMessage ? r`<div class="pkt-listbox__banner pkt-listbox__banner--user-message">
|
|
128
|
-
<pkt-icon
|
|
129
|
-
class="pkt-listbox__banner-icon"
|
|
130
|
-
name="exclamation-mark-circle"
|
|
131
|
-
size="large"
|
|
132
|
-
></pkt-icon>
|
|
133
|
-
${this.userMessage}
|
|
134
|
-
</div>` : p;
|
|
135
|
-
}
|
|
136
|
-
renderSearch() {
|
|
137
|
-
return this.includeSearch ? r`
|
|
138
|
-
<div class="pkt-listbox__search">
|
|
139
|
-
<span class="pkt-listbox__search-icon">
|
|
140
|
-
<pkt-icon name="magnifying-glass-small" size="large"></pkt-icon>
|
|
141
|
-
</span>
|
|
142
|
-
<input
|
|
143
|
-
class="pkt-txt-16-light"
|
|
144
|
-
type="text"
|
|
145
|
-
aria-label="Søk i listen"
|
|
146
|
-
form=""
|
|
147
|
-
placeholder=${this.searchPlaceholder || f.forms.search.placeholder}
|
|
148
|
-
@input=${this.handleSearchInput}
|
|
149
|
-
@keydown=${this.handleSearchKeydown}
|
|
150
|
-
.value=${this.searchValue}
|
|
151
|
-
data-type="searchbox"
|
|
152
|
-
?disabled=${this.disabled}
|
|
153
|
-
?readonly=${this.disabled}
|
|
154
|
-
role="searchbox"
|
|
155
|
-
/>
|
|
156
|
-
</div>
|
|
157
|
-
` : p;
|
|
158
|
-
}
|
|
159
|
-
// Event handlers
|
|
160
|
-
handleSearchInput(e) {
|
|
161
|
-
this.searchValue = e.target.value, this.dispatchEvent(
|
|
162
|
-
new CustomEvent("search", {
|
|
163
|
-
detail: this.searchValue,
|
|
164
|
-
bubbles: !1
|
|
165
|
-
})
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
handleSearchKeydown(e) {
|
|
169
|
-
switch (e.key) {
|
|
170
|
-
case "Enter":
|
|
171
|
-
e.preventDefault();
|
|
172
|
-
break;
|
|
173
|
-
case "ArrowUp":
|
|
174
|
-
case "Escape":
|
|
175
|
-
this.closeOptions(), e.preventDefault();
|
|
176
|
-
break;
|
|
177
|
-
case "ArrowDown":
|
|
178
|
-
case "Tab":
|
|
179
|
-
this.focusFirstOrSelectedOption();
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
handleOptionKeydown(e) {
|
|
184
|
-
const t = e.currentTarget, s = t.dataset.value, o = t.dataset.type, n = t.dataset.selected === "true";
|
|
185
|
-
if (!(!this.getOptionElements().length && (!this.customUserInput || !this.allowUserInput && this.customUserInput) && o !== "new-option" && o !== "searchbox"))
|
|
186
|
-
switch (e.key) {
|
|
187
|
-
case " ":
|
|
188
|
-
case "Enter":
|
|
189
|
-
this.toggleOption(t), e.preventDefault();
|
|
190
|
-
break;
|
|
191
|
-
case "Backspace":
|
|
192
|
-
s && (n ? this.toggleOption(t) : this.closeOptions()), e.preventDefault();
|
|
193
|
-
break;
|
|
194
|
-
case "Escape":
|
|
195
|
-
case "Tab":
|
|
196
|
-
this.closeOptions();
|
|
197
|
-
break;
|
|
198
|
-
case "ArrowDown":
|
|
199
|
-
e.altKey ? this.focusLastOption() : o === "searchbox" || o === "new-option" ? this.focusFirstOption() : this.focusNextOption(t), e.preventDefault();
|
|
200
|
-
break;
|
|
201
|
-
case "ArrowUp":
|
|
202
|
-
if (e.altKey)
|
|
203
|
-
this.focusFirstOption();
|
|
204
|
-
else if (t.dataset.index === "0" && this.includeSearch) {
|
|
205
|
-
const c = this.querySelector('[role="searchbox"]');
|
|
206
|
-
c && c.focus();
|
|
207
|
-
} else if (t.dataset.index === "0" && this.customUserInput) {
|
|
208
|
-
const c = this.querySelector('[data-type="new-option"]');
|
|
209
|
-
c && c.focus();
|
|
210
|
-
} else
|
|
211
|
-
this.focusPreviousOption(t);
|
|
212
|
-
e.preventDefault();
|
|
213
|
-
break;
|
|
214
|
-
case "Home":
|
|
215
|
-
this.focusFirstOption(), e.preventDefault();
|
|
216
|
-
break;
|
|
217
|
-
case "End":
|
|
218
|
-
this.focusLastOption(), e.preventDefault();
|
|
219
|
-
break;
|
|
220
|
-
default:
|
|
221
|
-
(e.metaKey || e.ctrlKey) && e.key === "a" && (this.selectAll(), e.preventDefault()), this.isLetterOrSpace(e.key) && (this.handleTypeAhead(e.key), e.preventDefault());
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// Focus management methods
|
|
226
|
-
focusAndScrollIntoView(e) {
|
|
227
|
-
e.scrollIntoView({ block: "nearest" }), window.setTimeout(() => e.focus(), 0);
|
|
228
|
-
}
|
|
229
|
-
focusNextOption(e) {
|
|
230
|
-
const t = e.nextElementSibling;
|
|
231
|
-
t && this.focusAndScrollIntoView(t);
|
|
232
|
-
}
|
|
233
|
-
focusPreviousOption(e) {
|
|
234
|
-
const t = e.previousElementSibling;
|
|
235
|
-
if (e.dataset.index === "0" && this.includeSearch) {
|
|
236
|
-
const s = this.querySelector('[role="searchbox"]');
|
|
237
|
-
s && this.focusAndScrollIntoView(s);
|
|
238
|
-
} else t && this.focusAndScrollIntoView(t);
|
|
239
|
-
}
|
|
240
|
-
focusFirstOption() {
|
|
241
|
-
const e = this.getOptionElements()[0];
|
|
242
|
-
e && this.focusAndScrollIntoView(e);
|
|
243
|
-
}
|
|
244
|
-
focusLastOption() {
|
|
245
|
-
const e = this.getOptionElements().pop();
|
|
246
|
-
e && this.focusAndScrollIntoView(e);
|
|
247
|
-
}
|
|
248
|
-
focusFirstOrSelectedOption() {
|
|
249
|
-
if (this.disabled) return;
|
|
250
|
-
const e = this.getOptionElements().find(
|
|
251
|
-
(t) => t.dataset.selected === "true"
|
|
252
|
-
);
|
|
253
|
-
if (this.allowUserInput && this.customUserInput) {
|
|
254
|
-
const t = this.querySelector('[data-type="new-option"]');
|
|
255
|
-
this.focusAndScrollIntoView(t);
|
|
256
|
-
} else if (e)
|
|
257
|
-
this.focusAndScrollIntoView(e);
|
|
258
|
-
else if (this.includeSearch && !(document.activeElement instanceof HTMLInputElement)) {
|
|
259
|
-
const t = this.querySelector('[role="searchbox"]');
|
|
260
|
-
window.setTimeout(() => t.focus(), 0);
|
|
261
|
-
} else
|
|
262
|
-
this.focusFirstOption();
|
|
263
|
-
}
|
|
264
|
-
// Event dispatching methods
|
|
265
|
-
toggleOption(e) {
|
|
266
|
-
const t = e instanceof HTMLElement ? e.dataset.disabled : e.disabled;
|
|
267
|
-
if (this.disabled || t) return;
|
|
268
|
-
const s = e instanceof HTMLElement ? e.dataset.value : e.value;
|
|
269
|
-
this.dispatchEvent(
|
|
270
|
-
new CustomEvent("option-toggle", {
|
|
271
|
-
detail: s,
|
|
272
|
-
bubbles: !1
|
|
273
|
-
})
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
selectAll() {
|
|
277
|
-
this.dispatchEvent(new CustomEvent("select-all", { bubbles: !1 }));
|
|
278
|
-
}
|
|
279
|
-
closeOptions() {
|
|
280
|
-
this.dispatchEvent(new CustomEvent("close-options", { bubbles: !1 }));
|
|
281
|
-
}
|
|
282
|
-
// Filtering and typeahead methods
|
|
283
|
-
filterOptions() {
|
|
284
|
-
this.searchValue ? this._filteredOptions = this.options.filter((e) => {
|
|
285
|
-
var s;
|
|
286
|
-
return (e.fulltext || e.label + e.value + (e.prefix || "")).toLowerCase().includes(((s = this.searchValue) == null ? void 0 : s.toLowerCase()) || "");
|
|
287
|
-
}) : this._filteredOptions = [...this.options];
|
|
288
|
-
}
|
|
289
|
-
isLetterOrSpace(e) {
|
|
290
|
-
return /^[\p{L} ]$/u.test(e);
|
|
291
|
-
}
|
|
292
|
-
handleTypeAhead(e) {
|
|
293
|
-
this.typeAheadString += e.toLowerCase(), this.typeAheadTimeout && clearTimeout(this.typeAheadTimeout), this.typeAheadTimeout = window.setTimeout(() => {
|
|
294
|
-
this.typeAheadString = "";
|
|
295
|
-
}, 500);
|
|
296
|
-
const s = this.getOptionElements().find(
|
|
297
|
-
(o) => {
|
|
298
|
-
var n;
|
|
299
|
-
return (n = o.textContent) == null ? void 0 : n.trim().toLowerCase().startsWith(this.typeAheadString);
|
|
300
|
-
}
|
|
301
|
-
);
|
|
302
|
-
s && this.focusAndScrollIntoView(s);
|
|
303
|
-
}
|
|
304
|
-
// DOM helper methods
|
|
305
|
-
getOptionElements() {
|
|
306
|
-
return this._filteredOptions.length ? Array.from(
|
|
307
|
-
this.querySelectorAll('[role="option"]:not([data-disabled])') || []
|
|
308
|
-
) : [];
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
l([
|
|
312
|
-
a({ type: String })
|
|
313
|
-
], i.prototype, "id", 2);
|
|
314
|
-
l([
|
|
315
|
-
a({ type: String })
|
|
316
|
-
], i.prototype, "label", 2);
|
|
317
|
-
l([
|
|
318
|
-
a({ type: Array })
|
|
319
|
-
], i.prototype, "options", 2);
|
|
320
|
-
l([
|
|
321
|
-
a({ type: Boolean, reflect: !0 })
|
|
322
|
-
], i.prototype, "isOpen", 2);
|
|
323
|
-
l([
|
|
324
|
-
a({ type: Boolean })
|
|
325
|
-
], i.prototype, "disabled", 2);
|
|
326
|
-
l([
|
|
327
|
-
a({ type: Boolean })
|
|
328
|
-
], i.prototype, "includeSearch", 2);
|
|
329
|
-
l([
|
|
330
|
-
a({ type: Boolean })
|
|
331
|
-
], i.prototype, "isMultiSelect", 2);
|
|
332
|
-
l([
|
|
333
|
-
a({ type: Boolean })
|
|
334
|
-
], i.prototype, "allowUserInput", 2);
|
|
335
|
-
l([
|
|
336
|
-
a({ type: Boolean })
|
|
337
|
-
], i.prototype, "maxIsReached", 2);
|
|
338
|
-
l([
|
|
339
|
-
a({ type: String })
|
|
340
|
-
], i.prototype, "customUserInput", 2);
|
|
341
|
-
l([
|
|
342
|
-
a({ type: String })
|
|
343
|
-
], i.prototype, "searchPlaceholder", 2);
|
|
344
|
-
l([
|
|
345
|
-
a({ type: String })
|
|
346
|
-
], i.prototype, "searchValue", 2);
|
|
347
|
-
l([
|
|
348
|
-
a({ type: Number })
|
|
349
|
-
], i.prototype, "maxLength", 2);
|
|
350
|
-
l([
|
|
351
|
-
a({ type: String })
|
|
352
|
-
], i.prototype, "userMessage", 2);
|
|
353
|
-
l([
|
|
354
|
-
y()
|
|
355
|
-
], i.prototype, "_filteredOptions", 2);
|
|
356
|
-
i = l([
|
|
357
|
-
m("pkt-listbox")
|
|
358
|
-
], i);
|
|
359
|
-
export {
|
|
360
|
-
i as P
|
|
361
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("./pkt-slot-controller-D4nKlom5.cjs");class a{constructor(t){this.nodes=[],this.options=[],this.host=t,this.host.addController(this),this.nodes=[],this.options=[],this.observer=new MutationObserver(e=>this.handleMutations(e))}hostConnected(){Array.from(this.host.childNodes).forEach(t=>{(t.nodeName==="OPTION"||t.nodeName==="DATA")&&this.addNode(t)}),this.createOptions(),this.observer.observe(this.host,{childList:!0,subtree:!1,attributes:!0})}hostDisconnected(){this.observer.disconnect()}addNode(t){(t.nodeName==="OPTION"||t.nodeName==="DATA")&&(t.hasAttribute("hidden")&&!t.hasAttribute("data-skip")&&t.setAttribute("data-hidden","true"),!t.hasAttribute("hidden")&&t.hasAttribute("data-skip")&&t.hasAttribute("data-hidden")&&t.removeAttribute("data-hidden"),t.setAttribute("class","pkt-hide"),t.setAttribute("data-skip","true"),t.setAttribute("hidden","true"),this.nodes.push(t))}createOptions(){this.options=this.nodes.map(t=>({value:t.hasAttribute("value")?t.getAttribute("value")??"":t.textContent??"",label:t.textContent||t.getAttribute("value")||"",selected:t.hasAttribute("selected"),disabled:t.hasAttribute("disabled"),hidden:t.hasAttribute("data-hidden")})),this.host.requestUpdate()}handleMutations(t){let e=!1;t.forEach(s=>{s.type==="childList"&&(s.addedNodes.forEach(i=>{r.isOptionElement(i)&&(this.addNode(i),e=!0)}),s.removedNodes.forEach(i=>{r.isOptionElement(i)&&(this.nodes=this.nodes.filter(h=>h!==i),e=!0)})),s.type==="attributes"&&r.isOptionElement(s.target)&&(this.addNode(s.target),e=!0)}),e&&this.createOptions()}}exports.PktOptionsSlotController=a;
|
package/dist/tag-BnT5onW2.cjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";const h=require("./class-map-Bokp1SoS.cjs"),t=require("./element-CMTfByxQ.cjs"),k=require("./state-BNgpvY-A.cjs"),g=require("./pkt-slot-controller-D4nKlom5.cjs"),c=require("./ref-CxLwrCxt.cjs");require("./icon-Dj0oZZSa.cjs");const u=require("./if-defined-hKKmbsI8.cjs"),d={size:{default:"medium"},skin:{default:"blue"},closeTag:{default:!1},type:{default:"button"}},r={props:d};var f=Object.defineProperty,y=Object.getOwnPropertyDescriptor,i=(n,e,a,o)=>{for(var s=o>1?void 0:o?y(e,a):e,l=n.length-1,p;l>=0;l--)(p=n[l])&&(s=(o?p(e,a,s):p(s))||s);return o&&s&&f(e,a,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:!1,composed:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:e},bubbles:!1,composed:!0}))},this.slotController=new g.PktSlotController(this,this.defaultSlot),this._isClosed=!1}firstUpdated(e){var a,o;if(super.firstUpdated(e),this.closeTag&&!this.ariaLabel){const s=(o=(a=this.defaultSlot.value)==null?void 0:a.textContent)==null?void 0:o.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},a={"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.b`
|
|
2
|
-
<button
|
|
3
|
-
class=${h.e(a)}
|
|
4
|
-
type=${this.type}
|
|
5
|
-
@click=${this.close}
|
|
6
|
-
aria-label=${u.o(this.ariaLabel||void 0)}
|
|
7
|
-
aria-description=${u.o(this._ariaDescription||void 0)}
|
|
8
|
-
>
|
|
9
|
-
${this.iconName&&t.b`<pkt-icon
|
|
10
|
-
class="pkt-tag__icon"
|
|
11
|
-
name=${this.iconName}
|
|
12
|
-
aria-hidden="true"
|
|
13
|
-
></pkt-icon>`}
|
|
14
|
-
<span ${c.n(this.defaultSlot)}></span>
|
|
15
|
-
<pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
|
|
16
|
-
</button>
|
|
17
|
-
`:t.b`
|
|
18
|
-
<span class=${h.e(e)}>
|
|
19
|
-
${this.iconName&&t.b`<pkt-icon
|
|
20
|
-
class="pkt-tag__icon"
|
|
21
|
-
name=${this.iconName}
|
|
22
|
-
aria-hidden="true"
|
|
23
|
-
></pkt-icon>`}
|
|
24
|
-
<span ${c.n(this.defaultSlot)}></span>
|
|
25
|
-
</span>
|
|
26
|
-
`}};i([t.n({type:Boolean,reflect:!0})],exports.PktTag.prototype,"closeTag",2);i([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"size",2);i([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"skin",2);i([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"textStyle",2);i([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"iconName",2);i([t.n({type:String})],exports.PktTag.prototype,"type",2);i([t.n({type:String})],exports.PktTag.prototype,"ariaLabel",2);i([k.r()],exports.PktTag.prototype,"_isClosed",2);i([k.r()],exports.PktTag.prototype,"_ariaDescription",2);exports.PktTag=i([t.t("pkt-tag")],exports.PktTag);
|