@univerjs/sheets-source-binding 0.6.0-nightly.202502131606 → 0.6.0-nightly.202502141606

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/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var J=Object.defineProperty;var H=(i,o,e)=>o in i?J(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var l=(i,o,e)=>H(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),C=require("@univerjs/sheets"),P=require("rxjs");class O{constructor(o){l(this,"_matrix",{});l(this,"_nodeMap",new Map);l(this,"_sourceIdMap",new Map);o&&this._init(o)}_init(o){this.fromJSON(o)}getBindingNodesBySourceId(o){const e=this._sourceIdMap.get(o);if(e)return e.map(t=>this._nodeMap.get(t))}setBindingNode(o,e,t){this._matrix[o]||(this._matrix[o]={}),this._matrix[o][e]||(this._matrix[o][e]=t),this._nodeMap.set(t.nodeId,t);const n=this._sourceIdMap.get(t.sourceId);n?n.push(t.nodeId):this._sourceIdMap.set(t.sourceId,[t.nodeId])}getBindingNode(o,e){var t;return(t=this._matrix[o])==null?void 0:t[e]}removeBindingNode(o,e){var n;const t=(n=this._matrix[o])==null?void 0:n[e];if(t){this._matrix[o][e]=void 0,this._nodeMap.delete(t.nodeId);const s=this._sourceIdMap.get(t.sourceId);if(s){const r=s.indexOf(t.nodeId);r>=0&&s.splice(r,1),s.length===0&&this._sourceIdMap.delete(t.sourceId)}}}getBindingNodeById(o){return this._nodeMap.get(o)}fromJSON(o){o.forEach(e=>{this.setBindingNode(e.row,e.column,e)})}toJSON(){return Array.from(this._nodeMap.values())}}var p=(i=>(i.List="list",i.Object="object",i))(p||{}),N=(i=>(i.Path="path",i.Value="value",i))(N||{}),B=(i=>(i.Add="add",i.Remove="remove",i.Update="update",i))(B||{});function A(i){return i instanceof Date&&!isNaN(i.getTime())}function $(i){const o=new Date(i);if(!A(o))return i;const e=new Date(Date.UTC(1900,0,1,0,0,0)),t=new Date(Date.UTC(1900,1,28,0,0,0));let s=(o.getTime()-e.getTime())/(1e3*3600*24);return o>t&&(s+=1),s+1}class T{constructor(o){l(this,"_data");l(this,"id");l(this,"_hasData",!1);l(this,"type");this.id=o}getId(){return this.id}getType(){return this.type}hasData(){return this._hasData}setSourceData(o){this._data=o,this._hasData=!0}toJSON(){return{id:this.id,type:this.type}}fromJSON(o){this.id=o.id,this.type=o.type}}class E extends T{constructor(e,t){super(e);l(this,"type",p.List);l(this,"_isListObject");l(this,"_fieldIndexMap",new Map);l(this,"_data",{fields:[],records:[]});this._isListObject=t!=null?t:!0}toggleListObject(e){this._isListObject=e}getData(e,t){const{path:n,row:s,containHeader:r}=e,d=this._fieldIndexMap.get(n),a=t-s;if(r&&a===0)return{v:this._data.fields[d]};let h;const c=r?1:0;return this._isListObject?h=this._data.records[a-c][n]:h=this._data.records[a-c][d],e.isDate===!0?{v:$(h),s:{n:{pattern:"yyyy-m-d am/pm h:mm"}},t:u.CellValueType.NUMBER}:{t:typeof h=="number"?u.CellValueType.NUMBER:u.CellValueType.STRING,v:h}}setSourceData(e){super.setSourceData(e);const{fields:t}=e;this._fieldIndexMap.clear(),t.forEach((n,s)=>{this._fieldIndexMap.set(n,s)})}getSourceInfo(){return{sourceId:this.id,sourceType:this.type,fields:this._data.fields,recordCount:this._data.records.length}}}class j extends T{constructor(e){super(e);l(this,"type",p.Object)}getData(e){const n=e.path.split(".");let s=this._data;for(const r of n)if(s=s[r],s===void 0)return null;return e.isDate===!0?{v:$(s),s:{n:{pattern:"yyyy-m-d am/pm h:mm"}},t:u.CellValueType.NUMBER}:{v:s,t:typeof s=="number"?u.CellValueType.NUMBER:u.CellValueType.STRING}}getSourceInfo(){return{sourceId:this.id,sourceType:p.Object}}}var k=Object.getOwnPropertyDescriptor,q=(i,o,e,t)=>{for(var n=t>1?void 0:t?k(o,e):o,s=i.length-1,r;s>=0;s--)(r=i[s])&&(n=r(n)||n);return n},D=(i,o)=>(e,t)=>o(e,t,i);let b=class extends u.Disposable{constructor(o,e,t){super();l(this,"modelMap",new Map);l(this,"_cellBindInfoUpdate$",new P.Subject);l(this,"cellBindInfoUpdate$",this._cellBindInfoUpdate$.asObservable());this._univerInstanceService=o,this._sheetInterceptorService=e,this._sheetsSelectionsService=t,this._initRemoveCommand()}_initRemoveCommand(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{const e=[],t=[],n=this._sheetsSelectionsService.getCurrentSelections(),s=C.getSheetCommandTarget(this._univerInstanceService);if(!s||!n||n.length===0)return{redos:[],undos:[]};const{unitId:r,subUnitId:d}=s;return(o.id===C.ClearSelectionContentCommand.id||o.id===C.ClearSelectionAllCommand.id)&&n.forEach(({range:a})=>{u.Range.foreach(a,(h,c)=>{this.getBindingNode(r,d,h,c)&&this.removeBindingNode(r,d,h,c)})}),{redos:e,undos:t}}}))}getBindingModelBySourceId(o){const e=[];return this.modelMap.forEach((t,n)=>{t.forEach((s,r)=>{const d=s.getBindingNodesBySourceId(o);if(d)for(const a of d)e.push({unitId:n,subunitId:r,sourceId:o,nodeId:a.nodeId,row:a.row,column:a.column})})}),e}addModel(o,e,t){var n;this.modelMap.has(o)||this.modelMap.set(o,new Map),(n=this.modelMap.get(o))==null||n.set(e,t)}getModel(o,e){var t;return(t=this.modelMap.get(o))==null?void 0:t.get(e)}setBindingNode(o,e,t){let n=this.getModel(o,e);n||(n=new O,this.addModel(o,e,n)),t.nodeId||(t.nodeId=u.generateRandomId());const{row:s,column:r}=t;if(s===void 0||r===void 0)throw new Error("row and column is required");const d=n.getBindingNode(s,r),a=t.type===p.List?!!t.containHeader:!1;n.setBindingNode(s,r,{...t,row:s,column:r}),this._cellBindInfoUpdate$.next({unitId:o,subunitId:e,sourceId:t.sourceId,nodeId:t.nodeId,row:s,column:r,containHeader:a,changeType:d?B.Update:B.Add,oldSourceId:d==null?void 0:d.sourceId,oldNodeContainHeader:(d==null?void 0:d.type)===p.List?!!d.containHeader:!1})}removeBindingNode(o,e,t,n){const s=this.getModel(o,e);if(s){const r=s.getBindingNode(t,n);r&&(s.removeBindingNode(t,n),this._cellBindInfoUpdate$.next({unitId:o,subunitId:e,sourceId:r.sourceId,nodeId:r.nodeId,row:t,column:n,changeType:B.Remove}))}}getBindingNode(o,e,t,n){const s=this.getModel(o,e);if(s)return s.getBindingNode(t,n)}getBindingNodeById(o,e,t){const n=this.getModel(o,e);if(n)return n.getBindingNodeById(t)}createModel(o,e,t){const n=new O(t);return this.addModel(o,e,n),n}toJSON(o){const e={},t=this.modelMap.get(o);return t&&t.forEach((n,s)=>{e[s]=n.toJSON()}),e}fromJSON(o,e){Object.entries(e).forEach(([t,n])=>{this.createModel(o,t,n)})}dispose(){this.modelMap.clear(),this._cellBindInfoUpdate$.complete()}};b=q([D(0,u.IUniverInstanceService),D(1,u.Inject(C.SheetInterceptorService)),D(2,u.Inject(C.SheetsSelectionsService))],b);class w extends u.Disposable{constructor(){super();l(this,"sourceMap",new Map);l(this,"_sourceDataUpdate$",new P.Subject);l(this,"sourceDataUpdate$",this._sourceDataUpdate$.asObservable())}_ensureUnitMap(e){let t=this.sourceMap.get(e);return t||(t=new Map,this.sourceMap.set(e,t)),t}_getUnitMap(e){return this.sourceMap.get(e)}getSource(e,t){const n=this._getUnitMap(e);return n==null?void 0:n.get(t)}createSource(e,t,n,s){const r=s===void 0?u.generateRandomId():s;let d;switch(t){case p.List:d=new E(r,n);break;case p.Object:d=new j(r);break;default:throw new Error(`Invalid source type: ${t}`)}return this._ensureUnitMap(e).set(r,d),d}updateSourceData(e,t,n){const s=this._getUnitMap(e),r=t instanceof T?t.getId():t,d=s==null?void 0:s.get(r);if(d)d.setSourceData(n),this._sourceDataUpdate$.next({...d.getSourceInfo(),unitId:e,changeType:B.Add});else throw new Error(`Source not found: ${r}`)}removeSource(e,t){const n=this._getUnitMap(e),s=n==null?void 0:n.get(t);s&&(n==null||n.delete(t),this._sourceDataUpdate$.next({...s.getSourceInfo(),unitId:e,changeType:B.Remove}))}toJSON(e){const t=[],n=this._getUnitMap(e);if(n)for(const s of n.values())t.push(s.toJSON());return t}fromJSON(e,t){const n=this._ensureUnitMap(e);for(const s of t){let r;switch(s.type){case p.List:r=new E(s.id);break;case p.Object:r=new j(s.id);break;default:throw new Error(`Invalid source type: ${s.type}`)}r.fromJSON(s),n.set(s.id,r)}}dispose(){this._sourceDataUpdate$.complete(),this.sourceMap.clear()}}var G=Object.getOwnPropertyDescriptor,W=(i,o,e,t)=>{for(var n=t>1?void 0:t?G(o,e):o,s=i.length-1,r;s>=0;s--)(r=i[s])&&(n=r(n)||n);return n},U=(i,o)=>(e,t)=>o(e,t,i);exports.SheetsSourceBindService=class extends u.Disposable{constructor(e,t,n){super();l(this,"_bindingModel",N.Value);l(this,"_bindModelRTreeCollection",new Map);this._sheetInterceptorService=e,this._sheetsBindingManager=t,this._sheetsSourceManager=n,this._registerInterceptor(),this._registerSourceChange()}usePathMode(){this._bindingModel=N.Path}useValueMode(){this._bindingModel=N.Value}getBindingModel(){return this._bindingModel}createBindModel(e,t){return this._sheetsBindingManager.createModel(e,t)}setBindingNode(e,t,n){this._sheetsBindingManager.setBindingNode(e,t,n)}removeBindingNode(e,t,n,s){this._sheetsBindingManager.removeBindingNode(e,t,n,s)}getBindingNode(e,t,n,s){return this._sheetsBindingManager.getBindingNode(e,t,n,s)}getSource(e,t){return this._sheetsSourceManager.getSource(e,t)}createSource(e,t,n,s){return this._sheetsSourceManager.createSource(e,t,n,s)}getSourceBindingPathInfo(e){return{source:this._sheetsSourceManager.toJSON(e),cellBinding:this._sheetsBindingManager.toJSON(e)}}loadSourceBindingPathInfo(e,t){this._sheetsSourceManager.fromJSON(e,t.source),this._sheetsBindingManager.fromJSON(e,t.cellBinding)}_ensureRTreeCollection(e){return this._bindModelRTreeCollection.has(e)||this._bindModelRTreeCollection.set(e,new u.RTree),this._bindModelRTreeCollection.get(e)}_getRTeeCollection(e){return this._bindModelRTreeCollection.get(e)}_registerSourceChange(){this.disposeWithMe(this._sheetsSourceManager.sourceDataUpdate$.subscribe(e=>{const{sourceId:t,sourceType:n,unitId:s,changeType:r}=e;if(n===p.List){if(r===B.Remove){const a=this._sheetsBindingManager.getBindingModelBySourceId(t),h=e.recordCount;for(const{unitId:c,subunitId:f,nodeId:g,row:S,column:M}of a){const I=this._getRTeeCollection(s),_=this._sheetsBindingManager.getBindingNodeById(c,f,g);if(I&&(_==null?void 0:_.type)===p.List){const m=_.containHeader?0:1,v={startRow:S,startColumn:M,endRow:S+h-m,endColumn:M};I.remove({unitId:c,sheetId:f,id:g,range:v})}}return}if(r===B.Update){const a=e.oldRecordCount,h=this._sheetsBindingManager.getBindingModelBySourceId(t);for(const{unitId:c,subunitId:f,nodeId:g,row:S,column:M}of h){const I=this._getRTeeCollection(s),_=this._sheetsBindingManager.getBindingNodeById(c,f,g);if(I&&(_==null?void 0:_.type)===p.List){const m=_.containHeader?0:1,v={startRow:S,startColumn:M,endRow:S+a-m,endColumn:M},y={startRow:S,startColumn:M,endRow:S+e.recordCount-m,endColumn:M};I.remove({unitId:c,sheetId:f,id:g,range:v}),I.insert({unitId:c,sheetId:f,id:g,range:y})}}return}const d=this._sheetsSourceManager.getSource(s,t);if(d&&d.hasData()){const h=d.getSourceInfo().recordCount,c=this._sheetsBindingManager.getBindingModelBySourceId(t);for(const{unitId:f,subunitId:g,nodeId:S,row:M,column:I}of c){const _=this._ensureRTreeCollection(f),m=this._sheetsBindingManager.getBindingNodeById(f,g,S);if(_&&(m==null?void 0:m.type)===p.List){const v=m.containHeader?0:1,y={startRow:M,startColumn:I,endRow:M+h-v,endColumn:I};_.insert({unitId:f,sheetId:g,id:S,range:y})}}}}})),this.disposeWithMe(this._sheetsBindingManager.cellBindInfoUpdate$.subscribe(e=>{const{unitId:t,subunitId:n,sourceId:s,nodeId:r,row:d,column:a,changeType:h,containHeader:c}=e,f=this._ensureRTreeCollection(t),g=this._sheetsSourceManager.getSource(t,s);if(g&&g.hasData()){const S=g.getSourceInfo();if(S.sourceType===p.List){const M=S.recordCount,I=c?0:1,_={startRow:d,startColumn:a,endRow:d+M-I,endColumn:a};if(h===B.Add)f.insert({unitId:t,sheetId:n,id:r,range:_});else if(h===B.Remove)f.remove({unitId:t,sheetId:n,id:r,range:_});else if(h===B.Update){const m=e.oldSourceId,v=e.oldNodeContainHeader?0:1,y=this._sheetsSourceManager.getSource(t,m);if(y&&y.hasData()){const V=y.getSourceInfo().recordCount,L={startRow:d,startColumn:a,endRow:d+V-v,endColumn:a};f.remove({unitId:t,sheetId:n,id:r,range:L})}f.insert({unitId:t,sheetId:n,id:r,range:_})}}}}))}_getPathModeCellValue(e,t,n,s){const r=this._sheetsBindingManager.getModel(e,t),d=r==null?void 0:r.getBindingNode(n,s);if(d){const a=d.type;if(a===p.List)return{v:`#{${d.path}}`,s:{cl:{rgb:"blue"}}};if(a===p.Object)return{v:`[${d.path}]`,s:{cl:{rgb:"blue"}}}}}_getValueModeCellValue(e,t,n,s){const r=this._sheetsBindingManager.getModel(e,t);if(r){const a=r.getBindingNode(n,s);if(a){const{sourceId:h}=a,c=this._sheetsSourceManager.getSource(e,h);if(c&&c.hasData())return(c==null?void 0:c.getData(a,n,s))||{v:""}}}const d=this._getRTeeCollection(e);if(r&&d){const a={startRow:n,startColumn:s,endRow:n,endColumn:s},h=Array.from(d.bulkSearch([{unitId:e,sheetId:t,range:a}]));if(h.length>0){const c=r.getBindingNodeById(h[0]);if(c){const{sourceId:f}=c,g=this._sheetsSourceManager.getSource(e,f);if(g&&g.hasData())return(g==null?void 0:g.getData(c,n,s))||{v:""}}}}}getBindingModelBySourceId(e){return this._sheetsBindingManager.getBindingModelBySourceId(e)}_registerInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Value|u.InterceptorEffectEnum.Style,priority:102,handler:(e,t,n)=>{const{row:s,col:r,unitId:d,subUnitId:a,workbook:h}=t;let c=null;if(this._bindingModel===N.Path?c=this._getPathModeCellValue(d,a,s,r):c=this._getValueModeCellValue(d,a,s,r),c!==null){const g={...(typeof(e==null?void 0:e.s)=="string"?h.getStyles().get(e==null?void 0:e.s):e==null?void 0:e.s)||{}};return c&&c.s&&Object.assign(g,c.s),n({...e,...c,s:g})}return n(e)}}))}dispose(){this._bindModelRTreeCollection.clear()}};exports.SheetsSourceBindService=W([U(0,u.Inject(C.SheetInterceptorService)),U(1,u.Inject(b)),U(2,u.Inject(w))],exports.SheetsSourceBindService);var z=Object.getOwnPropertyDescriptor,F=(i,o,e,t)=>{for(var n=t>1?void 0:t?z(o,e):o,s=i.length-1,r;s>=0;s--)(r=i[s])&&(n=r(n)||n);return n},x=(i,o)=>(e,t)=>o(e,t,i),R;exports.UniverSheetsBindingSourcePlugin=(R=class extends u.Plugin{constructor(o={},e,t){super(),this._config=o,this._injector=e,this._configService=t}onStarting(){[[b],[w],[exports.SheetsSourceBindService]].forEach(o=>this._injector.add(o))}onReady(){u.touchDependencies(this._injector,[[b],[w],[exports.SheetsSourceBindService]])}},l(R,"type",u.UniverInstanceType.UNIVER_SHEET),l(R,"pluginName","SHEET_BINDING_SOURCE_PLUGIN"),R);exports.UniverSheetsBindingSourcePlugin=F([x(1,u.Inject(u.Injector)),x(2,u.IConfigService)],exports.UniverSheetsBindingSourcePlugin);exports.BindModeEnum=N;exports.BindingModel=O;exports.DataBindingNodeTypeEnum=p;exports.SheetsSourceManager=w;exports.SourceModelBase=T;
1
+ "use strict";var J=Object.defineProperty;var H=(i,o,e)=>o in i?J(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var l=(i,o,e)=>H(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),C=require("@univerjs/sheets"),P=require("rxjs");class O{constructor(o){l(this,"_matrix",{});l(this,"_nodeMap",new Map);l(this,"_sourceIdMap",new Map);o&&this._init(o)}_init(o){this.fromJSON(o)}getBindingNodesBySourceId(o){const e=this._sourceIdMap.get(o);if(e)return e.map(t=>this._nodeMap.get(t))}setBindingNode(o,e,t){this._matrix[o]||(this._matrix[o]={}),this._matrix[o][e]||(this._matrix[o][e]=t),this._nodeMap.set(t.nodeId,t);const n=this._sourceIdMap.get(t.sourceId);n?n.push(t.nodeId):this._sourceIdMap.set(t.sourceId,[t.nodeId])}getBindingNode(o,e){var t;return(t=this._matrix[o])==null?void 0:t[e]}removeBindingNode(o,e){var n;const t=(n=this._matrix[o])==null?void 0:n[e];if(t){this._matrix[o][e]=void 0,this._nodeMap.delete(t.nodeId);const s=this._sourceIdMap.get(t.sourceId);if(s){const r=s.indexOf(t.nodeId);r>=0&&s.splice(r,1),s.length===0&&this._sourceIdMap.delete(t.sourceId)}}}getBindingNodeById(o){return this._nodeMap.get(o)}fromJSON(o){o.forEach(e=>{this.setBindingNode(e.row,e.column,e)})}toJSON(){return Array.from(this._nodeMap.values())}}var p=(i=>(i.List="list",i.Object="object",i))(p||{}),N=(i=>(i.Path="path",i.Value="value",i))(N||{}),B=(i=>(i.Add="add",i.Remove="remove",i.Update="update",i))(B||{});function A(i){return i instanceof Date&&!isNaN(i.getTime())}function $(i){const o=new Date(i);if(!A(o))return i;const e=new Date(Date.UTC(1900,0,1,0,0,0)),t=new Date(Date.UTC(1900,1,28,0,0,0));let s=(o.getTime()-e.getTime())/(1e3*3600*24);return o>t&&(s+=1),s+1}class T{constructor(o){l(this,"_data");l(this,"id");l(this,"_hasData",!1);l(this,"type");this.id=o}getId(){return this.id}getType(){return this.type}hasData(){return this._hasData}setSourceData(o){this._data=o,this._hasData=!0}toJSON(){return{id:this.id,type:this.type}}fromJSON(o){this.id=o.id,this.type=o.type}}class E extends T{constructor(e,t){super(e);l(this,"type",p.List);l(this,"_isListObject");l(this,"_fieldIndexMap",new Map);l(this,"_data",{fields:[],records:[]});this._isListObject=t!=null?t:!0}toggleListObject(e){this._isListObject=e}getData(e,t){const{path:n,row:s,containHeader:r}=e,a=this._fieldIndexMap.get(n),d=t-s;if(r&&d===0)return{v:this._data.fields[a]};let h;const c=r?1:0;if(this._isListObject?h=this._data.records[d-c][n]:h=this._data.records[d-c][a],e.isDate===!0){const f=e.formatter||"yyyy-m-d am/pm h:mm";return{v:$(h),s:{n:{pattern:f}},t:u.CellValueType.NUMBER}}else return e.formatter?{v:h,s:{n:{pattern:e.formatter}}}:{t:typeof h=="number"?u.CellValueType.NUMBER:u.CellValueType.STRING,v:h}}setSourceData(e){super.setSourceData(e);const{fields:t}=e;this._fieldIndexMap.clear(),t.forEach((n,s)=>{this._fieldIndexMap.set(n,s)})}getSourceInfo(){return{sourceId:this.id,sourceType:this.type,fields:this._data.fields,recordCount:this._data.records.length}}}class j extends T{constructor(e){super(e);l(this,"type",p.Object)}getData(e){const n=e.path.split(".");let s=this._data;for(const r of n)if(s=s[r],s===void 0)return null;if(e.isDate===!0){const r=e.formatter||"yyyy-m-d am/pm h:mm";return{v:$(s),s:{n:{pattern:r}},t:u.CellValueType.NUMBER}}else return e.formatter?{v:s,s:{n:{pattern:e.formatter}}}:{v:s,t:typeof s=="number"?u.CellValueType.NUMBER:u.CellValueType.STRING}}getSourceInfo(){return{sourceId:this.id,sourceType:p.Object}}}var k=Object.getOwnPropertyDescriptor,q=(i,o,e,t)=>{for(var n=t>1?void 0:t?k(o,e):o,s=i.length-1,r;s>=0;s--)(r=i[s])&&(n=r(n)||n);return n},D=(i,o)=>(e,t)=>o(e,t,i);let b=class extends u.Disposable{constructor(o,e,t){super();l(this,"modelMap",new Map);l(this,"_cellBindInfoUpdate$",new P.Subject);l(this,"cellBindInfoUpdate$",this._cellBindInfoUpdate$.asObservable());this._univerInstanceService=o,this._sheetInterceptorService=e,this._sheetsSelectionsService=t,this._initRemoveCommand()}_initRemoveCommand(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{const e=[],t=[],n=this._sheetsSelectionsService.getCurrentSelections(),s=C.getSheetCommandTarget(this._univerInstanceService);if(!s||!n||n.length===0)return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=s;return(o.id===C.ClearSelectionContentCommand.id||o.id===C.ClearSelectionAllCommand.id)&&n.forEach(({range:d})=>{u.Range.foreach(d,(h,c)=>{this.getBindingNode(r,a,h,c)&&this.removeBindingNode(r,a,h,c)})}),{redos:e,undos:t}}}))}getBindingModelBySourceId(o){const e=[];return this.modelMap.forEach((t,n)=>{t.forEach((s,r)=>{const a=s.getBindingNodesBySourceId(o);if(a)for(const d of a)e.push({unitId:n,subunitId:r,sourceId:o,nodeId:d.nodeId,row:d.row,column:d.column})})}),e}addModel(o,e,t){var n;this.modelMap.has(o)||this.modelMap.set(o,new Map),(n=this.modelMap.get(o))==null||n.set(e,t)}getModel(o,e){var t;return(t=this.modelMap.get(o))==null?void 0:t.get(e)}setBindingNode(o,e,t){let n=this.getModel(o,e);n||(n=new O,this.addModel(o,e,n)),t.nodeId||(t.nodeId=u.generateRandomId());const{row:s,column:r}=t;if(s===void 0||r===void 0)throw new Error("row and column is required");const a=n.getBindingNode(s,r),d=t.type===p.List?!!t.containHeader:!1;n.setBindingNode(s,r,{...t,row:s,column:r}),this._cellBindInfoUpdate$.next({unitId:o,subunitId:e,sourceId:t.sourceId,nodeId:t.nodeId,row:s,column:r,containHeader:d,changeType:a?B.Update:B.Add,oldSourceId:a==null?void 0:a.sourceId,oldNodeContainHeader:(a==null?void 0:a.type)===p.List?!!a.containHeader:!1})}removeBindingNode(o,e,t,n){const s=this.getModel(o,e);if(s){const r=s.getBindingNode(t,n);r&&(s.removeBindingNode(t,n),this._cellBindInfoUpdate$.next({unitId:o,subunitId:e,sourceId:r.sourceId,nodeId:r.nodeId,row:t,column:n,changeType:B.Remove}))}}getBindingNode(o,e,t,n){const s=this.getModel(o,e);if(s)return s.getBindingNode(t,n)}getBindingNodeById(o,e,t){const n=this.getModel(o,e);if(n)return n.getBindingNodeById(t)}createModel(o,e,t){const n=new O(t);return this.addModel(o,e,n),n}toJSON(o){const e={},t=this.modelMap.get(o);return t&&t.forEach((n,s)=>{e[s]=n.toJSON()}),e}fromJSON(o,e){Object.entries(e).forEach(([t,n])=>{this.createModel(o,t,n)})}dispose(){this.modelMap.clear(),this._cellBindInfoUpdate$.complete()}};b=q([D(0,u.IUniverInstanceService),D(1,u.Inject(C.SheetInterceptorService)),D(2,u.Inject(C.SheetsSelectionsService))],b);class w extends u.Disposable{constructor(){super();l(this,"sourceMap",new Map);l(this,"_sourceDataUpdate$",new P.Subject);l(this,"sourceDataUpdate$",this._sourceDataUpdate$.asObservable())}_ensureUnitMap(e){let t=this.sourceMap.get(e);return t||(t=new Map,this.sourceMap.set(e,t)),t}_getUnitMap(e){return this.sourceMap.get(e)}getSource(e,t){const n=this._getUnitMap(e);return n==null?void 0:n.get(t)}createSource(e,t,n,s){const r=s===void 0?u.generateRandomId():s;let a;switch(t){case p.List:a=new E(r,n);break;case p.Object:a=new j(r);break;default:throw new Error(`Invalid source type: ${t}`)}return this._ensureUnitMap(e).set(r,a),a}updateSourceData(e,t,n){const s=this._getUnitMap(e),r=t instanceof T?t.getId():t,a=s==null?void 0:s.get(r);if(a)a.setSourceData(n),this._sourceDataUpdate$.next({...a.getSourceInfo(),unitId:e,changeType:B.Add});else throw new Error(`Source not found: ${r}`)}removeSource(e,t){const n=this._getUnitMap(e),s=n==null?void 0:n.get(t);s&&(n==null||n.delete(t),this._sourceDataUpdate$.next({...s.getSourceInfo(),unitId:e,changeType:B.Remove}))}toJSON(e){const t=[],n=this._getUnitMap(e);if(n)for(const s of n.values())t.push(s.toJSON());return t}fromJSON(e,t){const n=this._ensureUnitMap(e);for(const s of t){let r;switch(s.type){case p.List:r=new E(s.id);break;case p.Object:r=new j(s.id);break;default:throw new Error(`Invalid source type: ${s.type}`)}r.fromJSON(s),n.set(s.id,r)}}dispose(){this._sourceDataUpdate$.complete(),this.sourceMap.clear()}}var G=Object.getOwnPropertyDescriptor,W=(i,o,e,t)=>{for(var n=t>1?void 0:t?G(o,e):o,s=i.length-1,r;s>=0;s--)(r=i[s])&&(n=r(n)||n);return n},U=(i,o)=>(e,t)=>o(e,t,i);exports.SheetsSourceBindService=class extends u.Disposable{constructor(e,t,n){super();l(this,"_bindingModel",N.Value);l(this,"_bindModelRTreeCollection",new Map);this._sheetInterceptorService=e,this._sheetsBindingManager=t,this._sheetsSourceManager=n,this._registerInterceptor(),this._registerSourceChange()}usePathMode(){this._bindingModel=N.Path}useValueMode(){this._bindingModel=N.Value}getBindingModel(){return this._bindingModel}createBindModel(e,t){return this._sheetsBindingManager.createModel(e,t)}setBindingNode(e,t,n){this._sheetsBindingManager.setBindingNode(e,t,n)}removeBindingNode(e,t,n,s){this._sheetsBindingManager.removeBindingNode(e,t,n,s)}getBindingNode(e,t,n,s){return this._sheetsBindingManager.getBindingNode(e,t,n,s)}getSource(e,t){return this._sheetsSourceManager.getSource(e,t)}createSource(e,t,n,s){return this._sheetsSourceManager.createSource(e,t,n,s)}getSourceBindingPathInfo(e){return{source:this._sheetsSourceManager.toJSON(e),cellBinding:this._sheetsBindingManager.toJSON(e)}}loadSourceBindingPathInfo(e,t){this._sheetsSourceManager.fromJSON(e,t.source),this._sheetsBindingManager.fromJSON(e,t.cellBinding)}_ensureRTreeCollection(e){return this._bindModelRTreeCollection.has(e)||this._bindModelRTreeCollection.set(e,new u.RTree),this._bindModelRTreeCollection.get(e)}_getRTeeCollection(e){return this._bindModelRTreeCollection.get(e)}_registerSourceChange(){this.disposeWithMe(this._sheetsSourceManager.sourceDataUpdate$.subscribe(e=>{const{sourceId:t,sourceType:n,unitId:s,changeType:r}=e;if(n===p.List){if(r===B.Remove){const d=this._sheetsBindingManager.getBindingModelBySourceId(t),h=e.recordCount;for(const{unitId:c,subunitId:f,nodeId:g,row:S,column:M}of d){const I=this._getRTeeCollection(s),_=this._sheetsBindingManager.getBindingNodeById(c,f,g);if(I&&(_==null?void 0:_.type)===p.List){const m=_.containHeader?0:1,v={startRow:S,startColumn:M,endRow:S+h-m,endColumn:M};I.remove({unitId:c,sheetId:f,id:g,range:v})}}return}if(r===B.Update){const d=e.oldRecordCount,h=this._sheetsBindingManager.getBindingModelBySourceId(t);for(const{unitId:c,subunitId:f,nodeId:g,row:S,column:M}of h){const I=this._getRTeeCollection(s),_=this._sheetsBindingManager.getBindingNodeById(c,f,g);if(I&&(_==null?void 0:_.type)===p.List){const m=_.containHeader?0:1,v={startRow:S,startColumn:M,endRow:S+d-m,endColumn:M},y={startRow:S,startColumn:M,endRow:S+e.recordCount-m,endColumn:M};I.remove({unitId:c,sheetId:f,id:g,range:v}),I.insert({unitId:c,sheetId:f,id:g,range:y})}}return}const a=this._sheetsSourceManager.getSource(s,t);if(a&&a.hasData()){const h=a.getSourceInfo().recordCount,c=this._sheetsBindingManager.getBindingModelBySourceId(t);for(const{unitId:f,subunitId:g,nodeId:S,row:M,column:I}of c){const _=this._ensureRTreeCollection(f),m=this._sheetsBindingManager.getBindingNodeById(f,g,S);if(_&&(m==null?void 0:m.type)===p.List){const v=m.containHeader?0:1,y={startRow:M,startColumn:I,endRow:M+h-v,endColumn:I};_.insert({unitId:f,sheetId:g,id:S,range:y})}}}}})),this.disposeWithMe(this._sheetsBindingManager.cellBindInfoUpdate$.subscribe(e=>{const{unitId:t,subunitId:n,sourceId:s,nodeId:r,row:a,column:d,changeType:h,containHeader:c}=e,f=this._ensureRTreeCollection(t),g=this._sheetsSourceManager.getSource(t,s);if(g&&g.hasData()){const S=g.getSourceInfo();if(S.sourceType===p.List){const M=S.recordCount,I=c?0:1,_={startRow:a,startColumn:d,endRow:a+M-I,endColumn:d};if(h===B.Add)f.insert({unitId:t,sheetId:n,id:r,range:_});else if(h===B.Remove)f.remove({unitId:t,sheetId:n,id:r,range:_});else if(h===B.Update){const m=e.oldSourceId,v=e.oldNodeContainHeader?0:1,y=this._sheetsSourceManager.getSource(t,m);if(y&&y.hasData()){const V=y.getSourceInfo().recordCount,L={startRow:a,startColumn:d,endRow:a+V-v,endColumn:d};f.remove({unitId:t,sheetId:n,id:r,range:L})}f.insert({unitId:t,sheetId:n,id:r,range:_})}}}}))}_getPathModeCellValue(e,t,n,s){const r=this._sheetsBindingManager.getModel(e,t),a=r==null?void 0:r.getBindingNode(n,s);if(a){const d=a.type;if(d===p.List)return{v:`#{${a.path}}`,s:{cl:{rgb:"blue"}}};if(d===p.Object)return{v:`[${a.path}]`,s:{cl:{rgb:"blue"}}}}}_getValueModeCellValue(e,t,n,s){const r=this._sheetsBindingManager.getModel(e,t);if(r){const d=r.getBindingNode(n,s);if(d){const{sourceId:h}=d,c=this._sheetsSourceManager.getSource(e,h);if(c&&c.hasData())return(c==null?void 0:c.getData(d,n,s))||{v:""}}}const a=this._getRTeeCollection(e);if(r&&a){const d={startRow:n,startColumn:s,endRow:n,endColumn:s},h=Array.from(a.bulkSearch([{unitId:e,sheetId:t,range:d}]));if(h.length>0){const c=r.getBindingNodeById(h[0]);if(c){const{sourceId:f}=c,g=this._sheetsSourceManager.getSource(e,f);if(g&&g.hasData())return(g==null?void 0:g.getData(c,n,s))||{v:""}}}}}getBindingModelBySourceId(e){return this._sheetsBindingManager.getBindingModelBySourceId(e)}_registerInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Value|u.InterceptorEffectEnum.Style,priority:102,handler:(e,t,n)=>{const{row:s,col:r,unitId:a,subUnitId:d,workbook:h}=t;let c=null;if(this._bindingModel===N.Path?c=this._getPathModeCellValue(a,d,s,r):c=this._getValueModeCellValue(a,d,s,r),c!==null){const g={...(typeof(e==null?void 0:e.s)=="string"?h.getStyles().get(e==null?void 0:e.s):e==null?void 0:e.s)||{}};return c&&c.s&&Object.assign(g,c.s),n({...e,...c,s:g})}return n(e)}}))}dispose(){this._bindModelRTreeCollection.clear()}};exports.SheetsSourceBindService=W([U(0,u.Inject(C.SheetInterceptorService)),U(1,u.Inject(b)),U(2,u.Inject(w))],exports.SheetsSourceBindService);var z=Object.getOwnPropertyDescriptor,F=(i,o,e,t)=>{for(var n=t>1?void 0:t?z(o,e):o,s=i.length-1,r;s>=0;s--)(r=i[s])&&(n=r(n)||n);return n},x=(i,o)=>(e,t)=>o(e,t,i),R;exports.UniverSheetsBindingSourcePlugin=(R=class extends u.Plugin{constructor(o={},e,t){super(),this._config=o,this._injector=e,this._configService=t}onStarting(){[[b],[w],[exports.SheetsSourceBindService]].forEach(o=>this._injector.add(o))}onReady(){u.touchDependencies(this._injector,[[b],[w],[exports.SheetsSourceBindService]])}},l(R,"type",u.UniverInstanceType.UNIVER_SHEET),l(R,"pluginName","SHEET_BINDING_SOURCE_PLUGIN"),R);exports.UniverSheetsBindingSourcePlugin=F([x(1,u.Inject(u.Injector)),x(2,u.IConfigService)],exports.UniverSheetsBindingSourcePlugin);exports.BindModeEnum=N;exports.BindingModel=O;exports.DataBindingNodeTypeEnum=p;exports.SheetsSourceManager=w;exports.SourceModelBase=T;
package/lib/es/index.js CHANGED
@@ -52,7 +52,7 @@ class $ {
52
52
  return Array.from(this._nodeMap.values());
53
53
  }
