@sampleapp.ai/sdk 1.0.29 → 1.0.31
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/components/guardian/app-layout-no-sidebar.js +8 -0
- package/dist/components/guardian/ask-ai-view.js +249 -0
- package/dist/components/guardian/code-focus-section.d.ts +41 -0
- package/dist/components/guardian/code-focus-section.js +174 -0
- package/dist/components/guardian/context/guardian-context.js +94 -0
- package/dist/components/guardian/context/vm-context.js +28 -0
- package/dist/components/guardian/default-guide-view.js +34 -0
- package/dist/components/guardian/demo/guardian-demo.js +35 -0
- package/dist/components/guardian/demo/left-view/toggle.js +28 -0
- package/dist/components/guardian/demo/left-view.js +49 -0
- package/dist/components/guardian/guardian-component.js +79 -0
- package/dist/components/guardian/guardian-demo.js +35 -0
- package/dist/components/guardian/guardian-home.d.ts +4 -0
- package/dist/components/guardian/guardian-home.js +61 -0
- package/dist/components/guardian/guardian-playground.js +45 -0
- package/dist/components/guardian/guardian-style-wrapper.js +29 -0
- package/dist/components/guardian/guardian-upload-spec.d.ts +14 -0
- package/dist/components/guardian/guardian-upload-spec.js +160 -0
- package/dist/components/guardian/header/glassmorphic-combobox.d.ts +15 -0
- package/dist/components/guardian/header/glassmorphic-combobox.js +30 -0
- package/dist/components/guardian/header.js +61 -0
- package/dist/components/guardian/hooks/use-frame-messages.js +65 -0
- package/dist/components/guardian/hooks/use-frame-params.js +44 -0
- package/dist/components/guardian/hooks/use-sandbox-url-loader.js +101 -0
- package/dist/components/guardian/ide/browser.js +538 -0
- package/dist/components/guardian/index.js +8 -0
- package/dist/components/guardian/layout/app-layout-no-sidebar.js +8 -0
- package/dist/components/guardian/layout/header/glassmorphic-combobox.js +48 -0
- package/dist/components/guardian/layout/header.js +63 -0
- package/dist/components/guardian/right-view/code-view.js +56 -0
- package/dist/components/guardian/right-view/pill-file-selector.js +233 -0
- package/dist/components/guardian/right-view/preview-control-bar.js +25 -0
- package/dist/components/guardian/right-view/right-panel-view.js +38 -0
- package/dist/components/guardian/right-view/right-top-down-view.js +289 -0
- package/dist/components/guardian/right-view/right-view.js +28 -0
- package/dist/components/guardian/right-view/simplified-editor.js +234 -0
- package/dist/components/guardian/types/ide-types.js +162 -0
- package/dist/components/guardian/types.js +3 -0
- package/dist/components/guardian/ui/ai-loader.js +48 -0
- package/dist/components/guardian/ui/badge.js +24 -0
- package/dist/components/guardian/ui/button.js +45 -0
- package/dist/components/guardian/ui/command.js +63 -0
- package/dist/components/guardian/ui/console-with-app.js +17 -0
- package/dist/components/guardian/ui/dialog.js +57 -0
- package/dist/components/guardian/ui/dropdown-menu.js +82 -0
- package/dist/components/guardian/ui/markdown.js +57 -0
- package/dist/components/guardian/ui/popover.js +25 -0
- package/dist/components/guardian/ui/tooltip.js +25 -0
- package/dist/components/guardian/utils.js +88 -0
- package/dist/components/guardian/zip-to-codebase.js +246 -0
- package/dist/components/guardian/zip-to-filetree.js +284 -0
- package/dist/components/icons.js +22 -0
- package/dist/components/sandbox/Sandbox.js +88 -0
- package/dist/components/sandbox/SandboxHome.js +141 -0
- package/dist/components/sandbox/api.js +84 -0
- package/dist/components/sandbox/guardian/app-layout-no-sidebar.js +11 -0
- package/dist/components/sandbox/guardian/ask-ai-view.js +249 -0
- package/dist/components/sandbox/guardian/code-focus-section.js +174 -0
- package/dist/components/sandbox/guardian/context/guardian-context.js +94 -0
- package/dist/components/sandbox/guardian/context/vm-context.js +28 -0
- package/dist/components/sandbox/guardian/default-guide-view.js +34 -0
- package/dist/components/sandbox/guardian/demo/guardian-demo.js +35 -0
- package/dist/components/sandbox/guardian/demo/left-view/toggle.js +28 -0
- package/dist/components/sandbox/guardian/demo/left-view.js +70 -0
- package/dist/components/sandbox/guardian/guardian-component.js +99 -0
- package/dist/components/sandbox/guardian/guardian-demo.js +35 -0
- package/dist/components/sandbox/guardian/guardian-home.d.ts +4 -0
- package/dist/components/sandbox/guardian/guardian-home.js +61 -0
- package/dist/components/sandbox/guardian/guardian-playground.js +45 -0
- package/dist/components/sandbox/guardian/guardian-style-wrapper.js +47 -0
- package/dist/components/sandbox/guardian/guardian-upload-spec.d.ts +14 -0
- package/dist/components/sandbox/guardian/guardian-upload-spec.js +160 -0
- package/dist/components/sandbox/guardian/header/glassmorphic-combobox.js +30 -0
- package/dist/components/sandbox/guardian/header.js +61 -0
- package/dist/components/sandbox/guardian/hooks/use-frame-messages.js +65 -0
- package/dist/components/sandbox/guardian/hooks/use-frame-params.js +44 -0
- package/dist/components/sandbox/guardian/hooks/use-sandbox-url-loader.js +125 -0
- package/dist/components/sandbox/guardian/ide/browser.js +538 -0
- package/dist/components/sandbox/guardian/index.js +8 -0
- package/dist/components/sandbox/guardian/right-view/code-view.js +60 -0
- package/dist/components/sandbox/guardian/right-view/pill-file-selector.js +246 -0
- package/dist/components/sandbox/guardian/right-view/preview-control-bar.js +25 -0
- package/dist/components/sandbox/guardian/right-view/right-panel-view.js +51 -0
- package/dist/components/sandbox/guardian/right-view/right-top-down-view.js +281 -0
- package/dist/components/sandbox/guardian/right-view/right-view.js +28 -0
- package/dist/components/sandbox/guardian/right-view/simplified-editor.js +234 -0
- package/dist/components/sandbox/guardian/types/ide-types.js +162 -0
- package/dist/components/sandbox/guardian/types.js +3 -0
- package/dist/components/sandbox/guardian/ui/ai-loader.js +91 -0
- package/dist/components/sandbox/guardian/ui/badge.js +24 -0
- package/dist/components/sandbox/guardian/ui/button.js +45 -0
- package/dist/components/sandbox/guardian/ui/command.js +63 -0
- package/dist/components/sandbox/guardian/ui/console-with-app.js +17 -0
- package/dist/components/sandbox/guardian/ui/dialog.js +57 -0
- package/dist/components/sandbox/guardian/ui/download-and-open-buttons.js +117 -0
- package/dist/components/sandbox/guardian/ui/dropdown-menu.js +82 -0
- package/dist/components/sandbox/guardian/ui/markdown/accordion-group/accordion.js +62 -0
- package/dist/components/sandbox/guardian/ui/markdown/accordion-group.js +23 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-check.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-error.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-info.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-note.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-tip.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-warning.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/shared/callout.js +9 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/shared/types.js +1 -0
- package/dist/components/sandbox/guardian/ui/markdown/card-group/card.js +18 -0
- package/dist/components/sandbox/guardian/ui/markdown/card-group.js +25 -0
- package/dist/components/sandbox/guardian/ui/markdown/code-group/code-block.js +54 -0
- package/dist/components/sandbox/guardian/ui/markdown/code-group.js +101 -0
- package/dist/components/sandbox/guardian/ui/markdown/icon.js +31 -0
- package/dist/components/sandbox/guardian/ui/markdown.js +791 -0
- package/dist/components/sandbox/guardian/ui/popover.js +25 -0
- package/dist/components/sandbox/guardian/ui/tooltip.js +25 -0
- package/dist/components/sandbox/guardian/utils.js +89 -0
- package/dist/components/sandbox/guardian/zip-to-codebase.js +259 -0
- package/dist/components/sandbox/guardian/zip-to-filetree.js +284 -0
- package/dist/components/sandbox/index.js +4 -0
- package/dist/components/sandbox/sandbox-control-bar.js +91 -0
- package/dist/components/sandbox/sandbox-header.js +52 -0
- package/dist/components/sandbox/sandbox-home/SandboxCard.js +65 -0
- package/dist/components/sandbox/sandbox-home/SandboxHome.js +115 -0
- package/dist/components/sandbox/sandbox-home/SearchBar.js +12 -0
- package/dist/components/sandbox/sandbox-home/index.js +3 -0
- package/dist/components/sandbox/sandbox-left-panel.js +248 -0
- package/dist/components/sandbox/sandbox-loading.js +48 -0
- package/dist/components/sandbox/sandbox-right-panel.js +247 -0
- package/dist/components/sandbox/types.js +1 -0
- package/dist/components/sandbox.js +32 -0
- package/dist/components/tailwind-example.js +46 -0
- package/dist/components/ui/skeleton.js +18 -0
- package/dist/index.d.ts +32 -103
- package/dist/index.es.js +90529 -423
- package/dist/index.js +13 -2
- package/dist/index.standalone.js +61 -53
- package/dist/index.standalone.umd.js +17 -24
- package/dist/lib/api-client.example.js +60 -0
- package/dist/lib/api-client.js +140 -0
- package/dist/lib/generated-css.js +4 -0
- package/dist/lib/inject-styles.js +42 -0
- package/dist/lib/shadow-dom-wrapper.js +42 -0
- package/dist/lib/utils.js +5 -0
- package/dist/sdk.css +1 -1
- package/dist/tailwind.css +1 -0
- package/package.json +41 -9
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
15
|
+
import { Check, ChevronRight, Circle } from "lucide-react";
|
|
16
|
+
import { cn } from "../../../../lib/utils";
|
|
17
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
18
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
19
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
20
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
21
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
22
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
23
|
+
const DropdownMenuSubTrigger = React.forwardRef((_a, ref) => {
|
|
24
|
+
var { className, inset, children, hideChevron } = _a, props = __rest(_a, ["className", "inset", "children", "hideChevron"]);
|
|
25
|
+
return (React.createElement(DropdownMenuPrimitive.SubTrigger, Object.assign({ ref: ref, className: cn("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", inset && "pl-8", className) }, props),
|
|
26
|
+
children,
|
|
27
|
+
!hideChevron && React.createElement(ChevronRight, { className: "ml-auto" })));
|
|
28
|
+
});
|
|
29
|
+
DropdownMenuSubTrigger.displayName =
|
|
30
|
+
DropdownMenuPrimitive.SubTrigger.displayName;
|
|
31
|
+
const DropdownMenuSubContent = React.forwardRef((_a, ref) => {
|
|
32
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
33
|
+
return (React.createElement(DropdownMenuPrimitive.SubContent, Object.assign({ ref: ref, className: cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props)));
|
|
34
|
+
});
|
|
35
|
+
DropdownMenuSubContent.displayName =
|
|
36
|
+
DropdownMenuPrimitive.SubContent.displayName;
|
|
37
|
+
const DropdownMenuContent = React.forwardRef((_a, ref) => {
|
|
38
|
+
var { className, sideOffset = 4 } = _a, props = __rest(_a, ["className", "sideOffset"]);
|
|
39
|
+
return (React.createElement(DropdownMenuPrimitive.Portal, null,
|
|
40
|
+
React.createElement(DropdownMenuPrimitive.Content, Object.assign({ ref: ref, sideOffset: sideOffset, className: cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props))));
|
|
41
|
+
});
|
|
42
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
43
|
+
const DropdownMenuItem = React.forwardRef((_a, ref) => {
|
|
44
|
+
var { className, inset } = _a, props = __rest(_a, ["className", "inset"]);
|
|
45
|
+
return (React.createElement(DropdownMenuPrimitive.Item, Object.assign({ ref: ref, className: cn("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", inset && "pl-8", className) }, props)));
|
|
46
|
+
});
|
|
47
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
48
|
+
const DropdownMenuCheckboxItem = React.forwardRef((_a, ref) => {
|
|
49
|
+
var { className, children, checked } = _a, props = __rest(_a, ["className", "children", "checked"]);
|
|
50
|
+
return (React.createElement(DropdownMenuPrimitive.CheckboxItem, Object.assign({ ref: ref, className: cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), checked: checked }, props),
|
|
51
|
+
React.createElement("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center" },
|
|
52
|
+
React.createElement(DropdownMenuPrimitive.ItemIndicator, null,
|
|
53
|
+
React.createElement(Check, { className: "h-4 w-4" }))),
|
|
54
|
+
children));
|
|
55
|
+
});
|
|
56
|
+
DropdownMenuCheckboxItem.displayName =
|
|
57
|
+
DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
58
|
+
const DropdownMenuRadioItem = React.forwardRef((_a, ref) => {
|
|
59
|
+
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
60
|
+
return (React.createElement(DropdownMenuPrimitive.RadioItem, Object.assign({ ref: ref, className: cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className) }, props),
|
|
61
|
+
React.createElement("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center" },
|
|
62
|
+
React.createElement(DropdownMenuPrimitive.ItemIndicator, null,
|
|
63
|
+
React.createElement(Circle, { className: "h-2 w-2 fill-current" }))),
|
|
64
|
+
children));
|
|
65
|
+
});
|
|
66
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
67
|
+
const DropdownMenuLabel = React.forwardRef((_a, ref) => {
|
|
68
|
+
var { className, inset } = _a, props = __rest(_a, ["className", "inset"]);
|
|
69
|
+
return (React.createElement(DropdownMenuPrimitive.Label, Object.assign({ ref: ref, className: cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className) }, props)));
|
|
70
|
+
});
|
|
71
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
72
|
+
const DropdownMenuSeparator = React.forwardRef((_a, ref) => {
|
|
73
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
74
|
+
return (React.createElement(DropdownMenuPrimitive.Separator, Object.assign({ ref: ref, className: cn("-mx-1 my-1 h-px bg-muted", className) }, props)));
|
|
75
|
+
});
|
|
76
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
77
|
+
const DropdownMenuShortcut = (_a) => {
|
|
78
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
79
|
+
return (React.createElement("span", Object.assign({ className: cn("ml-auto text-xs tracking-widest opacity-60", className) }, props)));
|
|
80
|
+
};
|
|
81
|
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
82
|
+
export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup, };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { cn } from "../../../../../../lib/utils";
|
|
3
|
+
import { ChevronRight } from "lucide-react";
|
|
4
|
+
import * as LucideIcons from "lucide-react";
|
|
5
|
+
import { Markdown } from "../../markdown";
|
|
6
|
+
export const Accordion = ({ title, children, icon, defaultOpen = false, className, inGroup = false, }) => {
|
|
7
|
+
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
8
|
+
const IconComponent = icon
|
|
9
|
+
? LucideIcons[icon]
|
|
10
|
+
: null;
|
|
11
|
+
const processNode = (node) => {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
13
|
+
// Handle string nodes (like whitespace and text)
|
|
14
|
+
if (typeof node === "string") {
|
|
15
|
+
return node;
|
|
16
|
+
}
|
|
17
|
+
// Handle arrays (like the root structure)
|
|
18
|
+
if (Array.isArray(node)) {
|
|
19
|
+
return node.map((item) => processNode(item)).join("");
|
|
20
|
+
}
|
|
21
|
+
// Handle React elements and objects
|
|
22
|
+
if (React.isValidElement(node) || (node && typeof node === "object")) {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
const element = node; // Type assertion for accessing properties
|
|
25
|
+
// Handle pre elements
|
|
26
|
+
if (element.type === "pre") {
|
|
27
|
+
const preChildren = (_a = element.props) === null || _a === void 0 ? void 0 : _a.children;
|
|
28
|
+
// Handle the nested code structure
|
|
29
|
+
if ((_b = preChildren === null || preChildren === void 0 ? void 0 : preChildren.props) === null || _b === void 0 ? void 0 : _b.children) {
|
|
30
|
+
return preChildren.props.children;
|
|
31
|
+
}
|
|
32
|
+
// Handle direct code content
|
|
33
|
+
if ((_f = (_e = (_d = (_c = preChildren === null || preChildren === void 0 ? void 0 : preChildren.props) === null || _c === void 0 ? void 0 : _c.node) === null || _d === void 0 ? void 0 : _d.children) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.value) {
|
|
34
|
+
return preChildren.props.node.children[0].value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Recursively process children
|
|
38
|
+
if ((_g = element.props) === null || _g === void 0 ? void 0 : _g.children) {
|
|
39
|
+
return processNode(element.props.children);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return "";
|
|
43
|
+
};
|
|
44
|
+
const markdownContent = processNode(children).trim();
|
|
45
|
+
return (React.createElement("div", { className: cn(inGroup
|
|
46
|
+
? "border-b border-zinc-200 last:border-0 dark:border-zinc-800"
|
|
47
|
+
: "rounded-lg border border-zinc-200 dark:border-zinc-800", className) },
|
|
48
|
+
React.createElement("button", { onClick: () => setIsOpen(!isOpen), className: cn("flex w-full items-center justify-between px-4 py-3", inGroup
|
|
49
|
+
? "hover:bg-zinc-100 dark:hover:bg-zinc-800/70"
|
|
50
|
+
: "rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-800/70", "bg-transparent focus:outline-none focus-visible:ring-2 focus-visible:ring-[#0066FF] dark:focus-visible:ring-[#66A3FF]", isOpen && "bg-zinc-100 dark:bg-zinc-800") },
|
|
51
|
+
React.createElement("div", { className: "flex items-center gap-2" },
|
|
52
|
+
React.createElement(ChevronRight, { className: cn("h-4 w-4 transition-transform duration-200", isOpen
|
|
53
|
+
? "rotate-90 text-[#0066FF] dark:text-[#66A3FF]"
|
|
54
|
+
: "text-zinc-500 dark:text-zinc-400") }),
|
|
55
|
+
IconComponent && (React.createElement(IconComponent, { className: "h-4 w-4 flex-shrink-0 text-[#0066FF] dark:text-[#66A3FF]" })),
|
|
56
|
+
React.createElement("span", { className: cn("text-sm font-medium", isOpen
|
|
57
|
+
? "text-[#0066FF] dark:text-[#66A3FF]"
|
|
58
|
+
: "text-zinc-700 dark:text-zinc-200") }, title))),
|
|
59
|
+
React.createElement("div", { className: cn("overflow-hidden transition-all duration-200", isOpen ? "max-h-[1000px] opacity-100" : "max-h-0 opacity-0") },
|
|
60
|
+
React.createElement("div", { className: "px-4 py-3 text-sm text-zinc-600 dark:text-zinc-300 bg-transparent" },
|
|
61
|
+
React.createElement(Markdown, null, markdownContent)))));
|
|
62
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "../../../../../lib/utils";
|
|
3
|
+
export const AccordionGroup = ({ children, className, }) => {
|
|
4
|
+
// More strict version with type checking
|
|
5
|
+
const childrenWithProps = React.Children.map(children, (child) => {
|
|
6
|
+
if (!React.isValidElement(child)) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
// Type guard to check if the child has the expected props
|
|
10
|
+
const hasRequiredProps = (element) => {
|
|
11
|
+
return "children" in element.props;
|
|
12
|
+
};
|
|
13
|
+
if (!hasRequiredProps(child)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (typeof child.props.children === "string" &&
|
|
17
|
+
!child.props.children.trim()) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return React.cloneElement(child, Object.assign(Object.assign({}, child.props), { inGroup: true }));
|
|
21
|
+
});
|
|
22
|
+
return (React.createElement("div", { className: cn("rounded-lg border border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-950", className) }, childrenWithProps));
|
|
23
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Callout } from "./shared/callout";
|
|
2
|
+
import { CheckCircle2 } from "lucide-react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export const CalloutCheck = ({ children }) => (React.createElement(Callout, { className: "border-emerald-200 bg-emerald-100 text-emerald-900 dark:border-emerald-800/30 dark:bg-emerald-900/30 dark:text-emerald-200", icon: React.createElement(CheckCircle2, { className: "h-5 w-5 text-emerald-500 dark:text-emerald-400" }) }, children));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Callout } from "./shared/callout";
|
|
2
|
+
import { AlertTriangle } from "lucide-react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export const CalloutError = ({ children }) => (React.createElement(Callout, { className: "border-red-200 bg-red-100 text-red-900 dark:border-red-800/30 dark:bg-red-900/30 dark:text-red-200", icon: React.createElement(AlertTriangle, { className: "h-5 w-5 text-red-500 dark:text-red-400" }) }, children));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Callout } from "./shared/callout";
|
|
2
|
+
import { Info } from "lucide-react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export const CalloutInfo = ({ children }) => (React.createElement(Callout, { className: "border-blue-200 bg-blue-100 text-blue-900 dark:border-blue-800/30 dark:bg-blue-900/30 dark:text-blue-200", icon: React.createElement(Info, { className: "h-5 w-5 text-blue-500 dark:text-blue-400" }) }, children));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Callout } from "./shared/callout";
|
|
2
|
+
import { AlertCircle } from "lucide-react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export const CalloutNote = ({ children }) => (React.createElement(Callout, { className: "border-neutral-200 bg-neutral-100 text-neutral-900 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-200", icon: React.createElement(AlertCircle, { className: "h-5 w-5 text-neutral-500 dark:text-neutral-400" }) }, children));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Callout } from "./shared/callout";
|
|
2
|
+
import { Star } from "lucide-react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export const CalloutTip = ({ children }) => (React.createElement(Callout, { className: "border-emerald-200 bg-emerald-100 text-emerald-900 dark:border-emerald-800/30 dark:bg-emerald-900/30 dark:text-emerald-200", icon: React.createElement(Star, { className: "h-5 w-5 text-emerald-500 dark:text-emerald-400" }) }, children));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Callout } from "./shared/callout";
|
|
2
|
+
import { AlertTriangle } from "lucide-react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export const CalloutWarning = ({ children }) => (React.createElement(Callout, { className: "border-amber-200 bg-amber-100 text-amber-900 dark:border-amber-800/30 dark:bg-amber-900/30 dark:text-amber-200", icon: React.createElement(AlertTriangle, { className: "h-5 w-5 text-amber-500 dark:text-amber-400" }) }, children));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "../../../../../../../lib/utils";
|
|
3
|
+
import { Markdown } from "../../../markdown";
|
|
4
|
+
export const Callout = ({ children, className, icon }) => {
|
|
5
|
+
return (React.createElement("div", { className: cn("my-4 flex items-start gap-4 rounded-md border bg-opacity-10 p-4", className) },
|
|
6
|
+
icon && React.createElement("div", { className: "mt-0.5 flex-shrink-0" }, icon),
|
|
7
|
+
React.createElement("div", null,
|
|
8
|
+
React.createElement(Markdown, null, children))));
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "../../../../../../lib/utils";
|
|
3
|
+
import * as LucideIcons from "lucide-react";
|
|
4
|
+
export const Card = ({ title, children, icon, href, img, horizontal = false, className, }) => {
|
|
5
|
+
const IconComponent = icon
|
|
6
|
+
? LucideIcons[icon]
|
|
7
|
+
: null;
|
|
8
|
+
const CardContent = () => (React.createElement(React.Fragment, null,
|
|
9
|
+
img && (React.createElement("div", { className: "overflow-hidden rounded-t-lg" },
|
|
10
|
+
React.createElement("img", { src: img, alt: title, className: "aspect-[2/1] w-full object-cover" }))),
|
|
11
|
+
React.createElement("div", { className: cn("flex flex-col space-y-2", horizontal ? "flex-row items-start space-x-4 space-y-0" : "", img ? "p-4" : "p-6") },
|
|
12
|
+
React.createElement("div", { className: "flex-1" },
|
|
13
|
+
IconComponent && (React.createElement(IconComponent, { className: "mb-2 h-5 w-5 text-[#0066FF] dark:text-[#66A3FF]" })),
|
|
14
|
+
React.createElement("h3", { className: "font-bold text-zinc-900 dark:text-zinc-100" }, title),
|
|
15
|
+
React.createElement("p", { className: "mt-2 text-zinc-600 dark:text-zinc-400" }, children)))));
|
|
16
|
+
return (React.createElement("div", { className: cn("group relative rounded-lg border border-zinc-200 bg-white transition-shadow hover:shadow-md dark:border-zinc-800 dark:bg-zinc-950", className) }, href ? (React.createElement("a", { href: href, className: "flex h-full flex-col", target: "_blank", rel: "noopener noreferrer" },
|
|
17
|
+
React.createElement(CardContent, null))) : (React.createElement(CardContent, null))));
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "../../../../../lib/utils";
|
|
3
|
+
//TODO: Fix the bug on not being able to display different number of columns
|
|
4
|
+
export const CardGroup = ({ children, cols = 2, className, }) => {
|
|
5
|
+
// Helper function to get the correct column classes
|
|
6
|
+
const getColumnClass = () => {
|
|
7
|
+
switch (cols) {
|
|
8
|
+
case 1:
|
|
9
|
+
return "grid-cols-1";
|
|
10
|
+
case 2:
|
|
11
|
+
return "grid-cols-1 sm:grid-cols-2";
|
|
12
|
+
case 3:
|
|
13
|
+
return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3";
|
|
14
|
+
case 4:
|
|
15
|
+
return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4";
|
|
16
|
+
case 5:
|
|
17
|
+
return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-5";
|
|
18
|
+
case 6:
|
|
19
|
+
return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-6";
|
|
20
|
+
default:
|
|
21
|
+
return "grid-cols-1 sm:grid-cols-2";
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return (React.createElement("div", { className: cn("grid gap-4", getColumnClass(), className) }, children));
|
|
25
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { memo, useState } from "react";
|
|
2
|
+
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
3
|
+
import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
4
|
+
import { cn } from "../../../../../../lib/utils";
|
|
5
|
+
import { Copy, CheckCircle2 } from "lucide-react";
|
|
6
|
+
export const CodeBlock = memo(({ language, value, title, className, children, isInsideCodeGroup = false, maxH, }) => {
|
|
7
|
+
const [copied, setCopied] = useState(false);
|
|
8
|
+
let code = value;
|
|
9
|
+
if (typeof children === "string") {
|
|
10
|
+
code = children;
|
|
11
|
+
}
|
|
12
|
+
const handleCopy = async () => {
|
|
13
|
+
try {
|
|
14
|
+
await navigator.clipboard.writeText(code || "");
|
|
15
|
+
setCopied(true);
|
|
16
|
+
setTimeout(() => setCopied(false), 2000);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
console.error("Failed to copy code:", err);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
// If inside CodeGroup, render just the code content
|
|
23
|
+
if (isInsideCodeGroup) {
|
|
24
|
+
return (React.createElement("div", { className: "group relative overflow-x-auto" },
|
|
25
|
+
React.createElement("div", { className: `${maxH || "max-h-[40vh]"} rounded-b-md bg-zinc-900 px-5 py-3 overflow-y-auto [&>pre]:overflow-x-auto` },
|
|
26
|
+
React.createElement("div", { className: "min-w-0 text-[13px]" },
|
|
27
|
+
React.createElement(SyntaxHighlighter, { language: language || "javascript", style: vscDarkPlus, PreTag: "div", customStyle: {
|
|
28
|
+
margin: 0,
|
|
29
|
+
padding: 0,
|
|
30
|
+
background: "transparent",
|
|
31
|
+
fontSize: "13px",
|
|
32
|
+
width: "100%",
|
|
33
|
+
minWidth: 0,
|
|
34
|
+
maxWidth: "100%",
|
|
35
|
+
}, wrapLongLines: false }, code || "")))));
|
|
36
|
+
}
|
|
37
|
+
// Standalone code block with title
|
|
38
|
+
return (React.createElement("div", { className: cn("relative w-full border rounded-lg mb-4", className) },
|
|
39
|
+
React.createElement("div", { className: "flex items-center justify-between px-4 py-2 bg-zinc-900 text-primary border-b rounded-t-md" },
|
|
40
|
+
React.createElement("span", { className: "text-xs text-primary font-mono" }, language || title || ""),
|
|
41
|
+
React.createElement("button", { type: "button", className: "h-5 w-5 flex items-center justify-center hover:bg-transparent text-zinc-200 hover:text-zinc-300 border-none", onClick: handleCopy }, copied ? (React.createElement(CheckCircle2, { className: "h-3 w-3 text-green-500" })) : (React.createElement(Copy, { className: "h-3 w-3" })))),
|
|
42
|
+
React.createElement("div", { className: `${maxH || "max-h-[40vh]"} rounded-b-md bg-zinc-900 px-5 py-3 overflow-y-auto [&>pre]:overflow-x-auto` },
|
|
43
|
+
React.createElement("div", { className: "min-w-0 text-[13px]" },
|
|
44
|
+
React.createElement(SyntaxHighlighter, { language: language || "javascript", style: vscDarkPlus, PreTag: "div", customStyle: {
|
|
45
|
+
margin: 0,
|
|
46
|
+
padding: 0,
|
|
47
|
+
background: "transparent",
|
|
48
|
+
fontSize: "13px",
|
|
49
|
+
width: "100%",
|
|
50
|
+
minWidth: 0,
|
|
51
|
+
maxWidth: "100%",
|
|
52
|
+
}, wrapLongLines: false }, code || "")))));
|
|
53
|
+
});
|
|
54
|
+
CodeBlock.displayName = "CodeBlock";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Copy } from "lucide-react";
|
|
3
|
+
import { cn } from "../../../../../lib/utils";
|
|
4
|
+
import { CodeBlock } from "./code-group/code-block";
|
|
5
|
+
export const CodeGroup = ({ children }) => {
|
|
6
|
+
const [activeTab, setActiveTab] = useState(0);
|
|
7
|
+
const [copied, setCopied] = useState(false);
|
|
8
|
+
const parseCodeBlock = (element) => {
|
|
9
|
+
if (!element || !element.props) {
|
|
10
|
+
console.warn("Invalid code block element");
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
// Handle both direct string content and nested code elements
|
|
15
|
+
let codeElement = null;
|
|
16
|
+
let content = "";
|
|
17
|
+
if (typeof element.props.children === "string") {
|
|
18
|
+
content = element.props.children.trim();
|
|
19
|
+
// Use the pre element's className if available
|
|
20
|
+
const classNameRaw = element.props.className || "";
|
|
21
|
+
const parts = classNameRaw.replace(/^language-/, "").split(" ");
|
|
22
|
+
const language = parts[0] || "plain";
|
|
23
|
+
const title = parts.slice(1).join(" ") || language;
|
|
24
|
+
return { language, title, content };
|
|
25
|
+
}
|
|
26
|
+
// Handle nested code element
|
|
27
|
+
if (Array.isArray(element.props.children)) {
|
|
28
|
+
const codeChild = element.props.children.find((child) => React.isValidElement(child) &&
|
|
29
|
+
(child.type === "code" || typeof child.type === "string"));
|
|
30
|
+
if (codeChild) {
|
|
31
|
+
codeElement = codeChild;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if (React.isValidElement(element.props.children)) {
|
|
35
|
+
codeElement = element.props.children;
|
|
36
|
+
}
|
|
37
|
+
if (!codeElement || !codeElement.props) {
|
|
38
|
+
console.warn("No valid code element found");
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const classNameRaw = codeElement.props.className || "";
|
|
42
|
+
const parts = classNameRaw.replace(/^language-/, "").split(" ");
|
|
43
|
+
const language = parts[0] || "plain";
|
|
44
|
+
const title = parts.slice(1).join(" ") || language;
|
|
45
|
+
// Handle different content structures
|
|
46
|
+
if (typeof codeElement.props.children === "string") {
|
|
47
|
+
content = codeElement.props.children.trim();
|
|
48
|
+
}
|
|
49
|
+
else if (Array.isArray(codeElement.props.children)) {
|
|
50
|
+
content = codeElement.props.children
|
|
51
|
+
.map((child) => {
|
|
52
|
+
var _a;
|
|
53
|
+
return typeof child === "string"
|
|
54
|
+
? child
|
|
55
|
+
: React.isValidElement(child)
|
|
56
|
+
? ((_a = child.props.children) === null || _a === void 0 ? void 0 : _a.toString()) || ""
|
|
57
|
+
: "";
|
|
58
|
+
})
|
|
59
|
+
.join("")
|
|
60
|
+
.trim();
|
|
61
|
+
}
|
|
62
|
+
return { language, title, content };
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error("Failed to parse code block:", error);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const validChildren = Array.isArray(children) ? children : [children];
|
|
70
|
+
const blocks = validChildren
|
|
71
|
+
.filter((child) => React.isValidElement(child) &&
|
|
72
|
+
(child.type === "pre" || typeof child.type === "string"))
|
|
73
|
+
.map(parseCodeBlock)
|
|
74
|
+
.filter((block) => block !== null);
|
|
75
|
+
if (blocks.length === 0) {
|
|
76
|
+
console.warn("No valid code blocks found");
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const handleCopy = async () => {
|
|
80
|
+
try {
|
|
81
|
+
await navigator.clipboard.writeText(blocks[activeTab].content);
|
|
82
|
+
setCopied(true);
|
|
83
|
+
setTimeout(() => setCopied(false), 2000);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.error("Failed to copy code:", err);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return (React.createElement("div", { className: "relative my-4 rounded-lg border border-zinc-200 bg-white shadow-sm dark:border-zinc-800 dark:bg-zinc-950" },
|
|
90
|
+
React.createElement("div", { className: "flex items-center justify-between border-b border-zinc-200 bg-zinc-50/80 dark:border-zinc-800 dark:bg-zinc-900/80" },
|
|
91
|
+
React.createElement("div", { className: "flex overflow-x-auto" }, blocks.map((block, index) => (React.createElement("button", { key: index, onClick: () => setActiveTab(index), className: cn("min-w-[120px] border-b-2 px-4 py-2 text-sm font-medium", "transition-all duration-200", activeTab === index
|
|
92
|
+
? "border-[#0066FF] text-[#0066FF] dark:border-[#66A3FF] dark:text-[#66A3FF]"
|
|
93
|
+
: "border-transparent text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-200") }, block.title)))),
|
|
94
|
+
React.createElement("div", { className: "border-l border-zinc-200 dark:border-zinc-800" },
|
|
95
|
+
React.createElement("button", { onClick: handleCopy, className: cn("p-2 transition-colors", copied
|
|
96
|
+
? "text-green-500 dark:text-green-400"
|
|
97
|
+
: "text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-200"), "aria-label": "Copy code" },
|
|
98
|
+
React.createElement(Copy, { className: "h-4 w-4" })))),
|
|
99
|
+
React.createElement("div", { className: "group relative" }, blocks.map((block, index) => (React.createElement("div", { key: index, className: cn("relative", activeTab === index ? "block" : "hidden") },
|
|
100
|
+
React.createElement(CodeBlock, { language: block.language, value: block.content, isInsideCodeGroup: true })))))));
|
|
101
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "../../../../../lib/utils";
|
|
3
|
+
import * as LucideIcons from "lucide-react";
|
|
4
|
+
const Icon = ({ icon, size = 24, color = "#0066FF", strokeWidth = 2, absoluteStrokeWidth = false, className, children, }) => {
|
|
5
|
+
// Ensure `size` is always passed as a string
|
|
6
|
+
const normalizedSize = typeof size === "number" ? `${size}` : size;
|
|
7
|
+
// Fetch the appropriate icon component from LucideIcons
|
|
8
|
+
const IconComponent = icon
|
|
9
|
+
? LucideIcons[icon]
|
|
10
|
+
: null;
|
|
11
|
+
if (!IconComponent) {
|
|
12
|
+
console.warn(`Icon "${icon}" not found or not provided`);
|
|
13
|
+
return (React.createElement("span", { className: cn("inline-block align-middle text-zinc-500 italic", className) }, `Icon "${icon}" not found`));
|
|
14
|
+
}
|
|
15
|
+
// Decide rendering behavior based on `children`
|
|
16
|
+
if (!children) {
|
|
17
|
+
// No inline text: render as standalone block-level element
|
|
18
|
+
return (React.createElement("div", { className: cn("block", className), style: {
|
|
19
|
+
lineHeight: 0, // Prevent extra spacing around the icon
|
|
20
|
+
} },
|
|
21
|
+
React.createElement(IconComponent, { size: normalizedSize, color: color, strokeWidth: strokeWidth, absoluteStrokeWidth: absoluteStrokeWidth })));
|
|
22
|
+
}
|
|
23
|
+
// Inline text exists: render as inline-flex with the text
|
|
24
|
+
return (React.createElement("span", { className: cn("inline-flex items-center align-middle gap-1", className), style: {
|
|
25
|
+
display: "inline-flex",
|
|
26
|
+
verticalAlign: "middle",
|
|
27
|
+
} },
|
|
28
|
+
React.createElement(IconComponent, { size: normalizedSize, color: color, strokeWidth: strokeWidth, absoluteStrokeWidth: absoluteStrokeWidth }),
|
|
29
|
+
React.createElement("span", null, children)));
|
|
30
|
+
};
|
|
31
|
+
export default Icon;
|