@openpkg-ts/ui 0.6.0 → 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.
- package/dist/docskit/index.d.ts +23 -4
- package/dist/docskit/index.js +84 -6
- package/package.json +1 -1
package/dist/docskit/index.d.ts
CHANGED
|
@@ -310,9 +310,9 @@ interface NestedParameterToggleProps {
|
|
|
310
310
|
className?: string;
|
|
311
311
|
}
|
|
312
312
|
/**
|
|
313
|
-
* "Show/Hide Child Attributes" toggle button (
|
|
314
|
-
* When collapsed:
|
|
315
|
-
* When expanded: top of
|
|
313
|
+
* "Show/Hide Child Attributes" toggle button (Stripe-style).
|
|
314
|
+
* When collapsed: inline-block rounded pill button.
|
|
315
|
+
* When expanded: full-width top of unified bordered container.
|
|
316
316
|
*/
|
|
317
317
|
declare function NestedParameterToggle({ expanded, onToggle, className }: NestedParameterToggleProps): ReactNode11;
|
|
318
318
|
import { ReactNode as ReactNode12 } from "react";
|
|
@@ -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
|
-
|
|
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 };
|
package/dist/docskit/index.js
CHANGED
|
@@ -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
|
|
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,
|
|
@@ -1309,7 +1310,7 @@ function APIReferenceLayout({
|
|
|
1309
1310
|
rightWidth = "42%"
|
|
1310
1311
|
}) {
|
|
1311
1312
|
return /* @__PURE__ */ jsxs12("div", {
|
|
1312
|
-
className: cn("openpkg-api-layout", "max-w-[1600px] mx-auto", "flex flex-col", "lg:grid", className),
|
|
1313
|
+
className: cn("openpkg-api-layout", "max-w-[1600px] mx-auto", "flex flex-col", "lg:grid lg:items-start", className),
|
|
1313
1314
|
style: {
|
|
1314
1315
|
"--openpkg-left-width": leftWidth,
|
|
1315
1316
|
"--openpkg-right-width": rightWidth
|
|
@@ -1896,7 +1897,7 @@ function NestedParameterToggle({
|
|
|
1896
1897
|
return /* @__PURE__ */ jsxs20("button", {
|
|
1897
1898
|
type: "button",
|
|
1898
1899
|
onClick: onToggle,
|
|
1899
|
-
className: cn("openpkg-nested-toggle", "flex items-center gap-2
|
|
1900
|
+
className: cn("openpkg-nested-toggle", "flex items-center gap-2", "font-sans text-[13px] font-medium", "text-[var(--openpkg-text-secondary)]", "bg-transparent", "border border-[var(--openpkg-border-medium)]", "px-2 py-1.5", "cursor-pointer", "transition-[width,border-radius,border-color,color] duration-200 ease-out", "hover:text-[var(--openpkg-text-primary)]", expanded ? "w-full rounded-t-md rounded-b-none border-b-[var(--openpkg-border-subtle)]" : "w-fit rounded-md", className),
|
|
1900
1901
|
"aria-expanded": expanded,
|
|
1901
1902
|
children: [
|
|
1902
1903
|
/* @__PURE__ */ jsx38("span", {
|
|
@@ -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,
|