@oslokommune/punkt-react 19.19.0 → 19.20.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,19 @@ 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.1...19.20.0) (2026-11-03)
9
+
10
+ ### Features
11
+ * typesikre progressbar (#3796).
12
+
13
+ ---
14
+
15
+
16
+ ## [19.20.0](https://github.com/oslokommune/punkt/compare/19.19.0...19.20.0) (2026-11-03)
17
+
18
+ ---
19
+
20
+
8
21
  ## [19.19.0](https://github.com/oslokommune/punkt/compare/19.18.5...19.19.0) (2026-10-28)
9
22
 
10
23
  ### Features
@@ -1,21 +1,7 @@
1
1
  import { HTMLAttributes, Ref } from 'react';
2
- import { TAriaLive, TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition } from '../../shared-types';
2
+ import { IPktProgressbarBase, TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition } from '../../shared-types';
3
3
  export type { TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition, };
4
- export interface IPktProgressbar extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'title'> {
5
- ariaLabel?: string | null;
6
- ariaLabelledby?: string | null;
7
- ariaLive?: TAriaLive;
8
- ariaValueText?: string | null;
9
- id?: string;
10
- role?: TProgressbarRole;
11
- skin?: TProgressbarSkin;
12
- statusPlacement?: TProgressbarStatusPlacement;
13
- statusType?: TProgressbarStatusType;
14
- title?: string | null;
15
- titlePosition?: TProgressbarTitlePosition;
16
- valueCurrent: number;
17
- valueMax?: number;
18
- valueMin?: number;
4
+ export interface IPktProgressbar extends IPktProgressbarBase, Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'title'> {
19
5
  ref?: Ref<HTMLDivElement>;
20
6
  }
21
7
  export declare const PktProgressbar: import('react').ForwardRefExoticComponent<Omit<IPktProgressbar, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,62 +1,69 @@
1
1
  "use client";
2
2
  import { __toESM as e } from "../../_virtual/_rolldown/runtime.js";
3
- import { require_classnames as t } from "../../node_modules/classnames/index.js";
4
- import { useGeneratedId as n } from "../../hooks/useGeneratedId.js";
5
- import { forwardRef as r, useEffect as i, useRef as a, useState as o } from "react";
6
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
3
+ import { PROGRESSBAR_DEFAULTS as t } from "../../shared-types/progressbar.js";
4
+ import "../../shared-types/index.js";
5
+ import { require_classnames as n } from "../../node_modules/classnames/index.js";
6
+ import { formatString as r } from "../../shared-strings/format.js";
7
+ import { usePktStrings as i } from "../../hooks/usePktStrings.js";
8
+ import { useGeneratedId as a } from "../../hooks/useGeneratedId.js";
9
+ import { forwardRef as o, useEffect as s, useRef as c, useState as l } from "react";
10
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
7
11
  //#region src/components/progressbar/Progressbar.tsx
8
- var l = /* @__PURE__ */ e(t(), 1), u = r(({ ariaLabel: e, ariaLabelledby: t, ariaLive: r = "polite", ariaValueText: u, id: d, role: f = "progressbar", skin: p = "dark-blue", statusPlacement: m = "following", statusType: h = "none", title: g, titlePosition: _ = "left", valueCurrent: v = 0, valueMax: y = 100, valueMin: b = 0, className: x, ...S }, C) => {
9
- let w = n(d), T = a(null), [E, D] = o(0);
10
- i(() => {
11
- T.current && D(T.current.getBoundingClientRect().width || 0);
12
- }, [v]);
13
- let O = y - b, k = Math.round(h === "fraction" ? v / O * 100 : (v - b) / O * 100), A = `${v} av ${O}`, j = h === "fraction" && !u ? `${v} av ${y - b}` : u || void 0, M = e ? void 0 : t || `${w}-title`;
14
- return /* @__PURE__ */ s("div", {
15
- ref: C,
16
- id: w,
17
- role: f,
18
- "aria-live": r,
12
+ var f = /* @__PURE__ */ e(n(), 1), p = o(({ ariaLabel: e, ariaLabelledby: n, ariaLive: o = t.ariaLive, ariaValueText: p, id: m, role: h = t.role, skin: g = t.skin, statusPlacement: _ = t.statusPlacement, statusType: v = t.statusType, title: y, titlePosition: b = t.titlePosition, valueCurrent: x = t.valueCurrent, valueMax: S = t.valueMax, valueMin: C = t.valueMin, strings: w, className: T, ...E }, D) => {
13
+ let O = a(m), k = i(["progressbar"], w), A = c(null), [j, M] = l(0);
14
+ s(() => {
15
+ A.current && M(A.current.getBoundingClientRect().width || 0);
16
+ }, [x]);
17
+ let N = S - C, P = x - C, F = Math.round(P / N * 100), I = r(k.progressbar.fraction, {
18
+ current: P,
19
+ total: N
20
+ }), L = v === "fraction" && !p ? I : p || void 0, R = e ? void 0 : n || `${O}-title`;
21
+ return /* @__PURE__ */ u("div", {
22
+ ref: D,
23
+ id: O,
24
+ role: h,
25
+ "aria-live": o,
19
26
  "aria-atomic": "true",
20
- "aria-valuenow": v,
21
- "aria-valuemin": b,
22
- "aria-valuemax": y,
23
- "aria-valuetext": j,
27
+ "aria-valuenow": x,
28
+ "aria-valuemin": C,
29
+ "aria-valuemax": S,
30
+ "aria-valuetext": L,
24
31
  "aria-label": e || void 0,
25
- "aria-labelledby": M,
26
- className: (0, l.default)("pkt-progressbar", x),
27
- ...S,
28
- children: /* @__PURE__ */ c("div", {
32
+ "aria-labelledby": R,
33
+ className: (0, f.default)("pkt-progressbar", T),
34
+ ...E,
35
+ children: /* @__PURE__ */ d("div", {
29
36
  className: "pkt-progressbar__container",
30
37
  style: {
31
- "--pkt-progress-label-width": `${E}px`,
32
- "--pkt-progress-width": `${k}%`
38
+ "--pkt-progress-label-width": `${j}px`,
39
+ "--pkt-progress-width": `${F}%`
33
40
  },
34
41
  children: [
35
- g && /* @__PURE__ */ s("p", {
36
- id: `${w}-title`,
37
- className: (0, l.default)("pkt-progressbar__title", { "pkt-progressbar__title-center": _ === "center" }),
38
- children: g
42
+ y && /* @__PURE__ */ u("p", {
43
+ id: `${O}-title`,
44
+ className: (0, f.default)("pkt-progressbar__title", { "pkt-progressbar__title-center": b === "center" }),
45
+ children: y
39
46
  }),
40
- /* @__PURE__ */ s("div", {
47
+ /* @__PURE__ */ u("div", {
41
48
  className: "pkt-progressbar__bar-wrapper",
42
- children: /* @__PURE__ */ s("div", { className: (0, l.default)("pkt-progressbar__bar", `pkt-progressbar__bar--${p}`) })
49
+ children: /* @__PURE__ */ u("div", { className: (0, f.default)("pkt-progressbar__bar", `pkt-progressbar__bar--${g}`) })
43
50
  }),
44
- h !== "none" && /* @__PURE__ */ s("div", {
45
- className: (0, l.default)("pkt-progressbar__status", { "pkt-progressbar__status--center": m === "center" }),
46
- children: /* @__PURE__ */ s("span", {
47
- ref: T,
48
- className: (0, l.default)({
49
- "pkt-progressbar__status-placement--following": m === "following",
50
- "pkt-progressbar__status-placement--center": m === "center",
51
- "pkt-progressbar__status-placement--left": m === "left"
51
+ v !== "none" && /* @__PURE__ */ u("div", {
52
+ className: (0, f.default)("pkt-progressbar__status", { "pkt-progressbar__status--center": _ === "center" }),
53
+ children: /* @__PURE__ */ u("span", {
54
+ ref: A,
55
+ className: (0, f.default)({
56
+ "pkt-progressbar__status-placement--following": _ === "following",
57
+ "pkt-progressbar__status-placement--center": _ === "center",
58
+ "pkt-progressbar__status-placement--left": _ === "left"
52
59
  }),
53
- children: h === "percentage" ? `${k}%` : A
60
+ children: v === "percentage" ? `${F}%` : I
54
61
  })
55
62
  })
56
63
  ]
57
64
  })
58
65
  });
59
66
  });
60
- u.displayName = "PktProgressbar";
67
+ p.displayName = "PktProgressbar";
61
68
  //#endregion
62
- export { u as PktProgressbar };
69
+ export { p as PktProgressbar };
@@ -1,47 +1,17 @@
1
1
  import { ChangeEventHandler, InputHTMLAttributes, ReactNode } from 'react';
2
- import { IPktStringsProps } from '../../shared-strings';
3
- export interface IPktTextinput extends InputHTMLAttributes<HTMLInputElement>, IPktStringsProps<'forms' | 'validation'> {
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
- ariaDescribedby?: string;
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
- helptextDropdownButton?: string;
17
- iconNameRight?: string;
18
- inline?: boolean;
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 { PktIcon as e } from "../icon/Icon.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, jsxs as s } from "react/jsx-runtime";
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 c = i(({ id: i, ariaDescribedby: c, ariaLabelledby: ee, autocomplete: te = "off", counter: l, hasFieldset: u, counterMaxLength: d, className: f, disabled: p = !1, errorMessage: m, hasError: h = !1, helptext: g, helptextDropdown: ne, helptextDropdownButton: re, iconNameRight: _, inline: ie = !1, fullwidth: v = !1, label: y, name: b, optionalTag: x = !1, optionalText: S, requiredTag: C = !1, requiredText: w, tagText: T = null, placeholder: E, prefix: D, suffix: O, type: k = "text", useWrapper: A = !0, omitSearchIcon: j = !1, value: M, minLength: N, maxLength: P, min: F, max: I, step: ae, size: L, readonly: R, required: z, dataTestid: B, onChange: V, skipForwardTestid: H = !1, inputSize: U = "medium", strings: W, ...G }, K) => {
10
- let q = l ?? (d ?? 0) > 0, J = [f, "pkt-textinput"].filter(Boolean).join(" "), Y = k === "search" && !_ && !j, oe = k === "date" && M ? M.slice(0, 10) : M, [se, ce] = a(0), X = M === void 0 ? se : M?.length || 0, Z = t(i), Q = `${Z}`, le = `${Q}-label`, $ = ee || le, ue = (e) => {
11
- q && ce(e.currentTarget?.value?.length || 0), V && V(e);
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__ */ o("div", {
14
- className: J,
15
- children: /* @__PURE__ */ o(r, {
16
- strings: W,
17
- ariaDescribedby: c,
18
- disabled: p,
19
- errorMessage: m,
20
- forId: Q,
21
- hasError: h,
22
- helptext: g,
23
- helptextDropdown: ne,
24
- helptextDropdownButton: re,
25
- inline: ie,
26
- label: y,
27
- optionalTag: x,
28
- optionalText: S,
29
- requiredTag: C,
30
- requiredText: w,
31
- tagText: T,
32
- useWrapper: A,
33
- counter: q,
34
- counterCurrent: X,
35
- counterMaxLength: d,
36
- hasFieldset: u ?? !1,
37
- size: U,
38
- children: /* @__PURE__ */ s("div", {
39
- className: `pkt-input__container pkt-input__container--${U}`,
40
- "data-testid": B,
41
- "data-skip-forward-testid": H ? "true" : void 0,
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
- D && /* @__PURE__ */ o("div", {
45
+ k && /* @__PURE__ */ a("div", {
44
46
  className: "pkt-input-prefix",
45
- children: D
47
+ children: k
46
48
  }),
47
- /* @__PURE__ */ o("input", {
48
- ...G,
49
- ref: K,
50
- className: `pkt-input pkt-input--${U} ${v ? "pkt-input--fullwidth" : ""} ${d && X > d ? "pkt-input--counter-error" : ""}`,
51
- type: k,
52
- name: `${b || Z}`,
53
- value: oe,
54
- id: Q,
55
- placeholder: E,
56
- autoComplete: te,
57
- disabled: p,
58
- "aria-invalid": h,
59
- "aria-errormessage": h ? `${Z}-error` : void 0,
60
- "aria-describedby": n({
61
- id: Q,
62
- hasHelptext: !!g,
63
- hasCounter: q,
64
- ariaDescribedby: c
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: F,
68
- max: I,
69
- onChange: ue,
70
- step: ae,
71
- minLength: N,
72
- maxLength: P,
73
- size: L,
74
- readOnly: R,
75
- required: z
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
- O && /* @__PURE__ */ s("p", {
79
+ A && /* @__PURE__ */ o("p", {
78
80
  className: "pkt-input-suffix",
79
81
  children: [
80
- O,
81
- _ && /* @__PURE__ */ o(e, {
82
+ A,
83
+ v && /* @__PURE__ */ a(t, {
82
84
  className: "pkt-input-suffix-icon",
83
- name: _
85
+ name: v
84
86
  }),
85
- Y && /* @__PURE__ */ o(e, {
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
- !O && _ && /* @__PURE__ */ o(e, {
93
+ !A && v && /* @__PURE__ */ a(t, {
92
94
  className: "pkt-input-icon",
93
- name: _
95
+ name: v
94
96
  }),
95
- !O && Y && /* @__PURE__ */ o(e, {
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
- c.displayName = "PktTextinput";
106
+ s.displayName = "PktTextinput";
105
107
  //#endregion
106
- export { c as PktTextinput };
108
+ export { s as PktTextinput };