@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-radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhi-radio.js","sources":["../../src/components/fhi-radio/fhi-radio.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 FhiRadioSelector = 'fhi-radio';\n\n/**\n * ## FHI Radio\n *\n * {@link https://designsystem.fhi.no/?path=/docs/komponenter-radio--docs}\n *\n * The `<fhi-radio>` component represents a single radio button.\n * It should be used within a group of options, allowing users to select one option from a set.\n *\n * @tag fhi-radio\n * @element fhi-radio\n */\n@customElement(FhiRadioSelector)\nexport class FhiRadio extends LitElement {\n static readonly formAssociated = true;\n\n /**\n * The text label assigned to and displayed next to the radio.\n * You should always provide a label.\n * @type {string}\n */\n @property({ type: String }) label?: string = undefined;\n\n /**\n * The name of the radio. This is submitted with the form data as a `key` when the checkbox is checked.\n * All `<fhi-radio>` components with the same name belong to the same group.\n * @reflect\n * @type {string}\n */\n @property({ type: String, reflect: true }) name?: string = undefined;\n\n /**\n * Sets the visual status of the radio. There is currently only one status available: `error`.\n * The `error` status is used to indicate that there is an issue with the radio, such as a required radio not being checked.\n * @reflect\n * @type {'error' | undefined}\n */\n @property({ type: String, reflect: true }) status?: 'error' = undefined;\n\n /**\n * Disables the radio. 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 /**\n * Whether the radio button is checked or not.\n * @type {boolean}\n */\n @property({ type: Boolean }) checked? = false;\n\n /**\n * The value of the radio. This is submitted with the form data as a `value` when the radio is checked.\n * @type {string}\n */\n @property({ type: String }) value: string = 'on';\n\n @query('#input-element')\n private _input!: HTMLInputElement;\n\n private _groupRoot: Document | HTMLFormElement;\n private _internals: ElementInternals;\n\n /**\n * Indicates if the radio button is part of a form.\n * @internal\n */\n public isFormElement = false;\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n this._groupRoot = document;\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n\n this.addEventListener('focus', this._setFocusOnInput);\n\n this.isFormElement = !!this._internals.form;\n\n if (this.isFormElement) {\n this._updateFormValue();\n this._groupRoot = this._internals.form!;\n }\n\n // If the radio has a name then it is part of a group and needs keyboard navigation\n if (this.name) {\n this.addEventListener('keydown', this._handleKeyDown);\n this._SetTabbableRadios();\n }\n }\n\n public disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeEventListener('keydown', this._handleKeyDown);\n this.removeEventListener('focus', this._setFocusOnInput);\n }\n\n private _setFocusOnInput() {\n this._input.focus();\n }\n\n private _getRadioGroup() {\n return Array.from(\n this._groupRoot.querySelectorAll<FhiRadio>(\n `${FhiRadioSelector}[name=\"${this.name}\"]`,\n ),\n );\n }\n\n private _SetTabbableRadios() {\n const radios = this._getRadioGroup();\n\n radios.forEach(radio => {\n // Only the checked radio should be tabbable\n radio.tabIndex = radio.checked ? 0 : -1;\n });\n\n // If none of the radios are checked, make the first one tabbable\n if (!radios.some(radio => radio.checked) && radios.length > 0) {\n radios[0].tabIndex = 0;\n }\n }\n\n public updated(changedProperties: Map<string, unknown>) {\n super.updated(changedProperties);\n\n // make sure the radio input can be programmatically toggeled. e.g by a form reset\n if (changedProperties.has('checked')) {\n this._input.checked = !!this.checked;\n this._updateFormValue();\n\n if (this.checked) {\n this.uncheckGroupMembers();\n }\n }\n\n // update the form value when the value or name input changes and the radio is already checked\n if (changedProperties.has('value') || changedProperties.has('name')) {\n if (this._input.checked) {\n this._updateFormValue();\n }\n }\n }\n\n public formResetCallback(): void {\n const radiosCheckedByDefault = this._getRadioGroup().filter(\n radio => typeof radio.getAttribute('checked') === 'string',\n );\n\n if (radiosCheckedByDefault.pop() === this) {\n this.checked = true;\n }\n\n this._updateFormValue();\n }\n\n private uncheckGroupMembers(): void {\n const radios = this._getRadioGroup();\n\n radios.forEach(radio => {\n if (radio === this) {\n return;\n }\n\n if (radio.isFormElement && this._groupRoot === document) {\n return;\n }\n\n radio.checked = false;\n });\n }\n\n private _updateFormValue(): void {\n if (!this.isFormElement) {\n return;\n }\n\n this._internals.setFormValue(this.checked ? this.value : null);\n }\n\n private _handleChange(event: Event): void {\n this.checked = (event.target as HTMLInputElement).checked;\n\n this.uncheckGroupMembers();\n\n this._updateFormValue();\n\n event.stopPropagation();\n this._dispatchChangeEvent();\n }\n private _handleInput(event: Event): void {\n event.stopPropagation();\n this._dispatchInputEvent();\n }\n\n private _dispatchChangeEvent(): void {\n /**\n * @type {Event} - Standard DOM event with the type `change`.\n * This event is dispatched when the radio is checked or unchecked.\n */\n this.dispatchEvent(new Event('change', { bubbles: true }));\n }\n\n private _dispatchInputEvent(): void {\n /**\n * @type {Event} - Standard DOM event with the type `input`.\n * This event is dispatched when the radio is checked or unchecked.\n */\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n }\n\n private _handleKeyDown(event: KeyboardEvent): void {\n const arrows = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n if (!arrows.includes(event.key)) {\n return;\n }\n\n event.preventDefault();\n\n const radios = this._getRadioGroup();\n\n if (radios.length < 2) {\n return;\n }\n\n const currentIndex = radios.indexOf(this);\n\n const nextIndex = currentIndex;\n let nextRadio: FhiRadio;\n\n if (event.key === 'ArrowUp' || event.key === 'ArrowLeft') {\n nextRadio = radios[nextIndex === 0 ? radios.length - 1 : nextIndex - 1];\n } else {\n nextRadio = radios[nextIndex === radios.length - 1 ? 0 : nextIndex + 1];\n }\n\n nextRadio.focus();\n this.checked = false;\n nextRadio.checked = true;\n this._SetTabbableRadios();\n }\n\n render() {\n return html`\n <label>\n <div class=\"radio-container\">\n <input\n type=\"radio\"\n id=\"input-element\"\n name=\"${ifDefined(this.name)}\"\n value=\"${this.value}\"\n ?checked=${this.checked}\n ?disabled=${this.disabled}\n @change=${this._handleChange}\n @input=${this._handleInput}\n />\n <svg\n class=\"radio-dot\"\n viewBox=\"0 0 18 18\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle r=\"6\" cx=\"9\" cy=\"9\" />\n </svg>\n </div>\n ${this.label}\n </label>\n `;\n }\n\n static styles = css`\n :host {\n --motion-radio-transition: var(--fhi-motion-ease-default)\n var(--fhi-motion-duration-quick);\n\n --color-radio-label: var(--fhi-color-neutral-text-default);\n --color-radio-border: var(--fhi-color-neutral-border-default);\n --color-radio-background: var(--fhi-color-neutral-background-default);\n\n --color-radio-border-hover: var(--fhi-color-accent-border-strong);\n --color-radio-background-hover: var(--fhi-color-accent-background-subtle);\n\n --color-radio-background-active: var(--fhi-color-accent-surface-default);\n\n --color-radio-outline: var(--fhi-color-accent-surface-hover);\n\n --typography-radio-label-font-family: var(--fhi-font-family-default);\n -webkit-font-smoothing: antialiased;\n --typography-radio-label-font-size: var(\n --fhi-typography-body-medium-font-size\n );\n\n --typography-radio-label-font-weight: var(\n --fhi-typography-body-medium-font-weight\n );\n\n --typography-radio-label-line-height: var(\n --fhi-typography-body-medium-line-height\n );\n --typography-radio-label-letter-spacing: var(\n --fhi-typography-body-medium-letter-spacing\n );\n\n --dimension-radio-label-gap: var(--fhi-spacing-050);\n --dimension-radio-width: var(--fhi-spacing-250);\n --dimension-radio-height: var(--fhi-spacing-250);\n --dimension-radio-margin: 0.125rem;\n --dimension-radio-border-width: var(--fhi-dimension-border-width);\n\n --dimension-radio-dot-size: 1.125rem;\n\n /* Checked state */\n --dimension-radio-border-width-checked: var(\n --fhi-dimension-border-width-active\n );\n\n /* Error state */\n --color-radio-border-error: var(--fhi-color-danger-border-default);\n --color-radio-background-error: var(\n --fhi-color-danger-background-default\n );\n\n --color-radio-border-error-hover: var(--fhi-color-danger-border-strong);\n --color-radio-background-error-hover: var(\n --fhi-color-danger-background-subtle\n );\n\n --color-radio-background-error-active: var(\n --fhi-color-danger-surface-default\n );\n\n --color-radio-outline-error: var(--fhi-color-danger-surface-hover);\n\n /* Disabled state */\n --opacity-disabled: var(--fhi-opacity-disabled);\n }\n\n :host {\n display: flex;\n align-items: center;\n width: max-content;\n\n label {\n display: flex;\n position: relative;\n gap: var(--dimension-radio-label-gap);\n color: var(--color-radio-label);\n font-family: var(--typography-radio-label-font-family);\n font-size: var(--typography-radio-label-font-size);\n font-weight: var(--typography-radio-label-font-weight);\n line-height: var(--typography-radio-label-line-height);\n letter-spacing: var(--typography-radio-label-letter-spacing);\n }\n\n .radio-container {\n display: flex;\n position: relative;\n }\n\n input {\n appearance: none;\n margin: var(--dimension-radio-margin);\n width: var(--dimension-radio-width);\n height: var(--dimension-radio-height);\n background-color: var(--color-radio-background);\n border: var(--dimension-radio-border-width) solid\n var(--color-radio-border);\n border-radius: var(--fhi-border-radius-full);\n transition: all var(--motion-radio-transition);\n }\n\n .radio-dot {\n visibility: hidden;\n opacity: 0;\n transition: opacity var(--motion-radio-transition);\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n height: var(--dimension-radio-dot-size);\n width: var(--dimension-radio-dot-size);\n }\n\n input:checked {\n border-width: var(--dimension-radio-border-width-checked);\n ~ .radio-dot {\n circle {\n fill: var(--color-radio-border);\n }\n visibility: visible;\n opacity: 1;\n }\n }\n }\n\n :host([disabled]) {\n opacity: var(--opacity-disabled);\n label,\n input {\n cursor: not-allowed;\n }\n }\n\n :host(:not(:disabled)) {\n input:hover:not(:checked) {\n border-color: var(--color-radio-border-hover);\n background-color: var(--color-radio-background-hover);\n }\n\n input:active:not(:checked) {\n border-color: var(--color-radio-border-hover);\n background-color: var(--color-radio-background-active);\n outline: var(--fhi-dimension-border-width-focus) solid\n var(--color-radio-outline);\n }\n }\n\n :host([status='error']) {\n input {\n border-color: var(--color-radio-border-error);\n background-color: var(--color-radio-background-error);\n }\n\n input:checked {\n ~ .radio-dot {\n circle {\n fill: var(--color-radio-border-error);\n }\n }\n }\n }\n\n :host([status='error']:not(:disabled)) {\n input:hover:not(:checked) {\n border-color: var(--color-radio-border-error-hover);\n background-color: var(--color-radio-background-error-hover);\n }\n\n input:active:not(:checked) {\n border-color: var(--color-radio-border-error-hover);\n background-color: var(--color-radio-background-error-active);\n outline-color: var(--color-radio-outline-error);\n }\n }\n `;\n}\n"],"names":["FhiRadioSelector","FhiRadio","LitElement","radios","radio","changedProperties","event","nextIndex","nextRadio","html","ifDefined","css","__decorateClass","property","query","customElement"],"mappings":";;;;;;;;AAIO,MAAMA,IAAmB;AAczB,IAAMC,IAAN,cAAuBC,EAAW;AAAA,EAyDvC,cAAc;AACZ,UAAA,GAlD0B,KAAA,QAAiB,QAQF,KAAA,OAAgB,QAQhB,KAAA,SAAmB,QAOlB,KAAA,WAAY,IAM3B,KAAA,UAAW,IAMZ,KAAA,QAAgB,MAY5C,KAAO,gBAAgB,IAIrB,KAAK,aAAa,KAAK,gBAAA,GACvB,KAAK,aAAa;AAAA,EACpB;AAAA,EAEO,oBAA0B;AAC/B,UAAM,kBAAA,GAEN,KAAK,iBAAiB,SAAS,KAAK,gBAAgB,GAEpD,KAAK,gBAAgB,CAAC,CAAC,KAAK,WAAW,MAEnC,KAAK,kBACP,KAAK,iBAAA,GACL,KAAK,aAAa,KAAK,WAAW,OAIhC,KAAK,SACP,KAAK,iBAAiB,WAAW,KAAK,cAAc,GACpD,KAAK,mBAAA;AAAA,EAET;AAAA,EAEO,uBAA6B;AAClC,UAAM,qBAAA,GACN,KAAK,oBAAoB,WAAW,KAAK,cAAc,GACvD,KAAK,oBAAoB,SAAS,KAAK,gBAAgB;AAAA,EACzD;AAAA,EAEQ,mBAAmB;AACzB,SAAK,OAAO,MAAA;AAAA,EACd;AAAA,EAEQ,iBAAiB;AACvB,WAAO,MAAM;AAAA,MACX,KAAK,WAAW;AAAA,QACd,GAAGF,CAAgB,UAAU,KAAK,IAAI;AAAA,MAAA;AAAA,IACxC;AAAA,EAEJ;AAAA,EAEQ,qBAAqB;AAC3B,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CAAA;AAQeW,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAhB9BZ,EAgBgC,WAAA,QAAA,CAAA;AAQAW,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAxB9BZ,EAwBgC,WAAA,UAAA,CAAA;AAOCW,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA/B/BZ,EA+BiC,WAAA,YAAA,CAAA;AAMfW,EAAA;AAAA,EAA5BC,EAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GArChBZ,EAqCkB,WAAA,WAAA,CAAA;AAMDW,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA3CfZ,EA2CiB,WAAA,SAAA,CAAA;AAGpBW,EAAA;AAAA,EADPE,EAAM,gBAAgB;AAAA,GA7CZb,EA8CH,WAAA,UAAA,CAAA;AA9CGA,IAANW,EAAA;AAAA,EADNG,EAAcf,CAAgB;AAAA,GAClBC,CAAA;"}
|
|
1
|
+
{"version":3,"file":"fhi-radio.js","names":[],"sources":["../../src/components/fhi-radio/fhi-radio.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 FhiRadioSelector = 'fhi-radio';\n\n/**\n * ## FHI Radio\n *\n * {@link https://designsystem.fhi.no/?path=/docs/komponenter-radio--docs}\n *\n * The `<fhi-radio>` component represents a single radio button.\n * It should be used within a group of options, allowing users to select one option from a set.\n *\n * @tag fhi-radio\n * @element fhi-radio\n */\n@customElement(FhiRadioSelector)\nexport class FhiRadio extends LitElement {\n static readonly formAssociated = true;\n\n /**\n * The text label assigned to and displayed next to the radio.\n * You should always provide a label.\n * @type {string}\n */\n @property({ type: String }) label?: string = undefined;\n\n /**\n * The name of the radio. This is submitted with the form data as a `key` when the checkbox is checked.\n * All `<fhi-radio>` components with the same name belong to the same group.\n * @reflect\n * @type {string}\n */\n @property({ type: String, reflect: true }) name?: string = undefined;\n\n /**\n * Sets the visual status of the radio. There is currently only one status available: `error`.\n * The `error` status is used to indicate that there is an issue with the radio, such as a required radio not being checked.\n * @reflect\n * @type {'error' | undefined}\n */\n @property({ type: String, reflect: true }) status?: 'error' = undefined;\n\n /**\n * Disables the radio. 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 /**\n * Whether the radio button is checked or not.\n * @type {boolean}\n */\n @property({ type: Boolean }) checked? = false;\n\n /**\n * The value of the radio. This is submitted with the form data as a `value` when the radio is checked.\n * @type {string}\n */\n @property({ type: String }) value: string = 'on';\n\n @query('#input-element')\n private _input!: HTMLInputElement;\n\n private _groupRoot: Document | HTMLFormElement;\n private _internals: ElementInternals;\n\n /**\n * Indicates if the radio button is part of a form.\n * @internal\n */\n public isFormElement = false;\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n this._groupRoot = document;\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n\n this.addEventListener('focus', this._setFocusOnInput);\n\n this.isFormElement = !!this._internals.form;\n\n if (this.isFormElement) {\n this._updateFormValue();\n this._groupRoot = this._internals.form!;\n }\n\n // If the radio has a name then it is part of a group and needs keyboard navigation\n if (this.name) {\n this.addEventListener('keydown', this._handleKeyDown);\n this._SetTabbableRadios();\n }\n }\n\n public disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeEventListener('keydown', this._handleKeyDown);\n this.removeEventListener('focus', this._setFocusOnInput);\n }\n\n private _setFocusOnInput() {\n this._input.focus();\n }\n\n private _getRadioGroup() {\n return Array.from(\n this._groupRoot.querySelectorAll<FhiRadio>(\n `${FhiRadioSelector}[name=\"${this.name}\"]`,\n ),\n );\n }\n\n private _SetTabbableRadios() {\n const radios = this._getRadioGroup();\n\n radios.forEach(radio => {\n // Only the checked radio should be tabbable\n radio.tabIndex = radio.checked ? 0 : -1;\n });\n\n // If none of the radios are checked, make the first one tabbable\n if (!radios.some(radio => radio.checked) && radios.length > 0) {\n radios[0].tabIndex = 0;\n }\n }\n\n public updated(changedProperties: Map<string, unknown>) {\n super.updated(changedProperties);\n\n // make sure the radio input can be programmatically toggeled. e.g by a form reset\n if (changedProperties.has('checked')) {\n this._input.checked = !!this.checked;\n this._updateFormValue();\n\n if (this.checked) {\n this.uncheckGroupMembers();\n }\n }\n\n // update the form value when the value or name input changes and the radio is already checked\n if (changedProperties.has('value') || changedProperties.has('name')) {\n if (this._input.checked) {\n this._updateFormValue();\n }\n }\n }\n\n public formResetCallback(): void {\n const radiosCheckedByDefault = this._getRadioGroup().filter(\n radio => typeof radio.getAttribute('checked') === 'string',\n );\n\n if (radiosCheckedByDefault.pop() === this) {\n this.checked = true;\n }\n\n this._updateFormValue();\n }\n\n private uncheckGroupMembers(): void {\n const radios = this._getRadioGroup();\n\n radios.forEach(radio => {\n if (radio === this) {\n return;\n }\n\n if (radio.isFormElement && this._groupRoot === document) {\n return;\n }\n\n radio.checked = false;\n });\n }\n\n private _updateFormValue(): void {\n if (!this.isFormElement) {\n return;\n }\n\n this._internals.setFormValue(this.checked ? this.value : null);\n }\n\n private _handleChange(event: Event): void {\n this.checked = (event.target as HTMLInputElement).checked;\n\n this.uncheckGroupMembers();\n\n this._updateFormValue();\n\n event.stopPropagation();\n this._dispatchChangeEvent();\n }\n private _handleInput(event: Event): void {\n event.stopPropagation();\n this._dispatchInputEvent();\n }\n\n private _dispatchChangeEvent(): void {\n /**\n * @type {Event} - Standard DOM event with the type `change`.\n * This event is dispatched when the radio is checked or unchecked.\n */\n this.dispatchEvent(new Event('change', { bubbles: true }));\n }\n\n private _dispatchInputEvent(): void {\n /**\n * @type {Event} - Standard DOM event with the type `input`.\n * This event is dispatched when the radio is checked or unchecked.\n */\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n }\n\n private _handleKeyDown(event: KeyboardEvent): void {\n const arrows = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n if (!arrows.includes(event.key)) {\n return;\n }\n\n event.preventDefault();\n\n const radios = this._getRadioGroup();\n\n if (radios.length < 2) {\n return;\n }\n\n const currentIndex = radios.indexOf(this);\n\n const nextIndex = currentIndex;\n let nextRadio: FhiRadio;\n\n if (event.key === 'ArrowUp' || event.key === 'ArrowLeft') {\n nextRadio = radios[nextIndex === 0 ? radios.length - 1 : nextIndex - 1];\n } else {\n nextRadio = radios[nextIndex === radios.length - 1 ? 0 : nextIndex + 1];\n }\n\n nextRadio.focus();\n this.checked = false;\n nextRadio.checked = true;\n this._SetTabbableRadios();\n }\n\n render() {\n return html`\n <label>\n <div class=\"radio-container\">\n <input\n type=\"radio\"\n id=\"input-element\"\n name=\"${ifDefined(this.name)}\"\n value=\"${this.value}\"\n ?checked=${this.checked}\n ?disabled=${this.disabled}\n @change=${this._handleChange}\n @input=${this._handleInput}\n />\n <svg\n class=\"radio-dot\"\n viewBox=\"0 0 18 18\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle r=\"6\" cx=\"9\" cy=\"9\" />\n </svg>\n </div>\n ${this.label}\n </label>\n `;\n }\n\n static styles = css`\n :host {\n --motion-radio-transition: var(--fhi-motion-ease-default)\n var(--fhi-motion-duration-quick);\n\n --color-radio-label: var(--fhi-color-neutral-text-default);\n --color-radio-border: var(--fhi-color-neutral-border-default);\n --color-radio-background: var(--fhi-color-neutral-background-default);\n\n --color-radio-border-hover: var(--fhi-color-accent-border-strong);\n --color-radio-background-hover: var(--fhi-color-accent-background-subtle);\n\n --color-radio-background-active: var(--fhi-color-accent-surface-default);\n\n --color-radio-outline: var(--fhi-color-accent-surface-hover);\n\n --typography-radio-label-font-family: var(--fhi-font-family-default);\n -webkit-font-smoothing: antialiased;\n --typography-radio-label-font-size: var(\n --fhi-typography-body-medium-font-size\n );\n\n --typography-radio-label-font-weight: var(\n --fhi-typography-body-medium-font-weight\n );\n\n --typography-radio-label-line-height: var(\n --fhi-typography-body-medium-line-height\n );\n --typography-radio-label-letter-spacing: var(\n --fhi-typography-body-medium-letter-spacing\n );\n\n --dimension-radio-label-gap: var(--fhi-spacing-050);\n --dimension-radio-width: var(--fhi-spacing-250);\n --dimension-radio-height: var(--fhi-spacing-250);\n --dimension-radio-margin: 0.125rem;\n --dimension-radio-border-width: var(--fhi-dimension-border-width);\n\n --dimension-radio-dot-size: 1.125rem;\n\n /* Checked state */\n --dimension-radio-border-width-checked: var(\n --fhi-dimension-border-width-active\n );\n\n /* Error state */\n --color-radio-border-error: var(--fhi-color-danger-border-default);\n --color-radio-background-error: var(\n --fhi-color-danger-background-default\n );\n\n --color-radio-border-error-hover: var(--fhi-color-danger-border-strong);\n --color-radio-background-error-hover: var(\n --fhi-color-danger-background-subtle\n );\n\n --color-radio-background-error-active: var(\n --fhi-color-danger-surface-default\n );\n\n --color-radio-outline-error: var(--fhi-color-danger-surface-hover);\n\n /* Disabled state */\n --opacity-disabled: var(--fhi-opacity-disabled);\n }\n\n :host {\n display: flex;\n align-items: center;\n width: max-content;\n\n label {\n display: flex;\n position: relative;\n gap: var(--dimension-radio-label-gap);\n color: var(--color-radio-label);\n font-family: var(--typography-radio-label-font-family);\n font-size: var(--typography-radio-label-font-size);\n font-weight: var(--typography-radio-label-font-weight);\n line-height: var(--typography-radio-label-line-height);\n letter-spacing: var(--typography-radio-label-letter-spacing);\n }\n\n .radio-container {\n display: flex;\n position: relative;\n }\n\n input {\n appearance: none;\n margin: var(--dimension-radio-margin);\n width: var(--dimension-radio-width);\n height: var(--dimension-radio-height);\n background-color: var(--color-radio-background);\n border: var(--dimension-radio-border-width) solid\n var(--color-radio-border);\n border-radius: var(--fhi-border-radius-full);\n transition: all var(--motion-radio-transition);\n }\n\n .radio-dot {\n visibility: hidden;\n opacity: 0;\n transition: opacity var(--motion-radio-transition);\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n height: var(--dimension-radio-dot-size);\n width: var(--dimension-radio-dot-size);\n }\n\n input:checked {\n border-width: var(--dimension-radio-border-width-checked);\n ~ .radio-dot {\n circle {\n fill: var(--color-radio-border);\n }\n visibility: visible;\n opacity: 1;\n }\n }\n }\n\n :host([disabled]) {\n opacity: var(--opacity-disabled);\n label,\n input {\n cursor: not-allowed;\n }\n }\n\n :host(:not(:disabled)) {\n input:hover:not(:checked) {\n border-color: var(--color-radio-border-hover);\n background-color: var(--color-radio-background-hover);\n }\n\n input:active:not(:checked) {\n border-color: var(--color-radio-border-hover);\n background-color: var(--color-radio-background-active);\n outline: var(--fhi-dimension-border-width-focus) solid\n var(--color-radio-outline);\n }\n }\n\n :host([status='error']) {\n input {\n border-color: var(--color-radio-border-error);\n background-color: var(--color-radio-background-error);\n }\n\n input:checked {\n ~ .radio-dot {\n circle {\n fill: var(--color-radio-border-error);\n }\n }\n }\n }\n\n :host([status='error']:not(:disabled)) {\n input:hover:not(:checked) {\n border-color: var(--color-radio-border-error-hover);\n background-color: var(--color-radio-background-error-hover);\n }\n\n input:active:not(:checked) {\n border-color: var(--color-radio-border-error-hover);\n background-color: var(--color-radio-background-error-active);\n outline-color: var(--color-radio-outline-error);\n }\n }\n `;\n}\n"],"mappings":";;;AAIA,IAAa,IAAmB,aAczB,IAAA,cAAuB,EAAW;;wBACN;;CAwDjC,cAAc;EAGZ,AAFA,MAAM,gBAlDqC,KAAA,eAQc,KAAA,iBAQG,KAAA,mBAON,mBAMhB,iBAMI,2BAYrB,IAIrB,KAAK,aAAa,KAAK,gBAAgB,GACvC,KAAK,aAAa;CACpB;CAEA,oBAAiC;EAa/B,AAZA,MAAM,kBAAkB,GAExB,KAAK,iBAAiB,SAAS,KAAK,gBAAgB,GAEpD,KAAK,gBAAgB,CAAC,CAAC,KAAK,WAAW,MAEnC,KAAK,kBACP,KAAK,iBAAiB,GACtB,KAAK,aAAa,KAAK,WAAW,OAIhC,KAAK,SACP,KAAK,iBAAiB,WAAW,KAAK,cAAc,GACpD,KAAK,mBAAm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;AA+KrB;GA5aG,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,KAAA,CAAA,MAQzB,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,MAQxC,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,MAOxC,EAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,MAMzC,EAAS,EAAE,MAAM,QAAQ,CAAC,CAAA,GAAA,EAAA,WAAA,WAAA,KAAA,CAAA,MAM1B,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,KAAA,CAAA,MAEzB,EAAM,gBAAgB,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,UA9CxB,EAAc,CAAgB,CAAA,GAAA,CAAA"}
|
package/fhi-tag.js
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
|
-
import {
|
|
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
2
|
import "./fhi-body.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
20
|
-
if (e.length === 0)
|
|
21
|
-
return;
|
|
22
|
-
const o = e[0];
|
|
23
|
-
if (o.nodeType === Node.ELEMENT_NODE && o.tagName.toLowerCase().startsWith("fhi-icon")) {
|
|
24
|
-
const r = o;
|
|
25
|
-
r.setAttribute("size", "1rem"), r.style.marginLeft = "calc(-1 * var(--fhi-spacing-050))";
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
render() {
|
|
29
|
-
return h`
|
|
3
|
+
//#region src/components/fhi-tag/fhi-tag.component.ts
|
|
4
|
+
var o = "fhi-tag", s = class extends r {
|
|
5
|
+
constructor(...e) {
|
|
6
|
+
super(...e), this.color = "neutral", this.variant = "subtle";
|
|
7
|
+
}
|
|
8
|
+
_handleSlotChange(e) {
|
|
9
|
+
let t = e.target.assignedNodes().filter((e) => e.nodeType === Node.ELEMENT_NODE || e.nodeType === Node.TEXT_NODE && e.textContent?.trim());
|
|
10
|
+
if (t.length === 0) return;
|
|
11
|
+
let n = t[0];
|
|
12
|
+
if (n.nodeType === Node.ELEMENT_NODE && n.tagName.toLowerCase().startsWith("fhi-icon")) {
|
|
13
|
+
let e = n;
|
|
14
|
+
e.setAttribute("size", "1rem"), e.style.marginLeft = "calc(-1 * var(--fhi-spacing-050))";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
return a`
|
|
30
19
|
<fhi-body size="small">
|
|
31
20
|
<slot
|
|
32
21
|
class="slot-container"
|
|
@@ -34,9 +23,9 @@ let c = class extends d {
|
|
|
34
23
|
></slot>
|
|
35
24
|
</fhi-body>
|
|
36
25
|
`;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
}
|
|
27
|
+
static {
|
|
28
|
+
this.styles = t`
|
|
40
29
|
:host {
|
|
41
30
|
--fhi-tag-border-color: unset;
|
|
42
31
|
}
|
|
@@ -116,17 +105,16 @@ c.styles = f`
|
|
|
116
105
|
}
|
|
117
106
|
}
|
|
118
107
|
`;
|
|
119
|
-
|
|
120
|
-
n({ type: String, reflect: !0 })
|
|
121
|
-
], c.prototype, "color", 2);
|
|
122
|
-
s([
|
|
123
|
-
n({ type: String, reflect: !0 })
|
|
124
|
-
], c.prototype, "variant", 2);
|
|
125
|
-
c = s([
|
|
126
|
-
u(b)
|
|
127
|
-
], c);
|
|
128
|
-
export {
|
|
129
|
-
c as FhiTag,
|
|
130
|
-
b as FhiTagSelector
|
|
108
|
+
}
|
|
131
109
|
};
|
|
132
|
-
|
|
110
|
+
i([e({
|
|
111
|
+
type: String,
|
|
112
|
+
reflect: !0
|
|
113
|
+
})], s.prototype, "color", void 0), i([e({
|
|
114
|
+
type: String,
|
|
115
|
+
reflect: !0
|
|
116
|
+
})], s.prototype, "variant", void 0), s = i([n(o)], s);
|
|
117
|
+
//#endregion
|
|
118
|
+
export { s as FhiTag, o as FhiTagSelector };
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=fhi-tag.js.map
|
package/fhi-tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhi-tag.js","sources":["../../src/components/fhi-tag/fhi-tag.component.ts"],"sourcesContent":["import { html, css, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport '../typography/fhi-body/fhi-body.component';\n\nexport const FhiTagSelector = 'fhi-tag';\n\n/**\n * ## FHI Tag\n *\n * {@link https://designsystem.fhi.no/?path=/docs/komponenter-tag--docs}\n *\n * The `<fhi-tag>` component is used to create non-interactive tags in accordance with the FHI Design System guidelines.\n *\n * @tag fhi-tag\n * @element fhi-tag\n *\n * @slot - The content of the tag. This should be pure text with, or without, an icon.\n */\n@customElement(FhiTagSelector)\nexport class FhiTag extends LitElement {\n /**\n * Sets the color theme of the tag.\n * @reflect\n * @type {'neutral' | 'accent' | 'success' | 'warning' | 'danger' | 'info'}\n */\n @property({ type: String, reflect: true }) color:\n | 'neutral'\n | 'accent'\n | 'success'\n | 'warning'\n | 'danger'\n | 'info' = 'neutral';\n\n /**\n * Sets the variant of the tag, which determines its visual style.\n * @reflect\n * @type {'subtle' | 'bordered'}\n */\n @property({ type: String, reflect: true })\n variant: 'subtle' | 'bordered' = 'subtle';\n\n private _handleSlotChange(event: Event): void {\n const nodes = (event.target as HTMLSlotElement).assignedNodes();\n\n const validNodes = nodes.filter(\n node =>\n node.nodeType === Node.ELEMENT_NODE ||\n (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()),\n );\n\n if (validNodes.length === 0) {\n return;\n }\n\n const firstNode: Node = validNodes[0];\n\n if (\n firstNode.nodeType === Node.ELEMENT_NODE &&\n (firstNode as Element).tagName.toLowerCase().startsWith('fhi-icon')\n ) {\n const icon = firstNode as HTMLElement;\n\n icon.setAttribute('size', '1rem');\n icon.style.marginLeft = 'calc(-1 * var(--fhi-spacing-050))';\n }\n }\n\n render() {\n return html`\n <fhi-body size=\"small\">\n <slot\n class=\"slot-container\"\n @slotchange=${this._handleSlotChange}\n ></slot>\n </fhi-body>\n `;\n }\n\n static styles = css`\n :host {\n --fhi-tag-border-color: unset;\n }\n\n :host {\n --fhi-tag-border-color: transparent;\n\n display: flex;\n width: fit-content;\n align-items: center;\n\n border: 1px solid var(--fhi-tag-border-color);\n border-radius: var(--fhi-border-radius-050);\n\n height: calc(var(--fhi-spacing-300) - 2px);\n padding: 0 calc(var(--fhi-spacing-100) - 1px);\n\n .slot-container {\n display: flex;\n align-items: center;\n\n gap: var(--fhi-spacing-050);\n }\n\n & fhi-body {\n color: inherit;\n text-wrap: nowrap;\n }\n }\n\n :host([color='neutral']) {\n color: var(--fhi-color-neutral-text-default);\n background-color: var(--fhi-color-neutral-surface-default);\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-neutral-surface-active);\n }\n }\n\n :host([color='accent']) {\n color: var(--fhi-color-accent-text-default);\n background-color: var(--fhi-color-accent-surface-default);\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-accent-surface-active);\n }\n }\n\n :host([color='success']) {\n color: var(--fhi-color-success-text-default);\n background-color: var(--fhi-color-success-surface-default);\n\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-success-surface-active);\n }\n }\n\n :host([color='warning']) {\n color: var(--fhi-color-warning-text-default);\n background-color: var(--fhi-color-warning-surface-default);\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-warning-surface-active);\n }\n }\n\n :host([color='danger']) {\n color: var(--fhi-color-danger-text-default);\n background-color: var(--fhi-color-danger-surface-default);\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-danger-surface-active);\n }\n }\n\n :host([color='info']) {\n color: var(--fhi-color-info-text-default);\n background-color: var(--fhi-color-info-surface-default);\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-info-surface-active);\n }\n }\n `;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"fhi-tag.js","names":[],"sources":["../../src/components/fhi-tag/fhi-tag.component.ts"],"sourcesContent":["import { html, css, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport '../typography/fhi-body/fhi-body.component';\n\nexport const FhiTagSelector = 'fhi-tag';\n\n/**\n * ## FHI Tag\n *\n * {@link https://designsystem.fhi.no/?path=/docs/komponenter-tag--docs}\n *\n * The `<fhi-tag>` component is used to create non-interactive tags in accordance with the FHI Design System guidelines.\n *\n * @tag fhi-tag\n * @element fhi-tag\n *\n * @slot - The content of the tag. This should be pure text with, or without, an icon.\n */\n@customElement(FhiTagSelector)\nexport class FhiTag extends LitElement {\n /**\n * Sets the color theme of the tag.\n * @reflect\n * @type {'neutral' | 'accent' | 'success' | 'warning' | 'danger' | 'info'}\n */\n @property({ type: String, reflect: true }) color:\n | 'neutral'\n | 'accent'\n | 'success'\n | 'warning'\n | 'danger'\n | 'info' = 'neutral';\n\n /**\n * Sets the variant of the tag, which determines its visual style.\n * @reflect\n * @type {'subtle' | 'bordered'}\n */\n @property({ type: String, reflect: true })\n variant: 'subtle' | 'bordered' = 'subtle';\n\n private _handleSlotChange(event: Event): void {\n const nodes = (event.target as HTMLSlotElement).assignedNodes();\n\n const validNodes = nodes.filter(\n node =>\n node.nodeType === Node.ELEMENT_NODE ||\n (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()),\n );\n\n if (validNodes.length === 0) {\n return;\n }\n\n const firstNode: Node = validNodes[0];\n\n if (\n firstNode.nodeType === Node.ELEMENT_NODE &&\n (firstNode as Element).tagName.toLowerCase().startsWith('fhi-icon')\n ) {\n const icon = firstNode as HTMLElement;\n\n icon.setAttribute('size', '1rem');\n icon.style.marginLeft = 'calc(-1 * var(--fhi-spacing-050))';\n }\n }\n\n render() {\n return html`\n <fhi-body size=\"small\">\n <slot\n class=\"slot-container\"\n @slotchange=${this._handleSlotChange}\n ></slot>\n </fhi-body>\n `;\n }\n\n static styles = css`\n :host {\n --fhi-tag-border-color: unset;\n }\n\n :host {\n --fhi-tag-border-color: transparent;\n\n display: flex;\n width: fit-content;\n align-items: center;\n\n border: 1px solid var(--fhi-tag-border-color);\n border-radius: var(--fhi-border-radius-050);\n\n height: calc(var(--fhi-spacing-300) - 2px);\n padding: 0 calc(var(--fhi-spacing-100) - 1px);\n\n .slot-container {\n display: flex;\n align-items: center;\n\n gap: var(--fhi-spacing-050);\n }\n\n & fhi-body {\n color: inherit;\n text-wrap: nowrap;\n }\n }\n\n :host([color='neutral']) {\n color: var(--fhi-color-neutral-text-default);\n background-color: var(--fhi-color-neutral-surface-default);\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-neutral-surface-active);\n }\n }\n\n :host([color='accent']) {\n color: var(--fhi-color-accent-text-default);\n background-color: var(--fhi-color-accent-surface-default);\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-accent-surface-active);\n }\n }\n\n :host([color='success']) {\n color: var(--fhi-color-success-text-default);\n background-color: var(--fhi-color-success-surface-default);\n\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-success-surface-active);\n }\n }\n\n :host([color='warning']) {\n color: var(--fhi-color-warning-text-default);\n background-color: var(--fhi-color-warning-surface-default);\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-warning-surface-active);\n }\n }\n\n :host([color='danger']) {\n color: var(--fhi-color-danger-text-default);\n background-color: var(--fhi-color-danger-surface-default);\n &:host([variant='bordered']) {\n border-color: var(--fhi-color-danger-surface-active);\n }\n }\n\n :host([color='info']) {\n color: var(--fhi-color-info-text-default);\n background-color: var(--fhi-color-info-surface-default);\n &:host([variant='bordered']) {\n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|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const e = t.target.assignedNodes()[0];
|
|
71
|
-
if (e.nodeType === Node.ELEMENT_NODE && e.tagName.toLowerCase().startsWith("fhi-icon")) {
|
|
72
|
-
const i = e;
|
|
73
|
-
this._input.style.paddingRight = "var(--fhi-spacing-500)", i.setAttribute("size", "1.5rem");
|
|
74
|
-
} else
|
|
75
|
-
console.error(
|
|
76
|
-
"Ivalid slot input. Fhi-text-input only accepts FHI Designsystem icons."
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
render() {
|
|
80
|
-
return s`
|
|
81
|
-
${this.label && s`<label for="input-element">${this.label}</label>`}
|
|
82
|
-
${this.helpText ? s`<p class="help-text">${this.helpText}</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-text-input/fhi-text-input.component.ts
|
|
4
|
+
var c = "fhi-text-input", l = class extends i {
|
|
5
|
+
static {
|
|
6
|
+
this.formAssociated = !0;
|
|
7
|
+
}
|
|
8
|
+
get name() {
|
|
9
|
+
return this._name;
|
|
10
|
+
}
|
|
11
|
+
set name(e) {
|
|
12
|
+
let t = this._name;
|
|
13
|
+
this._name = e, this.requestUpdate("name", t), this._internals.setFormValue(this._value);
|
|
14
|
+
}
|
|
15
|
+
get value() {
|
|
16
|
+
return this._value;
|
|
17
|
+
}
|
|
18
|
+
set value(e) {
|
|
19
|
+
let t = this._value;
|
|
20
|
+
this._value = e, this.requestUpdate("value", t), this._internals.setFormValue(this._value);
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
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();
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
super.connectedCallback(), this._internals.setFormValue(this.value);
|
|
27
|
+
}
|
|
28
|
+
_dispatchChangeEvent() {
|
|
29
|
+
this.dispatchEvent(new Event("change", {
|
|
30
|
+
bubbles: !0,
|
|
31
|
+
composed: !0
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
_dispatchInputEvent() {
|
|
35
|
+
this.dispatchEvent(new Event("input", {
|
|
36
|
+
bubbles: !0,
|
|
37
|
+
composed: !0
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
handleChange(e) {
|
|
41
|
+
e.stopPropagation(), this._dispatchChangeEvent();
|
|
42
|
+
}
|
|
43
|
+
handleInput(e) {
|
|
44
|
+
this.value = this._input.value, this._internals.setFormValue(this.value), e.stopPropagation(), this._dispatchInputEvent();
|
|
45
|
+
}
|
|
46
|
+
handleKeyDown(e) {
|
|
47
|
+
e.key === "Enter" && this._internals.form && this._internals.form.requestSubmit();
|
|
48
|
+
}
|
|
49
|
+
formResetCallback() {
|
|
50
|
+
this.value = this.getAttribute("value") || "", this._internals.setFormValue(this.value);
|
|
51
|
+
}
|
|
52
|
+
_handleStartSlotChange(e) {
|
|
53
|
+
let t = e.target.assignedNodes()[0];
|
|
54
|
+
if (t.nodeType === Node.ELEMENT_NODE && t.tagName.toLowerCase().startsWith("fhi-icon")) {
|
|
55
|
+
let e = t;
|
|
56
|
+
this._input.style.paddingLeft = "var(--fhi-spacing-500)", e.setAttribute("size", "1.5rem");
|
|
57
|
+
} else console.error("Ivalid slot input. Fhi-text-input only accepts FHI Designsystem icons.");
|
|
58
|
+
}
|
|
59
|
+
_handleEndSlotChange(e) {
|
|
60
|
+
let t = e.target.assignedNodes()[0];
|
|
61
|
+
if (t.nodeType === Node.ELEMENT_NODE && t.tagName.toLowerCase().startsWith("fhi-icon")) {
|
|
62
|
+
let e = t;
|
|
63
|
+
this._input.style.paddingRight = "var(--fhi-spacing-500)", e.setAttribute("size", "1.5rem");
|
|
64
|
+
} else console.error("Ivalid slot input. Fhi-text-input only accepts FHI Designsystem icons.");
|
|
65
|
+
}
|
|
66
|
+
render() {
|
|
67
|
+
return o`
|
|
68
|
+
${this.label && o`<label for="input-element">${this.label}</label>`}
|
|
69
|
+
${this.helpText ? o`<p class="help-text">${this.helpText}</p>` : ""}
|
|
83
70
|
<div class="input-container">
|
|
84
71
|
<input
|
|
85
72
|
id="input-element"
|
|
86
|
-
name=${
|
|
87
|
-
placeholder=${
|
|
73
|
+
name=${s(this.name)}
|
|
74
|
+
placeholder=${s(this.placeholder)}
|
|
88
75
|
.value=${this.value}
|
|
89
76
|
?readonly=${this.readonly}
|
|
90
77
|
?disabled=${this.disabled}
|
|
@@ -95,12 +82,11 @@ let o = class extends u {
|
|
|
95
82
|
<slot name="start" @slotchange=${this._handleStartSlotChange}> </slot>
|
|
96
83
|
<slot name="end" @slotchange=${this._handleEndSlotChange}> </slot>
|
|
97
84
|
</div>
|
|
98
|
-
${this.message ?
|
|
85
|
+
${this.message ? o`<p class="message">${this.message}</p>` : ""}
|
|
99
86
|
`;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
o.styles = c`
|
|
87
|
+
}
|
|
88
|
+
static {
|
|
89
|
+
this.styles = t`
|
|
104
90
|
:host {
|
|
105
91
|
--fhi-text-input-placeholder-color: unset;
|
|
106
92
|
}
|
|
@@ -267,41 +253,25 @@ o.styles = c`
|
|
|
267
253
|
}
|
|
268
254
|
}
|
|
269
255
|
`;
|
|
270
|
-
|
|
271
|
-
r({ type: String })
|
|
272
|
-
], o.prototype, "label", 2);
|
|
273
|
-
a([
|
|
274
|
-
r({ type: String })
|
|
275
|
-
], o.prototype, "message", 2);
|
|
276
|
-
a([
|
|
277
|
-
r({ type: String, attribute: "help-text" })
|
|
278
|
-
], o.prototype, "helpText", 2);
|
|
279
|
-
a([
|
|
280
|
-
r({ type: String })
|
|
281
|
-
], o.prototype, "placeholder", 2);
|
|
282
|
-
a([
|
|
283
|
-
r({ type: String, reflect: !0 })
|
|
284
|
-
], o.prototype, "status", 2);
|
|
285
|
-
a([
|
|
286
|
-
r({ type: Boolean, reflect: !0 })
|
|
287
|
-
], o.prototype, "readonly", 2);
|
|
288
|
-
a([
|
|
289
|
-
r({ type: Boolean, reflect: !0 })
|
|
290
|
-
], o.prototype, "disabled", 2);
|
|
291
|
-
a([
|
|
292
|
-
g("#input-element")
|
|
293
|
-
], o.prototype, "_input", 2);
|
|
294
|
-
a([
|
|
295
|
-
r({ type: String, reflect: !0 })
|
|
296
|
-
], o.prototype, "name", 1);
|
|
297
|
-
a([
|
|
298
|
-
r({ type: String })
|
|
299
|
-
], o.prototype, "value", 1);
|
|
300
|
-
o = a([
|
|
301
|
-
f(y)
|
|
302
|
-
], o);
|
|
303
|
-
export {
|
|
304
|
-
o as FhiTextInput,
|
|
305
|
-
y as FhiTextInputSelector
|
|
256
|
+
}
|
|
306
257
|
};
|
|
307
|
-
|
|
258
|
+
a([e({ type: String })], l.prototype, "label", void 0), a([e({ type: String })], l.prototype, "message", void 0), a([e({
|
|
259
|
+
type: String,
|
|
260
|
+
attribute: "help-text"
|
|
261
|
+
})], l.prototype, "helpText", void 0), a([e({ type: String })], l.prototype, "placeholder", void 0), a([e({
|
|
262
|
+
type: String,
|
|
263
|
+
reflect: !0
|
|
264
|
+
})], l.prototype, "status", void 0), a([e({
|
|
265
|
+
type: Boolean,
|
|
266
|
+
reflect: !0
|
|
267
|
+
})], l.prototype, "readonly", void 0), a([e({
|
|
268
|
+
type: Boolean,
|
|
269
|
+
reflect: !0
|
|
270
|
+
})], l.prototype, "disabled", void 0), a([r("#input-element")], l.prototype, "_input", void 0), a([e({
|
|
271
|
+
type: String,
|
|
272
|
+
reflect: !0
|
|
273
|
+
})], l.prototype, "name", null), a([e({ type: String })], l.prototype, "value", null), l = a([n(c)], l);
|
|
274
|
+
//#endregion
|
|
275
|
+
export { l as FhiTextInput, c as FhiTextInputSelector };
|
|
276
|
+
|
|
277
|
+
//# 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 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 private _handleStartSlotChange(event: Event): void {\n const iconNode: Node = (event.target as HTMLSlotElement).assignedNodes()[0];\n if (\n iconNode.nodeType === Node.ELEMENT_NODE &&\n (iconNode as Element).tagName.toLowerCase().startsWith('fhi-icon')\n ) {\n const icon = iconNode as HTMLElement;\n this._input.style.paddingLeft = 'var(--fhi-spacing-500)';\n icon.setAttribute('size', '1.5rem');\n } else {\n console.error(\n 'Ivalid slot input. Fhi-text-input only accepts FHI Designsystem icons.',\n );\n }\n }\n\n private _handleEndSlotChange(event: Event): void {\n const iconNode: Node = (event.target as HTMLSlotElement).assignedNodes()[0];\n\n if (\n iconNode.nodeType === Node.ELEMENT_NODE &&\n (iconNode as Element).tagName.toLowerCase().startsWith('fhi-icon')\n ) {\n const icon = iconNode as HTMLElement;\n this._input.style.paddingRight = 'var(--fhi-spacing-500)';\n icon.setAttribute('size', '1.5rem');\n } else {\n console.error(\n 'Ivalid slot input. Fhi-text-input only accepts FHI Designsystem icons.',\n );\n }\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 <div class=\"input-container\">\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 <slot name=\"start\" @slotchange=${this._handleStartSlotChange}> </slot>\n <slot name=\"end\" @slotchange=${this._handleEndSlotChange}> </slot>\n </div>\n ${this.message ? html`<p class=\"message\">${this.message}</p>` : ''}\n `;\n }\n\n static styles = css`\n :host {\n --fhi-text-input-placeholder-color: unset;\n }\n\n :host {\n display: flex;\n flex-direction: column;\n font-family: var(--fhi-font-family-default);\n -webkit-font-smoothing: antialiased;\n\n --fhi-text-input-placeholder-color: var(--fhi-color-neutral-base-default);\n\n label {\n font-weight: var(--fhi-typography-label-small-font-weight);\n font-size: var(--fhi-typography-label-small-font-size);\n line-height: var(--fhi-typography-label-small-line-height);\n letter-spacing: var(--fhi-typography-label-small-letter-spacing);\n color: var(--fhi-color-neutral-text-default);\n margin: 0 0 var(--fhi-spacing-050) 0;\n }\n\n label:has(+ p) {\n margin: 0 0 0 0;\n }\n\n input {\n box-sizing: border-box;\n flex: 1 1 auto;\n height: var(--fhi-spacing-500);\n border: var(--fhi-dimension-border-width) solid\n var(--fhi-color-neutral-border-default);\n border-radius: var(--fhi-border-radius-050);\n padding: 0 var(--fhi-spacing-150) 0 var(--fhi-spacing-150);\n color: var(--fhi-color-neutral-text-default);\n background-color: var(--fhi-color-neutral-background-default);\n font-family: var(--fhi-font-family-default);\n font-weight: var(--fhi-typography-body-medium-font-weight);\n font-size: var(--fhi-typography-body-medium-font-size);\n line-height: var(--fhi-typography-body-medium-line-height);\n letter-spacing: var(--fhi-typography-body-medium-letter-spacing);\n transition: all var(--fhi-motion-ease-default)\n var(--fhi-motion-duration-quick);\n &:hover {\n border-color: var(--fhi-color-accent-border-default);\n background-color: var(--fhi-color-accent-background-subtle);\n }\n &:focus {\n border-color: var(--fhi-color-accent-border-strong);\n background-color: var(--fhi-color-accent-background-default);\n }\n &::placeholder {\n color: var(--fhi-text-input-placeholder-color);\n }\n }\n\n slot[name='start'] {\n color: var(--fhi-color-neutral-text-subtle);\n }\n\n input:not([disabled]):not([readonly]):hover ~ slot[name='start'] {\n color: var(--fhi-color-accent-text-subtle);\n }\n input:not([disabled]):not([readonly]):active ~ slot[name='start'],\n input:not([disabled]):not([readonly]):focus ~ slot[name='start'] {\n color: var(--fhi-color-accent-text-default);\n }\n\n .message {\n margin: var(--fhi-spacing-050) 0 0 0;\n color: var(--fhi-color-neutral-text-default);\n font-weight: var(--fhi-typography-body-small-font-weight);\n font-size: var(--fhi-typography-body-small-font-size);\n line-height: var(--fhi-typography-body-small-line-height);\n letter-spacing: var(--fhi-typography-body-small-letter-spacing);\n }\n\n .help-text {\n color: var(--fhi-color-neutral-text-subtle);\n font-weight: var(--fhi-typography-body-small-font-weight);\n font-size: var(--fhi-typography-body-small-font-size);\n line-height: var(--fhi-typography-body-small-line-height);\n letter-spacing: var(--fhi-typography-body-small-letter-spacing);\n margin: 0 0 var(--fhi-spacing-050) 0;\n }\n\n .input-container {\n position: relative;\n display: flex;\n }\n\n slot[name='start'] {\n display: block;\n position: absolute;\n left: 0;\n top: 50%;\n transform: translateY(-50%);\n margin-left: 8px;\n height: fit-content;\n pointer-events: none;\n }\n\n slot[name='end'] {\n display: block;\n position: absolute;\n right: 0;\n top: 50%;\n transform: translateY(-50%);\n margin-right: 8px;\n height: fit-content;\n pointer-events: none;\n color: var(--fhi-color-neutral-text-subtle);\n }\n }\n\n :host([disabled]) {\n opacity: var(--fhi-opacity-disabled);\n cursor: not-allowed;\n label,\n input {\n cursor: not-allowed;\n }\n input {\n &:hover {\n border-color: var(--fhi-color-neutral-border-default);\n background-color: var(--fhi-color-neutral-background-default);\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(--fhi-dimension-border-width) solid\n var(--fhi-color-neutral-border-default);\n }\n }\n\n :host([status='error']:not([disabled]):not([readonly])) {\n label {\n color: var(--fhi-color-danger-text-default);\n }\n input {\n border-color: var(--fhi-color-danger-border-strong);\n background-color: var(--fhi-color-danger-background-default);\n color: var(--fhi-color-danger-text-default);\n }\n .message {\n color: var(--fhi-color-danger-text-subtle);\n }\n .help-text {\n color: var(--fhi-color-danger-text-default);\n }\n slot[name='start'] {\n color: var(--fhi-color-danger-text-subtle);\n }\n\n input:hover ~ slot[name='start'] {\n color: var(--fhi-color-danger-text-subtle);\n }\n input:focus ~ slot[name='start'] {\n color: var(--fhi-color-danger-text-subtle);\n }\n }\n `;\n}\n"],"names":["FhiTextInputSelector","FhiTextInput","LitElement","newName","oldName","newValue","oldValue","event","iconNode","icon","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,EAC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AAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA9Bfb,EA8BiB,WAAA,eAAA,CAAA;AASeY,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAvC9Bb,EAuCgC,WAAA,UAAA,CAAA;AAOCY,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA9C/Bb,EA8CiC,WAAA,YAAA,CAAA;AAOAY,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GArD/Bb,EAqDiC,WAAA,YAAA,CAAA;AAGpCY,EAAA;AAAA,EADPE,EAAM,gBAAgB;AAAA,GAvDZd,EAwDH,WAAA,UAAA,CAAA;AAcJY,EAAA;AAAA,EADHC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GArE9Bb,EAsEP,WAAA,QAAA,CAAA;AAuBAY,EAAA;AAAA,EADHC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA5Ffb,EA6FP,WAAA,SAAA,CAAA;AA7FOA,IAANY,EAAA;AAAA,EADNG,EAAchB,CAAoB;AAAA,GACtBC,CAAA;"}
|
|
1
|
+
{"version":3,"file":"fhi-text-input.js","names":[],"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 private _handleStartSlotChange(event: Event): void {\n const iconNode: Node = (event.target as HTMLSlotElement).assignedNodes()[0];\n if (\n iconNode.nodeType === Node.ELEMENT_NODE &&\n (iconNode as Element).tagName.toLowerCase().startsWith('fhi-icon')\n ) {\n const icon = iconNode as HTMLElement;\n this._input.style.paddingLeft = 'var(--fhi-spacing-500)';\n icon.setAttribute('size', '1.5rem');\n } else {\n console.error(\n 'Ivalid slot input. Fhi-text-input only accepts FHI Designsystem icons.',\n );\n }\n }\n\n private _handleEndSlotChange(event: Event): void {\n const iconNode: Node = (event.target as HTMLSlotElement).assignedNodes()[0];\n\n if (\n iconNode.nodeType === Node.ELEMENT_NODE &&\n (iconNode as Element).tagName.toLowerCase().startsWith('fhi-icon')\n ) {\n const icon = iconNode as HTMLElement;\n this._input.style.paddingRight = 'var(--fhi-spacing-500)';\n icon.setAttribute('size', '1.5rem');\n } else {\n console.error(\n 'Ivalid slot input. Fhi-text-input only accepts FHI Designsystem icons.',\n );\n }\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 <div class=\"input-container\">\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 <slot name=\"start\" @slotchange=${this._handleStartSlotChange}> </slot>\n <slot name=\"end\" @slotchange=${this._handleEndSlotChange}> </slot>\n </div>\n ${this.message ? html`<p class=\"message\">${this.message}</p>` : ''}\n `;\n }\n\n static styles = css`\n :host {\n --fhi-text-input-placeholder-color: unset;\n }\n\n :host {\n display: flex;\n flex-direction: column;\n font-family: var(--fhi-font-family-default);\n -webkit-font-smoothing: antialiased;\n\n --fhi-text-input-placeholder-color: var(--fhi-color-neutral-base-default);\n\n label {\n font-weight: var(--fhi-typography-label-small-font-weight);\n font-size: var(--fhi-typography-label-small-font-size);\n line-height: var(--fhi-typography-label-small-line-height);\n letter-spacing: var(--fhi-typography-label-small-letter-spacing);\n color: var(--fhi-color-neutral-text-default);\n margin: 0 0 var(--fhi-spacing-050) 0;\n }\n\n label:has(+ p) {\n margin: 0 0 0 0;\n }\n\n input {\n box-sizing: border-box;\n flex: 1 1 auto;\n height: var(--fhi-spacing-500);\n border: var(--fhi-dimension-border-width) solid\n var(--fhi-color-neutral-border-default);\n border-radius: var(--fhi-border-radius-050);\n padding: 0 var(--fhi-spacing-150) 0 var(--fhi-spacing-150);\n color: var(--fhi-color-neutral-text-default);\n background-color: var(--fhi-color-neutral-background-default);\n font-family: var(--fhi-font-family-default);\n font-weight: var(--fhi-typography-body-medium-font-weight);\n font-size: var(--fhi-typography-body-medium-font-size);\n line-height: var(--fhi-typography-body-medium-line-height);\n letter-spacing: var(--fhi-typography-body-medium-letter-spacing);\n transition: all var(--fhi-motion-ease-default)\n var(--fhi-motion-duration-quick);\n &:hover {\n border-color: var(--fhi-color-accent-border-default);\n background-color: var(--fhi-color-accent-background-subtle);\n }\n &:focus {\n border-color: var(--fhi-color-accent-border-strong);\n background-color: var(--fhi-color-accent-background-default);\n }\n &::placeholder {\n color: var(--fhi-text-input-placeholder-color);\n }\n }\n\n slot[name='start'] {\n color: var(--fhi-color-neutral-text-subtle);\n }\n\n input:not([disabled]):not([readonly]):hover ~ slot[name='start'] {\n color: var(--fhi-color-accent-text-subtle);\n }\n input:not([disabled]):not([readonly]):active ~ slot[name='start'],\n input:not([disabled]):not([readonly]):focus ~ slot[name='start'] {\n color: var(--fhi-color-accent-text-default);\n }\n\n .message {\n margin: var(--fhi-spacing-050) 0 0 0;\n color: var(--fhi-color-neutral-text-default);\n font-weight: var(--fhi-typography-body-small-font-weight);\n font-size: var(--fhi-typography-body-small-font-size);\n line-height: var(--fhi-typography-body-small-line-height);\n letter-spacing: var(--fhi-typography-body-small-letter-spacing);\n }\n\n .help-text {\n color: var(--fhi-color-neutral-text-subtle);\n font-weight: var(--fhi-typography-body-small-font-weight);\n font-size: var(--fhi-typography-body-small-font-size);\n line-height: var(--fhi-typography-body-small-line-height);\n letter-spacing: var(--fhi-typography-body-small-letter-spacing);\n margin: 0 0 var(--fhi-spacing-050) 0;\n }\n\n .input-container {\n position: relative;\n display: flex;\n }\n\n slot[name='start'] {\n display: block;\n position: absolute;\n left: 0;\n top: 50%;\n transform: translateY(-50%);\n margin-left: 8px;\n height: fit-content;\n pointer-events: none;\n }\n\n slot[name='end'] {\n display: block;\n position: absolute;\n right: 0;\n top: 50%;\n transform: translateY(-50%);\n margin-right: 8px;\n height: fit-content;\n pointer-events: none;\n color: var(--fhi-color-neutral-text-subtle);\n }\n }\n\n :host([disabled]) {\n opacity: var(--fhi-opacity-disabled);\n cursor: not-allowed;\n label,\n input {\n cursor: not-allowed;\n }\n input {\n &:hover {\n border-color: var(--fhi-color-neutral-border-default);\n background-color: var(--fhi-color-neutral-background-default);\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(--fhi-dimension-border-width) solid\n var(--fhi-color-neutral-border-default);\n }\n }\n\n :host([status='error']:not([disabled]):not([readonly])) {\n label {\n color: var(--fhi-color-danger-text-default);\n }\n input {\n border-color: var(--fhi-color-danger-border-strong);\n background-color: var(--fhi-color-danger-background-default);\n color: var(--fhi-color-danger-text-default);\n }\n .message {\n color: var(--fhi-color-danger-text-subtle);\n }\n .help-text {\n color: var(--fhi-color-danger-text-default);\n }\n slot[name='start'] {\n color: var(--fhi-color-danger-text-subtle);\n }\n\n input:hover ~ slot[name='start'] {\n color: var(--fhi-color-danger-text-subtle);\n }\n input:focus ~ slot[name='start'] {\n color: var(--fhi-color-danger-text-subtle);\n }\n }\n `;\n}\n"],"mappings":";;;AAIA,IAAa,IAAuB,kBAc7B,IAAA,cAA2B,EAAW;;wBACV;;CAoEjC,IACI,OAA2B;EAC7B,OAAO,KAAK;CACd;CACA,IAAI,KAAK,GAAiB;EACxB,IAAM,IAAU,KAAK;EAGrB,AAFA,KAAK,QAAQ,GACb,KAAK,cAAc,QAAQ,CAAO,GAClC,KAAK,WAAW,aAAa,KAAK,MAAM;CAC1C;CAcA,IACI,QAAgB;EAClB,OAAO,KAAK;CACd;CAEA,IAAI,MAAM,GAAkB;EAC1B,IAAM,IAAW,KAAK;EAGtB,AAFA,KAAK,SAAS,GACd,KAAK,cAAc,SAAS,CAAQ,GACpC,KAAK,WAAW,aAAa,KAAK,MAAM;CAC1C;CAIA,cAAc;EAEZ,AADA,MAAM,gBAnGqC,KAAA,kBAOE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MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,MAOzC,EAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,MAEzC,EAAM,gBAAgB,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,MActB,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,IAAA,MAuBxC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,IAAA,UA7F3B,EAAc,CAAoB,CAAA,GAAA,CAAA"}
|
package/fhi-title.js
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
new TypeError(
|
|
18
|
-
`The level property must be set to a number between 1 and 6. Current value: ${this.level}`
|
|
19
|
-
)
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
t.has("color") && (this.style.color = typeof this.color == "string" ? this.color : "currentcolor");
|
|
23
|
-
}
|
|
24
|
-
render() {
|
|
25
|
-
const t = `
|
|
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
|
+
import { t as o } from "./unsafe-html-CBTN3162.js";
|
|
3
|
+
//#region src/components/typography/fhi-title/fhi-title.component.ts
|
|
4
|
+
var s = "fhi-title", c = class extends r {
|
|
5
|
+
constructor(...e) {
|
|
6
|
+
super(...e), this.size = "medium", this.color = "currentcolor";
|
|
7
|
+
}
|
|
8
|
+
updated(e) {
|
|
9
|
+
if (super.updated(e), e.has("level")) {
|
|
10
|
+
let e = Number(this.level);
|
|
11
|
+
(isNaN(e) || e < 1 || e > 6) && console.error(/* @__PURE__ */ TypeError(`The level property must be set to a number between 1 and 6. Current value: ${this.level}`));
|
|
12
|
+
}
|
|
13
|
+
e.has("color") && (this.style.color = typeof this.color == "string" ? this.color : "currentcolor");
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
return a`${o(`
|
|
26
17
|
<h${this.level} class="title">
|
|
27
18
|
<slot></slot>
|
|
28
19
|
</h${this.level}>
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
l.styles = n`
|
|
20
|
+
`)}`;
|
|
21
|
+
}
|
|
22
|
+
static {
|
|
23
|
+
this.styles = t`
|
|
34
24
|
:host {
|
|
35
25
|
display: block;
|
|
36
26
|
contain: layout;
|
|
@@ -68,20 +58,13 @@ l.styles = n`
|
|
|
68
58
|
}
|
|
69
59
|
}
|
|
70
60
|
`;
|
|
71
|
-
|
|
72
|
-
p({ type: String, reflect: !0 })
|
|
73
|
-
], l.prototype, "size", 2);
|
|
74
|
-
o([
|
|
75
|
-
p({ type: String })
|
|
76
|
-
], l.prototype, "color", 2);
|
|
77
|
-
o([
|
|
78
|
-
p({ type: Number })
|
|
79
|
-
], l.prototype, "level", 2);
|
|
80
|
-
l = o([
|
|
81
|
-
y(u)
|
|
82
|
-
], l);
|
|
83
|
-
export {
|
|
84
|
-
l as FhiTitle,
|
|
85
|
-
u as FhiTitleSelector
|
|
61
|
+
}
|
|
86
62
|
};
|
|
87
|
-
|
|
63
|
+
i([e({
|
|
64
|
+
type: String,
|
|
65
|
+
reflect: !0
|
|
66
|
+
})], c.prototype, "size", void 0), i([e({ type: String })], c.prototype, "color", void 0), i([e({ type: Number })], c.prototype, "level", void 0), c = i([n(s)], c);
|
|
67
|
+
//#endregion
|
|
68
|
+
export { c as FhiTitle, s as FhiTitleSelector };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=fhi-title.js.map
|