@fileflow/sdk 0.1.26 → 0.1.27
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/{ImportWizard-C_B8FF5o.js → ImportWizard-Blk6OIRr.js} +2 -2
- package/dist/{ImportWizard-C_B8FF5o.js.map → ImportWizard-Blk6OIRr.js.map} +1 -1
- package/dist/{ImportWizard-CdHW2xzf.mjs → ImportWizard-Cg2yM2zN.mjs} +2 -2
- package/dist/{ImportWizard-CdHW2xzf.mjs.map → ImportWizard-Cg2yM2zN.mjs.map} +1 -1
- package/dist/import.js +1 -1
- package/dist/import.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
*
|
|
76
76
|
* @license MIT
|
|
77
77
|
*/function Te(e,o){return e?Vn(e)?Se.createElement(e,o):e:null}function Vn(e){return Pn(e)||typeof e=="function"||kn(e)}function Pn(e){return typeof e=="function"&&(()=>{const o=Object.getPrototypeOf(e);return o.prototype&&o.prototype.isReactComponent})()}function kn(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function bn(e){const o={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[t]=Se.useState(()=>({current:Sn(o)})),[n,r]=Se.useState(()=>t.current.initialState);return t.current.setOptions(s=>({...s,...e,state:{...n,...e.state},onStateChange:i=>{r(i),e.onStateChange==null||e.onStateChange(i)}})),t.current}const $e=({editable:e=!0,deletable:o=!0,pageSize:t=25,onCellEdit:n,onRowDelete:r})=>{const{rows:s,schema:i,mappings:a,errorsByRow:f,editingCell:c,startEditing:p,stopEditing:g,updateCell:d,deleteRow:u}=ne(),[m,h]=E.useState([]),[x,v]=E.useState(""),[C,R]=E.useState(""),$=E.useMemo(()=>a.filter(j=>j.targetKey!==null).map(j=>{const I=i==null?void 0:i.columns.find(M=>M.key===j.targetKey);return{sourceColumn:j.sourceColumn,targetKey:j.targetKey,label:(I==null?void 0:I.label)||j.targetKey,type:(I==null?void 0:I.type)||"string"}}),[a,i]),F=E.useCallback((j,I)=>{const M=f.get(j);return M==null?void 0:M.find(O=>O.columnKey===I)},[f]),V=(j,I,M)=>{R(M),p(j,I)},ee=()=>{c&&(d(c.rowIndex,c.columnKey,C),n==null||n(c.rowIndex,c.columnKey,C)),g()},D=()=>{R(""),g()},K=j=>{u(j),r==null||r(j)},Q=Lt(),A=E.useMemo(()=>[Q.accessor("rowIndex",{header:"#",size:o?80:60,cell:j=>{const I=j.getValue();return l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[l.jsx("span",{className:"ff-font-mono ff-text-xs",style:{color:"var(--ff-text-muted)"},children:I+1}),o&&l.jsx("button",{onClick:M=>{M.stopPropagation(),K(I)},title:"Delete row",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"4px",borderRadius:"4px",cursor:"pointer",color:"#8e8d89",background:"transparent",border:"none",transition:"color 0.15s, background-color 0.15s",marginLeft:"2px",flexShrink:0},onMouseEnter:M=>{M.currentTarget.style.color="#d43338",M.currentTarget.style.backgroundColor="#fcdede"},onMouseLeave:M=>{M.currentTarget.style.color="#8e8d89",M.currentTarget.style.backgroundColor="transparent"},children:l.jsx(bt,{style:{width:"14px",height:"14px",display:"block"}})})]})}}),...$.map(j=>Q.accessor(I=>I.data[j.targetKey]||I.data[j.sourceColumn],{id:j.targetKey,header:j.label,cell:I=>{const M=I.row.original.rowIndex,O=String(I.getValue()??""),H=F(M,j.targetKey);return(c==null?void 0:c.rowIndex)===M&&(c==null?void 0:c.columnKey)===j.targetKey?l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-2 ff-min-w-[280px]",children:[l.jsx("input",{type:"text",value:C,onChange:te=>R(te.target.value),onKeyDown:te=>{te.key==="Enter"&&ee(),te.key==="Escape"&&D()},className:"ff-input ff-py-2 ff-px-3 ff-text-sm ff-flex-1 ff-min-w-[160px]",autoFocus:!0}),l.jsx("button",{onClick:ee,className:"ff-btn ff-btn-primary ff-btn-sm ff-flex-shrink-0",children:"Save"}),l.jsx("button",{onClick:D,className:"ff-btn ff-btn-secondary ff-btn-sm ff-flex-shrink-0",children:"Cancel"})]}):l.jsxs("div",{className:w.clsx("ff-group ff-flex ff-items-center ff-gap-2",(H==null?void 0:H.severity)==="error"&&"ff-cell-error",(H==null?void 0:H.severity)==="warning"&&"ff-cell-warning"),children:[l.jsx("span",{className:"ff-flex-1 ff-truncate",children:O||l.jsx("span",{style:{color:"var(--ff-text-muted)"},children:"—"})}),H&&l.jsxs("div",{className:"ff-relative ff-group/tooltip",children:[H.severity==="error"?l.jsx(w.CircleAlert,{className:"ff-w-4 ff-h-4",style:{color:"var(--ff-error)"}}):l.jsx(w.TriangleAlert,{className:"ff-w-4 ff-h-4",style:{color:"var(--ff-warning)"}}),l.jsxs("div",{className:"ff-tooltip ff-bottom-full ff-left-1/2 ff-transform ff--translate-x-1/2 ff-mb-2 ff-w-48 group-hover/tooltip:ff-tooltip-visible",children:[H.message,H.suggestion&&l.jsx("span",{className:"ff-block ff-mt-1",style:{color:"var(--ff-text-muted)"},children:H.suggestion})]})]}),e&&l.jsx("button",{onClick:()=>V(M,j.targetKey,O),className:"ff-opacity-0 group-hover:ff-opacity-100 ff-p-1 ff-rounded ff-transition-opacity ff-edit-btn",children:l.jsx(Mt,{className:"ff-w-3 ff-h-3"})})]})}}))],[$,c,C,e,o,F,Q]),B=bn({data:s,columns:A,state:{sorting:m,globalFilter:x},onSortingChange:h,onGlobalFilterChange:v,getCoreRowModel:Rn(),getPaginationRowModel:Nn(),getSortedRowModel:Mn(),getFilteredRowModel:$n(),initialState:{pagination:{pageSize:t}}});return l.jsxs("div",{className:"ff-space-y-4",children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-justify-between",children:[l.jsx("input",{type:"text",value:x,onChange:j=>v(j.target.value),placeholder:"Search all columns...",className:"ff-input ff-max-w-xs"}),l.jsxs("div",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[B.getFilteredRowModel().rows.length," rows"]})]}),l.jsx("div",{className:"ff-table-container ff-max-h-[500px]",children:l.jsxs("table",{className:"ff-table",children:[l.jsx("thead",{children:B.getHeaderGroups().map(j=>l.jsx("tr",{children:j.headers.map(I=>l.jsx("th",{style:{width:I.getSize()},onClick:I.column.getToggleSortingHandler(),className:w.clsx(I.column.getCanSort()&&"ff-cursor-pointer ff-select-none"),children:l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-1",children:[Te(I.column.columnDef.header,I.getContext()),I.column.getIsSorted()&&l.jsx("span",{children:I.column.getIsSorted()==="asc"?"↑":"↓"})]})},I.id))},j.id))}),l.jsx("tbody",{children:B.getRowModel().rows.map(j=>{const I=f.has(j.original.rowIndex);return l.jsx("tr",{className:w.clsx(I&&"ff-row-error"),children:j.getVisibleCells().map(M=>l.jsx("td",{children:Te(M.column.columnDef.cell,M.getContext())},M.id))},j.id)})})]})}),l.jsxs("div",{className:"ff-flex ff-items-center ff-justify-between ff-px-2",children:[l.jsxs("div",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:["Page ",B.getState().pagination.pageIndex+1," of ",B.getPageCount()]}),l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-2",children:[l.jsxs("button",{onClick:()=>B.previousPage(),disabled:!B.getCanPreviousPage(),className:"ff-btn ff-btn-secondary ff-btn-sm",children:[l.jsx(xt,{className:"ff-w-4 ff-h-4"}),"Previous"]}),l.jsxs("button",{onClick:()=>B.nextPage(),disabled:!B.getCanNextPage(),className:"ff-btn ff-btn-secondary ff-btn-sm",children:["Next",l.jsx(w.ChevronRight,{className:"ff-w-4 ff-h-4"})]})]})]})]})},Ne=({showDetails:e=!0})=>{const{validationResults:o}=ne();if(!o)return null;const{isValid:t,totalRows:n,validRows:r,errorCount:s,warningCount:i,infoCount:a,summary:f}=o,c=Math.round(r/n*100);return l.jsxs("div",{className:"ff-space-y-4",children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-4 ff-p-4 ff-rounded-lg ff-border",style:{backgroundColor:t?"var(--ff-success-light)":"var(--ff-error-light)",borderColor:t?"var(--ff-success)":"var(--ff-error)"},children:[t?l.jsx(w.CircleCheckBig,{className:"ff-w-8 ff-h-8",style:{color:"var(--ff-success)"}}):l.jsx(w.CircleX,{className:"ff-w-8 ff-h-8",style:{color:"var(--ff-error)"}}),l.jsxs("div",{children:[l.jsx("h3",{className:"ff-text-lg ff-font-semibold",style:{color:t?"var(--ff-success-dark)":"var(--ff-error-dark)"},children:t?"Validation Passed":"Validation Failed"}),l.jsxs("p",{className:"ff-text-sm",style:{color:t?"var(--ff-success)":"var(--ff-error)"},children:[r," of ",n," rows are valid (",c,"%)"]})]})]}),l.jsxs("div",{className:"ff-grid ff-grid-cols-4 ff-gap-4",children:[l.jsxs("div",{className:"ff-border ff-rounded-lg ff-p-4 ff-text-center",style:{backgroundColor:"var(--ff-bg-primary)",borderColor:"var(--ff-border-light)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-text-primary)"},children:n}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:"Total Rows"})]}),l.jsxs("div",{className:"ff-border ff-rounded-lg ff-p-4 ff-text-center",style:{backgroundColor:"var(--ff-success-light)",borderColor:"var(--ff-success)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-success-dark)"},children:r}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-success)"},children:"Valid Rows"})]}),l.jsxs("div",{className:"ff-border ff-rounded-lg ff-p-4 ff-text-center",style:{backgroundColor:"var(--ff-error-light)",borderColor:"var(--ff-error)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-error-dark)"},children:s}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-error)"},children:"Errors"})]}),l.jsxs("div",{className:"ff-border ff-rounded-lg ff-p-4 ff-text-center",style:{backgroundColor:"var(--ff-warning-light)",borderColor:"var(--ff-warning)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-warning-dark)"},children:i}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-warning)"},children:"Warnings"})]})]}),e&&f.byColumn&&Object.keys(f.byColumn).length>0&&l.jsxs("div",{className:"ff-border ff-rounded-xl ff-overflow-hidden",style:{backgroundColor:"var(--ff-bg-primary)",borderColor:"var(--ff-border-light)"},children:[l.jsx("div",{className:"ff-px-4 ff-py-3",style:{backgroundColor:"var(--ff-bg-secondary)"},children:l.jsx("h4",{className:"ff-font-medium ff-text-sm",style:{color:"var(--ff-text-secondary)"},children:"Issues by Column"})}),l.jsx("div",{children:Object.entries(f.byColumn).filter(([,p])=>p.errorCount>0||p.warningCount>0).map(([p,g],d,u)=>l.jsxs("div",{className:"ff-flex ff-items-center ff-justify-between ff-px-4 ff-py-3",style:{borderTop:d>0?"1px solid var(--ff-border-light)":void 0},children:[l.jsxs("div",{className:"ff-flex-1 ff-min-w-0 ff-mr-4",children:[l.jsx("p",{className:"ff-font-medium ff-text-sm",style:{color:"var(--ff-text-primary)"},children:g.columnKey}),g.mostCommonError&&l.jsx("p",{className:"ff-text-sm ff-truncate",style:{color:"var(--ff-text-muted)"},children:g.mostCommonError})]}),l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-2 ff-flex-shrink-0",children:[g.errorCount>0&&l.jsxs("span",{className:"ff-badge ff-badge-error ff-whitespace-nowrap",children:[l.jsx(w.CircleX,{className:"ff-w-3 ff-h-3 ff-mr-1"}),g.errorCount," ",g.errorCount===1?"error":"errors"]}),g.warningCount>0&&l.jsxs("span",{className:"ff-badge ff-badge-warning ff-whitespace-nowrap",children:[l.jsx(w.TriangleAlert,{className:"ff-w-3 ff-h-3 ff-mr-1"}),g.warningCount," ",g.warningCount===1?"warning":"warnings"]})]})]},p))})]}),e&&f.duplicates&&f.duplicates.length>0&&l.jsx("div",{className:"ff-border ff-rounded-lg ff-p-4",style:{backgroundColor:"var(--ff-warning-light)",borderColor:"var(--ff-warning)"},children:l.jsxs("div",{className:"ff-flex ff-items-start ff-gap-3",children:[l.jsx(w.TriangleAlert,{className:"ff-w-5 ff-h-5 ff-flex-shrink-0 ff-mt-0.5",style:{color:"var(--ff-warning)"}}),l.jsxs("div",{children:[l.jsx("h4",{className:"ff-font-medium",style:{color:"var(--ff-warning-dark)"},children:"Duplicate Values Found"}),l.jsxs("ul",{className:"ff-mt-2 ff-space-y-1 ff-text-sm",style:{color:"var(--ff-warning-dark)"},children:[f.duplicates.slice(0,5).map((p,g)=>l.jsxs("li",{children:[l.jsx("span",{className:"ff-font-mono",children:p.columnKey}),': "',String(p.value),'" appears'," ",p.rowIndices.length," times (rows"," ",p.rowIndices.slice(0,3).map(d=>d+1).join(", "),p.rowIndices.length>3?"...":"",")"]},g)),f.duplicates.length>5&&l.jsxs("li",{style:{color:"var(--ff-warning)"},children:["... and ",f.duplicates.length-5," more duplicate groups"]})]})]})]})})]})},ye=["upload","mapping","validation","complete"],En=[{key:"upload",label:"Upload",icon:w.Upload},{key:"mapping",label:"Map Columns",icon:$t},{key:"validation",label:"Validate",icon:Pt},{key:"review",label:"Review",icon:St},{key:"complete",label:"Complete",icon:w.CircleCheckBig}],Ln=({template:e,schema:o,mode:t="modal",theme:n,useShadowDom:r=!1,onComplete:s,onCancel:i,onError:a})=>{const{step:f,sessionId:c,file:p,mappings:g,validationResults:d,isLoading:u,error:m,setSchema:h,setSessionId:x,setParsedData:v,setMappings:C,setUnmapped:R,setValidationResults:$,setStep:F,nextStep:V,previousStep:ee,setLoading:D,setError:K,reset:Q}=ne(),[A,B]=E.useState(null),[j,I]=E.useState(null),[M,O]=E.useState(0),[H,X]=E.useState("");E.useEffect(()=>{if(I(null),e)if(w.templateExists(e)){const _=w.getTemplateSchema(e);_?B(_):(I(`Failed to load template "${e}"`),a==null||a(new Error(`Failed to load template "${e}"`)))}else{const _=`Template "${e}" not found. Available templates: ${w.VALID_TEMPLATE_IDS.join(", ")}`;I(_),a==null||a(new Error(_))}else if(o)B(o);else{const _=`No template or schema provided. Please specify a template (${w.VALID_TEMPLATE_IDS.join(", ")}) or provide a custom schema.`;I(_),a==null||a(new Error(_))}},[e,o,a]),E.useEffect(()=>{A&&(h(A),te(A))},[A]);const te=async _=>{try{D(!0);const P=await w.getClient().createImportSession(_);x(P.sessionId)}catch(N){const P=N;K(P.message),a==null||a(P)}finally{D(!1)}},tt=_=>{const N=[];let P="",G=!1;for(let L=0;L<_.length;L++){const b=_[L];b==='"'?G&&_[L+1]==='"'?(P+='"',L++):G=!G:b===","&&!G?(N.push(P.trim()),P=""):P+=b}return N.push(P.trim()),N},nt=E.useCallback(async _=>{if(c)try{D(!0),K(null),C([]),R([],[]),$(null),O(10),X("Uploading file...");const N=w.getClient();O(20),X("Uploading to server...");const P=await N.uploadFile(c,_);O(40),X("Parsing all rows...");const L=(await _.text()).split(`
|
|
78
|
-
`).filter(Z=>Z.trim()),b=P.data.headers,U=L.slice(1).map((Z,ae)=>{const Ae=tt(Z),ze={};return b.forEach((ft,ct)=>{ze[ft]=Ae[ct]||""}),{rowIndex:ae,data:ze,rawData:Ae}});O(60),X("Processing rows..."),v({headers:b,rows:U,totalRows:U.length,sampleRows:U.slice(0,5)}),O(80),X("Matching columns..."),F("mapping"),await ot(),O(100),X("Done")}catch(N){K(`Failed to process the uploaded file: ${N.message}`)}finally{D(!1),O(0),X("")}},[c]),ot=async()=>{if(c)try{D(!0);const N=await w.getClient().matchColumns(c);C(N.mappings),R(N.unmappedSource,N.unmappedTarget)}catch(_){K(`Column matching failed: ${_.message}`)}finally{D(!1)}},rt=async()=>{if(c)try{D(!0),K(null);const N=await w.getClient().validateImport(c);$(N.validation),V()}catch(_){K(`Validation failed: ${_.message}`)}finally{D(!1)}},[be,le]=E.useState(null),[k,Ee]=E.useState(null),st=async()=>{if(c)try{D(!0),K(null),le(null);const P=await w.getClient().completeImport(c,{skipInvalidRows:!1,acknowledgeWarnings:!0}),G={...P,data:(P.data||[]).map(L=>L.data&&typeof L.data=="object"&&!Array.isArray(L.data)?{rowIndex:L.rowIndex??0,data:L.data,wasEdited:L.wasEdited??!1}:L)};Ee(G),F("complete"),s==null||s(G)}catch(_){le(_.message),F("complete")}finally{D(!1)}},ie=()=>{Q(),i==null||i()},Le=()=>{le(null),Ee(null),O(0),X(""),Q(),A&&(h(A),te(A))},lt=()=>En.findIndex(_=>_.key===f),it=()=>{switch(f){case"upload":return p!==null;case"mapping":return g.length>0&&g.some(_=>_.targetKey!==null);case"validation":return d!==null;case"review":return d!==null&&(d.isValid||d.errorCount===0);default:return!1}},at=async()=>{switch(f){case"mapping":await rt();break;case"validation":V();break;case"review":await st();break;default:V()}};if(j)return l.jsx(w.StyleProvider,{theme:n,useShadowDom:r,children:l.jsx("div",{className:"ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6",children:l.jsxs("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:[l.jsx("div",{className:"ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4",style:{backgroundColor:"var(--ff-error-light)"},children:l.jsx(w.X,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-error)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Configuration Error"}),l.jsx("p",{className:"ff-text-center ff-max-w-md ff-mb-4",style:{color:"var(--ff-text-muted)"},children:j}),i&&l.jsx("button",{onClick:ie,className:"ff-btn ff-btn-secondary",children:"Close"})]})})});if(!A)return l.jsx(w.StyleProvider,{theme:n,useShadowDom:r,children:l.jsx("div",{className:"ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6",children:l.jsxs("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:[l.jsx(w.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{style:{color:"var(--ff-text-muted)"},children:"Loading template..."})]})})});const oe=()=>{const _=f==="review"?"validation":f;return ye.indexOf(_)},ut=t==="embed"?"ff-container ff-embed":"ff-container ff-modal",De=l.jsx(l.Fragment,{children:l.jsxs("div",{className:ut,children:[l.jsxs("div",{className:"ff-modal-header",children:[l.jsxs("div",{className:"ff-modal-header-left",children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-3",children:[l.jsx("div",{className:"ff-modal-icon",children:l.jsx(_t,{})}),l.jsx("h2",{className:"ff-modal-title",children:"Import Data"})]}),l.jsx("div",{className:"ff-steps ff-ml-4",children:ye.map((_,N)=>l.jsxs(E.Fragment,{children:[l.jsx("div",{className:w.clsx("ff-step",oe()===N&&"ff-step-active",oe()>N&&"ff-step-complete",oe()<N&&"ff-step-pending"),children:oe()>N?"✓":N+1}),N<ye.length-1&&l.jsx("div",{className:w.clsx("ff-step-connector",oe()>N&&"ff-step-connector-complete")})]},_))})]}),l.jsx("button",{onClick:ie,className:"ff-modal-close",children:l.jsx(w.X,{className:"ff-w-5 ff-h-5"})})]}),l.jsxs("div",{className:"ff-modal-body",children:[m&&l.jsx("div",{className:"ff-mb-4 ff-p-4 ff-border ff-rounded-lg ff-text-sm",style:{backgroundColor:"var(--ff-error-light)",borderColor:"var(--ff-error)",color:"var(--ff-error)"},children:m}),f==="upload"&&l.jsx("div",{className:"ff-py-4",children:l.jsx("div",{className:"ff-max-w-xl ff-mx-auto",children:u&&M>0?l.jsxs("div",{className:"ff-p-8 ff-text-center",children:[l.jsx(w.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{className:"ff-font-medium ff-mb-2",style:{color:"var(--ff-text-primary)"},children:H}),l.jsx("div",{className:"ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2",children:l.jsx("div",{className:"ff-progress-bar",style:{width:`${M}%`,transition:"width 0.3s ease"}})}),l.jsxs("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[M,"% complete"]})]}):l.jsx(Be,{onFileSelect:nt})})}),f==="mapping"&&(u&&M>0?l.jsxs("div",{className:"ff-py-12 ff-text-center",children:[l.jsx(w.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{className:"ff-font-medium ff-mb-3",style:{color:"var(--ff-text-primary)"},children:H}),l.jsx("div",{className:"ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2",children:l.jsx("div",{className:"ff-progress-bar",style:{width:`${M}%`,transition:"width 0.3s ease"}})}),l.jsxs("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[M,"% complete"]})]}):l.jsx(Ke,{})),f==="validation"&&l.jsxs("div",{className:"ff-space-y-6",children:[l.jsx(Ne,{}),l.jsx($e,{editable:!0})]}),f==="review"&&l.jsxs("div",{className:"ff-space-y-6",children:[l.jsx(Ne,{showDetails:!1}),l.jsx($e,{editable:!1,pageSize:10})]}),f==="complete"&&l.jsx("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:be?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4",style:{backgroundColor:"var(--ff-error-light)"},children:l.jsx(w.X,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-error)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Import Failed"}),l.jsx("p",{className:"ff-text-center ff-max-w-md ff-mb-4",style:{color:"var(--ff-text-muted)"},children:be}),l.jsxs("div",{className:"ff-flex ff-gap-3",children:[l.jsx("button",{onClick:()=>{le(null),F("review")},className:"ff-btn ff-btn-secondary",children:"Back to Review"}),i&&l.jsx("button",{onClick:ie,className:"ff-btn ff-btn-secondary",children:"Close"})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ff-w-20 ff-h-20 ff-rounded-2xl ff-flex ff-items-center ff-justify-center ff-mb-6",style:{backgroundColor:"var(--ff-success-light)"},children:l.jsx(w.CircleCheckBig,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-success)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Import Complete!"}),l.jsx("p",{className:"ff-mb-6",style:{color:"var(--ff-text-muted)"},children:"Your data has been successfully imported."}),l.jsxs("div",{className:"ff-flex ff-gap-6 ff-mb-6",children:[l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-border-light)",backgroundColor:"var(--ff-bg-primary)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-text-primary)"},children:(k==null?void 0:k.totalRows)??(d==null?void 0:d.totalRows)??0}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:"Total Rows"})]}),l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-success)",backgroundColor:"var(--ff-success-light)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-success-dark)"},children:(k==null?void 0:k.importedRows)??(d==null?void 0:d.validRows)??0}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-success)"},children:"Imported"})]}),((k==null?void 0:k.skippedRows)??0)>0&&l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-warning)",backgroundColor:"var(--ff-warning-light)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-warning-dark)"},children:(k==null?void 0:k.skippedRows)??0}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-warning)"},children:"Skipped"})]}),l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-border-light)",backgroundColor:"var(--ff-bg-primary)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-text-primary)"},children:g.filter(_=>_.targetKey!==null).length}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:"Columns Mapped"})]})]}),(k==null?void 0:k.data)&&k.data.length>0&&(()=>{const _=k.data.slice(0,5),N=_[0],P=(N==null?void 0:N.data)||N,G=Object.keys(typeof P=="object"?P:{}).slice(0,6),L=(A==null?void 0:A.columns)||[];return G.length===0?null:l.jsxs("div",{className:"ff-w-full ff-mb-6",children:[l.jsxs("p",{className:"ff-text-xs ff-font-semibold ff-uppercase ff-tracking-wider ff-mb-2",style:{color:"var(--ff-text-muted)"},children:["Data Preview (first ",_.length," rows)"]}),l.jsx("div",{className:"ff-table-container ff-max-h-[250px]",children:l.jsxs("table",{className:"ff-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{style:{width:40},children:"#"}),G.map(b=>{const U=L.find(Z=>Z.key===b);return l.jsx("th",{children:(U==null?void 0:U.label)||b},b)}),G.length<Object.keys(typeof P=="object"?P:{}).length&&l.jsx("th",{children:"..."})]})}),l.jsx("tbody",{children:_.map((b,U)=>{const Z=(b==null?void 0:b.data)||b;return l.jsxs("tr",{children:[l.jsx("td",{children:l.jsx("span",{className:"ff-font-mono ff-text-xs",style:{color:"var(--ff-text-muted)"},children:((b==null?void 0:b.rowIndex)??U)+1})}),G.map(ae=>l.jsx("td",{children:l.jsx("span",{className:"ff-text-sm ff-truncate ff-block ff-max-w-[150px]",children:String((Z==null?void 0:Z[ae])??"—")})},ae)),G.length<Object.keys(typeof P=="object"?P:{}).length&&l.jsx("td",{children:l.jsx("span",{style:{color:"var(--ff-text-muted)"},children:"..."})})]},U)})})]})}),k.data.length>5&&l.jsxs("p",{className:"ff-text-xs ff-mt-1",style:{color:"var(--ff-text-muted)"},children:["Showing 5 of ",k.data.length," imported rows"]})]})})(),l.jsxs("div",{className:"ff-flex ff-gap-3",children:[l.jsx("button",{onClick:Le,className:"ff-btn ff-btn-primary",children:"Start New Import"}),i&&l.jsx("button",{onClick:ie,className:"ff-btn ff-btn-secondary",children:"Close"})]})]})})]}),l.jsx("div",{className:"ff-modal-footer",children:f==="complete"?l.jsxs(l.Fragment,{children:[l.jsx("div",{}),l.jsx("button",{onClick:Le,className:"ff-btn ff-btn-primary",children:"Start New Import"})]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:ee,disabled:lt()===0||u,className:"ff-btn ff-btn-ghost",children:"Back"}),l.jsx("button",{onClick:at,disabled:!it()||u,className:"ff-btn ff-btn-primary",children:u?l.jsxs(l.Fragment,{children:[l.jsx(w.LoaderCircle,{className:"ff-w-4 ff-h-4 ff-animate-spin"}),"Processing..."]}):f==="review"?"Complete Import":"Continue"})]})})]})});return l.jsx(w.StyleProvider,{theme:n,useShadowDom:r,children:t==="modal"?l.jsx("div",{className:"ff-overlay",children:De}):De})};exports.ColumnMapper=Ke;exports.DataTable=$e;exports.FileUploader=Be;exports.ImportWizard=Ln;exports.ValidationSummary=Ne;exports.useImportStore=ne;
|
|
79
|
-
//# sourceMappingURL=ImportWizard-
|
|
78
|
+
`).filter(Z=>Z.trim()),b=P.data.headers,U=L.slice(1).map((Z,ae)=>{const Ae=tt(Z),ze={};return b.forEach((ft,ct)=>{ze[ft]=Ae[ct]||""}),{rowIndex:ae,data:ze,rawData:Ae}});O(60),X("Processing rows..."),v({headers:b,rows:U,totalRows:U.length,sampleRows:U.slice(0,5)}),O(80),X("Matching columns..."),F("mapping"),await ot(),O(100),X("Done")}catch(N){K(`Failed to process the uploaded file: ${N.message}`)}finally{D(!1),O(0),X("")}},[c]),ot=async()=>{if(c)try{D(!0);const N=await w.getClient().matchColumns(c);C(N.mappings),R(N.unmappedSource,N.unmappedTarget)}catch(_){K(`Column matching failed: ${_.message}`)}finally{D(!1)}},rt=async()=>{if(c)try{D(!0),K(null);const N=await w.getClient().validateImport(c);$(N.validation),V()}catch(_){K(`Validation failed: ${_.message}`)}finally{D(!1)}},[be,le]=E.useState(null),[k,Ee]=E.useState(null),st=async()=>{if(c)try{D(!0),K(null),le(null);const P=await w.getClient().completeImport(c,{skipInvalidRows:!0,acknowledgeWarnings:!0}),G={...P,data:(P.data||[]).map(L=>L.data&&typeof L.data=="object"&&!Array.isArray(L.data)?{rowIndex:L.rowIndex??0,data:L.data,wasEdited:L.wasEdited??!1}:L)};Ee(G),F("complete"),s==null||s(G)}catch(_){le(_.message),F("complete")}finally{D(!1)}},ie=()=>{Q(),i==null||i()},Le=()=>{le(null),Ee(null),O(0),X(""),Q(),A&&(h(A),te(A))},lt=()=>En.findIndex(_=>_.key===f),it=()=>{switch(f){case"upload":return p!==null;case"mapping":return g.length>0&&g.some(_=>_.targetKey!==null);case"validation":return d!==null;case"review":return d!==null&&(d.isValid||d.errorCount===0);default:return!1}},at=async()=>{switch(f){case"mapping":await rt();break;case"validation":V();break;case"review":await st();break;default:V()}};if(j)return l.jsx(w.StyleProvider,{theme:n,useShadowDom:r,children:l.jsx("div",{className:"ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6",children:l.jsxs("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:[l.jsx("div",{className:"ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4",style:{backgroundColor:"var(--ff-error-light)"},children:l.jsx(w.X,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-error)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Configuration Error"}),l.jsx("p",{className:"ff-text-center ff-max-w-md ff-mb-4",style:{color:"var(--ff-text-muted)"},children:j}),i&&l.jsx("button",{onClick:ie,className:"ff-btn ff-btn-secondary",children:"Close"})]})})});if(!A)return l.jsx(w.StyleProvider,{theme:n,useShadowDom:r,children:l.jsx("div",{className:"ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6",children:l.jsxs("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:[l.jsx(w.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{style:{color:"var(--ff-text-muted)"},children:"Loading template..."})]})})});const oe=()=>{const _=f==="review"?"validation":f;return ye.indexOf(_)},ut=t==="embed"?"ff-container ff-embed":"ff-container ff-modal",De=l.jsx(l.Fragment,{children:l.jsxs("div",{className:ut,children:[l.jsxs("div",{className:"ff-modal-header",children:[l.jsxs("div",{className:"ff-modal-header-left",children:[l.jsxs("div",{className:"ff-flex ff-items-center ff-gap-3",children:[l.jsx("div",{className:"ff-modal-icon",children:l.jsx(_t,{})}),l.jsx("h2",{className:"ff-modal-title",children:"Import Data"})]}),l.jsx("div",{className:"ff-steps ff-ml-4",children:ye.map((_,N)=>l.jsxs(E.Fragment,{children:[l.jsx("div",{className:w.clsx("ff-step",oe()===N&&"ff-step-active",oe()>N&&"ff-step-complete",oe()<N&&"ff-step-pending"),children:oe()>N?"✓":N+1}),N<ye.length-1&&l.jsx("div",{className:w.clsx("ff-step-connector",oe()>N&&"ff-step-connector-complete")})]},_))})]}),l.jsx("button",{onClick:ie,className:"ff-modal-close",children:l.jsx(w.X,{className:"ff-w-5 ff-h-5"})})]}),l.jsxs("div",{className:"ff-modal-body",children:[m&&l.jsx("div",{className:"ff-mb-4 ff-p-4 ff-border ff-rounded-lg ff-text-sm",style:{backgroundColor:"var(--ff-error-light)",borderColor:"var(--ff-error)",color:"var(--ff-error)"},children:m}),f==="upload"&&l.jsx("div",{className:"ff-py-4",children:l.jsx("div",{className:"ff-max-w-xl ff-mx-auto",children:u&&M>0?l.jsxs("div",{className:"ff-p-8 ff-text-center",children:[l.jsx(w.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{className:"ff-font-medium ff-mb-2",style:{color:"var(--ff-text-primary)"},children:H}),l.jsx("div",{className:"ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2",children:l.jsx("div",{className:"ff-progress-bar",style:{width:`${M}%`,transition:"width 0.3s ease"}})}),l.jsxs("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[M,"% complete"]})]}):l.jsx(Be,{onFileSelect:nt})})}),f==="mapping"&&(u&&M>0?l.jsxs("div",{className:"ff-py-12 ff-text-center",children:[l.jsx(w.LoaderCircle,{className:"ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4",style:{color:"var(--ff-primary-90)"}}),l.jsx("p",{className:"ff-font-medium ff-mb-3",style:{color:"var(--ff-text-primary)"},children:H}),l.jsx("div",{className:"ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2",children:l.jsx("div",{className:"ff-progress-bar",style:{width:`${M}%`,transition:"width 0.3s ease"}})}),l.jsxs("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:[M,"% complete"]})]}):l.jsx(Ke,{})),f==="validation"&&l.jsxs("div",{className:"ff-space-y-6",children:[l.jsx(Ne,{}),l.jsx($e,{editable:!0})]}),f==="review"&&l.jsxs("div",{className:"ff-space-y-6",children:[l.jsx(Ne,{showDetails:!1}),l.jsx($e,{editable:!1,pageSize:10})]}),f==="complete"&&l.jsx("div",{className:"ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8",children:be?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4",style:{backgroundColor:"var(--ff-error-light)"},children:l.jsx(w.X,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-error)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Import Failed"}),l.jsx("p",{className:"ff-text-center ff-max-w-md ff-mb-4",style:{color:"var(--ff-text-muted)"},children:be}),l.jsxs("div",{className:"ff-flex ff-gap-3",children:[l.jsx("button",{onClick:()=>{le(null),F("review")},className:"ff-btn ff-btn-secondary",children:"Back to Review"}),i&&l.jsx("button",{onClick:ie,className:"ff-btn ff-btn-secondary",children:"Close"})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ff-w-20 ff-h-20 ff-rounded-2xl ff-flex ff-items-center ff-justify-center ff-mb-6",style:{backgroundColor:"var(--ff-success-light)"},children:l.jsx(w.CircleCheckBig,{className:"ff-w-10 ff-h-10",style:{color:"var(--ff-success)"}})}),l.jsx("h3",{className:"ff-text-xl ff-font-semibold ff-mb-2",style:{color:"var(--ff-text-primary)"},children:"Import Complete!"}),l.jsx("p",{className:"ff-mb-6",style:{color:"var(--ff-text-muted)"},children:"Your data has been successfully imported."}),l.jsxs("div",{className:"ff-flex ff-gap-6 ff-mb-6",children:[l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-border-light)",backgroundColor:"var(--ff-bg-primary)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-text-primary)"},children:(k==null?void 0:k.totalRows)??(d==null?void 0:d.totalRows)??0}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:"Total Rows"})]}),l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-success)",backgroundColor:"var(--ff-success-light)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-success-dark)"},children:(k==null?void 0:k.importedRows)??(d==null?void 0:d.validRows)??0}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-success)"},children:"Imported"})]}),((k==null?void 0:k.skippedRows)??0)>0&&l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-warning)",backgroundColor:"var(--ff-warning-light)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-warning-dark)"},children:(k==null?void 0:k.skippedRows)??0}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-warning)"},children:"Skipped"})]}),l.jsxs("div",{className:"ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border",style:{borderColor:"var(--ff-border-light)",backgroundColor:"var(--ff-bg-primary)"},children:[l.jsx("p",{className:"ff-text-2xl ff-font-bold",style:{color:"var(--ff-text-primary)"},children:g.filter(_=>_.targetKey!==null).length}),l.jsx("p",{className:"ff-text-sm",style:{color:"var(--ff-text-muted)"},children:"Columns Mapped"})]})]}),(k==null?void 0:k.data)&&k.data.length>0&&(()=>{const _=k.data.slice(0,5),N=_[0],P=(N==null?void 0:N.data)||N,G=Object.keys(typeof P=="object"?P:{}).slice(0,6),L=(A==null?void 0:A.columns)||[];return G.length===0?null:l.jsxs("div",{className:"ff-w-full ff-mb-6",children:[l.jsxs("p",{className:"ff-text-xs ff-font-semibold ff-uppercase ff-tracking-wider ff-mb-2",style:{color:"var(--ff-text-muted)"},children:["Data Preview (first ",_.length," rows)"]}),l.jsx("div",{className:"ff-table-container ff-max-h-[250px]",children:l.jsxs("table",{className:"ff-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{style:{width:40},children:"#"}),G.map(b=>{const U=L.find(Z=>Z.key===b);return l.jsx("th",{children:(U==null?void 0:U.label)||b},b)}),G.length<Object.keys(typeof P=="object"?P:{}).length&&l.jsx("th",{children:"..."})]})}),l.jsx("tbody",{children:_.map((b,U)=>{const Z=(b==null?void 0:b.data)||b;return l.jsxs("tr",{children:[l.jsx("td",{children:l.jsx("span",{className:"ff-font-mono ff-text-xs",style:{color:"var(--ff-text-muted)"},children:((b==null?void 0:b.rowIndex)??U)+1})}),G.map(ae=>l.jsx("td",{children:l.jsx("span",{className:"ff-text-sm ff-truncate ff-block ff-max-w-[150px]",children:String((Z==null?void 0:Z[ae])??"—")})},ae)),G.length<Object.keys(typeof P=="object"?P:{}).length&&l.jsx("td",{children:l.jsx("span",{style:{color:"var(--ff-text-muted)"},children:"..."})})]},U)})})]})}),k.data.length>5&&l.jsxs("p",{className:"ff-text-xs ff-mt-1",style:{color:"var(--ff-text-muted)"},children:["Showing 5 of ",k.data.length," imported rows"]})]})})(),l.jsxs("div",{className:"ff-flex ff-gap-3",children:[l.jsx("button",{onClick:Le,className:"ff-btn ff-btn-primary",children:"Start New Import"}),i&&l.jsx("button",{onClick:ie,className:"ff-btn ff-btn-secondary",children:"Close"})]})]})})]}),l.jsx("div",{className:"ff-modal-footer",children:f==="complete"?l.jsxs(l.Fragment,{children:[l.jsx("div",{}),l.jsx("button",{onClick:Le,className:"ff-btn ff-btn-primary",children:"Start New Import"})]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:ee,disabled:lt()===0||u,className:"ff-btn ff-btn-ghost",children:"Back"}),l.jsx("button",{onClick:at,disabled:!it()||u,className:"ff-btn ff-btn-primary",children:u?l.jsxs(l.Fragment,{children:[l.jsx(w.LoaderCircle,{className:"ff-w-4 ff-h-4 ff-animate-spin"}),"Processing..."]}):f==="review"?"Complete Import":"Continue"})]})})]})});return l.jsx(w.StyleProvider,{theme:n,useShadowDom:r,children:t==="modal"?l.jsx("div",{className:"ff-overlay",children:De}):De})};exports.ColumnMapper=Ke;exports.DataTable=$e;exports.FileUploader=Be;exports.ImportWizard=Ln;exports.ValidationSummary=Ne;exports.useImportStore=ne;
|
|
79
|
+
//# sourceMappingURL=ImportWizard-Blk6OIRr.js.map
|