@univerjs/sheets-numfmt 0.5.3 → 0.5.4

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 K=Object.defineProperty;var z=(e,t,n)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var N=(e,t,n)=>z(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),d=require("@univerjs/sheets"),$=require("rxjs"),T=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"],j={US:"$",CA:"C$",GB:"£",JP:"¥",IN:"₹",AU:"A$",CN:"¥",KR:"₩",RU:"₽",AT:"€",BE:"€",CY:"€",EE:"€",FI:"€",FR:"€",DE:"€",GR:"€",IE:"€",IT:"€",LV:"€",LT:"€",LU:"€",MT:"€",NL:"€",PT:"€",SK:"€",SI:"€",ES:"€"},w=[{label:"1930-08-05",suffix:"yyyy-MM-dd"},{label:"1930/08/05",suffix:"yyyy/MM/dd"},{label:"1930年08月05日",suffix:'yyyy"年"MM"月"dd"日"'},{label:"08-05",suffix:"MM-dd"},{label:"8月5日",suffix:'M"月"d"日"'},{label:"13:30:30",suffix:"h:mm:ss"},{label:"13:30",suffix:"h:mm"},{label:"下午01:30",suffix:"A/P hh:mm"},{label:"下午1:30",suffix:"A/P h:mm"},{label:"下午1:30:30",suffix:"A/P h:mm:ss"},{label:"08-05 下午 01:30",suffix:"MM-dd A/P hh:mm"}],A=[{label:"(1,235)",suffix:"#,##0_);(#,##0)"},{label:"(1,235) ",suffix:"#,##0_);[Red](#,##0)",color:"red"},{label:"1,234.56",suffix:"#,##0.00_);#,##0.00"},{label:"1,234.56",suffix:"#,##0.00_);[Red]#,##0.00",color:"red"},{label:"-1,234.56",suffix:"#,##0.00_);-#,##0.00"},{label:"-1,234.56",suffix:"#,##0.00_);[Red]-#,##0.00",color:"red"}],U=[{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);"${e}"#,##0.00`},{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,color:"red"},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);("${e}"#,##0.00)`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,color:"red"},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);-"${e}"#,##0.00`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,color:"red"}],J="SHEET_NUMFMT_PLUGIN",P=(e,t=0)=>{var r;return e&&(r=s.numfmt.getInfo(e).maxDecimals)!=null?r:t},Z=(e,t)=>{if(e&&!t||!e&&t)return!1;const n=a=>a.reduce((f,S)=>{if(f.isEnd)return f;const g=S.value||S.num;return S.type==="point"?(f.isEnd=!0,f):{...f,result:f.result+g}},{isEnd:!1,result:""}).result,r=s.numfmt.getInfo(e)._partitions,o=s.numfmt.getInfo(t)._partitions,c=n(r[0].tokens),i=n(o[0].tokens),l=n(r[1].tokens),m=n(o[1].tokens);return c===i&&l===m&&r[1].color===o[1].color},E=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),R=(e,t)=>e.split(";").map(r=>/\.0?/.test(r)?r.replace(/\.0*/g,`${t>0?".":""}${E(Number(t||0))}`):/0([^0]?)|0$/.test(r)?r.replace(/0([^0]+)|0$/,`0${t>0?".":""}${E(Number(t||0))}$1`):r).join(";"),Q=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),M={id:"sheet.command.numfmt.set.numfmt",type:s.CommandType.COMMAND,handler:(e,t)=>{if(!t)return!1;const n=e.get(s.ICommandService),r=e.get(s.IUniverInstanceService),o=e.get(s.IUndoRedoService),c=d.getSheetCommandTarget(r,t);if(!c)return!1;const{unitId:i,subUnitId:l}=c,m=t.values.filter(u=>!!u.pattern),a=t.values.filter(u=>!u.pattern),f=d.transformCellsToRange(i,l,m),S={unitId:i,subUnitId:l,ranges:a.map(u=>({startColumn:u.col,startRow:u.row,endColumn:u.col,endRow:u.row}))},g=[],h=[];if(m.length){Object.keys(f.values).forEach(v=>{const C=f.values[v];C.ranges=d.rangeMerge(C.ranges)}),g.push({id:d.SetNumfmtMutation.id,params:f});const u=d.factorySetNumfmtUndoMutation(e,f);h.push(...u)}if(a.length){S.ranges=d.rangeMerge(S.ranges),g.push({id:d.RemoveNumfmtMutation.id,params:S});const u=d.factoryRemoveNumfmtUndoMutation(e,S);h.push(...u)}const p=s.sequenceExecute(g,n).result;return p&&o.pushUndoRedo({unitID:i,undoMutations:h,redoMutations:g}),p}},F={id:"sheet.command.numfmt.add.decimal.command",type:s.CommandType.COMMAND,handler:async e=>{const t=e.get(s.ICommandService),n=e.get(d.SheetsSelectionsService),r=e.get(d.INumfmtService),o=e.get(s.IUniverInstanceService),c=n.getCurrentSelections();if(!c||!c.length)return!1;const i=d.getSheetCommandTarget(o);if(!i)return!1;const{unitId:l,subUnitId:m}=i;let a=0;c.forEach(h=>{s.Range.foreach(h.range,(p,u)=>{const v=r.getValue(l,m,p,u);if(!v){const y=i.worksheet.getCellRaw(p,u);if(!a&&y&&y.t===s.CellValueType.NUMBER&&y.v){const b=/\.(\d*)$/.exec(String(y.v));if(b){const I=b[1].length;if(!I)return;a=Math.max(a,I)}}return}const C=P(v.pattern);a=C>a?C:a})});const f=a+1,S=R(`0${f>0?".0":""}`,f),g=[];return c.forEach(h=>{s.Range.foreach(h.range,(p,u)=>{const v=r.getValue(l,m,p,u);if(!v)g.push({row:p,col:u,pattern:S});else{const C=P(v.pattern),y=R(v.pattern,C+1);y!==v.pattern&&g.push({row:p,col:u,pattern:y})}})}),g.length?await t.executeCommand(M.id,{values:g}):!1}};class D{constructor(){N(this,"_currencySymbol$",new $.BehaviorSubject("US"));N(this,"currencySymbol$",this._currencySymbol$.asObservable())}setCurrencySymbolByCountryCode(t){this._currencySymbol$.next(t)}getCurrencySymbol(){return this._currencySymbol$.getValue()}}const B={id:"sheet.command.numfmt.set.currency",type:s.CommandType.COMMAND,handler:async e=>{const t=e.get(s.ICommandService),n=e.get(d.SheetsSelectionsService),r=e.get(D),o=j[r.getCurrencySymbol()]||"$",c=n.getCurrentSelections();if(!c||!c.length)return!1;const i=[],l=U[4].suffix(o);return c.forEach(a=>{s.Range.foreach(a.range,(f,S)=>{i.push({row:f,col:S,pattern:l,type:"currency"})})}),await t.executeCommand(M.id,{values:i})}},L={id:"sheet.command.numfmt.set.percent",type:s.CommandType.COMMAND,handler:async e=>{const t=e.get(s.ICommandService),r=e.get(d.SheetsSelectionsService).getCurrentSelections();if(!r||!r.length)return!1;const o=[],c="0%";return r.forEach(l=>{s.Range.foreach(l.range,(m,a)=>{o.push({row:m,col:a,pattern:c,type:"percent"})})}),await t.executeCommand(M.id,{values:o})}},G={id:"sheet.command.numfmt.subtract.decimal.command",type:s.CommandType.COMMAND,handler:async e=>{const t=e.get(s.ICommandService),n=e.get(d.SheetsSelectionsService),r=e.get(d.INumfmtService),o=e.get(s.IUniverInstanceService),c=n.getCurrentSelections();if(!c||!c.length)return!1;const i=d.getSheetCommandTarget(o);if(!i)return!1;const{unitId:l,subUnitId:m}=i;let a=0;c.forEach(p=>{s.Range.foreach(p.range,(u,v)=>{const C=r.getValue(l,m,u,v);if(!C){const b=i.worksheet.getCellRaw(u,v);if(!a&&b&&b.t===s.CellValueType.NUMBER&&b.v){const I=/\.(\d*)$/.exec(String(b.v));if(I){const x=I[1].length;if(!x)return;a=Math.max(a,x)}}return}const y=P(C.pattern);a=y>a?y:a})});const f=a-1,S=R(`0${f>0?".0":"."}`,f),g=[];return c.forEach(p=>{s.Range.foreach(p.range,(u,v)=>{const C=r.getValue(l,m,u,v);if(!C)g.push({row:u,col:v,pattern:S});else{const y=P(C.pattern);g.push({row:u,col:v,pattern:R(C.pattern,y-1)})}})}),await t.executeCommand(M.id,{values:g})}},X=e=>s.numfmt.getInfo(e).type||"unknown",H=(e,t,n)=>{const r=s.numfmt.getInfo(e),o=n===s.LocaleType.ZH_CN?"zh-CN":"en",c=r._partitions[1],i=s.numfmt.format(e,t,{locale:o,throws:!1});return t<0?{result:i,color:c.color}:{result:i}},q=(e,t,n)=>e==="General"?{result:String(t)}:H(e,t,n);var k=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(e,t,n,r)=>{for(var o=r>1?void 0:r?ee(t,n):t,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=(r?i(t,n,o):i(o))||o);return r&&o&&k(t,n,o),o},_=(e,t)=>(n,r)=>t(n,r,e);exports.SheetsNumfmtCellContentController=class extends s.Disposable{constructor(t,n,r,o,c,i){super(),this._instanceService=t,this._sheetInterceptorService=n,this._themeService=r,this._commandService=o,this._numfmtService=c,this._localeService=i,this._initInterceptorCellContent()}_initInterceptorCellContent(){const t=new s.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(d.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value|s.InterceptorEffectEnum.Style,handler:(n,r,o)=>{const c=r.unitId,i=r.subUnitId;let l;const m=n;if(!m||m.t!==s.CellValueType.NUMBER||m.v==null||Number.isNaN(m.v))return o(n);if(n!=null&&n.s){const h=r.workbook.getStyles().get(n.s);h!=null&&h.n&&(l=h.n)}if(l||(l=this._numfmtService.getValue(c,i,r.row,r.col)),!l)return o(n);let a="";const f=t.getValue(r.row,r.col);if(f&&f.parameters===`${m.v}_${l.pattern}`)return o({...n,...f.result});const S=q(l.pattern,Number(m.v),this._localeService.getCurrentLocale());if(a=S.result,!a)return o(n);const g={v:a};if(S.color){const h=this._themeService.getCurrentTheme()[`${S.color}500`];h&&(g.interceptorStyle={cl:{rgb:h}})}return t.setValue(r.row,r.col,{result:g,parameters:`${m.v}_${l.pattern}`}),o({...n,...g})},priority:d.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id===d.SetNumfmtMutation.id){const r=n.params;Object.keys(r.values).forEach(o=>{r.values[o].ranges.forEach(i=>{s.Range.foreach(i,(l,m)=>{t.realDeleteValue(l,m)})})})}else if(n.id===d.SetRangeValuesMutation.id){const r=n.params;new s.ObjectMatrix(r.cellValue).forValue((o,c)=>{t.realDeleteValue(o,c)})}})),this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).pipe($.switchMap(n=>{var r;return(r=n==null?void 0:n.activeSheet$)!=null?r:$.of(null)}),$.skip(1)).subscribe(()=>t.reset()))}};exports.SheetsNumfmtCellContentController=te([_(0,s.IUniverInstanceService),_(1,s.Inject(d.SheetInterceptorService)),_(2,s.Inject(s.ThemeService)),_(3,s.Inject(s.ICommandService)),_(4,s.Inject(d.INumfmtService)),_(5,s.Inject(s.LocaleService))],exports.SheetsNumfmtCellContentController);class O extends s.Disposable{constructor(){super(...arguments);N(this,"_currencySymbol$",new $.BehaviorSubject("US"));N(this,"currencySymbol$",this._currencySymbol$.asObservable())}setCurrencySymbolByCountryCode(n){this._currencySymbol$.next(n)}getCurrencySymbol(){return this._currencySymbol$.getValue()}}var W=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,re=(e,t,n)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,se=(e,t,n,r)=>{for(var o=r>1?void 0:r?ne(t,n):t,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=(r?i(t,n,o):i(o))||o);return r&&o&&W(t,n,o),o},V=(e,t)=>(n,r)=>t(n,r,e),Y=(e,t,n)=>re(e,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsNumfmtPlugin=class extends s.Plugin{constructor(t=void 0,n,r){super(),this._config=t,this._injector=n,this._commandService=r}onStarting(){s.registerDependencies(this._injector,[[exports.SheetsNumfmtCellContentController],[D],[O]]),s.touchDependencies(this._injector,[[exports.SheetsNumfmtCellContentController]])}onRendered(){s.touchDependencies(this._injector,[[O]]),[F,G,B,L,M].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}};Y(exports.UniverSheetsNumfmtPlugin,"pluginName",J);Y(exports.UniverSheetsNumfmtPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtPlugin=se([s.DependentOn(d.UniverSheetsPlugin),V(1,s.Inject(s.Injector)),V(2,s.ICommandService)],exports.UniverSheetsNumfmtPlugin);const oe=e=>T.find(n=>e.includes(n)),ce=()=>T.map(e=>({label:e,value:e})),ie=e=>U.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),ae=()=>w.map(e=>({label:e.label,value:e.suffix})),ue=()=>A.map(e=>({label:e.label,value:e.suffix,color:e.color}));exports.AddDecimalCommand=F;exports.CURRENCYFORMAT=U;exports.DATEFMTLISG=w;exports.MenuCurrencyService=D;exports.NUMBERFORMAT=A;exports.SetCurrencyCommand=B;exports.SetNumfmtCommand=M;exports.SetPercentCommand=L;exports.SubtractDecimalCommand=G;exports.countryCurrencyMap=j;exports.currencySymbols=T;exports.getCurrencyFormatOptions=ie;exports.getCurrencyOptions=ce;exports.getCurrencyType=oe;exports.getDateFormatOptions=ae;exports.getDecimalFromPattern=P;exports.getDecimalString=E;exports.getNumberFormatOptions=ue;exports.getPatternPreview=H;exports.getPatternPreviewIgnoreGeneral=q;exports.getPatternType=X;exports.isPatternEqualWithoutDecimal=Z;exports.isPatternHasDecimal=Q;exports.setPatternDecimal=R;
1
+ "use strict";var Y=Object.defineProperty;var z=(e,t,s)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var N=(e,t,s)=>z(e,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@univerjs/core"),f=require("@univerjs/sheets"),$=require("rxjs"),X=require("@univerjs/engine-numfmt"),P=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"],V={US:"$",CA:"C$",GB:"£",JP:"¥",IN:"₹",AU:"A$",CN:"¥",KR:"₩",RU:"₽",AT:"€",BE:"€",CY:"€",EE:"€",FI:"€",FR:"€",DE:"€",GR:"€",IE:"€",IT:"€",LV:"€",LT:"€",LU:"€",MT:"€",NL:"€",PT:"€",SK:"€",SI:"€",ES:"€"},j=[{label:"1930-08-05",suffix:"yyyy-MM-dd"},{label:"1930/08/05",suffix:"yyyy/MM/dd"},{label:"1930年08月05日",suffix:'yyyy"年"MM"月"dd"日"'},{label:"08-05",suffix:"MM-dd"},{label:"8月5日",suffix:'M"月"d"日"'},{label:"13:30:30",suffix:"h:mm:ss"},{label:"13:30",suffix:"h:mm"},{label:"下午01:30",suffix:"A/P hh:mm"},{label:"下午1:30",suffix:"A/P h:mm"},{label:"下午1:30:30",suffix:"A/P h:mm:ss"},{label:"08-05 下午 01:30",suffix:"MM-dd A/P hh:mm"}],w=[{label:"(1,235)",suffix:"#,##0_);(#,##0)"},{label:"(1,235) ",suffix:"#,##0_);[Red](#,##0)",color:"red"},{label:"1,234.56",suffix:"#,##0.00_);#,##0.00"},{label:"1,234.56",suffix:"#,##0.00_);[Red]#,##0.00",color:"red"},{label:"-1,234.56",suffix:"#,##0.00_);-#,##0.00"},{label:"-1,234.56",suffix:"#,##0.00_);[Red]-#,##0.00",color:"red"}],U=[{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);"${e}"#,##0.00`},{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,color:"red"},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);("${e}"#,##0.00)`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,color:"red"},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);-"${e}"#,##0.00`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,color:"red"}],J="SHEET_NUMFMT_PLUGIN",R=(e,t=0)=>{var n;return e&&(n=r.numfmt.getInfo(e).maxDecimals)!=null?n:t},Z=(e,t)=>{if(e&&!t||!e&&t)return!1;const s=i=>i.reduce((m,h)=>{if(m.isEnd)return m;const g=h.value||h.num;return h.type==="point"?(m.isEnd=!0,m):{...m,result:m.result+g}},{isEnd:!1,result:""}).result,n=r.numfmt.getInfo(e)._partitions,o=r.numfmt.getInfo(t)._partitions,c=s(n[0].tokens),a=s(o[0].tokens),S=s(n[1].tokens),l=s(o[1].tokens);return c===a&&S===l&&n[1].color===o[1].color},E=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),T=(e,t)=>e.split(";").map(n=>/\.0?/.test(n)?n.replace(/\.0*/g,`${t>0?".":""}${E(Number(t||0))}`):/0([^0]?)|0$/.test(n)?n.replace(/0([^0]+)|0$/,`0${t>0?".":""}${E(Number(t||0))}$1`):n).join(";"),Q=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),M={id:"sheet.command.numfmt.set.numfmt",type:r.CommandType.COMMAND,handler:(e,t)=>{if(!t)return!1;const s=e.get(r.ICommandService),n=e.get(r.IUniverInstanceService),o=e.get(r.IUndoRedoService),c=f.getSheetCommandTarget(n,t);if(!c)return!1;const{unitId:a,subUnitId:S}=c,l=t.values.filter(u=>!!u.pattern),i=t.values.filter(u=>!u.pattern),m=f.transformCellsToRange(a,S,l),h={unitId:a,subUnitId:S,ranges:i.map(u=>({startColumn:u.col,startRow:u.row,endColumn:u.col,endRow:u.row}))},g=[],p=[];if(l.length){Object.keys(m.values).forEach(v=>{const C=m.values[v];C.ranges=f.rangeMerge(C.ranges)}),g.push({id:f.SetNumfmtMutation.id,params:m});const u=f.factorySetNumfmtUndoMutation(e,m);p.push(...u)}if(i.length){h.ranges=f.rangeMerge(h.ranges),g.push({id:f.RemoveNumfmtMutation.id,params:h});const u=f.factoryRemoveNumfmtUndoMutation(e,h);p.push(...u)}const d=r.sequenceExecute(g,s).result;return d&&o.pushUndoRedo({unitID:a,undoMutations:p,redoMutations:g}),d}},F={id:"sheet.command.numfmt.add.decimal.command",type:r.CommandType.COMMAND,handler:async e=>{const t=e.get(r.ICommandService),s=e.get(f.SheetsSelectionsService),n=e.get(f.INumfmtService),o=e.get(r.IUniverInstanceService),c=s.getCurrentSelections();if(!c||!c.length)return!1;const a=f.getSheetCommandTarget(o);if(!a)return!1;const{unitId:S,subUnitId:l}=a;let i=0;c.forEach(p=>{r.Range.foreach(p.range,(d,u)=>{const v=n.getValue(S,l,d,u);if(!v){const y=a.worksheet.getCellRaw(d,u);if(!i&&y&&y.t===r.CellValueType.NUMBER&&y.v){const b=/\.(\d*)$/.exec(String(y.v));if(b){const I=b[1].length;if(!I)return;i=Math.max(i,I)}}return}const C=R(v.pattern);i=C>i?C:i})});const m=i+1,h=T(`0${m>0?".0":""}`,m),g=[];return c.forEach(p=>{r.Range.foreach(p.range,(d,u)=>{const v=n.getValue(S,l,d,u);if(!v)g.push({row:d,col:u,pattern:h});else{const C=R(v.pattern),y=T(v.pattern,C+1);y!==v.pattern&&g.push({row:d,col:u,pattern:y})}})}),g.length?await t.executeCommand(M.id,{values:g}):!1}};class D{constructor(){N(this,"_currencySymbol$",new $.BehaviorSubject("US"));N(this,"currencySymbol$",this._currencySymbol$.asObservable())}setCurrencySymbolByCountryCode(t){this._currencySymbol$.next(t)}getCurrencySymbol(){return this._currencySymbol$.getValue()}}const B={id:"sheet.command.numfmt.set.currency",type:r.CommandType.COMMAND,handler:async e=>{const t=e.get(r.ICommandService),s=e.get(f.SheetsSelectionsService),n=e.get(D),o=V[n.getCurrencySymbol()]||"$",c=s.getCurrentSelections();if(!c||!c.length)return!1;const a=[],S=U[4].suffix(o);return c.forEach(i=>{r.Range.foreach(i.range,(m,h)=>{a.push({row:m,col:h,pattern:S,type:"currency"})})}),await t.executeCommand(M.id,{values:a})}},L={id:"sheet.command.numfmt.set.percent",type:r.CommandType.COMMAND,handler:async e=>{const t=e.get(r.ICommandService),n=e.get(f.SheetsSelectionsService).getCurrentSelections();if(!n||!n.length)return!1;const o=[],c="0%";return n.forEach(S=>{r.Range.foreach(S.range,(l,i)=>{o.push({row:l,col:i,pattern:c,type:"percent"})})}),await t.executeCommand(M.id,{values:o})}},G={id:"sheet.command.numfmt.subtract.decimal.command",type:r.CommandType.COMMAND,handler:async e=>{const t=e.get(r.ICommandService),s=e.get(f.SheetsSelectionsService),n=e.get(f.INumfmtService),o=e.get(r.IUniverInstanceService),c=s.getCurrentSelections();if(!c||!c.length)return!1;const a=f.getSheetCommandTarget(o);if(!a)return!1;const{unitId:S,subUnitId:l}=a;let i=0;c.forEach(d=>{r.Range.foreach(d.range,(u,v)=>{const C=n.getValue(S,l,u,v);if(!C){const b=a.worksheet.getCellRaw(u,v);if(!i&&b&&b.t===r.CellValueType.NUMBER&&b.v){const I=/\.(\d*)$/.exec(String(b.v));if(I){const O=I[1].length;if(!O)return;i=Math.max(i,O)}}return}const y=R(C.pattern);i=y>i?y:i})});const m=i-1,h=T(`0${m>0?".0":"."}`,m),g=[];return c.forEach(d=>{r.Range.foreach(d.range,(u,v)=>{const C=n.getValue(S,l,u,v);if(!C)g.push({row:u,col:v,pattern:h});else{const y=R(C.pattern);g.push({row:u,col:v,pattern:T(C.pattern,y-1)})}})}),await t.executeCommand(M.id,{values:g})}},k=e=>r.numfmt.getInfo(e).type||"unknown",q=(e,t,s)=>{const n=r.numfmt.getInfo(e),o=s===r.LocaleType.ZH_CN?"zh-CN":"en",c=n._partitions[1],a=r.numfmt.format(e,t,{locale:o,throws:!1});return t<0?{result:a,color:c.color}:{result:a}},H=(e,t,s)=>e==="General"?{result:String(t)}:q(e,t,s);var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(e,t,s,n)=>{for(var o=n>1?void 0:n?te(t,s):t,c=e.length-1,a;c>=0;c--)(a=e[c])&&(o=(n?a(t,s,o):a(o))||o);return n&&o&&ee(t,s,o),o},_=(e,t)=>(s,n)=>t(s,n,e);exports.SheetsNumfmtCellContentController=class extends r.Disposable{constructor(t,s,n,o,c,a){super(),this._instanceService=t,this._sheetInterceptorService=s,this._themeService=n,this._commandService=o,this._numfmtService=c,this._localeService=a,this._initInterceptorCellContent()}_initInterceptorCellContent(){const t={tl:{size:6,color:"#409f11"}},s=new r.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Value|r.InterceptorEffectEnum.Style,handler:(n,o,c)=>{const a=o.unitId,S=o.subUnitId;let l;const i=n;if(!i)return c(n);if(n!=null&&n.s){const d=o.workbook.getStyles().get(n.s);d!=null&&d.n&&(l=d.n)}if(l||(l=this._numfmtService.getValue(a,S,o.row,o.col)),!l)return c(n);if(l.pattern===X.DEFAULT_TEXT_FORMAT&&i.v&&r.isRealNum(i.v))return c({...n,markers:{...n==null?void 0:n.markers,...t}});if(i.t!==r.CellValueType.NUMBER||i.v==null||Number.isNaN(i.v))return c(n);let m="";const h=s.getValue(o.row,o.col);if(h&&h.parameters===`${i.v}_${l.pattern}`)return c({...n,...h.result});const g=H(l.pattern,Number(i.v),this._localeService.getCurrentLocale());if(m=g.result,!m)return c(n);const p={v:m};if(g.color){const d=this._themeService.getCurrentTheme()[`${g.color}500`];d&&(p.interceptorStyle={cl:{rgb:d}})}return s.setValue(o.row,o.col,{result:p,parameters:`${i.v}_${l.pattern}`}),c({...n,...p})},priority:f.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id===f.SetNumfmtMutation.id){const o=n.params;Object.keys(o.values).forEach(c=>{o.values[c].ranges.forEach(S=>{r.Range.foreach(S,(l,i)=>{s.realDeleteValue(l,i)})})})}else if(n.id===f.SetRangeValuesMutation.id){const o=n.params;new r.ObjectMatrix(o.cellValue).forValue((c,a)=>{s.realDeleteValue(c,a)})}})),this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe($.switchMap(n=>{var o;return(o=n==null?void 0:n.activeSheet$)!=null?o:$.of(null)}),$.skip(1)).subscribe(()=>s.reset()))}};exports.SheetsNumfmtCellContentController=ne([_(0,r.IUniverInstanceService),_(1,r.Inject(f.SheetInterceptorService)),_(2,r.Inject(r.ThemeService)),_(3,r.Inject(r.ICommandService)),_(4,r.Inject(f.INumfmtService)),_(5,r.Inject(r.LocaleService))],exports.SheetsNumfmtCellContentController);class x extends r.Disposable{constructor(){super(...arguments);N(this,"_currencySymbol$",new $.BehaviorSubject("US"));N(this,"currencySymbol$",this._currencySymbol$.asObservable())}setCurrencySymbolByCountryCode(s){this._currencySymbol$.next(s)}getCurrencySymbol(){return this._currencySymbol$.getValue()}}var W=Object.defineProperty,re=Object.getOwnPropertyDescriptor,se=(e,t,s)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,oe=(e,t,s,n)=>{for(var o=n>1?void 0:n?re(t,s):t,c=e.length-1,a;c>=0;c--)(a=e[c])&&(o=(n?a(t,s,o):a(o))||o);return n&&o&&W(t,s,o),o},A=(e,t)=>(s,n)=>t(s,n,e),K=(e,t,s)=>se(e,typeof t!="symbol"?t+"":t,s);exports.UniverSheetsNumfmtPlugin=class extends r.Plugin{constructor(t=void 0,s,n){super(),this._config=t,this._injector=s,this._commandService=n}onStarting(){r.registerDependencies(this._injector,[[exports.SheetsNumfmtCellContentController],[D],[x]]),r.touchDependencies(this._injector,[[exports.SheetsNumfmtCellContentController]])}onRendered(){r.touchDependencies(this._injector,[[x]]),[F,G,B,L,M].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}};K(exports.UniverSheetsNumfmtPlugin,"pluginName",J);K(exports.UniverSheetsNumfmtPlugin,"type",r.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtPlugin=oe([r.DependentOn(f.UniverSheetsPlugin),A(1,r.Inject(r.Injector)),A(2,r.ICommandService)],exports.UniverSheetsNumfmtPlugin);const ce=e=>P.find(s=>e.includes(s)),ie=()=>P.map(e=>({label:e,value:e})),ae=e=>U.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),ue=()=>j.map(e=>({label:e.label,value:e.suffix})),le=()=>w.map(e=>({label:e.label,value:e.suffix,color:e.color}));exports.AddDecimalCommand=F;exports.CURRENCYFORMAT=U;exports.DATEFMTLISG=j;exports.MenuCurrencyService=D;exports.NUMBERFORMAT=w;exports.SetCurrencyCommand=B;exports.SetNumfmtCommand=M;exports.SetPercentCommand=L;exports.SubtractDecimalCommand=G;exports.countryCurrencyMap=V;exports.currencySymbols=P;exports.getCurrencyFormatOptions=ae;exports.getCurrencyOptions=ie;exports.getCurrencyType=ce;exports.getDateFormatOptions=ue;exports.getDecimalFromPattern=R;exports.getDecimalString=E;exports.getNumberFormatOptions=le;exports.getPatternPreview=q;exports.getPatternPreviewIgnoreGeneral=H;exports.getPatternType=k;exports.isPatternEqualWithoutDecimal=Z;exports.isPatternHasDecimal=Q;exports.setPatternDecimal=T;
package/lib/es/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  var te = Object.defineProperty;
2
2
  var ne = (e, t, n) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var N = (e, t, n) => ne(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { numfmt as $, CommandType as E, ICommandService as b, IUniverInstanceService as D, IUndoRedoService as re, sequenceExecute as se, Range as C, CellValueType as V, LocaleType as oe, Inject as M, ThemeService as ce, LocaleService as ie, Disposable as K, ObjectMatrix as F, InterceptorEffectEnum as B, UniverInstanceType as Y, DependentOn as ae, Injector as le, Plugin as ue, registerDependencies as me, touchDependencies as L } from "@univerjs/core";
5
- import { getSheetCommandTarget as w, transformCellsToRange as fe, rangeMerge as G, SetNumfmtMutation as z, factorySetNumfmtUndoMutation as de, RemoveNumfmtMutation as he, factoryRemoveNumfmtUndoMutation as ge, SheetsSelectionsService as O, INumfmtService as A, SheetInterceptorService as ve, INTERCEPTOR_POINT as pe, InterceptCellContentPriority as Se, SetRangeValuesMutation as ye, UniverSheetsPlugin as Ce } from "@univerjs/sheets";
6
- import { BehaviorSubject as J, switchMap as be, of as _e, skip as Me } from "rxjs";
7
- const Z = [
4
+ import { numfmt as $, CommandType as I, ICommandService as C, IUniverInstanceService as O, IUndoRedoService as re, sequenceExecute as se, Range as _, CellValueType as V, LocaleType as oe, Inject as M, ThemeService as ce, LocaleService as ie, Disposable as q, ObjectMatrix as j, InterceptorEffectEnum as B, isRealNum as ae, UniverInstanceType as z, DependentOn as ue, Injector as le, Plugin as me, registerDependencies as fe, touchDependencies as L } from "@univerjs/core";
5
+ import { getSheetCommandTarget as A, transformCellsToRange as de, rangeMerge as G, SetNumfmtMutation as X, factorySetNumfmtUndoMutation as he, RemoveNumfmtMutation as ge, factoryRemoveNumfmtUndoMutation as pe, SheetsSelectionsService as D, INumfmtService as w, SheetInterceptorService as ve, INTERCEPTOR_POINT as Se, InterceptCellContentPriority as ye, SetRangeValuesMutation as _e, UniverSheetsPlugin as Ce } from "@univerjs/sheets";
6
+ import { BehaviorSubject as Y, switchMap as be, of as Me, skip as $e } from "rxjs";
7
+ import { DEFAULT_TEXT_FORMAT as Ee } from "@univerjs/engine-numfmt";
8
+ const J = [
8
9
  "$",
9
10
  "£",
10
11
  "¥",
@@ -32,7 +33,7 @@ const Z = [
32
33
  "₽",
33
34
  "₾",
34
35
  "₿"
35
- ], $e = {
36
+ ], Ne = {
36
37
  US: "$",
37
38
  // United States Dollar
38
39
  CA: "C$",
@@ -117,7 +118,7 @@ const Z = [
117
118
  label: "08-05 下午 01:30",
118
119
  suffix: "MM-dd A/P hh:mm"
119
120
  }
120
- ], Ne = [
121
+ ], Re = [
121
122
  {
122
123
  label: "(1,235)",
123
124
  suffix: "#,##0_);(#,##0)"
@@ -145,7 +146,7 @@ const Z = [
145
146
  suffix: "#,##0.00_);[Red]-#,##0.00",
146
147
  color: "red"
147
148
  }
148
- ], Q = [
149
+ ], Z = [
149
150
  {
150
151
  label: (e) => `${e}1,235`,
151
152
  suffix: (e) => `"${e}"#,##0.00_);"${e}"#,##0.00`
@@ -173,128 +174,128 @@ const Z = [
173
174
  suffix: (e) => `"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,
174
175
  color: "red"
175
176
  }
176
- ], Ee = "SHEET_NUMFMT_PLUGIN", x = (e, t = 0) => {
177
+ ], Te = "SHEET_NUMFMT_PLUGIN", T = (e, t = 0) => {
177
178
  var r;
178
179
  return e && (r = $.getInfo(e).maxDecimals) != null ? r : t;
179
- }, We = (e, t) => {
180
+ }, ze = (e, t) => {
180
181
  if (e && !t || !e && t)
181
182
  return !1;
182
183
  const n = (i) => i.reduce(
183
- (u, f) => {
184
- if (u.isEnd)
185
- return u;
186
- const m = f.value || f.num;
187
- return f.type === "point" ? (u.isEnd = !0, u) : { ...u, result: u.result + m };
184
+ (m, d) => {
185
+ if (m.isEnd)
186
+ return m;
187
+ const f = d.value || d.num;
188
+ return d.type === "point" ? (m.isEnd = !0, m) : { ...m, result: m.result + f };
188
189
  },
189
190
  { isEnd: !1, result: "" }
190
- ).result, r = $.getInfo(e)._partitions, s = $.getInfo(t)._partitions, c = n(r[0].tokens), o = n(s[0].tokens), l = n(r[1].tokens), d = n(s[1].tokens);
191
- return c === o && l === d && r[1].color === s[1].color;
192
- }, H = (e) => new Array(Math.min(Math.max(0, Number(e)), 30)).fill(0).join(""), P = (e, t) => e.split(";").map((r) => /\.0?/.test(r) ? r.replace(
191
+ ).result, r = $.getInfo(e)._partitions, s = $.getInfo(t)._partitions, o = n(r[0].tokens), c = n(s[0].tokens), u = n(r[1].tokens), l = n(s[1].tokens);
192
+ return o === c && u === l && r[1].color === s[1].color;
193
+ }, H = (e) => new Array(Math.min(Math.max(0, Number(e)), 30)).fill(0).join(""), x = (e, t) => e.split(";").map((r) => /\.0?/.test(r) ? r.replace(
193
194
  /\.0*/g,
194
195
  `${t > 0 ? "." : ""}${H(Number(t || 0))}`
195
196
  ) : /0([^0]?)|0$/.test(r) ? r.replace(
196
197
  /0([^0]+)|0$/,
197
198
  `0${t > 0 ? "." : ""}${H(Number(t || 0))}$1`
198
- ) : r).join(";"), qe = (e) => /\.0?/.test(e) || /0([^0]?)|0$/.test(e), R = {
199
+ ) : r).join(";"), Xe = (e) => /\.0?/.test(e) || /0([^0]?)|0$/.test(e), R = {
199
200
  id: "sheet.command.numfmt.set.numfmt",
200
- type: E.COMMAND,
201
+ type: I.COMMAND,
201
202
  handler: (e, t) => {
202
203
  if (!t)
203
204
  return !1;
204
- const n = e.get(b), r = e.get(D), s = e.get(re), c = w(r, t);
205
- if (!c) return !1;
206
- const { unitId: o, subUnitId: l } = c, d = t.values.filter((a) => !!a.pattern), i = t.values.filter((a) => !a.pattern), u = fe(o, l, d), f = {
207
- unitId: o,
208
- subUnitId: l,
205
+ const n = e.get(C), r = e.get(O), s = e.get(re), o = A(r, t);
206
+ if (!o) return !1;
207
+ const { unitId: c, subUnitId: u } = o, l = t.values.filter((a) => !!a.pattern), i = t.values.filter((a) => !a.pattern), m = de(c, u, l), d = {
208
+ unitId: c,
209
+ subUnitId: u,
209
210
  ranges: i.map((a) => ({
210
211
  startColumn: a.col,
211
212
  startRow: a.row,
212
213
  endColumn: a.col,
213
214
  endRow: a.row
214
215
  }))
215
- }, m = [], S = [];
216
- if (d.length) {
217
- Object.keys(u.values).forEach((h) => {
218
- const g = u.values[h];
219
- g.ranges = G(g.ranges);
220
- }), m.push({
221
- id: z.id,
222
- params: u
216
+ }, f = [], h = [];
217
+ if (l.length) {
218
+ Object.keys(m.values).forEach((g) => {
219
+ const p = m.values[g];
220
+ p.ranges = G(p.ranges);
221
+ }), f.push({
222
+ id: X.id,
223
+ params: m
223
224
  });
224
- const a = de(e, u);
225
- S.push(...a);
225
+ const a = he(e, m);
226
+ h.push(...a);
226
227
  }
227
228
  if (i.length) {
228
- f.ranges = G(f.ranges), m.push({
229
- id: he.id,
230
- params: f
229
+ d.ranges = G(d.ranges), f.push({
230
+ id: ge.id,
231
+ params: d
231
232
  });
232
- const a = ge(e, f);
233
- S.push(...a);
233
+ const a = pe(e, d);
234
+ h.push(...a);
234
235
  }
235
- const v = se(m, n).result;
236
+ const v = se(f, n).result;
236
237
  return v && s.pushUndoRedo({
237
- unitID: o,
238
- undoMutations: S,
239
- redoMutations: m
238
+ unitID: c,
239
+ undoMutations: h,
240
+ redoMutations: f
240
241
  }), v;
241
242
  }
242
- }, Re = {
243
+ }, xe = {
243
244
  id: "sheet.command.numfmt.add.decimal.command",
244
- type: E.COMMAND,
245
+ type: I.COMMAND,
245
246
  handler: async (e) => {
246
- const t = e.get(b), n = e.get(O), r = e.get(A), s = e.get(D), c = n.getCurrentSelections();
247
- if (!c || !c.length)
247
+ const t = e.get(C), n = e.get(D), r = e.get(w), s = e.get(O), o = n.getCurrentSelections();
248
+ if (!o || !o.length)
248
249
  return !1;
249
- const o = w(s);
250
- if (!o) return !1;
251
- const { unitId: l, subUnitId: d } = o;
250
+ const c = A(s);
251
+ if (!c) return !1;
252
+ const { unitId: u, subUnitId: l } = c;
252
253
  let i = 0;
253
- c.forEach((S) => {
254
- C.foreach(S.range, (v, a) => {
255
- const h = r.getValue(l, d, v, a);
256
- if (!h) {
257
- const p = o.worksheet.getCellRaw(v, a);
258
- if (!i && p && p.t === V.NUMBER && p.v) {
259
- const y = /\.(\d*)$/.exec(String(p.v));
254
+ o.forEach((h) => {
255
+ _.foreach(h.range, (v, a) => {
256
+ const g = r.getValue(u, l, v, a);
257
+ if (!g) {
258
+ const S = c.worksheet.getCellRaw(v, a);
259
+ if (!i && S && S.t === V.NUMBER && S.v) {
260
+ const y = /\.(\d*)$/.exec(String(S.v));
260
261
  if (y) {
261
- const I = y[1].length;
262
- if (!I)
262
+ const E = y[1].length;
263
+ if (!E)
263
264
  return;
264
- i = Math.max(i, I);
265
+ i = Math.max(i, E);
265
266
  }
266
267
  }
267
268
  return;
268
269
  }
269
- const g = x(h.pattern);
270
- i = g > i ? g : i;
270
+ const p = T(g.pattern);
271
+ i = p > i ? p : i;
271
272
  });
272
273
  });
273
- const u = i + 1, f = P(`0${u > 0 ? ".0" : ""}`, u), m = [];
274
- return c.forEach((S) => {
275
- C.foreach(S.range, (v, a) => {
276
- const h = r.getValue(l, d, v, a);
277
- if (!h)
278
- m.push({
274
+ const m = i + 1, d = x(`0${m > 0 ? ".0" : ""}`, m), f = [];
275
+ return o.forEach((h) => {
276
+ _.foreach(h.range, (v, a) => {
277
+ const g = r.getValue(u, l, v, a);
278
+ if (!g)
279
+ f.push({
279
280
  row: v,
280
281
  col: a,
281
- pattern: f
282
+ pattern: d
282
283
  });
283
284
  else {
284
- const g = x(h.pattern), p = P(h.pattern, g + 1);
285
- p !== h.pattern && m.push({
285
+ const p = T(g.pattern), S = x(g.pattern, p + 1);
286
+ S !== g.pattern && f.push({
286
287
  row: v,
287
288
  col: a,
288
- pattern: p
289
+ pattern: S
289
290
  });
290
291
  }
291
292
  });
292
- }), m.length ? await t.executeCommand(R.id, { values: m }) : !1;
293
+ }), f.length ? await t.executeCommand(R.id, { values: f }) : !1;
293
294
  }
294
295
  };
295
- class X {
296
+ class Q {
296
297
  constructor() {
297
- N(this, "_currencySymbol$", new J("US"));
298
+ N(this, "_currencySymbol$", new Y("US"));
298
299
  N(this, "currencySymbol$", this._currencySymbol$.asObservable());
299
300
  }
300
301
  /**
@@ -307,180 +308,195 @@ class X {
307
308
  return this._currencySymbol$.getValue();
308
309
  }
309
310
  }
310
- const xe = {
311
+ const Pe = {
311
312
  id: "sheet.command.numfmt.set.currency",
312
- type: E.COMMAND,
313
+ type: I.COMMAND,
313
314
  handler: async (e) => {
314
- const t = e.get(b), n = e.get(O), r = e.get(X), s = $e[r.getCurrencySymbol()] || "$", c = n.getCurrentSelections();
315
- if (!c || !c.length)
315
+ const t = e.get(C), n = e.get(D), r = e.get(Q), s = Ne[r.getCurrencySymbol()] || "$", o = n.getCurrentSelections();
316
+ if (!o || !o.length)
316
317
  return !1;
317
- const o = [], l = Q[4].suffix(s);
318
- return c.forEach((i) => {
319
- C.foreach(i.range, (u, f) => {
320
- o.push({ row: u, col: f, pattern: l, type: "currency" });
318
+ const c = [], u = Z[4].suffix(s);
319
+ return o.forEach((i) => {
320
+ _.foreach(i.range, (m, d) => {
321
+ c.push({ row: m, col: d, pattern: u, type: "currency" });
321
322
  });
322
- }), await t.executeCommand(R.id, { values: o });
323
+ }), await t.executeCommand(R.id, { values: c });
323
324
  }
324
- }, Pe = {
325
+ }, Ue = {
325
326
  id: "sheet.command.numfmt.set.percent",
326
- type: E.COMMAND,
327
+ type: I.COMMAND,
327
328
  handler: async (e) => {
328
- const t = e.get(b), r = e.get(O).getCurrentSelections();
329
+ const t = e.get(C), r = e.get(D).getCurrentSelections();
329
330
  if (!r || !r.length)
330
331
  return !1;
331
- const s = [], c = "0%";
332
- return r.forEach((l) => {
333
- C.foreach(l.range, (d, i) => {
334
- s.push({ row: d, col: i, pattern: c, type: "percent" });
332
+ const s = [], o = "0%";
333
+ return r.forEach((u) => {
334
+ _.foreach(u.range, (l, i) => {
335
+ s.push({ row: l, col: i, pattern: o, type: "percent" });
335
336
  });
336
337
  }), await t.executeCommand(R.id, { values: s });
337
338
  }
338
- }, Te = {
339
+ }, Oe = {
339
340
  id: "sheet.command.numfmt.subtract.decimal.command",
340
- type: E.COMMAND,
341
+ type: I.COMMAND,
341
342
  handler: async (e) => {
342
- const t = e.get(b), n = e.get(O), r = e.get(A), s = e.get(D), c = n.getCurrentSelections();
343
- if (!c || !c.length)
343
+ const t = e.get(C), n = e.get(D), r = e.get(w), s = e.get(O), o = n.getCurrentSelections();
344
+ if (!o || !o.length)
344
345
  return !1;
345
- const o = w(s);
346
- if (!o) return !1;
347
- const { unitId: l, subUnitId: d } = o;
346
+ const c = A(s);
347
+ if (!c) return !1;
348
+ const { unitId: u, subUnitId: l } = c;
348
349
  let i = 0;
349
- c.forEach((v) => {
350
- C.foreach(v.range, (a, h) => {
351
- const g = r.getValue(l, d, a, h);
352
- if (!g) {
353
- const y = o.worksheet.getCellRaw(a, h);
350
+ o.forEach((v) => {
351
+ _.foreach(v.range, (a, g) => {
352
+ const p = r.getValue(u, l, a, g);
353
+ if (!p) {
354
+ const y = c.worksheet.getCellRaw(a, g);
354
355
  if (!i && y && y.t === V.NUMBER && y.v) {
355
- const I = /\.(\d*)$/.exec(String(y.v));
356
- if (I) {
357
- const j = I[1].length;
358
- if (!j)
356
+ const E = /\.(\d*)$/.exec(String(y.v));
357
+ if (E) {
358
+ const F = E[1].length;
359
+ if (!F)
359
360
  return;
360
- i = Math.max(i, j);
361
+ i = Math.max(i, F);
361
362
  }
362
363
  }
363
364
  return;
364
365
  }
365
- const p = x(g.pattern);
366
- i = p > i ? p : i;
366
+ const S = T(p.pattern);
367
+ i = S > i ? S : i;
367
368
  });
368
369
  });
369
- const u = i - 1, f = P(`0${u > 0 ? ".0" : "."}`, u), m = [];
370
- return c.forEach((v) => {
371
- C.foreach(v.range, (a, h) => {
372
- const g = r.getValue(l, d, a, h);
373
- if (!g)
374
- m.push({
370
+ const m = i - 1, d = x(`0${m > 0 ? ".0" : "."}`, m), f = [];
371
+ return o.forEach((v) => {
372
+ _.foreach(v.range, (a, g) => {
373
+ const p = r.getValue(u, l, a, g);
374
+ if (!p)
375
+ f.push({
375
376
  row: a,
376
- col: h,
377
- pattern: f
377
+ col: g,
378
+ pattern: d
378
379
  });
379
380
  else {
380
- const p = x(g.pattern);
381
- m.push({
381
+ const S = T(p.pattern);
382
+ f.push({
382
383
  row: a,
383
- col: h,
384
- pattern: P(g.pattern, p - 1)
384
+ col: g,
385
+ pattern: x(p.pattern, S - 1)
385
386
  });
386
387
  }
387
388
  });
388
- }), await t.executeCommand(R.id, { values: m });
389
+ }), await t.executeCommand(R.id, { values: f });
389
390
  }
390
- }, Ke = (e) => $.getInfo(e).type || "unknown", Ue = (e, t, n) => {
391
- const r = $.getInfo(e), s = n === oe.ZH_CN ? "zh-CN" : "en", c = r._partitions[1], o = $.format(e, t, { locale: s, throws: !1 });
391
+ }, Ye = (e) => $.getInfo(e).type || "unknown", De = (e, t, n) => {
392
+ const r = $.getInfo(e), s = n === oe.ZH_CN ? "zh-CN" : "en", o = r._partitions[1], c = $.format(e, t, { locale: s, throws: !1 });
392
393
  return t < 0 ? {
393
- result: o,
394
- color: c.color
394
+ result: c,
395
+ color: o.color
395
396
  } : {
396
- result: o
397
+ result: c
397
398
  };
398
- }, De = (e, t, n) => e === "General" ? {
399
+ }, Ve = (e, t, n) => e === "General" ? {
399
400
  result: String(t)
400
- } : Ue(e, t, n);
401
- var Oe = Object.defineProperty, Ve = Object.getOwnPropertyDescriptor, we = (e, t, n, r) => {
402
- for (var s = r > 1 ? void 0 : r ? Ve(t, n) : t, c = e.length - 1, o; c >= 0; c--)
403
- (o = e[c]) && (s = (r ? o(t, n, s) : o(s)) || s);
404
- return r && s && Oe(t, n, s), s;
405
- }, _ = (e, t) => (n, r) => t(n, r, e);
406
- let T = class extends K {
407
- constructor(e, t, n, r, s, c) {
408
- super(), this._instanceService = e, this._sheetInterceptorService = t, this._themeService = n, this._commandService = r, this._numfmtService = s, this._localeService = c, this._initInterceptorCellContent();
401
+ } : De(e, t, n);
402
+ var Ae = Object.defineProperty, we = Object.getOwnPropertyDescriptor, Fe = (e, t, n, r) => {
403
+ for (var s = r > 1 ? void 0 : r ? we(t, n) : t, o = e.length - 1, c; o >= 0; o--)
404
+ (c = e[o]) && (s = (r ? c(t, n, s) : c(s)) || s);
405
+ return r && s && Ae(t, n, s), s;
406
+ }, b = (e, t) => (n, r) => t(n, r, e);
407
+ let P = class extends q {
408
+ constructor(e, t, n, r, s, o) {
409
+ super(), this._instanceService = e, this._sheetInterceptorService = t, this._themeService = n, this._commandService = r, this._numfmtService = s, this._localeService = o, this._initInterceptorCellContent();
409
410
  }
410
411
  // eslint-disable-next-line max-lines-per-function
411
412
  _initInterceptorCellContent() {
412
- const e = new F();
413
- this.disposeWithMe(this._sheetInterceptorService.intercept(pe.CELL_CONTENT, {
413
+ const e = {
414
+ tl: {
415
+ size: 6,
416
+ color: "#409f11"
417
+ }
418
+ }, t = new j();
419
+ this.disposeWithMe(this._sheetInterceptorService.intercept(Se.CELL_CONTENT, {
414
420
  effect: B.Value | B.Style,
415
- handler: (t, n, r) => {
416
- const s = n.unitId, c = n.subUnitId;
417
- let o;
418
- const l = t;
419
- if (!l || l.t !== V.NUMBER || l.v == null || Number.isNaN(l.v))
420
- return r(t);
421
- if (t != null && t.s) {
422
- const m = n.workbook.getStyles().get(t.s);
423
- m != null && m.n && (o = m.n);
421
+ handler: (n, r, s) => {
422
+ const o = r.unitId, c = r.subUnitId;
423
+ let u;
424
+ const l = n;
425
+ if (!l)
426
+ return s(n);
427
+ if (n != null && n.s) {
428
+ const h = r.workbook.getStyles().get(n.s);
429
+ h != null && h.n && (u = h.n);
424
430
  }
425
- if (o || (o = this._numfmtService.getValue(s, c, n.row, n.col)), !o)
426
- return r(t);
427
- let d = "";
428
- const i = e.getValue(n.row, n.col);
429
- if (i && i.parameters === `${l.v}_${o.pattern}`)
430
- return r({ ...t, ...i.result });
431
- const u = De(o.pattern, Number(l.v), this._localeService.getCurrentLocale());
432
- if (d = u.result, !d)
433
- return r(t);
434
- const f = { v: d };
435
- if (u.color) {
436
- const m = this._themeService.getCurrentTheme()[`${u.color}500`];
437
- m && (f.interceptorStyle = { cl: { rgb: m } });
431
+ if (u || (u = this._numfmtService.getValue(o, c, r.row, r.col)), !u)
432
+ return s(n);
433
+ if (u.pattern === Ee && l.v && ae(l.v))
434
+ return s({
435
+ ...n,
436
+ markers: {
437
+ ...n == null ? void 0 : n.markers,
438
+ ...e
439
+ }
440
+ });
441
+ if (l.t !== V.NUMBER || l.v == null || Number.isNaN(l.v))
442
+ return s(n);
443
+ let i = "";
444
+ const m = t.getValue(r.row, r.col);
445
+ if (m && m.parameters === `${l.v}_${u.pattern}`)
446
+ return s({ ...n, ...m.result });
447
+ const d = Ve(u.pattern, Number(l.v), this._localeService.getCurrentLocale());
448
+ if (i = d.result, !i)
449
+ return s(n);
450
+ const f = { v: i };
451
+ if (d.color) {
452
+ const h = this._themeService.getCurrentTheme()[`${d.color}500`];
453
+ h && (f.interceptorStyle = { cl: { rgb: h } });
438
454
  }
439
- return e.setValue(n.row, n.col, {
455
+ return t.setValue(r.row, r.col, {
440
456
  result: f,
441
- parameters: `${l.v}_${o.pattern}`
442
- }), r({ ...t, ...f });
457
+ parameters: `${l.v}_${u.pattern}`
458
+ }), s({ ...n, ...f });
443
459
  },
444
- priority: Se.NUMFMT
445
- })), this.disposeWithMe(this._commandService.onCommandExecuted((t) => {
446
- if (t.id === z.id) {
447
- const n = t.params;
448
- Object.keys(n.values).forEach((r) => {
449
- n.values[r].ranges.forEach((c) => {
450
- C.foreach(c, (o, l) => {
451
- e.realDeleteValue(o, l);
460
+ priority: ye.NUMFMT
461
+ })), this.disposeWithMe(this._commandService.onCommandExecuted((n) => {
462
+ if (n.id === X.id) {
463
+ const r = n.params;
464
+ Object.keys(r.values).forEach((s) => {
465
+ r.values[s].ranges.forEach((c) => {
466
+ _.foreach(c, (u, l) => {
467
+ t.realDeleteValue(u, l);
452
468
  });
453
469
  });
454
470
  });
455
- } else if (t.id === ye.id) {
456
- const n = t.params;
457
- new F(n.cellValue).forValue((r, s) => {
458
- e.realDeleteValue(r, s);
471
+ } else if (n.id === _e.id) {
472
+ const r = n.params;
473
+ new j(r.cellValue).forValue((s, o) => {
474
+ t.realDeleteValue(s, o);
459
475
  });
460
476
  }
461
477
  })), this.disposeWithMe(
462
- this._instanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET).pipe(
463
- be((t) => {
464
- var n;
465
- return (n = t == null ? void 0 : t.activeSheet$) != null ? n : _e(null);
478
+ this._instanceService.getCurrentTypeOfUnit$(z.UNIVER_SHEET).pipe(
479
+ be((n) => {
480
+ var r;
481
+ return (r = n == null ? void 0 : n.activeSheet$) != null ? r : Me(null);
466
482
  }),
467
- Me(1)
468
- ).subscribe(() => e.reset())
483
+ $e(1)
484
+ ).subscribe(() => t.reset())
469
485
  );
470
486
  }
471
487
  };
472
- T = we([
473
- _(0, D),
474
- _(1, M(ve)),
475
- _(2, M(ce)),
476
- _(3, M(b)),
477
- _(4, M(A)),
478
- _(5, M(ie))
479
- ], T);
480
- class W extends K {
488
+ P = Fe([
489
+ b(0, O),
490
+ b(1, M(ve)),
491
+ b(2, M(ce)),
492
+ b(3, M(C)),
493
+ b(4, M(w)),
494
+ b(5, M(ie))
495
+ ], P);
496
+ class W extends q {
481
497
  constructor() {
482
498
  super(...arguments);
483
- N(this, "_currencySymbol$", new J("US"));
499
+ N(this, "_currencySymbol$", new Y("US"));
484
500
  N(this, "currencySymbol$", this._currencySymbol$.asObservable());
485
501
  }
486
502
  /**
@@ -493,75 +509,75 @@ class W extends K {
493
509
  return this._currencySymbol$.getValue();
494
510
  }
495
511
  }
496
- var k = Object.defineProperty, Ae = Object.getOwnPropertyDescriptor, je = (e, t, n) => t in e ? k(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Fe = (e, t, n, r) => {
497
- for (var s = r > 1 ? void 0 : r ? Ae(t, n) : t, c = e.length - 1, o; c >= 0; c--)
498
- (o = e[c]) && (s = (r ? o(t, n, s) : o(s)) || s);
512
+ var k = Object.defineProperty, je = Object.getOwnPropertyDescriptor, Be = (e, t, n) => t in e ? k(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Le = (e, t, n, r) => {
513
+ for (var s = r > 1 ? void 0 : r ? je(t, n) : t, o = e.length - 1, c; o >= 0; o--)
514
+ (c = e[o]) && (s = (r ? c(t, n, s) : c(s)) || s);
499
515
  return r && s && k(t, n, s), s;
500
- }, q = (e, t) => (n, r) => t(n, r, e), ee = (e, t, n) => je(e, typeof t != "symbol" ? t + "" : t, n);
501
- let U = class extends ue {
516
+ }, K = (e, t) => (n, r) => t(n, r, e), ee = (e, t, n) => Be(e, typeof t != "symbol" ? t + "" : t, n);
517
+ let U = class extends me {
502
518
  constructor(e = void 0, t, n) {
503
519
  super(), this._config = e, this._injector = t, this._commandService = n;
504
520
  }
505
521
  onStarting() {
506
- me(this._injector, [
507
- [T],
508
- [X],
522
+ fe(this._injector, [
523
+ [P],
524
+ [Q],
509
525
  [W]
510
526
  ]), L(this._injector, [
511
- [T]
527
+ [P]
512
528
  ]);
513
529
  }
514
530
  onRendered() {
515
531
  L(this._injector, [
516
532
  [W]
517
533
  ]), [
518
- Re,
519
- Te,
520
534
  xe,
535
+ Oe,
521
536
  Pe,
537
+ Ue,
522
538
  R
523
539
  ].forEach((e) => {
524
540
  this.disposeWithMe(this._commandService.registerCommand(e));
525
541
  });
526
542
  }
527
543
  };
528
- ee(U, "pluginName", Ee);
529
- ee(U, "type", Y.UNIVER_SHEET);
530
- U = Fe([
531
- ae(Ce),
532
- q(1, M(le)),
533
- q(2, b)
544
+ ee(U, "pluginName", Te);
545
+ ee(U, "type", z.UNIVER_SHEET);
546
+ U = Le([
547
+ ue(Ce),
548
+ K(1, M(le)),
549
+ K(2, C)
534
550
  ], U);
535
- const Ye = (e) => Z.find((n) => e.includes(n)), ze = () => Z.map((e) => ({ label: e, value: e })), Je = (e) => Q.map((t) => ({
551
+ const Je = (e) => J.find((n) => e.includes(n)), Ze = () => J.map((e) => ({ label: e, value: e })), Qe = (e) => Z.map((t) => ({
536
552
  label: t.label(e),
537
553
  value: t.suffix(e),
538
554
  color: t.color
539
- })), Ze = () => Ie.map((e) => ({ label: e.label, value: e.suffix })), Qe = () => Ne.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
555
+ })), ke = () => Ie.map((e) => ({ label: e.label, value: e.suffix })), et = () => Re.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
540
556
  export {
541
- Re as AddDecimalCommand,
542
- Q as CURRENCYFORMAT,
557
+ xe as AddDecimalCommand,
558
+ Z as CURRENCYFORMAT,
543
559
  Ie as DATEFMTLISG,
544
- X as MenuCurrencyService,
545
- Ne as NUMBERFORMAT,
546
- xe as SetCurrencyCommand,
560
+ Q as MenuCurrencyService,
561
+ Re as NUMBERFORMAT,
562
+ Pe as SetCurrencyCommand,
547
563
  R as SetNumfmtCommand,
548
- Pe as SetPercentCommand,
549
- T as SheetsNumfmtCellContentController,
550
- Te as SubtractDecimalCommand,
564
+ Ue as SetPercentCommand,
565
+ P as SheetsNumfmtCellContentController,
566
+ Oe as SubtractDecimalCommand,
551
567
  U as UniverSheetsNumfmtPlugin,
552
- $e as countryCurrencyMap,
553
- Z as currencySymbols,
554
- Je as getCurrencyFormatOptions,
555
- ze as getCurrencyOptions,
556
- Ye as getCurrencyType,
557
- Ze as getDateFormatOptions,
558
- x as getDecimalFromPattern,
568
+ Ne as countryCurrencyMap,
569
+ J as currencySymbols,
570
+ Qe as getCurrencyFormatOptions,
571
+ Ze as getCurrencyOptions,
572
+ Je as getCurrencyType,
573
+ ke as getDateFormatOptions,
574
+ T as getDecimalFromPattern,
559
575
  H as getDecimalString,
560
- Qe as getNumberFormatOptions,
561
- Ue as getPatternPreview,
562
- De as getPatternPreviewIgnoreGeneral,
563
- Ke as getPatternType,
564
- We as isPatternEqualWithoutDecimal,
565
- qe as isPatternHasDecimal,
566
- P as setPatternDecimal
576
+ et as getNumberFormatOptions,
577
+ De as getPatternPreview,
578
+ Ve as getPatternPreviewIgnoreGeneral,
579
+ Ye as getPatternType,
580
+ ze as isPatternEqualWithoutDecimal,
581
+ Xe as isPatternHasDecimal,
582
+ x as setPatternDecimal
567
583
  };
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(s,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],n):(s=typeof globalThis<"u"?globalThis:s||self,n(s.UniverSheetsNumfmt={},s.UniverCore,s.UniverSheets,s.rxjs))})(this,function(s,n,l,N){"use strict";var le=Object.defineProperty;var oe=(s,n,l)=>n in s?le(s,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[n]=l;var E=(s,n,l)=>oe(s,typeof n!="symbol"?n+"":n,l);const T=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"],j={US:"$",CA:"C$",GB:"£",JP:"¥",IN:"₹",AU:"A$",CN:"¥",KR:"₩",RU:"₽",AT:"€",BE:"€",CY:"€",EE:"€",FI:"€",FR:"€",DE:"€",GR:"€",IE:"€",IT:"€",LV:"€",LT:"€",LU:"€",MT:"€",NL:"€",PT:"€",SK:"€",SI:"€",ES:"€"},V=[{label:"1930-08-05",suffix:"yyyy-MM-dd"},{label:"1930/08/05",suffix:"yyyy/MM/dd"},{label:"1930年08月05日",suffix:'yyyy"年"MM"月"dd"日"'},{label:"08-05",suffix:"MM-dd"},{label:"8月5日",suffix:'M"月"d"日"'},{label:"13:30:30",suffix:"h:mm:ss"},{label:"13:30",suffix:"h:mm"},{label:"下午01:30",suffix:"A/P hh:mm"},{label:"下午1:30",suffix:"A/P h:mm"},{label:"下午1:30:30",suffix:"A/P h:mm:ss"},{label:"08-05 下午 01:30",suffix:"MM-dd A/P hh:mm"}],w=[{label:"(1,235)",suffix:"#,##0_);(#,##0)"},{label:"(1,235) ",suffix:"#,##0_);[Red](#,##0)",color:"red"},{label:"1,234.56",suffix:"#,##0.00_);#,##0.00"},{label:"1,234.56",suffix:"#,##0.00_);[Red]#,##0.00",color:"red"},{label:"-1,234.56",suffix:"#,##0.00_);-#,##0.00"},{label:"-1,234.56",suffix:"#,##0.00_);[Red]-#,##0.00",color:"red"}],U=[{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);"${e}"#,##0.00`},{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,color:"red"},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);("${e}"#,##0.00)`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,color:"red"},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);-"${e}"#,##0.00`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,color:"red"}],z="SHEET_NUMFMT_PLUGIN",$=(e,t=0)=>{var i;return e&&(i=n.numfmt.getInfo(e).maxDecimals)!=null?i:t},J=(e,t)=>{if(e&&!t||!e&&t)return!1;const r=o=>o.reduce((S,v)=>{if(S.isEnd)return S;const g=v.value||v.num;return v.type==="point"?(S.isEnd=!0,S):{...S,result:S.result+g}},{isEnd:!1,result:""}).result,i=n.numfmt.getInfo(e)._partitions,a=n.numfmt.getInfo(t)._partitions,u=r(i[0].tokens),c=r(a[0].tokens),f=r(i[1].tokens),d=r(a[1].tokens);return u===c&&f===d&&i[1].color===a[1].color},D=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),P=(e,t)=>e.split(";").map(i=>/\.0?/.test(i)?i.replace(/\.0*/g,`${t>0?".":""}${D(Number(t||0))}`):/0([^0]?)|0$/.test(i)?i.replace(/0([^0]+)|0$/,`0${t>0?".":""}${D(Number(t||0))}$1`):i).join(";"),Z=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),M={id:"sheet.command.numfmt.set.numfmt",type:n.CommandType.COMMAND,handler:(e,t)=>{if(!t)return!1;const r=e.get(n.ICommandService),i=e.get(n.IUniverInstanceService),a=e.get(n.IUndoRedoService),u=l.getSheetCommandTarget(i,t);if(!u)return!1;const{unitId:c,subUnitId:f}=u,d=t.values.filter(m=>!!m.pattern),o=t.values.filter(m=>!m.pattern),S=l.transformCellsToRange(c,f,d),v={unitId:c,subUnitId:f,ranges:o.map(m=>({startColumn:m.col,startRow:m.row,endColumn:m.col,endRow:m.row}))},g=[],h=[];if(d.length){Object.keys(S.values).forEach(C=>{const y=S.values[C];y.ranges=l.rangeMerge(y.ranges)}),g.push({id:l.SetNumfmtMutation.id,params:S});const m=l.factorySetNumfmtUndoMutation(e,S);h.push(...m)}if(o.length){v.ranges=l.rangeMerge(v.ranges),g.push({id:l.RemoveNumfmtMutation.id,params:v});const m=l.factoryRemoveNumfmtUndoMutation(e,v);h.push(...m)}const p=n.sequenceExecute(g,r).result;return p&&a.pushUndoRedo({unitID:c,undoMutations:h,redoMutations:g}),p}},A={id:"sheet.command.numfmt.add.decimal.command",type:n.CommandType.COMMAND,handler:async e=>{const t=e.get(n.ICommandService),r=e.get(l.SheetsSelectionsService),i=e.get(l.INumfmtService),a=e.get(n.IUniverInstanceService),u=r.getCurrentSelections();if(!u||!u.length)return!1;const c=l.getSheetCommandTarget(a);if(!c)return!1;const{unitId:f,subUnitId:d}=c;let o=0;u.forEach(h=>{n.Range.foreach(h.range,(p,m)=>{const C=i.getValue(f,d,p,m);if(!C){const b=c.worksheet.getCellRaw(p,m);if(!o&&b&&b.t===n.CellValueType.NUMBER&&b.v){const _=/\.(\d*)$/.exec(String(b.v));if(_){const R=_[1].length;if(!R)return;o=Math.max(o,R)}}return}const y=$(C.pattern);o=y>o?y:o})});const S=o+1,v=P(`0${S>0?".0":""}`,S),g=[];return u.forEach(h=>{n.Range.foreach(h.range,(p,m)=>{const C=i.getValue(f,d,p,m);if(!C)g.push({row:p,col:m,pattern:v});else{const y=$(C.pattern),b=P(C.pattern,y+1);b!==C.pattern&&g.push({row:p,col:m,pattern:b})}})}),g.length?await t.executeCommand(M.id,{values:g}):!1}};class O{constructor(){E(this,"_currencySymbol$",new N.BehaviorSubject("US"));E(this,"currencySymbol$",this._currencySymbol$.asObservable())}setCurrencySymbolByCountryCode(t){this._currencySymbol$.next(t)}getCurrencySymbol(){return this._currencySymbol$.getValue()}}const F={id:"sheet.command.numfmt.set.currency",type:n.CommandType.COMMAND,handler:async e=>{const t=e.get(n.ICommandService),r=e.get(l.SheetsSelectionsService),i=e.get(O),a=j[i.getCurrencySymbol()]||"$",u=r.getCurrentSelections();if(!u||!u.length)return!1;const c=[],f=U[4].suffix(a);return u.forEach(o=>{n.Range.foreach(o.range,(S,v)=>{c.push({row:S,col:v,pattern:f,type:"currency"})})}),await t.executeCommand(M.id,{values:c})}},B={id:"sheet.command.numfmt.set.percent",type:n.CommandType.COMMAND,handler:async e=>{const t=e.get(n.ICommandService),i=e.get(l.SheetsSelectionsService).getCurrentSelections();if(!i||!i.length)return!1;const a=[],u="0%";return i.forEach(f=>{n.Range.foreach(f.range,(d,o)=>{a.push({row:d,col:o,pattern:u,type:"percent"})})}),await t.executeCommand(M.id,{values:a})}},L={id:"sheet.command.numfmt.subtract.decimal.command",type:n.CommandType.COMMAND,handler:async e=>{const t=e.get(n.ICommandService),r=e.get(l.SheetsSelectionsService),i=e.get(l.INumfmtService),a=e.get(n.IUniverInstanceService),u=r.getCurrentSelections();if(!u||!u.length)return!1;const c=l.getSheetCommandTarget(a);if(!c)return!1;const{unitId:f,subUnitId:d}=c;let o=0;u.forEach(p=>{n.Range.foreach(p.range,(m,C)=>{const y=i.getValue(f,d,m,C);if(!y){const _=c.worksheet.getCellRaw(m,C);if(!o&&_&&_.t===n.CellValueType.NUMBER&&_.v){const R=/\.(\d*)$/.exec(String(_.v));if(R){const K=R[1].length;if(!K)return;o=Math.max(o,K)}}return}const b=$(y.pattern);o=b>o?b:o})});const S=o-1,v=P(`0${S>0?".0":"."}`,S),g=[];return u.forEach(p=>{n.Range.foreach(p.range,(m,C)=>{const y=i.getValue(f,d,m,C);if(!y)g.push({row:m,col:C,pattern:v});else{const b=$(y.pattern);g.push({row:m,col:C,pattern:P(y.pattern,b-1)})}})}),await t.executeCommand(M.id,{values:g})}},Q=e=>n.numfmt.getInfo(e).type||"unknown",G=(e,t,r)=>{const i=n.numfmt.getInfo(e),a=r===n.LocaleType.ZH_CN?"zh-CN":"en",u=i._partitions[1],c=n.numfmt.format(e,t,{locale:a,throws:!1});return t<0?{result:c,color:u.color}:{result:c}},H=(e,t,r)=>e==="General"?{result:String(t)}:G(e,t,r);var X=Object.defineProperty,k=Object.getOwnPropertyDescriptor,ee=(e,t,r,i)=>{for(var a=i>1?void 0:i?k(t,r):t,u=e.length-1,c;u>=0;u--)(c=e[u])&&(a=(i?c(t,r,a):c(a))||a);return i&&a&&X(t,r,a),a},I=(e,t)=>(r,i)=>t(r,i,e);s.SheetsNumfmtCellContentController=class extends n.Disposable{constructor(t,r,i,a,u,c){super(),this._instanceService=t,this._sheetInterceptorService=r,this._themeService=i,this._commandService=a,this._numfmtService=u,this._localeService=c,this._initInterceptorCellContent()}_initInterceptorCellContent(){const t=new n.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(l.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Value|n.InterceptorEffectEnum.Style,handler:(r,i,a)=>{const u=i.unitId,c=i.subUnitId;let f;const d=r;if(!d||d.t!==n.CellValueType.NUMBER||d.v==null||Number.isNaN(d.v))return a(r);if(r!=null&&r.s){const h=i.workbook.getStyles().get(r.s);h!=null&&h.n&&(f=h.n)}if(f||(f=this._numfmtService.getValue(u,c,i.row,i.col)),!f)return a(r);let o="";const S=t.getValue(i.row,i.col);if(S&&S.parameters===`${d.v}_${f.pattern}`)return a({...r,...S.result});const v=H(f.pattern,Number(d.v),this._localeService.getCurrentLocale());if(o=v.result,!o)return a(r);const g={v:o};if(v.color){const h=this._themeService.getCurrentTheme()[`${v.color}500`];h&&(g.interceptorStyle={cl:{rgb:h}})}return t.setValue(i.row,i.col,{result:g,parameters:`${d.v}_${f.pattern}`}),a({...r,...g})},priority:l.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===l.SetNumfmtMutation.id){const i=r.params;Object.keys(i.values).forEach(a=>{i.values[a].ranges.forEach(c=>{n.Range.foreach(c,(f,d)=>{t.realDeleteValue(f,d)})})})}else if(r.id===l.SetRangeValuesMutation.id){const i=r.params;new n.ObjectMatrix(i.cellValue).forValue((a,u)=>{t.realDeleteValue(a,u)})}})),this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET).pipe(N.switchMap(r=>{var i;return(i=r==null?void 0:r.activeSheet$)!=null?i:N.of(null)}),N.skip(1)).subscribe(()=>t.reset()))}},s.SheetsNumfmtCellContentController=ee([I(0,n.IUniverInstanceService),I(1,n.Inject(l.SheetInterceptorService)),I(2,n.Inject(n.ThemeService)),I(3,n.Inject(n.ICommandService)),I(4,n.Inject(l.INumfmtService)),I(5,n.Inject(n.LocaleService))],s.SheetsNumfmtCellContentController);class q extends n.Disposable{constructor(){super(...arguments);E(this,"_currencySymbol$",new N.BehaviorSubject("US"));E(this,"currencySymbol$",this._currencySymbol$.asObservable())}setCurrencySymbolByCountryCode(r){this._currencySymbol$.next(r)}getCurrencySymbol(){return this._currencySymbol$.getValue()}}var x=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,re=(e,t,r,i)=>{for(var a=i>1?void 0:i?te(t,r):t,u=e.length-1,c;u>=0;u--)(c=e[u])&&(a=(i?c(t,r,a):c(a))||a);return i&&a&&x(t,r,a),a},W=(e,t)=>(r,i)=>t(r,i,e),Y=(e,t,r)=>ne(e,typeof t!="symbol"?t+"":t,r);s.UniverSheetsNumfmtPlugin=class extends n.Plugin{constructor(t=void 0,r,i){super(),this._config=t,this._injector=r,this._commandService=i}onStarting(){n.registerDependencies(this._injector,[[s.SheetsNumfmtCellContentController],[O],[q]]),n.touchDependencies(this._injector,[[s.SheetsNumfmtCellContentController]])}onRendered(){n.touchDependencies(this._injector,[[q]]),[A,L,F,B,M].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}},Y(s.UniverSheetsNumfmtPlugin,"pluginName",z),Y(s.UniverSheetsNumfmtPlugin,"type",n.UniverInstanceType.UNIVER_SHEET),s.UniverSheetsNumfmtPlugin=re([n.DependentOn(l.UniverSheetsPlugin),W(1,n.Inject(n.Injector)),W(2,n.ICommandService)],s.UniverSheetsNumfmtPlugin);const ie=e=>T.find(r=>e.includes(r)),se=()=>T.map(e=>({label:e,value:e})),ae=e=>U.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),ue=()=>V.map(e=>({label:e.label,value:e.suffix})),ce=()=>w.map(e=>({label:e.label,value:e.suffix,color:e.color}));s.AddDecimalCommand=A,s.CURRENCYFORMAT=U,s.DATEFMTLISG=V,s.MenuCurrencyService=O,s.NUMBERFORMAT=w,s.SetCurrencyCommand=F,s.SetNumfmtCommand=M,s.SetPercentCommand=B,s.SubtractDecimalCommand=L,s.countryCurrencyMap=j,s.currencySymbols=T,s.getCurrencyFormatOptions=ae,s.getCurrencyOptions=se,s.getCurrencyType=ie,s.getDateFormatOptions=ue,s.getDecimalFromPattern=$,s.getDecimalString=D,s.getNumberFormatOptions=ce,s.getPatternPreview=G,s.getPatternPreviewIgnoreGeneral=H,s.getPatternType=Q,s.isPatternEqualWithoutDecimal=J,s.isPatternHasDecimal=Z,s.setPatternDecimal=P,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(a,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/engine-numfmt")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs","@univerjs/engine-numfmt"],n):(a=typeof globalThis<"u"?globalThis:a||self,n(a.UniverSheetsNumfmt={},a.UniverCore,a.UniverSheets,a.rxjs,a.UniverEngineNumfmt))})(this,function(a,n,m,N,z){"use strict";var me=Object.defineProperty;var oe=(a,n,m)=>n in a?me(a,n,{enumerable:!0,configurable:!0,writable:!0,value:m}):a[n]=m;var E=(a,n,m)=>oe(a,typeof n!="symbol"?n+"":n,m);const P=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"],j={US:"$",CA:"C$",GB:"£",JP:"¥",IN:"₹",AU:"A$",CN:"¥",KR:"₩",RU:"₽",AT:"€",BE:"€",CY:"€",EE:"€",FI:"€",FR:"€",DE:"€",GR:"€",IE:"€",IT:"€",LV:"€",LT:"€",LU:"€",MT:"€",NL:"€",PT:"€",SK:"€",SI:"€",ES:"€"},A=[{label:"1930-08-05",suffix:"yyyy-MM-dd"},{label:"1930/08/05",suffix:"yyyy/MM/dd"},{label:"1930年08月05日",suffix:'yyyy"年"MM"月"dd"日"'},{label:"08-05",suffix:"MM-dd"},{label:"8月5日",suffix:'M"月"d"日"'},{label:"13:30:30",suffix:"h:mm:ss"},{label:"13:30",suffix:"h:mm"},{label:"下午01:30",suffix:"A/P hh:mm"},{label:"下午1:30",suffix:"A/P h:mm"},{label:"下午1:30:30",suffix:"A/P h:mm:ss"},{label:"08-05 下午 01:30",suffix:"MM-dd A/P hh:mm"}],V=[{label:"(1,235)",suffix:"#,##0_);(#,##0)"},{label:"(1,235) ",suffix:"#,##0_);[Red](#,##0)",color:"red"},{label:"1,234.56",suffix:"#,##0.00_);#,##0.00"},{label:"1,234.56",suffix:"#,##0.00_);[Red]#,##0.00",color:"red"},{label:"-1,234.56",suffix:"#,##0.00_);-#,##0.00"},{label:"-1,234.56",suffix:"#,##0.00_);[Red]-#,##0.00",color:"red"}],U=[{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);"${e}"#,##0.00`},{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,color:"red"},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);("${e}"#,##0.00)`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,color:"red"},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);-"${e}"#,##0.00`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,color:"red"}],X="SHEET_NUMFMT_PLUGIN",T=(e,r=0)=>{var t;return e&&(t=n.numfmt.getInfo(e).maxDecimals)!=null?t:r},J=(e,r)=>{if(e&&!r||!e&&r)return!1;const s=c=>c.reduce((d,h)=>{if(d.isEnd)return d;const g=h.value||h.num;return h.type==="point"?(d.isEnd=!0,d):{...d,result:d.result+g}},{isEnd:!1,result:""}).result,t=n.numfmt.getInfo(e)._partitions,i=n.numfmt.getInfo(r)._partitions,u=s(t[0].tokens),l=s(i[0].tokens),v=s(t[1].tokens),f=s(i[1].tokens);return u===l&&v===f&&t[1].color===i[1].color},D=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),$=(e,r)=>e.split(";").map(t=>/\.0?/.test(t)?t.replace(/\.0*/g,`${r>0?".":""}${D(Number(r||0))}`):/0([^0]?)|0$/.test(t)?t.replace(/0([^0]+)|0$/,`0${r>0?".":""}${D(Number(r||0))}$1`):t).join(";"),Z=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),M={id:"sheet.command.numfmt.set.numfmt",type:n.CommandType.COMMAND,handler:(e,r)=>{if(!r)return!1;const s=e.get(n.ICommandService),t=e.get(n.IUniverInstanceService),i=e.get(n.IUndoRedoService),u=m.getSheetCommandTarget(t,r);if(!u)return!1;const{unitId:l,subUnitId:v}=u,f=r.values.filter(o=>!!o.pattern),c=r.values.filter(o=>!o.pattern),d=m.transformCellsToRange(l,v,f),h={unitId:l,subUnitId:v,ranges:c.map(o=>({startColumn:o.col,startRow:o.row,endColumn:o.col,endRow:o.row}))},g=[],p=[];if(f.length){Object.keys(d.values).forEach(C=>{const y=d.values[C];y.ranges=m.rangeMerge(y.ranges)}),g.push({id:m.SetNumfmtMutation.id,params:d});const o=m.factorySetNumfmtUndoMutation(e,d);p.push(...o)}if(c.length){h.ranges=m.rangeMerge(h.ranges),g.push({id:m.RemoveNumfmtMutation.id,params:h});const o=m.factoryRemoveNumfmtUndoMutation(e,h);p.push(...o)}const S=n.sequenceExecute(g,s).result;return S&&i.pushUndoRedo({unitID:l,undoMutations:p,redoMutations:g}),S}},w={id:"sheet.command.numfmt.add.decimal.command",type:n.CommandType.COMMAND,handler:async e=>{const r=e.get(n.ICommandService),s=e.get(m.SheetsSelectionsService),t=e.get(m.INumfmtService),i=e.get(n.IUniverInstanceService),u=s.getCurrentSelections();if(!u||!u.length)return!1;const l=m.getSheetCommandTarget(i);if(!l)return!1;const{unitId:v,subUnitId:f}=l;let c=0;u.forEach(p=>{n.Range.foreach(p.range,(S,o)=>{const C=t.getValue(v,f,S,o);if(!C){const b=l.worksheet.getCellRaw(S,o);if(!c&&b&&b.t===n.CellValueType.NUMBER&&b.v){const _=/\.(\d*)$/.exec(String(b.v));if(_){const R=_[1].length;if(!R)return;c=Math.max(c,R)}}return}const y=T(C.pattern);c=y>c?y:c})});const d=c+1,h=$(`0${d>0?".0":""}`,d),g=[];return u.forEach(p=>{n.Range.foreach(p.range,(S,o)=>{const C=t.getValue(v,f,S,o);if(!C)g.push({row:S,col:o,pattern:h});else{const y=T(C.pattern),b=$(C.pattern,y+1);b!==C.pattern&&g.push({row:S,col:o,pattern:b})}})}),g.length?await r.executeCommand(M.id,{values:g}):!1}};class O{constructor(){E(this,"_currencySymbol$",new N.BehaviorSubject("US"));E(this,"currencySymbol$",this._currencySymbol$.asObservable())}setCurrencySymbolByCountryCode(r){this._currencySymbol$.next(r)}getCurrencySymbol(){return this._currencySymbol$.getValue()}}const F={id:"sheet.command.numfmt.set.currency",type:n.CommandType.COMMAND,handler:async e=>{const r=e.get(n.ICommandService),s=e.get(m.SheetsSelectionsService),t=e.get(O),i=j[t.getCurrencySymbol()]||"$",u=s.getCurrentSelections();if(!u||!u.length)return!1;const l=[],v=U[4].suffix(i);return u.forEach(c=>{n.Range.foreach(c.range,(d,h)=>{l.push({row:d,col:h,pattern:v,type:"currency"})})}),await r.executeCommand(M.id,{values:l})}},B={id:"sheet.command.numfmt.set.percent",type:n.CommandType.COMMAND,handler:async e=>{const r=e.get(n.ICommandService),t=e.get(m.SheetsSelectionsService).getCurrentSelections();if(!t||!t.length)return!1;const i=[],u="0%";return t.forEach(v=>{n.Range.foreach(v.range,(f,c)=>{i.push({row:f,col:c,pattern:u,type:"percent"})})}),await r.executeCommand(M.id,{values:i})}},L={id:"sheet.command.numfmt.subtract.decimal.command",type:n.CommandType.COMMAND,handler:async e=>{const r=e.get(n.ICommandService),s=e.get(m.SheetsSelectionsService),t=e.get(m.INumfmtService),i=e.get(n.IUniverInstanceService),u=s.getCurrentSelections();if(!u||!u.length)return!1;const l=m.getSheetCommandTarget(i);if(!l)return!1;const{unitId:v,subUnitId:f}=l;let c=0;u.forEach(S=>{n.Range.foreach(S.range,(o,C)=>{const y=t.getValue(v,f,o,C);if(!y){const _=l.worksheet.getCellRaw(o,C);if(!c&&_&&_.t===n.CellValueType.NUMBER&&_.v){const R=/\.(\d*)$/.exec(String(_.v));if(R){const Y=R[1].length;if(!Y)return;c=Math.max(c,Y)}}return}const b=T(y.pattern);c=b>c?b:c})});const d=c-1,h=$(`0${d>0?".0":"."}`,d),g=[];return u.forEach(S=>{n.Range.foreach(S.range,(o,C)=>{const y=t.getValue(v,f,o,C);if(!y)g.push({row:o,col:C,pattern:h});else{const b=T(y.pattern);g.push({row:o,col:C,pattern:$(y.pattern,b-1)})}})}),await r.executeCommand(M.id,{values:g})}},Q=e=>n.numfmt.getInfo(e).type||"unknown",G=(e,r,s)=>{const t=n.numfmt.getInfo(e),i=s===n.LocaleType.ZH_CN?"zh-CN":"en",u=t._partitions[1],l=n.numfmt.format(e,r,{locale:i,throws:!1});return r<0?{result:l,color:u.color}:{result:l}},q=(e,r,s)=>e==="General"?{result:String(r)}:G(e,r,s);var k=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(e,r,s,t)=>{for(var i=t>1?void 0:t?ee(r,s):r,u=e.length-1,l;u>=0;u--)(l=e[u])&&(i=(t?l(r,s,i):l(i))||i);return t&&i&&k(r,s,i),i},I=(e,r)=>(s,t)=>r(s,t,e);a.SheetsNumfmtCellContentController=class extends n.Disposable{constructor(r,s,t,i,u,l){super(),this._instanceService=r,this._sheetInterceptorService=s,this._themeService=t,this._commandService=i,this._numfmtService=u,this._localeService=l,this._initInterceptorCellContent()}_initInterceptorCellContent(){const r={tl:{size:6,color:"#409f11"}},s=new n.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(m.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Value|n.InterceptorEffectEnum.Style,handler:(t,i,u)=>{const l=i.unitId,v=i.subUnitId;let f;const c=t;if(!c)return u(t);if(t!=null&&t.s){const S=i.workbook.getStyles().get(t.s);S!=null&&S.n&&(f=S.n)}if(f||(f=this._numfmtService.getValue(l,v,i.row,i.col)),!f)return u(t);if(f.pattern===z.DEFAULT_TEXT_FORMAT&&c.v&&n.isRealNum(c.v))return u({...t,markers:{...t==null?void 0:t.markers,...r}});if(c.t!==n.CellValueType.NUMBER||c.v==null||Number.isNaN(c.v))return u(t);let d="";const h=s.getValue(i.row,i.col);if(h&&h.parameters===`${c.v}_${f.pattern}`)return u({...t,...h.result});const g=q(f.pattern,Number(c.v),this._localeService.getCurrentLocale());if(d=g.result,!d)return u(t);const p={v:d};if(g.color){const S=this._themeService.getCurrentTheme()[`${g.color}500`];S&&(p.interceptorStyle={cl:{rgb:S}})}return s.setValue(i.row,i.col,{result:p,parameters:`${c.v}_${f.pattern}`}),u({...t,...p})},priority:m.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===m.SetNumfmtMutation.id){const i=t.params;Object.keys(i.values).forEach(u=>{i.values[u].ranges.forEach(v=>{n.Range.foreach(v,(f,c)=>{s.realDeleteValue(f,c)})})})}else if(t.id===m.SetRangeValuesMutation.id){const i=t.params;new n.ObjectMatrix(i.cellValue).forValue((u,l)=>{s.realDeleteValue(u,l)})}})),this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET).pipe(N.switchMap(t=>{var i;return(i=t==null?void 0:t.activeSheet$)!=null?i:N.of(null)}),N.skip(1)).subscribe(()=>s.reset()))}},a.SheetsNumfmtCellContentController=te([I(0,n.IUniverInstanceService),I(1,n.Inject(m.SheetInterceptorService)),I(2,n.Inject(n.ThemeService)),I(3,n.Inject(n.ICommandService)),I(4,n.Inject(m.INumfmtService)),I(5,n.Inject(n.LocaleService))],a.SheetsNumfmtCellContentController);class H extends n.Disposable{constructor(){super(...arguments);E(this,"_currencySymbol$",new N.BehaviorSubject("US"));E(this,"currencySymbol$",this._currencySymbol$.asObservable())}setCurrencySymbolByCountryCode(s){this._currencySymbol$.next(s)}getCurrencySymbol(){return this._currencySymbol$.getValue()}}var W=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,re=(e,r,s)=>r in e?W(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,ie=(e,r,s,t)=>{for(var i=t>1?void 0:t?ne(r,s):r,u=e.length-1,l;u>=0;u--)(l=e[u])&&(i=(t?l(r,s,i):l(i))||i);return t&&i&&W(r,s,i),i},x=(e,r)=>(s,t)=>r(s,t,e),K=(e,r,s)=>re(e,typeof r!="symbol"?r+"":r,s);a.UniverSheetsNumfmtPlugin=class extends n.Plugin{constructor(r=void 0,s,t){super(),this._config=r,this._injector=s,this._commandService=t}onStarting(){n.registerDependencies(this._injector,[[a.SheetsNumfmtCellContentController],[O],[H]]),n.touchDependencies(this._injector,[[a.SheetsNumfmtCellContentController]])}onRendered(){n.touchDependencies(this._injector,[[H]]),[w,L,F,B,M].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}},K(a.UniverSheetsNumfmtPlugin,"pluginName",X),K(a.UniverSheetsNumfmtPlugin,"type",n.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsNumfmtPlugin=ie([n.DependentOn(m.UniverSheetsPlugin),x(1,n.Inject(n.Injector)),x(2,n.ICommandService)],a.UniverSheetsNumfmtPlugin);const se=e=>P.find(s=>e.includes(s)),ae=()=>P.map(e=>({label:e,value:e})),ue=e=>U.map(r=>({label:r.label(e),value:r.suffix(e),color:r.color})),ce=()=>A.map(e=>({label:e.label,value:e.suffix})),le=()=>V.map(e=>({label:e.label,value:e.suffix,color:e.color}));a.AddDecimalCommand=w,a.CURRENCYFORMAT=U,a.DATEFMTLISG=A,a.MenuCurrencyService=O,a.NUMBERFORMAT=V,a.SetCurrencyCommand=F,a.SetNumfmtCommand=M,a.SetPercentCommand=B,a.SubtractDecimalCommand=L,a.countryCurrencyMap=j,a.currencySymbols=P,a.getCurrencyFormatOptions=ue,a.getCurrencyOptions=ae,a.getCurrencyType=se,a.getDateFormatOptions=ce,a.getDecimalFromPattern=T,a.getDecimalString=D,a.getNumberFormatOptions=le,a.getPatternPreview=G,a.getPatternPreviewIgnoreGeneral=q,a.getPatternType=Q,a.isPatternEqualWithoutDecimal=J,a.isPatternHasDecimal=Z,a.setPatternDecimal=$,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "private": false,
5
5
  "description": "UniverSheet numfmt plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,15 +53,16 @@
53
53
  "rxjs": ">=7.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@univerjs/sheets": "0.5.3",
57
- "@univerjs/core": "0.5.3"
56
+ "@univerjs/core": "0.5.4",
57
+ "@univerjs/engine-numfmt": "0.5.4",
58
+ "@univerjs/sheets": "0.5.4"
58
59
  },
59
60
  "devDependencies": {
60
61
  "rxjs": "^7.8.1",
61
62
  "typescript": "^5.7.2",
62
- "vite": "^6.0.6",
63
+ "vite": "^6.0.7",
63
64
  "vitest": "^2.1.8",
64
- "@univerjs-infra/shared": "0.5.3"
65
+ "@univerjs-infra/shared": "0.5.4"
65
66
  },
66
67
  "scripts": {
67
68
  "test": "vitest run",