@oslokommune/punkt-react 13.19.0 → 13.19.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 +18 -0
- package/dist/punkt-react.es.js +590 -577
- package/dist/punkt-react.umd.js +35 -27
- package/package.json +3 -3
- package/src/components/tag/Tag.tsx +10 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "13.19.
|
|
3
|
+
"version": "13.19.2",
|
|
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": "^13.19.
|
|
42
|
+
"@oslokommune/punkt-elements": "^13.19.2",
|
|
43
43
|
"classnames": "^2.5.1",
|
|
44
44
|
"prettier": "^3.3.3",
|
|
45
45
|
"react-hook-form": "^7.53.0"
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
104
104
|
},
|
|
105
105
|
"license": "MIT",
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "5288eb3b3820c776ffbc2e9dc264664fa4d465ea"
|
|
107
107
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ReactNode,
|
|
9
9
|
RefObject,
|
|
10
10
|
useCallback,
|
|
11
|
+
useEffect,
|
|
11
12
|
useMemo,
|
|
12
13
|
useRef,
|
|
13
14
|
useState,
|
|
@@ -37,7 +38,7 @@ interface SpanPktTagProps extends BasePktTagProps, HTMLAttributes<HTMLSpanElemen
|
|
|
37
38
|
type?: undefined
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export type IPktTag = ButtonPktTagProps | SpanPktTagProps
|
|
41
|
+
export type IPktTag = ButtonPktTagProps | SpanPktTagProps
|
|
41
42
|
|
|
42
43
|
export const PktTag = forwardRef<HTMLSpanElement | HTMLButtonElement, ButtonPktTagProps | SpanPktTagProps>(
|
|
43
44
|
(
|
|
@@ -67,13 +68,15 @@ export const PktTag = forwardRef<HTMLSpanElement | HTMLButtonElement, ButtonPktT
|
|
|
67
68
|
}, [setClosed])
|
|
68
69
|
|
|
69
70
|
const spanRef: RefObject<HTMLButtonElement | HTMLSpanElement> = useRef<HTMLButtonElement | HTMLSpanElement>(null)
|
|
71
|
+
const [labelText, setLabelText] = useState('')
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
setLabelText(spanRef.current?.textContent?.trim() ?? '')
|
|
75
|
+
}, [children])
|
|
70
76
|
|
|
71
77
|
const ariaDescription = useMemo(() => {
|
|
72
|
-
if (closeTag && !ariaLabel) {
|
|
73
|
-
|
|
74
|
-
return (label && `Klikk for å fjerne ${label}`) || ariaDescriptionPropValue
|
|
75
|
-
}
|
|
76
|
-
}, [closeTag, ariaLabel])
|
|
78
|
+
if (closeTag && !ariaLabel) return (labelText && `Klikk for å fjerne ${labelText}`) || ariaDescriptionPropValue
|
|
79
|
+
}, [closeTag, ariaLabel, labelText, ariaDescriptionPropValue])
|
|
77
80
|
|
|
78
81
|
const classes = {
|
|
79
82
|
'pkt-tag': true,
|
|
@@ -112,7 +115,7 @@ export const PktTag = forwardRef<HTMLSpanElement | HTMLButtonElement, ButtonPktT
|
|
|
112
115
|
} else {
|
|
113
116
|
return (
|
|
114
117
|
<span {...props} className={classNames(classes, className)} ref={forwardedRef as ForwardedRef<HTMLSpanElement>}>
|
|
115
|
-
{iconName && <PktIcon className={'pkt-tag__icon'} name={iconName} />}
|
|
118
|
+
{iconName && <PktIcon className={'pkt-tag__icon'} name={iconName} aria-hidden="true" />}
|
|
116
119
|
<span ref={spanRef}>{children}</span>
|
|
117
120
|
</span>
|
|
118
121
|
)
|