@oslokommune/punkt-react 19.19.1 → 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 +8 -0
- package/dist/components/progressbar/Progressbar.d.ts +2 -16
- package/dist/components/progressbar/Progressbar.js +49 -42
- package/dist/punkt-react.cjs +1 -1
- package/dist/shared-strings/nb.d.ts +3 -0
- package/dist/shared-strings/nb.js +1 -0
- package/dist/shared-types/index.d.ts +2 -1
- package/dist/shared-types/index.js +4 -3
- package/dist/shared-types/progressbar.d.ts +82 -5
- package/dist/shared-types/progressbar.js +14 -0
- package/package.json +2 -2
- package/src/components/progressbar/Progressbar.test.tsx +25 -0
- package/src/components/progressbar/Progressbar.tsx +30 -40
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ 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
|
+
|
|
8
16
|
## [19.20.0](https://github.com/oslokommune/punkt/compare/19.19.0...19.20.0) (2026-11-03)
|
|
9
17
|
|
|
10
18
|
---
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
import { HTMLAttributes, Ref } from 'react';
|
|
2
|
-
import {
|
|
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 {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, [
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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":
|
|
21
|
-
"aria-valuemin":
|
|
22
|
-
"aria-valuemax":
|
|
23
|
-
"aria-valuetext":
|
|
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":
|
|
26
|
-
className: (0,
|
|
27
|
-
...
|
|
28
|
-
children: /* @__PURE__ */
|
|
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": `${
|
|
32
|
-
"--pkt-progress-width": `${
|
|
38
|
+
"--pkt-progress-label-width": `${j}px`,
|
|
39
|
+
"--pkt-progress-width": `${F}%`
|
|
33
40
|
},
|
|
34
41
|
children: [
|
|
35
|
-
|
|
36
|
-
id: `${
|
|
37
|
-
className: (0,
|
|
38
|
-
children:
|
|
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__ */
|
|
47
|
+
/* @__PURE__ */ u("div", {
|
|
41
48
|
className: "pkt-progressbar__bar-wrapper",
|
|
42
|
-
children: /* @__PURE__ */
|
|
49
|
+
children: /* @__PURE__ */ u("div", { className: (0, f.default)("pkt-progressbar__bar", `pkt-progressbar__bar--${g}`) })
|
|
43
50
|
}),
|
|
44
|
-
|
|
45
|
-
className: (0,
|
|
46
|
-
children: /* @__PURE__ */
|
|
47
|
-
ref:
|
|
48
|
-
className: (0,
|
|
49
|
-
"pkt-progressbar__status-placement--following":
|
|
50
|
-
"pkt-progressbar__status-placement--center":
|
|
51
|
-
"pkt-progressbar__status-placement--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:
|
|
60
|
+
children: v === "percentage" ? `${F}%` : I
|
|
54
61
|
})
|
|
55
62
|
})
|
|
56
63
|
]
|
|
57
64
|
})
|
|
58
65
|
});
|
|
59
66
|
});
|
|
60
|
-
|
|
67
|
+
p.displayName = "PktProgressbar";
|
|
61
68
|
//#endregion
|
|
62
|
-
export {
|
|
69
|
+
export { p as PktProgressbar };
|