@kushagradhawan/kookie-blocks 0.1.13 → 0.1.15
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/cjs/components/code/{CodeBlock.d.ts → code-block.d.ts} +1 -1
- package/dist/cjs/components/code/code-block.d.ts.map +1 -0
- package/dist/cjs/components/code/code-block.js +2 -0
- package/dist/cjs/components/code/code-block.js.map +7 -0
- package/dist/{esm/components/code/CopyButton.d.ts → cjs/components/code/copy-button.d.ts} +1 -1
- package/dist/cjs/components/code/copy-button.d.ts.map +1 -0
- package/dist/cjs/components/code/{CopyButton.js → copy-button.js} +1 -1
- package/dist/cjs/components/code/{CopyButton.js.map → copy-button.js.map} +2 -2
- package/dist/cjs/components/code/index.d.ts +3 -3
- package/dist/cjs/components/code/index.d.ts.map +1 -1
- package/dist/cjs/components/code/index.js +1 -1
- package/dist/cjs/components/code/index.js.map +3 -3
- package/dist/{esm/components/code/LanguageBadge.d.ts → cjs/components/code/language-badge.d.ts} +1 -1
- package/dist/cjs/components/code/language-badge.d.ts.map +1 -0
- package/dist/cjs/components/code/{LanguageBadge.js → language-badge.js} +1 -1
- package/dist/cjs/components/code/{LanguageBadge.js.map → language-badge.js.map} +2 -2
- package/dist/{esm/components/code/PreviewSection.d.ts → cjs/components/code/preview-section.d.ts} +1 -1
- package/dist/cjs/components/code/preview-section.d.ts.map +1 -0
- package/dist/cjs/components/code/{PreviewSection.js → preview-section.js} +1 -1
- package/dist/cjs/components/code/{PreviewSection.js.map → preview-section.js.map} +2 -2
- package/dist/{esm/components/code/SyntaxHighlighter.d.ts → cjs/components/code/syntax-highlighter.d.ts} +1 -1
- package/dist/cjs/components/code/syntax-highlighter.d.ts.map +1 -0
- package/dist/cjs/components/code/{SyntaxHighlighter.js → syntax-highlighter.js} +1 -1
- package/dist/cjs/components/code/{SyntaxHighlighter.js.map → syntax-highlighter.js.map} +2 -2
- package/dist/{esm/components/code/useCodeCard.d.ts → cjs/components/code/use-code-card.d.ts} +1 -1
- package/dist/cjs/components/code/use-code-card.d.ts.map +1 -0
- package/dist/cjs/components/code/{useCodeCard.js → use-code-card.js} +1 -1
- package/dist/cjs/components/code/{useCodeCard.js.map → use-code-card.js.map} +2 -2
- package/dist/cjs/components/hero/{Hero.d.ts → hero.d.ts} +1 -1
- package/dist/cjs/components/hero/{Hero.d.ts.map → hero.d.ts.map} +1 -1
- package/dist/cjs/components/hero/{Hero.js → hero.js} +1 -1
- package/dist/cjs/components/hero/{Hero.js.map → hero.js.map} +2 -2
- package/dist/cjs/components/hero/index.d.ts +1 -1
- package/dist/cjs/components/hero/index.js +1 -1
- package/dist/cjs/components/hero/index.js.map +2 -2
- package/dist/{esm/components/markdown/createMarkdownComponents.d.ts → cjs/components/markdown/create-markdown-components.d.ts} +1 -1
- package/dist/cjs/components/markdown/create-markdown-components.d.ts.map +1 -0
- package/dist/cjs/components/markdown/{createMarkdownComponents.js → create-markdown-components.js} +2 -2
- package/dist/cjs/components/markdown/create-markdown-components.js.map +7 -0
- package/dist/cjs/components/markdown/index.d.ts +4 -4
- package/dist/cjs/components/markdown/index.d.ts.map +1 -1
- package/dist/cjs/components/markdown/index.js +1 -1
- package/dist/cjs/components/markdown/index.js.map +3 -3
- package/dist/{esm/components/markdown/StreamingMarkdown.d.ts → cjs/components/markdown/streaming-markdown.d.ts} +1 -1
- package/dist/cjs/components/markdown/streaming-markdown.d.ts.map +1 -0
- package/dist/cjs/components/markdown/streaming-markdown.js +2 -0
- package/dist/cjs/components/markdown/streaming-markdown.js.map +7 -0
- package/dist/{esm/components/markdown/utils/markdownStreaming.d.ts → cjs/components/markdown/utils/markdown-streaming.d.ts} +1 -1
- package/dist/cjs/components/markdown/utils/markdown-streaming.d.ts.map +1 -0
- package/dist/cjs/components/markdown/utils/{markdownStreaming.js → markdown-streaming.js} +1 -1
- package/dist/cjs/components/markdown/utils/{markdownStreaming.js.map → markdown-streaming.js.map} +2 -2
- package/dist/esm/components/code/{CodeBlock.d.ts → code-block.d.ts} +1 -1
- package/dist/esm/components/code/code-block.d.ts.map +1 -0
- package/dist/esm/components/code/code-block.js +2 -0
- package/dist/esm/components/code/code-block.js.map +7 -0
- package/dist/{cjs/components/code/CopyButton.d.ts → esm/components/code/copy-button.d.ts} +1 -1
- package/dist/esm/components/code/copy-button.d.ts.map +1 -0
- package/dist/esm/components/code/{CopyButton.js → copy-button.js} +1 -1
- package/dist/esm/components/code/{CopyButton.js.map → copy-button.js.map} +1 -1
- package/dist/esm/components/code/index.d.ts +3 -3
- package/dist/esm/components/code/index.d.ts.map +1 -1
- package/dist/esm/components/code/index.js +1 -1
- package/dist/esm/components/code/index.js.map +2 -2
- package/dist/{cjs/components/code/LanguageBadge.d.ts → esm/components/code/language-badge.d.ts} +1 -1
- package/dist/esm/components/code/language-badge.d.ts.map +1 -0
- package/dist/esm/components/code/{LanguageBadge.js → language-badge.js} +1 -1
- package/dist/esm/components/code/{LanguageBadge.js.map → language-badge.js.map} +1 -1
- package/dist/{cjs/components/code/PreviewSection.d.ts → esm/components/code/preview-section.d.ts} +1 -1
- package/dist/esm/components/code/preview-section.d.ts.map +1 -0
- package/dist/esm/components/code/{PreviewSection.js → preview-section.js} +1 -1
- package/dist/esm/components/code/{PreviewSection.js.map → preview-section.js.map} +1 -1
- package/dist/{cjs/components/code/SyntaxHighlighter.d.ts → esm/components/code/syntax-highlighter.d.ts} +1 -1
- package/dist/esm/components/code/syntax-highlighter.d.ts.map +1 -0
- package/dist/esm/components/code/{SyntaxHighlighter.js → syntax-highlighter.js} +1 -1
- package/dist/esm/components/code/{SyntaxHighlighter.js.map → syntax-highlighter.js.map} +1 -1
- package/dist/{cjs/components/code/useCodeCard.d.ts → esm/components/code/use-code-card.d.ts} +1 -1
- package/dist/esm/components/code/use-code-card.d.ts.map +1 -0
- package/dist/esm/components/code/{useCodeCard.js → use-code-card.js} +1 -1
- package/dist/esm/components/code/{useCodeCard.js.map → use-code-card.js.map} +1 -1
- package/dist/esm/components/hero/{Hero.d.ts → hero.d.ts} +1 -1
- package/dist/esm/components/hero/{Hero.d.ts.map → hero.d.ts.map} +1 -1
- package/dist/esm/components/hero/{Hero.js → hero.js} +1 -1
- package/dist/esm/components/hero/{Hero.js.map → hero.js.map} +1 -1
- package/dist/esm/components/hero/index.d.ts +1 -1
- package/dist/esm/components/hero/index.js +1 -1
- package/dist/esm/components/hero/index.js.map +1 -1
- package/dist/{cjs/components/markdown/createMarkdownComponents.d.ts → esm/components/markdown/create-markdown-components.d.ts} +1 -1
- package/dist/esm/components/markdown/create-markdown-components.d.ts.map +1 -0
- package/dist/esm/components/markdown/{createMarkdownComponents.js → create-markdown-components.js} +2 -2
- package/dist/esm/components/markdown/{createMarkdownComponents.js.map → create-markdown-components.js.map} +2 -2
- package/dist/esm/components/markdown/index.d.ts +4 -4
- package/dist/esm/components/markdown/index.d.ts.map +1 -1
- package/dist/esm/components/markdown/index.js +1 -1
- package/dist/esm/components/markdown/index.js.map +2 -2
- package/dist/{cjs/components/markdown/StreamingMarkdown.d.ts → esm/components/markdown/streaming-markdown.d.ts} +1 -1
- package/dist/esm/components/markdown/streaming-markdown.d.ts.map +1 -0
- package/dist/esm/components/markdown/streaming-markdown.js +2 -0
- package/dist/esm/components/markdown/streaming-markdown.js.map +7 -0
- package/dist/{cjs/components/markdown/utils/markdownStreaming.d.ts → esm/components/markdown/utils/markdown-streaming.d.ts} +1 -1
- package/dist/esm/components/markdown/utils/markdown-streaming.d.ts.map +1 -0
- package/dist/esm/components/markdown/utils/{markdownStreaming.js → markdown-streaming.js} +1 -1
- package/dist/esm/components/markdown/utils/{markdownStreaming.js.map → markdown-streaming.js.map} +1 -1
- package/package.json +1 -1
- package/src/components/code/{CodeBlock.tsx → code-block.tsx} +2 -2
- package/src/components/code/index.ts +3 -3
- package/src/components/hero/index.ts +1 -1
- package/src/components/markdown/{createMarkdownComponents.tsx → create-markdown-components.tsx} +6 -7
- package/src/components/markdown/index.ts +4 -5
- package/src/components/markdown/{StreamingMarkdown.tsx → streaming-markdown.tsx} +2 -2
- package/dist/cjs/components/code/CodeBlock.d.ts.map +0 -1
- package/dist/cjs/components/code/CodeBlock.js +0 -2
- package/dist/cjs/components/code/CodeBlock.js.map +0 -7
- package/dist/cjs/components/code/CopyButton.d.ts.map +0 -1
- package/dist/cjs/components/code/LanguageBadge.d.ts.map +0 -1
- package/dist/cjs/components/code/PreviewSection.d.ts.map +0 -1
- package/dist/cjs/components/code/SyntaxHighlighter.d.ts.map +0 -1
- package/dist/cjs/components/code/useCodeCard.d.ts.map +0 -1
- package/dist/cjs/components/markdown/StreamingMarkdown.d.ts.map +0 -1
- package/dist/cjs/components/markdown/StreamingMarkdown.js +0 -2
- package/dist/cjs/components/markdown/StreamingMarkdown.js.map +0 -7
- package/dist/cjs/components/markdown/createMarkdownComponents.d.ts.map +0 -1
- package/dist/cjs/components/markdown/createMarkdownComponents.js.map +0 -7
- package/dist/cjs/components/markdown/utils/markdownStreaming.d.ts.map +0 -1
- package/dist/esm/components/code/CodeBlock.d.ts.map +0 -1
- package/dist/esm/components/code/CodeBlock.js +0 -2
- package/dist/esm/components/code/CodeBlock.js.map +0 -7
- package/dist/esm/components/code/CopyButton.d.ts.map +0 -1
- package/dist/esm/components/code/LanguageBadge.d.ts.map +0 -1
- package/dist/esm/components/code/PreviewSection.d.ts.map +0 -1
- package/dist/esm/components/code/SyntaxHighlighter.d.ts.map +0 -1
- package/dist/esm/components/code/useCodeCard.d.ts.map +0 -1
- package/dist/esm/components/markdown/StreamingMarkdown.d.ts.map +0 -1
- package/dist/esm/components/markdown/StreamingMarkdown.js +0 -2
- package/dist/esm/components/markdown/StreamingMarkdown.js.map +0 -7
- package/dist/esm/components/markdown/createMarkdownComponents.d.ts.map +0 -1
- package/dist/esm/components/markdown/utils/markdownStreaming.d.ts.map +0 -1
- /package/src/components/code/{CopyButton.tsx → copy-button.tsx} +0 -0
- /package/src/components/code/{LanguageBadge.tsx → language-badge.tsx} +0 -0
- /package/src/components/code/{PreviewSection.tsx → preview-section.tsx} +0 -0
- /package/src/components/code/{SyntaxHighlighter.tsx → syntax-highlighter.tsx} +0 -0
- /package/src/components/code/{useCodeCard.ts → use-code-card.ts} +0 -0
- /package/src/components/hero/{Hero.tsx → hero.tsx} +0 -0
- /package/src/components/markdown/utils/{markdownStreaming.ts → markdown-streaming.ts} +0 -0
|
@@ -2,4 +2,4 @@ import React from "react";
|
|
|
2
2
|
import type { CodeBlockProps } from "./types";
|
|
3
3
|
export declare function CodeBlock({ children, code, language, preview, showCopy, showLanguage, showLineNumbers, shikiConfig, background, backgroundProps, collapsible, collapsedHeight, file, }: CodeBlockProps): React.JSX.Element;
|
|
4
4
|
export declare function useCodeBlockContext(): boolean;
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=code-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../../../src/components/code/code-block.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwF,MAAM,OAAO,CAAC;AAK7G,OAAO,KAAK,EAAE,cAAc,EAAuC,MAAM,SAAS,CAAC;AA2RnF,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAe,EACf,YAAmB,EACnB,eAAsB,EACtB,WAAW,EACX,UAAU,EACV,eAAe,EACf,WAAkB,EAClB,eAA0C,EAC1C,IAAI,GACL,EAAE,cAAc,qBA2ChB;AAED,wBAAgB,mBAAmB,YAElC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var I=Object.create;var y=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var $=(r,o)=>{for(var t in o)y(r,t,{get:o[t],enumerable:!0})},S=(r,o,t,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of _(o))!D.call(r,l)&&l!==t&&y(r,l,{get:()=>o[l],enumerable:!(s=A(o,l))||s.enumerable});return r};var M=(r,o,t)=>(t=r!=null?I(z(r)):{},S(o||!r||!r.__esModule?y(t,"default",{value:r,enumerable:!0}):t,r)),W=r=>S(y({},"__esModule",{value:!0}),r);var X={};$(X,{CodeBlock:()=>J,useCodeBlockContext:()=>Q});module.exports=W(X);var e=M(require("react")),n=require("@kushagradhawan/kookie-ui"),w=require("@hugeicons/react"),f=require("@hugeicons/core-free-icons"),B=require("shiki"),x=require("./types"),v=require("./use-code-card"),T=require("./language-badge");const L=(0,e.createContext)(!1),O=360,U="one-light",j="one-dark-pro";function G({children:r,background:o="none",backgroundProps:t={}}){const{dotSize:s=24,color:l="var(--gray-10)",backgroundColor:c="var(--gray-2)",height:i,width:u="100%",radius:d="3"}=t,a=(0,e.useMemo)(()=>{if(o!=="none")return o==="dots"?{backgroundImage:`radial-gradient(circle, ${l} 1px, transparent 1px)`,borderRadius:`var(--radius-${d})`,backgroundSize:`${s}px ${s}px`,backgroundPosition:"center",backgroundColor:c,width:u,...i&&{height:i}}:{backgroundImage:`url(${o})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",borderRadius:`var(--radius-${d})`,width:u,...i&&{height:i}}},[o,l,c,s,i,u,d]);return e.default.createElement(n.Card,{size:"1",variant:"soft"},e.default.createElement(n.Flex,{justify:"center",align:"center",py:"4",style:a},e.default.createElement(n.Theme,{fontFamily:"sans"},r)))}function K(){return e.default.createElement(n.Box,{className:"code-skeleton"},["85%","70%","90%","60%","75%","80%"].map((o,t)=>e.default.createElement(n.Box,{key:t,className:"code-skeleton-line",style:{width:o}})))}const P=(0,e.memo)(function({code:o,language:t,showCopy:s,showLanguage:l,showLineNumbers:c,collapsible:i,collapsedHeight:u,file:d,isLoading:a=!1,children:p}){const{isExpanded:g,shouldShowToggle:h,copied:C,contentRef:m,contentMaxHeight:b,handleToggle:N,handleCopy:H}=(0,v.useCodeCard)({code:o,collapsedHeight:u}),k=i&&h,E=g?"rotate(180deg)":"rotate(0deg)",F=c?"code-content":"code-content hide-line-numbers";return e.default.createElement(n.Box,{position:"relative"},e.default.createElement(n.Card,{size:"1",variant:"soft"},e.default.createElement(n.Flex,{direction:"column"},e.default.createElement(n.Flex,{justify:"between",align:"start",gap:"2"},e.default.createElement(n.Flex,{align:"center",gap:"2"},l&&e.default.createElement(T.LanguageBadge,{language:t}),d&&e.default.createElement(n.Text,{size:"1",color:"gray",highContrast:!0},d)),e.default.createElement(n.Flex,{align:"center",className:"code-action-buttons"},k&&e.default.createElement(n.IconButton,{size:"2",variant:"ghost",color:"gray",onClick:N,tooltip:g?"Collapse":"Expand","aria-label":g?"Collapse code":"Expand code"},e.default.createElement(w.HugeiconsIcon,{icon:f.ArrowDown01Icon,style:{transform:E},className:"code-chevron",strokeWidth:1.75})),s&&e.default.createElement(n.Button,{size:"2",variant:"ghost",color:"gray",onClick:H,tooltip:C?"Copied!":"Copy","aria-label":C?"Copied!":"Copy code"},e.default.createElement(w.HugeiconsIcon,{icon:C?f.Tick01Icon:f.Copy01Icon,strokeWidth:1.75})," Copy"))),e.default.createElement(n.Box,{ref:m,style:{maxHeight:i?`${b}px`:void 0},className:F},e.default.createElement(n.ScrollArea,{type:"auto",scrollbars:"horizontal"},a?e.default.createElement(K,null):p)),k&&!g&&e.default.createElement(n.Box,{className:"code-scroll-shadow visible"}))))}),V=(0,e.memo)(function({code:o,language:t,showCopy:s,showLanguage:l,showLineNumbers:c,collapsible:i,collapsedHeight:u,file:d,shikiConfig:a}){const[p,g]=(0,e.useState)(null),h=(0,e.useMemo)(()=>{const m=a?.themes?.light||U,b=a?.themes?.dark||j;return{lang:t,themes:{light:m,dark:b},defaultColor:!1,langAlias:a?.langAlias,transformers:a?.transformers,meta:a?.meta?{__raw:a.meta}:void 0}},[t,a?.themes?.light,a?.themes?.dark,a?.langAlias,a?.transformers,a?.meta]);return(0,e.useEffect)(()=>{let m=!1;return(0,B.codeToHtml)(o,h).then(b=>{m||g(b)}).catch(b=>{}),()=>{m=!0}},[o,h]),e.default.createElement(P,{code:o,language:t,showCopy:s,showLanguage:l,showLineNumbers:c,collapsible:i,collapsedHeight:u,file:d,isLoading:p===null},p?e.default.createElement(n.Box,{dangerouslySetInnerHTML:{__html:p}}):null)}),q=(0,e.memo)(function({children:o,showCopy:t,showLanguage:s,showLineNumbers:l,collapsible:c,collapsedHeight:i,file:u}){const d=(0,x.extractTextFromChildren)(o),a=(0,x.extractLanguageFromChildren)(o);return e.default.createElement(P,{code:d,language:a,showCopy:t,showLanguage:s,showLineNumbers:l,collapsible:c,collapsedHeight:i,file:u},o)});function J({children:r,code:o,language:t,preview:s,showCopy:l=!0,showLanguage:c=!0,showLineNumbers:i=!0,shikiConfig:u,background:d,backgroundProps:a,collapsible:p=!0,collapsedHeight:g=O,file:h}){const C=t||(0,x.extractLanguageFromChildren)(r)||"text";return e.default.createElement(L.Provider,{value:!0},e.default.createElement(n.Box,{className:"docs-code-block",mt:"6",mb:"8"},e.default.createElement(n.Flex,{direction:"column",gap:"2"},s&&e.default.createElement(G,{background:d,backgroundProps:a},s),o&&e.default.createElement(V,{code:o,language:C,showCopy:l,showLanguage:c,showLineNumbers:i,collapsible:p,collapsedHeight:g,file:h,shikiConfig:u}),r&&!o&&e.default.createElement(q,{showCopy:l,showLanguage:c,showLineNumbers:i,collapsible:p,collapsedHeight:g,file:h},r))))}function Q(){return(0,e.useContext)(L)}
|
|
2
|
+
//# sourceMappingURL=code-block.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/code/code-block.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { useState, useEffect, useMemo, memo, createContext, useContext, type ReactNode } from \"react\";\nimport { Box, Card, Code, Flex, Button, Text, Theme, ScrollArea, IconButton } from \"@kushagradhawan/kookie-ui\";\nimport { HugeiconsIcon } from \"@hugeicons/react\";\nimport { Copy01Icon, Tick01Icon, ArrowDown01Icon } from \"@hugeicons/core-free-icons\";\nimport { codeToHtml, type BundledLanguage, type BundledTheme } from \"shiki\";\nimport type { CodeBlockProps, ShikiConfig, PreviewBackgroundProps } from \"./types\";\nimport { extractTextFromChildren, extractLanguageFromChildren } from \"./types\";\nimport { useCodeCard } from \"./use-code-card\";\nimport { LanguageBadge } from \"./language-badge\";\n\nconst CodeBlockContext = createContext<boolean>(false);\n\nconst DEFAULT_COLLAPSED_HEIGHT = 360;\nconst DEFAULT_LIGHT_THEME = \"one-light\";\nconst DEFAULT_DARK_THEME = \"one-dark-pro\";\n\ninterface PreviewSectionProps {\n children: ReactNode;\n background?: \"none\" | \"dots\" | string;\n backgroundProps?: PreviewBackgroundProps;\n}\n\nfunction PreviewSection({ children, background = \"none\", backgroundProps = {} }: PreviewSectionProps) {\n const { dotSize = 24, color = \"var(--gray-10)\", backgroundColor = \"var(--gray-2)\", height, width = \"100%\", radius = \"3\" } = backgroundProps;\n\n const backgroundStyle = useMemo((): React.CSSProperties | undefined => {\n if (background === \"none\") return undefined;\n\n if (background === \"dots\") {\n return {\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 width,\n ...(height && { height }),\n };\n }\n\n // Image background\n return {\n backgroundImage: `url(${background})`,\n backgroundSize: \"cover\",\n backgroundPosition: \"center\",\n backgroundRepeat: \"no-repeat\",\n borderRadius: `var(--radius-${radius})`,\n width,\n ...(height && { height }),\n };\n }, [background, color, backgroundColor, dotSize, height, width, radius]);\n\n return (\n <Card size=\"1\" variant=\"soft\">\n <Flex justify=\"center\" align=\"center\" py=\"4\" style={backgroundStyle}>\n <Theme fontFamily=\"sans\">{children}</Theme>\n </Flex>\n </Card>\n );\n}\n\ninterface CodeCardProps {\n code: string;\n language: string;\n showCopy: boolean;\n showLanguage: boolean;\n showLineNumbers: boolean;\n collapsible: boolean;\n collapsedHeight: number;\n file?: string;\n isLoading?: boolean;\n children: ReactNode;\n}\n\nfunction CodeSkeleton() {\n // Generate varied line widths for visual interest\n const lineWidths = [\"85%\", \"70%\", \"90%\", \"60%\", \"75%\", \"80%\"];\n\n return (\n <Box className=\"code-skeleton\">\n {lineWidths.map((width, index) => (\n <Box key={index} className=\"code-skeleton-line\" style={{ width }} />\n ))}\n </Box>\n );\n}\n\nconst CodeCard = memo(function CodeCard({\n code,\n language,\n showCopy,\n showLanguage,\n showLineNumbers,\n collapsible,\n collapsedHeight,\n file,\n isLoading = false,\n children,\n}: CodeCardProps) {\n const { isExpanded, shouldShowToggle, copied, contentRef, contentMaxHeight, handleToggle, handleCopy } = useCodeCard({\n code,\n collapsedHeight,\n });\n\n const showToggle = collapsible && shouldShowToggle;\n const chevronRotation = isExpanded ? \"rotate(180deg)\" : \"rotate(0deg)\";\n const contentClassName = showLineNumbers ? \"code-content\" : \"code-content hide-line-numbers\";\n\n return (\n <Box position=\"relative\">\n <Card size=\"1\" variant=\"soft\">\n <Flex direction=\"column\">\n <Flex justify=\"between\" align=\"start\" gap=\"2\">\n <Flex align=\"center\" gap=\"2\">\n {showLanguage && <LanguageBadge language={language} />}\n {file && (\n <Text size=\"1\" color=\"gray\" highContrast>\n {file}\n </Text>\n )}\n </Flex>\n\n <Flex align=\"center\" className=\"code-action-buttons\">\n {showToggle && (\n <IconButton\n size=\"2\"\n variant=\"ghost\"\n color=\"gray\"\n onClick={handleToggle}\n tooltip={isExpanded ? \"Collapse\" : \"Expand\"}\n aria-label={isExpanded ? \"Collapse code\" : \"Expand code\"}\n >\n <HugeiconsIcon icon={ArrowDown01Icon} style={{ transform: chevronRotation }} className=\"code-chevron\" strokeWidth={1.75} />\n </IconButton>\n )}\n {showCopy && (\n <Button\n size=\"2\"\n variant=\"ghost\"\n color=\"gray\"\n onClick={handleCopy}\n tooltip={copied ? \"Copied!\" : \"Copy\"}\n aria-label={copied ? \"Copied!\" : \"Copy code\"}\n >\n <HugeiconsIcon icon={copied ? Tick01Icon : Copy01Icon} strokeWidth={1.75} /> Copy\n </Button>\n )}\n </Flex>\n </Flex>\n\n <Box ref={contentRef} style={{ maxHeight: collapsible ? `${contentMaxHeight}px` : undefined }} className={contentClassName}>\n <ScrollArea type=\"auto\" scrollbars=\"horizontal\">\n {isLoading ? <CodeSkeleton /> : children}\n </ScrollArea>\n </Box>\n\n {showToggle && !isExpanded && <Box className=\"code-scroll-shadow visible\" />}\n </Flex>\n </Card>\n </Box>\n );\n});\n\ninterface RuntimeCodeSectionProps {\n code: string;\n language: string;\n showCopy: boolean;\n showLanguage: boolean;\n showLineNumbers: boolean;\n collapsible: boolean;\n collapsedHeight: number;\n file?: string;\n shikiConfig?: ShikiConfig;\n}\n\nconst RuntimeCodeSection = memo(function RuntimeCodeSection({\n code,\n language,\n showCopy,\n showLanguage,\n showLineNumbers,\n collapsible,\n collapsedHeight,\n file,\n shikiConfig,\n}: RuntimeCodeSectionProps) {\n const [highlighted, setHighlighted] = useState<string | null>(null);\n\n // Memoize Shiki config to prevent unnecessary re-highlights\n const shikiOptions = useMemo(() => {\n const lightTheme = shikiConfig?.themes?.light || DEFAULT_LIGHT_THEME;\n const darkTheme = shikiConfig?.themes?.dark || DEFAULT_DARK_THEME;\n\n return {\n lang: language as BundledLanguage,\n themes: {\n light: lightTheme as BundledTheme,\n dark: darkTheme as BundledTheme,\n },\n defaultColor: false as const,\n langAlias: shikiConfig?.langAlias,\n transformers: shikiConfig?.transformers,\n meta: shikiConfig?.meta ? { __raw: shikiConfig.meta } : undefined,\n };\n }, [language, shikiConfig?.themes?.light, shikiConfig?.themes?.dark, shikiConfig?.langAlias, shikiConfig?.transformers, shikiConfig?.meta]);\n\n useEffect(() => {\n let cancelled = false;\n\n codeToHtml(code, shikiOptions)\n .then((html) => {\n if (!cancelled) {\n setHighlighted(html);\n }\n })\n .catch((error) => {\n if (!cancelled) {\n // Keep previous highlighted content on error (stale while revalidate)\n if (process.env.NODE_ENV === \"development\") {\n console.error(\"[CodeBlock] Shiki highlighting failed:\", error);\n }\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [code, shikiOptions]);\n\n // Only show loading skeleton on initial render (no highlighted content yet)\n // During updates, keep showing previous highlighted content (stale while revalidate)\n const isInitialLoading = highlighted === null;\n\n return (\n <CodeCard\n code={code}\n language={language}\n showCopy={showCopy}\n showLanguage={showLanguage}\n showLineNumbers={showLineNumbers}\n collapsible={collapsible}\n collapsedHeight={collapsedHeight}\n file={file}\n isLoading={isInitialLoading}\n >\n {highlighted ? <Box dangerouslySetInnerHTML={{ __html: highlighted }} /> : null}\n </CodeCard>\n );\n});\n\ninterface ChildrenCodeSectionProps {\n children: ReactNode;\n showCopy: boolean;\n showLanguage: boolean;\n showLineNumbers: boolean;\n collapsible: boolean;\n collapsedHeight: number;\n file?: string;\n}\n\nconst ChildrenCodeSection = memo(function ChildrenCodeSection({\n children,\n showCopy,\n showLanguage,\n showLineNumbers,\n collapsible,\n collapsedHeight,\n file,\n}: ChildrenCodeSectionProps) {\n const code = extractTextFromChildren(children);\n const language = extractLanguageFromChildren(children);\n\n return (\n <CodeCard\n code={code}\n language={language}\n showCopy={showCopy}\n showLanguage={showLanguage}\n showLineNumbers={showLineNumbers}\n collapsible={collapsible}\n collapsedHeight={collapsedHeight}\n file={file}\n >\n {children}\n </CodeCard>\n );\n});\n\nexport function CodeBlock({\n children,\n code,\n language,\n preview,\n showCopy = true,\n showLanguage = true,\n showLineNumbers = true,\n shikiConfig,\n background,\n backgroundProps,\n collapsible = true,\n collapsedHeight = DEFAULT_COLLAPSED_HEIGHT,\n file,\n}: CodeBlockProps) {\n const displayLanguage = language || extractLanguageFromChildren(children) || \"text\";\n\n return (\n <CodeBlockContext.Provider value={true}>\n <Box className=\"docs-code-block\" mt=\"6\" mb=\"8\">\n <Flex direction=\"column\" gap=\"2\">\n {preview && (\n <PreviewSection background={background} backgroundProps={backgroundProps}>\n {preview}\n </PreviewSection>\n )}\n\n {code && (\n <RuntimeCodeSection\n code={code}\n language={displayLanguage}\n showCopy={showCopy}\n showLanguage={showLanguage}\n showLineNumbers={showLineNumbers}\n collapsible={collapsible}\n collapsedHeight={collapsedHeight}\n file={file}\n shikiConfig={shikiConfig}\n />\n )}\n\n {children && !code && (\n <ChildrenCodeSection\n showCopy={showCopy}\n showLanguage={showLanguage}\n showLineNumbers={showLineNumbers}\n collapsible={collapsible}\n collapsedHeight={collapsedHeight}\n file={file}\n >\n {children}\n </ChildrenCodeSection>\n )}\n </Flex>\n </Box>\n </CodeBlockContext.Provider>\n );\n}\n\nexport function useCodeBlockContext() {\n return useContext(CodeBlockContext);\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,wBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAqG,oBACrGC,EAAmF,qCACnFD,EAA8B,4BAC9BE,EAAwD,sCACxDC,EAAoE,iBAEpEC,EAAqE,mBACrEC,EAA4B,2BAC5BC,EAA8B,4BAE9B,MAAMC,KAAmB,iBAAuB,EAAK,EAE/CC,EAA2B,IAC3BC,EAAsB,YACtBC,EAAqB,eAQ3B,SAASC,EAAe,CAAE,SAAAC,EAAU,WAAAC,EAAa,OAAQ,gBAAAC,EAAkB,CAAC,CAAE,EAAwB,CACpG,KAAM,CAAE,QAAAC,EAAU,GAAI,MAAAC,EAAQ,iBAAkB,gBAAAC,EAAkB,gBAAiB,OAAAC,EAAQ,MAAAC,EAAQ,OAAQ,OAAAC,EAAS,GAAI,EAAIN,EAEtHO,KAAkB,WAAQ,IAAuC,CACrE,GAAIR,IAAe,OAEnB,OAAIA,IAAe,OACV,CACL,gBAAiB,2BAA2BG,CAAK,yBACjD,aAAc,gBAAgBI,CAAM,IACpC,eAAgB,GAAGL,CAAO,MAAMA,CAAO,KACvC,mBAAoB,SACpB,gBAAAE,EACA,MAAAE,EACA,GAAID,GAAU,CAAE,OAAAA,CAAO,CACzB,EAIK,CACL,gBAAiB,OAAOL,CAAU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jB,YAAaC,EACb,gBAAiBC,EACjB,KAAMC,GAELrB,CACH,CAEJ,CAAC,EAEM,SAASf,EAAU,CACxB,SAAAe,EACA,KAAAc,EACA,SAAAC,EACA,QAAA6B,EACA,SAAA5B,EAAW,GACX,aAAAC,EAAe,GACf,gBAAAC,EAAkB,GAClB,YAAAgB,EACA,WAAAjC,EACA,gBAAAC,EACA,YAAAiB,EAAc,GACd,gBAAAC,EAAkBxB,EAClB,KAAAyB,CACF,EAAmB,CACjB,MAAMwB,EAAkB9B,MAAY,+BAA4Bf,CAAQ,GAAK,OAE7E,OACE,EAAAU,QAAA,cAACf,EAAiB,SAAjB,CAA0B,MAAO,IAChC,EAAAe,QAAA,cAAC,OAAI,UAAU,kBAAkB,GAAG,IAAI,GAAG,KACzC,EAAAA,QAAA,cAAC,QAAK,UAAU,SAAS,IAAI,KAC1BkC,GACC,EAAAlC,QAAA,cAACX,EAAA,CAAe,WAAYE,EAAY,gBAAiBC,GACtD0C,CACH,EAGD9B,GACC,EAAAJ,QAAA,cAACuB,EAAA,CACC,KAAMnB,EACN,SAAU+B,EACV,SAAU7B,EACV,aAAcC,EACd,gBAAiBC,EACjB,YAAaC,EACb,gBAAiBC,EACjB,KAAMC,EACN,YAAaa,EACf,EAGDlC,GAAY,CAACc,GACZ,EAAAJ,QAAA,cAACiC,EAAA,CACC,SAAU3B,EACV,aAAcC,EACd,gBAAiBC,EACjB,YAAaC,EACb,gBAAiBC,EACjB,KAAMC,GAELrB,CACH,CAEJ,CACF,CACF,CAEJ,CAEO,SAASd,GAAsB,CACpC,SAAO,cAAWS,CAAgB,CACpC",
|
|
6
|
+
"names": ["code_block_exports", "__export", "CodeBlock", "useCodeBlockContext", "__toCommonJS", "import_react", "import_kookie_ui", "import_core_free_icons", "import_shiki", "import_types", "import_use_code_card", "import_language_badge", "CodeBlockContext", "DEFAULT_COLLAPSED_HEIGHT", "DEFAULT_LIGHT_THEME", "DEFAULT_DARK_THEME", "PreviewSection", "children", "background", "backgroundProps", "dotSize", "color", "backgroundColor", "height", "width", "radius", "backgroundStyle", "React", "CodeSkeleton", "index", "CodeCard", "code", "language", "showCopy", "showLanguage", "showLineNumbers", "collapsible", "collapsedHeight", "file", "isLoading", "isExpanded", "shouldShowToggle", "copied", "contentRef", "contentMaxHeight", "handleToggle", "handleCopy", "showToggle", "chevronRotation", "contentClassName", "RuntimeCodeSection", "shikiConfig", "highlighted", "setHighlighted", "shikiOptions", "lightTheme", "darkTheme", "cancelled", "html", "error", "ChildrenCodeSection", "preview", "displayLanguage"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-button.d.ts","sourceRoot":"","sources":["../../../../src/components/code/copy-button.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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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=
|
|
2
|
+
//# sourceMappingURL=copy-button.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/code/
|
|
3
|
+
"sources": ["../../../../src/components/code/copy-button.tsx"],
|
|
4
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
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": ["
|
|
6
|
+
"names": ["copy_button_exports", "__export", "CopyButton", "__toCommonJS", "import_react", "import_kookie_ui", "import_core_free_icons", "code", "copied", "setCopied", "resetTimeoutRef", "handleCopy", "React"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { CodeBlock, useCodeBlockContext } from "./
|
|
2
|
-
export { useCodeCard } from "./
|
|
3
|
-
export { LanguageBadge, formatLanguageForDisplay } from "./
|
|
1
|
+
export { CodeBlock, useCodeBlockContext } from "./code-block";
|
|
2
|
+
export { useCodeCard } from "./use-code-card";
|
|
3
|
+
export { LanguageBadge, formatLanguageForDisplay } from "./language-badge";
|
|
4
4
|
export type { CodeBlockProps, ShikiConfig, PreviewBackgroundProps } from "./types";
|
|
5
5
|
export { extractTextFromChildren, extractLanguageFromChildren, isReactElement } from "./types";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/code/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/code/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var c=(o,e)=>{for(var a in e)g(o,a,{get:e[a],enumerable:!0})},f=(o,e,a,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of C(e))!i.call(o,t)&&t!==a&&g(o,t,{get:()=>e[t],enumerable:!(m=x(e,t))||m.enumerable});return o};var l=o=>f(g({},"__esModule",{value:!0}),o);var s={};c(s,{CodeBlock:()=>p.CodeBlock,LanguageBadge:()=>d.LanguageBadge,extractLanguageFromChildren:()=>r.extractLanguageFromChildren,extractTextFromChildren:()=>r.extractTextFromChildren,formatLanguageForDisplay:()=>d.formatLanguageForDisplay,isReactElement:()=>r.isReactElement,useCodeBlockContext:()=>p.useCodeBlockContext,useCodeCard:()=>n.useCodeCard});module.exports=l(s);var p=require("./
|
|
1
|
+
"use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var c=(o,e)=>{for(var a in e)g(o,a,{get:e[a],enumerable:!0})},f=(o,e,a,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of C(e))!i.call(o,t)&&t!==a&&g(o,t,{get:()=>e[t],enumerable:!(m=x(e,t))||m.enumerable});return o};var l=o=>f(g({},"__esModule",{value:!0}),o);var s={};c(s,{CodeBlock:()=>p.CodeBlock,LanguageBadge:()=>d.LanguageBadge,extractLanguageFromChildren:()=>r.extractLanguageFromChildren,extractTextFromChildren:()=>r.extractTextFromChildren,formatLanguageForDisplay:()=>d.formatLanguageForDisplay,isReactElement:()=>r.isReactElement,useCodeBlockContext:()=>p.useCodeBlockContext,useCodeCard:()=>n.useCodeCard});module.exports=l(s);var p=require("./code-block"),n=require("./use-code-card"),d=require("./language-badge"),r=require("./types");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/code/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Public API\nexport { CodeBlock, useCodeBlockContext } from \"./
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0WAAAE,EAAAF,GACA,IAAAG,EAA+C,
|
|
6
|
-
"names": ["code_exports", "__export", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["// Public API\nexport { CodeBlock, useCodeBlockContext } from \"./code-block\";\nexport { useCodeCard } from \"./use-code-card\";\nexport { LanguageBadge, formatLanguageForDisplay } from \"./language-badge\";\nexport type { CodeBlockProps, ShikiConfig, PreviewBackgroundProps } from \"./types\";\nexport { extractTextFromChildren, extractLanguageFromChildren, isReactElement } from \"./types\";\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0WAAAE,EAAAF,GACA,IAAAG,EAA+C,wBAC/CC,EAA4B,2BAC5BC,EAAwD,4BAExDC,EAAqF",
|
|
6
|
+
"names": ["code_exports", "__export", "__toCommonJS", "import_code_block", "import_use_code_card", "import_language_badge", "import_types"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-badge.d.ts","sourceRoot":"","sources":["../../../../src/components/code/language-badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAsD1B;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,qBAQ7D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";var p=Object.create;var a=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var L=(s,t)=>{for(var e in t)a(s,e,{get:t[e],enumerable:!0})},n=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of c(t))!u.call(s,r)&&r!==e&&a(s,r,{get:()=>t[r],enumerable:!(o=S(t,r))||o.enumerable});return s};var d=(s,t,e)=>(e=s!=null?p(h(s)):{},n(t||!s||!s.__esModule?a(e,"default",{value:s,enumerable:!0}):e,s)),m=s=>n(a({},"__esModule",{value:!0}),s);var C={};L(C,{LanguageBadge:()=>x,formatLanguageForDisplay:()=>i});module.exports=m(C);var l=d(require("react")),g=require("@kushagradhawan/kookie-ui");const y={js:"JS",javascript:"JS",jsx:"JSX",ts:"TS",typescript:"TS",tsx:"TSX",py:"Python",python:"Python",rb:"Ruby",ruby:"Ruby",sh:"Shell",bash:"Shell",shell:"Shell",zsh:"Shell",css:"CSS",scss:"SCSS",sass:"Sass",less:"Less",html:"HTML",xml:"XML",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",markdown:"Markdown",mdx:"MDX",sql:"SQL",graphql:"GraphQL",gql:"GraphQL",go:"Go",rust:"Rust",rs:"Rust",swift:"Swift",kotlin:"Kotlin",java:"Java",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",vue:"Vue",svelte:"Svelte",astro:"Astro",dockerfile:"Docker",docker:"Docker",text:"Text",plaintext:"Text",txt:"Text"};function i(s){const t=s.toLowerCase().trim();return y[t]||s.toUpperCase()}function x({language:s}){const t=i(s);return l.default.createElement(g.Code,{size:"1",color:"gray",variant:"ghost"},t.toLowerCase())}
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=language-badge.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/code/
|
|
3
|
+
"sources": ["../../../../src/components/code/language-badge.tsx"],
|
|
4
4
|
"sourcesContent": ["import React from \"react\";\nimport { Code } from \"@kushagradhawan/kookie-ui\";\n\nconst LANGUAGE_DISPLAY_MAP: Record<string, string> = {\n js: \"JS\",\n javascript: \"JS\",\n jsx: \"JSX\",\n ts: \"TS\",\n typescript: \"TS\",\n tsx: \"TSX\",\n py: \"Python\",\n python: \"Python\",\n rb: \"Ruby\",\n ruby: \"Ruby\",\n sh: \"Shell\",\n bash: \"Shell\",\n shell: \"Shell\",\n zsh: \"Shell\",\n css: \"CSS\",\n scss: \"SCSS\",\n sass: \"Sass\",\n less: \"Less\",\n html: \"HTML\",\n xml: \"XML\",\n json: \"JSON\",\n yaml: \"YAML\",\n yml: \"YAML\",\n md: \"Markdown\",\n markdown: \"Markdown\",\n mdx: \"MDX\",\n sql: \"SQL\",\n graphql: \"GraphQL\",\n gql: \"GraphQL\",\n go: \"Go\",\n rust: \"Rust\",\n rs: \"Rust\",\n swift: \"Swift\",\n kotlin: \"Kotlin\",\n java: \"Java\",\n cpp: \"C++\",\n c: \"C\",\n cs: \"C#\",\n csharp: \"C#\",\n php: \"PHP\",\n vue: \"Vue\",\n svelte: \"Svelte\",\n astro: \"Astro\",\n dockerfile: \"Docker\",\n docker: \"Docker\",\n text: \"Text\",\n plaintext: \"Text\",\n txt: \"Text\",\n};\n\n/**\n * Formats a language identifier for display in the badge.\n * Converts technical identifiers to human-readable labels.\n */\nexport function formatLanguageForDisplay(lang: string): string {\n const normalized = lang.toLowerCase().trim();\n return LANGUAGE_DISPLAY_MAP[normalized] || lang.toUpperCase();\n}\n\ninterface LanguageBadgeProps {\n language: string;\n}\n\n/**\n * Displays the programming language as a small badge.\n * Uses Kookie UI's Code component with consistent styling.\n */\nexport function LanguageBadge({ language }: LanguageBadgeProps) {\n const displayLanguage = formatLanguageForDisplay(language);\n\n return (\n <Code size=\"1\" color=\"gray\" variant=\"ghost\">\n {displayLanguage.toLowerCase()}\n </Code>\n );\n}\n"],
|
|
5
5
|
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,6BAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAkB,oBAClBC,EAAqB,qCAErB,MAAMC,EAA+C,CACnD,GAAI,KACJ,WAAY,KACZ,IAAK,MACL,GAAI,KACJ,WAAY,KACZ,IAAK,MACL,GAAI,SACJ,OAAQ,SACR,GAAI,OACJ,KAAM,OACN,GAAI,QACJ,KAAM,QACN,MAAO,QACP,IAAK,QACL,IAAK,MACL,KAAM,OACN,KAAM,OACN,KAAM,OACN,KAAM,OACN,IAAK,MACL,KAAM,OACN,KAAM,OACN,IAAK,OACL,GAAI,WACJ,SAAU,WACV,IAAK,MACL,IAAK,MACL,QAAS,UACT,IAAK,UACL,GAAI,KACJ,KAAM,OACN,GAAI,OACJ,MAAO,QACP,OAAQ,SACR,KAAM,OACN,IAAK,MACL,EAAG,IACH,GAAI,KACJ,OAAQ,KACR,IAAK,MACL,IAAK,MACL,OAAQ,SACR,MAAO,QACP,WAAY,SACZ,OAAQ,SACR,KAAM,OACN,UAAW,OACX,IAAK,MACP,EAMO,SAASJ,EAAyBK,EAAsB,CAC7D,MAAMC,EAAaD,EAAK,YAAY,EAAE,KAAK,EAC3C,OAAOD,EAAqBE,CAAU,GAAKD,EAAK,YAAY,CAC9D,CAUO,SAASN,EAAc,CAAE,SAAAQ,CAAS,EAAuB,CAC9D,MAAMC,EAAkBR,EAAyBO,CAAQ,EAEzD,OACE,EAAAE,QAAA,cAAC,QAAK,KAAK,IAAI,MAAM,OAAO,QAAQ,SACjCD,EAAgB,YAAY,CAC/B,CAEJ",
|
|
6
|
-
"names": ["
|
|
6
|
+
"names": ["language_badge_exports", "__export", "LanguageBadge", "formatLanguageForDisplay", "__toCommonJS", "import_react", "import_kookie_ui", "LANGUAGE_DISPLAY_MAP", "lang", "normalized", "language", "displayLanguage", "React"]
|
|
7
7
|
}
|
package/dist/{esm/components/code/PreviewSection.d.ts → cjs/components/code/preview-section.d.ts}
RENAMED
|
@@ -13,4 +13,4 @@ interface PreviewSectionProps {
|
|
|
13
13
|
}
|
|
14
14
|
export declare function PreviewSection({ children, background, backgroundProps }: PreviewSectionProps): React.JSX.Element;
|
|
15
15
|
export {};
|
|
16
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=preview-section.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-section.d.ts","sourceRoot":"","sources":["../../../../src/components/code/preview-section.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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";var f=Object.create;var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var P=(r,e)=>{for(var t in e)d(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&&d(r,i,{get:()=>e[i],enumerable:!(a=m(e,i))||a.enumerable});return r};var h=(r,e,t)=>(t=r!=null?f(b(r)):{},u(e||!r||!r.__esModule?d(t,"default",{value:r,enumerable:!0}):t,r)),k=r=>u(d({},"__esModule",{value:!0}),r);var C={};P(C,{PreviewSection:()=>x});module.exports=k(C);var o=h(require("react")),n=require("@kushagradhawan/kookie-ui");function x({children:r,background:e="none",backgroundProps:t={}}){const{dotSize:a=24,color:i="var(--gray-10)",backgroundColor:l="var(--gray-2)",height:s,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,width:g,...s&&{height:s}};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})`,width:g,...s&&{height:s}};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=
|
|
2
|
+
//# sourceMappingURL=preview-section.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/code/
|
|
3
|
+
"sources": ["../../../../src/components/code/preview-section.tsx"],
|
|
4
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, 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 width,\n ...(height && { height }),\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 width,\n ...(height && { height }),\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
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,EAAQ,MAAAC,EAAQ,OAAQ,OAAAC,EAAS,GAAI,EAAIN,EAG5H,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,MAAAE,EACA,GAAID,GAAU,CAAE,OAAAA,CAAO,CACzB,EAEA,OACE,EAAAG,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,MAAAD,EACA,GAAID,GAAU,CAAE,OAAAA,CAAO,CACzB,EAEA,OACE,EAAAG,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": ["
|
|
6
|
+
"names": ["preview_section_exports", "__export", "PreviewSection", "__toCommonJS", "import_react", "import_kookie_ui", "children", "background", "backgroundProps", "dotSize", "color", "backgroundColor", "height", "width", "radius", "React", "dotsStyle", "imageStyle"]
|
|
7
7
|
}
|
|
@@ -7,4 +7,4 @@ interface SyntaxHighlighterProps {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function SyntaxHighlighter({ code, language, lightTheme, darkTheme }: SyntaxHighlighterProps): React.JSX.Element;
|
|
9
9
|
export {};
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=syntax-highlighter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syntax-highlighter.d.ts","sourceRoot":"","sources":["../../../../src/components/code/syntax-highlighter.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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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=
|
|
2
|
+
//# sourceMappingURL=syntax-highlighter.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/code/
|
|
3
|
+
"sources": ["../../../../src/components/code/syntax-highlighter.tsx"],
|
|
4
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
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": ["
|
|
6
|
+
"names": ["syntax_highlighter_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
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-code-card.d.ts","sourceRoot":"","sources":["../../../../src/components/code/use-code-card.ts"],"names":[],"mappings":"AAIA,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,iBAAiB;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,kBAAkB,GAAG,iBAAiB,CA0D5F"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";var l=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var R=(o,e)=>{for(var r in e)l(o,r,{get:e[r],enumerable:!0})},b=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of h(e))!E.call(o,n)&&n!==r&&l(o,n,{get:()=>e[n],enumerable:!(s=T(e,n))||s.enumerable});return o};var v=o=>b(l({},"__esModule",{value:!0}),o);var H={};R(H,{useCodeCard:()=>y});module.exports=v(H);var t=require("react");const x=2e3;function y({code:o,collapsedHeight:e}){const[r,s]=(0,t.useState)(!1),[n,d]=(0,t.useState)(e),[f,a]=(0,t.useState)(!1),i=(0,t.useRef)(null),c=(0,t.useRef)(null),p=n>e,C=r?n:e;(0,t.useEffect)(()=>{i.current&&d(i.current.scrollHeight)}),(0,t.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);const g=(0,t.useCallback)(()=>{s(u=>!u)},[]),m=(0,t.useCallback)(async()=>{if(o.trim())try{await navigator.clipboard.writeText(o),a(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>a(!1),x)}catch{}},[o]);return{isExpanded:r,shouldShowToggle:p,copied:f,contentRef:i,contentMaxHeight:C,handleToggle:g,handleCopy:m}}
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=use-code-card.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/code/
|
|
3
|
+
"sources": ["../../../../src/components/code/use-code-card.ts"],
|
|
4
4
|
"sourcesContent": ["import { useState, useRef, useEffect, useCallback } from \"react\";\n\nconst COPY_FEEDBACK_DURATION_MS = 2000;\n\ninterface UseCodeCardOptions {\n code: string;\n collapsedHeight: number;\n}\n\ninterface UseCodeCardReturn {\n isExpanded: boolean;\n shouldShowToggle: boolean;\n copied: boolean;\n contentRef: React.RefObject<HTMLDivElement | null>;\n contentMaxHeight: number;\n handleToggle: () => void;\n handleCopy: () => Promise<void>;\n}\n\n/**\n * Shared hook for code card UI behavior.\n * Handles expand/collapse state and copy functionality.\n */\nexport function useCodeCard({ code, collapsedHeight }: UseCodeCardOptions): UseCodeCardReturn {\n const [isExpanded, setIsExpanded] = useState(false);\n const [contentHeight, setContentHeight] = useState(collapsedHeight);\n const [copied, setCopied] = useState(false);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const resetTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const shouldShowToggle = contentHeight > collapsedHeight;\n const contentMaxHeight = isExpanded ? contentHeight : collapsedHeight;\n\n // Measure content height on mount and when content changes\n useEffect(() => {\n if (contentRef.current) {\n setContentHeight(contentRef.current.scrollHeight);\n }\n });\n\n // Cleanup timeout on unmount\n useEffect(() => {\n return () => {\n if (resetTimeoutRef.current) {\n clearTimeout(resetTimeoutRef.current);\n }\n };\n }, []);\n\n const handleToggle = useCallback(() => {\n setIsExpanded((prev) => !prev);\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 resetTimeoutRef.current = setTimeout(() => setCopied(false), COPY_FEEDBACK_DURATION_MS);\n } catch (error) {\n // Log error in development, fail gracefully in production\n if (process.env.NODE_ENV === \"development\") {\n console.error(\"[CodeBlock] Failed to copy to clipboard:\", error);\n }\n }\n }, [code]);\n\n return {\n isExpanded,\n shouldShowToggle,\n copied,\n contentRef,\n contentMaxHeight,\n handleToggle,\n handleCopy,\n };\n}\n"],
|
|
5
5
|
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyD,iBAEzD,MAAMC,EAA4B,IAqB3B,SAASH,EAAY,CAAE,KAAAI,EAAM,gBAAAC,CAAgB,EAA0C,CAC5F,KAAM,CAACC,EAAYC,CAAa,KAAI,YAAS,EAAK,EAC5C,CAACC,EAAeC,CAAgB,KAAI,YAASJ,CAAe,EAC5D,CAACK,EAAQC,CAAS,KAAI,YAAS,EAAK,EACpCC,KAAa,UAA8B,IAAI,EAC/CC,KAAkB,UAA6C,IAAI,EAEnEC,EAAmBN,EAAgBH,EACnCU,EAAmBT,EAAaE,EAAgBH,KAGtD,aAAU,IAAM,CACVO,EAAW,SACbH,EAAiBG,EAAW,QAAQ,YAAY,CAEpD,CAAC,KAGD,aAAU,IACD,IAAM,CACPC,EAAgB,SAClB,aAAaA,EAAgB,OAAO,CAExC,EACC,CAAC,CAAC,EAEL,MAAMG,KAAe,eAAY,IAAM,CACrCT,EAAeU,GAAS,CAACA,CAAI,CAC/B,EAAG,CAAC,CAAC,EAECC,KAAa,eAAY,SAAY,CACzC,GAAKd,EAAK,KAAK,EAEf,GAAI,CACF,MAAM,UAAU,UAAU,UAAUA,CAAI,EACxCO,EAAU,EAAI,EAEVE,EAAgB,SAClB,aAAaA,EAAgB,OAAO,EAEtCA,EAAgB,QAAU,WAAW,IAAMF,EAAU,EAAK,EAAGR,CAAyB,CACxF,MAAgB,CAKhB,CACF,EAAG,CAACC,CAAI,CAAC,EAET,MAAO,CACL,WAAAE,EACA,iBAAAQ,EACA,OAAAJ,EACA,WAAAE,EACA,iBAAAG,EACA,aAAAC,EACA,WAAAE,CACF,CACF",
|
|
6
|
-
"names": ["
|
|
6
|
+
"names": ["use_code_card_exports", "__export", "useCodeCard", "__toCommonJS", "import_react", "COPY_FEEDBACK_DURATION_MS", "code", "collapsedHeight", "isExpanded", "setIsExpanded", "contentHeight", "setContentHeight", "copied", "setCopied", "contentRef", "resetTimeoutRef", "shouldShowToggle", "contentMaxHeight", "handleToggle", "prev", "handleCopy"]
|
|
7
7
|
}
|
|
@@ -8,4 +8,4 @@ declare const Hero: React.ForwardRefExoticComponent<FlexProps & React.RefAttribu
|
|
|
8
8
|
Title: React.ForwardRefExoticComponent<HeadingProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
9
9
|
};
|
|
10
10
|
export { Hero };
|
|
11
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=hero.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"hero.d.ts","sourceRoot":"","sources":["../../../../src/components/hero/hero.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAcjF,QAAA,MAAM,IAAI;;;;;CAOR,CAAC;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";var d=Object.create;var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var r in e)i(o,r,{get:e[r],enumerable:!0})},m=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of g(e))!c.call(o,t)&&t!==r&&i(o,t,{get:()=>e[t],enumerable:!(s=f(e,t))||s.enumerable});return o};var T=(o,e,r)=>(r=o!=null?d(P(o)):{},m(e||!o||!o.__esModule?i(r,"default",{value:o,enumerable:!0}):r,o)),k=o=>m(i({},"__esModule",{value:!0}),o);var y={};u(y,{Hero:()=>l});module.exports=k(y);var n=T(require("react")),p=require("@kushagradhawan/kookie-ui");const a=n.forwardRef((o,e)=>n.createElement(p.Flex,{ref:e,direction:"column",gap:"6",p:"6",...o}));a.displayName="Hero.Variant1";const H=n.forwardRef((o,e)=>n.createElement(p.Heading,{ref:e,...o}));H.displayName="Hero.Title";const l=Object.assign(a,{Root:a,Variant1:a,One:a,Title:H});
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=hero.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/hero/
|
|
3
|
+
"sources": ["../../../../src/components/hero/hero.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from \"react\";\nimport { Flex, Heading } from \"@kushagradhawan/kookie-ui\";\nimport type { FlexProps } from \"@kushagradhawan/kookie-ui/components/flex\";\nimport type { HeadingProps } from \"@kushagradhawan/kookie-ui/components/heading\";\n\ntype HeroRootProps = FlexProps;\nconst HeroVariant1 = React.forwardRef<HTMLDivElement, HeroRootProps>((props, ref) => {\n return <Flex ref={ref} direction=\"column\" gap=\"6\" p=\"6\" {...props} />;\n});\nHeroVariant1.displayName = \"Hero.Variant1\";\n\ntype HeroTitleProps = HeadingProps;\nconst HeroTitle = React.forwardRef<HTMLHeadingElement, HeroTitleProps>((props, ref) => {\n return <Heading ref={ref} {...props} />;\n});\nHeroTitle.displayName = \"Hero.Title\";\n\nconst Hero = Object.assign(HeroVariant1, {\n // Base/root maps to the primary variant\n Root: HeroVariant1,\n Variant1: HeroVariant1,\n One: HeroVariant1,\n // Shared slots\n Title: HeroTitle,\n});\n\nexport { Hero };\n"],
|
|
5
5
|
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,UAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAuB,oBACvBC,EAA8B,qCAK9B,MAAMC,EAAeF,EAAM,WAA0C,CAACG,EAAOC,IACpEJ,EAAA,cAAC,QAAK,IAAKI,EAAK,UAAU,SAAS,IAAI,IAAI,EAAE,IAAK,GAAGD,EAAO,CACpE,EACDD,EAAa,YAAc,gBAG3B,MAAMG,EAAYL,EAAM,WAA+C,CAACG,EAAOC,IACtEJ,EAAA,cAAC,WAAQ,IAAKI,EAAM,GAAGD,EAAO,CACtC,EACDE,EAAU,YAAc,aAExB,MAAMP,EAAO,OAAO,OAAOI,EAAc,CAEvC,KAAMA,EACN,SAAUA,EACV,IAAKA,EAEL,MAAOG,CACT,CAAC",
|
|
6
|
-
"names": ["
|
|
6
|
+
"names": ["hero_exports", "__export", "Hero", "__toCommonJS", "React", "import_kookie_ui", "HeroVariant1", "props", "ref", "HeroTitle"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Hero } from './
|
|
1
|
+
export { Hero } from './hero';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o)=>{for(var f in o)m(r,f,{get:o[f],enumerable:!0})},c=(r,o,f,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of H(o))!a.call(r,e)&&e!==f&&m(r,e,{get:()=>o[e],enumerable:!(p=x(o,e))||p.enumerable});return r};var d=r=>c(m({},"__esModule",{value:!0}),r);var g={};b(g,{Hero:()=>t.Hero});module.exports=d(g);var t=require("./
|
|
1
|
+
"use strict";var m=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o)=>{for(var f in o)m(r,f,{get:o[f],enumerable:!0})},c=(r,o,f,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of H(o))!a.call(r,e)&&e!==f&&m(r,e,{get:()=>o[e],enumerable:!(p=x(o,e))||p.enumerable});return r};var d=r=>c(m({},"__esModule",{value:!0}),r);var g={};b(g,{Hero:()=>t.Hero});module.exports=d(g);var t=require("./hero");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/hero/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { Hero } from './
|
|
4
|
+
"sourcesContent": ["export { Hero } from './hero';\n"],
|
|
5
5
|
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kCAAAE,EAAAF,GAAA,IAAAG,EAAqB",
|
|
6
|
-
"names": ["hero_exports", "__export", "__toCommonJS", "
|
|
6
|
+
"names": ["hero_exports", "__export", "__toCommonJS", "import_hero"]
|
|
7
7
|
}
|
|
@@ -24,4 +24,4 @@ import type { MarkdownComponentOptions } from "./types";
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export declare function createMarkdownComponents(options?: MarkdownComponentOptions): Components;
|
|
27
|
-
//# sourceMappingURL=
|
|
27
|
+
//# sourceMappingURL=create-markdown-components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-markdown-components.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/create-markdown-components.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,KAAK,EAAE,wBAAwB,EAAyB,MAAM,SAAS,CAAC;AA8B/E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,wBAA6B,GAAG,UAAU,CAmJ3F"}
|
package/dist/cjs/components/markdown/{createMarkdownComponents.js → create-markdown-components.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var u=Object.create;var a=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var M=(o,i)=>{for(var t in i)a(o,t,{get:i[t],enumerable:!0})},p=(o,i,t,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of w(i))!k.call(o,e)&&e!==t&&a(o,e,{get:()=>i[e],enumerable:!(s=C(i,e))||s.enumerable});return o};var f=(o,i,t)=>(t=o!=null?u(y(o)):{},p(i||!o||!o.__esModule?a(t,"default",{value:o,enumerable:!0}):t,o)),P=o=>p(a({},"__esModule",{value:!0}),o);var B={};M(B,{createMarkdownComponents:()=>b});module.exports=P(B);var r=f(require("react")),n=require("@kushagradhawan/kookie-ui"),h=require("../code");function T(o){return o?o.match(/language-([\w-]+)/i)?.[1]??"text":"text"}function H(o){let i="";return o?(typeof o=="string"?i=o:Array.isArray(o)&&(i=o.map(t=>typeof t=="string"?t:"").join("")),i.replace(/^\n+|\n+$/g,"")):i}function b(o={}){const{codeBlockCollapsible:i=!1,imageComponent:t,inlineCodeHighContrast:s=!0}=o;return{h1:({children:e})=>r.default.createElement(n.Heading,{size:"
|
|
1
|
+
"use strict";var u=Object.create;var a=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var M=(o,i)=>{for(var t in i)a(o,t,{get:i[t],enumerable:!0})},p=(o,i,t,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of w(i))!k.call(o,e)&&e!==t&&a(o,e,{get:()=>i[e],enumerable:!(s=C(i,e))||s.enumerable});return o};var f=(o,i,t)=>(t=o!=null?u(y(o)):{},p(i||!o||!o.__esModule?a(t,"default",{value:o,enumerable:!0}):t,o)),P=o=>p(a({},"__esModule",{value:!0}),o);var B={};M(B,{createMarkdownComponents:()=>b});module.exports=P(B);var r=f(require("react")),n=require("@kushagradhawan/kookie-ui"),h=require("../code");function T(o){return o?o.match(/language-([\w-]+)/i)?.[1]??"text":"text"}function H(o){let i="";return o?(typeof o=="string"?i=o:Array.isArray(o)&&(i=o.map(t=>typeof t=="string"?t:"").join("")),i.replace(/^\n+|\n+$/g,"")):i}function b(o={}){const{codeBlockCollapsible:i=!1,imageComponent:t,inlineCodeHighContrast:s=!0}=o;return{h1:({children:e})=>r.default.createElement(n.Heading,{size:"9",weight:"medium",as:"h1",style:{marginTop:"1rem",marginBottom:"0.5rem"}},e),h2:({children:e})=>r.default.createElement(n.Heading,{weight:"medium",size:"6",as:"h2",style:{marginTop:"0.875rem",marginBottom:"0.5rem"}},e),h3:({children:e})=>r.default.createElement(n.Heading,{weight:"medium",size:"5",as:"h3",style:{marginTop:"0.75rem",marginBottom:"0.5rem"}},e),h4:({children:e})=>r.default.createElement(n.Heading,{weight:"medium",size:"4",as:"h4",style:{marginTop:"0.625rem",marginBottom:"0.5rem"}},e),h5:({children:e})=>r.default.createElement(n.Heading,{weight:"medium",size:"3",as:"h5",style:{marginTop:"0.5rem",marginBottom:"0.5rem"}},e),h6:({children:e})=>r.default.createElement(n.Heading,{weight:"medium",size:"2",as:"h6",style:{marginTop:"0.5rem",marginBottom:"0.5rem"}},e),p:({children:e})=>r.default.createElement(n.Text,{size:"3",as:"p",style:{lineHeight:"1.6"}},e),code:({className:e,children:d,inline:m})=>{const l=H(d);return m===!0||m===void 0&&!e&&!l.includes(`
|
|
2
2
|
`)&&l.length<100?r.default.createElement(n.Code,{highContrast:s,size:"3"},l):r.default.createElement(n.Box,{my:"2",style:{minWidth:0}},r.default.createElement(h.CodeBlock,{code:l,language:T(e),collapsible:i}))},ul:({children:e})=>r.default.createElement("ul",{style:{marginTop:"0.5rem",marginBottom:"0.5rem",lineHeight:"1.6",paddingLeft:"1.5rem",listStyleType:"disc"}},e),ol:({children:e})=>r.default.createElement("ol",{style:{marginTop:"0.5rem",marginBottom:"0.5rem",lineHeight:"1.6",paddingLeft:"1.5rem",listStyleType:"decimal"}},e),li:({children:e})=>r.default.createElement("li",{style:{marginBottom:"0.25rem",lineHeight:"1.6"}},e),blockquote:({children:e})=>r.default.createElement(n.Blockquote,null,e),a:({href:e,children:d})=>r.default.createElement("a",{href:e,style:{color:"var(--accent-9)",textDecoration:"underline"}},d),strong:({children:e})=>r.default.createElement(n.Text,{weight:"medium",style:{lineHeight:"1.6"}},e),em:({children:e})=>r.default.createElement(n.Text,{style:{lineHeight:"1.6",fontStyle:"italic"}},e),hr:()=>r.default.createElement("hr",{style:{color:"var(--gray-6)",marginTop:"0.5rem",marginBottom:"0.5rem",height:"1px",width:"100%",opacity:.5}}),pre:({children:e})=>r.default.createElement(r.default.Fragment,null,e),table:({children:e})=>r.default.createElement(n.Box,{my:"2",style:{overflowX:"auto"}},r.default.createElement(n.Table.Root,{size:"2",variant:"ghost"},e)),thead:({children:e})=>r.default.createElement(n.Table.Header,null,e),tbody:({children:e})=>r.default.createElement(n.Table.Body,null,e),tr:({children:e})=>r.default.createElement(n.Table.Row,null,e),th:({children:e})=>r.default.createElement(n.Table.ColumnHeaderCell,null,e),td:({children:e})=>r.default.createElement(n.Table.Cell,null,e),sub:({children:e})=>r.default.createElement("sub",null,e),sup:({children:e})=>r.default.createElement("sup",null,e),br:()=>r.default.createElement("br",null),img:t?e=>{const{src:d,alt:m,width:l,height:g}=e;return!d||typeof d!="string"?null:t({src:d,alt:m??"Image",width:l?String(l):void 0,height:g?String(g):void 0})}:void 0,details:({children:e})=>r.default.createElement("details",{style:{padding:"0.5rem 0"}},e),summary:({children:e})=>r.default.createElement("summary",{style:{cursor:"pointer",fontWeight:500}},e)}}
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=create-markdown-components.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/markdown/create-markdown-components.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { type ReactNode } from \"react\";\nimport type { Components } from \"react-markdown\";\nimport { Blockquote, Box, Code, Flex, Heading, Text, Table } from \"@kushagradhawan/kookie-ui\";\nimport { CodeBlock } from \"../code\";\nimport type { MarkdownComponentOptions, MarkdownChildrenProps } from \"./types\";\n\n/**\n * Extracts language from className (e.g., \"language-typescript\" -> \"typescript\")\n */\nfunction extractLanguage(className?: string): string {\n if (!className) {\n return \"text\";\n }\n const match = className.match(/language-([\\w-]+)/i);\n return match?.[1] ?? \"text\";\n}\n\n/**\n * Extracts code string from ReactNode children\n */\nfunction extractCode(children?: ReactNode): string {\n let code = \"\";\n if (!children) {\n return code;\n }\n if (typeof children === \"string\") {\n code = children;\n } else if (Array.isArray(children)) {\n code = children.map((child) => (typeof child === \"string\" ? child : \"\")).join(\"\");\n }\n // Trim trailing newlines but preserve internal whitespace\n return code.replace(/^\\n+|\\n+$/g, \"\");\n}\n\n/**\n * Creates markdown component mappings that work with both react-markdown and MDX.\n * Uses KookieUI components for consistent styling across all projects.\n *\n * @param options - Optional configuration for component behavior\n * @returns Component mappings for markdown/MDX renderers\n *\n * @example\n * ```tsx\n * // In react-markdown\n * <ReactMarkdown components={createMarkdownComponents()}>\n * {content}\n * </ReactMarkdown>\n *\n * // In MDX\n * export function useMDXComponents(components: MDXComponents) {\n * return {\n * ...createMarkdownComponents(),\n * ...components,\n * };\n * }\n * ```\n */\nexport function createMarkdownComponents(options: MarkdownComponentOptions = {}): Components {\n const { codeBlockCollapsible = false, imageComponent, inlineCodeHighContrast = true } = options;\n\n return {\n // Headings with consistent visual hierarchy (9-6-5-4-3-2)\n h1: ({ children }: MarkdownChildrenProps) => (\n <Heading size=\"9\" weight=\"medium\" as=\"h1\" style={{ marginTop: \"1rem\", marginBottom: \"0.5rem\" }}>\n {children}\n </Heading>\n ),\n h2: ({ children }: MarkdownChildrenProps) => (\n <Heading weight=\"medium\" size=\"6\" as=\"h2\" style={{ marginTop: \"0.875rem\", marginBottom: \"0.5rem\" }}>\n {children}\n </Heading>\n ),\n h3: ({ children }: MarkdownChildrenProps) => (\n <Heading weight=\"medium\" size=\"5\" as=\"h3\" style={{ marginTop: \"0.75rem\", marginBottom: \"0.5rem\" }}>\n {children}\n </Heading>\n ),\n h4: ({ children }: MarkdownChildrenProps) => (\n <Heading weight=\"medium\" size=\"4\" as=\"h4\" style={{ marginTop: \"0.625rem\", marginBottom: \"0.5rem\" }}>\n {children}\n </Heading>\n ),\n h5: ({ children }: MarkdownChildrenProps) => (\n <Heading weight=\"medium\" size=\"3\" as=\"h5\" style={{ marginTop: \"0.5rem\", marginBottom: \"0.5rem\" }}>\n {children}\n </Heading>\n ),\n h6: ({ children }: MarkdownChildrenProps) => (\n <Heading weight=\"medium\" size=\"2\" as=\"h6\" style={{ marginTop: \"0.5rem\", marginBottom: \"0.5rem\" }}>\n {children}\n </Heading>\n ),\n\n // Paragraph text\n p: ({ children }: MarkdownChildrenProps) => (\n <Text size=\"3\" as=\"p\" style={{ lineHeight: \"1.6\" }}>\n {children}\n </Text>\n ),\n\n // Code - inline vs block\n code: ({ className, children, inline }: { className?: string; children?: ReactNode; inline?: boolean }) => {\n const code = extractCode(children);\n\n // Block code: has className (language) OR is not marked as inline\n // Inline code: explicitly marked as inline=true, or no className and short single-line content\n const isInlineCode = inline === true || (inline === undefined && !className && !code.includes(\"\\n\") && code.length < 100);\n\n if (isInlineCode) {\n return (\n <Code highContrast={inlineCodeHighContrast} size=\"3\">\n {code}\n </Code>\n );\n }\n\n return (\n <Box my=\"2\" style={{ minWidth: 0 }}>\n <CodeBlock code={code} language={extractLanguage(className)} collapsible={codeBlockCollapsible} />\n </Box>\n );\n },\n\n // Lists\n ul: ({ children }: MarkdownChildrenProps) => (\n <ul style={{ marginTop: \"0.5rem\", marginBottom: \"0.5rem\", lineHeight: \"1.6\", paddingLeft: \"1.5rem\", listStyleType: \"disc\" }}>{children}</ul>\n ),\n ol: ({ children }: MarkdownChildrenProps) => (\n <ol style={{ marginTop: \"0.5rem\", marginBottom: \"0.5rem\", lineHeight: \"1.6\", paddingLeft: \"1.5rem\", listStyleType: \"decimal\" }}>{children}</ol>\n ),\n li: ({ children }: MarkdownChildrenProps) => <li style={{ marginBottom: \"0.25rem\", lineHeight: \"1.6\" }}>{children}</li>,\n\n // Blockquote\n blockquote: ({ children }: MarkdownChildrenProps) => <Blockquote>{children}</Blockquote>,\n\n // Links\n a: ({ href, children }: { href?: string; children?: ReactNode }) => (\n <a href={href} style={{ color: \"var(--accent-9)\", textDecoration: \"underline\" }}>\n {children}\n </a>\n ),\n\n // Text styling\n strong: ({ children }: MarkdownChildrenProps) => (\n <Text weight=\"medium\" style={{ lineHeight: \"1.6\" }}>\n {children}\n </Text>\n ),\n em: ({ children }: MarkdownChildrenProps) => <Text style={{ lineHeight: \"1.6\", fontStyle: \"italic\" }}>{children}</Text>,\n\n // Horizontal rule\n hr: () => (\n <hr\n style={{\n color: \"var(--gray-6)\",\n marginTop: \"0.5rem\",\n marginBottom: \"0.5rem\",\n height: \"1px\",\n width: \"100%\",\n opacity: 0.5,\n }}\n />\n ),\n\n // Pre wrapper (pass through to let code handle it)\n pre: ({ children }: MarkdownChildrenProps) => <>{children}</>,\n\n // Tables using KookieUI\n table: ({ children }: MarkdownChildrenProps) => (\n <Box my=\"2\" style={{ overflowX: \"auto\" }}>\n <Table.Root size=\"2\" variant=\"ghost\">\n {children}\n </Table.Root>\n </Box>\n ),\n thead: ({ children }: MarkdownChildrenProps) => <Table.Header>{children}</Table.Header>,\n tbody: ({ children }: MarkdownChildrenProps) => <Table.Body>{children}</Table.Body>,\n tr: ({ children }: MarkdownChildrenProps) => <Table.Row>{children}</Table.Row>,\n th: ({ children }: MarkdownChildrenProps) => <Table.ColumnHeaderCell>{children}</Table.ColumnHeaderCell>,\n td: ({ children }: MarkdownChildrenProps) => <Table.Cell>{children}</Table.Cell>,\n\n // HTML elements for raw HTML support\n sub: ({ children }: MarkdownChildrenProps) => <sub>{children}</sub>,\n sup: ({ children }: MarkdownChildrenProps) => <sup>{children}</sup>,\n br: () => <br />,\n\n // Images - use custom component if provided\n img: imageComponent\n ? (props: React.ImgHTMLAttributes<HTMLImageElement>) => {\n const { src, alt, width, height } = props;\n if (!src || typeof src !== \"string\") return null;\n return imageComponent({\n src,\n alt: alt ?? \"Image\",\n width: width ? String(width) : undefined,\n height: height ? String(height) : undefined,\n });\n }\n : undefined,\n\n // Details/Summary for expandable sections\n details: ({ children }: MarkdownChildrenProps) => <details style={{ padding: \"0.5rem 0\" }}>{children}</details>,\n summary: ({ children }: MarkdownChildrenProps) => <summary style={{ cursor: \"pointer\", fontWeight: 500 }}>{children}</summary>,\n };\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAsC,oBAEtCC,EAAkE,qCAClEC,EAA0B,mBAM1B,SAASC,EAAgBC,EAA4B,CACnD,OAAKA,EAGSA,EAAU,MAAM,oBAAoB,IACnC,CAAC,GAAK,OAHZ,MAIX,CAKA,SAASC,EAAYC,EAA8B,CACjD,IAAIC,EAAO,GACX,OAAKD,GAGD,OAAOA,GAAa,SACtBC,EAAOD,EACE,MAAM,QAAQA,CAAQ,IAC/BC,EAAOD,EAAS,IAAKE,GAAW,OAAOA,GAAU,SAAWA,EAAQ,EAAG,EAAE,KAAK,EAAE,GAG3ED,EAAK,QAAQ,aAAc,EAAE,GAR3BA,CASX,CAyBO,SAAST,EAAyBW,EAAoC,CAAC,EAAe,CAC3F,KAAM,CAAE,qBAAAC,EAAuB,GAAO,eAAAC,EAAgB,uBAAAC,EAAyB,EAAK,EAAIH,EAExF,MAAO,CAEL,GAAI,CAAC,CAAE,SAAAH,CAAS,IACd,EAAAO,QAAA,cAAC,WAAQ,KAAK,IAAI,OAAO,SAAS,GAAG,KAAK,MAAO,CAAE,UAAW,OAAQ,aAAc,QAAS,GAC1FP,CACH,EAEF,GAAI,CAAC,CAAE,SAAAA,CAAS,IACd,EAAAO,QAAA,cAAC,WAAQ,OAAO,SAAS,KAAK,IAAI,GAAG,KAAK,MAAO,CAAE,UAAW,WAAY,aAAc,QAAS,GAC9FP,CACH,EAEF,GAAI,CAAC,CAAE,S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__toCommonJS", "import_react", "import_kookie_ui", "import_code", "extractLanguage", "className", "extractCode", "children", "code", "child", "options", "codeBlockCollapsible", "imageComponent", "inlineCodeHighContrast", "React", "inline", "href", "props", "src", "alt", "width", "height"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { StreamingMarkdown } from "./
|
|
2
|
-
export type { StreamingMarkdownOptions } from "./
|
|
3
|
-
export { createMarkdownComponents } from "./
|
|
1
|
+
export { StreamingMarkdown } from "./streaming-markdown";
|
|
2
|
+
export type { StreamingMarkdownOptions } from "./streaming-markdown";
|
|
3
|
+
export { createMarkdownComponents } from "./create-markdown-components";
|
|
4
4
|
export type { MarkdownComponentOptions, MarkdownChildrenProps } from "./types";
|
|
5
|
-
export { completeUnterminatedMarkdown, parseMarkdownIntoBlocks } from "./utils/
|
|
5
|
+
export { completeUnterminatedMarkdown, parseMarkdownIntoBlocks } from "./utils/markdown-streaming";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,YAAY,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE/E,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var i=(r,o)=>{for(var n in o)p(r,n,{get:o[n],enumerable:!0})},M=(r,o,n,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of s(o))!w.call(r,e)&&e!==n&&p(r,e,{get:()=>o[e],enumerable:!(a=k(o,e))||a.enumerable});return r};var f=r=>M(p({},"__esModule",{value:!0}),r);var x={};i(x,{StreamingMarkdown:()=>m.StreamingMarkdown,completeUnterminatedMarkdown:()=>t.completeUnterminatedMarkdown,createMarkdownComponents:()=>d.createMarkdownComponents,parseMarkdownIntoBlocks:()=>t.parseMarkdownIntoBlocks});module.exports=f(x);var m=require("./streaming-markdown"),d=require("./create-markdown-components"),t=require("./utils/markdown-streaming");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/markdown/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { StreamingMarkdown } from \"./
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0OAAAE,EAAAF,GAAA,IAAAG,EAAkC
|
|
6
|
-
"names": ["markdown_exports", "__export", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["export { StreamingMarkdown } from \"./streaming-markdown\";\nexport type { StreamingMarkdownOptions } from \"./streaming-markdown\";\n\nexport { createMarkdownComponents } from \"./create-markdown-components\";\nexport type { MarkdownComponentOptions, MarkdownChildrenProps } from \"./types\";\n\nexport { completeUnterminatedMarkdown, parseMarkdownIntoBlocks } from \"./utils/markdown-streaming\";\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0OAAAE,EAAAF,GAAA,IAAAG,EAAkC,gCAGlCC,EAAyC,wCAGzCC,EAAsE",
|
|
6
|
+
"names": ["markdown_exports", "__export", "__toCommonJS", "import_streaming_markdown", "import_create_markdown_components", "import_markdown_streaming"]
|
|
7
7
|
}
|
|
@@ -75,4 +75,4 @@ type StreamingMarkdownProps = {
|
|
|
75
75
|
*/
|
|
76
76
|
export declare function StreamingMarkdown({ content, id, options }: StreamingMarkdownProps): React.JSX.Element | null;
|
|
77
77
|
export {};
|
|
78
|
-
//# sourceMappingURL=
|
|
78
|
+
//# sourceMappingURL=streaming-markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-markdown.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/streaming-markdown.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAsB,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOhE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AASxD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,GAAG;IAChE;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE3D;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CAClC,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC,CAAC;AA6CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,OAAY,EAAE,EAAE,sBAAsB,4BA2CtF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";"use client";var B=Object.create;var m=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var L=(o,n)=>{for(var t in n)m(o,t,{get:n[t],enumerable:!0})},M=(o,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of S(n))!x.call(o,r)&&r!==t&&m(o,r,{get:()=>n[r],enumerable:!(i=I(n,r))||i.enumerable});return o};var s=(o,n,t)=>(t=o!=null?B(E(o)):{},M(n||!o||!o.__esModule?m(t,"default",{value:o,enumerable:!0}):t,o)),A=o=>M(m({},"__esModule",{value:!0}),o);var H={};L(H,{StreamingMarkdown:()=>z});module.exports=A(H);var e=s(require("react")),O=s(require("react-markdown")),P=s(require("remark-gfm")),h=s(require("rehype-raw")),y=s(require("harden-react-markdown")),l=require("@kushagradhawan/kookie-ui"),C=require("./create-markdown-components"),d=require("./utils/markdown-streaming");const F=(0,y.default)(O.default),_=["https://","http://","/"],D=["https://","http://","/","data:"],N=["mailto:","tel:","data:","http:","https:"],R=typeof window<"u"&&window.location?.origin?window.location.origin:"https://app.kookie.ai";function G(o){return o||R}const k=(0,e.memo)(({content:o,defaultOrigin:n,components:t})=>e.default.createElement(l.Box,{width:"100%"},e.default.createElement(F,{defaultOrigin:n,allowedLinkPrefixes:_,allowedImagePrefixes:D,allowedProtocols:N,allowDataImages:!0,components:t,remarkPlugins:[P.default],rehypePlugins:[h.default]},o)),(o,n)=>o.content===n.content&&o.defaultOrigin===n.defaultOrigin&&o.components===n.components);k.displayName="MarkdownBlock";function z({content:o,id:n,options:t={}}){const{defaultOrigin:i,enableBlockMemoization:r=!0,blockParser:c,components:g={},...w}=t,f=(0,e.useMemo)(()=>G(i),[i]),u=(0,e.useMemo)(()=>({...(0,C.createMarkdownComponents)(w),...g}),[w,g]),p=(0,e.useMemo)(()=>{if(!r||!c){const a=(0,d.completeUnterminatedMarkdown)(o);return a.trim()?[a]:[]}return(0,d.parseMarkdownIntoBlocks)(o,c)},[o,r,c]);return p.length?p.length===1?e.default.createElement(k,{content:p[0],defaultOrigin:f,components:u}):e.default.createElement(l.Flex,{direction:"column",gap:"2",width:"100%"},p.map((a,b)=>e.default.createElement(k,{key:`${n}-block-${b}`,content:a,defaultOrigin:f,components:u}))):null}
|
|
2
|
+
//# sourceMappingURL=streaming-markdown.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/markdown/streaming-markdown.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport React, { memo, useMemo, type ReactNode } from \"react\";\nimport ReactMarkdown, { type Components } from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport rehypeRaw from \"rehype-raw\";\nimport hardenReactMarkdown from \"harden-react-markdown\";\nimport { Box, Flex } from \"@kushagradhawan/kookie-ui\";\nimport { createMarkdownComponents } from \"./create-markdown-components\";\nimport { completeUnterminatedMarkdown, parseMarkdownIntoBlocks } from \"./utils/markdown-streaming\";\nimport type { MarkdownComponentOptions } from \"./types\";\n\nconst HardenedMarkdown = hardenReactMarkdown(ReactMarkdown);\n\nconst LINK_PREFIXES = [\"https://\", \"http://\", \"/\"];\nconst IMAGE_PREFIXES = [\"https://\", \"http://\", \"/\", \"data:\"];\nconst ALLOWED_PROTOCOLS = [\"mailto:\", \"tel:\", \"data:\", \"http:\", \"https:\"];\nconst DEFAULT_APP_ORIGIN = typeof window !== \"undefined\" && window.location?.origin ? window.location.origin : \"https://app.kookie.ai\";\n\n/**\n * Options for StreamingMarkdown component\n */\nexport type StreamingMarkdownOptions = MarkdownComponentOptions & {\n /**\n * Security origin for link/image validation\n * @default window.location.origin or \"https://app.kookie.ai\"\n */\n defaultOrigin?: string;\n\n /**\n * Whether to enable block-level memoization for performance\n * Recommended for streaming scenarios where content updates frequently\n * @default true\n */\n enableBlockMemoization?: boolean;\n\n /**\n * Custom parser for splitting content into blocks\n * If not provided, content will be rendered as a single block\n * For optimal streaming performance, use marked.lexer with GFM enabled\n */\n blockParser?: (content: string) => Array<{ raw?: string }>;\n\n /**\n * Override default component mappings\n */\n components?: Partial<Components>;\n};\n\ntype StreamingMarkdownProps = {\n /**\n * Markdown content to render (supports streaming/incomplete markdown)\n */\n content: string;\n\n /**\n * Unique identifier for this markdown instance (used for keys)\n */\n id: string;\n\n /**\n * Optional configuration\n */\n options?: StreamingMarkdownOptions;\n};\n\ntype MarkdownBlockProps = {\n content: string;\n defaultOrigin: string;\n components: Components;\n};\n\n/**\n * Resolves the default origin for security validation\n */\nfunction resolveDefaultOrigin(customOrigin?: string): string {\n if (customOrigin) {\n return customOrigin;\n }\n return DEFAULT_APP_ORIGIN;\n}\n\n/**\n * Memoized markdown block component for efficient streaming rendering\n */\nconst MarkdownBlock = memo(\n ({ content, defaultOrigin, components }: MarkdownBlockProps) => {\n return (\n <Box width=\"100%\">\n <HardenedMarkdown\n defaultOrigin={defaultOrigin}\n allowedLinkPrefixes={LINK_PREFIXES}\n allowedImagePrefixes={IMAGE_PREFIXES}\n allowedProtocols={ALLOWED_PROTOCOLS}\n allowDataImages\n components={components}\n remarkPlugins={[remarkGfm]}\n rehypePlugins={[rehypeRaw]}\n >\n {content}\n </HardenedMarkdown>\n </Box>\n );\n },\n (previous, next) => previous.content === next.content && previous.defaultOrigin === next.defaultOrigin && previous.components === next.components\n);\n\nMarkdownBlock.displayName = \"MarkdownBlock\";\n\n/**\n * StreamingMarkdown - A drop-in markdown renderer designed for AI streaming.\n *\n * Features:\n * - Unterminated block parsing (handles incomplete markdown during streaming)\n * - Block-level memoization for performance\n * - Security hardening (validates links/images)\n * - GitHub Flavored Markdown support\n * - KookieUI component integration\n * - Code syntax highlighting via CodeBlock\n *\n * @example\n * ```tsx\n * import { StreamingMarkdown } from '@kushagradhawan/kookie-blocks';\n * import { marked } from 'marked';\n *\n * function ChatMessage({ message }) {\n * return (\n * <StreamingMarkdown\n * content={message.content}\n * id={message.id}\n * options={{\n * blockParser: (content) => marked.lexer(content, { gfm: true }),\n * enableBlockMemoization: true,\n * }}\n * />\n * );\n * }\n * ```\n */\nexport function StreamingMarkdown({ content, id, options = {} }: StreamingMarkdownProps) {\n const { defaultOrigin: customOrigin, enableBlockMemoization = true, blockParser, components: customComponents = {}, ...componentOptions } = options;\n\n // Resolve security origin\n const defaultOrigin = useMemo(() => resolveDefaultOrigin(customOrigin), [customOrigin]);\n\n // Create component mappings with custom overrides\n const markdownComponents = useMemo(() => {\n const baseComponents = createMarkdownComponents(componentOptions);\n return {\n ...baseComponents,\n ...customComponents,\n };\n }, [componentOptions, customComponents]);\n\n // Parse content into blocks for memoization (if enabled and parser provided)\n const blocks = useMemo(() => {\n if (!enableBlockMemoization || !blockParser) {\n // No block splitting - just complete unterminated markdown\n const completed = completeUnterminatedMarkdown(content);\n return completed.trim() ? [completed] : [];\n }\n\n return parseMarkdownIntoBlocks(content, blockParser);\n }, [content, enableBlockMemoization, blockParser]);\n\n if (!blocks.length) {\n return null;\n }\n\n // Single block - no need for wrapper\n if (blocks.length === 1) {\n return <MarkdownBlock content={blocks[0]} defaultOrigin={defaultOrigin} components={markdownComponents} />;\n }\n\n // Multiple blocks - render with flex wrapper\n return (\n <Flex direction=\"column\" gap=\"2\" width=\"100%\">\n {blocks.map((block, index) => (\n <MarkdownBlock key={`${id}-block-${index}`} content={block} defaultOrigin={defaultOrigin} components={markdownComponents} />\n ))}\n </Flex>\n );\n}\n"],
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAAqD,oBACrDC,EAA+C,6BAC/CC,EAAsB,yBACtBC,EAAsB,yBACtBC,EAAgC,oCAChCC,EAA0B,qCAC1BC,EAAyC,wCACzCC,EAAsE,sCAGtE,MAAMC,KAAmB,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B,EAAU,KAAK,EAAI,CAACA,CAAS,EAAI,CAAC,CAC3C,CAEA,SAAO,2BAAwBhB,EAASW,CAAW,CACrD,EAAG,CAACX,EAASU,EAAwBC,CAAW,CAAC,EAEjD,OAAKI,EAAO,OAKRA,EAAO,SAAW,EACb,EAAAZ,QAAA,cAACJ,EAAA,CAAc,QAASgB,EAAO,CAAC,EAAG,cAAed,EAAe,WAAYa,EAAoB,EAKxG,EAAAX,QAAA,cAAC,QAAK,UAAU,SAAS,IAAI,IAAI,MAAM,QACpCY,EAAO,IAAI,CAACE,EAAOC,IAClB,EAAAf,QAAA,cAACJ,EAAA,CAAc,IAAK,GAAGS,CAAE,UAAUU,CAAK,GAAI,QAASD,EAAO,cAAehB,EAAe,WAAYa,EAAoB,CAC3H,CACH,EAdO,IAgBX",
|
|
6
|
+
"names": ["streaming_markdown_exports", "__export", "StreamingMarkdown", "__toCommonJS", "import_react", "import_react_markdown", "import_remark_gfm", "import_rehype_raw", "import_harden_react_markdown", "import_kookie_ui", "import_create_markdown_components", "import_markdown_streaming", "HardenedMarkdown", "hardenReactMarkdown", "ReactMarkdown", "LINK_PREFIXES", "IMAGE_PREFIXES", "ALLOWED_PROTOCOLS", "DEFAULT_APP_ORIGIN", "resolveDefaultOrigin", "customOrigin", "MarkdownBlock", "content", "defaultOrigin", "components", "React", "remarkGfm", "rehypeRaw", "previous", "next", "id", "options", "enableBlockMemoization", "blockParser", "customComponents", "componentOptions", "markdownComponents", "blocks", "completed", "block", "index"]
|
|
7
|
+
}
|
|
@@ -29,4 +29,4 @@ export declare function completeUnterminatedMarkdown(content: string): string;
|
|
|
29
29
|
export declare function parseMarkdownIntoBlocks(content: string, parser?: (content: string) => Array<{
|
|
30
30
|
raw?: string;
|
|
31
31
|
}>): string[];
|
|
32
|
-
//# sourceMappingURL=
|
|
32
|
+
//# sourceMappingURL=markdown-streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-streaming.d.ts","sourceRoot":"","sources":["../../../../../src/components/markdown/utils/markdown-streaming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2IH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAsGpE;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACpD,MAAM,EAAE,CAuBV"}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
`,i=r<e.length-1&&e[r+1]===" ";return t&&i}function h(e,r){let n=0,t=-1;for(let s=0;s<e.length;s++)if(e[s]===r){if(b(e,s,r))continue;const a=s>0&&e[s-1]===r,l=s<e.length-1&&e[s+1]===r;if(a||l){l&&s++;continue}n++,t=s}return n%2===0||t===-1?!1:t===e.length-1?t>0:e.slice(t+1).length>0}function I(e){const r=/```/g,n=[];let t;for(;(t=r.exec(e))!==null;)n.push(t.index);return n.length%2===1}function g(e){if(!e.trim())return e;const r=e.trimEnd(),n=e.slice(r.length);let t=r;if(t.match(/```[\w-]*$/)&&!t.includes("```\n")&&!t.match(/```[\w-]+\n/)||I(t))return t+="\n```",t+n;if((t.replace(/```[\w-]*/g,"").match(/`/g)||[]).length%2===1)return t+="`",t+n;if(t.match(/\[([^\]]*)\]\(([^)]*)$/))return t+=")",t+n;if(u(t,"**"))return t+="**",t+n;if(u(t,"__"))return t+="__",t+n;if(x(t))return t+="~~",t+n;const f=t.split(`
|
|
3
3
|
`),c=f[f.length-1];return c.match(/^#{1,6}\s+.+$/)||c.match(/^(\s*)([-*+]|\d+\.)\s+.+$/)||c.match(/^>\s+.+$/)?(t+=`
|
|
4
4
|
`,t+n):h(t,"*")?(t+="*",t+n):(h(t,"_")&&(t+="_"),t+n)}function C(e,r){if(!e.trim())return[];const n=g(e);return r?r(n).map(i=>"raw"in i&&typeof i.raw=="string"?i.raw:"").filter(i=>!!i.trim()):[n]}
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=markdown-streaming.js.map
|