@univerjs/sheets-numfmt 0.1.11 → 0.1.12

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/index.css CHANGED
@@ -1 +1 @@
1
- .numfmt-panel{overflow-y:auto;display:flex;flex-direction:column;justify-content:space-between;height:100%}.numfmt-panel .group-title{font-size:16px;color:rgba(var(--color-black))}.numfmt-panel .label{font-size:15px;color:rgba(var(--grey-400))}.numfmt-panel .describe{font-size:13px;line-height:20px;color:rgba(var(--grey-600))}.numfmt-panel .preview{height:36px;padding:0 16px;font-size:14px;line-height:36px;color:var(--color-black);border:1px solid rgb(var(--grey-200));border-radius:4px}.numfmt-panel .btn-list{display:flex;justify-content:flex-end}.numfmt-panel .m-r-12{margin-right:12px}.numfmt-panel .m-t-16{margin-top:16px}.numfmt-panel .m-t-14{margin-top:14px}.numfmt-panel .m-t-8{margin-top:8px}.numfmt-panel .m-b-20{margin-bottom:20px}.options{display:flex;justify-content:space-between}.options .w-140{width:140px}.options .w-120{width:120px}.more-numfmt-type{display:flex;flex-shrink:0;padding:0 4px;font-size:13px;color:var(--black)}.more-numfmt-type .icon{display:flex;align-items:center;height:auto;padding-left:8px;font-size:10px;color:rgb(var(--grey-400))}.more-numfmt-type-options .line{width:100%;height:1px;background-color:rgb(var(--grey-200))}.more-numfmt-type-options .m-t-4{margin-top:4px}.more-numfmt-type-options .option-item{display:flex;align-items:center;justify-content:space-between;height:28px;padding:0 8px;font-size:13px}.more-numfmt-type-options .option-item:hover{background-color:rgb(var(--grey-100));border-radius:var(--border-radius-base)}.more-numfmt-type-options .m-l-26{margin-left:26px}
1
+ .numfmt-panel{overflow-y:auto;display:flex;flex-direction:column;justify-content:space-between;height:100%}.numfmt-panel .group-title{font-size:16px;color:rgba(var(--color-black))}.numfmt-panel .label{font-size:15px;color:rgba(var(--grey-400))}.numfmt-panel .describe{font-size:13px;line-height:20px;color:rgba(var(--grey-600))}.numfmt-panel .preview{height:36px;padding:0 16px;font-size:14px;line-height:36px;color:var(--color-black);border:1px solid rgb(var(--grey-200));border-radius:4px}.numfmt-panel .btn-list{display:flex;justify-content:flex-end}.numfmt-panel .m-r-12{margin-right:12px}.numfmt-panel .m-t-16{margin-top:16px}.numfmt-panel .m-t-14{margin-top:14px}.numfmt-panel .m-t-8{margin-top:8px}.numfmt-panel .m-b-20{margin-bottom:20px}.options{display:flex;justify-content:space-between}.options .w-140{width:140px}.options .w-120{width:120px}.more-numfmt-type{display:flex;flex-shrink:0;padding:0 4px;font-size:13px;color:var(--black)}.more-numfmt-type .icon{display:flex;align-items:center;height:auto;padding-left:8px;color:rgb(var(--grey-400))}.more-numfmt-type-options .line{width:100%;height:1px;background-color:rgb(var(--grey-200))}.more-numfmt-type-options .m-t-4{margin-top:4px}.more-numfmt-type-options .option-item{display:flex;align-items:center;justify-content:space-between;height:28px;padding:0 8px;font-size:13px}.more-numfmt-type-options .option-item:hover{background-color:rgb(var(--grey-100));border-radius:var(--border-radius-base)}.more-numfmt-type-options .m-l-26{margin-left:26px}
@@ -1,5 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
 
3
+ export declare const MORE_NUMFMT_TYPE_KEY = "sheet.numfmt.moreNumfmtType";
4
+ export declare const OPTIONS_KEY = "sheet.numfmt.moreNumfmtType.options";
3
5
  export declare const MoreNumfmtType: (props: {
4
6
  value?: string;
5
7
  }) => React.JSX.Element;
@@ -1,11 +1,16 @@
1
1
  import { Disposable } from '@univerjs/core';
2
- import { ComponentManager, IMenuService } from '@univerjs/ui';
2
+ import { MenuConfig, ComponentManager, IMenuService } from '@univerjs/ui';
3
3
  import { Injector } from '@wendellhu/redi';
4
4
 
5
+ export interface IUniverSheetsNumfmtConfig {
6
+ menu: MenuConfig;
7
+ }
8
+ export declare const DefaultSheetNumfmtConfig: {};
5
9
  export declare class NumfmtMenuController extends Disposable {
10
+ private readonly _config;
6
11
  private _injector;
7
12
  private _componentManager;
8
13
  private _menuService;
9
- constructor(_injector: Injector, _componentManager: ComponentManager, _menuService: IMenuService);
14
+ constructor(_config: Partial<IUniverSheetsNumfmtConfig>, _injector: Injector, _componentManager: ComponentManager, _menuService: IMenuService);
10
15
  private _initMenu;
11
16
  }
