@folkehelseinstituttet/designsystem 0.1.2 → 0.2.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/fhi-button.js CHANGED
@@ -1,622 +1,50 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- const M = globalThis, V = M.ShadowRoot && (M.ShadyCSS === void 0 || M.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, W = Symbol(), J = /* @__PURE__ */ new WeakMap();
7
- let ar = class {
8
- constructor(r, e, o) {
9
- if (this._$cssResult$ = !0, o !== W) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
10
- this.cssText = r, this.t = e;
11
- }
12
- get styleSheet() {
13
- let r = this.o;
14
- const e = this.t;
15
- if (V && r === void 0) {
16
- const o = e !== void 0 && e.length === 1;
17
- o && (r = J.get(e)), r === void 0 && ((this.o = r = new CSSStyleSheet()).replaceSync(this.cssText), o && J.set(e, r));
18
- }
19
- return r;
20
- }
21
- toString() {
22
- return this.cssText;
23
- }
1
+ import { i as u, n as c, r as b, x as v, t as s } from "./property-BHe3YuYx.js";
2
+ var g = Object.defineProperty, h = Object.getOwnPropertyDescriptor, l = (r, o, t, n) => {
3
+ for (var a = n > 1 ? void 0 : n ? h(o, t) : o, d = r.length - 1, i; d >= 0; d--)
4
+ (i = r[d]) && (a = (n ? i(o, t, a) : i(a)) || a);
5
+ return n && a && g(o, t, a), a;
24
6
  };
25
- const sr = (a) => new ar(typeof a == "string" ? a : a + "", void 0, W), dr = (a, ...r) => {
26
- const e = a.length === 1 ? a[0] : r.reduce((o, t, c) => o + ((l) => {
27
- if (l._$cssResult$ === !0) return l.cssText;
28
- if (typeof l == "number") return l;
29
- throw Error("Value passed to 'css' function must be a 'css' function result: " + l + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
30
- })(t) + a[c + 1], a[0]);
31
- return new ar(e, a, W);
32
- }, ur = (a, r) => {
33
- if (V) a.adoptedStyleSheets = r.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
34
- else for (const e of r) {
35
- const o = document.createElement("style"), t = M.litNonce;
36
- t !== void 0 && o.setAttribute("nonce", t), o.textContent = e.cssText, a.appendChild(o);
37
- }
38
- }, K = V ? (a) => a : (a) => a instanceof CSSStyleSheet ? ((r) => {
39
- let e = "";
40
- for (const o of r.cssRules) e += o.cssText;
41
- return sr(e);
42
- })(a) : a;
43
- /**
44
- * @license
45
- * Copyright 2017 Google LLC
46
- * SPDX-License-Identifier: BSD-3-Clause
47
- */
48
- const { is: hr, defineProperty: vr, getOwnPropertyDescriptor: br, getOwnPropertyNames: gr, getOwnPropertySymbols: fr, getPrototypeOf: pr } = Object, f = globalThis, Z = f.trustedTypes, yr = Z ? Z.emptyScript : "", L = f.reactiveElementPolyfillSupport, S = (a, r) => a, N = { toAttribute(a, r) {
49
- switch (r) {
50
- case Boolean:
51
- a = a ? yr : null;
52
- break;
53
- case Object:
54
- case Array:
55
- a = a == null ? a : JSON.stringify(a);
56
- }
57
- return a;
58
- }, fromAttribute(a, r) {
59
- let e = a;
60
- switch (r) {
61
- case Boolean:
62
- e = a !== null;
63
- break;
64
- case Number:
65
- e = a === null ? null : Number(a);
66
- break;
67
- case Object:
68
- case Array:
69
- try {
70
- e = JSON.parse(a);
71
- } catch {
72
- e = null;
73
- }
74
- }
75
- return e;
76
- } }, q = (a, r) => !hr(a, r), G = { attribute: !0, type: String, converter: N, reflect: !1, hasChanged: q };
77
- Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), f.litPropertyMetadata ?? (f.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
78
- class _ extends HTMLElement {
79
- static addInitializer(r) {
80
- this._$Ei(), (this.l ?? (this.l = [])).push(r);
81
- }
82
- static get observedAttributes() {
83
- return this.finalize(), this._$Eh && [...this._$Eh.keys()];
84
- }
85
- static createProperty(r, e = G) {
86
- if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(r, e), !e.noAccessor) {
87
- const o = Symbol(), t = this.getPropertyDescriptor(r, o, e);
88
- t !== void 0 && vr(this.prototype, r, t);
89
- }
90
- }
91
- static getPropertyDescriptor(r, e, o) {
92
- const { get: t, set: c } = br(this.prototype, r) ?? { get() {
93
- return this[e];
94
- }, set(l) {
95
- this[e] = l;
96
- } };
97
- return { get() {
98
- return t == null ? void 0 : t.call(this);
99
- }, set(l) {
100
- const i = t == null ? void 0 : t.call(this);
101
- c.call(this, l), this.requestUpdate(r, i, o);
102
- }, configurable: !0, enumerable: !0 };
103
- }
104
- static getPropertyOptions(r) {
105
- return this.elementProperties.get(r) ?? G;
106
- }
107
- static _$Ei() {
108
- if (this.hasOwnProperty(S("elementProperties"))) return;
109
- const r = pr(this);
110
- r.finalize(), r.l !== void 0 && (this.l = [...r.l]), this.elementProperties = new Map(r.elementProperties);
111
- }
112
- static finalize() {
113
- if (this.hasOwnProperty(S("finalized"))) return;
114
- if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(S("properties"))) {
115
- const e = this.properties, o = [...gr(e), ...fr(e)];
116
- for (const t of o) this.createProperty(t, e[t]);
117
- }
118
- const r = this[Symbol.metadata];
119
- if (r !== null) {
120
- const e = litPropertyMetadata.get(r);
121
- if (e !== void 0) for (const [o, t] of e) this.elementProperties.set(o, t);
122
- }
123
- this._$Eh = /* @__PURE__ */ new Map();
124
- for (const [e, o] of this.elementProperties) {
125
- const t = this._$Eu(e, o);
126
- t !== void 0 && this._$Eh.set(t, e);
127
- }
128
- this.elementStyles = this.finalizeStyles(this.styles);
129
- }
130
- static finalizeStyles(r) {
131
- const e = [];
132
- if (Array.isArray(r)) {
133
- const o = new Set(r.flat(1 / 0).reverse());
134
- for (const t of o) e.unshift(K(t));
135
- } else r !== void 0 && e.push(K(r));
136
- return e;
137
- }
138
- static _$Eu(r, e) {
139
- const o = e.attribute;
140
- return o === !1 ? void 0 : typeof o == "string" ? o : typeof r == "string" ? r.toLowerCase() : void 0;
141
- }
7
+ const f = "fhi-button";
8
+ let e = class extends b {
142
9
  constructor() {
143
- super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
144
- }
145
- _$Ev() {
146
- var r;
147
- this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (r = this.constructor.l) == null || r.forEach((e) => e(this));
148
- }
149
- addController(r) {
150
- var e;
151
- (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(r), this.renderRoot !== void 0 && this.isConnected && ((e = r.hostConnected) == null || e.call(r));
152
- }
153
- removeController(r) {
154
- var e;
155
- (e = this._$EO) == null || e.delete(r);
156
- }
157
- _$E_() {
158
- const r = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
159
- for (const o of e.keys()) this.hasOwnProperty(o) && (r.set(o, this[o]), delete this[o]);
160
- r.size > 0 && (this._$Ep = r);
161
- }
162
- createRenderRoot() {
163
- const r = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
164
- return ur(r, this.constructor.elementStyles), r;
10
+ super(), this.color = "accent", this.variant = "strong", this.size = "medium", this.disabled = !1, this.type = "submit", this._internals = this.attachInternals();
165
11
  }
166
12
  connectedCallback() {
167
- var r;
168
- this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (r = this._$EO) == null || r.forEach((e) => {
169
- var o;
170
- return (o = e.hostConnected) == null ? void 0 : o.call(e);
171
- });
172
- }
173
- enableUpdating(r) {
174
- }
175
- disconnectedCallback() {
176
- var r;
177
- (r = this._$EO) == null || r.forEach((e) => {
178
- var o;
179
- return (o = e.hostDisconnected) == null ? void 0 : o.call(e);
180
- });
181
- }
182
- attributeChangedCallback(r, e, o) {
183
- this._$AK(r, o);
184
- }
185
- _$EC(r, e) {
186
- var c;
187
- const o = this.constructor.elementProperties.get(r), t = this.constructor._$Eu(r, o);
188
- if (t !== void 0 && o.reflect === !0) {
189
- const l = (((c = o.converter) == null ? void 0 : c.toAttribute) !== void 0 ? o.converter : N).toAttribute(e, o.type);
190
- this._$Em = r, l == null ? this.removeAttribute(t) : this.setAttribute(t, l), this._$Em = null;
191
- }
192
- }
193
- _$AK(r, e) {
194
- var c;
195
- const o = this.constructor, t = o._$Eh.get(r);
196
- if (t !== void 0 && this._$Em !== t) {
197
- const l = o.getPropertyOptions(t), i = typeof l.converter == "function" ? { fromAttribute: l.converter } : ((c = l.converter) == null ? void 0 : c.fromAttribute) !== void 0 ? l.converter : N;
198
- this._$Em = t, this[t] = i.fromAttribute(e, l.type), this._$Em = null;
199
- }
200
- }
201
- requestUpdate(r, e, o) {
202
- if (r !== void 0) {
203
- if (o ?? (o = this.constructor.getPropertyOptions(r)), !(o.hasChanged ?? q)(this[r], e)) return;
204
- this.P(r, e, o);
205
- }
206
- this.isUpdatePending === !1 && (this._$ES = this._$ET());
207
- }
208
- P(r, e, o) {
209
- this._$AL.has(r) || this._$AL.set(r, e), o.reflect === !0 && this._$Em !== r && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(r);
210
- }
211
- async _$ET() {
212
- this.isUpdatePending = !0;
213
- try {
214
- await this._$ES;
215
- } catch (e) {
216
- Promise.reject(e);
217
- }
218
- const r = this.scheduleUpdate();
219
- return r != null && await r, !this.isUpdatePending;
220
- }
221
- scheduleUpdate() {
222
- return this.performUpdate();
223
- }
224
- performUpdate() {
225
- var o;
226
- if (!this.isUpdatePending) return;
227
- if (!this.hasUpdated) {
228
- if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
229
- for (const [c, l] of this._$Ep) this[c] = l;
230
- this._$Ep = void 0;
231
- }
232
- const t = this.constructor.elementProperties;
233
- if (t.size > 0) for (const [c, l] of t) l.wrapped !== !0 || this._$AL.has(c) || this[c] === void 0 || this.P(c, this[c], l);
234
- }
235
- let r = !1;
236
- const e = this._$AL;
237
- try {
238
- r = this.shouldUpdate(e), r ? (this.willUpdate(e), (o = this._$EO) == null || o.forEach((t) => {
239
- var c;
240
- return (c = t.hostUpdate) == null ? void 0 : c.call(t);
241
- }), this.update(e)) : this._$EU();
242
- } catch (t) {
243
- throw r = !1, this._$EU(), t;
244
- }
245
- r && this._$AE(e);
246
- }
247
- willUpdate(r) {
248
- }
249
- _$AE(r) {
250
- var e;
251
- (e = this._$EO) == null || e.forEach((o) => {
252
- var t;
253
- return (t = o.hostUpdated) == null ? void 0 : t.call(o);
254
- }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(r)), this.updated(r);
255
- }
256
- _$EU() {
257
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
258
- }
259
- get updateComplete() {
260
- return this.getUpdateComplete();
261
- }
262
- getUpdateComplete() {
263
- return this._$ES;
264
- }
265
- shouldUpdate(r) {
266
- return !0;
267
- }
268
- update(r) {
269
- this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU();
270
- }
271
- updated(r) {
272
- }
273
- firstUpdated(r) {
274
- }
275
- }
276
- _.elementStyles = [], _.shadowRootOptions = { mode: "open" }, _[S("elementProperties")] = /* @__PURE__ */ new Map(), _[S("finalized")] = /* @__PURE__ */ new Map(), L == null || L({ ReactiveElement: _ }), (f.reactiveElementVersions ?? (f.reactiveElementVersions = [])).push("2.0.4");
277
- /**
278
- * @license
279
- * Copyright 2017 Google LLC
280
- * SPDX-License-Identifier: BSD-3-Clause
281
- */
282
- const w = globalThis, R = w.trustedTypes, Q = R ? R.createPolicy("lit-html", { createHTML: (a) => a }) : void 0, lr = "$lit$", g = `lit$${Math.random().toFixed(9).slice(2)}$`, cr = "?" + g, mr = `<${cr}>`, $ = document, P = () => $.createComment(""), U = (a) => a === null || typeof a != "object" && typeof a != "function", F = Array.isArray, $r = (a) => F(a) || typeof (a == null ? void 0 : a[Symbol.iterator]) == "function", D = `[
283
- \f\r]`, E = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, X = /-->/g, Y = />/g, y = RegExp(`>|${D}(?:([^\\s"'>=/]+)(${D}*=${D}*(?:[^
284
- \f\r"'\`<>=]|("|')|))|$)`, "g"), rr = /'/g, er = /"/g, nr = /^(?:script|style|textarea|title)$/i, _r = (a) => (r, ...e) => ({ _$litType$: a, strings: r, values: e }), kr = _r(1), k = Symbol.for("lit-noChange"), u = Symbol.for("lit-nothing"), or = /* @__PURE__ */ new WeakMap(), m = $.createTreeWalker($, 129);
285
- function ir(a, r) {
286
- if (!F(a) || !a.hasOwnProperty("raw")) throw Error("invalid template strings array");
287
- return Q !== void 0 ? Q.createHTML(r) : r;
288
- }
289
- const xr = (a, r) => {
290
- const e = a.length - 1, o = [];
291
- let t, c = r === 2 ? "<svg>" : r === 3 ? "<math>" : "", l = E;
292
- for (let i = 0; i < e; i++) {
293
- const n = a[i];
294
- let d, h, s = -1, v = 0;
295
- for (; v < n.length && (l.lastIndex = v, h = l.exec(n), h !== null); ) v = l.lastIndex, l === E ? h[1] === "!--" ? l = X : h[1] !== void 0 ? l = Y : h[2] !== void 0 ? (nr.test(h[2]) && (t = RegExp("</" + h[2], "g")), l = y) : h[3] !== void 0 && (l = y) : l === y ? h[0] === ">" ? (l = t ?? E, s = -1) : h[1] === void 0 ? s = -2 : (s = l.lastIndex - h[2].length, d = h[1], l = h[3] === void 0 ? y : h[3] === '"' ? er : rr) : l === er || l === rr ? l = y : l === X || l === Y ? l = E : (l = y, t = void 0);
296
- const b = l === y && a[i + 1].startsWith("/>") ? " " : "";
297
- c += l === E ? n + mr : s >= 0 ? (o.push(d), n.slice(0, s) + lr + n.slice(s) + g + b) : n + g + (s === -2 ? i : b);
298
- }
299
- return [ir(a, c + (a[e] || "<?>") + (r === 2 ? "</svg>" : r === 3 ? "</math>" : "")), o];
300
- };
301
- class O {
302
- constructor({ strings: r, _$litType$: e }, o) {
303
- let t;
304
- this.parts = [];
305
- let c = 0, l = 0;
306
- const i = r.length - 1, n = this.parts, [d, h] = xr(r, e);
307
- if (this.el = O.createElement(d, o), m.currentNode = this.el.content, e === 2 || e === 3) {
308
- const s = this.el.content.firstChild;
309
- s.replaceWith(...s.childNodes);
310
- }
311
- for (; (t = m.nextNode()) !== null && n.length < i; ) {
312
- if (t.nodeType === 1) {
313
- if (t.hasAttributes()) for (const s of t.getAttributeNames()) if (s.endsWith(lr)) {
314
- const v = h[l++], b = t.getAttribute(s).split(g), z = /([.?@])?(.*)/.exec(v);
315
- n.push({ type: 1, index: c, name: z[2], strings: b, ctor: z[1] === "." ? Er : z[1] === "?" ? Sr : z[1] === "@" ? wr : B }), t.removeAttribute(s);
316
- } else s.startsWith(g) && (n.push({ type: 6, index: c }), t.removeAttribute(s));
317
- if (nr.test(t.tagName)) {
318
- const s = t.textContent.split(g), v = s.length - 1;
319
- if (v > 0) {
320
- t.textContent = R ? R.emptyScript : "";
321
- for (let b = 0; b < v; b++) t.append(s[b], P()), m.nextNode(), n.push({ type: 2, index: ++c });
322
- t.append(s[v], P());
323
- }
324
- }
325
- } else if (t.nodeType === 8) if (t.data === cr) n.push({ type: 2, index: c });
326
- else {
327
- let s = -1;
328
- for (; (s = t.data.indexOf(g, s + 1)) !== -1; ) n.push({ type: 7, index: c }), s += g.length - 1;
329
- }
330
- c++;
331
- }
332
- }
333
- static createElement(r, e) {
334
- const o = $.createElement("template");
335
- return o.innerHTML = r, o;
13
+ super.connectedCallback(), this.onkeyup = this._handleKeyup.bind(this), this.onkeydown = this._handleKeydown.bind(this);
336
14
  }
337
- }
338
- function x(a, r, e = a, o) {
339
- var l, i;
340
- if (r === k) return r;
341
- let t = o !== void 0 ? (l = e._$Co) == null ? void 0 : l[o] : e._$Cl;
342
- const c = U(r) ? void 0 : r._$litDirective$;
343
- return (t == null ? void 0 : t.constructor) !== c && ((i = t == null ? void 0 : t._$AO) == null || i.call(t, !1), c === void 0 ? t = void 0 : (t = new c(a), t._$AT(a, e, o)), o !== void 0 ? (e._$Co ?? (e._$Co = []))[o] = t : e._$Cl = t), t !== void 0 && (r = x(a, t._$AS(a, r.values), t, o)), r;
344
- }
345
- class Ar {
346
- constructor(r, e) {
347
- this._$AV = [], this._$AN = void 0, this._$AD = r, this._$AM = e;
15
+ click() {
16
+ this._handleClick();
348
17
  }
349
- get parentNode() {
350
- return this._$AM.parentNode;
18
+ _handleClick(r) {
19
+ var o, t;
20
+ r == null || r.preventDefault(), r == null || r.stopPropagation(), !this.disabled && (this.dispatchEvent(
21
+ new MouseEvent("click", { bubbles: !0, composed: !0 })
22
+ ), this.type === "submit" && ((o = this._internals.form) == null || o.requestSubmit()), this.type === "reset" && ((t = this._internals.form) == null || t.reset()));
351
23
  }
352
- get _$AU() {
353
- return this._$AM._$AU;
354
- }
355
- u(r) {
356
- const { el: { content: e }, parts: o } = this._$AD, t = ((r == null ? void 0 : r.creationScope) ?? $).importNode(e, !0);
357
- m.currentNode = t;
358
- let c = m.nextNode(), l = 0, i = 0, n = o[0];
359
- for (; n !== void 0; ) {
360
- if (l === n.index) {
361
- let d;
362
- n.type === 2 ? d = new T(c, c.nextSibling, this, r) : n.type === 1 ? d = new n.ctor(c, n.name, n.strings, this, r) : n.type === 6 && (d = new Cr(c, this, r)), this._$AV.push(d), n = o[++i];
363
- }
364
- l !== (n == null ? void 0 : n.index) && (c = m.nextNode(), l++);
365
- }
366
- return m.currentNode = $, t;
367
- }
368
- p(r) {
369
- let e = 0;
370
- for (const o of this._$AV) o !== void 0 && (o.strings !== void 0 ? (o._$AI(r, o, e), e += o.strings.length - 2) : o._$AI(r[e])), e++;
371
- }
372
- }
373
- class T {
374
- get _$AU() {
375
- var r;
376
- return ((r = this._$AM) == null ? void 0 : r._$AU) ?? this._$Cv;
377
- }
378
- constructor(r, e, o, t) {
379
- this.type = 2, this._$AH = u, this._$AN = void 0, this._$AA = r, this._$AB = e, this._$AM = o, this.options = t, this._$Cv = (t == null ? void 0 : t.isConnected) ?? !0;
380
- }
381
- get parentNode() {
382
- let r = this._$AA.parentNode;
383
- const e = this._$AM;
384
- return e !== void 0 && (r == null ? void 0 : r.nodeType) === 11 && (r = e.parentNode), r;
385
- }
386
- get startNode() {
387
- return this._$AA;
388
- }
389
- get endNode() {
390
- return this._$AB;
391
- }
392
- _$AI(r, e = this) {
393
- r = x(this, r, e), U(r) ? r === u || r == null || r === "" ? (this._$AH !== u && this._$AR(), this._$AH = u) : r !== this._$AH && r !== k && this._(r) : r._$litType$ !== void 0 ? this.$(r) : r.nodeType !== void 0 ? this.T(r) : $r(r) ? this.k(r) : this._(r);
394
- }
395
- O(r) {
396
- return this._$AA.parentNode.insertBefore(r, this._$AB);
397
- }
398
- T(r) {
399
- this._$AH !== r && (this._$AR(), this._$AH = this.O(r));
400
- }
401
- _(r) {
402
- this._$AH !== u && U(this._$AH) ? this._$AA.nextSibling.data = r : this.T($.createTextNode(r)), this._$AH = r;
403
- }
404
- $(r) {
405
- var c;
406
- const { values: e, _$litType$: o } = r, t = typeof o == "number" ? this._$AC(r) : (o.el === void 0 && (o.el = O.createElement(ir(o.h, o.h[0]), this.options)), o);
407
- if (((c = this._$AH) == null ? void 0 : c._$AD) === t) this._$AH.p(e);
408
- else {
409
- const l = new Ar(t, this), i = l.u(this.options);
410
- l.p(e), this.T(i), this._$AH = l;
411
- }
412
- }
413
- _$AC(r) {
414
- let e = or.get(r.strings);
415
- return e === void 0 && or.set(r.strings, e = new O(r)), e;
416
- }
417
- k(r) {
418
- F(this._$AH) || (this._$AH = [], this._$AR());
419
- const e = this._$AH;
420
- let o, t = 0;
421
- for (const c of r) t === e.length ? e.push(o = new T(this.O(P()), this.O(P()), this, this.options)) : o = e[t], o._$AI(c), t++;
422
- t < e.length && (this._$AR(o && o._$AB.nextSibling, t), e.length = t);
423
- }
424
- _$AR(r = this._$AA.nextSibling, e) {
425
- var o;
426
- for ((o = this._$AP) == null ? void 0 : o.call(this, !1, !0, e); r && r !== this._$AB; ) {
427
- const t = r.nextSibling;
428
- r.remove(), r = t;
24
+ _handleKeyup(r) {
25
+ if (r.key === " " || r.key === "Spacebar") {
26
+ this._handleClick(r);
27
+ const o = r.target;
28
+ o == null || o.blur(), o == null || o.focus();
429
29
  }
430
30
  }
431
- setConnected(r) {
432
- var e;
433
- this._$AM === void 0 && (this._$Cv = r, (e = this._$AP) == null || e.call(this, r));
434
- }
435
- }
436
- class B {
437
- get tagName() {
438
- return this.element.tagName;
439
- }
440
- get _$AU() {
441
- return this._$AM._$AU;
442
- }
443
- constructor(r, e, o, t, c) {
444
- this.type = 1, this._$AH = u, this._$AN = void 0, this.element = r, this.name = e, this._$AM = t, this.options = c, o.length > 2 || o[0] !== "" || o[1] !== "" ? (this._$AH = Array(o.length - 1).fill(new String()), this.strings = o) : this._$AH = u;
445
- }
446
- _$AI(r, e = this, o, t) {
447
- const c = this.strings;
448
- let l = !1;
449
- if (c === void 0) r = x(this, r, e, 0), l = !U(r) || r !== this._$AH && r !== k, l && (this._$AH = r);
450
- else {
451
- const i = r;
452
- let n, d;
453
- for (r = c[0], n = 0; n < c.length - 1; n++) d = x(this, i[o + n], e, n), d === k && (d = this._$AH[n]), l || (l = !U(d) || d !== this._$AH[n]), d === u ? r = u : r !== u && (r += (d ?? "") + c[n + 1]), this._$AH[n] = d;
454
- }
455
- l && !t && this.j(r);
456
- }
457
- j(r) {
458
- r === u ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, r ?? "");
459
- }
460
- }
461
- class Er extends B {
462
- constructor() {
463
- super(...arguments), this.type = 3;
464
- }
465
- j(r) {
466
- this.element[this.name] = r === u ? void 0 : r;
467
- }
468
- }
469
- class Sr extends B {
470
- constructor() {
471
- super(...arguments), this.type = 4;
472
- }
473
- j(r) {
474
- this.element.toggleAttribute(this.name, !!r && r !== u);
475
- }
476
- }
477
- class wr extends B {
478
- constructor(r, e, o, t, c) {
479
- super(r, e, o, t, c), this.type = 5;
480
- }
481
- _$AI(r, e = this) {
482
- if ((r = x(this, r, e, 0) ?? u) === k) return;
483
- const o = this._$AH, t = r === u && o !== u || r.capture !== o.capture || r.once !== o.once || r.passive !== o.passive, c = r !== u && (o === u || t);
484
- t && this.element.removeEventListener(this.name, this, o), c && this.element.addEventListener(this.name, this, r), this._$AH = r;
485
- }
486
- handleEvent(r) {
487
- var e;
488
- typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, r) : this._$AH.handleEvent(r);
489
- }
490
- }
491
- class Cr {
492
- constructor(r, e, o) {
493
- this.element = r, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = o;
494
- }
495
- get _$AU() {
496
- return this._$AM._$AU;
497
- }
498
- _$AI(r) {
499
- x(this, r);
500
- }
501
- }
502
- const j = w.litHtmlPolyfillSupport;
503
- j == null || j(O, T), (w.litHtmlVersions ?? (w.litHtmlVersions = [])).push("3.2.1");
504
- const Pr = (a, r, e) => {
505
- const o = (e == null ? void 0 : e.renderBefore) ?? r;
506
- let t = o._$litPart$;
507
- if (t === void 0) {
508
- const c = (e == null ? void 0 : e.renderBefore) ?? null;
509
- o._$litPart$ = t = new T(r.insertBefore(P(), c), c, void 0, e ?? {});
510
- }
511
- return t._$AI(a), t;
512
- };
513
- /**
514
- * @license
515
- * Copyright 2017 Google LLC
516
- * SPDX-License-Identifier: BSD-3-Clause
517
- */
518
- let C = class extends _ {
519
- constructor() {
520
- super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
521
- }
522
- createRenderRoot() {
523
- var e;
524
- const r = super.createRenderRoot();
525
- return (e = this.renderOptions).renderBefore ?? (e.renderBefore = r.firstChild), r;
526
- }
527
- update(r) {
528
- const e = this.render();
529
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(r), this._$Do = Pr(e, this.renderRoot, this.renderOptions);
530
- }
531
- connectedCallback() {
532
- var r;
533
- super.connectedCallback(), (r = this._$Do) == null || r.setConnected(!0);
534
- }
535
- disconnectedCallback() {
536
- var r;
537
- super.disconnectedCallback(), (r = this._$Do) == null || r.setConnected(!1);
538
- }
539
- render() {
540
- return k;
541
- }
542
- };
543
- var tr;
544
- C._$litElement$ = !0, C.finalized = !0, (tr = globalThis.litElementHydrateSupport) == null || tr.call(globalThis, { LitElement: C });
545
- const I = globalThis.litElementPolyfillSupport;
546
- I == null || I({ LitElement: C });
547
- (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.1");
548
- /**
549
- * @license
550
- * Copyright 2017 Google LLC
551
- * SPDX-License-Identifier: BSD-3-Clause
552
- */
553
- const Ur = (a) => (r, e) => {
554
- e !== void 0 ? e.addInitializer(() => {
555
- customElements.define(a, r);
556
- }) : customElements.define(a, r);
557
- };
558
- /**
559
- * @license
560
- * Copyright 2017 Google LLC
561
- * SPDX-License-Identifier: BSD-3-Clause
562
- */
563
- const Or = { attribute: !0, type: String, converter: N, reflect: !1, hasChanged: q }, Tr = (a = Or, r, e) => {
564
- const { kind: o, metadata: t } = e;
565
- let c = globalThis.litPropertyMetadata.get(t);
566
- if (c === void 0 && globalThis.litPropertyMetadata.set(t, c = /* @__PURE__ */ new Map()), c.set(e.name, a), o === "accessor") {
567
- const { name: l } = e;
568
- return { set(i) {
569
- const n = r.get.call(this);
570
- r.set.call(this, i), this.requestUpdate(l, n, a);
571
- }, init(i) {
572
- return i !== void 0 && this.P(l, void 0, a), i;
573
- } };
574
- }
575
- if (o === "setter") {
576
- const { name: l } = e;
577
- return function(i) {
578
- const n = this[l];
579
- r.call(this, i), this.requestUpdate(l, n, a);
580
- };
581
- }
582
- throw Error("Unsupported decorator location: " + o);
583
- };
584
- function H(a) {
585
- return (r, e) => typeof e == "object" ? Tr(a, r, e) : ((o, t, c) => {
586
- const l = t.hasOwnProperty(c);
587
- return t.constructor.createProperty(c, l ? { ...o, wrapped: !0 } : o), l ? Object.getOwnPropertyDescriptor(t, c) : void 0;
588
- })(a, r, e);
589
- }
590
- var Hr = Object.defineProperty, zr = Object.getOwnPropertyDescriptor, A = (a, r, e, o) => {
591
- for (var t = o > 1 ? void 0 : o ? zr(r, e) : r, c = a.length - 1, l; c >= 0; c--)
592
- (l = a[c]) && (t = (o ? l(r, e, t) : l(t)) || t);
593
- return o && t && Hr(r, e, t), t;
594
- };
595
- const Mr = "fhi-button";
596
- let p = class extends C {
597
- constructor() {
598
- super(), this.color = "accent", this.variant = "strong", this.size = "medium", this.disabled = !1, this.type = "submit", this._stopClickLeak = this._stopClickLeak.bind(this);
599
- }
600
- connectedCallback() {
601
- super.connectedCallback && super.connectedCallback(), this._form = this.closest("form");
602
- }
603
- firstUpdated() {
604
- this._formButton = document.createElement("button"), this._formButton.addEventListener("click", this._stopClickLeak), this.addEventListener("click", this._handleClick);
605
- }
606
- _handleClick(a) {
607
- var r, e;
608
- (this.type === "submit" || this.type === "reset") && this._form && !a.defaultPrevented && (this._formButton.type = this.type, (r = this._form) == null || r.appendChild(this._formButton), this._formButton.click(), (e = this._form) == null || e.removeChild(this._formButton));
609
- }
610
- _stopClickLeak(a) {
611
- a.target === this._formButton && a.stopImmediatePropagation();
31
+ _handleKeydown(r) {
32
+ r.key === "Enter" && this._handleClick(r);
612
33
  }
613
34
  render() {
614
- return kr`<button ?disabled=${this.disabled} type=${this.type}>
35
+ return v`<button
36
+ ?disabled=${this.disabled}
37
+ type=${this.type}
38
+ @keyup=${this._handleKeyup}
39
+ @keydown=${this._handleKeydown}
40
+ @click=${this._handleClick}
41
+ >
615
42
  <slot></slot>
616
43
  </button>`;
617
44
  }
618
45
  };
619
- p.styles = dr`
46
+ e.formAssociated = !0;
47
+ e.styles = u`
620
48
  :host {
621
49
  --dimension-border-radius: var(--fhi-border-radius-full);
622
50
  --dimension-border-width: var(--fhi-dimension-border-width);
@@ -667,22 +95,25 @@ p.styles = dr`
667
95
  var(--fhi-spacing-050) - var(--fhi-dimension-border-width)
668
96
  )
669
97
  calc(
670
- var(--fhi-spacing-150) +
671
- var(--fhi-spacing-050) - var(--fhi-dimension-border-width)
98
+ var(--fhi-spacing-150) + var(--fhi-spacing-050) - var(
99
+ --fhi-dimension-border-width
100
+ )
672
101
  );
673
102
  --dimension-padding-medium: calc(
674
103
  var(--fhi-spacing-100) - var(--fhi-dimension-border-width)
675
104
  )
676
105
  calc(
677
- var(--fhi-spacing-200) +
678
- var(--fhi-spacing-050) - var(--fhi-dimension-border-width)
106
+ var(--fhi-spacing-200) + var(--fhi-spacing-050) - var(
107
+ --fhi-dimension-border-width
108
+ )
679
109
  );
680
110
  --dimension-padding-large: calc(
681
111
  var(--fhi-spacing-200) - var(--fhi-dimension-border-width)
682
112
  )
683
113
  calc(
684
- var(--fhi-spacing-300) +
685
- var(--fhi-spacing-050) - var(--fhi-dimension-border-width)
114
+ var(--fhi-spacing-300) + var(--fhi-spacing-050) - var(
115
+ --fhi-dimension-border-width
116
+ )
686
117
  );
687
118
  --color-accent-strong-background: var(--fhi-color-accent-base-default);
688
119
  --color-accent-strong-border: var(--fhi-color-accent-base-default);
@@ -1234,26 +665,26 @@ p.styles = dr`
1234
665
  }
1235
666
  }
1236
667
  `;
1237
- A([
1238
- H({ type: String, reflect: !0 })
1239
- ], p.prototype, "color", 2);
1240
- A([
1241
- H({ type: String, reflect: !0 })
1242
- ], p.prototype, "variant", 2);
1243
- A([
1244
- H({ type: String, reflect: !0 })
1245
- ], p.prototype, "size", 2);
1246
- A([
1247
- H({ type: Boolean, reflect: !0 })
1248
- ], p.prototype, "disabled", 2);
1249
- A([
1250
- H({ type: String })
1251
- ], p.prototype, "type", 2);
1252
- p = A([
1253
- Ur(Mr)
1254
- ], p);
668
+ l([
669
+ c({ type: String, reflect: !0 })
670
+ ], e.prototype, "color", 2);
671
+ l([
672
+ c({ type: String, reflect: !0 })
673
+ ], e.prototype, "variant", 2);
674
+ l([
675
+ c({ type: String, reflect: !0 })
676
+ ], e.prototype, "size", 2);
677
+ l([
678
+ c({ type: Boolean, reflect: !0 })
679
+ ], e.prototype, "disabled", 2);
680
+ l([
681
+ c({ type: String })
682
+ ], e.prototype, "type", 2);
683
+ e = l([
684
+ s(f)
685
+ ], e);
1255
686
  export {
1256
- p as FhiButton,
1257
- Mr as FhiButtonSelector
687
+ e as FhiButton,
688
+ f as FhiButtonSelector
1258
689
  };
1259
690
  //# sourceMappingURL=fhi-button.js.map