54
54
  }
55
- var g = /* @__PURE__ */ ((i) => (i.List = "list", i.Object = "object", i))(g || {}), y = /* @__PURE__ */ ((i) => (i.Path = "path", i.Value = "value", i))(y || {}), S = /* @__PURE__ */ ((i) => (i.Add = "add", i.Remove = "remove", i.Update = "update", i))(S || {});
55
+ var g = /* @__PURE__ */ ((i) => (i.List = "list", i.Object = "object", i))(g || {}), y = /* @__PURE__ */ ((i) => (i.Path = "path", i.Value = "value", i))(y || {}), m = /* @__PURE__ */ ((i) => (i.Add = "add", i.Remove = "remove", i.Update = "update", i))(m || {});
56
56
  function ie(i) {
57
57
  return i instanceof Date && !isNaN(i.getTime());
58
58
  }
@@ -112,25 +112,36 @@ class E extends U {
112
112
  this._isListObject = t;
113
113
  }
114
114
  getData(t, o) {
115
- const { path: n, row: s, containHeader: r } = t, d = this._fieldIndexMap.get(n), c = o - s;
115
+ const { path: n, row: s, containHeader: r } = t, a = this._fieldIndexMap.get(n), c = o - s;
116
116
  if (r && c === 0)
117
117
  return {
118
- v: this._data.fields[d]
118
+ v: this._data.fields[a]
119
119
  };
120
- let a;
121
- const u = r ? 1 : 0;
122
- return this._isListObject ? a = this._data.records[c - u][n] : a = this._data.records[c - u][d], t.isDate === !0 ? {
123
- v: A(a),
124
- s: {
125
- n: {
126
- pattern: "yyyy-m-d am/pm h:mm"
120
+ let d;
121
+ const h = r ? 1 : 0;
122
+ if (this._isListObject ? d = this._data.records[c - h][n] : d = this._data.records[c - h][a], t.isDate === !0) {
123
+ const u = t.formatter || "yyyy-m-d am/pm h:mm";
124
+ return {
125
+ v: A(d),
126
+ s: {
127
+ n: {
128
+ pattern: u
129
+ }
130
+ },
131
+ t: v.NUMBER
132
+ };
133
+ } else
134
+ return t.formatter ? {
135
+ v: d,
136
+ s: {
137
+ n: {
138
+ pattern: t.formatter
139
+ }
127
140
  }
128
- },
129
- t: v.NUMBER
130
- } : {
131
- t: typeof a == "number" ? v.NUMBER : v.STRING,
132
- v: a
133
- };
141
+ } : {
142
+ t: typeof d == "number" ? v.NUMBER : v.STRING,
143
+ v: d
144
+ };
134
145
  }
135
146
  setSourceData(t) {
136
147
  super.setSourceData(t);
@@ -159,18 +170,29 @@ class P extends U {
159
170
  for (const r of n)
160
171
  if (s = s[r], s === void 0)
161
172
  return null;
162
- return t.isDate === !0 ? {
163
- v: A(s),
164
- s: {
165
- n: {
166
- pattern: "yyyy-m-d am/pm h:mm"
173
+ if (t.isDate === !0) {
174
+ const r = t.formatter || "yyyy-m-d am/pm h:mm";
175
+ return {
176
+ v: A(s),
177
+ s: {
178
+ n: {
179
+ pattern: r
180
+ }
181
+ },
182
+ t: v.NUMBER
183
+ };
184
+ } else
185
+ return t.formatter ? {
186
+ v: s,
187
+ s: {
188
+ n: {
189
+ pattern: t.formatter
190
+ }
167
191
  }
168
- },
169
- t: v.NUMBER
170
- } : {
171
- v: s,
172
- t: typeof s == "number" ? v.NUMBER : v.STRING
173
- };
192
+ } : {
193
+ v: s,
194
+ t: typeof s == "number" ? v.NUMBER : v.STRING
195
+ };
174
196
  }
175
197
  getSourceInfo() {
176
198
  return {
@@ -179,8 +201,8 @@ class P extends U {
179
201
  };
180
202
  }
181
203
  }
182
- var de = Object.getOwnPropertyDescriptor, ae = (i, e, t, o) => {
183
- for (var n = o > 1 ? void 0 : o ? de(e, t) : e, s = i.length - 1, r; s >= 0; s--)
204
+ var ae = Object.getOwnPropertyDescriptor, de = (i, e, t, o) => {
205
+ for (var n = o > 1 ? void 0 : o ? ae(e, t) : e, s = i.length - 1, r; s >= 0; s--)
184
206
  (r = i[s]) && (n = r(n) || n);
185
207
  return n;
186
208
  }, b = (i, e) => (t, o) => e(t, o, i);
@@ -202,10 +224,10 @@ let N = class extends O {
202
224
  redos: [],
203
225
  undos: []
204
226
  };
205
- const { unitId: r, subUnitId: d } = s;
227
+ const { unitId: r, subUnitId: a } = s;
206
228
  return (e.id === ne.id || e.id === se.id) && n.forEach(({ range: c }) => {
207
- F.foreach(c, (a, u) => {
208
- this.getBindingNode(r, d, a, u) && this.removeBindingNode(r, d, a, u);
229
+ F.foreach(c, (d, h) => {
230
+ this.getBindingNode(r, a, d, h) && this.removeBindingNode(r, a, d, h);
209
231
  });
210
232
  }), { redos: t, undos: o };
211
233
  }
@@ -216,9 +238,9 @@ let N = class extends O {
216
238
  const t = [];
217
239
  return this.modelMap.forEach((o, n) => {
218
240
  o.forEach((s, r) => {
219
- const d = s.getBindingNodesBySourceId(e);
220
- if (d)
221
- for (const c of d)
241
+ const a = s.getBindingNodesBySourceId(e);
242
+ if (a)
243
+ for (const c of a)
222
244
  t.push({
223
245
  unitId: n,
224
246
  subunitId: r,
@@ -244,7 +266,7 @@ let N = class extends O {
244
266
  const { row: s, column: r } = o;
245
267
  if (s === void 0 || r === void 0)
246
268
  throw new Error("row and column is required");
247
- const d = n.getBindingNode(s, r), c = o.type === g.List ? !!o.containHeader : !1;
269
+ const a = n.getBindingNode(s, r), c = o.type === g.List ? !!o.containHeader : !1;
248
270
  n.setBindingNode(s, r, { ...o, row: s, column: r }), this._cellBindInfoUpdate$.next({
249
271
  unitId: e,
250
272
  subunitId: t,
@@ -253,9 +275,9 @@ let N = class extends O {
253
275
  row: s,
254
276
  column: r,
255
277
  containHeader: c,
256
- changeType: d ? S.Update : S.Add,
257
- oldSourceId: d == null ? void 0 : d.sourceId,
258
- oldNodeContainHeader: (d == null ? void 0 : d.type) === g.List ? !!d.containHeader : !1
278
+ changeType: a ? m.Update : m.Add,
279
+ oldSourceId: a == null ? void 0 : a.sourceId,
280
+ oldNodeContainHeader: (a == null ? void 0 : a.type) === g.List ? !!a.containHeader : !1
259
281
  });
260
282
  }
261
283
  removeBindingNode(e, t, o, n) {
@@ -269,7 +291,7 @@ let N = class extends O {
269
291
  nodeId: r.nodeId,
270
292
  row: o,
271
293
  column: n,
272
- changeType: S.Remove
294
+ changeType: m.Remove
273
295
  }));
274
296
  }
275
297
  }
@@ -302,7 +324,7 @@ let N = class extends O {
302
324
  this.modelMap.clear(), this._cellBindInfoUpdate$.complete();
303
325
  }
304
326
  };
305
- N = ae([
327
+ N = de([
306
328
  b(0, z),
307
329
  b(1, C(V)),
308
330
  b(2, C(te))
@@ -327,29 +349,29 @@ class T extends O {
327
349
  }
328
350
  createSource(t, o, n, s) {
329
351
  const r = s === void 0 ? J() : s;
330
- let d;
352
+ let a;
331
353
  switch (o) {
332
354
  case g.List:
333
- d = new E(r, n);
355
+ a = new E(r, n);
334
356
  break;
335
357
  case g.Object:
336
- d = new P(r);
358
+ a = new P(r);
337
359
  break;
338
360
  default:
339
361
  throw new Error(`Invalid source type: ${o}`);
340
362
  }
341
- return this._ensureUnitMap(t).set(r, d), d;
363
+ return this._ensureUnitMap(t).set(r, a), a;
342
364
  }
343
365
  updateSourceData(t, o, n) {
344
- const s = this._getUnitMap(t), r = o instanceof U ? o.getId() : o, d = s == null ? void 0 : s.get(r);
345
- if (d)
346
- d.setSourceData(n), this._sourceDataUpdate$.next({ ...d.getSourceInfo(), unitId: t, changeType: S.Add });
366
+ const s = this._getUnitMap(t), r = o instanceof U ? o.getId() : o, a = s == null ? void 0 : s.get(r);
367
+ if (a)
368
+ a.setSourceData(n), this._sourceDataUpdate$.next({ ...a.getSourceInfo(), unitId: t, changeType: m.Add });
347
369
  else
348
370
  throw new Error(`Source not found: ${r}`);
349
371
  }
350
372
  removeSource(t, o) {
351
373
  const n = this._getUnitMap(t), s = n == null ? void 0 : n.get(o);
352
- s && (n == null || n.delete(o), this._sourceDataUpdate$.next({ ...s.getSourceInfo(), unitId: t, changeType: S.Remove }));
374
+ s && (n == null || n.delete(o), this._sourceDataUpdate$.next({ ...s.getSourceInfo(), unitId: t, changeType: m.Remove }));
353
375
  }
354
376
  toJSON(t) {
355
377
  const o = [], n = this._getUnitMap(t);
@@ -448,57 +470,57 @@ let R = class extends O {
448
470
  this.disposeWithMe(this._sheetsSourceManager.sourceDataUpdate$.subscribe((e) => {
449
471
  const { sourceId: t, sourceType: o, unitId: n, changeType: s } = e;
450
472
  if (o === g.List) {
451
- if (s === S.Remove) {
452
- const d = this._sheetsBindingManager.getBindingModelBySourceId(t), c = e.recordCount;
453
- for (const { unitId: a, subunitId: u, nodeId: h, row: p, column: _ } of d) {
454
- const M = this._getRTeeCollection(n), f = this._sheetsBindingManager.getBindingNodeById(a, u, h);
473
+ if (s === m.Remove) {
474
+ const a = this._sheetsBindingManager.getBindingModelBySourceId(t), c = e.recordCount;
475
+ for (const { unitId: d, subunitId: h, nodeId: u, row: p, column: _ } of a) {
476
+ const M = this._getRTeeCollection(n), f = this._sheetsBindingManager.getBindingNodeById(d, h, u);
455
477
  if (M && (f == null ? void 0 : f.type) === g.List) {
456
- const I = f.containHeader ? 0 : 1, m = { startRow: p, startColumn: _, endRow: p + c - I, endColumn: _ };
457
- M.remove({ unitId: a, sheetId: u, id: h, range: m });
478
+ const I = f.containHeader ? 0 : 1, S = { startRow: p, startColumn: _, endRow: p + c - I, endColumn: _ };
479
+ M.remove({ unitId: d, sheetId: h, id: u, range: S });
458
480
  }
459
481
  }
460
482
  return;
461
483
  }
462
- if (s === S.Update) {
463
- const d = e.oldRecordCount, c = this._sheetsBindingManager.getBindingModelBySourceId(t);
464
- for (const { unitId: a, subunitId: u, nodeId: h, row: p, column: _ } of c) {
465
- const M = this._getRTeeCollection(n), f = this._sheetsBindingManager.getBindingNodeById(a, u, h);
484
+ if (s === m.Update) {
485
+ const a = e.oldRecordCount, c = this._sheetsBindingManager.getBindingModelBySourceId(t);
486
+ for (const { unitId: d, subunitId: h, nodeId: u, row: p, column: _ } of c) {
487
+ const M = this._getRTeeCollection(n), f = this._sheetsBindingManager.getBindingNodeById(d, h, u);
466
488
  if (M && (f == null ? void 0 : f.type) === g.List) {
467
- const I = f.containHeader ? 0 : 1, m = { startRow: p, startColumn: _, endRow: p + d - I, endColumn: _ }, B = { startRow: p, startColumn: _, endRow: p + e.recordCount - I, endColumn: _ };
468
- M.remove({ unitId: a, sheetId: u, id: h, range: m }), M.insert({ unitId: a, sheetId: u, id: h, range: B });
489
+ const I = f.containHeader ? 0 : 1, S = { startRow: p, startColumn: _, endRow: p + a - I, endColumn: _ }, B = { startRow: p, startColumn: _, endRow: p + e.recordCount - I, endColumn: _ };
490
+ M.remove({ unitId: d, sheetId: h, id: u, range: S }), M.insert({ unitId: d, sheetId: h, id: u, range: B });
469
491
  }
470
492
  }
471
493
  return;
472
494
  }
473
495
  const r = this._sheetsSourceManager.getSource(n, t);
474
496
  if (r && r.hasData()) {
475
- const c = r.getSourceInfo().recordCount, a = this._sheetsBindingManager.getBindingModelBySourceId(t);
476
- for (const { unitId: u, subunitId: h, nodeId: p, row: _, column: M } of a) {
477
- const f = this._ensureRTreeCollection(u), I = this._sheetsBindingManager.getBindingNodeById(u, h, p);
497
+ const c = r.getSourceInfo().recordCount, d = this._sheetsBindingManager.getBindingModelBySourceId(t);
498
+ for (const { unitId: h, subunitId: u, nodeId: p, row: _, column: M } of d) {
499
+ const f = this._ensureRTreeCollection(h), I = this._sheetsBindingManager.getBindingNodeById(h, u, p);
478
500
  if (f && (I == null ? void 0 : I.type) === g.List) {
479
- const m = I.containHeader ? 0 : 1, B = { startRow: _, startColumn: M, endRow: _ + c - m, endColumn: M };
480
- f.insert({ unitId: u, sheetId: h, id: p, range: B });
501
+ const S = I.containHeader ? 0 : 1, B = { startRow: _, startColumn: M, endRow: _ + c - S, endColumn: M };
502
+ f.insert({ unitId: h, sheetId: u, id: p, range: B });
481
503
  }
482
504
  }
483
505
  }
484
506
  }
485
507
  })), this.disposeWithMe(this._sheetsBindingManager.cellBindInfoUpdate$.subscribe((e) => {
486
- const { unitId: t, subunitId: o, sourceId: n, nodeId: s, row: r, column: d, changeType: c, containHeader: a } = e, u = this._ensureRTreeCollection(t), h = this._sheetsSourceManager.getSource(t, n);
487
- if (h && h.hasData()) {
488
- const p = h.getSourceInfo();
508
+ const { unitId: t, subunitId: o, sourceId: n, nodeId: s, row: r, column: a, changeType: c, containHeader: d } = e, h = this._ensureRTreeCollection(t), u = this._sheetsSourceManager.getSource(t, n);
509
+ if (u && u.hasData()) {
510
+ const p = u.getSourceInfo();
489
511
  if (p.sourceType === g.List) {
490
- const _ = p.recordCount, M = a ? 0 : 1, f = { startRow: r, startColumn: d, endRow: r + _ - M, endColumn: d };
491
- if (c === S.Add)
492
- u.insert({ unitId: t, sheetId: o, id: s, range: f });
493
- else if (c === S.Remove)
494
- u.remove({ unitId: t, sheetId: o, id: s, range: f });
495
- else if (c === S.Update) {
496
- const I = e.oldSourceId, m = e.oldNodeContainHeader ? 0 : 1, B = this._sheetsSourceManager.getSource(t, I);
512
+ const _ = p.recordCount, M = d ? 0 : 1, f = { startRow: r, startColumn: a, endRow: r + _ - M, endColumn: a };
513
+ if (c === m.Add)
514
+ h.insert({ unitId: t, sheetId: o, id: s, range: f });
515
+ else if (c === m.Remove)
516
+ h.remove({ unitId: t, sheetId: o, id: s, range: f });
517
+ else if (c === m.Update) {
518
+ const I = e.oldSourceId, S = e.oldNodeContainHeader ? 0 : 1, B = this._sheetsSourceManager.getSource(t, I);
497
519
  if (B && B.hasData()) {
498
- const k = B.getSourceInfo().recordCount, G = { startRow: r, startColumn: d, endRow: r + k - m, endColumn: d };
499
- u.remove({ unitId: t, sheetId: o, id: s, range: G });
520
+ const k = B.getSourceInfo().recordCount, G = { startRow: r, startColumn: a, endRow: r + k - S, endColumn: a };
521
+ h.remove({ unitId: t, sheetId: o, id: s, range: G });
500
522
  }
501
- u.insert({ unitId: t, sheetId: o, id: s, range: f });
523
+ h.insert({ unitId: t, sheetId: o, id: s, range: f });
502
524
  }
503
525
  }
504
526
  }
@@ -507,13 +529,13 @@ let R = class extends O {
507
529
  _getPathModeCellValue(e, t, o, n) {
508
530
  const s = this._sheetsBindingManager.getModel(e, t), r = s == null ? void 0 : s.getBindingNode(o, n);
509
531
  if (r) {
510
- const d = r.type;
511
- if (d === g.List)
532
+ const a = r.type;
533
+ if (a === g.List)
512
534
  return {
513
535
  v: `#{${r.path}}`,
514
536
  s: { cl: { rgb: "blue" } }
515
537
  };
516
- if (d === g.Object)
538
+ if (a === g.Object)
517
539
  return {
518
540
  v: `[${r.path}]`,
519
541
  s: { cl: { rgb: "blue" } }
@@ -523,22 +545,22 @@ let R = class extends O {
523
545
  _getValueModeCellValue(e, t, o, n) {
524
546
  const s = this._sheetsBindingManager.getModel(e, t);
525
547
  if (s) {
526
- const d = s.getBindingNode(o, n);
527
- if (d) {
528
- const { sourceId: c } = d, a = this._sheetsSourceManager.getSource(e, c);
529
- if (a && a.hasData())
530
- return (a == null ? void 0 : a.getData(d, o, n)) || { v: "" };
548
+ const a = s.getBindingNode(o, n);
549
+ if (a) {
550
+ const { sourceId: c } = a, d = this._sheetsSourceManager.getSource(e, c);
551
+ if (d && d.hasData())
552
+ return (d == null ? void 0 : d.getData(a, o, n)) || { v: "" };
531
553
  }
532
554
  }
533
555
  const r = this._getRTeeCollection(e);
534
556
  if (s && r) {
535
- const d = { startRow: o, startColumn: n, endRow: o, endColumn: n }, c = Array.from(r.bulkSearch([{ unitId: e, sheetId: t, range: d }]));
557
+ const a = { startRow: o, startColumn: n, endRow: o, endColumn: n }, c = Array.from(r.bulkSearch([{ unitId: e, sheetId: t, range: a }]));
536
558
  if (c.length > 0) {
537
- const a = s.getBindingNodeById(c[0]);
538
- if (a) {
539
- const { sourceId: u } = a, h = this._sheetsSourceManager.getSource(e, u);
540
- if (h && h.hasData())
541
- return (h == null ? void 0 : h.getData(a, o, n)) || { v: "" };
559
+ const d = s.getBindingNodeById(c[0]);
560
+ if (d) {
561
+ const { sourceId: h } = d, u = this._sheetsSourceManager.getSource(e, h);
562
+ if (u && u.hasData())
563
+ return (u == null ? void 0 : u.getData(d, o, n)) || { v: "" };
542
564
  }
543
565
  }
544
566
  }
@@ -551,11 +573,11 @@ let R = class extends O {
551
573
  effect: x.Value | x.Style,
552
574
  priority: 102,
553
575
  handler: (e, t, o) => {
554
- const { row: n, col: s, unitId: r, subUnitId: d, workbook: c } = t;
555
- let a = null;
556
- if (this._bindingModel === y.Path ? a = this._getPathModeCellValue(r, d, n, s) : a = this._getValueModeCellValue(r, d, n, s), a !== null) {
557
- const h = { ...(typeof (e == null ? void 0 : e.s) == "string" ? c.getStyles().get(e == null ? void 0 : e.s) : e == null ? void 0 : e.s) || {} };
558
- return a && a.s && Object.assign(h, a.s), o({ ...e, ...a, s: h });
576
+ const { row: n, col: s, unitId: r, subUnitId: a, workbook: c } = t;
577
+ let d = null;
578
+ if (this._bindingModel === y.Path ? d = this._getPathModeCellValue(r, a, n, s) : d = this._getValueModeCellValue(r, a, n, s), d !== null) {
579
+ const u = { ...(typeof (e == null ? void 0 : e.s) == "string" ? c.getStyles().get(e == null ? void 0 : e.s) : e == null ? void 0 : e.s) || {} };
580
+ return d && d.s && Object.assign(u, d.s), o({ ...e, ...d, s: u });
559
581
  }
560
582
  return o(e);
561
583
  }
@@ -94,6 +94,10 @@ export interface ICellBindingNodeParam {
94
94
  */
95
95
  isDate?: boolean;
96
96
  nodeId?: string;
97
+ /**
98
+ * The formatter of the binding node, the formatter will be applied to the binding value.
99
+ */
100
+ formatter?: string;
97
101
  }
98
102
  export interface ICellBindingNode extends ICellBindingNodeParam {
99
103
  /**
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(h,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],a):(h=typeof globalThis<"u"?globalThis:h||self,a(h.UniverSheetsSourceBinding={},h.UniverCore,h.UniverSheets,h.rxjs))})(this,function(h,a,I,E){"use strict";var F=Object.defineProperty;var K=(h,a,I)=>a in h?F(h,a,{enumerable:!0,configurable:!0,writable:!0,value:I}):h[a]=I;var g=(h,a,I)=>K(h,typeof a!="symbol"?a+"":a,I);var D;class U{constructor(o){g(this,"_matrix",{});g(this,"_nodeMap",new Map);g(this,"_sourceIdMap",new Map);o&&this._init(o)}_init(o){this.fromJSON(o)}getBindingNodesBySourceId(o){const e=this._sourceIdMap.get(o);if(e)return e.map(t=>this._nodeMap.get(t))}setBindingNode(o,e,t){this._matrix[o]||(this._matrix[o]={}),this._matrix[o][e]||(this._matrix[o][e]=t),this._nodeMap.set(t.nodeId,t);const n=this._sourceIdMap.get(t.sourceId);n?n.push(t.nodeId):this._sourceIdMap.set(t.sourceId,[t.nodeId])}getBindingNode(o,e){var t;return(t=this._matrix[o])==null?void 0:t[e]}removeBindingNode(o,e){var n;const t=(n=this._matrix[o])==null?void 0:n[e];if(t){this._matrix[o][e]=void 0,this._nodeMap.delete(t.nodeId);const s=this._sourceIdMap.get(t.sourceId);if(s){const i=s.indexOf(t.nodeId);i>=0&&s.splice(i,1),s.length===0&&this._sourceIdMap.delete(t.sourceId)}}}getBindingNodeById(o){return this._nodeMap.get(o)}fromJSON(o){o.forEach(e=>{this.setBindingNode(e.row,e.column,e)})}toJSON(){return Array.from(this._nodeMap.values())}}var _=(d=>(d.List="list",d.Object="object",d))(_||{}),R=(d=>(d.Path="path",d.Value="value",d))(R||{}),B=(d=>(d.Add="add",d.Remove="remove",d.Update="update",d))(B||{});function x(d){return d instanceof Date&&!isNaN(d.getTime())}function P(d){const o=new Date(d);if(!x(o))return d;const e=new Date(Date.UTC(1900,0,1,0,0,0)),t=new Date(Date.UTC(1900,1,28,0,0,0));let s=(o.getTime()-e.getTime())/(1e3*3600*24);return o>t&&(s+=1),s+1}class w{constructor(o){g(this,"_data");g(this,"id");g(this,"_hasData",!1);g(this,"type");this.id=o}getId(){return this.id}getType(){return this.type}hasData(){return this._hasData}setSourceData(o){this._data=o,this._hasData=!0}toJSON(){return{id:this.id,type:this.type}}fromJSON(o){this.id=o.id,this.type=o.type}}class $ extends w{constructor(e,t){super(e);g(this,"type",_.List);g(this,"_isListObject");g(this,"_fieldIndexMap",new Map);g(this,"_data",{fields:[],records:[]});this._isListObject=t!=null?t:!0}toggleListObject(e){this._isListObject=e}getData(e,t){const{path:n,row:s,containHeader:i}=e,r=this._fieldIndexMap.get(n),c=t-s;if(i&&c===0)return{v:this._data.fields[r]};let l;const u=i?1:0;return this._isListObject?l=this._data.records[c-u][n]:l=this._data.records[c-u][r],e.isDate===!0?{v:P(l),s:{n:{pattern:"yyyy-m-d am/pm h:mm"}},t:a.CellValueType.NUMBER}:{t:typeof l=="number"?a.CellValueType.NUMBER:a.CellValueType.STRING,v:l}}setSourceData(e){super.setSourceData(e);const{fields:t}=e;this._fieldIndexMap.clear(),t.forEach((n,s)=>{this._fieldIndexMap.set(n,s)})}getSourceInfo(){return{sourceId:this.id,sourceType:this.type,fields:this._data.fields,recordCount:this._data.records.length}}}class V extends w{constructor(e){super(e);g(this,"type",_.Object)}getData(e){const n=e.path.split(".");let s=this._data;for(const i of n)if(s=s[i],s===void 0)return null;return e.isDate===!0?{v:P(s),s:{n:{pattern:"yyyy-m-d am/pm h:mm"}},t:a.CellValueType.NUMBER}:{v:s,t:typeof s=="number"?a.CellValueType.NUMBER:a.CellValueType.STRING}}getSourceInfo(){return{sourceId:this.id,sourceType:_.Object}}}var J=Object.getOwnPropertyDescriptor,H=(d,o,e,t)=>{for(var n=t>1?void 0:t?J(o,e):o,s=d.length-1,i;s>=0;s--)(i=d[s])&&(n=i(n)||n);return n},O=(d,o)=>(e,t)=>o(e,t,d);let b=class extends a.Disposable{constructor(o,e,t){super();g(this,"modelMap",new Map);g(this,"_cellBindInfoUpdate$",new E.Subject);g(this,"cellBindInfoUpdate$",this._cellBindInfoUpdate$.asObservable());this._univerInstanceService=o,this._sheetInterceptorService=e,this._sheetsSelectionsService=t,this._initRemoveCommand()}_initRemoveCommand(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{const e=[],t=[],n=this._sheetsSelectionsService.getCurrentSelections(),s=I.getSheetCommandTarget(this._univerInstanceService);if(!s||!n||n.length===0)return{redos:[],undos:[]};const{unitId:i,subUnitId:r}=s;return(o.id===I.ClearSelectionContentCommand.id||o.id===I.ClearSelectionAllCommand.id)&&n.forEach(({range:c})=>{a.Range.foreach(c,(l,u)=>{this.getBindingNode(i,r,l,u)&&this.removeBindingNode(i,r,l,u)})}),{redos:e,undos:t}}}))}getBindingModelBySourceId(o){const e=[];return this.modelMap.forEach((t,n)=>{t.forEach((s,i)=>{const r=s.getBindingNodesBySourceId(o);if(r)for(const c of r)e.push({unitId:n,subunitId:i,sourceId:o,nodeId:c.nodeId,row:c.row,column:c.column})})}),e}addModel(o,e,t){var n;this.modelMap.has(o)||this.modelMap.set(o,new Map),(n=this.modelMap.get(o))==null||n.set(e,t)}getModel(o,e){var t;return(t=this.modelMap.get(o))==null?void 0:t.get(e)}setBindingNode(o,e,t){let n=this.getModel(o,e);n||(n=new U,this.addModel(o,e,n)),t.nodeId||(t.nodeId=a.generateRandomId());const{row:s,column:i}=t;if(s===void 0||i===void 0)throw new Error("row and column is required");const r=n.getBindingNode(s,i),c=t.type===_.List?!!t.containHeader:!1;n.setBindingNode(s,i,{...t,row:s,column:i}),this._cellBindInfoUpdate$.next({unitId:o,subunitId:e,sourceId:t.sourceId,nodeId:t.nodeId,row:s,column:i,containHeader:c,changeType:r?B.Update:B.Add,oldSourceId:r==null?void 0:r.sourceId,oldNodeContainHeader:(r==null?void 0:r.type)===_.List?!!r.containHeader:!1})}removeBindingNode(o,e,t,n){const s=this.getModel(o,e);if(s){const i=s.getBindingNode(t,n);i&&(s.removeBindingNode(t,n),this._cellBindInfoUpdate$.next({unitId:o,subunitId:e,sourceId:i.sourceId,nodeId:i.nodeId,row:t,column:n,changeType:B.Remove}))}}getBindingNode(o,e,t,n){const s=this.getModel(o,e);if(s)return s.getBindingNode(t,n)}getBindingNodeById(o,e,t){const n=this.getModel(o,e);if(n)return n.getBindingNodeById(t)}createModel(o,e,t){const n=new U(t);return this.addModel(o,e,n),n}toJSON(o){const e={},t=this.modelMap.get(o);return t&&t.forEach((n,s)=>{e[s]=n.toJSON()}),e}fromJSON(o,e){Object.entries(e).forEach(([t,n])=>{this.createModel(o,t,n)})}dispose(){this.modelMap.clear(),this._cellBindInfoUpdate$.complete()}};b=H([O(0,a.IUniverInstanceService),O(1,a.Inject(I.SheetInterceptorService)),O(2,a.Inject(I.SheetsSelectionsService))],b);class T extends a.Disposable{constructor(){super();g(this,"sourceMap",new Map);g(this,"_sourceDataUpdate$",new E.Subject);g(this,"sourceDataUpdate$",this._sourceDataUpdate$.asObservable())}_ensureUnitMap(e){let t=this.sourceMap.get(e);return t||(t=new Map,this.sourceMap.set(e,t)),t}_getUnitMap(e){return this.sourceMap.get(e)}getSource(e,t){const n=this._getUnitMap(e);return n==null?void 0:n.get(t)}createSource(e,t,n,s){const i=s===void 0?a.generateRandomId():s;let r;switch(t){case _.List:r=new $(i,n);break;case _.Object:r=new V(i);break;default:throw new Error(`Invalid source type: ${t}`)}return this._ensureUnitMap(e).set(i,r),r}updateSourceData(e,t,n){const s=this._getUnitMap(e),i=t instanceof w?t.getId():t,r=s==null?void 0:s.get(i);if(r)r.setSourceData(n),this._sourceDataUpdate$.next({...r.getSourceInfo(),unitId:e,changeType:B.Add});else throw new Error(`Source not found: ${i}`)}removeSource(e,t){const n=this._getUnitMap(e),s=n==null?void 0:n.get(t);s&&(n==null||n.delete(t),this._sourceDataUpdate$.next({...s.getSourceInfo(),unitId:e,changeType:B.Remove}))}toJSON(e){const t=[],n=this._getUnitMap(e);if(n)for(const s of n.values())t.push(s.toJSON());return t}fromJSON(e,t){const n=this._ensureUnitMap(e);for(const s of t){let i;switch(s.type){case _.List:i=new $(s.id);break;case _.Object:i=new V(s.id);break;default:throw new Error(`Invalid source type: ${s.type}`)}i.fromJSON(s),n.set(s.id,i)}}dispose(){this._sourceDataUpdate$.complete(),this.sourceMap.clear()}}var A=Object.getOwnPropertyDescriptor,k=(d,o,e,t)=>{for(var n=t>1?void 0:t?A(o,e):o,s=d.length-1,i;s>=0;s--)(i=d[s])&&(n=i(n)||n);return n},j=(d,o)=>(e,t)=>o(e,t,d);h.SheetsSourceBindService=class extends a.Disposable{constructor(e,t,n){super();g(this,"_bindingModel",R.Value);g(this,"_bindModelRTreeCollection",new Map);this._sheetInterceptorService=e,this._sheetsBindingManager=t,this._sheetsSourceManager=n,this._registerInterceptor(),this._registerSourceChange()}usePathMode(){this._bindingModel=R.Path}useValueMode(){this._bindingModel=R.Value}getBindingModel(){return this._bindingModel}createBindModel(e,t){return this._sheetsBindingManager.createModel(e,t)}setBindingNode(e,t,n){this._sheetsBindingManager.setBindingNode(e,t,n)}removeBindingNode(e,t,n,s){this._sheetsBindingManager.removeBindingNode(e,t,n,s)}getBindingNode(e,t,n,s){return this._sheetsBindingManager.getBindingNode(e,t,n,s)}getSource(e,t){return this._sheetsSourceManager.getSource(e,t)}createSource(e,t,n,s){return this._sheetsSourceManager.createSource(e,t,n,s)}getSourceBindingPathInfo(e){return{source:this._sheetsSourceManager.toJSON(e),cellBinding:this._sheetsBindingManager.toJSON(e)}}loadSourceBindingPathInfo(e,t){this._sheetsSourceManager.fromJSON(e,t.source),this._sheetsBindingManager.fromJSON(e,t.cellBinding)}_ensureRTreeCollection(e){return this._bindModelRTreeCollection.has(e)||this._bindModelRTreeCollection.set(e,new a.RTree),this._bindModelRTreeCollection.get(e)}_getRTeeCollection(e){return this._bindModelRTreeCollection.get(e)}_registerSourceChange(){this.disposeWithMe(this._sheetsSourceManager.sourceDataUpdate$.subscribe(e=>{const{sourceId:t,sourceType:n,unitId:s,changeType:i}=e;if(n===_.List){if(i===B.Remove){const c=this._sheetsBindingManager.getBindingModelBySourceId(t),l=e.recordCount;for(const{unitId:u,subunitId:p,nodeId:f,row:M,column:m}of c){const v=this._getRTeeCollection(s),S=this._sheetsBindingManager.getBindingNodeById(u,p,f);if(v&&(S==null?void 0:S.type)===_.List){const y=S.containHeader?0:1,C={startRow:M,startColumn:m,endRow:M+l-y,endColumn:m};v.remove({unitId:u,sheetId:p,id:f,range:C})}}return}if(i===B.Update){const c=e.oldRecordCount,l=this._sheetsBindingManager.getBindingModelBySourceId(t);for(const{unitId:u,subunitId:p,nodeId:f,row:M,column:m}of l){const v=this._getRTeeCollection(s),S=this._sheetsBindingManager.getBindingNodeById(u,p,f);if(v&&(S==null?void 0:S.type)===_.List){const y=S.containHeader?0:1,C={startRow:M,startColumn:m,endRow:M+c-y,endColumn:m},N={startRow:M,startColumn:m,endRow:M+e.recordCount-y,endColumn:m};v.remove({unitId:u,sheetId:p,id:f,range:C}),v.insert({unitId:u,sheetId:p,id:f,range:N})}}return}const r=this._sheetsSourceManager.getSource(s,t);if(r&&r.hasData()){const l=r.getSourceInfo().recordCount,u=this._sheetsBindingManager.getBindingModelBySourceId(t);for(const{unitId:p,subunitId:f,nodeId:M,row:m,column:v}of u){const S=this._ensureRTreeCollection(p),y=this._sheetsBindingManager.getBindingNodeById(p,f,M);if(S&&(y==null?void 0:y.type)===_.List){const C=y.containHeader?0:1,N={startRow:m,startColumn:v,endRow:m+l-C,endColumn:v};S.insert({unitId:p,sheetId:f,id:M,range:N})}}}}})),this.disposeWithMe(this._sheetsBindingManager.cellBindInfoUpdate$.subscribe(e=>{const{unitId:t,subunitId:n,sourceId:s,nodeId:i,row:r,column:c,changeType:l,containHeader:u}=e,p=this._ensureRTreeCollection(t),f=this._sheetsSourceManager.getSource(t,s);if(f&&f.hasData()){const M=f.getSourceInfo();if(M.sourceType===_.List){const m=M.recordCount,v=u?0:1,S={startRow:r,startColumn:c,endRow:r+m-v,endColumn:c};if(l===B.Add)p.insert({unitId:t,sheetId:n,id:i,range:S});else if(l===B.Remove)p.remove({unitId:t,sheetId:n,id:i,range:S});else if(l===B.Update){const y=e.oldSourceId,C=e.oldNodeContainHeader?0:1,N=this._sheetsSourceManager.getSource(t,y);if(N&&N.hasData()){const W=N.getSourceInfo().recordCount,z={startRow:r,startColumn:c,endRow:r+W-C,endColumn:c};p.remove({unitId:t,sheetId:n,id:i,range:z})}p.insert({unitId:t,sheetId:n,id:i,range:S})}}}}))}_getPathModeCellValue(e,t,n,s){const i=this._sheetsBindingManager.getModel(e,t),r=i==null?void 0:i.getBindingNode(n,s);if(r){const c=r.type;if(c===_.List)return{v:`#{${r.path}}`,s:{cl:{rgb:"blue"}}};if(c===_.Object)return{v:`[${r.path}]`,s:{cl:{rgb:"blue"}}}}}_getValueModeCellValue(e,t,n,s){const i=this._sheetsBindingManager.getModel(e,t);if(i){const c=i.getBindingNode(n,s);if(c){const{sourceId:l}=c,u=this._sheetsSourceManager.getSource(e,l);if(u&&u.hasData())return(u==null?void 0:u.getData(c,n,s))||{v:""}}}const r=this._getRTeeCollection(e);if(i&&r){const c={startRow:n,startColumn:s,endRow:n,endColumn:s},l=Array.from(r.bulkSearch([{unitId:e,sheetId:t,range:c}]));if(l.length>0){const u=i.getBindingNodeById(l[0]);if(u){const{sourceId:p}=u,f=this._sheetsSourceManager.getSource(e,p);if(f&&f.hasData())return(f==null?void 0:f.getData(u,n,s))||{v:""}}}}}getBindingModelBySourceId(e){return this._sheetsBindingManager.getBindingModelBySourceId(e)}_registerInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Value|a.InterceptorEffectEnum.Style,priority:102,handler:(e,t,n)=>{const{row:s,col:i,unitId:r,subUnitId:c,workbook:l}=t;let u=null;if(this._bindingModel===R.Path?u=this._getPathModeCellValue(r,c,s,i):u=this._getValueModeCellValue(r,c,s,i),u!==null){const f={...(typeof(e==null?void 0:e.s)=="string"?l.getStyles().get(e==null?void 0:e.s):e==null?void 0:e.s)||{}};return u&&u.s&&Object.assign(f,u.s),n({...e,...u,s:f})}return n(e)}}))}dispose(){this._bindModelRTreeCollection.clear()}},h.SheetsSourceBindService=k([j(0,a.Inject(I.SheetInterceptorService)),j(1,a.Inject(b)),j(2,a.Inject(T))],h.SheetsSourceBindService);var q=Object.getOwnPropertyDescriptor,G=(d,o,e,t)=>{for(var n=t>1?void 0:t?q(o,e):o,s=d.length-1,i;s>=0;s--)(i=d[s])&&(n=i(n)||n);return n},L=(d,o)=>(e,t)=>o(e,t,d);h.UniverSheetsBindingSourcePlugin=(D=class extends a.Plugin{constructor(o={},e,t){super(),this._config=o,this._injector=e,this._configService=t}onStarting(){[[b],[T],[h.SheetsSourceBindService]].forEach(o=>this._injector.add(o))}onReady(){a.touchDependencies(this._injector,[[b],[T],[h.SheetsSourceBindService]])}},g(D,"type",a.UniverInstanceType.UNIVER_SHEET),g(D,"pluginName","SHEET_BINDING_SOURCE_PLUGIN"),D),h.UniverSheetsBindingSourcePlugin=G([L(1,a.Inject(a.Injector)),L(2,a.IConfigService)],h.UniverSheetsBindingSourcePlugin),h.BindModeEnum=R,h.BindingModel=U,h.DataBindingNodeTypeEnum=_,h.SheetsSourceManager=T,h.SourceModelBase=w,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
1
+ (function(h,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],a):(h=typeof globalThis<"u"?globalThis:h||self,a(h.UniverSheetsSourceBinding={},h.UniverCore,h.UniverSheets,h.rxjs))})(this,function(h,a,I,E){"use strict";var F=Object.defineProperty;var K=(h,a,I)=>a in h?F(h,a,{enumerable:!0,configurable:!0,writable:!0,value:I}):h[a]=I;var g=(h,a,I)=>K(h,typeof a!="symbol"?a+"":a,I);var D;class U{constructor(o){g(this,"_matrix",{});g(this,"_nodeMap",new Map);g(this,"_sourceIdMap",new Map);o&&this._init(o)}_init(o){this.fromJSON(o)}getBindingNodesBySourceId(o){const e=this._sourceIdMap.get(o);if(e)return e.map(t=>this._nodeMap.get(t))}setBindingNode(o,e,t){this._matrix[o]||(this._matrix[o]={}),this._matrix[o][e]||(this._matrix[o][e]=t),this._nodeMap.set(t.nodeId,t);const n=this._sourceIdMap.get(t.sourceId);n?n.push(t.nodeId):this._sourceIdMap.set(t.sourceId,[t.nodeId])}getBindingNode(o,e){var t;return(t=this._matrix[o])==null?void 0:t[e]}removeBindingNode(o,e){var n;const t=(n=this._matrix[o])==null?void 0:n[e];if(t){this._matrix[o][e]=void 0,this._nodeMap.delete(t.nodeId);const s=this._sourceIdMap.get(t.sourceId);if(s){const i=s.indexOf(t.nodeId);i>=0&&s.splice(i,1),s.length===0&&this._sourceIdMap.delete(t.sourceId)}}}getBindingNodeById(o){return this._nodeMap.get(o)}fromJSON(o){o.forEach(e=>{this.setBindingNode(e.row,e.column,e)})}toJSON(){return Array.from(this._nodeMap.values())}}var _=(d=>(d.List="list",d.Object="object",d))(_||{}),R=(d=>(d.Path="path",d.Value="value",d))(R||{}),v=(d=>(d.Add="add",d.Remove="remove",d.Update="update",d))(v||{});function x(d){return d instanceof Date&&!isNaN(d.getTime())}function P(d){const o=new Date(d);if(!x(o))return d;const e=new Date(Date.UTC(1900,0,1,0,0,0)),t=new Date(Date.UTC(1900,1,28,0,0,0));let s=(o.getTime()-e.getTime())/(1e3*3600*24);return o>t&&(s+=1),s+1}class w{constructor(o){g(this,"_data");g(this,"id");g(this,"_hasData",!1);g(this,"type");this.id=o}getId(){return this.id}getType(){return this.type}hasData(){return this._hasData}setSourceData(o){this._data=o,this._hasData=!0}toJSON(){return{id:this.id,type:this.type}}fromJSON(o){this.id=o.id,this.type=o.type}}class $ extends w{constructor(e,t){super(e);g(this,"type",_.List);g(this,"_isListObject");g(this,"_fieldIndexMap",new Map);g(this,"_data",{fields:[],records:[]});this._isListObject=t!=null?t:!0}toggleListObject(e){this._isListObject=e}getData(e,t){const{path:n,row:s,containHeader:i}=e,r=this._fieldIndexMap.get(n),c=t-s;if(i&&c===0)return{v:this._data.fields[r]};let l;const u=i?1:0;if(this._isListObject?l=this._data.records[c-u][n]:l=this._data.records[c-u][r],e.isDate===!0){const p=e.formatter||"yyyy-m-d am/pm h:mm";return{v:P(l),s:{n:{pattern:p}},t:a.CellValueType.NUMBER}}else return e.formatter?{v:l,s:{n:{pattern:e.formatter}}}:{t:typeof l=="number"?a.CellValueType.NUMBER:a.CellValueType.STRING,v:l}}setSourceData(e){super.setSourceData(e);const{fields:t}=e;this._fieldIndexMap.clear(),t.forEach((n,s)=>{this._fieldIndexMap.set(n,s)})}getSourceInfo(){return{sourceId:this.id,sourceType:this.type,fields:this._data.fields,recordCount:this._data.records.length}}}class V extends w{constructor(e){super(e);g(this,"type",_.Object)}getData(e){const n=e.path.split(".");let s=this._data;for(const i of n)if(s=s[i],s===void 0)return null;if(e.isDate===!0){const i=e.formatter||"yyyy-m-d am/pm h:mm";return{v:P(s),s:{n:{pattern:i}},t:a.CellValueType.NUMBER}}else return e.formatter?{v:s,s:{n:{pattern:e.formatter}}}:{v:s,t:typeof s=="number"?a.CellValueType.NUMBER:a.CellValueType.STRING}}getSourceInfo(){return{sourceId:this.id,sourceType:_.Object}}}var J=Object.getOwnPropertyDescriptor,H=(d,o,e,t)=>{for(var n=t>1?void 0:t?J(o,e):o,s=d.length-1,i;s>=0;s--)(i=d[s])&&(n=i(n)||n);return n},O=(d,o)=>(e,t)=>o(e,t,d);let b=class extends a.Disposable{constructor(o,e,t){super();g(this,"modelMap",new Map);g(this,"_cellBindInfoUpdate$",new E.Subject);g(this,"cellBindInfoUpdate$",this._cellBindInfoUpdate$.asObservable());this._univerInstanceService=o,this._sheetInterceptorService=e,this._sheetsSelectionsService=t,this._initRemoveCommand()}_initRemoveCommand(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{const e=[],t=[],n=this._sheetsSelectionsService.getCurrentSelections(),s=I.getSheetCommandTarget(this._univerInstanceService);if(!s||!n||n.length===0)return{redos:[],undos:[]};const{unitId:i,subUnitId:r}=s;return(o.id===I.ClearSelectionContentCommand.id||o.id===I.ClearSelectionAllCommand.id)&&n.forEach(({range:c})=>{a.Range.foreach(c,(l,u)=>{this.getBindingNode(i,r,l,u)&&this.removeBindingNode(i,r,l,u)})}),{redos:e,undos:t}}}))}getBindingModelBySourceId(o){const e=[];return this.modelMap.forEach((t,n)=>{t.forEach((s,i)=>{const r=s.getBindingNodesBySourceId(o);if(r)for(const c of r)e.push({unitId:n,subunitId:i,sourceId:o,nodeId:c.nodeId,row:c.row,column:c.column})})}),e}addModel(o,e,t){var n;this.modelMap.has(o)||this.modelMap.set(o,new Map),(n=this.modelMap.get(o))==null||n.set(e,t)}getModel(o,e){var t;return(t=this.modelMap.get(o))==null?void 0:t.get(e)}setBindingNode(o,e,t){let n=this.getModel(o,e);n||(n=new U,this.addModel(o,e,n)),t.nodeId||(t.nodeId=a.generateRandomId());const{row:s,column:i}=t;if(s===void 0||i===void 0)throw new Error("row and column is required");const r=n.getBindingNode(s,i),c=t.type===_.List?!!t.containHeader:!1;n.setBindingNode(s,i,{...t,row:s,column:i}),this._cellBindInfoUpdate$.next({unitId:o,subunitId:e,sourceId:t.sourceId,nodeId:t.nodeId,row:s,column:i,containHeader:c,changeType:r?v.Update:v.Add,oldSourceId:r==null?void 0:r.sourceId,oldNodeContainHeader:(r==null?void 0:r.type)===_.List?!!r.containHeader:!1})}removeBindingNode(o,e,t,n){const s=this.getModel(o,e);if(s){const i=s.getBindingNode(t,n);i&&(s.removeBindingNode(t,n),this._cellBindInfoUpdate$.next({unitId:o,subunitId:e,sourceId:i.sourceId,nodeId:i.nodeId,row:t,column:n,changeType:v.Remove}))}}getBindingNode(o,e,t,n){const s=this.getModel(o,e);if(s)return s.getBindingNode(t,n)}getBindingNodeById(o,e,t){const n=this.getModel(o,e);if(n)return n.getBindingNodeById(t)}createModel(o,e,t){const n=new U(t);return this.addModel(o,e,n),n}toJSON(o){const e={},t=this.modelMap.get(o);return t&&t.forEach((n,s)=>{e[s]=n.toJSON()}),e}fromJSON(o,e){Object.entries(e).forEach(([t,n])=>{this.createModel(o,t,n)})}dispose(){this.modelMap.clear(),this._cellBindInfoUpdate$.complete()}};b=H([O(0,a.IUniverInstanceService),O(1,a.Inject(I.SheetInterceptorService)),O(2,a.Inject(I.SheetsSelectionsService))],b);class T extends a.Disposable{constructor(){super();g(this,"sourceMap",new Map);g(this,"_sourceDataUpdate$",new E.Subject);g(this,"sourceDataUpdate$",this._sourceDataUpdate$.asObservable())}_ensureUnitMap(e){let t=this.sourceMap.get(e);return t||(t=new Map,this.sourceMap.set(e,t)),t}_getUnitMap(e){return this.sourceMap.get(e)}getSource(e,t){const n=this._getUnitMap(e);return n==null?void 0:n.get(t)}createSource(e,t,n,s){const i=s===void 0?a.generateRandomId():s;let r;switch(t){case _.List:r=new $(i,n);break;case _.Object:r=new V(i);break;default:throw new Error(`Invalid source type: ${t}`)}return this._ensureUnitMap(e).set(i,r),r}updateSourceData(e,t,n){const s=this._getUnitMap(e),i=t instanceof w?t.getId():t,r=s==null?void 0:s.get(i);if(r)r.setSourceData(n),this._sourceDataUpdate$.next({...r.getSourceInfo(),unitId:e,changeType:v.Add});else throw new Error(`Source not found: ${i}`)}removeSource(e,t){const n=this._getUnitMap(e),s=n==null?void 0:n.get(t);s&&(n==null||n.delete(t),this._sourceDataUpdate$.next({...s.getSourceInfo(),unitId:e,changeType:v.Remove}))}toJSON(e){const t=[],n=this._getUnitMap(e);if(n)for(const s of n.values())t.push(s.toJSON());return t}fromJSON(e,t){const n=this._ensureUnitMap(e);for(const s of t){let i;switch(s.type){case _.List:i=new $(s.id);break;case _.Object:i=new V(s.id);break;default:throw new Error(`Invalid source type: ${s.type}`)}i.fromJSON(s),n.set(s.id,i)}}dispose(){this._sourceDataUpdate$.complete(),this.sourceMap.clear()}}var A=Object.getOwnPropertyDescriptor,k=(d,o,e,t)=>{for(var n=t>1?void 0:t?A(o,e):o,s=d.length-1,i;s>=0;s--)(i=d[s])&&(n=i(n)||n);return n},j=(d,o)=>(e,t)=>o(e,t,d);h.SheetsSourceBindService=class extends a.Disposable{constructor(e,t,n){super();g(this,"_bindingModel",R.Value);g(this,"_bindModelRTreeCollection",new Map);this._sheetInterceptorService=e,this._sheetsBindingManager=t,this._sheetsSourceManager=n,this._registerInterceptor(),this._registerSourceChange()}usePathMode(){this._bindingModel=R.Path}useValueMode(){this._bindingModel=R.Value}getBindingModel(){return this._bindingModel}createBindModel(e,t){return this._sheetsBindingManager.createModel(e,t)}setBindingNode(e,t,n){this._sheetsBindingManager.setBindingNode(e,t,n)}removeBindingNode(e,t,n,s){this._sheetsBindingManager.removeBindingNode(e,t,n,s)}getBindingNode(e,t,n,s){return this._sheetsBindingManager.getBindingNode(e,t,n,s)}getSource(e,t){return this._sheetsSourceManager.getSource(e,t)}createSource(e,t,n,s){return this._sheetsSourceManager.createSource(e,t,n,s)}getSourceBindingPathInfo(e){return{source:this._sheetsSourceManager.toJSON(e),cellBinding:this._sheetsBindingManager.toJSON(e)}}loadSourceBindingPathInfo(e,t){this._sheetsSourceManager.fromJSON(e,t.source),this._sheetsBindingManager.fromJSON(e,t.cellBinding)}_ensureRTreeCollection(e){return this._bindModelRTreeCollection.has(e)||this._bindModelRTreeCollection.set(e,new a.RTree),this._bindModelRTreeCollection.get(e)}_getRTeeCollection(e){return this._bindModelRTreeCollection.get(e)}_registerSourceChange(){this.disposeWithMe(this._sheetsSourceManager.sourceDataUpdate$.subscribe(e=>{const{sourceId:t,sourceType:n,unitId:s,changeType:i}=e;if(n===_.List){if(i===v.Remove){const c=this._sheetsBindingManager.getBindingModelBySourceId(t),l=e.recordCount;for(const{unitId:u,subunitId:p,nodeId:f,row:M,column:m}of c){const B=this._getRTeeCollection(s),S=this._sheetsBindingManager.getBindingNodeById(u,p,f);if(B&&(S==null?void 0:S.type)===_.List){const y=S.containHeader?0:1,C={startRow:M,startColumn:m,endRow:M+l-y,endColumn:m};B.remove({unitId:u,sheetId:p,id:f,range:C})}}return}if(i===v.Update){const c=e.oldRecordCount,l=this._sheetsBindingManager.getBindingModelBySourceId(t);for(const{unitId:u,subunitId:p,nodeId:f,row:M,column:m}of l){const B=this._getRTeeCollection(s),S=this._sheetsBindingManager.getBindingNodeById(u,p,f);if(B&&(S==null?void 0:S.type)===_.List){const y=S.containHeader?0:1,C={startRow:M,startColumn:m,endRow:M+c-y,endColumn:m},N={startRow:M,startColumn:m,endRow:M+e.recordCount-y,endColumn:m};B.remove({unitId:u,sheetId:p,id:f,range:C}),B.insert({unitId:u,sheetId:p,id:f,range:N})}}return}const r=this._sheetsSourceManager.getSource(s,t);if(r&&r.hasData()){const l=r.getSourceInfo().recordCount,u=this._sheetsBindingManager.getBindingModelBySourceId(t);for(const{unitId:p,subunitId:f,nodeId:M,row:m,column:B}of u){const S=this._ensureRTreeCollection(p),y=this._sheetsBindingManager.getBindingNodeById(p,f,M);if(S&&(y==null?void 0:y.type)===_.List){const C=y.containHeader?0:1,N={startRow:m,startColumn:B,endRow:m+l-C,endColumn:B};S.insert({unitId:p,sheetId:f,id:M,range:N})}}}}})),this.disposeWithMe(this._sheetsBindingManager.cellBindInfoUpdate$.subscribe(e=>{const{unitId:t,subunitId:n,sourceId:s,nodeId:i,row:r,column:c,changeType:l,containHeader:u}=e,p=this._ensureRTreeCollection(t),f=this._sheetsSourceManager.getSource(t,s);if(f&&f.hasData()){const M=f.getSourceInfo();if(M.sourceType===_.List){const m=M.recordCount,B=u?0:1,S={startRow:r,startColumn:c,endRow:r+m-B,endColumn:c};if(l===v.Add)p.insert({unitId:t,sheetId:n,id:i,range:S});else if(l===v.Remove)p.remove({unitId:t,sheetId:n,id:i,range:S});else if(l===v.Update){const y=e.oldSourceId,C=e.oldNodeContainHeader?0:1,N=this._sheetsSourceManager.getSource(t,y);if(N&&N.hasData()){const W=N.getSourceInfo().recordCount,z={startRow:r,startColumn:c,endRow:r+W-C,endColumn:c};p.remove({unitId:t,sheetId:n,id:i,range:z})}p.insert({unitId:t,sheetId:n,id:i,range:S})}}}}))}_getPathModeCellValue(e,t,n,s){const i=this._sheetsBindingManager.getModel(e,t),r=i==null?void 0:i.getBindingNode(n,s);if(r){const c=r.type;if(c===_.List)return{v:`#{${r.path}}`,s:{cl:{rgb:"blue"}}};if(c===_.Object)return{v:`[${r.path}]`,s:{cl:{rgb:"blue"}}}}}_getValueModeCellValue(e,t,n,s){const i=this._sheetsBindingManager.getModel(e,t);if(i){const c=i.getBindingNode(n,s);if(c){const{sourceId:l}=c,u=this._sheetsSourceManager.getSource(e,l);if(u&&u.hasData())return(u==null?void 0:u.getData(c,n,s))||{v:""}}}const r=this._getRTeeCollection(e);if(i&&r){const c={startRow:n,startColumn:s,endRow:n,endColumn:s},l=Array.from(r.bulkSearch([{unitId:e,sheetId:t,range:c}]));if(l.length>0){const u=i.getBindingNodeById(l[0]);if(u){const{sourceId:p}=u,f=this._sheetsSourceManager.getSource(e,p);if(f&&f.hasData())return(f==null?void 0:f.getData(u,n,s))||{v:""}}}}}getBindingModelBySourceId(e){return this._sheetsBindingManager.getBindingModelBySourceId(e)}_registerInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Value|a.InterceptorEffectEnum.Style,priority:102,handler:(e,t,n)=>{const{row:s,col:i,unitId:r,subUnitId:c,workbook:l}=t;let u=null;if(this._bindingModel===R.Path?u=this._getPathModeCellValue(r,c,s,i):u=this._getValueModeCellValue(r,c,s,i),u!==null){const f={...(typeof(e==null?void 0:e.s)=="string"?l.getStyles().get(e==null?void 0:e.s):e==null?void 0:e.s)||{}};return u&&u.s&&Object.assign(f,u.s),n({...e,...u,s:f})}return n(e)}}))}dispose(){this._bindModelRTreeCollection.clear()}},h.SheetsSourceBindService=k([j(0,a.Inject(I.SheetInterceptorService)),j(1,a.Inject(b)),j(2,a.Inject(T))],h.SheetsSourceBindService);var q=Object.getOwnPropertyDescriptor,G=(d,o,e,t)=>{for(var n=t>1?void 0:t?q(o,e):o,s=d.length-1,i;s>=0;s--)(i=d[s])&&(n=i(n)||n);return n},L=(d,o)=>(e,t)=>o(e,t,d);h.UniverSheetsBindingSourcePlugin=(D=class extends a.Plugin{constructor(o={},e,t){super(),this._config=o,this._injector=e,this._configService=t}onStarting(){[[b],[T],[h.SheetsSourceBindService]].forEach(o=>this._injector.add(o))}onReady(){a.touchDependencies(this._injector,[[b],[T],[h.SheetsSourceBindService]])}},g(D,"type",a.UniverInstanceType.UNIVER_SHEET),g(D,"pluginName","SHEET_BINDING_SOURCE_PLUGIN"),D),h.UniverSheetsBindingSourcePlugin=G([L(1,a.Inject(a.Injector)),L(2,a.IConfigService)],h.UniverSheetsBindingSourcePlugin),h.BindModeEnum=R,h.BindingModel=U,h.DataBindingNodeTypeEnum=_,h.SheetsSourceManager=T,h.SourceModelBase=w,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-source-binding",
3
- "version": "0.6.0-nightly.202502131606",
3
+ "version": "0.6.0-nightly.202502141606",
4
4
  "private": false,
5
5
  "description": "A library for connect and bind data from other sources to Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -51,15 +51,15 @@
51
51
  "rxjs": ">=7.0.0"
52
52
  },
53
53
  "dependencies": {
54
- "@univerjs/core": "0.6.0-nightly.202502131606",
55
- "@univerjs/sheets": "0.6.0-nightly.202502131606"
54
+ "@univerjs/core": "0.6.0-nightly.202502141606",
55
+ "@univerjs/sheets": "0.6.0-nightly.202502141606"
56
56
  },
57
57
  "devDependencies": {
58
58
  "rxjs": "^7.8.1",
59
59
  "typescript": "^5.7.3",
60
60
  "vite": "^6.1.0",
61
61
  "vitest": "^3.0.5",
62
- "@univerjs-infra/shared": "0.6.0-alpha.0"
62
+ "@univerjs-infra/shared": "0.6.0"
63
63
  },
64
64
  "scripts": {
65
65
  "test": "vitest run",