@sampleapp.ai/sdk 1.0.34 → 1.0.36

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 (28) hide show
  1. package/dist/components/sandbox/Sandbox.js +15 -8
  2. package/dist/components/sandbox/guardian/ask-ai-view.js +4 -4
  3. package/dist/components/sandbox/guardian/code-focus-section.js +166 -28
  4. package/dist/components/sandbox/guardian/default-guide-view.js +1 -1
  5. package/dist/components/sandbox/guardian/demo/left-view.js +2 -2
  6. package/dist/components/sandbox/guardian/guardian-playground.js +2 -2
  7. package/dist/components/sandbox/guardian/guardian-style-wrapper.js +21 -2
  8. package/dist/components/sandbox/guardian/ide/browser.js +30 -30
  9. package/dist/components/sandbox/guardian/right-view/preview-control-bar.js +3 -3
  10. package/dist/components/sandbox/guardian/right-view/right-top-down-view.js +1 -1
  11. package/dist/components/sandbox/guardian/right-view/simplified-editor.js +7 -7
  12. package/dist/components/sandbox/guardian/types/ide-types.js +0 -1
  13. package/dist/components/sandbox/guardian/ui/download-and-open-buttons.js +1 -1
  14. package/dist/components/sandbox/guardian/ui/markdown/code-group/code-block.js +48 -11
  15. package/dist/components/sandbox/guardian/ui/markdown.js +1 -1
  16. package/dist/components/sandbox/sandbox-home/SandboxCard.js +4 -4
  17. package/dist/components/sandbox/sandbox-home/SandboxHome.js +9 -9
  18. package/dist/components/sandbox/sandbox-home/SearchBar.js +2 -2
  19. package/dist/index.d.ts +21 -2
  20. package/dist/index.es.js +10128 -19154
  21. package/dist/index.standalone.umd.js +11 -43
  22. package/dist/index.umd.js +99 -127
  23. package/dist/lib/generated-css.js +1 -1
  24. package/dist/lib/ssr-safe-decode-entity.js +16 -0
  25. package/dist/lib/ssr-safe-decode-named-character-reference.js +257 -0
  26. package/dist/sdk.css +1 -1
  27. package/dist/tailwind.css +1 -1
  28. package/package.json +3 -3
@@ -1,10 +1,39 @@
1
- import React, { memo, useState } from "react";
1
+ import React, { memo, useState, useEffect } from "react";
2
2
  import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
3
3
  import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism";
4
+ import { oneLight } from "react-syntax-highlighter/dist/esm/styles/prism";
4
5
  import { cn } from "../../../../../../lib/utils";
5
6
  import { Copy, CheckCircle2 } from "lucide-react";
