@univerjs/sheets-numfmt-ui 0.6.3 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/umd/index.js CHANGED
@@ -1,5 +1,5 @@
1
- (function(b,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/engine-formula"),require("@univerjs/engine-numfmt"),require("@univerjs/sheets"),require("rxjs"),require("rxjs/operators"),require("react/jsx-runtime"),require("react"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/engine-formula","@univerjs/engine-numfmt","@univerjs/sheets","rxjs","rxjs/operators","react/jsx-runtime","react","@univerjs/design"],o):(b=typeof globalThis<"u"?globalThis:b||self,o(b.UniverSheetsNumfmtUi={},b.UniverCore,b.UniverEngineRender,b.UniverSheetsNumfmt,b.UniverSheetsUi,b.UniverUi,b.UniverEngineFormula,b.UniverEngineNumfmt,b.UniverSheets,b.rxjs,b.rxjs.operators,b.React,b.React,b.UniverDesign))})(this,function(b,o,k,m,M,C,ve,W,h,w,V,u,y,P){"use strict";var lt=Object.defineProperty;var ut=(b,o,k)=>o in b?lt(b,o,{enumerable:!0,configurable:!0,writable:!0,value:k}):b[o]=k;var Z=(b,o,k)=>ut(b,typeof o!="symbol"?o+"":o,k);const ie={};var fe=Object.getOwnPropertyDescriptor,he=(e,t,r,n)=>{for(var i=n>1?void 0:n?fe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},L=(e,t)=>(r,n)=>t(r,n,e);const z="SHEET_NUMFMT_ALERT";let Y=class extends o.Disposable{constructor(e,t,r,n,i,a,s){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=r,this._localeService=n,this._formulaDataModel=i,this._zenZoneService=a,this._numfmtService=s,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(w.debounceTime(100)).subscribe(e=>{var t;if(e){const r=e.location,n=this._context.unit,i=n.getActiveSheet();if(!i)return;const a=r.unitId,s=r.subUnitId;let l;const c=i.getCell(r.row,r.col);if(c!=null&&c.s){const d=n.getStyles().get(c.s);d!=null&&d.n&&(l=d.n)}if(l||(l=this._numfmtService.getValue(a,s,r.row,r.col)),!l){this._hideAlert();return}if(W.isTextFormat(l.pattern)&&(c!=null&&c.v)&&o.isRealNum(c.v)){const d=this._cellAlertManagerService.currentAlert.get(z),S=(t=d==null?void 0:d.alert)==null?void 0:t.location;if(S&&S.row===r.row&&S.col===r.col&&S.subUnitId===r.subUnitId&&S.unitId===r.unitId)return;this._cellAlertManagerService.showAlert({type:M.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:r,width:200,height:74,key:z});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(z)}};Y=he([L(1,o.Inject(M.HoverManagerService)),L(2,o.Inject(M.CellAlertManagerService)),L(3,o.Inject(o.LocaleService)),L(4,o.Inject(ve.FormulaDataModel)),L(5,C.IZenZoneService),L(6,o.Inject(h.INumfmtService))],Y);const X={id:"sheet.operation.close.numfmt.panel",type:o.CommandType.OPERATION,handler:()=>!0},$={id:"sheet.operation.open.numfmt.panel",type:o.CommandType.OPERATION,handler:e=>(e.get(x).openPanel(),!0)};var Se=Object.getOwnPropertyDescriptor,ge=(e,t,r,n)=>{for(var i=n>1?void 0:n?Se(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},ye=(e,t)=>(r,n)=>t(r,n,e);const J=y.createContext([]);let H=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const r=this._getKey(e);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,t)})}markHabit(e,t){const r=this._getKey(e);this._localStorageService.getItem(r).then(n=>{if(n){const i=n.findIndex(a=>a===t);i>-1&&n.splice(i,1),n.unshift(t),this._localStorageService.setItem(r,n)}})}async getHabit(e,t){const r=this._getKey(e),n=await this._localStorageService.getItem(r);if(t&&n){const i=n.map((a,s,l)=>{const c=l.length;return{value:a,priority:c-s}});return t.sort((a,s)=>{var d,S;const l=((d=i.find(p=>p.value===a))==null?void 0:d.priority)||-1;return(((S=i.find(p=>p.value===s))==null?void 0:S.priority)||-1)-l})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};H=ge([ye(0,o.Inject(o.ILocalStorageService))],H);const ae="numfmtCurrency",_e=e=>{const t=C.useDependency(H),[r,n]=y.useState(m.currencySymbols);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(ae,[...m.currencySymbols]).then(a=>{n(a),e&&e(a)})})},[]),{userHabitCurrency:r,mark:a=>{t.markHabit(ae,a)}}},Ce=()=>{const e=y.useRef([]),[t,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[t]),i=>{e.current.push(i),r({})}},be=e=>!!m.getCurrencyType(e)&&e.startsWith("_("),Ie=e=>{const{defaultPattern:t,action:r,onChange:n}=e,[i,a]=y.useState(()=>m.getDecimalFromPattern(t||"",2)),s=y.useContext(J),[l,c]=y.useState(()=>m.getCurrencyType(t)||s[0]),d=y.useMemo(()=>s.map(_=>({label:_,value:_})),[]),p=C.useDependency(o.LocaleService).t;r.current=()=>m.setPatternDecimal(`_("${l}"* #,##0${i>0?".0":""}_)`,i);const v=_=>{c(_),n(m.setPatternDecimal(`_("${_}"* #,##0${i>0?".0":""}_)`,i))},g=_=>{const f=_||0;a(f),n(m.setPatternDecimal(`_("${l}"* #,##0${f>0?".0":""}_)`,f))};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:p("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8 w-120",children:u.jsx(P.InputNumber,{value:i,max:20,min:0,onChange:g})})]}),u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:p("sheet.numfmt.currencyType")}),u.jsx("div",{className:"m-t-8 w-140",children:u.jsx(P.Select,{onChange:v,options:d,value:l})})]})]}),u.jsx("div",{className:"describe m-t-14",children:p("sheet.numfmt.accountingDes")})]})},Te=e=>!!m.getCurrencyType(e)&&!e.startsWith("_("),Ee=e=>{const r=C.useDependency(o.LocaleService).t,n=y.useContext(J),[i,a]=y.useState(()=>m.getCurrencyType(e.defaultPattern)||n[0]),[s,l]=y.useState(()=>m.getDecimalFromPattern(e.defaultPattern||"",2)),[c,d]=y.useState(()=>{var I;const f=m.getCurrencyFormatOptions(i);return((I=f.find(O=>m.isPatternEqualWithoutDecimal(O.value,e.defaultPattern)))==null?void 0:I.value)||f[0].value}),S=y.useMemo(()=>m.getCurrencyFormatOptions(i),[i]),p=y.useMemo(()=>n.map(f=>({label:f,value:f})),[n]);e.action.current=()=>m.setPatternDecimal(c,s);const v=f=>{if(f===void 0)return;a(f);const E=m.getCurrencyFormatOptions(f)[0].value;d(E),e.onChange(m.setPatternDecimal(E,s))},g=f=>{f!==void 0&&(d(f),e.onChange(m.setPatternDecimal(f,s)))},_=f=>{l(f||0),e.onChange(m.setPatternDecimal(c,f||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:r("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8 w-120",children:u.jsx(P.InputNumber,{value:s,max:20,min:0,onChange:_})})]}),u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),u.jsx("div",{className:"m-t-8 w-140",children:u.jsx(P.Select,{onChange:v,options:p,value:i})})]})]}),u.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.SelectList,{onChange:g,options:S,value:c})}),u.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})};var D=function(){return D=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},D.apply(this,arguments)},Pe=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},oe=y.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,a=e.extend,s=Pe(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=y.useRef("_".concat(Oe()));return se(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},D({ref:t,className:l},s),a)});function se(e,t,r,n,i){return y.createElement(e.tag,D(D({key:t},Me(e,r,i)),n),(De(e,r).children||[]).map(function(a,s){return se(a,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function Me(e,t,r){var n=D({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(a){var s=a[0],l=a[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function De(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?D(D({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?D(D({},i),{attrs:D(D({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function Oe(){return Math.random().toString(36).substring(2,8)}oe.displayName="UniverIcon";var Ue={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"}}]},ce=y.forwardRef(function(e,t){return y.createElement(oe,Object.assign({},e,{id:"check-mark-single",ref:t,icon:Ue}))});ce.displayName="CheckMarkSingle";const F={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"},Q="customFormat",ee="numfmt_custom_pattern";function we(e){const{defaultPattern:t,action:r,onChange:n}=e,i=C.useDependency(H),a=C.useDependency(o.ILocalStorageService),s=C.useDependency(o.LocaleService),[l,c]=y.useState(t);r.current=()=>(i.markHabit(Q,l),a.getItem(ee).then((g=[])=>{const _=[...new Set([l,...g||[]])].splice(0,10).filter(f=>!!f);a.setItem(ee,_)}),l);const[d,S]=y.useState([]);y.useEffect(()=>{a.getItem(ee).then(g=>{const _=[...m.CURRENCYFORMAT.map(f=>f.suffix("$")),...m.DATEFMTLISG.map(f=>f.suffix),...m.NUMBERFORMAT.map(f=>f.suffix)];_.push(...g||[]),i.addHabit(Q,[]).finally(()=>{i.getHabit(Q,_).then(f=>{S([...new Set(f)])})})})},[]);const p=g=>{c(g),n(g)},v=()=>{n(l)};return u.jsxs("div",{className:F.customFormat,children:[u.jsx("div",{className:F.customFormatTitle,children:s.t("sheet.numfmt.customFormat")}),u.jsx(P.Input,{placeholder:s.t("sheet.numfmt.customFormat"),onBlur:v,value:l,onChange:c,className:F.customFormatInput}),u.jsx("div",{className:F.customFormatHistoryList,children:d.map(g=>u.jsxs("div",{onClick:()=>p(g),className:F.customFormatHistoryListItem,children:[u.jsx("div",{className:F.customFormatHistoryListItemIconWrap,children:l===g&&u.jsx(ce,{})}),u.jsx("div",{children:g})]},g))}),u.jsx("div",{className:F.customFormatDes,children:s.t("sheet.numfmt.customFormatDes")})]})}const Ne=e=>{const t=o.numfmt.getInfo(e);return m.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)},ke=e=>{const t=y.useMemo(m.getDateFormatOptions,[]),n=C.useDependency(o.LocaleService).t,[i,a]=y.useState(()=>{if(e.defaultPattern){const l=t.find(c=>c.value===e.defaultPattern);if(l)return l.value}return t[0].value});e.action.current=()=>i;const s=l=>{l!==void 0&&(a(l),e.onChange(l))};return u.jsxs("div",{children:[u.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.dateType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.SelectList,{value:i,options:t,onChange:s})}),u.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},Fe=e=>!e,Le=e=>{const r=C.useDependency(o.LocaleService).t;return e.action.current=()=>"",u.jsx("div",{children:u.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},je=e=>m.getNumberFormatOptions().some(t=>m.isPatternEqualWithoutDecimal(t.value,e)),$e=e=>{const t=C.useDependency(o.LocaleService),r=y.useMemo(m.getNumberFormatOptions,[]),[n,i]=y.useState(()=>m.getDecimalFromPattern(e.defaultPattern||"",0)),[a,s]=y.useState(()=>{const p=r.find(v=>m.isPatternEqualWithoutDecimal(v.value,e.defaultPattern||""));return(p==null?void 0:p.value)||r[0].value}),l=y.useMemo(()=>m.setPatternDecimal(a,Number(n||0)),[a,n]),c=y.useMemo(()=>!m.isPatternHasDecimal(a),[a]),d=p=>{i(p||0),e.onChange(m.setPatternDecimal(a,Number(p||0)))},S=p=>{p!==void 0&&(i(m.getDecimalFromPattern(p,0)),s(p),e.onChange(p))};return e.action.current=()=>l,u.jsxs("div",{children:[u.jsx("div",{className:"m-t-16 label",children:t.t("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.InputNumber,{disabled:c,value:n,max:20,min:0,onChange:d})}),u.jsxs("div",{className:"m-t-16 label",children:[" ",t.t("sheet.numfmt.negType")]}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.SelectList,{onChange:S,options:r,value:a})}),u.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},He=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:i}=e.value,a=C.useDependency(o.LocaleService),s=y.useRef(()=>""),l=a.t,c=Ce(),d=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Le},{label:"sheet.numfmt.accounting",component:Ie},{label:"sheet.numfmt.currency",component:Ee},{label:"sheet.numfmt.date",component:ke},{label:"sheet.numfmt.thousandthPercentile",component:$e},{label:"sheet.numfmt.customFormat",component:we}].map(T=>({...T,label:l(T.label)})),[]),[S,p]=y.useState(I),[v,g]=y.useState(()=>`${n}_${i}`),{mark:_,userHabitCurrency:f}=_e(()=>g(`${n}_${i}_userCurrency'`)),E=y.useMemo(()=>{var T;return(T=d.find(j=>j.label===S))==null?void 0:T.component},[S]);function I(){return[Fe,be,Te,Ne,je].reduce((j,st,ct)=>j||(st(r)?d[ct].label:""),"")||d[0].label}const O=d.map(T=>({label:T.label,value:T.label})),N=T=>{p(T),c(()=>e.onChange({type:"change",value:s.current()||""}))},K=T=>{e.onChange({type:"change",value:T})},ne=()=>{const T=s.current()||"",j=m.getCurrencyType(T);j&&_(j),e.onChange({type:"confirm",value:T})},R=()=>{e.onChange({type:"cancel",value:""})},re={onChange:K,defaultValue:t,defaultPattern:r,action:s};return y.useEffect(()=>{p(I()),g(`${n}_${i}`)},[n,i]),u.jsxs("div",{className:"numfmt-panel p-b-20",children:[u.jsxs("div",{children:[u.jsx("div",{className:"label m-t-14",children:l("sheet.numfmt.numfmtType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.Select,{onChange:N,options:O,value:S,style:{width:"100%"}})}),u.jsx("div",{children:E&&u.jsx(J.Provider,{value:f,children:y.createElement(E,{...re,key:v})})})]}),u.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[u.jsx(P.Button,{size:"small",onClick:R,className:"m-r-12",children:l("sheet.numfmt.cancel")}),u.jsx(P.Button,{type:"primary",size:"small",onClick:ne,children:l("sheet.numfmt.confirm")})]})]})};var xe=Object.getOwnPropertyDescriptor,Ae=(e,t,r,n)=>{for(var i=n>1?void 0:n?xe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},U=(e,t)=>(r,n)=>t(r,n,e);const le="SHEET_NUMFMT_PANEL";let x=class extends o.Disposable{constructor(t,r,n,i,a,s,l,c,d,S,p){super();Z(this,"_previewPattern","");Z(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=a,this._renderManagerService=s,this._numfmtService=l,this._componentManager=c,this._sidebarService=d,this._localeService=S,this._sheetsNumfmtCellContentController=p,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(w.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var E;const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,a=this._numfmtService,s=this._localeService,c=(((E=r.getCurrentSelections())==null?void 0:E.map(I=>I.range))||[])[0];if(!c)return!1;const d=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),S=d.getActiveSheet();if(!S)return!1;const p=S.getCellRaw(c.startRow,c.startColumn),v=a.getValue(d.getUnitId(),S.getSheetId(),c.startRow,c.startColumn);let g="";v&&(g=v.pattern);const _=(p==null?void 0:p.t)===o.CellValueType.NUMBER?p.v:12345678,f={onChange:I=>{var O;if(I.type==="change")this._previewPattern=I.value,this._forceUpdate();else if(I.type==="confirm"){const N=((O=r.getCurrentSelections())==null?void 0:O.map(R=>R.range))||[],K={values:[]},ne=m.getPatternType(I.value);N.forEach(R=>{o.Range.foreach(R,(re,T)=>{K.values.push({row:re,col:T,pattern:I.value,type:ne})})}),n.executeCommand(m.SetNumfmtCommand.id,K),t.close()}else I.type==="cancel"&&t.close()},value:{defaultPattern:g,defaultValue:_,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=t.open({header:{title:s.t("sheet.numfmt.title")},children:{label:le,...f},onClose:()=>{this._forceUpdate(),n.executeCommand(X.id)}}),!0}_forceUpdate(t){var n;const r=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(M.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[$,X].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(le,He)}_initRealTimeRenderingInterceptor(){const t=new w.Observable(n=>{this._commandService.onCommandExecuted(i=>{i.id===$.id&&n.next(!0),i.id===X.id&&n.next(!1)})}),r=w.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(V.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(o.toDisposable(r.pipe(V.switchMap(([n,i])=>new w.Observable(a=>{const s=new o.DisposableCollection;return n&&i.length&&a.next({selectionRanges:i,disposableCollection:s}),()=>{s.dispose()}})),V.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var s,l;const a=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(h.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:o.InterceptorEffectEnum.Value|o.InterceptorEffectEnum.Style,handler:(c,d,S)=>{const{row:p,col:v}=d,g=S(c)||{};if(i.find(_=>_.startColumn<=v&&_.endColumn>=v&&_.startRow<=p&&_.endRow>=p)){const _=d.worksheet.getCellRaw(p,v),f=_==null?void 0:_.v,E=_==null?void 0:_.t;if(f==null||E!==o.CellValueType.NUMBER||this._previewPattern===null)return g;const I=m.getPatternPreviewIgnoreGeneral(this._previewPattern,f,this._sheetsNumfmtCellContentController.local);if(I.color){const N=this._themeService.getCurrentTheme()[`${I.color}500`];return{...g,v:I.result,t:o.CellValueType.STRING,s:{cl:{rgb:N}}}}return{...g,v:I.result,t:o.CellValueType.STRING}}return g}})),(l=(s=this._renderManagerService.getRenderById(a.getUnitId()))==null?void 0:s.mainComponent)==null||l.makeDirty()})))}_commandExecutedListener(){const t=[h.RemoveNumfmtMutation.id,h.SetNumfmtMutation.id];this.disposeWithMe(new w.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(t.includes(i.id)){const a=i.params;r.next(a.unitId)}});return()=>n.dispose()}).pipe(V.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};x=Ae([U(0,o.Inject(h.SheetInterceptorService)),U(1,o.Inject(o.ThemeService)),U(2,o.IUniverInstanceService),U(3,o.ICommandService),U(4,o.Inject(h.SheetsSelectionsService)),U(5,k.IRenderManagerService),U(6,h.INumfmtService),U(7,o.Inject(C.ComponentManager)),U(8,C.ISidebarService),U(9,o.Inject(o.LocaleService)),U(10,o.Inject(m.SheetsNumfmtCellContentController))],x);var Re=Object.getOwnPropertyDescriptor,We=(e,t,r,n)=>{for(var i=n>1?void 0:n?Re(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},A=(e,t)=>(r,n)=>t(r,n,e);const Ve=()=>{let e=[];return{add:(i,a,s,l,c)=>e.push({unitId:i,subUnitId:a,row:s,col:l,value:c}),getEffects:()=>e,clean:()=>{e=[]}}};let B=class extends o.Disposable{constructor(t,r,n,i,a){super();Z(this,"_collectEffectMutation",Ve());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=a,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(h.BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const i=r.row,a=r.col,s=this._numfmtService.getValue(r.unitId,r.subUnitId,i,a);if(s)switch(m.getPatternType(s.pattern)){case"scientific":case"currency":case"grouped":case"number":{const c=r.worksheet.getCellRaw(i,a);return n&&n(c)}case"percent":case"date":case"time":case"datetime":default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(h.AFTER_CELL_EDIT,{handler:(t,r,n)=>{var S,p,v,g;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),a=(S=i&&m.getPatternType(i.pattern))!=null?S:"",s=()=>{i&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(t!=null&&t.v)&&!(t!=null&&t.p)||W.isTextFormat(i==null?void 0:i.pattern)||t.t===o.CellValueType.FORCE_STRING)return n(t);const l=(p=t.p)==null?void 0:p.body,c=(g=(v=t==null?void 0:t.p)==null?void 0:v.body)!=null&&g.dataStream?t.p.body.dataStream.replace(/\r\n$/,""):String(t.v),d=o.numfmt.parseDate(c)||o.numfmt.parseTime(c)||o.numfmt.parseNumber(c);if(l)if(qe(l)){const{dataStream:_}=l,f=_.replace(/\r\n$/,""),E=Number(f);if(Number.isNaN(E)&&!d)return n(t)}else return n(t);if(d){d.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:d.z});const _=Number(d.v);return n({...t,p:void 0,v:_,t:o.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(a)||!Be(c))&&s();return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case h.SetRangeValuesCommand.id:{const i=t._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),a=i.getUnitId(),s=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!s)return{redos:[],undos:[]};const l=t._collectEffectMutation.getEffects();if(t._collectEffectMutation.clean(),!l.length)return{redos:[],undos:[]};const c=l.filter(v=>{var g;return!!((g=v.value)!=null&&g.pattern)}).map(v=>({row:v.row,col:v.col,pattern:v.value.pattern})),d=l.filter(v=>{var g;return!((g=v.value)!=null&&g.pattern)}).map(v=>({startRow:v.row,endColumn:v.col,startColumn:v.col,endRow:v.row})),S=[],p=[];if(c.length){const v={id:h.SetNumfmtMutation.id,params:h.transformCellsToRange(a,s,c)};S.push(v),p.push(...h.factorySetNumfmtUndoMutation(t._injector,v.params))}if(d.length){const v={id:h.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:s,ranges:d}};S.push(v),p.push(...h.factoryRemoveNumfmtUndoMutation(t._injector,v.params))}return{redos:S,undos:p.reverse()}}}return{redos:[],undos:[]}}}))}};B=We([A(0,o.Inject(h.SheetInterceptorService)),A(1,o.Inject(h.INumfmtService)),A(2,o.Inject(o.IUniverInstanceService)),A(3,o.Inject(o.Injector)),A(4,o.Optional(M.IEditorBridgeService))],B);function Be(e){return/^-?\d+(\.\d+)?$/.test(e)}function qe(e){const{textRuns:t=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=e,a=["va"];return!(t.some(s=>!!(s.ts&&Object.keys(s.ts).some(c=>a.includes(c))))||r.some(s=>s.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const q=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:W.DEFAULT_TEXT_FORMAT_EXCEL},"|",{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:""}],Ge=e=>({icon:new w.Observable(t=>{const r=e.get(m.MenuCurrencyService);function n(a){return{[m.countryCurrencyMap.US]:"DollarSingle",[m.countryCurrencyMap.RU]:"RoubleSingle",[m.countryCurrencyMap.CN]:"RmbSingle",[m.countryCurrencyMap.AT]:"EuroSingle"}[a]||"DollarSingle"}const i=m.countryCurrencyMap[r.getCurrencySymbol()]||"$";return t.next(n(i)),r.currencySymbol$.subscribe(a=>{const s=m.countryCurrencyMap[a]||"$";t.next(n(s))})}),id:m.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellStylePermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),Ke=e=>({icon:"AddDigitsSingle",id:m.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellStylePermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),Ze=e=>({icon:"ReduceDigitsSingle",id:m.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellStylePermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),ze=e=>({icon:"PercentSingle",id:m.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellStylePermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),Ye=e=>{const t=e.get(o.IUniverInstanceService),r=e.get(o.ICommandService),n=e.get(o.LocaleService),i=e.get(h.SheetsSelectionsService),a=M.deriveStateFromActiveSheet$(t,"",({workbook:s,worksheet:l})=>new w.Observable(c=>w.merge(i.selectionMoveEnd$,new w.Observable(d=>{const S=[h.RemoveNumfmtMutation.id,h.SetNumfmtMutation.id],p=r.onCommandExecuted(v=>{S.includes(v.id)&&d.next(null)});return()=>p.dispose()})).subscribe(()=>{var S,p;const d=i.getCurrentSelections();if(d&&d[0]){const v=d[0].range,g=v.startRow,_=v.startColumn,f=(p=s.getStyles().get((S=l.getCell(g,_))==null?void 0:S.s))==null?void 0:p.n,E=f==null?void 0:f.pattern;let I=n.t("sheet.numfmt.general");if(W.isDefaultFormat(E)){c.next(I);return}if(E){const O=q.filter(N=>typeof N=="object"&&N.pattern).find(N=>m.isPatternEqualWithoutDecimal(E,N.pattern));O&&typeof O=="object"&&O.pattern?I=n.t(O.label):I=n.t("sheet.numfmt.moreFmt")}c.next(I)}})));return{label:ue,id:$.id,tooltip:"sheet.numfmt.title",type:C.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:me,hoverable:!1,selectable:!1}}],value$:a,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetSetCellStylePermission,h.WorksheetEditPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}},ue="sheet.numfmt.moreNumfmtType",me="sheet.numfmt.moreNumfmtType.options",Xe=e=>{const{value:t}=e,r=C.useDependency(o.LocaleService),n=t!=null?t:r.t("sheet.numfmt.general");return u.jsx("span",{className:"univer-text-sm",children:n})},Je=()=>{const e=C.useDependency(o.ICommandService),t=C.useDependency(o.LocaleService),r=C.useDependency(C.ILayoutService),n=C.useDependency(m.SheetsNumfmtCellContentController),i=C.useDependency(h.SheetsSelectionsService),a=c=>{const d=i.getCurrentLastSelection();if(!d)return;const S=d.range,p=[];o.Range.foreach(S,(v,g)=>{c?p.push({row:v,col:g,pattern:c,type:m.getPatternType(c)}):p.push({row:v,col:g})}),e.executeCommand(m.SetNumfmtCommand.id,{values:p}),r.focus()},s=c=>{if(c===0)a(null);else if(c===q.length-1)e.executeCommand($.id),r.focus();else{const d=q[c];d.pattern&&a(d.pattern)}},l=1220;return u.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:q.map((c,d)=>c==="|"?u.jsx(P.Separator,{},d):u.jsxs("div",{className:`
1
+ (function(b,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/engine-formula"),require("@univerjs/engine-numfmt"),require("@univerjs/sheets"),require("rxjs"),require("rxjs/operators"),require("react/jsx-runtime"),require("react"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/engine-formula","@univerjs/engine-numfmt","@univerjs/sheets","rxjs","rxjs/operators","react/jsx-runtime","react","@univerjs/design"],o):(b=typeof globalThis<"u"?globalThis:b||self,o(b.UniverSheetsNumfmtUi={},b.UniverCore,b.UniverEngineRender,b.UniverSheetsNumfmt,b.UniverSheetsUi,b.UniverUi,b.UniverEngineFormula,b.UniverEngineNumfmt,b.UniverSheets,b.rxjs,b.rxjs.operators,b.React,b.React,b.UniverDesign))})(this,function(b,o,F,m,M,C,ve,V,S,N,B,u,y,P){"use strict";var lt=Object.defineProperty;var ut=(b,o,F)=>o in b?lt(b,o,{enumerable:!0,configurable:!0,writable:!0,value:F}):b[o]=F;var Z=(b,o,F)=>ut(b,typeof o!="symbol"?o+"":o,F);const ie={};var fe=Object.getOwnPropertyDescriptor,he=(e,t,r,n)=>{for(var i=n>1?void 0:n?fe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},j=(e,t)=>(r,n)=>t(r,n,e);const z="SHEET_NUMFMT_ALERT";let Y=class extends o.Disposable{constructor(e,t,r,n,i,a,s){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=r,this._localeService=n,this._formulaDataModel=i,this._zenZoneService=a,this._numfmtService=s,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(N.debounceTime(100)).subscribe(e=>{var t;if(e){const r=e.location,n=this._context.unit,i=n.getActiveSheet();if(!i)return;const a=r.unitId,s=r.subUnitId;let l;const c=i.getCell(r.row,r.col);if(c!=null&&c.s){const d=n.getStyles().get(c.s);d!=null&&d.n&&(l=d.n)}if(l||(l=this._numfmtService.getValue(a,s,r.row,r.col)),!l){this._hideAlert();return}if(V.isTextFormat(l.pattern)&&(c!=null&&c.v)&&o.isRealNum(c.v)){const d=this._cellAlertManagerService.currentAlert.get(z),f=(t=d==null?void 0:d.alert)==null?void 0:t.location;if(f&&f.row===r.row&&f.col===r.col&&f.subUnitId===r.subUnitId&&f.unitId===r.unitId)return;this._cellAlertManagerService.showAlert({type:M.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:r,width:200,height:74,key:z});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(z)}};Y=he([j(1,o.Inject(M.HoverManagerService)),j(2,o.Inject(M.CellAlertManagerService)),j(3,o.Inject(o.LocaleService)),j(4,o.Inject(ve.FormulaDataModel)),j(5,C.IZenZoneService),j(6,o.Inject(S.INumfmtService))],Y);const X={id:"sheet.operation.close.numfmt.panel",type:o.CommandType.OPERATION,handler:()=>!0},H={id:"sheet.operation.open.numfmt.panel",type:o.CommandType.OPERATION,handler:e=>(e.get(A).openPanel(),!0)};var Se=Object.getOwnPropertyDescriptor,ge=(e,t,r,n)=>{for(var i=n>1?void 0:n?Se(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},ye=(e,t)=>(r,n)=>t(r,n,e);const J=y.createContext([]);let x=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const r=this._getKey(e);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,t)})}markHabit(e,t){const r=this._getKey(e);this._localStorageService.getItem(r).then(n=>{if(n){const i=n.findIndex(a=>a===t);i>-1&&n.splice(i,1),n.unshift(t),this._localStorageService.setItem(r,n)}})}async getHabit(e,t){const r=this._getKey(e),n=await this._localStorageService.getItem(r);if(t&&n){const i=n.map((a,s,l)=>{const c=l.length;return{value:a,priority:c-s}});return t.sort((a,s)=>{var d,f;const l=((d=i.find(p=>p.value===a))==null?void 0:d.priority)||-1;return(((f=i.find(p=>p.value===s))==null?void 0:f.priority)||-1)-l})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};x=ge([ye(0,o.Inject(o.ILocalStorageService))],x);const ae="numfmtCurrency",_e=e=>{const t=C.useDependency(x),[r,n]=y.useState(m.currencySymbols);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(ae,[...m.currencySymbols]).then(a=>{n(a),e&&e(a)})})},[]),{userHabitCurrency:r,mark:a=>{t.markHabit(ae,a)}}},Ce=()=>{const e=y.useRef([]),[t,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[t]),i=>{e.current.push(i),r({})}},be=e=>!!m.getCurrencyType(e)&&e.startsWith("_("),Ie=e=>{const{defaultPattern:t,action:r,onChange:n}=e,[i,a]=y.useState(()=>m.getDecimalFromPattern(t||"",2)),s=y.useContext(J),[l,c]=y.useState(()=>m.getCurrencyType(t)||s[0]),d=y.useMemo(()=>s.map(_=>({label:_,value:_})),[]),p=C.useDependency(o.LocaleService).t;r.current=()=>m.setPatternDecimal(`_("${l}"* #,##0${i>0?".0":""}_)`,i);const v=_=>{c(_),n(m.setPatternDecimal(`_("${_}"* #,##0${i>0?".0":""}_)`,i))},g=_=>{const h=_||0;a(h),n(m.setPatternDecimal(`_("${l}"* #,##0${h>0?".0":""}_)`,h))};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:p("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8 w-120",children:u.jsx(P.InputNumber,{value:i,max:20,min:0,onChange:g})})]}),u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:p("sheet.numfmt.currencyType")}),u.jsx("div",{className:"m-t-8 w-140",children:u.jsx(P.Select,{onChange:v,options:d,value:l})})]})]}),u.jsx("div",{className:"describe m-t-14",children:p("sheet.numfmt.accountingDes")})]})},Te=e=>!!m.getCurrencyType(e)&&!e.startsWith("_("),Ee=e=>{const r=C.useDependency(o.LocaleService).t,n=y.useContext(J),[i,a]=y.useState(()=>m.getCurrencyType(e.defaultPattern)||n[0]),[s,l]=y.useState(()=>m.getDecimalFromPattern(e.defaultPattern||"",2)),[c,d]=y.useState(()=>{var I;const h=m.getCurrencyFormatOptions(i);return((I=h.find(U=>m.isPatternEqualWithoutDecimal(U.value,e.defaultPattern)))==null?void 0:I.value)||h[0].value}),f=y.useMemo(()=>m.getCurrencyFormatOptions(i),[i]),p=y.useMemo(()=>n.map(h=>({label:h,value:h})),[n]);e.action.current=()=>m.setPatternDecimal(c,s);const v=h=>{if(h===void 0)return;a(h);const E=m.getCurrencyFormatOptions(h)[0].value;d(E),e.onChange(m.setPatternDecimal(E,s))},g=h=>{h!==void 0&&(d(h),e.onChange(m.setPatternDecimal(h,s)))},_=h=>{l(h||0),e.onChange(m.setPatternDecimal(c,h||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:r("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8 w-120",children:u.jsx(P.InputNumber,{value:s,max:20,min:0,onChange:_})})]}),u.jsxs("div",{className:"option",children:[u.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),u.jsx("div",{className:"m-t-8 w-140",children:u.jsx(P.Select,{onChange:v,options:p,value:i})})]})]}),u.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.SelectList,{onChange:g,options:f,value:c})}),u.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})};var D=function(){return D=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},D.apply(this,arguments)},Pe=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},oe=y.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,a=e.extend,s=Pe(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=y.useRef("_".concat(Ue()));return se(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},D({ref:t,className:l},s),a)});function se(e,t,r,n,i){return y.createElement(e.tag,D(D({key:t},Me(e,r,i)),n),(De(e,r).children||[]).map(function(a,s){return se(a,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function Me(e,t,r){var n=D({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(a){var s=a[0],l=a[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function De(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?D(D({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?D(D({},i),{attrs:D(D({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function Ue(){return Math.random().toString(36).substring(2,8)}oe.displayName="UniverIcon";var Oe={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"}}]},ce=y.forwardRef(function(e,t){return y.createElement(oe,Object.assign({},e,{id:"check-mark-single",ref:t,icon:Oe}))});ce.displayName="CheckMarkSingle";const L={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"},Q="customFormat",ee="numfmt_custom_pattern";function Ne(e){const{defaultPattern:t,action:r,onChange:n}=e,i=C.useDependency(x),a=C.useDependency(o.ILocalStorageService),s=C.useDependency(o.LocaleService),[l,c]=y.useState(t);r.current=()=>(i.markHabit(Q,l),a.getItem(ee).then((g=[])=>{const _=[...new Set([l,...g||[]])].splice(0,10).filter(h=>!!h);a.setItem(ee,_)}),l);const[d,f]=y.useState([]);y.useEffect(()=>{a.getItem(ee).then(g=>{const _=[...m.CURRENCYFORMAT.map(h=>h.suffix("$")),...m.DATEFMTLISG.map(h=>h.suffix),...m.NUMBERFORMAT.map(h=>h.suffix)];_.push(...g||[]),i.addHabit(Q,[]).finally(()=>{i.getHabit(Q,_).then(h=>{f([...new Set(h)])})})})},[]);const p=g=>{c(g),n(g)},v=()=>{n(l)};return u.jsxs("div",{className:L.customFormat,children:[u.jsx("div",{className:L.customFormatTitle,children:s.t("sheet.numfmt.customFormat")}),u.jsx(P.Input,{placeholder:s.t("sheet.numfmt.customFormat"),onBlur:v,value:l,onChange:c,className:L.customFormatInput}),u.jsx("div",{className:L.customFormatHistoryList,children:d.map(g=>u.jsxs("div",{onClick:()=>p(g),className:L.customFormatHistoryListItem,children:[u.jsx("div",{className:L.customFormatHistoryListItemIconWrap,children:l===g&&u.jsx(ce,{})}),u.jsx("div",{children:g})]},g))}),u.jsx("div",{className:L.customFormatDes,children:s.t("sheet.numfmt.customFormatDes")})]})}const we=e=>{const t=o.numfmt.getInfo(e);return m.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)},ke=e=>{const t=y.useMemo(m.getDateFormatOptions,[]),n=C.useDependency(o.LocaleService).t,[i,a]=y.useState(()=>{if(e.defaultPattern){const l=t.find(c=>c.value===e.defaultPattern);if(l)return l.value}return t[0].value});e.action.current=()=>i;const s=l=>{l!==void 0&&(a(l),e.onChange(l))};return u.jsxs("div",{children:[u.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.dateType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.SelectList,{value:i,options:t,onChange:s})}),u.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},Fe=e=>!e,Le=e=>{const r=C.useDependency(o.LocaleService).t;return e.action.current=()=>"",u.jsx("div",{children:u.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},je=e=>m.getNumberFormatOptions().some(t=>m.isPatternEqualWithoutDecimal(t.value,e)),$e=e=>{const t=C.useDependency(o.LocaleService),r=y.useMemo(m.getNumberFormatOptions,[]),[n,i]=y.useState(()=>m.getDecimalFromPattern(e.defaultPattern||"",0)),[a,s]=y.useState(()=>{const p=r.find(v=>m.isPatternEqualWithoutDecimal(v.value,e.defaultPattern||""));return(p==null?void 0:p.value)||r[0].value}),l=y.useMemo(()=>m.setPatternDecimal(a,Number(n||0)),[a,n]),c=y.useMemo(()=>!m.isPatternHasDecimal(a),[a]),d=p=>{i(p||0),e.onChange(m.setPatternDecimal(a,Number(p||0)))},f=p=>{p!==void 0&&(i(m.getDecimalFromPattern(p,0)),s(p),e.onChange(p))};return e.action.current=()=>l,u.jsxs("div",{children:[u.jsx("div",{className:"m-t-16 label",children:t.t("sheet.numfmt.decimalLength")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.InputNumber,{disabled:c,value:n,max:20,min:0,onChange:d})}),u.jsxs("div",{className:"m-t-16 label",children:[" ",t.t("sheet.numfmt.negType")]}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.SelectList,{onChange:f,options:r,value:a})}),u.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},He=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:i}=e.value,a=C.useDependency(o.LocaleService),s=y.useRef(()=>""),l=a.t,c=Ce(),d=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Le},{label:"sheet.numfmt.accounting",component:Ie},{label:"sheet.numfmt.currency",component:Ee},{label:"sheet.numfmt.date",component:ke},{label:"sheet.numfmt.thousandthPercentile",component:$e},{label:"sheet.numfmt.customFormat",component:Ne}].map(T=>({...T,label:l(T.label)})),[]),[f,p]=y.useState(I),[v,g]=y.useState(()=>`${n}_${i}`),{mark:_,userHabitCurrency:h}=_e(()=>g(`${n}_${i}_userCurrency'`)),E=y.useMemo(()=>{var T;return(T=d.find($=>$.label===f))==null?void 0:T.component},[f]);function I(){return[Fe,be,Te,we,je].reduce(($,st,ct)=>$||(st(r)?d[ct].label:""),"")||d[0].label}const U=d.map(T=>({label:T.label,value:T.label})),w=T=>{p(T),c(()=>e.onChange({type:"change",value:s.current()||""}))},k=T=>{e.onChange({type:"change",value:T})},ne=()=>{const T=s.current()||"",$=m.getCurrencyType(T);$&&_($),e.onChange({type:"confirm",value:T})},W=()=>{e.onChange({type:"cancel",value:""})},re={onChange:k,defaultValue:t,defaultPattern:r,action:s};return y.useEffect(()=>{p(I()),g(`${n}_${i}`)},[n,i]),u.jsxs("div",{className:"numfmt-panel p-b-20",children:[u.jsxs("div",{children:[u.jsx("div",{className:"label m-t-14",children:l("sheet.numfmt.numfmtType")}),u.jsx("div",{className:"m-t-8",children:u.jsx(P.Select,{onChange:w,options:U,value:f,style:{width:"100%"}})}),u.jsx("div",{children:E&&u.jsx(J.Provider,{value:h,children:y.createElement(E,{...re,key:v})})})]}),u.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[u.jsx(P.Button,{size:"small",onClick:W,className:"m-r-12",children:l("sheet.numfmt.cancel")}),u.jsx(P.Button,{type:"primary",size:"small",onClick:ne,children:l("sheet.numfmt.confirm")})]})]})};var xe=Object.getOwnPropertyDescriptor,Ae=(e,t,r,n)=>{for(var i=n>1?void 0:n?xe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},O=(e,t)=>(r,n)=>t(r,n,e);const le="SHEET_NUMFMT_PANEL";let A=class extends o.Disposable{constructor(t,r,n,i,a,s,l,c,d,f,p){super();Z(this,"_previewPattern","");Z(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=a,this._renderManagerService=s,this._numfmtService=l,this._componentManager=c,this._sidebarService=d,this._localeService=f,this._sheetsNumfmtCellContentController=p,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(N.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var E;const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,a=this._numfmtService,s=this._localeService,c=(((E=r.getCurrentSelections())==null?void 0:E.map(I=>I.range))||[])[0];if(!c)return!1;const d=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),f=d.getActiveSheet();if(!f)return!1;const p=f.getCellRaw(c.startRow,c.startColumn),v=a.getValue(d.getUnitId(),f.getSheetId(),c.startRow,c.startColumn);let g="";v&&(g=v.pattern);const _=(p==null?void 0:p.t)===o.CellValueType.NUMBER?p.v:12345678,h={onChange:I=>{var U;if(I.type==="change")this._previewPattern=I.value,this._forceUpdate();else if(I.type==="confirm"){const w=((U=r.getCurrentSelections())==null?void 0:U.map(W=>W.range))||[],k={values:[]},ne=m.getPatternType(I.value);w.forEach(W=>{o.Range.foreach(W,(re,T)=>{k.values.push({row:re,col:T,pattern:I.value,type:ne})})}),n.executeCommand(m.SetNumfmtCommand.id,k),t.close()}else I.type==="cancel"&&t.close()},value:{defaultPattern:g,defaultValue:_,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=t.open({header:{title:s.t("sheet.numfmt.title")},children:{label:le,...h},onClose:()=>{this._forceUpdate(),n.executeCommand(X.id)}}),!0}_forceUpdate(t){var n;const r=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(M.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[H,X].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(le,He)}_initRealTimeRenderingInterceptor(){const t=new N.Observable(n=>{this._commandService.onCommandExecuted(i=>{i.id===H.id&&n.next(!0),i.id===X.id&&n.next(!1)})}),r=N.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(B.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(o.toDisposable(r.pipe(B.switchMap(([n,i])=>new N.Observable(a=>{const s=new o.DisposableCollection;return n&&i.length&&a.next({selectionRanges:i,disposableCollection:s}),()=>{s.dispose()}})),B.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var s,l;const a=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:o.InterceptorEffectEnum.Value|o.InterceptorEffectEnum.Style,handler:(c,d,f)=>{const{row:p,col:v}=d,g=f(c)||{};if(i.find(_=>_.startColumn<=v&&_.endColumn>=v&&_.startRow<=p&&_.endRow>=p)){const _=d.worksheet.getCellRaw(p,v),h=_==null?void 0:_.v,E=_==null?void 0:_.t;if(h==null||E!==o.CellValueType.NUMBER||this._previewPattern===null)return g;const I=m.getPatternPreviewIgnoreGeneral(this._previewPattern,h,this._sheetsNumfmtCellContentController.local);if(I.color){const w=this._themeService.getCurrentTheme()[`${I.color}500`];return{...g,v:I.result,t:o.CellValueType.STRING,s:{cl:{rgb:w}}}}return{...g,v:I.result,t:o.CellValueType.STRING}}return g}})),(l=(s=this._renderManagerService.getRenderById(a.getUnitId()))==null?void 0:s.mainComponent)==null||l.makeDirty()})))}_commandExecutedListener(){const t=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id];this.disposeWithMe(new N.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(t.includes(i.id)){const a=i.params;r.next(a.unitId)}});return()=>n.dispose()}).pipe(B.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};A=Ae([O(0,o.Inject(S.SheetInterceptorService)),O(1,o.Inject(o.ThemeService)),O(2,o.IUniverInstanceService),O(3,o.ICommandService),O(4,o.Inject(S.SheetsSelectionsService)),O(5,F.IRenderManagerService),O(6,S.INumfmtService),O(7,o.Inject(C.ComponentManager)),O(8,C.ISidebarService),O(9,o.Inject(o.LocaleService)),O(10,o.Inject(m.SheetsNumfmtCellContentController))],A);var Re=Object.getOwnPropertyDescriptor,We=(e,t,r,n)=>{for(var i=n>1?void 0:n?Re(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},R=(e,t)=>(r,n)=>t(r,n,e);const Ve=()=>{let e=[];return{add:(i,a,s,l,c)=>e.push({unitId:i,subUnitId:a,row:s,col:l,value:c}),getEffects:()=>e,clean:()=>{e=[]}}};let q=class extends o.Disposable{constructor(t,r,n,i,a){super();Z(this,"_collectEffectMutation",Ve());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=a,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const i=r.row,a=r.col,s=this._numfmtService.getValue(r.unitId,r.subUnitId,i,a);if(s)switch(m.getPatternType(s.pattern)){case"scientific":case"currency":case"grouped":case"number":{const c=r.worksheet.getCellRaw(i,a);return n&&n(c)}case"percent":case"date":case"time":case"datetime":default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.AFTER_CELL_EDIT,{handler:(t,r,n)=>{var f,p,v,g;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),a=(f=i&&m.getPatternType(i.pattern))!=null?f:"",s=()=>{i&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(t!=null&&t.v)&&!(t!=null&&t.p)||V.isTextFormat(i==null?void 0:i.pattern)||t.t===o.CellValueType.FORCE_STRING)return n(t);const l=(p=t.p)==null?void 0:p.body,c=(g=(v=t==null?void 0:t.p)==null?void 0:v.body)!=null&&g.dataStream?t.p.body.dataStream.replace(/\r\n$/,""):String(t.v),d=o.numfmt.parseDate(c)||o.numfmt.parseTime(c)||o.numfmt.parseNumber(c);if(l)if(qe(l)){const{dataStream:_}=l,h=_.replace(/\r\n$/,""),E=Number(h);if(Number.isNaN(E)&&!d)return n(t)}else return n(t);if(d){d.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:d.z});const _=Number(d.v);return n({...t,p:void 0,v:_,t:o.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(a)||!Be(c))&&s();return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case S.SetRangeValuesCommand.id:{const i=t._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),a=i.getUnitId(),s=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!s)return{redos:[],undos:[]};const l=t._collectEffectMutation.getEffects();if(t._collectEffectMutation.clean(),!l.length)return{redos:[],undos:[]};const c=l.filter(v=>{var g;return!!((g=v.value)!=null&&g.pattern)}).map(v=>({row:v.row,col:v.col,pattern:v.value.pattern})),d=l.filter(v=>{var g;return!((g=v.value)!=null&&g.pattern)}).map(v=>({startRow:v.row,endColumn:v.col,startColumn:v.col,endRow:v.row})),f=[],p=[];if(c.length){const v={id:S.SetNumfmtMutation.id,params:S.transformCellsToRange(a,s,c)};f.push(v),p.push(...S.factorySetNumfmtUndoMutation(t._injector,v.params))}if(d.length){const v={id:S.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:s,ranges:d}};f.push(v),p.push(...S.factoryRemoveNumfmtUndoMutation(t._injector,v.params))}return{redos:f,undos:p.reverse()}}}return{redos:[],undos:[]}}}))}};q=We([R(0,o.Inject(S.SheetInterceptorService)),R(1,o.Inject(S.INumfmtService)),R(2,o.Inject(o.IUniverInstanceService)),R(3,o.Inject(o.Injector)),R(4,o.Optional(M.IEditorBridgeService))],q);function Be(e){return/^-?\d+(\.\d+)?$/.test(e)}function qe(e){const{textRuns:t=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=e,a=["va"];return!(t.some(s=>!!(s.ts&&Object.keys(s.ts).some(c=>a.includes(c))))||r.some(s=>s.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const G=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:V.DEFAULT_TEXT_FORMAT_EXCEL},"|",{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.percent",pattern:"0.00%"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Ge=e=>({icon:new N.Observable(t=>{const r=e.get(m.MenuCurrencyService);function n(a){return{[m.countryCurrencyMap.US]:"DollarSingle",[m.countryCurrencyMap.RU]:"RoubleSingle",[m.countryCurrencyMap.CN]:"RmbSingle",[m.countryCurrencyMap.AT]:"EuroSingle"}[a]||"DollarSingle"}const i=m.countryCurrencyMap[r.getCurrencySymbol()]||"$";return t.next(n(i)),r.currencySymbol$.subscribe(a=>{const s=m.countryCurrencyMap[a]||"$";t.next(n(s))})}),id:m.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Ke=e=>({icon:"AddDigitsSingle",id:m.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Ze=e=>({icon:"ReduceDigitsSingle",id:m.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),ze=e=>({icon:"PercentSingle",id:m.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Ye=e=>{const t=e.get(o.IUniverInstanceService),r=e.get(o.ICommandService),n=e.get(o.LocaleService),i=e.get(S.SheetsSelectionsService),a=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id],s=M.deriveStateFromActiveSheet$(t,"",({workbook:l,worksheet:c})=>new N.Observable(d=>N.merge(i.selectionMoveEnd$,o.fromCallback(r.onCommandExecuted.bind(r)).pipe(N.filter(([f])=>a.includes(f.id)))).subscribe(()=>{var p,v;const f=i.getCurrentSelections();if(f&&f[0]){const g=f[0].range,_=g.startRow,h=g.startColumn,E=(v=l.getStyles().get((p=c.getCell(_,h))==null?void 0:p.s))==null?void 0:v.n,I=E==null?void 0:E.pattern;let U=n.t("sheet.numfmt.general");if(V.isDefaultFormat(I)){d.next(U);return}if(I){const w=G.filter(k=>typeof k=="object"&&k.pattern).find(k=>m.isPatternEqualWithoutDecimal(I,k.pattern));w&&typeof w=="object"&&w.pattern?U=n.t(w.label):U=n.t("sheet.numfmt.moreFmt")}d.next(U)}})));return{label:ue,id:H.id,tooltip:"sheet.numfmt.title",type:C.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:me,hoverable:!1,selectable:!1}}],value$:s,hidden$:C.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(e,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetSetCellStylePermission,S.WorksheetEditPermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}},ue="sheet.numfmt.moreNumfmtType",me="sheet.numfmt.moreNumfmtType.options",Xe=e=>{const{value:t}=e,r=C.useDependency(o.LocaleService),n=t!=null?t:r.t("sheet.numfmt.general");return u.jsx("span",{className:"univer-text-sm",children:n})},Je=()=>{const e=C.useDependency(o.ICommandService),t=C.useDependency(o.LocaleService),r=C.useDependency(C.ILayoutService),n=C.useDependency(m.SheetsNumfmtCellContentController),i=C.useDependency(S.SheetsSelectionsService),a=c=>{const d=i.getCurrentLastSelection();if(!d)return;const f=d.range,p=[];o.Range.foreach(f,(v,g)=>{c?p.push({row:v,col:g,pattern:c,type:m.getPatternType(c)}):p.push({row:v,col:g})}),e.executeCommand(m.SetNumfmtCommand.id,{values:p}),r.focus()},s=c=>{if(c===0)a(null);else if(c===G.length-1)e.executeCommand(H.id),r.focus();else{const d=G[c];d.pattern&&a(d.pattern)}},l=1220;return u.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:G.map((c,d)=>c==="|"?u.jsx(P.Separator,{},d):u.jsxs("div",{className:`
2
2
  univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded
3
3
  univer-px-2 univer-text-[13px]
4
4
  hover:univer-bg-gray-100
5
- `,onClick:()=>{s(d)},children:[u.jsx("span",{children:t.t(c.label)}),u.jsx("span",{className:"univer-text-xs univer-text-gray-500",children:c.pattern?m.getPatternPreview(c.pattern||"",l,n.local).result.trim():""})]},d))})},Qe={[C.RibbonStartGroup.FORMULAS_INSERT]:{[m.SetCurrencyCommand.id]:{order:4,menuItemFactory:Ge},[m.AddDecimalCommand.id]:{order:5,menuItemFactory:Ke},[m.SubtractDecimalCommand.id]:{order:6,menuItemFactory:Ze},[m.SetPercentCommand.id]:{order:7,menuItemFactory:ze},[$.id]:{order:8,menuItemFactory:Ye}}};var et=Object.getOwnPropertyDescriptor,tt=(e,t,r,n)=>{for(var i=n>1?void 0:n?et(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},de=(e,t)=>(r,n)=>t(r,n,e);let G=class extends o.Disposable{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Qe),this.disposeWithMe(this._componentManager.register(ue,Xe)),this.disposeWithMe(this._componentManager.register(me,Je))}};G=tt([de(0,o.Inject(C.ComponentManager)),de(1,C.IMenuManagerService)],G);var nt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,it=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,at=(e,t,r,n)=>{for(var i=n>1?void 0:n?rt(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},te=(e,t)=>(r,n)=>t(r,n,e),pe=(e,t,r)=>it(e,typeof t!="symbol"?t+"":t,r);const ot="SHEET_NUMFMT_UI_PLUGIN";b.UniverSheetsNumfmtUIPlugin=class extends o.Plugin{constructor(t=ie,r,n,i){super(),this._config=t,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:a,...s}=o.merge({},ie,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(C.UI_PLUGIN_CONFIG_KEY,s)}onStarting(){o.registerDependencies(this._injector,[[x],[B],[H],[G]])}onRendered(){this._registerRenderModules(),o.touchDependencies(this._injector,[[x],[B],[G]])}_registerRenderModules(){[[Y]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,r))})}},pe(b.UniverSheetsNumfmtUIPlugin,"pluginName",ot),pe(b.UniverSheetsNumfmtUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),b.UniverSheetsNumfmtUIPlugin=at([o.DependentOn(M.UniverSheetsUIPlugin,m.UniverSheetsNumfmtPlugin),te(1,o.Inject(o.Injector)),te(2,o.IConfigService),te(3,k.IRenderManagerService)],b.UniverSheetsNumfmtUIPlugin),Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
5
+ `,onClick:()=>{s(d)},children:[u.jsx("span",{children:t.t(c.label)}),u.jsx("span",{className:"univer-text-xs univer-text-gray-500",children:c.pattern?m.getPatternPreview(c.pattern||"",l,n.local).result.trim():""})]},d))})},Qe={[C.RibbonStartGroup.FORMULAS_INSERT]:{[m.SetCurrencyCommand.id]:{order:4,menuItemFactory:Ge},[m.AddDecimalCommand.id]:{order:5,menuItemFactory:Ke},[m.SubtractDecimalCommand.id]:{order:6,menuItemFactory:Ze},[m.SetPercentCommand.id]:{order:7,menuItemFactory:ze},[H.id]:{order:8,menuItemFactory:Ye}}};var et=Object.getOwnPropertyDescriptor,tt=(e,t,r,n)=>{for(var i=n>1?void 0:n?et(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},de=(e,t)=>(r,n)=>t(r,n,e);let K=class extends o.Disposable{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Qe),this.disposeWithMe(this._componentManager.register(ue,Xe)),this.disposeWithMe(this._componentManager.register(me,Je))}};K=tt([de(0,o.Inject(C.ComponentManager)),de(1,C.IMenuManagerService)],K);var nt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,it=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,at=(e,t,r,n)=>{for(var i=n>1?void 0:n?rt(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=s(i)||i);return i},te=(e,t)=>(r,n)=>t(r,n,e),pe=(e,t,r)=>it(e,typeof t!="symbol"?t+"":t,r);const ot="SHEET_NUMFMT_UI_PLUGIN";b.UniverSheetsNumfmtUIPlugin=class extends o.Plugin{constructor(t=ie,r,n,i){super(),this._config=t,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:a,...s}=o.merge({},ie,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(C.UI_PLUGIN_CONFIG_KEY,s)}onStarting(){o.registerDependencies(this._injector,[[A],[q],[x],[K]])}onRendered(){this._registerRenderModules(),o.touchDependencies(this._injector,[[A],[q],[K]])}_registerRenderModules(){[[Y]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,r))})}},pe(b.UniverSheetsNumfmtUIPlugin,"pluginName",ot),pe(b.UniverSheetsNumfmtUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),b.UniverSheetsNumfmtUIPlugin=at([o.DependentOn(M.UniverSheetsUIPlugin,m.UniverSheetsNumfmtPlugin),te(1,o.Inject(o.Injector)),te(2,o.IConfigService),te(3,F.IRenderManagerService)],b.UniverSheetsNumfmtUIPlugin),Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt-ui",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "private": false,
5
5
  "description": "UniverSheet numfmt plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,15 +55,15 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@univerjs/icons": "^0.2.20",
58
- "@univerjs/core": "0.6.3",
59
- "@univerjs/design": "0.6.3",
60
- "@univerjs/engine-formula": "0.6.3",
61
- "@univerjs/engine-numfmt": "0.6.3",
62
- "@univerjs/engine-render": "0.6.3",
63
- "@univerjs/sheets": "0.6.3",
64
- "@univerjs/sheets-numfmt": "0.6.3",
65
- "@univerjs/sheets-ui": "0.6.3",
66
- "@univerjs/ui": "0.6.3"
58
+ "@univerjs/core": "0.6.4",
59
+ "@univerjs/design": "0.6.4",
60
+ "@univerjs/engine-numfmt": "0.6.4",
61
+ "@univerjs/engine-formula": "0.6.4",
62
+ "@univerjs/engine-render": "0.6.4",
63
+ "@univerjs/sheets-numfmt": "0.6.4",
64
+ "@univerjs/sheets": "0.6.4",
65
+ "@univerjs/sheets-ui": "0.6.4",
66
+ "@univerjs/ui": "0.6.4"
67
67
  },
68
68
  "devDependencies": {
69
69
  "less": "^4.2.2",
@@ -74,7 +74,7 @@
74
74
  "typescript": "^5.8.2",
75
75
  "vite": "^6.2.0",
76
76
  "vitest": "^3.0.7",
77
- "@univerjs-infra/shared": "0.6.3"
77
+ "@univerjs-infra/shared": "0.6.4"
78
78
  },
79
79
  "scripts": {
80
80
  "test": "vitest run",