@kopexa/grc 0.0.3 → 0.0.4

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.
@@ -389,15 +389,18 @@ function ImpactCard({
389
389
  showAuthenticity = false,
390
390
  readOnly = false,
391
391
  scale = "risk",
392
- title
392
+ title,
393
+ variant = "card"
393
394
  }) {
394
395
  var _a, _b;
395
396
  const intl = (0, import_i18n2.useSafeIntl)();
397
+ const isInline = variant === "inline";
396
398
  const [isEditing, setIsEditing] = (0, import_react.useState)(false);
397
399
  const [editValues, setEditValues] = (0, import_react.useState)(
398
400
  value || defaultImpact
399
401
  );
400
- const styles = (0, import_theme.impactCard)({ editing: isEditing });
402
+ const effectiveIsEditing = isInline ? !readOnly : isEditing;
403
+ const styles = (0, import_theme.impactCard)({ editing: !isInline && isEditing });
401
404
  const scaleConfig = typeof scale === "string" ? getScale(scale) : scale;
402
405
  const formatLabel = (level) => {
403
406
  const config = scaleConfig[level];
@@ -433,18 +436,28 @@ function ImpactCard({
433
436
  setEditValues(value || defaultImpact);
434
437
  setIsEditing(true);
435
438
  };
436
- const currentImpact = isEditing ? editValues : value || defaultImpact;
439
+ const currentImpact = isInline ? value || defaultImpact : isEditing ? editValues : value || defaultImpact;
437
440
  const handleLevelChange = (key) => (level) => {
438
- setEditValues((prev) => ({
439
- ...prev,
441
+ const newValues = {
442
+ ...isInline ? value || defaultImpact : editValues,
440
443
  [key]: level
441
- }));
444
+ };
445
+ if (isInline) {
446
+ onChange == null ? void 0 : onChange(newValues);
447
+ } else {
448
+ setEditValues(newValues);
449
+ }
442
450
  };
443
451
  const handleJustificationChange = (justification) => {
444
- setEditValues((prev) => ({
445
- ...prev,
452
+ const newValues = {
453
+ ...isInline ? value || defaultImpact : editValues,
446
454
  impactJustification: justification || void 0
447
- }));
455
+ };
456
+ if (isInline) {
457
+ onChange == null ? void 0 : onChange(newValues);
458
+ } else {
459
+ setEditValues(newValues);
460
+ }
448
461
  };
449
462
  const highestImpact = Math.max(
450
463
  currentImpact.impactConfidentiality,
@@ -456,6 +469,87 @@ function ImpactCard({
456
469
  const justificationHint = intl.formatMessage(messages.justification_hint, {
457
470
  level: highestLabel
458
471
  });
472
+ const impactRows = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
473
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
474
+ ImpactItemRow,
475
+ {
476
+ label: t.confidentiality,
477
+ shortLabel: "C",
478
+ value: currentImpact.impactConfidentiality,
479
+ isEditing: effectiveIsEditing,
480
+ scale: scaleConfig,
481
+ formatLabel,
482
+ onLevelChange: handleLevelChange("impactConfidentiality")
483
+ }
484
+ ),
485
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
486
+ ImpactItemRow,
487
+ {
488
+ label: t.integrity,
489
+ shortLabel: "I",
490
+ value: currentImpact.impactIntegrity,
491
+ isEditing: effectiveIsEditing,
492
+ scale: scaleConfig,
493
+ formatLabel,
494
+ onLevelChange: handleLevelChange("impactIntegrity")
495
+ }
496
+ ),
497
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
498
+ ImpactItemRow,
499
+ {
500
+ label: t.availability,
501
+ shortLabel: "A",
502
+ value: currentImpact.impactAvailability,
503
+ isEditing: effectiveIsEditing,
504
+ scale: scaleConfig,
505
+ formatLabel,
506
+ onLevelChange: handleLevelChange("impactAvailability")
507
+ }
508
+ ),
509
+ showAuthenticity && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
510
+ ImpactItemRow,
511
+ {
512
+ label: t.authenticity,
513
+ shortLabel: "Au",
514
+ value: (_b = currentImpact.impactAuthenticity) != null ? _b : 0,
515
+ isEditing: effectiveIsEditing,
516
+ scale: scaleConfig,
517
+ formatLabel,
518
+ onLevelChange: handleLevelChange("impactAuthenticity")
519
+ }
520
+ )
521
+ ] });
522
+ const justificationContent = showJustification && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.justificationSection(), children: [
523
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
524
+ "label",
525
+ {
526
+ htmlFor: "impact-justification",
527
+ className: styles.justificationLabel(),
528
+ children: [
529
+ t.justification,
530
+ highestImpact > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles.justificationHint(), children: justificationHint })
531
+ ]
532
+ }
533
+ ),
534
+ effectiveIsEditing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
535
+ import_sight.Textarea,
536
+ {
537
+ id: "impact-justification",
538
+ value: currentImpact.impactJustification || "",
539
+ onChange: (e) => handleJustificationChange(e.target.value),
540
+ placeholder: t.justificationPlaceholder,
541
+ rows: 3,
542
+ className: "text-sm"
543
+ }
544
+ ) : currentImpact.impactJustification ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: styles.justificationText(), children: currentImpact.impactJustification }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: styles.justificationEmpty(), children: t.noJustification })
545
+ ] });
546
+ if (isInline) {
547
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.wrapper(), children: [
548
+ title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.inlineHeader(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Heading, { level: "h4", className: "text-sm font-medium", children: title }) }),
549
+ impactRows,
550
+ justificationContent
551
+ ] });
552
+ }
459
553
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_sight.Card.Root, { className: styles.root(), children: [
460
554
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_sight.Card.Header, { className: "flex flex-row items-center justify-between", children: [
461
555
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
@@ -477,78 +571,8 @@ function ImpactCard({
477
571
  ] }))
478
572
  ] }),