6
7
  export const CodeBlock = memo(({ language, value, title, className, children, isInsideCodeGroup = false, maxH, }) => {
7
8
  const [copied, setCopied] = useState(false);
9
+ const [isDark, setIsDark] = useState(true);
10
+ // Detect if we're in dark mode by checking for .dark class on ancestor
11
+ useEffect(() => {
12
+ const checkTheme = () => {
13
+ var _a;
14
+ if (typeof document === "undefined")
15
+ return;
16
+ // Check if guardian-sdk-root has dark class
17
+ const root = document.querySelector(".guardian-sdk-root");
18
+ setIsDark((_a = root === null || root === void 0 ? void 0 : root.classList.contains("dark")) !== null && _a !== void 0 ? _a : true);
19
+ };
20
+ checkTheme();
21
+ // Also check on mount with a slight delay to ensure DOM is ready
22
+ const timer = setTimeout(checkTheme, 100);
23
+ // Watch for changes using MutationObserver
24
+ const observer = new MutationObserver(checkTheme);
25
+ const root = document.querySelector(".guardian-sdk-root");
26
+ if (root) {
27
+ observer.observe(root, {
28
+ attributes: true,
29
+ attributeFilter: ["class"],
30
+ });
31
+ }
32
+ return () => {
33
+ clearTimeout(timer);
34
+ observer.disconnect();
35
+ };
36
+ }, []);
8
37
  let code = value;
9
38
  if (typeof children === "string") {
10
39
  code = children;
@@ -22,33 +51,41 @@ export const CodeBlock = memo(({ language, value, title, className, children, is
22
51
  // If inside CodeGroup, render just the code content
23
52
  if (isInsideCodeGroup) {
24
53
  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: {
54
+ React.createElement("div", { className: `${maxH || "max-h-[40vh]"} rounded-b-md bg-zinc-100 dark:bg-zinc-900 px-5 py-3 overflow-y-auto [&>pre]:overflow-x-auto` },
55
+ React.createElement("div", { className: "min-w-0 text-[13px] [&_*]:!bg-transparent" },
56
+ React.createElement(SyntaxHighlighter, { language: language || "javascript", style: isDark ? vscDarkPlus : oneLight, PreTag: "div", customStyle: {
28
57
  margin: 0,
29
58
  padding: 0,
30
- background: "transparent",
59
+ background: "transparent !important",
31
60
  fontSize: "13px",
32
61
  width: "100%",
33
62
  minWidth: 0,
34
63
  maxWidth: "100%",
64
+ }, codeTagProps: {
65
+ style: {
66
+ background: "transparent !important",
67
+ },
35
68
  }, wrapLongLines: false }, code || "")))));
36
69
  }
37
70
  // Standalone code block with title
38
71
  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" },
72
+ React.createElement("div", { className: "flex items-center justify-between px-4 py-2 bg-zinc-100 dark:bg-zinc-900 text-primary border-b rounded-t-md" },
40
73
  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: {
74
+ React.createElement("button", { type: "button", className: "h-5 w-5 flex items-center justify-center hover:bg-transparent text-zinc-700 dark:text-zinc-200 hover:text-zinc-900 dark: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" })))),
75
+ React.createElement("div", { className: `${maxH || "max-h-[40vh]"} rounded-b-md bg-zinc-100 dark:bg-zinc-900 px-5 py-3 overflow-y-auto [&>pre]:overflow-x-auto` },
76
+ React.createElement("div", { className: "min-w-0 text-[13px] [&_*]:!bg-transparent" },
77
+ React.createElement(SyntaxHighlighter, { language: language || "javascript", style: isDark ? vscDarkPlus : oneLight, PreTag: "div", customStyle: {
45
78
  margin: 0,
46
79
  padding: 0,
47
- background: "transparent",
80
+ background: "transparent !important",
48
81
  fontSize: "13px",
49
82
  width: "100%",
50
83
  minWidth: 0,
51
84
  maxWidth: "100%",
85
+ }, codeTagProps: {
86
+ style: {
87
+ background: "transparent !important",
88
+ },
52
89
  }, wrapLongLines: false }, code || "")))));
53
90
  });
54
91
  CodeBlock.displayName = "CodeBlock";
