UNPKG

dap-design-system

Version:

Official design system for the DÁP (dap.gov.hu)

72 lines (71 loc) 2.53 kB
import { clsx as d } from "../../node_modules/clsx/dist/clsx.js"; import "../../node_modules/@lit/reactive-element/reactive-element.js"; import { html as l } from "../../node_modules/lit-html/lit-html.js"; import "../../node_modules/lit-element/lit-element.js"; import { property as r } from "../../node_modules/@lit/reactive-element/decorators/property.js"; import { ifDefined as u } from "../../node_modules/lit-html/directives/if-defined.js"; import "../../localization/localization.js"; import m from "../icon/icon.component.js"; import b from "../icon-button/icon-button.component.js"; import { InputBaseElement as y } from "../input/input-base-element.js"; import { translate as h } from "../../node_modules/lit-i18n/src/lit-i18n.js"; var f = Object.defineProperty, c = (p, o, n, v) => { for (var t = void 0, s = p.length - 1, a; s >= 0; s--) (a = p[s]) && (t = a(o, n, t) || t); return t && f(o, n, t), t; }; const e = class e extends y { constructor() { super(), this.copyButtonTestId = "copybox-copy-button", this.type = "text"; } render() { return this.renderInput( l`<span class=${d("input__addon-postfix copybox-input")} part="base"> <dap-ds-icon-button part="button" exportparts="base: copy-button-base, content: copy-button-content" data-testid=${this.copyButtonTestId} icon="clipboard-line" size=${u(this.size)} ?disabled=${this.disabled} aria-label=${this.copyButtonAriaLabel ? this.copyButtonAriaLabel : h("copy")} @click="${this.onCopy}"> <slot name="copy-icon"> <dap-ds-icon name="clipboard-line" part="copy-icon" exportparts="icon: copy-icon, base: copy-icon-base"></dap-ds-icon> </slot> </dap-ds-icon-button> </span>` ); } onCopy() { const o = this.innerInput; this.value = o.value, this.emit("dds-copy", { value: this.value }), this.copyToClipboard(); } copyToClipboard() { navigator.clipboard.writeText(this.value).then(() => { this.emit("dds-copy", { value: this.value }); }).catch(() => { this.emit("dds-not-allowed"); }); } }; e.tagName = "dap-ds-copybox-input", e.dependencies = { "dap-ds-icon-button": b, "dap-ds-icon": m }; let i = e; c([ r({ type: String }) ], i.prototype, "copyButtonAriaLabel"); c([ r() ], i.prototype, "copyButtonTestId"); export { i as default }; //# sourceMappingURL=copybox-input.component.js.map