@oslokommune/punkt-react 14.5.0 → 14.5.2
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 +18 -0
- package/dist/index.d.ts +16 -19
- package/dist/punkt-react.es.js +1308 -1382
- package/dist/punkt-react.umd.js +154 -182
- package/package.json +9 -3
- package/src/components/accordion/Accordion.test.tsx +4 -2
- package/src/components/accordion/Accordion.tsx +1 -1
- package/src/components/accordion/AccordionItem.tsx +3 -3
- package/src/components/alert/Alert.test.tsx +4 -5
- package/src/components/alert/Alert.tsx +5 -4
- package/src/components/backlink/BackLink.tsx +3 -3
- package/src/components/breadcrumbs/Breadcrumbs.test.tsx +4 -1
- package/src/components/breadcrumbs/Breadcrumbs.tsx +3 -5
- package/src/components/button/Button.test.tsx +5 -3
- package/src/components/button/Button.tsx +1 -2
- package/src/components/card/Card.tsx +6 -3
- package/src/components/checkbox/Checkbox.test.tsx +1 -1
- package/src/components/checkbox/Checkbox.tsx +10 -2
- package/src/components/combobox/Combobox.tsx +9 -8
- package/src/components/consent/Consent.tsx +3 -3
- package/src/components/datepicker/Datepicker.test.tsx +3 -1
- package/src/components/datepicker/Datepicker.tsx +11 -8
- package/src/components/footer/Footer.test.tsx +1 -1
- package/src/components/footer/Footer.tsx +3 -3
- package/src/components/footerSimple/FooterSimple.test.tsx +1 -1
- package/src/components/footerSimple/FooterSimple.tsx +3 -3
- package/src/components/header/Header.test.tsx +0 -1
- package/src/components/header/Header.tsx +1 -0
- package/src/components/header/HeaderService.test.tsx +2 -2
- package/src/components/header/HeaderService.tsx +34 -15
- package/src/components/header/types.ts +8 -8
- package/src/components/headerUserMenu/UserMenu.test.tsx +3 -3
- package/src/components/headerUserMenu/UserMenu.tsx +6 -2
- package/src/components/heading/Heading.test.tsx +4 -2
- package/src/components/heading/Heading.tsx +6 -5
- package/src/components/helptext/Helptext.tsx +3 -2
- package/src/components/icon/Icon.test.tsx +0 -1
- package/src/components/icon/Icon.tsx +4 -5
- package/src/components/input/Input.tsx +4 -5
- package/src/components/inputwrapper/InputWrapper.tsx +2 -1
- package/src/components/interfaces.ts +1 -1
- package/src/components/loader/Loader.test.tsx +0 -1
- package/src/components/loader/Loader.tsx +6 -4
- package/src/components/messagebox/Messagebox.tsx +1 -1
- package/src/components/modal/Modal.test.tsx +5 -6
- package/src/components/modal/Modal.tsx +4 -2
- package/src/components/progressbar/Progressbar.test.tsx +5 -3
- package/src/components/progressbar/Progressbar.tsx +6 -4
- package/src/components/radio/RadioButton.tsx +9 -3
- package/src/components/searchinput/SearchInput.test.tsx +3 -3
- package/src/components/searchinput/SearchInput.tsx +5 -1
- package/src/components/select/Select.test.tsx +0 -1
- package/src/components/select/Select.tsx +2 -0
- package/src/components/stepper/Step.tsx +2 -1
- package/src/components/stepper/Stepper.test.tsx +5 -3
- package/src/components/stepper/Stepper.tsx +5 -3
- package/src/components/table/Table.test.tsx +6 -6
- package/src/components/table/Table.tsx +2 -3
- package/src/components/table/TableBody.tsx +2 -3
- package/src/components/table/TableData.tsx +2 -3
- package/src/components/table/TableDataCell.tsx +2 -3
- package/src/components/table/TableHeader.tsx +2 -3
- package/src/components/table/TableHeaderCell.tsx +2 -3
- package/src/components/table/TableRow.tsx +2 -3
- package/src/components/tabs/TabItem.tsx +4 -4
- package/src/components/tabs/Tabs.test.tsx +5 -4
- package/src/components/tabs/Tabs.tsx +8 -5
- package/src/components/textarea/Textarea.test.tsx +0 -1
- package/src/components/textarea/Textarea.tsx +9 -4
- package/src/components/textinput/Textinput.tsx +11 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "14.5.
|
|
3
|
+
"version": "14.5.2",
|
|
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,13 +39,16 @@
|
|
|
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.5.2",
|
|
43
43
|
"classnames": "^2.5.1",
|
|
44
44
|
"prettier": "^3.3.3",
|
|
45
45
|
"react-hook-form": "^7.53.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@babel/plugin-transform-private-property-in-object": "^7.25.9",
|
|
49
|
+
"@eslint/compat": "^2.0.2",
|
|
50
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
51
|
+
"@eslint/js": "^9.37.0",
|
|
49
52
|
"@oslokommune/punkt-assets": "^14.1.1",
|
|
50
53
|
"@oslokommune/punkt-css": "^14.1.1",
|
|
51
54
|
"@testing-library/jest-dom": "^6.5.0",
|
|
@@ -60,7 +63,10 @@
|
|
|
60
63
|
"eslint": "^9.37.0",
|
|
61
64
|
"eslint-config-prettier": "^9.1.0",
|
|
62
65
|
"eslint-plugin-prettier": "^5.2.1",
|
|
66
|
+
"eslint-plugin-react": "^7.37.5",
|
|
67
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
63
68
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
69
|
+
"globals": "^14.0.0",
|
|
64
70
|
"jest": "^29.7.0",
|
|
65
71
|
"jest-axe": "^9.0.0",
|
|
66
72
|
"jest-environment-jsdom": "^29.7.0",
|
|
@@ -103,5 +109,5 @@
|
|
|
103
109
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
104
110
|
},
|
|
105
111
|
"license": "MIT",
|
|
106
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "fd47b46c754cf9df72186df66db3f17d2bb925b4"
|
|
107
113
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import '@testing-library/jest-dom'
|
|
2
|
+
|
|
3
|
+
import { fireEvent,render, screen } from '@testing-library/react'
|
|
2
4
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
5
|
+
import { createRef } from 'react'
|
|
6
|
+
|
|
3
7
|
import { PktAccordion } from './Accordion'
|
|
4
8
|
import { PktAccordionItem } from './AccordionItem'
|
|
5
|
-
import { render, screen, fireEvent } from '@testing-library/react'
|
|
6
|
-
import { createRef } from 'react'
|
|
7
9
|
|
|
8
10
|
expect.extend(toHaveNoViolations)
|
|
9
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { createContext, forwardRef, ReactNode, useContext } from 'react'
|
|
4
4
|
import type { TAccordionSkin } from 'shared-types'
|
|
5
5
|
|
|
6
6
|
export type TPktAccordionSkin = TAccordionSkin
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { ReactNode,
|
|
4
|
-
import type {
|
|
3
|
+
import { forwardRef, type MouseEvent, type ReactNode, type SyntheticEvent,useEffect, useState } from 'react'
|
|
4
|
+
import type { TAccordionSkin } from 'shared-types'
|
|
5
|
+
|
|
5
6
|
import { PktIcon } from '../icon/Icon'
|
|
6
7
|
import { useAccordionContext } from './Accordion'
|
|
7
|
-
import type { TAccordionSkin } from 'shared-types'
|
|
8
8
|
|
|
9
9
|
export type TPktAccordionSkin = TAccordionSkin
|
|
10
10
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
3
|
-
import { PktAlert } from './Alert'
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
4
2
|
|
|
5
|
-
import { cleanup } from '@testing-library/react'
|
|
3
|
+
import { cleanup, fireEvent, render, waitFor } from '@testing-library/react'
|
|
4
|
+
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
6
5
|
|
|
7
|
-
import '
|
|
6
|
+
import { PktAlert } from './Alert'
|
|
8
7
|
|
|
9
8
|
expect.extend(toHaveNoViolations)
|
|
10
9
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { ReactNode, useState } from 'react'
|
|
4
|
-
import { FC, HTMLAttributes, ReactElement, useCallback } from 'react'
|
|
5
3
|
import classNames from 'classnames'
|
|
4
|
+
import { FC, HTMLAttributes, ReactElement, ReactNode, useCallback, useState } from 'react'
|
|
5
|
+
import type { TAlertRole, TAlertSkin,TAriaLive } from 'shared-types'
|
|
6
|
+
|
|
6
7
|
import { PktButton, PktIcon } from '..'
|
|
7
|
-
import type { TAlertRole, TAriaLive, TAlertSkin } from 'shared-types'
|
|
8
8
|
|
|
9
9
|
export interface IPktAlert extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
10
10
|
skin?: TAlertSkin
|
|
@@ -48,8 +48,9 @@ export const PktAlert: FC<IPktAlert> = ({
|
|
|
48
48
|
|
|
49
49
|
const onClose = useCallback(() => {
|
|
50
50
|
setIsClosed(true)
|
|
51
|
-
props.onClose
|
|
51
|
+
if (props.onClose) {
|
|
52
52
|
props.onClose(new CustomEvent('close', { detail: { origin: event }, bubbles: true, composed: true }))
|
|
53
|
+
}
|
|
53
54
|
}, [props.onClose, setIsClosed])
|
|
54
55
|
|
|
55
56
|
const ariaLive = ariaLiveCamel || ariaLiveKebab
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import React, { ForwardRefExoticComponent, LegacyRef, AnchorHTMLAttributes, MouseEventHandler } from 'react'
|
|
4
3
|
import { createComponent } from '@lit/react'
|
|
5
|
-
import { PktBackLink as PktElBackLink } from '@oslokommune/punkt-elements'
|
|
6
|
-
|
|
4
|
+
import { type IPktBackLink as IPktElBackLink, PktBackLink as PktElBackLink } from '@oslokommune/punkt-elements'
|
|
5
|
+
// eslint-disable-next-line no-restricted-syntax -- React is required for createComponent
|
|
6
|
+
import React, { AnchorHTMLAttributes, ForwardRefExoticComponent, LegacyRef, MouseEventHandler } from 'react'
|
|
7
7
|
|
|
8
8
|
type ExtendedBackLink = Omit<IPktElBackLink, 'text'> & AnchorHTMLAttributes<HTMLAnchorElement>
|
|
9
9
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { render } from '@testing-library/react'
|
|
2
2
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
3
|
+
import { ReactNode } from 'react'
|
|
3
4
|
import { BrowserRouter as Router } from 'react-router-dom'
|
|
4
5
|
|
|
5
6
|
import { PktBreadcrumbs } from './Breadcrumbs'
|
|
@@ -7,10 +8,12 @@ import { PktBreadcrumbs } from './Breadcrumbs'
|
|
|
7
8
|
expect.extend(toHaveNoViolations)
|
|
8
9
|
|
|
9
10
|
// Create a Router with future flags to suppress warnings
|
|
10
|
-
const TestRouter = ({ children }: { children:
|
|
11
|
+
const TestRouter = ({ children }: { children: ReactNode }) => (
|
|
11
12
|
<Router
|
|
12
13
|
future={{
|
|
14
|
+
// eslint-disable-next-line camelcase
|
|
13
15
|
v7_startTransition: true,
|
|
16
|
+
// eslint-disable-next-line camelcase
|
|
14
17
|
v7_relativeSplatPath: true,
|
|
15
18
|
}}
|
|
16
19
|
>
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { ForwardedRef, forwardRef } from 'react'
|
|
4
|
-
import type { AnchorHTMLAttributes, ReactNode } from 'react'
|
|
3
|
+
import { ForwardedRef, forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'
|
|
5
4
|
import { Link } from 'react-router-dom'
|
|
6
5
|
|
|
7
|
-
import PktIcon from '../icon/Icon'
|
|
6
|
+
import { PktIcon } from '../icon/Icon'
|
|
8
7
|
|
|
9
8
|
export interface IBreadcrumbs {
|
|
10
9
|
text: string
|
|
@@ -91,5 +90,4 @@ export const PktBreadcrumbs = forwardRef(
|
|
|
91
90
|
)
|
|
92
91
|
},
|
|
93
92
|
)
|
|
94
|
-
|
|
95
|
-
export default PktBreadcrumbs
|
|
93
|
+
PktBreadcrumbs.displayName = 'PktBreadcrumbs'
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
2
|
+
|
|
1
3
|
import { render, screen } from '@testing-library/react'
|
|
2
|
-
import { useForm } from 'react-hook-form'
|
|
3
4
|
import userEvent from '@testing-library/user-event'
|
|
4
|
-
import { createRef } from 'react'
|
|
5
5
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
6
|
+
import { createRef } from 'react'
|
|
7
|
+
import { useForm } from 'react-hook-form'
|
|
8
|
+
|
|
6
9
|
import { PktButton } from './Button'
|
|
7
|
-
import '@testing-library/jest-dom'
|
|
8
10
|
|
|
9
11
|
expect.extend(toHaveNoViolations)
|
|
10
12
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import React, { FC, ReactElement, forwardRef, ReactNode, ForwardedRef } from 'react'
|
|
4
3
|
import { createComponent } from '@lit/react'
|
|
5
4
|
import { IPktHeading, PktCard as PktElCard } from '@oslokommune/punkt-elements'
|
|
6
|
-
|
|
7
|
-
import {
|
|
5
|
+
// eslint-disable-next-line no-restricted-syntax -- React is required for createComponent
|
|
6
|
+
import React, { FC, ForwardedRef, forwardRef, type ReactElement } from 'react'
|
|
8
7
|
import type { TCardSkin, TLayout } from 'shared-types'
|
|
9
8
|
|
|
9
|
+
import type { PktElConstructor, PktElType } from '@/interfaces/IPktElements'
|
|
10
|
+
|
|
11
|
+
import { IPktTag } from '../tag/Tag'
|
|
12
|
+
|
|
10
13
|
export type { TCardSkin, TLayout }
|
|
11
14
|
type TCardPadding = 'none' | 'default'
|
|
12
15
|
type TCardImageShape = 'square' | 'round'
|
|
@@ -84,7 +84,7 @@ describe('PktCheckbox', () => {
|
|
|
84
84
|
|
|
85
85
|
test('indeterminate state is independent of checked state', async () => {
|
|
86
86
|
const { getByRole } = render(
|
|
87
|
-
<PktCheckbox id="myCheckbox" label="My Checkbox" indeterminate={true} checked={true} />,
|
|
87
|
+
<PktCheckbox id="myCheckbox" label="My Checkbox" indeterminate={true} checked={true} readOnly />,
|
|
88
88
|
)
|
|
89
89
|
|
|
90
90
|
const checkbox = getByRole('checkbox') as HTMLInputElement
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ChangeEventHandler,
|
|
3
|
+
ForwardedRef,
|
|
4
|
+
forwardRef,
|
|
5
|
+
type InputHTMLAttributes,
|
|
6
|
+
ReactElement,
|
|
7
|
+
ReactNode,
|
|
8
|
+
useEffect,
|
|
9
|
+
useRef,
|
|
10
|
+
} from 'react'
|
|
3
11
|
|
|
4
12
|
export interface IPktCheckbox extends InputHTMLAttributes<HTMLInputElement> {
|
|
5
13
|
id: string
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
+
import { createComponent, EventName } from '@lit/react'
|
|
4
|
+
import { type IPktCombobox as IPktElCombobox, PktCombobox as PktElCombobox } from '@oslokommune/punkt-elements'
|
|
5
|
+
// eslint-disable-next-line no-restricted-syntax -- React is required for createComponent
|
|
3
6
|
import React, {
|
|
4
|
-
ForwardRefExoticComponent,
|
|
5
|
-
ReactNode,
|
|
6
|
-
SelectHTMLAttributes,
|
|
7
7
|
ChangeEventHandler,
|
|
8
|
-
FocusEventHandler,
|
|
9
8
|
FC,
|
|
10
|
-
|
|
9
|
+
FocusEventHandler,
|
|
11
10
|
forwardRef,
|
|
11
|
+
ForwardRefExoticComponent,
|
|
12
|
+
LegacyRef,
|
|
12
13
|
MouseEventHandler,
|
|
14
|
+
type ReactNode,
|
|
15
|
+
SelectHTMLAttributes,
|
|
13
16
|
} from 'react'
|
|
14
|
-
|
|
15
|
-
import type { IPktCombobox as IPktElCombobox } from '@oslokommune/punkt-elements'
|
|
16
|
-
import { createComponent, EventName } from '@lit/react'
|
|
17
|
+
|
|
17
18
|
import { PktEventWithTarget } from '@/interfaces/IPktElements'
|
|
18
19
|
|
|
19
20
|
type ExtendedCombobox = Omit<IPktElCombobox, 'helptext'> & SelectHTMLAttributes<HTMLSelectElement>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import React, { ForwardRefExoticComponent, LegacyRef } from 'react'
|
|
4
3
|
import { createComponent, EventName } from '@lit/react'
|
|
5
|
-
import { PktConsent as PktElConsent } from '@oslokommune/punkt-elements'
|
|
6
|
-
|
|
4
|
+
import { type IPktConsent as IPktElConsent, PktConsent as PktElConsent } from '@oslokommune/punkt-elements'
|
|
5
|
+
// eslint-disable-next-line no-restricted-syntax -- React is required for createComponent
|
|
6
|
+
import React, { ForwardRefExoticComponent, LegacyRef } from 'react'
|
|
7
7
|
|
|
8
8
|
export interface IPktConsent extends IPktElConsent {
|
|
9
9
|
ref?: LegacyRef<HTMLDivElement>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import '@testing-library/jest-dom'
|
|
2
|
+
|
|
2
3
|
import { fireEvent, render, waitFor } from '@testing-library/react'
|
|
3
4
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
import { IPktDatepicker,PktDatepicker } from './Datepicker'
|
|
5
7
|
|
|
6
8
|
const datePickerId = 'datepickerId'
|
|
7
9
|
const label = 'Date Picker Label'
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
+
import { createComponent, EventName } from '@lit/react'
|
|
4
|
+
import { PktDatepicker as PktEl } from '@oslokommune/punkt-elements'
|
|
5
|
+
// eslint-disable-next-line no-restricted-syntax -- React is required for createComponent
|
|
3
6
|
import React, {
|
|
4
|
-
ForwardRefExoticComponent,
|
|
5
|
-
LegacyRef,
|
|
6
7
|
ChangeEventHandler,
|
|
7
|
-
FocusEventHandler,
|
|
8
|
-
ReactNode,
|
|
9
|
-
InputHTMLAttributes,
|
|
10
8
|
FC,
|
|
11
|
-
|
|
9
|
+
FocusEventHandler,
|
|
12
10
|
ForwardedRef,
|
|
13
11
|
forwardRef,
|
|
12
|
+
ForwardRefExoticComponent,
|
|
13
|
+
InputHTMLAttributes,
|
|
14
|
+
LegacyRef,
|
|
15
|
+
ReactElement,
|
|
16
|
+
ReactNode,
|
|
14
17
|
} from 'react'
|
|
15
|
-
|
|
16
|
-
import { PktDatepicker as PktEl } from '@oslokommune/punkt-elements'
|
|
18
|
+
|
|
17
19
|
import type { PktEventWithTarget } from '@/interfaces/IPktElements'
|
|
18
20
|
|
|
19
21
|
// This component will be entirely rebuilt ASAP.
|
|
@@ -44,6 +46,7 @@ export interface IPktDatepicker extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
44
46
|
helptextDropdownButton?: string
|
|
45
47
|
hasError?: boolean
|
|
46
48
|
errorMessage?: string | ReactNode | ReactNode[]
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a temporary escape hatch until we have a proper type for the strings prop
|
|
47
50
|
strings?: any
|
|
48
51
|
ref?: LegacyRef<HTMLInputElement>
|
|
49
52
|
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Test med axe https://www.npmjs.com/package/jest-axe
|
|
2
2
|
import '@testing-library/jest-dom'
|
|
3
3
|
|
|
4
|
-
import { render, screen } from '../../utils/test-utils'
|
|
5
4
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
6
5
|
|
|
6
|
+
import { render, screen } from '../../utils/test-utils'
|
|
7
7
|
import { PktFooter } from './Footer'
|
|
8
8
|
|
|
9
9
|
expect.extend(toHaveNoViolations)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { FC, Fragment } from 'react'
|
|
4
|
-
import type { HTMLAttributes } from 'react'
|
|
3
|
+
import { FC, Fragment, type HTMLAttributes } from 'react'
|
|
5
4
|
|
|
6
|
-
import { PktIcon } from '../icon/Icon'
|
|
7
5
|
import { PktConsent } from '../consent/Consent'
|
|
6
|
+
import { PktIcon } from '../icon/Icon'
|
|
8
7
|
|
|
9
8
|
interface Link {
|
|
10
9
|
href: string
|
|
@@ -59,6 +58,7 @@ export const PktFooter: FC<IPktFooter> = ({
|
|
|
59
58
|
cookieSecure = null,
|
|
60
59
|
cookieExpiryDays = null,
|
|
61
60
|
onToggleConsent = (e: CustomEvent) => {
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
62
|
console.log(e.detail)
|
|
63
63
|
},
|
|
64
64
|
}) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Test med axe https://www.npmjs.com/package/jest-axe
|
|
2
2
|
import '@testing-library/jest-dom'
|
|
3
3
|
|
|
4
|
-
import { render } from '../../utils/test-utils'
|
|
5
4
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
6
5
|
|
|
6
|
+
import { render } from '../../utils/test-utils'
|
|
7
7
|
import { PktFooterSimple } from './FooterSimple'
|
|
8
8
|
|
|
9
9
|
expect.extend(toHaveNoViolations)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { FC } from 'react'
|
|
4
|
-
import type { HTMLAttributes } from 'react'
|
|
3
|
+
import { FC, type HTMLAttributes } from 'react'
|
|
5
4
|
|
|
6
|
-
import { PktIcon } from '../icon/Icon'
|
|
7
5
|
import { PktConsent } from '../consent/Consent'
|
|
6
|
+
import { PktIcon } from '../icon/Icon'
|
|
8
7
|
|
|
9
8
|
export interface IPktFooterSimple extends HTMLAttributes<HTMLDivElement> {
|
|
10
9
|
links?: Array<{
|
|
@@ -39,6 +38,7 @@ export const PktFooterSimple: FC<IPktFooterSimple> = ({
|
|
|
39
38
|
cookieSecure = null,
|
|
40
39
|
cookieExpiryDays = null,
|
|
41
40
|
onToggleConsent = (e: CustomEvent) => {
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
42
|
console.log(e.detail)
|
|
43
43
|
},
|
|
44
44
|
className,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '@testing-library/jest-dom'
|
|
2
|
+
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
2
4
|
import { vi } from 'vitest'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { render, screen, fireEvent } from '@testing-library/react'
|
|
5
5
|
|
|
6
6
|
//mock element width to control mobile/desktop behavior
|
|
7
7
|
let mockedWidth = 1280
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import classNames from 'classnames'
|
|
4
|
+
import {
|
|
5
|
+
type ChangeEvent,
|
|
6
|
+
type FocusEvent,
|
|
7
|
+
ForwardedRef,
|
|
8
|
+
forwardRef,
|
|
9
|
+
type KeyboardEvent,
|
|
10
|
+
type MutableRefObject,
|
|
11
|
+
type RefObject,
|
|
12
|
+
useCallback,
|
|
13
|
+
useEffect,
|
|
14
|
+
useMemo,
|
|
15
|
+
useRef,
|
|
16
|
+
useState,
|
|
17
|
+
} from 'react'
|
|
18
|
+
|
|
19
|
+
import { useElementWidth } from '../../hooks/useElementWidth'
|
|
20
|
+
import { useScrollLock } from '../../hooks/useScrollLock'
|
|
4
21
|
import { PktButton } from '../button/Button'
|
|
5
22
|
import { PktHeaderUserMenu } from '../headerUserMenu/UserMenu'
|
|
6
23
|
import { PktIcon } from '../icon/Icon'
|
|
7
24
|
import { PktLink } from '../link/Link'
|
|
8
25
|
import { PktTextinput } from '../textinput/Textinput'
|
|
9
|
-
import {
|
|
10
|
-
import classNames from 'classnames'
|
|
11
|
-
import { useScrollLock } from '../../hooks/useScrollLock'
|
|
12
|
-
import { User, Representing, UserMenuItem, UserMenuFooterItem, IPktHeader, THeaderMenu } from './types'
|
|
26
|
+
import { IPktHeader, Representing, THeaderMenu, User, UserMenuFooterItem, UserMenuItem } from './types'
|
|
13
27
|
|
|
14
|
-
export type {
|
|
28
|
+
export type { Representing, THeaderMenu, User, UserMenuFooterItem, UserMenuItem }
|
|
15
29
|
export type IPktHeaderService = IPktHeader
|
|
16
30
|
|
|
17
31
|
export const PktHeaderService = forwardRef(
|
|
@@ -57,6 +71,7 @@ export const PktHeaderService = forwardRef(
|
|
|
57
71
|
// Deprecation warning for userMenuFooter
|
|
58
72
|
useEffect(() => {
|
|
59
73
|
if (userMenuFooter) {
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
60
75
|
console.warn(
|
|
61
76
|
'PktHeaderService: The "userMenuFooter" prop is deprecated and will be removed in a future version. Please use "userMenu" instead.',
|
|
62
77
|
)
|
|
@@ -66,6 +81,7 @@ export const PktHeaderService = forwardRef(
|
|
|
66
81
|
// Warning for userOptions - no longer available
|
|
67
82
|
useEffect(() => {
|
|
68
83
|
if (userOptions) {
|
|
84
|
+
// eslint-disable-next-line no-console
|
|
69
85
|
console.warn('PktHeaderService: The "userOptions" prop is no longer available. Please use "userMenu" instead.')
|
|
70
86
|
}
|
|
71
87
|
}, [userOptions])
|
|
@@ -73,11 +89,13 @@ export const PktHeaderService = forwardRef(
|
|
|
73
89
|
// Deprecation warning for shortname
|
|
74
90
|
useEffect(() => {
|
|
75
91
|
if (user?.shortname) {
|
|
92
|
+
// eslint-disable-next-line no-console
|
|
76
93
|
console.warn(
|
|
77
94
|
'PktHeaderService: The "shortname" property on the user object is deprecated and will be removed in a future version.',
|
|
78
95
|
)
|
|
79
96
|
}
|
|
80
97
|
if (representing?.shortname) {
|
|
98
|
+
// eslint-disable-next-line no-console
|
|
81
99
|
console.warn(
|
|
82
100
|
'PktHeaderService: The "shortname" property on the representing object is deprecated and will be removed in a future version.',
|
|
83
101
|
)
|
|
@@ -117,11 +135,11 @@ export const PktHeaderService = forwardRef(
|
|
|
117
135
|
|
|
118
136
|
const setRefs = useCallback(
|
|
119
137
|
(element: HTMLDivElement | null) => {
|
|
120
|
-
;(internalRef as
|
|
138
|
+
;(internalRef as MutableRefObject<HTMLDivElement | null>).current = element
|
|
121
139
|
if (typeof ref === 'function') {
|
|
122
140
|
ref(element)
|
|
123
141
|
} else if (ref) {
|
|
124
|
-
;(ref as
|
|
142
|
+
;(ref as MutableRefObject<HTMLDivElement | null>).current = element
|
|
125
143
|
}
|
|
126
144
|
},
|
|
127
145
|
[ref],
|
|
@@ -129,10 +147,10 @@ export const PktHeaderService = forwardRef(
|
|
|
129
147
|
|
|
130
148
|
useScrollLock(isFixed && isMobile && openMenu !== 'none')
|
|
131
149
|
|
|
132
|
-
const handleFocusOut = useCallback((event:
|
|
150
|
+
const handleFocusOut = useCallback((event: FocusEvent<HTMLDivElement>, menuType: THeaderMenu) => {
|
|
133
151
|
const relatedTarget = event.relatedTarget as HTMLElement | null
|
|
134
152
|
|
|
135
|
-
let containerRef:
|
|
153
|
+
let containerRef: RefObject<HTMLDivElement>
|
|
136
154
|
switch (menuType) {
|
|
137
155
|
case 'user':
|
|
138
156
|
containerRef = userContainerRef
|
|
@@ -184,7 +202,7 @@ export const PktHeaderService = forwardRef(
|
|
|
184
202
|
}
|
|
185
203
|
}
|
|
186
204
|
|
|
187
|
-
const handleEscapeKey = (event: KeyboardEvent) => {
|
|
205
|
+
const handleEscapeKey = (event: globalThis.KeyboardEvent) => {
|
|
188
206
|
if (event.key === 'Escape' && openMenu !== 'none') {
|
|
189
207
|
event.preventDefault()
|
|
190
208
|
shouldRestoreFocusRef.current = true
|
|
@@ -410,8 +428,8 @@ export const PktHeaderService = forwardRef(
|
|
|
410
428
|
value={searchValue}
|
|
411
429
|
autoFocus
|
|
412
430
|
fullwidth={true}
|
|
413
|
-
onChange={(e:
|
|
414
|
-
onKeyDown={(e:
|
|
431
|
+
onChange={(e: ChangeEvent<HTMLInputElement>) => onSearchChange?.(e.target.value)}
|
|
432
|
+
onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {
|
|
415
433
|
if (e.key === 'Enter') {
|
|
416
434
|
onSearch?.((e.target as HTMLInputElement).value)
|
|
417
435
|
}
|
|
@@ -429,8 +447,8 @@ export const PktHeaderService = forwardRef(
|
|
|
429
447
|
useWrapper={false}
|
|
430
448
|
placeholder={searchPlaceholder}
|
|
431
449
|
value={searchValue}
|
|
432
|
-
onChange={(e:
|
|
433
|
-
onKeyDown={(e:
|
|
450
|
+
onChange={(e: ChangeEvent<HTMLInputElement>) => onSearchChange?.(e.target.value)}
|
|
451
|
+
onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {
|
|
434
452
|
if (e.key === 'Enter') {
|
|
435
453
|
onSearch?.((e.target as HTMLInputElement).value)
|
|
436
454
|
}
|
|
@@ -527,3 +545,4 @@ export const PktHeaderService = forwardRef(
|
|
|
527
545
|
return headerElement
|
|
528
546
|
},
|
|
529
547
|
)
|
|
548
|
+
PktHeaderService.displayName = 'PktHeaderService'
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MouseEvent, ReactNode } from 'react'
|
|
2
2
|
import type {
|
|
3
|
-
TSlotMenuVariant,
|
|
4
3
|
THeaderMenu,
|
|
5
|
-
TLogOutButtonPlacement,
|
|
6
4
|
THeaderPosition,
|
|
7
5
|
THeaderScrollBehavior,
|
|
6
|
+
TLogOutButtonPlacement,
|
|
7
|
+
TSlotMenuVariant,
|
|
8
8
|
} from 'shared-types'
|
|
9
9
|
|
|
10
10
|
export type {
|
|
11
|
-
TSlotMenuVariant,
|
|
12
11
|
THeaderMenu,
|
|
13
|
-
TLogOutButtonPlacement,
|
|
14
12
|
THeaderPosition,
|
|
15
13
|
THeaderScrollBehavior,
|
|
14
|
+
TLogOutButtonPlacement,
|
|
15
|
+
TSlotMenuVariant,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** User object for header components */
|
|
@@ -45,7 +45,7 @@ export interface UserMenuFooterItem {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export interface IPktHeader {
|
|
48
|
-
children?:
|
|
48
|
+
children?: ReactNode
|
|
49
49
|
/** Additional CSS class name(s) to apply to the header */
|
|
50
50
|
className?: string
|
|
51
51
|
/** Set dark mode on the header */
|
|
@@ -55,13 +55,13 @@ export interface IPktHeader {
|
|
|
55
55
|
/** Link URL for the logo */
|
|
56
56
|
logoLink?: string
|
|
57
57
|
/** Callback when logo is clicked */
|
|
58
|
-
logoClick?: (event:
|
|
58
|
+
logoClick?: (event: MouseEvent) => void
|
|
59
59
|
/** Name of the service displayed in the header */
|
|
60
60
|
serviceName?: string
|
|
61
61
|
/** Link URL for the service name */
|
|
62
62
|
serviceLink?: string
|
|
63
63
|
/** Callback when service name is clicked */
|
|
64
|
-
serviceClick?: (event:
|
|
64
|
+
serviceClick?: (event: MouseEvent) => void
|
|
65
65
|
/** Use compact header height */
|
|
66
66
|
compact?: boolean
|
|
67
67
|
/** User object with name, shortname, and lastLoggedIn */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import '@testing-library/jest-dom'
|
|
2
|
-
|
|
3
|
-
import { render, screen
|
|
2
|
+
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
4
4
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
5
5
|
import { vi } from 'vitest'
|
|
6
6
|
|
|
7
|
-
import { PktHeaderUserMenu } from './UserMenu'
|
|
8
7
|
import { UserMenuItem } from '../header/types'
|
|
8
|
+
import { PktHeaderUserMenu } from './UserMenu'
|
|
9
9
|
|
|
10
10
|
expect.extend(toHaveNoViolations)
|
|
11
11
|
|