{"version":3,"file":"TableGenerator.CGkICa4V.mjs","names":["useMemo","useState"],"sources":["https:/framerusercontent.com/modules/kz3YPs1HGUCTndnQCDfx/nCNHak7jAqpHPPDJ6WdV/TableGenerator.js"],"sourcesContent":["// Table Creator with custom styling and CSV data input\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function parseCSV(csv){// Universal robust CSV parse\nif(!csv)return{header:[],rows:[]};const lines=csv.trim().replace(/\\r/g,\"\").split(\"\\n\");if(lines.length===0)return{header:[],rows:[]};// Simple RFC4180 parser handling quoted entries\nconst parseLine=line=>{const result=[];let cur=\"\",inQuotes=false;for(let i=0;i<line.length;i++){const c=line[i];if(inQuotes){if(c==='\"'&&line[i+1]==='\"'){cur+='\"';i++;}else if(c==='\"'){inQuotes=false;}else{cur+=c;}}else if(c==='\"'){inQuotes=true;}else if(c===\",\"){result.push(cur);cur=\"\";}else{cur+=c;}}result.push(cur);return result;};const header=parseLine(lines[0]);const rows=lines.slice(1).map(parseLine);return{header,rows};}/**\n * Table Creator\n * Autosizes to parent unless given fixed size. Fully customizable.\n * CSV field supports pasted text or \"upload file\" for .csv file.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TableGenerator(props){const{csv,csvFile=\"\",border,borderRadius,heading,font,cellBackground,evenRowBackground,oddRowBackground,headingBackground,headingColor,cellColor,align,lastRowBackground,lastRowColor,style,scrollbarThumb,scrollbarTrack,scrollbarWidth,scrollbarRadius}=props;// Merge file content if present\nconst effectiveCSV=csvFile&&typeof csvFile===\"string\"&&csvFile.length>0?csvFile:csv;const{header,rows}=useMemo(()=>parseCSV(effectiveCSV),[effectiveCSV]);const effectiveRows=rows.filter(r=>r.length>1||r.length===1&&r[0].trim()!==\"\");// Check if CSV file is provided and is a link (string URL), try to fetch file contents if so\nconst[fileData,setFileData]=useState(\"\");useMemo(()=>{if(csvFile&&typeof csvFile===\"string\"&&csvFile.startsWith(\"http\")){fetch(csvFile).then(r=>r.text()).then(text=>{startTransition(()=>setFileData(text));}).catch(()=>{});}else{startTransition(()=>setFileData(\"\"));}},[csvFile]);const csvContent=fileData||(csvFile&&typeof csvFile===\"string\"&&csvFile.length>0?csvFile:csv);const{header:csvHeader,rows:csvRows}=useMemo(()=>parseCSV(csvContent),[csvContent]);const finalHeader=csvHeader;const finalRows=csvRows.filter(r=>r.length>1||r.length===1&&r[0].trim()!==\"\");return /*#__PURE__*/_jsxs(\"div\",{style:{...style,width:\"100%\",maxWidth:\"100%\",position:\"relative\",display:\"block\",border:border?`1px solid ${border}`:undefined,borderRadius:borderRadius,overflow:\"hidden\",background:cellBackground},children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                .tablegen-scroll::-webkit-scrollbar {\n                    height: ${scrollbarWidth||10}px;\n                    background: ${scrollbarTrack||\"#FAFAFA\"};\n                    border-radius: ${scrollbarRadius||6}px;\n                }\n                .tablegen-scroll::-webkit-scrollbar-thumb {\n                    background: ${scrollbarThumb||\"#DBDBDB\"};\n                    border-radius: ${scrollbarRadius||6}px;\n                }\n                /* For Firefox */\n                .tablegen-scroll {\n                    scrollbar-width: ${scrollbarWidth?scrollbarWidth>12?\"thin\":\"auto\":\"auto\"};\n                    scrollbar-color: ${scrollbarThumb||\"#DBDBDB\"} ${scrollbarTrack||\"#FAFAFA\"};\n                }\n            `}),/*#__PURE__*/_jsx(\"div\",{className:\"tablegen-scroll\",style:{width:\"100%\",overflowX:\"auto\",overflowY:\"hidden\"},children:/*#__PURE__*/_jsxs(\"table\",{style:{borderCollapse:\"separate\",borderSpacing:0,width:\"100%\",minWidth:\"max-content\",boxSizing:\"border-box\",tableLayout:\"auto\"},children:[/*#__PURE__*/_jsx(\"thead\",{children:/*#__PURE__*/_jsx(\"tr\",{children:finalHeader.map((h,i)=>/*#__PURE__*/_jsx(\"th\",{style:{...heading,background:headingBackground,color:headingColor,borderBottom:border?`1px solid ${border}`:undefined,borderRight:border?`1px solid ${border}`:undefined,padding:12,textAlign:align},children:h},i))})}),/*#__PURE__*/_jsx(\"tbody\",{children:finalRows.map((row,rIdx)=>{const isLast=rIdx===finalRows.length-1;return /*#__PURE__*/_jsx(\"tr\",{style:{background:isLast?lastRowBackground||(rIdx%2===0?evenRowBackground:oddRowBackground):rIdx%2===0?evenRowBackground:oddRowBackground},children:finalHeader.map((h,cIdx)=>/*#__PURE__*/_jsx(\"td\",{style:{...font,color:isLast?lastRowColor||cellColor:cellColor,borderRight:border?`1px solid ${border}`:undefined,borderBottom:border?`1px solid ${border}`:undefined,padding:10,textAlign:align,minWidth:60},children:row[cIdx]??\"\"},cIdx))},rIdx);})})]})})]});}addPropertyControls(TableGenerator,{csv:{type:ControlType.String,title:\"CSV Data\",defaultValue:\"Name,Age,Occupation\\nAmy,28,Developer\\nBen,32,Designer\",displayTextArea:true,placeholder:\"Paste your CSV data here, or upload a file\"},csvFile:{type:ControlType.File,allowedFileTypes:[\"csv\"],title:\"CSV File\"},border:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#EEEEEE\"},borderRadius:{type:ControlType.Number,title:\"Roundness\",defaultValue:8,min:0,max:32,step:1},align:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},heading:{type:ControlType.Font,title:\"Heading Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"18px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\",textAlign:\"left\"}},font:{type:ControlType.Font,title:\"Body Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\",textAlign:\"left\"}},headingBackground:{type:ControlType.Color,title:\"Heading Background\",defaultValue:\"#F5F5F5\"},headingColor:{type:ControlType.Color,title:\"Heading Color\",defaultValue:\"#000000\"},cellBackground:{type:ControlType.Color,title:\"Cell Background\",defaultValue:\"#FFFFFF\"},evenRowBackground:{type:ControlType.Color,title:\"Even Row\",defaultValue:\"#FFFFFF\"},oddRowBackground:{type:ControlType.Color,title:\"Odd Row\",defaultValue:\"#FAFAFA\"},cellColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#222222\"},lastRowBackground:{type:ControlType.Color,title:\"Last Row Background\",defaultValue:\"#fffbe0\"},lastRowColor:{type:ControlType.Color,title:\"Last Row Text\",defaultValue:\"#222222\"},scrollbarThumb:{type:ControlType.Color,title:\"Scrollbar Thumb\",defaultValue:\"#DBDBDB\"},scrollbarTrack:{type:ControlType.Color,title:\"Scrollbar Track\",defaultValue:\"#FAFAFA\"},scrollbarWidth:{type:ControlType.Number,title:\"Scrollbar Width\",defaultValue:10,min:6,max:24,step:1},scrollbarRadius:{type:ControlType.Number,title:\"Scrollbar Radius\",defaultValue:6,min:0,max:24,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TableGenerator\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableGenerator.map"],"mappings":"+LACiK,SAAS,EAAS,EAAI,CACvL,GAAG,CAAC,EAAI,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,IAAM,EAAM,EAAI,MAAM,CAAC,QAAQ,MAAM,GAAG,CAAC,MAAM;EAAK,CAAC,GAAG,EAAM,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,CACpI,IAAM,EAAU,GAAM,CAAC,IAAM,EAAO,EAAE,CAAK,EAAI,GAAG,EAAS,GAAM,IAAI,IAAI,EAAE,EAAE,EAAE,EAAK,OAA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