@oslokommune/punkt-react 19.16.2 → 19.17.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.17.0](https://github.com/oslokommune/punkt/compare/19.16.2...19.17.0) (2026-10-20)
9
+
10
+ ---
11
+
12
+
8
13
  ## [19.16.1](https://github.com/oslokommune/punkt/compare/19.16.0...19.16.1) (2026-10-19)
9
14
 
10
15
  ### Bug Fixes
@@ -26,6 +26,7 @@ export { PktHelptext } from './helptext/Helptext';
26
26
  export { PktIcon } from './icon/Icon';
27
27
  export { PktInput } from './input/Input';
28
28
  export { PktInputWrapper } from './inputwrapper/InputWrapper';
29
+ export type { IPktInputWrapper } from './inputwrapper/InputWrapper';
29
30
  export { PktLink } from './link/Link';
30
31
  export { PktLinkCard } from './linkcard/LinkCard';
31
32
  export { PktLoader } from './loader/Loader';
@@ -1,37 +1,14 @@
1
1
  import { FocusEventHandler, ReactNode, RefAttributes } from 'react';
2
- import { IPktStringsProps } from '../../shared-strings';
3
- import { TLayout } from '../../shared-types';
4
- export interface IPktInputWrapper extends RefAttributes<HTMLElement>, IPktStringsProps<'forms' | 'validation'> {
2
+ import { IPktInputWrapperBase } from '../../shared-types';
3
+ export interface IPktInputWrapper extends Omit<IPktInputWrapperBase, 'helptext' | 'helptextDropdown' | 'errorMessage'>, RefAttributes<HTMLElement> {
5
4
  id?: string;
6
5
  forId: string;
7
6
  label: string;
8
7
  helptext?: string | ReactNode;
9
8
  helptextDropdown?: string | ReactNode;
10
- /** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
11
- helptextDropdownButton?: string;
12
- counter?: boolean;
13
- counterCurrent?: number;
14
- counterMaxLength?: number;
15
- optionalTag?: boolean;
16
- /** @deprecated Bruk `strings={{ forms: { optional: '…' } }}` eller `setPktStrings()`. */
17
- optionalText?: string;
18
- requiredTag?: boolean;
19
- /** @deprecated Bruk `strings={{ forms: { required: '…' } }}` eller `setPktStrings()`. */
20
- requiredText?: string;
21
- tagText?: string | null;
22
- hasError?: boolean;
23
9
  errorMessage?: string | ReactNode;
24
- disabled?: boolean;
25
- inline?: boolean;
26
- ariaDescribedby?: string;
27
- useWrapper?: boolean;
28
10
  children?: ReactNode;
29
11
  className?: string;
30
- hasFieldset?: boolean;
31
- layout?: TLayout;
32
- role?: string;
33
- counterPosition?: 'top' | 'bottom';
34
- size?: 'small' | 'medium' | 'xsmall';
35
12
  onFocus?: FocusEventHandler<HTMLDivElement>;
36
13
  onBlur?: FocusEventHandler<HTMLDivElement>;
37
14
  }
@@ -1,128 +1,129 @@
1
1
  "use client";
2
- import { formatString as e } from "../../shared-strings/format.js";
3
- import { usePktStrings as t } from "../../hooks/usePktStrings.js";
4
- import { PktAlert as n } from "../alert/Alert.js";
5
- import { useGeneratedId as r } from "../../hooks/useGeneratedId.js";
6
- import { useFocusModality as i } from "../../hooks/useFocusModality.js";
7
- import { counterStatusId as a, isCounterExceeded as o } from "../../shared-utils/forms/described-by.js";
8
- import { PktHelptext as s } from "../helptext/Helptext.js";
9
- import { forwardRef as c } from "react";
10
- import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
2
+ import { INPUT_WRAPPER_DEFAULTS as e } from "../../shared-types/input-wrapper.js";
3
+ import { formatString as t } from "../../shared-strings/format.js";
4
+ import { usePktStrings as n } from "../../hooks/usePktStrings.js";
5
+ import { PktAlert as r } from "../alert/Alert.js";
6
+ import { useGeneratedId as i } from "../../hooks/useGeneratedId.js";
7
+ import { useFocusModality as a } from "../../hooks/useFocusModality.js";
8
+ import { counterStatusId as o, isCounterExceeded as s } from "../../shared-utils/forms/described-by.js";
9
+ import { PktHelptext as c } from "../helptext/Helptext.js";
10
+ import { forwardRef as l } from "react";
11
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
11
12
  //#region src/components/inputwrapper/InputWrapper.tsx
12
- var f = c(({ id: c, forId: f, label: p, helptext: m, helptextDropdown: h, helptextDropdownButton: ee, counter: g, counterCurrent: _ = 0, counterMaxLength: v, optionalTag: y = !1, optionalText: b, requiredTag: x = !1, requiredText: S, tagText: C = null, hasError: w = !1, errorMessage: T, disabled: E = !1, inline: D = !1, ariaDescribedby: O, useWrapper: k = !0, children: A, className: j = "", hasFieldset: M = !1, layout: N = "vertical", role: P, counterPosition: F = "bottom", size: I = "medium", strings: L, onFocus: R, onBlur: z }, B) => {
13
- let V = i(B), H = t(["forms", "validation"], L), U = r(f), W = [...new Set([O || (m ? `${U}-helptext` : ""), w && T ? `${U}-error` : ""].join(" ").split(" ").filter(Boolean))].join(" ") || void 0, G = !!g, K = G && F === "top", q = G && F === "bottom", J = [
13
+ var p = l(({ id: l, forId: p, label: m, helptext: h, helptextDropdown: g, helptextDropdownButton: _, counter: v, counterCurrent: y = e.counterCurrent, counterMaxLength: b, optionalTag: x = e.optionalTag, optionalText: S, requiredTag: C = e.requiredTag, requiredText: w, tagText: T = null, hasError: E = e.hasError, errorMessage: D, disabled: O = e.disabled, inline: k = e.inline, ariaDescribedby: ee, useWrapper: A = e.useWrapper, children: j, className: M = "", hasFieldset: N = e.hasFieldset, layout: P = e.layout, role: F, counterPosition: I = e.counterPosition, size: L = e.size, strings: R, onFocus: z, onBlur: B }, V) => {
14
+ let H = a(V), U = n(["forms", "validation"], R), W = i(p), G = [...new Set([ee || (h ? `${W}-helptext` : ""), E && D ? `${W}-error` : ""].join(" ").split(" ").filter(Boolean))].join(" ") || void 0, K = !!v, q = K && I === "top", J = K && I === "bottom", Y = [
14
15
  "pkt-inputwrapper",
15
- j,
16
- w ? "pkt-inputwrapper--error" : "",
17
- E ? "pkt-inputwrapper--disabled" : "",
18
- D ? "pkt-inputwrapper--inline" : "",
19
- I ? `pkt-inputwrapper--${I}` : ""
20
- ].filter(Boolean).join(" "), Y = [
16
+ M,
17
+ E ? "pkt-inputwrapper--error" : "",
18
+ O ? "pkt-inputwrapper--disabled" : "",
19
+ k ? "pkt-inputwrapper--inline" : "",
20
+ L ? `pkt-inputwrapper--${L}` : ""
21
+ ].filter(Boolean).join(" "), X = [
21
22
  "pkt-tag",
22
23
  "pkt-tag--small",
23
24
  "pkt-tag--thin-text"
24
- ].join(" "), X = o(_, v), Z = G ? /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ d("div", {
25
+ ].join(" "), Z = s(y, b), Q = K ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f("div", {
25
26
  className: "pkt-input__counter",
26
27
  "aria-hidden": "true",
27
- children: [_, v ? `/${v}` : ""]
28
- }), /* @__PURE__ */ u("div", {
28
+ children: [y, b ? `/${b}` : ""]
29
+ }), /* @__PURE__ */ d("div", {
29
30
  className: "pkt-sr-only",
30
- id: a(U),
31
+ id: o(W),
31
32
  "aria-live": "polite",
32
- children: X ? e(H.validation.counterExceeded, {
33
- current: _,
34
- max: v ?? 0
33
+ children: Z ? t(U.validation.counterExceeded, {
34
+ current: y,
35
+ max: b ?? 0
35
36
  }) : ""
36
- })] }) : null, Q = () => /* @__PURE__ */ d(l, { children: [
37
- C && /* @__PURE__ */ u("span", {
38
- className: Y + " pkt-tag--gray",
39
- children: C
37
+ })] }) : null, te = () => /* @__PURE__ */ f(u, { children: [
38
+ T && /* @__PURE__ */ d("span", {
39
+ className: X + " pkt-tag--gray",
40
+ children: T
40
41
  }),
41
- y && /* @__PURE__ */ u("span", {
42
- className: Y + " pkt-tag--blue-light",
43
- children: b ?? H.forms.optional
42
+ x && /* @__PURE__ */ d("span", {
43
+ className: X + " pkt-tag--blue-light",
44
+ children: S ?? U.forms.optional
44
45
  }),
45
- x && /* @__PURE__ */ u("span", {
46
- className: Y + " pkt-tag--beige",
47
- children: S ?? H.forms.required
46
+ C && /* @__PURE__ */ d("span", {
47
+ className: X + " pkt-tag--beige",
48
+ children: w ?? U.forms.required
48
49
  })
49
- ] }), te = () => {
50
- let e = /* @__PURE__ */ d(l, { children: [
51
- p,
50
+ ] }), ne = () => {
51
+ let e = /* @__PURE__ */ f(u, { children: [
52
+ m,
52
53
  " ",
53
- Q()
54
+ te()
54
55
  ] });
55
- return !k && M ? /* @__PURE__ */ u("legend", {
56
+ return !A && N ? /* @__PURE__ */ d("legend", {
56
57
  className: "pkt-sr-only",
57
- id: `${U}-label`,
58
- children: p
59
- }) : k ? M ? /* @__PURE__ */ u("legend", {
58
+ id: `${W}-label`,
59
+ children: m
60
+ }) : A ? N ? /* @__PURE__ */ d("legend", {
60
61
  className: "pkt-inputwrapper__legend",
61
- id: `${U}-label`,
62
+ id: `${W}-label`,
62
63
  children: e
63
- }) : /* @__PURE__ */ u("label", {
64
+ }) : /* @__PURE__ */ d("label", {
64
65
  className: "pkt-inputwrapper__label",
65
- htmlFor: U,
66
- id: `${U}-label`,
66
+ htmlFor: W,
67
+ id: `${W}-label`,
67
68
  children: e
68
- }) : /* @__PURE__ */ u("label", {
69
- htmlFor: U,
69
+ }) : /* @__PURE__ */ d("label", {
70
+ htmlFor: W,
70
71
  className: "pkt-sr-only",
71
- id: `${U}-label`,
72
- children: p
72
+ id: `${W}-label`,
73
+ children: m
73
74
  });
74
- }, ne = () => {
75
- let e = k ? m : void 0;
76
- return !e && !h ? null : /* @__PURE__ */ u(s, {
77
- forId: U,
75
+ }, re = () => {
76
+ let e = A ? h : void 0;
77
+ return !e && !g ? null : /* @__PURE__ */ d(c, {
78
+ forId: W,
78
79
  helptext: e,
79
- helptextDropdown: h,
80
- helptextDropdownButton: ee ?? H.forms.readMore
80
+ helptextDropdown: g,
81
+ helptextDropdownButton: _ ?? U.forms.readMore
81
82
  });
82
- }, re = I === "medium" ? "small" : "xsmall", $ = /* @__PURE__ */ d(l, { children: [
83
- te(),
83
+ }, ie = L === "medium" ? "small" : "xsmall", $ = /* @__PURE__ */ f(u, { children: [
84
84
  ne(),
85
- K && Z,
86
- M || N === "horizontal" ? /* @__PURE__ */ u("div", {
87
- className: N === "horizontal" ? "pkt-inputwrapper__options pkt-inputwrapper__options--horizontal" : "pkt-inputwrapper__options",
88
- children: A
89
- }) : A,
90
- q && Z,
91
- w && T && /* @__PURE__ */ u("div", {
85
+ re(),
86
+ q && Q,
87
+ N || P === "horizontal" ? /* @__PURE__ */ d("div", {
88
+ className: P === "horizontal" ? "pkt-inputwrapper__options pkt-inputwrapper__options--horizontal" : "pkt-inputwrapper__options",
89
+ children: j
90
+ }) : j,
91
+ J && Q,
92
+ E && D && /* @__PURE__ */ d("div", {
92
93
  className: "pkt-inputwrapper__alert-wrapper",
93
- children: /* @__PURE__ */ u(n, {
94
+ children: /* @__PURE__ */ d(r, {
94
95
  skin: "error",
95
- size: re,
96
+ size: ie,
96
97
  "aria-live": "assertive",
97
98
  role: "alert",
98
- id: `${U}-error`,
99
- children: T
99
+ id: `${W}-error`,
100
+ children: D
100
101
  })
101
102
  })
102
103
  ] });
103
- return /* @__PURE__ */ u("div", {
104
- id: c,
105
- className: J,
106
- role: P,
107
- "aria-labelledby": P ? `${U}-label` : void 0,
108
- ...V,
104
+ return /* @__PURE__ */ d("div", {
105
+ id: l,
106
+ className: Y,
107
+ role: F,
108
+ "aria-labelledby": F ? `${W}-label` : void 0,
109
+ ...H,
109
110
  onFocus: (e) => {
110
- V.onFocus(), R?.(e);
111
+ H.onFocus(), z?.(e);
111
112
  },
112
113
  onBlur: (e) => {
113
- V.onBlur(e), z?.(e);
114
+ H.onBlur(e), B?.(e);
114
115
  },
115
- children: M ? /* @__PURE__ */ u("fieldset", {
116
+ children: N ? /* @__PURE__ */ d("fieldset", {
116
117
  className: "pkt-inputwrapper__fieldset",
117
- "aria-describedby": W,
118
- disabled: E || void 0,
118
+ "aria-describedby": G,
119
+ disabled: O || void 0,
119
120
  children: $
120
- }) : /* @__PURE__ */ u("div", {
121
+ }) : /* @__PURE__ */ d("div", {
121
122
  className: "pkt-inputwrapper__fieldset",
122
123
  children: $
123
124
  })
124
125
  });
125
126
  });
126
- f.displayName = "PktInputWrapper";
127
+ p.displayName = "PktInputWrapper";
127
128
  //#endregion
128
- export { f as PktInputWrapper };
129
+ export { p as PktInputWrapper };