@oslokommune/punkt-react 19.16.0 → 19.16.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 +11 -0
- package/dist/_virtual/_rolldown/runtime.js +1 -1
- package/dist/components/calendar/useCalendarState.js +1 -5
- package/dist/components/combobox/useComboboxState.js +6 -18
- package/dist/components/consent/Consent.js +1 -1
- package/dist/components/fileupload/DropZone.js +1 -5
- package/dist/components/fileupload/Subcomponents.js +2 -5
- package/dist/components/header/HeaderGlobal.js +1 -1
- package/dist/components/header/HeaderService.js +1 -1
- package/dist/components/link/Link.js +1 -1
- package/dist/components/tabs/TabItem.js +2 -10
- package/dist/hooks/useElementWidth.js +9 -9
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +1 -1
- package/dist/node_modules/date-fns/constants.js +4 -8
- package/dist/node_modules/date-fns/getISOWeek.js +1 -1
- package/dist/node_modules/date-fns/getWeek.js +1 -1
- package/dist/punkt-react.cjs +1 -1
- package/dist/shared-utils/combobox/keyboard-navigation.js +9 -10
- package/dist/shared-utils/fileupload/focus-trap.js +1 -2
- package/dist/shared-utils/scroll-lock/index.js +1 -1
- package/package.json +3 -3
- package/src/components/hydration.test.tsx +61 -15
|
@@ -24,18 +24,17 @@ var e = (e) => {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
let a = i.find((e) => e.dataset.selected === "true");
|
|
27
|
-
if (a)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return;
|
|
27
|
+
if (a) e(a);
|
|
28
|
+
else {
|
|
29
|
+
if (r.includeSearch && !(document.activeElement instanceof HTMLInputElement)) {
|
|
30
|
+
let e = n.querySelector("[role=\"searchbox\"]");
|
|
31
|
+
if (e) {
|
|
32
|
+
window.setTimeout(() => e.focus(), 0);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
36
35
|
}
|
|
36
|
+
i[0] && e(i[0]);
|
|
37
37
|
}
|
|
38
|
-
i[0] && e(i[0]);
|
|
39
38
|
};
|
|
40
39
|
//#endregion
|
|
41
40
|
export { e as focusAndScrollIntoView, i as focusFirstOption, a as focusFirstOrSelectedOption, n as focusNextOption, r as focusPreviousOption, t as getOptionElements };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { e as trapTabInside };
|
|
1
|
+
export { trapTabInside } from "../focus-trap/index.js";
|
|
@@ -13,7 +13,7 @@ var e = "is-scroll-locked", t = 0, n = 0, r = () => typeof document < "u" && typ
|
|
|
13
13
|
}, o = () => {
|
|
14
14
|
r() && (t += 1, t === 1 && i());
|
|
15
15
|
}, s = () => {
|
|
16
|
-
|
|
16
|
+
r() && t !== 0 && (--t, t === 0 && a());
|
|
17
17
|
}, c = () => ({ locked: !1 }), l = (e, t) => {
|
|
18
18
|
e.locked !== t && (e.locked = t, t ? o() : s());
|
|
19
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "19.16.
|
|
3
|
+
"version": "19.16.2",
|
|
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,7 +42,7 @@
|
|
|
42
42
|
"@eslint/eslintrc": "^3.3.5",
|
|
43
43
|
"@eslint/js": "^10.0.1",
|
|
44
44
|
"@oslokommune/punkt-assets": "^19.14.2",
|
|
45
|
-
"@oslokommune/punkt-css": "^19.
|
|
45
|
+
"@oslokommune/punkt-css": "^19.16.2",
|
|
46
46
|
"@testing-library/jest-dom": "^6.9.1",
|
|
47
47
|
"@testing-library/react": "^16.3.2",
|
|
48
48
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
103
103
|
},
|
|
104
104
|
"license": "MIT",
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "feb42fbaff11316e83d1d588b58d8a5cad459e00"
|
|
106
106
|
}
|
|
@@ -1,32 +1,78 @@
|
|
|
1
1
|
import { act } from '@testing-library/react'
|
|
2
|
+
import type { ReactElement } from 'react'
|
|
2
3
|
import { hydrateRoot, type Root } from 'react-dom/client'
|
|
3
4
|
import { renderToString } from 'react-dom/server'
|
|
4
5
|
import { vi } from 'vitest'
|
|
5
6
|
|
|
6
7
|
import { serverRenderCases } from '../utils/serverRenderCases'
|
|
8
|
+
import { PktHeaderGlobal, PktHeaderService } from './index'
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
document.body.append(container)
|
|
10
|
+
const hydrate = async (element: () => ReactElement, { serverWithoutWindow = false } = {}) => {
|
|
11
|
+
if (serverWithoutWindow) vi.stubGlobal('window', undefined)
|
|
12
|
+
const html = renderToString(element())
|
|
13
|
+
vi.unstubAllGlobals()
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const container = document.createElement('div')
|
|
16
|
+
container.innerHTML = html
|
|
17
|
+
document.body.append(container)
|
|
18
|
+
|
|
19
|
+
const errors: string[] = []
|
|
20
|
+
const consoleError = vi.spyOn(console, 'error').mockImplementation((...args: unknown[]) => {
|
|
21
|
+
errors.push(args.map(String).join(' '))
|
|
22
|
+
})
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
+
let root: Root | undefined
|
|
25
|
+
await act(async () => {
|
|
26
|
+
root = hydrateRoot(container, element(), {
|
|
27
|
+
onRecoverableError: (error) => errors.push(String(error)),
|
|
24
28
|
})
|
|
29
|
+
})
|
|
30
|
+
consoleError.mockRestore()
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
const cleanup = () => {
|
|
27
33
|
act(() => root?.unmount())
|
|
28
34
|
container.remove()
|
|
35
|
+
}
|
|
36
|
+
return { container, errors, cleanup }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe('hydration', () => {
|
|
40
|
+
test.each(serverRenderCases)('%s hydrates without mismatches', async (_name, element) => {
|
|
41
|
+
const { errors, cleanup } = await hydrate(element)
|
|
42
|
+
cleanup()
|
|
29
43
|
|
|
30
44
|
expect(errors).toEqual([])
|
|
31
45
|
})
|
|
32
46
|
})
|
|
47
|
+
|
|
48
|
+
describe('hydration at phone width', () => {
|
|
49
|
+
let innerWidth: number
|
|
50
|
+
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
innerWidth = window.innerWidth
|
|
53
|
+
Object.defineProperty(window, 'innerWidth', { value: 375, configurable: true })
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
Object.defineProperty(window, 'innerWidth', { value: innerWidth, configurable: true })
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test.each([
|
|
61
|
+
[
|
|
62
|
+
'PktHeaderService',
|
|
63
|
+
() => <PktHeaderService serviceName="Service" user={{ name: 'Test User' }} logOut={() => {}} />,
|
|
64
|
+
'pkt-header-service--mobile',
|
|
65
|
+
],
|
|
66
|
+
['PktHeaderGlobal', () => <PktHeaderGlobal />, 'pkt-header-global--mobile'],
|
|
67
|
+
] as const)(
|
|
68
|
+
'%s hydrates the server markup and then switches to the mobile layout',
|
|
69
|
+
async (_name, element, mobileClass) => {
|
|
70
|
+
const { container, errors, cleanup } = await hydrate(element, { serverWithoutWindow: true })
|
|
71
|
+
const headerClasses = container.querySelector('header')?.className.split(' ') ?? []
|
|
72
|
+
cleanup()
|
|
73
|
+
|
|
74
|
+
expect(errors).toEqual([])
|
|
75
|
+
expect(headerClasses).toContain(mobileClass)
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
})
|