@univerjs/sheets-numfmt 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +576 -567
- package/lib/locale/en-US.json +1 -1
- package/lib/types/controllers/numfmt.editor.controller.d.ts +2 -2
- package/lib/umd/index.js +2 -2
- package/package.json +19 -19
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Re=Object.defineProperty;var Oe=(e,t,n)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var
|
|
1
|
+
"use strict";var Re=Object.defineProperty;var Oe=(e,t,n)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var H=(e,t,n)=>Oe(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),d=require("@univerjs/sheets"),C=require("@wendellhu/redi"),j=require("@univerjs/sheets-ui"),O=require("rxjs"),x=require("@univerjs/engine-numfmt"),de=require("@univerjs/engine-render"),I=require("@univerjs/ui"),k=require("rxjs/operators"),y=require("react"),E=require("@univerjs/design"),N=require("@wendellhu/redi/react-bindings"),$={id:"sheet.command.numfmt.set.numfmt",type:c.CommandType.COMMAND,handler:(e,t)=>{if(!t)return!1;const n=e.get(c.ICommandService),r=e.get(c.IUniverInstanceService),s=e.get(c.IUndoRedoService),i=d.getSheetCommandTarget(r,t);if(!i)return!1;const{unitId:o,subUnitId:a}=i,l=t.values.filter(v=>!!v.pattern),p=t.values.filter(v=>!v.pattern),f=d.transformCellsToRange(o,a,l),u={unitId:o,subUnitId:a,ranges:p.map(v=>({startColumn:v.col,startRow:v.row,endColumn:v.col,endRow:v.row}))},m=[],S=[];if(l.length){Object.keys(f.values).forEach(g=>{const b=f.values[g];b.ranges=d.rangeMerge(b.ranges)}),m.push({id:d.SetNumfmtMutation.id,params:f});const v=d.factorySetNumfmtUndoMutation(e,f);S.push(...v)}if(p.length){u.ranges=d.rangeMerge(u.ranges),m.push({id:d.RemoveNumfmtMutation.id,params:u});const v=d.factoryRemoveNumfmtUndoMutation(e,u);S.push(...v)}const _=c.sequenceExecute(m,n).result;return _&&s.pushUndoRedo({unitID:o,undoMutations:S,redoMutations:m}),_}},oe="SHEET_NUMFMT_PLUGIN",K=e=>x.getInfo(e).type||"unknown",Z=(e,t,n)=>{const r=x.getInfo(e),s=n===c.LocaleType.ZH_CN?"zh-CN":"en",i=r._partitions[1],o=x.format(e,t,{locale:s});return t<0?{result:o,color:i.color}:{result:o}};var je=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,$e=(e,t,n,r)=>{for(var s=r>1?void 0:r?xe(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&je(t,n,s),s},w=(e,t)=>(n,r)=>t(n,r,e);let W=class extends c.Disposable{constructor(e,t,n,r,s,i){super(),this._instanceService=e,this._sheetInterceptorService=t,this._themeService=n,this._commandService=r,this._numfmtService=s,this._localeService=i,this._initInterceptorCellContent()}_initInterceptorCellContent(){const e=new c.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(d.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,n,r)=>{const s=n.unitId,i=n.subUnitId,o=this._numfmtService.getValue(s,i,n.row,n.col);if(!o)return r(t);const a=t;if(!a||a.t!==c.CellValueType.NUMBER)return r(t);let l="";const p=e.getValue(n.row,n.col);if(p&&p.parameters===a.v)return r({...t,...p.result});const f=Z(o.pattern,Number(a.v),this._localeService.getCurrentLocale());if(l=f.result,!l)return r(t);const u={v:l};if(f.color){const m=this._themeService.getCurrentTheme()[`${f.color}500`];m&&(u.interceptorStyle={cl:{rgb:m}})}return e.setValue(n.row,n.col,{result:u,parameters:a.v}),r({...t,...u})},priority:10})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===d.SetNumfmtMutation.id){const n=t.params;Object.keys(n.values).forEach(r=>{n.values[r].ranges.forEach(i=>{c.Range.foreach(i,(o,a)=>{e.realDeleteValue(o,a)})})})}else if(t.id===d.SetRangeValuesMutation.id){const n=t.params;new c.ObjectMatrix(n.cellValue).forValue((r,s)=>{e.realDeleteValue(r,s)})}})),this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe(O.switchMap(t=>{var n;return(n=t==null?void 0:t.activeSheet$)!=null?n:O.of(null)}),O.skip(1)).subscribe(()=>e.reset()))}};W=$e([c.OnLifecycle(c.LifecycleStages.Rendered,W),w(0,c.IUniverInstanceService),w(1,C.Inject(d.SheetInterceptorService)),w(2,C.Inject(c.ThemeService)),w(3,C.Inject(c.ICommandService)),w(4,C.Inject(d.INumfmtService)),w(5,C.Inject(c.LocaleService))],W);const D=(e,t=0)=>{var r;return e&&(r=x.getInfo(e).maxDecimals)!=null?r:t},Q=(e,t)=>{if(e&&!t||!e&&t)return!1;const n=p=>p.reduce((f,u)=>{if(f.isEnd)return f;const m=u.value||u.num;return u.type==="point"?(f.isEnd=!0,f):{...f,result:f.result+m}},{isEnd:!1,result:""}).result,r=x.getInfo(e)._partitions,s=x.getInfo(t)._partitions,i=n(r[0].tokens),o=n(s[0].tokens),a=n(r[1].tokens),l=n(s[1].tokens);return i===o&&a===l&&r[1].color===s[1].color},ue=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),P=(e,t)=>e.split(";").map(r=>/\.0?/.test(r)?r.replace(/\.0*/g,`${t>0?".":""}${ue(Number(t||0))}`):/0([^0]?)|0$/.test(r)?r.replace(/0([^0]+)|0$/,`0${t>0?".":""}${ue(Number(t||0))}$1`):r).join(";"),De=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),fe={id:"sheet.command.numfmt.add.decimal.command",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),n=e.get(d.SelectionManagerService),r=e.get(d.INumfmtService),s=e.get(c.IUniverInstanceService),i=n.getSelections();if(!i||!i.length)return!1;const o=d.getSheetCommandTarget(s);if(!o)return!1;const{unitId:a,subUnitId:l}=o;let p=0;i.forEach(S=>{c.Range.foreach(S.range,(_,v)=>{const g=r.getValue(a,l,_,v);if(!g)return;const b=D(g.pattern);p=b>p?b:p})});const f=p+1,u=P(`0${f>0?".0":""}`,f),m=[];return i.forEach(S=>{c.Range.foreach(S.range,(_,v)=>{const g=r.getValue(a,l,_,v);if(!g)m.push({row:_,col:v,pattern:u});else{const b=D(g.pattern),T=P(g.pattern,b+1);T!==g.pattern&&m.push({row:_,col:v,pattern:T})}})}),m.length?await t.executeCommand($.id,{values:m}):!1}},Ue=[{label:"1930-08-05",suffix:"yyyy-MM-dd"},{label:"1930/08/05",suffix:"yyyy/MM/dd"},{label:"1930年08月05日",suffix:'yyyy"年"MM"月"dd"日"'},{label:"08-05",suffix:"MM-dd"},{label:"8月5日",suffix:'M"月"d"日"'},{label:"13:30:30",suffix:"h:mm:ss"},{label:"13:30",suffix:"h:mm"},{label:"下午01:30",suffix:"A/P hh:mm"},{label:"下午1:30",suffix:"A/P h:mm"},{label:"下午1:30:30",suffix:"A/P h:mm:ss"},{label:"08-05 下午 01:30",suffix:"MM-dd A/P hh:mm"}],we=[{label:"(1,235)",suffix:"#,##0_);(#,##0)"},{label:"(1,235) ",suffix:"#,##0_);[Red](#,##0)",color:"red"},{label:"1,234.56",suffix:"#,##0.00_);#,##0.00"},{label:"1,234.56",suffix:"#,##0.00_);[Red]#,##0.00",color:"red"},{label:"-1,234.56",suffix:"#,##0.00_);-#,##0.00"},{label:"-1,234.56",suffix:"#,##0.00_);[Red]-#,##0.00",color:"red"}],he=[{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);"${e}"#,##0.00`},{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,color:"red"},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);("${e}"#,##0.00)`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,color:"red"},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);-"${e}"#,##0.00`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,color:"red"}],pe={id:"sheet.command.numfmt.set.currency",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),r=e.get(d.SelectionManagerService).getSelections();if(!r||!r.length)return!1;const s=[],i=he[0].suffix("¥");return r.forEach(a=>{c.Range.foreach(a.range,(l,p)=>{s.push({row:l,col:p,pattern:i,type:"currency"})})}),await t.executeCommand($.id,{values:s})}},ve={id:"sheet.command.numfmt.subtract.decimal.command",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),n=e.get(d.SelectionManagerService),r=e.get(d.INumfmtService),s=e.get(c.IUniverInstanceService),i=n.getSelections();if(!i||!i.length)return!1;const o=d.getSheetCommandTarget(s);if(!o)return!1;const{unitId:a,subUnitId:l}=o;let p=0;i.forEach(_=>{c.Range.foreach(_.range,(v,g)=>{const b=r.getValue(a,l,v,g);if(!b)return;const T=D(b.pattern);p=T>p?T:p})});const f=p-1,u=P(`0${f>0?".0":"."}`,f),m=[];return i.forEach(_=>{c.Range.foreach(_.range,(v,g)=>{const b=r.getValue(a,l,v,g);if(!b)m.push({row:v,col:g,pattern:u});else{const T=D(b.pattern);m.push({row:v,col:g,pattern:P(b.pattern,T-1)})}})}),await t.executeCommand($.id,{values:m})}},re={id:"sheet.operation.close.numfmt.panel",type:c.CommandType.OPERATION,handler:()=>!0},ae=C.createIdentifier("INumfmtController");c.runOnLifecycle(c.LifecycleStages.Rendered,ae);const Y={id:"sheet.operation.open.numfmt.panel",type:c.CommandType.OPERATION,handler:e=>(e.get(ae).openPanel(),!0)};var Se={exports:{}},X={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Le=b,Ae=Symbol.for("react.element"),Ve=Symbol.for("react.fragment"),He=Object.prototype.hasOwnProperty,Be=Le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ke={key:!0,ref:!0,__self:!0,__source:!0};function ge(e,t,n){var s,r={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(s in t)He.call(t,s)&&!ke.hasOwnProperty(s)&&(r[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)r[s]===void 0&&(r[s]=t[s]);return{$$typeof:Ae,type:e,key:i,ref:o,props:r,_owner:Be.current}}X.Fragment=Ve;X.jsx=ge;X.jsxs=ge;Se.exports=X;var h=Se.exports;const le=b.createContext([]),ce=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"];var We=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(e,t,n,s)=>{for(var r=s>1?void 0:s?Fe(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(r=(s?o(t,n,r):o(r))||r);return s&&r&&We(t,n,r),r},Ge=(e,t)=>(n,s)=>t(n,s,e);let J=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const n=this._getKey(e);return this._localStorageService.getItem(n).then(s=>{s||this._localStorageService.setItem(n,t)})}markHabit(e,t){const n=this._getKey(e);this._localStorageService.getItem(n).then(s=>{if(s){const r=s.findIndex(i=>i===t);r>-1&&s.splice(r,1),s.unshift(t),this._localStorageService.setItem(n,s)}})}async getHabit(e,t){const n=this._getKey(e),s=await this._localStorageService.getItem(n);if(t&&s){const r=s.map((i,o,l)=>{const u=l.length;return{value:i,priority:u-o}});return t.sort((i,o)=>{var d,f;const l=((d=r.find(a=>a.value===i))==null?void 0:d.priority)||-1;return(((f=r.find(a=>a.value===o))==null?void 0:f.priority)||-1)-l})}return s||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};J=qe([Ge(0,C.Inject(c.ILocalStorageService))],J);const me="numfmtCurrency",ze=e=>{const t=N.useDependency(J),[n,s]=b.useState(ce);return b.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(me,[...ce]).then(i=>{s(i),e&&e(i)})})},[]),{userHabitCurrency:n,mark:i=>{t.markHabit(me,i)}}},Ke=()=>{const e=b.useRef([]),[t,n]=b.useState({});return b.useEffect(()=>{e.current.forEach(r=>{r()}),e.current=[]},[t]),r=>{e.current.push(r),n({})}},H=e=>ce.find(n=>e.includes(n)),Ye=e=>!!H(e)&&e.startsWith("_("),Je=e=>{const[t,n]=b.useState(()=>D(e.defaultPattern||"",2)),s=b.useContext(le),[r,i]=b.useState(()=>H(e.defaultPattern)||s[0]),o=b.useMemo(()=>s.map(a=>({label:a,value:a})),[]),u=N.useDependency(c.LocaleService).t;e.action.current=()=>P(`_("${r}"* #,##0${t>0?".0":""}_)`,t);const d=a=>{i(a),e.onChange(P(`_("${a}"* #,##0${t>0?".0":""}_)`,t))},f=a=>{const v=a||0;n(v),e.onChange(P(`_("${r}"* #,##0${v>0?".0":""}_)`,v))};return h.jsxs("div",{children:[h.jsxs("div",{className:"m-t-16 options ",children:[h.jsxs("div",{className:"option",children:[h.jsx("div",{className:"label",children:u("sheet.numfmt.decimalLength")}),h.jsx("div",{className:"m-t-8 w-120",children:h.jsx(E.InputNumber,{value:t,max:20,min:0,onChange:f})})]}),h.jsxs("div",{className:"option",children:[h.jsx("div",{className:"label",children:u("sheet.numfmt.currencyType")}),h.jsx("div",{className:"m-t-8 w-140",children:h.jsx(E.Select,{onChange:d,options:o,value:r})})]})]}),h.jsx("div",{className:"describe m-t-14",children:u("sheet.numfmt.accountingDes")})]})},re=e=>he.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),_e=()=>Ue.map(e=>({label:e.label,value:e.suffix})),be=()=>we.map(e=>({label:e.label,value:e.suffix,color:e.color})),Ze=e=>!!H(e)&&!e.startsWith("_("),Qe=e=>{const n=N.useDependency(c.LocaleService).t,s=b.useContext(le),[r,i]=b.useState(()=>H(e.defaultPattern)||s[0]),[o,l]=b.useState(()=>D(e.defaultPattern||"",2)),[u,d]=b.useState(()=>{var _;const p=re(r);return((_=p.find(T=>Q(T.value,e.defaultPattern)))==null?void 0:_.value)||p[0].value}),f=b.useMemo(()=>re(r),[r]),a=b.useMemo(()=>s.map(p=>({label:p,value:p})),[s]);e.action.current=()=>P(u,o);const v=p=>{i(p);const S=re(p)[0].value;d(S),e.onChange(P(S,o))},y=p=>{d(p),e.onChange(P(p,o))},g=p=>{l(p||0),e.onChange(P(u,p||0))};return h.jsxs("div",{children:[h.jsxs("div",{className:"m-t-16 options ",children:[h.jsxs("div",{className:"option",children:[h.jsx("div",{className:"label",children:n("sheet.numfmt.decimalLength")}),h.jsx("div",{className:"m-t-8 w-120",children:h.jsx(E.InputNumber,{value:o,max:20,min:0,onChange:g})})]}),h.jsxs("div",{className:"option",children:[h.jsx("div",{className:"label",children:n("sheet.numfmt.currencyType")}),h.jsx("div",{className:"m-t-8 w-140",children:h.jsx(E.Select,{onChange:v,options:a,value:r})})]})]}),h.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.negType")}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.SelectList,{onChange:y,options:f,value:u})}),h.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.currencyDes")})]})},Xe=e=>{const t=x.getInfo(e);return _e().map(n=>n.value).includes(e)||["date","datetime","time"].includes(t.type)},et=e=>{const t=b.useMemo(_e,[]),s=N.useDependency(c.LocaleService).t,[r,i]=b.useState(()=>{if(e.defaultPattern){const l=t.find(u=>u.value===e.defaultPattern);if(l)return l.value}return t[0].value});e.action.current=()=>r;const o=l=>{i(l),e.onChange(l)};return h.jsxs("div",{children:[h.jsx("div",{className:"m-t-16 label",children:s("sheet.numfmt.dateType")}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.SelectList,{value:r,options:t,onChange:o})}),h.jsx("div",{className:"describe m-t-14",children:s("sheet.numfmt.dateDes")})]})},tt=e=>!e,nt=e=>{const n=N.useDependency(c.LocaleService).t;return e.action.current=()=>"",h.jsx("div",{children:h.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.generalDes")})})},st=e=>be().some(t=>Q(t.value,e)),rt=e=>{const t=N.useDependency(c.LocaleService),n=b.useMemo(be,[]),[s,r]=b.useState(()=>D(e.defaultPattern||"",0)),[i,o]=b.useState(()=>{const a=n.find(v=>Q(v.value,e.defaultPattern||""));return(a==null?void 0:a.value)||n[0].value}),l=b.useMemo(()=>P(i,Number(s||0)),[i,s]),u=b.useMemo(()=>!De(i),[i]),d=a=>{r(a||0),e.onChange(P(i,Number(a||0)))},f=a=>{r(D(a,0)),o(a),e.onChange(a)};return e.action.current=()=>l,h.jsxs("div",{children:[h.jsx("div",{className:"m-t-16 label",children:t.t("sheet.numfmt.decimalLength")}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.InputNumber,{disabled:u,value:s,max:20,min:0,onChange:d})}),h.jsxs("div",{className:"m-t-16 label",children:[" ",t.t("sheet.numfmt.negType")]}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.SelectList,{onChange:f,options:n,value:i})}),h.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},it=e=>{const{defaultValue:t,defaultPattern:n,row:s,col:r}=e.value,i=N.useDependency(c.LocaleService),o=b.useRef(()=>""),l=i.t,u=Ke(),d=b.useMemo(()=>[{label:"sheet.numfmt.general",component:nt},{label:"sheet.numfmt.accounting",component:Je},{label:"sheet.numfmt.currency",component:Qe},{label:"sheet.numfmt.date",component:et},{label:"sheet.numfmt.thousandthPercentile",component:rt}].map(M=>({...M,label:l(M.label)})),[]),[f,a]=b.useState(_),[v,y]=b.useState(()=>`${s}_${r}`),{mark:g,userHabitCurrency:p}=ze(()=>y(`${s}_${r}_userCurrency'`)),S=b.useMemo(()=>{var M;return(M=d.find(U=>U.label===f))==null?void 0:M.component},[f]);function _(){return[tt,Ye,Ze,Xe,st].reduce((U,Ne,Ee)=>U||(Ne(n)?d[Ee].label:""),"")||d[0].label}const T=d.map(M=>({label:M.label,value:M.label})),L=M=>{a(M),u(()=>e.onChange({type:"change",value:o.current()||""}))},ee=M=>{e.onChange({type:"change",value:M})},te=()=>{const M=o.current()||"",U=H(M);U&&g(U),e.onChange({type:"confirm",value:M})},ne=()=>{e.onChange({type:"cancel",value:""})},Pe={onChange:ee,defaultValue:t,defaultPattern:n,action:o};return b.useEffect(()=>{a(_()),y(`${s}_${r}`)},[s,r]),h.jsxs("div",{className:"numfmt-panel p-b-20",children:[h.jsxs("div",{children:[h.jsx("div",{className:"label m-t-14",children:l("sheet.numfmt.numfmtType")}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.Select,{onChange:L,options:T,value:f})}),h.jsx("div",{children:S&&h.jsx(le.Provider,{value:p,children:b.createElement(S,{...Pe,key:v})})})]}),h.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[h.jsx(E.Button,{size:"small",onClick:ne,className:"m-r-12",children:l("sheet.numfmt.cancel")}),h.jsx(E.Button,{type:"primary",size:"small",onClick:te,children:l("sheet.numfmt.confirm")})]})]})},ye={id:"sheet.command.numfmt.set.percent",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),s=e.get(m.SelectionManagerService).getSelections();if(!s||!s.length)return!1;const r=[],i="0%";return s.forEach(l=>{c.Range.foreach(l.range,(u,d)=>{r.push({row:u,col:d,pattern:i,type:"percent"})})}),await t.executeCommand($.id,{values:r})}};var ot=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,at=(e,t,n,s)=>{for(var r=s>1?void 0:s?ct(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(r=(s?o(t,n,r):o(r))||r);return s&&r&&ot(t,n,r),r},R=(e,t)=>(n,s)=>t(n,s,e);let F=class extends c.Disposable{constructor(t,n,s,r,i,o,l,u,d,f){super();B(this,"_previewPattern","");B(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=n,this._univerInstanceService=s,this._commandService=r,this._selectionManagerService=i,this._renderManagerService=o,this._numfmtService=l,this._componentManager=u,this._sidebarService=d,this._localeService=f,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener()}openPanel(){const t=this._sidebarService,n=this._selectionManagerService,s=this._commandService,r=this._univerInstanceService,i=this._numfmtService,o=this._localeService,u=(n.getSelectionRanges()||[])[0];if(!u)return!1;const d=r.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),f=d.getActiveSheet(),a=f.getCellRaw(u.startRow,u.startColumn),v=i.getValue(d.getUnitId(),f.getSheetId(),u.startRow,u.startColumn);let y="";v&&(y=v.pattern);const g=(a==null?void 0:a.t)===c.CellValueType.NUMBER?a.v:12345678,p={onChange:S=>{if(S.type==="change")this._previewPattern=S.value,this._forceUpdate();else if(S.type==="confirm"){const _=n.getSelectionRanges()||[],T={values:[]},L=K(S.value);_.forEach(ee=>{c.Range.foreach(ee,(te,ne)=>{T.values.push({row:te,col:ne,pattern:S.value,type:L})})}),s.executeCommand($.id,T),t.close()}else S.type==="cancel"&&t.close()},value:{defaultPattern:y,defaultValue:g,row:u.startRow,col:u.startColumn}};return this._sidebarDisposable=t.open({header:{title:o.t("sheet.numfmt.title")},children:{label:oe,...p},onClose:()=>{this._forceUpdate(),s.executeCommand(se.id)}}),!0}_forceUpdate(t){var s;const n=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET).getUnitId());n==null||n.with(j.SheetSkeletonManagerService).reCalculate(),(s=n==null?void 0:n.mainComponent)==null||s.makeDirty()}_initCommands(){[fe,ve,pe,ye,Y,se,$].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(oe,it)}_initRealTimeRenderingInterceptor(){const t=new O.Observable(s=>{this._commandService.onCommandExecuted(r=>{r.id===Y.id&&s.next(!0),r.id===se.id&&s.next(!1)})}),n=O.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(k.map(s=>s?s.map(r=>r.range):[]))]);this.disposeWithMe(c.toDisposable(n.pipe(k.switchMap(([s,r])=>new O.Observable(i=>{const o=new c.DisposableCollection;return s&&r.length&&i.next({selectionRanges:r,disposableCollection:o}),()=>{o.dispose()}})),k.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:s,selectionRanges:r})=>{var o,l;const i=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);this.openPanel(),s.add(this._sheetInterceptorService.intercept(m.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,handler:(u,d,f)=>{const{row:a,col:v}=d,y=f(u)||{};if(r.find(g=>g.startColumn<=v&&g.endColumn>=v&&g.startRow<=a&&g.endRow>=a)){const g=d.worksheet.getCellRaw(a,v),p=g==null?void 0:g.v,S=g==null?void 0:g.t;if(p==null||S!==c.CellValueType.NUMBER||this._previewPattern===null)return y;const _=Z(this._previewPattern,p,this._localeService.getCurrentLocale());if(_.color){const L=this._themeService.getCurrentTheme()[`${_.color}500`];return{...y,v:_.result,t:c.CellValueType.STRING,s:{cl:{rgb:L}}}}return{...y,v:_.result,t:c.CellValueType.STRING}}return y}})),(l=(o=this._renderManagerService.getRenderById(i.getUnitId()))==null?void 0:o.mainComponent)==null||l.makeDirty()})))}_commandExecutedListener(){const t=[m.RemoveNumfmtMutation.id,m.SetNumfmtMutation.id];this.disposeWithMe(new O.Observable(n=>{const s=this._commandService.onCommandExecuted(r=>{if(t.includes(r.id)){const i=r.params;n.next(i.unitId)}});return()=>s.dispose()}).pipe(k.debounceTime(16)).subscribe(n=>this._forceUpdate(n)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var n;t||((n=this._sidebarDisposable)==null||n.dispose(),this._sidebarDisposable=null)})}};F=at([c.OnLifecycle(c.LifecycleStages.Rendered,F),R(0,C.Inject(m.SheetInterceptorService)),R(1,C.Inject(c.ThemeService)),R(2,c.IUniverInstanceService),R(3,c.ICommandService),R(4,C.Inject(m.SelectionManagerService)),R(5,de.IRenderManagerService),R(6,m.INumfmtService),R(7,C.Inject(I.ComponentManager)),R(8,I.ISidebarService),R(9,C.Inject(c.LocaleService))],F);var lt=Object.defineProperty,ut=Object.getOwnPropertyDescriptor,mt=(e,t,n,s)=>{for(var r=s>1?void 0:s?ut(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(r=(s?o(t,n,r):o(r))||r);return s&&r&<(t,n,r),r},A=(e,t)=>(n,s)=>t(n,s,e);const dt=()=>{let e=[];return{add:(r,i,o,l,u)=>e.push({unitId:r,subUnitId:i,row:o,col:l,value:u}),getEffects:()=>e,clean:()=>{e=[]}}};let q=class extends c.Disposable{constructor(t,n,s,r,i){super();B(this,"_collectEffectMutation",dt());this._sheetInterceptorService=t,this._numfmtService=n,this._univerInstanceService=s,this._injector=r,this._editorBridgeService=i,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{handler:(t,n,s)=>{const r=n.row,i=n.col,o=this._numfmtService.getValue(n.unitId,n.subUnitId,r,i);if(o)switch(K(o.pattern)){case"scientific":case"percent":case"currency":case"grouped":case"number":return n.worksheet.getCellRaw(r,i);case"date":case"time":case"datetime":default:return s&&s(t)}return s(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(t,n,s)=>{var f;this._collectEffectMutation.clean();const r=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),i=(f=r&&K(r.pattern))!=null?f:"",o=()=>{r&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,null)};if(!(t!=null&&t.v))return s(t);const l=String(t.v),u=x.parseDate(l)||x.parseTime(l);if(!!u){if(u&&u.z){const a=Number(u.v);return this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:u.z}),{...t,v:a,t:c.CellValueType.NUMBER}}}else(["date","time","datetime"].includes(i)||!ft(l))&&o();return s(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(n){switch(n.id){case m.SetRangeValuesCommand.id:{const s=t._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),r=s.getUnitId(),i=s.getActiveSheet().getSheetId(),o=t._collectEffectMutation.getEffects();if(!o.length)return{redos:[],undos:[]};const l=o.filter(a=>{var v;return!!((v=a.value)!=null&&v.pattern)}).map(a=>({row:a.row,col:a.col,pattern:a.value.pattern})),u=o.filter(a=>{var v;return!((v=a.value)!=null&&v.pattern)}).map(a=>({startRow:a.row,endColumn:a.col,startColumn:a.col,endRow:a.row})),d=[],f=[];if(l){const a={id:m.SetNumfmtMutation.id,params:m.transformCellsToRange(r,i,l)};d.push(a),f.push(...m.factorySetNumfmtUndoMutation(t._injector,a.params))}if(u){const a={id:m.RemoveNumfmtMutation.id,params:{unitId:r,subUnitId:i,ranges:u}};d.push(a),f.push(...m.factoryRemoveNumfmtUndoMutation(t._injector,a.params))}return{redos:d,undos:f.reverse()}}}return{redos:[],undos:[]}}}))}};q=mt([c.OnLifecycle(c.LifecycleStages.Rendered,q),A(0,C.Inject(m.SheetInterceptorService)),A(1,C.Inject(m.INumfmtService)),A(2,C.Inject(c.IUniverInstanceService)),A(3,C.Inject(C.Injector)),A(4,C.Inject(j.IEditorBridgeService))],q);function ft(e){return/^-?\d+(\.\d+)?$/.test(e)}var ht=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,vt=(e,t,n,s)=>{for(var r=s>1?void 0:s?pt(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(r=(s?o(t,n,r):o(r))||r);return s&&r&&ht(t,n,r),r},St=(e,t)=>(n,s)=>t(n,s,e);let G=class extends c.Disposable{constructor(e){super(),this._localeService=e}};G=vt([c.OnLifecycle(c.LifecycleStages.Rendered,G),St(0,C.Inject(c.LocaleService))],G);const z=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:"@@@"},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Ce="sheet.numfmt.moreNumfmtType",Ie="sheet.numfmt.moreNumfmtType.options",gt=e=>{var s;const t=N.useDependency(c.LocaleService),n=(s=e.value)!=null?s:t.t("sheet.numfmt.general");return h.jsx("span",{className:"more-numfmt-type",children:n})},_t=()=>{const e=N.useDependency(c.ICommandService),t=N.useDependency(c.LocaleService),n=N.useInjector(),s=N.useDependency(m.SelectionManagerService),r=l=>{const u=s.getLast();if(!u)return;const d=n.get(de.ITextSelectionRenderManager),f=u.range,a=[];c.Range.foreach(f,(v,y)=>{l?a.push({row:v,col:y,pattern:l,type:K(l)}):a.push({row:v,col:y})}),e.executeCommand($.id,{values:a}),d.focus()},i=l=>{if(l===0)r(null);else if(l===z.length-1)e.executeCommand(Y.id);else{const u=z[l];u.pattern&&r(u.pattern)}},o=1220;return h.jsx("div",{className:"more-numfmt-type-options",children:z.map((l,u)=>l==="|"?h.jsx("div",{className:"line m-t-4",onClick:d=>d.stopPropagation()},u):h.jsxs("div",{className:"option-item m-t-4",onClick:()=>{i(u)},children:[h.jsx("div",{children:t.t(l.label)}),h.jsx("div",{className:"m-l-26",children:l.pattern?Z(l.pattern||"",o,t.getCurrentLocale()).result:""})]},u))})},bt=e=>({icon:"RmbSingle",id:pe.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:I.MenuItemType.BUTTON,group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[I.MenuPosition.TOOLBAR_START],hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}),yt=e=>({icon:"AddDigitsSingle",id:fe.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:I.MenuItemType.BUTTON,positions:[I.MenuPosition.TOOLBAR_START],group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}),Ct=e=>({icon:"ReduceDigitsSingle",id:ve.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:I.MenuItemType.BUTTON,group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[I.MenuPosition.TOOLBAR_START],hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}),It=e=>({icon:"PercentSingle",id:ye.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:I.MenuItemType.BUTTON,group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[I.MenuPosition.TOOLBAR_START],hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}),Tt=e=>{const t=e.get(m.INumfmtService),n=e.get(c.IUniverInstanceService),s=e.get(c.ICommandService),r=e.get(c.LocaleService),i=e.get(m.SelectionManagerService),o=j.deriveStateFromActiveSheet$(n,"",({workbook:l,worksheet:u})=>new O.Observable(d=>O.merge(i.selectionMoveEnd$,new O.Observable(f=>{const a=[m.RemoveNumfmtMutation.id,m.SetNumfmtMutation.id],v=s.onCommandExecuted(y=>{a.includes(y.id)&&f.next(null)});return()=>v.dispose()})).subscribe(()=>{const f=i.getSelections();if(f&&f[0]){const a=f[0].range,v=a.startRow,y=a.startColumn,g=t.getValue(l.getUnitId(),u.getSheetId(),v,y),p=g==null?void 0:g.pattern;let S=r.t("sheet.numfmt.general");if(p){const _=z.filter(T=>typeof T=="object"&&T.pattern).find(T=>Q(p,T.pattern));_&&typeof _=="object"&&_.pattern?S=r.t(_.label):S=r.t("sheet.numfmt.moreFmt")}d.next(S)}})));return{label:Ce,id:Y.id,tooltip:"sheet.numfmt.title",type:I.MenuItemType.SELECTOR,group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[I.MenuPosition.TOOLBAR_START],selections:[{label:{name:Ie,hoverable:!1}}],value$:o,hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}};var Mt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Nt=(e,t,n,s)=>{for(var r=s>1?void 0:s?Pt(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(r=(s?o(t,n,r):o(r))||r);return s&&r&&Mt(t,n,r),r},ie=(e,t)=>(n,s)=>t(n,s,e);const Et={};let V=class extends c.Disposable{constructor(e,t,n,s){super(),this._config=e,this._injector=t,this._componentManager=n,this._menuService=s,this._initMenu()}_initMenu(){const{menu:e={}}=this._config;[It,yt,Ct,bt,Tt].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(t(this._injector),e))}),this.disposeWithMe(this._componentManager.register(Ce,gt)),this.disposeWithMe(this._componentManager.register(Ie,_t))}};V=Nt([c.OnLifecycle(c.LifecycleStages.Rendered,V),ie(1,C.Inject(C.Injector)),ie(2,C.Inject(I.ComponentManager)),ie(3,C.Inject(I.IMenuService))],V);var Te=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Ot=(e,t,n)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jt=(e,t,n,s)=>{for(var r=s>1?void 0:s?Rt(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(r=(s?o(t,n,r):o(r))||r);return s&&r&&Te(t,n,r),r},xt=(e,t)=>(n,s)=>t(n,s,e),Me=(e,t,n)=>(Ot(e,typeof t!="symbol"?t+"":t,n),n);exports.UniverSheetsNumfmtPlugin=class extends c.Plugin{constructor(t={},n){super(),this._config=t,this._injector=n,this._config=c.Tools.deepMerge({},Et,this._config)}onStarting(){this._injector.add([ae,{useClass:F,lazy:!1}]),this._injector.add([q]),this._injector.add([J]),this._injector.add([W]),this._injector.add([G]),this._injector.add([V,{useFactory:()=>this._injector.createInstance(V,this._config)}])}};Me(exports.UniverSheetsNumfmtPlugin,"pluginName",oe);Me(exports.UniverSheetsNumfmtPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtPlugin=jt([c.DependentOn(m.UniverSheetsPlugin,j.UniverSheetsUIPlugin),xt(1,C.Inject(C.Injector))],exports.UniverSheetsNumfmtPlugin);exports.SetNumfmtCommand=$;exports.getPatternPreview=Z;
|
|
9
|
+
*/var Le=y,Ae=Symbol.for("react.element"),Ve=Symbol.for("react.fragment"),Be=Object.prototype.hasOwnProperty,He=Le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ke={key:!0,ref:!0,__self:!0,__source:!0};function ge(e,t,n){var r,s={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)Be.call(t,r)&&!ke.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:Ae,type:e,key:i,ref:o,props:s,_owner:He.current}}X.Fragment=Ve;X.jsx=ge;X.jsxs=ge;Se.exports=X;var h=Se.exports;const le=y.createContext([]),ce=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"];var We=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(e,t,n,r)=>{for(var s=r>1?void 0:r?Fe(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&We(t,n,s),s},Ge=(e,t)=>(n,r)=>t(n,r,e);let J=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const n=this._getKey(e);return this._localStorageService.getItem(n).then(r=>{r||this._localStorageService.setItem(n,t)})}markHabit(e,t){const n=this._getKey(e);this._localStorageService.getItem(n).then(r=>{if(r){const s=r.findIndex(i=>i===t);s>-1&&r.splice(s,1),r.unshift(t),this._localStorageService.setItem(n,r)}})}async getHabit(e,t){const n=this._getKey(e),r=await this._localStorageService.getItem(n);if(t&&r){const s=r.map((i,o,a)=>{const l=a.length;return{value:i,priority:l-o}});return t.sort((i,o)=>{var p,f;const a=((p=s.find(u=>u.value===i))==null?void 0:p.priority)||-1;return(((f=s.find(u=>u.value===o))==null?void 0:f.priority)||-1)-a})}return r||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};J=qe([Ge(0,C.Inject(c.ILocalStorageService))],J);const me="numfmtCurrency",ze=e=>{const t=N.useDependency(J),[n,r]=y.useState(ce);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(me,[...ce]).then(i=>{r(i),e&&e(i)})})},[]),{userHabitCurrency:n,mark:i=>{t.markHabit(me,i)}}},Ke=()=>{const e=y.useRef([]),[t,n]=y.useState({});return y.useEffect(()=>{e.current.forEach(s=>{s()}),e.current=[]},[t]),s=>{e.current.push(s),n({})}},B=e=>ce.find(n=>e.includes(n)),Ye=e=>!!B(e)&&e.startsWith("_("),Je=e=>{const[t,n]=y.useState(()=>D(e.defaultPattern||"",2)),r=y.useContext(le),[s,i]=y.useState(()=>B(e.defaultPattern)||r[0]),o=y.useMemo(()=>r.map(u=>({label:u,value:u})),[]),l=N.useDependency(c.LocaleService).t;e.action.current=()=>P(`_("${s}"* #,##0${t>0?".0":""}_)`,t);const p=u=>{i(u),e.onChange(P(`_("${u}"* #,##0${t>0?".0":""}_)`,t))},f=u=>{const m=u||0;n(m),e.onChange(P(`_("${s}"* #,##0${m>0?".0":""}_)`,m))};return h.jsxs("div",{children:[h.jsxs("div",{className:"m-t-16 options ",children:[h.jsxs("div",{className:"option",children:[h.jsx("div",{className:"label",children:l("sheet.numfmt.decimalLength")}),h.jsx("div",{className:"m-t-8 w-120",children:h.jsx(E.InputNumber,{value:t,max:20,min:0,onChange:f})})]}),h.jsxs("div",{className:"option",children:[h.jsx("div",{className:"label",children:l("sheet.numfmt.currencyType")}),h.jsx("div",{className:"m-t-8 w-140",children:h.jsx(E.Select,{onChange:p,options:o,value:s})})]})]}),h.jsx("div",{className:"describe m-t-14",children:l("sheet.numfmt.accountingDes")})]})},se=e=>he.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),_e=()=>Ue.map(e=>({label:e.label,value:e.suffix})),be=()=>we.map(e=>({label:e.label,value:e.suffix,color:e.color})),Ze=e=>!!B(e)&&!e.startsWith("_("),Qe=e=>{const n=N.useDependency(c.LocaleService).t,r=y.useContext(le),[s,i]=y.useState(()=>B(e.defaultPattern)||r[0]),[o,a]=y.useState(()=>D(e.defaultPattern||"",2)),[l,p]=y.useState(()=>{var b;const v=se(s);return((b=v.find(T=>Q(T.value,e.defaultPattern)))==null?void 0:b.value)||v[0].value}),f=y.useMemo(()=>se(s),[s]),u=y.useMemo(()=>r.map(v=>({label:v,value:v})),[r]);e.action.current=()=>P(l,o);const m=v=>{if(v===void 0)return;i(v);const g=se(v)[0].value;p(g),e.onChange(P(g,o))},S=v=>{v!==void 0&&(p(v),e.onChange(P(v,o)))},_=v=>{a(v||0),e.onChange(P(l,v||0))};return h.jsxs("div",{children:[h.jsxs("div",{className:"m-t-16 options ",children:[h.jsxs("div",{className:"option",children:[h.jsx("div",{className:"label",children:n("sheet.numfmt.decimalLength")}),h.jsx("div",{className:"m-t-8 w-120",children:h.jsx(E.InputNumber,{value:o,max:20,min:0,onChange:_})})]}),h.jsxs("div",{className:"option",children:[h.jsx("div",{className:"label",children:n("sheet.numfmt.currencyType")}),h.jsx("div",{className:"m-t-8 w-140",children:h.jsx(E.Select,{onChange:m,options:u,value:s})})]})]}),h.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.negType")}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.SelectList,{onChange:S,options:f,value:l})}),h.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.currencyDes")})]})},Xe=e=>{const t=x.getInfo(e);return _e().map(n=>n.value).includes(e)||["date","datetime","time"].includes(t.type)},et=e=>{const t=y.useMemo(_e,[]),r=N.useDependency(c.LocaleService).t,[s,i]=y.useState(()=>{if(e.defaultPattern){const a=t.find(l=>l.value===e.defaultPattern);if(a)return a.value}return t[0].value});e.action.current=()=>s;const o=a=>{a!==void 0&&(i(a),e.onChange(a))};return h.jsxs("div",{children:[h.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.dateType")}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.SelectList,{value:s,options:t,onChange:o})}),h.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.dateDes")})]})},tt=e=>!e,nt=e=>{const n=N.useDependency(c.LocaleService).t;return e.action.current=()=>"",h.jsx("div",{children:h.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.generalDes")})})},rt=e=>be().some(t=>Q(t.value,e)),st=e=>{const t=N.useDependency(c.LocaleService),n=y.useMemo(be,[]),[r,s]=y.useState(()=>D(e.defaultPattern||"",0)),[i,o]=y.useState(()=>{const u=n.find(m=>Q(m.value,e.defaultPattern||""));return(u==null?void 0:u.value)||n[0].value}),a=y.useMemo(()=>P(i,Number(r||0)),[i,r]),l=y.useMemo(()=>!De(i),[i]),p=u=>{s(u||0),e.onChange(P(i,Number(u||0)))},f=u=>{u!==void 0&&(s(D(u,0)),o(u),e.onChange(u))};return e.action.current=()=>a,h.jsxs("div",{children:[h.jsx("div",{className:"m-t-16 label",children:t.t("sheet.numfmt.decimalLength")}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.InputNumber,{disabled:l,value:r,max:20,min:0,onChange:p})}),h.jsxs("div",{className:"m-t-16 label",children:[" ",t.t("sheet.numfmt.negType")]}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.SelectList,{onChange:f,options:n,value:i})}),h.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},it=e=>{const{defaultValue:t,defaultPattern:n,row:r,col:s}=e.value,i=N.useDependency(c.LocaleService),o=y.useRef(()=>""),a=i.t,l=Ke(),p=y.useMemo(()=>[{label:"sheet.numfmt.general",component:nt},{label:"sheet.numfmt.accounting",component:Je},{label:"sheet.numfmt.currency",component:Qe},{label:"sheet.numfmt.date",component:et},{label:"sheet.numfmt.thousandthPercentile",component:st}].map(M=>({...M,label:a(M.label)})),[]),[f,u]=y.useState(b),[m,S]=y.useState(()=>`${r}_${s}`),{mark:_,userHabitCurrency:v}=ze(()=>S(`${r}_${s}_userCurrency'`)),g=y.useMemo(()=>{var M;return(M=p.find(U=>U.label===f))==null?void 0:M.component},[f]);function b(){return[tt,Ye,Ze,Xe,rt].reduce((U,Ne,Ee)=>U||(Ne(n)?p[Ee].label:""),"")||p[0].label}const T=p.map(M=>({label:M.label,value:M.label})),L=M=>{u(M),l(()=>e.onChange({type:"change",value:o.current()||""}))},ee=M=>{e.onChange({type:"change",value:M})},te=()=>{const M=o.current()||"",U=B(M);U&&_(U),e.onChange({type:"confirm",value:M})},ne=()=>{e.onChange({type:"cancel",value:""})},Pe={onChange:ee,defaultValue:t,defaultPattern:n,action:o};return y.useEffect(()=>{u(b()),S(`${r}_${s}`)},[r,s]),h.jsxs("div",{className:"numfmt-panel p-b-20",children:[h.jsxs("div",{children:[h.jsx("div",{className:"label m-t-14",children:a("sheet.numfmt.numfmtType")}),h.jsx("div",{className:"m-t-8",children:h.jsx(E.Select,{onChange:L,options:T,value:f})}),h.jsx("div",{children:g&&h.jsx(le.Provider,{value:v,children:y.createElement(g,{...Pe,key:m})})})]}),h.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[h.jsx(E.Button,{size:"small",onClick:ne,className:"m-r-12",children:a("sheet.numfmt.cancel")}),h.jsx(E.Button,{type:"primary",size:"small",onClick:te,children:a("sheet.numfmt.confirm")})]})]})},ye={id:"sheet.command.numfmt.set.percent",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),r=e.get(d.SelectionManagerService).getSelections();if(!r||!r.length)return!1;const s=[],i="0%";return r.forEach(a=>{c.Range.foreach(a.range,(l,p)=>{s.push({row:l,col:p,pattern:i,type:"percent"})})}),await t.executeCommand($.id,{values:s})}};var ot=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,at=(e,t,n,r)=>{for(var s=r>1?void 0:r?ct(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&ot(t,n,s),s},R=(e,t)=>(n,r)=>t(n,r,e);let F=class extends c.Disposable{constructor(t,n,r,s,i,o,a,l,p,f){super();H(this,"_previewPattern","");H(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=n,this._univerInstanceService=r,this._commandService=s,this._selectionManagerService=i,this._renderManagerService=o,this._numfmtService=a,this._componentManager=l,this._sidebarService=p,this._localeService=f,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener()}openPanel(){const t=this._sidebarService,n=this._selectionManagerService,r=this._commandService,s=this._univerInstanceService,i=this._numfmtService,o=this._localeService,l=(n.getSelectionRanges()||[])[0];if(!l)return!1;const p=s.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),f=p.getActiveSheet();if(!f)return!1;const u=f.getCellRaw(l.startRow,l.startColumn),m=i.getValue(p.getUnitId(),f.getSheetId(),l.startRow,l.startColumn);let S="";m&&(S=m.pattern);const _=(u==null?void 0:u.t)===c.CellValueType.NUMBER?u.v:12345678,v={onChange:g=>{if(g.type==="change")this._previewPattern=g.value,this._forceUpdate();else if(g.type==="confirm"){const b=n.getSelectionRanges()||[],T={values:[]},L=K(g.value);b.forEach(ee=>{c.Range.foreach(ee,(te,ne)=>{T.values.push({row:te,col:ne,pattern:g.value,type:L})})}),r.executeCommand($.id,T),t.close()}else g.type==="cancel"&&t.close()},value:{defaultPattern:S,defaultValue:_,row:l.startRow,col:l.startColumn}};return this._sidebarDisposable=t.open({header:{title:o.t("sheet.numfmt.title")},children:{label:oe,...v},onClose:()=>{this._forceUpdate(),r.executeCommand(re.id)}}),!0}_forceUpdate(t){var r;const n=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET).getUnitId());n==null||n.with(j.SheetSkeletonManagerService).reCalculate(),(r=n==null?void 0:n.mainComponent)==null||r.makeDirty()}_initCommands(){[fe,ve,pe,ye,Y,re,$].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(oe,it)}_initRealTimeRenderingInterceptor(){const t=new O.Observable(r=>{this._commandService.onCommandExecuted(s=>{s.id===Y.id&&r.next(!0),s.id===re.id&&r.next(!1)})}),n=O.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(k.map(r=>r?r.map(s=>s.range):[]))]);this.disposeWithMe(c.toDisposable(n.pipe(k.switchMap(([r,s])=>new O.Observable(i=>{const o=new c.DisposableCollection;return r&&s.length&&i.next({selectionRanges:s,disposableCollection:o}),()=>{o.dispose()}})),k.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:r,selectionRanges:s})=>{var o,a;const i=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);this.openPanel(),r.add(this._sheetInterceptorService.intercept(d.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,handler:(l,p,f)=>{const{row:u,col:m}=p,S=f(l)||{};if(s.find(_=>_.startColumn<=m&&_.endColumn>=m&&_.startRow<=u&&_.endRow>=u)){const _=p.worksheet.getCellRaw(u,m),v=_==null?void 0:_.v,g=_==null?void 0:_.t;if(v==null||g!==c.CellValueType.NUMBER||this._previewPattern===null)return S;const b=Z(this._previewPattern,v,this._localeService.getCurrentLocale());if(b.color){const L=this._themeService.getCurrentTheme()[`${b.color}500`];return{...S,v:b.result,t:c.CellValueType.STRING,s:{cl:{rgb:L}}}}return{...S,v:b.result,t:c.CellValueType.STRING}}return S}})),(a=(o=this._renderManagerService.getRenderById(i.getUnitId()))==null?void 0:o.mainComponent)==null||a.makeDirty()})))}_commandExecutedListener(){const t=[d.RemoveNumfmtMutation.id,d.SetNumfmtMutation.id];this.disposeWithMe(new O.Observable(n=>{const r=this._commandService.onCommandExecuted(s=>{if(t.includes(s.id)){const i=s.params;n.next(i.unitId)}});return()=>r.dispose()}).pipe(k.debounceTime(16)).subscribe(n=>this._forceUpdate(n)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var n;t||((n=this._sidebarDisposable)==null||n.dispose(),this._sidebarDisposable=null)})}};F=at([c.OnLifecycle(c.LifecycleStages.Rendered,F),R(0,C.Inject(d.SheetInterceptorService)),R(1,C.Inject(c.ThemeService)),R(2,c.IUniverInstanceService),R(3,c.ICommandService),R(4,C.Inject(d.SelectionManagerService)),R(5,de.IRenderManagerService),R(6,d.INumfmtService),R(7,C.Inject(I.ComponentManager)),R(8,I.ISidebarService),R(9,C.Inject(c.LocaleService))],F);var lt=Object.defineProperty,ut=Object.getOwnPropertyDescriptor,mt=(e,t,n,r)=>{for(var s=r>1?void 0:r?ut(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&<(t,n,s),s},A=(e,t)=>(n,r)=>t(n,r,e);const dt=()=>{let e=[];return{add:(s,i,o,a,l)=>e.push({unitId:s,subUnitId:i,row:o,col:a,value:l}),getEffects:()=>e,clean:()=>{e=[]}}};let q=class extends c.Disposable{constructor(t,n,r,s,i){super();H(this,"_collectEffectMutation",dt());this._sheetInterceptorService=t,this._numfmtService=n,this._univerInstanceService=r,this._injector=s,this._editorBridgeService=i,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{handler:(t,n,r)=>{const s=n.row,i=n.col,o=this._numfmtService.getValue(n.unitId,n.subUnitId,s,i);if(o)switch(K(o.pattern)){case"scientific":case"percent":case"currency":case"grouped":case"number":return n.worksheet.getCellRaw(s,i);case"date":case"time":case"datetime":default:return r&&r(t)}return r(t)}})))}_initInterceptorEditorEnd(){this._editorBridgeService&&this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(t,n,r)=>{var f;this._collectEffectMutation.clean();const s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),i=(f=s&&K(s.pattern))!=null?f:"",o=()=>{s&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,null)};if(!(t!=null&&t.v))return r(t);const a=String(t.v),l=x.parseDate(a)||x.parseTime(a);if(!!l){if(l&&l.z){const u=Number(l.v);return this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:l.z}),{...t,v:u,t:c.CellValueType.NUMBER}}}else(["date","time","datetime"].includes(i)||!ft(a))&&o();return r(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(n){var r;switch(n.id){case d.SetRangeValuesCommand.id:{const s=t._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),i=s.getUnitId(),o=(r=s.getActiveSheet())==null?void 0:r.getSheetId();if(!o)return{redos:[],undos:[]};const a=t._collectEffectMutation.getEffects();if(!a.length)return{redos:[],undos:[]};const l=a.filter(m=>{var S;return!!((S=m.value)!=null&&S.pattern)}).map(m=>({row:m.row,col:m.col,pattern:m.value.pattern})),p=a.filter(m=>{var S;return!((S=m.value)!=null&&S.pattern)}).map(m=>({startRow:m.row,endColumn:m.col,startColumn:m.col,endRow:m.row})),f=[],u=[];if(l){const m={id:d.SetNumfmtMutation.id,params:d.transformCellsToRange(i,o,l)};f.push(m),u.push(...d.factorySetNumfmtUndoMutation(t._injector,m.params))}if(p){const m={id:d.RemoveNumfmtMutation.id,params:{unitId:i,subUnitId:o,ranges:p}};f.push(m),u.push(...d.factoryRemoveNumfmtUndoMutation(t._injector,m.params))}return{redos:f,undos:u.reverse()}}}return{redos:[],undos:[]}}}))}};q=mt([c.OnLifecycle(c.LifecycleStages.Rendered,q),A(0,C.Inject(d.SheetInterceptorService)),A(1,C.Inject(d.INumfmtService)),A(2,C.Inject(c.IUniverInstanceService)),A(3,C.Inject(C.Injector)),A(4,C.Optional(j.IEditorBridgeService))],q);function ft(e){return/^-?\d+(\.\d+)?$/.test(e)}var ht=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,vt=(e,t,n,r)=>{for(var s=r>1?void 0:r?pt(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&ht(t,n,s),s},St=(e,t)=>(n,r)=>t(n,r,e);let G=class extends c.Disposable{constructor(e){super(),this._localeService=e}};G=vt([c.OnLifecycle(c.LifecycleStages.Rendered,G),St(0,C.Inject(c.LocaleService))],G);const z=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:"@@@"},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Ce="sheet.numfmt.moreNumfmtType",Ie="sheet.numfmt.moreNumfmtType.options",gt=e=>{var r;const t=N.useDependency(c.LocaleService),n=(r=e.value)!=null?r:t.t("sheet.numfmt.general");return h.jsx("span",{className:"more-numfmt-type",children:n})},_t=()=>{const e=N.useDependency(c.ICommandService),t=N.useDependency(c.LocaleService),n=N.useInjector(),r=N.useDependency(d.SelectionManagerService),s=a=>{const l=r.getLast();if(!l)return;const p=n.get(de.ITextSelectionRenderManager),f=l.range,u=[];c.Range.foreach(f,(m,S)=>{a?u.push({row:m,col:S,pattern:a,type:K(a)}):u.push({row:m,col:S})}),e.executeCommand($.id,{values:u}),p.focus()},i=a=>{if(a===0)s(null);else if(a===z.length-1)e.executeCommand(Y.id);else{const l=z[a];l.pattern&&s(l.pattern)}},o=1220;return h.jsx("div",{className:"more-numfmt-type-options",children:z.map((a,l)=>a==="|"?h.jsx("div",{className:"line m-t-4",onClick:p=>p.stopPropagation()},l):h.jsxs("div",{className:"option-item m-t-4",onClick:()=>{i(l)},children:[h.jsx("div",{children:t.t(a.label)}),h.jsx("div",{className:"m-l-26",children:a.pattern?Z(a.pattern||"",o,t.getCurrentLocale()).result:""})]},l))})},bt=e=>({icon:"RmbSingle",id:pe.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:I.MenuItemType.BUTTON,group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[I.MenuPosition.TOOLBAR_START],hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetEditPermission,d.WorksheetSetCellStylePermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}),yt=e=>({icon:"AddDigitsSingle",id:fe.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:I.MenuItemType.BUTTON,positions:[I.MenuPosition.TOOLBAR_START],group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetEditPermission,d.WorksheetSetCellStylePermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}),Ct=e=>({icon:"ReduceDigitsSingle",id:ve.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:I.MenuItemType.BUTTON,group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[I.MenuPosition.TOOLBAR_START],hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetEditPermission,d.WorksheetSetCellStylePermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}),It=e=>({icon:"PercentSingle",id:ye.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:I.MenuItemType.BUTTON,group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[I.MenuPosition.TOOLBAR_START],hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetEditPermission,d.WorksheetSetCellStylePermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}),Tt=e=>{const t=e.get(d.INumfmtService),n=e.get(c.IUniverInstanceService),r=e.get(c.ICommandService),s=e.get(c.LocaleService),i=e.get(d.SelectionManagerService),o=j.deriveStateFromActiveSheet$(n,"",({workbook:a,worksheet:l})=>new O.Observable(p=>O.merge(i.selectionMoveEnd$,new O.Observable(f=>{const u=[d.RemoveNumfmtMutation.id,d.SetNumfmtMutation.id],m=r.onCommandExecuted(S=>{u.includes(S.id)&&f.next(null)});return()=>m.dispose()})).subscribe(()=>{const f=i.getSelections();if(f&&f[0]){const u=f[0].range,m=u.startRow,S=u.startColumn,_=t.getValue(a.getUnitId(),l.getSheetId(),m,S),v=_==null?void 0:_.pattern;let g=s.t("sheet.numfmt.general");if(v){const b=z.filter(T=>typeof T=="object"&&T.pattern).find(T=>Q(v,T.pattern));b&&typeof b=="object"&&b.pattern?g=s.t(b.label):g=s.t("sheet.numfmt.moreFmt")}p.next(g)}})));return{label:Ce,id:Y.id,tooltip:"sheet.numfmt.title",type:I.MenuItemType.SELECTOR,group:I.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[I.MenuPosition.TOOLBAR_START],selections:[{label:{name:Ie,hoverable:!1}}],value$:o,hidden$:I.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSetCellStylePermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}};var Mt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Nt=(e,t,n,r)=>{for(var s=r>1?void 0:r?Pt(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&Mt(t,n,s),s},ie=(e,t)=>(n,r)=>t(n,r,e);const Et={};let V=class extends c.Disposable{constructor(e,t,n,r){super(),this._config=e,this._injector=t,this._componentManager=n,this._menuService=r,this._initMenu()}_initMenu(){const{menu:e={}}=this._config;[It,yt,Ct,bt,Tt].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(t(this._injector),e))}),this.disposeWithMe(this._componentManager.register(Ce,gt)),this.disposeWithMe(this._componentManager.register(Ie,_t))}};V=Nt([c.OnLifecycle(c.LifecycleStages.Rendered,V),ie(1,C.Inject(C.Injector)),ie(2,C.Inject(I.ComponentManager)),ie(3,C.Inject(I.IMenuService))],V);var Te=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Ot=(e,t,n)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jt=(e,t,n,r)=>{for(var s=r>1?void 0:r?Rt(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&Te(t,n,s),s},xt=(e,t)=>(n,r)=>t(n,r,e),Me=(e,t,n)=>Ot(e,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsNumfmtPlugin=class extends c.Plugin{constructor(t={},n){super(),this._config=t,this._injector=n,this._config=c.Tools.deepMerge({},Et,this._config)}onStarting(){this._injector.add([ae,{useClass:F,lazy:!1}]),this._injector.add([q]),this._injector.add([J]),this._injector.add([W]),this._injector.add([G]),this._injector.add([V,{useFactory:()=>this._injector.createInstance(V,this._config)}])}};Me(exports.UniverSheetsNumfmtPlugin,"pluginName",oe);Me(exports.UniverSheetsNumfmtPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtPlugin=jt([c.DependentOn(d.UniverSheetsPlugin,j.UniverSheetsUIPlugin),xt(1,C.Inject(C.Injector))],exports.UniverSheetsNumfmtPlugin);exports.SetNumfmtCommand=$;exports.getPatternPreview=Z;
|