@oslokommune/punkt-react 13.0.3 → 13.1.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 +36 -0
- package/dist/index.d.ts +14 -0
- package/dist/punkt-react.es.js +10037 -9949
- package/dist/punkt-react.umd.js +439 -424
- package/package.json +3 -3
- package/src/components/checkbox/Checkbox.tsx +53 -6
- package/src/components/inputwrapper/InputWrapper.tsx +13 -12
- package/src/components/radio/RadioButton.tsx +45 -8
- package/src/components/select/Select.tsx +3 -0
- package/src/components/textarea/Textarea.tsx +3 -0
- package/src/components/textinput/Textinput.tsx +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.1.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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@lit-labs/ssr-dom-shim": "^1.2.1",
|
|
40
40
|
"@lit/react": "^1.0.7",
|
|
41
|
-
"@oslokommune/punkt-elements": "^13.
|
|
41
|
+
"@oslokommune/punkt-elements": "^13.1.0",
|
|
42
42
|
"angular-html-parser": "^6.0.2",
|
|
43
43
|
"html-format": "^1.1.7",
|
|
44
44
|
"prettier": "^3.3.3",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
113
113
|
},
|
|
114
114
|
"license": "MIT",
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "eec066758ede7f850bc9f4683957baee56e7abc5"
|
|
116
116
|
}
|
|
@@ -13,6 +13,11 @@ export interface IPktCheckbox extends React.InputHTMLAttributes<HTMLInputElement
|
|
|
13
13
|
isSwitch?: boolean
|
|
14
14
|
hideLabel?: boolean
|
|
15
15
|
labelPosition?: 'right' | 'left'
|
|
16
|
+
optionalTag?: boolean
|
|
17
|
+
optionalText?: string
|
|
18
|
+
requiredTag?: boolean
|
|
19
|
+
requiredText?: string
|
|
20
|
+
tagText?: string | null
|
|
16
21
|
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
17
22
|
}
|
|
18
23
|
|
|
@@ -28,18 +33,58 @@ export const PktCheckbox = forwardRef(
|
|
|
28
33
|
className,
|
|
29
34
|
isSwitch = false,
|
|
30
35
|
hideLabel = false,
|
|
31
|
-
labelPosition,
|
|
36
|
+
labelPosition = 'right',
|
|
32
37
|
defaultChecked,
|
|
33
38
|
checked,
|
|
39
|
+
optionalTag,
|
|
40
|
+
optionalText = 'Valgfritt',
|
|
41
|
+
requiredTag,
|
|
42
|
+
requiredText = 'Må fylles ut',
|
|
43
|
+
tagText,
|
|
34
44
|
...props
|
|
35
45
|
}: IPktCheckbox,
|
|
36
46
|
ref: ForwardedRef<HTMLInputElement>,
|
|
37
47
|
): React.ReactElement => {
|
|
38
48
|
const classes = [className, 'pkt-input-check'].filter(Boolean).join(' ')
|
|
39
49
|
|
|
50
|
+
const labelClasses = [
|
|
51
|
+
'pkt-input-check__input-label',
|
|
52
|
+
disabled ? 'pkt-input-check__input-label--disabled' : '',
|
|
53
|
+
`pkt-input-check__input-label--${labelPosition}`,
|
|
54
|
+
hideLabel ? 'pkt-sr-only' : '',
|
|
55
|
+
]
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.join(' ')
|
|
58
|
+
|
|
59
|
+
const inputTileClasses = [
|
|
60
|
+
'pkt-input-check__input',
|
|
61
|
+
hasTile ? 'pkt-input-check__input--tile' : '',
|
|
62
|
+
disabled && hasTile ? 'pkt-input-check__input--tile-disabled' : '',
|
|
63
|
+
]
|
|
64
|
+
.filter(Boolean)
|
|
65
|
+
.join(' ')
|
|
66
|
+
|
|
67
|
+
const tagClasses = ['pkt-tag', 'pkt-tag--small', 'pkt-tag--thin-text'].join(' ')
|
|
68
|
+
|
|
69
|
+
const renderTags = () => {
|
|
70
|
+
return (
|
|
71
|
+
<>
|
|
72
|
+
{tagText && <span className={tagClasses + ` pkt-tag--gray`}>{tagText}</span>}
|
|
73
|
+
{optionalTag && <span className={tagClasses + ` pkt-tag--blue-light`}>{optionalText}</span>}
|
|
74
|
+
{requiredTag && <span className={tagClasses + ` pkt-tag--beige`}>{requiredText}</span>}
|
|
75
|
+
</>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
40
79
|
return (
|
|
41
80
|
<div className={classes}>
|
|
42
|
-
<div className={
|
|
81
|
+
<div className={inputTileClasses}>
|
|
82
|
+
{labelPosition === 'left' && (
|
|
83
|
+
<label className={labelClasses} htmlFor={id}>
|
|
84
|
+
{label} {renderTags()}
|
|
85
|
+
{checkHelptext && <div className="pkt-input-check__input-helptext">{checkHelptext}</div>}
|
|
86
|
+
</label>
|
|
87
|
+
)}
|
|
43
88
|
<input
|
|
44
89
|
role={isSwitch ? 'switch' : 'checkbox'}
|
|
45
90
|
ref={ref}
|
|
@@ -50,10 +95,12 @@ export const PktCheckbox = forwardRef(
|
|
|
50
95
|
{...(checked !== undefined ? { checked } : { defaultChecked })}
|
|
51
96
|
{...props}
|
|
52
97
|
/>
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
|
|
98
|
+
{labelPosition === 'right' && (
|
|
99
|
+
<label className={labelClasses} htmlFor={id}>
|
|
100
|
+
{label} {renderTags()}
|
|
101
|
+
{checkHelptext && <div className="pkt-input-check__input-helptext">{checkHelptext}</div>}
|
|
102
|
+
</label>
|
|
103
|
+
)}
|
|
57
104
|
</div>
|
|
58
105
|
</div>
|
|
59
106
|
)
|
|
@@ -17,6 +17,7 @@ export interface IPktInputWrapper extends RefAttributes<HTMLElement> {
|
|
|
17
17
|
optionalText?: string
|
|
18
18
|
requiredTag?: boolean
|
|
19
19
|
requiredText?: string
|
|
20
|
+
tagText?: string | null
|
|
20
21
|
hasError?: boolean
|
|
21
22
|
errorMessage?: string | ReactNode
|
|
22
23
|
disabled?: boolean
|
|
@@ -45,6 +46,7 @@ export const PktInputWrapper = forwardRef(
|
|
|
45
46
|
optionalText = 'Valgfritt',
|
|
46
47
|
requiredTag = false,
|
|
47
48
|
requiredText = 'Må fylles ut',
|
|
49
|
+
tagText = null,
|
|
48
50
|
hasError = false,
|
|
49
51
|
errorMessage,
|
|
50
52
|
disabled = false,
|
|
@@ -61,8 +63,6 @@ export const PktInputWrapper = forwardRef(
|
|
|
61
63
|
) => {
|
|
62
64
|
const [isHelpTextOpen, setIsHelpTextOpen] = useState(false)
|
|
63
65
|
|
|
64
|
-
const tagText = optionalTag ? optionalText : requiredTag ? requiredText : null
|
|
65
|
-
|
|
66
66
|
const describedBy = ariaDescribedby || (helptext ? `${forId}-helptext` : undefined)
|
|
67
67
|
const showCounter = !!counter
|
|
68
68
|
const counterTop = showCounter && counterPosition === 'top'
|
|
@@ -80,15 +80,7 @@ export const PktInputWrapper = forwardRef(
|
|
|
80
80
|
.filter(Boolean)
|
|
81
81
|
.join(' ')
|
|
82
82
|
|
|
83
|
-
const tagClasses = [
|
|
84
|
-
'pkt-tag',
|
|
85
|
-
'pkt-tag--small',
|
|
86
|
-
'pkt-tag--thin-text',
|
|
87
|
-
optionalTag && 'pkt-tag--blue-light',
|
|
88
|
-
!optionalTag && requiredTag && 'pkt-tag--beige',
|
|
89
|
-
]
|
|
90
|
-
.filter(Boolean)
|
|
91
|
-
.join(' ')
|
|
83
|
+
const tagClasses = ['pkt-tag', 'pkt-tag--small', 'pkt-tag--thin-text'].join(' ')
|
|
92
84
|
|
|
93
85
|
const Counter = () =>
|
|
94
86
|
showCounter ? (
|
|
@@ -98,10 +90,19 @@ export const PktInputWrapper = forwardRef(
|
|
|
98
90
|
</div>
|
|
99
91
|
) : null
|
|
100
92
|
|
|
93
|
+
const renderTags = () => {
|
|
94
|
+
return (
|
|
95
|
+
<>
|
|
96
|
+
{tagText && <span className={tagClasses + ` pkt-tag--gray`}>{tagText}</span>}
|
|
97
|
+
{optionalTag && <span className={tagClasses + ` pkt-tag--blue-light`}>{optionalText}</span>}
|
|
98
|
+
{requiredTag && <span className={tagClasses + ` pkt-tag--beige`}>{requiredText}</span>}
|
|
99
|
+
</>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
101
102
|
const renderLabel = () => {
|
|
102
103
|
const labelContent = (
|
|
103
104
|
<>
|
|
104
|
-
{label} {
|
|
105
|
+
{label} {renderTags()}
|
|
105
106
|
</>
|
|
106
107
|
)
|
|
107
108
|
|
|
@@ -11,6 +11,11 @@ export interface IPktRadioButton extends React.InputHTMLAttributes<HTMLInputElem
|
|
|
11
11
|
checked?: boolean
|
|
12
12
|
hasError?: boolean
|
|
13
13
|
value?: string
|
|
14
|
+
optionalTag?: boolean
|
|
15
|
+
optionalText?: string
|
|
16
|
+
requiredTag?: boolean
|
|
17
|
+
requiredText?: string
|
|
18
|
+
tagText?: string | null
|
|
14
19
|
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
15
20
|
}
|
|
16
21
|
|
|
@@ -27,31 +32,63 @@ export const PktRadioButton = forwardRef(
|
|
|
27
32
|
hasError = false,
|
|
28
33
|
defaultChecked,
|
|
29
34
|
checked,
|
|
35
|
+
optionalTag,
|
|
36
|
+
optionalText,
|
|
37
|
+
requiredTag,
|
|
38
|
+
requiredText,
|
|
39
|
+
tagText,
|
|
30
40
|
...props
|
|
31
41
|
}: IPktRadioButton,
|
|
32
42
|
ref: ForwardedRef<HTMLInputElement>,
|
|
33
43
|
): React.ReactElement => {
|
|
34
44
|
const classes = [className, 'pkt-input-check'].filter(Boolean).join(' ')
|
|
35
45
|
|
|
46
|
+
const inputTileClasses = [
|
|
47
|
+
'pkt-input-check__input',
|
|
48
|
+
hasTile ? 'pkt-input-check__input--tile' : '',
|
|
49
|
+
disabled && hasTile ? 'pkt-input-check__input--tile-disabled' : '',
|
|
50
|
+
]
|
|
51
|
+
.filter(Boolean)
|
|
52
|
+
.join(' ')
|
|
53
|
+
|
|
54
|
+
const inputCheckBoxClasses = [
|
|
55
|
+
'pkt-input-check__input-checkbox',
|
|
56
|
+
hasError ? 'pkt-input-check__input-checkbox--error' : '',
|
|
57
|
+
]
|
|
58
|
+
.filter(Boolean)
|
|
59
|
+
.join(' ')
|
|
60
|
+
|
|
61
|
+
const labelClasses = ['pkt-input-check__input-label', disabled ? 'pkt-input-check__input-label--disabled' : '']
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.join(' ')
|
|
64
|
+
|
|
65
|
+
const tagClasses = ['pkt-tag', 'pkt-tag--small', 'pkt-tag--thin-text'].join(' ')
|
|
66
|
+
|
|
67
|
+
const renderTags = () => {
|
|
68
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
{tagText && <span className={tagClasses + ` pkt-tag--gray`}>{tagText}</span>}
|
|
71
|
+
{optionalTag && <span className={tagClasses + ` pkt-tag--blue-light`}>{optionalText}</span>}
|
|
72
|
+
{requiredTag && <span className={tagClasses + ` pkt-tag--beige`}>{requiredText}</span>}
|
|
73
|
+
</>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
36
77
|
return (
|
|
37
78
|
<div className={classes}>
|
|
38
|
-
<div
|
|
39
|
-
className={`pkt-input-check__input ${hasTile ? 'pkt-input-check__input--tile' : ''} ${
|
|
40
|
-
disabled && hasTile ? 'pkt-input-check__input--tile-disabled' : ''
|
|
41
|
-
}`}
|
|
42
|
-
>
|
|
79
|
+
<div className={inputTileClasses}>
|
|
43
80
|
<input
|
|
44
81
|
ref={ref}
|
|
45
82
|
id={id}
|
|
46
83
|
type="radio"
|
|
47
84
|
name={name}
|
|
48
85
|
disabled={disabled}
|
|
49
|
-
className={
|
|
86
|
+
className={inputCheckBoxClasses}
|
|
50
87
|
{...(checked !== undefined ? { checked } : { defaultChecked })}
|
|
51
88
|
{...props}
|
|
52
89
|
/>
|
|
53
|
-
<label className=
|
|
54
|
-
{label}
|
|
90
|
+
<label className={labelClasses} htmlFor={id}>
|
|
91
|
+
{label} {renderTags()}
|
|
55
92
|
{checkHelptext && <div className="pkt-input-check__input-helptext">{checkHelptext}</div>}
|
|
56
93
|
</label>
|
|
57
94
|
</div>
|
|
@@ -30,6 +30,7 @@ export interface IPktSelectProps extends SelectHTMLAttributes<HTMLSelectElement>
|
|
|
30
30
|
optionalText?: string
|
|
31
31
|
requiredTag?: boolean
|
|
32
32
|
requiredText?: string
|
|
33
|
+
tagText?: string | null
|
|
33
34
|
options?: Array<{ value: string; label: string; disabled?: boolean }>
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -55,6 +56,7 @@ export const PktSelect = forwardRef(
|
|
|
55
56
|
optionalText,
|
|
56
57
|
requiredTag = false,
|
|
57
58
|
requiredText,
|
|
59
|
+
tagText,
|
|
58
60
|
...props
|
|
59
61
|
}: IPktSelectProps,
|
|
60
62
|
ref: ForwardedRef<HTMLSelectElement>,
|
|
@@ -72,6 +74,7 @@ export const PktSelect = forwardRef(
|
|
|
72
74
|
optionalText={optionalText}
|
|
73
75
|
requiredTag={requiredTag}
|
|
74
76
|
requiredText={requiredText}
|
|
77
|
+
tagText={tagText}
|
|
75
78
|
hasError={hasError}
|
|
76
79
|
errorMessage={errorMessage}
|
|
77
80
|
disabled={disabled}
|
|
@@ -33,6 +33,7 @@ export interface IPktTextarea extends TextareaHTMLAttributes<HTMLTextAreaElement
|
|
|
33
33
|
optionalText?: string
|
|
34
34
|
requiredTag?: boolean
|
|
35
35
|
requiredText?: string
|
|
36
|
+
tagText?: string | null
|
|
36
37
|
placeholder?: string
|
|
37
38
|
rows?: number
|
|
38
39
|
useWrapper?: boolean
|
|
@@ -69,6 +70,7 @@ export const PktTextarea = forwardRef(
|
|
|
69
70
|
optionalText,
|
|
70
71
|
requiredTag = false,
|
|
71
72
|
requiredText,
|
|
73
|
+
tagText = null,
|
|
72
74
|
placeholder,
|
|
73
75
|
rows,
|
|
74
76
|
useWrapper = true,
|
|
@@ -121,6 +123,7 @@ export const PktTextarea = forwardRef(
|
|
|
121
123
|
optionalText={optionalText}
|
|
122
124
|
requiredTag={requiredTag}
|
|
123
125
|
requiredText={requiredText}
|
|
126
|
+
tagText={tagText}
|
|
124
127
|
useWrapper={useWrapper}
|
|
125
128
|
counter={counter}
|
|
126
129
|
counterCurrent={counterCurrent}
|
|
@@ -36,6 +36,7 @@ export interface IPktTextinput extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
36
36
|
optionalText?: string
|
|
37
37
|
requiredTag?: boolean
|
|
38
38
|
requiredText?: string
|
|
39
|
+
tagText?: string | null
|
|
39
40
|
placeholder?: string
|
|
40
41
|
prefix?: string
|
|
41
42
|
suffix?: string
|
|
@@ -81,6 +82,7 @@ export const PktTextinput = forwardRef(
|
|
|
81
82
|
optionalText,
|
|
82
83
|
requiredTag = false,
|
|
83
84
|
requiredText,
|
|
85
|
+
tagText = null,
|
|
84
86
|
placeholder,
|
|
85
87
|
prefix,
|
|
86
88
|
suffix,
|
|
@@ -144,6 +146,7 @@ export const PktTextinput = forwardRef(
|
|
|
144
146
|
optionalText={optionalText}
|
|
145
147
|
requiredTag={requiredTag}
|
|
146
148
|
requiredText={requiredText}
|
|
149
|
+
tagText={tagText}
|
|
147
150
|
useWrapper={useWrapper}
|
|
148
151
|
counter={counter}
|
|
149
152
|
counterCurrent={counterCurrent}
|