479
573
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_sight.Card.Body, { className: "space-y-3", children: [
480
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
481
- ImpactItemRow,
482
- {
483
- label: t.confidentiality,
484
- shortLabel: "C",
485
- value: currentImpact.impactConfidentiality,
486
- isEditing,
487
- scale: scaleConfig,
488
- formatLabel,
489
- onLevelChange: handleLevelChange("impactConfidentiality")
490
- }
491
- ),
492
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
493
- ImpactItemRow,
494
- {
495
- label: t.integrity,
496
- shortLabel: "I",
497
- value: currentImpact.impactIntegrity,
498
- isEditing,
499
- scale: scaleConfig,
500
- formatLabel,
501
- onLevelChange: handleLevelChange("impactIntegrity")
502
- }
503
- ),
504
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
505
- ImpactItemRow,
506
- {
507
- label: t.availability,
508
- shortLabel: "A",
509
- value: currentImpact.impactAvailability,
510
- isEditing,
511
- scale: scaleConfig,
512
- formatLabel,
513
- onLevelChange: handleLevelChange("impactAvailability")
514
- }
515
- ),
516
- showAuthenticity && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
517
- ImpactItemRow,
518
- {
519
- label: t.authenticity,
520
- shortLabel: "Au",
521
- value: (_b = currentImpact.impactAuthenticity) != null ? _b : 0,
522
- isEditing,
523
- scale: scaleConfig,
524
- formatLabel,
525
- onLevelChange: handleLevelChange("impactAuthenticity")
526
- }
527
- ),
528
- showJustification && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.justificationSection(), children: [
529
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
530
- "label",
531
- {
532
- htmlFor: "impact-justification",
533
- className: styles.justificationLabel(),
534
- children: [
535
- t.justification,
536
- highestImpact > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles.justificationHint(), children: justificationHint })
537
- ]
538
- }
539
- ),
540
- isEditing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
541
- import_sight.Textarea,
542
- {
543
- id: "impact-justification",
544
- value: currentImpact.impactJustification || "",
545
- onChange: (e) => handleJustificationChange(e.target.value),
546
- placeholder: t.justificationPlaceholder,
547
- rows: 3,
548
- className: "text-sm"
549
- }
550
- ) : currentImpact.impactJustification ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: styles.justificationText(), children: currentImpact.impactJustification }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: styles.justificationEmpty(), children: t.noJustification })
551
- ] })
574
+ impactRows,
575
+ justificationContent
552
576
  ] })
553
577
  ] });
554
578
  }
@@ -2,7 +2,7 @@
2
2
  import "../../chunk-GFABGXAO.mjs";
