@kopexa/grc 0.0.21 → 0.0.24
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/dist/chunk-VQUPRJG7.mjs +41 -0
- package/dist/common/impact/impact-badge.d.mts +26 -0
- package/dist/common/impact/impact-badge.d.ts +26 -0
- package/dist/common/impact/impact-badge.js +348 -0
- package/dist/common/impact/impact-badge.mjs +10 -0
- package/dist/common/impact/index.d.mts +1 -0
- package/dist/common/impact/index.d.ts +1 -0
- package/dist/common/impact/index.js +79 -44
- package/dist/common/impact/index.mjs +5 -1
- package/dist/common/index.d.mts +1 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +95 -60
- package/dist/common/index.mjs +17 -13
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +139 -104
- package/dist/index.mjs +17 -13
- package/package.json +8 -8
- package/src/common/impact/impact-badge.tsx +72 -0
- package/src/common/impact/index.ts +2 -0
- /package/dist/{chunk-GFABGXAO.mjs → chunk-4DMM2HCE.mjs} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kopexa/grc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "GRC (Governance, Risk, Compliance) components for Kopexa",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"react": ">=19.0.0-rc.0",
|
|
43
43
|
"react-dom": ">=19.0.0-rc.0",
|
|
44
44
|
"react-intl": "^7.1.14",
|
|
45
|
-
"@kopexa/
|
|
46
|
-
"@kopexa/
|
|
47
|
-
"@kopexa/
|
|
45
|
+
"@kopexa/sight": "17.6.5",
|
|
46
|
+
"@kopexa/theme": "17.18.0",
|
|
47
|
+
"@kopexa/tiptap": "17.6.7"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@kopexa/krn": "^1.0.1",
|
|
51
|
-
"@kopexa/react-utils": "17.0.
|
|
52
|
-
"@kopexa/shared-utils": "17.0.
|
|
53
|
-
"@kopexa/
|
|
54
|
-
"@kopexa/
|
|
51
|
+
"@kopexa/react-utils": "17.0.34",
|
|
52
|
+
"@kopexa/shared-utils": "17.0.34",
|
|
53
|
+
"@kopexa/icons": "17.6.0",
|
|
54
|
+
"@kopexa/i18n": "17.5.15"
|
|
55
55
|
},
|
|
56
56
|
"clean-package": "../../clean-package.config.json",
|
|
57
57
|
"publishConfig": {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useSafeIntl } from "@kopexa/i18n";
|
|
4
|
+
import { cn } from "@kopexa/shared-utils";
|
|
5
|
+
import {
|
|
6
|
+
getScale,
|
|
7
|
+
type ImpactLevel,
|
|
8
|
+
type ImpactScaleConfig,
|
|
9
|
+
type ImpactScalePreset,
|
|
10
|
+
} from "./scales";
|
|
11
|
+
|
|
12
|
+
export interface ImpactBadgeProps {
|
|
13
|
+
/** Impact level 0-5 */
|
|
14
|
+
level: ImpactLevel | number | null | undefined;
|
|
15
|
+
/** Scale preset or custom scale config */
|
|
16
|
+
scale?: ImpactScalePreset | ImpactScaleConfig;
|
|
17
|
+
/** Show numeric value before label */
|
|
18
|
+
showValue?: boolean;
|
|
19
|
+
/** Additional class names */
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* ImpactBadge displays an impact level as a colored badge.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <ImpactBadge level={3} scale="risk" />
|
|
29
|
+
* <ImpactBadge level={4} scale="asset" showValue />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function ImpactBadge({
|
|
33
|
+
level,
|
|
34
|
+
scale = "risk",
|
|
35
|
+
showValue = false,
|
|
36
|
+
className,
|
|
37
|
+
}: ImpactBadgeProps) {
|
|
38
|
+
const intl = useSafeIntl();
|
|
39
|
+
|
|
40
|
+
// Normalize level to ImpactLevel
|
|
41
|
+
const normalizedLevel: ImpactLevel =
|
|
42
|
+
level === null || level === undefined
|
|
43
|
+
? 0
|
|
44
|
+
: ((Math.min(5, Math.max(0, Math.round(level))) as ImpactLevel) ?? 0);
|
|
45
|
+
|
|
46
|
+
// Resolve scale config
|
|
47
|
+
const scaleConfig: ImpactScaleConfig =
|
|
48
|
+
typeof scale === "string" ? getScale(scale) : scale;
|
|
49
|
+
|
|
50
|
+
const config = scaleConfig[normalizedLevel];
|
|
51
|
+
const isUnrated = normalizedLevel === 0;
|
|
52
|
+
|
|
53
|
+
// Get label from i18n or fallback
|
|
54
|
+
const label = intl.formatMessage(config.message);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<span
|
|
58
|
+
className={cn(
|
|
59
|
+
"inline-flex items-center gap-1.5 text-sm font-medium px-2 py-0.5 rounded",
|
|
60
|
+
isUnrated
|
|
61
|
+
? "text-muted-foreground bg-muted"
|
|
62
|
+
: `${config.color} ${config.bgColor}`,
|
|
63
|
+
className,
|
|
64
|
+
)}
|
|
65
|
+
>
|
|
66
|
+
{showValue && !isUnrated && (
|
|
67
|
+
<span className="text-xs font-mono opacity-70">{normalizedLevel}</span>
|
|
68
|
+
)}
|
|
69
|
+
{label}
|
|
70
|
+
</span>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type { ImpactBadgeProps } from "./impact-badge";
|
|
2
|
+
export { ImpactBadge } from "./impact-badge";
|
|
1
3
|
export type { ImpactCardProps, ImpactValue } from "./impact-card";
|
|
2
4
|
export { ImpactCard } from "./impact-card";
|
|
3
5
|
export { messages as impactMessages } from "./messages";
|
|
File without changes
|