@folkehelseinstituttet/designsystem 0.40.0 → 0.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/decorate-DFXIek-k.js +611 -0
- package/decorate-DFXIek-k.js.map +1 -0
- package/fhi-body.js +23 -32
- package/fhi-body.js.map +1 -1
- package/fhi-button.js +90 -112
- package/fhi-button.js.map +1 -1
- package/fhi-checkbox.js +53 -66
- package/fhi-checkbox.js.map +1 -1
- package/fhi-data-table-cell.js +23 -29
- package/fhi-data-table-cell.js.map +1 -1
- package/fhi-data-table-row.js +40 -65
- package/fhi-data-table-row.js.map +1 -1
- package/fhi-data-table.js +30 -36
- package/fhi-data-table.js.map +1 -1
- package/fhi-date-input.component-Bus7CeKM.js +278 -0
- package/fhi-date-input.component-Bus7CeKM.js.map +1 -0
- package/fhi-date-input.js +2 -305
- package/fhi-display.js +29 -46
- package/fhi-display.js.map +1 -1
- package/fhi-flex.js +40 -50
- package/fhi-flex.js.map +1 -1
- package/fhi-grid.js +30 -46
- package/fhi-grid.js.map +1 -1
- package/fhi-headline.js +29 -46
- package/fhi-headline.js.map +1 -1
- package/fhi-icon-arrow-down-left.js +26 -43
- package/fhi-icon-arrow-down-left.js.map +1 -1
- package/fhi-icon-arrow-down-right.js +26 -43
- package/fhi-icon-arrow-down-right.js.map +1 -1
- package/fhi-icon-arrow-down.js +26 -43
- package/fhi-icon-arrow-down.js.map +1 -1
- package/fhi-icon-arrow-left.js +26 -43
- package/fhi-icon-arrow-left.js.map +1 -1
- package/fhi-icon-arrow-right-left.js +26 -43
- package/fhi-icon-arrow-right-left.js.map +1 -1
- package/fhi-icon-arrow-right.js +26 -43
- package/fhi-icon-arrow-right.js.map +1 -1
- package/fhi-icon-arrow-up-down.js +26 -43
- package/fhi-icon-arrow-up-down.js.map +1 -1
- package/fhi-icon-arrow-up-left.js +26 -43
- package/fhi-icon-arrow-up-left.js.map +1 -1
- package/fhi-icon-arrow-up-right.js +26 -43
- package/fhi-icon-arrow-up-right.js.map +1 -1
- package/fhi-icon-arrow-up.js +26 -43
- package/fhi-icon-arrow-up.js.map +1 -1
- package/fhi-icon-bell.js +26 -43
- package/fhi-icon-bell.js.map +1 -1
- package/fhi-icon-calendar-clock.js +26 -43
- package/fhi-icon-calendar-clock.js.map +1 -1
- package/fhi-icon-calendar.js +26 -43
- package/fhi-icon-calendar.js.map +1 -1
- package/fhi-icon-chart-bar-stacked.js +26 -43
- package/fhi-icon-chart-bar-stacked.js.map +1 -1
- package/fhi-icon-chart-bar.js +26 -43
- package/fhi-icon-chart-bar.js.map +1 -1
- package/fhi-icon-chart-column-stacked.js +26 -43
- package/fhi-icon-chart-column-stacked.js.map +1 -1
- package/fhi-icon-chart-column.js +26 -43
- package/fhi-icon-chart-column.js.map +1 -1
- package/fhi-icon-chart-line.js +26 -43
- package/fhi-icon-chart-line.js.map +1 -1
- package/fhi-icon-chart-no-axes-combined.js +26 -43
- package/fhi-icon-chart-no-axes-combined.js.map +1 -1
- package/fhi-icon-chart-pie.js +26 -43
- package/fhi-icon-chart-pie.js.map +1 -1
- package/fhi-icon-check.js +26 -43
- package/fhi-icon-check.js.map +1 -1
- package/fhi-icon-chevron-down.js +26 -43
- package/fhi-icon-chevron-down.js.map +1 -1
- package/fhi-icon-chevron-left.js +26 -43
- package/fhi-icon-chevron-left.js.map +1 -1
- package/fhi-icon-chevron-right.js +26 -43
- package/fhi-icon-chevron-right.js.map +1 -1
- package/fhi-icon-chevron-up.js +26 -43
- package/fhi-icon-chevron-up.js.map +1 -1
- package/fhi-icon-chevrons-down.js +26 -43
- package/fhi-icon-chevrons-down.js.map +1 -1
- package/fhi-icon-chevrons-left.js +26 -43
- package/fhi-icon-chevrons-left.js.map +1 -1
- package/fhi-icon-chevrons-right.js +26 -43
- package/fhi-icon-chevrons-right.js.map +1 -1
- package/fhi-icon-chevrons-up.js +26 -43
- package/fhi-icon-chevrons-up.js.map +1 -1
- package/fhi-icon-circle-arrow-down.js +26 -43
- package/fhi-icon-circle-arrow-down.js.map +1 -1
- package/fhi-icon-circle-arrow-left.js +26 -43
- package/fhi-icon-circle-arrow-left.js.map +1 -1
- package/fhi-icon-circle-arrow-right.js +26 -43
- package/fhi-icon-circle-arrow-right.js.map +1 -1
- package/fhi-icon-circle-arrow-up.js +26 -43
- package/fhi-icon-circle-arrow-up.js.map +1 -1
- package/fhi-icon-circle-check-big.js +26 -43
- package/fhi-icon-circle-check-big.js.map +1 -1
- package/fhi-icon-circle-check.js +26 -43
- package/fhi-icon-circle-check.js.map +1 -1
- package/fhi-icon-circle-chevron-down.js +26 -43
- package/fhi-icon-circle-chevron-down.js.map +1 -1
- package/fhi-icon-circle-chevron-left.js +26 -43
- package/fhi-icon-circle-chevron-left.js.map +1 -1
- package/fhi-icon-circle-chevron-right.js +26 -43
- package/fhi-icon-circle-chevron-right.js.map +1 -1
- package/fhi-icon-circle-chevron-up.js +26 -43
- package/fhi-icon-circle-chevron-up.js.map +1 -1
- package/fhi-icon-circle-exclamation.js +26 -43
- package/fhi-icon-circle-exclamation.js.map +1 -1
- package/fhi-icon-circle-info.js +26 -43
- package/fhi-icon-circle-info.js.map +1 -1
- package/fhi-icon-circle-minus.js +26 -43
- package/fhi-icon-circle-minus.js.map +1 -1
- package/fhi-icon-circle-plus.js +26 -43
- package/fhi-icon-circle-plus.js.map +1 -1
- package/fhi-icon-circle-question.js +26 -43
- package/fhi-icon-circle-question.js.map +1 -1
- package/fhi-icon-circle-x.js +26 -43
- package/fhi-icon-circle-x.js.map +1 -1
- package/fhi-icon-circle.js +26 -43
- package/fhi-icon-circle.js.map +1 -1
- package/fhi-icon-clock.js +26 -43
- package/fhi-icon-clock.js.map +1 -1
- package/fhi-icon-copy.js +26 -43
- package/fhi-icon-copy.js.map +1 -1
- package/fhi-icon-download.js +26 -43
- package/fhi-icon-download.js.map +1 -1
- package/fhi-icon-ellipsis-vertical.js +26 -43
- package/fhi-icon-ellipsis-vertical.js.map +1 -1
- package/fhi-icon-ellipsis.js +26 -43
- package/fhi-icon-ellipsis.js.map +1 -1
- package/fhi-icon-exclamation.js +26 -43
- package/fhi-icon-exclamation.js.map +1 -1
- package/fhi-icon-expand.js +26 -43
- package/fhi-icon-expand.js.map +1 -1
- package/fhi-icon-external-link.js +26 -43
- package/fhi-icon-external-link.js.map +1 -1
- package/fhi-icon-eye-off.js +26 -43
- package/fhi-icon-eye-off.js.map +1 -1
- package/fhi-icon-eye.js +26 -43
- package/fhi-icon-eye.js.map +1 -1
- package/fhi-icon-file-text.js +26 -43
- package/fhi-icon-file-text.js.map +1 -1
- package/fhi-icon-file.js +26 -43
- package/fhi-icon-file.js.map +1 -1
- package/fhi-icon-filter.js +26 -43
- package/fhi-icon-filter.js.map +1 -1
- package/fhi-icon-folder.js +26 -43
- package/fhi-icon-folder.js.map +1 -1
- package/fhi-icon-gear.js +26 -43
- package/fhi-icon-gear.js.map +1 -1
- package/fhi-icon-grid-9-dots.js +26 -43
- package/fhi-icon-grid-9-dots.js.map +1 -1
- package/fhi-icon-grip-horizontal.js +26 -43
- package/fhi-icon-grip-horizontal.js.map +1 -1
- package/fhi-icon-grip-vertical.js +26 -43
- package/fhi-icon-grip-vertical.js.map +1 -1
- package/fhi-icon-history.js +26 -43
- package/fhi-icon-history.js.map +1 -1
- package/fhi-icon-info.js +26 -43
- package/fhi-icon-info.js.map +1 -1
- package/fhi-icon-link-2-off.js +26 -43
- package/fhi-icon-link-2-off.js.map +1 -1
- package/fhi-icon-link-2.js +26 -43
- package/fhi-icon-link-2.js.map +1 -1
- package/fhi-icon-link.js +26 -43
- package/fhi-icon-link.js.map +1 -1
- package/fhi-icon-lock-open.js +26 -43
- package/fhi-icon-lock-open.js.map +1 -1
- package/fhi-icon-lock.js +26 -43
- package/fhi-icon-lock.js.map +1 -1
- package/fhi-icon-log-in.js +26 -43
- package/fhi-icon-log-in.js.map +1 -1
- package/fhi-icon-log-out.js +26 -43
- package/fhi-icon-log-out.js.map +1 -1
- package/fhi-icon-mail.js +26 -43
- package/fhi-icon-mail.js.map +1 -1
- package/fhi-icon-map-pin.js +26 -43
- package/fhi-icon-map-pin.js.map +1 -1
- package/fhi-icon-menu.js +26 -43
- package/fhi-icon-menu.js.map +1 -1
- package/fhi-icon-message.js +26 -43
- package/fhi-icon-message.js.map +1 -1
- package/fhi-icon-minus.js +26 -43
- package/fhi-icon-minus.js.map +1 -1
- package/fhi-icon-octagon-alert.js +26 -43
- package/fhi-icon-octagon-alert.js.map +1 -1
- package/fhi-icon-paperclip.js +26 -43
- package/fhi-icon-paperclip.js.map +1 -1
- package/fhi-icon-pencil.js +26 -43
- package/fhi-icon-pencil.js.map +1 -1
- package/fhi-icon-phone.js +26 -43
- package/fhi-icon-phone.js.map +1 -1
- package/fhi-icon-pin-off.js +26 -43
- package/fhi-icon-pin-off.js.map +1 -1
- package/fhi-icon-pin.js +26 -43
- package/fhi-icon-pin.js.map +1 -1
- package/fhi-icon-plus.js +26 -43
- package/fhi-icon-plus.js.map +1 -1
- package/fhi-icon-printer.js +26 -43
- package/fhi-icon-printer.js.map +1 -1
- package/fhi-icon-question.js +26 -43
- package/fhi-icon-question.js.map +1 -1
- package/fhi-icon-refresh.js +26 -43
- package/fhi-icon-refresh.js.map +1 -1
- package/fhi-icon-rotate-left.js +26 -43
- package/fhi-icon-rotate-left.js.map +1 -1
- package/fhi-icon-rotate-right.js +26 -43
- package/fhi-icon-rotate-right.js.map +1 -1
- package/fhi-icon-search.js +26 -43
- package/fhi-icon-search.js.map +1 -1
- package/fhi-icon-send.js +26 -43
- package/fhi-icon-send.js.map +1 -1
- package/fhi-icon-share.js +26 -43
- package/fhi-icon-share.js.map +1 -1
- package/fhi-icon-sheet.js +26 -43
- package/fhi-icon-sheet.js.map +1 -1
- package/fhi-icon-square-check-big.js +26 -43
- package/fhi-icon-square-check-big.js.map +1 -1
- package/fhi-icon-square-check.js +26 -43
- package/fhi-icon-square-check.js.map +1 -1
- package/fhi-icon-square-pen.js +26 -43
- package/fhi-icon-square-pen.js.map +1 -1
- package/fhi-icon-square-x.js +26 -43
- package/fhi-icon-square-x.js.map +1 -1
- package/fhi-icon-square.js +26 -43
- package/fhi-icon-square.js.map +1 -1
- package/fhi-icon-trash.js +26 -43
- package/fhi-icon-trash.js.map +1 -1
- package/fhi-icon-triangle-alert.js +26 -43
- package/fhi-icon-triangle-alert.js.map +1 -1
- package/fhi-icon-upload.js +26 -43
- package/fhi-icon-upload.js.map +1 -1
- package/fhi-icon-user.js +26 -43
- package/fhi-icon-user.js.map +1 -1
- package/fhi-icon-x.js +26 -43
- package/fhi-icon-x.js.map +1 -1
- package/fhi-label.js +23 -32
- package/fhi-label.js.map +1 -1
- package/fhi-modal-dialog.js +76 -111
- package/fhi-modal-dialog.js.map +1 -1
- package/fhi-radio.js +91 -109
- package/fhi-radio.js.map +1 -1
- package/fhi-tag.js +32 -44
- package/fhi-tag.js.map +1 -1
- package/fhi-text-input.js +96 -126
- package/fhi-text-input.js.map +1 -1
- package/fhi-title.js +29 -46
- package/fhi-title.js.map +1 -1
- package/fhi-tooltip.component-DJNDfrHK.js +919 -0
- package/fhi-tooltip.component-DJNDfrHK.js.map +1 -0
- package/fhi-tooltip.js +2 -1162
- package/fonts/RobotoFlex.ttf +0 -0
- package/if-defined-Dl-W5B5_.js +7 -0
- package/if-defined-Dl-W5B5_.js.map +1 -0
- package/index.js +123 -369
- package/package.json +1 -1
- package/theme/default.css +480 -1
- package/unsafe-html-CBTN3162.js +50 -0
- package/unsafe-html-CBTN3162.js.map +1 -0
- package/web-types.json +1 -1
- package/base-D76d76ww.js +0 -10
- package/base-D76d76ww.js.map +0 -1
- package/fhi-date-input.js.map +0 -1
- package/fhi-tooltip.js.map +0 -1
- package/fonts/RobotoFlex.ttf.js.map +0 -1
- package/if-defined-B_sR6Mtk.js +0 -11
- package/if-defined-B_sR6Mtk.js.map +0 -1
- package/index.js.map +0 -1
- package/property-B2Ico5CW.js +0 -605
- package/property-B2Ico5CW.js.map +0 -1
- package/query-Ddbd72Um.js +0 -21
- package/query-Ddbd72Um.js.map +0 -1
- package/unsafe-html-DfuTUjUu.js +0 -48
- package/unsafe-html-DfuTUjUu.js.map +0 -1
package/fhi-icon-x.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhi-icon-x.js","sources":["../../src/components/icons/fhi-icon-x.component.ts"],"sourcesContent":["\n/*\n This file is auto-generated by generate-icon-components.js. Do not edit it manually.\n*/\nimport { html, css, LitElement } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\n\nexport const FhiIconXSelector = \"fhi-icon-x\";\n\n/**\n * ## FhiIconX\n * \n * {@link https://designsystem.fhi.no/?path=/docs/ikoner--docs}\n * \n * @tag fhi-icon-x\n * @element fhi-icon-x\n */\n@customElement(FhiIconXSelector)\nexport class FhiIconX extends LitElement {\n\n /**\n * Sets the color for the icon.\n * Should preferably be a color token. See [Color Tokens](https://designsystem.fhi.no/?path=/docs/design-tokens-farger--docs)\n * @type {string}\n */ \n @property({ type: String }) color: string = \"currentcolor\";\n\n /**\n * Sets the size of the icon. Can be one of the predefined sizes, a number value, rem or px.\n * Number values are treated as px.\n * @type { 'xsmall' | 'small' | 'medium' | 'large' | number | string}\n */\n @property({ type: String }) size: 'xsmall' | 'small' | 'medium' | 'large' | number | `${number}px` | `${number}rem` = 'medium';\n\n private get _size(): string {\n switch (this.size) {\n case 'xsmall': \n return '1rem'; \n case 'small':\n return '1.25rem';\n case 'medium':\n return '1.5rem'; \n case 'large':\n return '2rem'; \n default:\n if (String(this.size).endsWith('px') || String(this.size).endsWith('rem')) {\n return String(this.size);\n }\n if (isNaN(Number(this.size))) {\n console.warn(`Invalid size value: ${this.size}. Falling back to default size '1.5rem'.`)\n return '1.5rem';\n }\n return `${this.size}px`;\n }\n }\n\n render() {\n return html`\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"${this._size}\" height=\"${this._size}\" fill=\"${this.color}\"><path d=\"M17.47 5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47.052.056a.75.75 0 0 1-1.056 1.056l-.056-.052L12 13.06l-5.47 5.47a.75.75 0 1 1-1.06-1.06L10.94 12 5.47 6.53l-.052-.056a.75.75 0 0 1 1.056-1.056l.056.052L12 10.94z\"/></svg>\n `;\n }\n \n static styles = css`\n :host {\n display: flex;\n max-height: min-content;\n max-width: min-content;\n }\n `;\n }\n"],"
|
|
1
|
+
{"version":3,"file":"fhi-icon-x.js","names":[],"sources":["../../src/components/icons/fhi-icon-x.component.ts"],"sourcesContent":["\n/*\n This file is auto-generated by generate-icon-components.js. Do not edit it manually.\n*/\nimport { html, css, LitElement } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\n\nexport const FhiIconXSelector = \"fhi-icon-x\";\n\n/**\n * ## FhiIconX\n * \n * {@link https://designsystem.fhi.no/?path=/docs/ikoner--docs}\n * \n * @tag fhi-icon-x\n * @element fhi-icon-x\n */\n@customElement(FhiIconXSelector)\nexport class FhiIconX extends LitElement {\n\n /**\n * Sets the color for the icon.\n * Should preferably be a color token. See [Color Tokens](https://designsystem.fhi.no/?path=/docs/design-tokens-farger--docs)\n * @type {string}\n */ \n @property({ type: String }) color: string = \"currentcolor\";\n\n /**\n * Sets the size of the icon. Can be one of the predefined sizes, a number value, rem or px.\n * Number values are treated as px.\n * @type { 'xsmall' | 'small' | 'medium' | 'large' | number | string}\n */\n @property({ type: String }) size: 'xsmall' | 'small' | 'medium' | 'large' | number | `${number}px` | `${number}rem` = 'medium';\n\n private get _size(): string {\n switch (this.size) {\n case 'xsmall': \n return '1rem'; \n case 'small':\n return '1.25rem';\n case 'medium':\n return '1.5rem'; \n case 'large':\n return '2rem'; \n default:\n if (String(this.size).endsWith('px') || String(this.size).endsWith('rem')) {\n return String(this.size);\n }\n if (isNaN(Number(this.size))) {\n console.warn(`Invalid size value: ${this.size}. Falling back to default size '1.5rem'.`)\n return '1.5rem';\n }\n return `${this.size}px`;\n }\n }\n\n render() {\n return html`\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"${this._size}\" height=\"${this._size}\" fill=\"${this.color}\"><path d=\"M17.47 5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47.052.056a.75.75 0 0 1-1.056 1.056l-.056-.052L12 13.06l-5.47 5.47a.75.75 0 1 1-1.06-1.06L10.94 12 5.47 6.53l-.052-.056a.75.75 0 0 1 1.056-1.056l.056.052L12 10.94z\"/></svg>\n `;\n }\n \n static styles = css`\n :host {\n display: flex;\n max-height: min-content;\n max-width: min-content;\n }\n `;\n }\n"],"mappings":";;AAOA,IAAa,IAAmB,cAWzB,IAAA,cAAuB,EAAW;;4BAOK,4BAO0E;;CAEtH,IAAY,QAAgB;EAC1B,QAAQ,KAAK,MAAb;GACE,KAAK,UACH,OAAO;GACT,KAAK,SACH,OAAO;GACT,KAAK,UACH,OAAO;GACT,KAAK,SACH,OAAO;GACT,SAQE,OAPI,OAAO,KAAK,IAAI,EAAE,SAAS,IAAI,KAAK,OAAO,KAAK,IAAI,EAAE,SAAS,KAAK,IAC/D,OAAO,KAAK,IAAI,IAErB,MAAM,OAAO,KAAK,IAAI,CAAC,KACzB,QAAQ,KAAK,uBAAuB,KAAK,KAAK,yCAAyC,GAChF,YAEF,GAAG,KAAK,KAAK;EACxB;CACF;CAEA,SAAS;EACP,OAAO,CAAI;2EAC4D,KAAK,MAAM,YAAY,KAAK,MAAM,UAAU,KAAK,MAAM;;CAEhI;;gBAEgB,CAAG;;;;;;;;AAOnB;GA5CC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,KAAA,CAAA,MAOzB,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,UAf3B,EAAc,CAAgB,CAAA,GAAA,CAAA"}
|
package/fhi-label.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
updated(t) {
|
|
13
|
-
super.updated(t), t.has("color") && (this.style.color = typeof this.color == "string" ? this.color : "currentcolor");
|
|
14
|
-
}
|
|
15
|
-
render() {
|
|
16
|
-
return g`
|
|
1
|
+
import { a as e, d as t, o as n, s as r, t as i, u as a } from "./decorate-DFXIek-k.js";
|
|
2
|
+
//#region src/components/typography/fhi-label/fhi-label.component.ts
|
|
3
|
+
var o = "fhi-label", s = class extends r {
|
|
4
|
+
constructor(...e) {
|
|
5
|
+
super(...e), this.size = "medium", this.color = "currentcolor";
|
|
6
|
+
}
|
|
7
|
+
updated(e) {
|
|
8
|
+
super.updated(e), e.has("color") && (this.style.color = typeof this.color == "string" ? this.color : "currentcolor");
|
|
9
|
+
}
|
|
10
|
+
render() {
|
|
11
|
+
return a`
|
|
17
12
|
<span class="label">
|
|
18
13
|
<slot></slot>
|
|
19
14
|
</span>
|
|
20
15
|
`;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
}
|
|
17
|
+
static {
|
|
18
|
+
this.styles = t`
|
|
24
19
|
:host {
|
|
25
20
|
display: block;
|
|
26
21
|
contain: layout;
|
|
@@ -58,17 +53,13 @@ l.styles = n`
|
|
|
58
53
|
}
|
|
59
54
|
}
|
|
60
55
|
`;
|
|
61
|
-
|
|
62
|
-
p({ type: String, reflect: !0 })
|
|
63
|
-
], l.prototype, "size", 2);
|
|
64
|
-
s([
|
|
65
|
-
p({ type: String })
|
|
66
|
-
], l.prototype, "color", 2);
|
|
67
|
-
l = s([
|
|
68
|
-
y(m)
|
|
69
|
-
], l);
|
|
70
|
-
export {
|
|
71
|
-
l as FhiLabel,
|
|
72
|
-
m as FhiLabelSelector
|
|
56
|
+
}
|
|
73
57
|
};
|
|
74
|
-
|
|
58
|
+
i([e({
|
|
59
|
+
type: String,
|
|
60
|
+
reflect: !0
|
|
61
|
+
})], s.prototype, "size", void 0), i([e({ type: String })], s.prototype, "color", void 0), s = i([n(o)], s);
|
|
62
|
+
//#endregion
|
|
63
|
+
export { s as FhiLabel, o as FhiLabelSelector };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=fhi-label.js.map
|
package/fhi-label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhi-label.js","sources":["../../src/components/typography/fhi-label/fhi-label.component.ts"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nexport const FhiLabelSelector = 'fhi-label';\n\n/**\n * ## FHI Label\n *\n * {@link https://designsystem.fhi.no/?path=/story/komponenter-typography-label--preview}\n *\n * The `<fhi-label>` component is used to display label text in accordance with the FHI Design System guidelines.\n * Use this component instead of the standard HTML `<label>` element to ensure consistent styling across your application.\n *\n * @tag fhi-label\n * @element fhi-label\n *\n * @slot - The content of the fhi-label component. This should be pure text.\n */\n@customElement(FhiLabelSelector)\nexport class FhiLabel extends LitElement {\n /**\n * Sets the font size of the given text.\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-label color=\"var(--fhi-color-primary-text-default)\">\n * This text will be in the primary text color.\n * </fhi-label>\n * ```\n *\n * @type {string}\n */\n @property({ type: String }) color?: string = 'currentcolor';\n\n updated(changedProperties: PropertyValues<this>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('color')) {\n this.style.color =\n typeof this.color === 'string' ? this.color : 'currentcolor';\n }\n }\n\n render() {\n return html`\n <span class=\"label\">\n <slot></slot>\n </span>\n `;\n }\n\n static styles = css`\n :host {\n display: block;\n contain: layout;\n .label {\n font-family: var(--fhi-font-family-default);\n -webkit-font-smoothing: antialiased;\n margin: 0;\n }\n }\n\n :host([size='large']) {\n .label {\n font-size: var(--fhi-typography-label-large-font-size);\n font-weight: var(--fhi-typography-label-large-font-weight);\n line-height: var(--fhi-typography-label-large-line-height);\n letter-spacing: var(--fhi-typography-label-large-letter-spacing);\n }\n }\n\n :host([size='medium']) {\n .label {\n font-size: var(--fhi-typography-label-medium-font-size);\n font-weight: var(--fhi-typography-label-medium-font-weight);\n line-height: var(--fhi-typography-label-medium-line-height);\n letter-spacing: var(--fhi-typography-label-medium-letter-spacing);\n }\n }\n\n :host([size='small']) {\n .label {\n font-size: var(--fhi-typography-label-small-font-size);\n font-weight: var(--fhi-typography-label-small-font-weight);\n line-height: var(--fhi-typography-label-small-line-height);\n letter-spacing: var(--fhi-typography-label-small-letter-spacing);\n }\n }\n `;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"fhi-label.js","names":[],"sources":["../../src/components/typography/fhi-label/fhi-label.component.ts"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nexport const FhiLabelSelector = 'fhi-label';\n\n/**\n * ## FHI Label\n *\n * {@link https://designsystem.fhi.no/?path=/story/komponenter-typography-label--preview}\n *\n * The `<fhi-label>` component is used to display label text in accordance with the FHI Design System guidelines.\n * Use this component instead of the standard HTML `<label>` element to ensure consistent styling across your application.\n *\n * @tag fhi-label\n * @element fhi-label\n *\n * @slot - The content of the fhi-label component. This should be pure text.\n */\n@customElement(FhiLabelSelector)\nexport class FhiLabel extends LitElement {\n /**\n * Sets the font size of the given text.\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-label color=\"var(--fhi-color-primary-text-default)\">\n * This text will be in the primary text color.\n * </fhi-label>\n * ```\n *\n * @type {string}\n */\n @property({ type: String }) color?: string = 'currentcolor';\n\n updated(changedProperties: PropertyValues<this>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('color')) {\n this.style.color =\n typeof this.color === 'string' ? this.color : 'currentcolor';\n }\n }\n\n render() {\n return html`\n <span class=\"label\">\n <slot></slot>\n </span>\n `;\n }\n\n static styles = css`\n :host {\n display: block;\n contain: layout;\n .label {\n font-family: var(--fhi-font-family-default);\n -webkit-font-smoothing: antialiased;\n margin: 0;\n }\n }\n\n :host([size='large']) {\n .label {\n font-size: var(--fhi-typography-label-large-font-size);\n font-weight: var(--fhi-typography-label-large-font-weight);\n line-height: var(--fhi-typography-label-large-line-height);\n letter-spacing: var(--fhi-typography-label-large-letter-spacing);\n }\n }\n\n :host([size='medium']) {\n .label {\n font-size: var(--fhi-typography-label-medium-font-size);\n font-weight: var(--fhi-typography-label-medium-font-weight);\n line-height: var(--fhi-typography-label-medium-line-height);\n letter-spacing: var(--fhi-typography-label-medium-letter-spacing);\n }\n }\n\n :host([size='small']) {\n .label {\n font-size: var(--fhi-typography-label-small-font-size);\n font-weight: var(--fhi-typography-label-small-font-weight);\n line-height: var(--fhi-typography-label-small-line-height);\n letter-spacing: var(--fhi-typography-label-small-letter-spacing);\n }\n }\n `;\n}\n"],"mappings":";;AAGA,IAAa,IAAmB,aAgBzB,IAAA,cAAuB,EAAW;;2BASzB,uBAiB+B;;CAE7C,QAAQ,GAAyC;EAG/C,AAFA,MAAM,QAAQ,CAAiB,GAE3B,EAAkB,IAAI,OAAO,MAC/B,KAAK,MAAM,QACT,OAAO,KAAK,SAAU,WAAW,KAAK,QAAQ;CAEpD;CAEA,SAAS;EACP,OAAO,CAAI;;;;;CAKb;;gBAEgB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCrB;GA7EG,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,MAoBxC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,KAAA,CAAA,UA3B3B,EAAc,CAAgB,CAAA,GAAA,CAAA"}
|
package/fhi-modal-dialog.js
CHANGED
|
@@ -1,86 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as h } from "./query-Ddbd72Um.js";
|
|
1
|
+
import { a as e, d as t, o as n, r, s as i, t as a, u as o } from "./decorate-DFXIek-k.js";
|
|
3
2
|
import "./fhi-button.js";
|
|
4
3
|
import "./fhi-icon-x.js";
|
|
5
4
|
import "./fhi-headline.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this._mouseDownInsideDialog = !1;
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
e.target === this._dialog && this.close(), e.stopPropagation();
|
|
66
|
-
}
|
|
67
|
-
_handleCloseButtonClick() {
|
|
68
|
-
this.close();
|
|
69
|
-
}
|
|
70
|
-
_handleDialogContentMouseDown() {
|
|
71
|
-
this._mouseDownInsideDialog = !0;
|
|
72
|
-
}
|
|
73
|
-
_handleFooterSlotChange() {
|
|
74
|
-
this._toggleFooter();
|
|
75
|
-
}
|
|
76
|
-
handleKeyPress(e) {
|
|
77
|
-
e.key === "Escape" && (e.preventDefault(), this.close());
|
|
78
|
-
}
|
|
79
|
-
_toggleFooter() {
|
|
80
|
-
this._footerSlot.assignedNodes({ flatten: !0 }).length === 0 ? this._footer.style.display = "none" : this._footer.style.display = "flex";
|
|
81
|
-
}
|
|
82
|
-
render() {
|
|
83
|
-
return f` <dialog
|
|
5
|
+
//#region src/components/fhi-modal-dialog/fhi-modal-dialog.component.ts
|
|
6
|
+
var s = "fhi-modal-dialog", c = class extends i {
|
|
7
|
+
constructor(...e) {
|
|
8
|
+
super(...e), this.open = !1, this.size = "medium", this.closeButtonLabel = "", this.heading = "", this._triggerElement = null, this._bodyOverflowStyle = "", this._mouseDownInsideDialog = !1;
|
|
9
|
+
}
|
|
10
|
+
updated(e) {
|
|
11
|
+
if (super.updated(e), e.has("open") && (this.open ? this.show() : this.close()), e.has("size") && this.size !== "small" && this.size !== "medium" && (this.size = "medium"), e.has("closeButtonLabel") && (typeof this.closeButtonLabel != "string" || this.closeButtonLabel.length === 0)) throw TypeError("The close-button-label property must be set to a non-empty string. This label must describe the purpose of the close button for accessibility reasons.");
|
|
12
|
+
if (e.has("closeButtonLabel") && (typeof this.heading != "string" || this.heading.length === 0)) throw TypeError("The heading property must be set to a non-empty string. This heading describes the purpose of the dialog.");
|
|
13
|
+
}
|
|
14
|
+
firstUpdated(e) {
|
|
15
|
+
super.firstUpdated(e), this._toggleFooter();
|
|
16
|
+
}
|
|
17
|
+
show() {
|
|
18
|
+
this._triggerElement = document.activeElement, this._bodyOverflowStyle = document.body.style.overflow, this.open ||= !0, document.body.style.overflow = "hidden", this._dialog.showModal(), setTimeout(() => {
|
|
19
|
+
this._focusDialog();
|
|
20
|
+
}, 10), this._dispatchToggleEvent(), this.addEventListener("keydown", this.handleKeyPress.bind(this));
|
|
21
|
+
}
|
|
22
|
+
close() {
|
|
23
|
+
this.open &&= !1, document.body.style.overflow = this._bodyOverflowStyle, this._dialog.close(), this._dispatchToggleEvent(), this._dispatchCloseEvent(), this._triggerElement?.focus(), this.removeEventListener("keydown", this.handleKeyPress.bind(this));
|
|
24
|
+
}
|
|
25
|
+
_focusDialog() {
|
|
26
|
+
this._dialog.focus();
|
|
27
|
+
}
|
|
28
|
+
_dispatchToggleEvent() {
|
|
29
|
+
this.dispatchEvent(new ToggleEvent("toggle", {
|
|
30
|
+
newState: this.open ? "open" : "closed",
|
|
31
|
+
oldState: this.open ? "closed" : "open"
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
_dispatchCloseEvent() {
|
|
35
|
+
this.dispatchEvent(new CloseEvent("close"));
|
|
36
|
+
}
|
|
37
|
+
_handleDialogMouseUp(e) {
|
|
38
|
+
if (this._mouseDownInsideDialog) {
|
|
39
|
+
this._mouseDownInsideDialog = !1;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
e.target === this._dialog && this.close(), e.stopPropagation();
|
|
43
|
+
}
|
|
44
|
+
_handleCloseButtonClick() {
|
|
45
|
+
this.close();
|
|
46
|
+
}
|
|
47
|
+
_handleDialogContentMouseDown() {
|
|
48
|
+
this._mouseDownInsideDialog = !0;
|
|
49
|
+
}
|
|
50
|
+
_handleFooterSlotChange() {
|
|
51
|
+
this._toggleFooter();
|
|
52
|
+
}
|
|
53
|
+
handleKeyPress(e) {
|
|
54
|
+
e.key === "Escape" && (e.preventDefault(), this.close());
|
|
55
|
+
}
|
|
56
|
+
_toggleFooter() {
|
|
57
|
+
this._footerSlot.assignedNodes({ flatten: !0 }).length === 0 ? this._footer.style.display = "none" : this._footer.style.display = "flex";
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
return o` <dialog
|
|
84
61
|
@mouseup=${this._handleDialogMouseUp}
|
|
85
62
|
aria-modal="true"
|
|
86
63
|
aria-labelledby="dialog-label"
|
|
@@ -114,9 +91,9 @@ let o = class extends p {
|
|
|
114
91
|
</footer>
|
|
115
92
|
</section>
|
|
116
93
|
</dialog>`;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
94
|
+
}
|
|
95
|
+
static {
|
|
96
|
+
this.styles = t`
|
|
120
97
|
@keyframes fhi-dialog-fade-in {
|
|
121
98
|
from {
|
|
122
99
|
opacity: 0;
|
|
@@ -203,32 +180,20 @@ o.styles = g`
|
|
|
203
180
|
}
|
|
204
181
|
}
|
|
205
182
|
`;
|
|
206
|
-
|
|
207
|
-
n({ type: Boolean, reflect: !0 })
|
|
208
|
-
], o.prototype, "open", 2);
|
|
209
|
-
i([
|
|
210
|
-
n({ type: String, attribute: "size", reflect: !0 })
|
|
211
|
-
], o.prototype, "size", 2);
|
|
212
|
-
i([
|
|
213
|
-
n({ type: String, attribute: "close-button-label" })
|
|
214
|
-
], o.prototype, "closeButtonLabel", 2);
|
|
215
|
-
i([
|
|
216
|
-
n({ type: String })
|
|
217
|
-
], o.prototype, "heading", 2);
|
|
218
|
-
i([
|
|
219
|
-
h("dialog")
|
|
220
|
-
], o.prototype, "_dialog", 2);
|
|
221
|
-
i([
|
|
222
|
-
h("footer")
|
|
223
|
-
], o.prototype, "_footer", 2);
|
|
224
|
-
i([
|
|
225
|
-
h('slot[name="footer"]')
|
|
226
|
-
], o.prototype, "_footerSlot", 2);
|
|
227
|
-
o = i([
|
|
228
|
-
c(b)
|
|
229
|
-
], o);
|
|
230
|
-
export {
|
|
231
|
-
o as FhiModalDialog,
|
|
232
|
-
b as FhiModalDialogSelector
|
|
183
|
+
}
|
|
233
184
|
};
|
|
234
|
-
|
|
185
|
+
a([e({
|
|
186
|
+
type: Boolean,
|
|
187
|
+
reflect: !0
|
|
188
|
+
})], c.prototype, "open", void 0), a([e({
|
|
189
|
+
type: String,
|
|
190
|
+
attribute: "size",
|
|
191
|
+
reflect: !0
|
|
192
|
+
})], c.prototype, "size", void 0), a([e({
|
|
193
|
+
type: String,
|
|
194
|
+
attribute: "close-button-label"
|
|
195
|
+
})], c.prototype, "closeButtonLabel", void 0), a([e({ type: String })], c.prototype, "heading", void 0), a([r("dialog")], c.prototype, "_dialog", void 0), a([r("footer")], c.prototype, "_footer", void 0), a([r("slot[name=\"footer\"]")], c.prototype, "_footerSlot", void 0), c = a([n(s)], c);
|
|
196
|
+
//#endregion
|
|
197
|
+
export { c as FhiModalDialog, s as FhiModalDialogSelector };
|
|
198
|
+
|
|
199
|
+
//# sourceMappingURL=fhi-modal-dialog.js.map
|
package/fhi-modal-dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhi-modal-dialog.js","sources":["../../src/components/fhi-modal-dialog/fhi-modal-dialog.component.ts"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport '../fhi-button/fhi-button.component';\nimport '../icons/fhi-icon-x.component';\nimport '../typography/fhi-headline/fhi-headline.component';\n\nexport const FhiModalDialogSelector = 'fhi-modal-dialog';\n\n/**\n * ## FHI Modal Dialog\n *\n * {@link https://designsystem.fhi.no/?path=/docs/komponenter-modal-dialog--docs}\n *\n * The `fhi-modal-dialog` component is used to display important information or prompt the user for input in a modal window.\n * It overlays the main content and usually requires user interaction before returning to the underlying page.\n *\n * @tag fhi-modal-dialog\n * @element fhi-modal-dialog\n *\n * @slot body - The main content of the dialog. Typically contains text or form elements.\n * @slot footer - The footer content of the dialog, typically containing action buttons.\n */\n@customElement(FhiModalDialogSelector)\nexport class FhiModalDialog extends LitElement {\n /**\n * Decides whether the dialog is open or closed.\n * By setting this property to true, the dialog will be shown. Setting it to false will close the dialog.\n *\n * This property is reflected as an attribute and will therefor also change if the user toggles the dialog or\n * if you use the `show()` and `close()` methods.\n * @reflect\n * @type {boolean}\n */\n @property({ type: Boolean, reflect: true })\n open: boolean = false;\n\n /**\n * Sets the maximum width of the dialog.\n * @type {'small' | 'medium'`}\n */\n @property({ type: String, attribute: 'size', reflect: true })\n size: 'small' | 'medium' = 'medium';\n\n /**\n * Label for the close button.\n * @type {string}\n */\n @property({ type: String, attribute: 'close-button-label' })\n closeButtonLabel: string = '';\n\n /**\n * The heading text of the dialog. This is displayed at the top of the dialog.\n * @type {string}\n */\n @property({ type: String })\n heading: string = '';\n\n @query('dialog')\n private _dialog!: HTMLDialogElement;\n\n @query('footer')\n private _footer!: HTMLElement;\n\n @query('slot[name=\"footer\"]')\n private _footerSlot!: HTMLSlotElement;\n\n private _triggerElement: HTMLElement | null = null;\n private _bodyOverflowStyle: string = '';\n private _mouseDownInsideDialog: boolean = false;\n\n updated(changedProperties: PropertyValues<this>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('open')) {\n if (this.open) {\n this.show();\n } else {\n this.close();\n }\n }\n\n // if invalid size is provided, default to 'medium'\n if (changedProperties.has('size')) {\n if (this.size !== 'small' && this.size !== 'medium') {\n this.size = 'medium';\n }\n }\n\n if (changedProperties.has('closeButtonLabel')) {\n if (\n typeof this.closeButtonLabel !== 'string' ||\n this.closeButtonLabel.length === 0\n ) {\n throw new TypeError(\n 'The close-button-label property must be set to a non-empty string. This label must describe the purpose of the close button for accessibility reasons.',\n );\n }\n }\n\n if (changedProperties.has('closeButtonLabel')) {\n if (typeof this.heading !== 'string' || this.heading.length === 0) {\n throw new TypeError(\n 'The heading property must be set to a non-empty string. This heading describes the purpose of the dialog.',\n );\n }\n }\n }\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n this._toggleFooter();\n }\n\n /**\n * Programmatically opens the dialog.\n * You can also open the dialog by instead setting the `open` property to `true`.\n */\n public show() {\n this._triggerElement = document.activeElement as HTMLElement | null;\n this._bodyOverflowStyle = document.body.style.overflow;\n\n if (!this.open) {\n this.open = true;\n }\n\n document.body.style.overflow = 'hidden';\n\n this._dialog.showModal();\n\n // Delay focus to make sure the windows screen reader properly detects the dialog\n setTimeout(() => {\n this._focusDialog();\n }, 10);\n\n this._dispatchToggleEvent();\n\n this.addEventListener('keydown', this.handleKeyPress.bind(this));\n }\n\n /**\n * Programmatically closes the dialog.\n * You can also close the dialog by instead setting the `open` property to `false`.\n */\n public close() {\n if (this.open) {\n this.open = false;\n }\n\n document.body.style.overflow = this._bodyOverflowStyle;\n\n this._dialog.close();\n\n this._dispatchToggleEvent();\n this._dispatchCloseEvent();\n\n this._triggerElement?.focus();\n\n this.removeEventListener('keydown', this.handleKeyPress.bind(this));\n }\n\n private _focusDialog() {\n this._dialog.focus();\n }\n\n private _dispatchToggleEvent() {\n /**\n * @type {Event} - Standard DOM event with the type `toggle`\n * This event is fired whenever the dialog is opened or closed.\n * */\n this.dispatchEvent(\n new ToggleEvent('toggle', {\n newState: this.open ? 'open' : 'closed',\n oldState: this.open ? 'closed' : 'open',\n }),\n );\n }\n\n private _dispatchCloseEvent() {\n /**\n * @type {Event} - Standard DOM event with the type `close`\n * This event is fired whenever the dialog is closed.\n * */\n this.dispatchEvent(new CloseEvent('close'));\n }\n\n private _handleDialogMouseUp(event: MouseEvent) {\n if (this._mouseDownInsideDialog) {\n this._mouseDownInsideDialog = false;\n return;\n }\n\n if (event.target === this._dialog) {\n this.close();\n }\n\n event.stopPropagation();\n }\n\n private _handleCloseButtonClick() {\n this.close();\n }\n\n private _handleDialogContentMouseDown() {\n this._mouseDownInsideDialog = true;\n }\n\n private _handleFooterSlotChange() {\n this._toggleFooter();\n }\n\n private handleKeyPress(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.close();\n }\n }\n\n private _toggleFooter() {\n const nodes = this._footerSlot.assignedNodes({ flatten: true });\n\n if (nodes.length === 0) {\n this._footer.style.display = 'none';\n } else {\n this._footer.style.display = 'flex';\n }\n }\n\n render() {\n return html` <dialog\n @mouseup=${this._handleDialogMouseUp}\n aria-modal=\"true\"\n aria-labelledby=\"dialog-label\"\n closedby=\"none\"\n role=\"dialog\"\n >\n <section\n class=\"dialog-content\"\n @mousedown=${this._handleDialogContentMouseDown}\n >\n <header>\n <fhi-headline ?hidden=${!this.heading} id=\"dialog-label\" level=\"1\"\n >${this.heading}\n </fhi-headline>\n <fhi-button\n variant=\"text\"\n color=\"neutral\"\n size=\"small\"\n @click=${this._handleCloseButtonClick}\n >\n ${this.closeButtonLabel}\n <fhi-icon-x></fhi-icon-x>\n </fhi-button>\n </header>\n <slot name=\"body\"></slot>\n <footer>\n <slot\n name=\"footer\"\n @slotchange=${this._handleFooterSlotChange}\n ></slot>\n </footer>\n </section>\n </dialog>`;\n }\n\n static styles = css`\n @keyframes fhi-dialog-fade-in {\n from {\n opacity: 0;\n }\n }\n\n :host {\n --dimension-dialog-border-width: var(--fhi-dimension-border-width);\n --dimension-dialog-border-radius: var(--fhi-border-radius-200);\n --dimension-dialog-header-padding: var(--fhi-spacing-500)\n var(--fhi-spacing-500) 0 var(--fhi-spacing-500);\n --dimension-dialog-header-gap: var(--fhi-spacing-050);\n --dimension-dialog-body-padding: var(--fhi-spacing-500);\n --dimension-dialog-footer-padding: 0 var(--fhi-spacing-500)\n var(--fhi-spacing-500) var(--fhi-spacing-500);\n --dimension-dialog-footer-gap: var(--fhi-spacing-050);\n\n --dimension-dialog-width-small: 28rem;\n --dimension-dialog-width-medium: 40rem;\n\n --color-backdrop: var(--fhi-color-neutral-surface-active);\n --color-dialog-border: var(--fhi-color-neutral-border-subtle);\n\n --motion-transition: var(--fhi-motion-duration-quick)\n var(--fhi-motion-ease-default);\n }\n\n :host {\n display: none;\n position: absolute;\n\n dialog {\n display: flex;\n overflow: hidden;\n border: var(--dimension-dialog-border-width) solid\n var(--color-dialog-border);\n border-radius: var(--dimension-dialog-border-radius);\n animation: var(--motion-transition) fhi-dialog-fade-in;\n padding: 0;\n .dialog-content {\n overflow: auto;\n flex: 1;\n }\n header {\n display: flex;\n justify-content: space-between;\n align-items: start;\n gap: var(--dimension-dialog-header-gap);\n padding: var(--dimension-dialog-header-padding);\n }\n slot[name='body'] {\n display: block;\n padding: var(--dimension-dialog-body-padding);\n }\n footer {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n gap: var(--dimension-dialog-footer-gap);\n flex-wrap: wrap;\n padding: var(--dimension-dialog-footer-padding);\n }\n &::backdrop {\n background-color: var(--color-backdrop);\n opacity: var(--fhi-opacity-disabled);\n animation: var(--motion-transition) fhi-dialog-fade-in;\n }\n }\n }\n\n :host([open]) {\n display: block;\n }\n\n :host([size='small']) {\n dialog {\n width: var(--dimension-dialog-width-small);\n }\n }\n\n :host([size='medium']) {\n dialog {\n width: var(--dimension-dialog-width-medium);\n }\n }\n `;\n}\n"],"names":["FhiModalDialogSelector","FhiModalDialog","LitElement","changedProperties","_changedProperties","_a","event","html","css","__decorateClass","property","query","customElement"],"mappings":";;;;;;;;;;AAOO,MAAMA,IAAyB;AAiB/B,IAAMC,IAAN,cAA6BC,EAAW;AAAA,EAAxC,cAAA;AAAA,UAAA,GAAA,SAAA,GAWL,KAAA,OAAgB,IAOhB,KAAA,OAA2B,UAO3B,KAAA,mBAA2B,IAO3B,KAAA,UAAkB,IAWlB,KAAQ,kBAAsC,MAC9C,KAAQ,qBAA6B,IACrC,KAAQ,yBAAkC;AAAA,EAAA;AAAA,EAE1C,QAAQC,GAAyC;AAkB/C,QAjBA,MAAM,QAAQA,CAAiB,GAE3BA,EAAkB,IAAI,MAAM,MAC1B,KAAK,OACP,KAAK,KAAA,IAEL,KAAK,MAAA,IAKLA,EAAkB,IAAI,MAAM,KAC1B,KAAK,SAAS,WAAW,KAAK,SAAS,aACzC,KAAK,OAAO,WAIZA,EAAkB,IAAI,kBAAkB,MAExC,OAAO,KAAK,oBAAqB,YACjC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"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport '../fhi-button/fhi-button.component';\nimport '../icons/fhi-icon-x.component';\nimport '../typography/fhi-headline/fhi-headline.component';\n\nexport const FhiModalDialogSelector = 'fhi-modal-dialog';\n\n/**\n * ## FHI Modal Dialog\n *\n * {@link https://designsystem.fhi.no/?path=/docs/komponenter-modal-dialog--docs}\n *\n * The `fhi-modal-dialog` component is used to display important information or prompt the user for input in a modal window.\n * It overlays the main content and usually requires user interaction before returning to the underlying page.\n *\n * @tag fhi-modal-dialog\n * @element fhi-modal-dialog\n *\n * @slot body - The main content of the dialog. Typically contains text or form elements.\n * @slot footer - The footer content of the dialog, typically containing action buttons.\n */\n@customElement(FhiModalDialogSelector)\nexport class FhiModalDialog extends LitElement {\n /**\n * Decides whether the dialog is open or closed.\n * By setting this property to true, the dialog will be shown. Setting it to false will close the dialog.\n *\n * This property is reflected as an attribute and will therefor also change if the user toggles the dialog or\n * if you use the `show()` and `close()` methods.\n * @reflect\n * @type {boolean}\n */\n @property({ type: Boolean, reflect: true })\n open: boolean = false;\n\n /**\n * Sets the maximum width of the dialog.\n * @type {'small' | 'medium'`}\n */\n @property({ type: String, attribute: 'size', reflect: true })\n size: 'small' | 'medium' = 'medium';\n\n /**\n * Label for the close button.\n * @type {string}\n */\n @property({ type: String, attribute: 'close-button-label' })\n closeButtonLabel: string = '';\n\n /**\n * The heading text of the dialog. This is displayed at the top of the dialog.\n * @type {string}\n */\n @property({ type: String })\n heading: string = '';\n\n @query('dialog')\n private _dialog!: HTMLDialogElement;\n\n @query('footer')\n private _footer!: HTMLElement;\n\n @query('slot[name=\"footer\"]')\n private _footerSlot!: HTMLSlotElement;\n\n private _triggerElement: HTMLElement | null = null;\n private _bodyOverflowStyle: string = '';\n private _mouseDownInsideDialog: boolean = false;\n\n updated(changedProperties: PropertyValues<this>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('open')) {\n if (this.open) {\n this.show();\n } else {\n this.close();\n }\n }\n\n // if invalid size is provided, default to 'medium'\n if (changedProperties.has('size')) {\n if (this.size !== 'small' && this.size !== 'medium') {\n this.size = 'medium';\n }\n }\n\n if (changedProperties.has('closeButtonLabel')) {\n if (\n typeof this.closeButtonLabel !== 'string' ||\n this.closeButtonLabel.length === 0\n ) {\n throw new TypeError(\n 'The close-button-label property must be set to a non-empty string. This label must describe the purpose of the close button for accessibility reasons.',\n );\n }\n }\n\n if (changedProperties.has('closeButtonLabel')) {\n if (typeof this.heading !== 'string' || this.heading.length === 0) {\n throw new TypeError(\n 'The heading property must be set to a non-empty string. This heading describes the purpose of the dialog.',\n );\n }\n }\n }\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n this._toggleFooter();\n }\n\n /**\n * Programmatically opens the dialog.\n * You can also open the dialog by instead setting the `open` property to `true`.\n */\n public show() {\n this._triggerElement = document.activeElement as HTMLElement | null;\n this._bodyOverflowStyle = document.body.style.overflow;\n\n if (!this.open) {\n this.open = true;\n }\n\n document.body.style.overflow = 'hidden';\n\n this._dialog.showModal();\n\n // Delay focus to make sure the windows screen reader properly detects the dialog\n setTimeout(() => {\n this._focusDialog();\n }, 10);\n\n this._dispatchToggleEvent();\n\n this.addEventListener('keydown', this.handleKeyPress.bind(this));\n }\n\n /**\n * Programmatically closes the dialog.\n * You can also close the dialog by instead setting the `open` property to `false`.\n */\n public close() {\n if (this.open) {\n this.open = false;\n }\n\n document.body.style.overflow = this._bodyOverflowStyle;\n\n this._dialog.close();\n\n this._dispatchToggleEvent();\n this._dispatchCloseEvent();\n\n this._triggerElement?.focus();\n\n this.removeEventListener('keydown', this.handleKeyPress.bind(this));\n }\n\n private _focusDialog() {\n this._dialog.focus();\n }\n\n private _dispatchToggleEvent() {\n /**\n * @type {Event} - Standard DOM event with the type `toggle`\n * This event is fired whenever the dialog is opened or closed.\n * */\n this.dispatchEvent(\n new ToggleEvent('toggle', {\n newState: this.open ? 'open' : 'closed',\n oldState: this.open ? 'closed' : 'open',\n }),\n );\n }\n\n private _dispatchCloseEvent() {\n /**\n * @type {Event} - Standard DOM event with the type `close`\n * This event is fired whenever the dialog is closed.\n * */\n this.dispatchEvent(new CloseEvent('close'));\n }\n\n private _handleDialogMouseUp(event: MouseEvent) {\n if (this._mouseDownInsideDialog) {\n this._mouseDownInsideDialog = false;\n return;\n }\n\n if (event.target === this._dialog) {\n this.close();\n }\n\n event.stopPropagation();\n }\n\n private _handleCloseButtonClick() {\n this.close();\n }\n\n private _handleDialogContentMouseDown() {\n this._mouseDownInsideDialog = true;\n }\n\n private _handleFooterSlotChange() {\n this._toggleFooter();\n }\n\n private handleKeyPress(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.close();\n }\n }\n\n private _toggleFooter() {\n const nodes = this._footerSlot.assignedNodes({ flatten: true });\n\n if (nodes.length === 0) {\n this._footer.style.display = 'none';\n } else {\n this._footer.style.display = 'flex';\n }\n }\n\n render() {\n return html` <dialog\n @mouseup=${this._handleDialogMouseUp}\n aria-modal=\"true\"\n aria-labelledby=\"dialog-label\"\n closedby=\"none\"\n role=\"dialog\"\n >\n <section\n class=\"dialog-content\"\n @mousedown=${this._handleDialogContentMouseDown}\n >\n <header>\n <fhi-headline ?hidden=${!this.heading} id=\"dialog-label\" level=\"1\"\n >${this.heading}\n </fhi-headline>\n <fhi-button\n variant=\"text\"\n color=\"neutral\"\n size=\"small\"\n @click=${this._handleCloseButtonClick}\n >\n ${this.closeButtonLabel}\n <fhi-icon-x></fhi-icon-x>\n </fhi-button>\n </header>\n <slot name=\"body\"></slot>\n <footer>\n <slot\n name=\"footer\"\n @slotchange=${this._handleFooterSlotChange}\n ></slot>\n </footer>\n </section>\n </dialog>`;\n }\n\n static styles = css`\n @keyframes fhi-dialog-fade-in {\n from {\n opacity: 0;\n }\n }\n\n :host {\n --dimension-dialog-border-width: var(--fhi-dimension-border-width);\n --dimension-dialog-border-radius: var(--fhi-border-radius-200);\n --dimension-dialog-header-padding: var(--fhi-spacing-500)\n var(--fhi-spacing-500) 0 var(--fhi-spacing-500);\n --dimension-dialog-header-gap: var(--fhi-spacing-050);\n --dimension-dialog-body-padding: var(--fhi-spacing-500);\n --dimension-dialog-footer-padding: 0 var(--fhi-spacing-500)\n var(--fhi-spacing-500) var(--fhi-spacing-500);\n --dimension-dialog-footer-gap: var(--fhi-spacing-050);\n\n --dimension-dialog-width-small: 28rem;\n --dimension-dialog-width-medium: 40rem;\n\n --color-backdrop: var(--fhi-color-neutral-surface-active);\n --color-dialog-border: var(--fhi-color-neutral-border-subtle);\n\n --motion-transition: var(--fhi-motion-duration-quick)\n var(--fhi-motion-ease-default);\n }\n\n :host {\n display: none;\n position: absolute;\n\n dialog {\n display: flex;\n overflow: hidden;\n border: var(--dimension-dialog-border-width) solid\n var(--color-dialog-border);\n border-radius: var(--dimension-dialog-border-radius);\n animation: var(--motion-transition) fhi-dialog-fade-in;\n padding: 0;\n .dialog-content {\n overflow: auto;\n flex: 1;\n }\n header {\n display: flex;\n justify-content: space-between;\n align-items: start;\n gap: var(--dimension-dialog-header-gap);\n padding: var(--dimension-dialog-header-padding);\n }\n slot[name='body'] {\n display: block;\n padding: var(--dimension-dialog-body-padding);\n }\n footer {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n gap: var(--dimension-dialog-footer-gap);\n flex-wrap: wrap;\n padding: var(--dimension-dialog-footer-padding);\n }\n &::backdrop {\n background-color: var(--color-backdrop);\n opacity: var(--fhi-opacity-disabled);\n animation: var(--motion-transition) fhi-dialog-fade-in;\n }\n }\n }\n\n :host([open]) {\n display: block;\n }\n\n :host([size='small']) {\n dialog {\n width: var(--dimension-dialog-width-small);\n }\n }\n\n :host([size='medium']) {\n dialog {\n width: var(--dimension-dialog-width-medium);\n }\n }\n `;\n}\n"],"mappings":";;;;;AAOA,IAAa,IAAyB,oBAiB/B,IAAA,cAA6B,EAAW;;2BAW7B,gBAOW,kCAOA,mBAOT,2BAW4B,gC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|
|
73
|
-
r.key === "ArrowUp" || r.key === "ArrowLeft" ? a = t[e === 0 ? t.length - 1 : e - 1] : a = t[e === t.length - 1 ? 0 : e + 1], a.focus(), this.checked = !1, a.checked = !0, this._SetTabbableRadios();
|
|
74
|
-
}
|
|
75
|
-
render() {
|
|
76
|
-
return p`
|
|
1
|
+
import { a as e, d as t, o as n, r, s as i, t as a, u as o } from "./decorate-DFXIek-k.js";
|
|
2
|
+
import { t as s } from "./if-defined-Dl-W5B5_.js";
|
|
3
|
+
//#region src/components/fhi-radio/fhi-radio.component.ts
|
|
4
|
+
var c = "fhi-radio", l = class extends i {
|
|
5
|
+
static {
|
|
6
|
+
this.formAssociated = !0;
|
|
7
|
+
}
|
|
8
|
+
constructor() {
|
|
9
|
+
super(), this.label = void 0, this.name = void 0, this.status = void 0, this.disabled = !1, this.checked = !1, this.value = "on", this.isFormElement = !1, this._internals = this.attachInternals(), this._groupRoot = document;
|
|
10
|
+
}
|
|
11
|
+
connectedCallback() {
|
|
12
|
+
super.connectedCallback(), this.addEventListener("focus", this._setFocusOnInput), this.isFormElement = !!this._internals.form, this.isFormElement && (this._updateFormValue(), this._groupRoot = this._internals.form), this.name && (this.addEventListener("keydown", this._handleKeyDown), this._SetTabbableRadios());
|
|
13
|
+
}
|
|
14
|
+
disconnectedCallback() {
|
|
15
|
+
super.disconnectedCallback(), this.removeEventListener("keydown", this._handleKeyDown), this.removeEventListener("focus", this._setFocusOnInput);
|
|
16
|
+
}
|
|
17
|
+
_setFocusOnInput() {
|
|
18
|
+
this._input.focus();
|
|
19
|
+
}
|
|
20
|
+
_getRadioGroup() {
|
|
21
|
+
return Array.from(this._groupRoot.querySelectorAll(`${c}[name="${this.name}"]`));
|
|
22
|
+
}
|
|
23
|
+
_SetTabbableRadios() {
|
|
24
|
+
let e = this._getRadioGroup();
|
|
25
|
+
e.forEach((e) => {
|
|
26
|
+
e.tabIndex = e.checked ? 0 : -1;
|
|
27
|
+
}), !e.some((e) => e.checked) && e.length > 0 && (e[0].tabIndex = 0);
|
|
28
|
+
}
|
|
29
|
+
updated(e) {
|
|
30
|
+
super.updated(e), e.has("checked") && (this._input.checked = !!this.checked, this._updateFormValue(), this.checked && this.uncheckGroupMembers()), (e.has("value") || e.has("name")) && this._input.checked && this._updateFormValue();
|
|
31
|
+
}
|
|
32
|
+
formResetCallback() {
|
|
33
|
+
this._getRadioGroup().filter((e) => typeof e.getAttribute("checked") == "string").pop() === this && (this.checked = !0), this._updateFormValue();
|
|
34
|
+
}
|
|
35
|
+
uncheckGroupMembers() {
|
|
36
|
+
this._getRadioGroup().forEach((e) => {
|
|
37
|
+
e !== this && (e.isFormElement && this._groupRoot === document || (e.checked = !1));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
_updateFormValue() {
|
|
41
|
+
this.isFormElement && this._internals.setFormValue(this.checked ? this.value : null);
|
|
42
|
+
}
|
|
43
|
+
_handleChange(e) {
|
|
44
|
+
this.checked = e.target.checked, this.uncheckGroupMembers(), this._updateFormValue(), e.stopPropagation(), this._dispatchChangeEvent();
|
|
45
|
+
}
|
|
46
|
+
_handleInput(e) {
|
|
47
|
+
e.stopPropagation(), this._dispatchInputEvent();
|
|
48
|
+
}
|
|
49
|
+
_dispatchChangeEvent() {
|
|
50
|
+
this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
51
|
+
}
|
|
52
|
+
_dispatchInputEvent() {
|
|
53
|
+
this.dispatchEvent(new Event("input", {
|
|
54
|
+
bubbles: !0,
|
|
55
|
+
composed: !0
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
_handleKeyDown(e) {
|
|
59
|
+
if (![
|
|
60
|
+
"ArrowUp",
|
|
61
|
+
"ArrowDown",
|
|
62
|
+
"ArrowLeft",
|
|
63
|
+
"ArrowRight"
|
|
64
|
+
].includes(e.key)) return;
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
let t = this._getRadioGroup();
|
|
67
|
+
if (t.length < 2) return;
|
|
68
|
+
let n = t.indexOf(this), r;
|
|
69
|
+
r = e.key === "ArrowUp" || e.key === "ArrowLeft" ? t[n === 0 ? t.length - 1 : n - 1] : t[n === t.length - 1 ? 0 : n + 1], r.focus(), this.checked = !1, r.checked = !0, this._SetTabbableRadios();
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
72
|
+
return o`
|
|
77
73
|
<label>
|
|
78
74
|
<div class="radio-container">
|
|
79
75
|
<input
|
|
80
76
|
type="radio"
|
|
81
77
|
id="input-element"
|
|
82
|
-
name="${
|
|
78
|
+
name="${s(this.name)}"
|
|
83
79
|
value="${this.value}"
|
|
84
80
|
?checked=${this.checked}
|
|
85
81
|
?disabled=${this.disabled}
|
|
@@ -97,10 +93,9 @@ let i = class extends u {
|
|
|
97
93
|
${this.label}
|
|
98
94
|
</label>
|
|
99
95
|
`;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
i.styles = h`
|
|
96
|
+
}
|
|
97
|
+
static {
|
|
98
|
+
this.styles = t`
|
|
104
99
|
:host {
|
|
105
100
|
--motion-radio-transition: var(--fhi-motion-ease-default)
|
|
106
101
|
var(--fhi-motion-duration-quick);
|
|
@@ -275,32 +270,19 @@ i.styles = h`
|
|
|
275
270
|
}
|
|
276
271
|
}
|
|
277
272
|
`;
|
|
278
|
-
|
|
279
|
-
n({ type: String })
|
|
280
|
-
], i.prototype, "label", 2);
|
|
281
|
-
d([
|
|
282
|
-
n({ type: String, reflect: !0 })
|
|
283
|
-
], i.prototype, "name", 2);
|
|
284
|
-
d([
|
|
285
|
-
n({ type: String, reflect: !0 })
|
|
286
|
-
], i.prototype, "status", 2);
|
|
287
|
-
d([
|
|
288
|
-
n({ type: Boolean, reflect: !0 })
|
|
289
|
-
], i.prototype, "disabled", 2);
|
|
290
|
-
d([
|
|
291
|
-
n({ type: Boolean })
|
|
292
|
-
], i.prototype, "checked", 2);
|
|
293
|
-
d([
|
|
294
|
-
n({ type: String })
|
|
295
|
-
], i.prototype, "value", 2);
|
|
296
|
-
d([
|
|
297
|
-
v("#input-element")
|
|
298
|
-
], i.prototype, "_input", 2);
|
|
299
|
-
i = d([
|
|
300
|
-
b(c)
|
|
301
|
-
], i);
|
|
302
|
-
export {
|
|
303
|
-
i as FhiRadio,
|
|
304
|
-
c as FhiRadioSelector
|
|
273
|
+
}
|
|
305
274
|
};
|
|
306
|
-
|
|
275
|
+
a([e({ type: String })], l.prototype, "label", void 0), a([e({
|
|
276
|
+
type: String,
|
|
277
|
+
reflect: !0
|
|
278
|
+
})], l.prototype, "name", void 0), a([e({
|
|
279
|
+
type: String,
|
|
280
|
+
reflect: !0
|
|
281
|
+
})], l.prototype, "status", void 0), a([e({
|
|
282
|
+
type: Boolean,
|
|
283
|
+
reflect: !0
|
|
284
|
+
})], l.prototype, "disabled", void 0), a([e({ type: Boolean })], l.prototype, "checked", void 0), a([e({ type: String })], l.prototype, "value", void 0), a([r("#input-element")], l.prototype, "_input", void 0), l = a([n(c)], l);
|
|
285
|
+
//#endregion
|
|
286
|
+
export { l as FhiRadio, c as FhiRadioSelector };
|
|
287
|
+
|
|
288
|
+
//# sourceMappingURL=fhi-radio.js.map
|