@socprime/react-ui 0.0.5

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.
Files changed (153) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/LICENSE +21 -0
  3. package/README.md +537 -0
  4. package/attack-flow.d.ts +16 -0
  5. package/charts.d.ts +32 -0
  6. package/decorators/index.js +8 -0
  7. package/decorators/withRouter.js +10 -0
  8. package/decorators/withTheme.js +10 -0
  9. package/decorators.d.ts +10 -0
  10. package/domain.d.ts +23 -0
  11. package/editor.d.ts +25 -0
  12. package/index.d.ts +702 -0
  13. package/lib/cn.js +8 -0
  14. package/lib/theme.js +26 -0
  15. package/lib/useFullscreen.js +52 -0
  16. package/lib/useListenOnResizeDebounce.js +22 -0
  17. package/lib/useThemeColors.js +39 -0
  18. package/package.json +113 -0
  19. package/preset/createConfig.js +98 -0
  20. package/preset/createPreview.js +53 -0
  21. package/preset/index.js +6 -0
  22. package/preset/restoreNativeFocus.js +33 -0
  23. package/preset/types.js +0 -0
  24. package/preset.d.ts +27 -0
  25. package/theme-9m7j1UoI.d.ts +5 -0
  26. package/ui/Accordion/Accordion.js +82 -0
  27. package/ui/Accordion/AccordionSection.js +41 -0
  28. package/ui/Accordion/FolderTreeExpandTrigger.js +29 -0
  29. package/ui/Accordion/chevronVariants.js +31 -0
  30. package/ui/Accordion/index.js +16 -0
  31. package/ui/AnimatedDots/AnimatedDots.js +10 -0
  32. package/ui/AnimatedDots/index.js +4 -0
  33. package/ui/Aside/Aside.js +34 -0
  34. package/ui/Aside/index.js +4 -0
  35. package/ui/AttackFlow/AttackFlow.js +9 -0
  36. package/ui/AttackFlow/AttackFlowLayout.js +63 -0
  37. package/ui/AttackFlow/Controls.js +42 -0
  38. package/ui/AttackFlow/Node.js +47 -0
  39. package/ui/AttackFlow/OtherNode.js +44 -0
  40. package/ui/AttackFlow/index.js +4 -0
  41. package/ui/AttackFlow/prependData.js +153 -0
  42. package/ui/AttackFlow/types.js +0 -0
  43. package/ui/AttackFlow/useAttackFlow.js +193 -0
  44. package/ui/Badge/Badge.js +57 -0
  45. package/ui/Badge/index.js +5 -0
  46. package/ui/Button/Button.css +1 -0
  47. package/ui/Button/Button.js +109 -0
  48. package/ui/Button/index.js +5 -0
  49. package/ui/Charts/AreaChartWithGradient.js +79 -0
  50. package/ui/Charts/index.js +4 -0
  51. package/ui/Checkbox/Checkbox.js +31 -0
  52. package/ui/Checkbox/index.js +4 -0
  53. package/ui/ConditionalContent/ConditionalContent.js +10 -0
  54. package/ui/ConditionalContent/index.js +4 -0
  55. package/ui/CorrelationTimer/CorrelationTimer.js +62 -0
  56. package/ui/CorrelationTimer/index.js +4 -0
  57. package/ui/DeleteButtonConfirm/DeleteButtonConfirm.js +65 -0
  58. package/ui/DeleteButtonConfirm/index.js +4 -0
  59. package/ui/Dialog/ConfirmDialog.js +54 -0
  60. package/ui/Dialog/DefaultDialog.js +82 -0
  61. package/ui/Dialog/Dialog.js +120 -0
  62. package/ui/Dialog/index.js +32 -0
  63. package/ui/Dropdown/Dropdown.js +204 -0
  64. package/ui/Dropdown/DropdownsCheckbox.js +102 -0
  65. package/ui/Dropdown/DropdownsSelect.js +97 -0
  66. package/ui/Dropdown/index.js +38 -0
  67. package/ui/Editor/Editor.js +97 -0
  68. package/ui/Editor/index.js +4 -0
  69. package/ui/Editor/monacoSetup.js +38 -0
  70. package/ui/Editor/theme.js +50 -0
  71. package/ui/Editor/types.js +0 -0
  72. package/ui/EmptyState/EmptyState.js +26 -0
  73. package/ui/EmptyState/index.js +4 -0
  74. package/ui/Field/Field.js +204 -0
  75. package/ui/Field/index.js +24 -0
  76. package/ui/HelperText/HelperText.js +7 -0
  77. package/ui/HelperText/index.js +4 -0
  78. package/ui/Input/Input.js +40 -0
  79. package/ui/Input/index.js +4 -0
  80. package/ui/InputNumber/InputNumber.js +90 -0
  81. package/ui/InputNumber/index.js +4 -0
  82. package/ui/InputPassword/InputPassword.js +30 -0
  83. package/ui/InputPassword/index.js +4 -0
  84. package/ui/Label/Label.js +13 -0
  85. package/ui/Label/LabelInfo.js +14 -0
  86. package/ui/Label/index.js +6 -0
  87. package/ui/MultiSelect/MultiSelect.js +163 -0
  88. package/ui/MultiSelect/index.js +4 -0
  89. package/ui/PageHeader/PageHeader.js +51 -0
  90. package/ui/PageHeader/index.js +4 -0
  91. package/ui/Pagination/Pagination.js +97 -0
  92. package/ui/Pagination/PaginationWrap.js +149 -0
  93. package/ui/Pagination/index.js +20 -0
  94. package/ui/RadioGroup/RadioGroup.js +45 -0
  95. package/ui/RadioGroup/index.js +5 -0
  96. package/ui/ScrollArea/ScrollArea.js +57 -0
  97. package/ui/ScrollArea/index.js +5 -0
  98. package/ui/SearchInput/SearchInput.js +38 -0
  99. package/ui/SearchInput/index.js +4 -0
  100. package/ui/SearchInputFields/SearchInputFields.js +53 -0
  101. package/ui/SearchInputFields/index.js +4 -0
  102. package/ui/Select/Select.js +155 -0
  103. package/ui/Select/SelectDefault.js +43 -0
  104. package/ui/Select/index.js +26 -0
  105. package/ui/Separator/Separator.js +26 -0
  106. package/ui/Separator/index.js +4 -0
  107. package/ui/Severity/Severity.js +11 -0
  108. package/ui/Severity/index.js +4 -0
  109. package/ui/Severity/utils.js +53 -0
  110. package/ui/Skeleton/Skeleton.js +25 -0
  111. package/ui/Skeleton/index.js +5 -0
  112. package/ui/Slider/Slider.js +50 -0
  113. package/ui/Slider/index.js +4 -0
  114. package/ui/Spinner/Spinner.js +21 -0
  115. package/ui/Spinner/index.js +5 -0
  116. package/ui/SpinnerSquare/SpinnerSquare.css +1 -0
  117. package/ui/SpinnerSquare/SpinnerSquare.js +22 -0
  118. package/ui/SpinnerSquare/index.js +4 -0
  119. package/ui/StatisticCard/StatisticCard.js +27 -0
  120. package/ui/StatisticCard/index.js +4 -0
  121. package/ui/StatisticCard/types.js +0 -0
  122. package/ui/Suggestions/Suggestions.js +244 -0
  123. package/ui/Suggestions/index.js +4 -0
  124. package/ui/Switch/Switch.js +64 -0
  125. package/ui/Switch/index.js +4 -0
  126. package/ui/SyncProcessBar/SyncProcessBar.js +14 -0
  127. package/ui/SyncProcessBar/index.js +4 -0
  128. package/ui/Table/GroupHeaderRow.js +36 -0
  129. package/ui/Table/RowGrouped.js +19 -0
  130. package/ui/Table/ServerGroupedTableBody.js +89 -0
  131. package/ui/Table/SortableHeader.js +46 -0
  132. package/ui/Table/Table.js +110 -0
  133. package/ui/Table/TableWrap.js +124 -0
  134. package/ui/Table/columnStyle.js +14 -0
  135. package/ui/Table/index.js +28 -0
  136. package/ui/Tabs/Tabs.js +76 -0
  137. package/ui/Tabs/index.js +4 -0
  138. package/ui/TextTruncate/TextTruncate.js +107 -0
  139. package/ui/TextTruncate/index.js +4 -0
  140. package/ui/Textarea/Textarea.js +20 -0
  141. package/ui/Textarea/index.js +4 -0
  142. package/ui/ThemeToggle/ThemeToggle.js +23 -0
  143. package/ui/ThemeToggle/index.js +4 -0
  144. package/ui/Toast/Toast.js +23 -0
  145. package/ui/Toast/index.js +4 -0
  146. package/ui/Tooltip/Tooltip.js +17 -0
  147. package/ui/Tooltip/TooltipLayout.js +60 -0
  148. package/ui/Tooltip/index.js +14 -0
  149. package/ui/TreeGuide/TreeGuide.js +23 -0
  150. package/ui/TreeGuide/index.js +5 -0
  151. package/ui/entries/charts.js +2 -0
  152. package/ui/entries/domain.js +3 -0
  153. package/ui/index.js +45 -0
