@folkehelseinstituttet/designsystem 0.30.0 → 0.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/custom-elements.json +621 -571
- package/fhi-body.js +10 -10
- package/fhi-body.js.map +1 -1
- package/fhi-button.js +12 -8
- package/fhi-button.js.map +1 -1
- package/fhi-date-input.js +62 -24
- package/fhi-date-input.js.map +1 -1
- package/fhi-display.js +13 -9
- package/fhi-display.js.map +1 -1
- package/fhi-headline.js +13 -9
- package/fhi-headline.js.map +1 -1
- package/fhi-label.js +10 -10
- package/fhi-label.js.map +1 -1
- package/fhi-modal-dialog.js +2 -2
- package/fhi-modal-dialog.js.map +1 -1
- package/fhi-tag.js +1 -1
- package/fhi-tag.js.map +1 -1
- package/fhi-text-input.js +88 -52
- package/fhi-text-input.js.map +1 -1
- package/fhi-title.js +13 -9
- package/fhi-title.js.map +1 -1
- package/fhi-tooltip.js +397 -395
- package/fhi-tooltip.js.map +1 -1
- package/index.js +354 -354
- package/package.json +12 -47
- package/web-types.json +280 -260
package/fhi-text-input.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import { e as
|
|
1
|
+
import { i as g, n as o, a as u, b as n, t as c } from "./property-DGdAXcEz.js";
|
|
2
|
+
import { e as y } from "./query-NJDNu0-P.js";
|
|
3
3
|
import { o as d } from "./if-defined-BW6N1yuF.js";
|
|
4
|
-
var
|
|
5
|
-
for (var i =
|
|
6
|
-
(
|
|
7
|
-
return
|
|
4
|
+
var v = Object.defineProperty, f = Object.getOwnPropertyDescriptor, r = (e, a, p, l) => {
|
|
5
|
+
for (var i = l > 1 ? void 0 : l ? f(a, p) : a, h = e.length - 1, s; h >= 0; h--)
|
|
6
|
+
(s = e[h]) && (i = (l ? s(a, p, i) : s(i)) || i);
|
|
7
|
+
return l && i && v(a, p, i), i;
|
|
8
8
|
};
|
|
9
|
-
const
|
|
10
|
-
let
|
|
9
|
+
const b = "fhi-text-input";
|
|
10
|
+
let t = class extends u {
|
|
11
11
|
constructor() {
|
|
12
|
-
super(), this.label = void 0, this.message = void 0, this.placeholder =
|
|
12
|
+
super(), this.label = void 0, this.message = void 0, this.helpText = void 0, this.placeholder = void 0, this.status = void 0, this.readonly = !1, this.disabled = !1, this._name = void 0, this._value = "", this._internals = this.attachInternals();
|
|
13
13
|
}
|
|
14
14
|
get name() {
|
|
15
15
|
return this._name;
|
|
16
16
|
}
|
|
17
|
-
set name(
|
|
18
|
-
const
|
|
19
|
-
this._name =
|
|
17
|
+
set name(e) {
|
|
18
|
+
const a = this._name;
|
|
19
|
+
this._name = e, this.requestUpdate("name", a), this._internals.setFormValue(this._value);
|
|
20
20
|
}
|
|
21
21
|
get value() {
|
|
22
22
|
return this._value;
|
|
23
23
|
}
|
|
24
|
-
set value(
|
|
25
|
-
const
|
|
26
|
-
this._value =
|
|
24
|
+
set value(e) {
|
|
25
|
+
const a = this._value;
|
|
26
|
+
this._value = e, this.requestUpdate("value", a), this._internals.setFormValue(this._value);
|
|
27
27
|
}
|
|
28
28
|
connectedCallback() {
|
|
29
29
|
super.connectedCallback(), this._internals.setFormValue(this.value);
|
|
@@ -44,21 +44,22 @@ let e = class extends c {
|
|
|
44
44
|
})
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
|
-
handleChange(
|
|
48
|
-
|
|
47
|
+
handleChange(e) {
|
|
48
|
+
e.stopPropagation(), this._dispatchChangeEvent();
|
|
49
49
|
}
|
|
50
|
-
handleInput(
|
|
51
|
-
this.value = this._input.value, this._internals.setFormValue(this.value),
|
|
50
|
+
handleInput(e) {
|
|
51
|
+
this.value = this._input.value, this._internals.setFormValue(this.value), e.stopPropagation(), this._dispatchInputEvent();
|
|
52
52
|
}
|
|
53
|
-
handleKeyDown(
|
|
54
|
-
|
|
53
|
+
handleKeyDown(e) {
|
|
54
|
+
e.key === "Enter" && this._internals.form && this._internals.form.requestSubmit();
|
|
55
55
|
}
|
|
56
56
|
formResetCallback() {
|
|
57
57
|
this.value = this.getAttribute("value") || "", this._internals.setFormValue(this.value);
|
|
58
58
|
}
|
|
59
59
|
render() {
|
|
60
|
-
return
|
|
61
|
-
${this.label &&
|
|
60
|
+
return n`
|
|
61
|
+
${this.label && n`<label for="input-element">${this.label}</label>`}
|
|
62
|
+
${this.helpText ? n`<p class="help-text">${this.helpText}</p>` : ""}
|
|
62
63
|
<input
|
|
63
64
|
id="input-element"
|
|
64
65
|
name=${d(this.name)}
|
|
@@ -70,12 +71,12 @@ let e = class extends c {
|
|
|
70
71
|
@input=${this.handleInput}
|
|
71
72
|
@keydown=${this.handleKeyDown}
|
|
72
73
|
/>
|
|
73
|
-
${this.message ?
|
|
74
|
+
${this.message ? n`<p class="message">${this.message}</p>` : ""}
|
|
74
75
|
`;
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
t.formAssociated = !0;
|
|
79
|
+
t.styles = g`
|
|
79
80
|
:host {
|
|
80
81
|
--typography-font-family: var(--fhi-font-family-default);
|
|
81
82
|
|
|
@@ -95,8 +96,7 @@ e.styles = u`
|
|
|
95
96
|
--typography-label-letter-spacing: var(
|
|
96
97
|
--fhi-typography-label-small-letter-spacing
|
|
97
98
|
);
|
|
98
|
-
|
|
99
|
-
--dimension-label-padding-bottom: var(--fhi-spacing-050);
|
|
99
|
+
--dimension-label-margin-bottom: var(--fhi-spacing-050);
|
|
100
100
|
|
|
101
101
|
/* input */
|
|
102
102
|
--color-input-placeholder: var(--fhi-color-neutral-base-default);
|
|
@@ -155,6 +155,23 @@ e.styles = u`
|
|
|
155
155
|
);
|
|
156
156
|
|
|
157
157
|
--dimension-message-margin-top: var(--fhi-spacing-050);
|
|
158
|
+
|
|
159
|
+
/* help-text */
|
|
160
|
+
--color-help-text-text: var(--fhi-color-neutral-text-subtle);
|
|
161
|
+
--color-help-text-text-error: var(--fhi-color-danger-text-default);
|
|
162
|
+
--typography-help-text-font-weight: var(
|
|
163
|
+
--fhi-typography-body-small-font-weight
|
|
164
|
+
);
|
|
165
|
+
--typography-help-text-font-size: var(
|
|
166
|
+
--fhi-typography-body-small-font-size
|
|
167
|
+
);
|
|
168
|
+
--typography-help-text-line-height: var(
|
|
169
|
+
--fhi-typography-body-small-line-height
|
|
170
|
+
);
|
|
171
|
+
--typography-help-text-letter-spacing: var(
|
|
172
|
+
--fhi-typography-body-small-letter-spacing
|
|
173
|
+
);
|
|
174
|
+
--dimension-help-text-margin-bottom: var(--fhi-spacing-050);
|
|
158
175
|
}
|
|
159
176
|
|
|
160
177
|
:host {
|
|
@@ -169,7 +186,11 @@ e.styles = u`
|
|
|
169
186
|
line-height: var(--typography-label-line-height);
|
|
170
187
|
letter-spacing: var(--typography-label-letter-spacing);
|
|
171
188
|
color: var(--color-label-text);
|
|
172
|
-
|
|
189
|
+
margin: 0 0 var(--dimension-label-margin-bottom) 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
label:has(+ p) {
|
|
193
|
+
margin: 0 0 0 0;
|
|
173
194
|
}
|
|
174
195
|
|
|
175
196
|
input {
|
|
@@ -209,6 +230,15 @@ e.styles = u`
|
|
|
209
230
|
line-height: var(--typography-message-line-height);
|
|
210
231
|
letter-spacing: var(--typography-message-letter-spacing);
|
|
211
232
|
}
|
|
233
|
+
|
|
234
|
+
.help-text {
|
|
235
|
+
color: var(--color-help-text-text);
|
|
236
|
+
font-weight: var(--typography-help-text-font-weight);
|
|
237
|
+
font-size: var(--typography-help-text-font-size);
|
|
238
|
+
line-height: var(--typography-help-text-line-height);
|
|
239
|
+
letter-spacing: var(--typography-help-text-letter-spacing);
|
|
240
|
+
margin: 0 0 var(--dimension-help-text-margin-bottom) 0;
|
|
241
|
+
}
|
|
212
242
|
}
|
|
213
243
|
|
|
214
244
|
:host([disabled]) {
|
|
@@ -248,40 +278,46 @@ e.styles = u`
|
|
|
248
278
|
.message {
|
|
249
279
|
color: var(--color-message-text-error);
|
|
250
280
|
}
|
|
281
|
+
.help-text {
|
|
282
|
+
color: var(--color-help-text-text-error);
|
|
283
|
+
}
|
|
251
284
|
}
|
|
252
285
|
`;
|
|
253
286
|
r([
|
|
254
|
-
|
|
255
|
-
],
|
|
287
|
+
o({ type: String })
|
|
288
|
+
], t.prototype, "label", 2);
|
|
289
|
+
r([
|
|
290
|
+
o({ type: String })
|
|
291
|
+
], t.prototype, "message", 2);
|
|
256
292
|
r([
|
|
257
|
-
|
|
258
|
-
],
|
|
293
|
+
o({ type: String, attribute: "help-text" })
|
|
294
|
+
], t.prototype, "helpText", 2);
|
|
259
295
|
r([
|
|
260
|
-
|
|
261
|
-
],
|
|
296
|
+
o({ type: String })
|
|
297
|
+
], t.prototype, "placeholder", 2);
|
|
262
298
|
r([
|
|
263
|
-
|
|
264
|
-
],
|
|
299
|
+
o({ type: String, reflect: !0 })
|
|
300
|
+
], t.prototype, "status", 2);
|
|
265
301
|
r([
|
|
266
|
-
|
|
267
|
-
],
|
|
302
|
+
o({ type: Boolean, reflect: !0 })
|
|
303
|
+
], t.prototype, "readonly", 2);
|
|
268
304
|
r([
|
|
269
|
-
|
|
270
|
-
],
|
|
305
|
+
o({ type: Boolean, reflect: !0 })
|
|
306
|
+
], t.prototype, "disabled", 2);
|
|
271
307
|
r([
|
|
272
|
-
|
|
273
|
-
],
|
|
308
|
+
y("#input-element")
|
|
309
|
+
], t.prototype, "_input", 2);
|
|
274
310
|
r([
|
|
275
|
-
|
|
276
|
-
],
|
|
311
|
+
o({ type: String, reflect: !0 })
|
|
312
|
+
], t.prototype, "name", 1);
|
|
277
313
|
r([
|
|
278
|
-
|
|
279
|
-
],
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
],
|
|
314
|
+
o({ type: String })
|
|
315
|
+
], t.prototype, "value", 1);
|
|
316
|
+
t = r([
|
|
317
|
+
c(b)
|
|
318
|
+
], t);
|
|
283
319
|
export {
|
|
284
|
-
|
|
285
|
-
|
|
320
|
+
t as FhiTextInput,
|
|
321
|
+
b as FhiTextInputSelector
|
|
286
322
|
};
|
|
287
323
|
//# sourceMappingURL=fhi-text-input.js.map
|
package/fhi-text-input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhi-text-input.js","sources":["../../src/components/fhi-text-input/fhi-text-input.component.ts"],"sourcesContent":["import { html, css, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nexport const FhiTextInputSelector = 'fhi-text-input';\n\n/**\n * ## FHI Text Input\n *\n * {@link https://designsystem.fhi.no/?path=/docs/komponenter-text-input--docs}\n *\n * The `<fhi-text-input>` component is used to collect user input in forms.\n * It provides a labeled input field with optional placeholder text, status indication, and a message area for additional information or validation feedback.\n *\n * @tag fhi-text-input\n * @element fhi-text-input\n */\n@customElement(FhiTextInputSelector)\nexport class FhiTextInput extends LitElement {\n /** @internal */\n static readonly formAssociated = true;\n\n /**\n * The text that labels the input field.\n * An input field should always have a label to ensure accessibility.\n * @type {string}\n */\n @property({ type: String }) label?: string = undefined;\n\n /**\n * The message shown beneath the input field.\n * This is often used to provide additional information or feedback to the user.\n * @type {string}\n */\n @property({ type: String }) message?: string = undefined;\n\n /**\n * Sets the placeholder text for the input field.\n * This text is displayed when the input field is empty, providing a hint to the user about the expected input.\n * @type {string}\n */\n @property({ type: String }) placeholder?: string | null = null;\n\n /**\n * Sets the visual status of the input. There is currently only one status available: `error`.\n *\n * The `error` status is used to indicate that there is an issue with the input, such as invalid or missing data.\n * @reflect\n * @type {'error'}\n */\n @property({ type: String, reflect: true }) status?: 'error' = undefined;\n\n /**\n * Sets the input to read-only. A read-only field cannot be modified by the user but may be submitted with the form.\n * @reflect\n * @type {boolean}\n */\n @property({ type: Boolean, reflect: true }) readonly? = false;\n\n /**\n * Disables the input. This changes its appearance and makes it non-interactive.\n * @reflect\n * @type {boolean}\n */\n @property({ type: Boolean, reflect: true }) disabled? = false;\n\n @query('#input-element')\n private _input!: HTMLInputElement;\n\n private _name?: string = undefined;\n\n /**\n * The name of the input. This is submitted with the form data as a `key`.\n *\n * This attribute conforms with the standard HTML `name` attribute for input fields.\n * See: {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name}\n *\n * @reflect\n * @type {string}\n */\n @property({ type: String, reflect: true })\n get name(): string | undefined {\n return this._name;\n }\n set name(newName: string) {\n const oldName = this._name;\n this._name = newName;\n this.requestUpdate('name', oldName);\n this._internals.setFormValue(this._value);\n }\n\n private _value: string = '';\n\n /**\n * The default value of the input field.\n *\n * You can fetch the current value of the text input by accessing this property directly on the component instance, or by listening for the `change` or `input` events which are dispatched whenever the value changes.\n *\n * This attribute conforms with the standard HTML `value` attribute for input fields.\n * See: {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value}\n *\n * @type {string}\n */\n @property({ type: String })\n get value(): string {\n return this._value;\n }\n\n set value(newValue: string) {\n const oldValue = this._value;\n this._value = newValue;\n this.requestUpdate('value', oldValue);\n this._internals.setFormValue(this._value);\n }\n\n private _internals: ElementInternals;\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this._internals.setFormValue(this.value);\n }\n\n private _dispatchChangeEvent(): void {\n /**\n * @type {Event} - Standard DOM event with the type `change`.\n * This event is dispatched when the value of the input changes.\n */\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _dispatchInputEvent(): void {\n /**\n * @type {Event} - Standard DOM event with the type `input`.\n * This event is dispatched when the value of the input changes.\n */\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private handleChange(event: Event): void {\n event.stopPropagation();\n this._dispatchChangeEvent();\n }\n\n private handleInput(event: Event): void {\n this.value = this._input.value;\n this._internals.setFormValue(this.value);\n\n event.stopPropagation();\n this._dispatchInputEvent();\n }\n\n private handleKeyDown(event: KeyboardEvent): void {\n if (event.key === 'Enter' && this._internals.form) {\n this._internals.form!.requestSubmit();\n }\n }\n\n public formResetCallback(): void {\n this.value = this.getAttribute('value') || '';\n this._internals.setFormValue(this.value);\n }\n\n render() {\n return html`\n ${this.label && html`<label for=\"input-element\">${this.label}</label>`}\n <input\n id=\"input-element\"\n name=${ifDefined(this.name)}\n placeholder=${ifDefined(this.placeholder)}\n .value=${this.value}\n ?readonly=${this.readonly}\n ?disabled=${this.disabled}\n @change=${this.handleChange}\n @input=${this.handleInput}\n @keydown=${this.handleKeyDown}\n />\n ${this.message ? html`<p class=\"message\">${this.message}</p>` : ''}\n `;\n }\n\n static styles = css`\n :host {\n --typography-font-family: var(--fhi-font-family-default);\n\n --opacity-disabled: var(--fhi-opacity-disabled);\n\n /* label */\n --color-label-text: var(--fhi-color-neutral-text-default);\n --color-label-text-error: var(--fhi-color-danger-text-default);\n\n --typography-label-font-weight: var(\n --fhi-typography-label-small-font-weight\n );\n --typography-label-font-size: var(--fhi-typography-label-small-font-size);\n --typography-label-line-height: var(\n --fhi-typography-label-small-line-height\n );\n --typography-label-letter-spacing: var(\n --fhi-typography-label-small-letter-spacing\n );\n\n --dimension-label-padding-bottom: var(--fhi-spacing-050);\n\n /* input */\n --color-input-placeholder: var(--fhi-color-neutral-base-default);\n --color-input-text: var(--fhi-color-neutral-text-default);\n --color-input-text-error: var(--fhi-color-danger-text-default);\n --color-input-background: var(--fhi-color-neutral-background-default);\n --color-input-background-active: var(\n --fhi-color-accent-background-default\n );\n --color-input-background-hover: var(--fhi-color-accent-background-subtle);\n --color-input-background-error: var(\n --fhi-color-danger-background-default\n );\n --color-input-border: var(--fhi-color-neutral-border-default);\n --color-input-border-hover: var(--fhi-color-accent-border-default);\n --color-input-border-active: var(--fhi-color-accent-border-strong);\n --color-input-border-error: var(--fhi-color-danger-border-strong);\n --color-input-border-disabled: var(--fhi-color-neutral-border-default);\n\n --typography-input-font-weight: var(\n --fhi-typography-body-medium-font-weight\n );\n --typography-input-font-size: var(--fhi-typography-body-medium-font-size);\n --typography-input-line-height: var(\n --fhi-typography-body-medium-line-height\n );\n --typography-input-letter-spacing: var(\n --fhi-typography-body-medium-letter-spacing\n );\n\n --dimension-input-border-width: var(--fhi-dimension-border-width);\n\n --dimension-input-height: var(--fhi-spacing-500);\n --dimension-input-border-radius: var(--fhi-border-radius-050);\n --dimension-input-padding-left: var(--fhi-spacing-150);\n --dimension-input-padding-right: var(--fhi-spacing-150);\n\n --motion-input-transition: all var(--fhi-motion-ease-default)\n var(--fhi-motion-duration-quick);\n\n /* message */\n --color-message-text: var(--fhi-color-neutral-text-default);\n --color-message-text-error: var(--fhi-color-danger-text-subtle);\n\n --typography-message-font-weight: var(\n --fhi-typography-body-small-font-weight\n );\n --typography-message-font-size: var(\n --fhi-typography-body-small-font-size\n );\n --typography-message-line-height: var(\n --fhi-typography-body-small-line-height\n );\n --typography-message-letter-spacing: var(\n --fhi-typography-body-small-letter-spacing\n );\n\n --dimension-message-margin-top: var(--fhi-spacing-050);\n }\n\n :host {\n display: flex;\n flex-direction: column;\n font-family: var(--typography-font-family);\n -webkit-font-smoothing: antialiased;\n\n label {\n font-weight: var(--typography-label-font-weight);\n font-size: var(--typography-label-font-size);\n line-height: var(--typography-label-line-height);\n letter-spacing: var(--typography-label-letter-spacing);\n color: var(--color-label-text);\n padding-bottom: var(--dimension-label-padding-bottom);\n }\n\n input {\n box-sizing: border-box;\n height: var(--dimension-input-height);\n border: var(--dimension-input-border-width) solid\n var(--color-input-border);\n border-radius: var(--dimension-input-border-radius);\n padding: 0 var(--dimension-input-padding-right) 0\n var(--dimension-input-padding-left);\n color: var(--color-input-text);\n background-color: var(--color-input-background);\n font-family: var(--typography-font-family);\n font-weight: var(--typography-input-font-weight);\n font-size: var(--typography-input-font-size);\n line-height: var(--typography-input-line-height);\n letter-spacing: var(--typography-input-letter-spacing);\n transition: var(--motion-input-transition);\n &:hover {\n border-color: var(--color-input-border-hover);\n background-color: var(--color-input-background-hover);\n }\n &:focus {\n border-color: var(--color-input-border-active);\n background-color: var(--color-input-background-active);\n }\n &::placeholder {\n color: var(--color-input-placeholder);\n }\n }\n\n .message {\n margin: var(--dimension-message-margin-top) 0 0 0;\n color: var(--color-message-text);\n font-weight: var(--typography-message-font-weight);\n font-size: var(--typography-message-font-size);\n line-height: var(--typography-message-line-height);\n letter-spacing: var(--typography-message-letter-spacing);\n }\n }\n\n :host([disabled]) {\n opacity: var(--opacity-disabled);\n cursor: not-allowed;\n label,\n input {\n cursor: not-allowed;\n }\n input {\n &:hover {\n border-color: var(--color-input-border);\n background-color: var(--color-input-background);\n }\n }\n }\n\n :host([readonly]:not([disabled])) {\n input {\n border: unset;\n border-radius: unset;\n background-color: unset;\n border-left: var(--dimension-input-border-width) solid\n var(--color-input-border);\n }\n }\n\n :host([status='error']:not([disabled]):not([readonly])) {\n label {\n color: var(--color-label-text-error);\n }\n input {\n border-color: var(--color-input-border-error);\n background-color: var(--color-input-background-error);\n color: var(--color-input-text-error);\n }\n .message {\n color: var(--color-message-text-error);\n }\n }\n `;\n}\n"],"names":["FhiTextInputSelector","FhiTextInput","LitElement","newName","oldName","newValue","oldValue","event","html","ifDefined","css","__decorateClass","property","query","customElement"],"mappings":";;;;;;;;AAIO,MAAMA,IAAuB;AAc7B,IAAMC,IAAN,cAA2BC,EAAW;AAAA,EAmG3C,cAAc;AACZ,UAAA,GA3F0B,KAAA,QAAiB,QAOjB,KAAA,UAAmB,QAOnB,KAAA,cAA8B,MASf,KAAA,SAAmB,QAOlB,KAAA,WAAY,IAOZ,KAAA,WAAY,IAKxD,KAAQ,QAAiB,QAsBzB,KAAQ,SAAiB,IA4BvB,KAAK,aAAa,KAAK,gBAAA;AAAA,EACzB;AAAA,EAvCA,IAAI,OAA2B;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,KAAKC,GAAiB;AACxB,UAAMC,IAAU,KAAK;AACrB,SAAK,QAAQD,GACb,KAAK,cAAc,QAAQC,CAAO,GAClC,KAAK,WAAW,aAAa,KAAK,MAAM;AAAA,EAC1C;AAAA,EAeA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;"}
|
|
1
|
+
{"version":3,"file":"fhi-text-input.js","sources":["../../src/components/fhi-text-input/fhi-text-input.component.ts"],"sourcesContent":["import { html, css, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nexport const FhiTextInputSelector = 'fhi-text-input';\n\n/**\n * ## FHI Text Input\n *\n * {@link https://designsystem.fhi.no/?path=/docs/komponenter-text-input--docs}\n *\n * The `<fhi-text-input>` component is used to collect user input in forms.\n * It provides a labeled input field with optional placeholder text, status indication, and a message area for additional information or validation feedback.\n *\n * @tag fhi-text-input\n * @element fhi-text-input\n */\n@customElement(FhiTextInputSelector)\nexport class FhiTextInput extends LitElement {\n static readonly formAssociated = true;\n\n /**\n * The text that labels the input field.\n * An input field should always have a label to ensure accessibility.\n * @type {string}\n */\n @property({ type: String }) label?: string = undefined;\n\n /**\n * The message shown beneath the input field.\n * This is often used to provide additional information or feedback to the user.\n * @type {string}\n */\n @property({ type: String }) message?: string = undefined;\n\n /**\n * The message shown above the input field.\n * This is often used to provide additional information to the user.\n * @type {string}\n */\n @property({ type: String, attribute: 'help-text' }) helpText?: string =\n undefined;\n\n /**\n * Sets the placeholder text for the input field.\n * This text is displayed when the input field is empty, providing a hint to the user about the expected input.\n * @type {string}\n */\n @property({ type: String }) placeholder?: string = undefined;\n\n /**\n * Sets the visual status of the input. There is currently only one status available: `error`.\n *\n * The `error` status is used to indicate that there is an issue with the input, such as invalid or missing data.\n * @reflect\n * @type {'error'}\n */\n @property({ type: String, reflect: true }) status?: 'error' = undefined;\n\n /**\n * Sets the input to read-only. A read-only field cannot be modified by the user but may be submitted with the form.\n * @reflect\n * @type {boolean}\n */\n @property({ type: Boolean, reflect: true }) readonly? = false;\n\n /**\n * Disables the input. This changes its appearance and makes it non-interactive.\n * @reflect\n * @type {boolean}\n */\n @property({ type: Boolean, reflect: true }) disabled? = false;\n\n @query('#input-element')\n private _input!: HTMLInputElement;\n\n private _name?: string = undefined;\n\n /**\n * The name of the input. This is submitted with the form data as a `key`.\n *\n * This attribute conforms with the standard HTML `name` attribute for input fields.\n * See: {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name}\n *\n * @reflect\n * @type {string}\n */\n @property({ type: String, reflect: true })\n get name(): string | undefined {\n return this._name;\n }\n set name(newName: string) {\n const oldName = this._name;\n this._name = newName;\n this.requestUpdate('name', oldName);\n this._internals.setFormValue(this._value);\n }\n\n private _value: string = '';\n\n /**\n * The default value of the input field.\n *\n * You can fetch the current value of the text input by accessing this property directly on the component instance, or by listening for the `change` or `input` events which are dispatched whenever the value changes.\n *\n * This attribute conforms with the standard HTML `value` attribute for input fields.\n * See: {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value}\n *\n * @type {string}\n */\n @property({ type: String })\n get value(): string {\n return this._value;\n }\n\n set value(newValue: string) {\n const oldValue = this._value;\n this._value = newValue;\n this.requestUpdate('value', oldValue);\n this._internals.setFormValue(this._value);\n }\n\n private _internals: ElementInternals;\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this._internals.setFormValue(this.value);\n }\n\n private _dispatchChangeEvent(): void {\n /**\n * @type {Event} - Standard DOM event with the type `change`.\n * This event is dispatched when the value of the input changes.\n */\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _dispatchInputEvent(): void {\n /**\n * @type {Event} - Standard DOM event with the type `input`.\n * This event is dispatched when the value of the input changes.\n */\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private handleChange(event: Event): void {\n event.stopPropagation();\n this._dispatchChangeEvent();\n }\n\n private handleInput(event: Event): void {\n this.value = this._input.value;\n this._internals.setFormValue(this.value);\n\n event.stopPropagation();\n this._dispatchInputEvent();\n }\n\n private handleKeyDown(event: KeyboardEvent): void {\n if (event.key === 'Enter' && this._internals.form) {\n this._internals.form!.requestSubmit();\n }\n }\n\n public formResetCallback(): void {\n this.value = this.getAttribute('value') || '';\n this._internals.setFormValue(this.value);\n }\n\n render() {\n return html`\n ${this.label && html`<label for=\"input-element\">${this.label}</label>`}\n ${this.helpText ? html`<p class=\"help-text\">${this.helpText}</p>` : ''}\n <input\n id=\"input-element\"\n name=${ifDefined(this.name)}\n placeholder=${ifDefined(this.placeholder)}\n .value=${this.value}\n ?readonly=${this.readonly}\n ?disabled=${this.disabled}\n @change=${this.handleChange}\n @input=${this.handleInput}\n @keydown=${this.handleKeyDown}\n />\n ${this.message ? html`<p class=\"message\">${this.message}</p>` : ''}\n `;\n }\n\n static styles = css`\n :host {\n --typography-font-family: var(--fhi-font-family-default);\n\n --opacity-disabled: var(--fhi-opacity-disabled);\n\n /* label */\n --color-label-text: var(--fhi-color-neutral-text-default);\n --color-label-text-error: var(--fhi-color-danger-text-default);\n\n --typography-label-font-weight: var(\n --fhi-typography-label-small-font-weight\n );\n --typography-label-font-size: var(--fhi-typography-label-small-font-size);\n --typography-label-line-height: var(\n --fhi-typography-label-small-line-height\n );\n --typography-label-letter-spacing: var(\n --fhi-typography-label-small-letter-spacing\n );\n --dimension-label-margin-bottom: var(--fhi-spacing-050);\n\n /* input */\n --color-input-placeholder: var(--fhi-color-neutral-base-default);\n --color-input-text: var(--fhi-color-neutral-text-default);\n --color-input-text-error: var(--fhi-color-danger-text-default);\n --color-input-background: var(--fhi-color-neutral-background-default);\n --color-input-background-active: var(\n --fhi-color-accent-background-default\n );\n --color-input-background-hover: var(--fhi-color-accent-background-subtle);\n --color-input-background-error: var(\n --fhi-color-danger-background-default\n );\n --color-input-border: var(--fhi-color-neutral-border-default);\n --color-input-border-hover: var(--fhi-color-accent-border-default);\n --color-input-border-active: var(--fhi-color-accent-border-strong);\n --color-input-border-error: var(--fhi-color-danger-border-strong);\n --color-input-border-disabled: var(--fhi-color-neutral-border-default);\n\n --typography-input-font-weight: var(\n --fhi-typography-body-medium-font-weight\n );\n --typography-input-font-size: var(--fhi-typography-body-medium-font-size);\n --typography-input-line-height: var(\n --fhi-typography-body-medium-line-height\n );\n --typography-input-letter-spacing: var(\n --fhi-typography-body-medium-letter-spacing\n );\n\n --dimension-input-border-width: var(--fhi-dimension-border-width);\n\n --dimension-input-height: var(--fhi-spacing-500);\n --dimension-input-border-radius: var(--fhi-border-radius-050);\n --dimension-input-padding-left: var(--fhi-spacing-150);\n --dimension-input-padding-right: var(--fhi-spacing-150);\n\n --motion-input-transition: all var(--fhi-motion-ease-default)\n var(--fhi-motion-duration-quick);\n\n /* message */\n --color-message-text: var(--fhi-color-neutral-text-default);\n --color-message-text-error: var(--fhi-color-danger-text-subtle);\n\n --typography-message-font-weight: var(\n --fhi-typography-body-small-font-weight\n );\n --typography-message-font-size: var(\n --fhi-typography-body-small-font-size\n );\n --typography-message-line-height: var(\n --fhi-typography-body-small-line-height\n );\n --typography-message-letter-spacing: var(\n --fhi-typography-body-small-letter-spacing\n );\n\n --dimension-message-margin-top: var(--fhi-spacing-050);\n\n /* help-text */\n --color-help-text-text: var(--fhi-color-neutral-text-subtle);\n --color-help-text-text-error: var(--fhi-color-danger-text-default);\n --typography-help-text-font-weight: var(\n --fhi-typography-body-small-font-weight\n );\n --typography-help-text-font-size: var(\n --fhi-typography-body-small-font-size\n );\n --typography-help-text-line-height: var(\n --fhi-typography-body-small-line-height\n );\n --typography-help-text-letter-spacing: var(\n --fhi-typography-body-small-letter-spacing\n );\n --dimension-help-text-margin-bottom: var(--fhi-spacing-050);\n }\n\n :host {\n display: flex;\n flex-direction: column;\n font-family: var(--typography-font-family);\n -webkit-font-smoothing: antialiased;\n\n label {\n font-weight: var(--typography-label-font-weight);\n font-size: var(--typography-label-font-size);\n line-height: var(--typography-label-line-height);\n letter-spacing: var(--typography-label-letter-spacing);\n color: var(--color-label-text);\n margin: 0 0 var(--dimension-label-margin-bottom) 0;\n }\n\n label:has(+ p) {\n margin: 0 0 0 0;\n }\n\n input {\n box-sizing: border-box;\n height: var(--dimension-input-height);\n border: var(--dimension-input-border-width) solid\n var(--color-input-border);\n border-radius: var(--dimension-input-border-radius);\n padding: 0 var(--dimension-input-padding-right) 0\n var(--dimension-input-padding-left);\n color: var(--color-input-text);\n background-color: var(--color-input-background);\n font-family: var(--typography-font-family);\n font-weight: var(--typography-input-font-weight);\n font-size: var(--typography-input-font-size);\n line-height: var(--typography-input-line-height);\n letter-spacing: var(--typography-input-letter-spacing);\n transition: var(--motion-input-transition);\n &:hover {\n border-color: var(--color-input-border-hover);\n background-color: var(--color-input-background-hover);\n }\n &:focus {\n border-color: var(--color-input-border-active);\n background-color: var(--color-input-background-active);\n }\n &::placeholder {\n color: var(--color-input-placeholder);\n }\n }\n\n .message {\n margin: var(--dimension-message-margin-top) 0 0 0;\n color: var(--color-message-text);\n font-weight: var(--typography-message-font-weight);\n font-size: var(--typography-message-font-size);\n line-height: var(--typography-message-line-height);\n letter-spacing: var(--typography-message-letter-spacing);\n }\n\n .help-text {\n color: var(--color-help-text-text);\n font-weight: var(--typography-help-text-font-weight);\n font-size: var(--typography-help-text-font-size);\n line-height: var(--typography-help-text-line-height);\n letter-spacing: var(--typography-help-text-letter-spacing);\n margin: 0 0 var(--dimension-help-text-margin-bottom) 0;\n }\n }\n\n :host([disabled]) {\n opacity: var(--opacity-disabled);\n cursor: not-allowed;\n label,\n input {\n cursor: not-allowed;\n }\n input {\n &:hover {\n border-color: var(--color-input-border);\n background-color: var(--color-input-background);\n }\n }\n }\n\n :host([readonly]:not([disabled])) {\n input {\n border: unset;\n border-radius: unset;\n background-color: unset;\n border-left: var(--dimension-input-border-width) solid\n var(--color-input-border);\n }\n }\n\n :host([status='error']:not([disabled]):not([readonly])) {\n label {\n color: var(--color-label-text-error);\n }\n input {\n border-color: var(--color-input-border-error);\n background-color: var(--color-input-background-error);\n color: var(--color-input-text-error);\n }\n .message {\n color: var(--color-message-text-error);\n }\n .help-text {\n color: var(--color-help-text-text-error);\n }\n }\n `;\n}\n"],"names":["FhiTextInputSelector","FhiTextInput","LitElement","newName","oldName","newValue","oldValue","event","html","ifDefined","css","__decorateClass","property","query","customElement"],"mappings":";;;;;;;;AAIO,MAAMA,IAAuB;AAc7B,IAAMC,IAAN,cAA2BC,EAAW;AAAA,EA0G3C,cAAc;AACZ,UAAA,GAnG0B,KAAA,QAAiB,QAOjB,KAAA,UAAmB,QAOK,KAAA,WAClD,QAO0B,KAAA,cAAuB,QASR,KAAA,SAAmB,QAOlB,KAAA,WAAY,IAOZ,KAAA,WAAY,IAKxD,KAAQ,QAAiB,QAsBzB,KAAQ,SAAiB,IA4BvB,KAAK,aAAa,KAAK,gBAAA;AAAA,EACzB;AAAA,EAvCA,IAAI,OAA2B;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,KAAKC,GAAiB;AACxB,UAAMC,IAAU,KAAK;AACrB,SAAK,QAAQD,GACb,KAAK,cAAc,QAAQC,CAAO,GAClC,KAAK,WAAW,aAAa,KAAK,MAAM;AAAA,EAC1C;AAAA,EAeA,IAAI,QAAgB;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,MAAMC,GAAkB;AAC1B,UAAMC,IAAW,KAAK;AACtB,SAAK,SAASD,GACd,KAAK,cAAc,SAASC,CAAQ,GACpC,KAAK,WAAW,aAAa,KAAK,MAAM;AAAA,EAC1C;AAAA,EASO,oBAA0B;AAC/B,UAAM,kBAAA,GACN,KAAK,WAAW,aAAa,KAAK,KAAK;AAAA,EACzC;AAAA,EAEQ,uBAA6B;AAKnC,SAAK;AAAA,MACH,IAAI,MAAM,UAAU;AAAA,QAClB,SAAS;AAAA,QACT,UAAU;AAAA,MAAA,CACX;AAAA,IAAA;AAAA,EAEL;AAAA,EAEQ,sBAA4B;AAKlC,SAAK;AAAA,MACH,IAAI,MAAM,SAAS;AAAA,QACjB,SAAS;AAAA,QACT,UAAU;AAAA,MAAA,CACX;AAAA,IAAA;AAAA,EAEL;AAAA,EAEQ,aAAaC,GAAoB;AACvC,IAAAA,EAAM,gBAAA,GACN,KA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ARfX,EAQiB,WAAA,SAAA,CAAA;AAOAU,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAffX,EAeiB,WAAA,WAAA,CAAA;AAOwBU,EAAA;AAAA,EAAnDC,EAAS,EAAE,MAAM,QAAQ,WAAW,aAAa;AAAA,GAtBvCX,EAsByC,WAAA,YAAA,CAAA;AAQxBU,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA9BfX,EA8BiB,WAAA,eAAA,CAAA;AASeU,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAvC9BX,EAuCgC,WAAA,UAAA,CAAA;AAOCU,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA9C/BX,EA8CiC,WAAA,YAAA,CAAA;AAOAU,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GArD/BX,EAqDiC,WAAA,YAAA,CAAA;AAGpCU,EAAA;AAAA,EADPE,EAAM,gBAAgB;AAAA,GAvDZZ,EAwDH,WAAA,UAAA,CAAA;AAcJU,EAAA;AAAA,EADHC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GArE9BX,EAsEP,WAAA,QAAA,CAAA;AAuBAU,EAAA;AAAA,EADHC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA5FfX,EA6FP,WAAA,SAAA,CAAA;AA7FOA,IAANU,EAAA;AAAA,EADNG,EAAcd,CAAoB;AAAA,GACtBC,CAAA;"}
|
package/fhi-title.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { i as g, n, a as p, b as f, t as m } from "./property-DGdAXcEz.js";
|
|
2
|
-
import { o as
|
|
3
|
-
var
|
|
4
|
-
for (var e = r > 1 ? void 0 : r ?
|
|
2
|
+
import { o as v } from "./unsafe-html-lUureUEN.js";
|
|
3
|
+
var y = Object.defineProperty, u = Object.getOwnPropertyDescriptor, a = (t, l, o, r) => {
|
|
4
|
+
for (var e = r > 1 ? void 0 : r ? u(l, o) : l, h = t.length - 1, s; h >= 0; h--)
|
|
5
5
|
(s = t[h]) && (e = (r ? s(l, o, e) : s(e)) || e);
|
|
6
|
-
return r && e &&
|
|
6
|
+
return r && e && y(l, o, e), e;
|
|
7
7
|
};
|
|
8
|
-
const
|
|
8
|
+
const c = "fhi-title";
|
|
9
9
|
let i = class extends p {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments), this.size = "medium";
|
|
12
12
|
}
|
|
13
13
|
updated(t) {
|
|
14
|
-
super.updated(t), t.has("
|
|
14
|
+
super.updated(t), t.has("level") && (typeof this.level != "number" || this.level < 1 || this.level > 6) && console.error(
|
|
15
|
+
new TypeError(
|
|
16
|
+
`The level property must be set to a valid value. invalid value: ${this.level}`
|
|
17
|
+
)
|
|
18
|
+
), t.has("color") && (this.style.color = typeof this.color == "string" ? this.color : "var(--fhi-color-neutral-text-default)");
|
|
15
19
|
}
|
|
16
20
|
render() {
|
|
17
21
|
const t = `
|
|
@@ -19,7 +23,7 @@ let i = class extends p {
|
|
|
19
23
|
<slot></slot>
|
|
20
24
|
</h${this.level}>
|
|
21
25
|
`;
|
|
22
|
-
return f`${
|
|
26
|
+
return f`${v(t)}`;
|
|
23
27
|
}
|
|
24
28
|
};
|
|
25
29
|
i.styles = g`
|
|
@@ -90,10 +94,10 @@ a([
|
|
|
90
94
|
n({ type: Number })
|
|
91
95
|
], i.prototype, "level", 2);
|
|
92
96
|
i = a([
|
|
93
|
-
m(
|
|
97
|
+
m(c)
|
|
94
98
|
], i);
|
|
95
99
|
export {
|
|
96
100
|
i as FhiTitle,
|
|
97
|
-
|
|
101
|
+
c as FhiTitleSelector
|
|
98
102
|
};
|
|
99
103
|
//# sourceMappingURL=fhi-title.js.map
|
package/fhi-title.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhi-title.js","sources":["../../src/components/fhi-title/fhi-title.component.ts"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nexport const FhiTitleSelector = 'fhi-title';\n\nexport type TitleLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * ## FHI Title\n *\n * {@link https://designsystem.fhi.no/?path=/story/komponenter-typography-title--preview}\n *\n * The `<fhi-title>` component is used to display title text in accordance with the FHI Design System guidelines.\n * Use this component instead of the standard HTML heading elements, `<h1>` - `<h6>`, to ensure consistent styling across your application.\n *\n * @tag fhi-title\n * @element fhi-title\n *\n * @slot - The content of the fhi-title component. This should be pure text.\n */\n@customElement(FhiTitleSelector)\nexport class FhiTitle extends LitElement {\n /**\n * Sets the size of the text styles.\n * @reflect\n * @type {'large' | 'medium' | 'small'}\n */\n @property({ type: String, reflect: true }) size:\n | 'large'\n | 'medium'\n | 'small' = 'medium';\n\n /**\n * Sets color of the given text. It supports any valid CSS color value (e.g. hex, rgb, rgba, hsl, hsla, color names).\n *\n * It is recommended to use Design Tokens for colors defined in the FHI Design System.\n * See: {@link https://designsystem.fhi.no/?path=/docs/design-tokens-farger--docs}\n *\n * Example:\n * ```html\n * <fhi-title color=\"var(--fhi-color-primary-text-default)\">\n * This text will be in the primary text color.\n * </fhi-title>\n * ```\n *\n * @type {string}\n */\n @property({ type: String }) color?: string;\n\n /**\n * Sets the heading level for the text, corresponding to HTML heading elements `<h1>` to `<h6>`.\n * @type {1 | 2 | 3 | 4 | 5 | 6}\n */\n @property({ type: Number }) level!: TitleLevel;\n\n updated(changedProperties: PropertyValues<this>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('
|
|
1
|
+
{"version":3,"file":"fhi-title.js","sources":["../../src/components/typography/fhi-title/fhi-title.component.ts"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nexport const FhiTitleSelector = 'fhi-title';\n\nexport type TitleLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * ## FHI Title\n *\n * {@link https://designsystem.fhi.no/?path=/story/komponenter-typography-title--preview}\n *\n * The `<fhi-title>` component is used to display title text in accordance with the FHI Design System guidelines.\n * Use this component instead of the standard HTML heading elements, `<h1>` - `<h6>`, to ensure consistent styling across your application.\n *\n * @tag fhi-title\n * @element fhi-title\n *\n * @slot - The content of the fhi-title component. This should be pure text.\n */\n@customElement(FhiTitleSelector)\nexport class FhiTitle extends LitElement {\n /**\n * Sets the size of the text styles.\n * @reflect\n * @type {'large' | 'medium' | 'small'}\n */\n @property({ type: String, reflect: true }) size:\n | 'large'\n | 'medium'\n | 'small' = 'medium';\n\n /**\n * Sets color of the given text. It supports any valid CSS color value (e.g. hex, rgb, rgba, hsl, hsla, color names).\n *\n * It is recommended to use Design Tokens for colors defined in the FHI Design System.\n * See: {@link https://designsystem.fhi.no/?path=/docs/design-tokens-farger--docs}\n *\n * Example:\n * ```html\n * <fhi-title color=\"var(--fhi-color-primary-text-default)\">\n * This text will be in the primary text color.\n * </fhi-title>\n * ```\n *\n * @type {string}\n */\n @property({ type: String }) color?: string;\n\n /**\n * Sets the heading level for the text, corresponding to HTML heading elements `<h1>` to `<h6>`.\n * @type {1 | 2 | 3 | 4 | 5 | 6}\n */\n @property({ type: Number }) level!: TitleLevel;\n\n updated(changedProperties: PropertyValues<this>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('level')) {\n if (typeof this.level !== 'number' || this.level < 1 || this.level > 6) {\n console.error(\n new TypeError(\n `The level property must be set to a valid value. invalid value: ${this.level}`,\n ),\n );\n }\n }\n\n if (changedProperties.has('color')) {\n this.style.color =\n typeof this.color === 'string'\n ? this.color\n : 'var(--fhi-color-neutral-text-default)';\n }\n }\n\n render() {\n const template = `\n <h${this.level} class=\"title\">\n <slot></slot>\n </h${this.level}>\n `;\n return html`${unsafeHTML(template)}`;\n }\n\n static styles = css`\n :host {\n --font-size-large: var(--fhi-typography-title-large-font-size);\n --font-weight-large: var(--fhi-typography-title-large-font-weight);\n --line-height-large: var(--fhi-typography-title-large-line-height);\n --letter-spacing-large: var(--fhi-typography-title-large-letter-spacing);\n\n --font-size-medium: var(--fhi-typography-title-medium-font-size);\n --font-weight-medium: var(--fhi-typography-title-medium-font-weight);\n --line-height-medium: var(--fhi-typography-title-medium-line-height);\n --letter-spacing-medium: var(\n --fhi-typography-title-medium-letter-spacing\n );\n\n --font-size-small: var(--fhi-typography-title-small-font-size);\n --font-weight-small: var(--fhi-typography-title-small-font-weight);\n --line-height-small: var(--fhi-typography-title-small-line-height);\n --letter-spacing-small: var(--fhi-typography-title-small-letter-spacing);\n }\n\n :host {\n display: block;\n contain: layout;\n color: var(--fhi-color-neutral-text-default);\n .title {\n font-family: var(--fhi-font-family-default);\n -webkit-font-smoothing: antialiased;\n margin: 0;\n }\n }\n\n :host([size='large']) {\n .title {\n font-size: var(--font-size-large);\n font-weight: var(--font-weight-large);\n line-height: var(--line-height-large);\n letter-spacing: var(--letter-spacing-large);\n }\n }\n\n :host([size='medium']) {\n .title {\n font-size: var(--font-size-medium);\n font-weight: var(--font-weight-medium);\n line-height: var(--line-height-medium);\n letter-spacing: var(--letter-spacing-medium);\n }\n }\n\n :host([size='small']) {\n .title {\n font-size: var(--font-size-small);\n font-weight: var(--font-weight-small);\n line-height: var(--line-height-small);\n letter-spacing: var(--letter-spacing-small);\n }\n }\n `;\n}\n"],"names":["FhiTitleSelector","FhiTitle","LitElement","changedProperties","template","html","unsafeHTML","css","__decorateClass","property","customElement"],"mappings":";;;;;;;AAIO,MAAMA,IAAmB;AAkBzB,IAAMC,IAAN,cAAuBC,EAAW;AAAA,EAAlC,cAAA;AAAA,UAAA,GAAA,SAAA,GAMsC,KAAA,OAG7B;AAAA,EAAA;AAAA,EAyBd,QAAQC,GAAyC;AAC/C,UAAM,QAAQA,CAAiB,GAE3BA,EAA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