@oslokommune/punkt-elements 14.2.0 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/index.d.ts +23 -20
- package/dist/pkt-header.cjs +9 -7
- package/dist/pkt-header.js +136 -122
- package/package.json +2 -2
- package/src/components/header/header-service.ts +12 -8
- package/src/components/header/header.ts +8 -2
- package/src/components/header/index.ts +4 -1
- package/src/components/header/types.ts +18 -22
- package/src/components/index.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [14.3.0](https://github.com/oslokommune/punkt/compare/14.2.0...14.3.0) (2026-02-04)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
Ingen
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
Ingen
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
Ingen
|
|
18
|
+
|
|
19
|
+
### Chores
|
|
20
|
+
Ingen
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
|
|
8
25
|
## [14.2.0](https://github.com/oslokommune/punkt/compare/14.1.1...14.2.0) (2026-02-04)
|
|
9
26
|
|
|
10
27
|
### ⚠ BREAKING CHANGES
|
package/dist/index.d.ts
CHANGED
|
@@ -15,12 +15,17 @@ import { TAriaLive } from '../../../../../shared-types';
|
|
|
15
15
|
import { TCardSkin } from '../../../../../shared-types';
|
|
16
16
|
import { TemplateResult } from 'lit-html';
|
|
17
17
|
import { TemplateResult as TemplateResult_2 } from 'lit';
|
|
18
|
+
import { THeaderMenu } from '../../../../../shared-types';
|
|
19
|
+
import { THeaderPosition } from '../../../../../shared-types';
|
|
20
|
+
import { THeaderScrollBehavior } from '../../../../../shared-types';
|
|
18
21
|
import { THeadingLevel } from '../../../../../shared-types';
|
|
19
22
|
import { THeadingSize } from '../../../../../shared-types';
|
|
20
23
|
import { THeadingWeight } from '../../../../../shared-types';
|
|
21
24
|
import { THTMLButtonType } from '../../../../../shared-types';
|
|
22
25
|
import { TLayout } from '../../../../../shared-types';
|
|
23
26
|
import { TMessageboxSkin } from '../../../../../shared-types';
|
|
27
|
+
import { TLogOutButtonPlacement as TPktHeaderLogOutButtonPlacement } from '../../../../../shared-types';
|
|
28
|
+
import { TSlotMenuVariant } from '../../../../../shared-types';
|
|
24
29
|
import { User } from '../../../../../shared-types';
|
|
25
30
|
import { UserMenuItem } from '../../../../../shared-types';
|
|
26
31
|
|
|
@@ -251,7 +256,11 @@ export declare interface IPktHeader {
|
|
|
251
256
|
/** Custom breakpoint for tablet responsive behavior in pixels. Default: 1280 */
|
|
252
257
|
tabletBreakpoint?: number;
|
|
253
258
|
/** Which menu is initially open */
|
|
254
|
-
openedMenu?:
|
|
259
|
+
openedMenu?: THeaderMenu;
|
|
260
|
+
/** Variant for the slot menu button. Default: 'icon-only' */
|
|
261
|
+
slotMenuVariant?: TSlotMenuVariant;
|
|
262
|
+
/** Text for the slot menu button. Default: 'Meny' */
|
|
263
|
+
slotMenuText?: string;
|
|
255
264
|
}
|
|
256
265
|
|
|
257
266
|
export declare type IPktHeaderRepresenting = Representing;
|
|
@@ -976,10 +985,12 @@ export declare class PktHeader extends PktElement<IPktHeader> implements IPktHea
|
|
|
976
985
|
searchValue: string;
|
|
977
986
|
mobileBreakpoint: number;
|
|
978
987
|
tabletBreakpoint: number;
|
|
979
|
-
openedMenu:
|
|
988
|
+
openedMenu: THeaderMenu;
|
|
980
989
|
logOutButtonPlacement: TPktHeaderLogOutButtonPlacement;
|
|
981
990
|
position: THeaderPosition;
|
|
982
991
|
scrollBehavior: THeaderScrollBehavior;
|
|
992
|
+
slotMenuVariant: TSlotMenuVariant;
|
|
993
|
+
slotMenuText: string;
|
|
983
994
|
hideLogo: Booleanish;
|
|
984
995
|
compact: Booleanish;
|
|
985
996
|
showSearch: Booleanish;
|
|
@@ -1008,10 +1019,12 @@ export declare class PktHeaderService extends PktElement<IPktHeader> implements
|
|
|
1008
1019
|
searchValue: string;
|
|
1009
1020
|
mobileBreakpoint: number;
|
|
1010
1021
|
tabletBreakpoint: number;
|
|
1011
|
-
openedMenu:
|
|
1022
|
+
openedMenu: THeaderMenu;
|
|
1012
1023
|
logOutButtonPlacement: TPktHeaderLogOutButtonPlacement;
|
|
1013
1024
|
position: THeaderPosition;
|
|
1014
1025
|
scrollBehavior: THeaderScrollBehavior;
|
|
1026
|
+
slotMenuVariant: TSlotMenuVariant;
|
|
1027
|
+
slotMenuText: string;
|
|
1015
1028
|
hideLogo: Booleanish;
|
|
1016
1029
|
compact: Booleanish;
|
|
1017
1030
|
showSearch: Booleanish;
|
|
@@ -1622,15 +1635,11 @@ declare type TCounterPosition = 'top' | 'bottom';
|
|
|
1622
1635
|
|
|
1623
1636
|
declare type TDay = `${number}${number}`;
|
|
1624
1637
|
|
|
1625
|
-
|
|
1626
|
-
* Position options for header
|
|
1627
|
-
*/
|
|
1628
|
-
declare type THeaderPosition = 'fixed' | 'relative';
|
|
1638
|
+
export { THeaderMenu }
|
|
1629
1639
|
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
declare type THeaderScrollBehavior = 'hide' | 'none';
|
|
1640
|
+
export { THeaderPosition }
|
|
1641
|
+
|
|
1642
|
+
export { THeaderScrollBehavior }
|
|
1634
1643
|
|
|
1635
1644
|
declare type TISODate = `${TYear}-${TMonth}-${TDay}`;
|
|
1636
1645
|
|
|
@@ -1656,15 +1665,7 @@ export declare type TPktButtonVariant = 'label-only' | 'icon-left' | 'icon-right
|
|
|
1656
1665
|
|
|
1657
1666
|
export declare type TPktComboboxTagPlacement = 'inside' | 'outside';
|
|
1658
1667
|
|
|
1659
|
-
|
|
1660
|
-
* Type for logout button placement
|
|
1661
|
-
*/
|
|
1662
|
-
export declare type TPktHeaderLogOutButtonPlacement = 'userMenu' | 'header' | 'both' | 'none';
|
|
1663
|
-
|
|
1664
|
-
/**
|
|
1665
|
-
* Type for which menu is currently open
|
|
1666
|
-
*/
|
|
1667
|
-
export declare type TPktHeaderMenu = 'none' | 'slot' | 'search' | 'user';
|
|
1668
|
+
export { TPktHeaderLogOutButtonPlacement }
|
|
1668
1669
|
|
|
1669
1670
|
export declare type TPktHeadingLevel = THeadingLevel;
|
|
1670
1671
|
|
|
@@ -1694,6 +1695,8 @@ export declare type TSelectOption = {
|
|
|
1694
1695
|
hidden?: boolean;
|
|
1695
1696
|
};
|
|
1696
1697
|
|
|
1698
|
+
export { TSlotMenuVariant }
|
|
1699
|
+
|
|
1697
1700
|
export declare type TTabItemSkin = 'blue' | 'green' | 'red' | 'beige' | 'yellow' | 'grey' | 'gray' | 'blue-light';
|
|
1698
1701
|
|
|
1699
1702
|
export declare type TTagSkin = 'blue' | 'blue-dark' | 'blue-light' | 'green' | 'red' | 'yellow' | 'beige' | 'gray' | 'grey';
|
package/dist/pkt-header.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./element-CJ_QKaki.cjs"),g=require("./pkt-slot-controller-BzddBp7z.cjs"),v=require("./if-defined-Bc9-_I01.cjs"),h=require("./ref-BFa5Utho.cjs"),u=require("./booleanish-BKVonob4.cjs"),d=require("./state-DSjcvzDN.cjs"),p=require("./class-map-C_erArZz.cjs");require("./button-DaM4jvhJ.cjs");require("./icon-MRx-m0Or.cjs");require("./link-Dw39h-YN.cjs");require("./textinput-IN3b0nSH.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./element-CJ_QKaki.cjs"),g=require("./pkt-slot-controller-BzddBp7z.cjs"),v=require("./if-defined-Bc9-_I01.cjs"),h=require("./ref-BFa5Utho.cjs"),u=require("./booleanish-BKVonob4.cjs"),d=require("./state-DSjcvzDN.cjs"),p=require("./class-map-C_erArZz.cjs");require("./button-DaM4jvhJ.cjs");require("./icon-MRx-m0Or.cjs");require("./link-Dw39h-YN.cjs");require("./textinput-IN3b0nSH.cjs");const b=o=>typeof o.target=="string"?{title:o.title,iconName:o.iconName,href:o.target}:{title:o.title,iconName:o.iconName,onClick:o.target},f=o=>b(o),m=o=>{if(!o)return;const e=typeof o=="string"?new Date(o):o;if(!isNaN(e.getTime()))return e.toLocaleDateString("nb-NO",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"})};var y=Object.defineProperty,S=Object.getOwnPropertyDescriptor,k=(o,e,s,n)=>{for(var r=n>1?void 0:n?S(e,s):e,l=o.length-1,c;l>=0;l--)(c=o[l])&&(r=(n?c(e,s,r):c(r))||r);return n&&r&&y(e,s,r),r};exports.PktHeaderUserMenu=class extends t.PktElement{constructor(){super(...arguments),this.canChangeRepresentation=!1,this.logoutOnClick=!1}handleChangeRepresentation(){this.dispatchEvent(new CustomEvent("change-representation",{bubbles:!0,composed:!0}))}handleLogout(){this.dispatchEvent(new CustomEvent("log-out",{bubbles:!0,composed:!0}))}handleMenuItemClick(e){"onClick"in e&&typeof e.onClick=="function"&&e.onClick()}renderLinkOrButton(e,s){const n="href"in e,r=p.e({"pkt-user-menu__link":!0,"pkt-link-button":!n,"pkt-link":!n,"pkt-link--icon-left":!n,[s||""]:!!s});return n?t.x`
|
|
2
2
|
<pkt-link
|
|
3
3
|
icon-name=${e.iconName||t.E}
|
|
4
4
|
href=${e.href}
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
`:t.E}
|
|
81
81
|
</ul>
|
|
82
82
|
</nav>
|
|
83
|
-
`}};k([t.n({type:Object})],exports.PktHeaderUserMenu.prototype,"user",2);k([t.n({type:String,attribute:"formatted-last-logged-in"})],exports.PktHeaderUserMenu.prototype,"formattedLastLoggedIn",2);k([t.n({type:Object})],exports.PktHeaderUserMenu.prototype,"representing",2);k([t.n({type:Array,attribute:"user-menu"})],exports.PktHeaderUserMenu.prototype,"userMenu",2);k([t.n({type:Boolean,attribute:"can-change-representation",converter:u.booleanishConverter})],exports.PktHeaderUserMenu.prototype,"canChangeRepresentation",2);k([t.n({type:Boolean,attribute:"logout-on-click",converter:u.booleanishConverter})],exports.PktHeaderUserMenu.prototype,"logoutOnClick",2);exports.PktHeaderUserMenu=k([t.t("pkt-header-user-menu")],exports.PktHeaderUserMenu);var $=Object.defineProperty,
|
|
84
|
-
<pkt-icon name="oslologo" aria-hidden="true" path=${
|
|
83
|
+
`}};k([t.n({type:Object})],exports.PktHeaderUserMenu.prototype,"user",2);k([t.n({type:String,attribute:"formatted-last-logged-in"})],exports.PktHeaderUserMenu.prototype,"formattedLastLoggedIn",2);k([t.n({type:Object})],exports.PktHeaderUserMenu.prototype,"representing",2);k([t.n({type:Array,attribute:"user-menu"})],exports.PktHeaderUserMenu.prototype,"userMenu",2);k([t.n({type:Boolean,attribute:"can-change-representation",converter:u.booleanishConverter})],exports.PktHeaderUserMenu.prototype,"canChangeRepresentation",2);k([t.n({type:Boolean,attribute:"logout-on-click",converter:u.booleanishConverter})],exports.PktHeaderUserMenu.prototype,"logoutOnClick",2);exports.PktHeaderUserMenu=k([t.t("pkt-header-user-menu")],exports.PktHeaderUserMenu);var $=Object.defineProperty,M=Object.getOwnPropertyDescriptor,i=(o,e,s,n)=>{for(var r=n>1?void 0:n?M(e,s):e,l=o.length-1,c;l>=0;l--)(c=o[l])&&(r=(n?c(e,s,r):c(r))||r);return n&&r&&$(e,s,r),r};const _="https://punkt-cdn.oslo.kommune.no/latest/logos/";exports.PktHeaderService=class extends t.PktElement{constructor(){super(),this.searchPlaceholder="Søk",this.searchValue="",this.mobileBreakpoint=768,this.tabletBreakpoint=1280,this.openedMenu="none",this.logOutButtonPlacement="none",this.position="fixed",this.scrollBehavior="hide",this.slotMenuVariant="icon-only",this.slotMenuText="Meny",this.hideLogo=!1,this.compact=!1,this.showSearch=!1,this.canChangeRepresentation=!1,this.hasLogOut=!1,this.isMobile=!1,this.isTablet=!1,this.openMenu="none",this.isHidden=!1,this.componentWidth=typeof window<"u"?window.innerWidth:0,this.hasSlotContent=!1,this.alignSlotRight=!1,this.alignSearchRight=!1,this.defaultSlot=h.e(),this.headerRef=h.e(),this.userContainerRef=h.e(),this.slotContainerRef=h.e(),this.searchContainerRef=h.e(),this.slotContentRef=h.e(),this.searchMenuRef=h.e(),this.lastScrollPosition=0,this.savedScrollY=0,this.lastFocusedElement=null,this.shouldRestoreFocus=!1,this.handleScroll=()=>{if(!this.shouldHideOnScroll)return;const e=window.pageYOffset||document.documentElement.scrollTop;e<0||Math.abs(e-this.lastScrollPosition)<60||(this.isHidden=e>this.lastScrollPosition,this.lastScrollPosition=e)},this.handleClickOutside=e=>{const s=e.target;this.user&&this.openMenu==="user"&&!s.closest(".pkt-header-service__user-container")&&(this.openMenu="none"),this.openMenu==="slot"&&!s.closest(".pkt-header-service__slot-container")&&(this.openMenu="none"),this.openMenu==="search"&&!s.closest(".pkt-header-service__search-container")&&!s.closest(".pkt-header-service__search-input")&&(this.openMenu="none")},this.handleFocusOut=(e,s)=>{const n=e.relatedTarget;let r;switch(s){case"user":r=this.userContainerRef;break;case"slot":r=this.slotContainerRef;break;case"search":r=this.searchContainerRef;break;default:return}const l=r.value;l&&(!n||!l.contains(n))&&(this.openMenu="none")},this.handleEscapeKey=e=>{e.key==="Escape"&&this.openMenu!=="none"&&(e.preventDefault(),this.shouldRestoreFocus=!0,this.openMenu="none")},this.slotController=new g.PktSlotController(this,this.defaultSlot)}updateSlots(e){this.hasSlotContent=e.has(null)||e.has(void 0)}connectedCallback(){super.connectedCallback(),this.setupScrollListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.resizeObserver)==null||e.disconnect(),window.removeEventListener("scroll",this.handleScroll),this.unlockScroll()}firstUpdated(){this.setupResizeObserver()}updated(e){if(super.updated(e),e.has("openedMenu")&&this.openedMenu!==this.openMenu&&(this.openMenu=this.openedMenu),(e.has("mobileBreakpoint")||e.has("tabletBreakpoint"))&&(this.updateIsMobile(),this.updateIsTablet()),e.has("openMenu")){const s=e.get("openMenu");this.openMenu!=="none"&&(s==="none"||s===void 0)?(document.addEventListener("mousedown",this.handleClickOutside),document.addEventListener("keydown",this.handleEscapeKey),(this.openMenu==="slot"||this.openMenu==="search")&&requestAnimationFrame(()=>{this.checkDropdownAlignment(this.openMenu)})):this.openMenu==="none"&&s!=="none"&&(document.removeEventListener("mousedown",this.handleClickOutside),document.removeEventListener("keydown",this.handleEscapeKey),this.restoreFocus())}(e.has("openMenu")||e.has("isMobile"))&&this.updateScrollLock()}setupResizeObserver(){const e=this.headerRef.value;e&&(this.componentWidth=e.offsetWidth,this.updateIsMobile(),this.updateIsTablet(),this.resizeObserver=new ResizeObserver(s=>{for(const n of s)n.borderBoxSize&&n.borderBoxSize.length>0?this.componentWidth=n.borderBoxSize[0].inlineSize:this.componentWidth=n.contentRect.width,this.updateIsMobile(),this.updateIsTablet()}),this.resizeObserver.observe(e))}updateIsMobile(){this.isMobile=this.componentWidth<this.mobileBreakpoint}updateIsTablet(){this.isTablet=this.componentWidth<this.tabletBreakpoint}updateScrollLock(){this.position==="fixed"&&this.isMobile&&this.openMenu!=="none"?this.lockScroll():this.unlockScroll()}lockScroll(){const e=document.body,s=document.documentElement;this.savedScrollY=window.scrollY||window.pageYOffset;const n=window.innerWidth-s.clientWidth;n>0&&(e.style.paddingRight=`${n}px`),e.style.position="fixed",e.style.top=`-${this.savedScrollY}px`,e.style.left="0",e.style.right="0",e.style.width="100%",e.style.overflow="hidden",s.classList.add("is-scroll-locked")}unlockScroll(){const e=document.body,s=document.documentElement;s.classList.contains("is-scroll-locked")&&(e.style.removeProperty("position"),e.style.removeProperty("top"),e.style.removeProperty("left"),e.style.removeProperty("right"),e.style.removeProperty("width"),e.style.removeProperty("overflow"),e.style.removeProperty("padding-right"),s.classList.remove("is-scroll-locked"),window.scrollTo({top:this.savedScrollY}))}setupScrollListener(){window.addEventListener("scroll",this.handleScroll)}restoreFocus(){this.shouldRestoreFocus&&this.lastFocusedElement&&document.contains(this.lastFocusedElement)&&this.lastFocusedElement.focus(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1}checkDropdownAlignment(e){const s=e==="slot"?this.slotContainerRef:this.searchContainerRef,n=e==="slot"?this.slotContentRef:this.searchMenuRef;if(!s.value||!n.value||!this.isTablet||this.isMobile)return;const r=s.value.getBoundingClientRect(),l=n.value.offsetWidth,c=r.left+l>window.innerWidth;e==="slot"?this.alignSlotRight=c:this.alignSearchRight=c}handleMenuToggle(e){this.openMenu!=="none"?this.openMenu="none":(this.lastFocusedElement=document.activeElement,this.openMenu=e)}handleLogoClick(e){this.dispatchEvent(new CustomEvent("logo-click",{bubbles:!0,composed:!0,detail:{originalEvent:e}}))}handleServiceClick(e){this.dispatchEvent(new CustomEvent("service-click",{bubbles:!0,composed:!0,detail:{originalEvent:e}}))}handleLogout(){this.dispatchEvent(new CustomEvent("log-out",{bubbles:!0,composed:!0}))}handleSearch(e){this.dispatchEvent(new CustomEvent("search",{detail:{query:e},bubbles:!0,composed:!0}))}handleSearchChange(e){this.dispatchEvent(new CustomEvent("search-change",{detail:{query:e},bubbles:!0,composed:!0}))}handleSearchInputChange(e){const s=e.target.value;this.handleSearchChange(s)}handleSearchKeyDown(e){e.key==="Enter"&&this.handleSearch(e.target.value)}get formattedLastLoggedIn(){var e;return m((e=this.user)==null?void 0:e.lastLoggedIn)}get isFixed(){return this.position==="fixed"}get shouldHideOnScroll(){return this.scrollBehavior==="hide"}get showLogoutInHeader(){return this.hasLogOut&&(this.logOutButtonPlacement==="header"||this.logOutButtonPlacement==="both")}get showLogoutInUserMenu(){return this.hasLogOut&&(this.logOutButtonPlacement==="userMenu"||this.logOutButtonPlacement==="both")}renderLogo(){if(this.hideLogo)return t.E;const e=t.x`
|
|
84
|
+
<pkt-icon name="oslologo" aria-hidden="true" path=${_}></pkt-icon>
|
|
85
85
|
`;return this.logoLink&&typeof this.logoLink=="string"?t.x`
|
|
86
86
|
<span class="pkt-header-service__logo">
|
|
87
87
|
<a href=${this.logoLink} aria-label="Tilbake til forside" @click=${this.handleLogoClick}>
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
${this.isTablet&&this.hasSlotContent?t.x`
|
|
133
133
|
<pkt-button
|
|
134
134
|
skin="secondary"
|
|
135
|
-
variant
|
|
135
|
+
variant=${this.slotMenuVariant}
|
|
136
136
|
iconName="menu"
|
|
137
137
|
size=${this.isMobile?"small":"medium"}
|
|
138
138
|
state=${this.openMenu==="slot"?"active":"normal"}
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
aria-controls="mobile-slot-menu"
|
|
142
142
|
aria-label="Åpne meny"
|
|
143
143
|
>
|
|
144
|
-
|
|
144
|
+
${this.slotMenuText}
|
|
145
145
|
</pkt-button>
|
|
146
146
|
`:t.E}
|
|
147
147
|
<div
|
|
@@ -275,7 +275,7 @@
|
|
|
275
275
|
${e}
|
|
276
276
|
<div class=${s}></div>
|
|
277
277
|
</div>
|
|
278
|
-
`}return e}};i([t.n({type:String,attribute:"service-name"})],exports.PktHeaderService.prototype,"serviceName",2);i([t.n({type:String,attribute:"service-link"})],exports.PktHeaderService.prototype,"serviceLink",2);i([t.n({type:String,attribute:"logo-link"})],exports.PktHeaderService.prototype,"logoLink",2);i([t.n({type:String,attribute:"search-placeholder"})],exports.PktHeaderService.prototype,"searchPlaceholder",2);i([t.n({type:String,attribute:"search-value"})],exports.PktHeaderService.prototype,"searchValue",2);i([t.n({type:Number,attribute:"mobile-breakpoint"})],exports.PktHeaderService.prototype,"mobileBreakpoint",2);i([t.n({type:Number,attribute:"tablet-breakpoint"})],exports.PktHeaderService.prototype,"tabletBreakpoint",2);i([t.n({type:String,attribute:"opened-menu"})],exports.PktHeaderService.prototype,"openedMenu",2);i([t.n({type:String,attribute:"log-out-button-placement"})],exports.PktHeaderService.prototype,"logOutButtonPlacement",2);i([t.n({type:String})],exports.PktHeaderService.prototype,"position",2);i([t.n({type:String,attribute:"scroll-behavior"})],exports.PktHeaderService.prototype,"scrollBehavior",2);i([t.n({type:Boolean,attribute:"hide-logo",converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"hideLogo",2);i([t.n({type:Boolean,converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"compact",2);i([t.n({type:Boolean,attribute:"show-search",converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"showSearch",2);i([t.n({type:Boolean,attribute:"can-change-representation",converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"canChangeRepresentation",2);i([t.n({type:Boolean,attribute:"has-log-out",converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"hasLogOut",2);i([t.n({type:Object})],exports.PktHeaderService.prototype,"user",2);i([t.n({type:Array,attribute:"user-menu"})],exports.PktHeaderService.prototype,"userMenu",2);i([t.n({type:Object})],exports.PktHeaderService.prototype,"representing",2);i([d.r()],exports.PktHeaderService.prototype,"isMobile",2);i([d.r()],exports.PktHeaderService.prototype,"isTablet",2);i([d.r()],exports.PktHeaderService.prototype,"openMenu",2);i([d.r()],exports.PktHeaderService.prototype,"isHidden",2);i([d.r()],exports.PktHeaderService.prototype,"componentWidth",2);i([d.r()],exports.PktHeaderService.prototype,"hasSlotContent",2);i([d.r()],exports.PktHeaderService.prototype,"alignSlotRight",2);i([d.r()],exports.PktHeaderService.prototype,"alignSearchRight",2);exports.PktHeaderService=i([t.t("pkt-header-service")],exports.PktHeaderService);var P=Object.defineProperty,C=Object.getOwnPropertyDescriptor,a=(o,e,s,n)=>{for(var r=n>1?void 0:n?C(e,s):e,l=o.length-1,c;l>=0;l--)(c=o[l])&&(r=(n?c(e,s,r):c(r))||r);return n&&r&&P(e,s,r),r};exports.PktHeader=class extends t.PktElement{constructor(){super(),this.defaultSlot=h.e(),this.searchPlaceholder="Søk",this.searchValue="",this.mobileBreakpoint=768,this.tabletBreakpoint=1280,this.openedMenu="none",this.logOutButtonPlacement="none",this.position="fixed",this.scrollBehavior="hide",this.hideLogo=!1,this.compact=!1,this.showSearch=!1,this.canChangeRepresentation=!1,this.hasLogOut=!1,this.slotController=new g.PktSlotController(this,this.defaultSlot)}firstUpdated(e){super.firstUpdated(e),this.emitDeprecationWarnings()}emitDeprecationWarnings(){this.userMenuFooter!==void 0&&console.warn("[PktHeader] userMenuFooter is deprecated. Use userMenu instead."),this.userOptions!==void 0&&console.warn("[PktHeader] userOptions is deprecated. Use userMenu instead.")}get effectiveUserMenu(){const e=this.userMenu||[],s=this.userMenuFooter||[],n=this.userOptions||[];return s.length||n.length?[...e,...n,...s]:this.userMenu}render(){return t.x`
|
|
278
|
+
`}return e}};i([t.n({type:String,attribute:"service-name"})],exports.PktHeaderService.prototype,"serviceName",2);i([t.n({type:String,attribute:"service-link"})],exports.PktHeaderService.prototype,"serviceLink",2);i([t.n({type:String,attribute:"logo-link"})],exports.PktHeaderService.prototype,"logoLink",2);i([t.n({type:String,attribute:"search-placeholder"})],exports.PktHeaderService.prototype,"searchPlaceholder",2);i([t.n({type:String,attribute:"search-value"})],exports.PktHeaderService.prototype,"searchValue",2);i([t.n({type:Number,attribute:"mobile-breakpoint"})],exports.PktHeaderService.prototype,"mobileBreakpoint",2);i([t.n({type:Number,attribute:"tablet-breakpoint"})],exports.PktHeaderService.prototype,"tabletBreakpoint",2);i([t.n({type:String,attribute:"opened-menu"})],exports.PktHeaderService.prototype,"openedMenu",2);i([t.n({type:String,attribute:"log-out-button-placement"})],exports.PktHeaderService.prototype,"logOutButtonPlacement",2);i([t.n({type:String})],exports.PktHeaderService.prototype,"position",2);i([t.n({type:String,attribute:"scroll-behavior"})],exports.PktHeaderService.prototype,"scrollBehavior",2);i([t.n({type:String,attribute:"slot-menu-variant"})],exports.PktHeaderService.prototype,"slotMenuVariant",2);i([t.n({type:String,attribute:"slot-menu-text"})],exports.PktHeaderService.prototype,"slotMenuText",2);i([t.n({type:Boolean,attribute:"hide-logo",converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"hideLogo",2);i([t.n({type:Boolean,converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"compact",2);i([t.n({type:Boolean,attribute:"show-search",converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"showSearch",2);i([t.n({type:Boolean,attribute:"can-change-representation",converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"canChangeRepresentation",2);i([t.n({type:Boolean,attribute:"has-log-out",converter:u.booleanishConverter})],exports.PktHeaderService.prototype,"hasLogOut",2);i([t.n({type:Object})],exports.PktHeaderService.prototype,"user",2);i([t.n({type:Array,attribute:"user-menu"})],exports.PktHeaderService.prototype,"userMenu",2);i([t.n({type:Object})],exports.PktHeaderService.prototype,"representing",2);i([d.r()],exports.PktHeaderService.prototype,"isMobile",2);i([d.r()],exports.PktHeaderService.prototype,"isTablet",2);i([d.r()],exports.PktHeaderService.prototype,"openMenu",2);i([d.r()],exports.PktHeaderService.prototype,"isHidden",2);i([d.r()],exports.PktHeaderService.prototype,"componentWidth",2);i([d.r()],exports.PktHeaderService.prototype,"hasSlotContent",2);i([d.r()],exports.PktHeaderService.prototype,"alignSlotRight",2);i([d.r()],exports.PktHeaderService.prototype,"alignSearchRight",2);exports.PktHeaderService=i([t.t("pkt-header-service")],exports.PktHeaderService);var P=Object.defineProperty,C=Object.getOwnPropertyDescriptor,a=(o,e,s,n)=>{for(var r=n>1?void 0:n?C(e,s):e,l=o.length-1,c;l>=0;l--)(c=o[l])&&(r=(n?c(e,s,r):c(r))||r);return n&&r&&P(e,s,r),r};exports.PktHeader=class extends t.PktElement{constructor(){super(),this.defaultSlot=h.e(),this.searchPlaceholder="Søk",this.searchValue="",this.mobileBreakpoint=768,this.tabletBreakpoint=1280,this.openedMenu="none",this.logOutButtonPlacement="none",this.position="fixed",this.scrollBehavior="hide",this.slotMenuVariant="icon-only",this.slotMenuText="Meny",this.hideLogo=!1,this.compact=!1,this.showSearch=!1,this.canChangeRepresentation=!1,this.hasLogOut=!1,this.slotController=new g.PktSlotController(this,this.defaultSlot)}firstUpdated(e){super.firstUpdated(e),this.emitDeprecationWarnings()}emitDeprecationWarnings(){this.userMenuFooter!==void 0&&console.warn("[PktHeader] userMenuFooter is deprecated. Use userMenu instead."),this.userOptions!==void 0&&console.warn("[PktHeader] userOptions is deprecated. Use userMenu instead.")}get effectiveUserMenu(){const e=this.userMenu||[],s=this.userMenuFooter||[],n=this.userOptions||[];return s.length||n.length?[...e,...n,...s]:this.userMenu}render(){return t.x`
|
|
279
279
|
<pkt-header-service
|
|
280
280
|
service-name=${v.o(this.serviceName)}
|
|
281
281
|
service-link=${v.o(this.serviceLink)}
|
|
@@ -288,6 +288,8 @@
|
|
|
288
288
|
log-out-button-placement=${this.logOutButtonPlacement}
|
|
289
289
|
position=${this.position}
|
|
290
290
|
scroll-behavior=${this.scrollBehavior}
|
|
291
|
+
slot-menu-variant=${this.slotMenuVariant}
|
|
292
|
+
slot-menu-text=${this.slotMenuText}
|
|
291
293
|
.hideLogo=${this.hideLogo}
|
|
292
294
|
.compact=${this.compact}
|
|
293
295
|
.showSearch=${this.showSearch}
|
|
@@ -299,4 +301,4 @@
|
|
|
299
301
|
>
|
|
300
302
|
<div class="pkt-contents" ${h.n(this.defaultSlot)}></div>
|
|
301
303
|
</pkt-header-service>
|
|
302
|
-
`}};a([t.n({type:String,attribute:"service-name"})],exports.PktHeader.prototype,"serviceName",2);a([t.n({type:String,attribute:"service-link"})],exports.PktHeader.prototype,"serviceLink",2);a([t.n({type:String,attribute:"logo-link"})],exports.PktHeader.prototype,"logoLink",2);a([t.n({type:String,attribute:"search-placeholder"})],exports.PktHeader.prototype,"searchPlaceholder",2);a([t.n({type:String,attribute:"search-value"})],exports.PktHeader.prototype,"searchValue",2);a([t.n({type:Number,attribute:"mobile-breakpoint"})],exports.PktHeader.prototype,"mobileBreakpoint",2);a([t.n({type:Number,attribute:"tablet-breakpoint"})],exports.PktHeader.prototype,"tabletBreakpoint",2);a([t.n({type:String,attribute:"opened-menu"})],exports.PktHeader.prototype,"openedMenu",2);a([t.n({type:String,attribute:"log-out-button-placement"})],exports.PktHeader.prototype,"logOutButtonPlacement",2);a([t.n({type:String})],exports.PktHeader.prototype,"position",2);a([t.n({type:String,attribute:"scroll-behavior"})],exports.PktHeader.prototype,"scrollBehavior",2);a([t.n({type:Boolean,attribute:"hide-logo",converter:u.booleanishConverter})],exports.PktHeader.prototype,"hideLogo",2);a([t.n({type:Boolean,converter:u.booleanishConverter})],exports.PktHeader.prototype,"compact",2);a([t.n({type:Boolean,attribute:"show-search",converter:u.booleanishConverter})],exports.PktHeader.prototype,"showSearch",2);a([t.n({type:Boolean,attribute:"can-change-representation",converter:u.booleanishConverter})],exports.PktHeader.prototype,"canChangeRepresentation",2);a([t.n({type:Boolean,attribute:"has-log-out",converter:u.booleanishConverter})],exports.PktHeader.prototype,"hasLogOut",2);a([t.n({type:Object})],exports.PktHeader.prototype,"user",2);a([t.n({type:Array,attribute:"user-menu"})],exports.PktHeader.prototype,"userMenu",2);a([t.n({type:Object})],exports.PktHeader.prototype,"representing",2);a([t.n({type:Array,attribute:"user-menu-footer"})],exports.PktHeader.prototype,"userMenuFooter",2);a([t.n({type:Array,attribute:"user-options"})],exports.PktHeader.prototype,"userOptions",2);exports.PktHeader=a([t.t("pkt-header")],exports.PktHeader);exports.formatLastLoggedIn=
|
|
304
|
+
`}};a([t.n({type:String,attribute:"service-name"})],exports.PktHeader.prototype,"serviceName",2);a([t.n({type:String,attribute:"service-link"})],exports.PktHeader.prototype,"serviceLink",2);a([t.n({type:String,attribute:"logo-link"})],exports.PktHeader.prototype,"logoLink",2);a([t.n({type:String,attribute:"search-placeholder"})],exports.PktHeader.prototype,"searchPlaceholder",2);a([t.n({type:String,attribute:"search-value"})],exports.PktHeader.prototype,"searchValue",2);a([t.n({type:Number,attribute:"mobile-breakpoint"})],exports.PktHeader.prototype,"mobileBreakpoint",2);a([t.n({type:Number,attribute:"tablet-breakpoint"})],exports.PktHeader.prototype,"tabletBreakpoint",2);a([t.n({type:String,attribute:"opened-menu"})],exports.PktHeader.prototype,"openedMenu",2);a([t.n({type:String,attribute:"log-out-button-placement"})],exports.PktHeader.prototype,"logOutButtonPlacement",2);a([t.n({type:String})],exports.PktHeader.prototype,"position",2);a([t.n({type:String,attribute:"scroll-behavior"})],exports.PktHeader.prototype,"scrollBehavior",2);a([t.n({type:String,attribute:"slot-menu-variant"})],exports.PktHeader.prototype,"slotMenuVariant",2);a([t.n({type:String,attribute:"slot-menu-text"})],exports.PktHeader.prototype,"slotMenuText",2);a([t.n({type:Boolean,attribute:"hide-logo",converter:u.booleanishConverter})],exports.PktHeader.prototype,"hideLogo",2);a([t.n({type:Boolean,converter:u.booleanishConverter})],exports.PktHeader.prototype,"compact",2);a([t.n({type:Boolean,attribute:"show-search",converter:u.booleanishConverter})],exports.PktHeader.prototype,"showSearch",2);a([t.n({type:Boolean,attribute:"can-change-representation",converter:u.booleanishConverter})],exports.PktHeader.prototype,"canChangeRepresentation",2);a([t.n({type:Boolean,attribute:"has-log-out",converter:u.booleanishConverter})],exports.PktHeader.prototype,"hasLogOut",2);a([t.n({type:Object})],exports.PktHeader.prototype,"user",2);a([t.n({type:Array,attribute:"user-menu"})],exports.PktHeader.prototype,"userMenu",2);a([t.n({type:Object})],exports.PktHeader.prototype,"representing",2);a([t.n({type:Array,attribute:"user-menu-footer"})],exports.PktHeader.prototype,"userMenuFooter",2);a([t.n({type:Array,attribute:"user-options"})],exports.PktHeader.prototype,"userOptions",2);exports.PktHeader=a([t.t("pkt-header")],exports.PktHeader);exports.formatLastLoggedIn=m;
|
package/dist/pkt-header.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as _, E as
|
|
1
|
+
import { P as _, E as u, x as n, n as s, a as M } from "./element-CRDRygXu.js";
|
|
2
2
|
import { P as S } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
3
3
|
import { o as $ } from "./if-defined-BWZGb3bh.js";
|
|
4
4
|
import { e as v, n as k } from "./ref-Xa5dbh--.js";
|
|
@@ -21,10 +21,10 @@ const C = (e) => typeof e.target == "string" ? { title: e.title, iconName: e.ico
|
|
|
21
21
|
minute: "2-digit"
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
|
-
var O = Object.defineProperty, R = Object.getOwnPropertyDescriptor, y = (e, t, i,
|
|
25
|
-
for (var
|
|
26
|
-
(m = e[p]) && (
|
|
27
|
-
return
|
|
24
|
+
var O = Object.defineProperty, R = Object.getOwnPropertyDescriptor, y = (e, t, i, c) => {
|
|
25
|
+
for (var a = c > 1 ? void 0 : c ? R(t, i) : t, p = e.length - 1, m; p >= 0; p--)
|
|
26
|
+
(m = e[p]) && (a = (c ? m(t, i, a) : m(a)) || a);
|
|
27
|
+
return c && a && O(t, i, a), a;
|
|
28
28
|
};
|
|
29
29
|
let b = class extends _ {
|
|
30
30
|
constructor() {
|
|
@@ -50,7 +50,7 @@ let b = class extends _ {
|
|
|
50
50
|
"onClick" in e && typeof e.onClick == "function" && e.onClick();
|
|
51
51
|
}
|
|
52
52
|
renderLinkOrButton(e, t) {
|
|
53
|
-
const i = "href" in e,
|
|
53
|
+
const i = "href" in e, c = g({
|
|
54
54
|
"pkt-user-menu__link": !0,
|
|
55
55
|
"pkt-link-button": !i,
|
|
56
56
|
"pkt-link": !i,
|
|
@@ -59,7 +59,7 @@ let b = class extends _ {
|
|
|
59
59
|
});
|
|
60
60
|
return i ? n`
|
|
61
61
|
<pkt-link
|
|
62
|
-
icon-name=${e.iconName ||
|
|
62
|
+
icon-name=${e.iconName || u}
|
|
63
63
|
href=${e.href}
|
|
64
64
|
aria-hidden="true"
|
|
65
65
|
class="pkt-user-menu__link ${t || ""}"
|
|
@@ -67,12 +67,12 @@ let b = class extends _ {
|
|
|
67
67
|
${e.title}
|
|
68
68
|
</pkt-link>
|
|
69
69
|
` : n`
|
|
70
|
-
<button class=${
|
|
70
|
+
<button class=${c} type="button" @click=${() => this.handleMenuItemClick(e)}>
|
|
71
71
|
${e.iconName ? n`<pkt-icon
|
|
72
72
|
name=${e.iconName}
|
|
73
73
|
class="pkt-link__icon"
|
|
74
74
|
aria-hidden="true"
|
|
75
|
-
></pkt-icon>` :
|
|
75
|
+
></pkt-icon>` : u}
|
|
76
76
|
${e.title}
|
|
77
77
|
</button>
|
|
78
78
|
`;
|
|
@@ -103,14 +103,14 @@ let b = class extends _ {
|
|
|
103
103
|
<div class="pkt-user-menu__last-logged-in">
|
|
104
104
|
Sist pålogget: <time>${this.formattedLastLoggedIn}</time>
|
|
105
105
|
</div>
|
|
106
|
-
` :
|
|
106
|
+
` : u}
|
|
107
107
|
</li>
|
|
108
|
-
` :
|
|
108
|
+
` : u}
|
|
109
109
|
|
|
110
110
|
<!-- User menu items -->
|
|
111
111
|
${e && e.length > 0 ? n`
|
|
112
112
|
<li class="pkt-user-menu__item">${this.renderLinkSection(e)}</li>
|
|
113
|
-
` :
|
|
113
|
+
` : u}
|
|
114
114
|
|
|
115
115
|
<!-- Representing section -->
|
|
116
116
|
${this.representing ? n`
|
|
@@ -119,7 +119,7 @@ let b = class extends _ {
|
|
|
119
119
|
<div class="pkt-user-menu__name" translate="no">${this.representing.name}</div>
|
|
120
120
|
${this.representing.orgNumber ? n`<div class="pkt-user-menu__org-number">
|
|
121
121
|
Org.nr. ${this.representing.orgNumber}
|
|
122
|
-
</div>` :
|
|
122
|
+
</div>` : u}
|
|
123
123
|
${this.canChangeRepresentation ? n`
|
|
124
124
|
<ul class="pkt-user-menu__sublist mt-size-16">
|
|
125
125
|
<li class="pkt-user-menu__subitem">
|
|
@@ -130,9 +130,9 @@ let b = class extends _ {
|
|
|
130
130
|
})}
|
|
131
131
|
</li>
|
|
132
132
|
</ul>
|
|
133
|
-
` :
|
|
133
|
+
` : u}
|
|
134
134
|
</li>
|
|
135
|
-
` :
|
|
135
|
+
` : u}
|
|
136
136
|
|
|
137
137
|
<!-- Change representation without representing object -->
|
|
138
138
|
${!this.representing && this.canChangeRepresentation ? n`
|
|
@@ -147,7 +147,7 @@ let b = class extends _ {
|
|
|
147
147
|
</li>
|
|
148
148
|
</ul>
|
|
149
149
|
</li>
|
|
150
|
-
` :
|
|
150
|
+
` : u}
|
|
151
151
|
|
|
152
152
|
<!-- Logout -->
|
|
153
153
|
${this.logoutOnClick ? n`
|
|
@@ -158,7 +158,7 @@ let b = class extends _ {
|
|
|
158
158
|
onClick: () => this.handleLogout()
|
|
159
159
|
})}
|
|
160
160
|
</li>
|
|
161
|
-
` :
|
|
161
|
+
` : u}
|
|
162
162
|
</ul>
|
|
163
163
|
</nav>
|
|
164
164
|
`;
|
|
@@ -189,15 +189,15 @@ y([
|
|
|
189
189
|
b = y([
|
|
190
190
|
M("pkt-header-user-menu")
|
|
191
191
|
], b);
|
|
192
|
-
var B = Object.defineProperty, E = Object.getOwnPropertyDescriptor,
|
|
193
|
-
for (var
|
|
194
|
-
(m = e[p]) && (
|
|
195
|
-
return
|
|
192
|
+
var B = Object.defineProperty, E = Object.getOwnPropertyDescriptor, r = (e, t, i, c) => {
|
|
193
|
+
for (var a = c > 1 ? void 0 : c ? E(t, i) : t, p = e.length - 1, m; p >= 0; p--)
|
|
194
|
+
(m = e[p]) && (a = (c ? m(t, i, a) : m(a)) || a);
|
|
195
|
+
return c && a && B(t, i, a), a;
|
|
196
196
|
};
|
|
197
197
|
const P = "https://punkt-cdn.oslo.kommune.no/latest/logos/";
|
|
198
198
|
let o = class extends _ {
|
|
199
199
|
constructor() {
|
|
200
|
-
super(), this.searchPlaceholder = "Søk", this.searchValue = "", this.mobileBreakpoint = 768, this.tabletBreakpoint = 1280, this.openedMenu = "none", this.logOutButtonPlacement = "none", this.position = "fixed", this.scrollBehavior = "hide", this.hideLogo = !1, this.compact = !1, this.showSearch = !1, this.canChangeRepresentation = !1, this.hasLogOut = !1, this.isMobile = !1, this.isTablet = !1, this.openMenu = "none", this.isHidden = !1, this.componentWidth = typeof window < "u" ? window.innerWidth : 0, this.hasSlotContent = !1, this.alignSlotRight = !1, this.alignSearchRight = !1, this.defaultSlot = v(), this.headerRef = v(), this.userContainerRef = v(), this.slotContainerRef = v(), this.searchContainerRef = v(), this.slotContentRef = v(), this.searchMenuRef = v(), this.lastScrollPosition = 0, this.savedScrollY = 0, this.lastFocusedElement = null, this.shouldRestoreFocus = !1, this.handleScroll = () => {
|
|
200
|
+
super(), this.searchPlaceholder = "Søk", this.searchValue = "", this.mobileBreakpoint = 768, this.tabletBreakpoint = 1280, this.openedMenu = "none", this.logOutButtonPlacement = "none", this.position = "fixed", this.scrollBehavior = "hide", this.slotMenuVariant = "icon-only", this.slotMenuText = "Meny", this.hideLogo = !1, this.compact = !1, this.showSearch = !1, this.canChangeRepresentation = !1, this.hasLogOut = !1, this.isMobile = !1, this.isTablet = !1, this.openMenu = "none", this.isHidden = !1, this.componentWidth = typeof window < "u" ? window.innerWidth : 0, this.hasSlotContent = !1, this.alignSlotRight = !1, this.alignSearchRight = !1, this.defaultSlot = v(), this.headerRef = v(), this.userContainerRef = v(), this.slotContainerRef = v(), this.searchContainerRef = v(), this.slotContentRef = v(), this.searchMenuRef = v(), this.lastScrollPosition = 0, this.savedScrollY = 0, this.lastFocusedElement = null, this.shouldRestoreFocus = !1, this.handleScroll = () => {
|
|
201
201
|
if (!this.shouldHideOnScroll) return;
|
|
202
202
|
const e = window.pageYOffset || document.documentElement.scrollTop;
|
|
203
203
|
e < 0 || Math.abs(e - this.lastScrollPosition) < 60 || (this.isHidden = e > this.lastScrollPosition, this.lastScrollPosition = e);
|
|
@@ -206,22 +206,22 @@ let o = class extends _ {
|
|
|
206
206
|
this.user && this.openMenu === "user" && !t.closest(".pkt-header-service__user-container") && (this.openMenu = "none"), this.openMenu === "slot" && !t.closest(".pkt-header-service__slot-container") && (this.openMenu = "none"), this.openMenu === "search" && !t.closest(".pkt-header-service__search-container") && !t.closest(".pkt-header-service__search-input") && (this.openMenu = "none");
|
|
207
207
|
}, this.handleFocusOut = (e, t) => {
|
|
208
208
|
const i = e.relatedTarget;
|
|
209
|
-
let
|
|
209
|
+
let c;
|
|
210
210
|
switch (t) {
|
|
211
211
|
case "user":
|
|
212
|
-
|
|
212
|
+
c = this.userContainerRef;
|
|
213
213
|
break;
|
|
214
214
|
case "slot":
|
|
215
|
-
|
|
215
|
+
c = this.slotContainerRef;
|
|
216
216
|
break;
|
|
217
217
|
case "search":
|
|
218
|
-
|
|
218
|
+
c = this.searchContainerRef;
|
|
219
219
|
break;
|
|
220
220
|
default:
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
|
-
const
|
|
224
|
-
|
|
223
|
+
const a = c.value;
|
|
224
|
+
a && (!i || !a.contains(i)) && (this.openMenu = "none");
|
|
225
225
|
}, this.handleEscapeKey = (e) => {
|
|
226
226
|
e.key === "Escape" && this.openMenu !== "none" && (e.preventDefault(), this.shouldRestoreFocus = !0, this.openMenu = "none");
|
|
227
227
|
}, this.slotController = new S(this, this.defaultSlot);
|
|
@@ -283,7 +283,7 @@ let o = class extends _ {
|
|
|
283
283
|
checkDropdownAlignment(e) {
|
|
284
284
|
const t = e === "slot" ? this.slotContainerRef : this.searchContainerRef, i = e === "slot" ? this.slotContentRef : this.searchMenuRef;
|
|
285
285
|
if (!t.value || !i.value || !this.isTablet || this.isMobile) return;
|
|
286
|
-
const
|
|
286
|
+
const c = t.value.getBoundingClientRect(), a = i.value.offsetWidth, p = c.left + a > window.innerWidth;
|
|
287
287
|
e === "slot" ? this.alignSlotRight = p : this.alignSearchRight = p;
|
|
288
288
|
}
|
|
289
289
|
handleMenuToggle(e) {
|
|
@@ -357,7 +357,7 @@ let o = class extends _ {
|
|
|
357
357
|
return this.hasLogOut && (this.logOutButtonPlacement === "userMenu" || this.logOutButtonPlacement === "both");
|
|
358
358
|
}
|
|
359
359
|
renderLogo() {
|
|
360
|
-
if (this.hideLogo) return
|
|
360
|
+
if (this.hideLogo) return u;
|
|
361
361
|
const e = n`
|
|
362
362
|
<pkt-icon name="oslologo" aria-hidden="true" path=${P}></pkt-icon>
|
|
363
363
|
`;
|
|
@@ -405,7 +405,7 @@ let o = class extends _ {
|
|
|
405
405
|
<span class="pkt-header-service__service-name" @click=${this.handleServiceClick}>
|
|
406
406
|
<span class="pkt-header-service__service-link">${this.serviceName}</span>
|
|
407
407
|
</span>
|
|
408
|
-
` :
|
|
408
|
+
` : u;
|
|
409
409
|
}
|
|
410
410
|
renderSlotContainer() {
|
|
411
411
|
const e = g({
|
|
@@ -424,7 +424,7 @@ let o = class extends _ {
|
|
|
424
424
|
${this.isTablet && this.hasSlotContent ? n`
|
|
425
425
|
<pkt-button
|
|
426
426
|
skin="secondary"
|
|
427
|
-
variant
|
|
427
|
+
variant=${this.slotMenuVariant}
|
|
428
428
|
iconName="menu"
|
|
429
429
|
size=${this.isMobile ? "small" : "medium"}
|
|
430
430
|
state=${this.openMenu === "slot" ? "active" : "normal"}
|
|
@@ -433,14 +433,14 @@ let o = class extends _ {
|
|
|
433
433
|
aria-controls="mobile-slot-menu"
|
|
434
434
|
aria-label="Åpne meny"
|
|
435
435
|
>
|
|
436
|
-
|
|
436
|
+
${this.slotMenuText}
|
|
437
437
|
</pkt-button>
|
|
438
|
-
` :
|
|
438
|
+
` : u}
|
|
439
439
|
<div
|
|
440
440
|
class=${t}
|
|
441
441
|
id="mobile-slot-menu"
|
|
442
|
-
role=${this.isTablet ? "menu" :
|
|
443
|
-
aria-label=${this.isTablet ? "Meny" :
|
|
442
|
+
role=${this.isTablet ? "menu" : u}
|
|
443
|
+
aria-label=${this.isTablet ? "Meny" : u}
|
|
444
444
|
${k(this.slotContentRef)}
|
|
445
445
|
${k(this.defaultSlot)}
|
|
446
446
|
></div>
|
|
@@ -448,7 +448,7 @@ let o = class extends _ {
|
|
|
448
448
|
`;
|
|
449
449
|
}
|
|
450
450
|
renderSearch() {
|
|
451
|
-
if (!this.showSearch) return
|
|
451
|
+
if (!this.showSearch) return u;
|
|
452
452
|
if (this.isTablet) {
|
|
453
453
|
const e = g({
|
|
454
454
|
"pkt-header-service__search-container": !0,
|
|
@@ -494,7 +494,7 @@ let o = class extends _ {
|
|
|
494
494
|
i.key === "Enter" && this.handleSearch(i.target.value);
|
|
495
495
|
}}
|
|
496
496
|
></pkt-textinput>
|
|
497
|
-
` :
|
|
497
|
+
` : u}
|
|
498
498
|
</div>
|
|
499
499
|
</div>
|
|
500
500
|
`;
|
|
@@ -515,7 +515,7 @@ let o = class extends _ {
|
|
|
515
515
|
}
|
|
516
516
|
renderUserButton() {
|
|
517
517
|
var t;
|
|
518
|
-
if (!this.user) return
|
|
518
|
+
if (!this.user) return u;
|
|
519
519
|
const e = g({
|
|
520
520
|
"pkt-header-service__user-menu": this.isMobile === !1,
|
|
521
521
|
"pkt-header-service__mobile-menu": this.isMobile === !0,
|
|
@@ -547,7 +547,7 @@ let o = class extends _ {
|
|
|
547
547
|
<div class=${e}>
|
|
548
548
|
<pkt-header-user-menu
|
|
549
549
|
.user=${this.user}
|
|
550
|
-
formatted-last-logged-in=${this.formattedLastLoggedIn ||
|
|
550
|
+
formatted-last-logged-in=${this.formattedLastLoggedIn || u}
|
|
551
551
|
.representing=${this.representing}
|
|
552
552
|
.userMenu=${this.userMenu}
|
|
553
553
|
?can-change-representation=${this.canChangeRepresentation}
|
|
@@ -558,7 +558,7 @@ let o = class extends _ {
|
|
|
558
558
|
@log-out=${this.handleLogout}
|
|
559
559
|
></pkt-header-user-menu>
|
|
560
560
|
</div>
|
|
561
|
-
` :
|
|
561
|
+
` : u}
|
|
562
562
|
</div>
|
|
563
563
|
`;
|
|
564
564
|
}
|
|
@@ -591,7 +591,7 @@ let o = class extends _ {
|
|
|
591
591
|
>
|
|
592
592
|
Logg ut
|
|
593
593
|
</pkt-button>
|
|
594
|
-
` :
|
|
594
|
+
` : u}
|
|
595
595
|
</div>
|
|
596
596
|
|
|
597
597
|
<div class="pkt-header-service__user">
|
|
@@ -606,7 +606,7 @@ let o = class extends _ {
|
|
|
606
606
|
>
|
|
607
607
|
Logg ut
|
|
608
608
|
</pkt-button>
|
|
609
|
-
` :
|
|
609
|
+
` : u}
|
|
610
610
|
</div>
|
|
611
611
|
</header>
|
|
612
612
|
`;
|
|
@@ -630,102 +630,108 @@ let o = class extends _ {
|
|
|
630
630
|
return e;
|
|
631
631
|
}
|
|
632
632
|
};
|
|
633
|
-
|
|
633
|
+
r([
|
|
634
634
|
s({ type: String, attribute: "service-name" })
|
|
635
635
|
], o.prototype, "serviceName", 2);
|
|
636
|
-
|
|
636
|
+
r([
|
|
637
637
|
s({ type: String, attribute: "service-link" })
|
|
638
638
|
], o.prototype, "serviceLink", 2);
|
|
639
|
-
|
|
639
|
+
r([
|
|
640
640
|
s({ type: String, attribute: "logo-link" })
|
|
641
641
|
], o.prototype, "logoLink", 2);
|
|
642
|
-
|
|
642
|
+
r([
|
|
643
643
|
s({ type: String, attribute: "search-placeholder" })
|
|
644
644
|
], o.prototype, "searchPlaceholder", 2);
|
|
645
|
-
|
|
645
|
+
r([
|
|
646
646
|
s({ type: String, attribute: "search-value" })
|
|
647
647
|
], o.prototype, "searchValue", 2);
|
|
648
|
-
|
|
648
|
+
r([
|
|
649
649
|
s({ type: Number, attribute: "mobile-breakpoint" })
|
|
650
650
|
], o.prototype, "mobileBreakpoint", 2);
|
|
651
|
-
|
|
651
|
+
r([
|
|
652
652
|
s({ type: Number, attribute: "tablet-breakpoint" })
|
|
653
653
|
], o.prototype, "tabletBreakpoint", 2);
|
|
654
|
-
|
|
654
|
+
r([
|
|
655
655
|
s({ type: String, attribute: "opened-menu" })
|
|
656
656
|
], o.prototype, "openedMenu", 2);
|
|
657
|
-
|
|
657
|
+
r([
|
|
658
658
|
s({ type: String, attribute: "log-out-button-placement" })
|
|
659
659
|
], o.prototype, "logOutButtonPlacement", 2);
|
|
660
|
-
|
|
660
|
+
r([
|
|
661
661
|
s({ type: String })
|
|
662
662
|
], o.prototype, "position", 2);
|
|
663
|
-
|
|
663
|
+
r([
|
|
664
664
|
s({ type: String, attribute: "scroll-behavior" })
|
|
665
665
|
], o.prototype, "scrollBehavior", 2);
|
|
666
|
-
|
|
666
|
+
r([
|
|
667
|
+
s({ type: String, attribute: "slot-menu-variant" })
|
|
668
|
+
], o.prototype, "slotMenuVariant", 2);
|
|
669
|
+
r([
|
|
670
|
+
s({ type: String, attribute: "slot-menu-text" })
|
|
671
|
+
], o.prototype, "slotMenuText", 2);
|
|
672
|
+
r([
|
|
667
673
|
s({ type: Boolean, attribute: "hide-logo", converter: d })
|
|
668
674
|
], o.prototype, "hideLogo", 2);
|
|
669
|
-
|
|
675
|
+
r([
|
|
670
676
|
s({ type: Boolean, converter: d })
|
|
671
677
|
], o.prototype, "compact", 2);
|
|
672
|
-
|
|
678
|
+
r([
|
|
673
679
|
s({ type: Boolean, attribute: "show-search", converter: d })
|
|
674
680
|
], o.prototype, "showSearch", 2);
|
|
675
|
-
|
|
681
|
+
r([
|
|
676
682
|
s({
|
|
677
683
|
type: Boolean,
|
|
678
684
|
attribute: "can-change-representation",
|
|
679
685
|
converter: d
|
|
680
686
|
})
|
|
681
687
|
], o.prototype, "canChangeRepresentation", 2);
|
|
682
|
-
|
|
688
|
+
r([
|
|
683
689
|
s({ type: Boolean, attribute: "has-log-out", converter: d })
|
|
684
690
|
], o.prototype, "hasLogOut", 2);
|
|
685
|
-
|
|
691
|
+
r([
|
|
686
692
|
s({ type: Object })
|
|
687
693
|
], o.prototype, "user", 2);
|
|
688
|
-
|
|
694
|
+
r([
|
|
689
695
|
s({ type: Array, attribute: "user-menu" })
|
|
690
696
|
], o.prototype, "userMenu", 2);
|
|
691
|
-
|
|
697
|
+
r([
|
|
692
698
|
s({ type: Object })
|
|
693
699
|
], o.prototype, "representing", 2);
|
|
694
|
-
|
|
700
|
+
r([
|
|
695
701
|
f()
|
|
696
702
|
], o.prototype, "isMobile", 2);
|
|
697
|
-
|
|
703
|
+
r([
|
|
698
704
|
f()
|
|
699
705
|
], o.prototype, "isTablet", 2);
|
|
700
|
-
|
|
706
|
+
r([
|
|
701
707
|
f()
|
|
702
708
|
], o.prototype, "openMenu", 2);
|
|
703
|
-
|
|
709
|
+
r([
|
|
704
710
|
f()
|
|
705
711
|
], o.prototype, "isHidden", 2);
|
|
706
|
-
|
|
712
|
+
r([
|
|
707
713
|
f()
|
|
708
714
|
], o.prototype, "componentWidth", 2);
|
|
709
|
-
|
|
715
|
+
r([
|
|
710
716
|
f()
|
|
711
717
|
], o.prototype, "hasSlotContent", 2);
|
|
712
|
-
|
|
718
|
+
r([
|
|
713
719
|
f()
|
|
714
720
|
], o.prototype, "alignSlotRight", 2);
|
|
715
|
-
|
|
721
|
+
r([
|
|
716
722
|
f()
|
|
717
723
|
], o.prototype, "alignSearchRight", 2);
|
|
718
|
-
o =
|
|
724
|
+
o = r([
|
|
719
725
|
M("pkt-header-service")
|
|
720
726
|
], o);
|
|
721
|
-
var
|
|
722
|
-
for (var
|
|
723
|
-
(m = e[p]) && (
|
|
724
|
-
return
|
|
727
|
+
var x = Object.defineProperty, N = Object.getOwnPropertyDescriptor, h = (e, t, i, c) => {
|
|
728
|
+
for (var a = c > 1 ? void 0 : c ? N(t, i) : t, p = e.length - 1, m; p >= 0; p--)
|
|
729
|
+
(m = e[p]) && (a = (c ? m(t, i, a) : m(a)) || a);
|
|
730
|
+
return c && a && x(t, i, a), a;
|
|
725
731
|
};
|
|
726
|
-
let
|
|
732
|
+
let l = class extends _ {
|
|
727
733
|
constructor() {
|
|
728
|
-
super(), this.defaultSlot = v(), this.searchPlaceholder = "Søk", this.searchValue = "", this.mobileBreakpoint = 768, this.tabletBreakpoint = 1280, this.openedMenu = "none", this.logOutButtonPlacement = "none", this.position = "fixed", this.scrollBehavior = "hide", this.hideLogo = !1, this.compact = !1, this.showSearch = !1, this.canChangeRepresentation = !1, this.hasLogOut = !1, this.slotController = new S(this, this.defaultSlot);
|
|
734
|
+
super(), this.defaultSlot = v(), this.searchPlaceholder = "Søk", this.searchValue = "", this.mobileBreakpoint = 768, this.tabletBreakpoint = 1280, this.openedMenu = "none", this.logOutButtonPlacement = "none", this.position = "fixed", this.scrollBehavior = "hide", this.slotMenuVariant = "icon-only", this.slotMenuText = "Meny", this.hideLogo = !1, this.compact = !1, this.showSearch = !1, this.canChangeRepresentation = !1, this.hasLogOut = !1, this.slotController = new S(this, this.defaultSlot);
|
|
729
735
|
}
|
|
730
736
|
firstUpdated(e) {
|
|
731
737
|
super.firstUpdated(e), this.emitDeprecationWarnings();
|
|
@@ -754,6 +760,8 @@ let h = class extends _ {
|
|
|
754
760
|
log-out-button-placement=${this.logOutButtonPlacement}
|
|
755
761
|
position=${this.position}
|
|
756
762
|
scroll-behavior=${this.scrollBehavior}
|
|
763
|
+
slot-menu-variant=${this.slotMenuVariant}
|
|
764
|
+
slot-menu-text=${this.slotMenuText}
|
|
757
765
|
.hideLogo=${this.hideLogo}
|
|
758
766
|
.compact=${this.compact}
|
|
759
767
|
.showSearch=${this.showSearch}
|
|
@@ -768,78 +776,84 @@ let h = class extends _ {
|
|
|
768
776
|
`;
|
|
769
777
|
}
|
|
770
778
|
};
|
|
771
|
-
|
|
779
|
+
h([
|
|
772
780
|
s({ type: String, attribute: "service-name" })
|
|
773
|
-
],
|
|
774
|
-
|
|
781
|
+
], l.prototype, "serviceName", 2);
|
|
782
|
+
h([
|
|
775
783
|
s({ type: String, attribute: "service-link" })
|
|
776
|
-
],
|
|
777
|
-
|
|
784
|
+
], l.prototype, "serviceLink", 2);
|
|
785
|
+
h([
|
|
778
786
|
s({ type: String, attribute: "logo-link" })
|
|
779
|
-
],
|
|
780
|
-
|
|
787
|
+
], l.prototype, "logoLink", 2);
|
|
788
|
+
h([
|
|
781
789
|
s({ type: String, attribute: "search-placeholder" })
|
|
782
|
-
],
|
|
783
|
-
|
|
790
|
+
], l.prototype, "searchPlaceholder", 2);
|
|
791
|
+
h([
|
|
784
792
|
s({ type: String, attribute: "search-value" })
|
|
785
|
-
],
|
|
786
|
-
|
|
793
|
+
], l.prototype, "searchValue", 2);
|
|
794
|
+
h([
|
|
787
795
|
s({ type: Number, attribute: "mobile-breakpoint" })
|
|
788
|
-
],
|
|
789
|
-
|
|
796
|
+
], l.prototype, "mobileBreakpoint", 2);
|
|
797
|
+
h([
|
|
790
798
|
s({ type: Number, attribute: "tablet-breakpoint" })
|
|
791
|
-
],
|
|
792
|
-
|
|
799
|
+
], l.prototype, "tabletBreakpoint", 2);
|
|
800
|
+
h([
|
|
793
801
|
s({ type: String, attribute: "opened-menu" })
|
|
794
|
-
],
|
|
795
|
-
|
|
802
|
+
], l.prototype, "openedMenu", 2);
|
|
803
|
+
h([
|
|
796
804
|
s({ type: String, attribute: "log-out-button-placement" })
|
|
797
|
-
],
|
|
798
|
-
|
|
805
|
+
], l.prototype, "logOutButtonPlacement", 2);
|
|
806
|
+
h([
|
|
799
807
|
s({ type: String })
|
|
800
|
-
],
|
|
801
|
-
|
|
808
|
+
], l.prototype, "position", 2);
|
|
809
|
+
h([
|
|
802
810
|
s({ type: String, attribute: "scroll-behavior" })
|
|
803
|
-
],
|
|
804
|
-
|
|
811
|
+
], l.prototype, "scrollBehavior", 2);
|
|
812
|
+
h([
|
|
813
|
+
s({ type: String, attribute: "slot-menu-variant" })
|
|
814
|
+
], l.prototype, "slotMenuVariant", 2);
|
|
815
|
+
h([
|
|
816
|
+
s({ type: String, attribute: "slot-menu-text" })
|
|
817
|
+
], l.prototype, "slotMenuText", 2);
|
|
818
|
+
h([
|
|
805
819
|
s({ type: Boolean, attribute: "hide-logo", converter: d })
|
|
806
|
-
],
|
|
807
|
-
|
|
820
|
+
], l.prototype, "hideLogo", 2);
|
|
821
|
+
h([
|
|
808
822
|
s({ type: Boolean, converter: d })
|
|
809
|
-
],
|
|
810
|
-
|
|
823
|
+
], l.prototype, "compact", 2);
|
|
824
|
+
h([
|
|
811
825
|
s({ type: Boolean, attribute: "show-search", converter: d })
|
|
812
|
-
],
|
|
813
|
-
|
|
826
|
+
], l.prototype, "showSearch", 2);
|
|
827
|
+
h([
|
|
814
828
|
s({
|
|
815
829
|
type: Boolean,
|
|
816
830
|
attribute: "can-change-representation",
|
|
817
831
|
converter: d
|
|
818
832
|
})
|
|
819
|
-
],
|
|
820
|
-
|
|
833
|
+
], l.prototype, "canChangeRepresentation", 2);
|
|
834
|
+
h([
|
|
821
835
|
s({ type: Boolean, attribute: "has-log-out", converter: d })
|
|
822
|
-
],
|
|
823
|
-
|
|
836
|
+
], l.prototype, "hasLogOut", 2);
|
|
837
|
+
h([
|
|
824
838
|
s({ type: Object })
|
|
825
|
-
],
|
|
826
|
-
|
|
839
|
+
], l.prototype, "user", 2);
|
|
840
|
+
h([
|
|
827
841
|
s({ type: Array, attribute: "user-menu" })
|
|
828
|
-
],
|
|
829
|
-
|
|
842
|
+
], l.prototype, "userMenu", 2);
|
|
843
|
+
h([
|
|
830
844
|
s({ type: Object })
|
|
831
|
-
],
|
|
832
|
-
|
|
845
|
+
], l.prototype, "representing", 2);
|
|
846
|
+
h([
|
|
833
847
|
s({ type: Array, attribute: "user-menu-footer" })
|
|
834
|
-
],
|
|
835
|
-
|
|
848
|
+
], l.prototype, "userMenuFooter", 2);
|
|
849
|
+
h([
|
|
836
850
|
s({ type: Array, attribute: "user-options" })
|
|
837
|
-
],
|
|
838
|
-
|
|
851
|
+
], l.prototype, "userOptions", 2);
|
|
852
|
+
l = h([
|
|
839
853
|
M("pkt-header")
|
|
840
|
-
],
|
|
854
|
+
], l);
|
|
841
855
|
export {
|
|
842
|
-
|
|
856
|
+
l as PktHeader,
|
|
843
857
|
o as PktHeaderService,
|
|
844
858
|
b as PktHeaderUserMenu,
|
|
845
859
|
w as formatLastLoggedIn
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.3.0",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
80
80
|
},
|
|
81
81
|
"license": "MIT",
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "892df7abaa2e9e117dc32b0c44c77592c80233cb"
|
|
83
83
|
}
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
User,
|
|
9
9
|
Representing,
|
|
10
10
|
UserMenuItem,
|
|
11
|
-
|
|
11
|
+
THeaderMenu,
|
|
12
12
|
TLogOutButtonPlacement,
|
|
13
13
|
THeaderPosition,
|
|
14
14
|
THeaderScrollBehavior,
|
|
15
|
+
TSlotMenuVariant,
|
|
15
16
|
IPktHeader,
|
|
16
17
|
Booleanish,
|
|
17
18
|
booleanishConverter,
|
|
@@ -35,12 +36,15 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
35
36
|
@property({ type: String, attribute: 'search-value' }) searchValue = ''
|
|
36
37
|
@property({ type: Number, attribute: 'mobile-breakpoint' }) mobileBreakpoint: number = 768
|
|
37
38
|
@property({ type: Number, attribute: 'tablet-breakpoint' }) tabletBreakpoint: number = 1280
|
|
38
|
-
@property({ type: String, attribute: 'opened-menu' }) openedMenu:
|
|
39
|
+
@property({ type: String, attribute: 'opened-menu' }) openedMenu: THeaderMenu = 'none'
|
|
39
40
|
@property({ type: String, attribute: 'log-out-button-placement' })
|
|
40
41
|
logOutButtonPlacement: TLogOutButtonPlacement = 'none'
|
|
41
42
|
@property({ type: String }) position: THeaderPosition = 'fixed'
|
|
42
43
|
@property({ type: String, attribute: 'scroll-behavior' }) scrollBehavior: THeaderScrollBehavior =
|
|
43
44
|
'hide'
|
|
45
|
+
@property({ type: String, attribute: 'slot-menu-variant' })
|
|
46
|
+
slotMenuVariant: TSlotMenuVariant = 'icon-only'
|
|
47
|
+
@property({ type: String, attribute: 'slot-menu-text' }) slotMenuText = 'Meny'
|
|
44
48
|
|
|
45
49
|
@property({ type: Boolean, attribute: 'hide-logo', converter: booleanishConverter })
|
|
46
50
|
hideLogo: Booleanish = false
|
|
@@ -62,7 +66,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
62
66
|
|
|
63
67
|
@state() private isMobile = false
|
|
64
68
|
@state() private isTablet = false
|
|
65
|
-
@state() private openMenu:
|
|
69
|
+
@state() private openMenu: THeaderMenu = 'none'
|
|
66
70
|
@state() private isHidden = false
|
|
67
71
|
@state() private componentWidth = typeof window !== 'undefined' ? window.innerWidth : 0
|
|
68
72
|
@state() private hasSlotContent = false
|
|
@@ -123,7 +127,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
if (changedProperties.has('openMenu')) {
|
|
126
|
-
const previousOpenMenu = changedProperties.get('openMenu') as
|
|
130
|
+
const previousOpenMenu = changedProperties.get('openMenu') as THeaderMenu | undefined
|
|
127
131
|
if (
|
|
128
132
|
this.openMenu !== 'none' &&
|
|
129
133
|
(previousOpenMenu === 'none' || previousOpenMenu === undefined)
|
|
@@ -263,7 +267,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
263
267
|
}
|
|
264
268
|
}
|
|
265
269
|
|
|
266
|
-
private handleFocusOut = (event: FocusEvent, menuType:
|
|
270
|
+
private handleFocusOut = (event: FocusEvent, menuType: THeaderMenu) => {
|
|
267
271
|
const relatedTarget = event.relatedTarget as HTMLElement | null
|
|
268
272
|
|
|
269
273
|
let containerRef: Ref<HTMLElement>
|
|
@@ -325,7 +329,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
325
329
|
}
|
|
326
330
|
}
|
|
327
331
|
|
|
328
|
-
private handleMenuToggle(mode:
|
|
332
|
+
private handleMenuToggle(mode: THeaderMenu) {
|
|
329
333
|
if (this.openMenu !== 'none') {
|
|
330
334
|
this.openMenu = 'none'
|
|
331
335
|
} else {
|
|
@@ -520,7 +524,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
520
524
|
? html`
|
|
521
525
|
<pkt-button
|
|
522
526
|
skin="secondary"
|
|
523
|
-
variant
|
|
527
|
+
variant=${this.slotMenuVariant}
|
|
524
528
|
iconName="menu"
|
|
525
529
|
size=${this.isMobile ? 'small' : 'medium'}
|
|
526
530
|
state=${this.openMenu === 'slot' ? 'active' : 'normal'}
|
|
@@ -529,7 +533,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
529
533
|
aria-controls="mobile-slot-menu"
|
|
530
534
|
aria-label="Åpne meny"
|
|
531
535
|
>
|
|
532
|
-
|
|
536
|
+
${this.slotMenuText}
|
|
533
537
|
</pkt-button>
|
|
534
538
|
`
|
|
535
539
|
: nothing}
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
User,
|
|
9
9
|
Representing,
|
|
10
10
|
UserMenuItem,
|
|
11
|
-
|
|
11
|
+
THeaderMenu,
|
|
12
12
|
TLogOutButtonPlacement,
|
|
13
13
|
THeaderPosition,
|
|
14
14
|
THeaderScrollBehavior,
|
|
15
|
+
TSlotMenuVariant,
|
|
15
16
|
IPktHeader,
|
|
16
17
|
Booleanish,
|
|
17
18
|
booleanishConverter,
|
|
@@ -43,12 +44,15 @@ export class PktHeader extends PktElement<IPktHeader> implements IPktHeader {
|
|
|
43
44
|
@property({ type: String, attribute: 'search-value' }) searchValue = ''
|
|
44
45
|
@property({ type: Number, attribute: 'mobile-breakpoint' }) mobileBreakpoint: number = 768
|
|
45
46
|
@property({ type: Number, attribute: 'tablet-breakpoint' }) tabletBreakpoint: number = 1280
|
|
46
|
-
@property({ type: String, attribute: 'opened-menu' }) openedMenu:
|
|
47
|
+
@property({ type: String, attribute: 'opened-menu' }) openedMenu: THeaderMenu = 'none'
|
|
47
48
|
@property({ type: String, attribute: 'log-out-button-placement' })
|
|
48
49
|
logOutButtonPlacement: TLogOutButtonPlacement = 'none'
|
|
49
50
|
@property({ type: String }) position: THeaderPosition = 'fixed'
|
|
50
51
|
@property({ type: String, attribute: 'scroll-behavior' }) scrollBehavior: THeaderScrollBehavior =
|
|
51
52
|
'hide'
|
|
53
|
+
@property({ type: String, attribute: 'slot-menu-variant' })
|
|
54
|
+
slotMenuVariant: TSlotMenuVariant = 'icon-only'
|
|
55
|
+
@property({ type: String, attribute: 'slot-menu-text' }) slotMenuText = 'Meny'
|
|
52
56
|
|
|
53
57
|
@property({ type: Boolean, attribute: 'hide-logo', converter: booleanishConverter })
|
|
54
58
|
hideLogo: Booleanish = false
|
|
@@ -119,6 +123,8 @@ export class PktHeader extends PktElement<IPktHeader> implements IPktHeader {
|
|
|
119
123
|
log-out-button-placement=${this.logOutButtonPlacement}
|
|
120
124
|
position=${this.position}
|
|
121
125
|
scroll-behavior=${this.scrollBehavior}
|
|
126
|
+
slot-menu-variant=${this.slotMenuVariant}
|
|
127
|
+
slot-menu-text=${this.slotMenuText}
|
|
122
128
|
.hideLogo=${this.hideLogo}
|
|
123
129
|
.compact=${this.compact}
|
|
124
130
|
.showSearch=${this.showSearch}
|
|
@@ -6,10 +6,22 @@ import type {
|
|
|
6
6
|
Representing as SharedRepresenting,
|
|
7
7
|
UserMenuItem as SharedUserMenuItem,
|
|
8
8
|
TInternalMenuItem as SharedTInternalMenuItem,
|
|
9
|
+
TSlotMenuVariant,
|
|
10
|
+
THeaderMenu,
|
|
11
|
+
TLogOutButtonPlacement,
|
|
12
|
+
THeaderPosition,
|
|
13
|
+
THeaderScrollBehavior,
|
|
9
14
|
} from 'shared-types'
|
|
10
15
|
import { convertUserMenuItem as sharedConvertUserMenuItem } from 'shared-types'
|
|
11
16
|
|
|
12
|
-
export type {
|
|
17
|
+
export type {
|
|
18
|
+
Booleanish,
|
|
19
|
+
TSlotMenuVariant,
|
|
20
|
+
THeaderMenu,
|
|
21
|
+
TLogOutButtonPlacement,
|
|
22
|
+
THeaderPosition,
|
|
23
|
+
THeaderScrollBehavior,
|
|
24
|
+
}
|
|
13
25
|
export { booleanishConverter }
|
|
14
26
|
|
|
15
27
|
// Re-export with PktIconName typing
|
|
@@ -25,26 +37,6 @@ export const convertUserMenuItem = (item: UserMenuItem): TInternalMenuItem => {
|
|
|
25
37
|
return sharedConvertUserMenuItem(item)
|
|
26
38
|
}
|
|
27
39
|
|
|
28
|
-
/**
|
|
29
|
-
* Type for which menu is currently open
|
|
30
|
-
*/
|
|
31
|
-
export type TPktHeaderMenu = 'none' | 'slot' | 'search' | 'user'
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Type for logout button placement
|
|
35
|
-
*/
|
|
36
|
-
export type TLogOutButtonPlacement = 'userMenu' | 'header' | 'both' | 'none'
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Position options for header
|
|
40
|
-
*/
|
|
41
|
-
export type THeaderPosition = 'fixed' | 'relative'
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Scroll behavior options for header
|
|
45
|
-
*/
|
|
46
|
-
export type THeaderScrollBehavior = 'hide' | 'none'
|
|
47
|
-
|
|
48
40
|
/**
|
|
49
41
|
* Interface for the Header component props
|
|
50
42
|
*/
|
|
@@ -86,5 +78,9 @@ export interface IPktHeader {
|
|
|
86
78
|
/** Custom breakpoint for tablet responsive behavior in pixels. Default: 1280 */
|
|
87
79
|
tabletBreakpoint?: number
|
|
88
80
|
/** Which menu is initially open */
|
|
89
|
-
openedMenu?:
|
|
81
|
+
openedMenu?: THeaderMenu
|
|
82
|
+
/** Variant for the slot menu button. Default: 'icon-only' */
|
|
83
|
+
slotMenuVariant?: TSlotMenuVariant
|
|
84
|
+
/** Text for the slot menu button. Default: 'Meny' */
|
|
85
|
+
slotMenuText?: string
|
|
90
86
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -49,8 +49,11 @@ export type {
|
|
|
49
49
|
User as IPktHeaderUser,
|
|
50
50
|
Representing as IPktHeaderRepresenting,
|
|
51
51
|
UserMenuItem as IPktHeaderUserMenuItem,
|
|
52
|
-
|
|
52
|
+
THeaderMenu,
|
|
53
53
|
TLogOutButtonPlacement as TPktHeaderLogOutButtonPlacement,
|
|
54
|
+
THeaderPosition,
|
|
55
|
+
THeaderScrollBehavior,
|
|
56
|
+
TSlotMenuVariant,
|
|
54
57
|
IPktHeader,
|
|
55
58
|
} from '@/components/header'
|
|
56
59
|
|