@@ -229,7 +229,7 @@ export const Markdown = ({ children, className, isRestricted, showToc, themeColo
229
229
  // If it's an inline code block, render it as a small block by default
230
230
  // so it visually separates from the surrounding text instead of sitting inline.
231
231
  if (isInline) {
232
- return (React.createElement("code", Object.assign({ className: cn("inline-block text-[var(--colors-primary)] text-sm bg-[var(--colors-secondary)] px-2 py-1 rounded-lg mt-2", className) }, props), children));
232
+ return (React.createElement("code", Object.assign({ className: cn("inline-block text-zinc-900 dark:text-zinc-100 text-sm bg-zinc-100 dark:bg-zinc-800 px-2 py-1 rounded-lg mt-2 font-mono", className) }, props), children));
233
233
  }
234
234
  // Extract language and title
235
235
  const language = (match === null || match === void 0 ? void 0 : match[1]) || "";
@@ -50,14 +50,14 @@ export const SandboxCard = ({ title, description, sandboxId, basePath = "/sandbo
50
50
  window.location.href = `${cleanBasePath}/${sandboxId}`;
51
51
  }
52
52
  };
53
- return (React.createElement("div", { onClick: handleClick, className: "group relative block min-w-[240px] w-full h-[200px] border border-[#333] bg-[#0a0a0a] rounded-lg overflow-hidden transition-all duration-100 ease-out hover:border-[#444] focus-visible:outline-none cursor-pointer" },
53
+ return (React.createElement("div", { onClick: handleClick, className: "group relative block min-w-[240px] w-full h-[200px] border border-zinc-200 dark:border-[#333] bg-zinc-50 dark:bg-[#0a0a0a] rounded-lg overflow-hidden transition-all duration-100 ease-out hover:border-zinc-300 dark:hover:border-[#444] focus-visible:outline-none cursor-pointer" },
54
54
  React.createElement("div", { className: "flex flex-col gap-1 px-6 py-5" },
55
55
  React.createElement("div", { className: "flex items-center max-w-max pr-2.5" },
56
- React.createElement("h3", { className: "text-[16px] font-medium m-0 w-max whitespace-nowrap overflow-hidden text-ellipsis flex-1 mr-0 text-white" }, safeTitle),
56
+ React.createElement("h3", { className: "text-[16px] font-medium m-0 w-max whitespace-nowrap overflow-hidden text-ellipsis flex-1 mr-0 text-zinc-900 dark:text-white" }, safeTitle),
57
57
  React.createElement("svg", { className: "rotate-[-45deg] translate-x-[-2px] opacity-0 transition-all duration-100 ease-out origin-center group-hover:opacity-100 group-hover:translate-x-[4px] ml-1", height: "16", strokeLinejoin: "round", style: { width: 12, height: 12, color: "currentColor" }, viewBox: "0 0 16 16", width: "16" },
58
58
  React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9.53033 2.21968L9 1.68935L7.93934 2.75001L8.46967 3.28034L12.4393 7.25001H1.75H1V8.75001H1.75H12.4393L8.46967 12.7197L7.93934 13.25L9 14.3107L9.53033 13.7803L14.6036 8.70711C14.9941 8.31659 14.9941 7.68342 14.6036 7.2929L9.53033 2.21968Z", fill: "currentColor" }))),
59
- React.createElement("p", { className: "text-[14px] text-gray-400 m-0 line-clamp-2" }, safeDescription)),
60
- React.createElement("div", { className: "absolute top-[110px] -right-10 w-[300px] h-[100px] rounded-lg border border-[#333] overflow-hidden shadow-lg transition-transform duration-100 ease-out rotate-[-5deg] group-hover:rotate-[-3deg] group-hover:-translate-y-1 group-hover:-translate-x-0.5" }, imageUrl ? (React.createElement("img", { src: imageUrl, alt: safeTitle, className: "w-full h-full object-cover", style: { transform: "rotate(0deg)" } })) : (React.createElement("div", { className: `w-full h-full bg-gradient-to-br ${gradient} flex items-center justify-center` },
59
+ React.createElement("p", { className: "text-[14px] text-zinc-500 dark:text-gray-400 m-0 line-clamp-2" }, safeDescription)),
60
+ React.createElement("div", { className: "absolute top-[110px] -right-10 w-[300px] h-[100px] rounded-lg border border-zinc-200 dark:border-[#333] overflow-hidden shadow-lg transition-transform duration-100 ease-out rotate-[-5deg] group-hover:rotate-[-3deg] group-hover:-translate-y-1 group-hover:-translate-x-0.5" }, imageUrl ? (React.createElement("img", { src: imageUrl, alt: safeTitle, className: "w-full h-full object-cover", style: { transform: "rotate(0deg)" } })) : (React.createElement("div", { className: `w-full h-full bg-gradient-to-br ${gradient} flex items-center justify-center` },
61
61
  React.createElement("div", { className: "w-full px-6 space-y-2" },
62
62
  React.createElement("div", { className: "h-2 bg-white/20 rounded w-1/2 mx-auto" }),
63
63
  React.createElement("div", { className: "h-1.5 bg-white/10 rounded w-3/4 mx-auto" }),
@@ -90,26 +90,26 @@ export const SandboxHome = ({ apiKey, orgid, sandboxes, basePath = "/sandbox", }
90
90
  return matchesTitle || matchesDescription;
91
91
  });
92
92
  }, [allSandboxes, searchQuery]);
93
- return (React.createElement("div", { className: "min-h-screen bg-black" },
93
+ return (React.createElement("div", { className: "min-h-screen bg-white dark:bg-black" },
94
94
  React.createElement("div", { className: "pt-16 pb-12 px-4 md:px-6" },
95
95
  React.createElement("div", { className: "max-w-[1400px] mx-auto" },
96
96
  React.createElement(SearchBar, { value: searchQuery, onChange: setSearchQuery }))),
97
97
  React.createElement("div", { className: "px-4 md:px-6 pb-16" },
98
- React.createElement("div", { className: "max-w-[1400px] mx-auto" }, loading ? (React.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4" }, [...Array(6)].map((_, i) => (React.createElement("div", { key: i, className: "relative block min-w-[240px] w-full h-[200px] border border-[#333] bg-[#0a0a0a] rounded-lg overflow-hidden" },
98
+ React.createElement("div", { className: "max-w-[1400px] mx-auto" }, loading ? (React.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4" }, [...Array(6)].map((_, i) => (React.createElement("div", { key: i, className: "relative block min-w-[240px] w-full h-[200px] border border-zinc-200 dark:border-[#333] bg-zinc-50 dark:bg-[#0a0a0a] rounded-lg overflow-hidden" },
99
99
  React.createElement("div", { className: "flex flex-col gap-1 px-6 py-5" },
100
100
  React.createElement("div", { className: "flex items-center max-w-max pr-2.5" },
101
- React.createElement(Skeleton, { className: "h-5 w-32 bg-zinc-800" })),
102
- React.createElement(Skeleton, { className: "h-4 w-full bg-zinc-800 mt-1" }),
103
- React.createElement(Skeleton, { className: "h-4 w-3/4 bg-zinc-800 mt-1" })),
104
- React.createElement("div", { className: "absolute top-[110px] -right-10 w-[300px] h-[100px] rounded-lg border border-[#333] overflow-hidden shadow-lg rotate-[-5deg]" },
105
- React.createElement(Skeleton, { className: "w-full h-full bg-zinc-800" }))))))) : error && !sandboxes ? (React.createElement("div", { className: "col-span-full text-center py-16" },
101
+ React.createElement(Skeleton, { className: "h-5 w-32 bg-zinc-200 dark:bg-zinc-800" })),
102
+ React.createElement(Skeleton, { className: "h-4 w-full bg-zinc-200 dark:bg-zinc-800 mt-1" }),
103
+ React.createElement(Skeleton, { className: "h-4 w-3/4 bg-zinc-200 dark:bg-zinc-800 mt-1" })),
104
+ React.createElement("div", { className: "absolute top-[110px] -right-10 w-[300px] h-[100px] rounded-lg border border-zinc-200 dark:border-[#333] overflow-hidden shadow-lg rotate-[-5deg]" },
105
+ React.createElement(Skeleton, { className: "w-full h-full bg-zinc-200 dark:bg-zinc-800" }))))))) : error && !sandboxes ? (React.createElement("div", { className: "col-span-full text-center py-16" },
106
106
  React.createElement("p", { className: "text-red-500 text-lg" },
107
107
  "Error: ",
108
108
  error),
109
- React.createElement("p", { className: "text-gray-500 text-sm mt-2" }, "Please check your API key and try again."))) : (React.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4" }, filteredSandboxes && filteredSandboxes.length > 0 ? (filteredSandboxes
109
+ React.createElement("p", { className: "text-zinc-500 dark:text-gray-500 text-sm mt-2" }, "Please check your API key and try again."))) : (React.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4" }, filteredSandboxes && filteredSandboxes.length > 0 ? (filteredSandboxes
110
110
  .filter((sandbox) => sandbox && sandbox.title && sandbox.description)
111
111
  .map((sandbox) => (React.createElement(SandboxCard, { key: sandbox.id, title: sandbox.title || "", description: sandbox.description || "", sandboxId: sandbox.sandboxId, basePath: basePath, imageUrl: `https://sampleappassets.blob.core.windows.net/assets/${orgid}/${sandbox.id}.png` })))) : (React.createElement("div", { className: "col-span-full text-center py-16" },
112
- React.createElement("p", { className: "text-gray-500 text-lg" }, searchQuery
112
+ React.createElement("p", { className: "text-zinc-500 dark:text-gray-500 text-lg" }, searchQuery
113
113
  ? `No sandboxes found matching "${searchQuery}".`
114
114
  : "No sandboxes available. Provide sandboxes prop to display cards.")))))))));
115
115
  };
@@ -6,7 +6,7 @@ import React from "react";
6
6
  export const SearchBar = ({ value, onChange, placeholder = "Search sample apps...", }) => {
7
7
  return (React.createElement("div", { className: "relative max-w-md mx-auto" },
8
8
  React.createElement("div", { className: "absolute inset-y-0 left-4 flex items-center pointer-events-none" },
9
- React.createElement("svg", { className: "w-4 h-4 text-gray-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" },
9
+ React.createElement("svg", { className: "w-4 h-4 text-zinc-400 dark:text-gray-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" },
10
10
  React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" }))),
11
- React.createElement("input", { type: "text", placeholder: placeholder, value: value, onChange: (e) => onChange(e.target.value), className: "w-full bg-[#0a0a0a] border border-[#222] rounded-lg py-3 pl-11 pr-4 text-sm text-white placeholder:text-gray-500 focus:outline-none focus:border-gray-600 transition-colors" })));
11
+ React.createElement("input", { type: "text", placeholder: placeholder, value: value, onChange: (e) => onChange(e.target.value), className: "w-full bg-white dark:bg-[#0a0a0a] border border-zinc-200 dark:border-[#222] rounded-lg py-3 pl-11 pr-4 text-sm text-zinc-900 dark:text-white placeholder:text-zinc-400 dark:placeholder:text-gray-500 focus:outline-none focus:border-zinc-400 dark:focus:border-gray-600 transition-colors" })));
12
12
  };
package/dist/index.d.ts CHANGED
@@ -248,7 +248,7 @@ export declare type GuardianNestedConfig = Record<string, GuardianUseCaseConfig>
248
248
  *
249
249
  * When isFrame=true, reads framework from URL params client-side.
250
250
  */
251
- export declare function GuardianPlayground({ nestedConfig, useCase, framework: serverFramework, isFrame, apiKey, env, chatUid, }: {
251
+ export declare function GuardianPlayground({ nestedConfig, useCase, framework: serverFramework, isFrame, apiKey, env, chatUid, theme, }: {
252
252
  /** Nested config structure (use case → framework → config) */
253
253
  nestedConfig: GuardianNestedConfig;
254
254
  /** Current use case ID */
@@ -263,6 +263,8 @@ export declare function GuardianPlayground({ nestedConfig, useCase, framework: s
263
263
  env?: Record<string, string>;
264
264
  /** Chat UID for starting sandbox */
265
265
  chatUid?: string;
266
+ /** Theme mode - "light", "dark", or "system". Defaults to "dark" */
267
+ theme?: ThemeMode;
266
268
  }): default_2.JSX.Element;
267
269
 
268
270
  export declare function GuardianProvider({ children }: {
@@ -343,9 +345,16 @@ declare class SampleAppSDK {
343
345
  * apiKey={process.env.NEXT_PUBLIC_SAMPLEAPP_API_KEY!}
344
346
  * sandboxId="launchdarkly-feature-flags"
345
347
  * />
348
+ *
349
+ * // Light mode
350
+ * <Sandbox
351
+ * apiKey={process.env.NEXT_PUBLIC_SAMPLEAPP_API_KEY!}
352
+ * sandboxId="launchdarkly-feature-flags"
353
+ * theme="light"
354
+ * />
346
355
  * ```
347
356
  */
348
- export declare function Sandbox({ apiKey, sandboxId, env, themeColor, }: SandboxProps): default_2.JSX.Element | null;
357
+ export declare function Sandbox({ apiKey, sandboxId, env, themeColor, theme, }: SandboxProps): default_2.JSX.Element | null;
349
358
 
350
359
  export declare const SandboxHome: React_2.FC<SandboxHomeProps>;
351
360
 
@@ -379,6 +388,8 @@ export declare interface SandboxProps {
379
388
  env?: Record<string, string>;
380
389
  /** Optional theme color override */
381
390
  themeColor?: string;
391
+ /** Theme mode - "light", "dark", or "system". Defaults to "dark" */
392
+ theme?: ThemeMode;
382
393
  }
383
394
 
384
395
  declare interface SandboxUrlConfig {
@@ -431,6 +442,14 @@ export declare interface ThemeColors {
431
442
  };
432
443
  }
433
444
 
445
+ /**
446
+ * Theme mode for the SDK
447
+ * - "light": Light mode
448
+ * - "dark": Dark mode
449
+ * - "system": Follows system preference
450
+ */
451
+ export declare type ThemeMode = "light" | "dark" | "system";
452
+
434
453
  export declare type ThemeName = "ocean" | "autumn" | "mint" | "sunset" | "lavender" | "forest" | "coral";
435
454
 
436
455
  export declare const themes: Record<ThemeName, ThemeColors>;