UNPKG

@postnord/web-components

Version:
52 lines (48 loc) 3.76 kB
/*! * Built with Stencil * By PostNord. */ import { t as transformTag, r as registerInstance, c as createEvent, g as getElement, h } from './index-XKg-ydzH.js'; import { a as arrow_right } from './arrow_right-D_UyW-KH.js'; const pnPageNavDropdownItemCss = () => `${transformTag("pn-page-nav-dropdown-item")}:first-of-type li>a,${transformTag("pn-page-nav-dropdown-item")}:first-of-type li>button{border-radius:0.5em 0.5em 0 0}${transformTag("pn-page-nav-dropdown-item")}:last-of-type li>a,${transformTag("pn-page-nav-dropdown-item")}:last-of-type li>button{border-radius:0 0 0.5em 0.5em}${transformTag("pn-page-nav-dropdown-item")}:last-of-type li>hr{display:none}${transformTag("pn-page-nav-dropdown-item")} li{font-size:inherit}${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}${transformTag("pn-page-nav-dropdown-item")} li>*>${transformTag("pn-icon")}{margin-left:1em}${transformTag("pn-page-nav-dropdown-item")} li>*.pn-page-nav-dropdown-item-active{background:#005d92}${transformTag("pn-page-nav-dropdown-item")} li>*.pn-page-nav-dropdown-item-active:hover,${transformTag("pn-page-nav-dropdown-item")} li>*.pn-page-nav-dropdown-item-active:focus{background:#005d92}${transformTag("pn-page-nav-dropdown-item")} li>*:hover,${transformTag("pn-page-nav-dropdown-item")} li>*:focus{background:#0d234b}${transformTag("pn-page-nav-dropdown-item")} li>*:focus{box-shadow:inset 0 0 0 0.1em #005d92, inset 0 0 0 0.2em #d3cecb}${transformTag("pn-page-nav-dropdown-item")} li>a{text-decoration:none}${transformTag("pn-page-nav-dropdown-item")} li>button{background:none}${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) { registerInstance(this, hostRef); this.itemselection = createEvent(this, "itemselection", 7); } get hostElement() { return 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 (h("li", { key: '93c6bd31a88c76797cee2bc915c31e6ecfa5aace' }, h(TagName, { key: '2818d4f3a1572f863f9b9a8609d572f5994f6e75', href: this.href || '#', class: this.setClassnames(), type: this.getType(), onClick: e => this.select(e), tabindex: "-1" }, h("slot", { key: 'e04f130737445747a2b93bf9d7372bf22889fcff' }), h("pn-icon", { key: '934d46f6bd482171d974efec7c4494f8b1b1faff', icon: arrow_right, color: "white" })), h("hr", { key: 'c5c9c4a24affe5b10d56e8a6ca5d6bee434aa571' }))); } }; PnPageNavDropdownItem.style = pnPageNavDropdownItemCss(); export { PnPageNavDropdownItem as pn_page_nav_dropdown_item };