@felleslosninger/minid-elements 0.1.4 → 0.1.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"alert.component.d.ts","sourceRoot":"","sources":["../../src/components/alert.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAIhD,OAAO,uBAAuB,CAAC;AAS/B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,UAAU,CAAC;KACzB;CACF;;AAMD;;;;;;;;;;;;;GAaG;AACH,qBACa,UAAW,SAAQ,eAAkB;IAChD,OAAO,CAAC,eAAe,CAAC,CAAS;IACjC,OAAO,CAAC,qBAAqB,CAAC,CAAS;IAGvC,OAAO,CAAC,IAAI,CAAe;IAE3B;;;OAGG;IAEH,IAAI,UAAS;IAEb;;OAEG;IAEH,QAAQ,UAAS;IAEjB;;;;OAIG;IAEH,QAAQ,SAAY;IAEpB;;OAEG;IAEH,QAAQ,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAU;IAE7D;;OAEG;IAEH,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAQ;IAEhC;;OAEG;IAEH,QAAQ,UAAS;IAEjB;;;;;OAKG;IAEH,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAS;IAGjD,OAAO,CAAC,aAAa,CAAiB;IAGtC,OAAO,CAAC,mBAAmB,CAAC,CAI1B;IAEF,YAAY;IAIZ,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,cAAc;IAahB,gBAAgB;IAwCtB,oBAAoB;IAIpB;;OAEG;IACG,IAAI;IASV;;OAEG;IACG,IAAI;IASV;;;;OAIG;IACG,KAAK,CACT,OAAO,EAAE,UAAU,CAAC,qBAAqB,CAAC,EAC1C,QAAQ,CAAC,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CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,EACjC,QAAQ,UAAO;IA+DR,MAAM;CAsEhB"}
@@ -182,7 +182,9 @@ let MinidAlert = class extends styled(LitElement) {
182
182
  @mouseenter=${this.pauseAutoHide}
183
183
  @mouseleave=${this.resumeAutoHide}
184
184
  >
185
- <div class="${classMap({ "grid-cols-[1fr_auto]": this.closable })} grid">
185
+ <div
186
+ class="${classMap({ "grid-cols-[1fr_auto]": this.closable })} grid"
187
+ >
186
188
  <div aria-live="${this.arialive}">
187
189
  <slot>
188
190
  ${!this.notificationContent?.title ? nothing : html`<h2 class="text-heading-xs">
@@ -218,7 +220,7 @@ ${this.notificationContent?.details}</pre
218
220
  "hover:bg-info-surface-hover": info,
219
221
  "hover:bg-success-surface-hover": success,
220
222
  "hover:bg-warning-surface-hover": warning
221
- })} flex rounded p-2 self-start justify-self-end"
223
+ })} flex self-start justify-self-end rounded p-2"
222
224
  @click="${this.hide}"
223
225
  aria-label="Dismiss alert"
224
226
  >
@@ -1 +1 @@
1
- {"version":3,"file":"alert.js","sources":["../../src/components/alert.component.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styled } from '../mixins/tailwind.mixin.ts';\nimport './icon/icon.component';\nimport { watch } from '../internal/watch';\nimport {\n getAnimation,\n setDefaultAnimation,\n} from '../utilities/animation-registry';\nimport { waitForEvent } from '../internal/event';\nimport { animateTo, stopAnimations } from '../internal/animate';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-alert': MinidAlert;\n }\n}\n\nconst toastStack = Object.assign(document.createElement('div'), {\n className: 'mid-toast-stack',\n});\n\n/**\n * Alerts need to have the `open` attribute to be displayed\n * @csspart base - Select the base of the alert\n *\n * @event mid-show - Emitted when the alert opens.\n * @event mid-after-show - Emitted after the alert opens and all animations are complete.\n * @event mid-hide - Emitted when the alert closes.\n * @event mid-after-hide - Emitted after the alert closes and all animations are complete.\n *\n * @slot -- The default slot for the content of the alert\n *\n * @animation alert.show - The animation to use when showing the alert.\n * @animation alert.hide - The animation to use when hiding the alert.\n */\n@customElement('mid-alert')\nexport class MinidAlert extends styled(LitElement) {\n private autoHideTimeout?: number;\n private remainingTimeInterval?: number;\n\n @query('[part~=\"base\"]')\n private base!: HTMLElement;\n\n /**\n * Indicates whether or not the alert is open. You can toggle this attribute to show and hide the alert, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the alert's open state.\n */\n @property({ type: Boolean, reflect: true })\n open = false;\n\n /**\n * Enables a close button that allows the user to dismiss the alert.\n */\n @property({ type: Boolean, reflect: true })\n closable = false;\n\n /**\n * The length of time, in milliseconds, the alert will show before closing itself. If the user interacts with\n * the alert before it closes (e.g. moves the mouse over it), the timer will restart. Defaults to `Infinity`, meaning\n * the alert will not close on its own.\n */\n @property({ type: Number })\n duration = Infinity;\n\n /**\n * Sets color and icon according to severity\n */\n @property({ reflect: true })\n severity: 'warning' | 'info' | 'danger' | 'success' = 'info';\n\n /**\n * Sets size of icon, padding and font-size.\n */\n @property({ reflect: true })\n size: 'sm' | 'md' | 'lg' = 'md';\n\n /**\n * Adds a shadow to elevate the component\n */\n @property({ type: Boolean })\n elevated = false;\n\n /**\n * Sets the `aria-live` attribute on the alert host element.\n * Prefer wrapping the alert in a `role=\"alert\"` or `aria-live` container instead.\n * Use `\"polite\"` for non-urgent updates and `\"assertive\"` for time-sensitive ones.\n * Defaults to `\"off\"`.\n */\n @property({ reflect: true })\n arialive: 'polite' | 'assertive' | 'off' = 'off';\n\n @state()\n private remainingTime = this.duration;\n\n @state()\n private notificationContent?: {\n title?: string;\n message: string;\n details?: string;\n };\n\n firstUpdated() {\n this.base.hidden = !this.open;\n }\n\n private restartAutoHide() {\n clearTimeout(this.autoHideTimeout);\n clearInterval(this.remainingTimeInterval);\n if (this.open && this.duration < Infinity) {\n this.autoHideTimeout = window.setTimeout(\n () => this.hide(),\n this.duration\n );\n this.remainingTime = this.duration;\n this.remainingTimeInterval = window.setInterval(() => {\n this.remainingTime -= 100;\n }, 100);\n }\n }\n\n private pauseAutoHide() {\n clearTimeout(this.autoHideTimeout);\n clearInterval(this.remainingTimeInterval);\n }\n\n private resumeAutoHide() {\n if (this.duration < Infinity) {\n this.autoHideTimeout = window.setTimeout(\n () => this.hide(),\n this.remainingTime\n );\n this.remainingTimeInterval = window.setInterval(() => {\n this.remainingTime -= 100;\n }, 100);\n }\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.dispatchEvent(\n new Event('mid-show', { composed: true, bubbles: true })\n );\n\n if (this.duration < Infinity) {\n this.restartAutoHide();\n }\n\n await stopAnimations(this.base);\n this.base.hidden = false;\n const { keyframes, options } = getAnimation(this, 'alert.show');\n await animateTo(this.base, keyframes, options);\n\n this.dispatchEvent(\n new Event('mid-after-show', { composed: true, bubbles: true })\n );\n } else {\n // Hide\n this.dispatchEvent(\n new Event('mid-hide', { composed: true, bubbles: true })\n );\n\n clearTimeout(this.autoHideTimeout);\n clearInterval(this.remainingTimeInterval);\n\n await stopAnimations(this.base);\n const { keyframes, options } = getAnimation(this, 'alert.hide');\n await animateTo(this.base, keyframes, options);\n this.base.hidden = true;\n\n this.dispatchEvent(\n new Event('mid-after-hide', { composed: true, bubbles: true })\n );\n }\n }\n\n @watch('duration')\n handleDurationChange() {\n this.restartAutoHide();\n }\n\n /**\n * Shows the alert.\n */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'mid-after-show');\n }\n\n /**\n * Hides the alert\n */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'mid-after-hide');\n }\n\n /**\n * Displays the alert as a toast notification. This will move the alert out of its position in the DOM and, when\n * dismissed, it will be removed from the DOM completely. By storing a reference to the alert, you can reuse it by\n * calling this method again. The returned promise will resolve after the alert is hidden.\n */\n async toast(\n content: MinidAlert['notificationContent'],\n duration?: number,\n severity?: MinidAlert['severity'],\n closable = true\n ) {\n return new Promise<void>((resolve) => {\n if (toastStack.parentElement === null) {\n document.body.append(toastStack);\n }\n\n if (content) {\n this.notificationContent = content;\n }\n\n if (severity) {\n this.severity = severity;\n }\n\n if (duration) {\n this.duration = duration;\n }\n\n this.closable = closable;\n this.elevated = true;\n\n // We wrap this in a timeout for `getBoundingClientRect` to get the height properly\n setTimeout(() => {\n toastStack.appendChild(this);\n\n animateTo(\n toastStack,\n [\n {\n transform: `translateY(${this.getBoundingClientRect().height}px)`,\n },\n { transform: 'translateY(0px)' },\n ],\n { duration: 250, easing: 'ease-out' }\n );\n }, 0);\n\n // Wait for the toast stack to render\n requestAnimationFrame(() => {\n // Force a reflow for the initial transition\n this.clientWidth;\n this.show();\n });\n\n this.addEventListener(\n 'mid-after-hide',\n () => {\n toastStack.removeChild(this);\n resolve();\n\n // Remove the toast stack from the DOM when there are no more alerts\n if (toastStack.querySelector('mid-alert') === null) {\n toastStack.remove();\n }\n },\n { once: true }\n );\n });\n }\n\n override render() {\n const danger = this.severity === 'danger';\n const warning = this.severity === 'warning';\n const info = this.severity === 'info';\n const success = this.severity === 'success';\n\n return html`\n <div\n part=\"base\"\n class=\"ds-alert\"\n data-size=\"${this.size}\"\n data-color=\"${this.severity}\"\n @mouseenter=${this.pauseAutoHide}\n @mouseleave=${this.resumeAutoHide}\n >\n <div class=\"${classMap({ 'grid-cols-[1fr_auto]': this.closable })} grid\">\n <div aria-live=\"${this.arialive}\">\n <slot>\n ${!this.notificationContent?.title\n ? nothing\n : html`<h2 class=\"text-heading-xs\">\n ${this.notificationContent?.title}\n </h2>`}\n ${this.notificationContent?.message}\n ${!this.notificationContent?.details\n ? nothing\n : html`<div\n class=\"${classMap({\n 'border-danger': danger,\n 'border-info': info,\n 'border-success': success,\n 'border-warning': warning,\n 'bg-danger-surface-hover': danger,\n 'bg-info-surface-hover': info,\n 'bg-success-surface-hover': success,\n 'bg-warning-surface-hover': warning,\n })} text-body-sm mt-0.5 border-l-4 p-3\"\n >\n <pre class=\"break-all whitespace-pre-wrap\">\n${this.notificationContent?.details}</pre\n >\n </div>`}\n </slot>\n </div>\n ${this.closable\n ? html`\n <button\n class=\"${classMap({\n 'text-info-subtle': info,\n 'text-danger-subtle': danger,\n 'text-success-subtle': success,\n 'text-warning-subtle': warning,\n 'hover:bg-danger-surface-hover': danger,\n 'hover:bg-info-surface-hover': info,\n 'hover:bg-success-surface-hover': success,\n 'hover:bg-warning-surface-hover': warning,\n })} flex rounded p-2 self-start justify-self-end\"\n @click=\"${this.hide}\"\n aria-label=\"Dismiss alert\"\n >\n <mid-icon class=\"size-6\" name=\"xmark\"> </mid-icon>\n </button>\n `\n : nothing}\n </div>\n </div>\n `;\n }\n}\n\nsetDefaultAnimation('alert.show', {\n keyframes: [\n { opacity: 0, transform: 'translateY(100%)' },\n { opacity: 1, transform: 'translateY(0px)' },\n ],\n options: { duration: 400, easing: 'ease-out' },\n});\n\nsetDefaultAnimation('alert.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.8 },\n ],\n options: { duration: 250, easing: 'ease-in' },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,aAAa,OAAO,OAAO,SAAS,cAAc,KAAK,GAAG;AAAA,EAC9D,WAAW;AACb,CAAC;AAiBM,IAAM,aAAN,cAAyB,OAAO,UAAU,EAAE;AAAA,EAA5C,cAAA;AAAA,UAAA,GAAA,SAAA;AAYL,SAAA,OAAO;AAMP,SAAA,WAAW;AAQX,SAAA,WAAW;AAMX,SAAA,WAAsD;AAMtD,SAAA,OAA2B;AAM3B,SAAA,WAAW;AASX,SAAA,WAA2C;AAG3C,SAAQ,gBAAgB,KAAK;AAAA,EAAA;AAAA,EAS7B,eAAe;AACb,SAAK,KAAK,SAAS,CAAC,KAAK;AAAA,EAC3B;AAAA,EAEQ,kBAAkB;AACxB,iBAAa,KAAK,eAAe;AACjC,kBAAc,KAA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,MAAM,UAAU;AAAA,GA7IN,WA8IX,WAAA,wBAAA,CAAA;AA9IW,aAAN,gBAAA;AAAA,EADN,cAAc,WAAW;AAAA,GACb,UAAA;AAsTb,oBAAoB,cAAc;AAAA,EAChC,WAAW;AAAA,IACT,EAAE,SAAS,GAAG,WAAW,mBAAA;AAAA,IACzB,EAAE,SAAS,GAAG,WAAW,kBAAA;AAAA,EAAkB;AAAA,EAE7C,SAAS,EAAE,UAAU,KAAK,QAAQ,WAAA;AACpC,CAAC;AAED,oBAAoB,cAAc;AAAA,EAChC,WAAW;AAAA,IACT,EAAE,SAAS,GAAG,OAAO,EAAA;AAAA,IACrB,EAAE,SAAS,GAAG,OAAO,IAAA;AAAA,EAAI;AAAA,EAE3B,SAAS,EAAE,UAAU,KAAK,QAAQ,UAAA;AACpC,CAAC;"}
1
+ {"version":3,"file":"alert.js","sources":["../../src/components/alert.component.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styled } from '../mixins/tailwind.mixin.ts';\nimport './icon/icon.component';\nimport { watch } from '../internal/watch';\nimport {\n getAnimation,\n setDefaultAnimation,\n} from '../utilities/animation-registry';\nimport { waitForEvent } from '../internal/event';\nimport { animateTo, stopAnimations } from '../internal/animate';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-alert': MinidAlert;\n }\n}\n\nconst toastStack = Object.assign(document.createElement('div'), {\n className: 'mid-toast-stack',\n});\n\n/**\n * Alerts need to have the `open` attribute to be displayed\n * @csspart base - Select the base of the alert\n *\n * @event mid-show - Emitted when the alert opens.\n * @event mid-after-show - Emitted after the alert opens and all animations are complete.\n * @event mid-hide - Emitted when the alert closes.\n * @event mid-after-hide - Emitted after the alert closes and all animations are complete.\n *\n * @slot -- The default slot for the content of the alert\n *\n * @animation alert.show - The animation to use when showing the alert.\n * @animation alert.hide - The animation to use when hiding the alert.\n */\n@customElement('mid-alert')\nexport class MinidAlert extends styled(LitElement) {\n private autoHideTimeout?: number;\n private remainingTimeInterval?: number;\n\n @query('[part~=\"base\"]')\n private base!: HTMLElement;\n\n /**\n * Indicates whether or not the alert is open. You can toggle this attribute to show and hide the alert, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the alert's open state.\n */\n @property({ type: Boolean, reflect: true })\n open = false;\n\n /**\n * Enables a close button that allows the user to dismiss the alert.\n */\n @property({ type: Boolean, reflect: true })\n closable = false;\n\n /**\n * The length of time, in milliseconds, the alert will show before closing itself. If the user interacts with\n * the alert before it closes (e.g. moves the mouse over it), the timer will restart. Defaults to `Infinity`, meaning\n * the alert will not close on its own.\n */\n @property({ type: Number })\n duration = Infinity;\n\n /**\n * Sets color and icon according to severity\n */\n @property({ reflect: true })\n severity: 'warning' | 'info' | 'danger' | 'success' = 'info';\n\n /**\n * Sets size of icon, padding and font-size.\n */\n @property({ reflect: true })\n size: 'sm' | 'md' | 'lg' = 'md';\n\n /**\n * Adds a shadow to elevate the component\n */\n @property({ type: Boolean })\n elevated = false;\n\n /**\n * Sets the `aria-live` attribute on the alert host element.\n * Prefer wrapping the alert in a `role=\"alert\"` or `aria-live` container instead.\n * Use `\"polite\"` for non-urgent updates and `\"assertive\"` for time-sensitive ones.\n * Defaults to `\"off\"`.\n */\n @property({ reflect: true })\n arialive: 'polite' | 'assertive' | 'off' = 'off';\n\n @state()\n private remainingTime = this.duration;\n\n @state()\n private notificationContent?: {\n title?: string;\n message: string;\n details?: string;\n };\n\n firstUpdated() {\n this.base.hidden = !this.open;\n }\n\n private restartAutoHide() {\n clearTimeout(this.autoHideTimeout);\n clearInterval(this.remainingTimeInterval);\n if (this.open && this.duration < Infinity) {\n this.autoHideTimeout = window.setTimeout(\n () => this.hide(),\n this.duration\n );\n this.remainingTime = this.duration;\n this.remainingTimeInterval = window.setInterval(() => {\n this.remainingTime -= 100;\n }, 100);\n }\n }\n\n private pauseAutoHide() {\n clearTimeout(this.autoHideTimeout);\n clearInterval(this.remainingTimeInterval);\n }\n\n private resumeAutoHide() {\n if (this.duration < Infinity) {\n this.autoHideTimeout = window.setTimeout(\n () => this.hide(),\n this.remainingTime\n );\n this.remainingTimeInterval = window.setInterval(() => {\n this.remainingTime -= 100;\n }, 100);\n }\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.dispatchEvent(\n new Event('mid-show', { composed: true, bubbles: true })\n );\n\n if (this.duration < Infinity) {\n this.restartAutoHide();\n }\n\n await stopAnimations(this.base);\n this.base.hidden = false;\n const { keyframes, options } = getAnimation(this, 'alert.show');\n await animateTo(this.base, keyframes, options);\n\n this.dispatchEvent(\n new Event('mid-after-show', { composed: true, bubbles: true })\n );\n } else {\n // Hide\n this.dispatchEvent(\n new Event('mid-hide', { composed: true, bubbles: true })\n );\n\n clearTimeout(this.autoHideTimeout);\n clearInterval(this.remainingTimeInterval);\n\n await stopAnimations(this.base);\n const { keyframes, options } = getAnimation(this, 'alert.hide');\n await animateTo(this.base, keyframes, options);\n this.base.hidden = true;\n\n this.dispatchEvent(\n new Event('mid-after-hide', { composed: true, bubbles: true })\n );\n }\n }\n\n @watch('duration')\n handleDurationChange() {\n this.restartAutoHide();\n }\n\n /**\n * Shows the alert.\n */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'mid-after-show');\n }\n\n /**\n * Hides the alert\n */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'mid-after-hide');\n }\n\n /**\n * Displays the alert as a toast notification. This will move the alert out of its position in the DOM and, when\n * dismissed, it will be removed from the DOM completely. By storing a reference to the alert, you can reuse it by\n * calling this method again. The returned promise will resolve after the alert is hidden.\n */\n async toast(\n content: MinidAlert['notificationContent'],\n duration?: number,\n severity?: MinidAlert['severity'],\n closable = true\n ) {\n return new Promise<void>((resolve) => {\n if (toastStack.parentElement === null) {\n document.body.append(toastStack);\n }\n\n if (content) {\n this.notificationContent = content;\n }\n\n if (severity) {\n this.severity = severity;\n }\n\n if (duration) {\n this.duration = duration;\n }\n\n this.closable = closable;\n this.elevated = true;\n\n // We wrap this in a timeout for `getBoundingClientRect` to get the height properly\n setTimeout(() => {\n toastStack.appendChild(this);\n\n animateTo(\n toastStack,\n [\n {\n transform: `translateY(${this.getBoundingClientRect().height}px)`,\n },\n { transform: 'translateY(0px)' },\n ],\n { duration: 250, easing: 'ease-out' }\n );\n }, 0);\n\n // Wait for the toast stack to render\n requestAnimationFrame(() => {\n // Force a reflow for the initial transition. Reading the property is the\n // side effect, so the \"unused expression\" here is deliberate.\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n this.clientWidth;\n this.show();\n });\n\n this.addEventListener(\n 'mid-after-hide',\n () => {\n toastStack.removeChild(this);\n resolve();\n\n // Remove the toast stack from the DOM when there are no more alerts\n if (toastStack.querySelector('mid-alert') === null) {\n toastStack.remove();\n }\n },\n { once: true }\n );\n });\n }\n\n override render() {\n const danger = this.severity === 'danger';\n const warning = this.severity === 'warning';\n const info = this.severity === 'info';\n const success = this.severity === 'success';\n\n return html`\n <div\n part=\"base\"\n class=\"ds-alert\"\n data-size=\"${this.size}\"\n data-color=\"${this.severity}\"\n @mouseenter=${this.pauseAutoHide}\n @mouseleave=${this.resumeAutoHide}\n >\n <div\n class=\"${classMap({ 'grid-cols-[1fr_auto]': this.closable })} grid\"\n >\n <div aria-live=\"${this.arialive}\">\n <slot>\n ${!this.notificationContent?.title\n ? nothing\n : html`<h2 class=\"text-heading-xs\">\n ${this.notificationContent?.title}\n </h2>`}\n ${this.notificationContent?.message}\n ${!this.notificationContent?.details\n ? nothing\n : html`<div\n class=\"${classMap({\n 'border-danger': danger,\n 'border-info': info,\n 'border-success': success,\n 'border-warning': warning,\n 'bg-danger-surface-hover': danger,\n 'bg-info-surface-hover': info,\n 'bg-success-surface-hover': success,\n 'bg-warning-surface-hover': warning,\n })} text-body-sm mt-0.5 border-l-4 p-3\"\n >\n <pre class=\"break-all whitespace-pre-wrap\">\n${this.notificationContent?.details}</pre\n >\n </div>`}\n </slot>\n </div>\n ${this.closable\n ? html`\n <button\n class=\"${classMap({\n 'text-info-subtle': info,\n 'text-danger-subtle': danger,\n 'text-success-subtle': success,\n 'text-warning-subtle': warning,\n 'hover:bg-danger-surface-hover': danger,\n 'hover:bg-info-surface-hover': info,\n 'hover:bg-success-surface-hover': success,\n 'hover:bg-warning-surface-hover': warning,\n })} flex self-start justify-self-end rounded p-2\"\n @click=\"${this.hide}\"\n aria-label=\"Dismiss alert\"\n >\n <mid-icon class=\"size-6\" name=\"xmark\"> </mid-icon>\n </button>\n `\n : nothing}\n </div>\n </div>\n `;\n }\n}\n\nsetDefaultAnimation('alert.show', {\n keyframes: [\n { opacity: 0, transform: 'translateY(100%)' },\n { opacity: 1, transform: 'translateY(0px)' },\n ],\n options: { duration: 400, easing: 'ease-out' },\n});\n\nsetDefaultAnimation('alert.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.8 },\n ],\n options: { duration: 250, easing: 'ease-in' },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,aAAa,OAAO,OAAO,SAAS,cAAc,KAAK,GAAG;AAAA,EAC9D,WAAW;AACb,CAAC;AAiBM,IAAM,aAAN,cAAyB,OAAO,UAAU,EAAE;AAAA,EAA5C,cAAA;AAAA,UAAA,GAAA,SAAA;AAYL,SAAA,OAAO;AAMP,SAAA,WAAW;AAQX,SAAA,WAAW;AAMX,SAAA,WAAsD;AAMtD,SAAA,OAA2B;AAM3B,SAAA,WAAW;AASX,SAAA,WAA2C;AAG3C,SAAQ,gBAAgB,KAAK;AAAA,EAAA;AAAA,EAS7B,eAAe;AACb,SAAK,KAAK,SAAS,CAAC,KAAK;AAAA,EAC3B;AAAA,EAEQ,kBAAkB;AACxB,iBAAa,KAAK,eAAe;AACjC,kBAAc,KAAK,qBAAqB;AACxC,QAAI,KAAK,QAAQ,KAAK,W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X,WAAA,wBAAA,CAAA;AA9IW,aAAN,gBAAA;AAAA,EADN,cAAc,WAAW;AAAA,GACb,UAAA;AA0Tb,oBAAoB,cAAc;AAAA,EAChC,WAAW;AAAA,IACT,EAAE,SAAS,GAAG,WAAW,mBAAA;AAAA,IACzB,EAAE,SAAS,GAAG,WAAW,kBAAA;AAAA,EAAkB;AAAA,EAE7C,SAAS,EAAE,UAAU,KAAK,QAAQ,WAAA;AACpC,CAAC;AAED,oBAAoB,cAAc;AAAA,EAChC,WAAW;AAAA,IACT,EAAE,SAAS,GAAG,OAAO,EAAA;AAAA,IACrB,EAAE,SAAS,GAAG,OAAO,IAAA;AAAA,EAAI;AAAA,EAE3B,SAAS,EAAE,UAAU,KAAK,QAAQ,UAAA;AACpC,CAAC;"}
@@ -48,6 +48,7 @@ export declare class MinidButton extends MinidButton_base {
48
48
  * Toggle icon only styling
49
49
  */
50
50
  iconstyled: boolean;
51
+ constructor();
51
52
  handleClick(): void;
52
53
  private get isLink();
53
54
  click(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"button.component.d.ts","sourceRoot":"","sources":["../../src/components/button.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,UAAU,EAAE,MAAM,KAAK,CAAC;AAMtC,OAAO,wBAAwB,CAAC;AAGhC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,WAAW,CAAC;KAC3B;CACF;;AAUD;;;;GAIG;AACH,qBACa,WAAY,SAAQ,gBAA4C;IAE3E,MAAM,EAAG,iBAAiB,GAAG,eAAe,CAAC;IAE7C;;OAEG;IAEH,KAAK,SAAM;IAEX;;OAEG;IAEH,OAAO,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAa;IAE1D;;OAEG;IAEH,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAQ;IAEhC;;OAEG;IAEH,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAY;IAE/C;;OAE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, html } from "lit/static-html.js";
6
6
  import { styled } from "../mixins/tailwind.mixin.js";
7
7
  import "./spinner.js";
8
8
  import { FormControlMixin } from "../mixins/form-control.mixin.js";
9
+ import { getLang } from "../utilities/lang.js";
10
+ import { getTranslations } from "../utilities/translations.js";
11
+ import { L as LangController } from "../lang.controller-P4W-9ipy.js";
9
12
  var __defProp = Object.defineProperty;
10
13
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
14
  var __decorateClass = (decorators, target, key, kind) => {
@@ -25,7 +28,7 @@ const styles = [
25
28
  ];
26
29
  let MinidButton = class extends FormControlMixin(styled(LitElement, styles)) {
27
30
  constructor() {
28
- super(...arguments);
31
+ super();
29
32
  this.value = "";
30
33
  this.variant = "primary";
31
34
  this.size = "md";
@@ -34,6 +37,7 @@ let MinidButton = class extends FormControlMixin(styled(LitElement, styles)) {
34
37
  this.loading = false;
35
38
  this.loadingtext = "";
36
39
  this.iconstyled = false;
40
+ new LangController(this);
37
41
  }
38
42
  handleClick() {
39
43
  if (this.type === "submit") {
@@ -61,6 +65,7 @@ let MinidButton = class extends FormControlMixin(styled(LitElement, styles)) {
61
65
  const secondary = this.variant === "secondary";
62
66
  const tertiary = this.variant === "tertiary";
63
67
  const spinnerOnly = this.loading && !this.loadingtext;
68
+ const translations = getTranslations(getLang(this));
64
69
  return html`<${tag}
65
70
  part="base"
66
71
  class="${classMap({
@@ -112,6 +117,7 @@ let MinidButton = class extends FormControlMixin(styled(LitElement, styles)) {
112
117
  "left-[calc(50%_-_0.5em)]": spinnerOnly
113
118
  })}"
114
119
  part="spinner"
120
+ label=${spinnerOnly ? translations.loading : ""}
115
121
  ></mid-spinner>` : ""}
116
122
  </${tag}>`;
117
123
  }
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","sources":["../../src/components/button.component.ts"],"sourcesContent":["import { css, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { html, literal } from 'lit/static-html.js';\nimport { styled } from '../mixins/tailwind.mixin.ts';\nimport './spinner.component.ts';\nimport { FormControlMixin } from '../mixins/form-control.mixin.ts';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-button': MinidButton;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: inline-flex;\n }\n `,\n];\n\n/**\n * @slot -- The default slot for the button's text content\n * @csspart base - Select the button or anchor element\n * @csspart spinner - Select the spinner element\n */\n@customElement('mid-button')\nexport class MinidButton extends FormControlMixin(styled(LitElement, styles)) {\n @query('[part=\"base\"]')\n button!: HTMLButtonElement | HTMLLinkElement;\n\n /**\n * The value of the button (optional)\n */\n @property({ type: String })\n value = '';\n\n /**\n * The variant of the button\n */\n @property({ type: String })\n variant: 'primary' | 'secondary' | 'tertiary' = 'primary';\n\n /**\n * The size of the button. Defaults to 'md'\n */\n @property({ type: String })\n size: 'md' | 'lg' | 'sm' = 'md';\n\n /**\n * The type of the button. Defaults to normal 'button'\n */\n @property({ type: String })\n type: 'submit' | 'button' | 'reset' = 'button';\n\n /**\n * The href of the button. If set, the button will be rendered as an anchor tag\n */\n @property({ type: String })\n href: string | undefined;\n\n /**\n * Whether the button is disabled\n */\n @property({ type: Boolean })\n disabled = false;\n\n /**\n * Toggle loading state\n */\n @property({ type: Boolean })\n loading = false;\n\n /**\n * Text to show when button is in loading state\n */\n @property()\n loadingtext = '';\n\n /**\n * Toggle icon only styling\n */\n @property({ type: Boolean })\n iconstyled = false;\n\n handleClick() {\n if (this.type === 'submit') {\n this.value && this.setValue(this.value);\n this.internals.form?.requestSubmit();\n } else if (this.type === 'reset') {\n this.internals.form?.reset();\n }\n }\n\n private get isLink() {\n return !!this.href;\n }\n\n click() {\n this.button.click();\n }\n\n blur() {\n this.button.blur();\n }\n\n focus(options?: FocusOptions) {\n this.button.focus(options);\n }\n\n override render() {\n const tag = this.isLink ? literal`a` : literal`button`;\n const primary = this.variant === 'primary';\n const secondary = this.variant === 'secondary';\n const tertiary = this.variant === 'tertiary';\n const spinnerOnly = this.loading && !this.loadingtext;\n\n return html`<${tag}\n part=\"base\"\n class=\"${classMap({\n 'w-12': this.iconstyled,\n 'h-12': this.iconstyled,\n 'py-2': !this.iconstyled,\n 'px-4': !this.iconstyled,\n 'bg-accent-base': primary,\n 'text-accent-base-contrast': primary,\n 'border-transparent': primary || tertiary,\n 'hover:bg-accent-base-hover': primary,\n 'active:bg-accent-base-active': primary,\n 'bg-transparent': secondary || tertiary,\n 'active:bg-accent-surface-active': secondary || tertiary,\n 'hover:bg-accent-surface-hover': secondary || tertiary,\n 'text-accent-subtle': secondary || tertiary,\n 'hover:text-accent': secondary || tertiary,\n 'border-accent-strong': secondary,\n 'text-body-sm': this.size === 'sm',\n 'text-body-md': this.size === 'md',\n 'text-body-lg': this.size === 'lg',\n 'cursor-wait': this.loading && !this.disabled,\n 'cursor-pointer': !this.loading && !this.disabled,\n 'cursor-not-allowed': this.disabled,\n relative: spinnerOnly,\n 'gap-0': spinnerOnly,\n 'opacity-disabled': this.disabled && !this.loading,\n })} grow focus-visible:focus-ring leading-sm flex h-fit min-h-12 min-w-12 items-center justify-center gap-2 rounded border font-medium\"\n type=${this.type}\n aria-busy=${this.loading}\n ?disabled=${this.disabled || this.loading}\n href=\"${ifDefined(this.href)}\"\n @click=\"${this.handleClick}\"\n >\n <slot\n class=\"${classMap({\n invisible: spinnerOnly,\n })}\"\n ?hidden=${this.loading && !!this.loadingtext}\n ></slot>\n <span ?hidden=${!this.loading || !this.loadingtext}>\n ${this.loadingtext}\n </span>\n ${\n this.loading\n ? html`<mid-spinner\n class=\"${classMap({\n 'text-[1.4rem]': true,\n absolute: spinnerOnly,\n 'top-[calc(50%_-_0.5em)]': spinnerOnly,\n 'left-[calc(50%_-_0.5em)]': spinnerOnly,\n })}\"\n part=\"spinner\"\n ></mid-spinner>`\n : ''\n }\n </${tag}>`;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAeA,MAAM,S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,MAAM,OAAA,CAAQ;AAAA,GAbf,YAcX,WAAA,WAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAnBf,YAoBX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAzBf,YA0BX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/Bf,YAgCX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GArChB,YAsCX,WAAA,YAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GA3ChB,YA4CX,WAAA,WAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAA;AAAS,GAjDC,YAkDX,WAAA,eAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAvDhB,YAwDX,WAAA,cAAA,CAAA;AAxDW,cAAN,gBAAA;AAAA,EADN,cAAc,YAAY;AAAA,GACd,WAAA;"}
1
+ {"version":3,"file":"button.js","sources":["../../src/components/button.component.ts"],"sourcesContent":["import { css, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { html, literal } from 'lit/static-html.js';\nimport { styled } from '../mixins/tailwind.mixin.ts';\nimport './spinner.component.ts';\nimport { FormControlMixin } from '../mixins/form-control.mixin.ts';\nimport { getLang } from '../utilities/lang.js';\nimport { getTranslations } from '../utilities/translations.js';\nimport { LangController } from '../controllers/lang.controller.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-button': MinidButton;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: inline-flex;\n }\n `,\n];\n\n/**\n * @slot -- The default slot for the button's text content\n * @csspart base - Select the button or anchor element\n * @csspart spinner - Select the spinner element\n */\n@customElement('mid-button')\nexport class MinidButton extends FormControlMixin(styled(LitElement, styles)) {\n @query('[part=\"base\"]')\n button!: HTMLButtonElement | HTMLLinkElement;\n\n /**\n * The value of the button (optional)\n */\n @property({ type: String })\n value = '';\n\n /**\n * The variant of the button\n */\n @property({ type: String })\n variant: 'primary' | 'secondary' | 'tertiary' = 'primary';\n\n /**\n * The size of the button. Defaults to 'md'\n */\n @property({ type: String })\n size: 'md' | 'lg' | 'sm' = 'md';\n\n /**\n * The type of the button. Defaults to normal 'button'\n */\n @property({ type: String })\n type: 'submit' | 'button' | 'reset' = 'button';\n\n /**\n * The href of the button. If set, the button will be rendered as an anchor tag\n */\n @property({ type: String })\n href: string | undefined;\n\n /**\n * Whether the button is disabled\n */\n @property({ type: Boolean })\n disabled = false;\n\n /**\n * Toggle loading state\n */\n @property({ type: Boolean })\n loading = false;\n\n /**\n * Text to show when button is in loading state\n */\n @property()\n loadingtext = '';\n\n /**\n * Toggle icon only styling\n */\n @property({ type: Boolean })\n iconstyled = false;\n\n constructor() {\n super();\n new LangController(this);\n }\n\n handleClick() {\n if (this.type === 'submit') {\n this.value && this.setValue(this.value);\n this.internals.form?.requestSubmit();\n } else if (this.type === 'reset') {\n this.internals.form?.reset();\n }\n }\n\n private get isLink() {\n return !!this.href;\n }\n\n click() {\n this.button.click();\n }\n\n blur() {\n this.button.blur();\n }\n\n focus(options?: FocusOptions) {\n this.button.focus(options);\n }\n\n override render() {\n const tag = this.isLink ? literal`a` : literal`button`;\n const primary = this.variant === 'primary';\n const secondary = this.variant === 'secondary';\n const tertiary = this.variant === 'tertiary';\n const spinnerOnly = this.loading && !this.loadingtext;\n const translations = getTranslations(getLang(this));\n\n return html`<${tag}\n part=\"base\"\n class=\"${classMap({\n 'w-12': this.iconstyled,\n 'h-12': this.iconstyled,\n 'py-2': !this.iconstyled,\n 'px-4': !this.iconstyled,\n 'bg-accent-base': primary,\n 'text-accent-base-contrast': primary,\n 'border-transparent': primary || tertiary,\n 'hover:bg-accent-base-hover': primary,\n 'active:bg-accent-base-active': primary,\n 'bg-transparent': secondary || tertiary,\n 'active:bg-accent-surface-active': secondary || tertiary,\n 'hover:bg-accent-surface-hover': secondary || tertiary,\n 'text-accent-subtle': secondary || tertiary,\n 'hover:text-accent': secondary || tertiary,\n 'border-accent-strong': secondary,\n 'text-body-sm': this.size === 'sm',\n 'text-body-md': this.size === 'md',\n 'text-body-lg': this.size === 'lg',\n 'cursor-wait': this.loading && !this.disabled,\n 'cursor-pointer': !this.loading && !this.disabled,\n 'cursor-not-allowed': this.disabled,\n relative: spinnerOnly,\n 'gap-0': spinnerOnly,\n 'opacity-disabled': this.disabled && !this.loading,\n })} grow focus-visible:focus-ring leading-sm flex h-fit min-h-12 min-w-12 items-center justify-center gap-2 rounded border font-medium\"\n type=${this.type}\n aria-busy=${this.loading}\n ?disabled=${this.disabled || this.loading}\n href=\"${ifDefined(this.href)}\"\n @click=\"${this.handleClick}\"\n >\n <slot\n class=\"${classMap({\n invisible: spinnerOnly,\n })}\"\n ?hidden=${this.loading && !!this.loadingtext}\n ></slot>\n <span ?hidden=${!this.loading || !this.loadingtext}>\n ${this.loadingtext}\n </span>\n ${\n this.loading\n ? html`<mid-spinner\n class=\"${classMap({\n 'text-[1.4rem]': true,\n absolute: spinnerOnly,\n 'top-[calc(50%_-_0.5em)]': spinnerOnly,\n 'left-[calc(50%_-_0.5em)]': spinnerOnly,\n })}\"\n part=\"spinner\"\n label=${spinnerOnly ? translations.loading : ''}\n ></mid-spinner>`\n : ''\n }\n </${tag}>`;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAKF;AAQO,IAAM,cAAN,cAA0B,iBAAiB,OAAO,YAAY,MAAM,CAAC,EAAE;AAAA,EA0D5E,cAAc;AACZ,UAAA;AAnDF,SAAA,Q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MA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAnBf,YAoBX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAzBf,YA0BX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/Bf,YAgCX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GArChB,YAsCX,WAAA,YAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GA3ChB,YA4CX,WAAA,WAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAA;AAAS,GAjDC,YAkDX,WAAA,eAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAvDhB,YAwDX,WAAA,cAAA,CAAA;AAxDW,cAAN,gBAAA;AAAA,EADN,cAAc,YAAY;AAAA,GACd,WAAA;"}
@@ -79,7 +79,8 @@ let MinidDialog = class extends styled(LitElement, styles) {
79
79
  this.dialog,
80
80
  panelAnimation.keyframes,
81
81
  panelAnimation.options
82
- ), this.dispatchEvent(
82
+ );
83
+ this.dispatchEvent(
83
84
  new Event("mid-after-show", { bubbles: true, composed: true })
84
85
  );
85
86
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","sources":["../../src/components/dialog.component.ts"],"sourcesContent":["import { css, html, LitElement, nothing } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { getLang } from '../utilities/lang';\nimport { getTranslations } from '../utilities/translations';\nimport { LangController } from '../controllers/lang.controller.js';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport { styled } from '../mixins/tailwind.mixin';\nimport './icon/icon.component';\nimport {\n getAnimation,\n setDefaultAnimation,\n} from '../utilities/animation-registry';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { lockBodyScrolling, unlockBodyScrolling } from '../internal/scroll';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-dialog': MinidDialog;\n }\n}\n\nconst styles = [\n css`\n :host {\n --width: 40rem;\n display: block;\n }\n `,\n];\n\n/**\n *\n * @event mid-show - Emitted when the dialog opens.\n * @event mid-after-show - Emitted after the dialog opens and all animations are complete.\n * @event mid-hide - Emitted when the dialog closes.\n * @event mid-after-hide - Emitted after the dialog closes and all animations are complete.\n * @event {{ source: 'close-button' | 'keyboard' | 'overlay' }} mid-request-close - Emitted when the user attempts to\n * close the dialog by clicking the close button, clicking the overlay, or pressing escape. Calling\n * `event.preventDefault()` will keep the dialog open. Avoid using this unless closing the dialog will result in\n * destructive behavior such as data loss.\n *\n * @csspart base - Select the base `dialog` element\n * @csspart header - Select the `header` element\n * @csspart body - Select the `article` element\n * @csspart footer - Select the `footer` element\n *\n * @slot -- The default slot for the body content of the dialog\n * @slot heading - The content inside the `h2` element\n * @slot footer - The content inside the `footer` element\n *\n * @animation dialog.show - The animation to use when showing the dialog.\n * @animation dialog.hide - The animation to use when hiding the dialog.\n * @animation dialog.denyClose - The animation to use when closing the dialog is prevented.\n *\n */\n@customElement('mid-dialog')\nexport class MinidDialog extends styled(LitElement, styles) {\n @query('#dialog')\n dialog!: HTMLDialogElement;\n\n /**\n * Indicates whether or not the dialog is open. You can toggle this attribute to show and hide the dialog, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the dialog's open state.\n */\n @property({ type: Boolean, reflect: true })\n open = false;\n\n /**\n * The dialog's label as displayed in the header. You should always include a relevant label even when using\n * `no-header`, as it is required for proper accessibility. If you need to display HTML, use the `label` slot instead.\n */\n @property({ reflect: true })\n heading = '';\n\n /**\n * When set, the dialog uses `role=\"alertdialog\"` instead of `role=\"dialog\"`, signalling urgency to screen readers.\n * Use this for blocking dialogs that require immediate user attention.\n */\n @property({ type: Boolean, reflect: true })\n alertdialog = false;\n\n private requestClose(source: 'close-button' | 'keyboard' | 'overlay') {\n const requestCloseEvent = new CustomEvent('mid-request-close', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: { source },\n });\n this.dispatchEvent(requestCloseEvent);\n\n if (requestCloseEvent.defaultPrevented) {\n const { keyframes, options } = getAnimation(this, 'dialog.denyClose');\n animateTo(this.dialog, keyframes, options);\n return;\n }\n\n this.hide();\n }\n\n handleDialogCancel = (event: Event) => {\n event.preventDefault();\n\n if (event.defaultPrevented) {\n this.requestClose('keyboard');\n } else {\n this.hide();\n }\n };\n\n private handleBackdropClick({ target }: Event) {\n // if the target is the dialog, the backdrop was clicked\n if (target === this.dialog) {\n this.requestClose('overlay');\n }\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.dispatchEvent(\n new Event('mid-show', { composed: true, bubbles: true })\n );\n // this.addOpenListeners();\n this.dialog.showModal();\n\n if (this.alertdialog) {\n this.dialog.focus();\n }\n\n lockBodyScrolling(this);\n\n const panelAnimation = getAnimation(this, 'dialog.show');\n await animateTo(\n this.dialog,\n panelAnimation.keyframes,\n panelAnimation.options\n ),\n this.dispatchEvent(\n new Event('mid-after-show', { bubbles: true, composed: true })\n );\n } else {\n // Hide\n this.dispatchEvent(\n new Event('mid-hide', { bubbles: true, composed: true })\n );\n\n await Promise.all([stopAnimations(this.dialog)]);\n const panelAnimation = getAnimation(this, 'dialog.hide');\n\n // The backdrop can only be animated with css because it's a pseudo element\n // so we add a animation class to trigger it at the same time as the dialog animation\n this.dialog.classList.add('backdrop:animate-fade-out');\n await animateTo(\n this.dialog,\n panelAnimation.keyframes,\n panelAnimation.options\n );\n this.dialog.classList.remove('backdrop:animate-fade-out');\n this.dialog.close();\n this.dialog.hidden = false;\n unlockBodyScrolling(this);\n this.dispatchEvent(\n new Event('mid-after-hide', { composed: true, bubbles: true })\n );\n }\n }\n\n /**\n * Shows the dialog.\n */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'mid-after-show');\n }\n\n /**\n * Hides the dialog\n */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'mid-after-hide');\n }\n\n constructor() {\n super();\n new LangController(this);\n }\n\n override render() {\n const t = getTranslations(getLang(this));\n\n return html`\n <dialog\n part=\"base\"\n id=\"dialog\"\n tabindex=\"-1\"\n role=${this.alertdialog ? 'alertdialog' : 'dialog'}\n aria-label=${this.heading || nothing}\n aria-modal=\"true\"\n class=\"text-neutral m-auto max-h-[calc(100%---spacing(8))] w-(--width) max-w-[calc(100%---spacing(8))] flex-col rounded-lg p-6 shadow-xl backdrop:bg-black/50 open:flex open:animate-none\"\n @cancel=${this.handleDialogCancel}\n @click=${this.handleBackdropClick}\n >\n <header part=\"header\" class=\"text-heading-sm flex justify-between\">\n <slot name=\"heading\"></slot>\n <div class=\"h-0\">\n <button\n autofocus\n aria-label=${t.close}\n @click=\"${() => this.requestClose('close-button')}\"\n class=\"text-body-md focus-visible:focus-ring text-neutral hover:bg-neutral-surface-hover float-right flex size-12 translate-x-3 -translate-y-3 items-center justify-center rounded\"\n >\n <mid-icon class=\"size-6\" name=\"xmark\"></mid-icon>\n </button>\n </div>\n </header>\n <div part=\"body\" class=\"overflow-auto\">\n <slot> </slot>\n </div>\n <footer part=\"footer\">\n <slot name=\"footer\"> </slot>\n </footer>\n </dialog>\n `;\n }\n}\n\nsetDefaultAnimation('dialog.show', {\n keyframes: [\n { opacity: 0, scale: 0.8 },\n { opacity: 1, scale: 1 },\n ],\n options: { duration: 250, easing: 'ease' },\n});\n\nsetDefaultAnimation('dialog.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.8 },\n ],\n options: { duration: 250, easing: 'ease' },\n});\n\nsetDefaultAnimation('dialog.denyClose', {\n keyframes: [{ scale: 1 }, { scale: 1.03 }, { scale: 1 }],\n options: { duration: 100 },\n});\n"],"names":[],"mappings":";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ACvB,CAAC;"}
1
+ {"version":3,"file":"dialog.js","sources":["../../src/components/dialog.component.ts"],"sourcesContent":["import { css, html, LitElement, nothing } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { getLang } from '../utilities/lang';\nimport { getTranslations } from '../utilities/translations';\nimport { LangController } from '../controllers/lang.controller.js';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport { styled } from '../mixins/tailwind.mixin';\nimport './icon/icon.component';\nimport {\n getAnimation,\n setDefaultAnimation,\n} from '../utilities/animation-registry';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { lockBodyScrolling, unlockBodyScrolling } from '../internal/scroll';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-dialog': MinidDialog;\n }\n}\n\nconst styles = [\n css`\n :host {\n --width: 40rem;\n display: block;\n }\n `,\n];\n\n/**\n *\n * @event mid-show - Emitted when the dialog opens.\n * @event mid-after-show - Emitted after the dialog opens and all animations are complete.\n * @event mid-hide - Emitted when the dialog closes.\n * @event mid-after-hide - Emitted after the dialog closes and all animations are complete.\n * @event {{ source: 'close-button' | 'keyboard' | 'overlay' }} mid-request-close - Emitted when the user attempts to\n * close the dialog by clicking the close button, clicking the overlay, or pressing escape. Calling\n * `event.preventDefault()` will keep the dialog open. Avoid using this unless closing the dialog will result in\n * destructive behavior such as data loss.\n *\n * @csspart base - Select the base `dialog` element\n * @csspart header - Select the `header` element\n * @csspart body - Select the `article` element\n * @csspart footer - Select the `footer` element\n *\n * @slot -- The default slot for the body content of the dialog\n * @slot heading - The content inside the `h2` element\n * @slot footer - The content inside the `footer` element\n *\n * @animation dialog.show - The animation to use when showing the dialog.\n * @animation dialog.hide - The animation to use when hiding the dialog.\n * @animation dialog.denyClose - The animation to use when closing the dialog is prevented.\n *\n */\n@customElement('mid-dialog')\nexport class MinidDialog extends styled(LitElement, styles) {\n @query('#dialog')\n dialog!: HTMLDialogElement;\n\n /**\n * Indicates whether or not the dialog is open. You can toggle this attribute to show and hide the dialog, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the dialog's open state.\n */\n @property({ type: Boolean, reflect: true })\n open = false;\n\n /**\n * The dialog's label as displayed in the header. You should always include a relevant label even when using\n * `no-header`, as it is required for proper accessibility. If you need to display HTML, use the `label` slot instead.\n */\n @property({ reflect: true })\n heading = '';\n\n /**\n * When set, the dialog uses `role=\"alertdialog\"` instead of `role=\"dialog\"`, signalling urgency to screen readers.\n * Use this for blocking dialogs that require immediate user attention.\n */\n @property({ type: Boolean, reflect: true })\n alertdialog = false;\n\n private requestClose(source: 'close-button' | 'keyboard' | 'overlay') {\n const requestCloseEvent = new CustomEvent('mid-request-close', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: { source },\n });\n this.dispatchEvent(requestCloseEvent);\n\n if (requestCloseEvent.defaultPrevented) {\n const { keyframes, options } = getAnimation(this, 'dialog.denyClose');\n animateTo(this.dialog, keyframes, options);\n return;\n }\n\n this.hide();\n }\n\n handleDialogCancel = (event: Event) => {\n event.preventDefault();\n\n if (event.defaultPrevented) {\n this.requestClose('keyboard');\n } else {\n this.hide();\n }\n };\n\n private handleBackdropClick({ target }: Event) {\n // if the target is the dialog, the backdrop was clicked\n if (target === this.dialog) {\n this.requestClose('overlay');\n }\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.dispatchEvent(\n new Event('mid-show', { composed: true, bubbles: true })\n );\n // this.addOpenListeners();\n this.dialog.showModal();\n\n if (this.alertdialog) {\n this.dialog.focus();\n }\n\n lockBodyScrolling(this);\n\n const panelAnimation = getAnimation(this, 'dialog.show');\n await animateTo(\n this.dialog,\n panelAnimation.keyframes,\n panelAnimation.options\n );\n this.dispatchEvent(\n new Event('mid-after-show', { bubbles: true, composed: true })\n );\n } else {\n // Hide\n this.dispatchEvent(\n new Event('mid-hide', { bubbles: true, composed: true })\n );\n\n await Promise.all([stopAnimations(this.dialog)]);\n const panelAnimation = getAnimation(this, 'dialog.hide');\n\n // The backdrop can only be animated with css because it's a pseudo element\n // so we add a animation class to trigger it at the same time as the dialog animation\n this.dialog.classList.add('backdrop:animate-fade-out');\n await animateTo(\n this.dialog,\n panelAnimation.keyframes,\n panelAnimation.options\n );\n this.dialog.classList.remove('backdrop:animate-fade-out');\n this.dialog.close();\n this.dialog.hidden = false;\n unlockBodyScrolling(this);\n this.dispatchEvent(\n new Event('mid-after-hide', { composed: true, bubbles: true })\n );\n }\n }\n\n /**\n * Shows the dialog.\n */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'mid-after-show');\n }\n\n /**\n * Hides the dialog\n */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'mid-after-hide');\n }\n\n constructor() {\n super();\n new LangController(this);\n }\n\n override render() {\n const t = getTranslations(getLang(this));\n\n return html`\n <dialog\n part=\"base\"\n id=\"dialog\"\n tabindex=\"-1\"\n role=${this.alertdialog ? 'alertdialog' : 'dialog'}\n aria-label=${this.heading || nothing}\n aria-modal=\"true\"\n class=\"text-neutral m-auto max-h-[calc(100%---spacing(8))] w-(--width) max-w-[calc(100%---spacing(8))] flex-col rounded-lg p-6 shadow-xl backdrop:bg-black/50 open:flex open:animate-none\"\n @cancel=${this.handleDialogCancel}\n @click=${this.handleBackdropClick}\n >\n <header part=\"header\" class=\"text-heading-sm flex justify-between\">\n <slot name=\"heading\"></slot>\n <div class=\"h-0\">\n <button\n autofocus\n aria-label=${t.close}\n @click=\"${() => this.requestClose('close-button')}\"\n class=\"text-body-md focus-visible:focus-ring text-neutral hover:bg-neutral-surface-hover float-right flex size-12 translate-x-3 -translate-y-3 items-center justify-center rounded\"\n >\n <mid-icon class=\"size-6\" name=\"xmark\"></mid-icon>\n </button>\n </div>\n </header>\n <div part=\"body\" class=\"overflow-auto\">\n <slot> </slot>\n </div>\n <footer part=\"footer\">\n <slot name=\"footer\"> </slot>\n </footer>\n </dialog>\n `;\n }\n}\n\nsetDefaultAnimation('dialog.show', {\n keyframes: [\n { opacity: 0, scale: 0.8 },\n { opacity: 1, scale: 1 },\n ],\n options: { duration: 250, easing: 'ease' },\n});\n\nsetDefaultAnimation('dialog.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.8 },\n ],\n options: { duration: 250, easing: 'ease' },\n});\n\nsetDefaultAnimation('dialog.denyClose', {\n keyframes: [{ scale: 1 }, { scale: 1.03 }, { scale: 1 }],\n options: { duration: 100 },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAMF;AA4BO,IAAM,cAAN,cAA0B,OAAO,YAAY,MAAM,EAAE;AAAA,EAwI1D,cAAc;AACZ,UAAA;AAhIF,SAAA,OAAO;AAOP,SAAA,UAAU;AAOV,SAAA,cAAc;AAoBd,SAAA,qBAAqB,CAAC,UAAiB;AACrC,YAAM,eAAA;AAEN,UAAI,MAAM,kBAAkB;AAC1B,aAAK,aAAa,UAAU;AAAA,MAC9B,OAAO;AACL,aAAK,KAAA;AAAA,MACP;AAAA,IACF;AAuFE,QAAI,eAAe,IAAI;AAAA,EACzB;AAAA,EAlHQ,aAAa,QAAiD;AACpE,UAAM,oBAAoB,IAAI,YAAY,qBAAqB;AAAA,MAC7D,SAAS;AAAA,MACT,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ,EAAE,OAAA;AAAA,IAAO,CAClB;AACD,SAAK,cAAc,iBAAiB;AAEpC,QAAI,kBAAkB,kBAAkB;AACtC,YAAM,EAAE,WAAW,QAAA,IAAY,aAAa,MAAM,kBAAkB;AACpE,gBAAU,KAAK,QAAQ,WAAW,OAAO;AACzC;AAAA,IACF;AAEA,SAAK,KAAA;AAAA,EACP;AAAA,EAYQ,oBAAoB,EAAE,UAAiB;AAE7C,QAAI,WAAW,KAAK,QAAQ;AAC1B,WAAK,aAAa,SAAS;AAA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,CAAC;AAED,oBAAoB,eAAe;AAAA,EACjC,WAAW;AAAA,IACT,EAAE,SAAS,GAAG,OAAO,EAAA;AAAA,IACrB,EAAE,SAAS,GAAG,OAAO,IAAA;AAAA,EAAI;AAAA,EAE3B,SAAS,EAAE,UAAU,KAAK,QAAQ,OAAA;AACpC,CAAC;AAED,oBAAoB,oBAAoB;AAAA,EACtC,WAAW,CAAC,EAAE,OAAO,KAAK,EAAE,OAAO,QAAQ,EAAE,OAAO,GAAG;AAAA,EACvD,SAAS,EAAE,UAAU,IAAA;AACvB,CAAC;"}
@@ -9,6 +9,7 @@ declare const MinidSpinner_base: typeof LitElement;
9
9
  * Size and color can be adjusted with `font-size` and `color` css properties
10
10
  */
11
11
  export declare class MinidSpinner extends MinidSpinner_base {
12
+ label: string;
12
13
  render(): import('lit').TemplateResult<1>;
13
14
  }
14
15
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"spinner.component.d.ts","sourceRoot":"","sources":["../../src/components/spinner.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAG5C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,YAAY,CAAC;KAC7B;CACF;;AAUD;;GAEG;AACH,qBACa,YAAa,SAAQ,iBAA0B;IACjD,MAAM;CA6BhB"}
1
+ {"version":3,"file":"spinner.component.d.ts","sourceRoot":"","sources":["../../src/components/spinner.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAW,MAAM,KAAK,CAAC;AAGrD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,YAAY,CAAC;KAC7B;CACF;;AAUD;;GAEG;AACH,qBACa,YAAa,SAAQ,iBAA0B;IAG1D,KAAK,SAAM;IAEF,MAAM;CAiChB"}
@@ -1,12 +1,14 @@
1
- import { customElement } from "lit/decorators.js";
2
- import { css, LitElement, html } from "lit";
1
+ import { property, customElement } from "lit/decorators.js";
2
+ import { css, LitElement, nothing, html } from "lit";
3
3
  import { styled } from "../mixins/tailwind.mixin.js";
4
+ var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __decorateClass = (decorators, target, key, kind) => {
6
7
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
7
8
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
8
9
  if (decorator = decorators[i])
9
- result = decorator(result) || result;
10
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
11
+ if (kind && result) __defProp(target, key, result);
10
12
  return result;
11
13
  };
12
14
  const styles = [
@@ -17,13 +19,19 @@ const styles = [
17
19
  `
18
20
  ];
19
21
  let MinidSpinner = class extends styled(LitElement, styles) {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.label = "";
25
+ }
20
26
  render() {
21
27
  return html`
28
+ ${!this.label ? nothing : html`<span class="sr-only">${this.label}</span>`}
22
29
  <svg
23
30
  class="animate-spin-slow"
24
31
  width="1em"
25
32
  height="1em"
26
33
  viewBox="0 0 50 50"
34
+ aria-hidden="true"
27
35
  >
28
36
  <circle
29
37
  opacity="0.2"
@@ -47,6 +55,9 @@ let MinidSpinner = class extends styled(LitElement, styles) {
47
55
  `;
48
56
  }
49
57
  };
58
+ __decorateClass([
59
+ property()
60
+ ], MinidSpinner.prototype, "label", 2);
50
61
  MinidSpinner = __decorateClass([
51
62
  customElement("mid-spinner")
52
63
  ], MinidSpinner);
@@ -1 +1 @@
1
- {"version":3,"file":"spinner.js","sources":["../../src/components/spinner.component.ts"],"sourcesContent":["import { customElement } from 'lit/decorators.js';\nimport { css, html, LitElement } from 'lit';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-spinner': MinidSpinner;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: inline-flex;\n }\n `,\n];\n\n/**\n * Size and color can be adjusted with `font-size` and `color` css properties\n */\n@customElement('mid-spinner')\nexport class MinidSpinner extends styled(LitElement, styles) {\n override render() {\n return html`\n <svg\n class=\"animate-spin-slow\"\n width=\"1em\"\n height=\"1em\"\n viewBox=\"0 0 50 50\"\n >\n <circle\n opacity=\"0.2\"\n stroke=\"currentColor\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n <circle\n class=\"animate-dash\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n stroke=\"currentColor\"\n ></circle>\n </svg>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAUA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAKF;AAMO,IAAM,eAAN,cAA2B,OAAO,YAAY,MAAM,EAAE;AAAA,EAClD,SAAS;AAChB,WAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BT;AACF;AA9Ba,eAAN,gBAAA;AAAA,EADN,cAAc,aAAa;AAAA,GACf,YAAA;"}
1
+ {"version":3,"file":"spinner.js","sources":["../../src/components/spinner.component.ts"],"sourcesContent":["import { customElement, property } from 'lit/decorators.js';\nimport { css, html, LitElement, nothing } from 'lit';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-spinner': MinidSpinner;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: inline-flex;\n }\n `,\n];\n\n/**\n * Size and color can be adjusted with `font-size` and `color` css properties\n */\n@customElement('mid-spinner')\nexport class MinidSpinner extends styled(LitElement, styles) {\n\n @property()\n label = '';\n\n override render() {\n return html`\n ${!this.label\n ? nothing\n : html`<span class=\"sr-only\">${this.label}</span>`}\n <svg\n class=\"animate-spin-slow\"\n width=\"1em\"\n height=\"1em\"\n viewBox=\"0 0 50 50\"\n aria-hidden=\"true\"\n >\n <circle\n opacity=\"0.2\"\n stroke=\"currentColor\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n <circle\n class=\"animate-dash\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n stroke=\"currentColor\"\n ></circle>\n </svg>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAUA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAKF;AAMO,IAAM,eAAN,cAA2B,OAAO,YAAY,MAAM,EAAE;AAAA,EAAtD,cAAA;AAAA,UAAA,GAAA,SAAA;AAGL,SAAA,QAAQ;AAAA,EAAA;AAAA,EAEC,SAAS;AAChB,WAAO;AAAA,QACH,CAAC,KAAK,QACJ,UACA,6BAA6B,KAAK,KAAK,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BxD;AACF;AAnCE,gBAAA;AAAA,EADC,SAAA;AAAS,GAFC,aAGX,WAAA,SAAA,CAAA;AAHW,eAAN,gBAAA;AAAA,EADN,cAAc,aAAa;AAAA,GACf,YAAA;"}
@@ -8,6 +8,7 @@ export interface ComponentTranslations {
8
8
  hidePassword: string;
9
9
  openCountrySelector: string;
10
10
  close: string;
11
+ loading: string;
11
12
  }
12
13
  /**
13
14
  * Override or extend translations for a given BCP-47 language tag.
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../src/utilities/translations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAsCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAC3C,IAAI,CAIN;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAMnE"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../src/utilities/translations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AA0CD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAC3C,IAAI,CAIN;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAMnE"}
@@ -4,28 +4,32 @@ const builtins = {
4
4
  showPassword: "Vis passord",
5
5
  hidePassword: "Skjul passord",
6
6
  openCountrySelector: "Åpne landsvelger",
7
- close: "Lukk"
7
+ close: "Lukk",
8
+ loading: "Laster"
8
9
  },
9
10
  nn: {
10
11
  clear: "Tøm",
11
12
  showPassword: "Vis passord",
12
13
  hidePassword: "Gøym passord",
13
14
  openCountrySelector: "Opna landsveljar",
14
- close: "Lukk"
15
+ close: "Lukk",
16
+ loading: "Lastar"
15
17
  },
16
18
  se: {
17
19
  clear: "Sihko",
18
20
  showPassword: "Čájet sátnesuodji",
19
21
  hidePassword: "Čiehka sátnesuodji",
20
22
  openCountrySelector: "Rahpat riikkaválljenjoavkku",
21
- close: "Gidde"
23
+ close: "Gidde",
24
+ loading: "Viežžamin"
22
25
  },
23
26
  en: {
24
27
  clear: "Clear",
25
28
  showPassword: "Show password",
26
29
  hidePassword: "Hide password",
27
30
  openCountrySelector: "Open country selector",
28
- close: "Close"
31
+ close: "Close",
32
+ loading: "Loading"
29
33
  }
30
34
  };
31
35
  const registry = new Map(
@@ -1 +1 @@
1
- {"version":3,"file":"translations.js","sources":["../../src/utilities/translations.ts"],"sourcesContent":["/**\n * All UI strings that components render themselves (e.g. aria-labels on\n * icon-only buttons). Every supported language must provide all keys.\n */\nexport interface ComponentTranslations {\n clear: string;\n showPassword: string;\n hidePassword: string;\n openCountrySelector: string;\n close: string;\n}\n\n\nconst builtins: Record<string, ComponentTranslations> = {\n nb: {\n clear: 'Tøm',\n showPassword: 'Vis passord',\n hidePassword: 'Skjul passord',\n openCountrySelector: 'Åpne landsvelger',\n close: 'Lukk',\n },\n nn: {\n clear: 'Tøm',\n showPassword: 'Vis passord',\n hidePassword: 'Gøym passord',\n openCountrySelector: 'Opna landsveljar',\n close: 'Lukk',\n },\n se: {\n clear: 'Sihko',\n showPassword: 'Čájet sátnesuodji',\n hidePassword: 'Čiehka sátnesuodji',\n openCountrySelector: 'Rahpat riikkaválljenjoavkku',\n close: 'Gidde',\n },\n en: {\n clear: 'Clear',\n showPassword: 'Show password',\n hidePassword: 'Hide password',\n openCountrySelector: 'Open country selector',\n close: 'Close',\n },\n};\n\nconst registry = new Map<string, ComponentTranslations>(\n Object.entries(builtins)\n);\n\n/**\n * Override or extend translations for a given BCP-47 language tag.\n * Merges the provided strings with the existing entry for that tag, so you\n * only need to supply the keys you want to change.\n *\n * Call this once at app startup, before any components render.\n *\n * @example Override a single string for Norwegian Bokmål\n * ```ts\n * setTranslations('nb', { clear: 'Slett' });\n * ```\n *\n * @example Register a completely new language\n * ```ts\n * setTranslations('fr', {\n * clear: 'Effacer',\n * showPassword: 'Afficher le mot de passe',\n * hidePassword: 'Masquer le mot de passe',\n * });\n * ```\n */\nexport function setTranslations(\n lang: string,\n translations: Partial<ComponentTranslations>\n): void {\n const base = resolveBaseLang(lang);\n const existing = registry.get(lang) ?? registry.get(base) ?? builtins.nb;\n registry.set(lang, { ...existing, ...translations });\n}\n\n/**\n * Returns the translations for the given BCP-47 language tag.\n *\n * Resolution order:\n * 1. Exact tag match (e.g. `'nb-NO'`)\n * 2. Base language match (e.g. `'nb'` from `'nb-NO'`)\n * 3. Norwegian Bokmål as final fallback\n */\nexport function getTranslations(lang: string): ComponentTranslations {\n return (\n registry.get(lang) ??\n registry.get(resolveBaseLang(lang)) ??\n builtins.nb\n );\n}\n\nfunction resolveBaseLang(lang: string): string {\n return lang.toLowerCase().split('-')[0];\n}"],"names":[],"mappings":"AAaA,MAAM,WAAkD;AAAA,EACtD,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,EAAA;AAAA,EAET,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,EAAA;AAAA,EAET,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,EAAA;AAAA,EAET,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,EAAA;AAEX;AAEA,MAAM,WAAW,IAAI;AAAA,EACnB,OAAO,QAAQ,QAAQ;AACzB;AAuBO,SAAS,gBACd,MACA,cACM;AACN,QAAM,OAAO,gBAAgB,IAAI;AACjC,QAAM,WAAW,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;AACtE,WAAS,IAAI,MAAM,EAAE,GAAG,UAAU,GAAG,cAAc;AACrD;AAUO,SAAS,gBAAgB,MAAqC;AACnE,SACE,SAAS,IAAI,IAAI,KACjB,SAAS,IAAI,gBAAgB,IAAI,CAAC,KAClC,SAAS;AAEb;AAEA,SAAS,gBAAgB,MAAsB;AAC7C,SAAO,KAAK,YAAA,EAAc,MAAM,GAAG,EAAE,CAAC;AACxC;"}
1
+ {"version":3,"file":"translations.js","sources":["../../src/utilities/translations.ts"],"sourcesContent":["/**\n * All UI strings that components render themselves (e.g. aria-labels on\n * icon-only buttons). Every supported language must provide all keys.\n */\nexport interface ComponentTranslations {\n clear: string;\n showPassword: string;\n hidePassword: string;\n openCountrySelector: string;\n close: string;\n loading: string;\n}\n\n\nconst builtins: Record<string, ComponentTranslations> = {\n nb: {\n clear: 'Tøm',\n showPassword: 'Vis passord',\n hidePassword: 'Skjul passord',\n openCountrySelector: 'Åpne landsvelger',\n close: 'Lukk',\n loading: 'Laster',\n },\n nn: {\n clear: 'Tøm',\n showPassword: 'Vis passord',\n hidePassword: 'Gøym passord',\n openCountrySelector: 'Opna landsveljar',\n close: 'Lukk',\n loading: 'Lastar',\n },\n se: {\n clear: 'Sihko',\n showPassword: 'Čájet sátnesuodji',\n hidePassword: 'Čiehka sátnesuodji',\n openCountrySelector: 'Rahpat riikkaválljenjoavkku',\n close: 'Gidde',\n loading: 'Viežžamin',\n },\n en: {\n clear: 'Clear',\n showPassword: 'Show password',\n hidePassword: 'Hide password',\n openCountrySelector: 'Open country selector',\n close: 'Close',\n loading: 'Loading',\n },\n};\n\nconst registry = new Map<string, ComponentTranslations>(\n Object.entries(builtins)\n);\n\n/**\n * Override or extend translations for a given BCP-47 language tag.\n * Merges the provided strings with the existing entry for that tag, so you\n * only need to supply the keys you want to change.\n *\n * Call this once at app startup, before any components render.\n *\n * @example Override a single string for Norwegian Bokmål\n * ```ts\n * setTranslations('nb', { clear: 'Slett' });\n * ```\n *\n * @example Register a completely new language\n * ```ts\n * setTranslations('fr', {\n * clear: 'Effacer',\n * showPassword: 'Afficher le mot de passe',\n * hidePassword: 'Masquer le mot de passe',\n * });\n * ```\n */\nexport function setTranslations(\n lang: string,\n translations: Partial<ComponentTranslations>\n): void {\n const base = resolveBaseLang(lang);\n const existing = registry.get(lang) ?? registry.get(base) ?? builtins.nb;\n registry.set(lang, { ...existing, ...translations });\n}\n\n/**\n * Returns the translations for the given BCP-47 language tag.\n *\n * Resolution order:\n * 1. Exact tag match (e.g. `'nb-NO'`)\n * 2. Base language match (e.g. `'nb'` from `'nb-NO'`)\n * 3. Norwegian Bokmål as final fallback\n */\nexport function getTranslations(lang: string): ComponentTranslations {\n return (\n registry.get(lang) ??\n registry.get(resolveBaseLang(lang)) ??\n builtins.nb\n );\n}\n\nfunction resolveBaseLang(lang: string): string {\n return lang.toLowerCase().split('-')[0];\n}"],"names":[],"mappings":"AAcA,MAAM,WAAkD;AAAA,EACtD,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAEb;AAEA,MAAM,WAAW,IAAI;AAAA,EACnB,OAAO,QAAQ,QAAQ;AACzB;AAuBO,SAAS,gBACd,MACA,cACM;AACN,QAAM,OAAO,gBAAgB,IAAI;AACjC,QAAM,WAAW,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;AACtE,WAAS,IAAI,MAAM,EAAE,GAAG,UAAU,GAAG,cAAc;AACrD;AAUO,SAAS,gBAAgB,MAAqC;AACnE,SACE,SAAS,IAAI,IAAI,KACjB,SAAS,IAAI,gBAAgB,IAAI,CAAC,KAClC,SAAS;AAEb;AAEA,SAAS,gBAAgB,MAAsB;AAC7C,SAAO,KAAK,YAAA,EAAc,MAAM,GAAG,EAAE,CAAC;AACxC;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felleslosninger/minid-elements",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "MinID Web Components",
5
5
  "author": "Digitaliseringsdirektoratet",
6
6
  "license": "MIT",
@@ -174,6 +174,7 @@
174
174
  "@changesets/cli": "^2.30.0",
175
175
  "@custom-elements-manifest/analyzer": "^0.10.3",
176
176
  "@digdir/designsystemet": "^1.13.2",
177
+ "@eslint/js": "^10.0.1",
177
178
  "@floating-ui/dom": "^1.6.10",
178
179
  "@navikt/aksel-icons": "^7.1.2",
179
180
  "@storybook/addon-a11y": "^9.0.12",
@@ -181,30 +182,26 @@
181
182
  "@storybook/addon-links": "^9.0.12",
182
183
  "@storybook/addon-vitest": "^9.0.12",
183
184
  "@storybook/builder-vite": "^9.0.12",
184
- "@storybook/test": "^8.6.14",
185
- "@storybook/test-runner": "^0.23.0",
186
185
  "@storybook/web-components-vite": "^9.0.12",
187
186
  "@tailwindcss/cli": "^4.1.6",
188
187
  "@types/node": "^22.7.4",
189
188
  "@types/qrcode": "^1.5.5",
190
189
  "@types/react": "^19.1.2",
191
190
  "@types/webappsec-credential-management": "^0.6.9",
192
- "@typescript-eslint/eslint-plugin": "^8.31.0",
193
- "@typescript-eslint/parser": "^8.31.0",
194
191
  "@u-elements/u-datalist": "^1.0.5",
195
192
  "@vitejs/plugin-basic-ssl": "^2.0.0",
196
193
  "@vitejs/plugin-legacy": "^6.1.0",
197
- "@vitest/browser": "^3.2.4",
198
- "@vitest/coverage-istanbul": "^3.2.4",
199
- "@vitest/coverage-v8": "^3.2.4",
200
- "axe-playwright": "^2.1.0",
201
- "concurrently": "^9.0.1",
202
- "eslint": "^9.25.1",
194
+ "@vitest/browser": "^3.2.7",
195
+ "@vitest/coverage-istanbul": "^3.2.7",
196
+ "@vitest/coverage-v8": "^3.2.7",
197
+ "concurrently": "^9.2.4",
198
+ "eslint": "^10.8.0",
203
199
  "eslint-plugin-storybook": "^9.0.12",
204
200
  "glob": "^13.0.6",
201
+ "globals": "^17.8.0",
205
202
  "jsdom": "^26.1.0",
206
203
  "playwright": "^1.53.0",
207
- "postcss": "^8.5.1",
204
+ "postcss": "^8.5.24",
208
205
  "prettier": "^3.5.3",
209
206
  "prettier-plugin-tailwindcss": "^0.6.11",
210
207
  "rimraf": "^6.0.1",
@@ -216,11 +213,12 @@
216
213
  "terser": "^5.24.0",
217
214
  "tslib": "^2.8.0",
218
215
  "typescript": "^5.6.3",
219
- "vite": "^6.1.0",
216
+ "typescript-eslint": "^8.65.0",
217
+ "vite": "^6.4.3",
220
218
  "vite-plugin-dts": "^4.2.3",
221
219
  "vite-plugin-externalize-deps": "^0.8.0",
222
220
  "vite-plugin-web-components-hmr": "^0.1.3",
223
- "vitest": "^3.2.4"
221
+ "vitest": "^3.2.7"
224
222
  },
225
223
  "scripts": {
226
224
  "make-icons": "node ./scripts/make-icons.js",
@@ -232,6 +230,7 @@
232
230
  "storybook:dev": "concurrently --kill-others \"pnpm run analyze -- --watch\" \"npx @tailwindcss/cli -i ./src/styles/tailwind.css -o ./.storybook/public/tailwind.css --watch\" \"pnpm run storybook\"",
233
231
  "storybook:build": "pnpm run build && rimraf storybook-static && pnpm run analyze && npx @tailwindcss/cli -i ./src/styles/tailwind.css -o ./.storybook/public/tailwind.css && pnpm exec storybook build",
234
232
  "analyze": "custom-elements-manifest analyze",
233
+ "lint": "eslint .",
235
234
  "build:theme": "pnpm exec designsystemet tokens create --config designsystemet.config.json && pnpm exec designsystemet tokens build --config designsystemet.config.json --experimental-tailwind",
236
235
  "release": "pnpm build && pnpm exec changeset publish"
237
236
  }