UNPKG

@postnord/web-components

Version:

PostNord Web Components

88 lines (83 loc) 10.8 kB
/*! * Built with Stencil * By PostNord. */ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client'; import { u as uuidv4 } from './helpers.js'; import { d as defineCustomElement$2 } from './pn-icon2.js'; const pnCheckboxCss = "pn-checkbox{position:relative;display:inline-block}pn-checkbox .pn-checkbox{position:relative;display:flex;gap:0.75em}pn-checkbox .pn-checkbox-label{color:#2d2013}pn-checkbox .pn-checkbox-helpertext{color:#5e554a}pn-checkbox .pn-checkbox-content{display:flex;flex-direction:column;font-weight:400;line-height:1.5;flex:1;margin:0}pn-checkbox .pn-checkbox-outer{width:1.5em;height:1.5em;background-color:#ffffff;display:flex;align-items:center;justify-content:center;position:relative;border:0.0625em solid #969087;border-radius:0.25em;cursor:pointer;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:outline-color, border-color, background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){pn-checkbox .pn-checkbox-outer{transition-duration:0s;transition-delay:0s}}pn-checkbox .pn-checkbox-outer svg{width:1.25em;fill:none}pn-checkbox .pn-checkbox-outer svg polyline{stroke:#ffffff;transform-origin:0 0;stroke-linecap:round;stroke-dasharray:23;stroke-dashoffset:23;transition-property:stroke-dashoffset;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1);transition-delay:0s}@media (prefers-reduced-motion: reduce){pn-checkbox .pn-checkbox-outer svg polyline{transition-duration:0s;transition-delay:0s}}pn-checkbox .pn-checkbox[data-tile]{position:relative;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:1em;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:outline-color, background-color, border-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){pn-checkbox .pn-checkbox[data-tile]{transition-duration:0s;transition-delay:0s}}pn-checkbox .pn-checkbox[data-tile][data-invalid]{border-color:#a70707}pn-checkbox .pn-checkbox[data-invalid] .pn-checkbox-outer{border-color:#a70707}pn-checkbox>input{cursor:pointer;opacity:0;position:absolute;margin:0;z-index:1;top:0;left:0;width:100%;height:100%;-webkit-tap-highlight-color:transparent}pn-checkbox>input[aria-describedby]+.pn-checkbox[data-tile] .pn-checkbox-label{font-weight:500}pn-checkbox>input:hover+.pn-checkbox>.pn-checkbox-outer{background-color:#e0f8ff;border-color:#005d92}pn-checkbox>input:hover+.pn-checkbox[data-tile]{background-color:#e0f8ff;border-color:#005d92}pn-checkbox>input:hover+.pn-checkbox[data-tile][data-invalid]{background-color:#fdefee;border-color:#a70707}pn-checkbox>input:hover+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#fdefee;border-color:#a70707}pn-checkbox>input:focus-visible+.pn-checkbox>.pn-checkbox-outer{outline-color:#005d92}pn-checkbox>input:focus-visible+.pn-checkbox[data-tile]{outline-color:#005d92;border-color:#005d92}pn-checkbox>input:focus-visible+.pn-checkbox[data-tile][data-invalid]{outline-color:#a70707;border-color:#a70707}pn-checkbox>input:focus-visible+.pn-checkbox[data-tile][data-invalid]>.pn-checkbox-outer{outline-color:transparent}pn-checkbox>input:focus-visible+.pn-checkbox[data-tile]>.pn-checkbox-outer{outline-color:transparent}pn-checkbox>input:focus-visible+.pn-checkbox[data-invalid]>.pn-checkbox-outer{outline-color:#a70707}pn-checkbox>input:checked+.pn-checkbox>.pn-checkbox-outer{background-color:#005d92;border-color:#005d92}pn-checkbox>input:checked+.pn-checkbox>.pn-checkbox-outer svg .pn-checkbox-checkmark-path{transition-delay:0.2s;stroke-dashoffset:0}pn-checkbox>input:checked+.pn-checkbox>.pn-checkbox-outer svg .pn-checkbox-indeterminate-path{stroke-dashoffset:23}pn-checkbox>input:checked+.pn-checkbox[data-tile]{background-color:#e0f8ff;border-color:#005d92}pn-checkbox>input:checked+.pn-checkbox[data-tile][data-invalid]{background-color:#fdefee;border-color:#a70707}pn-checkbox>input:checked+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#a70707;border-color:#a70707}pn-checkbox>input:checked:hover+.pn-checkbox[data-tile]{border-color:#0d234b}pn-checkbox>input:checked:hover+.pn-checkbox>.pn-checkbox-outer{background-color:#0d234b;border-color:#0d234b}pn-checkbox>input:checked:hover+.pn-checkbox[data-invalid]{border-color:#500715}pn-checkbox>input:checked:hover+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#500715;border-color:#500715}pn-checkbox>input:indeterminate+.pn-checkbox>.pn-checkbox-outer{background-color:#005d92;border-color:#005d92}pn-checkbox>input:indeterminate+.pn-checkbox>.pn-checkbox-outer svg .pn-checkbox-checkmark-path{stroke-dashoffset:23}pn-checkbox>input:indeterminate+.pn-checkbox>.pn-checkbox-outer svg .pn-checkbox-indeterminate-path{stroke-dashoffset:0}pn-checkbox>input:indeterminate+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#a70707;border-color:#a70707}pn-checkbox>input:indeterminate:hover+.pn-checkbox>.pn-checkbox-outer{background-color:#0d234b;border-color:#0d234b}pn-checkbox>input:indeterminate:hover+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#500715;border-color:#500715}pn-checkbox>input:disabled{cursor:not-allowed}pn-checkbox>input:disabled+.pn-checkbox>.pn-checkbox-outer{background-color:#f3f2f2;border-color:#969087}pn-checkbox>input:disabled+.pn-checkbox[data-tile]{background-color:#f3f2f2;border-color:#f3f2f2}pn-checkbox>input:disabled+.pn-checkbox[data-tile]>pn-icon>.pn-icon-svg path{fill:#5e554a}pn-checkbox>input:disabled+.pn-checkbox[data-tile]>.pn-checkbox-content>.pn-checkbox-label{color:#5e554a}pn-checkbox>input:disabled+.pn-checkbox[data-tile][data-invalid]{background-color:#f3f2f2;border-color:#f3f2f2}pn-checkbox>input:disabled:hover+.pn-checkbox[data-tile]{border-color:#f3f2f2}pn-checkbox>input:disabled:hover+.pn-checkbox[data-tile][data-invalid]{background-color:#f3f2f2;border-color:#f3f2f2}pn-checkbox>input:disabled:hover+.pn-checkbox[data-tile]>.pn-checkbox-outer{background-color:#f3f2f2;border-color:#969087}pn-checkbox>input:disabled:hover+.pn-checkbox>.pn-checkbox-outer,pn-checkbox>input:disabled:hover+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#f3f2f2;border-color:#969087}pn-checkbox>input:disabled:checked+.pn-checkbox>.pn-checkbox-outer,pn-checkbox>input:disabled:checked+.pn-checkbox[data-invalid]>.pn-checkbox-outer,pn-checkbox>input:disabled:checked:hover+.pn-checkbox>.pn-checkbox-outer,pn-checkbox>input:disabled:checked:hover+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#969087;border-color:#969087}pn-checkbox>input:disabled:indeterminate+.pn-checkbox>.pn-checkbox-outer,pn-checkbox>input:disabled:indeterminate:hover+.pn-checkbox>.pn-checkbox-outer,pn-checkbox>input:disabled:indeterminate:disabled:hover+.pn-checkbox>.pn-checkbox-outer{background-color:#969087;border-color:#969087}"; const PnCheckboxStyle0 = pnCheckboxCss; const PnCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class PnCheckbox extends HTMLElement { constructor() { super(); this.__registerHost(); this.label = undefined; this.value = undefined; this.name = undefined; this.checked = false; this.helpertext = undefined; this.checkboxid = this.id; this.disabled = false; this.required = false; this.invalid = false; this.indeterminate = false; this.tile = false; this.icon = null; } id = `pn-checkbox-${uuidv4()}`; idHelpertext = `${this.id}-helpertext`; get hostElement() { return this; } handleId() { this.idHelpertext = `${this.checkboxid}-helpertext`; } handlechange() { this.indeterminate = false; } componentWillLoad() { this.handleId(); } render() { return (h(Host, { key: 'f0639bf5c45347c39ef933b7f4967be10e671e46' }, h("input", { key: '560e64e32b38b40a847b3b7283255dc9e9f36f72', type: "checkbox", id: this.checkboxid, value: this.value, name: this.name || this.checkboxid, disabled: this.disabled, checked: this.checked, required: this.required, indeterminate: this.indeterminate, "aria-invalid": this.invalid?.toString(), "aria-describedby": this.helpertext && this.idHelpertext }), h("div", { key: 'ac86d6c2bd460ce3b29fe8862b9a7b64ca23e2dd', class: "pn-checkbox", "data-tile": this.tile, "data-invalid": this.invalid }, h("div", { key: '6df97a9582503dc04946f3e590dff276bf87d885', class: "pn-checkbox-outer" }, h("svg", { key: '37d8212ac1b0088ebcbe28cd02d5cc6e59352e63', xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none" }, h("polyline", { key: 'b19a548634e5fe186291a0d24c4c3f81efe8eab1', class: "pn-checkbox-checkmark-path", points: "4,12 9,17 20,6", "stroke-width": "3" }), h("polyline", { key: '040639fc42060dff6db8fab45dc713ccf81631bf', class: "pn-checkbox-indeterminate-path", points: "4,12 20,12", "stroke-width": "3" }))), (!!this.label || !!this.helpertext) && (h("p", { key: '3006b0ba0826003608453423259914a3b9622168', class: "pn-checkbox-content" }, !!this.label && (h("label", { key: '2de986fd9df0d639e5b398c24b4aa95e6e416c5d', htmlFor: this.checkboxid, class: "pn-checkbox-label" }, this.label)), !!this.helpertext && (h("span", { key: '13c417fef46e456a1e036a22c9655da2fa19de24', id: this.idHelpertext, class: "pn-checkbox-helpertext" }, this.helpertext)))), this.tile && this.icon && h("pn-icon", { key: '204b119d1bf7da4ce2fb90d1f53114b6a5ada7dd', icon: this.icon, color: "gray900" })))); } static get watchers() { return { "checkboxid": ["handleId"] }; } static get style() { return PnCheckboxStyle0; } }, [0, "pn-checkbox", { "label": [1], "value": [513], "name": [1], "checked": [4], "helpertext": [1], "checkboxid": [1], "disabled": [4], "required": [4], "invalid": [4], "indeterminate": [1028], "tile": [4], "icon": [1] }, [[0, "change", "handlechange"]], { "checkboxid": ["handleId"] }]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["pn-checkbox", "pn-icon"]; components.forEach(tagName => { switch (tagName) { case "pn-checkbox": if (!customElements.get(tagName)) { customElements.define(tagName, PnCheckbox$1); } break; case "pn-icon": if (!customElements.get(tagName)) { defineCustomElement$2(); } break; } }); } const PnCheckbox = PnCheckbox$1; const defineCustomElement = defineCustomElement$1; export { PnCheckbox, defineCustomElement }; //# sourceMappingURL=pn-checkbox.js.map