@oslokommune/punkt-react 19.19.0 → 19.19.1
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 +5 -0
- package/dist/components/textinput/Textinput.d.ts +6 -36
- package/dist/components/textinput/Textinput.js +80 -78
- package/dist/punkt-react.cjs +1 -1
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/shared-types/index.js +5 -4
- package/dist/shared-types/textinput.d.ts +82 -0
- package/dist/shared-types/textinput.js +18 -0
- package/package.json +2 -2
- package/src/components/textinput/Textinput.test.tsx +26 -0
- package/src/components/textinput/Textinput.tsx +26 -51
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [19.20.0](https://github.com/oslokommune/punkt/compare/19.19.0...19.20.0) (2026-11-03)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
|
|
8
13
|
## [19.19.0](https://github.com/oslokommune/punkt/compare/19.18.5...19.19.0) (2026-10-28)
|
|
9
14
|
|
|
10
15
|
### Features
|
|
@@ -1,47 +1,17 @@
|
|
|
1
1
|
import { ChangeEventHandler, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export interface IPktTextinput extends
|
|
2
|
+
import { IPktTextinputBase } from '../../shared-types';
|
|
3
|
+
export interface IPktTextinput extends Omit<IPktTextinputBase, 'helptext' | 'helptextDropdown' | 'errorMessage'>, Omit<InputHTMLAttributes<HTMLInputElement>, keyof IPktTextinputBase> {
|
|
4
4
|
id: string;
|
|
5
|
-
|
|
6
|
-
ariaLabelledby?: string;
|
|
7
|
-
autocomplete?: string;
|
|
8
|
-
counter?: boolean;
|
|
9
|
-
hasFieldset?: boolean;
|
|
10
|
-
counterMaxLength?: number;
|
|
11
|
-
disabled?: boolean;
|
|
5
|
+
label: string;
|
|
12
6
|
errorMessage?: string | ReactNode | ReactNode[];
|
|
13
|
-
hasError?: boolean;
|
|
14
7
|
helptext?: string | ReactNode | ReactNode[];
|
|
15
8
|
helptextDropdown?: string | ReactNode | ReactNode[];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
fullwidth?: boolean;
|
|
20
|
-
label: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
optionalTag?: boolean;
|
|
23
|
-
optionalText?: string;
|
|
24
|
-
requiredTag?: boolean;
|
|
25
|
-
requiredText?: string;
|
|
26
|
-
tagText?: string | null;
|
|
27
|
-
placeholder?: string;
|
|
28
|
-
prefix?: string;
|
|
29
|
-
suffix?: string;
|
|
30
|
-
type?: string;
|
|
31
|
-
useWrapper?: boolean;
|
|
32
|
-
value?: string;
|
|
33
|
-
omitSearchIcon?: boolean;
|
|
34
|
-
min?: number | string;
|
|
35
|
-
max?: number | string;
|
|
36
|
-
minLength?: number;
|
|
37
|
-
maxLength?: number;
|
|
38
|
-
step?: string;
|
|
39
|
-
size?: number;
|
|
9
|
+
/** @deprecated Bruk `autoComplete`. */
|
|
10
|
+
autocomplete?: string;
|
|
11
|
+
/** @deprecated Bruk `readOnly`. */
|
|
40
12
|
readonly?: boolean;
|
|
41
|
-
required?: boolean;
|
|
42
13
|
dataTestid?: string;
|
|
43
14
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
44
15
|
skipForwardTestid?: boolean;
|
|
45
|
-
inputSize?: 'small' | 'medium' | 'xsmall';
|
|
46
16
|
}
|
|
47
17
|
export declare const PktTextinput: import('react').ForwardRefExoticComponent<IPktTextinput & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,98 +1,100 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { TEXTINPUT_DEFAULTS as e } from "../../shared-types/textinput.js";
|
|
3
|
+
import "../../shared-types/index.js";
|
|
4
|
+
import { PktIcon as t } from "../icon/Icon.js";
|
|
5
|
+
import { useGeneratedId as n } from "../../hooks/useGeneratedId.js";
|
|
6
|
+
import { describedByIds as ee } from "../../shared-utils/forms/described-by.js";
|
|
7
|
+
import { PktInputWrapper as te } from "../inputwrapper/InputWrapper.js";
|
|
8
|
+
import { forwardRef as r, useState as i } from "react";
|
|
9
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
8
10
|
//#region src/components/textinput/Textinput.tsx
|
|
9
|
-
var
|
|
10
|
-
let
|
|
11
|
-
|
|
11
|
+
var s = r(({ id: r, ariaDescribedby: s, ariaLabelledby: c, autoComplete: l, autocomplete: u, counter: d, hasFieldset: ne, counterMaxLength: f, className: p, disabled: m = e.disabled, errorMessage: h, hasError: g = e.hasError, helptext: _, helptextDropdown: re, helptextDropdownButton: ie, iconNameRight: v, inline: y = e.inline, fullwidth: b = e.fullwidth, label: x, name: S, optionalTag: C = e.optionalTag, optionalText: w, requiredTag: T = e.requiredTag, requiredText: E, tagText: D = null, placeholder: O, prefix: k, suffix: A, type: j = e.type, useWrapper: M = e.useWrapper, omitSearchIcon: N = e.omitSearchIcon, value: P, minLength: F, maxLength: I, min: L, max: ae, step: R, size: z, readOnly: B, readonly: V, required: H = e.required, dataTestid: U, onChange: W, skipForwardTestid: G = !1, inputSize: K = e.inputSize, strings: q, ...J }, oe) => {
|
|
12
|
+
let Y = d ?? (f ?? 0) > 0, se = [p, "pkt-textinput"].filter(Boolean).join(" "), X = j === "search" && !v && !N, ce = j === "date" && P ? P.slice(0, 10) : P, [le, ue] = i(0), Z = P === void 0 ? le : P?.length || 0, Q = n(r), $ = `${Q}`, de = `${$}-label`, fe = c || de, pe = (e) => {
|
|
13
|
+
Y && ue(e.currentTarget?.value?.length || 0), W && W(e);
|
|
12
14
|
};
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
className:
|
|
15
|
-
children: /* @__PURE__ */
|
|
16
|
-
strings:
|
|
17
|
-
ariaDescribedby:
|
|
18
|
-
disabled:
|
|
19
|
-
errorMessage:
|
|
20
|
-
forId:
|
|
21
|
-
hasError:
|
|
22
|
-
helptext:
|
|
23
|
-
helptextDropdown:
|
|
24
|
-
helptextDropdownButton:
|
|
25
|
-
inline:
|
|
26
|
-
label:
|
|
27
|
-
optionalTag:
|
|
28
|
-
optionalText:
|
|
29
|
-
requiredTag:
|
|
30
|
-
requiredText:
|
|
31
|
-
tagText:
|
|
32
|
-
useWrapper:
|
|
33
|
-
counter:
|
|
34
|
-
counterCurrent:
|
|
35
|
-
counterMaxLength:
|
|
36
|
-
hasFieldset:
|
|
37
|
-
size:
|
|
38
|
-
children: /* @__PURE__ */
|
|
39
|
-
className: `pkt-input__container pkt-input__container--${
|
|
40
|
-
"data-testid":
|
|
41
|
-
"data-skip-forward-testid":
|
|
15
|
+
return /* @__PURE__ */ a("div", {
|
|
16
|
+
className: se,
|
|
17
|
+
children: /* @__PURE__ */ a(te, {
|
|
18
|
+
strings: q,
|
|
19
|
+
ariaDescribedby: s,
|
|
20
|
+
disabled: m,
|
|
21
|
+
errorMessage: h,
|
|
22
|
+
forId: $,
|
|
23
|
+
hasError: g,
|
|
24
|
+
helptext: _,
|
|
25
|
+
helptextDropdown: re,
|
|
26
|
+
helptextDropdownButton: ie,
|
|
27
|
+
inline: y,
|
|
28
|
+
label: x,
|
|
29
|
+
optionalTag: C,
|
|
30
|
+
optionalText: w,
|
|
31
|
+
requiredTag: T,
|
|
32
|
+
requiredText: E,
|
|
33
|
+
tagText: D,
|
|
34
|
+
useWrapper: M,
|
|
35
|
+
counter: Y,
|
|
36
|
+
counterCurrent: Z,
|
|
37
|
+
counterMaxLength: f,
|
|
38
|
+
hasFieldset: ne ?? !1,
|
|
39
|
+
size: K,
|
|
40
|
+
children: /* @__PURE__ */ o("div", {
|
|
41
|
+
className: `pkt-input__container pkt-input__container--${K}`,
|
|
42
|
+
"data-testid": U,
|
|
43
|
+
"data-skip-forward-testid": G ? "true" : void 0,
|
|
42
44
|
children: [
|
|
43
|
-
|
|
45
|
+
k && /* @__PURE__ */ a("div", {
|
|
44
46
|
className: "pkt-input-prefix",
|
|
45
|
-
children:
|
|
47
|
+
children: k
|
|
46
48
|
}),
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
...
|
|
49
|
-
ref:
|
|
50
|
-
className: `pkt-input pkt-input--${
|
|
51
|
-
type:
|
|
52
|
-
name: `${
|
|
53
|
-
value:
|
|
54
|
-
id:
|
|
55
|
-
placeholder:
|
|
56
|
-
autoComplete:
|
|
57
|
-
disabled:
|
|
58
|
-
"aria-invalid":
|
|
59
|
-
"aria-errormessage":
|
|
60
|
-
"aria-describedby":
|
|
61
|
-
id:
|
|
62
|
-
hasHelptext: !!
|
|
63
|
-
hasCounter:
|
|
64
|
-
ariaDescribedby:
|
|
49
|
+
/* @__PURE__ */ a("input", {
|
|
50
|
+
...J,
|
|
51
|
+
ref: oe,
|
|
52
|
+
className: `pkt-input pkt-input--${K} ${b ? "pkt-input--fullwidth" : ""} ${f && Z > f ? "pkt-input--counter-error" : ""}`,
|
|
53
|
+
type: j,
|
|
54
|
+
name: `${S || Q}`,
|
|
55
|
+
value: ce,
|
|
56
|
+
id: $,
|
|
57
|
+
placeholder: O,
|
|
58
|
+
autoComplete: l ?? u ?? e.autoComplete,
|
|
59
|
+
disabled: m,
|
|
60
|
+
"aria-invalid": g,
|
|
61
|
+
"aria-errormessage": g ? `${Q}-error` : void 0,
|
|
62
|
+
"aria-describedby": ee({
|
|
63
|
+
id: $,
|
|
64
|
+
hasHelptext: !!_,
|
|
65
|
+
hasCounter: Y,
|
|
66
|
+
ariaDescribedby: s
|
|
65
67
|
}),
|
|
66
|
-
"aria-labelledby":
|
|
67
|
-
min:
|
|
68
|
-
max:
|
|
69
|
-
onChange:
|
|
70
|
-
step:
|
|
71
|
-
minLength:
|
|
72
|
-
maxLength:
|
|
73
|
-
size:
|
|
74
|
-
readOnly:
|
|
75
|
-
required:
|
|
68
|
+
"aria-labelledby": fe,
|
|
69
|
+
min: L,
|
|
70
|
+
max: ae,
|
|
71
|
+
onChange: pe,
|
|
72
|
+
step: R,
|
|
73
|
+
minLength: F,
|
|
74
|
+
maxLength: I,
|
|
75
|
+
size: z,
|
|
76
|
+
readOnly: B ?? V ?? e.readOnly,
|
|
77
|
+
required: H
|
|
76
78
|
}),
|
|
77
|
-
|
|
79
|
+
A && /* @__PURE__ */ o("p", {
|
|
78
80
|
className: "pkt-input-suffix",
|
|
79
81
|
children: [
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
A,
|
|
83
|
+
v && /* @__PURE__ */ a(t, {
|
|
82
84
|
className: "pkt-input-suffix-icon",
|
|
83
|
-
name:
|
|
85
|
+
name: v
|
|
84
86
|
}),
|
|
85
|
-
|
|
87
|
+
X && /* @__PURE__ */ a(t, {
|
|
86
88
|
className: "pkt-input-suffix-icon",
|
|
87
89
|
name: "magnifying-glass-big"
|
|
88
90
|
})
|
|
89
91
|
]
|
|
90
92
|
}),
|
|
91
|
-
!
|
|
93
|
+
!A && v && /* @__PURE__ */ a(t, {
|
|
92
94
|
className: "pkt-input-icon",
|
|
93
|
-
name:
|
|
95
|
+
name: v
|
|
94
96
|
}),
|
|
95
|
-
!
|
|
97
|
+
!A && X && /* @__PURE__ */ a(t, {
|
|
96
98
|
className: "pkt-input-icon",
|
|
97
99
|
name: "magnifying-glass-big"
|
|
98
100
|
})
|
|
@@ -101,6 +103,6 @@ var c = i(({ id: i, ariaDescribedby: c, ariaLabelledby: ee, autocomplete: te = "
|
|
|
101
103
|
})
|
|
102
104
|
});
|
|
103
105
|
});
|
|
104
|
-
|
|
106
|
+
s.displayName = "PktTextinput";
|
|
105
107
|
//#endregion
|
|
106
|
-
export {
|
|
108
|
+
export { s as PktTextinput };
|