@postnord/web-components
Version:
PostNord Web Components
197 lines (196 loc) • 7 kB
JavaScript
/*!
* Built with Stencil
* By PostNord.
*/
import { uuidv4 } from "../../../../globals/helpers";
import { h, Host } from "@stencil/core";
/**
* The `pn-segment` is built with a native `input[type="radio"]` in the background.
* Do not listen to events on the `pn-segment`, but on the `pn-segmented-control` instead.
*/
export class PnSegment {
constructor() {
this.label = undefined;
this.name = undefined;
this.value = undefined;
this.selected = false;
this.segmentid = this.id;
this.icon = undefined;
this.disabled = false;
}
id = `pn-segment-${uuidv4()}`;
hostElement;
/** This event is used by the `pn-segmented-control` component. Do not use manually. */
segmentHover;
handleHover(mouse) {
this.segmentHover.emit(mouse);
}
render() {
return (h(Host, { key: 'b325719082527754f09c013b3e01e8de7d5595e7', onMouseEnter: (event) => this.handleHover(event) }, h("input", { key: 'a077d547cf945c3d54d345bda5ead3fd7282b527', class: "pn-segment", id: this.segmentid, name: this.name, checked: this.selected, type: "radio", value: this.value, disabled: this.disabled }), h("label", { key: '334868268acf600c2dd1d15e585d3a98859dba44', htmlFor: this.segmentid, class: "pn-segment-label" }, this.icon && h("pn-icon", { key: 'bff15a1148753a1abc5eb9dfcee01026f8eabbb5', icon: this.icon, color: "blue700" }), h("span", { key: '3b6a60bee13d4f929ac463196b1b8492a2efccbc', class: "pn-segment-text" }, this.label, h("slot", { key: '266ffb928bcd8f1e66c771ccb5856032859c08e7' })))));
}
static get is() { return "pn-segment"; }
static get originalStyleUrls() {
return {
"$": ["pn-segment.scss"]
};
}
static get styleUrls() {
return {
"$": ["pn-segment.css"]
};
}
static get properties() {
return {
"label": {
"type": "string",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": false,
"optional": true,
"docs": {
"tags": [],
"text": "The segment label, same as the slot."
},
"attribute": "label",
"reflect": false
},
"name": {
"type": "string",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": true,
"optional": false,
"docs": {
"tags": [],
"text": "The segment controller name."
},
"attribute": "name",
"reflect": false
},
"value": {
"type": "string",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": true,
"optional": false,
"docs": {
"tags": [],
"text": "The segment value."
},
"attribute": "value",
"reflect": false
},
"selected": {
"type": "boolean",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [{
"name": "hide",
"text": "true"
}],
"text": "Set the segment as selected. Used by the `pn-segmented-control`. **Do not use manually**."
},
"attribute": "selected",
"reflect": false,
"defaultValue": "false"
},
"segmentid": {
"type": "string",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "A unique HTML id."
},
"attribute": "segmentid",
"reflect": false,
"defaultValue": "this.id"
},
"icon": {
"type": "string",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": false,
"optional": true,
"docs": {
"tags": [],
"text": "The SVG content of the icon you want."
},
"attribute": "icon",
"reflect": false
},
"disabled": {
"type": "boolean",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "Disable the segment."
},
"attribute": "disabled",
"reflect": false,
"defaultValue": "false"
}
};
}
static get events() {
return [{
"method": "segmentHover",
"name": "segmentHover",
"bubbles": true,
"cancelable": true,
"composed": true,
"docs": {
"tags": [],
"text": "This event is used by the `pn-segmented-control` component. Do not use manually."
},
"complexType": {
"original": "MouseEvent",
"resolved": "MouseEvent",
"references": {
"MouseEvent": {
"location": "global",
"id": "global::MouseEvent"
}
}
}
}];
}
static get elementRef() { return "hostElement"; }
}
//# sourceMappingURL=pn-segment.js.map