@@ -0,0 +1,57 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { cva } from "class-variance-authority";
3
+ import { XIcon } from "lucide-react";
4
+ import { cn } from "../../lib/cn.js";
5
+ const badgeVariants = cva(
6
+ "inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-2xs transition-colors focus:outline-none",
7
+ {
8
+ variants: {
9
+ variant: {
10
+ yellow: "border-yellow/20 font-normal text-2xs bg-yellow/10 text-yellow shadow hover:bg-yellow/20",
11
+ purple: "border-purple/20 font-normal text-2xs bg-purple/10 text-default shadow hover:bg-purple/20",
12
+ default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
13
+ dark: "border-border bg-primary text-primary-foreground shadow hover:bg-primary/80",
14
+ defaultOutline: "border-border bg-primary text-primary-foreground shadow hover:bg-secondary",
15
+ warning: "border-warning/20 font-normal text-2xs bg-warning/10 text-default shadow hover:bg-warning/20",
16
+ critical: "border-critical/20 font-normal text-2xs bg-critical/10 text-default shadow hover:bg-critical/20",
17
+ secondary: "border-border bg-secondary text-subdued hover:bg-secondary/80",
18
+ outline: "text-foreground border-border",
19
+ success: "border-success/20 font-normal text-2xs bg-success/10 text-default shadow hover:bg-success/20",
20
+ lightBlue: "border-light-blue/20 font-normal text-2xs bg-light-blue/10 text-default shadow hover:bg-light-blue/20",
21
+ redViolet: "border-red-violet/20 font-normal text-2xs bg-red-violet/10 text-default shadow hover:bg-red-violet/20"
22
+ }
23
+ },
24
+ defaultVariants: {
25
+ variant: "default"
26
+ }
27
+ }
28
+ );
29
+ function Badge({ className, variant, onRemove, children, ...props }) {
30
+ return /* @__PURE__ */ jsxs("div", { className: cn(badgeVariants({ variant }), className), ...props, children: [
31
+ children,
32
+ onRemove && /* @__PURE__ */ jsx(
33
+ "span",
34
+ {
35
+ role: "button",
36
+ tabIndex: 0,
37
+ onClick: (e) => {
38
+ e.stopPropagation();
39
+ onRemove();
40
+ },
41
+ onKeyDown: (e) => {
42
+ if (e.key === "Enter" || e.key === " ") {
43
+ e.preventDefault();
44
+ e.stopPropagation();
45
+ onRemove();
46
+ }
47
+ },
48
+ className: "hover:text-default/30 focus:ring-success/40 ml-1 cursor-pointer rounded-sm focus:ring-2 focus:outline-none",
49
+ children: /* @__PURE__ */ jsx(XIcon, { className: "size-3 text-inherit" })
50
+ }
51
+ )
52
+ ] });
53
+ }
54
+ export {
55
+ Badge,
56
+ badgeVariants
57
+ };
@@ -0,0 +1,5 @@
1
+ import { Badge, badgeVariants } from "./Badge.js";
2
+ export {
3
+ Badge,
4
+ badgeVariants
5
+ };
@@ -0,0 +1 @@
1
+ .btn:not(.disabled),.btn:not(disabled){cursor:pointer}.btn:disabled{cursor:not-allowed;pointer-events:none;opacity:.5}.btn--icon:disabled{pointer-events:all;background-color:rgba(0,0,0,0);color:var(--color-subdued)}.btn[aria-invalid=true]{box-shadow:0 0 0 3px var(--color-destructive);border-color:var(--color-destructive)}.btn svg{pointer-events:none;flex-shrink:0}.btn svg:not([class*=size-]):not([width]):not([height]){width:1em;height:1em}
@@ -0,0 +1,109 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { cn } from "../../lib/cn.js";
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import { Loader2 } from "lucide-react";
5
+ import React from "react";
6
+ import { cva } from "class-variance-authority";
7
+ import { Link } from "react-router-dom";
8
+ import "./Button.css";
9
+ const buttonVariants = cva(
10
+ "flex items-center justify-center gap-2 whitespace-nowrap rounded-xs border-1 transition-all duration-200 outline-none rounded-s",
11
+ {
12
+ variants: {
13
+ variant: {
14
+ primary: "btn px-4 border-btn-primary bg-btn-primary hover:bg-btn-primary-hover active:bg-btn-primary-active disabled:bg-btn-primary-disabled disabled:border-btn-primary-disabled disabled:text-subdued text-dark",
15
+ primaryOutline: "btn px-4 border-btn-primary bg-transparent hover:bg-btn-primary/10 hover:border-btn-primary/50 active:bg-btn-primary/20 disabled:border-btn-primary-disabled disabled:bg-transparent dark:text-default light:text-dark",
16
+ secondary: "btn px-4 border-border bg-btn-secondary hover:bg-btn-secondary-hover/30 active:bg-btn-secondary-active disabled:bg-btn-secondary-disabled dark:text-subdued light:hover:text-default light:text-dark",
17
+ secondaryOutline: "btn px-4 border-border bg-hover/20 hover:bg-hover/60 active:bg-btn-secondary/20 disabled:border-btn-secondary-disabled disabled:bg-transparent dark:text-subdued light:text-dark ring-0",
18
+ criticalOutline: "btn px-4 border-btn-destructive/30 bg-transparent hover:bg-btn-destructive-hover/20 hover:border-btn-destructive/30 active:bg-btn-destructive-active/20 disabled:border-critical/70 disabled:bg-transparent text-critical/90 hover:text-critical disabled:text-critical/70",
19
+ ghost: "btn px-4 border-transparent bg-transparent text-foreground [&_svg]:text-subdued active:bg-btn-primary/10 active:border-btn-primary/5 [&.is-active]:bg-transparent [&.is-active]:border-btn-primary/50 [&.is-active_svg]:text-btn-primary [&:active_svg]:text-btn-primary hover:bg-btn-ghost hover:[&:not(.is-active)_svg]:text-subdued",
20
+ outline: "btn px-4 btn--outline",
21
+ icon: "btn px-1 btn--icon border-transparent dark:text-subdued light:text-dark hover:bg-hover dark:hover:text-success",
22
+ custom: ""
23
+ },
24
+ size: {
25
+ xxs: "h-6",
26
+ xs: "h-7",
27
+ s: "h-8",
28
+ m: "h-9",
29
+ l: "h-10",
30
+ xl: "h-11",
31
+ lg: "h-12",
32
+ custom: ""
33
+ }
34
+ },
35
+ compoundVariants: [
36
+ { variant: "icon", size: "xxs", className: "w-6" },
37
+ { variant: "icon", size: "xs", className: "w-7" },
38
+ { variant: "icon", size: "s", className: "w-8" },
39
+ { variant: "icon", size: "m", className: "w-9" },
40
+ { variant: "icon", size: "l", className: "w-10" },
41
+ { variant: "icon", size: "xl", className: "w-11" },
42
+ { variant: "icon", size: "lg", className: "w-12" }
43
+ ],
44
+ defaultVariants: {
45
+ variant: "primary",
46
+ size: "m"
47
+ }
48
+ }
49
+ );
50
+ const Button = ({
51
+ className,
52
+ variant,
53
+ size,
54
+ asChild = false,
55
+ loading,
56
+ children,
57
+ disabled,
58
+ to,
59
+ href,
60
+ ...props
61
+ }) => {
62
+ const classes = buttonVariants({ variant, size, className });
63
+ const processedChildren = loading && React.Children.count(children) > 0 ? (() => {
64
+ const childrenArray = React.Children.toArray(children);
65
+ const firstChild = childrenArray[0];
66
+ if (React.isValidElement(firstChild)) {
67
+ return [
68
+ /* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin" }, "loader"),
69
+ ...childrenArray.slice(1)
70
+ ];
71
+ }
72
+ return [/* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin" }, "loader"), ...childrenArray];
73
+ })() : children;
74
+ const commonProps = {
75
+ "data-slot": "button",
76
+ className: cn(classes, loading && "opacity-50"),
77
+ children: processedChildren
78
+ };
79
+ if (asChild) {
80
+ return /* @__PURE__ */ jsx(Slot, { ...commonProps, ...props });
81
+ }
82
+ if (to) {
83
+ return /* @__PURE__ */ jsx(Link, { to, ...commonProps, ...props });
84
+ }
85
+ if (href) {
86
+ const { className: anchorClassName, ...anchorProps } = props;
87
+ return /* @__PURE__ */ jsx(
88
+ "a",
89
+ {
90
+ href,
91
+ ...commonProps,
92
+ ...anchorProps,
93
+ className: cn(commonProps.className, anchorClassName)
94
+ }
95
+ );
96
+ }
97
+ return /* @__PURE__ */ jsx(
98
+ "button",
99
+ {
100
+ ...commonProps,
101
+ ...props,
102
+ disabled: disabled || loading
103
+ }
104
+ );
105
+ };
106
+ export {
107
+ Button,
108
+ buttonVariants
109
+ };
@@ -0,0 +1,5 @@
1
+ import { Button, buttonVariants } from "./Button.js";
2
+ export {
3
+ Button,
4
+ buttonVariants
5
+ };
@@ -0,0 +1,79 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useThemeColors } from "../../lib/useThemeColors.js";
3
+ import { memo } from "react";
4
+ import { Area, AreaChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
5
+ const isPaddingPoint = (point) => point.name === "";
6
+ const normalizeSinglePointData = (data) => {
7
+ if (data.length !== 1) {
8
+ return data;
9
+ }
10
+ const [point] = data;
11
+ return [
12
+ { name: point.name, value: point.value },
13
+ point,
14
+ { name: point.name, value: point.value }
15
+ ];
16
+ };
17
+ const AreaChartWithGradientComponent = ({
18
+ data,
19
+ color,
20
+ height = 300
21
+ }) => {
22
+ const { primary, border, default: textDefault } = useThemeColors();
23
+ const gradientId = `gradient-${color.replace("#", "")}`;
24
+ const chartData = normalizeSinglePointData(data);
25
+ const isSinglePoint = data.length === 1;
26
+ return /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: isSinglePoint ? 15 : height, children: /* @__PURE__ */ jsxs(AreaChart, { data: chartData, children: [
27
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
28
+ /* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: color, stopOpacity: 0.8 }),
29
+ /* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: color, stopOpacity: 0.1 })
30
+ ] }) }),
31
+ /* @__PURE__ */ jsx(XAxis, { dataKey: "name", hide: true }),
32
+ /* @__PURE__ */ jsx(YAxis, { hide: true }),
33
+ /* @__PURE__ */ jsx(
34
+ Tooltip,
35
+ {
36
+ contentStyle: {
37
+ backgroundColor: primary,
38
+ border: `1px solid ${border}`,
39
+ borderRadius: "6px",
40
+ fontSize: "12px",
41
+ padding: "8px 12px",
42
+ color: textDefault
43
+ },
44
+ formatter: (value, _name, item) => {
45
+ const point = item?.payload;
46
+ if (point && isPaddingPoint(point)) {
47
+ return null;
48
+ }
49
+ return value;
50
+ },
51
+ labelFormatter: (label) => label === "" ? "" : label,
52
+ cursor: { stroke: color, strokeWidth: 1, strokeDasharray: "4 4" }
53
+ }
54
+ ),
55
+ /* @__PURE__ */ jsx(
56
+ Area,
57
+ {
58
+ type: isSinglePoint ? "linear" : "monotone",
59
+ dataKey: "value",
60
+ stroke: color,
61
+ fillOpacity: 1,
62
+ fill: `url(#${gradientId})`,
63
+ strokeWidth: 2,
64
+ activeDot: {
65
+ r: 4,
66
+ fill: color,
67
+ stroke: color,
68
+ strokeWidth: 1,
69
+ strokeDasharray: "4 4",
70
+ opacity: 0.7
71
+ }
72
+ }
73
+ )
74
+ ] }) });
75
+ };
76
+ const AreaChartWithGradient = memo(AreaChartWithGradientComponent);
77
+ export {
78
+ AreaChartWithGradient
79
+ };
@@ -0,0 +1,4 @@
1
+ import { AreaChartWithGradient } from "./AreaChartWithGradient.js";
2
+ export {
3
+ AreaChartWithGradient
4
+ };
@@ -0,0 +1,31 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
3
+ import { CheckIcon } from "lucide-react";
4
+ import { cn } from "../../lib/cn.js";
5
+ const Checkbox = ({
6
+ className,
7
+ ...props
8
+ }) => {
9
+ return /* @__PURE__ */ jsx(
10
+ CheckboxPrimitive.Root,
11
+ {
12
+ "data-slot": "checkbox",
13
+ className: cn(
14
+ "peer border-border bg-secondary data-[state=checked]:bg-success data-[state=checked]:text-dark focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 aria-invalid:border-destructive size-4 shrink-0 cursor-pointer rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
15
+ className
16
+ ),
17
+ ...props,
18
+ children: /* @__PURE__ */ jsx(
19
+ CheckboxPrimitive.Indicator,
20
+ {
21
+ "data-slot": "checkbox-indicator",
22
+ className: "grid place-content-center text-current transition-none",
23
+ children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5" })
24
+ }
25
+ )
26
+ }
27
+ );
28
+ };
29
+ export {
30
+ Checkbox
31
+ };
@@ -0,0 +1,4 @@
1
+ import { Checkbox as Checkbox2 } from "./Checkbox.js";
2
+ export {
3
+ Checkbox2 as Checkbox
4
+ };
@@ -0,0 +1,10 @@
1
+ const ConditionalContent = ({
2
+ loading,
3
+ loadingContent,
4
+ loadedContent
5
+ }) => {
6
+ return loading ? loadingContent : loadedContent;
7
+ };
8
+ export {
9
+ ConditionalContent
10
+ };
@@ -0,0 +1,4 @@
1
+ import { ConditionalContent } from "./ConditionalContent.js";
2
+ export {
3
+ ConditionalContent
4
+ };
@@ -0,0 +1,62 @@
1
+ import { jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { Badge } from "../Badge/Badge.js";
4
+ const CorrelationTimer = ({ isRunning, runningTime }) => {
5
+ const [elapsedSeconds, setElapsedSeconds] = useState(0);
6
+ useEffect(() => {
7
+ if (!isRunning) {
8
+ setElapsedSeconds(0);
9
+ return;
10
+ }
11
+ const syncAt = Date.now();
12
+ const isTimestamp = runningTime != null && runningTime > 1e12;
13
+ const calculateElapsed = () => {
14
+ if (runningTime == null) {
15
+ return Math.floor((Date.now() - syncAt) / 1e3);
16
+ }
17
+ if (isTimestamp) {
18
+ return Math.floor((Date.now() - runningTime) / 1e3);
19
+ }
20
+ return runningTime + Math.floor((Date.now() - syncAt) / 1e3);
21
+ };
22
+ setElapsedSeconds(calculateElapsed());
23
+ const interval = setInterval(() => {
24
+ setElapsedSeconds(calculateElapsed());
25
+ }, 1e3);
26
+ return () => clearInterval(interval);
27
+ }, [isRunning, runningTime]);
28
+ const formatTime = (seconds) => {
29
+ if (seconds < 60) {
30
+ return `${seconds}s`;
31
+ }
32
+ if (seconds < 3600) {
33
+ const minutes = Math.floor(seconds / 60);
34
+ return `${minutes}m`;
35
+ }
36
+ if (seconds < 86400) {
37
+ const hours = Math.floor(seconds / 3600);
38
+ return `${hours}h`;
39
+ }
40
+ if (seconds < 2592e3) {
41
+ const days = Math.floor(seconds / 86400);
42
+ return `${days}d`;
43
+ }
44
+ if (seconds < 31536e3) {
45
+ const months = Math.floor(seconds / 2592e3);
46
+ return `${months}mo`;
47
+ }
48
+ const years = Math.floor(seconds / 31536e3);
49
+ return `${years}y`;
50
+ };
51
+ return /* @__PURE__ */ jsxs(Badge, { className: "text-success", variant: "success", children: [
52
+ "Running",
53
+ /* @__PURE__ */ jsxs("span", { children: [
54
+ "(",
55
+ formatTime(elapsedSeconds),
56
+ ")"
57
+ ] })
58
+ ] });
59
+ };
60
+ export {
61
+ CorrelationTimer
62
+ };
@@ -0,0 +1,4 @@
1
+ import { CorrelationTimer } from "./CorrelationTimer.js";
2
+ export {
3
+ CorrelationTimer
4
+ };
@@ -0,0 +1,65 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { ConfirmDeleteDialog } from "../Dialog/ConfirmDialog.js";
3
+ import { TrashIcon } from "lucide-react";
4
+ import { useState } from "react";
5
+ import { Button } from "../Button/Button.js";
6
+ const DeleteButtonConfirm = ({
7
+ loading,
8
+ isOpen,
9
+ title,
10
+ message,
11
+ onOpen,
12
+ onClose,
13
+ onConfirm
14
+ }) => {
15
+ const [isOpenLocal, setIsOpenLocal] = useState(false);
16
+ const handleOpen = () => {
17
+ if (onOpen) {
18
+ onOpen();
19
+ } else {
20
+ setIsOpenLocal(true);
21
+ }
22
+ };
23
+ const handleClose = () => {
24
+ if (onClose) {
25
+ onClose();
26
+ } else {
27
+ setIsOpenLocal(false);
28
+ }
29
+ };
30
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
31
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxs(
32
+ Button,
33
+ {
34
+ variant: "criticalOutline",
35
+ className: "text-xs",
36
+ size: "l",
37
+ onClick: handleOpen,
38
+ type: "button",
39
+ disabled: loading,
40
+ children: [
41
+ /* @__PURE__ */ jsx(TrashIcon, { className: "size-4" }),
42
+ "Delete"
43
+ ]
44
+ }
45
+ ) }),
46
+ /* @__PURE__ */ jsx(
47
+ ConfirmDeleteDialog,
48
+ {
49
+ loading,
50
+ isOpen: isOpen !== void 0 ? isOpen : isOpenLocal,
51
+ onClose: handleClose,
52
+ onConfirm,
53
+ title,
54
+ message: /* @__PURE__ */ jsxs(Fragment, { children: [
55
+ 'Are you sure you want to delete "',
56
+ message,
57
+ '"? This action cannot be undone.'
58
+ ] })
59
+ }
60
+ )
61
+ ] });
62
+ };
63
+ export {
64
+ DeleteButtonConfirm
65
+ };
@@ -0,0 +1,4 @@
1
+ import { DeleteButtonConfirm } from "./DeleteButtonConfirm.js";
2
+ export {
3
+ DeleteButtonConfirm
4
+ };
@@ -0,0 +1,54 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button } from "../Button/Button.js";
3
+ import {
4
+ Dialog,
5
+ DialogContent,
6
+ DialogDescription,
7
+ DialogFooter,
8
+ DialogHeader,
9
+ DialogTitle
10
+ } from "./Dialog.js";
11
+ const ConfirmDeleteDialog = ({
12
+ isOpen,
13
+ onClose,
14
+ onConfirm,
15
+ title,
16
+ message,
17
+ loading = false
18
+ }) => {
19
+ return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxs(DialogContent, { className: "border-border bg-secondary sm:max-w-[500px]", children: [
20
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
21
+ /* @__PURE__ */ jsx(DialogTitle, { className: "text-default", children: title }),
22
+ /* @__PURE__ */ jsx(DialogDescription, { className: "sr-only", children: message })
23
+ ] }),
24
+ /* @__PURE__ */ jsx("div", { className: "text-subdued px-6 text-xs", children: message }),
25
+ /* @__PURE__ */ jsxs(DialogFooter, { className: "gap-2", children: [
26
+ /* @__PURE__ */ jsx(
27
+ Button,
28
+ {
29
+ className: "text-xs",
30
+ type: "button",
31
+ onClick: onClose,
32
+ variant: "secondaryOutline",
33
+ disabled: loading,
34
+ children: "Cancel"
35
+ }
36
+ ),
37
+ /* @__PURE__ */ jsx(
38
+ Button,
39
+ {
40
+ className: "text-xs",
41
+ type: "button",
42
+ onClick: onConfirm,
43
+ variant: "criticalOutline",
44
+ loading,
45
+ children: "Delete"
46
+ }
47
+ )
48
+ ] })
49
+ ] }) });
50
+ };
51
+ export {
52
+ ConfirmDeleteDialog,
53
+ ConfirmDeleteDialog as ConfirmDialog
54
+ };
@@ -0,0 +1,82 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button } from "../Button/Button.js";
3
+ import {
4
+ Dialog,
5
+ DialogContent,
6
+ DialogDescription,
7
+ DialogFooter,
8
+ DialogHeader,
9
+ DialogTitle
10
+ } from "./Dialog.js";
11
+ import { ScrollArea } from "../ScrollArea/ScrollArea.js";
12
+ import { cn } from "../../lib/cn.js";
13
+ import { XIcon } from "lucide-react";
14
+ const DefaultDialog = ({
15
+ isOpen,
16
+ onClose,
17
+ onConfirm,
18
+ confirmText = "Confirm",
19
+ confirmVariant = "primary",
20
+ cancelText = "Cancel",
21
+ disabled = false,
22
+ title,
23
+ children,
24
+ loading = false,
25
+ className,
26
+ classNameHeader,
27
+ classNameTitle,
28
+ classNameCloseButton,
29
+ hideFooter = true,
30
+ scrollable = false,
31
+ scrollAreaClassName = "",
32
+ titleDescription
33
+ }) => {
34
+ const content = scrollable ? /* @__PURE__ */ jsx(ScrollArea, { className: cn("max-h-[calc(100vh-8rem)]", scrollAreaClassName), children: /* @__PURE__ */ jsx("div", { className: "pr-4", children }) }) : children;
35
+ return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxs(
36
+ DialogContent,
37
+ {
38
+ className: cn(
39
+ "border-border bg-secondary sm:max-w-[500px]",
40
+ scrollable && "flex flex-col",
41
+ className
42
+ ),
43
+ hideCloseButton: true,
44
+ children: [
45
+ /* @__PURE__ */ jsxs(DialogHeader, { className: cn(scrollable ? "shrink-0" : "", classNameHeader), children: [
46
+ /* @__PURE__ */ jsx(DialogTitle, { className: cn("text-default", classNameTitle), children: title }),
47
+ /* @__PURE__ */ jsx(DialogDescription, { className: "sr-only", children: titleDescription })
48
+ ] }),
49
+ /* @__PURE__ */ jsx(Button, { className: cn("absolute top-6 right-4 left-auto bottom-auto", classNameCloseButton), variant: "icon", size: "xxs", onClick: onClose, children: /* @__PURE__ */ jsx(XIcon, { className: "size-4" }) }),
50
+ /* @__PURE__ */ jsx("div", { className: cn(scrollable && "min-h-0 flex-1"), children: content }),
51
+ !hideFooter && /* @__PURE__ */ jsxs(DialogFooter, { className: cn("gap-2 py-5", scrollable && "shrink-0"), children: [
52
+ onClose && /* @__PURE__ */ jsx(
53
+ Button,
54
+ {
55
+ className: "text-xs",
56
+ type: "button",
57
+ onClick: onClose,
58
+ variant: "secondaryOutline",
59
+ disabled: disabled || loading,
60
+ children: cancelText
61
+ }
62
+ ),
63
+ onConfirm && /* @__PURE__ */ jsx(
64
+ Button,
65
+ {
66
+ className: "text-xs",
67
+ type: "button",
68
+ onClick: onConfirm,
69
+ variant: confirmVariant,
70
+ loading,
71
+ disabled,
72
+ children: confirmText
73
+ }
74
+ )
75
+ ] })
76
+ ]
77
+ }
78
+ ) });
79
+ };
80
+ export {
81
+ DefaultDialog
82
+ };