@oslokommune/punkt-react 16.13.3 → 16.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "16.13.3",
3
+ "version": "16.14.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",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@lit-labs/ssr-dom-shim": "^1.2.1",
41
41
  "@lit/react": "^1.0.7",
42
- "@oslokommune/punkt-elements": "^16.13.2",
42
+ "@oslokommune/punkt-elements": "^16.14.0",
43
43
  "classnames": "^2.5.1",
44
44
  "prettier": "^3.3.3",
45
45
  "react-hook-form": "^7.53.0"
@@ -50,7 +50,7 @@
50
50
  "@eslint/eslintrc": "^3.3.3",
51
51
  "@eslint/js": "^9.37.0",
52
52
  "@oslokommune/punkt-assets": "^16.13.2",
53
- "@oslokommune/punkt-css": "^16.13.3",
53
+ "@oslokommune/punkt-css": "^16.14.0",
54
54
  "@testing-library/jest-dom": "^6.5.0",
55
55
  "@testing-library/react": "^16.0.1",
56
56
  "@testing-library/user-event": "^14.5.2",
@@ -109,5 +109,5 @@
109
109
  "url": "https://github.com/oslokommune/punkt/issues"
110
110
  },
111
111
  "license": "MIT",
112
- "gitHead": "0a14763e4a1d49a5c8dccf51dc0dfc08a6d05cb1"
112
+ "gitHead": "af9088d3c57930488829eb4e6384dbfb9aceac32"
113
113
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { ForwardedRef, forwardRef, type ReactNode, RefAttributes, useState } from 'react'
4
4
 
5
+ import { useFocusModality } from '../../hooks/useFocusModality'
5
6
  import { PktAlert } from '../alert/Alert'
6
7
  import { PktButton } from '../button/Button'
7
8
 
@@ -64,6 +65,8 @@ export const PktInputWrapper = forwardRef(
64
65
  ) => {
65
66
  const [isHelpTextOpen, setIsHelpTextOpen] = useState(false)
66
67
 
68
+ const focusModality = useFocusModality<HTMLDivElement>(ref)
69
+
67
70
  const describedBy = ariaDescribedby || (helptext ? `${forId}-helptext` : undefined)
68
71
  const showCounter = !!counter
69
72
  const counterTop = showCounter && counterPosition === 'top'
@@ -189,7 +192,7 @@ export const PktInputWrapper = forwardRef(
189
192
  )
190
193
 
191
194
  return (
192
- <div className={wrapperClasses} ref={ref} role={role}>
195
+ <div className={wrapperClasses} role={role} {...focusModality}>
193
196
  {hasFieldset ? (
194
197
  <fieldset className="pkt-inputwrapper__fieldset" aria-describedby={describedBy}>
195
198
  {content}
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { ChangeEvent, createElement, forwardRef, HTMLProps, ReactNode } from 'react'
4
4
 
5
+ import { useFocusModality } from '../../hooks/useFocusModality'
5
6
  import { PktButton } from '../button/Button'
6
7
 
7
8
  interface SearchSuggestion {
@@ -74,22 +75,22 @@ export const PktSearchInput = forwardRef<HTMLInputElement, ISearchInput | ISearc
74
75
  fullwidth ? 'pkt-searchinput--fullwidth' : ''
75
76
  }`
76
77
 
77
- let WrapperElement
78
- if (action) {
79
- // eslint-disable-next-line react/display-name
80
- WrapperElement = (children: ReactNode) => (
81
- <form role="search" className={wrapperClass} action={action} method={method}>
78
+ const focusModality = useFocusModality()
79
+
80
+ const wrapperProps = {
81
+ role: 'search',
82
+ className: wrapperClass,
83
+ ...focusModality,
84
+ }
85
+
86
+ const WrapperElement = (children: ReactNode) =>
87
+ action ? (
88
+ <form {...wrapperProps} action={action} method={method}>
82
89
  {children}
83
90
  </form>
91
+ ) : (
92
+ <div {...wrapperProps}>{children}</div>
84
93
  )
85
- } else {
86
- // eslint-disable-next-line react/display-name
87
- WrapperElement = (children: ReactNode) => (
88
- <div role="search" className={wrapperClass}>
89
- {children}
90
- </div>
91
- )
92
- }
93
94
 
94
95
  return WrapperElement(
95
96
  <>