@postnord/web-components
Version:
PostNord Web Components
54 lines (49 loc) • 3.86 kB
JavaScript
/*!
* Built with Stencil
* By PostNord.
*/
;
var index = require('./index-DWu-2oJc.js');
var arrow_right = require('./arrow_right-CABi9Wkp.js');
const pnPageNavDropdownItemCss = () => `${index.transformTag("pn-page-nav-dropdown-item")}:first-of-type li>a,${index.transformTag("pn-page-nav-dropdown-item")}:first-of-type li>button{border-radius:0.5em 0.5em 0 0}${index.transformTag("pn-page-nav-dropdown-item")}:last-of-type li>a,${index.transformTag("pn-page-nav-dropdown-item")}:last-of-type li>button{border-radius:0 0 0.5em 0.5em}${index.transformTag("pn-page-nav-dropdown-item")}:last-of-type li>hr{display:none}${index.transformTag("pn-page-nav-dropdown-item")} li{font-size:inherit}${index.transformTag("pn-page-nav-dropdown-item")} li>*{color:#ffffff;font-size:inherit;border:none;padding:1em;margin:0;display:flex;justify-content:space-between;align-items:center;cursor:pointer;transition:background 0.15s;outline:none;width:100%;font-weight:500}${index.transformTag("pn-page-nav-dropdown-item")} li>*>${index.transformTag("pn-icon")}{margin-left:1em}${index.transformTag("pn-page-nav-dropdown-item")} li>*.pn-page-nav-dropdown-item-active{background:#005d92}${index.transformTag("pn-page-nav-dropdown-item")} li>*.pn-page-nav-dropdown-item-active:hover,${index.transformTag("pn-page-nav-dropdown-item")} li>*.pn-page-nav-dropdown-item-active:focus{background:#005d92}${index.transformTag("pn-page-nav-dropdown-item")} li>*:hover,${index.transformTag("pn-page-nav-dropdown-item")} li>*:focus{background:#0d234b}${index.transformTag("pn-page-nav-dropdown-item")} li>*:focus{box-shadow:inset 0 0 0 0.1em #005d92, inset 0 0 0 0.2em #d3cecb}${index.transformTag("pn-page-nav-dropdown-item")} li>a{text-decoration:none}${index.transformTag("pn-page-nav-dropdown-item")} li>button{background:none}${index.transformTag("pn-page-nav-dropdown-item")} li>hr{bottom:0;padding:0;margin:0 auto;border-top:0.0625em solid #d3cecb;opacity:0.6;width:85%}`;
const PnPageNavDropdownItem = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.itemselection = index.createEvent(this, "itemselection", 7);
}
get hostElement() { return index.getElement(this); }
/**
* The value that will be emitted upon selection, only pass this if the item
* is a link, if you want a button (for quick actions), omit this prop.
*/
value;
/** Pass an href to the items if you want to have links that lead outside of your app */
href;
/** Ignore this, it's internal communication with parent. @hide true */
active = false;
/** Ignore this, it's internal communication with parent */
itemselection;
select(e) {
if (this.value && !this.href)
e.preventDefault();
this.itemselection.emit(this.value);
}
setClassnames() {
let classes = 'pn-page-nav-dropdown-item ';
if (this.active)
classes += 'pn-page-nav-dropdown-item-active ';
return classes;
}
getType() {
return this.value ? null : 'button';
}
getTagName() {
return this.value ? 'a' : 'button';
}
render() {
const TagName = this.getTagName();
return (index.h("li", { key: 'a092dbd0ea2bead9b2d974cadf80f74190a0d14e' }, index.h(TagName, { key: 'd0d9542e100b59c39ced2612c9b279d7d07bd876', href: this.href || '#', class: this.setClassnames(), type: this.getType(), onClick: e => this.select(e), tabindex: "-1" }, index.h("slot", { key: '96f8721e300c4b32e72df20079030986d5ffee6b' }), index.h("pn-icon", { key: 'd835de522cec9ec9f686bb9c0d30d842d4feeb80', icon: arrow_right.arrow_right, color: "white" })), index.h("hr", { key: 'db691728876fa378a714eb13202922a99bd8ca46' })));
}
};
PnPageNavDropdownItem.style = pnPageNavDropdownItemCss();
exports.pn_page_nav_dropdown_item = PnPageNavDropdownItem;