@univerjs/sheets-numfmt 0.15.3 → 0.15.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 z=Object.defineProperty;var X=(e,r,a)=>r in e?z(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a;var U=(e,r,a)=>X(e,typeof r!="symbol"?r+"":r,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@univerjs/core"),f=require("@univerjs/sheets"),N=require("rxjs"),J=require("@univerjs/engine-formula"),x=["$","£","¥","¤","֏","؋","৳","฿","៛","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿","﷼"],E=new Map([[t.LocaleType.EN_US,"$"],[t.LocaleType.RU_RU,"₽"],[t.LocaleType.VI_VN,"₫"],[t.LocaleType.ZH_CN,"¥"],[t.LocaleType.ZH_TW,"NT$"],[t.LocaleType.FR_FR,"€"],[t.LocaleType.FA_IR,"﷼"],[t.LocaleType.KO_KR,"₩"],[t.LocaleType.ES_ES,"€"],[t.LocaleType.CA_ES,"€"]]);function V(e){switch(e){case t.LocaleType.CA_ES:case t.LocaleType.ES_ES:case t.LocaleType.FR_FR:return{icon:"EuroIcon",symbol:E.get(e)||"€",locale:e};case t.LocaleType.RU_RU:return{icon:"RoubleIcon",symbol:E.get(e)||"₽",locale:e};case t.LocaleType.ZH_CN:return{icon:"RmbIcon",symbol:E.get(e)||"¥",locale:e};case t.LocaleType.EN_US:default:return{icon:"DollarIcon",symbol:"$",locale:t.LocaleType.EN_US}}}function F(e){return E.get(e)||"$"}function j(e,r=2){let a=r;r>127&&(a=127);let n="";return a>0&&(n=`.${"0".repeat(a)}`),`"${F(e)}"#,##0${n}_);[Red]("${F(e)}"#,##0${n})`}const 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"}],B=[{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"}],G=[{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"}],$=(e,r=0)=>{var n;return e&&(n=t.numfmt.getFormatInfo(e).maxDecimals)!=null?n:r},L=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),O=(e,r)=>e.split(";").map(n=>/\.0?/.test(n)?n.replace(/\.0*/g,`${r>0?".":""}${L(Number(r||0))}`):/0([^0]?)|0$/.test(n)?n.replace(/0([^0]+)|0$/,`0${r>0?".":""}${L(Number(r||0))}$1`):n).join(";"),Q=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),R={id:"sheet.command.numfmt.set.numfmt",type:t.CommandType.COMMAND,handler:(e,r)=>{if(!r)return!1;const a=e.get(t.ICommandService),n=e.get(t.IUniverInstanceService),s=e.get(t.IUndoRedoService),o=f.getSheetCommandTarget(n,r);if(!o)return!1;const{unitId:l,subUnitId:d,worksheet:i}=o,u=r.values.filter(c=>!!c.pattern),_=r.values.filter(c=>!c.pattern),T=f.transformCellsToRange(l,d,u),h={unitId:l,subUnitId:d,ranges:_.map(c=>({startColumn:c.col,startRow:c.row,endColumn:c.col,endRow:c.row}))},M=[],C=[];if(u.length){const c=u.reduce((g,m)=>{t.isTextFormat(m.pattern)&&g.setValue(m.row,m.col,{t:t.CellValueType.STRING});const v=i.getCellRaw(m.row,m.col);if(v){const I=f.checkCellValueType(v.v);I!==v.t&&g.setValue(m.row,m.col,{t:I})}return g},new t.ObjectMatrix).getMatrix(),p=new t.ObjectMatrix;new t.ObjectMatrix(c).forValue((g,m)=>{const v=i.getCellRaw(g,m);v?p.setValue(g,m,{t:v.t}):p.setValue(g,m,{t:void 0})}),Object.keys(T.values).forEach(g=>{const m=T.values[g];m.ranges=f.rangeMerge(m.ranges)}),M.push({id:f.SetNumfmtMutation.id,params:T});const y=f.factorySetNumfmtUndoMutation(e,T);C.push(...y)}if(_.length){h.ranges=f.rangeMerge(h.ranges);const c=_.reduce((g,m)=>{const v=i.getCellRaw(m.row,m.col);if(v){const I=f.checkCellValueType(v.v);I!==v.t&&g.setValue(m.row,m.col,{t:I})}return g},new t.ObjectMatrix).getMatrix(),p=new t.ObjectMatrix;new t.ObjectMatrix(c).forValue((g,m)=>{const v=i.getCellRaw(g,m);v?p.setValue(g,m,{t:v.t}):p.setValue(g,m,{t:void 0})}),M.push({id:f.RemoveNumfmtMutation.id,params:h},{id:f.SetRangeValuesMutation.id,params:{unitId:l,subUnitId:d,cellValue:c}});const y=f.factoryRemoveNumfmtUndoMutation(e,h);C.push({id:f.SetRangeValuesMutation.id,params:{unitId:l,subUnitId:d,cellValue:p.getMatrix()}},...y)}const S=t.sequenceExecute(M,a).result;return S&&s.pushUndoRedo({unitID:l,undoMutations:C,redoMutations:M}),S}},H={id:"sheet.command.numfmt.add.decimal.command",type:t.CommandType.COMMAND,handler:async e=>{const r=e.get(t.ICommandService),a=e.get(f.SheetsSelectionsService),n=e.get(f.INumfmtService),s=e.get(t.IUniverInstanceService),o=a.getCurrentSelections();if(!o||!o.length)return!1;const l=f.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:i}=l;let u=0;o.forEach(M=>{t.Range.foreach(M.range,(C,S)=>{const c=n.getValue(d,i,C,S);if(!c){const y=l.worksheet.getCellRaw(C,S);if(!u&&y&&y.t===t.CellValueType.NUMBER&&y.v){const g=/\.(\d*)$/.exec(String(y.v));if(g){const m=g[1].length;if(!m)return;u=Math.max(u,m)}}return}const p=$(c.pattern);u=p>u?p:u})});const _=u+1,T=O(`0${_>0?".0":""}`,_),h=[];return o.forEach(M=>{t.Range.foreach(M.range,(C,S)=>{const c=n.getValue(d,i,C,S);if(t.isDefaultFormat(c==null?void 0:c.pattern))h.push({row:C,col:S,pattern:T});else{const p=$(c.pattern),y=O(c.pattern,p+1);y!==c.pattern&&h.push({row:C,col:S,pattern:y})}})}),h.length?await r.executeCommand(R.id,{values:h}):!1}},W={id:"sheet.command.numfmt.set.currency",type:t.CommandType.COMMAND,handler:async e=>{const r=e.get(t.ICommandService),a=e.get(f.SheetsSelectionsService),n=e.get(t.LocaleService),s=a.getCurrentSelections();if(!s||!s.length)return!1;const o=[],l=V(n.getCurrentLocale()),d=j(l.locale);return s.forEach(u=>{t.Range.foreach(u.range,(_,T)=>{o.push({row:_,col:T,pattern:d,type:"currency"})})}),await r.executeCommand(R.id,{values:o})}},K={id:"sheet.command.numfmt.set.percent",type:t.CommandType.COMMAND,handler:async e=>{const r=e.get(t.ICommandService),n=e.get(f.SheetsSelectionsService).getCurrentSelections();if(!n||!n.length)return!1;const s=[],o="0%";return n.forEach(d=>{t.Range.foreach(d.range,(i,u)=>{s.push({row:i,col:u,pattern:o,type:"percent"})})}),await r.executeCommand(R.id,{values:s})}},q={id:"sheet.command.numfmt.subtract.decimal.command",type:t.CommandType.COMMAND,handler:async e=>{const r=e.get(t.ICommandService),a=e.get(f.SheetsSelectionsService),n=e.get(f.INumfmtService),s=e.get(t.IUniverInstanceService),o=a.getCurrentSelections();if(!o||!o.length)return!1;const l=f.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:i}=l;let u=0;o.forEach(C=>{t.Range.foreach(C.range,(S,c)=>{const p=n.getValue(d,i,S,c);if(!p){const g=l.worksheet.getCellRaw(S,c);if(!u&&g&&g.t===t.CellValueType.NUMBER&&g.v){const m=/\.(\d*)$/.exec(String(g.v));if(m){const v=m[1].length;if(!v)return;u=Math.max(u,v)}}return}const y=$(p.pattern);u=y>u?y:u})});const _=u-1,T=O(`0${_>0?".0":"."}`,_),h=[];return o.forEach(C=>{t.Range.foreach(C.range,(S,c)=>{const p=n.getValue(d,i,S,c);if(t.isDefaultFormat(p==null?void 0:p.pattern))h.push({row:S,col:c,pattern:T});else{const y=$(p.pattern);h.push({row:S,col:c,pattern:O(p.pattern,y-1)})}})}),await r.executeCommand(R.id,{values:h})}},D="sheets-numfmt.config",w={},ee=e=>t.numfmt.getFormatInfo(e).type||"unknown",Z=(e,r,a="en")=>{try{const n=t.numfmt.formatColor(e,r),s=n?String(n):void 0,o=t.numfmt.format(e,r,{locale:a,throws:!1});return r<0?{result:o,color:s}:{result:o}}catch(n){console.warn("getPatternPreview error:",e,n)}return{result:String(r)}},k=(e,r,a)=>e===t.DEFAULT_NUMBER_FORMAT?{result:String(J.stripErrorMargin(r))}:Z(e,r,a);var te=Object.getOwnPropertyDescriptor,ne=(e,r,a,n)=>{for(var s=n>1?void 0:n?te(r,a):r,o=e.length-1,l;o>=0;o--)(l=e[o])&&(s=l(s)||s);return s},b=(e,r)=>(a,n)=>r(a,n,e);const re={tl:{size:6,color:"#409f11"}};exports.SheetsNumfmtCellContentController=class extends t.Disposable{constructor(a,n,s,o,l,d,i){super();U(this,"_locale$",new N.BehaviorSubject("en"));U(this,"locale$",this._locale$.asObservable());this._instanceService=a,this._sheetInterceptorService=n,this._themeService=s,this._commandService=o,this._numfmtService=l,this._localeService=d,this._configService=i,this._initInterceptorCellContent()}get locale(){const a=this._locale$.getValue();if(a)return a;switch(this._localeService.getCurrentLocale()){case t.LocaleType.FR_FR:return"fr";case t.LocaleType.RU_RU:return"ru";case t.LocaleType.VI_VN:return"vi";case t.LocaleType.ZH_CN:return"zh-CN";case t.LocaleType.KO_KR:return"ko";case t.LocaleType.ZH_TW:return"zh-TW";case t.LocaleType.ES_ES:case t.LocaleType.CA_ES:return"es";case t.LocaleType.EN_US:case t.LocaleType.FA_IR:default:return"en"}}_initInterceptorCellContent(){const a=new t.ObjectMatrix;this.disposeWithMe(N.merge(this._locale$,this._localeService.currentLocale$).subscribe(()=>{a.reset()})),this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Value|t.InterceptorEffectEnum.Style,handler:(n,s,o)=>{var C,S;if(!n||n.v===void 0||n.v===null||n.t===t.CellValueType.BOOLEAN||n.t===t.CellValueType.FORCE_STRING)return o(n);const l=s.unitId,d=s.subUnitId;let i;if(n!=null&&n.s){const c=s.workbook.getStyles().get(n.s);c!=null&&c.n&&(i=c.n)}if(i||(i=this._numfmtService.getValue(l,d,s.row,s.col)),t.isDefaultFormat(i==null?void 0:i.pattern)||n.t!==t.CellValueType.NUMBER&&f.checkCellValueType(n.v,n.t)!==t.CellValueType.NUMBER)return o(n);const u=n;if((!n||n===s.rawData)&&(n={...s.rawData}),t.isTextFormat(i==null?void 0:i.pattern))return(C=this._configService.getConfig(D))!=null&&C.disableTextFormatMark?(n.t=t.CellValueType.STRING,o(n)):(n.t=t.CellValueType.STRING,n.markers={...n==null?void 0:n.markers,...re},o(n));let _="";const T=a.getValue(s.row,s.col);if(T&&T.parameters===`${u.v}_${i==null?void 0:i.pattern}`)return o({...n,...T.result});const h=k(i==null?void 0:i.pattern,Number(u.v),this.locale);if(_=h.result,!_)return o(n);const M={v:_,t:t.CellValueType.NUMBER};if(h.color){const c=(S=this._themeService.getColorFromTheme(`${h.color}.500`))!=null?S:h.color;c&&(M.interceptorStyle={cl:{rgb:c}})}return a.setValue(s.row,s.col,{result:M,parameters:`${u.v}_${i==null?void 0:i.pattern}`}),Object.assign(n,M),o(n)},priority:f.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id===f.SetNumfmtMutation.id){const s=n.params;Object.keys(s.values).forEach(o=>{s.values[o].ranges.forEach(d=>{t.Range.foreach(d,(i,u)=>{a.realDeleteValue(i,u)})})})}else if(n.id===f.SetRangeValuesMutation.id){const s=n.params;new t.ObjectMatrix(s.cellValue).forValue((o,l)=>{a.realDeleteValue(o,l)})}})),this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe(N.switchMap(n=>{var s;return(s=n==null?void 0:n.activeSheet$)!=null?s:N.of(null)}),N.skip(1)).subscribe(()=>a.reset()))}setNumfmtLocal(a){this._locale$.next(a)}};exports.SheetsNumfmtCellContentController=ne([b(0,t.IUniverInstanceService),b(1,t.Inject(f.SheetInterceptorService)),b(2,t.Inject(t.ThemeService)),b(3,t.Inject(t.ICommandService)),b(4,t.Inject(f.INumfmtService)),b(5,t.Inject(t.LocaleService)),b(6,t.IConfigService)],exports.SheetsNumfmtCellContentController);const ae="SHEET_NUMFMT_PLUGIN";var se=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,ce=(e,r,a)=>r in e?se(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,ie=(e,r,a,n)=>{for(var s=n>1?void 0:n?oe(r,a):r,o=e.length-1,l;o>=0;o--)(l=e[o])&&(s=l(s)||s);return s},P=(e,r)=>(a,n)=>r(a,n,e),Y=(e,r,a)=>ce(e,typeof r!="symbol"?r+"":r,a);exports.UniverSheetsNumfmtPlugin=class extends t.Plugin{constructor(r=w,a,n,s){super(),this._config=r,this._injector=a,this._configService=n,this._commandService=s;const{...o}=t.merge({},w,this._config);this._configService.setConfig(D,o)}onStarting(){t.registerDependencies(this._injector,[[exports.SheetsNumfmtCellContentController]]),t.touchDependencies(this._injector,[[exports.SheetsNumfmtCellContentController]]),[H,q,W,K,R].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};Y(exports.UniverSheetsNumfmtPlugin,"pluginName",ae);Y(exports.UniverSheetsNumfmtPlugin,"type",t.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtPlugin=ie([t.DependentOn(f.UniverSheetsPlugin),P(1,t.Inject(t.Injector)),P(2,t.IConfigService),P(3,t.ICommandService)],exports.UniverSheetsNumfmtPlugin);const le=e=>x.find(a=>e.includes(a)),ue=()=>x.map(e=>({label:e,value:e})),me=e=>G.map(r=>({label:r.label(e),value:r.suffix(e),color:r.color})),fe=()=>A.map(e=>({label:e.label,value:e.suffix})),ge=()=>B.map(e=>({label:e.label,value:e.suffix,color:e.color}));exports.AddDecimalCommand=H;exports.CURRENCYFORMAT=G;exports.DATEFMTLISG=A;exports.NUMBERFORMAT=B;exports.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY=D;exports.SetCurrencyCommand=W;exports.SetNumfmtCommand=R;exports.SetPercentCommand=K;exports.SubtractDecimalCommand=q;exports.currencySymbols=x;exports.getCurrencyFormat=j;exports.getCurrencyFormatOptions=me;exports.getCurrencyOptions=ue;exports.getCurrencySymbolByLocale=F;exports.getCurrencySymbolIconByLocale=V;exports.getCurrencyType=le;exports.getDateFormatOptions=fe;exports.getDecimalFromPattern=$;exports.getDecimalString=L;exports.getNumberFormatOptions=ge;exports.getPatternPreview=Z;exports.getPatternPreviewIgnoreGeneral=k;exports.getPatternType=ee;exports.isPatternHasDecimal=Q;exports.localeCurrencySymbolMap=E;exports.setPatternDecimal=O;
1
+ "use strict";var z=Object.defineProperty;var X=(e,r,a)=>r in e?z(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a;var U=(e,r,a)=>X(e,typeof r!="symbol"?r+"":r,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@univerjs/core"),f=require("@univerjs/sheets"),N=require("rxjs"),J=require("@univerjs/engine-formula"),x=["$","£","¥","¤","֏","؋","৳","฿","៛","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿","﷼"],E=new Map([[t.LocaleType.EN_US,"$"],[t.LocaleType.RU_RU,"₽"],[t.LocaleType.VI_VN,"₫"],[t.LocaleType.ZH_CN,"¥"],[t.LocaleType.ZH_TW,"NT$"],[t.LocaleType.FR_FR,"€"],[t.LocaleType.FA_IR,"﷼"],[t.LocaleType.KO_KR,"₩"],[t.LocaleType.ES_ES,"€"],[t.LocaleType.CA_ES,"€"],[t.LocaleType.SK_SK,"€"]]);function V(e){switch(e){case t.LocaleType.CA_ES:case t.LocaleType.ES_ES:case t.LocaleType.FR_FR:case t.LocaleType.SK_SK:return{icon:"EuroIcon",symbol:E.get(e)||"€",locale:e};case t.LocaleType.RU_RU:return{icon:"RoubleIcon",symbol:E.get(e)||"₽",locale:e};case t.LocaleType.ZH_CN:return{icon:"RmbIcon",symbol:E.get(e)||"¥",locale:e};case t.LocaleType.EN_US:default:return{icon:"DollarIcon",symbol:"$",locale:t.LocaleType.EN_US}}}function L(e){return E.get(e)||"$"}function j(e,r=2){let a=r;r>127&&(a=127);let n="";return a>0&&(n=`.${"0".repeat(a)}`),`"${L(e)}"#,##0${n}_);[Red]("${L(e)}"#,##0${n})`}const 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"}],B=[{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"}],G=[{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"}],$=(e,r=0)=>{var n;return e&&(n=t.numfmt.getFormatInfo(e).maxDecimals)!=null?n:r},F=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),O=(e,r)=>e.split(";").map(n=>/\.0?/.test(n)?n.replace(/\.0*/g,`${r>0?".":""}${F(Number(r||0))}`):/0([^0]?)|0$/.test(n)?n.replace(/0([^0]+)|0$/,`0${r>0?".":""}${F(Number(r||0))}$1`):n).join(";"),Q=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),R={id:"sheet.command.numfmt.set.numfmt",type:t.CommandType.COMMAND,handler:(e,r)=>{if(!r)return!1;const a=e.get(t.ICommandService),n=e.get(t.IUniverInstanceService),s=e.get(t.IUndoRedoService),o=f.getSheetCommandTarget(n,r);if(!o)return!1;const{unitId:l,subUnitId:d,worksheet:i}=o,u=r.values.filter(c=>!!c.pattern),_=r.values.filter(c=>!c.pattern),T=f.transformCellsToRange(l,d,u),h={unitId:l,subUnitId:d,ranges:_.map(c=>({startColumn:c.col,startRow:c.row,endColumn:c.col,endRow:c.row}))},M=[],y=[];if(u.length){const c=u.reduce((g,m)=>{t.isTextFormat(m.pattern)&&g.setValue(m.row,m.col,{t:t.CellValueType.STRING});const v=i.getCellRaw(m.row,m.col);if(v){const I=f.checkCellValueType(v.v);I!==v.t&&g.setValue(m.row,m.col,{t:I})}return g},new t.ObjectMatrix).getMatrix(),p=new t.ObjectMatrix;new t.ObjectMatrix(c).forValue((g,m)=>{const v=i.getCellRaw(g,m);v?p.setValue(g,m,{t:v.t}):p.setValue(g,m,{t:void 0})}),Object.keys(T.values).forEach(g=>{const m=T.values[g];m.ranges=f.rangeMerge(m.ranges)}),M.push({id:f.SetNumfmtMutation.id,params:T});const C=f.factorySetNumfmtUndoMutation(e,T);y.push(...C)}if(_.length){h.ranges=f.rangeMerge(h.ranges);const c=_.reduce((g,m)=>{const v=i.getCellRaw(m.row,m.col);if(v){const I=f.checkCellValueType(v.v);I!==v.t&&g.setValue(m.row,m.col,{t:I})}return g},new t.ObjectMatrix).getMatrix(),p=new t.ObjectMatrix;new t.ObjectMatrix(c).forValue((g,m)=>{const v=i.getCellRaw(g,m);v?p.setValue(g,m,{t:v.t}):p.setValue(g,m,{t:void 0})}),M.push({id:f.RemoveNumfmtMutation.id,params:h},{id:f.SetRangeValuesMutation.id,params:{unitId:l,subUnitId:d,cellValue:c}});const C=f.factoryRemoveNumfmtUndoMutation(e,h);y.push({id:f.SetRangeValuesMutation.id,params:{unitId:l,subUnitId:d,cellValue:p.getMatrix()}},...C)}const S=t.sequenceExecute(M,a).result;return S&&s.pushUndoRedo({unitID:l,undoMutations:y,redoMutations:M}),S}},H={id:"sheet.command.numfmt.add.decimal.command",type:t.CommandType.COMMAND,handler:async e=>{const r=e.get(t.ICommandService),a=e.get(f.SheetsSelectionsService),n=e.get(f.INumfmtService),s=e.get(t.IUniverInstanceService),o=a.getCurrentSelections();if(!o||!o.length)return!1;const l=f.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:i}=l;let u=0;o.forEach(M=>{t.Range.foreach(M.range,(y,S)=>{const c=n.getValue(d,i,y,S);if(!c){const C=l.worksheet.getCellRaw(y,S);if(!u&&C&&C.t===t.CellValueType.NUMBER&&C.v){const g=/\.(\d*)$/.exec(String(C.v));if(g){const m=g[1].length;if(!m)return;u=Math.max(u,m)}}return}const p=$(c.pattern);u=p>u?p:u})});const _=u+1,T=O(`0${_>0?".0":""}`,_),h=[];return o.forEach(M=>{t.Range.foreach(M.range,(y,S)=>{const c=n.getValue(d,i,y,S);if(t.isDefaultFormat(c==null?void 0:c.pattern))h.push({row:y,col:S,pattern:T});else{const p=$(c.pattern),C=O(c.pattern,p+1);C!==c.pattern&&h.push({row:y,col:S,pattern:C})}})}),h.length?await r.executeCommand(R.id,{values:h}):!1}},K={id:"sheet.command.numfmt.set.currency",type:t.CommandType.COMMAND,handler:async e=>{const r=e.get(t.ICommandService),a=e.get(f.SheetsSelectionsService),n=e.get(t.LocaleService),s=a.getCurrentSelections();if(!s||!s.length)return!1;const o=[],l=V(n.getCurrentLocale()),d=j(l.locale);return s.forEach(u=>{t.Range.foreach(u.range,(_,T)=>{o.push({row:_,col:T,pattern:d,type:"currency"})})}),await r.executeCommand(R.id,{values:o})}},W={id:"sheet.command.numfmt.set.percent",type:t.CommandType.COMMAND,handler:async e=>{const r=e.get(t.ICommandService),n=e.get(f.SheetsSelectionsService).getCurrentSelections();if(!n||!n.length)return!1;const s=[],o="0%";return n.forEach(d=>{t.Range.foreach(d.range,(i,u)=>{s.push({row:i,col:u,pattern:o,type:"percent"})})}),await r.executeCommand(R.id,{values:s})}},k={id:"sheet.command.numfmt.subtract.decimal.command",type:t.CommandType.COMMAND,handler:async e=>{const r=e.get(t.ICommandService),a=e.get(f.SheetsSelectionsService),n=e.get(f.INumfmtService),s=e.get(t.IUniverInstanceService),o=a.getCurrentSelections();if(!o||!o.length)return!1;const l=f.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:i}=l;let u=0;o.forEach(y=>{t.Range.foreach(y.range,(S,c)=>{const p=n.getValue(d,i,S,c);if(!p){const g=l.worksheet.getCellRaw(S,c);if(!u&&g&&g.t===t.CellValueType.NUMBER&&g.v){const m=/\.(\d*)$/.exec(String(g.v));if(m){const v=m[1].length;if(!v)return;u=Math.max(u,v)}}return}const C=$(p.pattern);u=C>u?C:u})});const _=u-1,T=O(`0${_>0?".0":"."}`,_),h=[];return o.forEach(y=>{t.Range.foreach(y.range,(S,c)=>{const p=n.getValue(d,i,S,c);if(t.isDefaultFormat(p==null?void 0:p.pattern))h.push({row:S,col:c,pattern:T});else{const C=$(p.pattern);h.push({row:S,col:c,pattern:O(p.pattern,C-1)})}})}),await r.executeCommand(R.id,{values:h})}},D="sheets-numfmt.config",w={},ee=e=>t.numfmt.getFormatInfo(e).type||"unknown",q=(e,r,a="en")=>{try{const n=t.numfmt.formatColor(e,r),s=n?String(n):void 0,o=t.numfmt.format(e,r,{locale:a,throws:!1});return r<0?{result:o,color:s}:{result:o}}catch(n){console.warn("getPatternPreview error:",e,n)}return{result:String(r)}},Z=(e,r,a)=>e===t.DEFAULT_NUMBER_FORMAT?{result:String(J.stripErrorMargin(r))}:q(e,r,a);var te=Object.getOwnPropertyDescriptor,ne=(e,r,a,n)=>{for(var s=n>1?void 0:n?te(r,a):r,o=e.length-1,l;o>=0;o--)(l=e[o])&&(s=l(s)||s);return s},b=(e,r)=>(a,n)=>r(a,n,e);const re={tl:{size:6,color:"#409f11"}};exports.SheetsNumfmtCellContentController=class extends t.Disposable{constructor(a,n,s,o,l,d,i){super();U(this,"_locale$",new N.BehaviorSubject("en"));U(this,"locale$",this._locale$.asObservable());this._instanceService=a,this._sheetInterceptorService=n,this._themeService=s,this._commandService=o,this._numfmtService=l,this._localeService=d,this._configService=i,this._initInterceptorCellContent()}get locale(){const a=this._locale$.getValue();if(a)return a;switch(this._localeService.getCurrentLocale()){case t.LocaleType.FR_FR:return"fr";case t.LocaleType.RU_RU:return"ru";case t.LocaleType.VI_VN:return"vi";case t.LocaleType.ZH_CN:return"zh-CN";case t.LocaleType.KO_KR:return"ko";case t.LocaleType.ZH_TW:return"zh-TW";case t.LocaleType.ES_ES:case t.LocaleType.CA_ES:return"es";case t.LocaleType.SK_SK:return"sk";case t.LocaleType.EN_US:case t.LocaleType.FA_IR:default:return"en"}}_initInterceptorCellContent(){const a=new t.ObjectMatrix;this.disposeWithMe(N.merge(this._locale$,this._localeService.currentLocale$).subscribe(()=>{a.reset()})),this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Value|t.InterceptorEffectEnum.Style,handler:(n,s,o)=>{var y,S;if(!n||n.v===void 0||n.v===null||n.t===t.CellValueType.BOOLEAN||n.t===t.CellValueType.FORCE_STRING)return o(n);const l=s.unitId,d=s.subUnitId;let i;if(n!=null&&n.s){const c=s.workbook.getStyles().get(n.s);c!=null&&c.n&&(i=c.n)}if(i||(i=this._numfmtService.getValue(l,d,s.row,s.col)),t.isDefaultFormat(i==null?void 0:i.pattern)||n.t!==t.CellValueType.NUMBER&&f.checkCellValueType(n.v,n.t)!==t.CellValueType.NUMBER)return o(n);const u=n;if((!n||n===s.rawData)&&(n={...s.rawData}),t.isTextFormat(i==null?void 0:i.pattern))return(y=this._configService.getConfig(D))!=null&&y.disableTextFormatMark?(n.t=t.CellValueType.STRING,o(n)):(n.t=t.CellValueType.STRING,n.markers={...n==null?void 0:n.markers,...re},o(n));let _="";const T=a.getValue(s.row,s.col);if(T&&T.parameters===`${u.v}_${i==null?void 0:i.pattern}`)return o({...n,...T.result});const h=Z(i==null?void 0:i.pattern,Number(u.v),this.locale);if(_=h.result,!_)return o(n);const M={v:_,t:t.CellValueType.NUMBER};if(h.color){const c=(S=this._themeService.getColorFromTheme(`${h.color}.500`))!=null?S:h.color;c&&(M.interceptorStyle={cl:{rgb:c}})}return a.setValue(s.row,s.col,{result:M,parameters:`${u.v}_${i==null?void 0:i.pattern}`}),Object.assign(n,M),o(n)},priority:f.InterceptCellContentPriority.NUMFMT})),this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id===f.SetNumfmtMutation.id){const s=n.params;Object.keys(s.values).forEach(o=>{s.values[o].ranges.forEach(d=>{t.Range.foreach(d,(i,u)=>{a.realDeleteValue(i,u)})})})}else if(n.id===f.SetRangeValuesMutation.id){const s=n.params;new t.ObjectMatrix(s.cellValue).forValue((o,l)=>{a.realDeleteValue(o,l)})}})),this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe(N.switchMap(n=>{var s;return(s=n==null?void 0:n.activeSheet$)!=null?s:N.of(null)}),N.skip(1)).subscribe(()=>a.reset()))}setNumfmtLocal(a){this._locale$.next(a)}};exports.SheetsNumfmtCellContentController=ne([b(0,t.IUniverInstanceService),b(1,t.Inject(f.SheetInterceptorService)),b(2,t.Inject(t.ThemeService)),b(3,t.Inject(t.ICommandService)),b(4,t.Inject(f.INumfmtService)),b(5,t.Inject(t.LocaleService)),b(6,t.IConfigService)],exports.SheetsNumfmtCellContentController);const ae="SHEET_NUMFMT_PLUGIN";var se=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,ce=(e,r,a)=>r in e?se(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,ie=(e,r,a,n)=>{for(var s=n>1?void 0:n?oe(r,a):r,o=e.length-1,l;o>=0;o--)(l=e[o])&&(s=l(s)||s);return s},P=(e,r)=>(a,n)=>r(a,n,e),Y=(e,r,a)=>ce(e,typeof r!="symbol"?r+"":r,a);exports.UniverSheetsNumfmtPlugin=class extends t.Plugin{constructor(r=w,a,n,s){super(),this._config=r,this._injector=a,this._configService=n,this._commandService=s;const{...o}=t.merge({},w,this._config);this._configService.setConfig(D,o)}onStarting(){t.registerDependencies(this._injector,[[exports.SheetsNumfmtCellContentController]]),t.touchDependencies(this._injector,[[exports.SheetsNumfmtCellContentController]]),[H,k,K,W,R].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};Y(exports.UniverSheetsNumfmtPlugin,"pluginName",ae);Y(exports.UniverSheetsNumfmtPlugin,"type",t.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtPlugin=ie([t.DependentOn(f.UniverSheetsPlugin),P(1,t.Inject(t.Injector)),P(2,t.IConfigService),P(3,t.ICommandService)],exports.UniverSheetsNumfmtPlugin);const le=e=>x.find(a=>e.includes(a)),ue=()=>x.map(e=>({label:e,value:e})),me=e=>G.map(r=>({label:r.label(e),value:r.suffix(e),color:r.color})),fe=()=>A.map(e=>({label:e.label,value:e.suffix})),ge=()=>B.map(e=>({label:e.label,value:e.suffix,color:e.color}));exports.AddDecimalCommand=H;exports.CURRENCYFORMAT=G;exports.DATEFMTLISG=A;exports.NUMBERFORMAT=B;exports.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY=D;exports.SetCurrencyCommand=K;exports.SetNumfmtCommand=R;exports.SetPercentCommand=W;exports.SubtractDecimalCommand=k;exports.currencySymbols=x;exports.getCurrencyFormat=j;exports.getCurrencyFormatOptions=me;exports.getCurrencyOptions=ue;exports.getCurrencySymbolByLocale=L;exports.getCurrencySymbolIconByLocale=V;exports.getCurrencyType=le;exports.getDateFormatOptions=fe;exports.getDecimalFromPattern=$;exports.getDecimalString=F;exports.getNumberFormatOptions=ge;exports.getPatternPreview=q;exports.getPatternPreviewIgnoreGeneral=Z;exports.getPatternType=ee;exports.isPatternHasDecimal=Q;exports.localeCurrencySymbolMap=E;exports.setPatternDecimal=O;
package/lib/es/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  var ae = Object.defineProperty;
2
- var ie = (e, r, t) => r in e ? ae(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var L = (e, r, t) => ie(e, typeof r != "symbol" ? r + "" : r, t);
4
- import { LocaleType as f, numfmt as x, CommandType as U, ICommandService as $, IUniverInstanceService as V, IUndoRedoService as ce, isTextFormat as J, CellValueType as M, ObjectMatrix as R, sequenceExecute as le, Range as N, isDefaultFormat as W, LocaleService as Q, DEFAULT_NUMBER_FORMAT as ue, Inject as I, ThemeService as fe, IConfigService as ee, Disposable as me, InterceptorEffectEnum as z, UniverInstanceType as te, DependentOn as de, Injector as ge, Plugin as he, merge as pe, registerDependencies as _e, touchDependencies as ve } from "@univerjs/core";
5
- import { getSheetCommandTarget as K, transformCellsToRange as Se, checkCellValueType as H, rangeMerge as k, SetNumfmtMutation as re, factorySetNumfmtUndoMutation as Ce, RemoveNumfmtMutation as ye, SetRangeValuesMutation as G, factoryRemoveNumfmtUndoMutation as be, SheetsSelectionsService as j, INumfmtService as Z, SheetInterceptorService as Me, INTERCEPTOR_POINT as Re, InterceptCellContentPriority as Ee, UniverSheetsPlugin as Ne } from "@univerjs/sheets";
2
+ var ce = (e, r, t) => r in e ? ae(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
+ var L = (e, r, t) => ce(e, typeof r != "symbol" ? r + "" : r, t);
4
+ import { LocaleType as i, numfmt as x, CommandType as U, ICommandService as $, IUniverInstanceService as V, IUndoRedoService as ie, isTextFormat as J, CellValueType as M, ObjectMatrix as R, sequenceExecute as le, Range as N, isDefaultFormat as G, LocaleService as Q, DEFAULT_NUMBER_FORMAT as ue, Inject as I, ThemeService as fe, IConfigService as ee, Disposable as me, InterceptorEffectEnum as k, UniverInstanceType as te, DependentOn as de, Injector as ge, Plugin as he, merge as pe, registerDependencies as _e, touchDependencies as Se } from "@univerjs/core";
5
+ import { getSheetCommandTarget as W, transformCellsToRange as ve, checkCellValueType as B, rangeMerge as z, SetNumfmtMutation as re, factorySetNumfmtUndoMutation as Ce, RemoveNumfmtMutation as ye, SetRangeValuesMutation as H, factoryRemoveNumfmtUndoMutation as be, SheetsSelectionsService as j, INumfmtService as Z, SheetInterceptorService as Me, INTERCEPTOR_POINT as Re, InterceptCellContentPriority as Ee, UniverSheetsPlugin as Ne } from "@univerjs/sheets";
6
6
  import { BehaviorSubject as $e, merge as Ie, switchMap as Te, of as Ue, skip as Oe } from "rxjs";
7
7
  import { stripErrorMargin as we } from "@univerjs/engine-formula";
8
8
  const ne = [
@@ -35,45 +35,47 @@ const ne = [
35
35
  "₿",
36
36
  "﷼"
37
37
  ], w = /* @__PURE__ */ new Map([
38
- [f.EN_US, "$"],
39
- [f.RU_RU, "₽"],
40
- [f.VI_VN, "₫"],
41
- [f.ZH_CN, "¥"],
42
- [f.ZH_TW, "NT$"],
43
- [f.FR_FR, "€"],
44
- [f.FA_IR, "﷼"],
45
- [f.KO_KR, "₩"],
46
- [f.ES_ES, "€"],
47
- [f.CA_ES, "€"]
38
+ [i.EN_US, "$"],
39
+ [i.RU_RU, "₽"],
40
+ [i.VI_VN, "₫"],
41
+ [i.ZH_CN, "¥"],
42
+ [i.ZH_TW, "NT$"],
43
+ [i.FR_FR, "€"],
44
+ [i.FA_IR, "﷼"],
45
+ [i.KO_KR, "₩"],
46
+ [i.ES_ES, "€"],
47
+ [i.CA_ES, "€"],
48
+ [i.SK_SK, "€"]
48
49
  ]);
49
50
  function xe(e) {
50
51
  switch (e) {
51
- case f.CA_ES:
52
- case f.ES_ES:
53
- case f.FR_FR:
52
+ case i.CA_ES:
53
+ case i.ES_ES:
54
+ case i.FR_FR:
55
+ case i.SK_SK:
54
56
  return {
55
57
  icon: "EuroIcon",
56
58
  symbol: w.get(e) || "€",
57
59
  locale: e
58
60
  };
59
- case f.RU_RU:
61
+ case i.RU_RU:
60
62
  return {
61
63
  icon: "RoubleIcon",
62
64
  symbol: w.get(e) || "₽",
63
65
  locale: e
64
66
  };
65
- case f.ZH_CN:
67
+ case i.ZH_CN:
66
68
  return {
67
69
  icon: "RmbIcon",
68
70
  symbol: w.get(e) || "¥",
69
71
  locale: e
70
72
  };
71
- case f.EN_US:
73
+ case i.EN_US:
72
74
  default:
73
75
  return {
74
76
  icon: "DollarIcon",
75
77
  symbol: "$",
76
- locale: f.EN_US
78
+ locale: i.EN_US
77
79
  };
78
80
  }
79
81
  }
@@ -203,78 +205,78 @@ const Fe = [
203
205
  handler: (e, r) => {
204
206
  if (!r)
205
207
  return !1;
206
- const t = e.get($), n = e.get(V), s = e.get(ce), a = K(n, r);
208
+ const t = e.get($), n = e.get(V), s = e.get(ie), a = W(n, r);
207
209
  if (!a) return !1;
208
- const { unitId: l, subUnitId: o, worksheet: h } = a, u = r.values.filter((i) => !!i.pattern), C = r.values.filter((i) => !i.pattern), y = Se(l, o, u), p = {
209
- unitId: l,
210
+ const { unitId: u, subUnitId: o, worksheet: h } = a, f = r.values.filter((c) => !!c.pattern), C = r.values.filter((c) => !c.pattern), y = ve(u, o, f), p = {
211
+ unitId: u,
210
212
  subUnitId: o,
211
- ranges: C.map((i) => ({
212
- startColumn: i.col,
213
- startRow: i.row,
214
- endColumn: i.col,
215
- endRow: i.row
213
+ ranges: C.map((c) => ({
214
+ startColumn: c.col,
215
+ startRow: c.row,
216
+ endColumn: c.col,
217
+ endRow: c.row
216
218
  }))
217
219
  }, b = [], _ = [];
218
- if (u.length) {
219
- const i = u.reduce((d, c) => {
220
- J(c.pattern) && d.setValue(c.row, c.col, { t: M.STRING });
221
- const S = h.getCellRaw(c.row, c.col);
222
- if (S) {
223
- const T = H(S.v);
224
- T !== S.t && d.setValue(c.row, c.col, { t: T });
220
+ if (f.length) {
221
+ const c = f.reduce((d, l) => {
222
+ J(l.pattern) && d.setValue(l.row, l.col, { t: M.STRING });
223
+ const v = h.getCellRaw(l.row, l.col);
224
+ if (v) {
225
+ const T = B(v.v);
226
+ T !== v.t && d.setValue(l.row, l.col, { t: T });
225
227
  }
226
228
  return d;
227
229
  }, new R()).getMatrix(), g = new R();
228
- new R(i).forValue((d, c) => {
229
- const S = h.getCellRaw(d, c);
230
- S ? g.setValue(d, c, { t: S.t }) : g.setValue(d, c, { t: void 0 });
230
+ new R(c).forValue((d, l) => {
231
+ const v = h.getCellRaw(d, l);
232
+ v ? g.setValue(d, l, { t: v.t }) : g.setValue(d, l, { t: void 0 });
231
233
  }), Object.keys(y.values).forEach((d) => {
232
- const c = y.values[d];
233
- c.ranges = k(c.ranges);
234
+ const l = y.values[d];
235
+ l.ranges = z(l.ranges);
234
236
  }), b.push({
235
237
  id: re.id,
236
238
  params: y
237
239
  });
238
- const v = Ce(e, y);
239
- _.push(...v);
240
+ const S = Ce(e, y);
241
+ _.push(...S);
240
242
  }
241
243
  if (C.length) {
242
- p.ranges = k(p.ranges);
243
- const i = C.reduce((d, c) => {
244
- const S = h.getCellRaw(c.row, c.col);
245
- if (S) {
246
- const T = H(S.v);
247
- T !== S.t && d.setValue(c.row, c.col, { t: T });
244
+ p.ranges = z(p.ranges);
245
+ const c = C.reduce((d, l) => {
246
+ const v = h.getCellRaw(l.row, l.col);
247
+ if (v) {
248
+ const T = B(v.v);
249
+ T !== v.t && d.setValue(l.row, l.col, { t: T });
248
250
  }
249
251
  return d;
250
252
  }, new R()).getMatrix(), g = new R();
251
- new R(i).forValue((d, c) => {
252
- const S = h.getCellRaw(d, c);
253
- S ? g.setValue(d, c, { t: S.t }) : g.setValue(d, c, { t: void 0 });
253
+ new R(c).forValue((d, l) => {
254
+ const v = h.getCellRaw(d, l);
255
+ v ? g.setValue(d, l, { t: v.t }) : g.setValue(d, l, { t: void 0 });
254
256
  }), b.push({
255
257
  id: ye.id,
256
258
  params: p
257
259
  }, {
258
- id: G.id,
260
+ id: H.id,
259
261
  params: {
260
- unitId: l,
262
+ unitId: u,
261
263
  subUnitId: o,
262
- cellValue: i
264
+ cellValue: c
263
265
  }
264
266
  });
265
- const v = be(e, p);
267
+ const S = be(e, p);
266
268
  _.push({
267
- id: G.id,
269
+ id: H.id,
268
270
  params: {
269
- unitId: l,
271
+ unitId: u,
270
272
  subUnitId: o,
271
273
  cellValue: g.getMatrix()
272
274
  }
273
- }, ...v);
275
+ }, ...S);
274
276
  }
275
277
  const m = le(b, t).result;
276
278
  return m && s.pushUndoRedo({
277
- unitID: l,
279
+ unitID: u,
278
280
  undoMutations: _,
279
281
  redoMutations: b
280
282
  }), m;
@@ -286,46 +288,46 @@ const Fe = [
286
288
  const r = e.get($), t = e.get(j), n = e.get(Z), s = e.get(V), a = t.getCurrentSelections();
287
289
  if (!a || !a.length)
288
290
  return !1;
289
- const l = K(s);
290
- if (!l) return !1;
291
- const { unitId: o, subUnitId: h } = l;
292
- let u = 0;
291
+ const u = W(s);
292
+ if (!u) return !1;
293
+ const { unitId: o, subUnitId: h } = u;
294
+ let f = 0;
293
295
  a.forEach((b) => {
294
296
  N.foreach(b.range, (_, m) => {
295
- const i = n.getValue(o, h, _, m);
296
- if (!i) {
297
- const v = l.worksheet.getCellRaw(_, m);
298
- if (!u && v && v.t === M.NUMBER && v.v) {
299
- const d = /\.(\d*)$/.exec(String(v.v));
297
+ const c = n.getValue(o, h, _, m);
298
+ if (!c) {
299
+ const S = u.worksheet.getCellRaw(_, m);
300
+ if (!f && S && S.t === M.NUMBER && S.v) {
301
+ const d = /\.(\d*)$/.exec(String(S.v));
300
302
  if (d) {
301
- const c = d[1].length;
302
- if (!c)
303
+ const l = d[1].length;
304
+ if (!l)
303
305
  return;
304
- u = Math.max(u, c);
306
+ f = Math.max(f, l);
305
307
  }
306
308
  }
307
309
  return;
308
310
  }
309
- const g = P(i.pattern);
310
- u = g > u ? g : u;
311
+ const g = P(c.pattern);
312
+ f = g > f ? g : f;
311
313
  });
312
314
  });
313
- const C = u + 1, y = F(`0${C > 0 ? ".0" : ""}`, C), p = [];
315
+ const C = f + 1, y = F(`0${C > 0 ? ".0" : ""}`, C), p = [];
314
316
  return a.forEach((b) => {
315
317
  N.foreach(b.range, (_, m) => {
316
- const i = n.getValue(o, h, _, m);
317
- if (W(i == null ? void 0 : i.pattern))
318
+ const c = n.getValue(o, h, _, m);
319
+ if (G(c == null ? void 0 : c.pattern))
318
320
  p.push({
319
321
  row: _,
320
322
  col: m,
321
323
  pattern: y
322
324
  });
323
325
  else {
324
- const g = P(i.pattern), v = F(i.pattern, g + 1);
325
- v !== i.pattern && p.push({
326
+ const g = P(c.pattern), S = F(c.pattern, g + 1);
327
+ S !== c.pattern && p.push({
326
328
  row: _,
327
329
  col: m,
328
- pattern: v
330
+ pattern: S
329
331
  });
330
332
  }
331
333
  });
@@ -338,9 +340,9 @@ const Fe = [
338
340
  const r = e.get($), t = e.get(j), n = e.get(Q), s = t.getCurrentSelections();
339
341
  if (!s || !s.length)
340
342
  return !1;
341
- const a = [], l = xe(n.getCurrentLocale()), o = Pe(l.locale);
342
- return s.forEach((u) => {
343
- N.foreach(u.range, (C, y) => {
343
+ const a = [], u = xe(n.getCurrentLocale()), o = Pe(u.locale);
344
+ return s.forEach((f) => {
345
+ N.foreach(f.range, (C, y) => {
344
346
  a.push({ row: C, col: y, pattern: o, type: "currency" });
345
347
  });
346
348
  }), await r.executeCommand(O.id, { values: a });
@@ -354,64 +356,64 @@ const Fe = [
354
356
  return !1;
355
357
  const s = [], a = "0%";
356
358
  return n.forEach((o) => {
357
- N.foreach(o.range, (h, u) => {
358
- s.push({ row: h, col: u, pattern: a, type: "percent" });
359
+ N.foreach(o.range, (h, f) => {
360
+ s.push({ row: h, col: f, pattern: a, type: "percent" });
359
361
  });
360
362
  }), await r.executeCommand(O.id, { values: s });
361
363
  }
362
- }, Be = {
364
+ }, Ke = {
363
365
  id: "sheet.command.numfmt.subtract.decimal.command",
364
366
  type: U.COMMAND,
365
367
  handler: async (e) => {
366
368
  const r = e.get($), t = e.get(j), n = e.get(Z), s = e.get(V), a = t.getCurrentSelections();
367
369
  if (!a || !a.length)
368
370
  return !1;
369
- const l = K(s);
370
- if (!l) return !1;
371
- const { unitId: o, subUnitId: h } = l;
372
- let u = 0;
371
+ const u = W(s);
372
+ if (!u) return !1;
373
+ const { unitId: o, subUnitId: h } = u;
374
+ let f = 0;
373
375
  a.forEach((_) => {
374
- N.foreach(_.range, (m, i) => {
375
- const g = n.getValue(o, h, m, i);
376
+ N.foreach(_.range, (m, c) => {
377
+ const g = n.getValue(o, h, m, c);
376
378
  if (!g) {
377
- const d = l.worksheet.getCellRaw(m, i);
378
- if (!u && d && d.t === M.NUMBER && d.v) {
379
- const c = /\.(\d*)$/.exec(String(d.v));
380
- if (c) {
381
- const S = c[1].length;
382
- if (!S)
379
+ const d = u.worksheet.getCellRaw(m, c);
380
+ if (!f && d && d.t === M.NUMBER && d.v) {
381
+ const l = /\.(\d*)$/.exec(String(d.v));
382
+ if (l) {
383
+ const v = l[1].length;
384
+ if (!v)
383
385
  return;
384
- u = Math.max(u, S);
386
+ f = Math.max(f, v);
385
387
  }
386
388
  }
387
389
  return;
388
390
  }
389
- const v = P(g.pattern);
390
- u = v > u ? v : u;
391
+ const S = P(g.pattern);
392
+ f = S > f ? S : f;
391
393
  });
392
394
  });
393
- const C = u - 1, y = F(`0${C > 0 ? ".0" : "."}`, C), p = [];
395
+ const C = f - 1, y = F(`0${C > 0 ? ".0" : "."}`, C), p = [];
394
396
  return a.forEach((_) => {
395
- N.foreach(_.range, (m, i) => {
396
- const g = n.getValue(o, h, m, i);
397
- if (W(g == null ? void 0 : g.pattern))
397
+ N.foreach(_.range, (m, c) => {
398
+ const g = n.getValue(o, h, m, c);
399
+ if (G(g == null ? void 0 : g.pattern))
398
400
  p.push({
399
401
  row: m,
400
- col: i,
402
+ col: c,
401
403
  pattern: y
402
404
  });
403
405
  else {
404
- const v = P(g.pattern);
406
+ const S = P(g.pattern);
405
407
  p.push({
406
408
  row: m,
407
- col: i,
408
- pattern: F(g.pattern, v - 1)
409
+ col: c,
410
+ pattern: F(g.pattern, S - 1)
409
411
  });
410
412
  }
411
413
  });
412
414
  }), await r.executeCommand(O.id, { values: p });
413
415
  }
414
- }, se = "sheets-numfmt.config", X = {}, st = (e) => x.getFormatInfo(e).type || "unknown", He = (e, r, t = "en") => {
416
+ }, se = "sheets-numfmt.config", X = {}, st = (e) => x.getFormatInfo(e).type || "unknown", Be = (e, r, t = "en") => {
415
417
  try {
416
418
  const n = x.formatColor(e, r), s = n ? String(n) : void 0, a = x.format(e, r, { locale: t, throws: !1 });
417
419
  return r < 0 ? {
@@ -426,13 +428,13 @@ const Fe = [
426
428
  return {
427
429
  result: String(r)
428
430
  };
429
- }, Ge = (e, r, t) => e === ue ? {
431
+ }, He = (e, r, t) => e === ue ? {
430
432
  result: String(we(r))
431
433
  // In Excel, the default General format also needs to handle numeric precision.
432
- } : He(e, r, t);
433
- var We = Object.getOwnPropertyDescriptor, Ke = (e, r, t, n) => {
434
- for (var s = n > 1 ? void 0 : n ? We(r, t) : r, a = e.length - 1, l; a >= 0; a--)
435
- (l = e[a]) && (s = l(s) || s);
434
+ } : Be(e, r, t);
435
+ var Ge = Object.getOwnPropertyDescriptor, We = (e, r, t, n) => {
436
+ for (var s = n > 1 ? void 0 : n ? Ge(r, t) : r, a = e.length - 1, u; a >= 0; a--)
437
+ (u = e[a]) && (s = u(s) || s);
436
438
  return s;
437
439
  }, E = (e, r) => (t, n) => r(t, n, e);
438
440
  const Ze = {
@@ -442,34 +444,36 @@ const Ze = {
442
444
  }
443
445
  };
444
446
  let D = class extends me {
445
- constructor(r, t, n, s, a, l, o) {
447
+ constructor(r, t, n, s, a, u, o) {
446
448
  super();
447
449
  L(this, "_locale$", new $e("en"));
448
450
  L(this, "locale$", this._locale$.asObservable());
449
- this._instanceService = r, this._sheetInterceptorService = t, this._themeService = n, this._commandService = s, this._numfmtService = a, this._localeService = l, this._configService = o, this._initInterceptorCellContent();
451
+ this._instanceService = r, this._sheetInterceptorService = t, this._themeService = n, this._commandService = s, this._numfmtService = a, this._localeService = u, this._configService = o, this._initInterceptorCellContent();
450
452
  }
451
453
  get locale() {
452
454
  const r = this._locale$.getValue();
453
455
  if (r)
454
456
  return r;
455
457
  switch (this._localeService.getCurrentLocale()) {
456
- case f.FR_FR:
458
+ case i.FR_FR:
457
459
  return "fr";
458
- case f.RU_RU:
460
+ case i.RU_RU:
459
461
  return "ru";
460
- case f.VI_VN:
462
+ case i.VI_VN:
461
463
  return "vi";
462
- case f.ZH_CN:
464
+ case i.ZH_CN:
463
465
  return "zh-CN";
464
- case f.KO_KR:
466
+ case i.KO_KR:
465
467
  return "ko";
466
- case f.ZH_TW:
468
+ case i.ZH_TW:
467
469
  return "zh-TW";
468
- case f.ES_ES:
469
- case f.CA_ES:
470
+ case i.ES_ES:
471
+ case i.CA_ES:
470
472
  return "es";
471
- case f.EN_US:
472
- case f.FA_IR:
473
+ case i.SK_SK:
474
+ return "sk";
475
+ case i.EN_US:
476
+ case i.FA_IR:
473
477
  default:
474
478
  return "en";
475
479
  }
@@ -480,31 +484,31 @@ let D = class extends me {
480
484
  this.disposeWithMe(Ie(this._locale$, this._localeService.currentLocale$).subscribe(() => {
481
485
  r.reset();
482
486
  })), this.disposeWithMe(this._sheetInterceptorService.intercept(Re.CELL_CONTENT, {
483
- effect: z.Value | z.Style,
487
+ effect: k.Value | k.Style,
484
488
  // eslint-disable-next-line max-lines-per-function, complexity
485
489
  handler: (t, n, s) => {
486
490
  var b, _;
487
491
  if (!t || t.v === void 0 || t.v === null || t.t === M.BOOLEAN || t.t === M.FORCE_STRING)
488
492
  return s(t);
489
- const a = n.unitId, l = n.subUnitId;
493
+ const a = n.unitId, u = n.subUnitId;
490
494
  let o;
491
495
  if (t != null && t.s) {
492
496
  const m = n.workbook.getStyles().get(t.s);
493
497
  m != null && m.n && (o = m.n);
494
498
  }
495
- if (o || (o = this._numfmtService.getValue(a, l, n.row, n.col)), W(o == null ? void 0 : o.pattern) || t.t !== M.NUMBER && H(t.v, t.t) !== M.NUMBER)
499
+ if (o || (o = this._numfmtService.getValue(a, u, n.row, n.col)), G(o == null ? void 0 : o.pattern) || t.t !== M.NUMBER && B(t.v, t.t) !== M.NUMBER)
496
500
  return s(t);
497
501
  const h = t;
498
502
  if ((!t || t === n.rawData) && (t = { ...n.rawData }), J(o == null ? void 0 : o.pattern))
499
503
  return (b = this._configService.getConfig(se)) != null && b.disableTextFormatMark ? (t.t = M.STRING, s(t)) : (t.t = M.STRING, t.markers = { ...t == null ? void 0 : t.markers, ...Ze }, s(t));
500
- let u = "";
504
+ let f = "";
501
505
  const C = r.getValue(n.row, n.col);
502
506
  if (C && C.parameters === `${h.v}_${o == null ? void 0 : o.pattern}`)
503
507
  return s({ ...t, ...C.result });
504
- const y = Ge(o == null ? void 0 : o.pattern, Number(h.v), this.locale);
505
- if (u = y.result, !u)
508
+ const y = He(o == null ? void 0 : o.pattern, Number(h.v), this.locale);
509
+ if (f = y.result, !f)
506
510
  return s(t);
507
- const p = { v: u, t: M.NUMBER };
511
+ const p = { v: f, t: M.NUMBER };
508
512
  if (y.color) {
509
513
  const m = (_ = this._themeService.getColorFromTheme(`${y.color}.500`)) != null ? _ : y.color;
510
514
  m && (p.interceptorStyle = { cl: { rgb: m } });
@@ -519,13 +523,13 @@ let D = class extends me {
519
523
  if (t.id === re.id) {
520
524
  const n = t.params;
521
525
  Object.keys(n.values).forEach((s) => {
522
- n.values[s].ranges.forEach((l) => {
523
- N.foreach(l, (o, h) => {
526
+ n.values[s].ranges.forEach((u) => {
527
+ N.foreach(u, (o, h) => {
524
528
  r.realDeleteValue(o, h);
525
529
  });
526
530
  });
527
531
  });
528
- } else if (t.id === G.id) {
532
+ } else if (t.id === H.id) {
529
533
  const n = t.params;
530
534
  new R(n.cellValue).forValue((s, a) => {
531
535
  r.realDeleteValue(s, a);
@@ -545,7 +549,7 @@ let D = class extends me {
545
549
  this._locale$.next(r);
546
550
  }
547
551
  };
548
- D = Ke([
552
+ D = We([
549
553
  E(0, V),
550
554
  E(1, I(Me)),
551
555
  E(2, I(fe)),
@@ -554,12 +558,12 @@ D = Ke([
554
558
  E(5, I(Q)),
555
559
  E(6, ee)
556
560
  ], D);
557
- const ze = "SHEET_NUMFMT_PLUGIN";
558
- var ke = Object.defineProperty, Ye = Object.getOwnPropertyDescriptor, qe = (e, r, t) => r in e ? ke(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, Xe = (e, r, t, n) => {
559
- for (var s = n > 1 ? void 0 : n ? Ye(r, t) : r, a = e.length - 1, l; a >= 0; a--)
560
- (l = e[a]) && (s = l(s) || s);
561
+ const ke = "SHEET_NUMFMT_PLUGIN";
562
+ var ze = Object.defineProperty, Ye = Object.getOwnPropertyDescriptor, qe = (e, r, t) => r in e ? ze(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, Xe = (e, r, t, n) => {
563
+ for (var s = n > 1 ? void 0 : n ? Ye(r, t) : r, a = e.length - 1, u; a >= 0; a--)
564
+ (u = e[a]) && (s = u(s) || s);
561
565
  return s;
562
- }, B = (e, r) => (t, n) => r(t, n, e), oe = (e, r, t) => qe(e, typeof r != "symbol" ? r + "" : r, t);
566
+ }, K = (e, r) => (t, n) => r(t, n, e), oe = (e, r, t) => qe(e, typeof r != "symbol" ? r + "" : r, t);
563
567
  let A = class extends he {
564
568
  constructor(e = X, r, t, n) {
565
569
  super(), this._config = e, this._injector = r, this._configService = t, this._commandService = n;
@@ -573,11 +577,11 @@ let A = class extends he {
573
577
  onStarting() {
574
578
  _e(this._injector, [
575
579
  [D]
576
- ]), ve(this._injector, [
580
+ ]), Se(this._injector, [
577
581
  [D]
578
582
  ]), [
579
583
  Ve,
580
- Be,
584
+ Ke,
581
585
  je,
582
586
  Le,
583
587
  O
@@ -586,19 +590,19 @@ let A = class extends he {
586
590
  });
587
591
  }
588
592
  };
589
- oe(A, "pluginName", ze);
593
+ oe(A, "pluginName", ke);
590
594
  oe(A, "type", te.UNIVER_SHEET);
591
595
  A = Xe([
592
596
  de(Ne),
593
- B(1, I(ge)),
594
- B(2, ee),
595
- B(3, $)
597
+ K(1, I(ge)),
598
+ K(2, ee),
599
+ K(3, $)
596
600
  ], A);
597
- const ot = (e) => ne.find((t) => e.includes(t)), at = () => ne.map((e) => ({ label: e, value: e })), it = (e) => Ae.map((r) => ({
601
+ const ot = (e) => ne.find((t) => e.includes(t)), at = () => ne.map((e) => ({ label: e, value: e })), ct = (e) => Ae.map((r) => ({
598
602
  label: r.label(e),
599
603
  value: r.suffix(e),
600
604
  color: r.color
601
- })), ct = () => Fe.map((e) => ({ label: e.label, value: e.suffix })), lt = () => De.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
605
+ })), it = () => Fe.map((e) => ({ label: e.label, value: e.suffix })), lt = () => De.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
602
606
  export {
603
607
  Ve as AddDecimalCommand,
604
608
  Ae as CURRENCYFORMAT,
@@ -609,21 +613,21 @@ export {
609
613
  O as SetNumfmtCommand,
610
614
  Le as SetPercentCommand,
611
615
  D as SheetsNumfmtCellContentController,
612
- Be as SubtractDecimalCommand,
616
+ Ke as SubtractDecimalCommand,
613
617
  A as UniverSheetsNumfmtPlugin,
614
618
  ne as currencySymbols,
615
619
  Pe as getCurrencyFormat,
616
- it as getCurrencyFormatOptions,
620
+ ct as getCurrencyFormatOptions,
617
621
  at as getCurrencyOptions,
618
622
  Y as getCurrencySymbolByLocale,
619
623
  xe as getCurrencySymbolIconByLocale,
620
624
  ot as getCurrencyType,
621
- ct as getDateFormatOptions,
625
+ it as getDateFormatOptions,
622
626
  P as getDecimalFromPattern,
623
627
  q as getDecimalString,
624
628
  lt as getNumberFormatOptions,
625
- He as getPatternPreview,
626
- Ge as getPatternPreviewIgnoreGeneral,
629
+ Be as getPatternPreview,
630
+ He as getPatternPreviewIgnoreGeneral,
627
631
  st as getPatternType,
628
632
  nt as isPatternHasDecimal,
629
633
  w as localeCurrencySymbolMap,