{"version":3,"file":"switch-t8JmaVOi.js","sources":["../../src/atoms/switch.ts"],"sourcesContent":["import { css, html, LitElement } from \"lit\";\nimport { customElement } from \"lit/decorators/custom-element.js\";\nimport { sharedStyles } from \"../styles/shared\";\nimport { property } from \"lit/decorators/property.js\";\nimport \"../atoms/progress-spinner\";\nimport \"../atoms/text\";\nimport { Size } from \"shared\";\nimport { live } from \"lit/directives/live.js\";\nimport { when } from \"lit/directives/when.js\";\n\n@customElement(\"bs-switch\")\nexport class BsSwitch extends LitElement {\n\tstatic get styles() {\n\t\treturn [\n\t\t\tsharedStyles,\n\t\t\tcss`\n\t\t\t\t:host {\n\t\t\t\t\tdisplay: inline-flex;\n\t\t\t\t\tuser-select: none;\n\t\t\t\t\tposition: relative;\n\t\t\t\t\t-webkit-user-select: none;\n\t\t\t\t\t--_switch-width: var(--switch-width, 60px);\n\t\t\t\t\t--_switch-height: var(--switch-height, 34px);\n\t\t\t\t\t--_switch-slider-height: calc(var(--_switch-height) * 0.75);\n\t\t\t\t\t--_switch-slider-left-right-padding: calc((var(--_switch-height) - var(--_switch-slider-height)) / 2);\n\t\t\t\t}\n\n\t\t\t\t:host(:not([loading])) {\n\t\t\t\t\ttransition: 120ms ease-out transform;\n\t\t\t\t}\n\n\t\t\t\t:host([loading]) #label {\n\t\t\t\t\topacity: 0;\n\t\t\t\t\tpointer-events: none;\n\t\t\t\t}\n\n\t\t\t\t#label {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tgap: var(--space-s);\n\t\t\t\t\talign-items: center;\n\t\t\t\t}\n\n\t\t\t\t#switch {\n\t\t\t\t\tposition: relative;\n\t\t\t\t\tdisplay: inline-flex;\n\t\t\t\t\twidth: var(--_switch-width);\n\t\t\t\t\theight: var(--_switch-height);\n\t\t\t\t\ttransform: scale(1);\n\t\t\t\t}\n\n\t\t\t\t:host(:hover) #switch {\n\t\t\t\t\ttransform: scale(1.05);\n\t\t\t\t}\n\n\t\t\t\t:host([disabled]) {\n\t\t\t\t\topacity: 0.5;\n\t\t\t\t\tpointer-events: none;\n\t\t\t\t}\n\n\t\t\t\t:host([size=\"tiny\"]) {\n\t\t\t\t\t--_switch-width: 35px;\n\t\t\t\t\t--_switch-height: 20px;\n\t\t\t\t}\n\n\t\t\t\t:host([size=\"small\"]) {\n\t\t\t\t\t--_switch-width: 52px;\n\t\t\t\t\t--_switch-height: 30px;\n\t\t\t\t}\n\n\t\t\t\t:host([size=\"large\"]) {\n\t\t\t\t\t--_switch-width: 88px;\n\t\t\t\t\t--_switch-height: 50px;\n\t\t\t\t}\n\n\t\t\t\t#input {\n\t\t\t\t\topacity: 0;\n\t\t\t\t\twidth: 0;\n\t\t\t\t\theight: 0;\n\t\t\t\t}\n\n\t\t\t\t#slider {\n\t\t\t\t\tposition: absolute;\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\tright: 0;\n\t\t\t\t\tbottom: 0;\n\t\t\t\t\ttransition: 120ms ease-out background;\n\t\t\t\t\tborder-radius: 9999px;\n\t\t\t\t\tbackground: var(--switch-bg, var(--shade-normal));\n\t\t\t\t\tcolor: var(--switch-color, var(--background));\n\t\t\t\t}\n\n\t\t\t\t#slider:before {\n\t\t\t\t\tposition: absolute;\n\t\t\t\t\tcontent: \"\";\n\t\t\t\t\theight: var(--_switch-slider-height);\n\t\t\t\t\twidth: var(--_switch-slider-height);\n\t\t\t\t\ttop: 50%;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\tbackground-color: currentColor;\n\t\t\t\t\ttransition: 120ms ease-out transform;\n\t\t\t\t\tborder-radius: 50%;\n\t\t\t\t\ttransform: translate(var(--_switch-slider-left-right-padding), -50%);\n\t\t\t\t}\n\n\t\t\t\t#input:checked + #slider {\n\t\t\t\t\tbackground: var(--switch-bg-checked, var(--success-normal));\n\t\t\t\t\tcolor: var(--switch-color-checked, var(--background));\n\t\t\t\t}\n\n\t\t\t\t#input:checked + #slider:before {\n\t\t\t\t\ttransform: translate(\n\t\t\t\t\t\tcalc(var(--_switch-width) - var(--_switch-slider-height) - var(--_switch-slider-left-right-padding)),\n\t\t\t\t\t\t-50%\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t#spinner {\n\t\t\t\t\t--progress-spinner-size: 16px;\n\t\t\t\t\tposition: absolute;\n\t\t\t\t\ttop: 50%;\n\t\t\t\t\ttransform: translateY(-50%);\n\t\t\t\t\tright: 0;\n\t\t\t\t}\n\n\t\t\t\t.text {\n\t\t\t\t\tline-height: 1;\n\t\t\t\t}\n\t\t\t`\n\t\t];\n\t}\n\n\t@property({ type: String, reflect: true }) size: Size = \"medium\";\n\t@property({ type: Boolean, reflect: true }) checked = false;\n\t@property({ type: Boolean, reflect: true }) disabled = false;\n\t@property({ type: Boolean, reflect: true }) loading = false;\n\t@property({ type: String, attribute: \"after-text\" }) afterText: string | undefined;\n\t@property({ type: String, attribute: \"before-text\" }) beforeText: string | undefined;\n\n\tonCheckboxInput(e: Event) {\n\t\tthis.checked = (e.target as HTMLInputElement).checked ?? false;\n\t\tthis.dispatchEvent(new CustomEvent(\"update\", { detail: this.checked }));\n\t}\n\n\trender() {\n\t\treturn html`\n\t\t\t${when(this.loading, () => html``)}\n\t\t\t\n\t\t`;\n\t}\n}\n"],"names":["BsSwitch","LitElement","sharedStyles","css","e","html","when","live","__decorateClass","property","customElement"],"mappings":"oVAWa,IAAAA,EAAN,cAAuBC,CAAW,CAAlC,aAAA,CAAA,MAAA,GAAA,SAAA,EA0HkD,KAAA,KAAA,SACF,KAAA,QAAA,GACC,KAAA,SAAA,GACD,KAAA,QAAA,EAAA,CA5HtD,WAAW,QAAS,CACZ,MAAA,CACNC,EACAC;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;A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