@oslokommune/punkt-react 12.30.2 → 12.31.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 +36 -0
- package/dist/index.d.ts +9 -4
- package/dist/punkt-react.es.js +7948 -7906
- package/dist/punkt-react.umd.js +272 -260
- package/package.json +4 -4
- package/src/components/backlink/BackLink.test.tsx +37 -43
- package/src/components/backlink/BackLink.tsx +15 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.31.0",
|
|
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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@lit-labs/ssr-dom-shim": "^1.2.1",
|
|
40
40
|
"@lit/react": "^1.0.5",
|
|
41
|
-
"@oslokommune/punkt-elements": "^12.
|
|
41
|
+
"@oslokommune/punkt-elements": "^12.31.0",
|
|
42
42
|
"angular-html-parser": "^6.0.2",
|
|
43
43
|
"html-format": "^1.1.7",
|
|
44
44
|
"prettier": "^3.3.3",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@oslokommune/punkt-assets": "^12.30.1",
|
|
51
|
-
"@oslokommune/punkt-css": "^12.
|
|
51
|
+
"@oslokommune/punkt-css": "^12.31.0",
|
|
52
52
|
"@testing-library/jest-dom": "^6.5.0",
|
|
53
53
|
"@testing-library/react": "^16.0.1",
|
|
54
54
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
112
112
|
},
|
|
113
113
|
"license": "MIT",
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "95a46dc5e5fcbab72e2c303c26127a95297c3e83"
|
|
115
115
|
}
|
|
@@ -1,50 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react'
|
|
3
2
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
4
3
|
|
|
5
|
-
import { PktBackLink } from './BackLink'
|
|
4
|
+
import { PktBackLink } from './BackLink'
|
|
6
5
|
|
|
7
6
|
expect.extend(toHaveNoViolations)
|
|
8
7
|
|
|
9
8
|
describe('PktBackLink', () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
it('renders with no wcag errors with axe', async () => {
|
|
44
|
-
const { container } = render(<PktBackLink text="Tilbake" href="/" />)
|
|
45
|
-
const results = await axe(container)
|
|
46
|
-
|
|
47
|
-
expect(results).toHaveNoViolations()
|
|
48
|
-
})
|
|
9
|
+
it('renders with default text and href', async () => {
|
|
10
|
+
const { getByRole } = render(<PktBackLink />)
|
|
11
|
+
await window.customElements.whenDefined('pkt-backlink')
|
|
12
|
+
const link = getByRole('link')
|
|
13
|
+
await expect(link.textContent).toBe('Forsiden')
|
|
14
|
+
await expect(link.getAttribute('href')).toBe('/')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('renders with custom text and href', async () => {
|
|
18
|
+
const { getByRole } = render(<PktBackLink href="/custom-url" text="Custom Text" />)
|
|
19
|
+
await window.customElements.whenDefined('pkt-backlink')
|
|
20
|
+
const link = getByRole('link')
|
|
21
|
+
await expect(link.textContent).toBe('Custom Text')
|
|
22
|
+
await expect(link.getAttribute('href')).toBe('/custom-url')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('calls onClick when clicked', async () => {
|
|
26
|
+
const onClickMock = jest.fn()
|
|
27
|
+
const { getByText } = render(<PktBackLink text="Back" onClick={onClickMock} />)
|
|
28
|
+
await window.customElements.whenDefined('pkt-backlink')
|
|
29
|
+
const link = getByText('Back')
|
|
30
|
+
await fireEvent.click(link)
|
|
31
|
+
|
|
32
|
+
await expect(onClickMock).toHaveBeenCalledTimes(1)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('accessibility', () => {
|
|
36
|
+
it('renders with no wcag errors with axe', async () => {
|
|
37
|
+
const { container } = render(<PktBackLink text="Tilbake" href="/" />)
|
|
38
|
+
|
|
39
|
+
const results = await axe(container)
|
|
40
|
+
|
|
41
|
+
await expect(results).toHaveNoViolations()
|
|
49
42
|
})
|
|
50
|
-
})
|
|
43
|
+
})
|
|
44
|
+
})
|
|
@@ -1,36 +1,22 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ForwardRefExoticComponent, LegacyRef, AnchorHTMLAttributes, MouseEventHandler } from 'react'
|
|
2
|
+
import { createComponent, EventName } from '@lit/react'
|
|
3
|
+
import { PktBackLink as PktElBackLink } from '@oslokommune/punkt-elements'
|
|
4
|
+
import type { IPktBackLink as IPktElBackLink } from '@oslokommune/punkt-elements'
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
type ExtendedBackLink = Omit<IPktElBackLink, 'text'> & AnchorHTMLAttributes<HTMLAnchorElement>
|
|
4
7
|
|
|
5
|
-
export interface IPktBackLink extends
|
|
6
|
-
href?: string
|
|
8
|
+
export interface IPktBackLink extends ExtendedBackLink {
|
|
7
9
|
text?: string
|
|
8
|
-
|
|
10
|
+
ref?: LegacyRef<HTMLAnchorElement>
|
|
11
|
+
ariaLabel?: string
|
|
12
|
+
onClick?: MouseEventHandler<HTMLAnchorElement>
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export const PktBackLink =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onClick(event)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<nav ref={ref} className={classes} aria-label="Gå tilbake et steg">
|
|
23
|
-
<a href={href || '/'} className="pkt-link pkt-link--icon-left" onClick={handleClick} {...props}>
|
|
24
|
-
<PktIcon
|
|
25
|
-
className="pkt-back-link__icon pkt-icon pkt-link__icon"
|
|
26
|
-
name="chevron-thin-left"
|
|
27
|
-
aria-hidden="true"
|
|
28
|
-
/>
|
|
29
|
-
<span className="pkt-back-link__text">{text || 'Forsiden'}</span>
|
|
30
|
-
</a>
|
|
31
|
-
</nav>
|
|
32
|
-
)
|
|
33
|
-
},
|
|
34
|
-
)
|
|
15
|
+
export const PktBackLink = createComponent({
|
|
16
|
+
tagName: 'pkt-backlink',
|
|
17
|
+
elementClass: PktElBackLink,
|
|
18
|
+
react: React,
|
|
19
|
+
displayName: 'PktBackLink',
|
|
20
|
+
}) as ForwardRefExoticComponent<IPktBackLink>
|
|
35
21
|
|
|
36
22
|
PktBackLink.displayName = 'PktBackLink'
|