@oslokommune/punkt-react 14.2.0 → 14.3.1
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 +36 -0
- package/dist/index.d.ts +15 -6
- package/dist/punkt-react.es.js +2563 -2545
- package/dist/punkt-react.umd.js +275 -273
- package/package.json +3 -3
- package/src/components/header/HeaderService.tsx +10 -6
- package/src/components/header/types.ts +25 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.3.1",
|
|
4
4
|
"description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@lit-labs/ssr-dom-shim": "^1.2.1",
|
|
41
41
|
"@lit/react": "^1.0.7",
|
|
42
|
-
"@oslokommune/punkt-elements": "^14.
|
|
42
|
+
"@oslokommune/punkt-elements": "^14.3.0",
|
|
43
43
|
"classnames": "^2.5.1",
|
|
44
44
|
"prettier": "^3.3.3",
|
|
45
45
|
"react-hook-form": "^7.53.0"
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
104
104
|
},
|
|
105
105
|
"license": "MIT",
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "53803b9d2bfd31e286f7ee79b2184570a3e208cc"
|
|
107
107
|
}
|
|
@@ -9,9 +9,9 @@ import { PktTextinput } from '../textinput/Textinput'
|
|
|
9
9
|
import { useElementWidth } from '../../hooks/useElementWidth'
|
|
10
10
|
import classNames from 'classnames'
|
|
11
11
|
import { useScrollLock } from '../../hooks/useScrollLock'
|
|
12
|
-
import { User, Representing, UserMenuItem, UserMenuFooterItem, IPktHeader,
|
|
12
|
+
import { User, Representing, UserMenuItem, UserMenuFooterItem, IPktHeader, THeaderMenu } from './types'
|
|
13
13
|
|
|
14
|
-
export type { User, Representing, UserMenuItem, UserMenuFooterItem,
|
|
14
|
+
export type { User, Representing, UserMenuItem, UserMenuFooterItem, THeaderMenu }
|
|
15
15
|
export type IPktHeaderService = IPktHeader
|
|
16
16
|
|
|
17
17
|
export const PktHeaderService = forwardRef(
|
|
@@ -20,6 +20,7 @@ export const PktHeaderService = forwardRef(
|
|
|
20
20
|
mobileBreakpoint = 768,
|
|
21
21
|
tabletBreakpoint = 1280,
|
|
22
22
|
children,
|
|
23
|
+
className,
|
|
23
24
|
compact = false,
|
|
24
25
|
'data-mode': dataMode,
|
|
25
26
|
logOutButtonPlacement = 'none',
|
|
@@ -45,6 +46,8 @@ export const PktHeaderService = forwardRef(
|
|
|
45
46
|
logoClick,
|
|
46
47
|
position = 'fixed',
|
|
47
48
|
scrollBehavior = 'hide',
|
|
49
|
+
slotMenuVariant = 'icon-only',
|
|
50
|
+
slotMenuText = 'Meny',
|
|
48
51
|
}: IPktHeaderService,
|
|
49
52
|
ref: ForwardedRef<HTMLDivElement>,
|
|
50
53
|
) => {
|
|
@@ -126,7 +129,7 @@ export const PktHeaderService = forwardRef(
|
|
|
126
129
|
|
|
127
130
|
useScrollLock(isFixed && isMobile && openMenu !== 'none')
|
|
128
131
|
|
|
129
|
-
const handleFocusOut = useCallback((event: React.FocusEvent<HTMLDivElement>, menuType:
|
|
132
|
+
const handleFocusOut = useCallback((event: React.FocusEvent<HTMLDivElement>, menuType: THeaderMenu) => {
|
|
130
133
|
const relatedTarget = event.relatedTarget as HTMLElement | null
|
|
131
134
|
|
|
132
135
|
let containerRef: React.RefObject<HTMLDivElement>
|
|
@@ -246,7 +249,7 @@ export const PktHeaderService = forwardRef(
|
|
|
246
249
|
)
|
|
247
250
|
|
|
248
251
|
const handleMenuToggle = useCallback(
|
|
249
|
-
(mode:
|
|
252
|
+
(mode: THeaderMenu) => {
|
|
250
253
|
if (openMenu !== 'none') {
|
|
251
254
|
setOpenMenu('none')
|
|
252
255
|
} else {
|
|
@@ -276,6 +279,7 @@ export const PktHeaderService = forwardRef(
|
|
|
276
279
|
isFixed && 'pkt-header-service--fixed',
|
|
277
280
|
shouldHideOnScroll && 'pkt-header-service--scroll-to-hide',
|
|
278
281
|
hidden && 'pkt-header-service--hidden',
|
|
282
|
+
className,
|
|
279
283
|
)}
|
|
280
284
|
data-mode={dataMode}
|
|
281
285
|
ref={setRefs}
|
|
@@ -343,7 +347,7 @@ export const PktHeaderService = forwardRef(
|
|
|
343
347
|
{isTablet && children && (
|
|
344
348
|
<PktButton
|
|
345
349
|
skin="secondary"
|
|
346
|
-
variant=
|
|
350
|
+
variant={slotMenuVariant}
|
|
347
351
|
iconName="menu"
|
|
348
352
|
size={isMobile ? 'small' : 'medium'}
|
|
349
353
|
state={openMenu === 'slot' ? 'active' : 'normal'}
|
|
@@ -352,7 +356,7 @@ export const PktHeaderService = forwardRef(
|
|
|
352
356
|
aria-controls="mobile-slot-menu"
|
|
353
357
|
aria-label="Åpne meny"
|
|
354
358
|
>
|
|
355
|
-
|
|
359
|
+
{slotMenuText}
|
|
356
360
|
</PktButton>
|
|
357
361
|
)}
|
|
358
362
|
<div
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { TBreakpoint } from '../../types/breakpoint'
|
|
2
|
+
import type {
|
|
3
|
+
TSlotMenuVariant,
|
|
4
|
+
THeaderMenu,
|
|
5
|
+
TLogOutButtonPlacement,
|
|
6
|
+
THeaderPosition,
|
|
7
|
+
THeaderScrollBehavior,
|
|
8
|
+
} from 'shared-types'
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
TSlotMenuVariant,
|
|
12
|
+
THeaderMenu,
|
|
13
|
+
TLogOutButtonPlacement,
|
|
14
|
+
THeaderPosition,
|
|
15
|
+
THeaderScrollBehavior,
|
|
16
|
+
}
|
|
2
17
|
|
|
3
18
|
/** User object for header components */
|
|
4
19
|
export interface User {
|
|
@@ -29,10 +44,10 @@ export interface UserMenuFooterItem {
|
|
|
29
44
|
target: string | (() => void)
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
export type TPktHeaderServiceMenu = 'none' | 'slot' | 'search' | 'user'
|
|
33
|
-
|
|
34
47
|
export interface IPktHeader {
|
|
35
48
|
children?: React.ReactNode
|
|
49
|
+
/** Additional CSS class name(s) to apply to the header */
|
|
50
|
+
className?: string
|
|
36
51
|
/** Set dark mode on the header */
|
|
37
52
|
'data-mode'?: 'dark'
|
|
38
53
|
/** Hide the Oslo logo. Default: false (logo is shown) */
|
|
@@ -64,7 +79,7 @@ export interface IPktHeader {
|
|
|
64
79
|
/** @deprecated userOptions is no longer available. Use userMenu instead. */
|
|
65
80
|
userOptions?: UserMenuItem[]
|
|
66
81
|
/** Where to show the logout button: 'userMenu', 'header', 'both', or 'none' */
|
|
67
|
-
logOutButtonPlacement?:
|
|
82
|
+
logOutButtonPlacement?: TLogOutButtonPlacement
|
|
68
83
|
/** Callback when user clicks logout */
|
|
69
84
|
logOut?: () => void
|
|
70
85
|
/** Show search input in the header */
|
|
@@ -82,9 +97,13 @@ export interface IPktHeader {
|
|
|
82
97
|
/** Custom breakpoint for tablet responsive behavior (interaction pattern) in pixels. Default: 1280 */
|
|
83
98
|
tabletBreakpoint?: number
|
|
84
99
|
/** Which menu is initially open */
|
|
85
|
-
openedMenu?:
|
|
100
|
+
openedMenu?: THeaderMenu
|
|
86
101
|
/** Header position. 'fixed' fixes to top of viewport, 'relative' follows document flow. Default: 'fixed' */
|
|
87
|
-
position?:
|
|
102
|
+
position?: THeaderPosition
|
|
88
103
|
/** Scroll behavior. 'hide' hides header on scroll down, 'none' keeps it visible. Default: 'hide' */
|
|
89
|
-
scrollBehavior?:
|
|
104
|
+
scrollBehavior?: THeaderScrollBehavior
|
|
105
|
+
/** Variant for the slot menu button in tablet/mobile mode. Default: 'icon-only' */
|
|
106
|
+
slotMenuVariant?: TSlotMenuVariant
|
|
107
|
+
/** Text for the slot menu button in tablet/mobile mode. Default: 'Meny' */
|
|
108
|
+
slotMenuText?: string
|
|
90
109
|
}
|