@kopexa/grc 0.0.5 → 0.0.7

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.
@@ -0,0 +1,110 @@
1
+ "use client";
2
+
3
+ // src/risk/messages.ts
4
+ import { defineMessages } from "@kopexa/i18n";
5
+ var messages = defineMessages({
6
+ // Card title
7
+ title: {
8
+ id: "grc.risk_treatment.title",
9
+ defaultMessage: "Risk Treatment"
10
+ },
11
+ // Strategy selection
12
+ strategy_label: {
13
+ id: "grc.risk_treatment.strategy_label",
14
+ defaultMessage: "Selected Strategy"
15
+ },
16
+ strategy_prompt: {
17
+ id: "grc.risk_treatment.strategy_prompt",
18
+ defaultMessage: "How do you want to handle this risk?"
19
+ },
20
+ // Treatment options - labels
21
+ accept_label: {
22
+ id: "grc.risk_treatment.accept.label",
23
+ defaultMessage: "Accept"
24
+ },
25
+ mitigate_label: {
26
+ id: "grc.risk_treatment.mitigate.label",
27
+ defaultMessage: "Mitigate"
28
+ },
29
+ transfer_label: {
30
+ id: "grc.risk_treatment.transfer.label",
31
+ defaultMessage: "Transfer"
32
+ },
33
+ avoid_label: {
34
+ id: "grc.risk_treatment.avoid.label",
35
+ defaultMessage: "Avoid"
36
+ },
37
+ not_defined_label: {
38
+ id: "grc.risk_treatment.not_defined.label",
39
+ defaultMessage: "No strategy defined"
40
+ },
41
+ // Treatment options - descriptions
42
+ accept_description: {
43
+ id: "grc.risk_treatment.accept.description",
44
+ defaultMessage: "Consciously accept the risk because treatment costs exceed potential damage or the risk is within acceptable limits."
45
+ },
46
+ mitigate_description: {
47
+ id: "grc.risk_treatment.mitigate.description",
48
+ defaultMessage: "Reduce the risk to an acceptable level through implementation of controls and measures."
49
+ },
50
+ transfer_description: {
51
+ id: "grc.risk_treatment.transfer.description",
52
+ defaultMessage: "Transfer the risk to third parties (e.g., insurance, outsourcing)."
53
+ },
54
+ avoid_description: {
55
+ id: "grc.risk_treatment.avoid.description",
56
+ defaultMessage: "Completely eliminate the risk by avoiding the risky activity or changing business processes."
57
+ },
58
+ // Treatment options - hints (requirements)
59
+ mitigate_hint: {
60
+ id: "grc.risk_treatment.mitigate.hint",
61
+ defaultMessage: "Requires: Action plan, Control mapping"
62
+ },
63
+ transfer_hint: {
64
+ id: "grc.risk_treatment.transfer.hint",
65
+ defaultMessage: "Requires: Contract documentation, Residual risk assessment"
66
+ },
67
+ avoid_hint: {
68
+ id: "grc.risk_treatment.avoid.hint",
69
+ defaultMessage: "Requires: Business Impact Analysis"
70
+ },
71
+ accept_hint: {
72
+ id: "grc.risk_treatment.accept.hint",
73
+ defaultMessage: "Requires: Documented approval"
74
+ },
75
+ // Rationale
76
+ rationale_label: {
77
+ id: "grc.risk_treatment.rationale_label",
78
+ defaultMessage: "Rationale"
79
+ },
80
+ rationale_placeholder: {
81
+ id: "grc.risk_treatment.rationale_placeholder",
82
+ defaultMessage: "Document why this strategy was chosen..."
83
+ },
84
+ no_rationale: {
85
+ id: "grc.risk_treatment.no_rationale",
86
+ defaultMessage: "No rationale defined"
87
+ },
88
+ // Actions
89
+ edit: {
90
+ id: "grc.risk_treatment.edit",
91
+ defaultMessage: "Edit"
92
+ },
93
+ cancel: {
94
+ id: "grc.risk_treatment.cancel",
95
+ defaultMessage: "Cancel"
96
+ },
97
+ save: {
98
+ id: "grc.risk_treatment.save",
99
+ defaultMessage: "Save"
100
+ },
101
+ // Recommendation badge
102
+ recommended: {
103
+ id: "grc.risk_treatment.recommended",
104
+ defaultMessage: "Recommended"
105
+ }
106
+ });
107
+
108
+ export {
109
+ messages
110
+ };
@@ -0,0 +1 @@
1
+ "use client";
@@ -0,0 +1,248 @@
1
+ "use client";
2
+ import {
3
+ messages
4
+ } from "./chunk-AHKTFAZC.mjs";
5
+
6
+ // src/risk/risk-treatment-card.tsx
7
+ import { useSafeIntl } from "@kopexa/i18n";
8
+ import { CheckCirleIcon, EditIcon } from "@kopexa/icons";
9
+ import {
10
+ Button,
11
+ Card,
12
+ Chip,
13
+ Heading,
14
+ Separator,
15
+ Textarea
16
+ } from "@kopexa/sight";
17
+ import { useState } from "react";
18
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
19
+ function TreatmentOption({
20
+ id,
21
+ label,
22
+ description,
23
+ hint,
24
+ isSelected,
25
+ isRecommended,
26
+ recommendedLabel,
27
+ onSelect
28
+ }) {
29
+ return /* @__PURE__ */ jsx(
30
+ "button",
31
+ {
32
+ type: "button",
33
+ onClick: () => onSelect(id),
34
+ className: `
35
+ w-full text-left p-4 rounded-lg border-2 transition-all
36
+ ${isSelected ? "border-primary bg-primary/5" : "border-border hover:border-primary/50 hover:bg-muted/50"}
37
+ `,
38
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
39
+ /* @__PURE__ */ jsx(
40
+ "div",
41
+ {
42
+ className: `
43
+ mt-0.5 size-5 rounded-full border-2 flex items-center justify-center flex-shrink-0
44
+ ${isSelected ? "border-primary bg-primary" : "border-muted-foreground"}
45
+ `,
46
+ children: isSelected && /* @__PURE__ */ jsx("div", { className: "size-2 rounded-full bg-primary-foreground" })
47
+ }
48
+ ),
49
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
50
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
51
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: label }),
52
+ isRecommended && /* @__PURE__ */ jsx(Chip, { size: "sm", color: "success", variant: "flat", children: recommendedLabel })
53
+ ] }),
54
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mt-1", children: description }),
55
+ hint && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground mt-2 flex items-center gap-1", children: [
56
+ /* @__PURE__ */ jsx("span", { className: "text-primary", children: "\u2192" }),
57
+ hint
58
+ ] })
59
+ ] })
60
+ ] })
61
+ }
62
+ );
63
+ }
64
+ var defaultValue = {
65
+ treatment: "not_defined",
66
+ rationale: void 0
67
+ };
68
+ function RiskTreatmentCard({
69
+ value,
70
+ onChange,
71
+ readOnly = false,
72
+ title,
73
+ recommended
74
+ }) {
75
+ const intl = useSafeIntl();
76
+ const [isEditing, setIsEditing] = useState(false);
77
+ const [editValues, setEditValues] = useState(
78
+ value || defaultValue
79
+ );
80
+ const t = {
81
+ title: intl.formatMessage(messages.title),
82
+ strategyLabel: intl.formatMessage(messages.strategy_label),
83
+ strategyPrompt: intl.formatMessage(messages.strategy_prompt),
84
+ rationaleLabel: intl.formatMessage(messages.rationale_label),
85
+ rationalePlaceholder: intl.formatMessage(messages.rationale_placeholder),
86
+ noRationale: intl.formatMessage(messages.no_rationale),
87
+ edit: intl.formatMessage(messages.edit),
88
+ cancel: intl.formatMessage(messages.cancel),
89
+ save: intl.formatMessage(messages.save),
90
+ recommended: intl.formatMessage(messages.recommended),
91
+ // Treatment labels
92
+ acceptLabel: intl.formatMessage(messages.accept_label),
93
+ mitigateLabel: intl.formatMessage(messages.mitigate_label),
94
+ transferLabel: intl.formatMessage(messages.transfer_label),
95
+ avoidLabel: intl.formatMessage(messages.avoid_label),
96
+ notDefinedLabel: intl.formatMessage(messages.not_defined_label),
97
+ // Treatment descriptions
98
+ acceptDescription: intl.formatMessage(messages.accept_description),
99
+ mitigateDescription: intl.formatMessage(messages.mitigate_description),
100
+ transferDescription: intl.formatMessage(messages.transfer_description),
101
+ avoidDescription: intl.formatMessage(messages.avoid_description),
102
+ // Treatment hints
103
+ acceptHint: intl.formatMessage(messages.accept_hint),
104
+ mitigateHint: intl.formatMessage(messages.mitigate_hint),
105
+ transferHint: intl.formatMessage(messages.transfer_hint),
106
+ avoidHint: intl.formatMessage(messages.avoid_hint)
107
+ };
108
+ const treatmentLabels = {
109
+ accept: t.acceptLabel,
110
+ mitigate: t.mitigateLabel,
111
+ transfer: t.transferLabel,
112
+ avoid: t.avoidLabel,
113
+ not_defined: t.notDefinedLabel
114
+ };
115
+ const treatmentOptions = [
116
+ {
117
+ id: "accept",
118
+ label: t.acceptLabel,
119
+ description: t.acceptDescription,
120
+ hint: t.acceptHint
121
+ },
122
+ {
123
+ id: "mitigate",
124
+ label: t.mitigateLabel,
125
+ description: t.mitigateDescription,
126
+ hint: t.mitigateHint
127
+ },
128
+ {
129
+ id: "transfer",
130
+ label: t.transferLabel,
131
+ description: t.transferDescription,
132
+ hint: t.transferHint
133
+ },
134
+ {
135
+ id: "avoid",
136
+ label: t.avoidLabel,
137
+ description: t.avoidDescription,
138
+ hint: t.avoidHint
139
+ }
140
+ ];
141
+ const cardTitle = title != null ? title : t.title;
142
+ const currentValue = isEditing ? editValues : value || defaultValue;
143
+ const isNotDefined = currentValue.treatment === "not_defined";
144
+ const handleSave = () => {
145
+ onChange == null ? void 0 : onChange(editValues);
146
+ setIsEditing(false);
147
+ };
148
+ const handleCancel = () => {
149
+ setEditValues(value || defaultValue);
150
+ setIsEditing(false);
151
+ };
152
+ const handleStartEdit = () => {
153
+ setEditValues(value || defaultValue);
154
+ setIsEditing(true);
155
+ };
156
+ const handleTreatmentSelect = (treatment) => {
157
+ setEditValues((prev) => ({ ...prev, treatment }));
158
+ };
159
+ const handleRationaleChange = (rationale) => {
160
+ setEditValues((prev) => ({ ...prev, rationale: rationale || void 0 }));
161
+ };
162
+ return /* @__PURE__ */ jsxs(Card.Root, { variant: "accent", children: [
163
+ /* @__PURE__ */ jsxs(Card.Header, { className: "flex flex-row items-center justify-between", children: [
164
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
165
+ /* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-base", children: cardTitle }),
166
+ isEditing && /* @__PURE__ */ jsx(Chip, { size: "sm", color: "primary", children: t.edit })
167
+ ] }),
168
+ !readOnly && (!isEditing ? /* @__PURE__ */ jsx(
169
+ Button,
170
+ {
171
+ variant: "ghost",
172
+ size: "sm",
173
+ isIconOnly: true,
174
+ onClick: handleStartEdit,
175
+ "aria-label": t.edit,
176
+ children: /* @__PURE__ */ jsx(EditIcon, { className: "size-4" })
177
+ }
178
+ ) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
179
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: handleCancel, children: t.cancel }),
180
+ /* @__PURE__ */ jsx(Button, { size: "sm", onClick: handleSave, children: t.save })
181
+ ] }))
182
+ ] }),
183
+ /* @__PURE__ */ jsx(Card.Body, { className: "space-y-4", children: isEditing ? /* @__PURE__ */ jsxs(Fragment, { children: [
184
+ /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
185
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t.strategyPrompt }),
186
+ /* @__PURE__ */ jsx("div", { className: "grid gap-3", children: treatmentOptions.map((option) => /* @__PURE__ */ jsx(
187
+ TreatmentOption,
188
+ {
189
+ id: option.id,
190
+ label: option.label,
191
+ description: option.description,
192
+ hint: option.hint,
193
+ isSelected: editValues.treatment === option.id,
194
+ isRecommended: recommended === option.id,
195
+ recommendedLabel: t.recommended,
196
+ onSelect: handleTreatmentSelect
197
+ },
198
+ option.id
199
+ )) })
200
+ ] }),
201
+ /* @__PURE__ */ jsx(Separator, {}),
202
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
203
+ /* @__PURE__ */ jsx(
204
+ "label",
205
+ {
206
+ htmlFor: "treatment-rationale",
207
+ className: "text-sm font-medium",
208
+ children: t.rationaleLabel
209
+ }
210
+ ),
211
+ /* @__PURE__ */ jsx(
212
+ Textarea,
213
+ {
214
+ id: "treatment-rationale",
215
+ value: editValues.rationale || "",
216
+ onChange: (e) => handleRationaleChange(e.target.value),
217
+ placeholder: t.rationalePlaceholder,
218
+ rows: 3,
219
+ className: "text-sm"
220
+ }
221
+ )
222
+ ] })
223
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
224
+ /* @__PURE__ */ jsxs("div", { children: [
225
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium mb-1", children: t.strategyLabel }),
226
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
227
+ !isNotDefined && /* @__PURE__ */ jsx(CheckCirleIcon, { className: "size-4 text-success" }),
228
+ /* @__PURE__ */ jsx(
229
+ "p",
230
+ {
231
+ className: `text-sm ${isNotDefined ? "text-muted-foreground" : ""}`,
232
+ children: treatmentLabels[currentValue.treatment]
233
+ }
234
+ )
235
+ ] })
236
+ ] }),
237
+ /* @__PURE__ */ jsx(Separator, {}),
238
+ /* @__PURE__ */ jsxs("div", { children: [
239
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium mb-1", children: t.rationaleLabel }),
240
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: currentValue.rationale || t.noRationale })
241
+ ] })
242
+ ] }) })
243
+ ] });
244
+ }
245
+
246
+ export {
247
+ RiskTreatmentCard
248
+ };
@@ -1,24 +1,5 @@
1
1
  "use client";
