@kushagradhawan/kookie-blocks 0.1.2 → 0.1.4
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/components.css +136 -0
- package/dist/cjs/components/code/CodeBlock.d.ts +4 -0
- package/dist/cjs/components/code/CodeBlock.d.ts.map +1 -0
- package/dist/cjs/components/code/CodeBlock.js +2 -0
- package/dist/cjs/components/code/CodeBlock.js.map +7 -0
- package/dist/cjs/components/code/CopyButton.d.ts +7 -0
- package/dist/cjs/components/code/CopyButton.d.ts.map +1 -0
- package/dist/cjs/components/code/CopyButton.js +2 -0
- package/dist/cjs/components/code/CopyButton.js.map +7 -0
- package/dist/cjs/components/code/LanguageBadge.d.ts +7 -0
- package/dist/cjs/components/code/LanguageBadge.d.ts.map +1 -0
- package/dist/cjs/components/code/LanguageBadge.js +2 -0
- package/dist/cjs/components/code/LanguageBadge.js.map +7 -0
- package/dist/cjs/components/code/PreviewSection.d.ts +16 -0
- package/dist/cjs/components/code/PreviewSection.d.ts.map +1 -0
- package/dist/cjs/components/code/PreviewSection.js +2 -0
- package/dist/cjs/components/code/PreviewSection.js.map +7 -0
- package/dist/cjs/components/code/SyntaxHighlighter.d.ts +10 -0
- package/dist/cjs/components/code/SyntaxHighlighter.d.ts.map +1 -0
- package/dist/cjs/components/code/SyntaxHighlighter.js +2 -0
- package/dist/cjs/components/code/SyntaxHighlighter.js.map +7 -0
- package/dist/cjs/components/code/index.d.ts +3 -0
- package/dist/cjs/components/code/index.d.ts.map +1 -0
- package/dist/cjs/components/code/index.js +2 -0
- package/dist/cjs/components/code/index.js.map +7 -0
- package/dist/cjs/components/code/types.d.ts +24 -0
- package/dist/cjs/components/code/types.d.ts.map +1 -0
- package/dist/cjs/components/code/types.js +2 -0
- package/dist/cjs/components/code/types.js.map +7 -0
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.d.ts.map +1 -1
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/components/index.js.map +2 -2
- package/dist/esm/components/code/CodeBlock.d.ts +4 -0
- package/dist/esm/components/code/CodeBlock.d.ts.map +1 -0
- package/dist/esm/components/code/CodeBlock.js +2 -0
- package/dist/esm/components/code/CodeBlock.js.map +7 -0
- package/dist/esm/components/code/CopyButton.d.ts +7 -0
- package/dist/esm/components/code/CopyButton.d.ts.map +1 -0
- package/dist/esm/components/code/CopyButton.js +2 -0
- package/dist/esm/components/code/CopyButton.js.map +7 -0
- package/dist/esm/components/code/LanguageBadge.d.ts +7 -0
- package/dist/esm/components/code/LanguageBadge.d.ts.map +1 -0
- package/dist/esm/components/code/LanguageBadge.js +2 -0
- package/dist/esm/components/code/LanguageBadge.js.map +7 -0
- package/dist/esm/components/code/PreviewSection.d.ts +16 -0
- package/dist/esm/components/code/PreviewSection.d.ts.map +1 -0
- package/dist/esm/components/code/PreviewSection.js +2 -0
- package/dist/esm/components/code/PreviewSection.js.map +7 -0
- package/dist/esm/components/code/SyntaxHighlighter.d.ts +10 -0
- package/dist/esm/components/code/SyntaxHighlighter.d.ts.map +1 -0
- package/dist/esm/components/code/SyntaxHighlighter.js +2 -0
- package/dist/esm/components/code/SyntaxHighlighter.js.map +7 -0
- package/dist/esm/components/code/index.d.ts +3 -0
- package/dist/esm/components/code/index.d.ts.map +1 -0
- package/dist/esm/components/code/index.js +2 -0
- package/dist/esm/components/code/index.js.map +7 -0
- package/dist/esm/components/code/types.d.ts +24 -0
- package/dist/esm/components/code/types.d.ts.map +1 -0
- package/dist/esm/components/code/types.js +1 -0
- package/dist/esm/components/code/types.js.map +7 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/index.js.map +2 -2
- package/package.json +6 -5
- package/src/components/code/CodeBlock.tsx +119 -0
- package/src/components/code/CopyButton.tsx +46 -0
- package/src/components/code/LanguageBadge.tsx +33 -0
- package/src/components/code/PreviewSection.tsx +70 -0
- package/src/components/code/SyntaxHighlighter.tsx +55 -0
- package/src/components/code/index.ts +3 -0
- package/src/components/code/types.ts +32 -0
- package/src/components/index.css +122 -0
- package/src/components/index.ts +1 -0
- package/styles.css +114 -0
package/components.css
CHANGED
|
@@ -1 +1,137 @@
|
|
|
1
1
|
/* Components CSS aggregator for Kookie Blocks (e.g., hero variants if styled). */
|
|
2
|
+
|
|
3
|
+
/* ============================================
|
|
4
|
+
Code Block Component Styles
|
|
5
|
+
============================================ */
|
|
6
|
+
|
|
7
|
+
/* Code block wrapper - constrain width in flex containers */
|
|
8
|
+
|
|
9
|
+
.code-block-wrapper {
|
|
10
|
+
min-width: 0;
|
|
11
|
+
max-width: 100%;
|
|
12
|
+
width: 100%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* Code block content (the pre part, below the header) */
|
|
17
|
+
|
|
18
|
+
.code-block-content {
|
|
19
|
+
width: 100%;
|
|
20
|
+
min-width: 0;
|
|
21
|
+
overflow-x: auto;
|
|
22
|
+
/* Hide scrollbars while keeping scroll functionality */
|
|
23
|
+
scrollbar-width: none; /* Firefox */
|
|
24
|
+
-ms-overflow-style: none; /* IE/Edge */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Hide scrollbars for webkit browsers */
|
|
28
|
+
|
|
29
|
+
.code-block-content::-webkit-scrollbar,
|
|
30
|
+
.code-block-content::-webkit-scrollbar-horizontal,
|
|
31
|
+
.code-block-content::-webkit-scrollbar-vertical,
|
|
32
|
+
.code-block-content::-webkit-scrollbar-track,
|
|
33
|
+
.code-block-content::-webkit-scrollbar-thumb,
|
|
34
|
+
.code-block-content::-webkit-scrollbar-corner {
|
|
35
|
+
display: none !important;
|
|
36
|
+
width: 0 !important;
|
|
37
|
+
height: 0 !important;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Also hide scrollbars on any pre/code elements inside code content */
|
|
41
|
+
|
|
42
|
+
.code-block-content pre::-webkit-scrollbar,
|
|
43
|
+
.code-block-content pre::-webkit-scrollbar-horizontal,
|
|
44
|
+
.code-block-content pre::-webkit-scrollbar-vertical,
|
|
45
|
+
.code-block-content pre::-webkit-scrollbar-track,
|
|
46
|
+
.code-block-content pre::-webkit-scrollbar-thumb,
|
|
47
|
+
.code-block-content pre::-webkit-scrollbar-corner,
|
|
48
|
+
.code-block-content code::-webkit-scrollbar,
|
|
49
|
+
.code-block-content code::-webkit-scrollbar-horizontal,
|
|
50
|
+
.code-block-content code::-webkit-scrollbar-vertical,
|
|
51
|
+
.code-block-content code::-webkit-scrollbar-track,
|
|
52
|
+
.code-block-content code::-webkit-scrollbar-thumb,
|
|
53
|
+
.code-block-content code::-webkit-scrollbar-corner {
|
|
54
|
+
display: none !important;
|
|
55
|
+
width: 0 !important;
|
|
56
|
+
height: 0 !important;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.code-block-wrapper pre,
|
|
60
|
+
.code-block-wrapper .code-block-content pre {
|
|
61
|
+
overflow-x: visible; /* Let .code-block-content handle scrolling */
|
|
62
|
+
max-width: 100%;
|
|
63
|
+
min-width: 0;
|
|
64
|
+
margin: 0;
|
|
65
|
+
width: 100%;
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Ensure Shiki-generated pre elements fill width */
|
|
70
|
+
|
|
71
|
+
.code-block-content > pre {
|
|
72
|
+
width: 100% !important;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* Code elements inside pre */
|
|
77
|
+
|
|
78
|
+
.code-block-wrapper pre code,
|
|
79
|
+
.code-block-wrapper .code-block-content pre code {
|
|
80
|
+
font-family: var(--font-mono);
|
|
81
|
+
font-size: var(--font-size-2);
|
|
82
|
+
line-height: 1.75;
|
|
83
|
+
background: none !important;
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
gap: var(--space-1);
|
|
87
|
+
counter-reset: line;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Shiki line spans */
|
|
91
|
+
|
|
92
|
+
.code-block-wrapper pre code .line,
|
|
93
|
+
.code-block-wrapper .code-block-content pre code .line {
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
gap: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* Line numbers */
|
|
100
|
+
|
|
101
|
+
.code-block-wrapper pre code .line::before,
|
|
102
|
+
.code-block-wrapper .code-block-content pre code .line::before {
|
|
103
|
+
counter-increment: line;
|
|
104
|
+
content: counter(line);
|
|
105
|
+
display: inline-block;
|
|
106
|
+
min-width: 2ch;
|
|
107
|
+
text-align: right;
|
|
108
|
+
font-size: var(--font-size-1);
|
|
109
|
+
color: var(--gray-a9);
|
|
110
|
+
-webkit-user-select: none;
|
|
111
|
+
-moz-user-select: none;
|
|
112
|
+
user-select: none;
|
|
113
|
+
flex-shrink: 0;
|
|
114
|
+
margin-right: var(--space-4);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Default to light theme for all tokens (codeToHtml with defaultColor: false) */
|
|
118
|
+
|
|
119
|
+
.code-block-wrapper pre.shiki span {
|
|
120
|
+
color: var(--shiki-light) !important;
|
|
121
|
+
font-style: var(--shiki-light-font-style);
|
|
122
|
+
font-weight: var(--shiki-light-font-weight);
|
|
123
|
+
-webkit-text-decoration: var(--shiki-light-text-decoration);
|
|
124
|
+
text-decoration: var(--shiki-light-text-decoration);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* Override with dark theme colors when inside a dark context */
|
|
128
|
+
|
|
129
|
+
.dark .code-block-wrapper pre.shiki span,
|
|
130
|
+
.dark-theme .code-block-wrapper pre.shiki span,
|
|
131
|
+
[data-appearance="dark"] .code-block-wrapper pre.shiki span {
|
|
132
|
+
color: var(--shiki-dark) !important;
|
|
133
|
+
font-style: var(--shiki-dark-font-style);
|
|
134
|
+
font-weight: var(--shiki-dark-font-weight);
|
|
135
|
+
-webkit-text-decoration: var(--shiki-dark-text-decoration);
|
|
136
|
+
text-decoration: var(--shiki-dark-text-decoration);
|
|
137
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CodeBlockProps } from "./types";
|
|
3
|
+
export declare function CodeBlock({ children, code, language, preview, showCopy, showLanguage, lightTheme, darkTheme, background, backgroundProps, }: CodeBlockProps): React.JSX.Element | null;
|
|
4
|
+
//# sourceMappingURL=CodeBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../../../src/components/code/CodeBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAM9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAwD9C,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAe,EACf,YAAmB,EACnB,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,GAChB,EAAE,cAAc,4BA6ChB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var P=Object.create;var l=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var j=(o,t)=>{for(var e in t)l(o,e,{get:t[e],enumerable:!0})},f=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!F.call(o,s)&&s!==e&&l(o,s,{get:()=>t[s],enumerable:!(r=b(t,s))||r.enumerable});return o};var w=(o,t,e)=>(e=o!=null?P(k(o)):{},f(t||!o||!o.__esModule?l(e,"default",{value:o,enumerable:!0}):e,o)),B=o=>f(l({},"__esModule",{value:!0}),o);var T={};j(T,{CodeBlock:()=>S});module.exports=B(T);var n=w(require("react")),a=require("@kushagradhawan/kookie-ui"),u=require("./SyntaxHighlighter"),d=require("./CopyButton"),g=require("./LanguageBadge"),y=require("./PreviewSection");function v(o){if(!o)return"text";if(typeof o=="object"&&o!==null&&"props"in o){const t=o.props;if(t?.children&&typeof t.children=="object"){const p=(t.children.props?.className||"").match(/language-([\w-]+)/i);if(p)return p[1]}const r=(t?.className||"").match(/language-([\w-]+)/i);if(r)return r[1]}return"text"}function L(o){if(!o)return"";if(typeof o=="object"&&o!==null&&"props"in o){const t=o.props;if(t?.children&&typeof t.children=="object"){const r=t.children.props?.children;if(typeof r=="string")return r}if(typeof t?.children=="string")return t.children}return typeof o=="string"?o:""}function S({children:o,code:t,language:e,preview:r,showCopy:s=!0,showLanguage:m=!0,lightTheme:p,darkTheme:x,background:C,backgroundProps:N}){let c=t,i=e;return o&&!t&&(c=L(o),i=e||v(o)),i||(i="text"),!c&&!o?null:n.default.createElement(a.Flex,{direction:"column",className:"code-block-wrapper",style:{minWidth:0},my:"2"},r&&n.default.createElement(y.PreviewSection,{background:C,backgroundProps:N},r),n.default.createElement(a.Card,{size:"2",variant:"soft"},n.default.createElement(a.Flex,{gap:"2",direction:"column"},n.default.createElement(a.Flex,{align:"start",justify:"between"},m&&n.default.createElement(g.LanguageBadge,{language:i}),s&&c&&n.default.createElement(d.CopyButton,{code:c})),t&&n.default.createElement(u.SyntaxHighlighter,{code:t,language:i,lightTheme:p,darkTheme:x}),o&&!t&&n.default.createElement("div",{className:"code-block-content"},o))))}
|
|
2
|
+
//# sourceMappingURL=CodeBlock.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/CodeBlock.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { type ReactNode } from \"react\";\nimport { Card, Flex } from \"@kushagradhawan/kookie-ui\";\nimport { SyntaxHighlighter } from \"./SyntaxHighlighter\";\nimport { CopyButton } from \"./CopyButton\";\nimport { LanguageBadge } from \"./LanguageBadge\";\nimport { PreviewSection } from \"./PreviewSection\";\nimport type { CodeBlockProps } from \"./types\";\n\nfunction extractLanguageFromChildren(children?: ReactNode): string {\n if (!children) return \"text\";\n\n // Try to extract language from pre > code className\n if (typeof children === \"object\" && children !== null && \"props\" in children) {\n const childProps = (children as any).props;\n\n // If children is a <pre><code className=\"language-xxx\">\n if (childProps?.children && typeof childProps.children === \"object\") {\n const codeProps = (childProps.children as any).props;\n const className = codeProps?.className || \"\";\n const match = className.match(/language-([\\w-]+)/i);\n if (match) return match[1];\n }\n\n // Direct className on children\n const className = childProps?.className || \"\";\n const match = className.match(/language-([\\w-]+)/i);\n if (match) return match[1];\n }\n\n return \"text\";\n}\n\nfunction extractCodeFromChildren(children?: ReactNode): string {\n if (!children) return \"\";\n\n // Try to extract text from pre > code structure\n if (typeof children === \"object\" && children !== null && \"props\" in children) {\n const childProps = (children as any).props;\n\n // If children is <pre><code>...</code></pre>\n if (childProps?.children && typeof childProps.children === \"object\") {\n const codeProps = (childProps.children as any).props;\n const codeChildren = codeProps?.children;\n\n if (typeof codeChildren === \"string\") {\n return codeChildren;\n }\n }\n\n // Direct text content\n if (typeof childProps?.children === \"string\") {\n return childProps.children;\n }\n }\n\n if (typeof children === \"string\") {\n return children;\n }\n\n return \"\";\n}\n\nexport function CodeBlock({\n children,\n code,\n language,\n preview,\n showCopy = true,\n showLanguage = true,\n lightTheme,\n darkTheme,\n background,\n backgroundProps,\n}: CodeBlockProps) {\n // Determine the code and language to display\n let displayCode = code;\n let displayLanguage = language;\n\n // If children are provided (pre-highlighted from MDX), extract code and language\n if (children && !code) {\n displayCode = extractCodeFromChildren(children);\n displayLanguage = language || extractLanguageFromChildren(children);\n }\n\n // Default language\n if (!displayLanguage) {\n displayLanguage = \"text\";\n }\n\n // If no code to display, render nothing\n if (!displayCode && !children) {\n return null;\n }\n\n return (\n <Flex direction=\"column\" className=\"code-block-wrapper\" style={{ minWidth: 0 }} my=\"2\">\n {preview && (\n <PreviewSection background={background} backgroundProps={backgroundProps}>\n {preview}\n </PreviewSection>\n )}\n\n <Card size=\"2\" variant=\"soft\">\n <Flex gap=\"2\" direction=\"column\">\n <Flex align=\"start\" justify=\"between\">\n {showLanguage && <LanguageBadge language={displayLanguage} />}\n {showCopy && displayCode && <CopyButton code={displayCode} />}\n </Flex>\n\n {/* If we have runtime code, use SyntaxHighlighter */}\n {code && <SyntaxHighlighter code={code} language={displayLanguage} lightTheme={lightTheme} darkTheme={darkTheme} />}\n\n {/* If we have pre-highlighted children from MDX, render them */}\n {children && !code && <div className=\"code-block-content\">{children}</div>}\n </Flex>\n </Card>\n </Flex>\n );\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAsC,oBACtCC,EAA2B,qCAC3BC,EAAkC,+BAClCC,EAA2B,wBAC3BC,EAA8B,2BAC9BC,EAA+B,4BAG/B,SAASC,EAA4BC,EAA8B,CACjE,GAAI,CAACA,EAAU,MAAO,OAGtB,GAAI,OAAOA,GAAa,UAAYA,IAAa,MAAQ,UAAWA,EAAU,CAC5E,MAAMC,EAAcD,EAAiB,MAGrC,GAAIC,GAAY,UAAY,OAAOA,EAAW,UAAa,SAAU,CAGnE,MAAMC,GAFaD,EAAW,SAAiB,OAClB,WAAa,IAClB,MAAM,oBAAoB,EAClD,GAAIC,EAAO,OAAOA,EAAM,CAAC,CAC3B,CAIA,MAAMA,GADYD,GAAY,WAAa,IACnB,MAAM,oBAAoB,EAClD,GAAIC,EAAO,OAAOA,EAAM,CAAC,CAC3B,CAEA,MAAO,MACT,CAEA,SAASC,EAAwBH,EAA8B,CAC7D,GAAI,CAACA,EAAU,MAAO,GAGtB,GAAI,OAAOA,GAAa,UAAYA,IAAa,MAAQ,UAAWA,EAAU,CAC5E,MAAMC,EAAcD,EAAiB,MAGrC,GAAIC,GAAY,UAAY,OAAOA,EAAW,UAAa,SAAU,CAEnE,MAAMG,EADaH,EAAW,SAAiB,OACf,SAEhC,GAAI,OAAOG,GAAiB,SAC1B,OAAOA,CAEX,CAGA,GAAI,OAAOH,GAAY,UAAa,SAClC,OAAOA,EAAW,QAEtB,CAEA,OAAI,OAAOD,GAAa,SACfA,EAGF,EACT,CAEO,SAAST,EAAU,CACxB,SAAAS,EACA,KAAAK,EACA,SAAAC,EACA,QAAAC,EACA,SAAAC,EAAW,GACX,aAAAC,EAAe,GACf,WAAAC,EACA,UAAAC,EACA,WAAAC,EACA,gBAAAC,CACF,EAAmB,CAEjB,IAAIC,EAAcT,EACdU,EAAkBT,EActB,OAXIN,GAAY,CAACK,IACfS,EAAcX,EAAwBH,CAAQ,EAC9Ce,EAAkBT,GAAYP,EAA4BC,CAAQ,GAI/De,IACHA,EAAkB,QAIhB,CAACD,GAAe,CAACd,EACZ,KAIP,EAAAgB,QAAA,cAAC,QAAK,UAAU,SAAS,UAAU,qBAAqB,MAAO,CAAE,SAAU,CAAE,EAAG,GAAG,KAChFT,GACC,EAAAS,QAAA,cAAC,kBAAe,WAAYJ,EAAY,gBAAiBC,GACtDN,CACH,EAGF,EAAAS,QAAA,cAAC,QAAK,KAAK,IAAI,QAAQ,QACrB,EAAAA,QAAA,cAAC,QAAK,IAAI,IAAI,UAAU,UACtB,EAAAA,QAAA,cAAC,QAAK,MAAM,QAAQ,QAAQ,WACzBP,GAAgB,EAAAO,QAAA,cAAC,iBAAc,SAAUD,EAAiB,EAC1DP,GAAYM,GAAe,EAAAE,QAAA,cAAC,cAAW,KAAMF,EAAa,CAC7D,EAGCT,GAAQ,EAAAW,QAAA,cAAC,qBAAkB,KAAMX,EAAM,SAAUU,EAAiB,WAAYL,EAAY,UAAWC,EAAW,EAGhHX,GAAY,CAACK,GAAQ,EAAAW,QAAA,cAAC,OAAI,UAAU,sBAAsBhB,CAAS,CACtE,CACF,CACF,CAEJ",
|
|
6
|
+
"names": ["CodeBlock_exports", "__export", "CodeBlock", "__toCommonJS", "import_react", "import_kookie_ui", "import_SyntaxHighlighter", "import_CopyButton", "import_LanguageBadge", "import_PreviewSection", "extractLanguageFromChildren", "children", "childProps", "match", "extractCodeFromChildren", "codeChildren", "code", "language", "preview", "showCopy", "showLanguage", "lightTheme", "darkTheme", "background", "backgroundProps", "displayCode", "displayLanguage", "React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyButton.d.ts","sourceRoot":"","sources":["../../../../src/components/code/CopyButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,qBAoCnD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var f=Object.create;var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var T=(t,o)=>{for(var e in o)u(t,e,{get:o[e],enumerable:!0})},p=(t,o,e,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of m(o))!y.call(t,i)&&i!==e&&u(t,i,{get:()=>o[i],enumerable:!(n=l(o,i))||n.enumerable});return t};var d=(t,o,e)=>(e=t!=null?f(C(t)):{},p(o||!t||!t.__esModule?u(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>p(u({},"__esModule",{value:!0}),t);var b={};T(b,{CopyButton:()=>g});module.exports=B(b);var r=d(require("react")),a=require("@kushagradhawan/kookie-ui"),s=require("@hugeicons/react"),c=require("@hugeicons/core-free-icons");function g({code:t}){const[o,e]=(0,r.useState)(!1),n=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);const i=(0,r.useCallback)(async()=>{if(t.trim())try{await navigator.clipboard.writeText(t),e(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{e(!1)},2e3)}catch{}},[t]);return r.default.createElement(a.Button,{size:"2",tooltip:o?"Copied":"Copy code",variant:"ghost",onClick:i,"aria-label":o?"Copied":"Copy code"},r.default.createElement(s.HugeiconsIcon,{icon:o?c.Tick01Icon:c.Copy01Icon})," Copy")}
|
|
2
|
+
//# sourceMappingURL=CopyButton.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/CopyButton.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Button } from \"@kushagradhawan/kookie-ui\";\nimport { HugeiconsIcon } from \"@hugeicons/react\";\nimport { Copy01Icon, Tick01Icon } from \"@hugeicons/core-free-icons\";\n\ninterface CopyButtonProps {\n code: string;\n}\n\nexport function CopyButton({ code }: CopyButtonProps) {\n const [copied, setCopied] = useState(false);\n const resetTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n return () => {\n if (resetTimeoutRef.current) {\n clearTimeout(resetTimeoutRef.current);\n }\n };\n }, []);\n\n const handleCopy = useCallback(async () => {\n if (!code.trim()) return;\n\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n\n if (resetTimeoutRef.current) {\n clearTimeout(resetTimeoutRef.current);\n }\n\n resetTimeoutRef.current = setTimeout(() => {\n setCopied(false);\n }, 2000);\n } catch {\n // Silently fail\n }\n }, [code]);\n\n return (\n <Button size=\"2\" tooltip={copied ? \"Copied\" : \"Copy code\"} variant=\"ghost\" onClick={handleCopy} aria-label={copied ? \"Copied\" : \"Copy code\"}>\n <HugeiconsIcon icon={copied ? Tick01Icon : Copy01Icon} /> Copy\n </Button>\n );\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgE,oBAChEC,EAAuB,qCACvBD,EAA8B,4BAC9BE,EAAuC,sCAMhC,SAASJ,EAAW,CAAE,KAAAK,CAAK,EAAoB,CACpD,KAAM,CAACC,EAAQC,CAAS,KAAI,YAAS,EAAK,EACpCC,KAAkB,UAA6C,IAAI,KAEzE,aAAU,IACD,IAAM,CACPA,EAAgB,SAClB,aAAaA,EAAgB,OAAO,CAExC,EACC,CAAC,CAAC,EAEL,MAAMC,KAAa,eAAY,SAAY,CACzC,GAAKJ,EAAK,KAAK,EAEf,GAAI,CACF,MAAM,UAAU,UAAU,UAAUA,CAAI,EACxCE,EAAU,EAAI,EAEVC,EAAgB,SAClB,aAAaA,EAAgB,OAAO,EAGtCA,EAAgB,QAAU,WAAW,IAAM,CACzCD,EAAU,EAAK,CACjB,EAAG,GAAI,CACT,MAAQ,CAER,CACF,EAAG,CAACF,CAAI,CAAC,EAET,OACE,EAAAK,QAAA,cAAC,UAAO,KAAK,IAAI,QAASJ,EAAS,SAAW,YAAa,QAAQ,QAAQ,QAASG,EAAY,aAAYH,EAAS,SAAW,aAC9H,EAAAI,QAAA,cAAC,iBAAc,KAAMJ,EAAS,aAAa,aAAY,EAAE,OAC3D,CAEJ",
|
|
6
|
+
"names": ["CopyButton_exports", "__export", "CopyButton", "__toCommonJS", "import_react", "import_kookie_ui", "import_core_free_icons", "code", "copied", "setCopied", "resetTimeoutRef", "handleCopy", "React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LanguageBadge.d.ts","sourceRoot":"","sources":["../../../../src/components/code/LanguageBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAkBD,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,qBAQ7D"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var u=Object.create;var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var l=(a,t)=>{for(var e in t)n(a,e,{get:t[e],enumerable:!0})},o=(a,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let g of c(t))!h.call(a,g)&&g!==e&&n(a,g,{get:()=>t[g],enumerable:!(r=p(t,g))||r.enumerable});return a};var f=(a,t,e)=>(e=a!=null?u(d(a)):{},o(t||!a||!a.__esModule?n(e,"default",{value:a,enumerable:!0}):e,a)),L=a=>o(n({},"__esModule",{value:!0}),a);var y={};l(y,{LanguageBadge:()=>x});module.exports=L(y);var s=f(require("react")),i=require("@kushagradhawan/kookie-ui");function m(a){return{js:"JS",jsx:"JSX",ts:"TS",tsx:"TSX",py:"Python",rb:"Ruby",sh:"Shell",bash:"Bash",text:"plaintext"}[a.toLowerCase()]||a}function x({language:a}){const t=m(a);return s.default.createElement(i.Code,{size:"1",color:"gray",highContrast:!0},t)}
|
|
2
|
+
//# sourceMappingURL=LanguageBadge.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/LanguageBadge.tsx"],
|
|
4
|
+
"sourcesContent": ["import React from \"react\";\nimport { Code } from \"@kushagradhawan/kookie-ui\";\n\ninterface LanguageBadgeProps {\n language: string;\n}\n\nfunction formatLanguage(lang: string): string {\n const languageMap: Record<string, string> = {\n js: \"JS\",\n jsx: \"JSX\",\n ts: \"TS\",\n tsx: \"TSX\",\n py: \"Python\",\n rb: \"Ruby\",\n sh: \"Shell\",\n bash: \"Bash\",\n text: \"plaintext\",\n };\n\n return languageMap[lang.toLowerCase()] || lang;\n}\n\nexport function LanguageBadge({ language }: LanguageBadgeProps) {\n const displayLanguage = formatLanguage(language);\n\n return (\n <Code size=\"1\" color=\"gray\" highContrast>\n {displayLanguage}\n </Code>\n );\n}\n\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAqB,qCAMrB,SAASC,EAAeC,EAAsB,CAa5C,MAZ4C,CAC1C,GAAI,KACJ,IAAK,MACL,GAAI,KACJ,IAAK,MACL,GAAI,SACJ,GAAI,OACJ,GAAI,QACJ,KAAM,OACN,KAAM,WACR,EAEmBA,EAAK,YAAY,CAAC,GAAKA,CAC5C,CAEO,SAASL,EAAc,CAAE,SAAAM,CAAS,EAAuB,CAC9D,MAAMC,EAAkBH,EAAeE,CAAQ,EAE/C,OACE,EAAAE,QAAA,cAAC,QAAK,KAAK,IAAI,MAAM,OAAO,aAAY,IACrCD,CACH,CAEJ",
|
|
6
|
+
"names": ["LanguageBadge_exports", "__export", "LanguageBadge", "__toCommonJS", "import_react", "import_kookie_ui", "formatLanguage", "lang", "language", "displayLanguage", "React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
|
+
interface PreviewSectionProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
background?: "none" | "dots" | string;
|
|
5
|
+
backgroundProps?: {
|
|
6
|
+
dotSize?: number;
|
|
7
|
+
color?: string;
|
|
8
|
+
backgroundColor?: string;
|
|
9
|
+
height?: string;
|
|
10
|
+
width?: string;
|
|
11
|
+
radius?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function PreviewSection({ children, background, backgroundProps }: PreviewSectionProps): React.JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=PreviewSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewSection.d.ts","sourceRoot":"","sources":["../../../../src/components/code/PreviewSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG9C,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,eAAe,CAAC,EAAE;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,UAAmB,EAAE,eAAoB,EAAE,EAAE,mBAAmB,qBAqD1G"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var f=Object.create;var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var x=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},u=(r,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of S(e))!v.call(r,i)&&i!==t&&s(r,i,{get:()=>e[i],enumerable:!(a=m(e,i))||a.enumerable});return r};var P=(r,e,t)=>(t=r!=null?f(b(r)):{},u(e||!r||!r.__esModule?s(t,"default",{value:r,enumerable:!0}):t,r)),h=r=>u(s({},"__esModule",{value:!0}),r);var C={};x(C,{PreviewSection:()=>k});module.exports=h(C);var o=P(require("react")),n=require("@kushagradhawan/kookie-ui");function k({children:r,background:e="none",backgroundProps:t={}}){const{dotSize:a=24,color:i="var(--gray-10)",backgroundColor:l="var(--gray-2)",height:d="300px",width:g="100%",radius:c="3"}=t;if(e==="none")return o.default.createElement(n.Card,{size:"1",variant:"soft"},o.default.createElement(n.Flex,{justify:"center",align:"center",py:"4"},o.default.createElement(n.Theme,{fontFamily:"sans"},r)));if(e==="dots"){const y={backgroundImage:`radial-gradient(circle, ${i} 1px, transparent 1px)`,borderRadius:`var(--radius-${c})`,backgroundSize:`${a}px ${a}px`,backgroundPosition:"center",backgroundColor:l,height:d,width:g};return o.default.createElement(n.Card,{size:"1",variant:"soft"},o.default.createElement(n.Flex,{justify:"center",align:"center",py:"4",style:y},o.default.createElement(n.Theme,{fontFamily:"sans"},r)))}const p={backgroundImage:`url(${e})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",borderRadius:`var(--radius-${c})`,height:d,width:g};return o.default.createElement(n.Card,{size:"1",variant:"soft"},o.default.createElement(n.Flex,{justify:"center",align:"center",py:"4",style:p},o.default.createElement(n.Theme,{fontFamily:"sans"},r)))}
|
|
2
|
+
//# sourceMappingURL=PreviewSection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/PreviewSection.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { type ReactNode } from \"react\";\nimport { Card, Flex, Theme } from \"@kushagradhawan/kookie-ui\";\n\ninterface PreviewSectionProps {\n children: ReactNode;\n background?: \"none\" | \"dots\" | string;\n backgroundProps?: {\n dotSize?: number;\n color?: string;\n backgroundColor?: string;\n height?: string;\n width?: string;\n radius?: string;\n };\n}\n\nexport function PreviewSection({ children, background = \"none\", backgroundProps = {} }: PreviewSectionProps) {\n const { dotSize = 24, color = \"var(--gray-10)\", backgroundColor = \"var(--gray-2)\", height = \"300px\", width = \"100%\", radius = \"3\" } = backgroundProps;\n\n // Render with no background (default card styling)\n if (background === \"none\") {\n return (\n <Card size=\"1\" variant=\"soft\">\n <Flex justify=\"center\" align=\"center\" py=\"4\">\n <Theme fontFamily=\"sans\">{children}</Theme>\n </Flex>\n </Card>\n );\n }\n\n // Render with dots pattern background\n if (background === \"dots\") {\n const dotsStyle: React.CSSProperties = {\n backgroundImage: `radial-gradient(circle, ${color} 1px, transparent 1px)`,\n borderRadius: `var(--radius-${radius})`,\n backgroundSize: `${dotSize}px ${dotSize}px`,\n backgroundPosition: \"center\",\n backgroundColor,\n height,\n width,\n };\n\n return (\n <Card size=\"1\" variant=\"soft\">\n <Flex justify=\"center\" align=\"center\" py=\"4\" style={dotsStyle}>\n <Theme fontFamily=\"sans\">{children}</Theme>\n </Flex>\n </Card>\n );\n }\n\n // Render with custom image background\n const imageStyle: React.CSSProperties = {\n backgroundImage: `url(${background})`,\n backgroundSize: \"cover\",\n backgroundPosition: \"center\",\n backgroundRepeat: \"no-repeat\",\n borderRadius: `var(--radius-${radius})`,\n height,\n width,\n };\n\n return (\n <Card size=\"1\" variant=\"soft\">\n <Flex justify=\"center\" align=\"center\" py=\"4\" style={imageStyle}>\n <Theme fontFamily=\"sans\">{children}</Theme>\n </Flex>\n </Card>\n );\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAsC,oBACtCC,EAAkC,qCAe3B,SAASH,EAAe,CAAE,SAAAI,EAAU,WAAAC,EAAa,OAAQ,gBAAAC,EAAkB,CAAC,CAAE,EAAwB,CAC3G,KAAM,CAAE,QAAAC,EAAU,GAAI,MAAAC,EAAQ,iBAAkB,gBAAAC,EAAkB,gBAAiB,OAAAC,EAAS,QAAS,MAAAC,EAAQ,OAAQ,OAAAC,EAAS,GAAI,EAAIN,EAGtI,GAAID,IAAe,OACjB,OACE,EAAAQ,QAAA,cAAC,QAAK,KAAK,IAAI,QAAQ,QACrB,EAAAA,QAAA,cAAC,QAAK,QAAQ,SAAS,MAAM,SAAS,GAAG,KACvC,EAAAA,QAAA,cAAC,SAAM,WAAW,QAAQT,CAAS,CACrC,CACF,EAKJ,GAAIC,IAAe,OAAQ,CACzB,MAAMS,EAAiC,CACrC,gBAAiB,2BAA2BN,CAAK,yBACjD,aAAc,gBAAgBI,CAAM,IACpC,eAAgB,GAAGL,CAAO,MAAMA,CAAO,KACvC,mBAAoB,SACpB,gBAAAE,EACA,OAAAC,EACA,MAAAC,CACF,EAEA,OACE,EAAAE,QAAA,cAAC,QAAK,KAAK,IAAI,QAAQ,QACrB,EAAAA,QAAA,cAAC,QAAK,QAAQ,SAAS,MAAM,SAAS,GAAG,IAAI,MAAOC,GAClD,EAAAD,QAAA,cAAC,SAAM,WAAW,QAAQT,CAAS,CACrC,CACF,CAEJ,CAGA,MAAMW,EAAkC,CACtC,gBAAiB,OAAOV,CAAU,IAClC,eAAgB,QAChB,mBAAoB,SACpB,iBAAkB,YAClB,aAAc,gBAAgBO,CAAM,IACpC,OAAAF,EACA,MAAAC,CACF,EAEA,OACE,EAAAE,QAAA,cAAC,QAAK,KAAK,IAAI,QAAQ,QACrB,EAAAA,QAAA,cAAC,QAAK,QAAQ,SAAS,MAAM,SAAS,GAAG,IAAI,MAAOE,GAClD,EAAAF,QAAA,cAAC,SAAM,WAAW,QAAQT,CAAS,CACrC,CACF,CAEJ",
|
|
6
|
+
"names": ["PreviewSection_exports", "__export", "PreviewSection", "__toCommonJS", "import_react", "import_kookie_ui", "children", "background", "backgroundProps", "dotSize", "color", "backgroundColor", "height", "width", "radius", "React", "dotsStyle", "imageStyle"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SyntaxHighlighterProps {
|
|
3
|
+
code: string;
|
|
4
|
+
language: string;
|
|
5
|
+
lightTheme?: string;
|
|
6
|
+
darkTheme?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function SyntaxHighlighter({ code, language, lightTheme, darkTheme }: SyntaxHighlighterProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=SyntaxHighlighter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyntaxHighlighter.d.ts","sourceRoot":"","sources":["../../../../src/components/code/SyntaxHighlighter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAgC,EAAE,SAA8B,EAAE,EAAE,sBAAsB,qBAuC7I"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var f=Object.create;var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var E=(t,e)=>{for(var n in e)o(t,n,{get:e[n],enumerable:!0})},a=(t,e,n,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of u(e))!H.call(t,r)&&r!==n&&o(t,r,{get:()=>e[r],enumerable:!(l=m(e,r))||l.enumerable});return t};var T=(t,e,n)=>(n=t!=null?f(p(t)):{},a(e||!t||!t.__esModule?o(n,"default",{value:t,enumerable:!0}):n,t)),_=t=>a(o({},"__esModule",{value:!0}),t);var k={};E(k,{SyntaxHighlighter:()=>S});module.exports=_(k);var i=T(require("react")),c=require("shiki"),s=require("@kushagradhawan/kookie-ui");const x="one-light",y="one-dark-pro";function S({code:t,language:e,lightTheme:n=x,darkTheme:l=y}){const[r,h]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let g=!1;return(0,c.codeToHtml)(t,{lang:e,themes:{light:n,dark:l},defaultColor:!1}).then(d=>{g||h(d)}).catch(()=>{g||h(null)}),()=>{g=!0}},[t,e,n,l]),r?i.default.createElement(s.Box,{className:"code-block-content",width:"100%",style:{minWidth:0},dangerouslySetInnerHTML:{__html:r}}):i.default.createElement("pre",{className:"code-block-content"},i.default.createElement(s.Code,{size:"3"},t))}
|
|
2
|
+
//# sourceMappingURL=SyntaxHighlighter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/SyntaxHighlighter.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { useEffect, useState } from \"react\";\nimport { codeToHtml } from \"shiki\";\nimport { Box, Code } from \"@kushagradhawan/kookie-ui\";\n\ninterface SyntaxHighlighterProps {\n code: string;\n language: string;\n lightTheme?: string;\n darkTheme?: string;\n}\n\nconst DEFAULT_LIGHT_THEME = \"one-light\";\nconst DEFAULT_DARK_THEME = \"one-dark-pro\";\n\nexport function SyntaxHighlighter({ code, language, lightTheme = DEFAULT_LIGHT_THEME, darkTheme = DEFAULT_DARK_THEME }: SyntaxHighlighterProps) {\n const [highlighted, setHighlighted] = useState<string | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n codeToHtml(code, {\n lang: language,\n themes: {\n light: lightTheme,\n dark: darkTheme,\n },\n defaultColor: false,\n })\n .then((html) => {\n if (!cancelled) {\n setHighlighted(html);\n }\n })\n .catch(() => {\n if (!cancelled) {\n setHighlighted(null);\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [code, language, lightTheme, darkTheme]);\n\n if (!highlighted) {\n return (\n <pre className=\"code-block-content\">\n <Code size=\"3\">{code}</Code>\n </pre>\n );\n }\n\n return <Box className=\"code-block-content\" width=\"100%\" style={{ minWidth: 0 }} dangerouslySetInnerHTML={{ __html: highlighted }} />;\n}\n\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2C,oBAC3CC,EAA2B,iBAC3BC,EAA0B,qCAS1B,MAAMC,EAAsB,YACtBC,EAAqB,eAEpB,SAASN,EAAkB,CAAE,KAAAO,EAAM,SAAAC,EAAU,WAAAC,EAAaJ,EAAqB,UAAAK,EAAYJ,CAAmB,EAA2B,CAC9I,KAAM,CAACK,EAAaC,CAAc,KAAI,YAAwB,IAAI,EA6BlE,SA3BA,aAAU,IAAM,CACd,IAAIC,EAAY,GAEhB,uBAAWN,EAAM,CACf,KAAMC,EACN,OAAQ,CACN,MAAOC,EACP,KAAMC,CACR,EACA,aAAc,EAChB,CAAC,EACE,KAAMI,GAAS,CACTD,GACHD,EAAeE,CAAI,CAEvB,CAAC,EACA,MAAM,IAAM,CACND,GACHD,EAAe,IAAI,CAEvB,CAAC,EAEI,IAAM,CACXC,EAAY,EACd,CACF,EAAG,CAACN,EAAMC,EAAUC,EAAYC,CAAS,CAAC,EAErCC,EAQE,EAAAI,QAAA,cAAC,OAAI,UAAU,qBAAqB,MAAM,OAAO,MAAO,CAAE,SAAU,CAAE,EAAG,wBAAyB,CAAE,OAAQJ,CAAY,EAAG,EAN9H,EAAAI,QAAA,cAAC,OAAI,UAAU,sBACb,EAAAA,QAAA,cAAC,QAAK,KAAK,KAAKR,CAAK,CACvB,CAKN",
|
|
6
|
+
"names": ["SyntaxHighlighter_exports", "__export", "SyntaxHighlighter", "__toCommonJS", "import_react", "import_shiki", "import_kookie_ui", "DEFAULT_LIGHT_THEME", "DEFAULT_DARK_THEME", "code", "language", "lightTheme", "darkTheme", "highlighted", "setHighlighted", "cancelled", "html", "React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/code/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var m=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},s=(e,o,r,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let p of k(o))!l.call(e,p)&&p!==r&&t(e,p,{get:()=>o[p],enumerable:!(c=f(o,p))||c.enumerable});return e};var x=e=>s(t({},"__esModule",{value:!0}),e);var y={};m(y,{CodeBlock:()=>d.CodeBlock});module.exports=x(y);var d=require("./CodeBlock");
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Public API - only CodeBlock is exported\nexport { CodeBlock } from \"./CodeBlock\";\nexport type { CodeBlockProps } from \"./types\";\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4CAAAE,EAAAF,GACA,IAAAG,EAA0B",
|
|
6
|
+
"names": ["code_exports", "__export", "__toCommonJS", "import_CodeBlock"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface CodeBlockProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
code?: string;
|
|
5
|
+
language?: string;
|
|
6
|
+
preview?: ReactNode;
|
|
7
|
+
showCopy?: boolean;
|
|
8
|
+
showLanguage?: boolean;
|
|
9
|
+
file?: string;
|
|
10
|
+
collapsible?: boolean;
|
|
11
|
+
collapsedHeight?: number;
|
|
12
|
+
background?: "none" | "dots" | string;
|
|
13
|
+
backgroundProps?: {
|
|
14
|
+
dotSize?: number;
|
|
15
|
+
color?: string;
|
|
16
|
+
backgroundColor?: string;
|
|
17
|
+
height?: string;
|
|
18
|
+
width?: string;
|
|
19
|
+
radius?: string;
|
|
20
|
+
};
|
|
21
|
+
lightTheme?: string;
|
|
22
|
+
darkTheme?: string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/code/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,cAAc;IAE7B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,eAAe,CAAC,EAAE;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IAGF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var d=(o,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of a(e))!s.call(o,r)&&r!==i&&t(o,r,{get:()=>e[r],enumerable:!(n=g(e,r))||n.enumerable});return o};var l=o=>d(t({},"__esModule",{value:!0}),o);var c={};module.exports=l(c);
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/types.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ReactNode } from \"react\";\n\nexport interface CodeBlockProps {\n // Content modes (mutually exclusive)\n children?: ReactNode; // Pre-highlighted HTML from build-time (MDX)\n code?: string; // Raw code to highlight at runtime\n language?: string; // Language for runtime highlighting\n\n // Optional features\n preview?: ReactNode; // Preview component (for docs)\n showCopy?: boolean; // Default: true\n showLanguage?: boolean; // Default: true\n file?: string; // File path label\n collapsible?: boolean; // Enable expand/collapse\n collapsedHeight?: number; // Default: 360px\n\n // Preview styling (for kookie-ui docs)\n background?: \"none\" | \"dots\" | string; // Background type\n backgroundProps?: {\n dotSize?: number;\n color?: string;\n backgroundColor?: string;\n height?: string;\n width?: string;\n radius?: string;\n };\n\n // Theme\n lightTheme?: string; // Default: 'one-light'\n darkTheme?: string; // Default: 'one-dark-pro'\n}\n\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["types_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(r,m)&&m!==p&&a(r,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return r},f=(r,o,p)=>(t(r,o,"default"),p&&t(p,o,"default"));var g=r=>t(a({},"__esModule",{value:!0}),r);var e={};module.exports=g(e);f(e,require("./code"),module.exports);f(e,require("./hero"),module.exports);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './hero';\n"],
|
|
5
|
-
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,kBAAd",
|
|
4
|
+
"sourcesContent": ["export * from './code';\nexport * from './hero';\n"],
|
|
5
|
+
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,kBAAd,gBACAE,EAAAF,EAAc,kBADd",
|
|
6
6
|
"names": ["components_exports", "__toCommonJS", "__reExport"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CodeBlockProps } from "./types";
|
|
3
|
+
export declare function CodeBlock({ children, code, language, preview, showCopy, showLanguage, lightTheme, darkTheme, background, backgroundProps, }: CodeBlockProps): React.JSX.Element | null;
|
|
4
|
+
//# sourceMappingURL=CodeBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../../../src/components/code/CodeBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAM9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAwD9C,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAe,EACf,YAAmB,EACnB,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,GAChB,EAAE,cAAc,4BA6ChB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"react";import{Card as d,Flex as p}from"@kushagradhawan/kookie-ui";import{SyntaxHighlighter as g}from"./SyntaxHighlighter";import{CopyButton as y}from"./CopyButton";import{LanguageBadge as x}from"./LanguageBadge";import{PreviewSection as C}from"./PreviewSection";function N(o){if(!o)return"text";if(typeof o=="object"&&o!==null&&"props"in o){const t=o.props;if(t?.children&&typeof t.children=="object"){const a=(t.children.props?.className||"").match(/language-([\w-]+)/i);if(a)return a[1]}const r=(t?.className||"").match(/language-([\w-]+)/i);if(r)return r[1]}return"text"}function P(o){if(!o)return"";if(typeof o=="object"&&o!==null&&"props"in o){const t=o.props;if(t?.children&&typeof t.children=="object"){const r=t.children.props?.children;if(typeof r=="string")return r}if(typeof t?.children=="string")return t.children}return typeof o=="string"?o:""}function B({children:o,code:t,language:s,preview:r,showCopy:c=!0,showLanguage:l=!0,lightTheme:a,darkTheme:m,background:f,backgroundProps:u}){let i=t,n=s;return o&&!t&&(i=P(o),n=s||N(o)),n||(n="text"),!i&&!o?null:e.createElement(p,{direction:"column",className:"code-block-wrapper",style:{minWidth:0},my:"2"},r&&e.createElement(C,{background:f,backgroundProps:u},r),e.createElement(d,{size:"2",variant:"soft"},e.createElement(p,{gap:"2",direction:"column"},e.createElement(p,{align:"start",justify:"between"},l&&e.createElement(x,{language:n}),c&&i&&e.createElement(y,{code:i})),t&&e.createElement(g,{code:t,language:n,lightTheme:a,darkTheme:m}),o&&!t&&e.createElement("div",{className:"code-block-content"},o))))}export{B as CodeBlock};
|
|
2
|
+
//# sourceMappingURL=CodeBlock.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/CodeBlock.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { type ReactNode } from \"react\";\nimport { Card, Flex } from \"@kushagradhawan/kookie-ui\";\nimport { SyntaxHighlighter } from \"./SyntaxHighlighter\";\nimport { CopyButton } from \"./CopyButton\";\nimport { LanguageBadge } from \"./LanguageBadge\";\nimport { PreviewSection } from \"./PreviewSection\";\nimport type { CodeBlockProps } from \"./types\";\n\nfunction extractLanguageFromChildren(children?: ReactNode): string {\n if (!children) return \"text\";\n\n // Try to extract language from pre > code className\n if (typeof children === \"object\" && children !== null && \"props\" in children) {\n const childProps = (children as any).props;\n\n // If children is a <pre><code className=\"language-xxx\">\n if (childProps?.children && typeof childProps.children === \"object\") {\n const codeProps = (childProps.children as any).props;\n const className = codeProps?.className || \"\";\n const match = className.match(/language-([\\w-]+)/i);\n if (match) return match[1];\n }\n\n // Direct className on children\n const className = childProps?.className || \"\";\n const match = className.match(/language-([\\w-]+)/i);\n if (match) return match[1];\n }\n\n return \"text\";\n}\n\nfunction extractCodeFromChildren(children?: ReactNode): string {\n if (!children) return \"\";\n\n // Try to extract text from pre > code structure\n if (typeof children === \"object\" && children !== null && \"props\" in children) {\n const childProps = (children as any).props;\n\n // If children is <pre><code>...</code></pre>\n if (childProps?.children && typeof childProps.children === \"object\") {\n const codeProps = (childProps.children as any).props;\n const codeChildren = codeProps?.children;\n\n if (typeof codeChildren === \"string\") {\n return codeChildren;\n }\n }\n\n // Direct text content\n if (typeof childProps?.children === \"string\") {\n return childProps.children;\n }\n }\n\n if (typeof children === \"string\") {\n return children;\n }\n\n return \"\";\n}\n\nexport function CodeBlock({\n children,\n code,\n language,\n preview,\n showCopy = true,\n showLanguage = true,\n lightTheme,\n darkTheme,\n background,\n backgroundProps,\n}: CodeBlockProps) {\n // Determine the code and language to display\n let displayCode = code;\n let displayLanguage = language;\n\n // If children are provided (pre-highlighted from MDX), extract code and language\n if (children && !code) {\n displayCode = extractCodeFromChildren(children);\n displayLanguage = language || extractLanguageFromChildren(children);\n }\n\n // Default language\n if (!displayLanguage) {\n displayLanguage = \"text\";\n }\n\n // If no code to display, render nothing\n if (!displayCode && !children) {\n return null;\n }\n\n return (\n <Flex direction=\"column\" className=\"code-block-wrapper\" style={{ minWidth: 0 }} my=\"2\">\n {preview && (\n <PreviewSection background={background} backgroundProps={backgroundProps}>\n {preview}\n </PreviewSection>\n )}\n\n <Card size=\"2\" variant=\"soft\">\n <Flex gap=\"2\" direction=\"column\">\n <Flex align=\"start\" justify=\"between\">\n {showLanguage && <LanguageBadge language={displayLanguage} />}\n {showCopy && displayCode && <CopyButton code={displayCode} />}\n </Flex>\n\n {/* If we have runtime code, use SyntaxHighlighter */}\n {code && <SyntaxHighlighter code={code} language={displayLanguage} lightTheme={lightTheme} darkTheme={darkTheme} />}\n\n {/* If we have pre-highlighted children from MDX, render them */}\n {children && !code && <div className=\"code-block-content\">{children}</div>}\n </Flex>\n </Card>\n </Flex>\n );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAA+B,QACtC,OAAS,QAAAC,EAAM,QAAAC,MAAY,4BAC3B,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,cAAAC,MAAkB,eAC3B,OAAS,iBAAAC,MAAqB,kBAC9B,OAAS,kBAAAC,MAAsB,mBAG/B,SAASC,EAA4BC,EAA8B,CACjE,GAAI,CAACA,EAAU,MAAO,OAGtB,GAAI,OAAOA,GAAa,UAAYA,IAAa,MAAQ,UAAWA,EAAU,CAC5E,MAAMC,EAAcD,EAAiB,MAGrC,GAAIC,GAAY,UAAY,OAAOA,EAAW,UAAa,SAAU,CAGnE,MAAMC,GAFaD,EAAW,SAAiB,OAClB,WAAa,IAClB,MAAM,oBAAoB,EAClD,GAAIC,EAAO,OAAOA,EAAM,CAAC,CAC3B,CAIA,MAAMA,GADYD,GAAY,WAAa,IACnB,MAAM,oBAAoB,EAClD,GAAIC,EAAO,OAAOA,EAAM,CAAC,CAC3B,CAEA,MAAO,MACT,CAEA,SAASC,EAAwBH,EAA8B,CAC7D,GAAI,CAACA,EAAU,MAAO,GAGtB,GAAI,OAAOA,GAAa,UAAYA,IAAa,MAAQ,UAAWA,EAAU,CAC5E,MAAMC,EAAcD,EAAiB,MAGrC,GAAIC,GAAY,UAAY,OAAOA,EAAW,UAAa,SAAU,CAEnE,MAAMG,EADaH,EAAW,SAAiB,OACf,SAEhC,GAAI,OAAOG,GAAiB,SAC1B,OAAOA,CAEX,CAGA,GAAI,OAAOH,GAAY,UAAa,SAClC,OAAOA,EAAW,QAEtB,CAEA,OAAI,OAAOD,GAAa,SACfA,EAGF,EACT,CAEO,SAASK,EAAU,CACxB,SAAAL,EACA,KAAAM,EACA,SAAAC,EACA,QAAAC,EACA,SAAAC,EAAW,GACX,aAAAC,EAAe,GACf,WAAAC,EACA,UAAAC,EACA,WAAAC,EACA,gBAAAC,CACF,EAAmB,CAEjB,IAAIC,EAAcT,EACdU,EAAkBT,EActB,OAXIP,GAAY,CAACM,IACfS,EAAcZ,EAAwBH,CAAQ,EAC9CgB,EAAkBT,GAAYR,EAA4BC,CAAQ,GAI/DgB,IACHA,EAAkB,QAIhB,CAACD,GAAe,CAACf,EACZ,KAIPR,EAAA,cAACE,EAAA,CAAK,UAAU,SAAS,UAAU,qBAAqB,MAAO,CAAE,SAAU,CAAE,EAAG,GAAG,KAChFc,GACChB,EAAA,cAACM,EAAA,CAAe,WAAYe,EAAY,gBAAiBC,GACtDN,CACH,EAGFhB,EAAA,cAACC,EAAA,CAAK,KAAK,IAAI,QAAQ,QACrBD,EAAA,cAACE,EAAA,CAAK,IAAI,IAAI,UAAU,UACtBF,EAAA,cAACE,EAAA,CAAK,MAAM,QAAQ,QAAQ,WACzBgB,GAAgBlB,EAAA,cAACK,EAAA,CAAc,SAAUmB,EAAiB,EAC1DP,GAAYM,GAAevB,EAAA,cAACI,EAAA,CAAW,KAAMmB,EAAa,CAC7D,EAGCT,GAAQd,EAAA,cAACG,EAAA,CAAkB,KAAMW,EAAM,SAAUU,EAAiB,WAAYL,EAAY,UAAWC,EAAW,EAGhHZ,GAAY,CAACM,GAAQd,EAAA,cAAC,OAAI,UAAU,sBAAsBQ,CAAS,CACtE,CACF,CACF,CAEJ",
|
|
6
|
+
"names": ["React", "Card", "Flex", "SyntaxHighlighter", "CopyButton", "LanguageBadge", "PreviewSection", "extractLanguageFromChildren", "children", "childProps", "match", "extractCodeFromChildren", "codeChildren", "CodeBlock", "code", "language", "preview", "showCopy", "showLanguage", "lightTheme", "darkTheme", "background", "backgroundProps", "displayCode", "displayLanguage"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyButton.d.ts","sourceRoot":"","sources":["../../../../src/components/code/CopyButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,qBAoCnD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import n,{useCallback as u,useEffect as c,useRef as p,useState as a}from"react";import{Button as s}from"@kushagradhawan/kookie-ui";import{HugeiconsIcon as f}from"@hugeicons/react";import{Copy01Icon as l,Tick01Icon as m}from"@hugeicons/core-free-icons";function B({code:o}){const[e,r]=a(!1),t=p(null);c(()=>()=>{t.current&&clearTimeout(t.current)},[]);const i=u(async()=>{if(o.trim())try{await navigator.clipboard.writeText(o),r(!0),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{r(!1)},2e3)}catch{}},[o]);return n.createElement(s,{size:"2",tooltip:e?"Copied":"Copy code",variant:"ghost",onClick:i,"aria-label":e?"Copied":"Copy code"},n.createElement(f,{icon:e?m:l})," Copy")}export{B as CopyButton};
|
|
2
|
+
//# sourceMappingURL=CopyButton.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/CopyButton.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Button } from \"@kushagradhawan/kookie-ui\";\nimport { HugeiconsIcon } from \"@hugeicons/react\";\nimport { Copy01Icon, Tick01Icon } from \"@hugeicons/core-free-icons\";\n\ninterface CopyButtonProps {\n code: string;\n}\n\nexport function CopyButton({ code }: CopyButtonProps) {\n const [copied, setCopied] = useState(false);\n const resetTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n return () => {\n if (resetTimeoutRef.current) {\n clearTimeout(resetTimeoutRef.current);\n }\n };\n }, []);\n\n const handleCopy = useCallback(async () => {\n if (!code.trim()) return;\n\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n\n if (resetTimeoutRef.current) {\n clearTimeout(resetTimeoutRef.current);\n }\n\n resetTimeoutRef.current = setTimeout(() => {\n setCopied(false);\n }, 2000);\n } catch {\n // Silently fail\n }\n }, [code]);\n\n return (\n <Button size=\"2\" tooltip={copied ? \"Copied\" : \"Copy code\"} variant=\"ghost\" onClick={handleCopy} aria-label={copied ? \"Copied\" : \"Copy code\"}>\n <HugeiconsIcon icon={copied ? Tick01Icon : Copy01Icon} /> Copy\n </Button>\n );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,GAAS,eAAAC,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QAChE,OAAS,UAAAC,MAAc,4BACvB,OAAS,iBAAAC,MAAqB,mBAC9B,OAAS,cAAAC,EAAY,cAAAC,MAAkB,6BAMhC,SAASC,EAAW,CAAE,KAAAC,CAAK,EAAoB,CACpD,KAAM,CAACC,EAAQC,CAAS,EAAIR,EAAS,EAAK,EACpCS,EAAkBV,EAA6C,IAAI,EAEzED,EAAU,IACD,IAAM,CACPW,EAAgB,SAClB,aAAaA,EAAgB,OAAO,CAExC,EACC,CAAC,CAAC,EAEL,MAAMC,EAAab,EAAY,SAAY,CACzC,GAAKS,EAAK,KAAK,EAEf,GAAI,CACF,MAAM,UAAU,UAAU,UAAUA,CAAI,EACxCE,EAAU,EAAI,EAEVC,EAAgB,SAClB,aAAaA,EAAgB,OAAO,EAGtCA,EAAgB,QAAU,WAAW,IAAM,CACzCD,EAAU,EAAK,CACjB,EAAG,GAAI,CACT,MAAQ,CAER,CACF,EAAG,CAACF,CAAI,CAAC,EAET,OACEV,EAAA,cAACK,EAAA,CAAO,KAAK,IAAI,QAASM,EAAS,SAAW,YAAa,QAAQ,QAAQ,QAASG,EAAY,aAAYH,EAAS,SAAW,aAC9HX,EAAA,cAACM,EAAA,CAAc,KAAMK,EAASH,EAAaD,EAAY,EAAE,OAC3D,CAEJ",
|
|
6
|
+
"names": ["React", "useCallback", "useEffect", "useRef", "useState", "Button", "HugeiconsIcon", "Copy01Icon", "Tick01Icon", "CopyButton", "code", "copied", "setCopied", "resetTimeoutRef", "handleCopy"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LanguageBadge.d.ts","sourceRoot":"","sources":["../../../../src/components/code/LanguageBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAkBD,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,qBAQ7D"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"react";import{Code as g}from"@kushagradhawan/kookie-ui";function n(a){return{js:"JS",jsx:"JSX",ts:"TS",tsx:"TSX",py:"Python",rb:"Ruby",sh:"Shell",bash:"Bash",text:"plaintext"}[a.toLowerCase()]||a}function s({language:a}){const t=n(a);return e.createElement(g,{size:"1",color:"gray",highContrast:!0},t)}export{s as LanguageBadge};
|
|
2
|
+
//# sourceMappingURL=LanguageBadge.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/LanguageBadge.tsx"],
|
|
4
|
+
"sourcesContent": ["import React from \"react\";\nimport { Code } from \"@kushagradhawan/kookie-ui\";\n\ninterface LanguageBadgeProps {\n language: string;\n}\n\nfunction formatLanguage(lang: string): string {\n const languageMap: Record<string, string> = {\n js: \"JS\",\n jsx: \"JSX\",\n ts: \"TS\",\n tsx: \"TSX\",\n py: \"Python\",\n rb: \"Ruby\",\n sh: \"Shell\",\n bash: \"Bash\",\n text: \"plaintext\",\n };\n\n return languageMap[lang.toLowerCase()] || lang;\n}\n\nexport function LanguageBadge({ language }: LanguageBadgeProps) {\n const displayLanguage = formatLanguage(language);\n\n return (\n <Code size=\"1\" color=\"gray\" highContrast>\n {displayLanguage}\n </Code>\n );\n}\n\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,MAAY,4BAMrB,SAASC,EAAeC,EAAsB,CAa5C,MAZ4C,CAC1C,GAAI,KACJ,IAAK,MACL,GAAI,KACJ,IAAK,MACL,GAAI,SACJ,GAAI,OACJ,GAAI,QACJ,KAAM,OACN,KAAM,WACR,EAEmBA,EAAK,YAAY,CAAC,GAAKA,CAC5C,CAEO,SAASC,EAAc,CAAE,SAAAC,CAAS,EAAuB,CAC9D,MAAMC,EAAkBJ,EAAeG,CAAQ,EAE/C,OACEL,EAAA,cAACC,EAAA,CAAK,KAAK,IAAI,MAAM,OAAO,aAAY,IACrCK,CACH,CAEJ",
|
|
6
|
+
"names": ["React", "Code", "formatLanguage", "lang", "LanguageBadge", "language", "displayLanguage"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
|
+
interface PreviewSectionProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
background?: "none" | "dots" | string;
|
|
5
|
+
backgroundProps?: {
|
|
6
|
+
dotSize?: number;
|
|
7
|
+
color?: string;
|
|
8
|
+
backgroundColor?: string;
|
|
9
|
+
height?: string;
|
|
10
|
+
width?: string;
|
|
11
|
+
radius?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function PreviewSection({ children, background, backgroundProps }: PreviewSectionProps): React.JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=PreviewSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewSection.d.ts","sourceRoot":"","sources":["../../../../src/components/code/PreviewSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG9C,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,eAAe,CAAC,EAAE;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,UAAmB,EAAE,eAAoB,EAAE,EAAE,mBAAmB,qBAqD1G"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import r from"react";import{Card as t,Flex as o,Theme as i}from"@kushagradhawan/kookie-ui";function S({children:e,background:n="none",backgroundProps:c={}}){const{dotSize:a=24,color:u="var(--gray-10)",backgroundColor:l="var(--gray-2)",height:s="300px",width:d="100%",radius:g="3"}=c;if(n==="none")return r.createElement(t,{size:"1",variant:"soft"},r.createElement(o,{justify:"center",align:"center",py:"4"},r.createElement(i,{fontFamily:"sans"},e)));if(n==="dots"){const y={backgroundImage:`radial-gradient(circle, ${u} 1px, transparent 1px)`,borderRadius:`var(--radius-${g})`,backgroundSize:`${a}px ${a}px`,backgroundPosition:"center",backgroundColor:l,height:s,width:d};return r.createElement(t,{size:"1",variant:"soft"},r.createElement(o,{justify:"center",align:"center",py:"4",style:y},r.createElement(i,{fontFamily:"sans"},e)))}const p={backgroundImage:`url(${n})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",borderRadius:`var(--radius-${g})`,height:s,width:d};return r.createElement(t,{size:"1",variant:"soft"},r.createElement(o,{justify:"center",align:"center",py:"4",style:p},r.createElement(i,{fontFamily:"sans"},e)))}export{S as PreviewSection};
|
|
2
|
+
//# sourceMappingURL=PreviewSection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/PreviewSection.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { type ReactNode } from \"react\";\nimport { Card, Flex, Theme } from \"@kushagradhawan/kookie-ui\";\n\ninterface PreviewSectionProps {\n children: ReactNode;\n background?: \"none\" | \"dots\" | string;\n backgroundProps?: {\n dotSize?: number;\n color?: string;\n backgroundColor?: string;\n height?: string;\n width?: string;\n radius?: string;\n };\n}\n\nexport function PreviewSection({ children, background = \"none\", backgroundProps = {} }: PreviewSectionProps) {\n const { dotSize = 24, color = \"var(--gray-10)\", backgroundColor = \"var(--gray-2)\", height = \"300px\", width = \"100%\", radius = \"3\" } = backgroundProps;\n\n // Render with no background (default card styling)\n if (background === \"none\") {\n return (\n <Card size=\"1\" variant=\"soft\">\n <Flex justify=\"center\" align=\"center\" py=\"4\">\n <Theme fontFamily=\"sans\">{children}</Theme>\n </Flex>\n </Card>\n );\n }\n\n // Render with dots pattern background\n if (background === \"dots\") {\n const dotsStyle: React.CSSProperties = {\n backgroundImage: `radial-gradient(circle, ${color} 1px, transparent 1px)`,\n borderRadius: `var(--radius-${radius})`,\n backgroundSize: `${dotSize}px ${dotSize}px`,\n backgroundPosition: \"center\",\n backgroundColor,\n height,\n width,\n };\n\n return (\n <Card size=\"1\" variant=\"soft\">\n <Flex justify=\"center\" align=\"center\" py=\"4\" style={dotsStyle}>\n <Theme fontFamily=\"sans\">{children}</Theme>\n </Flex>\n </Card>\n );\n }\n\n // Render with custom image background\n const imageStyle: React.CSSProperties = {\n backgroundImage: `url(${background})`,\n backgroundSize: \"cover\",\n backgroundPosition: \"center\",\n backgroundRepeat: \"no-repeat\",\n borderRadius: `var(--radius-${radius})`,\n height,\n width,\n };\n\n return (\n <Card size=\"1\" variant=\"soft\">\n <Flex justify=\"center\" align=\"center\" py=\"4\" style={imageStyle}>\n <Theme fontFamily=\"sans\">{children}</Theme>\n </Flex>\n </Card>\n );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAA+B,QACtC,OAAS,QAAAC,EAAM,QAAAC,EAAM,SAAAC,MAAa,4BAe3B,SAASC,EAAe,CAAE,SAAAC,EAAU,WAAAC,EAAa,OAAQ,gBAAAC,EAAkB,CAAC,CAAE,EAAwB,CAC3G,KAAM,CAAE,QAAAC,EAAU,GAAI,MAAAC,EAAQ,iBAAkB,gBAAAC,EAAkB,gBAAiB,OAAAC,EAAS,QAAS,MAAAC,EAAQ,OAAQ,OAAAC,EAAS,GAAI,EAAIN,EAGtI,GAAID,IAAe,OACjB,OACEN,EAAA,cAACC,EAAA,CAAK,KAAK,IAAI,QAAQ,QACrBD,EAAA,cAACE,EAAA,CAAK,QAAQ,SAAS,MAAM,SAAS,GAAG,KACvCF,EAAA,cAACG,EAAA,CAAM,WAAW,QAAQE,CAAS,CACrC,CACF,EAKJ,GAAIC,IAAe,OAAQ,CACzB,MAAMQ,EAAiC,CACrC,gBAAiB,2BAA2BL,CAAK,yBACjD,aAAc,gBAAgBI,CAAM,IACpC,eAAgB,GAAGL,CAAO,MAAMA,CAAO,KACvC,mBAAoB,SACpB,gBAAAE,EACA,OAAAC,EACA,MAAAC,CACF,EAEA,OACEZ,EAAA,cAACC,EAAA,CAAK,KAAK,IAAI,QAAQ,QACrBD,EAAA,cAACE,EAAA,CAAK,QAAQ,SAAS,MAAM,SAAS,GAAG,IAAI,MAAOY,GAClDd,EAAA,cAACG,EAAA,CAAM,WAAW,QAAQE,CAAS,CACrC,CACF,CAEJ,CAGA,MAAMU,EAAkC,CACtC,gBAAiB,OAAOT,CAAU,IAClC,eAAgB,QAChB,mBAAoB,SACpB,iBAAkB,YAClB,aAAc,gBAAgBO,CAAM,IACpC,OAAAF,EACA,MAAAC,CACF,EAEA,OACEZ,EAAA,cAACC,EAAA,CAAK,KAAK,IAAI,QAAQ,QACrBD,EAAA,cAACE,EAAA,CAAK,QAAQ,SAAS,MAAM,SAAS,GAAG,IAAI,MAAOa,GAClDf,EAAA,cAACG,EAAA,CAAM,WAAW,QAAQE,CAAS,CACrC,CACF,CAEJ",
|
|
6
|
+
"names": ["React", "Card", "Flex", "Theme", "PreviewSection", "children", "background", "backgroundProps", "dotSize", "color", "backgroundColor", "height", "width", "radius", "dotsStyle", "imageStyle"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SyntaxHighlighterProps {
|
|
3
|
+
code: string;
|
|
4
|
+
language: string;
|
|
5
|
+
lightTheme?: string;
|
|
6
|
+
darkTheme?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function SyntaxHighlighter({ code, language, lightTheme, darkTheme }: SyntaxHighlighterProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=SyntaxHighlighter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyntaxHighlighter.d.ts","sourceRoot":"","sources":["../../../../src/components/code/SyntaxHighlighter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAgC,EAAE,SAA8B,EAAE,EAAE,sBAAsB,qBAuC7I"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import n,{useEffect as h,useState as a}from"react";import{codeToHtml as c}from"shiki";import{Box as d,Code as f}from"@kushagradhawan/kookie-ui";const m="one-light",u="one-dark-pro";function T({code:t,language:r,lightTheme:i=m,darkTheme:l=u}){const[o,s]=a(null);return h(()=>{let e=!1;return c(t,{lang:r,themes:{light:i,dark:l},defaultColor:!1}).then(g=>{e||s(g)}).catch(()=>{e||s(null)}),()=>{e=!0}},[t,r,i,l]),o?n.createElement(d,{className:"code-block-content",width:"100%",style:{minWidth:0},dangerouslySetInnerHTML:{__html:o}}):n.createElement("pre",{className:"code-block-content"},n.createElement(f,{size:"3"},t))}export{T as SyntaxHighlighter};
|
|
2
|
+
//# sourceMappingURL=SyntaxHighlighter.js.map
|