@felleslosninger/minid-elements 0.1.4 → 0.1.6
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/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.js +4 -2
- package/dist/components/alert.js.map +1 -1
- package/dist/components/button.component.d.ts +1 -0
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.js +7 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/checkbox.component.d.ts +8 -0
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.js +49 -3
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/code-input.component.d.ts +23 -0
- package/dist/components/code-input.component.d.ts.map +1 -1
- package/dist/components/code-input.js +167 -25
- package/dist/components/code-input.js.map +1 -1
- package/dist/components/dialog.js +2 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/spinner.component.d.ts +1 -0
- package/dist/components/spinner.component.d.ts.map +1 -1
- package/dist/components/spinner.js +14 -3
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/textfield.component.d.ts +1 -0
- package/dist/components/textfield.component.d.ts.map +1 -1
- package/dist/components/textfield.js +17 -2
- package/dist/components/textfield.js.map +1 -1
- package/dist/utilities/translations.d.ts +1 -0
- package/dist/utilities/translations.d.ts.map +1 -1
- package/dist/utilities/translations.js +8 -4
- package/dist/utilities/translations.js.map +1 -1
- package/package.json +13 -14
|
@@ -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;I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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,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,EACjC,QAAQ,UAAO;IA+DR,MAAM;CAsEhB"}
|
package/dist/components/alert.js
CHANGED
|
@@ -182,7 +182,9 @@ let MinidAlert = class extends styled(LitElement) {
|
|
|
182
182
|
@mouseenter=${this.pauseAutoHide}
|
|
183
183
|
@mouseleave=${this.resumeAutoHide}
|
|
184
184
|
>
|
|
185
|
-
<div
|
|
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
|
|
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,KAAK,qBAAqB;AACxC,QAAI,KAAK,QAAQ,KAAK,WAAW,UAAU;AACzC,WAAK,kBAAkB,OAAO;AAAA,QAC5B,MAAM,KAAK,KAAA;AAAA,QACX,KAAK;AAAA,MAAA;AAEP,WAAK,gBAAgB,KAAK;AAC1B,WAAK,wBAAwB,OAAO,YAAY,MAAM;AACpD,aAAK,iBAAiB;AAAA,MACxB,GAAG,GAAG;AAAA,IACR;AAAA,EACF;AAAA,EAEQ,gBAAgB;AACtB,iBAAa,KAAK,eAAe;AACjC,kBAAc,KAAK,qBA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C,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,WAAW,UAAU;AACzC,WAAK,kBAAkB,OAAO;AAAA,QAC5B,MAAM,KAAK,KAAA;AAAA,QACX,KAAK;AAAA,MAAA;AAEP,WAAK,gBAAgB,KAAK;AAC1B,WAAK,wBAAwB,OAAO,YAAY,MAAM;AACpD,aAAK,iBAAiB;AAAA,MACxB,GAAG,GAAG;AAAA,IACR;AAAA,EACF;AAAA,EAEQ,gBAAgB;AACtB,iBAAa,KAAK,eAAe;AACjC,kBAAc,KAAK,qBAAqB;AAAA,EAC1C;AAAA,EAEQ,iBAA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E,SAAS,GAAG,OAAO,EAAA;AAAA,IACrB,EAAE,SAAS,GAAG,OAAO,IAAA;AAAA,EAAI;AAAA,EAE3B,SAAS,EAAE,UAAU,KAAK,QAAQ,UAAA;AACpC,CAAC;"}
|
|
@@ -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;
|
|
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;AAMhC,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;;OAEG;IAEH,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAEzB;;OAEG;IAEH,QAAQ,UAAS;IAEjB;;OAEG;IAEH,OAAO,UAAS;IAEhB;;OAEG;IAEH,WAAW,SAAM;IAEjB;;OAEG;IAEH,UAAU,UAAS;;IAOnB,WAAW;IASX,OAAO,KAAK,MAAM,GAEjB;IAED,KAAK;IAIL,IAAI;IAIJ,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY;IAInB,MAAM;CAmEhB"}
|
|
@@ -6,6 +6,9 @@ import { literal, 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(
|
|
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":"
|
|
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,QAAQ;AAMR,SAAA,UAAgD;AAMhD,SAAA,OAA2B;AAM3B,SAAA,OAAsC;AAYtC,SAAA,WAAW;AAMX,SAAA,UAAU;AAMV,SAAA,cAAc;AAMd,SAAA,aAAa;AAIX,QAAI,eAAe,IAAI;AAAA,EACzB;AAAA,EAEA,cAAc;AACZ,QAAI,KAAK,SAAS,UAAU;AAC1B,WAAK,SAAS,KAAK,SAAS,KAAK,KAAK;AACtC,WAAK,UAAU,MAAM,cAAA;AAAA,IACvB,WAAW,KAAK,SAAS,SAAS;AAChC,WAAK,UAAU,MAAM,MAAA;AAAA,IACvB;AAAA,EACF;AAAA,EAEA,IAAY,SAAS;AACnB,WAAO,CAAC,CAAC,KAAK;AAAA,EAChB;AAAA,EAEA,QAA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MA,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;"}
|
|
@@ -9,10 +9,17 @@ declare const MinidCheckbox_base: import('../types/mixin-constructor.ts').Constr
|
|
|
9
9
|
* @slot -- The default slot for the label text of the checkbox
|
|
10
10
|
* @slot description - The slot for the description text of the checkbox
|
|
11
11
|
*
|
|
12
|
+
* @csspart label - The checkbox's label.
|
|
13
|
+
* @csspart description - The checkbox's description.
|
|
14
|
+
* @csspart validation-message - The error message shown by `invalidmessage`.
|
|
15
|
+
*
|
|
12
16
|
* @event mid-change - Emitted when the checked state changes
|
|
13
17
|
*/
|
|
14
18
|
export declare class MinidCheckbox extends MinidCheckbox_base {
|
|
15
19
|
private input;
|
|
20
|
+
private readonly hasSlotController;
|
|
21
|
+
private readonly descriptionId;
|
|
22
|
+
private readonly validationId;
|
|
16
23
|
/**
|
|
17
24
|
* The name of the checkbox, submitted as a name/value pair with form data.
|
|
18
25
|
*/
|
|
@@ -26,6 +33,7 @@ export declare class MinidCheckbox extends MinidCheckbox_base {
|
|
|
26
33
|
disabled: boolean;
|
|
27
34
|
readonly: boolean;
|
|
28
35
|
invalid: boolean;
|
|
36
|
+
invalidmessage: string;
|
|
29
37
|
required: boolean;
|
|
30
38
|
static get formControlValidators(): import('../types/validator.type.ts').Validator[];
|
|
31
39
|
shouldFormValueUpdate(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.component.d.ts","sourceRoot":"","sources":["../../src/components/checkbox.component.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"checkbox.component.d.ts","sourceRoot":"","sources":["../../src/components/checkbox.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAK5C,OAAO,0BAA0B,CAAC;AAOlC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,aAAa,CAAC;KAC/B;CACF;;AAUD;;;;;;;;;GASG;AAEH,qBACa,aAAc,SAAQ,kBAElC;IAEC,OAAO,CAAC,KAAK,CAAoB;IAEjC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAGhC;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgB;IAE7C;;OAEG;IAEH,IAAI,SAAM;IAEV;;OAEG;IAEH,KAAK,SAAQ;IAGb,OAAO,UAAS;IAGhB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,QAAQ,UAAS;IAGjB,QAAQ,UAAS;IAGjB,OAAO,UAAS;IAGhB,cAAc,SAAM;IAGpB,QAAQ,UAAS;IAEjB,MAAM,KAAK,qBAAqB,qDAE/B;IAED,qBAAqB,IAAI,OAAO;IAIhC,IAAI,gBAAgB,qBAEnB;IAED,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY;IAI5B;;OAEG;IACH,IAAI;IAKJ,iBAAiB;IAKR,MAAM;CAoEhB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { LitElement, html } from "lit";
|
|
1
|
+
import { css, LitElement, html } from "lit";
|
|
2
2
|
import { query, property, customElement } from "lit/decorators.js";
|
|
3
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
3
4
|
import { live } from "lit/directives/live.js";
|
|
4
5
|
import { styled } from "../mixins/tailwind.mixin.js";
|
|
5
6
|
import "./icon/icon.js";
|
|
@@ -7,6 +8,7 @@ import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
7
8
|
import { FormControlMixin } from "../mixins/form-control.mixin.js";
|
|
8
9
|
import { watch } from "../internal/watch.js";
|
|
9
10
|
import { requiredValidator } from "../mixins/validators.js";
|
|
11
|
+
import { HasSlotController } from "../internal/slot.js";
|
|
10
12
|
var __defProp = Object.defineProperty;
|
|
11
13
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
14
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -17,15 +19,31 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
17
19
|
if (kind && result) __defProp(target, key, result);
|
|
18
20
|
return result;
|
|
19
21
|
};
|
|
20
|
-
|
|
22
|
+
const styles = [
|
|
23
|
+
css`
|
|
24
|
+
.description {
|
|
25
|
+
color: var(--ds-color-neutral-text-subtle);
|
|
26
|
+
}
|
|
27
|
+
`
|
|
28
|
+
];
|
|
29
|
+
let MinidCheckbox = class extends FormControlMixin(
|
|
30
|
+
styled(LitElement, styles)
|
|
31
|
+
) {
|
|
21
32
|
constructor() {
|
|
22
33
|
super(...arguments);
|
|
34
|
+
this.hasSlotController = new HasSlotController(
|
|
35
|
+
this,
|
|
36
|
+
"description"
|
|
37
|
+
);
|
|
38
|
+
this.descriptionId = "description";
|
|
39
|
+
this.validationId = "validation";
|
|
23
40
|
this.name = "";
|
|
24
41
|
this.value = "on";
|
|
25
42
|
this.checked = false;
|
|
26
43
|
this.disabled = false;
|
|
27
44
|
this.readonly = false;
|
|
28
45
|
this.invalid = false;
|
|
46
|
+
this.invalidmessage = "";
|
|
29
47
|
this.required = false;
|
|
30
48
|
}
|
|
31
49
|
static get formControlValidators() {
|
|
@@ -73,6 +91,12 @@ let MinidCheckbox = class extends FormControlMixin(styled(LitElement)) {
|
|
|
73
91
|
this.setValue(this.value);
|
|
74
92
|
}
|
|
75
93
|
render() {
|
|
94
|
+
const hasDescription = !!this.description || this.hasSlotController.test("description");
|
|
95
|
+
const isInvalid = this.invalid || !!this.invalidmessage;
|
|
96
|
+
const describedBy = [
|
|
97
|
+
hasDescription ? this.descriptionId : void 0,
|
|
98
|
+
this.invalidmessage ? this.validationId : void 0
|
|
99
|
+
].filter(Boolean).join(" ") || void 0;
|
|
76
100
|
return html`
|
|
77
101
|
<ds-field class="ds-field">
|
|
78
102
|
<input
|
|
@@ -85,6 +109,11 @@ let MinidCheckbox = class extends FormControlMixin(styled(LitElement)) {
|
|
|
85
109
|
?checked=${this.checked}
|
|
86
110
|
?readonly=${this.readonly}
|
|
87
111
|
?required=${this.required}
|
|
112
|
+
aria-invalid=${isInvalid ? "true" : "false"}
|
|
113
|
+
aria-describedby=${ifDefined(describedBy)}
|
|
114
|
+
aria-errormessage=${ifDefined(
|
|
115
|
+
this.invalidmessage ? this.validationId : void 0
|
|
116
|
+
)}
|
|
88
117
|
@click=${this.handleClick}
|
|
89
118
|
@keydown=${this.handleKeydown}
|
|
90
119
|
/>
|
|
@@ -95,7 +124,11 @@ let MinidCheckbox = class extends FormControlMixin(styled(LitElement)) {
|
|
|
95
124
|
>
|
|
96
125
|
<slot></slot>
|
|
97
126
|
</label>
|
|
98
|
-
<div
|
|
127
|
+
<div
|
|
128
|
+
class="description"
|
|
129
|
+
id="${this.descriptionId}"
|
|
130
|
+
aria-hidden="true"
|
|
131
|
+
>
|
|
99
132
|
<slot
|
|
100
133
|
name="description"
|
|
101
134
|
part="description"
|
|
@@ -103,6 +136,16 @@ let MinidCheckbox = class extends FormControlMixin(styled(LitElement)) {
|
|
|
103
136
|
${this.description}
|
|
104
137
|
</slot>
|
|
105
138
|
</div>
|
|
139
|
+
<p
|
|
140
|
+
class="${classMap({
|
|
141
|
+
"ds-validation-message": !!this.invalidmessage
|
|
142
|
+
})}"
|
|
143
|
+
part="validation-message"
|
|
144
|
+
id="${this.validationId}"
|
|
145
|
+
aria-live="polite"
|
|
146
|
+
>
|
|
147
|
+
${this.invalidmessage}
|
|
148
|
+
</p>
|
|
106
149
|
</ds-field>
|
|
107
150
|
`;
|
|
108
151
|
}
|
|
@@ -131,6 +174,9 @@ __decorateClass([
|
|
|
131
174
|
__decorateClass([
|
|
132
175
|
property({ type: Boolean })
|
|
133
176
|
], MinidCheckbox.prototype, "invalid", 2);
|
|
177
|
+
__decorateClass([
|
|
178
|
+
property()
|
|
179
|
+
], MinidCheckbox.prototype, "invalidmessage", 2);
|
|
134
180
|
__decorateClass([
|
|
135
181
|
property({ type: Boolean, reflect: true })
|
|
136
182
|
], MinidCheckbox.prototype, "required", 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","sources":["../../src/components/checkbox.component.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { live } from 'lit/directives/live.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport './icon/icon.component.ts';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { FormControlMixin } from '../mixins/form-control.mixin.ts';\nimport { watch } from '../internal/watch.ts';\nimport { requiredValidator } from '../mixins/validators.ts';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-checkbox': MinidCheckbox;\n }\n}\n\n/**\n * @slot -- The default slot for the label text of the checkbox\n * @slot description - The slot for the description text of the checkbox\n *\n * @event mid-change - Emitted when the checked state changes\n */\n\n@customElement('mid-checkbox')\nexport class MinidCheckbox extends FormControlMixin(styled(LitElement)) {\n @query('input[type=\"checkbox\"]')\n private input!: HTMLInputElement;\n\n /**\n * The name of the checkbox, submitted as a name/value pair with form data.\n */\n @property()\n name = '';\n\n /**\n * The current value of the checkbox, submitted as a name/value pair with form data.\n */\n @property()\n value = 'on';\n\n @property({ type: Boolean })\n checked = false;\n\n @property()\n description?: string;\n\n @property({ type: Boolean })\n disabled = false;\n\n @property({ type: Boolean })\n readonly = false;\n\n @property({ type: Boolean })\n invalid = false;\n\n @property({ type: Boolean, reflect: true })\n required = false;\n\n static get formControlValidators() {\n return [requiredValidator];\n }\n\n shouldFormValueUpdate(): boolean {\n return this.checked;\n }\n\n get validationTarget() {\n return this.input;\n }\n\n private handleKeydown(event: KeyboardEvent) {\n const hasModifier =\n event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n\n // Pressing enter when focused on an input should submit the form like a native input, but we wait a tick before\n // submitting to allow users to cancel the keydown event if they need to\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n //\n // When using an Input Method Editor (IME), pressing enter will cause the form to submit unexpectedly. One way\n // to check for this is to look at event.isComposing, which will be true when the IME is open.\n if (!event.defaultPrevented && !event.isComposing) {\n this.form.requestSubmit();\n }\n });\n }\n }\n\n private handleClick() {\n this.checked = !this.checked;\n // this.indeterminate = false;\n this.dispatchEvent(new Event('mid-change'));\n }\n\n /**\n * Simulates a click on the checkbox.\n */\n click() {\n this.input.click();\n }\n\n /**\n * Sets focus on the checkbox.\n */\n focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /**\n * Removes focus from the checkbox.\n */\n blur() {\n this.input.blur();\n }\n\n @watch(['checked', 'value'])\n handleStateChange() {\n // this.input.indeterminate = this.indeterminate; // force a sync update\n this.setValue(this.value);\n }\n\n override render() {\n\n return html`\n <ds-field class=\"ds-field\">\n <input\n id=\"input\"\n class=\"ds-input\"\n type=\"checkbox\"\n value=${ifDefined(this.value)}\n .checked=${live(this.checked)}\n ?disabled=${this.disabled}\n ?checked=${this.checked}\n ?readonly=${this.readonly}\n ?required=${this.required}\n @click=${this.handleClick}\n @keydown=${this.handleKeydown}\n />\n <label\n class=\"ds-label\"\n part=\"label\"\n for=\"input\"\n >\n <slot></slot>\n </label>\n <div
|
|
1
|
+
{"version":3,"file":"checkbox.js","sources":["../../src/components/checkbox.component.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { live } from 'lit/directives/live.js';\nimport { styled } from '../mixins/tailwind.mixin';\nimport './icon/icon.component.ts';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { FormControlMixin } from '../mixins/form-control.mixin.ts';\nimport { watch } from '../internal/watch.ts';\nimport { requiredValidator } from '../mixins/validators.ts';\nimport { HasSlotController } from '../internal/slot.ts';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-checkbox': MinidCheckbox;\n }\n}\n\nconst styles = [\n css`\n .description {\n color: var(--ds-color-neutral-text-subtle);\n }\n `,\n];\n\n/**\n * @slot -- The default slot for the label text of the checkbox\n * @slot description - The slot for the description text of the checkbox\n *\n * @csspart label - The checkbox's label.\n * @csspart description - The checkbox's description.\n * @csspart validation-message - The error message shown by `invalidmessage`.\n *\n * @event mid-change - Emitted when the checked state changes\n */\n\n@customElement('mid-checkbox')\nexport class MinidCheckbox extends FormControlMixin(\n styled(LitElement, styles)\n) {\n @query('input[type=\"checkbox\"]')\n private input!: HTMLInputElement;\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'description'\n );\n\n private readonly descriptionId = 'description';\n private readonly validationId = 'validation';\n\n /**\n * The name of the checkbox, submitted as a name/value pair with form data.\n */\n @property()\n name = '';\n\n /**\n * The current value of the checkbox, submitted as a name/value pair with form data.\n */\n @property()\n value = 'on';\n\n @property({ type: Boolean })\n checked = false;\n\n @property()\n description?: string;\n\n @property({ type: Boolean })\n disabled = false;\n\n @property({ type: Boolean })\n readonly = false;\n\n @property({ type: Boolean })\n invalid = false;\n\n @property()\n invalidmessage = '';\n\n @property({ type: Boolean, reflect: true })\n required = false;\n\n static get formControlValidators() {\n return [requiredValidator];\n }\n\n shouldFormValueUpdate(): boolean {\n return this.checked;\n }\n\n get validationTarget() {\n return this.input;\n }\n\n private handleKeydown(event: KeyboardEvent) {\n const hasModifier =\n event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n\n // Pressing enter when focused on an input should submit the form like a native input, but we wait a tick before\n // submitting to allow users to cancel the keydown event if they need to\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n //\n // When using an Input Method Editor (IME), pressing enter will cause the form to submit unexpectedly. One way\n // to check for this is to look at event.isComposing, which will be true when the IME is open.\n if (!event.defaultPrevented && !event.isComposing) {\n this.form.requestSubmit();\n }\n });\n }\n }\n\n private handleClick() {\n this.checked = !this.checked;\n // this.indeterminate = false;\n this.dispatchEvent(new Event('mid-change'));\n }\n\n /**\n * Simulates a click on the checkbox.\n */\n click() {\n this.input.click();\n }\n\n /**\n * Sets focus on the checkbox.\n */\n focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /**\n * Removes focus from the checkbox.\n */\n blur() {\n this.input.blur();\n }\n\n @watch(['checked', 'value'])\n handleStateChange() {\n // this.input.indeterminate = this.indeterminate; // force a sync update\n this.setValue(this.value);\n }\n\n override render() {\n const hasDescription =\n !!this.description || this.hasSlotController.test('description');\n const isInvalid = this.invalid || !!this.invalidmessage;\n const describedBy =\n [\n hasDescription ? this.descriptionId : undefined,\n this.invalidmessage ? this.validationId : undefined,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n\n // The description wrapper is aria-hidden. It is already announced through\n // the aria-describedby above, and without this the text is also reachable as\n // its own node when navigating the page, so it is read out twice.\n\n return html`\n <ds-field class=\"ds-field\">\n <input\n id=\"input\"\n class=\"ds-input\"\n type=\"checkbox\"\n value=${ifDefined(this.value)}\n .checked=${live(this.checked)}\n ?disabled=${this.disabled}\n ?checked=${this.checked}\n ?readonly=${this.readonly}\n ?required=${this.required}\n aria-invalid=${isInvalid ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy)}\n aria-errormessage=${ifDefined(\n this.invalidmessage ? this.validationId : undefined\n )}\n @click=${this.handleClick}\n @keydown=${this.handleKeydown}\n />\n <label\n class=\"ds-label\"\n part=\"label\"\n for=\"input\"\n >\n <slot></slot>\n </label>\n <div\n class=\"description\"\n id=\"${this.descriptionId}\"\n aria-hidden=\"true\"\n >\n <slot\n name=\"description\"\n part=\"description\"\n >\n ${this.description}\n </slot>\n </div>\n <p\n class=\"${classMap({\n 'ds-validation-message': !!this.invalidmessage,\n })}\"\n part=\"validation-message\"\n id=\"${this.validationId}\"\n a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B,cAIH,WAAA,SAAA,CAAA;AAcR,gBAAA;AAAA,EADC,SAAA;AAAS,GAjBC,cAkBX,WAAA,QAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAA;AAAS,GAvBC,cAwBX,WAAA,SAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GA1BhB,cA2BX,WAAA,WAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GA7BC,cA8BX,WAAA,eAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAhChB,cAiCX,WAAA,YAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAnChB,cAoCX,WAAA,YAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAtChB,cAuCX,WAAA,WAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAA;AAAS,GAzCC,cA0CX,WAAA,kBAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GA5C/B,cA6CX,WAAA,YAAA,CAAA;AA4DA,gBAAA;AAAA,EADC,MAAM,CAAC,WAAW,OAAO,CAAC;AAAA,GAxGhB,cAyGX,WAAA,qBAAA,CAAA;AAzGW,gBAAN,gBAAA;AAAA,EADN,cAAc,cAAc;AAAA,GAChB,aAAA;"}
|
|
@@ -14,10 +14,13 @@ declare const MinidCodeInput_base: import('../types/mixin-constructor.ts').Const
|
|
|
14
14
|
* @event {detail: { validity: ValidityState }} mid-invalid-show - Emitted when the error message should be shown
|
|
15
15
|
*
|
|
16
16
|
* @slot label - The input's label if you need to use HTML. Alternatively, you can use the `label` attribute.
|
|
17
|
+
* @slot description - The input's description if you need to use HTML. Alternatively, you can use the `description` attribute.
|
|
17
18
|
*
|
|
18
19
|
* @csspart input-container - The wrapper around the input elements. This can be used to adjust font-size.
|
|
20
|
+
* @csspart description - The description shown between the label and the character boxes.
|
|
19
21
|
* @csspart character-boxes - The container for the visual character boxes.
|
|
20
22
|
* @csspart character-box - An individual character box.
|
|
23
|
+
* @csspart validation-message - The error message shown by `invalidmessage`.
|
|
21
24
|
*
|
|
22
25
|
* @method focus - Focuses the input element
|
|
23
26
|
* @method clear - Clears the input
|
|
@@ -25,10 +28,12 @@ declare const MinidCodeInput_base: import('../types/mixin-constructor.ts').Const
|
|
|
25
28
|
export declare class MinidCodeInput extends MinidCodeInput_base {
|
|
26
29
|
private readonly hasSlotControler;
|
|
27
30
|
private readonly labelId;
|
|
31
|
+
private readonly descriptionId;
|
|
28
32
|
private readonly validationId;
|
|
29
33
|
private inputElement;
|
|
30
34
|
value: string;
|
|
31
35
|
label: string;
|
|
36
|
+
description: string;
|
|
32
37
|
type: 'number' | 'text';
|
|
33
38
|
/**
|
|
34
39
|
* For displaying appropriate virtual keyboard
|
|
@@ -38,6 +43,7 @@ export declare class MinidCodeInput extends MinidCodeInput_base {
|
|
|
38
43
|
* Adjusts the font-size of the code inputs
|
|
39
44
|
*/
|
|
40
45
|
size: 'sm' | 'md' | 'lg';
|
|
46
|
+
labelsize?: 'sm' | 'md' | 'lg';
|
|
41
47
|
/**
|
|
42
48
|
* Number of input characters or digits
|
|
43
49
|
*/
|
|
@@ -59,6 +65,7 @@ export declare class MinidCodeInput extends MinidCodeInput_base {
|
|
|
59
65
|
* Visually hides `label` (still available for screen readers)
|
|
60
66
|
*/
|
|
61
67
|
hidelabel: boolean;
|
|
68
|
+
hidedescription: boolean;
|
|
62
69
|
/**
|
|
63
70
|
* Makes the input required
|
|
64
71
|
*/
|
|
@@ -68,13 +75,28 @@ export declare class MinidCodeInput extends MinidCodeInput_base {
|
|
|
68
75
|
*/
|
|
69
76
|
pattern?: string;
|
|
70
77
|
private isFocused;
|
|
78
|
+
private caretPosition;
|
|
71
79
|
static get formControlValidators(): import('../types/validator.type.ts').Validator[];
|
|
72
80
|
get validationTarget(): HTMLInputElement;
|
|
73
81
|
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
82
|
+
connectedCallback(): void;
|
|
83
|
+
disconnectedCallback(): void;
|
|
74
84
|
private handleBoxClick;
|
|
85
|
+
/**
|
|
86
|
+
* Catches caret moves we did not make - arrow keys, Home/End, word jumps,
|
|
87
|
+
* shift-selection - without enumerating keys, and keeps up while a key is held.
|
|
88
|
+
*
|
|
89
|
+
* Must be listened for on the document: for a caret move the user made,
|
|
90
|
+
* Chromium fires it only there, not at the input and not into the shadow root,
|
|
91
|
+
* so an `@selectionchange` binding on either never runs.
|
|
92
|
+
*/
|
|
93
|
+
private handleSelectionChange;
|
|
94
|
+
private syncCaretPosition;
|
|
75
95
|
private handleFocus;
|
|
76
96
|
private handleBlur;
|
|
97
|
+
private filterValue;
|
|
77
98
|
private handleBeforeInput;
|
|
99
|
+
private handlePaste;
|
|
78
100
|
private handleInput;
|
|
79
101
|
private handleChange;
|
|
80
102
|
private handleKeydown;
|
|
@@ -82,6 +104,7 @@ export declare class MinidCodeInput extends MinidCodeInput_base {
|
|
|
82
104
|
resetFormControl(): void;
|
|
83
105
|
focus(options?: FocusOptions): void;
|
|
84
106
|
handleLengthChange(): void;
|
|
107
|
+
handleValueChange(): void;
|
|
85
108
|
render(): import('lit').TemplateResult<1>;
|
|
86
109
|
}
|
|
87
110
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-input.component.d.ts","sourceRoot":"","sources":["../../src/components/code-input.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,
|
|
1
|
+
{"version":3,"file":"code-input.component.d.ts","sourceRoot":"","sources":["../../src/components/code-input.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAW,cAAc,EAAE,MAAM,KAAK,CAAC;AASrE,OAAO,0BAA0B,CAAC;AASlC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,g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