3
3
  import {
4
4
  ImpactCard
5
- } from "../../chunk-TW3S4OE2.mjs";
5
+ } from "../../chunk-AGASJJ7X.mjs";
6
6
  import {
7
7
  assetScale,
8
8
  getScale,
@@ -597,15 +597,18 @@ function ImpactCard({
597
597
  showAuthenticity = false,
598
598
  readOnly = false,
599
599
  scale = "risk",
600
- title
600
+ title,
601
+ variant = "card"
601
602
  }) {
602
603
  var _a, _b;
603
604
  const intl = (0, import_i18n6.useSafeIntl)();
605
+ const isInline = variant === "inline";
604
606
  const [isEditing, setIsEditing] = (0, import_react.useState)(false);
605
607
  const [editValues, setEditValues] = (0, import_react.useState)(
606
608
  value || defaultImpact
607
609
  );
608
- const styles = (0, import_theme3.impactCard)({ editing: isEditing });
610
+ const effectiveIsEditing = isInline ? !readOnly : isEditing;
611
+ const styles = (0, import_theme3.impactCard)({ editing: !isInline && isEditing });
609
612
  const scaleConfig = typeof scale === "string" ? getScale(scale) : scale;
610
613
  const formatLabel = (level) => {
611
614
  const config = scaleConfig[level];
@@ -641,18 +644,28 @@ function ImpactCard({
641
644
  setEditValues(value || defaultImpact);
642
645
  setIsEditing(true);
643
646
  };
644
- const currentImpact = isEditing ? editValues : value || defaultImpact;
647
+ const currentImpact = isInline ? value || defaultImpact : isEditing ? editValues : value || defaultImpact;
645
648
  const handleLevelChange = (key) => (level) => {
646
- setEditValues((prev) => ({
647
- ...prev,
649
+ const newValues = {
650
+ ...isInline ? value || defaultImpact : editValues,
648
651
  [key]: level
649
- }));
652
+ };
653
+ if (isInline) {
654
+ onChange == null ? void 0 : onChange(newValues);
655
+ } else {
656
+ setEditValues(newValues);
657
+ }
650
658
  };
651
659
  const handleJustificationChange = (justification) => {
652
- setEditValues((prev) => ({
653
- ...prev,
660
+ const newValues = {
661
+ ...isInline ? value || defaultImpact : editValues,
654
662
  impactJustification: justification || void 0
655
- }));
663
+ };
664
+ if (isInline) {
665
+ onChange == null ? void 0 : onChange(newValues);
666
+ } else {
667
+ setEditValues(newValues);
668
+ }
656
669
  };
657
670
  const highestImpact = Math.max(
658
671
  currentImpact.impactConfidentiality,
@@ -664,6 +677,87 @@ function ImpactCard({
664
677
  const justificationHint = intl.formatMessage(messages3.justification_hint, {
665
678
  level: highestLabel
666
679
  });
680
+ const impactRows = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
681
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
682
+ ImpactItemRow,
683
+ {
684
+ label: t.confidentiality,
685
+ shortLabel: "C",
686
+ value: currentImpact.impactConfidentiality,
687
+ isEditing: effectiveIsEditing,
688
+ scale: scaleConfig,
689
+ formatLabel,
690
+ onLevelChange: handleLevelChange("impactConfidentiality")
691
+ }
692
+ ),
693
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
694
+ ImpactItemRow,
695
+ {
696
+ label: t.integrity,
697
+ shortLabel: "I",
698
+ value: currentImpact.impactIntegrity,
699
+ isEditing: effectiveIsEditing,
700
+ scale: scaleConfig,
701
+ formatLabel,
702
+ onLevelChange: handleLevelChange("impactIntegrity")
703
+ }
704
+ ),
705
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
706
+ ImpactItemRow,
707
+ {
708
+ label: t.availability,
709
+ shortLabel: "A",
710
+ value: currentImpact.impactAvailability,
711
+ isEditing: effectiveIsEditing,
712
+ scale: scaleConfig,
713
+ formatLabel,
714
+ onLevelChange: handleLevelChange("impactAvailability")
715
+ }
716
+ ),
717
+ showAuthenticity && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
718
+ ImpactItemRow,
719
+ {
720
+ label: t.authenticity,
721
+ shortLabel: "Au",
722
+ value: (_b = currentImpact.impactAuthenticity) != null ? _b : 0,
723
+ isEditing: effectiveIsEditing,
724
+ scale: scaleConfig,
725
+ formatLabel,
726
+ onLevelChange: handleLevelChange("impactAuthenticity")
727
+ }
728
+ )
729
+ ] });
730
+ const justificationContent = showJustification && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: styles.justificationSection(), children: [
731
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
732
+ "label",
733
+ {
734
+ htmlFor: "impact-justification",
735
+ className: styles.justificationLabel(),
736
+ children: [
737
+ t.justification,
738
+ highestImpact > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: styles.justificationHint(), children: justificationHint })
739
+ ]
740
+ }
741
+ ),
742
+ effectiveIsEditing ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
743
+ import_sight3.Textarea,
744
+ {
745
+ id: "impact-justification",
746
+ value: currentImpact.impactJustification || "",
747
+ onChange: (e) => handleJustificationChange(e.target.value),
748
+ placeholder: t.justificationPlaceholder,
749
+ rows: 3,
750
+ className: "text-sm"
751
+ }
752
+ ) : currentImpact.impactJustification ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: styles.justificationText(), children: currentImpact.impactJustification }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: styles.justificationEmpty(), children: t.noJustification })
753
+ ] });
754
+ if (isInline) {
755
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: styles.wrapper(), children: [
756
+ title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: styles.inlineHeader(), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_sight3.Heading, { level: "h4", className: "text-sm font-medium", children: title }) }),
757
+ impactRows,
758
+ justificationContent
759
+ ] });
760
+ }
667
761
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_sight3.Card.Root, { className: styles.root(), children: [
668
762
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_sight3.Card.Header, { className: "flex flex-row items-center justify-between", children: [
669
763
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2", children: [
@@ -685,78 +779,8 @@ function ImpactCard({
685
779
  ] }))
686
780
  ] }),
