UNPKG

@utrecht/web-component-library-stencil

Version:

Stencil component library bundle for the Municipality of Utrecht based on the NL Design System architecture

63 lines (62 loc) 2.29 kB
/** * @license EUPL-1.2 * Copyright (c) 2020-2024 Frameless B.V. * Copyright (c) 2021-2024 Gemeente Utrecht */ import { h } from "@stencil/core"; import clsx from "clsx"; const enumGuard = (values) => (x) => values.includes(x); const ROLES = ['status', 'alert']; const isAlertRole = enumGuard(ROLES); const TYPES = ['error', 'warning', 'info', 'ok']; const isAlertType = enumGuard(TYPES); const typeToRole = { info: 'status', ok: 'status', warning: 'alert', error: 'alert', }; export class Alert { constructor() { this.type = undefined; } render() { const computedType = isAlertType(this.type) ? this.type : 'info'; const computedRole = isAlertRole(typeToRole[computedType]) ? typeToRole[computedType] : 'status'; return (h("div", { key: 'b55c15b4ba985f5cf49b3edf8564ad698ab08332', class: clsx('utrecht-alert', `utrecht-alert--${computedType}`) }, h("div", { key: '979fba4b78603a6a46c4c61e28a0c7b0411567f7', class: "utrecht-alert__icon" }, h("slot", { key: 'fce4262e8df49413c6fc2af1448766d647988b7e', name: "icon" })), h("div", { key: '4494157b106bca1c9213b78c44c36c34b04a01a0', class: "utrecht-alert__content" }, h("div", { key: '654e071124ad372ec08fb474532da28de9ab8a2b', class: "utrecht-alert__message", role: computedRole }, h("slot", { key: '171e19b07378e008490b5db0ff2f6a9ffba5dbef' }))))); } static get is() { return "utrecht-alert"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["alert.scss"] }; } static get styleUrls() { return { "$": ["alert.css"] }; } static get properties() { return { "type": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "type", "reflect": false } }; } } //# sourceMappingURL=alert.js.map