@oslokommune/punkt-react 13.6.16 → 13.7.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 +23 -0
- package/dist/index.d.ts +38 -74
- package/dist/punkt-react.es.js +5358 -35971
- package/dist/punkt-react.umd.js +418 -548
- package/package.json +11 -15
- package/src/components/accordion/Accordion.test.tsx +1 -1
- package/src/components/accordion/Accordion.tsx +1 -1
- package/src/components/accordion/AccordionItem.tsx +6 -5
- package/src/components/alert/Alert.tsx +2 -1
- package/src/components/breadcrumbs/Breadcrumbs.test.tsx +16 -4
- package/src/components/breadcrumbs/Breadcrumbs.tsx +3 -2
- package/src/components/button/Button.tsx +3 -2
- package/src/components/checkbox/Checkbox.tsx +4 -3
- package/src/components/footer/Footer.tsx +6 -5
- package/src/components/footerSimple/FooterSimple.tsx +4 -3
- package/src/components/icon/Icon.test.tsx +6 -19
- package/src/components/index.ts +0 -2
- package/src/components/input/Input.tsx +4 -3
- package/src/components/radio/RadioButton.tsx +3 -2
- package/src/components/searchinput/SearchInput.tsx +3 -3
- package/src/components/stepper/Stepper.tsx +6 -6
- package/src/components/table/Table.tsx +2 -1
- package/src/components/table/TableBody.tsx +2 -1
- package/src/components/table/TableData.tsx +2 -1
- package/src/components/table/TableDataCell.tsx +2 -1
- package/src/components/table/TableHeader.tsx +2 -1
- package/src/components/table/TableHeaderCell.tsx +2 -1
- package/src/components/table/TableRow.tsx +2 -1
- package/src/components/tag/Tag.tsx +2 -1
- package/src/components/preview/Preview.tsx +0 -274
- package/src/components/preview/PreviewCode.tsx +0 -118
- package/src/components/preview/PreviewPropEditor.tsx +0 -266
- package/src/components/preview/PreviewSpecs.tsx +0 -125
- package/src/components/preview/PreviewWithJson.tsx +0 -519
- package/src/components/preview/preview-types.ts +0 -42
- package/src/components/preview/preview-utils.ts +0 -226
- package/src/components/preview/previewJson/accordion.json +0 -84
- package/src/components/preview/previewJson/alert.json +0 -27
- package/src/components/preview/previewJson/backlink.json +0 -14
- package/src/components/preview/previewJson/breadcrumbs.json +0 -17
- package/src/components/preview/previewJson/button.json +0 -28
- package/src/components/preview/previewJson/card.json +0 -41
- package/src/components/preview/previewJson/checkbox.json +0 -21
- package/src/components/preview/previewJson/combobox.json +0 -24
- package/src/components/preview/previewJson/consent.json +0 -14
- package/src/components/preview/previewJson/datepicker.json +0 -14
- package/src/components/preview/previewJson/footer-simple.json +0 -17
- package/src/components/preview/previewJson/footer.json +0 -29
- package/src/components/preview/previewJson/header.json +0 -34
- package/src/components/preview/previewJson/icon.json +0 -13
- package/src/components/preview/previewJson/input-wrapper.json +0 -39
- package/src/components/preview/previewJson/link.json +0 -28
- package/src/components/preview/previewJson/linkcard.json +0 -30
- package/src/components/preview/previewJson/loader.json +0 -28
- package/src/components/preview/previewJson/messagebox.json +0 -28
- package/src/components/preview/previewJson/modal.json +0 -65
- package/src/components/preview/previewJson/progressbar.json +0 -16
- package/src/components/preview/previewJson/radiobutton.json +0 -21
- package/src/components/preview/previewJson/searchinput.json +0 -20
- package/src/components/preview/previewJson/select.json +0 -73
- package/src/components/preview/previewJson/steps.json +0 -72
- package/src/components/preview/previewJson/table.json +0 -130
- package/src/components/preview/previewJson/tabs.json +0 -33
- package/src/components/preview/previewJson/tag.json +0 -26
- package/src/components/preview/previewJson/textarea.json +0 -18
- package/src/components/preview/previewJson/textinput.json +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.7.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",
|
|
@@ -33,12 +33,13 @@
|
|
|
33
33
|
"lint:fix": "eslint --fix 'src/**/*.{jsx,ts,tsx}'",
|
|
34
34
|
"format": "prettier --write src//**/*.{ts,tsx,css} --config ./.prettierrc",
|
|
35
35
|
"preview": "vite preview --outDir dist-app",
|
|
36
|
-
"test": "
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
40
|
"@lit-labs/ssr-dom-shim": "^1.2.1",
|
|
40
41
|
"@lit/react": "^1.0.7",
|
|
41
|
-
"@oslokommune/punkt-elements": "^13.
|
|
42
|
+
"@oslokommune/punkt-elements": "^13.7.0",
|
|
42
43
|
"prettier": "^3.3.3",
|
|
43
44
|
"react-element-to-jsx-string": "^15.0.0",
|
|
44
45
|
"react-hook-form": "^7.53.0",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"@testing-library/jest-dom": "^6.5.0",
|
|
52
53
|
"@testing-library/react": "^16.0.1",
|
|
53
54
|
"@testing-library/user-event": "^14.5.2",
|
|
54
|
-
"@types/jest": "^29.5.
|
|
55
|
+
"@types/jest": "^29.5.14",
|
|
55
56
|
"@types/jest-axe": "^3.5.9",
|
|
56
57
|
"@types/node": "^20.12.10",
|
|
57
58
|
"@types/react": "^18.3.5",
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
60
61
|
"@vitejs/plugin-react": "^4.3.1",
|
|
61
62
|
"classnames": "^2.5.1",
|
|
62
|
-
"eslint": "^9.
|
|
63
|
+
"eslint": "^9.37.0",
|
|
63
64
|
"eslint-config-prettier": "^9.1.0",
|
|
64
65
|
"eslint-plugin-prettier": "^5.2.1",
|
|
65
66
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
@@ -67,11 +68,11 @@
|
|
|
67
68
|
"jest-axe": "^9.0.0",
|
|
68
69
|
"jest-environment-jsdom": "^29.7.0",
|
|
69
70
|
"react-hooks": "^1.0.1",
|
|
70
|
-
"react-scripts": "^5.0.1",
|
|
71
71
|
"sass": "^1.78.0",
|
|
72
|
-
"typescript": "^5.
|
|
73
|
-
"vite": "^
|
|
74
|
-
"vite-plugin-dts": "^4.
|
|
72
|
+
"typescript": "^5.9.3",
|
|
73
|
+
"vite": "^6.3.6",
|
|
74
|
+
"vite-plugin-dts": "^4.5.4",
|
|
75
|
+
"vitest": "^3.2.4"
|
|
75
76
|
},
|
|
76
77
|
"peerDependencies": {
|
|
77
78
|
"@oslokommune/punkt-assets": "*",
|
|
@@ -97,11 +98,6 @@
|
|
|
97
98
|
"ux",
|
|
98
99
|
"ui"
|
|
99
100
|
],
|
|
100
|
-
"jest": {
|
|
101
|
-
"transformIgnorePatterns": [
|
|
102
|
-
"<rootDir>/node_modules/(?!@lit/react)"
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
101
|
"repository": {
|
|
106
102
|
"type": "git",
|
|
107
103
|
"url": "git+https://github.com/oslokommune/punkt.git"
|
|
@@ -110,5 +106,5 @@
|
|
|
110
106
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
111
107
|
},
|
|
112
108
|
"license": "MIT",
|
|
113
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "cfe27c04046718ff79f60e3babba60062296f05b"
|
|
114
110
|
}
|
|
@@ -3,7 +3,7 @@ import { axe, toHaveNoViolations } from 'jest-axe'
|
|
|
3
3
|
import { PktAccordion } from './Accordion'
|
|
4
4
|
import { PktAccordionItem } from './AccordionItem'
|
|
5
5
|
import { render, screen, fireEvent } from '@testing-library/react'
|
|
6
|
-
import
|
|
6
|
+
import { createRef } from 'react'
|
|
7
7
|
|
|
8
8
|
expect.extend(toHaveNoViolations)
|
|
9
9
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { ReactNode, useState, useEffect, forwardRef } from 'react'
|
|
4
|
+
import type { MouseEvent, SyntheticEvent } from 'react'
|
|
4
5
|
import { PktIcon } from '../icon/Icon'
|
|
5
6
|
import { useAccordionContext } from './Accordion'
|
|
6
7
|
|
|
@@ -16,8 +17,8 @@ export interface IPktAccordionItem {
|
|
|
16
17
|
children?: ReactNode
|
|
17
18
|
name?: string
|
|
18
19
|
className?: string
|
|
19
|
-
onClick?: (e:
|
|
20
|
-
onToggle?: (e:
|
|
20
|
+
onClick?: (e: MouseEvent<HTMLDetailsElement>) => void
|
|
21
|
+
onToggle?: (e: SyntheticEvent<HTMLDetailsElement>) => void
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export const PktAccordionItem = forwardRef<HTMLDetailsElement, IPktAccordionItem>(
|
|
@@ -52,7 +53,7 @@ export const PktAccordionItem = forwardRef<HTMLDetailsElement, IPktAccordionItem
|
|
|
52
53
|
}
|
|
53
54
|
}, [defaultOpen, controlledIsOpen])
|
|
54
55
|
|
|
55
|
-
const handleToggle = (e:
|
|
56
|
+
const handleToggle = (e: SyntheticEvent<HTMLDetailsElement>) => {
|
|
56
57
|
const detailsElement = e.currentTarget
|
|
57
58
|
const newOpenState = detailsElement.open
|
|
58
59
|
|
|
@@ -63,7 +64,7 @@ export const PktAccordionItem = forwardRef<HTMLDetailsElement, IPktAccordionItem
|
|
|
63
64
|
onToggle?.(e)
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
const handleClick = (e:
|
|
67
|
+
const handleClick = (e: MouseEvent<HTMLDetailsElement>) => {
|
|
67
68
|
// La native toggle skje først, så trigge onClick
|
|
68
69
|
setTimeout(() => {
|
|
69
70
|
onClick?.(e)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { FC, ForwardedRef, forwardRef, ReactElement } from 'react'
|
|
4
|
+
import * as React from 'react'
|
|
4
5
|
import { createComponent, EventName } from '@lit/react'
|
|
5
6
|
import { PktAlert as PktElAlert } from '@oslokommune/punkt-elements'
|
|
6
7
|
import type { PktElType, PktElConstructor } from '@/interfaces/IPktElements'
|
|
@@ -6,6 +6,18 @@ import { PktBreadcrumbs } from './Breadcrumbs'
|
|
|
6
6
|
|
|
7
7
|
expect.extend(toHaveNoViolations)
|
|
8
8
|
|
|
9
|
+
// Create a Router with future flags to suppress warnings
|
|
10
|
+
const TestRouter = ({ children }: { children: React.ReactNode }) => (
|
|
11
|
+
<Router
|
|
12
|
+
future={{
|
|
13
|
+
v7_startTransition: true,
|
|
14
|
+
v7_relativeSplatPath: true,
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
17
|
+
{children}
|
|
18
|
+
</Router>
|
|
19
|
+
)
|
|
20
|
+
|
|
9
21
|
describe('PktBreadcrumbs Component', () => {
|
|
10
22
|
const breadcrumbs = [
|
|
11
23
|
{ text: 'Home', href: '/' },
|
|
@@ -15,9 +27,9 @@ describe('PktBreadcrumbs Component', () => {
|
|
|
15
27
|
|
|
16
28
|
it('renders breadcrumbs correctly with react-router navigation', async () => {
|
|
17
29
|
const { getAllByText } = render(
|
|
18
|
-
<
|
|
30
|
+
<TestRouter>
|
|
19
31
|
<PktBreadcrumbs breadcrumbs={breadcrumbs} navigationType="router" />
|
|
20
|
-
</
|
|
32
|
+
</TestRouter>,
|
|
21
33
|
)
|
|
22
34
|
await window.customElements.whenDefined('pkt-icon')
|
|
23
35
|
|
|
@@ -37,9 +49,9 @@ describe('PktBreadcrumbs Component', () => {
|
|
|
37
49
|
|
|
38
50
|
it('renders back link correctly on mobile with router navigation', async () => {
|
|
39
51
|
const { getAllByText } = render(
|
|
40
|
-
<
|
|
52
|
+
<TestRouter>
|
|
41
53
|
<PktBreadcrumbs breadcrumbs={breadcrumbs} navigationType="router" />
|
|
42
|
-
</
|
|
54
|
+
</TestRouter>,
|
|
43
55
|
)
|
|
44
56
|
await window.customElements.whenDefined('pkt-icon')
|
|
45
57
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { ForwardedRef, forwardRef } from 'react'
|
|
4
|
+
import type { AnchorHTMLAttributes } from 'react'
|
|
4
5
|
import { Link } from 'react-router-dom'
|
|
5
6
|
|
|
6
7
|
import PktIcon from '../icon/Icon'
|
|
@@ -10,7 +11,7 @@ export interface IBreadcrumbs {
|
|
|
10
11
|
href: string
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export interface IPktBreadcrumbs extends
|
|
14
|
+
export interface IPktBreadcrumbs extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
14
15
|
breadcrumbs: IBreadcrumbs[]
|
|
15
16
|
navigationType?: 'router' | 'anchor'
|
|
16
17
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import
|
|
2
|
+
import { ForwardedRef, forwardRef } from 'react'
|
|
3
|
+
import type { ButtonHTMLAttributes } from 'react'
|
|
3
4
|
|
|
4
5
|
import { PktIcon } from '../icon/Icon'
|
|
5
6
|
declare global {
|
|
@@ -10,7 +11,7 @@ declare global {
|
|
|
10
11
|
|
|
11
12
|
window.pktAnimationPath = window.pktAnimationPath || 'https://punkt-cdn.oslo.kommune.no/latest/animations/'
|
|
12
13
|
|
|
13
|
-
export interface IPktButton extends
|
|
14
|
+
export interface IPktButton extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
14
15
|
iconName?: string
|
|
15
16
|
secondIconName?: string
|
|
16
17
|
mode?: 'light' | 'dark'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ChangeEventHandler, ForwardedRef, forwardRef, ReactNode, ReactElement } from 'react'
|
|
2
|
+
import type { InputHTMLAttributes } from 'react'
|
|
2
3
|
|
|
3
|
-
export interface IPktCheckbox extends
|
|
4
|
+
export interface IPktCheckbox extends InputHTMLAttributes<HTMLInputElement> {
|
|
4
5
|
id: string
|
|
5
6
|
hasTile?: boolean
|
|
6
7
|
disabled?: boolean
|
|
@@ -44,7 +45,7 @@ export const PktCheckbox = forwardRef(
|
|
|
44
45
|
...props
|
|
45
46
|
}: IPktCheckbox,
|
|
46
47
|
ref: ForwardedRef<HTMLInputElement>,
|
|
47
|
-
):
|
|
48
|
+
): ReactElement => {
|
|
48
49
|
const classes = [className, 'pkt-input-check'].filter(Boolean).join(' ')
|
|
49
50
|
|
|
50
51
|
const labelClasses = [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { FC, Fragment } from 'react'
|
|
4
|
+
import type { HTMLAttributes } from 'react'
|
|
4
5
|
|
|
5
6
|
import { PktIcon } from '../icon/Icon'
|
|
6
7
|
import { PktConsent } from '../consent/Consent'
|
|
@@ -25,7 +26,7 @@ interface SocialLink {
|
|
|
25
26
|
openInNewTab?: boolean
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
export interface IPktFooter extends
|
|
29
|
+
export interface IPktFooter extends HTMLAttributes<HTMLDivElement> {
|
|
29
30
|
columnOne: Column
|
|
30
31
|
columnTwo: Column
|
|
31
32
|
socialLinks?: SocialLink[]
|
|
@@ -42,7 +43,7 @@ export interface IPktFooter extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
42
43
|
onToggleConsent?: (e: CustomEvent) => void
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export const PktFooter:
|
|
46
|
+
export const PktFooter: FC<IPktFooter> = ({
|
|
46
47
|
columnOne,
|
|
47
48
|
columnTwo,
|
|
48
49
|
socialLinks,
|
|
@@ -169,7 +170,7 @@ export const PktFooter: React.FC<IPktFooter> = ({
|
|
|
169
170
|
{socialLinks
|
|
170
171
|
.filter((link) => link.iconName)
|
|
171
172
|
.map((link, index) => (
|
|
172
|
-
<
|
|
173
|
+
<Fragment key={`sociallinks-${index}`}>
|
|
173
174
|
<a
|
|
174
175
|
href={link.href}
|
|
175
176
|
aria-label={`til ${link.iconName}`}
|
|
@@ -179,7 +180,7 @@ export const PktFooter: React.FC<IPktFooter> = ({
|
|
|
179
180
|
>
|
|
180
181
|
<PktIcon className="pkt-footer__social-icon" name={link.iconName} />
|
|
181
182
|
</a>
|
|
182
|
-
</
|
|
183
|
+
</Fragment>
|
|
183
184
|
))}
|
|
184
185
|
</div>
|
|
185
186
|
</div>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { FC } from 'react'
|
|
4
|
+
import type { HTMLAttributes } from 'react'
|
|
4
5
|
|
|
5
6
|
import { PktIcon } from '../icon/Icon'
|
|
6
7
|
import { PktConsent } from '../consent/Consent'
|
|
7
8
|
|
|
8
|
-
export interface IPktFooterSimple extends
|
|
9
|
+
export interface IPktFooterSimple extends HTMLAttributes<HTMLDivElement> {
|
|
9
10
|
links?: Array<{
|
|
10
11
|
href: string
|
|
11
12
|
text: string
|
|
@@ -25,7 +26,7 @@ export interface IPktFooterSimple extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
25
26
|
onToggleConsent?: (e: CustomEvent) => void
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
export const PktFooterSimple:
|
|
29
|
+
export const PktFooterSimple: FC<IPktFooterSimple> = ({
|
|
29
30
|
links = [],
|
|
30
31
|
openLinksInNewTab = false,
|
|
31
32
|
personvernOgInfoLink = 'https://www.oslo.kommune.no/personvern-og-informasjonskapsler/',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '@testing-library/jest-dom'
|
|
2
2
|
|
|
3
3
|
import { render, screen, waitFor } from '../../utils/test-utils'
|
|
4
|
-
import React from 'react'
|
|
5
4
|
|
|
6
5
|
import { PktIcon } from './Icon'
|
|
7
6
|
|
|
@@ -11,26 +10,14 @@ declare global {
|
|
|
11
10
|
pktIconPath: string
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
|
-
window.pktFetch = (file = 'filnavn.svg') =>
|
|
15
|
-
Promise.resolve({
|
|
16
|
-
ok: true,
|
|
17
|
-
text: () => Promise.resolve(`<svg role="img" data-testid="icon" data-filename=${file}>Her er SVGen</svg>`),
|
|
18
|
-
})
|
|
19
|
-
window.pktIconPath = 'sti'
|
|
20
13
|
|
|
21
14
|
describe('PktIcon', () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
setItem: function (key: string, value: string) {
|
|
29
|
-
store[key] = value.toString()
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
})()
|
|
33
|
-
Object.defineProperty(global, 'localStorage', { value: localStorageMock })
|
|
15
|
+
window.pktFetch = (file = 'filnavn.svg') =>
|
|
16
|
+
Promise.resolve({
|
|
17
|
+
ok: true,
|
|
18
|
+
text: () => Promise.resolve(`<svg role="img" data-testid="icon" data-filename=${file}>Her er SVGen</svg>`),
|
|
19
|
+
})
|
|
20
|
+
window.pktIconPath = 'sti'
|
|
34
21
|
|
|
35
22
|
describe('with default fetcher', () => {
|
|
36
23
|
test('fetches SVG with default fetcher', async () => {
|
package/src/components/index.ts
CHANGED
|
@@ -22,8 +22,6 @@ export { PktLinkCard } from './linkcard/LinkCard'
|
|
|
22
22
|
export { PktLoader } from './loader/Loader'
|
|
23
23
|
export { PktMessagebox } from './messagebox/Messagebox'
|
|
24
24
|
export { PktModal } from './modal/Modal'
|
|
25
|
-
export { PktPreview } from './preview/Preview'
|
|
26
|
-
export { PktPreviewWithJson } from './preview/PreviewWithJson'
|
|
27
25
|
export { PktProgressbar } from './progressbar/Progressbar'
|
|
28
26
|
export { PktRadioButton } from './radio/RadioButton'
|
|
29
27
|
export { PktSearchInput } from './searchinput/SearchInput'
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { ForwardedRef, forwardRef } from 'react'
|
|
4
|
+
import type { InputHTMLAttributes } from 'react'
|
|
4
5
|
|
|
5
|
-
interface InputProps extends
|
|
6
|
+
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
6
7
|
/** The input's label */
|
|
7
8
|
label?: string
|
|
8
9
|
/** The input's id */
|
|
@@ -21,7 +22,7 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
|
21
22
|
* <Input label="First name" id="firstName" validationMessage="First name is required" />
|
|
22
23
|
*
|
|
23
24
|
*/
|
|
24
|
-
export const PktInput =
|
|
25
|
+
export const PktInput = forwardRef(
|
|
25
26
|
({ label, id, children, ...props }: InputProps, ref: ForwardedRef<HTMLInputElement>): React.ReactElement => {
|
|
26
27
|
return (
|
|
27
28
|
<div className="pkt-form-group">
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ChangeEventHandler, ForwardedRef, forwardRef, ReactNode } from 'react'
|
|
2
|
+
import type { InputHTMLAttributes } from 'react'
|
|
2
3
|
|
|
3
|
-
export interface IPktRadioButton extends
|
|
4
|
+
export interface IPktRadioButton extends InputHTMLAttributes<HTMLInputElement> {
|
|
4
5
|
id: string
|
|
5
6
|
name: string
|
|
6
7
|
label: string
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { ChangeEvent, forwardRef, HTMLProps, ReactNode, createElement } from 'react'
|
|
4
4
|
|
|
5
5
|
import { PktButton } from '../button/Button'
|
|
6
6
|
|
|
@@ -33,7 +33,7 @@ interface ISearchForm extends ISearch {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
interface ISearchInput extends ISearch {
|
|
36
|
-
onChange: (event:
|
|
36
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void
|
|
37
37
|
disabled?: boolean
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -145,7 +145,7 @@ export const PktSearchInput = forwardRef<HTMLInputElement, ISearchInput | ISearc
|
|
|
145
145
|
<ul id={`${id}-suggestions`} className="pkt-searchinput__suggestions" aria-live="assertive">
|
|
146
146
|
{suggestions.map((suggestion, index) => (
|
|
147
147
|
<li key={`search-suggestion-${index}`}>
|
|
148
|
-
{
|
|
148
|
+
{createElement(
|
|
149
149
|
suggestion.href ? 'a' : suggestion.onClick ? 'button' : 'div',
|
|
150
150
|
{
|
|
151
151
|
href: suggestion.href,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { ReactElement, Ref, forwardRef } from 'react'
|
|
3
|
+
import { ReactElement, Ref, forwardRef, Children, isValidElement, cloneElement } from 'react'
|
|
4
|
+
import type { HTMLAttributes } from 'react'
|
|
4
5
|
import { IPktStep } from './Step'
|
|
5
6
|
import classNames from 'classnames'
|
|
6
|
-
import React from 'react'
|
|
7
7
|
|
|
8
|
-
export interface IPktStepper extends
|
|
8
|
+
export interface IPktStepper extends HTMLAttributes<HTMLOListElement> {
|
|
9
9
|
/**
|
|
10
10
|
* The index of the current active step
|
|
11
11
|
*/
|
|
@@ -55,9 +55,9 @@ export const PktStepper = forwardRef(
|
|
|
55
55
|
orientation === 'horizontal' ? 'pkt-stepper--horizontal' : 'pkt-stepper--vertical',
|
|
56
56
|
)
|
|
57
57
|
|
|
58
|
-
const childrenWithProps =
|
|
59
|
-
if (
|
|
60
|
-
return
|
|
58
|
+
const childrenWithProps = Children.map(children, (child, index) => {
|
|
59
|
+
if (isValidElement(child)) {
|
|
60
|
+
return cloneElement(child, {
|
|
61
61
|
className: classNames(child.props.className, {
|
|
62
62
|
'pkt-step--hideStep': hideNonActiveSteps && index !== activeStep,
|
|
63
63
|
'pkt-step--hideContent': hideNonActiveStepsContent && index !== activeStep,
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import * as React from 'react'
|
|
5
|
+
import type { HTMLAttributes } from 'react'
|
|
5
6
|
|
|
6
7
|
export type TTableSkin = 'basic' | 'zebra-blue'
|
|
7
8
|
|
|
8
|
-
interface ITableProps extends
|
|
9
|
+
interface ITableProps extends HTMLAttributes<HTMLTableElement> {
|
|
9
10
|
compact?: boolean
|
|
10
11
|
skin?: 'basic' | 'zebra-blue'
|
|
11
12
|
responsiveView?: boolean
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import * as React from 'react'
|
|
5
|
+
import type { HTMLAttributes } from 'react'
|
|
5
6
|
|
|
6
|
-
interface ITableBodyProps extends
|
|
7
|
+
interface ITableBodyProps extends HTMLAttributes<HTMLTableSectionElement> {
|
|
7
8
|
className?: string
|
|
8
9
|
children: React.ReactNode
|
|
9
10
|
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import * as React from 'react'
|
|
5
|
+
import type { HTMLAttributes } from 'react'
|
|
5
6
|
|
|
6
|
-
interface TableDataProps extends
|
|
7
|
+
interface TableDataProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
7
8
|
className?: string
|
|
8
9
|
children: React.ReactNode | React.ReactNode[]
|
|
9
10
|
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import * as React from 'react'
|
|
5
|
+
import type { HTMLAttributes } from 'react'
|
|
5
6
|
|
|
6
|
-
interface ITableDataCellProps extends
|
|
7
|
+
interface ITableDataCellProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
7
8
|
className?: string
|
|
8
9
|
children?: React.ReactNode
|
|
9
10
|
dataLabel?: string
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import * as React from 'react'
|
|
5
|
+
import type { HTMLAttributes } from 'react'
|
|
5
6
|
|
|
6
|
-
interface ITableHeaderProps extends
|
|
7
|
+
interface ITableHeaderProps extends HTMLAttributes<HTMLTableSectionElement> {
|
|
7
8
|
className?: string
|
|
8
9
|
children: React.ReactNode
|
|
9
10
|
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import * as React from 'react'
|
|
5
|
+
import type { HTMLAttributes } from 'react'
|
|
5
6
|
|
|
6
|
-
interface ITableHeaderCellProps extends
|
|
7
|
+
interface ITableHeaderCellProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
7
8
|
className?: string
|
|
8
9
|
children: React.ReactNode
|
|
9
10
|
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import * as React from 'react'
|
|
5
|
+
import type { HTMLAttributes } from 'react'
|
|
5
6
|
|
|
6
|
-
interface ITableRowProps extends
|
|
7
|
+
interface ITableRowProps extends HTMLAttributes<HTMLTableRowElement> {
|
|
7
8
|
className?: string
|
|
8
9
|
children: React.ReactNode
|
|
9
10
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { FC, ForwardedRef, forwardRef, ReactElement } from 'react'
|
|
4
|
+
import * as React from 'react'
|
|
4
5
|
import { createComponent, EventName } from '@lit/react'
|
|
5
6
|
import { PktTag as PktElTag } from '@oslokommune/punkt-elements'
|
|
6
7
|
import type { PktElType, PktElConstructor } from '@/interfaces/IPktElements'
|