@univerjs/sheets-numfmt 0.1.9 → 0.1.11
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 +2 -2
- package/lib/es/index.js +257 -214
- package/lib/types/commands/commands/set-numfmt.command.d.ts +1 -1
- package/lib/types/components/accounting/index.d.ts +1 -1
- package/lib/types/components/currency/index.d.ts +1 -1
- package/lib/types/components/date/index.d.ts +1 -1
- package/lib/types/components/general/index.d.ts +1 -1
- package/lib/types/components/stories/Panel.stories.d.ts +1 -1
- package/lib/types/components/thousandth-percentile/index.d.ts +1 -1
- package/lib/types/controllers/__tests__/test.util.d.ts +1 -1
- package/lib/types/controllers/numfmt.cell-content.controller.d.ts +2 -2
- package/lib/types/controllers/numfmt.controller.d.ts +8 -6
- package/lib/types/controllers/numfmt.editor.controller.d.ts +3 -3
- package/lib/types/controllers/numfmt.menu.controller.d.ts +2 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/index.d.ts +1 -0
- package/lib/types/locale/ru-RU.d.ts +4 -0
- package/lib/types/menu/menu.d.ts +2 -2
- package/lib/types/numfmt-plugin.d.ts +1 -1
- package/lib/types/utils/pattern.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +22 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IBusinessComponentProps } from '../../base/types';
|
|
2
1
|
import { FC } from 'react';
|
|
2
|
+
import { IBusinessComponentProps } from '../../base/types';
|
|
3
3
|
|
|
4
4
|
export declare const isAccountingPanel: (pattern: string) => boolean;
|
|
5
5
|
export declare const AccountingPanel: FC<IBusinessComponentProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IBusinessComponentProps } from '../../base/types';
|
|
2
1
|
import { FC } from 'react';
|
|
2
|
+
import { IBusinessComponentProps } from '../../base/types';
|
|
3
3
|
|
|
4
4
|
export declare const isCurrencyPanel: (pattern: string) => boolean;
|
|
5
5
|
export declare const CurrencyPanel: FC<IBusinessComponentProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IBusinessComponentProps } from '../../base/types';
|
|
2
1
|
import { FC } from 'react';
|
|
2
|
+
import { IBusinessComponentProps } from '../../base/types';
|
|
3
3
|
|
|
4
4
|
export declare const isDatePanel: (pattern: string) => boolean;
|
|
5
5
|
export declare const DatePanel: FC<IBusinessComponentProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IBusinessComponentProps } from '../../base/types';
|
|
2
1
|
import { FC } from 'react';
|
|
2
|
+
import { IBusinessComponentProps } from '../../base/types';
|
|
3
3
|
|
|
4
4
|
export declare const isGeneralPanel: (pattern: string) => boolean;
|
|
5
5
|
export declare const GeneralPanel: FC<IBusinessComponentProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IBusinessComponentProps } from '../../base/types';
|
|
2
1
|
import { FC } from 'react';
|
|
2
|
+
import { IBusinessComponentProps } from '../../base/types';
|
|
3
3
|
|
|
4
4
|
export declare const isThousandthPercentilePanel: (pattern: string) => boolean;
|
|
5
5
|
export declare const ThousandthPercentilePanel: FC<IBusinessComponentProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
|
|
2
|
-
import { INumfmtService, SheetInterceptorService } from '@univerjs/sheets';
|
|
3
1
|
import { Disposable, ICommandService, LocaleService, ThemeService } from '@univerjs/core';
|
|
2
|
+
import { INumfmtService, SheetInterceptorService } from '@univerjs/sheets';
|
|
3
|
+
import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
|
|
4
4
|
|
|
5
5
|
export declare class NumfmtCellContent extends Disposable {
|
|
6
6
|
private _sheetInterceptorService;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { INumfmtController } from './type';
|
|
2
|
-
import { ComponentManager, ISidebarService } from '@univerjs/ui';
|
|
3
|
-
import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
|
|
4
|
-
import { INumfmtService, SelectionManagerService, SheetInterceptorService } from '@univerjs/sheets';
|
|
5
|
-
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
6
1
|
import { Disposable, ICommandService, IUniverInstanceService, LocaleService, ThemeService } from '@univerjs/core';
|
|
2
|
+
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
3
|
+
import { INumfmtService, SelectionManagerService, SheetInterceptorService } from '@univerjs/sheets';
|
|
4
|
+
import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
|
|
5
|
+
import { ComponentManager, ISidebarService } from '@univerjs/ui';
|
|
6
|
+
import { INumfmtController } from './type';
|
|
7
7
|
|
|
8
8
|
export declare class NumfmtController extends Disposable implements INumfmtController {
|
|
9
9
|
private _sheetInterceptorService;
|
|
@@ -25,9 +25,11 @@ export declare class NumfmtController extends Disposable implements INumfmtContr
|
|
|
25
25
|
*/
|
|
26
26
|
private _previewPattern;
|
|
27
27
|
constructor(_sheetInterceptorService: SheetInterceptorService, _themeService: ThemeService, _univerInstanceService: IUniverInstanceService, _sheetSkeletonManagerService: SheetSkeletonManagerService, _commandService: ICommandService, _selectionManagerService: SelectionManagerService, _renderManagerService: IRenderManagerService, _numfmtService: INumfmtService, _componentManager: ComponentManager, _sidebarService: ISidebarService, _localeService: LocaleService);
|
|
28
|
-
openPanel
|
|
28
|
+
openPanel(): boolean;
|
|
29
29
|
private _initCommands;
|
|
30
30
|
private _initPanel;
|
|
31
31
|
private _initRealTimeRenderingInterceptor;
|
|
32
32
|
private _commandExecutedListener;
|
|
33
|
+
private _sidebarDisposable;
|
|
34
|
+
private _initCloseListener;
|
|
33
35
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Injector } from '@wendellhu/redi';
|
|
2
|
-
import { IEditorBridgeService } from '@univerjs/sheets-ui';
|
|
3
|
-
import { INumfmtService, SheetInterceptorService } from '@univerjs/sheets';
|
|
4
1
|
import { Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { INumfmtService, SheetInterceptorService } from '@univerjs/sheets';
|
|
3
|
+
import { IEditorBridgeService } from '@univerjs/sheets-ui';
|
|
4
|
+
import { Injector } from '@wendellhu/redi';
|
|
5
5
|
|
|
6
6
|
export declare class NumfmtEditorController extends Disposable {
|
|
7
7
|
private _sheetInterceptorService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Injector } from '@wendellhu/redi';
|
|
2
|
-
import { ComponentManager, IMenuService } from '@univerjs/ui';
|
|
3
1
|
import { Disposable } from '@univerjs/core';
|
|
2
|
+
import { ComponentManager, IMenuService } from '@univerjs/ui';
|
|
3
|
+
import { Injector } from '@wendellhu/redi';
|
|
4
4
|
|
|
5
5
|
export declare class NumfmtMenuController extends Disposable {
|
|
6
6
|
private _injector;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export { type ISetNumfmtCommandParams, SetNumfmtCommand } from './commands/commands/set-numfmt.command';
|
|
17
|
-
export { enUS, zhCN } from './locale';
|
|
17
|
+
export { enUS, zhCN, ruRU } from './locale';
|
|
18
18
|
export { UniverSheetsNumfmtPlugin } from './numfmt-plugin';
|
|
19
19
|
export { getPatternPreview } from './utils/pattern';
|
package/lib/types/menu/menu.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { IAccessor } from '@wendellhu/redi';
|
|
3
1
|
import { ComponentManager, IMenuSelectorItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
|
|
2
|
+
import { IAccessor } from '@wendellhu/redi';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
4
|
|
|
5
5
|
export declare const CurrencyMenuItem: (componentManager: ComponentManager) => (accessor: IAccessor) => {
|
|
6
6
|
icon: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FormatType } from '@univerjs/sheets';
|
|
2
1
|
import { LocaleType } from '@univerjs/core';
|
|
2
|
+
import { FormatType } from '@univerjs/sheets';
|
|
3
3
|
|
|
4
4
|
export declare const getPatternType: (pattern: string) => FormatType;
|
|
5
5
|
export declare const getPatternPreview: (pattern: string, value: number, _locale?: LocaleType) => {
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(I,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/engine-numfmt"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-ui","rxjs/operators","@univerjs/engine-numfmt","@univerjs/engine-render","@univerjs/ui","rxjs","react","@univerjs/design","@wendellhu/redi/react-bindings"],c):(I=typeof globalThis<"u"?globalThis:I||self,c(I.UniverSheetsNumfmt={},I.UniverCore,I.UniverSheets,I["@wendellhu/redi"],I.UniverSheetsUi,I.rxjs.operators,I.UniverEngineNumfmt,I.UniverEngineRender,I.UniverUi,I.rxjs,I.React,I.UniverDesign,I["@wendellhu/redi/react-bindings"]))})(this,function(I,c,v,_,G,k,P,ve,M,U,g,x,R){"use strict";var Xt=Object.defineProperty;var qt=(I,c,v)=>c in I?Xt(I,c,{enumerable:!0,configurable:!0,writable:!0,value:v}):I[c]=v;var H=(I,c,v)=>(qt(I,typeof c!="symbol"?c+"":c,v),v);var se;const L={id:"sheet.command.numfmt.set.numfmt",type:c.CommandType.COMMAND,handler:(e,t)=>{if(!t)return!1;const r=e.get(c.ICommandService),n=e.get(c.IUniverInstanceService),a=e.get(c.IUndoRedoService),s=v.getSheetCommandTarget(n,t);if(!s)return!1;const{unitId:i,subUnitId:l}=s,u=t.values.filter(h=>!!h.pattern),m=t.values.filter(h=>!h.pattern),f=v.transformCellsToRange(i,l,u),o={unitId:i,subUnitId:l,ranges:m.map(h=>({startColumn:h.col,startRow:h.row,endColumn:h.col,endRow:h.row}))},p=[],b=[];if(u.length){Object.keys(f.values).forEach(S=>{const C=f.values[S];C.ranges=v.rangeMerge(C.ranges)}),p.push({id:v.SetNumfmtMutation.id,params:f});const h=v.factorySetNumfmtUndoMutation(e,f);b.push(...h)}if(m.length){o.ranges=v.rangeMerge(o.ranges),p.push({id:v.RemoveNumfmtMutation.id,params:o});const h=v.factoryRemoveNumfmtUndoMutation(e,o);b.push(...h)}const y=c.sequenceExecute(p,r).result;return y&&a.pushUndoRedo({unitID:i,undoMutations:b,redoMutations:p}),y}},pe={sheet:{numfmt:{percent:"Percentage",title:"Number format",numfmtType:"Format types",cancel:"Cancel",confirm:"Confirm",general:"General",accounting:"Accounting",text:"Text",number:"Number",currency:"Currency",date:"Date",time:"Time",thousandthPercentile:"Thousands separator",preview:"Preview",dateTime:"Date and time",decimalLength:"Decimal places",currencyType:"Currency Symbol",moreFmt:"More Formats",financialValue:"Financial value",roundingCurrency:"Rounding up the currency",timeDuration:"Duration Time",currencyDes:"The currency format is used to represent general currency values. The accounting format aligns a column of values with decimal points",accountingDes:"The accounting number format aligns a column of values with currency symbols and decimal points",dateType:"Date Type",dateDes:"The date format presents date and time series values as date values.",negType:"A negative number type",generalDes:"The regular format does not contain any specific number format.",thousandthPercentileDes:"The percentile format is used for the representation of ordinary numbers. Monetary and accounting formats provide a specialized format for monetary value calculations.",addDecimal:"Increase decimal places",subtractDecimal:"Decreasing decimal places"}}},ge={sheet:{numfmt:{percent:"百分比",title:"数字格式",numfmtType:"格式类型",cancel:"取消",confirm:"确认",general:"常规",accounting:"会计",text:"文本",number:"数值",currency:"货币",date:"日期",time:"时间",thousandthPercentile:"千分位符",preview:"示例",dateTime:"日期时间",decimalLength:"小数位数",currencyType:"货币类型",moreFmt:"更多格式",financialValue:"财务数值",roundingCurrency:"货币取整",timeDuration:"持续时间",currencyDes:"货币格式用于表示一般货币数值。会计格式可以对一列数值进行小数点对齐",accountingDes:"会计数字格式可对一列数值进行货币符号和小数点对齐",dateType:"日期类型",dateDes:"日期格式将日期和时间系列数值品示为日期值。",negType:"负数类型",generalDes:"常规格式不包含任何特定的数字格式。",thousandthPercentileDes:"千分位符格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。",addDecimal:"增加小数位",subtractDecimal:"减少小数位"}}},ie="SHEET_NUMFMT_PLUGIN",K=e=>P.getInfo(e).type||"unknown",Z=(e,t,r)=>{const n=P.getInfo(e),a=r===c.LocaleType.ZH_CN?"zh-CN":"en",s=n._partitions[1],i=P.format(e,t,{locale:a});return t<0?{result:i,color:s.color}:{result:i}};var Ue=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Ve=(e,t,r,n)=>{for(var a=n>1?void 0:n?Le(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Ue(t,r,a),a},B=(e,t)=>(r,n)=>t(r,n,e);let Y=class extends c.Disposable{constructor(e,t,r,n,a,s){super(),this._sheetInterceptorService=e,this._themeService=t,this._sheetSkeletonManagerService=r,this._commandService=n,this._numfmtService=a,this._localeService=s,this._initInterceptorCellContent()}_initInterceptorCellContent(){const e=new c.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,r,n)=>{const a=r.unitId,s=r.subUnitId,i=this._numfmtService.getValue(a,s,r.row,r.col);if(!i)return n(t);const l=t;if(!l||l.t!==c.CellValueType.NUMBER)return n(t);let u="";const m=e.getValue(r.row,r.col);if(m&&m.parameters===l.v)return n({...t,...m.result});const f=Z(i.pattern,Number(l.v),this._localeService.getCurrentLocale());if(u=f.result,!u)return n(t);const o={v:u};if(f.color){const p=this._themeService.getCurrentTheme()[`${f.color}500`];p&&(o.interceptorStyle={cl:{rgb:p}})}return e.setValue(r.row,r.col,{result:o,parameters:l.v}),n({...t,...o})}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===v.SetNumfmtMutation.id){const r=t.params;Object.keys(r.values).forEach(n=>{r.values[n].ranges.forEach(s=>{c.Range.foreach(s,(i,l)=>{e.realDeleteValue(i,l)})})})}})),this.disposeWithMe(c.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.pipe(k.map(t=>t==null?void 0:t.sheetId),k.distinctUntilChanged()).subscribe(()=>{e.reset()})))}};Y=Ve([c.OnLifecycle(c.LifecycleStages.Rendered,Y),B(0,_.Inject(v.SheetInterceptorService)),B(1,_.Inject(c.ThemeService)),B(2,_.Inject(G.SheetSkeletonManagerService)),B(3,_.Inject(c.ICommandService)),B(4,_.Inject(v.INumfmtService)),B(5,_.Inject(c.LocaleService))],Y);const V=(e,t=0)=>{var n;return e&&(n=P.getInfo(e).maxDecimals)!=null?n:t},J=(e,t)=>{if(e&&!t||!e&&t)return!1;const r=m=>m.reduce((f,o)=>{if(f.isEnd)return f;const p=o.value||o.num;return o.type==="point"?(f.isEnd=!0,f):{...f,result:f.result+p}},{isEnd:!1,result:""}).result,n=P.getInfo(e)._partitions,a=P.getInfo(t)._partitions,s=r(n[0].tokens),i=r(a[0].tokens),l=r(n[1].tokens),u=r(a[1].tokens);return s===i&&l===u&&n[1].color===a[1].color},Se=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),j=(e,t)=>e.split(";").map(n=>/\.0?/.test(n)?n.replace(/\.0*/g,`${t>0?".":""}${Se(Number(t||0))}`):/0([^0]?)|0$/.test(n)?n.replace(/0([^0]+)|0$/,`0${t>0?".":""}${Se(Number(t||0))}$1`):n).join(";"),Ae=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),ye={id:"sheet.command.numfmt.add.decimal.command",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),r=e.get(v.SelectionManagerService),n=e.get(v.INumfmtService),a=e.get(c.IUniverInstanceService),s=r.getSelections();if(!s||!s.length)return!1;const i=v.getSheetCommandTarget(a);if(!i)return!1;const{unitId:l,subUnitId:u}=i;let m=0;s.forEach(b=>{c.Range.foreach(b.range,(y,h)=>{const S=n.getValue(l,u,y,h);if(!S)return;const C=V(S.pattern);m=C>m?C:m})});const f=m+1,o=j(`0${f>0?".0":""}`,f),p=[];return s.forEach(b=>{c.Range.foreach(b.range,(y,h)=>{const S=n.getValue(l,u,y,h);if(!S)p.push({row:y,col:h,pattern:o});else{const C=V(S.pattern),T=j(S.pattern,C+1);T!==S.pattern&&p.push({row:y,col:h,pattern:T})}})}),p.length?await t.executeCommand(L.id,{values:p}):!1}},He=[{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"}],ke=[{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"}],Ce=[{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={id:"sheet.command.numfmt.set.currency",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),n=e.get(v.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const a=[],s=Ce[0].suffix("¥");return n.forEach(l=>{c.Range.foreach(l.range,(u,m)=>{a.push({row:u,col:m,pattern:s,type:"currency"})})}),await t.executeCommand(L.id,{values:a})}},be={id:"sheet.command.numfmt.subtract.decimal.command",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),r=e.get(v.SelectionManagerService),n=e.get(v.INumfmtService),a=e.get(c.IUniverInstanceService),s=r.getSelections();if(!s||!s.length)return!1;const i=v.getSheetCommandTarget(a);if(!i)return!1;const{unitId:l,subUnitId:u}=i;let m=0;s.forEach(y=>{c.Range.foreach(y.range,(h,S)=>{const C=n.getValue(l,u,h,S);if(!C)return;const T=V(C.pattern);m=T>m?T:m})});const f=m-1,o=j(`0${f>0?".0":"."}`,f),p=[];return s.forEach(y=>{c.Range.foreach(y.range,(h,S)=>{const C=n.getValue(l,u,h,S);if(!C)p.push({row:h,col:S,pattern:o});else{const T=V(C.pattern);p.push({row:h,col:S,pattern:j(C.pattern,T-1)})}})}),await t.executeCommand(L.id,{values:p})}},ce={id:"sheet.operation.close.numfmt.panel",type:c.CommandType.OPERATION,handler:()=>!0},oe=_.createIdentifier("INumfmtController");c.runOnLifecycle(c.LifecycleStages.Rendered,oe);const Q={id:"sheet.operation.open.numfmt.panel",type:c.CommandType.OPERATION,handler:e=>(e.get(oe).openPanel(),!0)};var Ie={exports:{}},X={};/**
|
|
1
|
+
(function(_,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/engine-numfmt"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-ui","rxjs/operators","@univerjs/engine-numfmt","@univerjs/engine-render","@univerjs/ui","rxjs","react","@univerjs/design","@wendellhu/redi/react-bindings"],i):(_=typeof globalThis<"u"?globalThis:_||self,i(_.UniverSheetsNumfmt={},_.UniverCore,_.UniverSheets,_["@wendellhu/redi"],_.UniverSheetsUi,_.rxjs.operators,_.UniverEngineNumfmt,_.UniverEngineRender,_.UniverUi,_.rxjs,_.React,_.UniverDesign,_["@wendellhu/redi/react-bindings"]))})(this,function(_,i,v,I,G,k,x,ve,M,U,g,O,j){"use strict";var qt=Object.defineProperty;var en=(_,i,v)=>i in _?qt(_,i,{enumerable:!0,configurable:!0,writable:!0,value:v}):_[i]=v;var A=(_,i,v)=>(en(_,typeof i!="symbol"?i+"":i,v),v);var se;const L={id:"sheet.command.numfmt.set.numfmt",type:i.CommandType.COMMAND,handler:(e,t)=>{if(!t)return!1;const r=e.get(i.ICommandService),n=e.get(i.IUniverInstanceService),a=e.get(i.IUndoRedoService),s=v.getSheetCommandTarget(n,t);if(!s)return!1;const{unitId:c,subUnitId:l}=s,u=t.values.filter(h=>!!h.pattern),m=t.values.filter(h=>!h.pattern),f=v.transformCellsToRange(c,l,u),o={unitId:c,subUnitId:l,ranges:m.map(h=>({startColumn:h.col,startRow:h.row,endColumn:h.col,endRow:h.row}))},p=[],b=[];if(u.length){Object.keys(f.values).forEach(S=>{const C=f.values[S];C.ranges=v.rangeMerge(C.ranges)}),p.push({id:v.SetNumfmtMutation.id,params:f});const h=v.factorySetNumfmtUndoMutation(e,f);b.push(...h)}if(m.length){o.ranges=v.rangeMerge(o.ranges),p.push({id:v.RemoveNumfmtMutation.id,params:o});const h=v.factoryRemoveNumfmtUndoMutation(e,o);b.push(...h)}const y=i.sequenceExecute(p,r).result;return y&&a.pushUndoRedo({unitID:c,undoMutations:b,redoMutations:p}),y}},pe={sheet:{numfmt:{percent:"Percentage",title:"Number format",numfmtType:"Format types",cancel:"Cancel",confirm:"Confirm",general:"General",accounting:"Accounting",text:"Text",number:"Number",currency:"Currency",date:"Date",time:"Time",thousandthPercentile:"Thousands separator",preview:"Preview",dateTime:"Date and time",decimalLength:"Decimal places",currencyType:"Currency Symbol",moreFmt:"More Formats",financialValue:"Financial value",roundingCurrency:"Rounding up the currency",timeDuration:"Duration Time",currencyDes:"The currency format is used to represent general currency values. The accounting format aligns a column of values with decimal points",accountingDes:"The accounting number format aligns a column of values with currency symbols and decimal points",dateType:"Date Type",dateDes:"The date format presents date and time series values as date values.",negType:"A negative number type",generalDes:"The regular format does not contain any specific number format.",thousandthPercentileDes:"The percentile format is used for the representation of ordinary numbers. Monetary and accounting formats provide a specialized format for monetary value calculations.",addDecimal:"Increase decimal places",subtractDecimal:"Decreasing decimal places"}}},ge={sheet:{numfmt:{percent:"百分比",title:"数字格式",numfmtType:"格式类型",cancel:"取消",confirm:"确认",general:"常规",accounting:"会计",text:"文本",number:"数值",currency:"货币",date:"日期",time:"时间",thousandthPercentile:"千分位符",preview:"示例",dateTime:"日期时间",decimalLength:"小数位数",currencyType:"货币类型",moreFmt:"更多格式",financialValue:"财务数值",roundingCurrency:"货币取整",timeDuration:"持续时间",currencyDes:"货币格式用于表示一般货币数值。会计格式可以对一列数值进行小数点对齐",accountingDes:"会计数字格式可对一列数值进行货币符号和小数点对齐",dateType:"日期类型",dateDes:"日期格式将日期和时间系列数值品示为日期值。",negType:"负数类型",generalDes:"常规格式不包含任何特定的数字格式。",thousandthPercentileDes:"千分位符格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。",addDecimal:"增加小数位",subtractDecimal:"减少小数位"}}},Ue={sheet:{numfmt:{percent:"Процент",title:"Формат числа",numfmtType:"Типы форматов",cancel:"Отмена",confirm:"Подтвердить",general:"Общий",accounting:"Бухгалтерский",text:"Текст",number:"Число",currency:"Валюта",date:"Дата",time:"Время",thousandthPercentile:"Разделитель тысяч",preview:"Предпросмотр",dateTime:"Дата и время",decimalLength:"Десятичные знаки",currencyType:"Символ валюты",moreFmt:"Другие форматы",financialValue:"Финансовое значение",roundingCurrency:"Округление валюты",timeDuration:"Продолжительность времени",currencyDes:"Формат валюты используется для представления общих значений валюты. Формат бухгалтерского учета выравнивает столбец значений по десятичным точкам.",accountingDes:"Формат бухгалтерских чисел выравнивает столбец значений по символам валюты и десятичным точкам.",dateType:"Тип даты",dateDes:"Формат даты представляет значения времени и даты как значения даты.",negType:"Тип отрицательного числа",generalDes:"Обычный формат не содержит никакого специфического формата числа.",thousandthPercentileDes:"Формат процента используется для представления обычных чисел. Монетарные и бухгалтерские форматы предоставляют специальный формат для вычислений монетарных значений.",addDecimal:"Увеличить количество десятичных знаков",subtractDecimal:"Уменьшить количество десятичных знаков"}}},ie="SHEET_NUMFMT_PLUGIN",K=e=>x.getInfo(e).type||"unknown",Z=(e,t,r)=>{const n=x.getInfo(e),a=r===i.LocaleType.ZH_CN?"zh-CN":"en",s=n._partitions[1],c=x.format(e,t,{locale:a});return t<0?{result:c,color:s.color}:{result:c}};var Le=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,He=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ve(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(a=(n?c(t,r,a):c(a))||a);return n&&a&&Le(t,r,a),a},F=(e,t)=>(r,n)=>t(r,n,e);let Y=class extends i.Disposable{constructor(e,t,r,n,a,s){super(),this._sheetInterceptorService=e,this._themeService=t,this._sheetSkeletonManagerService=r,this._commandService=n,this._numfmtService=a,this._localeService=s,this._initInterceptorCellContent()}_initInterceptorCellContent(){const e=new i.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,r,n)=>{const a=r.unitId,s=r.subUnitId,c=this._numfmtService.getValue(a,s,r.row,r.col);if(!c)return n(t);const l=t;if(!l||l.t!==i.CellValueType.NUMBER)return n(t);let u="";const m=e.getValue(r.row,r.col);if(m&&m.parameters===l.v)return n({...t,...m.result});const f=Z(c.pattern,Number(l.v),this._localeService.getCurrentLocale());if(u=f.result,!u)return n(t);const o={v:u};if(f.color){const p=this._themeService.getCurrentTheme()[`${f.color}500`];p&&(o.interceptorStyle={cl:{rgb:p}})}return e.setValue(r.row,r.col,{result:o,parameters:l.v}),n({...t,...o})}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===v.SetNumfmtMutation.id){const r=t.params;Object.keys(r.values).forEach(n=>{r.values[n].ranges.forEach(s=>{i.Range.foreach(s,(c,l)=>{e.realDeleteValue(c,l)})})})}})),this.disposeWithMe(i.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.pipe(k.map(t=>t==null?void 0:t.sheetId),k.distinctUntilChanged()).subscribe(()=>{e.reset()})))}};Y=He([i.OnLifecycle(i.LifecycleStages.Rendered,Y),F(0,I.Inject(v.SheetInterceptorService)),F(1,I.Inject(i.ThemeService)),F(2,I.Inject(G.SheetSkeletonManagerService)),F(3,I.Inject(i.ICommandService)),F(4,I.Inject(v.INumfmtService)),F(5,I.Inject(i.LocaleService))],Y);const V=(e,t=0)=>{var n;return e&&(n=x.getInfo(e).maxDecimals)!=null?n:t},J=(e,t)=>{if(e&&!t||!e&&t)return!1;const r=m=>m.reduce((f,o)=>{if(f.isEnd)return f;const p=o.value||o.num;return o.type==="point"?(f.isEnd=!0,f):{...f,result:f.result+p}},{isEnd:!1,result:""}).result,n=x.getInfo(e)._partitions,a=x.getInfo(t)._partitions,s=r(n[0].tokens),c=r(a[0].tokens),l=r(n[1].tokens),u=r(a[1].tokens);return s===c&&l===u&&n[1].color===a[1].color},Se=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),R=(e,t)=>e.split(";").map(n=>/\.0?/.test(n)?n.replace(/\.0*/g,`${t>0?".":""}${Se(Number(t||0))}`):/0([^0]?)|0$/.test(n)?n.replace(/0([^0]+)|0$/,`0${t>0?".":""}${Se(Number(t||0))}$1`):n).join(";"),Ae=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),ye={id:"sheet.command.numfmt.add.decimal.command",type:i.CommandType.COMMAND,handler:async e=>{const t=e.get(i.ICommandService),r=e.get(v.SelectionManagerService),n=e.get(v.INumfmtService),a=e.get(i.IUniverInstanceService),s=r.getSelections();if(!s||!s.length)return!1;const c=v.getSheetCommandTarget(a);if(!c)return!1;const{unitId:l,subUnitId:u}=c;let m=0;s.forEach(b=>{i.Range.foreach(b.range,(y,h)=>{const S=n.getValue(l,u,y,h);if(!S)return;const C=V(S.pattern);m=C>m?C:m})});const f=m+1,o=R(`0${f>0?".0":""}`,f),p=[];return s.forEach(b=>{i.Range.foreach(b.range,(y,h)=>{const S=n.getValue(l,u,y,h);if(!S)p.push({row:y,col:h,pattern:o});else{const C=V(S.pattern),T=R(S.pattern,C+1);T!==S.pattern&&p.push({row:y,col:h,pattern:T})}})}),p.length?await t.executeCommand(L.id,{values:p}):!1}},ke=[{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"}],Fe=[{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"}],Ce=[{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={id:"sheet.command.numfmt.set.currency",type:i.CommandType.COMMAND,handler:async e=>{const t=e.get(i.ICommandService),n=e.get(v.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const a=[],s=Ce[0].suffix("¥");return n.forEach(l=>{i.Range.foreach(l.range,(u,m)=>{a.push({row:u,col:m,pattern:s,type:"currency"})})}),await t.executeCommand(L.id,{values:a})}},be={id:"sheet.command.numfmt.subtract.decimal.command",type:i.CommandType.COMMAND,handler:async e=>{const t=e.get(i.ICommandService),r=e.get(v.SelectionManagerService),n=e.get(v.INumfmtService),a=e.get(i.IUniverInstanceService),s=r.getSelections();if(!s||!s.length)return!1;const c=v.getSheetCommandTarget(a);if(!c)return!1;const{unitId:l,subUnitId:u}=c;let m=0;s.forEach(y=>{i.Range.foreach(y.range,(h,S)=>{const C=n.getValue(l,u,h,S);if(!C)return;const T=V(C.pattern);m=T>m?T:m})});const f=m-1,o=R(`0${f>0?".0":"."}`,f),p=[];return s.forEach(y=>{i.Range.foreach(y.range,(h,S)=>{const C=n.getValue(l,u,h,S);if(!C)p.push({row:h,col:S,pattern:o});else{const T=V(C.pattern);p.push({row:h,col:S,pattern:R(C.pattern,T-1)})}})}),await t.executeCommand(L.id,{values:p})}},ce={id:"sheet.operation.close.numfmt.panel",type:i.CommandType.OPERATION,handler:()=>!0},oe=I.createIdentifier("INumfmtController");i.runOnLifecycle(i.LifecycleStages.Rendered,oe);const Q={id:"sheet.operation.open.numfmt.panel",type:i.CommandType.OPERATION,handler:e=>(e.get(oe).openPanel(),!0)};var Ie={exports:{}},X={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Be=g,Fe=Symbol.for("react.element"),ze=Symbol.for("react.fragment"),$e=Object.prototype.hasOwnProperty,We=Be.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ge={key:!0,ref:!0,__self:!0,__source:!0};function Me(e,t,r){var n,a={},s=null,i=null;r!==void 0&&(s=""+r),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(i=t.ref);for(n in t)$e.call(t,n)&&!Ge.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)a[n]===void 0&&(a[n]=t[n]);return{$$typeof:Fe,type:e,key:s,ref:i,props:a,_owner:We.current}}X.Fragment=ze,X.jsx=Me,X.jsxs=Me,Ie.exports=X;var d=Ie.exports;const le=g.createContext([]),ue=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"];var Ke=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Ye=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ze(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Ke(t,r,a),a},Je=(e,t)=>(r,n)=>t(r,n,e);let q=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const r=this._getKey(e);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,t)})}markHabit(e,t){const r=this._getKey(e);this._localStorageService.getItem(r).then(n=>{if(n){const a=n.findIndex(s=>s===t);a>-1&&n.splice(a,1),n.unshift(t),this._localStorageService.setItem(r,n)}})}async getHabit(e,t){const r=this._getKey(e),n=await this._localStorageService.getItem(r);if(t&&n){const a=n.map((s,i,l)=>{const u=l.length;return{value:s,priority:u-i}});return t.sort((s,i)=>{var m,f;const l=((m=a.find(o=>o.value===s))==null?void 0:m.priority)||-1;return(((f=a.find(o=>o.value===i))==null?void 0:f.priority)||-1)-l})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};q=Ye([Je(0,_.Inject(c.ILocalStorageService))],q);const Te="numfmtCurrency",Qe=e=>{const t=R.useDependency(q),[r,n]=g.useState(ue);return g.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(Te,[...ue]).then(s=>{n(s),e&&e(s)})})},[]),{userHabitCurrency:r,mark:s=>{t.markHabit(Te,s)}}},Xe=()=>{const e=g.useRef([]),[t,r]=g.useState({});return g.useEffect(()=>{e.current.forEach(a=>{a()}),e.current=[]},[t]),a=>{e.current.push(a),r({})}},$=e=>ue.find(r=>e.includes(r)),qe=e=>!!$(e)&&e.startsWith("_("),et=e=>{const[t,r]=g.useState(()=>V(e.defaultPattern||"",2)),n=g.useContext(le),[a,s]=g.useState(()=>$(e.defaultPattern)||n[0]),i=g.useMemo(()=>n.map(o=>({label:o,value:o})),[]),u=R.useDependency(c.LocaleService).t;e.action.current=()=>j(`_("${a}"* #,##0${t>0?".0":""}_)`,t);const m=o=>{s(o),e.onChange(j(`_("${o}"* #,##0${t>0?".0":""}_)`,t))},f=o=>{const p=o||0;r(p),e.onChange(j(`_("${a}"* #,##0${p>0?".0":""}_)`,p))};return d.jsxs("div",{children:[d.jsxs("div",{className:"m-t-16 options ",children:[d.jsxs("div",{className:"option",children:[d.jsx("div",{className:"label",children:u("sheet.numfmt.decimalLength")}),d.jsx("div",{className:"m-t-8 w-120",children:d.jsx(x.InputNumber,{value:t,max:20,min:0,onChange:f})})]}),d.jsxs("div",{className:"option",children:[d.jsx("div",{className:"label",children:u("sheet.numfmt.currencyType")}),d.jsx("div",{className:"m-t-8 w-140",children:d.jsx(x.Select,{onChange:m,options:i,value:a})})]})]}),d.jsx("div",{className:"describe m-t-14",children:u("sheet.numfmt.accountingDes")})]})},me=e=>Ce.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),Ne=()=>He.map(e=>({label:e.label,value:e.suffix})),je=()=>ke.map(e=>({label:e.label,value:e.suffix,color:e.color})),tt=e=>!!$(e)&&!e.startsWith("_("),nt=e=>{const r=R.useDependency(c.LocaleService).t,n=g.useContext(le),[a,s]=g.useState(()=>$(e.defaultPattern)||n[0]),[i,l]=g.useState(()=>V(e.defaultPattern||"",2)),[u,m]=g.useState(()=>{var C;const h=me(a);return((C=h.find(T=>J(T.value,e.defaultPattern)))==null?void 0:C.value)||h[0].value}),f=g.useMemo(()=>me(a),[a]),o=g.useMemo(()=>n.map(h=>({label:h,value:h})),[n]);e.action.current=()=>j(u,i);const p=h=>{s(h);const S=me(h)[0].value;m(S),e.onChange(j(S,i))},b=h=>{m(h),e.onChange(j(h,i))},y=h=>{l(h||0),e.onChange(j(u,h||0))};return d.jsxs("div",{children:[d.jsxs("div",{className:"m-t-16 options ",children:[d.jsxs("div",{className:"option",children:[d.jsx("div",{className:"label",children:r("sheet.numfmt.decimalLength")}),d.jsx("div",{className:"m-t-8 w-120",children:d.jsx(x.InputNumber,{value:i,max:20,min:0,onChange:y})})]}),d.jsxs("div",{className:"option",children:[d.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),d.jsx("div",{className:"m-t-8 w-140",children:d.jsx(x.Select,{onChange:p,options:o,value:a})})]})]}),d.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),d.jsx("div",{className:"m-t-8",children:d.jsx(x.SelectList,{onChange:b,options:f,value:u})}),d.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})},rt=e=>{const t=P.getInfo(e);return Ne().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)},at=e=>{const t=g.useMemo(Ne,[]),n=R.useDependency(c.LocaleService).t,[a,s]=g.useState(()=>{if(e.defaultPattern){const l=t.find(u=>u.value===e.defaultPattern);if(l)return l.value}return t[0].value});e.action.current=()=>a;const i=l=>{s(l),e.onChange(l)};return d.jsxs("div",{children:[d.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.dateType")}),d.jsx("div",{className:"m-t-8",children:d.jsx(x.SelectList,{value:a,options:t,onChange:i})}),d.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},st=e=>!e,it=e=>{const r=R.useDependency(c.LocaleService).t;return e.action.current=()=>"",d.jsx("div",{children:d.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},ct=e=>je().some(t=>J(t.value,e)),ot=e=>{const t=R.useDependency(c.LocaleService),r=g.useMemo(je,[]),[n,a]=g.useState(()=>V(e.defaultPattern||"",0)),[s,i]=g.useState(()=>{const o=r.find(p=>J(p.value,e.defaultPattern||""));return(o==null?void 0:o.value)||r[0].value}),l=g.useMemo(()=>j(s,Number(n||0)),[s,n]),u=g.useMemo(()=>!Ae(s),[s]),m=o=>{a(o||0),e.onChange(j(s,Number(o||0)))},f=o=>{a(V(o,0)),i(o),e.onChange(o)};return e.action.current=()=>l,d.jsxs("div",{children:[d.jsx("div",{className:"m-t-16 label",children:t.t("sheet.numfmt.decimalLength")}),d.jsx("div",{className:"m-t-8",children:d.jsx(x.InputNumber,{disabled:u,value:n,max:20,min:0,onChange:m})}),d.jsxs("div",{className:"m-t-16 label",children:[" ",t.t("sheet.numfmt.negType")]}),d.jsx("div",{className:"m-t-8",children:d.jsx(x.SelectList,{onChange:f,options:r,value:s})}),d.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},lt=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:a}=e.value,s=R.useDependency(c.LocaleService),i=g.useRef(()=>""),l=s.t,u=Xe(),m=g.useMemo(()=>[{label:"sheet.numfmt.general",component:it},{label:"sheet.numfmt.accounting",component:et},{label:"sheet.numfmt.currency",component:nt},{label:"sheet.numfmt.date",component:at},{label:"sheet.numfmt.thousandthPercentile",component:ot}].map(N=>({...N,label:l(N.label)})),[]),[f,o]=g.useState(C),[p,b]=g.useState(()=>`${n}_${a}`),{mark:y,userHabitCurrency:h}=Qe(()=>b(`${n}_${a}_userCurrency'`)),S=g.useMemo(()=>{var N;return(N=m.find(z=>z.label===f))==null?void 0:N.component},[f]);function C(){return[st,qe,tt,rt,ct].reduce((z,Jt,Qt)=>z||(Jt(r)?m[Qt].label:""),"")||m[0].label}const T=m.map(N=>({label:N.label,value:N.label})),E=N=>{o(N),u(()=>e.onChange({type:"change",value:i.current()||""}))},w=N=>{e.onChange({type:"change",value:N})},A=()=>{const N=i.current()||"",z=$(N);z&&y(z),e.onChange({type:"confirm",value:N})},fe=()=>{e.onChange({type:"cancel",value:""})},he={onChange:w,defaultValue:t,defaultPattern:r,action:i};return g.useEffect(()=>{o(C()),b(`${n}_${a}`)},[n,a]),d.jsxs("div",{className:"numfmt-panel p-b-20",children:[d.jsxs("div",{children:[d.jsx("div",{className:"label m-t-14",children:l("sheet.numfmt.numfmtType")}),d.jsx("div",{className:"m-t-8",children:d.jsx(x.Select,{onChange:E,options:T,value:f})}),d.jsx("div",{children:S&&d.jsx(le.Provider,{value:h,children:g.createElement(S,{...he,key:p})})})]}),d.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[d.jsx(x.Button,{size:"small",onClick:fe,className:"m-r-12",children:l("sheet.numfmt.cancel")}),d.jsx(x.Button,{type:"primary",size:"small",onClick:A,children:l("sheet.numfmt.confirm")})]})]})},Re={id:"sheet.command.numfmt.set.percent",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),n=e.get(v.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const a=[],s="0%";return n.forEach(l=>{c.Range.foreach(l.range,(u,m)=>{a.push({row:u,col:m,pattern:s,type:"percent"})})}),await t.executeCommand(L.id,{values:a})}};var ut=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,dt=(e,t,r,n)=>{for(var a=n>1?void 0:n?mt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&ut(t,r,a),a},D=(e,t)=>(r,n)=>t(r,n,e);let ee=class extends c.Disposable{constructor(t,r,n,a,s,i,l,u,m,f,o){super();H(this,"_previewPattern","");H(this,"openPanel",()=>{const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,a=this._univerInstanceService,s=this._numfmtService,i=this._localeService,u=(r.getSelectionRanges()||[])[0];if(!u)return!1;const m=a.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),f=m.getActiveSheet(),o=f.getCellRaw(u.startRow,u.startColumn),p=s.getValue(m.getUnitId(),f.getSheetId(),u.startRow,u.startColumn);let b="";p&&(b=p.pattern);const y=(o==null?void 0:o.t)===c.CellValueType.NUMBER?o.v:12345678,h={onChange:S=>{var C,T;if(S.type==="change")this._previewPattern=S.value,this._sheetSkeletonManagerService.reCalculate(),(T=(C=this._renderManagerService.getRenderById(m.getUnitId()))==null?void 0:C.mainComponent)==null||T.makeDirty();else if(S.type==="confirm"){const E=r.getSelectionRanges()||[],w={values:[]},A=K(S.value);E.forEach(fe=>{c.Range.foreach(fe,(he,N)=>{w.values.push({row:he,col:N,pattern:S.value,type:A})})}),n.executeCommand(L.id,w),t.close()}else S.type==="cancel"&&t.close()},value:{defaultPattern:b,defaultValue:y,row:u.startRow,col:u.startColumn}};t.open({header:{title:i.t("sheet.numfmt.title")},children:{label:ie,...h},onClose:()=>{var S,C;this._sheetSkeletonManagerService.reCalculate(),(C=(S=this._renderManagerService.getRenderById(m.getUnitId()))==null?void 0:S.mainComponent)==null||C.makeDirty(),n.executeCommand(ce.id)}})});this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._sheetSkeletonManagerService=a,this._commandService=s,this._selectionManagerService=i,this._renderManagerService=l,this._numfmtService=u,this._componentManager=m,this._sidebarService=f,this._localeService=o,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._commandExecutedListener()}_initCommands(){[ye,be,_e,Re,Q,ce,L].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(ie,lt)}_initRealTimeRenderingInterceptor(){const t=new U.Observable(n=>{this._commandService.onCommandExecuted(a=>{a.id===Q.id&&n.next(!0),a.id===ce.id&&n.next(!1)})}),r=U.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(k.map(n=>n?n.map(a=>a.range):[]))]);this.disposeWithMe(c.toDisposable(r.pipe(k.switchMap(([n,a])=>new U.Observable(s=>{const i=new c.DisposableCollection;return n&&a.length&&s.next({selectionRanges:a,disposableCollection:i}),()=>{i.dispose()}})),k.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:a})=>{var i,l;const s=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,handler:(u,m,f)=>{const{row:o,col:p}=m,b=f(u)||{};if(a.find(y=>y.startColumn<=p&&y.endColumn>=p&&y.startRow<=o&&y.endRow>=o)){const y=m.worksheet.getCellRaw(o,p),h=y==null?void 0:y.v,S=y==null?void 0:y.t;if(h==null||S!==c.CellValueType.NUMBER||this._previewPattern===null)return b;const C=Z(this._previewPattern,h,this._localeService.getCurrentLocale());if(C.color){const E=this._themeService.getCurrentTheme()[`${C.color}500`];return{...b,v:C.result,t:c.CellValueType.STRING,s:{cl:{rgb:E}}}}return{...b,v:C.result,t:c.CellValueType.STRING}}return b}})),(l=(i=this._renderManagerService.getRenderById(s.getUnitId()))==null?void 0:i.mainComponent)==null||l.makeDirty()})))}_commandExecutedListener(){const t=[v.RemoveNumfmtMutation.id,v.SetNumfmtMutation.id];this.disposeWithMe(c.toDisposable(U.merge(new U.Observable(r=>{const n=this._commandService.onCommandExecuted(a=>{if(t.includes(a.id)){const s=a.params;r.next(s.unitId)}});return()=>{n.dispose()}})).pipe(k.debounceTime(16)).subscribe(r=>{var n,a;this._sheetSkeletonManagerService.reCalculate(),(a=(n=this._renderManagerService.getRenderById(r))==null?void 0:n.mainComponent)==null||a.makeDirty()})))}};ee=dt([c.OnLifecycle(c.LifecycleStages.Rendered,ee),D(0,_.Inject(v.SheetInterceptorService)),D(1,_.Inject(c.ThemeService)),D(2,_.Inject(c.IUniverInstanceService)),D(3,_.Inject(G.SheetSkeletonManagerService)),D(4,_.Inject(c.ICommandService)),D(5,_.Inject(v.SelectionManagerService)),D(6,_.Inject(ve.IRenderManagerService)),D(7,_.Inject(v.INumfmtService)),D(8,_.Inject(M.ComponentManager)),D(9,_.Inject(M.ISidebarService)),D(10,_.Inject(c.LocaleService))],ee);var ft=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,vt=(e,t,r,n)=>{for(var a=n>1?void 0:n?ht(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&ft(t,r,a),a},W=(e,t)=>(r,n)=>t(r,n,e);const pt=()=>{let e=[];return{add:(a,s,i,l,u)=>e.push({unitId:a,subUnitId:s,row:i,col:l,value:u}),getEffects:()=>e,clean:()=>{e=[]}}};let te=class extends c.Disposable{constructor(t,r,n,a,s){super();H(this,"_collectEffectMutation",pt());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=a,this._editorBridgeService=s,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const a=r.row,s=r.col,i=this._numfmtService.getValue(r.unitId,r.subUnitId,a,s);if(i)switch(K(i.pattern)){case"scientific":case"percent":case"currency":case"grouped":case"number":return r.worksheet.getCellRaw(a,s);case"date":case"time":case"datetime":default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(t,r,n)=>{var f;this._collectEffectMutation.clean();const a=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),s=(f=a&&K(a.pattern))!=null?f:"",i=()=>{a&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(t!=null&&t.v))return n(t);const l=String(t.v),u=P.parseDate(l)||P.parseTime(l);if(!!u){if(u&&u.z){const o=Number(u.v);return this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:u.z}),{...t,v:o,t:c.CellValueType.NUMBER}}}else(["date","time","datetime"].includes(s)||!gt(l))&&i();return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){switch(r.id){case v.SetRangeValuesCommand.id:{const n=t._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),a=n.getUnitId(),s=n.getActiveSheet().getSheetId(),i=t._collectEffectMutation.getEffects();if(!i.length)return{redos:[],undos:[]};const l=i.filter(o=>{var p;return!!((p=o.value)!=null&&p.pattern)}).map(o=>({row:o.row,col:o.col,pattern:o.value.pattern})),u=i.filter(o=>{var p;return!((p=o.value)!=null&&p.pattern)}).map(o=>({startRow:o.row,endColumn:o.col,startColumn:o.col,endRow:o.row})),m=[],f=[];if(l){const o={id:v.SetNumfmtMutation.id,params:v.transformCellsToRange(a,s,l)};m.push(o),f.push(...v.factorySetNumfmtUndoMutation(t._injector,o.params))}if(u){const o={id:v.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:s,ranges:u}};m.push(o),f.push(...v.factoryRemoveNumfmtUndoMutation(t._injector,o.params))}return{redos:m,undos:f.reverse()}}}return{redos:[],undos:[]}}}))}};te=vt([c.OnLifecycle(c.LifecycleStages.Rendered,te),W(0,_.Inject(v.SheetInterceptorService)),W(1,_.Inject(v.INumfmtService)),W(2,_.Inject(c.IUniverInstanceService)),W(3,_.Inject(_.Injector)),W(4,_.Inject(G.IEditorBridgeService))],te);function gt(e){return/^-?\d+(\.\d+)?$/.test(e)}var St=Object.defineProperty,yt=Object.getOwnPropertyDescriptor,Ct=(e,t,r,n)=>{for(var a=n>1?void 0:n?yt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&St(t,r,a),a},_t=(e,t)=>(r,n)=>t(r,n,e);let ne=class extends c.Disposable{constructor(t){super();H(this,"_initLocal",()=>{this._localeService.load({zhCN:ge,enUS:pe})});this._localeService=t,this._initLocal()}};ne=Ct([c.OnLifecycle(c.LifecycleStages.Rendered,ne),_t(0,_.Inject(c.LocaleService))],ne);var O=function(){return O=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},O.apply(this,arguments)},bt=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r},F=g.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,s=e.extend,i=bt(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),u=g.useRef("_".concat(Tt()));return Oe(r,"".concat(n),{defIds:r.defIds,idSuffix:u.current},O({ref:t,className:l},i),s)});function Oe(e,t,r,n,a){return g.createElement(e.tag,O(O({key:t},It(e,r,a)),n),(Mt(e,r).children||[]).map(function(s,i){return Oe(s,"".concat(t,"-").concat(e.tag,"-").concat(i),r,void 0,a)}))}function It(e,t,r){var n=O({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var a=t.defIds;return!a||a.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var i=s[0],l=s[1];typeof l=="string"&&(n[i]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Mt(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?O(O({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?O(O({},a),{attrs:O(O({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function Tt(){return Math.random().toString(36).substring(2,8)}F.displayName="UniverIcon";var Nt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.99988 3.60921C3.99988 2.32055 5.04456 1.27588 6.33321 1.27588 7.62187 1.27588 8.66654 2.32055 8.66654 3.60921V6.24136C8.66654 7.53002 7.62187 8.5747 6.33321 8.5747 5.04455 8.5747 3.99988 7.53002 3.99988 6.24136V3.60921zM6.33321 2.60921C5.78093 2.60921 5.33321 3.05693 5.33321 3.60921V6.24136C5.33321 6.79364 5.78093 7.24136 6.33321 7.24136 6.88549 7.24136 7.33321 6.79364 7.33321 6.24136V3.60921C7.33321 3.05693 6.88549 2.60921 6.33321 2.60921zM9.99988 3.60921C9.99988 2.32055 11.0446 1.27588 12.3332 1.27588 13.6219 1.27588 14.6665 2.32055 14.6665 3.60921V6.24136C14.6665 7.53002 13.6219 8.5747 12.3332 8.5747 11.0446 8.5747 9.99988 7.53002 9.99988 6.24136V3.60921zM12.3332 2.60921C11.7809 2.60921 11.3332 3.05693 11.3332 3.60921V6.24136C11.3332 6.79364 11.7809 7.24136 12.3332 7.24136 12.8855 7.24136 13.3332 6.79364 13.3332 6.24136V3.60921C13.3332 3.05693 12.8855 2.60921 12.3332 2.60921z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4713 9.58625C12.211 9.3259 11.7889 9.3259 11.5285 9.58625 11.2682 9.8466 11.2682 10.2687 11.5285 10.5291L12.3904 11.391H6.33329C5.9651 11.391 5.66663 11.6895 5.66663 12.0577 5.66663 12.4258 5.9651 12.7243 6.33329 12.7243H12.3904L11.5285 13.5862C11.2682 13.8466 11.2682 14.2687 11.5285 14.5291 11.7889 14.7894 12.211 14.7894 12.4713 14.5291L14.4669 12.5335C14.4851 12.5156 14.5022 12.4968 14.5183 12.477 14.5484 12.4399 14.5739 12.4003 14.5948 12.359 14.6407 12.2685 14.6666 12.1661 14.6666 12.0577 14.6666 11.9492 14.6407 11.8468 14.5948 11.7563 14.5739 11.715 14.5484 11.6754 14.5183 11.6383 14.5022 11.6185 14.4851 11.5997 14.4669 11.5818L12.4713 9.58625zM1.33325 7.98825C1.33325 7.62006 1.63173 7.32159 1.99992 7.32159H2.33325C2.70144 7.32159 2.99992 7.62006 2.99992 7.98825 2.99992 8.35644 2.70144 8.65492 2.33325 8.65492H1.99992C1.63173 8.65492 1.33325 8.35644 1.33325 7.98825z"}}]},xe=g.forwardRef(function(e,t){return g.createElement(F,Object.assign({},e,{id:"add-digits-single",ref:t,icon:Nt}))});xe.displayName="AddDigitsSingle";const jt=xe;var Rt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0.629584 3.99986C1.13729 3.4922 1.9604 3.49224 2.46806 3.99995L7.57569 9.10806C7.81 9.3424 8.18992 9.3424 8.42424 9.10808L13.5323 3.99998C14.04 3.4923 14.8631 3.4923 15.3708 3.99998C15.8785 4.50766 15.8785 5.33078 15.3708 5.83846L9.41415 11.7951C8.63307 12.5762 7.36669 12.5762 6.58565 11.7951L0.629497 5.83834C0.121839 5.33063 0.121879 4.50752 0.629584 3.99986Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},De=g.forwardRef(function(e,t){return g.createElement(F,Object.assign({},e,{id:"more-down-single",ref:t,icon:Rt}))});De.displayName="MoreDownSingle";const Ot=De;var xt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_561_2",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_561_2)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{d:"M4.91876 2.65039C3.66601 2.65039 2.65045 3.66595 2.65045 4.9187 2.65045 6.17146 3.66601 7.18702 4.91876 7.18702 6.17152 7.18702 7.18708 6.17146 7.18708 4.9187 7.18708 3.66595 6.17152 2.65039 4.91876 2.65039zM3.94663 4.9187C3.94663 4.38181 4.38187 3.94657 4.91876 3.94657 5.45566 3.94657 5.8909 4.38181 5.8909 4.9187 5.8909 5.4556 5.45566 5.89084 4.91876 5.89084 4.38187 5.89084 3.94663 5.4556 3.94663 4.9187zM11.0812 8.81299C9.82842 8.81299 8.81286 9.82855 8.81286 11.0813 8.81286 12.3341 9.82842 13.3496 11.0812 13.3496 12.3339 13.3496 13.3495 12.3341 13.3495 11.0813 13.3495 9.82855 12.3339 8.81299 11.0812 8.81299zM10.109 11.0813C10.109 10.5444 10.5443 10.1092 11.0812 10.1092 11.6181 10.1092 12.0533 10.5444 12.0533 11.0813 12.0533 11.6182 11.6181 12.0534 11.0812 12.0534 10.5443 12.0534 10.109 11.6182 10.109 11.0813zM13.1597 2.84021C13.4128 3.09331 13.4128 3.50365 13.1597 3.75675L3.7568 13.1596C3.5037 13.4127 3.09336 13.4127 2.84026 13.1596 2.58717 12.9065 2.58717 12.4962 2.84026 12.2431L12.2431 2.84021C12.4962 2.58712 12.9066 2.58712 13.1597 2.84021z"}}]}]},Pe=g.forwardRef(function(e,t){return g.createElement(F,Object.assign({},e,{id:"percent-single",ref:t,icon:xt}))});Pe.displayName="PercentSingle";const Dt=Pe;var Pt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5 3.61825C5 2.32958 6.04468 1.28491 7.33333 1.28491C8.62199 1.28491 9.66667 2.32958 9.66667 3.61825V6.30787C9.66667 7.59653 8.62199 8.64121 7.33333 8.64121C6.04468 8.64121 5 7.59653 5 6.30787V3.61825ZM7.33333 2.61825C6.78105 2.61825 6.33333 3.06596 6.33333 3.61825V6.30787C6.33333 6.86015 6.78106 7.30787 7.33333 7.30787C7.88561 7.30787 8.33333 6.86015 8.33333 6.30787V3.61825C8.33333 3.06596 7.88561 2.61825 7.33333 2.61825Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2 7.9745C2 7.60631 2.29848 7.30783 2.66667 7.30783H3C3.36819 7.30783 3.66667 7.60631 3.66667 7.9745 3.66667 8.34269 3.36819 8.64117 3 8.64117H2.66667C2.29848 8.64117 2 8.34269 2 7.9745zM8.80482 9.56197C9.06517 9.82232 9.06517 10.2444 8.80482 10.5048L7.94289 11.3667H13.3334C13.7016 11.3667 14.0001 11.6652 14.0001 12.0334 14.0001 12.4016 13.7016 12.7 13.3334 12.7H7.94289L8.80482 13.562C9.06517 13.8223 9.06517 14.2444 8.80482 14.5048 8.54447 14.7651 8.12236 14.7651 7.86201 14.5048L5.86201 12.5048C5.79809 12.4409 5.74987 12.3672 5.71733 12.2886 5.68474 12.21 5.66675 12.1238 5.66675 12.0334 5.66675 11.943 5.68474 11.8568 5.71733 11.7782 5.74987 11.6996 5.79809 11.6259 5.86201 11.562L7.86201 9.56197C8.12236 9.30162 8.54447 9.30162 8.80482 9.56197z"}}]},Ee=g.forwardRef(function(e,t){return g.createElement(F,Object.assign({},e,{id:"reduce-digits-single",ref:t,icon:Pt}))});Ee.displayName="ReduceDigitsSingle";const Et=Ee;var wt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.05443 1.55744C4.34898 1.33653 4.76685 1.39623 4.98776 1.69078L7.99996 5.98276L11.0122 1.69078C11.2331 1.39623 11.6509 1.33653 11.9455 1.55744C12.24 1.77836 12.2997 2.19623 12.0788 2.49078L9.33338 6.42708H12.0788C12.447 6.42708 12.7455 6.72556 12.7455 7.09375C12.7455 7.46194 12.447 7.76042 12.0788 7.76042H8.66659V9.69702H12.3348C12.703 9.69702 13.0015 9.9955 13.0015 10.3637C13.0015 10.7319 12.703 11.0304 12.3348 11.0304H8.66659V13.9091C8.66659 14.2773 8.36811 14.5758 7.99992 14.5758C7.63173 14.5758 7.33325 14.2773 7.33325 13.9091V11.0304H3.66508C3.29689 11.0304 2.99841 10.7319 2.99841 10.3637C2.99841 9.9955 3.29689 9.69702 3.66508 9.69702H7.33325V7.76042H3.92109C3.5529 7.76042 3.25443 7.46194 3.25443 7.09375C3.25443 6.72556 3.5529 6.42708 3.92109 6.42708H6.66653L3.92109 2.49078C3.70018 2.19623 3.75987 1.77836 4.05443 1.55744Z"}}]},we=g.forwardRef(function(e,t){return g.createElement(F,Object.assign({},e,{id:"rmb-single",ref:t,icon:wt}))});we.displayName="RmbSingle";const Ut=we,re=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:"@@@"},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Lt=e=>{var n;const t=R.useDependency(c.LocaleService),r=(n=e.value)!=null?n:t.t("sheet.numfmt.general");return d.jsx("span",{className:"more-numfmt-type",children:r})},Vt=()=>{const e=R.useDependency(c.ICommandService),t=R.useDependency(c.LocaleService),r=R.useInjector(),n=R.useDependency(v.SelectionManagerService),a=l=>{const u=n.getLast();if(!u)return;const m=r.get(ve.ITextSelectionRenderManager),f=u.range,o=[];c.Range.foreach(f,(p,b)=>{l?o.push({row:p,col:b,pattern:l,type:K(l)}):o.push({row:p,col:b})}),e.executeCommand(L.id,{values:o}),m.focus()},s=l=>{if(l===0)a(null);else if(l===re.length-1)e.executeCommand(Q.id);else{const u=re[l];u.pattern&&a(u.pattern)}},i=1220;return d.jsx("div",{className:"more-numfmt-type-options",children:re.map((l,u)=>l==="|"?d.jsx("div",{className:"line m-t-4",onClick:m=>m.stopPropagation()},u):d.jsxs("div",{className:"option-item m-t-4",onClick:()=>{s(u)},children:[d.jsx("div",{children:t.t(l.label)}),d.jsx("div",{className:"m-l-26",children:l.pattern?Z(l.pattern||"",i,t.getCurrentLocale()).result:""})]},u))})},At=e=>{const t="icon-rmbSingle";return e.register(t,Ut),e.register("MoreDownSingle",Ot),r=>({icon:t,id:_e.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(r)})},Ht=e=>{const t="icon-addDigitsSingle";return e.register(t,jt),r=>({icon:t,id:ye.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:M.MenuItemType.BUTTON,positions:[M.MenuPosition.TOOLBAR_START],group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(r)})},kt=e=>{const t="icon-reduceDigitsSingle";return e.register(t,Et),r=>({icon:t,id:be.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(r)})},Bt=e=>{const t="icon-PercentSingle";return e.register(t,Dt),r=>({icon:t,id:Re.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(r)})},Ft=e=>{const t="sheet.numfmt.moreNumfmtType",r="sheet.numfmt.moreNumfmtType.options";return e.register(t,Lt),e.register(r,Vt),n=>{const a=n.get(v.INumfmtService),s=n.get(c.IUniverInstanceService),i=n.get(c.ICommandService),l=n.get(c.LocaleService),u=n.get(v.SelectionManagerService),m=G.deriveStateFromActiveSheet$(s,"",({workbook:f,worksheet:o})=>new U.Observable(p=>U.merge(u.selectionMoveEnd$,new U.Observable(b=>{const y=[v.RemoveNumfmtMutation.id,v.SetNumfmtMutation.id],h=i.onCommandExecuted(S=>{y.includes(S.id)&&b.next(null)});return()=>h.dispose()})).subscribe(()=>{const b=u.getSelections();if(b&&b[0]){const y=b[0].range,h=y.startRow,S=y.startColumn,C=a.getValue(f.getUnitId(),o.getSheetId(),h,S),T=C==null?void 0:C.pattern;let E=l.t("sheet.numfmt.general");if(T){const w=re.filter(A=>typeof A=="object"&&A.pattern).find(A=>J(T,A.pattern));w&&typeof w=="object"&&w.pattern?E=l.t(w.label):E=l.t("sheet.numfmt.moreFmt")}p.next(E)}})));return{label:t,id:Q.id,tooltip:"sheet.numfmt.title",type:M.MenuItemType.SELECTOR,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],selections:[{label:{name:r,hoverable:!1}}],value$:m,hidden$:M.getMenuHiddenObservable(n,c.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(n)}}};var zt=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Wt=(e,t,r,n)=>{for(var a=n>1?void 0:n?$t(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&zt(t,r,a),a},de=(e,t)=>(r,n)=>t(r,n,e);let ae=class extends c.Disposable{constructor(e,t,r){super(),this._injector=e,this._componentManager=t,this._menuService=r,this._initMenu()}_initMenu(){[Bt,Ht,kt,At,Ft].map(e=>e(this._componentManager)).forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(e(this._injector)))})}};ae=Wt([c.OnLifecycle(c.LifecycleStages.Rendered,ae),de(0,_.Inject(_.Injector)),de(1,_.Inject(M.ComponentManager)),de(2,_.Inject(M.IMenuService))],ae);var Gt=Object.defineProperty,Kt=Object.getOwnPropertyDescriptor,Zt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Kt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Gt(t,r,a),a},Yt=(e,t)=>(r,n)=>t(r,n,e);I.UniverSheetsNumfmtPlugin=(se=class extends c.Plugin{constructor(t,r){super(),this._injector=r}onStarting(){this._injector.add([oe,{useClass:ee,lazy:!1}]),this._injector.add([te]),this._injector.add([q]),this._injector.add([Y]),this._injector.add([ne]),this._injector.add([ae])}},H(se,"pluginName",ie),H(se,"type",c.UniverInstanceType.UNIVER_SHEET),se),I.UniverSheetsNumfmtPlugin=Zt([Yt(1,_.Inject(_.Injector))],I.UniverSheetsNumfmtPlugin),I.SetNumfmtCommand=L,I.enUS=pe,I.getPatternPreview=Z,I.zhCN=ge,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var Be=g,ze=Symbol.for("react.element"),$e=Symbol.for("react.fragment"),We=Object.prototype.hasOwnProperty,Ge=Be.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ke={key:!0,ref:!0,__self:!0,__source:!0};function Me(e,t,r){var n,a={},s=null,c=null;r!==void 0&&(s=""+r),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(c=t.ref);for(n in t)We.call(t,n)&&!Ke.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)a[n]===void 0&&(a[n]=t[n]);return{$$typeof:ze,type:e,key:s,ref:c,props:a,_owner:Ge.current}}X.Fragment=$e,X.jsx=Me,X.jsxs=Me,Ie.exports=X;var d=Ie.exports;const le=g.createContext([]),ue=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"];var Ze=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Je=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ye(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(a=(n?c(t,r,a):c(a))||a);return n&&a&&Ze(t,r,a),a},Qe=(e,t)=>(r,n)=>t(r,n,e);let q=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const r=this._getKey(e);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,t)})}markHabit(e,t){const r=this._getKey(e);this._localStorageService.getItem(r).then(n=>{if(n){const a=n.findIndex(s=>s===t);a>-1&&n.splice(a,1),n.unshift(t),this._localStorageService.setItem(r,n)}})}async getHabit(e,t){const r=this._getKey(e),n=await this._localStorageService.getItem(r);if(t&&n){const a=n.map((s,c,l)=>{const u=l.length;return{value:s,priority:u-c}});return t.sort((s,c)=>{var m,f;const l=((m=a.find(o=>o.value===s))==null?void 0:m.priority)||-1;return(((f=a.find(o=>o.value===c))==null?void 0:f.priority)||-1)-l})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};q=Je([Qe(0,I.Inject(i.ILocalStorageService))],q);const Te="numfmtCurrency",Xe=e=>{const t=j.useDependency(q),[r,n]=g.useState(ue);return g.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(Te,[...ue]).then(s=>{n(s),e&&e(s)})})},[]),{userHabitCurrency:r,mark:s=>{t.markHabit(Te,s)}}},qe=()=>{const e=g.useRef([]),[t,r]=g.useState({});return g.useEffect(()=>{e.current.forEach(a=>{a()}),e.current=[]},[t]),a=>{e.current.push(a),r({})}},$=e=>ue.find(r=>e.includes(r)),et=e=>!!$(e)&&e.startsWith("_("),tt=e=>{const[t,r]=g.useState(()=>V(e.defaultPattern||"",2)),n=g.useContext(le),[a,s]=g.useState(()=>$(e.defaultPattern)||n[0]),c=g.useMemo(()=>n.map(o=>({label:o,value:o})),[]),u=j.useDependency(i.LocaleService).t;e.action.current=()=>R(`_("${a}"* #,##0${t>0?".0":""}_)`,t);const m=o=>{s(o),e.onChange(R(`_("${o}"* #,##0${t>0?".0":""}_)`,t))},f=o=>{const p=o||0;r(p),e.onChange(R(`_("${a}"* #,##0${p>0?".0":""}_)`,p))};return d.jsxs("div",{children:[d.jsxs("div",{className:"m-t-16 options ",children:[d.jsxs("div",{className:"option",children:[d.jsx("div",{className:"label",children:u("sheet.numfmt.decimalLength")}),d.jsx("div",{className:"m-t-8 w-120",children:d.jsx(O.InputNumber,{value:t,max:20,min:0,onChange:f})})]}),d.jsxs("div",{className:"option",children:[d.jsx("div",{className:"label",children:u("sheet.numfmt.currencyType")}),d.jsx("div",{className:"m-t-8 w-140",children:d.jsx(O.Select,{onChange:m,options:c,value:a})})]})]}),d.jsx("div",{className:"describe m-t-14",children:u("sheet.numfmt.accountingDes")})]})},me=e=>Ce.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),Ne=()=>ke.map(e=>({label:e.label,value:e.suffix})),Re=()=>Fe.map(e=>({label:e.label,value:e.suffix,color:e.color})),nt=e=>!!$(e)&&!e.startsWith("_("),rt=e=>{const r=j.useDependency(i.LocaleService).t,n=g.useContext(le),[a,s]=g.useState(()=>$(e.defaultPattern)||n[0]),[c,l]=g.useState(()=>V(e.defaultPattern||"",2)),[u,m]=g.useState(()=>{var C;const h=me(a);return((C=h.find(T=>J(T.value,e.defaultPattern)))==null?void 0:C.value)||h[0].value}),f=g.useMemo(()=>me(a),[a]),o=g.useMemo(()=>n.map(h=>({label:h,value:h})),[n]);e.action.current=()=>R(u,c);const p=h=>{s(h);const S=me(h)[0].value;m(S),e.onChange(R(S,c))},b=h=>{m(h),e.onChange(R(h,c))},y=h=>{l(h||0),e.onChange(R(u,h||0))};return d.jsxs("div",{children:[d.jsxs("div",{className:"m-t-16 options ",children:[d.jsxs("div",{className:"option",children:[d.jsx("div",{className:"label",children:r("sheet.numfmt.decimalLength")}),d.jsx("div",{className:"m-t-8 w-120",children:d.jsx(O.InputNumber,{value:c,max:20,min:0,onChange:y})})]}),d.jsxs("div",{className:"option",children:[d.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),d.jsx("div",{className:"m-t-8 w-140",children:d.jsx(O.Select,{onChange:p,options:o,value:a})})]})]}),d.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),d.jsx("div",{className:"m-t-8",children:d.jsx(O.SelectList,{onChange:b,options:f,value:u})}),d.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})},at=e=>{const t=x.getInfo(e);return Ne().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)},st=e=>{const t=g.useMemo(Ne,[]),n=j.useDependency(i.LocaleService).t,[a,s]=g.useState(()=>{if(e.defaultPattern){const l=t.find(u=>u.value===e.defaultPattern);if(l)return l.value}return t[0].value});e.action.current=()=>a;const c=l=>{s(l),e.onChange(l)};return d.jsxs("div",{children:[d.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.dateType")}),d.jsx("div",{className:"m-t-8",children:d.jsx(O.SelectList,{value:a,options:t,onChange:c})}),d.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},it=e=>!e,ct=e=>{const r=j.useDependency(i.LocaleService).t;return e.action.current=()=>"",d.jsx("div",{children:d.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},ot=e=>Re().some(t=>J(t.value,e)),lt=e=>{const t=j.useDependency(i.LocaleService),r=g.useMemo(Re,[]),[n,a]=g.useState(()=>V(e.defaultPattern||"",0)),[s,c]=g.useState(()=>{const o=r.find(p=>J(p.value,e.defaultPattern||""));return(o==null?void 0:o.value)||r[0].value}),l=g.useMemo(()=>R(s,Number(n||0)),[s,n]),u=g.useMemo(()=>!Ae(s),[s]),m=o=>{a(o||0),e.onChange(R(s,Number(o||0)))},f=o=>{a(V(o,0)),c(o),e.onChange(o)};return e.action.current=()=>l,d.jsxs("div",{children:[d.jsx("div",{className:"m-t-16 label",children:t.t("sheet.numfmt.decimalLength")}),d.jsx("div",{className:"m-t-8",children:d.jsx(O.InputNumber,{disabled:u,value:n,max:20,min:0,onChange:m})}),d.jsxs("div",{className:"m-t-16 label",children:[" ",t.t("sheet.numfmt.negType")]}),d.jsx("div",{className:"m-t-8",children:d.jsx(O.SelectList,{onChange:f,options:r,value:s})}),d.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},ut=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:a}=e.value,s=j.useDependency(i.LocaleService),c=g.useRef(()=>""),l=s.t,u=qe(),m=g.useMemo(()=>[{label:"sheet.numfmt.general",component:ct},{label:"sheet.numfmt.accounting",component:tt},{label:"sheet.numfmt.currency",component:rt},{label:"sheet.numfmt.date",component:st},{label:"sheet.numfmt.thousandthPercentile",component:lt}].map(N=>({...N,label:l(N.label)})),[]),[f,o]=g.useState(C),[p,b]=g.useState(()=>`${n}_${a}`),{mark:y,userHabitCurrency:h}=Xe(()=>b(`${n}_${a}_userCurrency'`)),S=g.useMemo(()=>{var N;return(N=m.find(z=>z.label===f))==null?void 0:N.component},[f]);function C(){return[it,et,nt,at,ot].reduce((z,Qt,Xt)=>z||(Qt(r)?m[Xt].label:""),"")||m[0].label}const T=m.map(N=>({label:N.label,value:N.label})),E=N=>{o(N),u(()=>e.onChange({type:"change",value:c.current()||""}))},w=N=>{e.onChange({type:"change",value:N})},H=()=>{const N=c.current()||"",z=$(N);z&&y(z),e.onChange({type:"confirm",value:N})},fe=()=>{e.onChange({type:"cancel",value:""})},he={onChange:w,defaultValue:t,defaultPattern:r,action:c};return g.useEffect(()=>{o(C()),b(`${n}_${a}`)},[n,a]),d.jsxs("div",{className:"numfmt-panel p-b-20",children:[d.jsxs("div",{children:[d.jsx("div",{className:"label m-t-14",children:l("sheet.numfmt.numfmtType")}),d.jsx("div",{className:"m-t-8",children:d.jsx(O.Select,{onChange:E,options:T,value:f})}),d.jsx("div",{children:S&&d.jsx(le.Provider,{value:h,children:g.createElement(S,{...he,key:p})})})]}),d.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[d.jsx(O.Button,{size:"small",onClick:fe,className:"m-r-12",children:l("sheet.numfmt.cancel")}),d.jsx(O.Button,{type:"primary",size:"small",onClick:H,children:l("sheet.numfmt.confirm")})]})]})},je={id:"sheet.command.numfmt.set.percent",type:i.CommandType.COMMAND,handler:async e=>{const t=e.get(i.ICommandService),n=e.get(v.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const a=[],s="0%";return n.forEach(l=>{i.Range.foreach(l.range,(u,m)=>{a.push({row:u,col:m,pattern:s,type:"percent"})})}),await t.executeCommand(L.id,{values:a})}};var mt=Object.defineProperty,dt=Object.getOwnPropertyDescriptor,ft=(e,t,r,n)=>{for(var a=n>1?void 0:n?dt(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(a=(n?c(t,r,a):c(a))||a);return n&&a&&mt(t,r,a),a},P=(e,t)=>(r,n)=>t(r,n,e);let ee=class extends i.Disposable{constructor(t,r,n,a,s,c,l,u,m,f,o){super();A(this,"_previewPattern","");A(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._sheetSkeletonManagerService=a,this._commandService=s,this._selectionManagerService=c,this._renderManagerService=l,this._numfmtService=u,this._componentManager=m,this._sidebarService=f,this._localeService=o,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener()}openPanel(){const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,a=this._univerInstanceService,s=this._numfmtService,c=this._localeService,u=(r.getSelectionRanges()||[])[0];if(!u)return!1;const m=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),f=m.getActiveSheet(),o=f.getCellRaw(u.startRow,u.startColumn),p=s.getValue(m.getUnitId(),f.getSheetId(),u.startRow,u.startColumn);let b="";p&&(b=p.pattern);const y=(o==null?void 0:o.t)===i.CellValueType.NUMBER?o.v:12345678,h={onChange:S=>{var C,T;if(S.type==="change")this._previewPattern=S.value,this._sheetSkeletonManagerService.reCalculate(),(T=(C=this._renderManagerService.getRenderById(m.getUnitId()))==null?void 0:C.mainComponent)==null||T.makeDirty();else if(S.type==="confirm"){const E=r.getSelectionRanges()||[],w={values:[]},H=K(S.value);E.forEach(fe=>{i.Range.foreach(fe,(he,N)=>{w.values.push({row:he,col:N,pattern:S.value,type:H})})}),n.executeCommand(L.id,w),t.close()}else S.type==="cancel"&&t.close()},value:{defaultPattern:b,defaultValue:y,row:u.startRow,col:u.startColumn}};return this._sidebarDisposable=t.open({header:{title:c.t("sheet.numfmt.title")},children:{label:ie,...h},onClose:()=>{var S,C;this._sheetSkeletonManagerService.reCalculate(),(C=(S=this._renderManagerService.getRenderById(m.getUnitId()))==null?void 0:S.mainComponent)==null||C.makeDirty(),n.executeCommand(ce.id)}}),!0}_initCommands(){[ye,be,_e,je,Q,ce,L].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(ie,ut)}_initRealTimeRenderingInterceptor(){const t=new U.Observable(n=>{this._commandService.onCommandExecuted(a=>{a.id===Q.id&&n.next(!0),a.id===ce.id&&n.next(!1)})}),r=U.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(k.map(n=>n?n.map(a=>a.range):[]))]);this.disposeWithMe(i.toDisposable(r.pipe(k.switchMap(([n,a])=>new U.Observable(s=>{const c=new i.DisposableCollection;return n&&a.length&&s.next({selectionRanges:a,disposableCollection:c}),()=>{c.dispose()}})),k.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:a})=>{var c,l;const s=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,handler:(u,m,f)=>{const{row:o,col:p}=m,b=f(u)||{};if(a.find(y=>y.startColumn<=p&&y.endColumn>=p&&y.startRow<=o&&y.endRow>=o)){const y=m.worksheet.getCellRaw(o,p),h=y==null?void 0:y.v,S=y==null?void 0:y.t;if(h==null||S!==i.CellValueType.NUMBER||this._previewPattern===null)return b;const C=Z(this._previewPattern,h,this._localeService.getCurrentLocale());if(C.color){const E=this._themeService.getCurrentTheme()[`${C.color}500`];return{...b,v:C.result,t:i.CellValueType.STRING,s:{cl:{rgb:E}}}}return{...b,v:C.result,t:i.CellValueType.STRING}}return b}})),(l=(c=this._renderManagerService.getRenderById(s.getUnitId()))==null?void 0:c.mainComponent)==null||l.makeDirty()})))}_commandExecutedListener(){const t=[v.RemoveNumfmtMutation.id,v.SetNumfmtMutation.id];this.disposeWithMe(i.toDisposable(U.merge(new U.Observable(r=>{const n=this._commandService.onCommandExecuted(a=>{if(t.includes(a.id)){const s=a.params;r.next(s.unitId)}});return()=>{n.dispose()}})).pipe(k.debounceTime(16)).subscribe(r=>{var n,a;this._sheetSkeletonManagerService.reCalculate(),(a=(n=this._renderManagerService.getRenderById(r))==null?void 0:n.mainComponent)==null||a.makeDirty()})))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};ee=ft([i.OnLifecycle(i.LifecycleStages.Rendered,ee),P(0,I.Inject(v.SheetInterceptorService)),P(1,I.Inject(i.ThemeService)),P(2,i.IUniverInstanceService),P(3,I.Inject(G.SheetSkeletonManagerService)),P(4,i.ICommandService),P(5,I.Inject(v.SelectionManagerService)),P(6,ve.IRenderManagerService),P(7,v.INumfmtService),P(8,I.Inject(M.ComponentManager)),P(9,M.ISidebarService),P(10,I.Inject(i.LocaleService))],ee);var ht=Object.defineProperty,vt=Object.getOwnPropertyDescriptor,pt=(e,t,r,n)=>{for(var a=n>1?void 0:n?vt(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(a=(n?c(t,r,a):c(a))||a);return n&&a&&ht(t,r,a),a},W=(e,t)=>(r,n)=>t(r,n,e);const gt=()=>{let e=[];return{add:(a,s,c,l,u)=>e.push({unitId:a,subUnitId:s,row:c,col:l,value:u}),getEffects:()=>e,clean:()=>{e=[]}}};let te=class extends i.Disposable{constructor(t,r,n,a,s){super();A(this,"_collectEffectMutation",gt());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=a,this._editorBridgeService=s,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this.disposeWithMe(i.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const a=r.row,s=r.col,c=this._numfmtService.getValue(r.unitId,r.subUnitId,a,s);if(c)switch(K(c.pattern)){case"scientific":case"percent":case"currency":case"grouped":case"number":return r.worksheet.getCellRaw(a,s);case"date":case"time":case"datetime":default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(i.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(t,r,n)=>{var f;this._collectEffectMutation.clean();const a=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),s=(f=a&&K(a.pattern))!=null?f:"",c=()=>{a&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(t!=null&&t.v))return n(t);const l=String(t.v),u=x.parseDate(l)||x.parseTime(l);if(!!u){if(u&&u.z){const o=Number(u.v);return this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:u.z}),{...t,v:o,t:i.CellValueType.NUMBER}}}else(["date","time","datetime"].includes(s)||!St(l))&&c();return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){switch(r.id){case v.SetRangeValuesCommand.id:{const n=t._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),a=n.getUnitId(),s=n.getActiveSheet().getSheetId(),c=t._collectEffectMutation.getEffects();if(!c.length)return{redos:[],undos:[]};const l=c.filter(o=>{var p;return!!((p=o.value)!=null&&p.pattern)}).map(o=>({row:o.row,col:o.col,pattern:o.value.pattern})),u=c.filter(o=>{var p;return!((p=o.value)!=null&&p.pattern)}).map(o=>({startRow:o.row,endColumn:o.col,startColumn:o.col,endRow:o.row})),m=[],f=[];if(l){const o={id:v.SetNumfmtMutation.id,params:v.transformCellsToRange(a,s,l)};m.push(o),f.push(...v.factorySetNumfmtUndoMutation(t._injector,o.params))}if(u){const o={id:v.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:s,ranges:u}};m.push(o),f.push(...v.factoryRemoveNumfmtUndoMutation(t._injector,o.params))}return{redos:m,undos:f.reverse()}}}return{redos:[],undos:[]}}}))}};te=pt([i.OnLifecycle(i.LifecycleStages.Rendered,te),W(0,I.Inject(v.SheetInterceptorService)),W(1,I.Inject(v.INumfmtService)),W(2,I.Inject(i.IUniverInstanceService)),W(3,I.Inject(I.Injector)),W(4,I.Inject(G.IEditorBridgeService))],te);function St(e){return/^-?\d+(\.\d+)?$/.test(e)}var yt=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,_t=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ct(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(a=(n?c(t,r,a):c(a))||a);return n&&a&&yt(t,r,a),a},bt=(e,t)=>(r,n)=>t(r,n,e);let ne=class extends i.Disposable{constructor(t){super();A(this,"_initLocal",()=>{this._localeService.load({zhCN:ge,enUS:pe})});this._localeService=t,this._initLocal()}};ne=_t([i.OnLifecycle(i.LifecycleStages.Rendered,ne),bt(0,I.Inject(i.LocaleService))],ne);var D=function(){return D=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},D.apply(this,arguments)},It=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r},B=g.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,s=e.extend,c=It(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),u=g.useRef("_".concat(Nt()));return De(r,"".concat(n),{defIds:r.defIds,idSuffix:u.current},D({ref:t,className:l},c),s)});function De(e,t,r,n,a){return g.createElement(e.tag,D(D({key:t},Mt(e,r,a)),n),(Tt(e,r).children||[]).map(function(s,c){return De(s,"".concat(t,"-").concat(e.tag,"-").concat(c),r,void 0,a)}))}function Mt(e,t,r){var n=D({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var a=t.defIds;return!a||a.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var c=s[0],l=s[1];typeof l=="string"&&(n[c]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Tt(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?D(D({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?D(D({},a),{attrs:D(D({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function Nt(){return Math.random().toString(36).substring(2,8)}B.displayName="UniverIcon";var Rt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.99988 3.60921C3.99988 2.32055 5.04456 1.27588 6.33321 1.27588 7.62187 1.27588 8.66654 2.32055 8.66654 3.60921V6.24136C8.66654 7.53002 7.62187 8.5747 6.33321 8.5747 5.04455 8.5747 3.99988 7.53002 3.99988 6.24136V3.60921zM6.33321 2.60921C5.78093 2.60921 5.33321 3.05693 5.33321 3.60921V6.24136C5.33321 6.79364 5.78093 7.24136 6.33321 7.24136 6.88549 7.24136 7.33321 6.79364 7.33321 6.24136V3.60921C7.33321 3.05693 6.88549 2.60921 6.33321 2.60921zM9.99988 3.60921C9.99988 2.32055 11.0446 1.27588 12.3332 1.27588 13.6219 1.27588 14.6665 2.32055 14.6665 3.60921V6.24136C14.6665 7.53002 13.6219 8.5747 12.3332 8.5747 11.0446 8.5747 9.99988 7.53002 9.99988 6.24136V3.60921zM12.3332 2.60921C11.7809 2.60921 11.3332 3.05693 11.3332 3.60921V6.24136C11.3332 6.79364 11.7809 7.24136 12.3332 7.24136 12.8855 7.24136 13.3332 6.79364 13.3332 6.24136V3.60921C13.3332 3.05693 12.8855 2.60921 12.3332 2.60921z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4713 9.58625C12.211 9.3259 11.7889 9.3259 11.5285 9.58625 11.2682 9.8466 11.2682 10.2687 11.5285 10.5291L12.3904 11.391H6.33329C5.9651 11.391 5.66663 11.6895 5.66663 12.0577 5.66663 12.4258 5.9651 12.7243 6.33329 12.7243H12.3904L11.5285 13.5862C11.2682 13.8466 11.2682 14.2687 11.5285 14.5291 11.7889 14.7894 12.211 14.7894 12.4713 14.5291L14.4669 12.5335C14.4851 12.5156 14.5022 12.4968 14.5183 12.477 14.5484 12.4399 14.5739 12.4003 14.5948 12.359 14.6407 12.2685 14.6666 12.1661 14.6666 12.0577 14.6666 11.9492 14.6407 11.8468 14.5948 11.7563 14.5739 11.715 14.5484 11.6754 14.5183 11.6383 14.5022 11.6185 14.4851 11.5997 14.4669 11.5818L12.4713 9.58625zM1.33325 7.98825C1.33325 7.62006 1.63173 7.32159 1.99992 7.32159H2.33325C2.70144 7.32159 2.99992 7.62006 2.99992 7.98825 2.99992 8.35644 2.70144 8.65492 2.33325 8.65492H1.99992C1.63173 8.65492 1.33325 8.35644 1.33325 7.98825z"}}]},Oe=g.forwardRef(function(e,t){return g.createElement(B,Object.assign({},e,{id:"add-digits-single",ref:t,icon:Rt}))});Oe.displayName="AddDigitsSingle";const jt=Oe;var Dt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0.629584 3.99986C1.13729 3.4922 1.9604 3.49224 2.46806 3.99995L7.57569 9.10806C7.81 9.3424 8.18992 9.3424 8.42424 9.10808L13.5323 3.99998C14.04 3.4923 14.8631 3.4923 15.3708 3.99998C15.8785 4.50766 15.8785 5.33078 15.3708 5.83846L9.41415 11.7951C8.63307 12.5762 7.36669 12.5762 6.58565 11.7951L0.629497 5.83834C0.121839 5.33063 0.121879 4.50752 0.629584 3.99986Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},Pe=g.forwardRef(function(e,t){return g.createElement(B,Object.assign({},e,{id:"more-down-single",ref:t,icon:Dt}))});Pe.displayName="MoreDownSingle";const Ot=Pe;var Pt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_561_2",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_561_2)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{d:"M4.91876 2.65039C3.66601 2.65039 2.65045 3.66595 2.65045 4.9187 2.65045 6.17146 3.66601 7.18702 4.91876 7.18702 6.17152 7.18702 7.18708 6.17146 7.18708 4.9187 7.18708 3.66595 6.17152 2.65039 4.91876 2.65039zM3.94663 4.9187C3.94663 4.38181 4.38187 3.94657 4.91876 3.94657 5.45566 3.94657 5.8909 4.38181 5.8909 4.9187 5.8909 5.4556 5.45566 5.89084 4.91876 5.89084 4.38187 5.89084 3.94663 5.4556 3.94663 4.9187zM11.0812 8.81299C9.82842 8.81299 8.81286 9.82855 8.81286 11.0813 8.81286 12.3341 9.82842 13.3496 11.0812 13.3496 12.3339 13.3496 13.3495 12.3341 13.3495 11.0813 13.3495 9.82855 12.3339 8.81299 11.0812 8.81299zM10.109 11.0813C10.109 10.5444 10.5443 10.1092 11.0812 10.1092 11.6181 10.1092 12.0533 10.5444 12.0533 11.0813 12.0533 11.6182 11.6181 12.0534 11.0812 12.0534 10.5443 12.0534 10.109 11.6182 10.109 11.0813zM13.1597 2.84021C13.4128 3.09331 13.4128 3.50365 13.1597 3.75675L3.7568 13.1596C3.5037 13.4127 3.09336 13.4127 2.84026 13.1596 2.58717 12.9065 2.58717 12.4962 2.84026 12.2431L12.2431 2.84021C12.4962 2.58712 12.9066 2.58712 13.1597 2.84021z"}}]}]},xe=g.forwardRef(function(e,t){return g.createElement(B,Object.assign({},e,{id:"percent-single",ref:t,icon:Pt}))});xe.displayName="PercentSingle";const xt=xe;var Et={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5 3.61825C5 2.32958 6.04468 1.28491 7.33333 1.28491C8.62199 1.28491 9.66667 2.32958 9.66667 3.61825V6.30787C9.66667 7.59653 8.62199 8.64121 7.33333 8.64121C6.04468 8.64121 5 7.59653 5 6.30787V3.61825ZM7.33333 2.61825C6.78105 2.61825 6.33333 3.06596 6.33333 3.61825V6.30787C6.33333 6.86015 6.78106 7.30787 7.33333 7.30787C7.88561 7.30787 8.33333 6.86015 8.33333 6.30787V3.61825C8.33333 3.06596 7.88561 2.61825 7.33333 2.61825Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2 7.9745C2 7.60631 2.29848 7.30783 2.66667 7.30783H3C3.36819 7.30783 3.66667 7.60631 3.66667 7.9745 3.66667 8.34269 3.36819 8.64117 3 8.64117H2.66667C2.29848 8.64117 2 8.34269 2 7.9745zM8.80482 9.56197C9.06517 9.82232 9.06517 10.2444 8.80482 10.5048L7.94289 11.3667H13.3334C13.7016 11.3667 14.0001 11.6652 14.0001 12.0334 14.0001 12.4016 13.7016 12.7 13.3334 12.7H7.94289L8.80482 13.562C9.06517 13.8223 9.06517 14.2444 8.80482 14.5048 8.54447 14.7651 8.12236 14.7651 7.86201 14.5048L5.86201 12.5048C5.79809 12.4409 5.74987 12.3672 5.71733 12.2886 5.68474 12.21 5.66675 12.1238 5.66675 12.0334 5.66675 11.943 5.68474 11.8568 5.71733 11.7782 5.74987 11.6996 5.79809 11.6259 5.86201 11.562L7.86201 9.56197C8.12236 9.30162 8.54447 9.30162 8.80482 9.56197z"}}]},Ee=g.forwardRef(function(e,t){return g.createElement(B,Object.assign({},e,{id:"reduce-digits-single",ref:t,icon:Et}))});Ee.displayName="ReduceDigitsSingle";const wt=Ee;var Ut={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.05443 1.55744C4.34898 1.33653 4.76685 1.39623 4.98776 1.69078L7.99996 5.98276L11.0122 1.69078C11.2331 1.39623 11.6509 1.33653 11.9455 1.55744C12.24 1.77836 12.2997 2.19623 12.0788 2.49078L9.33338 6.42708H12.0788C12.447 6.42708 12.7455 6.72556 12.7455 7.09375C12.7455 7.46194 12.447 7.76042 12.0788 7.76042H8.66659V9.69702H12.3348C12.703 9.69702 13.0015 9.9955 13.0015 10.3637C13.0015 10.7319 12.703 11.0304 12.3348 11.0304H8.66659V13.9091C8.66659 14.2773 8.36811 14.5758 7.99992 14.5758C7.63173 14.5758 7.33325 14.2773 7.33325 13.9091V11.0304H3.66508C3.29689 11.0304 2.99841 10.7319 2.99841 10.3637C2.99841 9.9955 3.29689 9.69702 3.66508 9.69702H7.33325V7.76042H3.92109C3.5529 7.76042 3.25443 7.46194 3.25443 7.09375C3.25443 6.72556 3.5529 6.42708 3.92109 6.42708H6.66653L3.92109 2.49078C3.70018 2.19623 3.75987 1.77836 4.05443 1.55744Z"}}]},we=g.forwardRef(function(e,t){return g.createElement(B,Object.assign({},e,{id:"rmb-single",ref:t,icon:Ut}))});we.displayName="RmbSingle";const Lt=we,re=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:"@@@"},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Vt=e=>{var n;const t=j.useDependency(i.LocaleService),r=(n=e.value)!=null?n:t.t("sheet.numfmt.general");return d.jsx("span",{className:"more-numfmt-type",children:r})},Ht=()=>{const e=j.useDependency(i.ICommandService),t=j.useDependency(i.LocaleService),r=j.useInjector(),n=j.useDependency(v.SelectionManagerService),a=l=>{const u=n.getLast();if(!u)return;const m=r.get(ve.ITextSelectionRenderManager),f=u.range,o=[];i.Range.foreach(f,(p,b)=>{l?o.push({row:p,col:b,pattern:l,type:K(l)}):o.push({row:p,col:b})}),e.executeCommand(L.id,{values:o}),m.focus()},s=l=>{if(l===0)a(null);else if(l===re.length-1)e.executeCommand(Q.id);else{const u=re[l];u.pattern&&a(u.pattern)}},c=1220;return d.jsx("div",{className:"more-numfmt-type-options",children:re.map((l,u)=>l==="|"?d.jsx("div",{className:"line m-t-4",onClick:m=>m.stopPropagation()},u):d.jsxs("div",{className:"option-item m-t-4",onClick:()=>{s(u)},children:[d.jsx("div",{children:t.t(l.label)}),d.jsx("div",{className:"m-l-26",children:l.pattern?Z(l.pattern||"",c,t.getCurrentLocale()).result:""})]},u))})},At=e=>{const t="icon-rmbSingle";return e.register(t,Lt),e.register("MoreDownSingle",Ot),r=>({icon:t,id:_e.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,i.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(r)})},kt=e=>{const t="icon-addDigitsSingle";return e.register(t,jt),r=>({icon:t,id:ye.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:M.MenuItemType.BUTTON,positions:[M.MenuPosition.TOOLBAR_START],group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,hidden$:M.getMenuHiddenObservable(r,i.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(r)})},Ft=e=>{const t="icon-reduceDigitsSingle";return e.register(t,wt),r=>({icon:t,id:be.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,i.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(r)})},Bt=e=>{const t="icon-PercentSingle";return e.register(t,xt),r=>({icon:t,id:je.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,i.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(r)})},zt=e=>{const t="sheet.numfmt.moreNumfmtType",r="sheet.numfmt.moreNumfmtType.options";return e.register(t,Vt),e.register(r,Ht),n=>{const a=n.get(v.INumfmtService),s=n.get(i.IUniverInstanceService),c=n.get(i.ICommandService),l=n.get(i.LocaleService),u=n.get(v.SelectionManagerService),m=G.deriveStateFromActiveSheet$(s,"",({workbook:f,worksheet:o})=>new U.Observable(p=>U.merge(u.selectionMoveEnd$,new U.Observable(b=>{const y=[v.RemoveNumfmtMutation.id,v.SetNumfmtMutation.id],h=c.onCommandExecuted(S=>{y.includes(S.id)&&b.next(null)});return()=>h.dispose()})).subscribe(()=>{const b=u.getSelections();if(b&&b[0]){const y=b[0].range,h=y.startRow,S=y.startColumn,C=a.getValue(f.getUnitId(),o.getSheetId(),h,S),T=C==null?void 0:C.pattern;let E=l.t("sheet.numfmt.general");if(T){const w=re.filter(H=>typeof H=="object"&&H.pattern).find(H=>J(T,H.pattern));w&&typeof w=="object"&&w.pattern?E=l.t(w.label):E=l.t("sheet.numfmt.moreFmt")}p.next(E)}})));return{label:t,id:Q.id,tooltip:"sheet.numfmt.title",type:M.MenuItemType.SELECTOR,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],selections:[{label:{name:r,hoverable:!1}}],value$:m,hidden$:M.getMenuHiddenObservable(n,i.UniverInstanceType.UNIVER_SHEET),disabled$:v.getCurrentSheetDisabled$(n)}}};var $t=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Gt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Wt(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(a=(n?c(t,r,a):c(a))||a);return n&&a&&$t(t,r,a),a},de=(e,t)=>(r,n)=>t(r,n,e);let ae=class extends i.Disposable{constructor(e,t,r){super(),this._injector=e,this._componentManager=t,this._menuService=r,this._initMenu()}_initMenu(){[Bt,kt,Ft,At,zt].map(e=>e(this._componentManager)).forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(e(this._injector)))})}};ae=Gt([i.OnLifecycle(i.LifecycleStages.Rendered,ae),de(0,I.Inject(I.Injector)),de(1,I.Inject(M.ComponentManager)),de(2,I.Inject(M.IMenuService))],ae);var Kt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Yt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Zt(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(a=(n?c(t,r,a):c(a))||a);return n&&a&&Kt(t,r,a),a},Jt=(e,t)=>(r,n)=>t(r,n,e);_.UniverSheetsNumfmtPlugin=(se=class extends i.Plugin{constructor(t,r){super(),this._injector=r}onStarting(){this._injector.add([oe,{useClass:ee,lazy:!1}]),this._injector.add([te]),this._injector.add([q]),this._injector.add([Y]),this._injector.add([ne]),this._injector.add([ae])}},A(se,"pluginName",ie),A(se,"type",i.UniverInstanceType.UNIVER_SHEET),se),_.UniverSheetsNumfmtPlugin=Yt([Jt(1,I.Inject(I.Injector))],_.UniverSheetsNumfmtPlugin),_.SetNumfmtCommand=L,_.enUS=pe,_.getPatternPreview=Z,_.ruRU=Ue,_.zhCN=ge,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-numfmt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet numfmt plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,38 +53,38 @@
|
|
|
53
53
|
"npm": ">=8.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@wendellhu/redi": "^0.
|
|
56
|
+
"@wendellhu/redi": "^0.15.1",
|
|
57
57
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
58
58
|
"rxjs": ">=7.0.0",
|
|
59
|
-
"@univerjs/core": "0.1.
|
|
60
|
-
"@univerjs/design": "0.1.
|
|
61
|
-
"@univerjs/engine-numfmt": "0.1.
|
|
62
|
-
"@univerjs/engine-render": "0.1.
|
|
63
|
-
"@univerjs/sheets": "0.1.
|
|
64
|
-
"@univerjs/sheets-ui": "0.1.
|
|
65
|
-
"@univerjs/ui": "0.1.
|
|
59
|
+
"@univerjs/core": "0.1.11",
|
|
60
|
+
"@univerjs/design": "0.1.11",
|
|
61
|
+
"@univerjs/engine-numfmt": "0.1.11",
|
|
62
|
+
"@univerjs/engine-render": "0.1.11",
|
|
63
|
+
"@univerjs/sheets": "0.1.11",
|
|
64
|
+
"@univerjs/sheets-ui": "0.1.11",
|
|
65
|
+
"@univerjs/ui": "0.1.11"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@univerjs/icons": "^0.1.
|
|
68
|
+
"@univerjs/icons": "^0.1.45"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/react": "^18.2.79",
|
|
72
|
-
"@wendellhu/redi": "^0.
|
|
72
|
+
"@wendellhu/redi": "^0.15.1",
|
|
73
73
|
"less": "^4.2.0",
|
|
74
74
|
"react": "18.2.0",
|
|
75
75
|
"rxjs": "^7.8.1",
|
|
76
76
|
"typescript": "^5.4.5",
|
|
77
|
-
"vite": "^5.2.
|
|
78
|
-
"vitest": "^1.
|
|
79
|
-
"@univerjs/core": "0.1.
|
|
80
|
-
"@univerjs/design": "0.1.
|
|
81
|
-
"@univerjs/engine-formula": "0.1.
|
|
82
|
-
"@univerjs/engine-numfmt": "0.1.
|
|
83
|
-
"@univerjs/
|
|
84
|
-
"@univerjs/sheets": "0.1.
|
|
85
|
-
"@univerjs/
|
|
86
|
-
"@univerjs/ui": "0.1.
|
|
87
|
-
"@univerjs/
|
|
77
|
+
"vite": "^5.2.11",
|
|
78
|
+
"vitest": "^1.6.0",
|
|
79
|
+
"@univerjs/core": "0.1.11",
|
|
80
|
+
"@univerjs/design": "0.1.11",
|
|
81
|
+
"@univerjs/engine-formula": "0.1.11",
|
|
82
|
+
"@univerjs/engine-numfmt": "0.1.11",
|
|
83
|
+
"@univerjs/shared": "0.1.11",
|
|
84
|
+
"@univerjs/sheets": "0.1.11",
|
|
85
|
+
"@univerjs/engine-render": "0.1.11",
|
|
86
|
+
"@univerjs/sheets-ui": "0.1.11",
|
|
87
|
+
"@univerjs/ui": "0.1.11"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"test": "vitest run",
|