@ingestro/importer-react 4.9.3 → 4.9.5
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/{chunk-F2V7OQWG.js → chunk-ET4YM2J3.js} +1 -1
- package/chunk-FJK35UW2.js +1 -0
- package/{chunk-FVCICCC3.js → chunk-LROANN4K.js} +48 -48
- package/chunk-YNRGLIVA.js +1 -0
- package/index.d.ts +87 -2
- package/index.js +729 -701
- package/package.json +1 -1
- package/workers/matchValues/index.js +1 -1
- package/workers/parseData/index.js +1 -1
- package/workers/searchAndReplace/index.js +1 -1
- package/chunk-FRFILSYE.js +0 -1
- package/chunk-NPXJPUQJ.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as se,i as q,j as g,r as J}from"./chunk-FJK35UW2.js";import{G as pe,H as j,I as Y,K as W,L as H,M as $,b as ie,c as le,d as S,k as ue,l as p,m as M,n as _,u as me,v as de,w as E,x as he}from"./chunk-LROANN4K.js";import{b as D}from"./chunk-REPANPD5.js";import{isEmpty as He,uniq as $e}from"lodash";var ce=0,G=class{constructor({sheet:e,columnKey:t,rows:r,id:n,label:a,refJoinSheetColum:s,parserDateFormat:i}){this.removed=!1;this.label="";this.dateInputFormatSamples=null;this.parsedDateSamplesByInputFormat=new Map;this.getColumnKey=()=>this.columnKey;this.getId=()=>this.id;this.getSheet=()=>this.sheet;this.getRows=()=>this.rows;this.getUniqueRows=()=>(this.uniques===void 0&&(this.uniques=$e(this.getRows())),this.uniques);this.remove=()=>{this.removed=!0};this.unRemove=()=>{this.removed=!1};this.isRemoved=()=>this.removed;this.getType=()=>0;this.getFileName=()=>this.sheet.getSheetFileName();this.toJSON=()=>({columnKey:this.columnKey,id:this.id,rows:this.rows,type:this.getType()});this.equal=e=>this.getId()===e.getId();this.keyEqual=e=>this.columnKey===e.columnKey;this.setIndex=e=>{this.index=e};this.getIndex=()=>this.index;this.normalizeInputFormatKey=e=>{let t=typeof e=="string"?e.trim():"";return t!==""?t:null};this.dateInputFormatCacheKey=e=>this.normalizeInputFormatKey(e)??"\0auto";this.needsDateFormatParse=e=>!this.parsedDateSamplesByInputFormat.has(this.dateInputFormatCacheKey(e));this.hasParsedDateForInputFormat=e=>!this.needsDateFormatParse(e);this.getParsedDateSamplesForInputFormat=e=>this.parsedDateSamplesByInputFormat.get(this.dateInputFormatCacheKey(e));this.getDateInputFormatSamples=()=>this.dateInputFormatSamples??this.rows;this.getParserDateFormat=()=>this.parserDateFormat;this.applyDateInputFormatParse=(e,t)=>{let r=this.getDateInputFormatSamples();if(e.length!==r.length)throw new Error(`SheetColumn.applyDateInputFormatParse: parsed sample count (${e.length}) must match source sample count (${r.length}) for column "${this.columnKey}".`);this.parsedDateSamplesByInputFormat.set(this.dateInputFormatCacheKey(t),e)};this.getRefJoinSheetColum=()=>this.refJoinSheetColum;this.columnKey=t.trim(),this.sheet=e,Object.defineProperty(this,"sheet",{value:e,enumerable:!1,writable:!0,configurable:!0}),this.rows=He(r)?[""]:r,this.dateInputFormatSamples=[...this.rows],typeof n>"u"?(ce++,this.id=`${t}-${ce}`):this.id=n,a&&(this.label=a),i&&(this.parserDateFormat=i),Object.defineProperty(this,"refJoinSheetColum",{value:s,enumerable:!1,writable:!0,configurable:!0})}setRows(e){this.rows=e,this.uniques=void 0}},C=G;var Q=class extends C{constructor({sheet:t,sheetColumns:r,rows:n,id:a,columnKey:s}){super({columnKey:s,rows:n,sheet:t,id:a});this.getType=()=>1;this.getJoinedSheetColumns=()=>this.sheetColumns;this.toJSON=()=>({columnKey:this.columnKey,id:this.id,rows:this.rows,sheetColumns:this.sheetColumns.map(t=>t.toJSON()),type:this.getType()});this.sheetColumns=r}},fe=Q;var ge=["?",",","@"];import{isNaN as Ke,minBy as Ue,isString as Le,isEqual as Be,isEmpty as ye,isNil as ze}from"lodash";var ee=class{constructor({sheets:e,filename:t,type:r,fileSize:n}){this.globalNumberFormat="eu";this.columnsNumberFormat=[];this.needsConfiguration=!1;this.pendingXmlConfigKey=null;this.pendingXmlConfig=null;this.sourceXml=null;this.sourcePdfFile=null;this.pdfDocument=null;this.selectedPdfTableIds=null;this.keepSheetSelection=!1;this.addSheet=e=>{this.sheets.push(e)};this.setNeedsConfiguration=e=>{this.needsConfiguration=e};this.getNeedsConfiguration=()=>this.needsConfiguration;this.setPendingXmlConfigKey=e=>{this.pendingXmlConfigKey=e};this.getPendingXmlConfigKey=()=>this.pendingXmlConfigKey;this.setPendingXmlConfig=e=>{this.pendingXmlConfig=e};this.getPendingXmlConfig=()=>this.pendingXmlConfig;this.setSourceXml=e=>{this.sourceXml=e};this.getSourceXml=()=>this.sourceXml;this.setSourcePdfFile=e=>{this.sourcePdfFile=e};this.getSourcePdfFile=()=>this.sourcePdfFile;this.setPdfDocument=e=>{this.pdfDocument=e};this.getPdfDocument=()=>this.pdfDocument;this.setSelectedPdfTableIds=e=>{this.selectedPdfTableIds=e};this.getSelectedPdfTableIds=()=>this.selectedPdfTableIds;this.setKeepSheetSelection=e=>{this.keepSheetSelection=e};this.getKeepSheetSelection=()=>this.keepSheetSelection;this.replaceSheets=e=>{let t=this.needsConfiguration||!!this.pendingXmlConfigKey||!!this.pendingXmlConfig||!!this.sourceXml,r=!!this.sourcePdfFile||!!this.pdfDocument;this.sheets=e,this.sheets.forEach(n=>{n.setSpreadSheet(this)}),this.needsConfiguration=!1,this.pendingXmlConfigKey=null,t?this.keepSheetSelection=!0:r||(this.pendingXmlConfig=null,this.sourceXml=null),r&&(this.keepSheetSelection=!0)};this.isSelected=()=>{for(let e=0;e<this.sheets.length;e++)if(this.sheets[e].isSelected())return!0;return!1};this.getSheets=()=>this.sheets;this.getSelectedSheets=()=>this.sheets.filter(e=>e.isSelected());this.getFilename=()=>this.filename;this.selectAllSheet=e=>this.sheets.forEach(t=>{t.setSelected(e)});this.getType=()=>this.type;this.setType=e=>{this.type=e};this.getFileSize=()=>{let e=this.fileSize/1e6;return Number(parseFloat(`${e}`).toFixed(4))};this.sheets=e,this.filename=t,this.type=r,this.fileSize=n??0,this.sheets.forEach(a=>{a.setSpreadSheet(this)})}setNumberFormat(e){this.globalNumberFormat=e.global,this.columnsNumberFormat=e.columns}getNumberFormat(){return{global:this.globalNumberFormat,columns:this.columnsNumberFormat}}},Se=ee;var Je={dmy:"D/M/YYYY",us:"M/D/YY",de:"DD.MM.YYYY"},Ce=(o,e)=>o?de(o,E(e)):void 0,Fe=o=>{let e=E(o);return e==="os"?me():Je[e]},Nt=({data:o,excelDateCells:e,columnDateFormats:t,maxRow:r=50,maxCol:n=300})=>{let a=Math.min(o.length,r),s=o.slice(0,a).map(i=>i.slice(0,n));return he(s,e,i=>E(t?.[i]))};var Me=0,te=class{constructor({data:e,name:t,isNotSetColumn:r,id:n,columnDateFormats:a,excelDateCells:s}){this.selected=!1;this.isManualSelectHeader=!1;this.columns=[];this.columnsInitialized=!1;this.headerRowIndex=0;this.transposed=!1;this.headerRowIndexes=[];this.addedColumns=[];this.usedSourceCells=new Set;this.mergedHeadersActive=!1;this.mergedRowsBackup=null;this.availableRows=null;this.spreadSheet=new Se({filename:"",sheets:[],type:"xlsx",fileSize:0});this.getId=()=>this.id;this.setSpreadSheet=e=>{this.spreadSheet=e};this.getSpreadSheet=()=>this.spreadSheet;this.setSelected=e=>{this.selected=e};this.isSelected=()=>this.selected;this.setHeaderRowIndex=e=>{this.headerRowIndex=e,this.columnsInitialized=!1,this.mergedHeadersActive||(this.headerRowIndexes=[e])};this.setTransposed=e=>{this.transposed=e};this.getTransposed=()=>this.transposed;this.setHeaderRowIndexes=e=>{this.headerRowIndexes=[...e]};this.getHeaderRowIndexes=()=>this.headerRowIndexes.length>0?this.headerRowIndexes:[this.headerRowIndex];this.addAddedColumn=e=>{if(this.addedColumns.push(e),e.sourceCell){let n=`${e.sourceCell.row},${e.sourceCell.col}`;this.usedSourceCells.add(n)}let t=this.data[this.headerRowIndex],r=this.data.length>0?Math.max(...this.data.map(n=>n.length)):0;t&&t.push(e.columnName);for(let n=0;n<this.data.length;n++)if(n!==this.headerRowIndex){for(;this.data[n].length<r;)this.data[n].push("");n<this.headerRowIndex?this.data[n].push(""):this.data[n].push(e.value)}this.setColumns()};this.removeAddedColumn=e=>{let r=(this.data[this.headerRowIndex]?.length||0)-this.addedColumns.length,n=e-r;if(n<0||n>=this.addedColumns.length)return;let a=this.addedColumns[n];if(a?.sourceCell){let s=`${a.sourceCell.row},${a.sourceCell.col}`;this.usedSourceCells.delete(s)}for(let s=0;s<this.data.length;s++)this.data[s].splice(e,1);this.addedColumns.splice(n,1),this.setColumns()};this.removeColumnFromData=e=>{if(!(e<0)){for(let t=0;t<this.data.length;t++)this.data[t].length>e&&this.data[t].splice(e,1);this.columnDateFormats=void 0,this.excelDateCells=void 0}};this.clearAddedColumns=()=>{if(this.addedColumns.length>0){let t=(this.data[this.headerRowIndex]?.length||0)-this.addedColumns.length;for(let r=this.addedColumns.length-1;r>=0;r--){let n=t+r;for(let a=0;a<this.data.length;a++)this.data[a].length>n&&this.data[a].splice(n,1)}}this.addedColumns=[],this.usedSourceCells.clear(),this.setColumns()};this.isSourceCellUsed=(e,t)=>{let r=`${e},${t}`;return this.usedSourceCells.has(r)};this.getAddedColumnBySourceCell=(e,t)=>this.addedColumns.find(r=>r.sourceCell&&r.sourceCell.row===e&&r.sourceCell.col===t);this.getAddedColumns=()=>this.addedColumns;this.setMergedHeadersActive=e=>{this.mergedHeadersActive=e};this.isMergedHeadersActive=()=>this.mergedHeadersActive;this.setMergedRowsBackup=e=>{this.mergedRowsBackup=e};this.getMergedRowsBackup=()=>this.mergedRowsBackup;this.setAvailableRows=e=>{this.availableRows=e};this.getAvailableRows=()=>this.availableRows;this.isLoneWhitelistCharacter=e=>{let t=e.toString()?.trim()??"";return ge.some(r=>t===r)};this.isSignificantCell=e=>!ye(e)&&!this.isLoneWhitelistCharacter(e);this.collapseAdjacentDuplicates=e=>e.filter((t,r)=>r===0||`${t}`!=`${e[r-1]}`);this.getSignificantCells=e=>{let t=(e??[]).filter(this.isSignificantCell);return this.collapseAdjacentDuplicates(t)};this.getDataTransform=()=>this.data.map((e,t)=>({data:e,index:t,length:this.getSignificantCells(e).length}));this.getMaxLengthColumns=()=>this.getDataTransform().reduce((t,r)=>Math.max(t,r.length),0);this.isHeaderLikeCell=e=>!se.includes(Le(e)?e.toLowerCase():e)&&Ke(Number(e));this.countHeaderLikeCells=e=>this.getSignificantCells(e).filter(this.isHeaderLikeCell).length;this.setHeaderByAutoDetection=()=>{let t=this.getMaxLengthColumns(),r=this.getDataTransform().slice(0,50).filter(a=>a.length===t&&this.countHeaderLikeCells(a.data)===t),n=r.length===1?r[0].index:Ue(r,a=>a.length)?.index??0;this.setHeaderRowIndex(n)};this.getHeaderRowIndex=()=>this.headerRowIndex;this.getHeaderRow=()=>this.data[this.headerRowIndex]?.filter(e=>!!e);this.getColumns=()=>(this.ensureColumnsBuilt(),this.columns.filter(e=>!e.isRemoved()));this.getSortedColumns=()=>[...this.getColumns()].sort((e,t)=>D(e.getColumnKey())<D(t.getColumnKey())?-1:D(e.getColumnKey())>D(t.getColumnKey())?1:0);this.getColumnsWithRemoved=()=>(this.ensureColumnsBuilt(),this.columns.filter(e=>e.getType()!==1));this.getColumn=(e,t)=>(this.ensureColumnsBuilt(),this.columns.find(r=>t?D(r.getColumnKey())===D(`${e}`):r.getColumnKey()===e));this.getColumnsByKey=(e,t)=>(this.ensureColumnsBuilt(),this.columns.filter(r=>t?D(r.getColumnKey())===D(`${e}`):r.getColumnKey()===e));this.getValues=()=>{let e=this.data.filter((r,n)=>n>this.headerRowIndex);if(ye(e))return[[]];let t=[];for(let r=0;r<e.length;r++){let n=[];for(let a=0;a<this.data[this.headerRowIndex].length;a++)ze(this.data[this.headerRowIndex][a])||n.push(this.parseValue(e[r][a]));t.push(n)}return t};this.getData=()=>this.data;this.getExcelDateCells=()=>this.excelDateCells;this.getColumnDateFormats=()=>this.columnDateFormats;this.getName=()=>this.name;this.getDisplayName=({t:e})=>{if(this.getName()?.length>0)return this.getName();switch(this.spreadSheet.getType()){case"json":return`${e("txt_default_sheet_prefix_name")} 1`;case"csv":return`${e("txt_default_sheet_prefix_name")} 1`;default:return""}};this.getSheetFileName=()=>`${this.spreadSheet.getFilename()}`;this.getIsManualSelectHeader=()=>this.isManualSelectHeader;this.setIsManualSelectHeader=()=>{this.isManualSelectHeader=!0};this.clearIsManualSelectHeader=()=>{this.isManualSelectHeader=!1};this.addColumn=e=>{this.ensureColumnsBuilt(),this.columns.push(new C({columnKey:`${e}`,sheet:this,rows:this.getRowsByColumnIndex(this.getColumnIndex(e))}))};this.removeColumn=e=>{this.ensureColumnsBuilt(),this.columns.find(t=>t.getColumnKey()===e)?.remove()};this.removeColumnByIndex=e=>{this.ensureColumnsBuilt(),this.columns.find((t,r)=>r===e)?.remove()};this.setData=e=>{this.data=e,this.columnDateFormats=void 0,this.excelDateCells=void 0};this.toJSON=()=>({name:this.name,id:this.id,type:this.getType(),values:this.getValues(),headerRow:this.getHeaderRow()});this.equal=e=>this.id===e.getId();this.getType=()=>0;this.getRowsByColumnIndex=e=>{if(e===-1)return[];let t=[],r=this.columnDateFormats?.[e];for(let n=0;n<this.data.length;n++){let a=this.data[n];if(n>this.headerRowIndex){let s=a[e]??"",i=Ce(this.excelDateCells?.[`${n},${e}`],r);t.push(i??this.parseValue(s))}}return t};this.getExcelDisplayInputFormat=e=>{if(!this.excelDateCells)return;let t=!1;for(let r=this.headerRowIndex+1;r<this.data.length;r++)if((this.data[r]?.[e]??"")!==""){if(!this.excelDateCells[`${r},${e}`])return;t=!0}return t?Fe(this.columnDateFormats?.[e]):void 0};this.ensureColumnsBuilt=()=>{this.columnsInitialized||this.setColumns()};this.setColumns=()=>{let e=this.data[this.headerRowIndex];if(e){let t=[];for(let r=0;r<e.length;++r){let n=e[r];n&&t.push(new C({columnKey:`${n}`,sheet:this,rows:this.getRowsByColumnIndex(r),parserDateFormat:this.columnDateFormats?.[r]??this.getExcelDisplayInputFormat(r)}))}this.columns=t}else this.columns=[];this.columnsInitialized=!0};this.getColumnIndex=e=>this.data[this.headerRowIndex].findIndex(n=>Be(`${n}`,`${e}`));this.parseValue=e=>typeof e=="string"?e.trim():e;this.data=e,this.name=t,this.columnDateFormats=a,this.excelDateCells=s,typeof n>"u"?(Me++,this.id=`${t}-${Me}`):this.id=n,this.columnsInitialized=!!r}},Ie=te;var re=class extends Ie{constructor({joinedData:t,sheets:r,mappings:n,mappingIndexes:a}){super({data:t.data,name:"join-sheet",isNotSetColumn:!0});this.sheets=[];this.joinHistory=[];this.findRefJoinSheetColumn=t=>{let r=this.sheets.length===2?this.sheets[0]:this,n=this.sheets[this.sheets.length-1];if(t<r.getColumns().length)return r.getColumns()[t];let a=t-r.getColumns().length;return n.getColumns().filter((s,i)=>this.joinHistory[this.joinHistory.length-1].mappingIndexes.every(l=>l.target!==i))[a]};this.setJoinColumns=(t,r)=>{let n=this.data[this.headerRowIndex];if(!n){this.columns=[];return}let a=[];for(let s=0;s<n.length;++s){let i=n[s],l=r.findIndex(u=>u.source===s),m=this.columns[s]&&this.columns[s].getType()===1;if(l>=0||m){let u=t[l],d;m&&l>=0?d=[...this.columns[s].getJoinedSheetColumns(),u.target]:m?d=this.columns[s].getJoinedSheetColumns():d=[u.source.getRefJoinSheetColum()??u.source,u.target],a.push(new fe({columnKey:`${i}`,sheetColumns:d,sheet:this,rows:this.getRowsByColumnIndex(s)}))}else{let u=this.columns[s]?this.columns[s].getRefJoinSheetColum()??this.columns[s]:this.findRefJoinSheetColumn(s);a.push(new C({columnKey:`${i}`,sheet:u.getSheet(),rows:this.getRowsByColumnIndex(s),refJoinSheetColum:u}))}}this.columns=a};this.getJoinedSheets=()=>this.sheets;this.getType=()=>1;this.joinSheet=(t,r,n,a)=>{this.setData(t.data),this.sheets.push(r),this.joinHistory.push({mappingIndexes:a,type:t.type,row:t.data.length,col:this.data[this.headerRowIndex]?.length??0}),this.setJoinColumns(n,a)};this.getJoinColumns=()=>this.columns.filter(t=>t.getType()===1);this.getJoinHistory=()=>this.joinHistory;this.headerRowIndex=0,this.joinHistory.push({mappingIndexes:a,type:t.type,row:t.data.length,col:this.data[this.headerRowIndex]?.length??0}),this.sheets=r,this.setJoinColumns(n,a)}},Bt=re;var xe=({rowA:o,rowB:e},t)=>t.every(r=>{let n=`${o[r.source]??""}`,a=`${e[r.target]??""}`;return n===a&&n!==""&&a!==""}),Xe=(o,e,t)=>{let r=[],n=o.headerRow,a=e.headerRow;for(let s=0;s<n.length;++s)r.push(n[s]);for(let s=0;s<a.length;++s)t.every(i=>i.target!==s)&&r.push(a[s]);return r},qt=async(o,e)=>{let t=o.values,r=e.values,n=o.headerRow,a=e.headerRow,s=[...n,...a],i=[];i.push(s);for(let l=0;l<t.length;++l)i.push([...t[l],...r[0]]);return{data:i,type:"ADD_TO_ALL_ROWS"}},Gt=async(o,e)=>{let t=o.values,r=e.values,n=o.headerRow,a=e.headerRow,s=[...n,...a],i=[];i.push(s);for(let l=0;l<t.length;++l)i.push([...t[l],...a.map(()=>"")]);for(let l=0;l<r.length;++l)i.push([...n.map(()=>""),...r[l]]);return{data:i,type:"JOIN_WITHOUT_COLUMNS"}},Zt=async(o,e,t)=>{let r=o.values,n=e.values,a=[],s=[],i={},l=Xe(o,e,t);a.push(l);for(let m=0;m<r.length;++m){let u=!1,d=r[m];for(let h=0;h<n.length;++h){let c=n[h];xe({rowA:d,rowB:c},t)&&(i[h]=!0,u=!0,a.push([...d,...c.filter((f,O)=>t.every(P=>P.target!==O))]))}u||s.push([...d,...e.headerRow.filter((h,c)=>t.every(f=>f.target!==c)).map(()=>"")])}for(let m=0;m<n.length;++m){if(i[m])continue;let u=n[m],d=o.headerRow.map(()=>"");t.forEach(h=>{d[h.source]=u[h.target]}),s.push([...d,...u.filter((h,c)=>t.every(f=>f.target!==c))])}return s.forEach(m=>{a.push(m)}),{data:a,type:"JOIN_ON_COLUMNS"}},Qt=async(o,e,t)=>{let r=e.headerRow.filter((i,l)=>t.every(m=>m.target!==l)),a=[[...o.headerRow,...r]];for(let i=0;i<o.values.length;++i){let l=[...o.values[i],...r.map(()=>"")];a.push(l)}let s=e.values;for(let i=0;i<s.length;++i){let l=o.headerRow.map(()=>""),m=[];for(let u=0;u<e.headerRow.length;++u){let d=t.find(h=>h.target===u);d?l[d.source]=s[i][u]:m.push(s[i][u])}a.push([...l,...m])}return{data:a,type:"APPEND_TO_COLUMNS"}},er=async(o,e,t)=>{let r=o.values,n=e.values,a=r.length+n.length,s=0,i={};for(let l=0;l<r.length;l++){let m=r[l],u=null,d=0;for(let h=0;h<n.length;h++){let c=n[h];if(xe({rowA:m,rowB:c},t)&&(u=h,d++,d===2))break}d===1&&u!==null&&(s+=1,i[u]=!0)}for(let l=0;l<n.length;l++)i[l]&&(s+=1);return{count:s,total:a}};import{isNil as pt}from"lodash";var Te=o=>o.some(e=>typeof e=="string"&&p(e)&&!S(e.trim())),F=o=>!Te(o)&&!o.some(e=>typeof e=="boolean"),I=o=>o.filter(e=>typeof e=="string"&&p(e)&&!S(e.trim())),je=(o,e)=>{let t=e?.trim();return t||(F(o),"")};var x=/T\d{1,2}:\d{2}(:\d{2})?(\.\d+)?/i,k=/\b\d{1,2}:\d{2}(:\d{2})?(\.\d+)?(\s*[AaPp][Mm])?\b/,We=/\s+\d{1,2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:\s*[AaPp][Mm])?(?:Z|[+-](?:[01]\d|2[0-3])(?::?[0-5]\d)?)?\s*$/i,K=/\b[AaPp][Mm]\b/,qe=/\d{1,2}:\d{2}:\d{2}\.(\d+)/;var U=o=>o.match(qe)?.[1]?.length??0,we=o=>o<=0||o>9?"":`.${"S".repeat(o)}`,b=o=>{let e=o.trim();return x.test(e)?e.split(/T/i)[0]??"":e.replace(We,"")};var Ge=/^\d{4}([/.\- ])\d{1,2}\1\d{1,2}$/,Ze=/^\d{1,2}([/.\- ])\d{1,2}\1(?:\d{2}|\d{4})$/;var be=o=>{let e=!1,t=!1;for(let r of o){if(typeof r!="string"||!p(r))continue;let n=b(r);if(Ge.test(n)){e=!0;continue}Ze.test(n)&&(t=!0)}return{sawYearFirst:e,sawDayOrMonthFirst:t}},T=o=>{let{sawYearFirst:e,sawDayOrMonthFirst:t}=be(o);return e&&!t},Re=o=>{let{sawYearFirst:e,sawDayOrMonthFirst:t}=be(o);return e&&t};var L=o=>o?"D":"DD",B=o=>o?"M":"MM";var et=o=>{let e=U(o),t=e>0||/\d{1,2}:\d{2}:\d{2}/.test(o),r=o.match(/(?:[T\s]|^)(\d{1,2}):\d{2}/i)?.[1]??"";return{isoT:x.test(o),seconds:t,fractionDigits:e,timezone:Y(o),meridiem:K.test(o),unpaddedHour:r.length===1,paddedHour:r.length===2&&r.startsWith("0")}},tt=(o,e)=>o.isoT===e.isoT&&o.seconds===e.seconds&&o.fractionDigits===e.fractionDigits&&o.timezone===e.timezone&&o.meridiem===e.meridiem;var rt=o=>{let e=[];for(let t of o){if(typeof t!="string"||!p(t))continue;let r=pe(b(t));r&&(e.includes(r)||e.push(r))}return e},y=o=>{let e=!1,t=!1,r=null,n=!1,a=!1;for(let s of o){if(typeof s!="string"||!p(s))continue;let i=s.trim();if(!(x.test(i)||k.test(i))){if(e=!0,t)return!0;continue}if(t=!0,e)return!0;let u=et(i);if(u.fractionDigits>9)return!0;if(u.unpaddedHour&&(n=!0),u.paddedHour&&(a=!0),!r){r=u;continue}if(!tt(r,u))return!0}return!!(n&&a)};var R=o=>{if(y(o))return"";let e=!1,t=!1,r=!1,n=!1,a=0,s=!1,i=!1;for(let c of o){if(typeof c!="string"||!p(c))continue;let f=c.trim(),O=x.test(f);if(!O&&!k.test(f))continue;e=!0,O&&(t=!0),K.test(f)&&(r=!0);let P=U(f);P>0?(n=!0,a=P):/\d{1,2}:\d{2}:\d{2}/.test(f)&&(n=!0),Y(f)&&(s=!0),(f.match(/(?:[T\s]|^)(\d{1,2}):\d{2}/i)?.[1]??"").length===1&&(i=!0)}if(!e)return"";let l=t?"[T]":" ",m=r?i?"h":"hh":i?"H":"HH",u=r?" A":"",d=we(a),h=s?"Z":"";return n?`${l}${m}:mm:ss${d}${u}${h}`:`${l}${m}:mm${u}${h}`},w=(o,e)=>{let t=o.trim();if(!t||/[Hh]/.test(t))return t;let r=R(e);return r?`${t}${r}`:t};var z=(o,e="",t={firstUnpadded:!1,secondUnpadded:!1})=>`YYYY${o}${B(t.firstUnpadded)}${o}${L(t.secondUnpadded)}${e}`,N=(o,e,t="",r="YYYY",n={firstUnpadded:!1,secondUnpadded:!1})=>`${o==="dM"?[L(n.firstUnpadded),B(n.secondUnpadded),r].join(e):[B(n.firstUnpadded),L(n.secondUnpadded),r].join(e)}${t}`,Ne=(o,e="",t="YYYY",r={firstUnpadded:!1,secondUnpadded:!1})=>({dayFirst:N("dM",o,e,t,r),monthFirst:N("Md",o,e,t,r)}),Ve=["/","-","."],ot=(o="",e="YYYY",t={firstUnpadded:!1,secondUnpadded:!1},r=Ve)=>{let n=[];for(let a of r){let{dayFirst:s,monthFirst:i}=Ne(a,o,e,t);n.push(s,i)}return n};var nt=o=>o.every(e=>typeof e!="number"&&(typeof e!="string"||!p(e))),V=({colType:o,inputFormat:e,samples:t,parserDateFormat:r})=>{if(!_(o))return null;if(M(e))return"configured";if(r?.trim())return"detected";if(F(t))return nt(t)?"detected":"undetected";let n=I(t);return y(n)||Re(n)?"undetected":T(n)?"detected":H(n)===null?"undetected":"detected"},at=o=>o.getDateFormatPromptResolved?.()??o.getDeclaredInputFormat?.(),oe=o=>o.getDateFormatPromptResolved?.()??(typeof o.getDeclaredInputFormat=="function"?o.getDeclaredInputFormat():o.getInputFormat()),st=o=>o.some(e=>{let t=e.matchedDataModel?.dataModel;return!t||!e.sheetColumn?!1:V({colType:t.getType(),inputFormat:oe(t),samples:e.sheetColumn.getDateInputFormatSamples(),parserDateFormat:e.sheetColumn.getParserDateFormat?.()})==="undetected"});var X={firstUnpadded:!1,secondUnpadded:!1},ve=({colType:o,inputFormat:e,samples:t,parserDateFormat:r})=>{let n=V({colType:o,inputFormat:e,samples:t,parserDateFormat:r}),a=I(t);if(n==="configured")return w((e??"").trim(),a);if(n!=="detected")return"";let s=r?.trim();if(s)return s;let i=R(a),l=j(a);if(T(a))return z(l,i,X);let m=H(a);return m!=="dM"&&m!=="Md"?"":N(m,l,i,"YYYY",X)},it=(o,e)=>{o.forEach(t=>{let r=t.matchedDataModel?.dataModel;if(!r?.setInputFormat||!t.sheetColumn)return;let n=r.getType(),a=oe(r),s=t.sheetColumn.getDateInputFormatSamples(),i=t.sheetColumn.getParserDateFormat?.(),l=I(s),m=V({colType:n,inputFormat:a,samples:s,parserDateFormat:i});if(!m)return;let u=e?.getChosenFormat?.(t)?.trim()||"",d=u||ve({colType:n,inputFormat:a,samples:s,parserDateFormat:i});if(!d&&m==="undetected"&&e?.fallbackUndetected&&!F(s)&&!y(l)){let h=j(l),c=R(l);d=T(l)?z(h,c,X):N("dM",h,c,"YYYY",X)}!u&&!M(a)&&F(s)&&!d||d&&r.setInputFormat(w(d,l))})};var lt=o=>{if(o==null)return"";if(typeof o=="object"&&!Array.isArray(o)&&"value"in o){let e=o.value;return typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:""}return typeof o=="string"||typeof o=="number"||typeof o=="boolean"?o:""},ut=(o,e)=>o.map(t=>({sheetColumn:{getDateInputFormatSamples:()=>e.map(r=>lt(r?.[t.getKey()]))},matchedDataModel:{dataModel:t}}));import Ae from"moment";var mt=5,Oe=o=>{let e=Ae(o,ie,!0);if(e.isValid())return e;let t=Ae.parseZone(o,le,!0);return t.isValid()?t:null},dt=(o,e)=>{if(!p(o))return null;let t=$([o],e)[0];if(typeof t!="string")return null;if(t===o||t===o.trim()){if(!S(t.trim()))return null;let n=Oe(t.trim());return n?{original:o,parsedMoment:n}:null}let r=Oe(t);return r?{original:o,parsedMoment:r}:null},ht=({samples:o,inputFormat:e,outputFormat:t,maxRows:r=mt})=>o.filter(a=>p(a)).slice(0,r).map(a=>{let s=dt(a,e);return s?{original:a,formatted:s.parsedMoment.format(t)}:{original:a,formatted:null}});var Pe=(o,e)=>{if(!_(e.getType()))return g.parse(o,{dataModel:e});if(ue(o))return null;let t=`${o}`,r=e.getInputFormat();if(M(r)){if(S(t))return g.parse(t,{dataModel:e});let n=r;if(!W(t,n)){let a=w(n,[t]);if(a!==n&&W(t,a))n=a;else return t}return g.parse($([t],n)[0],{dataModel:e})}return g.parse(t,{dataModel:e})};var ne=class{constructor({sheetColumn:e,matchedDataModel:t,detectedNumberFormats:r}){this.parseSheetValue=(e,t)=>t.dataModel.getType()==="date"?Pe(e,t.dataModel):g.parse(e,t);this.getOptionValue=(e,t)=>{if(!t)if(this.matchedDataModel.dataModel){let r=this.sheetColumn.columnKey,a=this.detectedNumberFormats.columns.find(s=>s.column===r)?.numberFormat||this.detectedNumberFormats.global;return this.parseSheetValue(e,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0,numberFormat:a})}else return e;for(let r=0;r<t.length;r++)if(`${t[r]?.sheetOption}`==`${e}`){let n=!pt(t[r]?.dataModelOptions)&&(t[r]?.dataModelOptions?.length??0)>0;if(t[r]?.autoPreserved===!0&&t[r]?.dataModelOption==null&&!n){if(this.matchedDataModel.dataModel instanceof J){let a=`${e}`,s=this.matchedDataModel.dataModel.getOptions().find(i=>i.label===a||i.value===a);if(s)return g.parse(s.value,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0})}return e}return this.matchedDataModel.dataModel&&this.matchedDataModel.dataModel.getIsMultiSelection()?g.parse(t[r]?.dataModelOptions,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0}):this.matchedDataModel.dataModel?g.parse(t[r]?.dataModelOption,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0}):t[r]?.dataModelOption}};this.getValues=()=>{let e=this.sheetColumn.rows,t=[];for(let r=0;r<e.length;r++){let n=e[r],a=this.getOptionValue(n,this.matchedOptions);t.push(a)}return t};if(this.sheetColumn=e,this.matchedDataModel=t,this.matchedOptions=void 0,this.detectedNumberFormats=r||{global:"eu",columns:[]},this.matchedDataModel.matchedOptions){this.matchedOptions=[];for(let n=0;n<(this.matchedDataModel.matchedOptions?.length??0);n++){let a=this.matchedDataModel.matchedOptions[n];this.matchedDataModel.dataModel?.getIsMultiSelection()?a.dataModelOptions&&this.matchedOptions.push(a):a.dataModelOption!==void 0&&a.dataModelOption!==null?this.matchedOptions.push(a):a.autoPreserved===!0&&!a.userCleared&&this.matchedOptions.push(a)}}}},_e=ne;var ae=class{constructor(e){this.matchedColumns=[];this.parseValues=()=>{let e=[];this.matchedColumns.forEach(t=>{let r=t.matchedDataModel,a=new _e({sheetColumn:t.sheetColumn,matchedDataModel:r,detectedNumberFormats:this.detectedNumberFormats}).getValues(),s=r.dataModel.getKey();a.forEach((i,l)=>{e[l]?e[l][s]=i:e[l]={[s]:i}})});for(let t=0;t<e.length;++t)for(let r=0;r<this.columns.length;++r){let a=this.columns[r].key;e[t][a]===void 0&&(e[t][a]=null)}return e};this.getValues=()=>(this.matchedColumns=[],this.matching.filter(t=>t.matchedDataModel?.dataModel).forEach(t=>{this.matchedColumns.push({sheetColumn:t.sheetColumn,matchedDataModel:t.matchedDataModel})}),this.parseValues());let{matching:t,detectedNumberFormats:r}=e;this.matching=t,this.detectedNumberFormats=r||{global:"eu",columns:[]},this.columns=e.columns??[]}},Ee=ae;var Oo=({matching:o,detectedNumberFormats:e,columns:t})=>new Ee({matching:o,detectedNumberFormats:e,columns:t}).getValues();import*as Ye from"comlink";var v=class{static{this.serialize=e=>e.serialize()}static{this.deSerialize=e=>q.isTypeCategory(e.type)?new J({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,options:e.options,validators:[],alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,isMultiSelection:e.isMultiSelection??!1,allowCustomOptions:e.allowCustomOptions,allowedCustomOptionTypes:e.allowedCustomOptionTypes,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration}):new q({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,validators:[],alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,outputFormat:e.outputFormat,inputFormat:e.inputFormat,numberFormat:e.numberFormat,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration})}};var A=class{static{this.serialize=e=>{let t={matching:[],detectedNumberFormats:e.detectedNumberFormats,columns:e.columns};return t.matching=e.matching.map(r=>({sheetColumn:r.sheetColumn,matchedDataModel:r.matchedDataModel?{dataModel:r.matchedDataModel.dataModel?v.serialize(r.matchedDataModel.dataModel):r.matchedDataModel.dataModel,matchedOptions:r.matchedDataModel.matchedOptions}:r.matchedDataModel})),[t,[]]}}static{this.deserialize=e=>({matching:e.matching.map(t=>({sheetColumn:t.sheetColumn,matchedDataModel:t.matchedDataModel?{dataModel:t.matchedDataModel.dataModel?v.deSerialize(t.matchedDataModel.dataModel):t.matchedDataModel.dataModel,matchedOptions:t.matchedDataModel.matchedOptions}:t.matchedDataModel})),detectedNumberFormats:e.detectedNumberFormats,columns:e.columns})}};Ye.transferHandlers.set("Matching",{canHandle:o=>!!(o!==null&&typeof o=="object"&&o.matching),serialize:o=>A.serialize(o),deserialize:o=>A.deserialize(o)});export{C as a,Se as b,Nt as c,Ie as d,I as e,je as f,T as g,rt as h,y as i,R as j,z as k,Ne as l,Ve as m,ot as n,V as o,at as p,st as q,ve as r,it as s,ut as t,ht as u,Bt as v,qt as w,Gt as x,Zt as y,Qt as z,er as A,Oo as B,v as C};
|
package/index.d.ts
CHANGED
|
@@ -299,6 +299,17 @@ export type IHeaderStepHandler = (params: {
|
|
|
299
299
|
stay: IStayFn;
|
|
300
300
|
}) => Promise<void> | void;
|
|
301
301
|
|
|
302
|
+
export type IPreProcessingStepUpdateDataFn = IHeaderStepUpdateDataFn;
|
|
303
|
+
|
|
304
|
+
export type IPreProcessingStepHandler = (params: {
|
|
305
|
+
data: ISheetData[];
|
|
306
|
+
updateData: IPreProcessingStepUpdateDataFn;
|
|
307
|
+
alert: IAlertFn;
|
|
308
|
+
block: IBlockFn;
|
|
309
|
+
proceed: IProceedFn;
|
|
310
|
+
stay: IStayFn;
|
|
311
|
+
}) => Promise<void> | void;
|
|
312
|
+
|
|
302
313
|
export type IReviewData = Record<
|
|
303
314
|
string,
|
|
304
315
|
{
|
|
@@ -320,6 +331,7 @@ export type IReviewStepHandler = (params: {
|
|
|
320
331
|
|
|
321
332
|
export type IStepHandler = {
|
|
322
333
|
uploadStep?: IUploadStepHandler;
|
|
334
|
+
preProcessingStep?: IPreProcessingStepHandler;
|
|
323
335
|
mappingStep?: IMappingStepHandler;
|
|
324
336
|
headerStep?: IHeaderStepHandler;
|
|
325
337
|
reviewStep?: IReviewStepHandler;
|
|
@@ -599,6 +611,7 @@ export type I18nOverrides =
|
|
|
599
611
|
type IAdditionalInfo = {
|
|
600
612
|
uploadStep?: boolean;
|
|
601
613
|
sheetSelectionStep?: boolean;
|
|
614
|
+
preProcessingStep?: boolean;
|
|
602
615
|
headerStep?: boolean;
|
|
603
616
|
mappingStep?: boolean;
|
|
604
617
|
reviewStep?: boolean;
|
|
@@ -619,6 +632,7 @@ export type ISkipConfigurationMapping = {
|
|
|
619
632
|
automaticMapping?: boolean;
|
|
620
633
|
applyColumnMapping?: IApplyMappingMode;
|
|
621
634
|
applyOptionMapping?: IApplyMappingMode;
|
|
635
|
+
requireConfirmation?: boolean;
|
|
622
636
|
};
|
|
623
637
|
|
|
624
638
|
export type ISkipConfiguration = {
|
|
@@ -700,6 +714,7 @@ export type SettingsAPI = {
|
|
|
700
714
|
transpose?: boolean;
|
|
701
715
|
mergeHeaders?: boolean;
|
|
702
716
|
metadataSelection?: boolean;
|
|
717
|
+
preProcessing?: boolean;
|
|
703
718
|
collapseMatchedColumns?: boolean;
|
|
704
719
|
skipConfiguration?: ISkipConfiguration;
|
|
705
720
|
disableColumnRemapping?: boolean;
|
|
@@ -988,6 +1003,7 @@ export type ThemeAPI = {
|
|
|
988
1003
|
};
|
|
989
1004
|
loader?: LoaderThemeAPI;
|
|
990
1005
|
headerSelect?: HeaderMatchAPI;
|
|
1006
|
+
preProcessing?: PreProcessingThemeAPI;
|
|
991
1007
|
dropzone?: DropzoneThemeAPI;
|
|
992
1008
|
progressBar?: ProgressBarThemeAPI;
|
|
993
1009
|
joinSheet?: JoinSheetThemeAPI;
|
|
@@ -1239,6 +1255,74 @@ export type HeaderMatchAPI = {
|
|
|
1239
1255
|
};
|
|
1240
1256
|
};
|
|
1241
1257
|
|
|
1258
|
+
export type PreProcessingThemeAPI = {
|
|
1259
|
+
accent?: {
|
|
1260
|
+
color?: string;
|
|
1261
|
+
};
|
|
1262
|
+
root?: CSSInterpolation;
|
|
1263
|
+
pageHeader?: HeaderThemeAPI;
|
|
1264
|
+
content?: CSSInterpolation;
|
|
1265
|
+
additionalInfo?: IAdditionalInfoTheme;
|
|
1266
|
+
infoBox?: InfoBoxThemeAPI;
|
|
1267
|
+
inventory?: {
|
|
1268
|
+
root?: CSSInterpolation;
|
|
1269
|
+
fileChip?: CSSInterpolation & {
|
|
1270
|
+
focused?: CSSInterpolation;
|
|
1271
|
+
configureButton?: CSSInterpolation;
|
|
1272
|
+
parsedBadge?: CSSInterpolation;
|
|
1273
|
+
};
|
|
1274
|
+
sheetRow?: CSSInterpolation & {
|
|
1275
|
+
selected?: CSSInterpolation;
|
|
1276
|
+
viewing?: CSSInterpolation;
|
|
1277
|
+
processedTag?: CSSInterpolation;
|
|
1278
|
+
};
|
|
1279
|
+
addFileButton?: CSSInterpolation;
|
|
1280
|
+
};
|
|
1281
|
+
preview?: {
|
|
1282
|
+
root?: CSSInterpolation;
|
|
1283
|
+
title?: CSSInterpolation;
|
|
1284
|
+
headerHint?: CSSInterpolation;
|
|
1285
|
+
combineRequired?: CSSInterpolation;
|
|
1286
|
+
empty?: CSSInterpolation;
|
|
1287
|
+
table?: HeaderMatchAPI['table'];
|
|
1288
|
+
};
|
|
1289
|
+
modal?: {
|
|
1290
|
+
root?: CSSInterpolation;
|
|
1291
|
+
overlay?: CSSInterpolation;
|
|
1292
|
+
header?: CSSInterpolation;
|
|
1293
|
+
footer?: CSSInterpolation;
|
|
1294
|
+
tabs?: {
|
|
1295
|
+
root?: CSSInterpolation;
|
|
1296
|
+
tab?: CSSInterpolation;
|
|
1297
|
+
activeTab?: CSSInterpolation;
|
|
1298
|
+
};
|
|
1299
|
+
recipe?: {
|
|
1300
|
+
root?: CSSInterpolation;
|
|
1301
|
+
step?: CSSInterpolation;
|
|
1302
|
+
stepEditing?: CSSInterpolation;
|
|
1303
|
+
stepGenerated?: CSSInterpolation;
|
|
1304
|
+
empty?: CSSInterpolation;
|
|
1305
|
+
addStep?: CSSInterpolation;
|
|
1306
|
+
addStepOption?: CSSInterpolation;
|
|
1307
|
+
};
|
|
1308
|
+
combine?: {
|
|
1309
|
+
joinPopover?: CSSInterpolation;
|
|
1310
|
+
joinColumnsDialog?: JoinColumnsDialogThemeAPI;
|
|
1311
|
+
appendColumnsDialog?: AppendColumnsDialogThemeAPI;
|
|
1312
|
+
matchStatus?: JoinSheetMatchStatus;
|
|
1313
|
+
};
|
|
1314
|
+
aiAssist?: {
|
|
1315
|
+
root?: CSSInterpolation;
|
|
1316
|
+
input?: CSSInterpolation;
|
|
1317
|
+
suggestion?: CSSInterpolation;
|
|
1318
|
+
};
|
|
1319
|
+
preview?: SheetPreviewThemeAPI;
|
|
1320
|
+
metadataSelection?: NonNullable<
|
|
1321
|
+
NonNullable<HeaderMatchAPI['features']>['metadataSelection']
|
|
1322
|
+
>;
|
|
1323
|
+
};
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1242
1326
|
type DropzoneIllustrationStyle = {
|
|
1243
1327
|
borderColor?: string;
|
|
1244
1328
|
headerColor?: string;
|
|
@@ -2038,6 +2122,7 @@ export declare const useDataImporter: (
|
|
|
2038
2122
|
export type DynamicStepValues =
|
|
2039
2123
|
| 'header'
|
|
2040
2124
|
| 'mapping'
|
|
2125
|
+
| 'preProcessing'
|
|
2041
2126
|
| 'review'
|
|
2042
2127
|
| 'sheetSelection';
|
|
2043
2128
|
|
|
@@ -2066,9 +2151,9 @@ export type IParseFilePdfConfiguration = {
|
|
|
2066
2151
|
};
|
|
2067
2152
|
|
|
2068
2153
|
export type SheetSelectionUploadFile = {
|
|
2069
|
-
fileName
|
|
2154
|
+
fileName?: string;
|
|
2070
2155
|
sheets: {
|
|
2071
|
-
sheetName
|
|
2156
|
+
sheetName?: string;
|
|
2072
2157
|
data: UploadData;
|
|
2073
2158
|
visibility?: SheetVisibility;
|
|
2074
2159
|
}[];
|