@oslokommune/punkt-react 19.17.1 → 19.18.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 CHANGED
@@ -5,6 +5,11 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [19.18.0](https://github.com/oslokommune/punkt/compare/19.17.1...19.18.0) (2026-10-20)
9
+
10
+ ---
11
+
12
+
8
13
  ## [19.17.1](https://github.com/oslokommune/punkt/compare/19.17.0...19.17.1) (2026-10-20)
9
14
 
10
15
  ### Bug Fixes
@@ -54,6 +54,7 @@ export { PktTabs } from './tabs/Tabs';
54
54
  export { PktTabItem } from './tabs/TabItem';
55
55
  export { PktTag } from './tag/Tag';
56
56
  export { PktTextarea } from './textarea/Textarea';
57
+ export type { IPktTextarea } from './textarea/Textarea';
57
58
  export { PktTextinput } from './textinput/Textinput';
58
59
  export { PktTimepicker } from './timepicker/Timepicker';
59
60
  export * from './interfaces';
@@ -1,39 +1,14 @@
1
1
  import { ChangeEventHandler, ReactNode, TextareaHTMLAttributes } from 'react';
2
- import { TPktInputSize } from '../../shared-types/size';
3
- import { IPktStringsProps } from '../../shared-strings';
4
- export interface IPktTextarea extends TextareaHTMLAttributes<HTMLTextAreaElement>, IPktStringsProps<'forms' | 'validation'> {
2
+ import { IPktTextareaBase } from '../../shared-types';
3
+ export interface IPktTextarea extends Omit<IPktTextareaBase, 'helptext' | 'helptextDropdown' | 'errorMessage'>, Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, keyof IPktTextareaBase> {
5
4
  id: string;
6
- ariaDescribedby?: string;
7
- ariaLabelledby?: 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
- helptextDropdownButton?: string;
17
- inline?: boolean;
18
- fullwidth?: boolean;
19
- label: string;
20
- name?: string;
21
- optionalTag?: boolean;
22
- optionalText?: string;
23
- requiredTag?: boolean;
24
- requiredText?: string;
25
- tagText?: string | null;
26
- placeholder?: string;
27
- rows?: number;
28
- useWrapper?: boolean;
29
- value?: string;
9
+ /** @deprecated Bruk `autoComplete`. */
30
10
  autocomplete?: string;
31
- minLength?: number;
32
- maxLength?: number;
33
- readOnly?: boolean;
34
- required?: boolean;
35
11
  skipForwardTestid?: boolean;
36
- inputSize?: TPktInputSize;
37
12
  onChange?: ChangeEventHandler<HTMLTextAreaElement>;
38
13
  }
39
14
  export declare const PktTextarea: import('react').ForwardRefExoticComponent<IPktTextarea & import('react').RefAttributes<HTMLTextAreaElement>>;
@@ -1,74 +1,75 @@
1
1
  "use client";
2
- import { useGeneratedId as e } from "../../hooks/useGeneratedId.js";
3
- import { describedByIds as t } from "../../shared-utils/forms/described-by.js";
4
- import { PktInputWrapper as n } from "../inputwrapper/InputWrapper.js";
5
- import { forwardRef as r, useState as i } from "react";
6
- import { jsx as a } from "react/jsx-runtime";
2
+ import { TEXTAREA_DEFAULTS as e } from "../../shared-types/textarea.js";
3
+ import { useGeneratedId as t } from "../../hooks/useGeneratedId.js";
4
+ import { describedByIds as n } from "../../shared-utils/forms/described-by.js";
5
+ import { PktInputWrapper as r } from "../inputwrapper/InputWrapper.js";
6
+ import { forwardRef as i, useState as a } from "react";
7
+ import { jsx as o } from "react/jsx-runtime";
7
8
  //#region src/components/textarea/Textarea.tsx
8
- var o = r(({ id: r, ariaDescribedby: o, ariaLabelledby: s, counter: c, hasFieldset: l, counterMaxLength: u, className: d, disabled: f, errorMessage: p, hasError: m = !1, helptext: h, helptextDropdown: g, helptextDropdownButton: _, inline: v, fullwidth: y = !1, label: b, name: x, optionalTag: S = !1, optionalText: C, requiredTag: w = !1, requiredText: T, tagText: E = null, placeholder: D, rows: O, useWrapper: k = !0, onChange: A, value: j, autoComplete: M = "off", minLength: N, maxLength: P, readOnly: F, skipForwardTestid: I = !1, inputSize: L = "medium", strings: R, ...z }, B) => {
9
- let V = c ?? (u ?? 0) > 0, H = [
10
- d,
9
+ var s = i(({ id: i, ariaDescribedby: s, ariaLabelledby: c, counter: l, hasFieldset: u, counterMaxLength: d, className: f, disabled: p, errorMessage: m, hasError: h = e.hasError, helptext: g, helptextDropdown: _, helptextDropdownButton: v, inline: y, 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, rows: k, useWrapper: A = e.useWrapper, onChange: j, value: M, autoComplete: N, autocomplete: P, minLength: F, maxLength: I, readOnly: L, skipForwardTestid: R = !1, inputSize: z = e.inputSize, strings: B, ...V }, H) => {
10
+ let U = l ?? (d ?? 0) > 0, W = [
11
+ f,
11
12
  "pkt-textinput",
12
13
  "pkt-textarea"
13
- ].filter(Boolean).join(" "), U = e(r), W = `${U}-input`, G = `${W}-label`, K = s || G, [q, J] = i(0), Y = j === void 0 ? q : j?.length || 0, X = (e) => {
14
- V && J(e.currentTarget?.value?.length || 0), A && A(e);
14
+ ].filter(Boolean).join(" "), G = t(i), K = `${G}-input`, q = `${K}-label`, J = c || q, [Y, X] = a(0), Z = M === void 0 ? Y : M?.length || 0, Q = (e) => {
15
+ U && X(e.currentTarget?.value?.length || 0), j && j(e);
15
16
  };
16
- return /* @__PURE__ */ a("div", {
17
- className: H,
18
- children: /* @__PURE__ */ a(n, {
19
- strings: R,
20
- ariaDescribedby: o,
21
- disabled: f,
22
- errorMessage: p,
23
- forId: W,
24
- hasError: m,
25
- helptext: h,
26
- helptextDropdown: g,
27
- helptextDropdownButton: _,
28
- inline: v,
29
- label: b,
30
- optionalTag: S,
31
- optionalText: C,
32
- requiredTag: w,
33
- requiredText: T,
34
- tagText: E,
35
- useWrapper: k,
36
- counter: V,
37
- counterCurrent: Y,
38
- counterMaxLength: u,
39
- hasFieldset: l ?? !1,
40
- size: L,
41
- children: /* @__PURE__ */ a("textarea", {
17
+ return /* @__PURE__ */ o("div", {
18
+ className: W,
19
+ children: /* @__PURE__ */ o(r, {
20
+ strings: B,
21
+ ariaDescribedby: s,
22
+ disabled: p,
23
+ errorMessage: m,
24
+ forId: K,
25
+ hasError: h,
26
+ helptext: g,
27
+ helptextDropdown: _,
28
+ helptextDropdownButton: v,
29
+ inline: y,
30
+ label: x,
31
+ optionalTag: C,
32
+ optionalText: w,
33
+ requiredTag: T,
34
+ requiredText: E,
35
+ tagText: D,
36
+ useWrapper: A,
37
+ counter: U,
38
+ counterCurrent: Z,
39
+ counterMaxLength: d,
40
+ hasFieldset: u ?? !1,
41
+ size: z,
42
+ children: /* @__PURE__ */ o("textarea", {
42
43
  ref: (e) => {
43
- J(e?.value?.length || 0), typeof B == "function" ? B(e) : B && (B.current = e);
44
+ X(e?.value?.length || 0), typeof H == "function" ? H(e) : H && (H.current = e);
44
45
  },
45
- className: `pkt-input pkt-input--${L} ${y ? "pkt-input--fullwidth" : ""} ${u && Y > u ? "pkt-input--counter-error" : ""}`,
46
- name: `${x || U}`,
47
- id: W,
48
- placeholder: D,
49
- disabled: f,
50
- rows: O,
51
- "aria-labelledby": K,
52
- "aria-invalid": m,
53
- "aria-errormessage": m ? `${U}-error` : void 0,
54
- "aria-describedby": t({
55
- id: W,
56
- hasHelptext: !!h,
57
- hasCounter: V,
58
- ariaDescribedby: o
46
+ className: `pkt-input pkt-input--${z} ${b ? "pkt-input--fullwidth" : ""} ${d && Z > d ? "pkt-input--counter-error" : ""}`,
47
+ name: `${S || G}`,
48
+ id: K,
49
+ placeholder: O,
50
+ disabled: p,
51
+ rows: k,
52
+ "aria-labelledby": J,
53
+ "aria-invalid": h,
54
+ "aria-errormessage": h ? `${K}-error` : void 0,
55
+ "aria-describedby": n({
56
+ id: K,
57
+ hasHelptext: !!g,
58
+ hasCounter: U,
59
+ ariaDescribedby: s
59
60
  }),
60
- ...z,
61
- onChange: X,
62
- value: j,
63
- autoComplete: M,
64
- minLength: N,
65
- maxLength: P,
66
- readOnly: F,
67
- "data-skip-forward-testid": I ? "true" : void 0
61
+ ...V,
62
+ onChange: Q,
63
+ value: M,
64
+ autoComplete: N ?? P ?? e.autoComplete,
65
+ minLength: F,
66
+ maxLength: I,
67
+ readOnly: L,
68
+ "data-skip-forward-testid": R ? "true" : void 0
68
69
  })
69
70
  })
70
71
  });
71
72
  });
72
- o.displayName = "PktTextarea";
73
+ s.displayName = "PktTextarea";
73
74
  //#endregion
74
- export { o as PktTextarea };
75
+ export { s as PktTextarea };