2
2
  import "../chunk-HJUSN7FD.mjs";
3
- import "../chunk-HI7F2CF4.mjs";
4
- import {
5
- RiskRatingDisplay
6
- } from "../chunk-5TBN3JQA.mjs";
7
- import {
8
- messages as messages2
9
- } from "../chunk-DC44K745.mjs";
10
- import {
11
- getRiskLevelFromRating,
12
- isRatingUnrated,
13
- riskLevelConfig
14
- } from "../chunk-VFX3DASQ.mjs";
15
- import "../chunk-TICWEZUI.mjs";
16
- import "../chunk-CND77GVC.mjs";
17
- import {
18
- ControlChip,
19
- MappedControls
20
- } from "../chunk-QDYL5ABK.mjs";
21
- import "../chunk-QS5S6V26.mjs";
22
3
  import "../chunk-GFABGXAO.mjs";
23
4
  import {
24
5
  ImpactCard
@@ -33,12 +14,31 @@ import {
33
14
  import {
34
15
  messages
35
16
  } from "../chunk-GF3WJZVI.mjs";
17
+ import "../chunk-HI7F2CF4.mjs";
18
+ import {
19
+ RiskRatingDisplay
20
+ } from "../chunk-5TBN3JQA.mjs";
21
+ import {
22
+ messages as messages2
23
+ } from "../chunk-DC44K745.mjs";
24
+ import {
25
+ getRiskLevelFromRating,
26
+ isRatingUnrated,
27
+ riskLevelConfig
28
+ } from "../chunk-VFX3DASQ.mjs";
29
+ import "../chunk-TICWEZUI.mjs";
36
30
  import {
37
31
  ComplianceBadges,
38
32
  DoraBadge,
39
33
  Nis2Badge
40
34
  } from "../chunk-7754RETD.mjs";
41
35
  import "../chunk-B47KDUYY.mjs";
36
+ import "../chunk-CND77GVC.mjs";
37
+ import {
38
+ ControlChip,
39
+ MappedControls
40
+ } from "../chunk-QDYL5ABK.mjs";
41
+ import "../chunk-QS5S6V26.mjs";
42
42
  export {
43
43
  ComplianceBadges,
44
44
  ControlChip,
package/dist/index.d.mts CHANGED
@@ -6,6 +6,9 @@ export { ImpactLevel, ImpactLevelConfig, ImpactScaleConfig, ImpactScalePreset, a
6
6
  export { messages as riskMessages } from './common/risk/messages.mjs';
7
7
  export { RiskRatingDisplay, RiskRatingDisplayProps } from './common/risk/risk-rating-display.mjs';
8
8
  export { RiskLevel, RiskRating, getRiskLevelFromRating, isRatingUnrated, riskLevelConfig } from './common/risk/types.mjs';
9
+ export { messages as riskTreatmentMessages } from './risk/messages.mjs';
10
+ export { RiskTreatmentCard, RiskTreatmentCardProps } from './risk/risk-treatment-card.mjs';
11
+ export { RiskTreatment, RiskTreatmentValue, TreatmentOption } from './risk/types.mjs';
9
12
  import 'react/jsx-runtime';
10
13
  import 'react';
11
14
  import 'react-intl';
package/dist/index.d.ts CHANGED
@@ -6,6 +6,9 @@ export { ImpactLevel, ImpactLevelConfig, ImpactScaleConfig, ImpactScalePreset, a
6
6
  export { messages as riskMessages } from './common/risk/messages.js';
7
7
  export { RiskRatingDisplay, RiskRatingDisplayProps } from './common/risk/risk-rating-display.js';
8
8
  export { RiskLevel, RiskRating, getRiskLevelFromRating, isRatingUnrated, riskLevelConfig } from './common/risk/types.js';
9
+ export { messages as riskTreatmentMessages } from './risk/messages.js';
10
+ export { RiskTreatmentCard, RiskTreatmentCardProps } from './risk/risk-treatment-card.js';
11
+ export { RiskTreatment, RiskTreatmentValue, TreatmentOption } from './risk/types.js';
9
12
  import 'react/jsx-runtime';
10
13
  import 'react';
11
14
  import 'react-intl';