@openpkg-ts/ui 0.6.1 → 0.6.2

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.
@@ -687,4 +687,23 @@ interface TypeBadgeProps extends React13.HTMLAttributes<HTMLSpanElement> {
687
687
  * Automatically detects type category and applies appropriate color.
688
688
  */
689
689
  declare const TypeBadge: React13.ForwardRefExoticComponent<TypeBadgeProps & React13.RefAttributes<HTMLSpanElement>>;
690
- export { wordWrap2 as wordWrap, useSyncSection, useSyncScroll, typeBadgeVariants, tooltip, toCodeGroup, theme, mark, link, lineNumbers2 as lineNumbers, hover, flagsToOptions, expandable, endpointBadgeVariants, diff, collapse, callout, addDocsKit, WithNotes, WithHover, TypeColor, TypeBadgeProps, TypeBadge, TooltipLink, TerminalSkeleton, Terminal, TabsTrigger, TabsList, TabsContent, Tabs, SyncScrollProviderProps, SyncScrollProvider, SyncScrollContextValue, SingleCode, ResponseBlockProps, ResponseBlock, ParameterListProps, ParameterList, PackageInstall, NestedParameterToggleProps, NestedParameterToggle, NestedParameterContainerProps, NestedParameterContainer, MultiCode, MethodSectionProps, MethodSection, LanguageSelectorProps, LanguageSelector, Language, InlineCodeSkeleton, ImportSectionProps, ImportSection, HttpMethod, HoverLink, ExpandableParameterProps, ExpandableParameter, ExampleSectionProps, CodeExample2 as ExampleSectionCodeExample, ExampleSection, ExampleChipsProps, ExampleChips, ExampleChip, EnumValuesSectionProps, EnumValuesSection, EnumValue, EndpointHeaderProps, EndpointHeader, EndpointBadgeProps, EndpointBadge, DocsKitInlineCode, DocsKitCode, DiffStats, CopyButton, CollapsiblePanelProps, CollapsiblePanel, CodeTabsSkeleton, CodeInfo, CodeIcon, CodeGroup, CodeExample, CodeBlockSkeleton, CodeBlockProps, CodeBlock, Code, ClientTerminal, ClientInlineCode, ClientDocsKitCode, ClientDiffCodeProps, ClientDiffCode, ClientCode, APISectionProps, APISection, APIReferencePageProps, APIReferencePage, APIReferenceLayoutProps, APIReferenceLayout, APIParameterSchema, APIParameterItemProps, APIParameterItem, APICodePanelProps, APICodePanel };
690
+ interface RunnableSnippetProps {
691
+ /** Code to display */
692
+ code: string;
693
+ /** Language for syntax highlighting */
694
+ language?: string;
695
+ /** Optional title */
696
+ title?: string;
697
+ /** For demo: mock execution state */
698
+ mockState?: "idle" | "running" | "success" | "error";
699
+ /** For demo: mock output data */
700
+ mockOutput?: string;
701
+ /** Custom className */
702
+ className?: string;
703
+ }
704
+ /**
705
+ * Interactive code block with run button and output display.
706
+ * Currently uses mock states; will be wired to sandbox execution in Phase 2.
707
+ */
708
+ declare function RunnableSnippet({ code, language, title, mockState, mockOutput, className }: RunnableSnippetProps): React.ReactNode;
709
+ export { wordWrap2 as wordWrap, useSyncSection, useSyncScroll, typeBadgeVariants, tooltip, toCodeGroup, theme, mark, link, lineNumbers2 as lineNumbers, hover, flagsToOptions, expandable, endpointBadgeVariants, diff, collapse, callout, addDocsKit, WithNotes, WithHover, TypeColor, TypeBadgeProps, TypeBadge, TooltipLink, TerminalSkeleton, Terminal, TabsTrigger, TabsList, TabsContent, Tabs, SyncScrollProviderProps, SyncScrollProvider, SyncScrollContextValue, SingleCode, RunnableSnippetProps, RunnableSnippet, ResponseBlockProps, ResponseBlock, ParameterListProps, ParameterList, PackageInstall, NestedParameterToggleProps, NestedParameterToggle, NestedParameterContainerProps, NestedParameterContainer, MultiCode, MethodSectionProps, MethodSection, LanguageSelectorProps, LanguageSelector, Language, InlineCodeSkeleton, ImportSectionProps, ImportSection, HttpMethod, HoverLink, ExpandableParameterProps, ExpandableParameter, ExampleSectionProps, CodeExample2 as ExampleSectionCodeExample, ExampleSection, ExampleChipsProps, ExampleChips, ExampleChip, EnumValuesSectionProps, EnumValuesSection, EnumValue, EndpointHeaderProps, EndpointHeader, EndpointBadgeProps, EndpointBadge, DocsKitInlineCode, DocsKitCode, DiffStats, CopyButton, CollapsiblePanelProps, CollapsiblePanel, CodeTabsSkeleton, CodeInfo, CodeIcon, CodeGroup, CodeExample, CodeBlockSkeleton, CodeBlockProps, CodeBlock, Code, ClientTerminal, ClientInlineCode, ClientDocsKitCode, ClientDiffCodeProps, ClientDiffCode, ClientCode, APISectionProps, APISection, APIReferencePageProps, APIReferencePage, APIReferenceLayoutProps, APIReferenceLayout, APIParameterSchema, APIParameterItemProps, APIParameterItem, APICodePanelProps, APICodePanel };
@@ -196,9 +196,10 @@ var line = {
196
196
  return /* @__PURE__ */ jsx5("div", {
197
197
  style: {
198
198
  borderLeftColor: "var(--openpkg-line-border, transparent)",
199
- backgroundColor: "var(--openpkg-line-bg, transparent)"
199
+ backgroundColor: "var(--openpkg-line-bg, transparent)",
200
+ transition: "background-color 0.3s ease"
200
201
  },
201
- className: "flex border-l-2 border-l-transparent background-color 0.3s ease",
202
+ className: "flex border-l-2 border-l-transparent",
202
203
  children: /* @__PURE__ */ jsx5(InnerLine2, {
203
204
  merge: props,
204
205
  className: "px-3 flex-1"
@@ -683,10 +684,10 @@ var wordWrap = {
683
684
  // src/docskit/code.handlers.tsx
684
685
  function getHandlers(options) {
685
686
  return [
686
- line,
687
- options.lineNumbers && lineNumbers,
688
687
  mark,
689
688
  diff,
689
+ line,
690
+ options.lineNumbers && lineNumbers,
690
691
  link,
691
692
  callout,
692
693
  ...collapse,
@@ -2834,6 +2835,82 @@ var TypeBadge = React8.forwardRef(({ className, type, typeColor, ...props }, ref
2834
2835
  });
2835
2836
  });
2836
2837
  TypeBadge.displayName = "TypeBadge";
2838
+ // src/docskit/runnable-snippet.tsx
2839
+ import { Loader2, Play } from "lucide-react";
2840
+ import { useState as useState16 } from "react";
2841
+ import { jsx as jsx53, jsxs as jsxs31 } from "react/jsx-runtime";
2842
+
2843
+ function RunnableSnippet({
2844
+ code,
2845
+ language = "typescript",
2846
+ title,
2847
+ mockState = "idle",
2848
+ mockOutput,
2849
+ className
2850
+ }) {
2851
+ const [state, setState] = useState16(mockState);
2852
+ const [output, setOutput] = useState16(mockOutput ?? null);
2853
+ const [duration, setDuration] = useState16(0);
2854
+ const handleRun = () => {
2855
+ setState("running");
2856
+ setOutput(null);
2857
+ const startTime = Date.now();
2858
+ setTimeout(() => {
2859
+ const elapsed = Date.now() - startTime;
2860
+ setDuration(elapsed);
2861
+ if (mockState === "error") {
2862
+ setState("error");
2863
+ setOutput(mockOutput ?? "Error: Execution failed");
2864
+ } else {
2865
+ setState("success");
2866
+ setOutput(mockOutput ?? JSON.stringify({ result: "success", timestamp: new Date().toISOString() }, null, 2));
2867
+ }
2868
+ }, 1200);
2869
+ };
2870
+ const codeblock = {
2871
+ value: code,
2872
+ lang: language,
2873
+ meta: title
2874
+ };
2875
+ return /* @__PURE__ */ jsxs31("div", {
2876
+ className: cn("relative", className),
2877
+ children: [
2878
+ /* @__PURE__ */ jsxs31("div", {
2879
+ className: "relative group",
2880
+ children: [
2881
+ /* @__PURE__ */ jsx53(ClientDocsKitCode, {
2882
+ codeblock
2883
+ }),
2884
+ /* @__PURE__ */ jsx53("button", {
2885
+ type: "button",
2886
+ onClick: handleRun,
2887
+ disabled: state === "running",
2888
+ className: cn("absolute right-3 top-3 z-10", "size-8 flex items-center justify-center", "rounded border border-openpkg-code-border bg-openpkg-code-bg", "text-openpkg-code-text-inactive", "cursor-pointer transition-opacity duration-200", "opacity-0 group-hover:opacity-100", state === "running" && "cursor-not-allowed opacity-100"),
2889
+ "aria-label": "Run code",
2890
+ children: state === "running" ? /* @__PURE__ */ jsx53(Loader2, {
2891
+ size: 16,
2892
+ className: "animate-spin"
2893
+ }) : /* @__PURE__ */ jsx53(Play, {
2894
+ size: 16,
2895
+ className: "fill-current"
2896
+ })
2897
+ })
2898
+ ]
2899
+ }),
2900
+ output && /* @__PURE__ */ jsx53("div", {
2901
+ className: "-mt-4",
2902
+ children: /* @__PURE__ */ jsx53(CollapsiblePanel, {
2903
+ title: `${state === "success" ? "✓ Success" : "✕ Error"} | ${duration}ms`,
2904
+ defaultExpanded: true,
2905
+ children: /* @__PURE__ */ jsx53("pre", {
2906
+ className: "p-4 m-0 text-xs font-mono overflow-auto max-h-[400px]",
2907
+ children: output
2908
+ })
2909
+ })
2910
+ })
2911
+ ]
2912
+ });
2913
+ }
2837
2914
  export {
2838
2915
  wordWrap,
2839
2916
  useSyncSection,
@@ -2865,6 +2942,7 @@ export {
2865
2942
  Tabs,
2866
2943
  SyncScrollProvider,
2867
2944
  SingleCode,
2945
+ RunnableSnippet,
2868
2946
  ResponseBlock,
2869
2947
  ParameterList,
2870
2948
  PackageInstall,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/ui",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "UI primitives and components for OpenPkg documentation",
5
5
  "homepage": "https://github.com/ryanwaits/openpkg-ts#readme",
6
6
  "repository": {