@@ -1,8 +1,8 @@
1
- import { ComponentManager, IMenuSelectorItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
1
+ import { IMenuSelectorItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
2
2
  import { IAccessor } from '@wendellhu/redi';
3
3
  import { Observable } from 'rxjs';
4
4
 
5
- export declare const CurrencyMenuItem: (componentManager: ComponentManager) => (accessor: IAccessor) => {
5
+ export declare const CurrencyMenuItem: (accessor: IAccessor) => {
6
6
  icon: string;
7
7
  id: string;
8
8
  title: string;
@@ -13,7 +13,7 @@ export declare const CurrencyMenuItem: (componentManager: ComponentManager) => (
13
13
  hidden$: Observable<boolean>;
14
14
  disabled$: Observable<boolean>;
15
15
  };
16
- export declare const AddDecimalMenuItem: (componentManager: ComponentManager) => (accessor: IAccessor) => {
16
+ export declare const AddDecimalMenuItem: (accessor: IAccessor) => {
17
17
  icon: string;
18
18
  id: string;
19
19
  title: string;
@@ -24,7 +24,7 @@ export declare const AddDecimalMenuItem: (componentManager: ComponentManager) =>
24
24
  hidden$: Observable<boolean>;
25
25
  disabled$: Observable<boolean>;
26
26
  };
27
- export declare const SubtractDecimalMenuItem: (componentManager: ComponentManager) => (accessor: IAccessor) => {
27
+ export declare const SubtractDecimalMenuItem: (accessor: IAccessor) => {
28
28
  icon: string;
29
29
  id: string;
30
30
  title: string;
@@ -35,7 +35,7 @@ export declare const SubtractDecimalMenuItem: (componentManager: ComponentManage
35
35
  hidden$: Observable<boolean>;
36
36
  disabled$: Observable<boolean>;
37
37
  };
38
- export declare const PercentMenuItem: (componentManager: ComponentManager) => (accessor: IAccessor) => {
38
+ export declare const PercentMenuItem: (accessor: IAccessor) => {
39
39
  icon: string;
40
40
  id: string;
41
41
  title: string;
@@ -46,4 +46,4 @@ export declare const PercentMenuItem: (componentManager: ComponentManager) => (a
46
46
  hidden$: Observable<boolean>;
47
47
  disabled$: Observable<boolean>;
48
48
  };
49
- export declare const FactoryOtherMenuItem: (componentManager: ComponentManager) => (_accessor: IAccessor) => IMenuSelectorItem<import('@univerjs/ui/services/menu/menu.js').MenuItemDefaultValueType, undefined>;
49
+ export declare const FactoryOtherMenuItem: (accessor: IAccessor) => IMenuSelectorItem;
@@ -1,10 +1,12 @@
1
1
  import { Plugin, UniverInstanceType } from '@univerjs/core';
2
2
  import { Injector } from '@wendellhu/redi';
3
+ import { IUniverSheetsNumfmtConfig } from './controllers/numfmt.menu.controller';
3
4
 
4
5
  export declare class UniverSheetsNumfmtPlugin extends Plugin {
6
+ private readonly _config;
5
7
  readonly _injector: Injector;
6
8
  static pluginName: string;
7
9
  static type: UniverInstanceType;
8
- constructor(_config: unknown, _injector: Injector);
10
+ constructor(_config: Partial<IUniverSheetsNumfmtConfig>, _injector: Injector);
9
11
  onStarting(): void;
10
12
  }
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
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={};/**
1
+ (function(y,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):(y=typeof globalThis<"u"?globalThis:y||self,i(y.UniverSheetsNumfmt={},y.UniverCore,y.UniverSheets,y["@wendellhu/redi"],y.UniverSheetsUi,y.rxjs.operators,y.UniverEngineNumfmt,y.UniverEngineRender,y.UniverUi,y.rxjs,y.React,y.UniverDesign,y["@wendellhu/redi/react-bindings"]))})(this,function(y,i,h,I,W,L,E,fe,T,O,b,P,R){"use strict";var Ut=Object.defineProperty;var wt=(y,i,h)=>i in y?Ut(y,i,{enumerable:!0,configurable:!0,writable:!0,value:h}):y[i]=h;var w=(y,i,h)=>(wt(y,typeof i!="symbol"?i+"":i,h),h);var te;const x={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),s=e.get(i.IUndoRedoService),a=h.getSheetCommandTarget(n,t);if(!a)return!1;const{unitId:c,subUnitId:l}=a,u=t.values.filter(p=>!!p.pattern),m=t.values.filter(p=>!p.pattern),f=h.transformCellsToRange(c,l,u),o={unitId:c,subUnitId:l,ranges:m.map(p=>({startColumn:p.col,startRow:p.row,endColumn:p.col,endRow:p.row}))},v=[],C=[];if(u.length){Object.keys(f.values).forEach(S=>{const g=f.values[S];g.ranges=h.rangeMerge(g.ranges)}),v.push({id:h.SetNumfmtMutation.id,params:f});const p=h.factorySetNumfmtUndoMutation(e,f);C.push(...p)}if(m.length){o.ranges=h.rangeMerge(o.ranges),v.push({id:h.RemoveNumfmtMutation.id,params:o});const p=h.factoryRemoveNumfmtUndoMutation(e,o);C.push(...p)}const _=i.sequenceExecute(v,r).result;return _&&s.pushUndoRedo({unitID:c,undoMutations:C,redoMutations:v}),_}},he={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"}}},pe={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:"减少小数位"}}},Pe={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:"Уменьшить количество десятичных знаков"}}},re="SHEET_NUMFMT_PLUGIN",k=e=>E.getInfo(e).type||"unknown",G=(e,t,r)=>{const n=E.getInfo(e),s=r===i.LocaleType.ZH_CN?"zh-CN":"en",a=n._partitions[1],c=E.format(e,t,{locale:s});return t<0?{result:c,color:a.color}:{result:c}};var De=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(e,t,r,n)=>{for(var s=n>1?void 0:n?Ee(t,r):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(n?c(t,r,s):c(s))||s);return n&&s&&De(t,r,s),s},A=(e,t)=>(r,n)=>t(r,n,e);let z=class extends i.Disposable{constructor(e,t,r,n,s,a){super(),this._sheetInterceptorService=e,this._themeService=t,this._sheetSkeletonManagerService=r,this._commandService=n,this._numfmtService=s,this._localeService=a,this._initInterceptorCellContent()}_initInterceptorCellContent(){const e=new i.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(h.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,r,n)=>{const s=r.unitId,a=r.subUnitId,c=this._numfmtService.getValue(s,a,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=G(c.pattern,Number(l.v),this._localeService.getCurrentLocale());if(u=f.result,!u)return n(t);const o={v:u};if(f.color){const v=this._themeService.getCurrentTheme()[`${f.color}500`];v&&(o.interceptorStyle={cl:{rgb:v}})}return e.setValue(r.row,r.col,{result:o,parameters:l.v}),n({...t,...o})}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===h.SetNumfmtMutation.id){const r=t.params;Object.keys(r.values).forEach(n=>{r.values[n].ranges.forEach(a=>{i.Range.foreach(a,(c,l)=>{e.realDeleteValue(c,l)})})})}})),this.disposeWithMe(i.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.pipe(L.map(t=>t==null?void 0:t.sheetId),L.distinctUntilChanged()).subscribe(()=>{e.reset()})))}};z=Oe([i.OnLifecycle(i.LifecycleStages.Rendered,z),A(0,I.Inject(h.SheetInterceptorService)),A(1,I.Inject(i.ThemeService)),A(2,I.Inject(W.SheetSkeletonManagerService)),A(3,I.Inject(i.ICommandService)),A(4,I.Inject(h.INumfmtService)),A(5,I.Inject(i.LocaleService))],z);const U=(e,t=0)=>{var n;return e&&(n=E.getInfo(e).maxDecimals)!=null?n:t},K=(e,t)=>{if(e&&!t||!e&&t)return!1;const r=m=>m.reduce((f,o)=>{if(f.isEnd)return f;const v=o.value||o.num;return o.type==="point"?(f.isEnd=!0,f):{...f,result:f.result+v}},{isEnd:!1,result:""}).result,n=E.getInfo(e)._partitions,s=E.getInfo(t)._partitions,a=r(n[0].tokens),c=r(s[0].tokens),l=r(n[1].tokens),u=r(s[1].tokens);return a===c&&l===u&&n[1].color===s[1].color},ve=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?".":""}${ve(Number(t||0))}`):/0([^0]?)|0$/.test(n)?n.replace(/0([^0]+)|0$/,`0${t>0?".":""}${ve(Number(t||0))}$1`):n).join(";"),xe=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),Se={id:"sheet.command.numfmt.add.decimal.command",type:i.CommandType.COMMAND,handler:async e=>{const t=e.get(i.ICommandService),r=e.get(h.SelectionManagerService),n=e.get(h.INumfmtService),s=e.get(i.IUniverInstanceService),a=r.getSelections();if(!a||!a.length)return!1;const c=h.getSheetCommandTarget(s);if(!c)return!1;const{unitId:l,subUnitId:u}=c;let m=0;a.forEach(C=>{i.Range.foreach(C.range,(_,p)=>{const S=n.getValue(l,u,_,p);if(!S)return;const g=U(S.pattern);m=g>m?g:m})});const f=m+1,o=j(`0${f>0?".0":""}`,f),v=[];return a.forEach(C=>{i.Range.foreach(C.range,(_,p)=>{const S=n.getValue(l,u,_,p);if(!S)v.push({row:_,col:p,pattern:o});else{const g=U(S.pattern),M=j(S.pattern,g+1);M!==S.pattern&&v.push({row:_,col:p,pattern:M})}})}),v.length?await t.executeCommand(x.id,{values:v}):!1}},Ue=[{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"}],we=[{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"}],ge=[{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(h.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const s=[],a=ge[0].suffix("¥");return n.forEach(l=>{i.Range.foreach(l.range,(u,m)=>{s.push({row:u,col:m,pattern:a,type:"currency"})})}),await t.executeCommand(x.id,{values:s})}},ye={id:"sheet.command.numfmt.subtract.decimal.command",type:i.CommandType.COMMAND,handler:async e=>{const t=e.get(i.ICommandService),r=e.get(h.SelectionManagerService),n=e.get(h.INumfmtService),s=e.get(i.IUniverInstanceService),a=r.getSelections();if(!a||!a.length)return!1;const c=h.getSheetCommandTarget(s);if(!c)return!1;const{unitId:l,subUnitId:u}=c;let m=0;a.forEach(_=>{i.Range.foreach(_.range,(p,S)=>{const g=n.getValue(l,u,p,S);if(!g)return;const M=U(g.pattern);m=M>m?M:m})});const f=m-1,o=j(`0${f>0?".0":"."}`,f),v=[];return a.forEach(_=>{i.Range.foreach(_.range,(p,S)=>{const g=n.getValue(l,u,p,S);if(!g)v.push({row:p,col:S,pattern:o});else{const M=U(g.pattern);v.push({row:p,col:S,pattern:j(g.pattern,M-1)})}})}),await t.executeCommand(x.id,{values:v})}},se={id:"sheet.operation.close.numfmt.panel",type:i.CommandType.OPERATION,handler:()=>!0},ae=I.createIdentifier("INumfmtController");i.runOnLifecycle(i.LifecycleStages.Rendered,ae);const Y={id:"sheet.operation.open.numfmt.panel",type:i.CommandType.OPERATION,handler:e=>(e.get(ae).openPanel(),!0)};var be={exports:{}},J={};/**
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,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"})});
9
+ */var Le=b,Ae=Symbol.for("react.element"),Ve=Symbol.for("react.fragment"),$e=Object.prototype.hasOwnProperty,He=Le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Fe={key:!0,ref:!0,__self:!0,__source:!0};function Ce(e,t,r){var n,s={},a=null,c=null;r!==void 0&&(a=""+r),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(c=t.ref);for(n in t)$e.call(t,n)&&!Fe.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)s[n]===void 0&&(s[n]=t[n]);return{$$typeof:Ae,type:e,key:a,ref:c,props:s,_owner:He.current}}J.Fragment=Ve,J.jsx=Ce,J.jsxs=Ce,be.exports=J;var d=be.exports;const ie=b.createContext([]),ce=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"];var Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ke=(e,t,r,n)=>{for(var s=n>1?void 0:n?We(t,r):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(n?c(t,r,s):c(s))||s);return n&&s&&Be(t,r,s),s},Ge=(e,t)=>(r,n)=>t(r,n,e);let Z=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 s=n.findIndex(a=>a===t);s>-1&&n.splice(s,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 s=n.map((a,c,l)=>{const u=l.length;return{value:a,priority:u-c}});return t.sort((a,c)=>{var m,f;const l=((m=s.find(o=>o.value===a))==null?void 0:m.priority)||-1;return(((f=s.find(o=>o.value===c))==null?void 0:f.priority)||-1)-l})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};Z=ke([Ge(0,I.Inject(i.ILocalStorageService))],Z);const Ie="numfmtCurrency",ze=e=>{const t=R.useDependency(Z),[r,n]=b.useState(ce);return b.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(Ie,[...ce]).then(a=>{n(a),e&&e(a)})})},[]),{userHabitCurrency:r,mark:a=>{t.markHabit(Ie,a)}}},Ke=()=>{const e=b.useRef([]),[t,r]=b.useState({});return b.useEffect(()=>{e.current.forEach(s=>{s()}),e.current=[]},[t]),s=>{e.current.push(s),r({})}},$=e=>ce.find(r=>e.includes(r)),Ye=e=>!!$(e)&&e.startsWith("_("),Je=e=>{const[t,r]=b.useState(()=>U(e.defaultPattern||"",2)),n=b.useContext(ie),[s,a]=b.useState(()=>$(e.defaultPattern)||n[0]),c=b.useMemo(()=>n.map(o=>({label:o,value:o})),[]),u=R.useDependency(i.LocaleService).t;e.action.current=()=>j(`_("${s}"* #,##0${t>0?".0":""}_)`,t);const m=o=>{a(o),e.onChange(j(`_("${o}"* #,##0${t>0?".0":""}_)`,t))},f=o=>{const v=o||0;r(v),e.onChange(j(`_("${s}"* #,##0${v>0?".0":""}_)`,v))};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(P.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(P.Select,{onChange:m,options:c,value:s})})]})]}),d.jsx("div",{className:"describe m-t-14",children:u("sheet.numfmt.accountingDes")})]})},oe=e=>ge.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),Te=()=>Ue.map(e=>({label:e.label,value:e.suffix})),Me=()=>we.map(e=>({label:e.label,value:e.suffix,color:e.color})),Ze=e=>!!$(e)&&!e.startsWith("_("),Qe=e=>{const r=R.useDependency(i.LocaleService).t,n=b.useContext(ie),[s,a]=b.useState(()=>$(e.defaultPattern)||n[0]),[c,l]=b.useState(()=>U(e.defaultPattern||"",2)),[u,m]=b.useState(()=>{var g;const p=oe(s);return((g=p.find(M=>K(M.value,e.defaultPattern)))==null?void 0:g.value)||p[0].value}),f=b.useMemo(()=>oe(s),[s]),o=b.useMemo(()=>n.map(p=>({label:p,value:p})),[n]);e.action.current=()=>j(u,c);const v=p=>{a(p);const S=oe(p)[0].value;m(S),e.onChange(j(S,c))},C=p=>{m(p),e.onChange(j(p,c))},_=p=>{l(p||0),e.onChange(j(u,p||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(P.InputNumber,{value:c,max:20,min:0,onChange:_})})]}),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(P.Select,{onChange:v,options:o,value:s})})]})]}),d.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),d.jsx("div",{className:"m-t-8",children:d.jsx(P.SelectList,{onChange:C,options:f,value:u})}),d.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})},Xe=e=>{const t=E.getInfo(e);return Te().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)},qe=e=>{const t=b.useMemo(Te,[]),n=R.useDependency(i.LocaleService).t,[s,a]=b.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=()=>s;const c=l=>{a(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(P.SelectList,{value:s,options:t,onChange:c})}),d.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},et=e=>!e,tt=e=>{const r=R.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")})})},nt=e=>Me().some(t=>K(t.value,e)),rt=e=>{const t=R.useDependency(i.LocaleService),r=b.useMemo(Me,[]),[n,s]=b.useState(()=>U(e.defaultPattern||"",0)),[a,c]=b.useState(()=>{const o=r.find(v=>K(v.value,e.defaultPattern||""));return(o==null?void 0:o.value)||r[0].value}),l=b.useMemo(()=>j(a,Number(n||0)),[a,n]),u=b.useMemo(()=>!xe(a),[a]),m=o=>{s(o||0),e.onChange(j(a,Number(o||0)))},f=o=>{s(U(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(P.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(P.SelectList,{onChange:f,options:r,value:a})}),d.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},st=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:s}=e.value,a=R.useDependency(i.LocaleService),c=b.useRef(()=>""),l=a.t,u=Ke(),m=b.useMemo(()=>[{label:"sheet.numfmt.general",component:tt},{label:"sheet.numfmt.accounting",component:Je},{label:"sheet.numfmt.currency",component:Qe},{label:"sheet.numfmt.date",component:qe},{label:"sheet.numfmt.thousandthPercentile",component:rt}].map(N=>({...N,label:l(N.label)})),[]),[f,o]=b.useState(g),[v,C]=b.useState(()=>`${n}_${s}`),{mark:_,userHabitCurrency:p}=ze(()=>C(`${n}_${s}_userCurrency'`)),S=b.useMemo(()=>{var N;return(N=m.find(V=>V.label===f))==null?void 0:N.component},[f]);function g(){return[et,Ye,Ze,Xe,nt].reduce((V,Ot,xt)=>V||(Ot(r)?m[xt].label:""),"")||m[0].label}const M=m.map(N=>({label:N.label,value:N.label})),B=N=>{o(N),u(()=>e.onChange({type:"change",value:c.current()||""}))},ne=N=>{e.onChange({type:"change",value:N})},ue=()=>{const N=c.current()||"",V=$(N);V&&_(V),e.onChange({type:"confirm",value:N})},me=()=>{e.onChange({type:"cancel",value:""})},de={onChange:ne,defaultValue:t,defaultPattern:r,action:c};return b.useEffect(()=>{o(g()),C(`${n}_${s}`)},[n,s]),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(P.Select,{onChange:B,options:M,value:f})}),d.jsx("div",{children:S&&d.jsx(ie.Provider,{value:p,children:b.createElement(S,{...de,key:v})})})]}),d.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[d.jsx(P.Button,{size:"small",onClick:me,className:"m-r-12",children:l("sheet.numfmt.cancel")}),d.jsx(P.Button,{type:"primary",size:"small",onClick:ue,children:l("sheet.numfmt.confirm")})]})]})},Ne={id:"sheet.command.numfmt.set.percent",type:i.CommandType.COMMAND,handler:async e=>{const t=e.get(i.ICommandService),n=e.get(h.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const s=[],a="0%";return n.forEach(l=>{i.Range.foreach(l.range,(u,m)=>{s.push({row:u,col:m,pattern:a,type:"percent"})})}),await t.executeCommand(x.id,{values:s})}};var at=Object.defineProperty,it=Object.getOwnPropertyDescriptor,ct=(e,t,r,n)=>{for(var s=n>1?void 0:n?it(t,r):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(n?c(t,r,s):c(s))||s);return n&&s&&at(t,r,s),s},D=(e,t)=>(r,n)=>t(r,n,e);let Q=class extends i.Disposable{constructor(t,r,n,s,a,c,l,u,m,f,o){super();w(this,"_previewPattern","");w(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._sheetSkeletonManagerService=s,this._commandService=a,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,s=this._univerInstanceService,a=this._numfmtService,c=this._localeService,u=(r.getSelectionRanges()||[])[0];if(!u)return!1;const m=s.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),f=m.getActiveSheet(),o=f.getCellRaw(u.startRow,u.startColumn),v=a.getValue(m.getUnitId(),f.getSheetId(),u.startRow,u.startColumn);let C="";v&&(C=v.pattern);const _=(o==null?void 0:o.t)===i.CellValueType.NUMBER?o.v:12345678,p={onChange:S=>{var g,M;if(S.type==="change")this._previewPattern=S.value,this._sheetSkeletonManagerService.reCalculate(),(M=(g=this._renderManagerService.getRenderById(m.getUnitId()))==null?void 0:g.mainComponent)==null||M.makeDirty();else if(S.type==="confirm"){const B=r.getSelectionRanges()||[],ne={values:[]},ue=k(S.value);B.forEach(me=>{i.Range.foreach(me,(de,N)=>{ne.values.push({row:de,col:N,pattern:S.value,type:ue})})}),n.executeCommand(x.id,ne),t.close()}else S.type==="cancel"&&t.close()},value:{defaultPattern:C,defaultValue:_,row:u.startRow,col:u.startColumn}};return this._sidebarDisposable=t.open({header:{title:c.t("sheet.numfmt.title")},children:{label:re,...p},onClose:()=>{var S,g;this._sheetSkeletonManagerService.reCalculate(),(g=(S=this._renderManagerService.getRenderById(m.getUnitId()))==null?void 0:S.mainComponent)==null||g.makeDirty(),n.executeCommand(se.id)}}),!0}_initCommands(){[Se,ye,_e,Ne,Y,se,x].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(re,st)}_initRealTimeRenderingInterceptor(){const t=new O.Observable(n=>{this._commandService.onCommandExecuted(s=>{s.id===Y.id&&n.next(!0),s.id===se.id&&n.next(!1)})}),r=O.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(L.map(n=>n?n.map(s=>s.range):[]))]);this.disposeWithMe(i.toDisposable(r.pipe(L.switchMap(([n,s])=>new O.Observable(a=>{const c=new i.DisposableCollection;return n&&s.length&&a.next({selectionRanges:s,disposableCollection:c}),()=>{c.dispose()}})),L.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:s})=>{var c,l;const a=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(h.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,handler:(u,m,f)=>{const{row:o,col:v}=m,C=f(u)||{};if(s.find(_=>_.startColumn<=v&&_.endColumn>=v&&_.startRow<=o&&_.endRow>=o)){const _=m.worksheet.getCellRaw(o,v),p=_==null?void 0:_.v,S=_==null?void 0:_.t;if(p==null||S!==i.CellValueType.NUMBER||this._previewPattern===null)return C;const g=G(this._previewPattern,p,this._localeService.getCurrentLocale());if(g.color){const B=this._themeService.getCurrentTheme()[`${g.color}500`];return{...C,v:g.result,t:i.CellValueType.STRING,s:{cl:{rgb:B}}}}return{...C,v:g.result,t:i.CellValueType.STRING}}return C}})),(l=(c=this._renderManagerService.getRenderById(a.getUnitId()))==null?void 0:c.mainComponent)==null||l.makeDirty()})))}_commandExecutedListener(){const t=[h.RemoveNumfmtMutation.id,h.SetNumfmtMutation.id];this.disposeWithMe(i.toDisposable(O.merge(new O.Observable(r=>{const n=this._commandService.onCommandExecuted(s=>{if(t.includes(s.id)){const a=s.params;r.next(a.unitId)}});return()=>{n.dispose()}})).pipe(L.debounceTime(16)).subscribe(r=>{var n,s;this._sheetSkeletonManagerService.reCalculate(),(s=(n=this._renderManagerService.getRenderById(r))==null?void 0:n.mainComponent)==null||s.makeDirty()})))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};Q=ct([i.OnLifecycle(i.LifecycleStages.Rendered,Q),D(0,I.Inject(h.SheetInterceptorService)),D(1,I.Inject(i.ThemeService)),D(2,i.IUniverInstanceService),D(3,I.Inject(W.SheetSkeletonManagerService)),D(4,i.ICommandService),D(5,I.Inject(h.SelectionManagerService)),D(6,fe.IRenderManagerService),D(7,h.INumfmtService),D(8,I.Inject(T.ComponentManager)),D(9,T.ISidebarService),D(10,I.Inject(i.LocaleService))],Q);var ot=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,ut=(e,t,r,n)=>{for(var s=n>1?void 0:n?lt(t,r):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(n?c(t,r,s):c(s))||s);return n&&s&&ot(t,r,s),s},H=(e,t)=>(r,n)=>t(r,n,e);const mt=()=>{let e=[];return{add:(s,a,c,l,u)=>e.push({unitId:s,subUnitId:a,row:c,col:l,value:u}),getEffects:()=>e,clean:()=>{e=[]}}};let X=class extends i.Disposable{constructor(t,r,n,s,a){super();w(this,"_collectEffectMutation",mt());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=s,this._editorBridgeService=a,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 s=r.row,a=r.col,c=this._numfmtService.getValue(r.unitId,r.subUnitId,s,a);if(c)switch(k(c.pattern)){case"scientific":case"percent":case"currency":case"grouped":case"number":return r.worksheet.getCellRaw(s,a);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 s=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),a=(f=s&&k(s.pattern))!=null?f:"",c=()=>{s&&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=E.parseDate(l)||E.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(a)||!dt(l))&&c();return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){switch(r.id){case h.SetRangeValuesCommand.id:{const n=t._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),s=n.getUnitId(),a=n.getActiveSheet().getSheetId(),c=t._collectEffectMutation.getEffects();if(!c.length)return{redos:[],undos:[]};const l=c.filter(o=>{var v;return!!((v=o.value)!=null&&v.pattern)}).map(o=>({row:o.row,col:o.col,pattern:o.value.pattern})),u=c.filter(o=>{var v;return!((v=o.value)!=null&&v.pattern)}).map(o=>({startRow:o.row,endColumn:o.col,startColumn:o.col,endRow:o.row})),m=[],f=[];if(l){const o={id:h.SetNumfmtMutation.id,params:h.transformCellsToRange(s,a,l)};m.push(o),f.push(...h.factorySetNumfmtUndoMutation(t._injector,o.params))}if(u){const o={id:h.RemoveNumfmtMutation.id,params:{unitId:s,subUnitId:a,ranges:u}};m.push(o),f.push(...h.factoryRemoveNumfmtUndoMutation(t._injector,o.params))}return{redos:m,undos:f.reverse()}}}return{redos:[],undos:[]}}}))}};X=ut([i.OnLifecycle(i.LifecycleStages.Rendered,X),H(0,I.Inject(h.SheetInterceptorService)),H(1,I.Inject(h.INumfmtService)),H(2,I.Inject(i.IUniverInstanceService)),H(3,I.Inject(I.Injector)),H(4,I.Inject(W.IEditorBridgeService))],X);function dt(e){return/^-?\d+(\.\d+)?$/.test(e)}var ft=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,pt=(e,t,r,n)=>{for(var s=n>1?void 0:n?ht(t,r):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(n?c(t,r,s):c(s))||s);return n&&s&&ft(t,r,s),s},vt=(e,t)=>(r,n)=>t(r,n,e);let q=class extends i.Disposable{constructor(t){super();w(this,"_initLocal",()=>{this._localeService.load({zhCN:pe,enUS:he})});this._localeService=t,this._initLocal()}};q=pt([i.OnLifecycle(i.LifecycleStages.Rendered,q),vt(0,I.Inject(i.LocaleService))],q);const ee=[{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:""}],je="sheet.numfmt.moreNumfmtType",Re="sheet.numfmt.moreNumfmtType.options",St=e=>{var n;const t=R.useDependency(i.LocaleService),r=(n=e.value)!=null?n:t.t("sheet.numfmt.general");return d.jsx("span",{className:"more-numfmt-type",children:r})},gt=()=>{const e=R.useDependency(i.ICommandService),t=R.useDependency(i.LocaleService),r=R.useInjector(),n=R.useDependency(h.SelectionManagerService),s=l=>{const u=n.getLast();if(!u)return;const m=r.get(fe.ITextSelectionRenderManager),f=u.range,o=[];i.Range.foreach(f,(v,C)=>{l?o.push({row:v,col:C,pattern:l,type:k(l)}):o.push({row:v,col:C})}),e.executeCommand(x.id,{values:o}),m.focus()},a=l=>{if(l===0)s(null);else if(l===ee.length-1)e.executeCommand(Y.id);else{const u=ee[l];u.pattern&&s(u.pattern)}},c=1220;return d.jsx("div",{className:"more-numfmt-type-options",children:ee.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:()=>{a(u)},children:[d.jsx("div",{children:t.t(l.label)}),d.jsx("div",{className:"m-l-26",children:l.pattern?G(l.pattern||"",c,t.getCurrentLocale()).result:""})]},u))})},_t=e=>({icon:"RmbSingle",id:_e.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:T.MenuItemType.BUTTON,group:T.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[T.MenuPosition.TOOLBAR_START],hidden$:T.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:h.getCurrentSheetDisabled$(e)}),yt=e=>({icon:"AddDigitsSingle",id:Se.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:T.MenuItemType.BUTTON,positions:[T.MenuPosition.TOOLBAR_START],group:T.MenuGroup.TOOLBAR_FORMULAS_INSERT,hidden$:T.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:h.getCurrentSheetDisabled$(e)}),bt=e=>({icon:"ReduceDigitsSingle",id:ye.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:T.MenuItemType.BUTTON,group:T.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[T.MenuPosition.TOOLBAR_START],hidden$:T.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:h.getCurrentSheetDisabled$(e)}),Ct=e=>({icon:"PercentSingle",id:Ne.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:T.MenuItemType.BUTTON,group:T.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[T.MenuPosition.TOOLBAR_START],hidden$:T.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:h.getCurrentSheetDisabled$(e)}),It=e=>{const t=e.get(h.INumfmtService),r=e.get(i.IUniverInstanceService),n=e.get(i.ICommandService),s=e.get(i.LocaleService),a=e.get(h.SelectionManagerService),c=W.deriveStateFromActiveSheet$(r,"",({workbook:l,worksheet:u})=>new O.Observable(m=>O.merge(a.selectionMoveEnd$,new O.Observable(f=>{const o=[h.RemoveNumfmtMutation.id,h.SetNumfmtMutation.id],v=n.onCommandExecuted(C=>{o.includes(C.id)&&f.next(null)});return()=>v.dispose()})).subscribe(()=>{const f=a.getSelections();if(f&&f[0]){const o=f[0].range,v=o.startRow,C=o.startColumn,_=t.getValue(l.getUnitId(),u.getSheetId(),v,C),p=_==null?void 0:_.pattern;let S=s.t("sheet.numfmt.general");if(p){const g=ee.filter(M=>typeof M=="object"&&M.pattern).find(M=>K(p,M.pattern));g&&typeof g=="object"&&g.pattern?S=s.t(g.label):S=s.t("sheet.numfmt.moreFmt")}m.next(S)}})));return{label:je,id:Y.id,tooltip:"sheet.numfmt.title",type:T.MenuItemType.SELECTOR,group:T.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[T.MenuPosition.TOOLBAR_START],selections:[{label:{name:Re,hoverable:!1}}],value$:c,hidden$:T.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:h.getCurrentSheetDisabled$(e)}};var Tt=Object.defineProperty,Mt=Object.getOwnPropertyDescriptor,Nt=(e,t,r,n)=>{for(var s=n>1?void 0:n?Mt(t,r):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(n?c(t,r,s):c(s))||s);return n&&s&&Tt(t,r,s),s},le=(e,t)=>(r,n)=>t(r,n,e);const jt={};let F=class extends i.Disposable{constructor(e,t,r,n){super(),this._config=e,this._injector=t,this._componentManager=r,this._menuService=n,this._initMenu()}_initMenu(){const{menu:e={}}=this._config;[Ct,yt,bt,_t,It].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(t(this._injector),e))}),this.disposeWithMe(this._componentManager.register(je,St)),this.disposeWithMe(this._componentManager.register(Re,gt))}};F=Nt([i.OnLifecycle(i.LifecycleStages.Rendered,F),le(1,I.Inject(I.Injector)),le(2,I.Inject(T.ComponentManager)),le(3,I.Inject(T.IMenuService))],F);var Rt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Dt=(e,t,r,n)=>{for(var s=n>1?void 0:n?Pt(t,r):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(n?c(t,r,s):c(s))||s);return n&&s&&Rt(t,r,s),s},Et=(e,t)=>(r,n)=>t(r,n,e);y.UniverSheetsNumfmtPlugin=(te=class extends i.Plugin{constructor(t={},r){super(),this._config=t,this._injector=r,this._config=i.Tools.deepMerge({},jt,this._config)}onStarting(){this._injector.add([ae,{useClass:Q,lazy:!1}]),this._injector.add([X]),this._injector.add([Z]),this._injector.add([z]),this._injector.add([q]),this._injector.add([F,{useFactory:()=>this._injector.createInstance(F,this._config)}])}},w(te,"pluginName",re),w(te,"type",i.UniverInstanceType.UNIVER_SHEET),te),y.UniverSheetsNumfmtPlugin=Dt([Et(1,I.Inject(I.Injector))],y.UniverSheetsNumfmtPlugin),y.SetNumfmtCommand=x,y.enUS=he,y.getPatternPreview=G,y.ruRU=Pe,y.zhCN=pe,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
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.15.1",
56
+ "@wendellhu/redi": "0.15.2",
57
57
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
58
58
  "rxjs": ">=7.0.0",
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"
59
+ "@univerjs/core": "0.1.12",
60
+ "@univerjs/design": "0.1.12",
61
+ "@univerjs/engine-numfmt": "0.1.12",
62
+ "@univerjs/engine-render": "0.1.12",
63
+ "@univerjs/sheets": "0.1.12",
64
+ "@univerjs/sheets-ui": "0.1.12",
65
+ "@univerjs/ui": "0.1.12"
66
66
  },
67
67
  "dependencies": {
68
- "@univerjs/icons": "^0.1.45"
68
+ "@univerjs/icons": "^0.1.52"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/react": "^18.2.79",
72
- "@wendellhu/redi": "^0.15.1",
72
+ "@wendellhu/redi": "0.15.2",
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
77
  "vite": "^5.2.11",
78
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"
79
+ "@univerjs/design": "0.1.12",
80
+ "@univerjs/engine-formula": "0.1.12",
81
+ "@univerjs/engine-numfmt": "0.1.12",
82
+ "@univerjs/engine-render": "0.1.12",
83
+ "@univerjs/shared": "0.1.12",
84
+ "@univerjs/sheets": "0.1.12",
85
+ "@univerjs/sheets-ui": "0.1.12",
86
+ "@univerjs/ui": "0.1.12",
87
+ "@univerjs/core": "0.1.12"
88
88
  },
89
89
  "scripts": {
90
90
  "test": "vitest run",