{"version":3,"file":"EditorStyleCodeBlock.DXe1Awet.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/DhEDz4UFFbxG1e1B8qaL/Bt0YBaTCV9tpZpzePj8i/EditorStyleCodeBlock.js"],"sourcesContent":["// Build a React code component for Framer named EditorStyleCodeBlock.\n// The goal is to display code exactly like in a code editor (VSCode style), with customizable colors and fonts.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function EditorStyleCodeBlock(props){const{code=`# Example YAML\ntype: validation\nname: email_check\nchecks:\n  - valid_values: [\"@gmail.com\", \"@yahoo.com\"]\n  - max_length: 255`,backgroundColor,gutterBackground,borderColor,defaultTextColor,keywordColor,stringColor,commentColor,numberColor,fontFamily,fontSize,lineHeight,padding,showLineNumbers,lineNumberColor,lineNumberPadding}=props;const highlightedLines=useMemo(()=>{const lines=code.split(\"\\n\");return lines.map((line,index)=>{const tokens=[];let remaining=line;let position=0;while(position<remaining.length){const rest=remaining.slice(position);// Comments (highest priority)\nif(rest.match(/^#.*/)){const match=rest.match(/^#.*/)[0];tokens.push({text:match,color:commentColor});position+=match.length;continue;}// Strings with double quotes\nif(rest.match(/^\"[^\"]*\"/)){const match=rest.match(/^\"[^\"]*\"/)[0];tokens.push({text:match,color:stringColor});position+=match.length;continue;}// Strings with single quotes\nif(rest.match(/^'[^']*'/)){const match=rest.match(/^'[^']*'/)[0];tokens.push({text:match,color:stringColor});position+=match.length;continue;}// Numbers\nif(rest.match(/^\\d+(\\.\\d+)?/)){const match=rest.match(/^\\d+(\\.\\d+)?/)[0];tokens.push({text:match,color:numberColor});position+=match.length;continue;}// Keywords (common YAML/code keywords)\nif(rest.match(/^(type|name|checks|valid_values|max_length|min_length|required|optional|default|true|false|null|function|const|let|var|if|else|return|import|export|from|class|interface|enum)\\b/)){const match=rest.match(/^(type|name|checks|valid_values|max_length|min_length|required|optional|default|true|false|null|function|const|let|var|if|else|return|import|export|from|class|interface|enum)\\b/)[0];tokens.push({text:match,color:keywordColor});position+=match.length;continue;}// Default text (single character at a time)\ntokens.push({text:rest[0],color:defaultTextColor});position+=1;}return{lineNumber:index+1,tokens};});},[code,keywordColor,stringColor,commentColor,numberColor,defaultTextColor]);const gutterWidth=showLineNumbers?50:0;return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",backgroundColor,border:`1px solid ${borderColor}`,borderRadius:8,overflow:\"hidden\",boxShadow:\"inset 0 1px 3px rgba(0, 0, 0, 0.1)\",display:\"flex\",fontFamily,fontSize,lineHeight},children:[showLineNumbers&&/*#__PURE__*/_jsx(\"div\",{style:{width:gutterWidth,backgroundColor:gutterBackground,padding:`${padding}px ${lineNumberPadding}px`,textAlign:\"right\",color:lineNumberColor,userSelect:\"none\",flexShrink:0,borderRight:`1px solid ${borderColor}`},children:highlightedLines.map(line=>/*#__PURE__*/_jsx(\"div\",{style:{whiteSpace:\"pre\"},children:line.lineNumber},line.lineNumber))}),/*#__PURE__*/_jsx(\"div\",{style:{flex:1,padding,overflow:\"hidden\",whiteSpace:\"pre\",fontFamily:\"inherit\",fontSize:\"inherit\",lineHeight:\"inherit\"},children:highlightedLines.map((line,idx)=>/*#__PURE__*/_jsx(\"div\",{children:line.tokens.map((token,tokenIdx)=>/*#__PURE__*/_jsx(\"span\",{style:{color:token.color},children:token.text},tokenIdx))},idx))})]});}addPropertyControls(EditorStyleCodeBlock,{code:{type:ControlType.String,title:\"Code\",displayTextArea:true,defaultValue:`# Example YAML\ntype: validation\nname: email_check\nchecks:\n  - valid_values: [\"@gmail.com\", \"@yahoo.com\"]\n  - max_length: 255`},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#1E1E1E\"},gutterBackground:{type:ControlType.Color,title:\"Gutter Background\",defaultValue:\"#252526\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#3E3E42\"},defaultTextColor:{type:ControlType.Color,title:\"Default Text\",defaultValue:\"#D4D4D4\"},keywordColor:{type:ControlType.Color,title:\"Keyword Color\",defaultValue:\"#569CD6\"},stringColor:{type:ControlType.Color,title:\"String Color\",defaultValue:\"#CE9178\"},commentColor:{type:ControlType.Color,title:\"Comment Color\",defaultValue:\"#6A9955\"},numberColor:{type:ControlType.Color,title:\"Number Color\",defaultValue:\"#B5CEA8\"},fontFamily:{type:ControlType.String,title:\"Font Family\",defaultValue:\"Menlo, Monaco, 'Courier New', monospace\"},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:14,min:8,max:24,step:1,unit:\"px\"},lineHeight:{type:ControlType.Number,title:\"Line Height\",defaultValue:1.5,min:1,max:3,step:.1},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:16,min:0,max:48,step:4,unit:\"px\"},showLineNumbers:{type:ControlType.Boolean,title:\"Line Numbers\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},lineNumberColor:{type:ControlType.Color,title:\"Line Number Color\",defaultValue:\"#858585\"},lineNumberPadding:{type:ControlType.Number,title:\"Line Number Padding\",defaultValue:8,min:0,max:32,step:2,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EditorStyleCodeBlock\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./EditorStyleCodeBlock.map"],"mappings":"kLAKG,SAAwB,EAAqB,EAAM,CAAC,GAAK,CAAC,OAAK;;;;;qBAK7C,kBAAgB,mBAAiB,cAAY,mBAAiB,eAAa,cAAY,eAAa,cAAY,aAAW,WAAS,aAAW,UAAQ,kBAAgB,kBAAgB,qBAAmB,EAAY,EAAiBA,MAAyB,EAAK,MAAM;EAAK,CAAc,KAAK,EAAK,IAAQ,CAAC,IAAM,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