@oslokommune/punkt-elements 12.17.2 → 12.18.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/dist/alert-BbVWu2lm.cjs +27 -0
- package/dist/alert-Dh6A96vo.js +159 -0
- package/dist/{index-D2jSRMrn.js → calendar-BUqcNvfI.js} +41 -29
- package/dist/calendar-QSulz7im.cjs +108 -0
- package/dist/card-B0GPdG5M.cjs +23 -0
- package/dist/card-kWt0BA2a.js +170 -0
- package/dist/{class-map-a5HUzP83.cjs → class-map-Boa7BqCc.cjs} +2 -2
- package/dist/{class-map-CBvUV2N3.js → class-map-hz16xq5a.js} +9 -10
- package/dist/datepicker-BHepKxof.cjs +154 -0
- package/dist/datepicker-iNCYioZ9.js +659 -0
- package/dist/helptext--4FLdAWi.js +194 -0
- package/dist/helptext-iZEgxz2U.cjs +23 -0
- package/dist/icon-CdMQ6zBT.cjs +250 -0
- package/dist/{index-CFDwiDTU.js → icon-wUXeHiBk.js} +7371 -7559
- package/dist/if-defined-DEDlGbAc.cjs +5 -0
- package/dist/if-defined-ZFE4ti2t.js +10 -0
- package/dist/index.d.ts +96 -51
- package/dist/input-element-D1Vls6A5.js +184 -0
- package/dist/input-element-DPKoFVwJ.cjs +1 -0
- package/dist/{input-wrapper-6vTrKtsW.js → input-wrapper-BTQk3W8T.js} +10 -10
- package/dist/input-wrapper-D-PNRJB_.cjs +46 -0
- package/dist/link-BpqavGSD.cjs +8 -0
- package/dist/link-Bx9nVgZi.js +108 -0
- package/dist/{linkcard-BlWQ8jOv.js → linkcard-CUrbzjLK.js} +16 -17
- package/dist/linkcard-DSu3A4Yx.cjs +13 -0
- package/dist/messagebox-C1aWoQbu.cjs +12 -0
- package/dist/messagebox-LpiVQIoM.js +107 -0
- package/dist/{modal-DYTVJjYh.cjs → modal-Avai5eVz.cjs} +2 -2
- package/dist/{modal-3OZTPqee.js → modal-Co1YFmHi.js} +8 -8
- package/dist/pkt-alert.cjs +1 -27
- package/dist/pkt-alert.js +4 -157
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +4 -7
- package/dist/pkt-card.cjs +1 -23
- package/dist/pkt-card.js +4 -168
- package/dist/pkt-datepicker.cjs +1 -154
- package/dist/pkt-datepicker.js +4 -657
- 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 +4 -4
- package/dist/pkt-index.cjs +29 -1
- package/dist/pkt-index.js +127 -30
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -8
- package/dist/pkt-link.js +4 -107
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -12
- package/dist/pkt-messagebox.js +4 -105
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-progressbar.cjs +1 -0
- package/dist/pkt-progressbar.js +6 -0
- package/dist/pkt-slot-controller-Ckk_yV0j.cjs +1 -0
- package/dist/pkt-slot-controller-RJvOnbF4.js +61 -0
- package/dist/pkt-tag.cjs +1 -17
- package/dist/pkt-tag.js +4 -148
- 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-BS_oawSB.js +150 -0
- package/dist/progressbar-CuXkbAhJ.cjs +32 -0
- package/dist/ref-DCOsLZQg.cjs +13 -0
- package/dist/ref-DuFGTLVX.js +142 -0
- package/dist/state-BfyXV7EL.js +12 -0
- package/dist/state-SKYD8kRO.cjs +5 -0
- package/dist/stringutils-CkVRq4jP.cjs +1 -0
- package/dist/stringutils-DJjRa8dG.js +7 -0
- package/dist/tag-CGy2mSLE.cjs +17 -0
- package/dist/tag-DGFgUF3l.js +150 -0
- package/dist/{textarea-BTpJjEhO.js → textarea-BAGWR1Hi.js} +29 -29
- package/dist/textarea-BiUrhAlk.cjs +48 -0
- package/dist/{textinput-BIhQEr8z.cjs → textinput-CHOR5PPp.cjs} +2 -2
- package/dist/{textinput-CVo5wG14.js → textinput-pJ3N8m6g.js} +23 -23
- package/package.json +2 -2
- package/src/components/alert/alert.ts +115 -0
- package/src/components/alert/index.ts +4 -113
- package/src/components/calendar/calendar.ts +711 -0
- package/src/components/calendar/index.ts +3 -711
- package/src/components/card/card.ts +78 -0
- package/src/components/card/index.ts +4 -77
- package/src/components/datepicker/datepicker.ts +619 -0
- package/src/components/datepicker/index.ts +3 -618
- package/src/components/helptext/helptext.ts +2 -2
- package/src/components/icon/icon.ts +99 -0
- package/src/components/icon/index.ts +3 -98
- package/src/components/index.ts +29 -15
- package/src/components/input-wrapper/input-wrapper.ts +2 -2
- package/src/components/link/index.ts +3 -56
- package/src/components/link/link.ts +57 -0
- package/src/components/linkcard/index.ts +1 -1
- package/src/components/linkcard/linkcard.ts +5 -6
- package/src/components/messagebox/index.ts +4 -69
- package/src/components/messagebox/messagebox.ts +69 -0
- package/src/components/modal/index.ts +0 -1
- package/src/components/modal/modal.ts +5 -7
- package/src/components/progressbar/index.ts +12 -0
- package/src/components/progressbar/progressbar.ts +144 -0
- package/src/components/tag/index.ts +4 -109
- package/src/components/tag/tag.ts +118 -0
- package/src/components/textarea/textarea.ts +5 -4
- package/src/components/textinput/textinput.ts +3 -3
- package/dist/converters-DNCwIFwr.js +0 -17
- package/dist/converters-DhM11VlY.cjs +0 -1
- package/dist/custom-element-B-TlBwRu.cjs +0 -9
- package/dist/custom-element-CWfU4dcr.js +0 -38
- package/dist/element.d.ts +0 -8
- package/dist/helptext-DBolvFI4.js +0 -72
- package/dist/helptext-_fMLOOCL.cjs +0 -23
- package/dist/index-CR7t1zY9.cjs +0 -238
- package/dist/index-CmTjXoAb.cjs +0 -9
- package/dist/index-RwtTBIhT.js +0 -88
- package/dist/index-tvpcg-ad.cjs +0 -108
- package/dist/input-wrapper-DX41tnbj.cjs +0 -46
- package/dist/linkcard-Det6CJ5D.cjs +0 -13
- package/dist/pkt-component-template.cjs +0 -29
- package/dist/pkt-component-template.js +0 -99
- package/dist/pkt-element.cjs +0 -1
- package/dist/pkt-element.js +0 -5
- package/dist/ref-C2yPtMJA.cjs +0 -13
- package/dist/ref-CaiKp3S2.js +0 -202
- package/dist/textarea-B45ZZYpx.cjs +0 -48
- package/src/components/component-template/index.ts +0 -129
- package/src/components/element/index.ts +0 -353
- /package/dist/{component-template.d.ts → progressbar.d.ts} +0 -0
package/dist/ref-CaiKp3S2.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { Z as p, E as A } from "./index-CFDwiDTU.js";
|
|
2
|
-
import { i as v, a as N, e as m } from "./custom-element-CWfU4dcr.js";
|
|
3
|
-
class w {
|
|
4
|
-
constructor(e, ...t) {
|
|
5
|
-
this.nodes = [], this.host = e, this.host.addController(this), this.slots = t, this.nodes = [], this.observer = new MutationObserver((i) => this.handleMutations(i));
|
|
6
|
-
}
|
|
7
|
-
hostConnected() {
|
|
8
|
-
this.updateNodes(), this.observer.observe(this.host, { childList: !0 });
|
|
9
|
-
}
|
|
10
|
-
hostDisconnected() {
|
|
11
|
-
this.observer.disconnect();
|
|
12
|
-
}
|
|
13
|
-
hostUpdated() {
|
|
14
|
-
this.updateSlots();
|
|
15
|
-
}
|
|
16
|
-
updateNodes() {
|
|
17
|
-
this.nodes = [], Array.from(this.host.childNodes).forEach((t) => {
|
|
18
|
-
var i;
|
|
19
|
-
if (t.nodeType === Node.TEXT_NODE && ((i = t.nodeValue) != null && i.trim())) {
|
|
20
|
-
const o = document == null ? void 0 : document.createElement("template");
|
|
21
|
-
o.content.appendChild(t), this.nodes.push(o);
|
|
22
|
-
} else this.isSlotElement(t) || this.nodes.push(t);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
updateSlots() {
|
|
26
|
-
this.slots.forEach((e) => {
|
|
27
|
-
if (!e.value) return;
|
|
28
|
-
const t = e.value.getAttribute("name"), o = this.nodes.flatMap(
|
|
29
|
-
(n) => n.getAttribute && n.getAttribute("slot") == t ? this.nodeFromElement(n, e) : []
|
|
30
|
-
).filter(
|
|
31
|
-
(n) => e.value && !e.value.contains(n) && !n.contains(e.value)
|
|
32
|
-
);
|
|
33
|
-
o.length > 0 && e.value.replaceChildren(...o);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
handleMutations(e) {
|
|
37
|
-
let t = !1;
|
|
38
|
-
e.forEach((i) => {
|
|
39
|
-
i.type === "childList" && (i.addedNodes.forEach((o) => {
|
|
40
|
-
var h;
|
|
41
|
-
const n = o.nodeType === Node.ELEMENT_NODE && !this.isSlotElement(o), d = o.nodeType === Node.TEXT_NODE && ((h = o.nodeValue) == null ? void 0 : h.trim());
|
|
42
|
-
if (n)
|
|
43
|
-
this.nodes.push(o), t = !0;
|
|
44
|
-
else if (d) {
|
|
45
|
-
const l = document == null ? void 0 : document.createElement("template");
|
|
46
|
-
l.content.appendChild(o), this.nodes.push(l), t = !0;
|
|
47
|
-
}
|
|
48
|
-
}), i.removedNodes.forEach((o) => {
|
|
49
|
-
this.nodes = this.nodes.filter((n) => n !== o), t = !0;
|
|
50
|
-
}));
|
|
51
|
-
}), t && this.updateSlots();
|
|
52
|
-
}
|
|
53
|
-
isSlotElement(e) {
|
|
54
|
-
return this.slots.some((t) => t.value === e);
|
|
55
|
-
}
|
|
56
|
-
nodeFromElement(e, t) {
|
|
57
|
-
var i;
|
|
58
|
-
return e === ((i = t.value) == null ? void 0 : i.parentNode) ? [] : e instanceof HTMLTemplateElement ? Array.from(e.content.childNodes) : [e];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @license
|
|
63
|
-
* Copyright 2020 Google LLC
|
|
64
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
65
|
-
*/
|
|
66
|
-
const { I: E } = p, g = (s) => s.strings === void 0, $ = () => document.createComment(""), B = (s, e, t) => {
|
|
67
|
-
var n;
|
|
68
|
-
const i = s._$AA.parentNode, o = e === void 0 ? s._$AB : e._$AA;
|
|
69
|
-
if (t === void 0) {
|
|
70
|
-
const d = i.insertBefore($(), o), h = i.insertBefore($(), o);
|
|
71
|
-
t = new E(d, h, s, s.options);
|
|
72
|
-
} else {
|
|
73
|
-
const d = t._$AB.nextSibling, h = t._$AM, l = h !== s;
|
|
74
|
-
if (l) {
|
|
75
|
-
let r;
|
|
76
|
-
(n = t._$AQ) == null || n.call(t, s), t._$AM = s, t._$AP !== void 0 && (r = s._$AU) !== h._$AU && t._$AP(r);
|
|
77
|
-
}
|
|
78
|
-
if (d !== o || l) {
|
|
79
|
-
let r = t._$AA;
|
|
80
|
-
for (; r !== d; ) {
|
|
81
|
-
const _ = r.nextSibling;
|
|
82
|
-
i.insertBefore(r, o), r = _;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return t;
|
|
87
|
-
}, H = (s, e, t = s) => (s._$AI(e, t), s), C = {}, O = (s, e = C) => s._$AH = e, P = (s) => s._$AH, k = (s) => {
|
|
88
|
-
var i;
|
|
89
|
-
(i = s._$AP) == null || i.call(s, !1, !0);
|
|
90
|
-
let e = s._$AA;
|
|
91
|
-
const t = s._$AB.nextSibling;
|
|
92
|
-
for (; e !== t; ) {
|
|
93
|
-
const o = e.nextSibling;
|
|
94
|
-
e.remove(), e = o;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* @license
|
|
99
|
-
* Copyright 2017 Google LLC
|
|
100
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
101
|
-
*/
|
|
102
|
-
const c = (s, e) => {
|
|
103
|
-
var i;
|
|
104
|
-
const t = s._$AN;
|
|
105
|
-
if (t === void 0) return !1;
|
|
106
|
-
for (const o of t) (i = o._$AO) == null || i.call(o, e, !1), c(o, e);
|
|
107
|
-
return !0;
|
|
108
|
-
}, a = (s) => {
|
|
109
|
-
let e, t;
|
|
110
|
-
do {
|
|
111
|
-
if ((e = s._$AM) === void 0) break;
|
|
112
|
-
t = e._$AN, t.delete(s), s = e;
|
|
113
|
-
} while ((t == null ? void 0 : t.size) === 0);
|
|
114
|
-
}, f = (s) => {
|
|
115
|
-
for (let e; e = s._$AM; s = e) {
|
|
116
|
-
let t = e._$AN;
|
|
117
|
-
if (t === void 0) e._$AN = t = /* @__PURE__ */ new Set();
|
|
118
|
-
else if (t.has(s)) break;
|
|
119
|
-
t.add(s), T(e);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
function b(s) {
|
|
123
|
-
this._$AN !== void 0 ? (a(this), this._$AM = s, f(this)) : this._$AM = s;
|
|
124
|
-
}
|
|
125
|
-
function M(s, e = !1, t = 0) {
|
|
126
|
-
const i = this._$AH, o = this._$AN;
|
|
127
|
-
if (o !== void 0 && o.size !== 0) if (e) if (Array.isArray(i)) for (let n = t; n < i.length; n++) c(i[n], !1), a(i[n]);
|
|
128
|
-
else i != null && (c(i, !1), a(i));
|
|
129
|
-
else c(this, s);
|
|
130
|
-
}
|
|
131
|
-
const T = (s) => {
|
|
132
|
-
s.type == N.CHILD && (s._$AP ?? (s._$AP = M), s._$AQ ?? (s._$AQ = b));
|
|
133
|
-
};
|
|
134
|
-
class S extends v {
|
|
135
|
-
constructor() {
|
|
136
|
-
super(...arguments), this._$AN = void 0;
|
|
137
|
-
}
|
|
138
|
-
_$AT(e, t, i) {
|
|
139
|
-
super._$AT(e, t, i), f(this), this.isConnected = e._$AU;
|
|
140
|
-
}
|
|
141
|
-
_$AO(e, t = !0) {
|
|
142
|
-
var i, o;
|
|
143
|
-
e !== this.isConnected && (this.isConnected = e, e ? (i = this.reconnected) == null || i.call(this) : (o = this.disconnected) == null || o.call(this)), t && (c(this, e), a(this));
|
|
144
|
-
}
|
|
145
|
-
setValue(e) {
|
|
146
|
-
if (g(this._$Ct)) this._$Ct._$AI(e, this);
|
|
147
|
-
else {
|
|
148
|
-
const t = [...this._$Ct._$AH];
|
|
149
|
-
t[this._$Ci] = e, this._$Ct._$AI(t, this, 0);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
disconnected() {
|
|
153
|
-
}
|
|
154
|
-
reconnected() {
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* @license
|
|
159
|
-
* Copyright 2020 Google LLC
|
|
160
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
161
|
-
*/
|
|
162
|
-
const D = () => new y();
|
|
163
|
-
class y {
|
|
164
|
-
}
|
|
165
|
-
const u = /* @__PURE__ */ new WeakMap(), I = m(class extends S {
|
|
166
|
-
render(s) {
|
|
167
|
-
return A;
|
|
168
|
-
}
|
|
169
|
-
update(s, [e]) {
|
|
170
|
-
var i;
|
|
171
|
-
const t = e !== this.Y;
|
|
172
|
-
return t && this.Y !== void 0 && this.rt(void 0), (t || this.lt !== this.ct) && (this.Y = e, this.ht = (i = s.options) == null ? void 0 : i.host, this.rt(this.ct = s.element)), A;
|
|
173
|
-
}
|
|
174
|
-
rt(s) {
|
|
175
|
-
if (this.isConnected || (s = void 0), typeof this.Y == "function") {
|
|
176
|
-
const e = this.ht ?? globalThis;
|
|
177
|
-
let t = u.get(e);
|
|
178
|
-
t === void 0 && (t = /* @__PURE__ */ new WeakMap(), u.set(e, t)), t.get(this.Y) !== void 0 && this.Y.call(this.ht, void 0), t.set(this.Y, s), s !== void 0 && this.Y.call(this.ht, s);
|
|
179
|
-
} else this.Y.value = s;
|
|
180
|
-
}
|
|
181
|
-
get lt() {
|
|
182
|
-
var s, e;
|
|
183
|
-
return typeof this.Y == "function" ? (s = u.get(this.ht ?? globalThis)) == null ? void 0 : s.get(this.Y) : (e = this.Y) == null ? void 0 : e.value;
|
|
184
|
-
}
|
|
185
|
-
disconnected() {
|
|
186
|
-
this.lt === this.ct && this.rt(void 0);
|
|
187
|
-
}
|
|
188
|
-
reconnected() {
|
|
189
|
-
this.rt(this.ct);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
export {
|
|
193
|
-
k as M,
|
|
194
|
-
w as P,
|
|
195
|
-
D as e,
|
|
196
|
-
g as f,
|
|
197
|
-
O as m,
|
|
198
|
-
I as n,
|
|
199
|
-
P as p,
|
|
200
|
-
B as r,
|
|
201
|
-
H as v
|
|
202
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";const a=require("./index-CR7t1zY9.cjs"),s=require("./custom-element-B-TlBwRu.cjs"),u=require("./ref-C2yPtMJA.cjs"),p=require("./class-map-a5HUzP83.cjs");require("./input-wrapper-DX41tnbj.cjs");require("./index-CmTjXoAb.cjs");/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2020 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const d=s.e(class extends s.i{constructor(r){if(super(r),r.type!==s.t$1.PROPERTY&&r.type!==s.t$1.ATTRIBUTE&&r.type!==s.t$1.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!u.f(r))throw Error("`live` bindings can only contain a single expression")}render(r){return r}update(r,[e]){if(e===a.T||e===a.E)return e;const i=r.element,t=r.name;if(r.type===s.t$1.PROPERTY){if(e===i[t])return a.T}else if(r.type===s.t$1.BOOLEAN_ATTRIBUTE){if(!!e===i.hasAttribute(t))return a.T}else if(r.type===s.t$1.ATTRIBUTE&&i.getAttribute(t)===e+"")return a.T;return u.m(r),e}});var c=Object.defineProperty,$=Object.getOwnPropertyDescriptor,o=(r,e,i,t)=>{for(var n=t>1?void 0:t?$(e,i):e,l=r.length-1,h;l>=0;l--)(h=r[l])&&(n=(t?h(e,i,n):h(n))||n);return t&&n&&c(e,i,n),n};exports.PktTextarea=class extends a.PktInputElement{constructor(){super(...arguments),this.value="",this.autocomplete="off",this.placeholder="",this.rows=null,this.counterCurrent=0,this.inputRef=u.e()}attributeChangedCallback(e,i,t){e==="value"&&this.value!==i&&(this.counterCurrent=t?t.length:0,this.valueChanged(t,i)),super.attributeChangedCallback(e,i,t)}updated(e){var i;super.updated(e),e.has("value")&&(this.counterCurrent=((i=this.value)==null?void 0:i.length)||0,this.valueChanged(this.value,e.get("value"))),e.has("id")&&!this.name&&this.id&&(this.name=this.id)}render(){const e=p.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}),i=this.ariaLabelledby||`${this.id}-input-label`;return a.x`<pkt-input-wrapper
|
|
6
|
-
label="${this.label}"
|
|
7
|
-
?counter=${this.counter}
|
|
8
|
-
?disabled=${this.disabled}
|
|
9
|
-
?hasError=${this.hasError}
|
|
10
|
-
?inline=${this.inline}
|
|
11
|
-
?optionalTag=${this.optionalTag}
|
|
12
|
-
?required=${this.required}
|
|
13
|
-
?requiredTag=${this.requiredTag}
|
|
14
|
-
?useWrapper=${this.useWrapper}
|
|
15
|
-
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
16
|
-
.counterCurrent=${this.counterCurrent}
|
|
17
|
-
.counterMaxLength=${this.counterMaxLength}
|
|
18
|
-
.errorMessage=${this.errorMessage}
|
|
19
|
-
.forId="${this.id+"-input"}"
|
|
20
|
-
.helptext=${this.helptext}
|
|
21
|
-
.helptextDropdown=${this.helptextDropdown}
|
|
22
|
-
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
23
|
-
.optionalText=${this.optionalText}
|
|
24
|
-
.requiredText=${this.requiredText}
|
|
25
|
-
class="pkt-textarea"
|
|
26
|
-
>
|
|
27
|
-
<textarea
|
|
28
|
-
${u.n(this.inputRef)}
|
|
29
|
-
class=${e}
|
|
30
|
-
id=${this.id+"-input"}
|
|
31
|
-
name=${(this.name||this.id)+"-input"}
|
|
32
|
-
placeholder=${this.placeholder??a.E}
|
|
33
|
-
.value=${d(this.value)}
|
|
34
|
-
minlength=${this.minlength||a.E}
|
|
35
|
-
maxlength=${this.maxlength||a.E}
|
|
36
|
-
?readonly=${this.readonly}
|
|
37
|
-
autocomplete=${this.autocomplete}
|
|
38
|
-
aria-labelledby=${i}
|
|
39
|
-
aria-invalid=${this.hasError}
|
|
40
|
-
aria-errormessage=${`${this.id}-error`}
|
|
41
|
-
rows=${this.rows}
|
|
42
|
-
?disabled=${this.disabled}
|
|
43
|
-
@input=${t=>{this.value=t.target.value,this.onInput(),t.stopImmediatePropagation()}}
|
|
44
|
-
@change=${t=>{t.stopImmediatePropagation()}}
|
|
45
|
-
@focus=${t=>{this.onFocus(),t.stopImmediatePropagation()}}
|
|
46
|
-
@blur=${t=>{this.value=t.target.value,this.onBlur(),t.stopImmediatePropagation()}}
|
|
47
|
-
></textarea>
|
|
48
|
-
</pkt-input-wrapper>`}};o([a.n({type:String,reflect:!0})],exports.PktTextarea.prototype,"value",2);o([a.n({type:String})],exports.PktTextarea.prototype,"autocomplete",2);o([a.n({type:String})],exports.PktTextarea.prototype,"placeholder",2);o([a.n({type:Number})],exports.PktTextarea.prototype,"rows",2);o([a.r()],exports.PktTextarea.prototype,"counterCurrent",2);exports.PktTextarea=o([s.t("pkt-textarea")],exports.PktTextarea);
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit'
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
3
|
-
import { PktElement } from '../element'
|
|
4
|
-
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
5
|
-
import { ref, Ref, createRef } from 'lit/directives/ref.js'
|
|
6
|
-
|
|
7
|
-
// If you need to convert an object to a list of classes, use classMap
|
|
8
|
-
import { classMap } from 'lit/directives/class-map.js'
|
|
9
|
-
|
|
10
|
-
// If you need text strings add them in this file and include it
|
|
11
|
-
import translations from '../../translations/no.json'
|
|
12
|
-
|
|
13
|
-
// If you need to convert attribute strings to JavaScript objects,
|
|
14
|
-
// use helpers from converters.ts
|
|
15
|
-
import { csvToArray } from '../../helpers/converters'
|
|
16
|
-
|
|
17
|
-
@customElement('pkt-component')
|
|
18
|
-
export class PktComponent extends PktElement {
|
|
19
|
-
/**
|
|
20
|
-
* Element attributes => props
|
|
21
|
-
* Example:
|
|
22
|
-
* <pkt-component string="hei" strings="hei,og,hallo" darkmode>
|
|
23
|
-
* Hei!
|
|
24
|
-
* </pkt-component>
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
@property({ type: String })
|
|
28
|
-
string: string = ''
|
|
29
|
-
|
|
30
|
-
@property({ converter: csvToArray })
|
|
31
|
-
strings: string[] = []
|
|
32
|
-
|
|
33
|
-
@property({ type: Boolean })
|
|
34
|
-
darkmode: boolean = false
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Private properties, for internal use only
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
@property({ type: Array }) private _list: string[] = []
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Runs on mount, used to set up various values and whatever you need to run
|
|
44
|
-
*/
|
|
45
|
-
connectedCallback() {
|
|
46
|
-
this.strings.length &&
|
|
47
|
-
this.strings.forEach((string) => {
|
|
48
|
-
this._list.push(string.toUpperCase())
|
|
49
|
-
})
|
|
50
|
-
super.connectedCallback()
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Set up slot support for Light DOM
|
|
55
|
-
*/
|
|
56
|
-
slotController: PktSlotController
|
|
57
|
-
defaultSlot: Ref<HTMLElement> = createRef()
|
|
58
|
-
namedSlot: Ref<HTMLElement> = createRef()
|
|
59
|
-
|
|
60
|
-
constructor() {
|
|
61
|
-
super()
|
|
62
|
-
this.slotController = new PktSlotController(this, this.defaultSlot, this.namedSlot)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Render functions
|
|
67
|
-
*/
|
|
68
|
-
render() {
|
|
69
|
-
const classes = {
|
|
70
|
-
'pkt-component': true,
|
|
71
|
-
'pkt-component--has-list': this.strings.length > 0,
|
|
72
|
-
'pkt-darkmode': this.darkmode,
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return html`
|
|
76
|
-
<div class="${classMap(classes)}">
|
|
77
|
-
<h1 class="pkt-txt-28">${this.string}</h1>
|
|
78
|
-
|
|
79
|
-
<h2 class="pkt-txt-22">Innhold fra attributter og funksjoner</h2>
|
|
80
|
-
<div>${this.renderList(this.strings)}</div>
|
|
81
|
-
<div>${this.renderList(this.doStuff(this._list))}</div>
|
|
82
|
-
|
|
83
|
-
<h2 class="pkt-txt-22">Slot</h2>
|
|
84
|
-
<div ${ref(this.defaultSlot)}>defaultSlotRef</div>
|
|
85
|
-
<h2 class="pkt-txt-22">Named slot</h2>
|
|
86
|
-
<select
|
|
87
|
-
name="named-slot"
|
|
88
|
-
${ref(this.namedSlot)}
|
|
89
|
-
@change=${(e: Event) => alert((e.target as HTMLSelectElement).value)}
|
|
90
|
-
>
|
|
91
|
-
namedSlotRef
|
|
92
|
-
</select>
|
|
93
|
-
|
|
94
|
-
<h2 class="pkt-txt-22">Knapp som emitter en event</h2>
|
|
95
|
-
<button type="button" @click=${() => this.handleGreeting()}>
|
|
96
|
-
Si ${translations.example.hi}
|
|
97
|
-
</button>
|
|
98
|
-
</div>
|
|
99
|
-
`
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private renderList(list: string[]) {
|
|
103
|
-
return html`
|
|
104
|
-
<ul>
|
|
105
|
-
${list.map((i) => html`<li>${i}</li>`)}
|
|
106
|
-
</ul>
|
|
107
|
-
`
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Add other functionality under here
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
|
-
private doStuff(val: string[]) {
|
|
115
|
-
return val.reverse()
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Handlers for returning data from the component
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
private handleGreeting() {
|
|
123
|
-
this.dispatchEvent(
|
|
124
|
-
new CustomEvent('pkt-greeting', {
|
|
125
|
-
detail: 'Hei på deg!',
|
|
126
|
-
}),
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
}
|