687
781
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_sight3.Card.Body, { className: "space-y-3", children: [
688
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
689
- ImpactItemRow,
690
- {
691
- label: t.confidentiality,
692
- shortLabel: "C",
693
- value: currentImpact.impactConfidentiality,
694
- isEditing,
695
- scale: scaleConfig,
696
- formatLabel,
697
- onLevelChange: handleLevelChange("impactConfidentiality")
698
- }
699
- ),
700
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
701
- ImpactItemRow,
702
- {
703
- label: t.integrity,
704
- shortLabel: "I",
705
- value: currentImpact.impactIntegrity,
706
- isEditing,
707
- scale: scaleConfig,
708
- formatLabel,
709
- onLevelChange: handleLevelChange("impactIntegrity")
710
- }
711
- ),
712
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
713
- ImpactItemRow,
714
- {
715
- label: t.availability,
716
- shortLabel: "A",
717
- value: currentImpact.impactAvailability,
718
- isEditing,
719
- scale: scaleConfig,
720
- formatLabel,
721
- onLevelChange: handleLevelChange("impactAvailability")
722
- }
723
- ),
724
- showAuthenticity && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
725
- ImpactItemRow,
726
- {
727
- label: t.authenticity,
728
- shortLabel: "Au",
729
- value: (_b = currentImpact.impactAuthenticity) != null ? _b : 0,
730
- isEditing,
731
- scale: scaleConfig,
732
- formatLabel,
733
- onLevelChange: handleLevelChange("impactAuthenticity")
734
- }
735
- ),
736
- showJustification && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: styles.justificationSection(), children: [
737
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
738
- "label",
739
- {
740
- htmlFor: "impact-justification",
741
- className: styles.justificationLabel(),
742
- children: [
743
- t.justification,
744
- highestImpact > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: styles.justificationHint(), children: justificationHint })
745
- ]
746
- }
747
- ),
748
- isEditing ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
749
- import_sight3.Textarea,
750
- {
751
- id: "impact-justification",
752
- value: currentImpact.impactJustification || "",
753
- onChange: (e) => handleJustificationChange(e.target.value),
754
- placeholder: t.justificationPlaceholder,
755
- rows: 3,
756
- className: "text-sm"
757
- }
758
- ) : currentImpact.impactJustification ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: styles.justificationText(), children: currentImpact.impactJustification }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: styles.justificationEmpty(), children: t.noJustification })
759
- ] })
782
+ impactRows,
783
+ justificationContent
760
784
  ] })
761
785
  ] });
762
786
  }
@@ -22,7 +22,7 @@ import "../chunk-QS5S6V26.mjs";
22
22
  import "../chunk-GFABGXAO.mjs";
23
23
  import {
24
24
  ImpactCard
25
- } from "../chunk-TW3S4OE2.mjs";
25
+ } from "../chunk-AGASJJ7X.mjs";
26
26
  import {
27
27
  assetScale,
28
28
  getScale,