@oslokommune/punkt-react 19.18.5 → 19.19.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 +20 -0
- package/dist/components/stepper/Step.js +1 -1
- package/dist/components/table/Table.js +9 -8
- package/dist/punkt-react.cjs +1 -1
- package/dist/shared-types/table.d.ts +3 -2
- package/package.json +4 -4
- package/src/components/stepper/Step.tsx +1 -1
- package/src/components/table/Table.test.tsx +44 -3
- package/src/components/table/Table.tsx +11 -0
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Visual skins for pkt-table — shared runtime source for types, specs, and Preview.
|
|
10
10
|
*/
|
|
11
|
-
export declare const TABLE_SKINS: readonly ['basic', 'zebra
|
|
12
|
-
export type TPktTableSkin = (typeof TABLE_SKINS)[number];
|
|
11
|
+
export declare const TABLE_SKINS: readonly ['basic', 'zebra'];
|
|
12
|
+
export type TPktTableSkin = (typeof TABLE_SKINS)[number] | 'zebra-blue';
|
|
13
13
|
/**
|
|
14
14
|
* Table props shared by React and typed component specs.
|
|
15
15
|
*/
|
|
16
16
|
export interface IPktTableBase {
|
|
17
17
|
compact?: boolean;
|
|
18
|
+
/** `'zebra-blue'` er deprecated og fjernes i en kommende versjon. Bruk `'zebra'`. */
|
|
18
19
|
skin?: TPktTableSkin;
|
|
19
20
|
responsiveView?: boolean;
|
|
20
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.19.0",
|
|
4
4
|
"description": "React komponentbibliotek til Punkt, designsystem for Oslo kommune",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo kommune",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"@eslint/compat": "^2.1.0",
|
|
43
43
|
"@eslint/eslintrc": "^3.3.5",
|
|
44
44
|
"@eslint/js": "^10.0.1",
|
|
45
|
-
"@oslokommune/punkt-assets": "^19.
|
|
46
|
-
"@oslokommune/punkt-css": "^19.
|
|
45
|
+
"@oslokommune/punkt-assets": "^19.19.0",
|
|
46
|
+
"@oslokommune/punkt-css": "^19.19.0",
|
|
47
47
|
"@testing-library/jest-dom": "^7.0.1",
|
|
48
48
|
"@testing-library/react": "^16.3.2",
|
|
49
49
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
104
104
|
},
|
|
105
105
|
"license": "MIT",
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "44fc3d8f067708fc6704966219994891e9d5f9b3"
|
|
107
107
|
}
|
|
@@ -24,7 +24,7 @@ export interface IPktStep {
|
|
|
24
24
|
|
|
25
25
|
const incompleteStepSVG = (
|
|
26
26
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
|
|
27
|
-
<circle cx="12" cy="12" r="7"
|
|
27
|
+
<circle cx="12" cy="12" r="7" fill="#CCC" />
|
|
28
28
|
</svg>
|
|
29
29
|
)
|
|
30
30
|
|
|
@@ -2,6 +2,7 @@ import '@testing-library/jest-dom'
|
|
|
2
2
|
|
|
3
3
|
import { render, screen } from '@testing-library/react'
|
|
4
4
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
5
|
+
import { vi } from 'vitest'
|
|
5
6
|
|
|
6
7
|
import { PktTable } from './Table'
|
|
7
8
|
import { PktTableBody } from './TableBody'
|
|
@@ -39,9 +40,9 @@ describe('<PktTable />', () => {
|
|
|
39
40
|
expect(screen.getByText('Table data 2')).toBeInTheDocument()
|
|
40
41
|
})
|
|
41
42
|
|
|
42
|
-
test('renders correctly with skin "zebra
|
|
43
|
+
test('renders correctly with skin "zebra" and compact set to true', () => {
|
|
43
44
|
render(
|
|
44
|
-
<PktTable skin="zebra
|
|
45
|
+
<PktTable skin="zebra" compact>
|
|
45
46
|
<PktTableHeader>
|
|
46
47
|
<PktTableRow>
|
|
47
48
|
<PktTableHeaderCell>Header 1</PktTableHeaderCell>
|
|
@@ -59,6 +60,46 @@ describe('<PktTable />', () => {
|
|
|
59
60
|
|
|
60
61
|
// Assert that the component applies the props correctly
|
|
61
62
|
expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--compact')
|
|
62
|
-
expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--zebra
|
|
63
|
+
expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--zebra')
|
|
64
|
+
expect(screen.getByTestId('pkt-table')).not.toHaveClass('pkt-table--zebra-blue')
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
describe('deprecated skin "zebra-blue"', () => {
|
|
68
|
+
afterEach(() => vi.restoreAllMocks())
|
|
69
|
+
|
|
70
|
+
test('renders both the zebra and the zebra-blue class', () => {
|
|
71
|
+
vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
72
|
+
render(
|
|
73
|
+
<PktTable skin="zebra-blue">
|
|
74
|
+
<PktTableBody>
|
|
75
|
+
<PktTableRow>
|
|
76
|
+
<PktTableDataCell>Table data</PktTableDataCell>
|
|
77
|
+
</PktTableRow>
|
|
78
|
+
</PktTableBody>
|
|
79
|
+
</PktTable>,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--zebra')
|
|
83
|
+
expect(screen.getByTestId('pkt-table')).toHaveClass('pkt-table--zebra-blue')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('warns once, however many tables use it', async () => {
|
|
87
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
88
|
+
vi.resetModules()
|
|
89
|
+
const { PktTable: FreshTable } = await import('./Table')
|
|
90
|
+
render(
|
|
91
|
+
<>
|
|
92
|
+
<FreshTable skin="zebra-blue">
|
|
93
|
+
<tbody />
|
|
94
|
+
</FreshTable>
|
|
95
|
+
<FreshTable skin="zebra-blue">
|
|
96
|
+
<tbody />
|
|
97
|
+
</FreshTable>
|
|
98
|
+
</>,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
expect(warn).toHaveBeenCalledTimes(1)
|
|
102
|
+
expect(warn).toHaveBeenCalledWith(expect.stringContaining('skin="zebra"'))
|
|
103
|
+
})
|
|
63
104
|
})
|
|
64
105
|
})
|
|
@@ -9,6 +9,8 @@ export interface IPktTable extends IPktTableBase, HTMLAttributes<HTMLTableElemen
|
|
|
9
9
|
children: ReactNode
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
let hasWarnedZebraBlue = false
|
|
13
|
+
|
|
12
14
|
export const PktTable = ({
|
|
13
15
|
className,
|
|
14
16
|
compact = TABLE_DEFAULTS.compact,
|
|
@@ -17,6 +19,14 @@ export const PktTable = ({
|
|
|
17
19
|
children,
|
|
18
20
|
...props
|
|
19
21
|
}: IPktTable) => {
|
|
22
|
+
if (skin === 'zebra-blue' && !hasWarnedZebraBlue) {
|
|
23
|
+
hasWarnedZebraBlue = true
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.warn(
|
|
26
|
+
'PktTable: skin="zebra-blue" is deprecated and will be removed in a future version. Please use skin="zebra" instead.',
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
return (
|
|
21
31
|
<table
|
|
22
32
|
data-testid="pkt-table"
|
|
@@ -24,6 +34,7 @@ export const PktTable = ({
|
|
|
24
34
|
'pkt-table--responsive': responsiveView,
|
|
25
35
|
'pkt-table--compact': compact,
|
|
26
36
|
'pkt-table--basic': skin === 'basic',
|
|
37
|
+
'pkt-table--zebra': skin === 'zebra' || skin === 'zebra-blue',
|
|
27
38
|
'pkt-table--zebra-blue': skin === 'zebra-blue',
|
|
28
39
|
})}
|
|
29
40
|
role="table"
|