@oslokommune/punkt-react 13.0.1 → 13.0.3
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 +36 -0
- package/dist/index.d.ts +3 -4
- package/dist/punkt-react.es.js +2640 -2641
- package/dist/punkt-react.umd.js +107 -107
- package/package.json +2 -2
- package/src/components/checkbox/Checkbox.tsx +1 -1
- package/src/components/radio/RadioButton.tsx +1 -1
- package/src/components/textarea/Textarea.tsx +9 -10
- package/src/components/textinput/Textinput.tsx +3 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.3",
|
|
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",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
113
113
|
},
|
|
114
114
|
"license": "MIT",
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "9e0607440983576ee5baff7f3304e13857fa11d1"
|
|
116
116
|
}
|
|
@@ -47,7 +47,7 @@ export const PktCheckbox = forwardRef(
|
|
|
47
47
|
type="checkbox"
|
|
48
48
|
id={id}
|
|
49
49
|
disabled={disabled}
|
|
50
|
-
|
|
50
|
+
{...(checked !== undefined ? { checked } : { defaultChecked })}
|
|
51
51
|
{...props}
|
|
52
52
|
/>
|
|
53
53
|
<label className="pkt-input-check__input-label" htmlFor={id}>
|
|
@@ -47,7 +47,7 @@ export const PktRadioButton = forwardRef(
|
|
|
47
47
|
name={name}
|
|
48
48
|
disabled={disabled}
|
|
49
49
|
className={`pkt-input-check__input-checkbox ${hasError ? 'pkt-input-check__input-checkbox--error' : ''}`}
|
|
50
|
-
|
|
50
|
+
{...(checked !== undefined ? { checked } : { defaultChecked })}
|
|
51
51
|
{...props}
|
|
52
52
|
/>
|
|
53
53
|
<label className="pkt-input-check__input-label" htmlFor={id}>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import React, {
|
|
4
4
|
ChangeEvent,
|
|
5
|
+
ChangeEventHandler,
|
|
5
6
|
ForwardedRef,
|
|
6
7
|
forwardRef,
|
|
7
8
|
ReactNode,
|
|
8
9
|
TextareaHTMLAttributes,
|
|
9
10
|
useEffect,
|
|
10
|
-
useRef,
|
|
11
11
|
useState,
|
|
12
12
|
} from 'react'
|
|
13
13
|
|
|
@@ -43,7 +43,7 @@ export interface IPktTextarea extends TextareaHTMLAttributes<HTMLTextAreaElement
|
|
|
43
43
|
readOnly?: boolean
|
|
44
44
|
required?: boolean
|
|
45
45
|
skipForwardTestid?: boolean
|
|
46
|
-
onChange?:
|
|
46
|
+
onChange?: ChangeEventHandler<HTMLTextAreaElement>
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export const PktTextarea = forwardRef(
|
|
@@ -89,8 +89,6 @@ export const PktTextarea = forwardRef(
|
|
|
89
89
|
const labelId = `${inputId}-label` // id til label elementet og sendes inn til aria-labelledby i input (genereres i InputWrapper)
|
|
90
90
|
const labelledBy = ariaLabelledby || labelId
|
|
91
91
|
|
|
92
|
-
const internalRef = useRef<HTMLTextAreaElement>(null)
|
|
93
|
-
|
|
94
92
|
const [counterCurrent, setCounterCurrent] = useState(0)
|
|
95
93
|
|
|
96
94
|
const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
|
|
@@ -101,9 +99,10 @@ export const PktTextarea = forwardRef(
|
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
useEffect(() => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
if (value !== undefined) {
|
|
103
|
+
setCounterCurrent(value?.length || 0)
|
|
104
|
+
}
|
|
105
|
+
}, [value])
|
|
107
106
|
|
|
108
107
|
return (
|
|
109
108
|
<PktInputWrapper
|
|
@@ -128,11 +127,11 @@ export const PktTextarea = forwardRef(
|
|
|
128
127
|
counterMaxLength={counterMaxLength}
|
|
129
128
|
>
|
|
130
129
|
<textarea
|
|
131
|
-
ref={
|
|
130
|
+
ref={ref}
|
|
132
131
|
className={`pkt-input ${fullwidth ? 'pkt-input--fullwidth' : ''} ${
|
|
133
132
|
counterMaxLength && counterCurrent > counterMaxLength ? 'pkt-input--counter-error' : ''
|
|
134
133
|
}`}
|
|
135
|
-
name={`${name || id}
|
|
134
|
+
name={`${name || id}`}
|
|
136
135
|
id={inputId}
|
|
137
136
|
placeholder={placeholder}
|
|
138
137
|
disabled={disabled}
|
|
@@ -4,11 +4,11 @@ import React, {
|
|
|
4
4
|
ForwardedRef,
|
|
5
5
|
forwardRef,
|
|
6
6
|
InputHTMLAttributes,
|
|
7
|
-
useRef,
|
|
8
7
|
useEffect,
|
|
9
8
|
useState,
|
|
10
9
|
ChangeEvent,
|
|
11
10
|
ReactNode,
|
|
11
|
+
ChangeEventHandler,
|
|
12
12
|
} from 'react'
|
|
13
13
|
|
|
14
14
|
import { PktIcon } from '../icon/Icon'
|
|
@@ -52,7 +52,7 @@ export interface IPktTextinput extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
52
52
|
readonly?: boolean
|
|
53
53
|
required?: boolean
|
|
54
54
|
dataTestid?: string
|
|
55
|
-
onChange?:
|
|
55
|
+
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
56
56
|
skipForwardTestid?: boolean
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -115,10 +115,7 @@ export const PktTextinput = forwardRef(
|
|
|
115
115
|
const labelledBy = ariaLabelledby || labelId
|
|
116
116
|
|
|
117
117
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
118
|
-
|
|
119
|
-
if (counter) {
|
|
120
|
-
setCounterCurrent(newValue?.length || 0)
|
|
121
|
-
}
|
|
118
|
+
counter && setCounterCurrent(event.currentTarget?.value?.length || 0)
|
|
122
119
|
if (onChange) {
|
|
123
120
|
onChange(event)
|
|
124
121
|
}
|