{"version":3,"file":"Table.Cilo_cYG.mjs","names":[],"sources":["https:/framerusercontent.com/modules/xtg1F5tBLaBMfo5MkegL/ziJAm7bghXqrG5sUBXSp/Table.js"],"sourcesContent":["// Table.framer.tsx\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";const clampCols=n=>Math.min(4,Math.max(2,Math.round(n)));export default function Table(props){const{columns,columnsCount,rows,radius,fontSize,fontFamily,lineHeight,headerBg,headerText,bodyText,borderColor,bgColor,zebra,zebraBg,zebraRows=[],compact,stickyHeader,align}=props;const colCount=clampCols(columnsCount);const shownHeaders=(columns||[]).slice(0,colCount);const cellPad=compact?\"8px 10px\":\"12px 16px\";const isRowZebra=rowIndexZeroBased=>{if(!zebra)return false;if(Array.isArray(zebraRows)&&zebraRows.length>0){return zebraRows.includes(rowIndexZeroBased+1);}return rowIndexZeroBased%2===1;};return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",borderRadius:radius,overflow:\"hidden\",background:bgColor,border:`1px solid ${borderColor}`},children:/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",overflow:\"auto\"},children:/*#__PURE__*/_jsxs(\"table\",{style:{width:\"100%\",borderCollapse:\"collapse\",fontFamily,fontSize,lineHeight:`${lineHeight}`},children:[/*#__PURE__*/_jsx(\"thead\",{style:{background:headerBg,position:stickyHeader?\"sticky\":undefined,top:stickyHeader?0:undefined,zIndex:stickyHeader?1:undefined},children:/*#__PURE__*/_jsx(\"tr\",{children:shownHeaders.map((h,i)=>/*#__PURE__*/_jsx(\"th\",{style:{textAlign:align,color:headerText,fontWeight:600,padding:cellPad,borderBottom:`1px solid ${borderColor}`,whiteSpace:\"pre-wrap\"},dangerouslySetInnerHTML:{__html:h}},i))})}),/*#__PURE__*/_jsx(\"tbody\",{children:rows.map((r,ri)=>{const bg=isRowZebra(ri)?zebraBg:\"transparent\";const cells=[r.col1,r.col2,r.col3,r.col4].slice(0,colCount);return /*#__PURE__*/_jsx(\"tr\",{style:{background:bg},children:cells.map((c,ci)=>/*#__PURE__*/_jsx(\"td\",{style:{textAlign:align,color:bodyText,padding:cellPad,borderBottom:`1px solid ${borderColor}`,verticalAlign:\"top\",whiteSpace:\"pre-wrap\"},dangerouslySetInnerHTML:{__html:c}},ci))},ri);})})]})})});}/* --------------------------- Property Controls --------------------------- */addPropertyControls(Table,{columnsCount:{title:\"欄數\",type:ControlType.Number,defaultValue:3,min:2,max:4,step:1,displayStepper:true},columns:{title:\"標題\",type:ControlType.Array,control:{type:ControlType.String,placeholder:\"欄位標題（可含 <br>）\"},defaultValue:[\"港鐵站\",\"巴士路線\",\"下車地點\"]},rows:{title:\"資料列\",type:ControlType.Array,control:{type:ControlType.Object,controls:{col1:{type:ControlType.String,title:\"Col 1\"},col2:{type:ControlType.String,title:\"Col 2 (可含 <a>)\"},col3:{type:ControlType.String,title:\"Col 3\"},col4:{type:ControlType.String,title:\"Col 4 (選填)\"}}},defaultValue:[{col1:\"牛頭角站\",col2:'<a href=\"https://www.kmb.hk/route/98\" target=\"_blank\">98</a>',col3:\"百勝角\"},{col1:\"觀塘站\",col2:'<a href=\"https://www.kmb.hk/route/98\" target=\"_blank\">98</a>',col3:\"百勝角\"},{col1:\"調景嶺站\",col2:'<a href=\"https://www.kmb.hk/route/793\" target=\"_blank\">793</a>, <a href=\"https://www.kmb.hk/route/796X\" target=\"_blank\">796X</a>, <a href=\"https://www.citybus.com.hk/route/A28\" target=\"_blank\">A28</a>',col3:\"邱氏影城\"},{col1:\"將軍澳站\",col2:'<a href=\"https://www.kmb.hk/route/290E\" target=\"_blank\">290E</a>（繁忙時段服務）',col3:\"消防及救護學院\"}]},// Style\nradius:{title:\"Radius\",type:ControlType.Number,defaultValue:10},fontSize:{title:\"字級\",type:ControlType.Number,defaultValue:15},lineHeight:{title:\"行高\",type:ControlType.Number,defaultValue:1.5},fontFamily:{title:\"字型\",type:ControlType.String,defaultValue:\"Inter, 'Noto Sans TC', sans-serif\"},headerBg:{title:\"表頭底色\",type:ControlType.Color,defaultValue:\"#0F6A57\"},headerText:{title:\"表頭文字\",type:ControlType.Color,defaultValue:\"#FFFFFF\"},bodyText:{title:\"內文文字\",type:ControlType.Color,defaultValue:\"#333333\"},borderColor:{title:\"邊框\",type:ControlType.Color,defaultValue:\"#E5E5E5\"},bgColor:{title:\"底色\",type:ControlType.Color,defaultValue:\"#FFFFFF\"},zebra:{title:\"斑馬紋\",type:ControlType.Boolean,defaultValue:true},zebraBg:{title:\"斑馬底色\",type:ControlType.Color,defaultValue:\"#F7F7F7\"},zebraRows:{title:\"指定行號\",type:ControlType.Array,control:{type:ControlType.Number},defaultValue:[]},compact:{title:\"緊湊模式\",type:ControlType.Boolean,defaultValue:false},stickyHeader:{title:\"固定表頭\",type:ControlType.Boolean,defaultValue:true},align:{title:\"對齊\",type:ControlType.Enum,options:[\"left\",\"center\",\"right\"],optionTitles:[\"靠左\",\"置中\",\"靠右\"],defaultValue:\"left\"}})/* 預設尺寸 */;Table.defaultProps={width:900,height:500};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Table\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Table.map"],"mappings":"mKACsK,SAAwB,EAAM,EAAM,CAAC,GAAK,CAAC,UAAQ,eAAa,OAAK,SAAO,WAAS,aAAW,aAAW,WAAS,aAAW,WAAS,cAAY,UAAQ,QAAM,UAAQ,YAAU,EAAE,CAAC,UAAQ,eAAa,SAAO,EAAY,EAAS,EAAU,EAAa,CAAO,GAAc,GAAS,EAAE,EAAE,MAAM,EAAE,EAAS,CAAO,EAAQ,EAAQ,WAAW,YAAkB,EAAW,GAAwB,EAAsB,MAAM,QAAQ,EAAU,EAAE,EAAU,OAAO,EAAU,EAAU,SAAS,EAAkB,EAAE,CAAS,EAAkB,GAAI,EAApI,GAAwI,OAAo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