@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: 'c04c9f14d3b5436efb16cd391eb2bbc64be74b38', onMouseEnter: (event) => this.handleHover(event) }, h("input", { key: '8e755a9c00f5f058e6dcacfb14000fa6ea2916a8', class: "pn-segment", id: this.segmentid, name: this.name, checked: this.selected, type: "radio", value: this.value, disabled: this.disabled }), h("label", { key: 'dc13164594408f0cc3da2812fec29c280d09423b', htmlFor: this.segmentid, class: "pn-segment-label" }, this.icon && h("pn-icon", { key: 'cb77aa8a7b2595b6a99eb2ff5f58230c934d3bc0', icon: this.icon, color: "blue700" }), h("span", { key: 'a4368885dfc0b2d78d0c76df7e7dcaf2de479697', class: "pn-segment-text" }, this.label, h("slot", { key: '20e1385578b7f7e52b3a1cc637b84461aa1ef216' })))));
}
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