@univerjs/sheets-numfmt-ui 0.5.4 → 0.5.5-experimental.20250123-34738ff

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,9 +1 @@
1
- "use strict";var ye=Object.defineProperty;var be=(t,e,n)=>e in t?ye(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var W=(t,e,n)=>be(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),ue=require("@univerjs/engine-render"),m=require("@univerjs/sheets-numfmt"),M=require("@univerjs/sheets-ui"),I=require("@univerjs/ui"),Ce=require("@univerjs/engine-formula"),ne=require("@univerjs/engine-numfmt"),S=require("@univerjs/sheets"),x=require("rxjs"),B=require("rxjs/operators"),_=require("react"),N=require("@univerjs/design"),se={};var Ie=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(t,e,n,r)=>{for(var s=r>1?void 0:r?Pe(e,n):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&Ie(e,n,s),s},U=(t,e)=>(n,r)=>e(n,r,t);const Z="SHEET_NUMFMT_ALERT";let te=class extends o.Disposable{constructor(t,e,n,r,s,i,c){super(),this._context=t,this._hoverManagerService=e,this._cellAlertManagerService=n,this._localeService=r,this._formulaDataModel=s,this._zenZoneService=i,this._numfmtService=c,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(x.debounceTime(100)).subscribe(t=>{var e;if(t){const n=t.location,r=this._context.unit,s=r.getActiveSheet();if(!s)return;const i=n.unitId,c=n.subUnitId;let a;const l=s.getCell(n.row,n.col);if(l!=null&&l.s){const d=r.getStyles().get(l.s);d!=null&&d.n&&(a=d.n)}if(a||(a=this._numfmtService.getValue(i,c,n.row,n.col)),!a){this._hideAlert();return}if(a.pattern===ne.DEFAULT_TEXT_FORMAT&&(l!=null&&l.v)&&o.isRealNum(l.v)){const d=this._cellAlertManagerService.currentAlert.get(Z),f=(e=d==null?void 0:d.alert)==null?void 0:e.location;if(f&&f.row===n.row&&f.col===n.col&&f.subUnitId===n.subUnitId&&f.unitId===n.unitId)return;this._cellAlertManagerService.showAlert({type:M.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n,width:200,height:74,key:Z});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(Z)}};te=Te([U(1,o.Inject(M.HoverManagerService)),U(2,o.Inject(M.CellAlertManagerService)),U(3,o.Inject(o.LocaleService)),U(4,o.Inject(Ce.FormulaDataModel)),U(5,I.IZenZoneService),U(6,o.Inject(S.INumfmtService))],te);const z={id:"sheet.operation.close.numfmt.panel",type:o.CommandType.OPERATION,handler:()=>!0},L={id:"sheet.operation.open.numfmt.panel",type:o.CommandType.OPERATION,handler:t=>(t.get(H).openPanel(),!0)};var J={exports:{}},F={};/**
2
- * @license React
3
- * react-jsx-runtime.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var ie;function Ee(){if(ie)return F;ie=1;var t=_,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(a,l,d){var f,h={},p=null,g=null;d!==void 0&&(p=""+d),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(g=l.ref);for(f in l)r.call(l,f)&&!i.hasOwnProperty(f)&&(h[f]=l[f]);if(a&&a.defaultProps)for(f in l=a.defaultProps,l)h[f]===void 0&&(h[f]=l[f]);return{$$typeof:e,type:a,key:p,ref:g,props:h,_owner:s.current}}return F.Fragment=n,F.jsx=c,F.jsxs=c,F}var oe;function Ne(){return oe||(oe=1,J.exports=Ee()),J.exports}var u=Ne(),Me=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Re=(t,e,n,r)=>{for(var s=r>1?void 0:r?je(e,n):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&Me(e,n,s),s},xe=(t,e)=>(n,r)=>e(n,r,t);const re=_.createContext([]);let k=class{constructor(t){this._localStorageService=t}_getKey(t){return`userHabitController_${t}`}async addHabit(t,e){const n=this._getKey(t);return this._localStorageService.getItem(n).then(r=>{r||this._localStorageService.setItem(n,e)})}markHabit(t,e){const n=this._getKey(t);this._localStorageService.getItem(n).then(r=>{if(r){const s=r.findIndex(i=>i===e);s>-1&&r.splice(s,1),r.unshift(e),this._localStorageService.setItem(n,r)}})}async getHabit(t,e){const n=this._getKey(t),r=await this._localStorageService.getItem(n);if(e&&r){const s=r.map((i,c,a)=>{const l=a.length;return{value:i,priority:l-c}});return e.sort((i,c)=>{var d,f;const a=((d=s.find(h=>h.value===i))==null?void 0:d.priority)||-1;return(((f=s.find(h=>h.value===c))==null?void 0:f.priority)||-1)-a})}return r||[]}deleteHabit(t){this._localStorageService.removeItem(t)}};k=Re([xe(0,o.Inject(o.ILocalStorageService))],k);const ce="numfmtCurrency",Oe=t=>{const e=o.useDependency(k),[n,r]=_.useState(m.currencySymbols);return _.useEffect(()=>{e.addHabit("numfmtCurrency",[]).then(()=>{e.getHabit(ce,[...m.currencySymbols]).then(i=>{r(i),t(i)})})},[]),{userHabitCurrency:n,mark:i=>{e.markHabit(ce,i)}}},De=()=>{const t=_.useRef([]),[e,n]=_.useState({});return _.useEffect(()=>{t.current.forEach(s=>{s()}),t.current=[]},[e]),s=>{t.current.push(s),n({})}},Ue=t=>!!m.getCurrencyType(t)&&t.startsWith("_("),we=t=>{const{defaultPattern:e,action:n,onChange:r}=t,[s,i]=_.useState(()=>m.getDecimalFromPattern(e||"",2)),c=_.useContext(re),[a,l]=_.useState(()=>m.getCurrencyType(e)||c[0]),d=_.useMemo(()=>c.map(y=>({label:y,value:y})),[]),h=o.useDependency(o.LocaleService).t;n.current=()=>m.setPatternDecimal(`_("${a}"* #,##0${s>0?".0":""}_)`,s);const p=y=>{l(y),r(m.setPatternDecimal(`_("${y}"* #,##0${s>0?".0":""}_)`,s))},g=y=>{const v=y||0;i(v),r(m.setPatternDecimal(`_("${a}"* #,##0${v>0?".0":""}_)`,v))};return u.jsxs("div",{children:[u.jsxs("div",{className:"m-t-16 options",children:[u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:h("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8 w-120",children:u.jsx(N.InputNumber,{value:s,max:20,min:0,onChange:g})})]}),u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:h("sheet.numfmt.currencyType")}),u.jsx("div",{className:"m-t-8 w-140",children:u.jsx(N.Select,{onChange:p,options:d,value:a})})]})]}),u.jsx("div",{className:"describe m-t-14",children:h("sheet.numfmt.accountingDes")})]})},Fe=t=>!!m.getCurrencyType(t)&&!t.startsWith("_("),$e=t=>{const n=o.useDependency(o.LocaleService).t,r=_.useContext(re),[s,i]=_.useState(()=>m.getCurrencyType(t.defaultPattern)||r[0]),[c,a]=_.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",2)),[l,d]=_.useState(()=>{var b;const v=m.getCurrencyFormatOptions(s);return((b=v.find(T=>m.isPatternEqualWithoutDecimal(T.value,t.defaultPattern)))==null?void 0:b.value)||v[0].value}),f=_.useMemo(()=>m.getCurrencyFormatOptions(s),[s]),h=_.useMemo(()=>r.map(v=>({label:v,value:v})),[r]);t.action.current=()=>m.setPatternDecimal(l,c);const p=v=>{if(v===void 0)return;i(v);const P=m.getCurrencyFormatOptions(v)[0].value;d(P),t.onChange(m.setPatternDecimal(P,c))},g=v=>{v!==void 0&&(d(v),t.onChange(m.setPatternDecimal(v,c)))},y=v=>{a(v||0),t.onChange(m.setPatternDecimal(l,v||0))};return u.jsxs("div",{children:[u.jsxs("div",{className:"m-t-16 options",children:[u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:n("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8 w-120",children:u.jsx(N.InputNumber,{value:c,max:20,min:0,onChange:y})})]}),u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:n("sheet.numfmt.currencyType")}),u.jsx("div",{className:"m-t-8 w-140",children:u.jsx(N.Select,{onChange:p,options:h,value:s})})]})]}),u.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.negType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(N.SelectList,{onChange:g,options:f,value:l})}),u.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.currencyDes")})]})};var E=function(){return E=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},E.apply(this,arguments)},Le=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n},me=_.forwardRef(function(t,e){var n=t.icon,r=t.id,s=t.className,i=t.extend,c=Le(t,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),l=_.useRef("_".concat(Ae()));return de(n,"".concat(r),{defIds:n.defIds,idSuffix:l.current},E({ref:e,className:a},c),i)});function de(t,e,n,r,s){return _.createElement(t.tag,E(E({key:e},ke(t,n,s)),r),(He(t,n).children||[]).map(function(i,c){return de(i,"".concat(e,"-").concat(t.tag,"-").concat(c),n,void 0,s)}))}function ke(t,e,n){var r=E({},t.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(i){var c=i[0],a=i[1];typeof a=="string"&&(r[c]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function He(t,e){var n,r=e.defIds;return!r||r.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?E(E({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?E(E({},s),{attrs:E(E({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function Ae(){return Math.random().toString(36).substring(2,8)}me.displayName="UniverIcon";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},he=_.forwardRef(function(t,e){return _.createElement(me,Object.assign({},t,{id:"check-mark-single",ref:e,icon:We}))});he.displayName="CheckMarkSingle";const Be="univer-custom-format-title",Ve="univer-custom-format-input",qe="univer-custom-format-history-list",Ge="univer-custom-format-history-list-item",Ke="univer-custom-format-history-list-item-icon-wrap",Ye="univer-custom-format-des",O={customFormatTitle:Be,customFormatInput:Ve,customFormatHistoryList:qe,customFormatHistoryListItem:Ge,customFormatHistoryListItemIconWrap:Ke,customFormatDes:Ye},X="customFormat",Q="numfmt_custom_pattern";function Ze(t){const{defaultPattern:e,action:n,onChange:r}=t,s=o.useDependency(k),i=o.useDependency(o.ILocalStorageService),c=o.useDependency(o.LocaleService),[a,l]=_.useState(e);n.current=()=>(s.markHabit(X,a),i.getItem(Q).then((g=[])=>{const y=[...new Set([a,...g||[]])].splice(0,10).filter(v=>!!v);i.setItem(Q,y)}),a);const[d,f]=_.useState([]);_.useEffect(()=>{i.getItem(Q).then(g=>{const y=[...m.CURRENCYFORMAT.map(v=>v.suffix("$")),...m.DATEFMTLISG.map(v=>v.suffix),...m.NUMBERFORMAT.map(v=>v.suffix)];y.push(...g||[]),s.addHabit(X,[]).finally(()=>{s.getHabit(X,y).then(v=>{f([...new Set(v)])})})})},[]);const h=g=>{l(g),r(g)},p=()=>{r(a)};return u.jsxs("div",{className:O.customFormat,children:[u.jsx("div",{className:O.customFormatTitle,children:c.t("sheet.numfmt.customFormat")}),u.jsx(N.Input,{placeholder:c.t("sheet.numfmt.customFormat"),onBlur:p,value:a,onChange:l,className:O.customFormatInput}),u.jsx("div",{className:O.customFormatHistoryList,children:d.map(g=>u.jsxs("div",{onClick:()=>h(g),className:O.customFormatHistoryListItem,children:[u.jsx("div",{className:O.customFormatHistoryListItemIconWrap,children:a===g&&u.jsx(he,{})}),u.jsx("div",{children:g})]},g))}),u.jsx("div",{className:O.customFormatDes,children:c.t("sheet.numfmt.customFormatDes")})]})}const ze=t=>{const e=o.numfmt.getInfo(t);return m.getDateFormatOptions().map(n=>n.value).includes(t)||["date","datetime","time"].includes(e.type)},Je=t=>{const e=_.useMemo(m.getDateFormatOptions,[]),r=o.useDependency(o.LocaleService).t,[s,i]=_.useState(()=>{if(t.defaultPattern){const a=e.find(l=>l.value===t.defaultPattern);if(a)return a.value}return e[0].value});t.action.current=()=>s;const c=a=>{a!==void 0&&(i(a),t.onChange(a))};return u.jsxs("div",{children:[u.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.dateType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(N.SelectList,{value:s,options:e,onChange:c})}),u.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.dateDes")})]})},Xe=t=>!t,Qe=t=>{const n=o.useDependency(o.LocaleService).t;return t.action.current=()=>"",u.jsx("div",{children:u.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.generalDes")})})},et=t=>m.getNumberFormatOptions().some(e=>m.isPatternEqualWithoutDecimal(e.value,t)),tt=t=>{const e=o.useDependency(o.LocaleService),n=_.useMemo(m.getNumberFormatOptions,[]),[r,s]=_.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",0)),[i,c]=_.useState(()=>{const h=n.find(p=>m.isPatternEqualWithoutDecimal(p.value,t.defaultPattern||""));return(h==null?void 0:h.value)||n[0].value}),a=_.useMemo(()=>m.setPatternDecimal(i,Number(r||0)),[i,r]),l=_.useMemo(()=>!m.isPatternHasDecimal(i),[i]),d=h=>{s(h||0),t.onChange(m.setPatternDecimal(i,Number(h||0)))},f=h=>{h!==void 0&&(s(m.getDecimalFromPattern(h,0)),c(h),t.onChange(h))};return t.action.current=()=>a,u.jsxs("div",{children:[u.jsx("div",{className:"m-t-16 label",children:e.t("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8",children:u.jsx(N.InputNumber,{disabled:l,value:r,max:20,min:0,onChange:d})}),u.jsxs("div",{className:"m-t-16 label",children:[" ",e.t("sheet.numfmt.negType")]}),u.jsx("div",{className:"m-t-8",children:u.jsx(N.SelectList,{onChange:f,options:n,value:i})}),u.jsx("div",{className:"describe m-t-14",children:e.t("sheet.numfmt.thousandthPercentileDes")})]})},nt=t=>{const{defaultValue:e,defaultPattern:n,row:r,col:s}=t.value,i=o.useDependency(o.LocaleService),c=_.useRef(()=>""),a=i.t,l=De(),d=_.useMemo(()=>[{label:"sheet.numfmt.general",component:Qe},{label:"sheet.numfmt.accounting",component:we},{label:"sheet.numfmt.currency",component:$e},{label:"sheet.numfmt.date",component:Je},{label:"sheet.numfmt.thousandthPercentile",component:tt},{label:"sheet.numfmt.customFormat",component:Ze}].map(C=>({...C,label:a(C.label)})),[]),[f,h]=_.useState(b),[p,g]=_.useState(()=>`${r}_${s}`),{mark:y,userHabitCurrency:v}=Oe(()=>g(`${r}_${s}_userCurrency'`)),P=_.useMemo(()=>{var C;return(C=d.find(D=>D.label===f))==null?void 0:C.component},[f]);function b(){return[Xe,Ue,Fe,ze,et].reduce((D,ge,_e)=>D||(ge(n)?d[_e].label:""),"")||d[0].label}const T=d.map(C=>({label:C.label,value:C.label})),j=C=>{h(C),l(()=>t.onChange({type:"change",value:c.current()||""}))},A=C=>{t.onChange({type:"change",value:C})},K=()=>{const C=c.current()||"",D=m.getCurrencyType(C);D&&y(D),t.onChange({type:"confirm",value:C})},w=()=>{t.onChange({type:"cancel",value:""})},Y={onChange:A,defaultValue:e,defaultPattern:n,action:c};return _.useEffect(()=>{h(b()),g(`${r}_${s}`)},[r,s]),u.jsxs("div",{className:"numfmt-panel p-b-20",children:[u.jsxs("div",{children:[u.jsx("div",{className:"label m-t-14",children:a("sheet.numfmt.numfmtType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(N.Select,{onChange:j,options:T,value:f,style:{width:"100%"}})}),u.jsx("div",{children:P&&u.jsx(re.Provider,{value:v,children:_.createElement(P,{...Y,key:p})})})]}),u.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[u.jsx(N.Button,{size:"small",onClick:w,className:"m-r-12",children:a("sheet.numfmt.cancel")}),u.jsx(N.Button,{type:"primary",size:"small",onClick:K,children:a("sheet.numfmt.confirm")})]})]})};var rt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,it=(t,e,n,r)=>{for(var s=r>1?void 0:r?st(e,n):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&rt(e,n,s),s},R=(t,e)=>(n,r)=>e(n,r,t);const ae="SHEET_NUMFMT_PANEL";let H=class extends o.Disposable{constructor(e,n,r,s,i,c,a,l,d,f){super();W(this,"_previewPattern","");W(this,"_sidebarDisposable",null);this._sheetInterceptorService=e,this._themeService=n,this._univerInstanceService=r,this._commandService=s,this._selectionManagerService=i,this._renderManagerService=c,this._numfmtService=a,this._componentManager=l,this._sidebarService=d,this._localeService=f,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener()}openPanel(){var P;const e=this._sidebarService,n=this._selectionManagerService,r=this._commandService,s=this._univerInstanceService,i=this._numfmtService,c=this._localeService,l=(((P=n.getCurrentSelections())==null?void 0:P.map(b=>b.range))||[])[0];if(!l)return!1;const d=s.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),f=d.getActiveSheet();if(!f)return!1;const h=f.getCellRaw(l.startRow,l.startColumn),p=i.getValue(d.getUnitId(),f.getSheetId(),l.startRow,l.startColumn);let g="";p&&(g=p.pattern);const y=(h==null?void 0:h.t)===o.CellValueType.NUMBER?h.v:12345678,v={onChange:b=>{var T;if(b.type==="change")this._previewPattern=b.value,this._forceUpdate();else if(b.type==="confirm"){const j=((T=n.getCurrentSelections())==null?void 0:T.map(w=>w.range))||[],A={values:[]},K=m.getPatternType(b.value);j.forEach(w=>{o.Range.foreach(w,(Y,C)=>{A.values.push({row:Y,col:C,pattern:b.value,type:K})})}),r.executeCommand(m.SetNumfmtCommand.id,A),e.close()}else b.type==="cancel"&&e.close()},value:{defaultPattern:g,defaultValue:y,row:l.startRow,col:l.startColumn}};return this._sidebarDisposable=e.open({header:{title:c.t("sheet.numfmt.title")},children:{label:ae,...v},onClose:()=>{this._forceUpdate(),r.executeCommand(z.id)}}),!0}_forceUpdate(e){var r;const n=this._renderManagerService.getRenderById(e!=null?e:this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getUnitId());n==null||n.with(M.SheetSkeletonManagerService).reCalculate(),(r=n==null?void 0:n.mainComponent)==null||r.makeDirty()}_initCommands(){[L,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initPanel(){this._componentManager.register(ae,nt)}_initRealTimeRenderingInterceptor(){const e=new x.Observable(r=>{this._commandService.onCommandExecuted(s=>{s.id===L.id&&r.next(!0),s.id===z.id&&r.next(!1)})}),n=x.combineLatest([e,this._selectionManagerService.selectionMoveEnd$.pipe(B.map(r=>r?r.map(s=>s.range):[]))]);this.disposeWithMe(o.toDisposable(n.pipe(B.switchMap(([r,s])=>new x.Observable(i=>{const c=new o.DisposableCollection;return r&&s.length&&i.next({selectionRanges:s,disposableCollection:c}),()=>{c.dispose()}})),B.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:r,selectionRanges:s})=>{var c,a;const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);this.openPanel(),r.add(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:o.InterceptorEffectEnum.Value|o.InterceptorEffectEnum.Style,handler:(l,d,f)=>{const{row:h,col:p}=d,g=f(l)||{};if(s.find(y=>y.startColumn<=p&&y.endColumn>=p&&y.startRow<=h&&y.endRow>=h)){const y=d.worksheet.getCellRaw(h,p),v=y==null?void 0:y.v,P=y==null?void 0:y.t;if(v==null||P!==o.CellValueType.NUMBER||this._previewPattern===null)return g;const b=m.getPatternPreviewIgnoreGeneral(this._previewPattern,v,this._localeService.getCurrentLocale());if(b.color){const j=this._themeService.getCurrentTheme()[`${b.color}500`];return{...g,v:b.result,t:o.CellValueType.STRING,s:{cl:{rgb:j}}}}return{...g,v:b.result,t:o.CellValueType.STRING}}return g}})),(a=(c=this._renderManagerService.getRenderById(i.getUnitId()))==null?void 0:c.mainComponent)==null||a.makeDirty()})))}_commandExecutedListener(){const e=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id];this.disposeWithMe(new x.Observable(n=>{const r=this._commandService.onCommandExecuted(s=>{if(e.includes(s.id)){const i=s.params;n.next(i.unitId)}});return()=>r.dispose()}).pipe(B.debounceTime(16)).subscribe(n=>this._forceUpdate(n)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{var n;e||((n=this._sidebarDisposable)==null||n.dispose(),this._sidebarDisposable=null)})}};H=it([R(0,o.Inject(S.SheetInterceptorService)),R(1,o.Inject(o.ThemeService)),R(2,o.IUniverInstanceService),R(3,o.ICommandService),R(4,o.Inject(S.SheetsSelectionsService)),R(5,ue.IRenderManagerService),R(6,S.INumfmtService),R(7,o.Inject(I.ComponentManager)),R(8,I.ISidebarService),R(9,o.Inject(o.LocaleService))],H);var ot=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,at=(t,e,n,r)=>{for(var s=r>1?void 0:r?ct(e,n):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&ot(e,n,s),s},$=(t,e)=>(n,r)=>e(n,r,t);const lt=()=>{let t=[];return{add:(s,i,c,a,l)=>t.push({unitId:s,subUnitId:i,row:c,col:a,value:l}),getEffects:()=>t,clean:()=>{t=[]}}};let q=class extends o.Disposable{constructor(e,n,r,s,i){super();W(this,"_collectEffectMutation",lt());this._sheetInterceptorService=e,this._numfmtService=n,this._univerInstanceService=r,this._injector=s,this._editorBridgeService=i,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.BEFORE_CELL_EDIT,{handler:(e,n,r)=>{const s=n.row,i=n.col,c=this._numfmtService.getValue(n.unitId,n.subUnitId,s,i);if(c)switch(m.getPatternType(c.pattern)){case"scientific":case"currency":case"grouped":case"number":return n.worksheet.getCellRaw(s,i);case"percent":case"date":case"time":case"datetime":default:return r&&r(e)}return r(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.AFTER_CELL_EDIT,{handler:(e,n,r)=>{var f,h,p,g;this._collectEffectMutation.clean();const s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),i=(f=s&&m.getPatternType(s.pattern))!=null?f:"",c=()=>{s&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,null)};if(!(e!=null&&e.v)&&!(e!=null&&e.p)||(s==null?void 0:s.pattern)===ne.DEFAULT_TEXT_FORMAT||e.t===o.CellValueType.FORCE_STRING)return r(e);const a=(h=e.p)==null?void 0:h.body,l=(g=(p=e==null?void 0:e.p)==null?void 0:p.body)!=null&&g.dataStream?e.p.body.dataStream.replace(/\r\n$/,""):String(e.v),d=o.numfmt.parseDate(l)||o.numfmt.parseTime(l)||o.numfmt.parseNumber(l);if(a)if(mt(a)){const{dataStream:y}=a,v=y.replace(/\r\n$/,""),P=Number(v);if(Number.isNaN(P)&&!d)return r(e)}else return r(e);if(d){d.z&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:d.z});const y=Number(d.v);return r({...e,p:void 0,v:y,t:o.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(i)||!ut(l))&&c();return r(e)}})))}_initInterceptorCommands(){const e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(n){var r;switch(n.id){case S.SetRangeValuesCommand.id:{const s=e._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),i=s.getUnitId(),c=(r=s.getActiveSheet())==null?void 0:r.getSheetId();if(!c)return{redos:[],undos:[]};const a=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!a.length)return{redos:[],undos:[]};const l=a.filter(p=>{var g;return!!((g=p.value)!=null&&g.pattern)}).map(p=>({row:p.row,col:p.col,pattern:p.value.pattern})),d=a.filter(p=>{var g;return!((g=p.value)!=null&&g.pattern)}).map(p=>({startRow:p.row,endColumn:p.col,startColumn:p.col,endRow:p.row})),f=[],h=[];if(l.length){const p={id:S.SetNumfmtMutation.id,params:S.transformCellsToRange(i,c,l)};f.push(p),h.push(...S.factorySetNumfmtUndoMutation(e._injector,p.params))}if(d.length){const p={id:S.RemoveNumfmtMutation.id,params:{unitId:i,subUnitId:c,ranges:d}};f.push(p),h.push(...S.factoryRemoveNumfmtUndoMutation(e._injector,p.params))}return{redos:f,undos:h.reverse()}}}return{redos:[],undos:[]}}}))}};q=at([$(0,o.Inject(S.SheetInterceptorService)),$(1,o.Inject(S.INumfmtService)),$(2,o.Inject(o.IUniverInstanceService)),$(3,o.Inject(o.Injector)),$(4,o.Optional(M.IEditorBridgeService))],q);function ut(t){return/^-?\d+(\.\d+)?$/.test(t)}function mt(t){const{textRuns:e=[],paragraphs:n=[],customRanges:r,customBlocks:s=[]}=t,i=["va"];return!(e.some(c=>!!(c.ts&&Object.keys(c.ts).some(l=>i.includes(l))))||n.some(c=>c.bullet)||n.length>=2||r!=null&&r.length||s.length>0)}const V=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:ne.DEFAULT_TEXT_FORMAT},"|",{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:""}],dt=t=>({icon:new x.Observable(e=>{const n=t.get(m.MenuCurrencyService);function r(i){return{[m.countryCurrencyMap.US]:"DollarSingle",[m.countryCurrencyMap.RU]:"RoubleSingle",[m.countryCurrencyMap.CN]:"RmbSingle",[m.countryCurrencyMap.AT]:"EuroSingle"}[i]||"DollarSingle"}const s=m.countryCurrencyMap[n.getCurrencySymbol()]||"$";return e.next(r(s)),n.currencySymbol$.subscribe(i=>{const c=m.countryCurrencyMap[i]||"$";e.next(r(c))})}),id:m.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),ht=t=>({icon:"AddDigitsSingle",id:m.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),ft=t=>({icon:"ReduceDigitsSingle",id:m.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),pt=t=>({icon:"PercentSingle",id:m.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),vt=t=>{const e=t.get(o.IUniverInstanceService),n=t.get(o.ICommandService),r=t.get(o.LocaleService),s=t.get(S.SheetsSelectionsService),i=M.deriveStateFromActiveSheet$(e,"",({workbook:c,worksheet:a})=>new x.Observable(l=>x.merge(s.selectionMoveEnd$,new x.Observable(d=>{const f=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id],h=n.onCommandExecuted(p=>{f.includes(p.id)&&d.next(null)});return()=>h.dispose()})).subscribe(()=>{var f,h;const d=s.getCurrentSelections();if(d&&d[0]){const p=d[0].range,g=p.startRow,y=p.startColumn,v=(h=c.getStyles().get((f=a.getCell(g,y))==null?void 0:f.s))==null?void 0:h.n,P=v==null?void 0:v.pattern;let b=r.t("sheet.numfmt.general");if(P){const T=V.filter(j=>typeof j=="object"&&j.pattern).find(j=>m.isPatternEqualWithoutDecimal(P,j.pattern));T&&typeof T=="object"&&T.pattern?b=r.t(T.label):b=r.t("sheet.numfmt.moreFmt")}l.next(b)}})));return{label:fe,id:L.id,tooltip:"sheet.numfmt.title",type:I.MenuItemType.SELECTOR,selections:[{label:{name:pe,hoverable:!1}}],value$:i,hidden$:I.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetSetCellStylePermission,S.WorksheetEditPermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}},fe="sheet.numfmt.moreNumfmtType",pe="sheet.numfmt.moreNumfmtType.options",St=t=>{var r;const e=o.useDependency(o.LocaleService),n=(r=t.value)!=null?r:e.t("sheet.numfmt.general");return u.jsx("span",{className:"more-numfmt-type",children:n})},gt=()=>{const t=o.useDependency(o.ICommandService),e=o.useDependency(o.LocaleService),n=o.useDependency(I.ILayoutService);o.useInjector();const r=o.useDependency(S.SheetsSelectionsService),s=a=>{const l=r.getCurrentLastSelection();if(!l)return;const d=l.range,f=[];o.Range.foreach(d,(h,p)=>{a?f.push({row:h,col:p,pattern:a,type:m.getPatternType(a)}):f.push({row:h,col:p})}),t.executeCommand(m.SetNumfmtCommand.id,{values:f}),n.focus()},i=a=>{if(a===0)s(null);else if(a===V.length-1)t.executeCommand(L.id);else{const l=V[a];l.pattern&&s(l.pattern)}},c=1220;return u.jsx("div",{className:"more-numfmt-type-options",children:V.map((a,l)=>a==="|"?u.jsx("div",{className:"line m-t-4",onClick:d=>d.stopPropagation()},l):u.jsxs("div",{className:"option-item m-t-4",onClick:()=>{i(l)},children:[u.jsx("div",{children:e.t(a.label)}),u.jsx("div",{className:"m-l-26",children:a.pattern?m.getPatternPreview(a.pattern||"",c,e.getCurrentLocale()).result:""})]},l))})},_t={[I.RibbonStartGroup.FORMULAS_INSERT]:{[m.SetCurrencyCommand.id]:{order:4,menuItemFactory:dt},[m.AddDecimalCommand.id]:{order:5,menuItemFactory:ht},[m.SubtractDecimalCommand.id]:{order:6,menuItemFactory:ft},[m.SetPercentCommand.id]:{order:7,menuItemFactory:pt},[L.id]:{order:8,menuItemFactory:vt}}};var yt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Ct=(t,e,n,r)=>{for(var s=r>1?void 0:r?bt(e,n):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&yt(e,n,s),s},le=(t,e)=>(n,r)=>e(n,r,t);let G=class extends o.Disposable{constructor(t,e){super(),this._componentManager=t,this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(_t),this.disposeWithMe(this._componentManager.register(fe,St)),this.disposeWithMe(this._componentManager.register(pe,gt))}};G=Ct([le(0,o.Inject(I.ComponentManager)),le(1,I.IMenuManagerService)],G);var ve=Object.defineProperty,It=Object.getOwnPropertyDescriptor,Pt=(t,e,n)=>e in t?ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Tt=(t,e,n,r)=>{for(var s=r>1?void 0:r?It(e,n):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&ve(e,n,s),s},ee=(t,e)=>(n,r)=>e(n,r,t),Se=(t,e,n)=>Pt(t,typeof e!="symbol"?e+"":e,n);const Et="SHEET_NUMFMT_UI_PLUGIN";exports.UniverSheetsNumfmtUIPlugin=class extends o.Plugin{constructor(e=se,n,r,s){super(),this._config=e,this._injector=n,this._configService=r,this._renderManagerService=s;const{menu:i,...c}=o.merge({},se,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(I.UI_PLUGIN_CONFIG_KEY,c)}onStarting(){o.registerDependencies(this._injector,[[H],[q],[k],[G]])}onRendered(){this._registerRenderModules(),o.touchDependencies(this._injector,[[H],[q],[G]])}_registerRenderModules(){[[te]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,n))})}};Se(exports.UniverSheetsNumfmtUIPlugin,"pluginName",Et);Se(exports.UniverSheetsNumfmtUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtUIPlugin=Tt([o.DependentOn(M.UniverSheetsUIPlugin,m.UniverSheetsNumfmtPlugin),ee(1,o.Inject(o.Injector)),ee(2,o.IConfigService),ee(3,ue.IRenderManagerService)],exports.UniverSheetsNumfmtUIPlugin);
1
+ "use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key2,value)=>key2 in obj?__defProp(obj,key2,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key2]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key2,value)=>__defNormalProp(obj,typeof key2!="symbol"?key2+"":key2,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),engineRender=require("@univerjs/engine-render"),sheetsNumfmt=require("@univerjs/sheets-numfmt"),sheetsUi=require("@univerjs/sheets-ui"),ui=require("@univerjs/ui"),engineFormula=require("@univerjs/engine-formula"),engineNumfmt=require("@univerjs/engine-numfmt"),sheets=require("@univerjs/sheets"),rxjs=require("rxjs"),operators=require("rxjs/operators"),jsxRuntime=require("react/jsx-runtime"),react=require("react"),design=require("@univerjs/design"),defaultPluginConfig={};var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key2,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key2):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key2,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key2,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key2)=>decorator(target,key2,index),"__decorateParam$5");const ALERT_KEY="SHEET_NUMFMT_ALERT";var _a;let NumfmtAlertRenderController=(_a=class extends core.Disposable{constructor(_context,_hoverManagerService,_cellAlertManagerService,_localeService,_formulaDataModel,_zenZoneService,_numfmtService){super(),this._context=_context,this._hoverManagerService=_hoverManagerService,this._cellAlertManagerService=_cellAlertManagerService,this._localeService=_localeService,this._formulaDataModel=_formulaDataModel,this._zenZoneService=_zenZoneService,this._numfmtService=_numfmtService,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(rxjs.debounceTime(100)).subscribe(cellPos=>{var _a7;if(cellPos){const location=cellPos.location,workbook=this._context.unit,worksheet=workbook.getActiveSheet();if(!worksheet)return;const unitId=location.unitId,sheetId=location.subUnitId;let numfmtValue;const cellData=worksheet.getCell(location.row,location.col);if(cellData!=null&&cellData.s){const style=workbook.getStyles().get(cellData.s);style!=null&&style.n&&(numfmtValue=style.n)}if(numfmtValue||(numfmtValue=this._numfmtService.getValue(unitId,sheetId,location.row,location.col)),!numfmtValue){this._hideAlert();return}if(numfmtValue.pattern===engineNumfmt.DEFAULT_TEXT_FORMAT&&(cellData!=null&&cellData.v)&&core.isRealNum(cellData.v)){const currentAlert=this._cellAlertManagerService.currentAlert.get(ALERT_KEY),currentLoc=(_a7=currentAlert==null?void 0:currentAlert.alert)==null?void 0:_a7.location;if(currentLoc&&currentLoc.row===location.row&&currentLoc.col===location.col&&currentLoc.subUnitId===location.subUnitId&&currentLoc.unitId===location.unitId)return;this._cellAlertManagerService.showAlert({type:sheetsUi.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location,width:200,height:74,key:ALERT_KEY});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(visible=>{visible&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(ALERT_KEY)}},__name(_a,"NumfmtAlertRenderController"),_a);NumfmtAlertRenderController=__decorateClass$5([__decorateParam$5(1,core.Inject(sheetsUi.HoverManagerService)),__decorateParam$5(2,core.Inject(sheetsUi.CellAlertManagerService)),__decorateParam$5(3,core.Inject(core.LocaleService)),__decorateParam$5(4,core.Inject(engineFormula.FormulaDataModel)),__decorateParam$5(5,ui.IZenZoneService),__decorateParam$5(6,core.Inject(sheets.INumfmtService))],NumfmtAlertRenderController);const CloseNumfmtPanelOperator={id:"sheet.operation.close.numfmt.panel",type:core.CommandType.OPERATION,handler:__name(()=>!0,"handler")},OpenNumfmtPanelOperator={id:"sheet.operation.open.numfmt.panel",type:core.CommandType.OPERATION,handler:__name(accessor=>(accessor.get(SheetNumfmtUIController).openPanel(),!0),"handler")};var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key2,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key2):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key2,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key2,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key2)=>decorator(target,key2,index),"__decorateParam$4");const UserHabitCurrencyContext=react.createContext([]);var _a2;let UserHabitController=(_a2=class{constructor(_localStorageService){this._localStorageService=_localStorageService}_getKey(habit){return`userHabitController_${habit}`}async addHabit(habit,initValue){const key2=this._getKey(habit);return this._localStorageService.getItem(key2).then(item=>{item||this._localStorageService.setItem(key2,initValue)})}markHabit(habit,value){const key2=this._getKey(habit);this._localStorageService.getItem(key2).then(list=>{if(list){const index=list.findIndex(item=>item===value);index>-1&&list.splice(index,1),list.unshift(value),this._localStorageService.setItem(key2,list)}})}async getHabit(habit,sortList){const key2=this._getKey(habit),result=await this._localStorageService.getItem(key2);if(sortList&&result){const priority=result.map((item,index,arr)=>{const length=arr.length;return{value:item,priority:length-index}});return sortList.sort((a,b)=>{var _a7,_b;const ap=((_a7=priority.find(item=>item.value===a))==null?void 0:_a7.priority)||-1;return(((_b=priority.find(item=>item.value===b))==null?void 0:_b.priority)||-1)-ap})}return result||[]}deleteHabit(habit){this._localStorageService.removeItem(habit)}},__name(_a2,"UserHabitController"),_a2);UserHabitController=__decorateClass$4([__decorateParam$4(0,core.Inject(core.ILocalStorageService))],UserHabitController);const key$1="numfmtCurrency",useCurrencyOptions=__name(onOptionChange=>{const userHabitController=core.useDependency(UserHabitController),[options,optionsSet]=react.useState(sheetsNumfmt.currencySymbols);return react.useEffect(()=>{userHabitController.addHabit("numfmtCurrency",[]).then(()=>{userHabitController.getHabit(key$1,[...sheetsNumfmt.currencySymbols]).then(list=>{optionsSet(list),onOptionChange(list)})})},[]),{userHabitCurrency:options,mark:__name(v=>{userHabitController.markHabit(key$1,v)},"mark")}},"useCurrencyOptions"),useNextTick=__name(()=>{const effectList=react.useRef([]),[value,dispatch]=react.useState({});return react.useEffect(()=>{effectList.current.forEach(fn=>{fn()}),effectList.current=[]},[value]),__name(fn=>{effectList.current.push(fn),dispatch({})},"nextTick")},"useNextTick"),isAccountingPanel=__name(pattern=>!!sheetsNumfmt.getCurrencyType(pattern)&&pattern.startsWith("_("),"isAccountingPanel"),AccountingPanel=__name(props=>{const{defaultPattern,action,onChange}=props,[decimal,decimalSet]=react.useState(()=>sheetsNumfmt.getDecimalFromPattern(defaultPattern||"",2)),userHabitCurrency=react.useContext(UserHabitCurrencyContext),[suffix,suffixSet]=react.useState(()=>sheetsNumfmt.getCurrencyType(defaultPattern)||userHabitCurrency[0]),options=react.useMemo(()=>userHabitCurrency.map(key2=>({label:key2,value:key2})),[]),t=core.useDependency(core.LocaleService).t;action.current=()=>sheetsNumfmt.setPatternDecimal(`_("${suffix}"* #,##0${decimal>0?".0":""}_)`,decimal);const onSelect=__name(v=>{suffixSet(v),onChange(sheetsNumfmt.setPatternDecimal(`_("${v}"* #,##0${decimal>0?".0":""}_)`,decimal))},"onSelect"),onDecimalChange=__name(v=>{const decimal2=v||0;decimalSet(decimal2),onChange(sheetsNumfmt.setPatternDecimal(`_("${suffix}"* #,##0${decimal2>0?".0":""}_)`,decimal2))},"onDecimalChange");return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"m-t-16 options",children:[jsxRuntime.jsxs("div",{className:"option",children:[jsxRuntime.jsx("div",{className:"label",children:t("sheet.numfmt.decimalLength")}),jsxRuntime.jsx("div",{className:"m-t-8 w-120",children:jsxRuntime.jsx(design.InputNumber,{value:decimal,max:20,min:0,onChange:onDecimalChange})})]}),jsxRuntime.jsxs("div",{className:"option",children:[jsxRuntime.jsx("div",{className:"label",children:t("sheet.numfmt.currencyType")}),jsxRuntime.jsx("div",{className:"m-t-8 w-140",children:jsxRuntime.jsx(design.Select,{onChange:onSelect,options,value:suffix})})]})]}),jsxRuntime.jsx("div",{className:"describe m-t-14",children:t("sheet.numfmt.accountingDes")})]})},"AccountingPanel"),isCurrencyPanel=__name(pattern=>!!sheetsNumfmt.getCurrencyType(pattern)&&!pattern.startsWith("_("),"isCurrencyPanel"),CurrencyPanel=__name(props=>{const t=core.useDependency(core.LocaleService).t,userHabitCurrency=react.useContext(UserHabitCurrencyContext),[suffix,suffixSet]=react.useState(()=>sheetsNumfmt.getCurrencyType(props.defaultPattern)||userHabitCurrency[0]),[decimal,decimalSet]=react.useState(()=>sheetsNumfmt.getDecimalFromPattern(props.defaultPattern||"",2)),[pattern,patternSet]=react.useState(()=>{var _a7;const negativeOptions2=sheetsNumfmt.getCurrencyFormatOptions(suffix);return((_a7=negativeOptions2.find(item=>sheetsNumfmt.isPatternEqualWithoutDecimal(item.value,props.defaultPattern)))==null?void 0:_a7.value)||negativeOptions2[0].value}),negativeOptions=react.useMemo(()=>sheetsNumfmt.getCurrencyFormatOptions(suffix),[suffix]),options=react.useMemo(()=>userHabitCurrency.map(key2=>({label:key2,value:key2})),[userHabitCurrency]);props.action.current=()=>sheetsNumfmt.setPatternDecimal(pattern,decimal);const onSelect=__name(value=>{if(value===void 0)return;suffixSet(value);const pattern2=sheetsNumfmt.getCurrencyFormatOptions(value)[0].value;patternSet(pattern2),props.onChange(sheetsNumfmt.setPatternDecimal(pattern2,decimal))},"onSelect"),onChange=__name(value=>{value!==void 0&&(patternSet(value),props.onChange(sheetsNumfmt.setPatternDecimal(value,decimal)))},"onChange"),onDecimalChange=__name(v=>{decimalSet(v||0),props.onChange(sheetsNumfmt.setPatternDecimal(pattern,v||0))},"onDecimalChange");return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"m-t-16 options",children:[jsxRuntime.jsxs("div",{className:"option",children:[jsxRuntime.jsx("div",{className:"label",children:t("sheet.numfmt.decimalLength")}),jsxRuntime.jsx("div",{className:"m-t-8 w-120",children:jsxRuntime.jsx(design.InputNumber,{value:decimal,max:20,min:0,onChange:onDecimalChange})})]}),jsxRuntime.jsxs("div",{className:"option",children:[jsxRuntime.jsx("div",{className:"label",children:t("sheet.numfmt.currencyType")}),jsxRuntime.jsx("div",{className:"m-t-8 w-140",children:jsxRuntime.jsx(design.Select,{onChange:onSelect,options,value:suffix})})]})]}),jsxRuntime.jsx("div",{className:"m-t-16 label",children:t("sheet.numfmt.negType")}),jsxRuntime.jsx("div",{className:"m-t-8",children:jsxRuntime.jsx(design.SelectList,{onChange,options:negativeOptions,value:pattern})}),jsxRuntime.jsx("div",{className:"describe m-t-14",children:t("sheet.numfmt.currencyDes")})]})},"CurrencyPanel");var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=react.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=react.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return react.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a7){var key2=_a7[0],value=_a7[1];typeof value=="string"&&(attrs[key2]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a7,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a7=node.children)===null||_a7===void 0)&&_a7.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},CheckMarkSingle=react.forwardRef(function(props,ref){return react.createElement(IconBase,Object.assign({},props,{id:"check-mark-single",ref,icon:element}))});CheckMarkSingle.displayName="CheckMarkSingle";const customFormatTitle="univer-custom-format-title",customFormatInput="univer-custom-format-input",customFormatHistoryList="univer-custom-format-history-list",customFormatHistoryListItem="univer-custom-format-history-list-item",customFormatHistoryListItemIconWrap="univer-custom-format-history-list-item-icon-wrap",customFormatDes="univer-custom-format-des",styles={customFormatTitle,customFormatInput,customFormatHistoryList,customFormatHistoryListItem,customFormatHistoryListItemIconWrap,customFormatDes},key="customFormat",historyPatternKey="numfmt_custom_pattern";function CustomFormat(props){const{defaultPattern,action,onChange}=props,userHabitController=core.useDependency(UserHabitController),localStorageService=core.useDependency(core.ILocalStorageService),localeService=core.useDependency(core.LocaleService),[pattern,patternSet]=react.useState(defaultPattern);action.current=()=>(userHabitController.markHabit(key,pattern),localStorageService.getItem(historyPatternKey).then((list=[])=>{const _list=[...new Set([pattern,...list||[]])].splice(0,10).filter(e=>!!e);localStorageService.setItem(historyPatternKey,_list)}),pattern);const[options,optionsSet]=react.useState([]);react.useEffect(()=>{localStorageService.getItem(historyPatternKey).then(historyList=>{const list=[...sheetsNumfmt.CURRENCYFORMAT.map(item=>item.suffix("$")),...sheetsNumfmt.DATEFMTLISG.map(item=>item.suffix),...sheetsNumfmt.NUMBERFORMAT.map(item=>item.suffix)];list.push(...historyList||[]),userHabitController.addHabit(key,[]).finally(()=>{userHabitController.getHabit(key,list).then(list2=>{optionsSet([...new Set(list2)])})})})},[]);const handleClick=__name(p=>{patternSet(p),onChange(p)},"handleClick"),handleBlur=__name(()=>{onChange(pattern)},"handleBlur");return jsxRuntime.jsxs("div",{className:styles.customFormat,children:[jsxRuntime.jsx("div",{className:styles.customFormatTitle,children:localeService.t("sheet.numfmt.customFormat")}),jsxRuntime.jsx(design.Input,{placeholder:localeService.t("sheet.numfmt.customFormat"),onBlur:handleBlur,value:pattern,onChange:patternSet,className:styles.customFormatInput}),jsxRuntime.jsx("div",{className:styles.customFormatHistoryList,children:options.map(p=>jsxRuntime.jsxs("div",{onClick:__name(()=>handleClick(p),"onClick"),className:styles.customFormatHistoryListItem,children:[jsxRuntime.jsx("div",{className:styles.customFormatHistoryListItemIconWrap,children:pattern===p&&jsxRuntime.jsx(CheckMarkSingle,{})}),jsxRuntime.jsx("div",{children:p})]},p))}),jsxRuntime.jsx("div",{className:styles.customFormatDes,children:localeService.t("sheet.numfmt.customFormatDes")})]})}__name(CustomFormat,"CustomFormat");const isDatePanel=__name(pattern=>{const info=core.numfmt.getInfo(pattern);return sheetsNumfmt.getDateFormatOptions().map(item=>item.value).includes(pattern)||["date","datetime","time"].includes(info.type)},"isDatePanel"),DatePanel=__name(props=>{const options=react.useMemo(sheetsNumfmt.getDateFormatOptions,[]),t=core.useDependency(core.LocaleService).t,[suffix,suffixSet]=react.useState(()=>{if(props.defaultPattern){const item=options.find(item2=>item2.value===props.defaultPattern);if(item)return item.value}return options[0].value});props.action.current=()=>suffix;const onChange=__name(v=>{v!==void 0&&(suffixSet(v),props.onChange(v))},"onChange");return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"m-t-16 label",children:t("sheet.numfmt.dateType")}),jsxRuntime.jsx("div",{className:"m-t-8",children:jsxRuntime.jsx(design.SelectList,{value:suffix,options,onChange})}),jsxRuntime.jsx("div",{className:"describe m-t-14",children:t("sheet.numfmt.dateDes")})]})},"DatePanel"),isGeneralPanel=__name(pattern=>!pattern,"isGeneralPanel"),GeneralPanel=__name(props=>{const t=core.useDependency(core.LocaleService).t;return props.action.current=()=>"",jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{className:"describe m-t-14",children:t("sheet.numfmt.generalDes")})})},"GeneralPanel"),isThousandthPercentilePanel=__name(pattern=>sheetsNumfmt.getNumberFormatOptions().some(item=>sheetsNumfmt.isPatternEqualWithoutDecimal(item.value,pattern)),"isThousandthPercentilePanel"),ThousandthPercentilePanel=__name(props=>{const localeService=core.useDependency(core.LocaleService),options=react.useMemo(sheetsNumfmt.getNumberFormatOptions,[]),[decimal,decimalSet]=react.useState(()=>sheetsNumfmt.getDecimalFromPattern(props.defaultPattern||"",0)),[suffix,suffixSet]=react.useState(()=>{const item=options.find(item2=>sheetsNumfmt.isPatternEqualWithoutDecimal(item2.value,props.defaultPattern||""));return(item==null?void 0:item.value)||options[0].value}),pattern=react.useMemo(()=>sheetsNumfmt.setPatternDecimal(suffix,Number(decimal||0)),[suffix,decimal]),isInputDisable=react.useMemo(()=>!sheetsNumfmt.isPatternHasDecimal(suffix),[suffix]),handleDecimalChange=__name(decimal2=>{decimalSet(decimal2||0),props.onChange(sheetsNumfmt.setPatternDecimal(suffix,Number(decimal2||0)))},"handleDecimalChange"),handleClick=__name(v=>{v!==void 0&&(decimalSet(sheetsNumfmt.getDecimalFromPattern(v,0)),suffixSet(v),props.onChange(v))},"handleClick");return props.action.current=()=>pattern,jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"m-t-16 label",children:localeService.t("sheet.numfmt.decimalLength")}),jsxRuntime.jsx("div",{className:"m-t-8",children:jsxRuntime.jsx(design.InputNumber,{disabled:isInputDisable,value:decimal,max:20,min:0,onChange:handleDecimalChange})}),jsxRuntime.jsxs("div",{className:"m-t-16 label",children:[" ",localeService.t("sheet.numfmt.negType")]}),jsxRuntime.jsx("div",{className:"m-t-8",children:jsxRuntime.jsx(design.SelectList,{onChange:handleClick,options,value:suffix})}),jsxRuntime.jsx("div",{className:"describe m-t-14",children:localeService.t("sheet.numfmt.thousandthPercentileDes")})]})},"ThousandthPercentilePanel"),SheetNumfmtPanel=__name(props=>{const{defaultValue,defaultPattern,row,col}=props.value,localeService=core.useDependency(core.LocaleService),getCurrentPattern=react.useRef(()=>""),t=localeService.t,nextTick=useNextTick(),typeOptions=react.useMemo(()=>[{label:"sheet.numfmt.general",component:GeneralPanel},{label:"sheet.numfmt.accounting",component:AccountingPanel},{label:"sheet.numfmt.currency",component:CurrencyPanel},{label:"sheet.numfmt.date",component:DatePanel},{label:"sheet.numfmt.thousandthPercentile",component:ThousandthPercentilePanel},{label:"sheet.numfmt.customFormat",component:CustomFormat}].map(item=>({...item,label:t(item.label)})),[]),[type,typeSet]=react.useState(findDefaultType),[key2,keySet]=react.useState(()=>`${row}_${col}`),{mark,userHabitCurrency}=useCurrencyOptions(()=>keySet(`${row}_${col}_userCurrency'`)),BusinessComponent=react.useMemo(()=>{var _a7;return(_a7=typeOptions.find(item=>item.label===type))==null?void 0:_a7.component},[type]);function findDefaultType(){return[isGeneralPanel,isAccountingPanel,isCurrencyPanel,isDatePanel,isThousandthPercentilePanel].reduce((pre,curFn,index)=>pre||(curFn(defaultPattern)?typeOptions[index].label:""),"")||typeOptions[0].label}__name(findDefaultType,"findDefaultType");const selectOptions=typeOptions.map(option=>({label:option.label,value:option.label})),handleSelect=__name(value=>{typeSet(value),nextTick(()=>props.onChange({type:"change",value:getCurrentPattern.current()||""}))},"handleSelect"),handleChange=__name(v=>{props.onChange({type:"change",value:v})},"handleChange"),handleConfirm=__name(()=>{const pattern=getCurrentPattern.current()||"",currency=sheetsNumfmt.getCurrencyType(pattern);currency&&mark(currency),props.onChange({type:"confirm",value:pattern})},"handleConfirm"),handleCancel=__name(()=>{props.onChange({type:"cancel",value:""})},"handleCancel"),subProps={onChange:handleChange,defaultValue,defaultPattern,action:getCurrentPattern};return react.useEffect(()=>{typeSet(findDefaultType()),keySet(`${row}_${col}`)},[row,col]),jsxRuntime.jsxs("div",{className:"numfmt-panel p-b-20",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"label m-t-14",children:t("sheet.numfmt.numfmtType")}),jsxRuntime.jsx("div",{className:"m-t-8",children:jsxRuntime.jsx(design.Select,{onChange:handleSelect,options:selectOptions,value:type,style:{width:"100%"}})}),jsxRuntime.jsx("div",{children:BusinessComponent&&jsxRuntime.jsx(UserHabitCurrencyContext.Provider,{value:userHabitCurrency,children:react.createElement(BusinessComponent,{...subProps,key:key2})})})]}),jsxRuntime.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[jsxRuntime.jsx(design.Button,{size:"small",onClick:handleCancel,className:"m-r-12",children:t("sheet.numfmt.cancel")}),jsxRuntime.jsx(design.Button,{type:"primary",size:"small",onClick:handleConfirm,children:t("sheet.numfmt.confirm")})]})]})},"SheetNumfmtPanel");var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key2,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key2):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key2,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key2,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key2)=>decorator(target,key2,index),"__decorateParam$3");const SHEET_NUMFMT_PANEL="SHEET_NUMFMT_PANEL";var _a3;let SheetNumfmtUIController=(_a3=class extends core.Disposable{constructor(_sheetInterceptorService,_themeService,_univerInstanceService,_commandService,_selectionManagerService,_renderManagerService,_numfmtService,_componentManager,_sidebarService,_localeService,_sheetsNumfmtCellContentController){super();__publicField(this,"_previewPattern","");__publicField(this,"_sidebarDisposable",null);this._sheetInterceptorService=_sheetInterceptorService,this._themeService=_themeService,this._univerInstanceService=_univerInstanceService,this._commandService=_commandService,this._selectionManagerService=_selectionManagerService,this._renderManagerService=_renderManagerService,this._numfmtService=_numfmtService,this._componentManager=_componentManager,this._sidebarService=_sidebarService,this._localeService=_localeService,this._sheetsNumfmtCellContentController=_sheetsNumfmtCellContentController,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(rxjs.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var _a7;const sidebarService=this._sidebarService,selectionManagerService=this._selectionManagerService,commandService=this._commandService,univerInstanceService=this._univerInstanceService,numfmtService=this._numfmtService,localeService=this._localeService,range=(((_a7=selectionManagerService.getCurrentSelections())==null?void 0:_a7.map(s=>s.range))||[])[0];if(!range)return!1;const workbook=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),sheet=workbook.getActiveSheet();if(!sheet)return!1;const cellValue=sheet.getCellRaw(range.startRow,range.startColumn),numfmtValue=numfmtService.getValue(workbook.getUnitId(),sheet.getSheetId(),range.startRow,range.startColumn);let pattern="";numfmtValue&&(pattern=numfmtValue.pattern);const defaultValue=(cellValue==null?void 0:cellValue.t)===core.CellValueType.NUMBER?cellValue.v:12345678,props={onChange:__name(config=>{var _a8;if(config.type==="change")this._previewPattern=config.value,this._forceUpdate();else if(config.type==="confirm"){const selections2=((_a8=selectionManagerService.getCurrentSelections())==null?void 0:_a8.map(s=>s.range))||[],params={values:[]},patternType=sheetsNumfmt.getPatternType(config.value);selections2.forEach(rangeInfo=>{core.Range.foreach(rangeInfo,(row,col)=>{params.values.push({row,col,pattern:config.value,type:patternType})})}),commandService.executeCommand(sheetsNumfmt.SetNumfmtCommand.id,params),sidebarService.close()}else config.type==="cancel"&&sidebarService.close()},"onChange"),value:{defaultPattern:pattern,defaultValue,row:range.startRow,col:range.startColumn}};return this._sidebarDisposable=sidebarService.open({header:{title:localeService.t("sheet.numfmt.title")},children:{label:SHEET_NUMFMT_PANEL,...props},onClose:__name(()=>{this._forceUpdate(),commandService.executeCommand(CloseNumfmtPanelOperator.id)},"onClose")}),!0}_forceUpdate(unitId){var _a7;const renderUnit=this._renderManagerService.getRenderById(unitId!=null?unitId:this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET).getUnitId());renderUnit==null||renderUnit.with(sheetsUi.SheetSkeletonManagerService).reCalculate(),(_a7=renderUnit==null?void 0:renderUnit.mainComponent)==null||_a7.makeDirty()}_initCommands(){[OpenNumfmtPanelOperator,CloseNumfmtPanelOperator].forEach(config=>{this.disposeWithMe(this._commandService.registerCommand(config))})}_initPanel(){this._componentManager.register(SHEET_NUMFMT_PANEL,SheetNumfmtPanel)}_initRealTimeRenderingInterceptor(){const isPanelOpenObserver=new rxjs.Observable(subscriber=>{this._commandService.onCommandExecuted(commandInfo=>{commandInfo.id===OpenNumfmtPanelOperator.id&&subscriber.next(!0),commandInfo.id===CloseNumfmtPanelOperator.id&&subscriber.next(!1)})}),combineOpenAndSelection$=rxjs.combineLatest([isPanelOpenObserver,this._selectionManagerService.selectionMoveEnd$.pipe(operators.map(selectionInfos=>selectionInfos?selectionInfos.map(selectionInfo=>selectionInfo.range):[]))]);this.disposeWithMe(core.toDisposable(combineOpenAndSelection$.pipe(operators.switchMap(([isOpen,selectionRanges])=>new rxjs.Observable(subscribe=>{const disposableCollection=new core.DisposableCollection;return isOpen&&selectionRanges.length&&subscribe.next({selectionRanges,disposableCollection}),()=>{disposableCollection.dispose()}})),operators.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection,selectionRanges})=>{var _a7,_b;const workbook=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);this.openPanel(),disposableCollection.add(this._sheetInterceptorService.intercept(sheets.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:core.InterceptorEffectEnum.Value|core.InterceptorEffectEnum.Style,handler:__name((cell,location,next)=>{const{row,col}=location,defaultValue=next(cell)||{};if(selectionRanges.find(range=>range.startColumn<=col&&range.endColumn>=col&&range.startRow<=row&&range.endRow>=row)){const rawValue=location.worksheet.getCellRaw(row,col),value=rawValue==null?void 0:rawValue.v,type=rawValue==null?void 0:rawValue.t;if(value==null||type!==core.CellValueType.NUMBER||this._previewPattern===null)return defaultValue;const info=sheetsNumfmt.getPatternPreviewIgnoreGeneral(this._previewPattern,value,this._sheetsNumfmtCellContentController.local);if(info.color){const color=this._themeService.getCurrentTheme()[`${info.color}500`];return{...defaultValue,v:info.result,t:core.CellValueType.STRING,s:{cl:{rgb:color}}}}return{...defaultValue,v:info.result,t:core.CellValueType.STRING}}return defaultValue},"handler")})),(_b=(_a7=this._renderManagerService.getRenderById(workbook.getUnitId()))==null?void 0:_a7.mainComponent)==null||_b.makeDirty()})))}_commandExecutedListener(){const commandList=[sheets.RemoveNumfmtMutation.id,sheets.SetNumfmtMutation.id];this.disposeWithMe(new rxjs.Observable(subscribe=>{const disposable=this._commandService.onCommandExecuted(command=>{if(commandList.includes(command.id)){const params=command.params;subscribe.next(params.unitId)}});return()=>disposable.dispose()}).pipe(operators.debounceTime(16)).subscribe(unitId=>this._forceUpdate(unitId)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET).subscribe(unit=>{var _a7;unit||((_a7=this._sidebarDisposable)==null||_a7.dispose(),this._sidebarDisposable=null)})}},__name(_a3,"SheetNumfmtUIController"),_a3);SheetNumfmtUIController=__decorateClass$3([__decorateParam$3(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$3(1,core.Inject(core.ThemeService)),__decorateParam$3(2,core.IUniverInstanceService),__decorateParam$3(3,core.ICommandService),__decorateParam$3(4,core.Inject(sheets.SheetsSelectionsService)),__decorateParam$3(5,engineRender.IRenderManagerService),__decorateParam$3(6,sheets.INumfmtService),__decorateParam$3(7,core.Inject(ui.ComponentManager)),__decorateParam$3(8,ui.ISidebarService),__decorateParam$3(9,core.Inject(core.LocaleService)),__decorateParam$3(10,core.Inject(sheetsNumfmt.SheetsNumfmtCellContentController))],SheetNumfmtUIController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key2,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key2):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key2,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key2,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key2)=>decorator(target,key2,index),"__decorateParam$2");const createCollectEffectMutation=__name(()=>{let list=[];return{add:__name((unitId,subUnitId,row,col,value)=>list.push({unitId,subUnitId,row,col,value}),"add"),getEffects:__name(()=>list,"getEffects"),clean:__name(()=>{list=[]},"clean")}},"createCollectEffectMutation");var _a4;let NumfmtEditorController=(_a4=class extends core.Disposable{constructor(_sheetInterceptorService,_numfmtService,_univerInstanceService,_injector,_editorBridgeService){super();__publicField(this,"_collectEffectMutation",createCollectEffectMutation());this._sheetInterceptorService=_sheetInterceptorService,this._numfmtService=_numfmtService,this._univerInstanceService=_univerInstanceService,this._injector=_injector,this._editorBridgeService=_editorBridgeService,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(core.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(sheets.BEFORE_CELL_EDIT,{handler:__name((value,context,next)=>{const row=context.row,col=context.col,numfmtCell=this._numfmtService.getValue(context.unitId,context.subUnitId,row,col);if(numfmtCell)switch(sheetsNumfmt.getPatternType(numfmtCell.pattern)){case"scientific":case"currency":case"grouped":case"number":{const cell=context.worksheet.getCellRaw(row,col);return next&&next(cell)}case"percent":case"date":case"time":case"datetime":default:return next&&next(value)}return next(value)},"handler")})))}_initInterceptorEditorEnd(){this.disposeWithMe(core.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(sheets.AFTER_CELL_EDIT,{handler:__name((value,context,next)=>{var _a7,_b,_c,_d;this._collectEffectMutation.clean();const currentNumfmtValue=this._numfmtService.getValue(context.unitId,context.subUnitId,context.row,context.col),currentNumfmtType=(_a7=currentNumfmtValue&&sheetsNumfmt.getPatternType(currentNumfmtValue.pattern))!=null?_a7:"",clean=__name(()=>{currentNumfmtValue&&this._collectEffectMutation.add(context.unitId,context.subUnitId,context.row,context.col,null)},"clean");if(!(value!=null&&value.v)&&!(value!=null&&value.p)||(currentNumfmtValue==null?void 0:currentNumfmtValue.pattern)===engineNumfmt.DEFAULT_TEXT_FORMAT||value.t===core.CellValueType.FORCE_STRING)return next(value);const body=(_b=value.p)==null?void 0:_b.body,content=(_d=(_c=value==null?void 0:value.p)==null?void 0:_c.body)!=null&&_d.dataStream?value.p.body.dataStream.replace(/\r\n$/,""):String(value.v),numfmtInfo=core.numfmt.parseDate(content)||core.numfmt.parseTime(content)||core.numfmt.parseNumber(content);if(body)if(canConvertRichTextToNumfmt(body)){const{dataStream}=body,dataStreamWithoutEnd=dataStream.replace(/\r\n$/,""),num=Number(dataStreamWithoutEnd);if(Number.isNaN(num)&&!numfmtInfo)return next(value)}else return next(value);if(numfmtInfo){numfmtInfo.z&&this._collectEffectMutation.add(context.unitId,context.subUnitId,context.row,context.col,{pattern:numfmtInfo.z});const v=Number(numfmtInfo.v);return next({...value,p:void 0,v,t:core.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(currentNumfmtType)||!isNumeric(content))&&clean();return next(value)},"handler")})))}_initInterceptorCommands(){const self=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(command){var _a7;switch(command.id){case sheets.SetRangeValuesCommand.id:{const workbook=self._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),unitId=workbook.getUnitId(),subUnitId=(_a7=workbook.getActiveSheet())==null?void 0:_a7.getSheetId();if(!subUnitId)return{redos:[],undos:[]};const list=self._collectEffectMutation.getEffects();if(self._collectEffectMutation.clean(),!list.length)return{redos:[],undos:[]};const cells=list.filter(item=>{var _a8;return!!((_a8=item.value)!=null&&_a8.pattern)}).map(item=>({row:item.row,col:item.col,pattern:item.value.pattern})),removeCells=list.filter(item=>{var _a8;return!((_a8=item.value)!=null&&_a8.pattern)}).map(item=>({startRow:item.row,endColumn:item.col,startColumn:item.col,endRow:item.row})),redos=[],undos=[];if(cells.length){const redo={id:sheets.SetNumfmtMutation.id,params:sheets.transformCellsToRange(unitId,subUnitId,cells)};redos.push(redo),undos.push(...sheets.factorySetNumfmtUndoMutation(self._injector,redo.params))}if(removeCells.length){const redo={id:sheets.RemoveNumfmtMutation.id,params:{unitId,subUnitId,ranges:removeCells}};redos.push(redo),undos.push(...sheets.factoryRemoveNumfmtUndoMutation(self._injector,redo.params))}return{redos,undos:undos.reverse()}}}return{redos:[],undos:[]}}}))}},__name(_a4,"NumfmtEditorController"),_a4);NumfmtEditorController=__decorateClass$2([__decorateParam$2(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$2(1,core.Inject(sheets.INumfmtService)),__decorateParam$2(2,core.Inject(core.IUniverInstanceService)),__decorateParam$2(3,core.Inject(core.Injector)),__decorateParam$2(4,core.Optional(sheetsUi.IEditorBridgeService))],NumfmtEditorController);function isNumeric(str){return/^-?\d+(\.\d+)?$/.test(str)}__name(isNumeric,"isNumeric");function canConvertRichTextToNumfmt(body){const{textRuns=[],paragraphs=[],customRanges,customBlocks=[]}=body,richTextStyle=["va"];return!(textRuns.some(textRun=>!!(textRun.ts&&Object.keys(textRun.ts).some(property=>richTextStyle.includes(property))))||paragraphs.some(paragraph=>paragraph.bullet)||paragraphs.length>=2||customRanges!=null&&customRanges.length||customBlocks.length>0)}__name(canConvertRichTextToNumfmt,"canConvertRichTextToNumfmt");const MENU_OPTIONS=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:engineNumfmt.DEFAULT_TEXT_FORMAT},"|",{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:""}],CurrencyMenuItem=__name(accessor=>({icon:new rxjs.Observable(subscribe=>{const menuCurrencyService=accessor.get(sheetsNumfmt.MenuCurrencyService);function getIconKey(symbol2){return{[sheetsNumfmt.countryCurrencyMap.US]:"DollarSingle",[sheetsNumfmt.countryCurrencyMap.RU]:"RoubleSingle",[sheetsNumfmt.countryCurrencyMap.CN]:"RmbSingle",[sheetsNumfmt.countryCurrencyMap.AT]:"EuroSingle"}[symbol2]||"DollarSingle"}__name(getIconKey,"getIconKey");const symbol=sheetsNumfmt.countryCurrencyMap[menuCurrencyService.getCurrencySymbol()]||"$";return subscribe.next(getIconKey(symbol)),menuCurrencyService.currencySymbol$.subscribe(code=>{const symbol2=sheetsNumfmt.countryCurrencyMap[code]||"$";subscribe.next(getIconKey(symbol2))})}),id:sheetsNumfmt.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:ui.MenuItemType.BUTTON,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellStylePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}),"CurrencyMenuItem"),AddDecimalMenuItem=__name(accessor=>({icon:"AddDigitsSingle",id:sheetsNumfmt.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:ui.MenuItemType.BUTTON,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellStylePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}),"AddDecimalMenuItem"),SubtractDecimalMenuItem=__name(accessor=>({icon:"ReduceDigitsSingle",id:sheetsNumfmt.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:ui.MenuItemType.BUTTON,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellStylePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}),"SubtractDecimalMenuItem"),PercentMenuItem=__name(accessor=>({icon:"PercentSingle",id:sheetsNumfmt.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:ui.MenuItemType.BUTTON,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellStylePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}),"PercentMenuItem"),FactoryOtherMenuItem=__name(accessor=>{const univerInstanceService=accessor.get(core.IUniverInstanceService),commandService=accessor.get(core.ICommandService),localeService=accessor.get(core.LocaleService),selectionManagerService=accessor.get(sheets.SheetsSelectionsService),value$=sheetsUi.deriveStateFromActiveSheet$(univerInstanceService,"",({workbook,worksheet})=>new rxjs.Observable(subscribe=>rxjs.merge(selectionManagerService.selectionMoveEnd$,new rxjs.Observable(commandSubscribe=>{const commandList=[sheets.RemoveNumfmtMutation.id,sheets.SetNumfmtMutation.id],disposable=commandService.onCommandExecuted(commandInfo=>{commandList.includes(commandInfo.id)&&commandSubscribe.next(null)});return()=>disposable.dispose()})).subscribe(()=>{var _a7,_b;const selections=selectionManagerService.getCurrentSelections();if(selections&&selections[0]){const range=selections[0].range,row=range.startRow,col=range.startColumn,numfmtValue=(_b=workbook.getStyles().get((_a7=worksheet.getCell(row,col))==null?void 0:_a7.s))==null?void 0:_b.n,pattern=numfmtValue==null?void 0:numfmtValue.pattern;let value=localeService.t("sheet.numfmt.general");if(pattern){const item=MENU_OPTIONS.filter(item2=>typeof item2=="object"&&item2.pattern).find(item2=>sheetsNumfmt.isPatternEqualWithoutDecimal(pattern,item2.pattern));item&&typeof item=="object"&&item.pattern?value=localeService.t(item.label):value=localeService.t("sheet.numfmt.moreFmt")}subscribe.next(value)}})));return{label:MORE_NUMFMT_TYPE_KEY,id:OpenNumfmtPanelOperator.id,tooltip:"sheet.numfmt.title",type:ui.MenuItemType.SELECTOR,selections:[{label:{name:OPTIONS_KEY,hoverable:!1}}],value$,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetSetCellStylePermission,sheets.WorksheetEditPermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}},"FactoryOtherMenuItem"),MORE_NUMFMT_TYPE_KEY="sheet.numfmt.moreNumfmtType",OPTIONS_KEY="sheet.numfmt.moreNumfmtType.options",MoreNumfmtType=__name(props=>{var _a7;const localeService=core.useDependency(core.LocaleService),value=(_a7=props.value)!=null?_a7:localeService.t("sheet.numfmt.general");return jsxRuntime.jsx("span",{className:"more-numfmt-type",children:value})},"MoreNumfmtType"),Options=__name(()=>{const commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),layoutService=core.useDependency(ui.ILayoutService),sheetsNumfmtCellContentController=core.useDependency(sheetsNumfmt.SheetsNumfmtCellContentController),selectionManagerService=core.useDependency(sheets.SheetsSelectionsService),setNumfmt=__name(pattern=>{const selection=selectionManagerService.getCurrentLastSelection();if(!selection)return;const range=selection.range,values=[];core.Range.foreach(range,(row,col)=>{pattern?values.push({row,col,pattern,type:sheetsNumfmt.getPatternType(pattern)}):values.push({row,col})}),commandService.executeCommand(sheetsNumfmt.SetNumfmtCommand.id,{values}),layoutService.focus()},"setNumfmt"),handleOnclick=__name(index=>{if(index===0)setNumfmt(null);else if(index===MENU_OPTIONS.length-1)commandService.executeCommand(OpenNumfmtPanelOperator.id);else{const item=MENU_OPTIONS[index];item.pattern&&setNumfmt(item.pattern)}},"handleOnclick"),defaultValue=1220;return jsxRuntime.jsx("div",{className:"more-numfmt-type-options",children:MENU_OPTIONS.map((item,index)=>item==="|"?jsxRuntime.jsx("div",{className:"line m-t-4",onClick:__name(e=>e.stopPropagation(),"onClick")},index):jsxRuntime.jsxs("div",{className:"option-item m-t-4",onClick:__name(()=>{handleOnclick(index)},"onClick"),children:[jsxRuntime.jsx("div",{children:localeService.t(item.label)}),jsxRuntime.jsx("div",{className:"m-l-26",children:item.pattern?sheetsNumfmt.getPatternPreview(item.pattern||"",defaultValue,sheetsNumfmtCellContentController.local).result:""})]},index))})},"Options"),menuSchema={[ui.RibbonStartGroup.FORMULAS_INSERT]:{[sheetsNumfmt.SetCurrencyCommand.id]:{order:4,menuItemFactory:CurrencyMenuItem},[sheetsNumfmt.AddDecimalCommand.id]:{order:5,menuItemFactory:AddDecimalMenuItem},[sheetsNumfmt.SubtractDecimalCommand.id]:{order:6,menuItemFactory:SubtractDecimalMenuItem},[sheetsNumfmt.SetPercentCommand.id]:{order:7,menuItemFactory:PercentMenuItem},[OpenNumfmtPanelOperator.id]:{order:8,menuItemFactory:FactoryOtherMenuItem}}};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key2,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key2):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key2,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key2,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key2)=>decorator(target,key2,index),"__decorateParam$1"),_a5;let NumfmtMenuController=(_a5=class extends core.Disposable{constructor(_componentManager,_menuManagerService){super(),this._componentManager=_componentManager,this._menuManagerService=_menuManagerService,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(menuSchema),this.disposeWithMe(this._componentManager.register(MORE_NUMFMT_TYPE_KEY,MoreNumfmtType)),this.disposeWithMe(this._componentManager.register(OPTIONS_KEY,Options))}},__name(_a5,"NumfmtMenuController"),_a5);NumfmtMenuController=__decorateClass$1([__decorateParam$1(0,core.Inject(ui.ComponentManager)),__decorateParam$1(1,ui.IMenuManagerService)],NumfmtMenuController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key2,value)=>key2 in obj?__defProp2(obj,key2,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key2]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key2,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key2):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key2,result):decorator(result))||result);return kind&&result&&__defProp2(target,key2,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key2)=>decorator(target,key2,index),"__decorateParam"),__publicField2=__name((obj,key2,value)=>__defNormalProp2(obj,typeof key2!="symbol"?key2+"":key2,value),"__publicField");const SHEET_NUMFMT_UI_PLUGIN="SHEET_NUMFMT_UI_PLUGIN";var _a6;exports.UniverSheetsNumfmtUIPlugin=(_a6=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService,_renderManagerService){super(),this._config=_config,this._injector=_injector,this._configService=_configService,this._renderManagerService=_renderManagerService;const{menu,...rest}=core.merge({},defaultPluginConfig,this._config);menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(ui.UI_PLUGIN_CONFIG_KEY,rest)}onStarting(){core.registerDependencies(this._injector,[[SheetNumfmtUIController],[NumfmtEditorController],[UserHabitController],[NumfmtMenuController]])}onRendered(){this._registerRenderModules(),core.touchDependencies(this._injector,[[SheetNumfmtUIController],[NumfmtEditorController],[NumfmtMenuController]])}_registerRenderModules(){[[NumfmtAlertRenderController]].forEach(m=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(core.UniverInstanceType.UNIVER_SHEET,m))})}},__name(_a6,"UniverSheetsNumfmtUIPlugin"),_a6);__publicField2(exports.UniverSheetsNumfmtUIPlugin,"pluginName",SHEET_NUMFMT_UI_PLUGIN);__publicField2(exports.UniverSheetsNumfmtUIPlugin,"type",core.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtUIPlugin=__decorateClass([core.DependentOn(sheetsUi.UniverSheetsUIPlugin,sheetsNumfmt.UniverSheetsNumfmtPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService),__decorateParam(3,engineRender.IRenderManagerService)],exports.UniverSheetsNumfmtUIPlugin);
@@ -1 +1 @@
1
- "use strict";const e={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:"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",customFormat:"Custom Format",customFormatDes:"Generate custom number formats based on existing formats."}}};module.exports=e;
1
+ "use strict";const locale={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:"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",customFormat:"Custom Format",customFormatDes:"Generate custom number formats based on existing formats."}}};module.exports=locale;
@@ -1 +1 @@
1
- "use strict";const e={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:"کاهش اعشار",customFormat:"قالب‌بندی سفارشی",customFormatDes:"ایجاد قالب‌بندی‌های عددی سفارشی بر اساس قالب‌بندی‌های موجود."}}};module.exports=e;
1
+ "use strict";const locale={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:"کاهش اعشار",customFormat:"قالب‌بندی سفارشی",customFormatDes:"ایجاد قالب‌بندی‌های عددی سفارشی بر اساس قالب‌بندی‌های موجود."}}};module.exports=locale;
@@ -1 +1 @@
1
- "use strict";const e={sheet:{numfmt:{percent:"Pourcentage",title:"Format de nombre",numfmtType:"Types de format",cancel:"Annuler",confirm:"Confirmer",general:"Général",accounting:"Comptabilité",text:"Texte",number:"Nombre",currency:"Devise",date:"Date",time:"Heure",thousandthPercentile:"Séparateur de milliers",preview:"Aperçu",dateTime:"Date et heure",decimalLength:"Nombre de décimales",currencyType:"Symbole de devise",moreFmt:"Formats",financialValue:"Valeur financière",roundingCurrency:"Arrondir la devise",timeDuration:"Durée",currencyDes:"Le format de devise est utilisé pour représenter des valeurs monétaires générales. Le format de comptabilité aligne une colonne de valeurs avec des points décimaux",accountingDes:"Le format de nombre de comptabilité aligne une colonne de valeurs avec des symboles de devise et des points décimaux",dateType:"Type de date",dateDes:"Le format de date présente les valeurs de la série date et heure sous forme de valeurs de date.",negType:"Type de nombre négatif",generalDes:"Le format général ne contient aucun format de nombre spécifique.",thousandthPercentileDes:"Le format de percentile est utilisé pour la représentation des nombres ordinaires. Les formats monétaires et comptables fournissent un format spécialisé pour les calculs de valeurs monétaires.",addDecimal:"Augmenter les décimales",subtractDecimal:"Diminuer les décimales",customFormat:"Format personnalisé",customFormatDes:"Générer des formats de nombre personnalisés basés sur des formats existants."}}};module.exports=e;
1
+ "use strict";const locale={sheet:{numfmt:{percent:"Pourcentage",title:"Format de nombre",numfmtType:"Types de format",cancel:"Annuler",confirm:"Confirmer",general:"Général",accounting:"Comptabilité",text:"Texte",number:"Nombre",currency:"Devise",date:"Date",time:"Heure",thousandthPercentile:"Séparateur de milliers",preview:"Aperçu",dateTime:"Date et heure",decimalLength:"Nombre de décimales",currencyType:"Symbole de devise",moreFmt:"Formats",financialValue:"Valeur financière",roundingCurrency:"Arrondir la devise",timeDuration:"Durée",currencyDes:"Le format de devise est utilisé pour représenter des valeurs monétaires générales. Le format de comptabilité aligne une colonne de valeurs avec des points décimaux",accountingDes:"Le format de nombre de comptabilité aligne une colonne de valeurs avec des symboles de devise et des points décimaux",dateType:"Type de date",dateDes:"Le format de date présente les valeurs de la série date et heure sous forme de valeurs de date.",negType:"Type de nombre négatif",generalDes:"Le format général ne contient aucun format de nombre spécifique.",thousandthPercentileDes:"Le format de percentile est utilisé pour la représentation des nombres ordinaires. Les formats monétaires et comptables fournissent un format spécialisé pour les calculs de valeurs monétaires.",addDecimal:"Augmenter les décimales",subtractDecimal:"Diminuer les décimales",customFormat:"Format personnalisé",customFormatDes:"Générer des formats de nombre personnalisés basés sur des formats existants."}}};module.exports=locale;
@@ -1 +1 @@
1
- "use strict";const e={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:"Уменьшить количество десятичных знаков",customFormat:"Custom Format",customFormatDes:"Generate custom number formats based on existing formats."}}};module.exports=e;
1
+ "use strict";const locale={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:"Уменьшить количество десятичных знаков",customFormat:"Custom Format",customFormatDes:"Generate custom number formats based on existing formats."}}};module.exports=locale;
@@ -1 +1 @@
1
- "use strict";const n={sheet:{numfmt:{percent:"Phần trăm",title:"Định dạng số",numfmtType:"Loại định dạng",cancel:"Hủy bỏ",confirm:"Xác nhận",general:"Chung",accounting:"Kế toán",text:"Văn bản",number:"Số",currency:"Tiền tệ",date:"Ngày",time:"Thời gian",thousandthPercentile:"Phân vị phần nghìn",preview:"Xem trước",dateTime:"Ngày giờ",decimalLength:"Số chữ số thập phân",currencyType:"Loại tiền tệ",moreFmt:"Nhiều định dạng hơn",financialValue:"Giá trị tài chính",roundingCurrency:"Tiền tệ làm tròn",timeDuration:"Thời lượng",currencyDes:"Định dạng tiền tệ được sử dụng để biểu thị các giá trị tiền tệ thông thường. Định dạng kế toán có thể căn chỉnh các giá trị trong một cột với dấu thập phân.",accountingDes:"Định dạng số kế toán có thể căn chỉnh các ký hiệu tiền tệ và dấu thập phân trong một cột các giá trị.",dateType:"Loại ngày",dateDes:"Định dạng ngày biểu thị các giá trị chuỗi ngày và thời gian dưới dạng giá trị ngày.",negType:"Loại số âm",generalDes:"Định dạng chung không chứa bất kỳ định dạng số cụ thể nào.",thousandthPercentileDes:"Định dạng phân vị phần nghìn được sử dụng để biểu thị các số thông thường. Các định dạng tiền tệ và kế toán cung cấp các định dạng chuyên dụng để tính toán giá trị tiền tệ.",addDecimal:"Thêm chữ số thập phân",subtractDecimal:"Giảm chữ số thập phân",customFormat:"Custom Format",customFormatDes:"Generate custom number formats based on existing formats."}}};module.exports=n;
1
+ "use strict";const locale={sheet:{numfmt:{percent:"Phần trăm",title:"Định dạng số",numfmtType:"Loại định dạng",cancel:"Hủy bỏ",confirm:"Xác nhận",general:"Chung",accounting:"Kế toán",text:"Văn bản",number:"Số",currency:"Tiền tệ",date:"Ngày",time:"Thời gian",thousandthPercentile:"Phân vị phần nghìn",preview:"Xem trước",dateTime:"Ngày giờ",decimalLength:"Số chữ số thập phân",currencyType:"Loại tiền tệ",moreFmt:"Nhiều định dạng hơn",financialValue:"Giá trị tài chính",roundingCurrency:"Tiền tệ làm tròn",timeDuration:"Thời lượng",currencyDes:"Định dạng tiền tệ được sử dụng để biểu thị các giá trị tiền tệ thông thường. Định dạng kế toán có thể căn chỉnh các giá trị trong một cột với dấu thập phân.",accountingDes:"Định dạng số kế toán có thể căn chỉnh các ký hiệu tiền tệ và dấu thập phân trong một cột các giá trị.",dateType:"Loại ngày",dateDes:"Định dạng ngày biểu thị các giá trị chuỗi ngày và thời gian dưới dạng giá trị ngày.",negType:"Loại số âm",generalDes:"Định dạng chung không chứa bất kỳ định dạng số cụ thể nào.",thousandthPercentileDes:"Định dạng phân vị phần nghìn được sử dụng để biểu thị các số thông thường. Các định dạng tiền tệ và kế toán cung cấp các định dạng chuyên dụng để tính toán giá trị tiền tệ.",addDecimal:"Thêm chữ số thập phân",subtractDecimal:"Giảm chữ số thập phân",customFormat:"Custom Format",customFormatDes:"Generate custom number formats based on existing formats."}}};module.exports=locale;
@@ -1 +1 @@
1
- "use strict";const e={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:"减少小数位",customFormat:"自定义格式",customFormatDes:"根据现有格式生成自定义数字格式。"}}};module.exports=e;
1
+ "use strict";const locale={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:"减少小数位",customFormat:"自定义格式",customFormatDes:"根据现有格式生成自定义数字格式。"}}};module.exports=locale;
@@ -1 +1 @@
1
- "use strict";const e={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:"減少小數位",customFormat:"Custom Format",customFormatDes:"Generate custom number formats based on existing formats."}}};module.exports=e;
1
+ "use strict";const locale={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:"減少小數位",customFormat:"Custom Format",customFormatDes:"Generate custom number formats based on existing formats."}}};module.exports=locale;