@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
JavaScript
/**
* @license EUPL-1.2
* Copyright (c) 2020-2024 Frameless B.V.
* Copyright (c) 2021-2024 Gemeente Utrecht
*/
import { h } from "@stencil/core";
export class BadgeCounter {
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: '69feb190325dd2c5ab694f708493b6bfcae9808f', class: "utrecht-badge-counter" }, textContent ? textContent : h("slot", null));
}
static get is() { return "utrecht-badge-counter"; }
static get encapsulation() { return "shadow"; }
static get originalStyleUrls() {
return {
"$": ["badge-counter.scss"]
};
}
static get styleUrls() {
return {
"$": ["badge-counter.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=badge-counter.js.map