UNPKG

@utrecht/web-component-library-stencil

Version:

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

89 lines (88 loc) 2.85 kB
/** * @license EUPL-1.2 * Copyright (c) 2020-2024 Frameless B.V. * Copyright (c) 2021-2024 Gemeente Utrecht */ import { h } from "@stencil/core"; export class NumberBadge { constructor() { this.value = undefined; this.max = undefined; this.locale = undefined; } render() { const { locale, max, value } = this; const limited = typeof max === 'number' && typeof value === 'number' && Number(value) > Number(max); const formatNumber = (n) => (locale ? Intl.NumberFormat(locale).format(n) : String(n)); const textContent = limited ? `${formatNumber(max)}+` : typeof value === 'number' ? formatNumber(value) : ''; return h("div", { key: 'b87b41d6b285380d0bca7429067a4acbee35eccd', class: "utrecht-number-badge" }, textContent ? textContent : h("slot", null)); } static get is() { return "utrecht-number-badge"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["number-badge.scss"] }; } static get styleUrls() { return { "$": ["number-badge.css"] }; } static get properties() { return { "value": { "type": "number", "mutable": false, "complexType": { "original": "number", "resolved": "number", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "value", "reflect": false }, "max": { "type": "number", "mutable": false, "complexType": { "original": "number", "resolved": "number", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "max", "reflect": false }, "locale": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "locale", "reflect": false } }; } } //# sourceMappingURL=number-badge.js.map