@veltrixsecops/app-sdk 2.0.0 → 2.2.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.
@@ -0,0 +1,600 @@
1
+ import {
2
+ getHostRuntime
3
+ } from "../chunk-MMWEXHPU.js";
4
+
5
+ // src/ui/index.tsx
6
+ import * as React from "react";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ function getHostUi(name) {
9
+ return getHostRuntime()?.ui?.[name];
10
+ }
11
+ var fallbackNote = { fontFamily: "inherit" };
12
+ var Button = React.forwardRef((props, ref) => {
13
+ const HostButton = getHostUi("Button");
14
+ if (HostButton) return /* @__PURE__ */ jsx(HostButton, { ref, ...props });
15
+ const {
16
+ variant: _variant,
17
+ size: _size,
18
+ isLoading,
19
+ loadingText,
20
+ fullWidth,
21
+ leftIcon,
22
+ rightIcon,
23
+ children,
24
+ disabled,
25
+ type,
26
+ style,
27
+ ...rest
28
+ } = props;
29
+ return /* @__PURE__ */ jsxs(
30
+ "button",
31
+ {
32
+ ref,
33
+ type: type ?? "button",
34
+ disabled: disabled || isLoading,
35
+ "aria-busy": isLoading || void 0,
36
+ style: {
37
+ ...fallbackNote,
38
+ display: "inline-flex",
39
+ alignItems: "center",
40
+ gap: 6,
41
+ padding: "6px 14px",
42
+ borderRadius: 6,
43
+ border: "1px solid currentColor",
44
+ background: "transparent",
45
+ cursor: disabled || isLoading ? "not-allowed" : "pointer",
46
+ width: fullWidth ? "100%" : void 0,
47
+ opacity: disabled || isLoading ? 0.6 : 1,
48
+ justifyContent: "center",
49
+ ...style
50
+ },
51
+ ...rest,
52
+ children: [
53
+ leftIcon,
54
+ isLoading ? loadingText ?? children : children,
55
+ rightIcon
56
+ ]
57
+ }
58
+ );
59
+ });
60
+ Button.displayName = "Button";
61
+ var BADGE_FALLBACK_COLORS = {
62
+ default: "#6b7280",
63
+ primary: "#4f46e5",
64
+ secondary: "#6b7280",
65
+ success: "#16a34a",
66
+ danger: "#dc2626",
67
+ warning: "#d97706",
68
+ info: "#0284c7"
69
+ };
70
+ var Badge = ({ variant = "default", size = "md", rounded, dot, children, style, ...rest }) => {
71
+ const HostBadge = getHostUi("Badge");
72
+ if (HostBadge) return /* @__PURE__ */ jsx(HostBadge, { variant, size, rounded, dot, style, ...rest, children });
73
+ const color = BADGE_FALLBACK_COLORS[variant];
74
+ const fontSize = size === "sm" ? 11 : size === "lg" ? 14 : 12;
75
+ return /* @__PURE__ */ jsxs(
76
+ "span",
77
+ {
78
+ style: {
79
+ ...fallbackNote,
80
+ display: "inline-flex",
81
+ alignItems: "center",
82
+ gap: 4,
83
+ padding: size === "sm" ? "1px 6px" : size === "lg" ? "3px 10px" : "2px 8px",
84
+ borderRadius: rounded ? 999 : 4,
85
+ border: `1px solid ${color}`,
86
+ color,
87
+ fontSize,
88
+ fontWeight: 500,
89
+ ...style
90
+ },
91
+ ...rest,
92
+ children: [
93
+ dot && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { width: 6, height: 6, borderRadius: "50%", background: color } }),
94
+ children
95
+ ]
96
+ }
97
+ );
98
+ };
99
+ Badge.displayName = "Badge";
100
+ var Card = ({ children, style, ...rest }) => {
101
+ const HostCard = getHostUi("Card");
102
+ if (HostCard) return /* @__PURE__ */ jsx(HostCard, { style, ...rest, children });
103
+ return /* @__PURE__ */ jsx("div", { style: { ...fallbackNote, border: "1px solid #d1d5db", borderRadius: 8, overflow: "hidden", ...style }, ...rest, children });
104
+ };
105
+ Card.displayName = "Card";
106
+ var CardHeader = ({ actions, children, style, ...rest }) => {
107
+ const HostCardHeader = getHostUi("CardHeader");
108
+ if (HostCardHeader) return /* @__PURE__ */ jsx(HostCardHeader, { actions, style, ...rest, children });
109
+ return /* @__PURE__ */ jsxs(
110
+ "div",
111
+ {
112
+ style: {
113
+ ...fallbackNote,
114
+ padding: "12px 16px",
115
+ borderBottom: "1px solid #d1d5db",
116
+ display: "flex",
117
+ alignItems: "center",
118
+ justifyContent: "space-between",
119
+ gap: 12,
120
+ ...style
121
+ },
122
+ ...rest,
123
+ children: [
124
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, minWidth: 0 }, children }),
125
+ actions && /* @__PURE__ */ jsx("div", { children: actions })
126
+ ]
127
+ }
128
+ );
129
+ };
130
+ CardHeader.displayName = "CardHeader";
131
+ var CardBody = ({ children, style, ...rest }) => {
132
+ const HostCardBody = getHostUi("CardBody");
133
+ if (HostCardBody) return /* @__PURE__ */ jsx(HostCardBody, { style, ...rest, children });
134
+ return /* @__PURE__ */ jsx("div", { style: { ...fallbackNote, padding: "12px 16px", ...style }, ...rest, children });
135
+ };
136
+ CardBody.displayName = "CardBody";
137
+ var CardFooter = ({ children, style, ...rest }) => {
138
+ const HostCardFooter = getHostUi("CardFooter");
139
+ if (HostCardFooter) return /* @__PURE__ */ jsx(HostCardFooter, { style, ...rest, children });
140
+ return /* @__PURE__ */ jsx("div", { style: { ...fallbackNote, padding: "12px 16px", borderTop: "1px solid #d1d5db", ...style }, ...rest, children });
141
+ };
142
+ CardFooter.displayName = "CardFooter";
143
+ var Input = React.forwardRef((props, ref) => {
144
+ const HostInput = getHostUi("Input");
145
+ if (HostInput) return /* @__PURE__ */ jsx(HostInput, { ref, ...props });
146
+ const { label, error, helperText, leftIcon, rightIcon, fullWidth = true, id, style, ...rest } = props;
147
+ const inputId = id ?? (label ? `vx-input-${label.toLowerCase().replace(/\s+/g, "-")}` : void 0);
148
+ return /* @__PURE__ */ jsxs("div", { style: { ...fallbackNote, width: fullWidth ? "100%" : void 0 }, children: [
149
+ label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, style: { display: "block", fontSize: 13, fontWeight: 500, marginBottom: 4 }, children: label }),
150
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
151
+ leftIcon,
152
+ /* @__PURE__ */ jsx(
153
+ "input",
154
+ {
155
+ ref,
156
+ id: inputId,
157
+ "aria-invalid": !!error || void 0,
158
+ style: { flex: 1, padding: "6px 10px", borderRadius: 6, border: "1px solid #9ca3af", ...style },
159
+ ...rest
160
+ }
161
+ ),
162
+ rightIcon
163
+ ] }),
164
+ error && /* @__PURE__ */ jsx("p", { role: "alert", style: { marginTop: 4, fontSize: 12, color: "#dc2626" }, children: error }),
165
+ helperText && !error && /* @__PURE__ */ jsx("p", { style: { marginTop: 4, fontSize: 12, color: "#6b7280" }, children: helperText })
166
+ ] });
167
+ });
168
+ Input.displayName = "Input";
169
+ var Textarea = React.forwardRef((props, ref) => {
170
+ const HostTextarea = getHostUi("Textarea");
171
+ if (HostTextarea) return /* @__PURE__ */ jsx(HostTextarea, { ref, ...props });
172
+ const { label, error, helperText, fullWidth = true, id, rows = 4, style, ...rest } = props;
173
+ const textareaId = id ?? (label ? `vx-textarea-${label.toLowerCase().replace(/\s+/g, "-")}` : void 0);
174
+ return /* @__PURE__ */ jsxs("div", { style: { ...fallbackNote, width: fullWidth ? "100%" : void 0 }, children: [
175
+ label && /* @__PURE__ */ jsx("label", { htmlFor: textareaId, style: { display: "block", fontSize: 13, fontWeight: 500, marginBottom: 4 }, children: label }),
176
+ /* @__PURE__ */ jsx(
177
+ "textarea",
178
+ {
179
+ ref,
180
+ id: textareaId,
181
+ rows,
182
+ "aria-invalid": !!error || void 0,
183
+ style: { width: "100%", padding: "6px 10px", borderRadius: 6, border: "1px solid #9ca3af", ...style },
184
+ ...rest
185
+ }
186
+ ),
187
+ error && /* @__PURE__ */ jsx("p", { role: "alert", style: { marginTop: 4, fontSize: 12, color: "#dc2626" }, children: error }),
188
+ helperText && !error && /* @__PURE__ */ jsx("p", { style: { marginTop: 4, fontSize: 12, color: "#6b7280" }, children: helperText })
189
+ ] });
190
+ });
191
+ Textarea.displayName = "Textarea";
192
+ var Checkbox = React.forwardRef((props, ref) => {
193
+ const HostCheckbox = getHostUi("Checkbox");
194
+ if (HostCheckbox) return /* @__PURE__ */ jsx(HostCheckbox, { ref, ...props });
195
+ const { label, error, helperText, id, disabled, ...rest } = props;
196
+ const generatedId = React.useId();
197
+ const inputId = id ?? generatedId;
198
+ return /* @__PURE__ */ jsxs("div", { style: fallbackNote, children: [
199
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
200
+ /* @__PURE__ */ jsx("input", { ref, id: inputId, type: "checkbox", disabled, "aria-invalid": !!error || void 0, ...rest }),
201
+ label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, style: { fontSize: 13, cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.6 : 1 }, children: label })
202
+ ] }),
203
+ error && /* @__PURE__ */ jsx("p", { role: "alert", style: { marginTop: 4, fontSize: 12, color: "#dc2626" }, children: error }),
204
+ helperText && !error && /* @__PURE__ */ jsx("p", { style: { marginTop: 4, fontSize: 12, color: "#6b7280" }, children: helperText })
205
+ ] });
206
+ });
207
+ Checkbox.displayName = "Checkbox";
208
+ var Select = (props) => {
209
+ const HostSelect = getHostUi("Select");
210
+ if (HostSelect) return /* @__PURE__ */ jsx(HostSelect, { ...props });
211
+ const { options, value, onChange, placeholder = "Select\u2026", label, error, helperText, disabled, fullWidth = true, id, name, className } = props;
212
+ const selectId = id ?? (label ? `vx-select-${label.toLowerCase().replace(/\s+/g, "-")}` : void 0);
213
+ return /* @__PURE__ */ jsxs("div", { className, style: { ...fallbackNote, width: fullWidth ? "100%" : void 0 }, children: [
214
+ label && /* @__PURE__ */ jsx("label", { htmlFor: selectId, style: { display: "block", fontSize: 13, fontWeight: 500, marginBottom: 4 }, children: label }),
215
+ /* @__PURE__ */ jsxs(
216
+ "select",
217
+ {
218
+ id: selectId,
219
+ name,
220
+ "aria-label": props["aria-label"],
221
+ "aria-invalid": !!error || void 0,
222
+ disabled,
223
+ value: value ?? "",
224
+ onChange: (event) => onChange?.(event.target.value),
225
+ style: { width: "100%", padding: "6px 10px", borderRadius: 6, border: "1px solid #9ca3af" },
226
+ children: [
227
+ placeholder && /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: placeholder }),
228
+ options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value))
229
+ ]
230
+ }
231
+ ),
232
+ error && /* @__PURE__ */ jsx("p", { role: "alert", style: { marginTop: 4, fontSize: 12, color: "#dc2626" }, children: error }),
233
+ helperText && !error && /* @__PURE__ */ jsx("p", { style: { marginTop: 4, fontSize: 12, color: "#6b7280" }, children: helperText })
234
+ ] });
235
+ };
236
+ Select.displayName = "Select";
237
+ var FormField = (props) => {
238
+ const HostFormField = getHostUi("FormField");
239
+ if (HostFormField) return /* @__PURE__ */ jsx(HostFormField, { ...props });
240
+ const { label, htmlFor, error, hint, required, className, children } = props;
241
+ return /* @__PURE__ */ jsxs("div", { className, style: fallbackNote, children: [
242
+ label && /* @__PURE__ */ jsxs("label", { htmlFor, style: { display: "block", fontSize: 13, fontWeight: 500, marginBottom: 4 }, children: [
243
+ label,
244
+ required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { color: "#dc2626", marginLeft: 2 }, children: "*" })
245
+ ] }),
246
+ children,
247
+ error && /* @__PURE__ */ jsx("p", { role: "alert", style: { marginTop: 4, fontSize: 12, color: "#dc2626" }, children: error }),
248
+ hint && !error && /* @__PURE__ */ jsx("p", { style: { marginTop: 4, fontSize: 12, color: "#6b7280" }, children: hint })
249
+ ] });
250
+ };
251
+ FormField.displayName = "FormField";
252
+ var Tabs = (props) => {
253
+ const HostTabs = getHostUi("Tabs");
254
+ if (HostTabs) return /* @__PURE__ */ jsx(HostTabs, { ...props });
255
+ const { tabs, defaultActiveIndex = 0, activeIndex, onTabChange, children, className } = props;
256
+ const [internalIndex, setInternalIndex] = React.useState(defaultActiveIndex);
257
+ const isControlled = activeIndex !== void 0;
258
+ const currentIndex = isControlled ? activeIndex : internalIndex;
259
+ const activeTab = tabs[currentIndex];
260
+ const selectTab = (index) => {
261
+ if (tabs[index]?.disabled) return;
262
+ if (!isControlled) setInternalIndex(index);
263
+ onTabChange?.(index);
264
+ };
265
+ return /* @__PURE__ */ jsxs("div", { className, style: fallbackNote, children: [
266
+ /* @__PURE__ */ jsx("div", { role: "tablist", style: { display: "flex", gap: 4, borderBottom: "1px solid #d1d5db" }, children: tabs.map((tab, index) => /* @__PURE__ */ jsx(
267
+ "button",
268
+ {
269
+ type: "button",
270
+ role: "tab",
271
+ "aria-selected": index === currentIndex,
272
+ disabled: tab.disabled,
273
+ onClick: () => selectTab(index),
274
+ style: {
275
+ padding: "6px 12px",
276
+ border: "none",
277
+ borderBottom: index === currentIndex ? "2px solid currentColor" : "2px solid transparent",
278
+ background: "transparent",
279
+ cursor: tab.disabled ? "not-allowed" : "pointer",
280
+ fontWeight: index === currentIndex ? 600 : 400,
281
+ opacity: tab.disabled ? 0.5 : 1
282
+ },
283
+ children: tab.label
284
+ },
285
+ tab.key ?? index
286
+ )) }),
287
+ /* @__PURE__ */ jsx("div", { role: "tabpanel", style: { padding: 12 }, children: children || activeTab?.content })
288
+ ] });
289
+ };
290
+ Tabs.displayName = "Tabs";
291
+ var EmptyState = (props) => {
292
+ const HostEmptyState = getHostUi("EmptyState");
293
+ if (HostEmptyState) return /* @__PURE__ */ jsx(HostEmptyState, { ...props });
294
+ const { icon, title, description, action, className } = props;
295
+ return /* @__PURE__ */ jsxs("div", { className, style: { ...fallbackNote, textAlign: "center", padding: "32px 16px" }, children: [
296
+ icon && /* @__PURE__ */ jsx("div", { style: { marginBottom: 12 }, children: icon }),
297
+ /* @__PURE__ */ jsx("p", { style: { fontWeight: 600, marginBottom: description ? 4 : 0 }, children: title }),
298
+ description && /* @__PURE__ */ jsx("p", { style: { fontSize: 13, color: "#6b7280", marginBottom: action ? 12 : 0 }, children: description }),
299
+ action
300
+ ] });
301
+ };
302
+ EmptyState.displayName = "EmptyState";
303
+ var skeletonRadius = { text: 4, circular: "50%", rectangular: 8 };
304
+ var Skeleton = (props) => {
305
+ const HostSkeleton = getHostUi("Skeleton");
306
+ if (HostSkeleton) return /* @__PURE__ */ jsx(HostSkeleton, { ...props });
307
+ const { variant = "text", width, height, style, ...rest } = props;
308
+ return /* @__PURE__ */ jsx(
309
+ "div",
310
+ {
311
+ "aria-hidden": "true",
312
+ style: {
313
+ background: "#e5e7eb",
314
+ borderRadius: skeletonRadius[variant],
315
+ width: width ?? (variant === "text" ? "100%" : void 0),
316
+ height: height ?? (variant === "text" ? 14 : void 0),
317
+ ...style
318
+ },
319
+ ...rest
320
+ }
321
+ );
322
+ };
323
+ Skeleton.displayName = "Skeleton";
324
+ var SkeletonText = (props) => {
325
+ const HostSkeletonText = getHostUi("SkeletonText");
326
+ if (HostSkeletonText) return /* @__PURE__ */ jsx(HostSkeletonText, { ...props });
327
+ const { lines = 3, width = "100%", lastLineWidth = "80%", className } = props;
328
+ return /* @__PURE__ */ jsx("div", { className, style: { display: "flex", flexDirection: "column", gap: 8 }, children: Array.from({ length: lines }).map((_, index) => /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: index === lines - 1 ? lastLineWidth : width }, index)) });
329
+ };
330
+ SkeletonText.displayName = "SkeletonText";
331
+ var SkeletonCard = (props) => {
332
+ const HostSkeletonCard = getHostUi("SkeletonCard");
333
+ if (HostSkeletonCard) return /* @__PURE__ */ jsx(HostSkeletonCard, { ...props });
334
+ const { hasAvatar, hasActions, className } = props;
335
+ return /* @__PURE__ */ jsxs("div", { className, style: { border: "1px solid #e5e7eb", borderRadius: 8, padding: 16 }, children: [
336
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 12 }, children: [
337
+ hasAvatar && /* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: 40, height: 40 }),
338
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
339
+ /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "60%" }),
340
+ /* @__PURE__ */ jsx("div", { style: { marginTop: 8 }, children: /* @__PURE__ */ jsx(SkeletonText, { lines: 2 }) })
341
+ ] })
342
+ ] }),
343
+ hasActions && /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8, marginTop: 12 }, children: [
344
+ /* @__PURE__ */ jsx(Skeleton, { variant: "rectangular", width: 72, height: 30 }),
345
+ /* @__PURE__ */ jsx(Skeleton, { variant: "rectangular", width: 72, height: 30 })
346
+ ] })
347
+ ] });
348
+ };
349
+ SkeletonCard.displayName = "SkeletonCard";
350
+ var Tooltip = (props) => {
351
+ const HostTooltip = getHostUi("Tooltip");
352
+ if (HostTooltip) return /* @__PURE__ */ jsx(HostTooltip, { ...props });
353
+ const { content, disabled, className, children } = props;
354
+ const titleText = typeof content === "string" ? content : void 0;
355
+ if (disabled || !titleText) return /* @__PURE__ */ jsx(Fragment, { children });
356
+ return /* @__PURE__ */ jsx("span", { className, title: titleText, style: { display: "inline-flex" }, children });
357
+ };
358
+ Tooltip.displayName = "Tooltip";
359
+ var spinnerDiameter = { sm: 16, md: 24, lg: 32 };
360
+ var Spinner = (props) => {
361
+ const HostSpinner = getHostUi("Spinner");
362
+ if (HostSpinner) return /* @__PURE__ */ jsx(HostSpinner, { ...props });
363
+ const { size = "md", className, label } = props;
364
+ const diameter = spinnerDiameter[size];
365
+ return /* @__PURE__ */ jsxs("div", { className, role: "status", "aria-live": "polite", style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
366
+ /* @__PURE__ */ jsx(
367
+ "div",
368
+ {
369
+ "aria-hidden": "true",
370
+ style: {
371
+ width: diameter,
372
+ height: diameter,
373
+ borderRadius: "50%",
374
+ border: "2px solid currentColor",
375
+ borderTopColor: "transparent",
376
+ animation: "vx-sdk-spin 0.8s linear infinite"
377
+ }
378
+ }
379
+ ),
380
+ label && /* @__PURE__ */ jsx("p", { style: { marginTop: 8, fontSize: 12, color: "#6b7280" }, children: label }),
381
+ /* @__PURE__ */ jsx("span", { style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" }, children: label || "Loading" }),
382
+ /* @__PURE__ */ jsx("style", { children: "@keyframes vx-sdk-spin { to { transform: rotate(360deg) } }" })
383
+ ] });
384
+ };
385
+ Spinner.displayName = "Spinner";
386
+ function FallbackDataTable(props) {
387
+ const { columns, data, rowKey, isLoading, emptyState, onRowClick, rowActions, className } = props;
388
+ const showEmpty = !isLoading && data.length === 0;
389
+ return /* @__PURE__ */ jsx("div", { className, style: fallbackNote, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
390
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
391
+ columns.map((column) => /* @__PURE__ */ jsx("th", { style: { textAlign: column.align ?? "left", padding: "8px 10px", borderBottom: "1px solid #d1d5db" }, children: column.header }, column.key)),
392
+ rowActions && /* @__PURE__ */ jsx("th", { style: { padding: "8px 10px", borderBottom: "1px solid #d1d5db" } })
393
+ ] }) }),
394
+ /* @__PURE__ */ jsxs("tbody", { children: [
395
+ isLoading && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: Math.max(columns.length + (rowActions ? 1 : 0), 1), style: { padding: "12px 10px" }, children: "Loading\u2026" }) }),
396
+ showEmpty && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: Math.max(columns.length + (rowActions ? 1 : 0), 1), children: /* @__PURE__ */ jsx(EmptyState, { title: emptyState?.title ?? "No data", description: emptyState?.description, icon: emptyState?.icon, action: emptyState?.action }) }) }),
397
+ !isLoading && !showEmpty && data.map((row) => /* @__PURE__ */ jsxs(
398
+ "tr",
399
+ {
400
+ onClick: onRowClick ? () => onRowClick(row) : void 0,
401
+ style: { cursor: onRowClick ? "pointer" : void 0, borderBottom: "1px solid #e5e7eb" },
402
+ children: [
403
+ columns.map((column) => /* @__PURE__ */ jsx("td", { style: { textAlign: column.align ?? "left", padding: "8px 10px" }, children: column.render ? column.render(row) : String(row[column.key] ?? "") }, column.key)),
404
+ rowActions && /* @__PURE__ */ jsx("td", { style: { padding: "8px 10px" }, onClick: (event) => event.stopPropagation(), children: rowActions(row) })
405
+ ]
406
+ },
407
+ rowKey(row)
408
+ ))
409
+ ] })
410
+ ] }) });
411
+ }
412
+ function DataTable(props) {
413
+ const HostDataTable = getHostUi("DataTable");
414
+ if (HostDataTable) return /* @__PURE__ */ jsx(HostDataTable, { ...props });
415
+ return /* @__PURE__ */ jsx(FallbackDataTable, { ...props });
416
+ }
417
+ var DELTA_FALLBACK_COLOR = {
418
+ up: "#16a34a",
419
+ down: "#dc2626",
420
+ neutral: "#6b7280"
421
+ };
422
+ var StatsCard = (props) => {
423
+ const HostStatsCard = getHostUi("StatsCard");
424
+ if (HostStatsCard) return /* @__PURE__ */ jsx(HostStatsCard, { ...props });
425
+ const { label, value, icon, delta, isLoading, onClick, className } = props;
426
+ const isClickable = Boolean(onClick);
427
+ return /* @__PURE__ */ jsxs(
428
+ "div",
429
+ {
430
+ role: isClickable ? "button" : void 0,
431
+ tabIndex: isClickable ? 0 : void 0,
432
+ onClick,
433
+ onKeyDown: isClickable ? (event) => {
434
+ if (event.key === "Enter" || event.key === " ") {
435
+ event.preventDefault();
436
+ onClick?.();
437
+ }
438
+ } : void 0,
439
+ className,
440
+ style: {
441
+ ...fallbackNote,
442
+ border: "1px solid #d1d5db",
443
+ borderRadius: 8,
444
+ padding: 16,
445
+ display: "flex",
446
+ alignItems: "flex-start",
447
+ justifyContent: "space-between",
448
+ gap: 12,
449
+ cursor: isClickable ? "pointer" : void 0
450
+ },
451
+ children: [
452
+ /* @__PURE__ */ jsxs("div", { style: { minWidth: 0, flex: 1 }, children: [
453
+ /* @__PURE__ */ jsx("p", { style: { fontSize: 13, color: "#6b7280", margin: 0 }, children: label }),
454
+ /* @__PURE__ */ jsx("p", { style: { fontSize: 28, fontWeight: 700, margin: "4px 0 0" }, children: isLoading ? "\u2026" : value }),
455
+ delta && !isLoading && /* @__PURE__ */ jsxs("p", { style: { fontSize: 13, color: DELTA_FALLBACK_COLOR[delta.direction], margin: "4px 0 0" }, children: [
456
+ delta.value,
457
+ " ",
458
+ delta.label
459
+ ] })
460
+ ] }),
461
+ icon && /* @__PURE__ */ jsx("div", { "aria-hidden": "true", children: icon })
462
+ ]
463
+ }
464
+ );
465
+ };
466
+ StatsCard.displayName = "StatsCard";
467
+ var FORM_DIALOG_MAX_WIDTH = { sm: 420, md: 520, lg: 680 };
468
+ var FormDialog = (props) => {
469
+ const HostFormDialog = getHostUi("FormDialog");
470
+ if (HostFormDialog) return /* @__PURE__ */ jsx(HostFormDialog, { ...props });
471
+ const {
472
+ isOpen,
473
+ onClose,
474
+ title,
475
+ description,
476
+ children,
477
+ onSubmit,
478
+ submitText = "Save",
479
+ cancelText = "Cancel",
480
+ isSubmitting = false,
481
+ error = null,
482
+ size = "md",
483
+ disableBackdropClose = false,
484
+ submitDisabled = false
485
+ } = props;
486
+ React.useEffect(() => {
487
+ if (!isOpen) return;
488
+ const handleKeyDown = (event) => {
489
+ if (event.key === "Escape" && !isSubmitting) onClose();
490
+ };
491
+ document.addEventListener("keydown", handleKeyDown);
492
+ return () => document.removeEventListener("keydown", handleKeyDown);
493
+ }, [isOpen, isSubmitting, onClose]);
494
+ if (!isOpen) return null;
495
+ const requestClose = () => {
496
+ if (!isSubmitting) onClose();
497
+ };
498
+ return /* @__PURE__ */ jsx(
499
+ "div",
500
+ {
501
+ style: { position: "fixed", inset: 0, background: "rgba(0,0,0,0.5)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 50 },
502
+ onClick: disableBackdropClose ? void 0 : requestClose,
503
+ children: /* @__PURE__ */ jsx(
504
+ "div",
505
+ {
506
+ role: "dialog",
507
+ "aria-modal": "true",
508
+ "aria-label": title,
509
+ style: { background: "white", color: "black", borderRadius: 8, width: "100%", maxWidth: FORM_DIALOG_MAX_WIDTH[size], maxHeight: "80vh", overflow: "auto", ...fallbackNote },
510
+ onClick: (event) => event.stopPropagation(),
511
+ children: /* @__PURE__ */ jsxs(
512
+ "form",
513
+ {
514
+ onSubmit: (event) => {
515
+ event.preventDefault();
516
+ void onSubmit();
517
+ },
518
+ children: [
519
+ /* @__PURE__ */ jsxs("div", { style: { padding: 16, borderBottom: "1px solid #d1d5db" }, children: [
520
+ /* @__PURE__ */ jsx("h3", { style: { margin: 0, fontSize: 16, fontWeight: 600 }, children: title }),
521
+ description && /* @__PURE__ */ jsx("p", { style: { margin: "4px 0 0", fontSize: 13, color: "#6b7280" }, children: description })
522
+ ] }),
523
+ /* @__PURE__ */ jsxs("div", { style: { padding: 16, display: "flex", flexDirection: "column", gap: 12 }, children: [
524
+ error && /* @__PURE__ */ jsx("p", { role: "alert", style: { margin: 0, fontSize: 13, color: "#dc2626" }, children: error }),
525
+ children
526
+ ] }),
527
+ /* @__PURE__ */ jsxs("div", { style: { padding: 16, borderTop: "1px solid #d1d5db", display: "flex", justifyContent: "flex-end", gap: 8 }, children: [
528
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", onClick: requestClose, disabled: isSubmitting, children: cancelText }),
529
+ /* @__PURE__ */ jsx(Button, { type: "submit", variant: "primary", isLoading: isSubmitting, disabled: submitDisabled, children: submitText })
530
+ ] })
531
+ ]
532
+ }
533
+ )
534
+ }
535
+ )
536
+ }
537
+ );
538
+ };
539
+ FormDialog.displayName = "FormDialog";
540
+ function fallbackToast(message, options) {
541
+ console.warn(`[@veltrixsecops/app-sdk/ui] Toast (${options?.variant ?? "info"}): ${message}`);
542
+ return "fallback-toast";
543
+ }
544
+ var fallbackToastContext = {
545
+ toasts: [],
546
+ toast: fallbackToast,
547
+ success: (message) => fallbackToast(message, { variant: "success" }),
548
+ error: (message) => fallbackToast(message, { variant: "error" }),
549
+ warning: (message) => fallbackToast(message, { variant: "warning" }),
550
+ info: (message) => fallbackToast(message, { variant: "info" }),
551
+ promise: (promise) => promise,
552
+ dismiss: () => {
553
+ },
554
+ dismissAll: () => {
555
+ }
556
+ };
557
+ function useToast() {
558
+ const hostUseToast = getHostUi("useToast");
559
+ if (hostUseToast) return hostUseToast();
560
+ return fallbackToastContext;
561
+ }
562
+ var fallbackConfirmationContext = {
563
+ confirm: (options) => {
564
+ console.warn(
565
+ `[@veltrixsecops/app-sdk/ui] ConfirmationDialog is only available inside the Veltrix platform \u2014 "${options.title}" auto-resolved to "not confirmed" (fail closed).`
566
+ );
567
+ return Promise.resolve(false);
568
+ }
569
+ };
570
+ function useConfirmDialog() {
571
+ const hostUseConfirmDialog = getHostUi("useConfirmDialog");
572
+ if (hostUseConfirmDialog) return hostUseConfirmDialog();
573
+ return fallbackConfirmationContext;
574
+ }
575
+ export {
576
+ Badge,
577
+ Button,
578
+ Card,
579
+ CardBody,
580
+ CardFooter,
581
+ CardHeader,
582
+ Checkbox,
583
+ DataTable,
584
+ EmptyState,
585
+ FormDialog,
586
+ FormField,
587
+ Input,
588
+ Select,
589
+ Skeleton,
590
+ SkeletonCard,
591
+ SkeletonText,
592
+ Spinner,
593
+ StatsCard,
594
+ Tabs,
595
+ Textarea,
596
+ Tooltip,
597
+ useConfirmDialog,
598
+ useToast
599
+ };
600
+ //# sourceMappingURL=index.js.map