@univerjs/sheets-numfmt-ui 0.6.0-alpha.0 → 0.6.0-experimental.20250212-dbe9830

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var ve=Object.defineProperty;var Se=(t,e,n)=>e in t?ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var A=(t,e,n)=>Se(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@univerjs/core"),oe=require("@univerjs/engine-render"),m=require("@univerjs/sheets-numfmt"),M=require("@univerjs/sheets-ui"),I=require("@univerjs/ui"),ge=require("@univerjs/engine-formula"),ee=require("@univerjs/engine-numfmt"),S=require("@univerjs/sheets"),R=require("rxjs"),W=require("rxjs/operators"),l=require("react/jsx-runtime"),_=require("react"),E=require("@univerjs/design"),ne={};var _e=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,be=(t,e,n,r)=>{for(var s=r>1?void 0:r?ye(e,n):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&_e(e,n,s),s},U=(t,e)=>(n,r)=>e(n,r,t);const Z="SHEET_NUMFMT_ALERT";let Q=class extends i.Disposable{constructor(t,e,n,r,s,o,c){super(),this._context=t,this._hoverManagerService=e,this._cellAlertManagerService=n,this._localeService=r,this._formulaDataModel=s,this._zenZoneService=o,this._numfmtService=c,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(R.debounceTime(100)).subscribe(t=>{var e;if(t){const n=t.location,r=this._context.unit,s=r.getActiveSheet();if(!s)return;const o=n.unitId,c=n.subUnitId;let u;const a=s.getCell(n.row,n.col);if(a!=null&&a.s){const d=r.getStyles().get(a.s);d!=null&&d.n&&(u=d.n)}if(u||(u=this._numfmtService.getValue(o,c,n.row,n.col)),!u){this._hideAlert();return}if(u.pattern===ee.DEFAULT_TEXT_FORMAT&&(a!=null&&a.v)&&i.isRealNum(a.v)){const d=this._cellAlertManagerService.currentAlert.get(Z),v=(e=d==null?void 0:d.alert)==null?void 0:e.location;if(v&&v.row===n.row&&v.col===n.col&&v.subUnitId===n.subUnitId&&v.unitId===n.unitId)return;this._cellAlertManagerService.showAlert({type:M.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n,width:200,height:74,key:Z});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(Z)}};Q=be([U(1,i.Inject(M.HoverManagerService)),U(2,i.Inject(M.CellAlertManagerService)),U(3,i.Inject(i.LocaleService)),U(4,i.Inject(ge.FormulaDataModel)),U(5,I.IZenZoneService),U(6,i.Inject(S.INumfmtService))],Q);const z={id:"sheet.operation.close.numfmt.panel",type:i.CommandType.OPERATION,handler:()=>!0},$={id:"sheet.operation.open.numfmt.panel",type:i.CommandType.OPERATION,handler:t=>(t.get(k).openPanel(),!0)};var Ce=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Pe=(t,e,n,r)=>{for(var s=r>1?void 0:r?Ie(e,n):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&Ce(e,n,s),s},Te=(t,e)=>(n,r)=>e(n,r,t);const te=_.createContext([]);let L=class{constructor(t){this._localStorageService=t}_getKey(t){return`userHabitController_${t}`}async addHabit(t,e){const n=this._getKey(t);return this._localStorageService.getItem(n).then(r=>{r||this._localStorageService.setItem(n,e)})}markHabit(t,e){const n=this._getKey(t);this._localStorageService.getItem(n).then(r=>{if(r){const s=r.findIndex(o=>o===e);s>-1&&r.splice(s,1),r.unshift(e),this._localStorageService.setItem(n,r)}})}async getHabit(t,e){const n=this._getKey(t),r=await this._localStorageService.getItem(n);if(e&&r){const s=r.map((o,c,u)=>{const a=u.length;return{value:o,priority:a-c}});return e.sort((o,c)=>{var d,v;const u=((d=s.find(h=>h.value===o))==null?void 0:d.priority)||-1;return(((v=s.find(h=>h.value===c))==null?void 0:v.priority)||-1)-u})}return r||[]}deleteHabit(t){this._localStorageService.removeItem(t)}};L=Pe([Te(0,i.Inject(i.ILocalStorageService))],L);const re="numfmtCurrency",Ne=t=>{const e=i.useDependency(L),[n,r]=_.useState(m.currencySymbols);return _.useEffect(()=>{e.addHabit("numfmtCurrency",[]).then(()=>{e.getHabit(re,[...m.currencySymbols]).then(o=>{r(o),t(o)})})},[]),{userHabitCurrency:n,mark:o=>{e.markHabit(re,o)}}},Ee=()=>{const t=_.useRef([]),[e,n]=_.useState({});return _.useEffect(()=>{t.current.forEach(s=>{s()}),t.current=[]},[e]),s=>{t.current.push(s),n({})}},Me=t=>!!m.getCurrencyType(t)&&t.startsWith("_("),je=t=>{const{defaultPattern:e,action:n,onChange:r}=t,[s,o]=_.useState(()=>m.getDecimalFromPattern(e||"",2)),c=_.useContext(te),[u,a]=_.useState(()=>m.getCurrencyType(e)||c[0]),d=_.useMemo(()=>c.map(y=>({label:y,value:y})),[]),h=i.useDependency(i.LocaleService).t;n.current=()=>m.setPatternDecimal(`_("${u}"* #,##0${s>0?".0":""}_)`,s);const f=y=>{a(y),r(m.setPatternDecimal(`_("${y}"* #,##0${s>0?".0":""}_)`,s))},g=y=>{const p=y||0;o(p),r(m.setPatternDecimal(`_("${u}"* #,##0${p>0?".0":""}_)`,p))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:h("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(E.InputNumber,{value:s,max:20,min:0,onChange:g})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:h("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(E.Select,{onChange:f,options:d,value:u})})]})]}),l.jsx("div",{className:"describe m-t-14",children:h("sheet.numfmt.accountingDes")})]})},De=t=>!!m.getCurrencyType(t)&&!t.startsWith("_("),Re=t=>{const n=i.useDependency(i.LocaleService).t,r=_.useContext(te),[s,o]=_.useState(()=>m.getCurrencyType(t.defaultPattern)||r[0]),[c,u]=_.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",2)),[a,d]=_.useState(()=>{var b;const p=m.getCurrencyFormatOptions(s);return((b=p.find(T=>m.isPatternEqualWithoutDecimal(T.value,t.defaultPattern)))==null?void 0:b.value)||p[0].value}),v=_.useMemo(()=>m.getCurrencyFormatOptions(s),[s]),h=_.useMemo(()=>r.map(p=>({label:p,value:p})),[r]);t.action.current=()=>m.setPatternDecimal(a,c);const f=p=>{if(p===void 0)return;o(p);const P=m.getCurrencyFormatOptions(p)[0].value;d(P),t.onChange(m.setPatternDecimal(P,c))},g=p=>{p!==void 0&&(d(p),t.onChange(m.setPatternDecimal(p,c)))},y=p=>{u(p||0),t.onChange(m.setPatternDecimal(a,p||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:n("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(E.InputNumber,{value:c,max:20,min:0,onChange:y})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:n("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(E.Select,{onChange:f,options:h,value:s})})]})]}),l.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.negType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.SelectList,{onChange:g,options:v,value:a})}),l.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.currencyDes")})]})};var N=function(){return N=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},N.apply(this,arguments)},xe=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n},ce=_.forwardRef(function(t,e){var n=t.icon,r=t.id,s=t.className,o=t.extend,c=xe(t,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),a=_.useRef("_".concat(we()));return ae(n,"".concat(r),{defIds:n.defIds,idSuffix:a.current},N({ref:e,className:u},c),o)});function ae(t,e,n,r,s){return _.createElement(t.tag,N(N({key:e},Oe(t,n,s)),r),(Ue(t,n).children||[]).map(function(o,c){return ae(o,"".concat(e,"-").concat(t.tag,"-").concat(c),n,void 0,s)}))}function Oe(t,e,n){var r=N({},t.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(o){var c=o[0],u=o[1];typeof u=="string"&&(r[c]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Ue(t,e){var n,r=e.defIds;return!r||r.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?N(N({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?N(N({},s),{attrs:N(N({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function we(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var Fe={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"}}]},le=_.forwardRef(function(t,e){return _.createElement(ce,Object.assign({},t,{id:"check-mark-single",ref:e,icon:Fe}))});le.displayName="CheckMarkSingle";const $e="univer-custom-format-title",Le="univer-custom-format-input",ke="univer-custom-format-history-list",He="univer-custom-format-history-list-item",Ae="univer-custom-format-history-list-item-icon-wrap",We="univer-custom-format-des",x={customFormatTitle:$e,customFormatInput:Le,customFormatHistoryList:ke,customFormatHistoryListItem:He,customFormatHistoryListItemIconWrap:Ae,customFormatDes:We},Y="customFormat",X="numfmt_custom_pattern";function Ve(t){const{defaultPattern:e,action:n,onChange:r}=t,s=i.useDependency(L),o=i.useDependency(i.ILocalStorageService),c=i.useDependency(i.LocaleService),[u,a]=_.useState(e);n.current=()=>(s.markHabit(Y,u),o.getItem(X).then((g=[])=>{const y=[...new Set([u,...g||[]])].splice(0,10).filter(p=>!!p);o.setItem(X,y)}),u);const[d,v]=_.useState([]);_.useEffect(()=>{o.getItem(X).then(g=>{const y=[...m.CURRENCYFORMAT.map(p=>p.suffix("$")),...m.DATEFMTLISG.map(p=>p.suffix),...m.NUMBERFORMAT.map(p=>p.suffix)];y.push(...g||[]),s.addHabit(Y,[]).finally(()=>{s.getHabit(Y,y).then(p=>{v([...new Set(p)])})})})},[]);const h=g=>{a(g),r(g)},f=()=>{r(u)};return l.jsxs("div",{className:x.customFormat,children:[l.jsx("div",{className:x.customFormatTitle,children:c.t("sheet.numfmt.customFormat")}),l.jsx(E.Input,{placeholder:c.t("sheet.numfmt.customFormat"),onBlur:f,value:u,onChange:a,className:x.customFormatInput}),l.jsx("div",{className:x.customFormatHistoryList,children:d.map(g=>l.jsxs("div",{onClick:()=>h(g),className:x.customFormatHistoryListItem,children:[l.jsx("div",{className:x.customFormatHistoryListItemIconWrap,children:u===g&&l.jsx(le,{})}),l.jsx("div",{children:g})]},g))}),l.jsx("div",{className:x.customFormatDes,children:c.t("sheet.numfmt.customFormatDes")})]})}const Be=t=>{const e=i.numfmt.getInfo(t);return m.getDateFormatOptions().map(n=>n.value).includes(t)||["date","datetime","time"].includes(e.type)},qe=t=>{const e=_.useMemo(m.getDateFormatOptions,[]),r=i.useDependency(i.LocaleService).t,[s,o]=_.useState(()=>{if(t.defaultPattern){const u=e.find(a=>a.value===t.defaultPattern);if(u)return u.value}return e[0].value});t.action.current=()=>s;const c=u=>{u!==void 0&&(o(u),t.onChange(u))};return l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.dateType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.SelectList,{value:s,options:e,onChange:c})}),l.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.dateDes")})]})},Ge=t=>!t,Ke=t=>{const n=i.useDependency(i.LocaleService).t;return t.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.generalDes")})})},Ze=t=>m.getNumberFormatOptions().some(e=>m.isPatternEqualWithoutDecimal(e.value,t)),ze=t=>{const e=i.useDependency(i.LocaleService),n=_.useMemo(m.getNumberFormatOptions,[]),[r,s]=_.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",0)),[o,c]=_.useState(()=>{const h=n.find(f=>m.isPatternEqualWithoutDecimal(f.value,t.defaultPattern||""));return(h==null?void 0:h.value)||n[0].value}),u=_.useMemo(()=>m.setPatternDecimal(o,Number(r||0)),[o,r]),a=_.useMemo(()=>!m.isPatternHasDecimal(o),[o]),d=h=>{s(h||0),t.onChange(m.setPatternDecimal(o,Number(h||0)))},v=h=>{h!==void 0&&(s(m.getDecimalFromPattern(h,0)),c(h),t.onChange(h))};return t.action.current=()=>u,l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:e.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.InputNumber,{disabled:a,value:r,max:20,min:0,onChange:d})}),l.jsxs("div",{className:"m-t-16 label",children:[" ",e.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.SelectList,{onChange:v,options:n,value:o})}),l.jsx("div",{className:"describe m-t-14",children:e.t("sheet.numfmt.thousandthPercentileDes")})]})},Ye=t=>{const{defaultValue:e,defaultPattern:n,row:r,col:s}=t.value,o=i.useDependency(i.LocaleService),c=_.useRef(()=>""),u=o.t,a=Ee(),d=_.useMemo(()=>[{label:"sheet.numfmt.general",component:Ke},{label:"sheet.numfmt.accounting",component:je},{label:"sheet.numfmt.currency",component:Re},{label:"sheet.numfmt.date",component:qe},{label:"sheet.numfmt.thousandthPercentile",component:ze},{label:"sheet.numfmt.customFormat",component:Ve}].map(C=>({...C,label:u(C.label)})),[]),[v,h]=_.useState(b),[f,g]=_.useState(()=>`${r}_${s}`),{mark:y,userHabitCurrency:p}=Ne(()=>g(`${r}_${s}_userCurrency'`)),P=_.useMemo(()=>{var C;return(C=d.find(O=>O.label===v))==null?void 0:C.component},[v]);function b(){return[Ge,Me,De,Be,Ze].reduce((O,fe,pe)=>O||(fe(n)?d[pe].label:""),"")||d[0].label}const T=d.map(C=>({label:C.label,value:C.label})),D=C=>{h(C),a(()=>t.onChange({type:"change",value:c.current()||""}))},H=C=>{t.onChange({type:"change",value:C})},G=()=>{const C=c.current()||"",O=m.getCurrencyType(C);O&&y(O),t.onChange({type:"confirm",value:C})},w=()=>{t.onChange({type:"cancel",value:""})},K={onChange:H,defaultValue:e,defaultPattern:n,action:c};return _.useEffect(()=>{h(b()),g(`${r}_${s}`)},[r,s]),l.jsxs("div",{className:"numfmt-panel p-b-20",children:[l.jsxs("div",{children:[l.jsx("div",{className:"label m-t-14",children:u("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.Select,{onChange:D,options:T,value:v,style:{width:"100%"}})}),l.jsx("div",{children:P&&l.jsx(te.Provider,{value:p,children:_.createElement(P,{...K,key:f})})})]}),l.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[l.jsx(E.Button,{size:"small",onClick:w,className:"m-r-12",children:u("sheet.numfmt.cancel")}),l.jsx(E.Button,{type:"primary",size:"small",onClick:G,children:u("sheet.numfmt.confirm")})]})]})};var Xe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(t,e,n,r)=>{for(var s=r>1?void 0:r?Je(e,n):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&Xe(e,n,s),s},j=(t,e)=>(n,r)=>e(n,r,t);const se="SHEET_NUMFMT_PANEL";let k=class extends i.Disposable{constructor(e,n,r,s,o,c,u,a,d,v,h){super();A(this,"_previewPattern","");A(this,"_sidebarDisposable",null);this._sheetInterceptorService=e,this._themeService=n,this._univerInstanceService=r,this._commandService=s,this._selectionManagerService=o,this._renderManagerService=c,this._numfmtService=u,this._componentManager=a,this._sidebarService=d,this._localeService=v,this._sheetsNumfmtCellContentController=h,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(R.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var P;const e=this._sidebarService,n=this._selectionManagerService,r=this._commandService,s=this._univerInstanceService,o=this._numfmtService,c=this._localeService,a=(((P=n.getCurrentSelections())==null?void 0:P.map(b=>b.range))||[])[0];if(!a)return!1;const d=s.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),v=d.getActiveSheet();if(!v)return!1;const h=v.getCellRaw(a.startRow,a.startColumn),f=o.getValue(d.getUnitId(),v.getSheetId(),a.startRow,a.startColumn);let g="";f&&(g=f.pattern);const y=(h==null?void 0:h.t)===i.CellValueType.NUMBER?h.v:12345678,p={onChange:b=>{var T;if(b.type==="change")this._previewPattern=b.value,this._forceUpdate();else if(b.type==="confirm"){const D=((T=n.getCurrentSelections())==null?void 0:T.map(w=>w.range))||[],H={values:[]},G=m.getPatternType(b.value);D.forEach(w=>{i.Range.foreach(w,(K,C)=>{H.values.push({row:K,col:C,pattern:b.value,type:G})})}),r.executeCommand(m.SetNumfmtCommand.id,H),e.close()}else b.type==="cancel"&&e.close()},value:{defaultPattern:g,defaultValue:y,row:a.startRow,col:a.startColumn}};return this._sidebarDisposable=e.open({header:{title:c.t("sheet.numfmt.title")},children:{label:se,...p},onClose:()=>{this._forceUpdate(),r.executeCommand(z.id)}}),!0}_forceUpdate(e){var r;const n=this._renderManagerService.getRenderById(e!=null?e:this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId());n==null||n.with(M.SheetSkeletonManagerService).reCalculate(),(r=n==null?void 0:n.mainComponent)==null||r.makeDirty()}_initCommands(){[$,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initPanel(){this._componentManager.register(se,Ye)}_initRealTimeRenderingInterceptor(){const e=new R.Observable(r=>{this._commandService.onCommandExecuted(s=>{s.id===$.id&&r.next(!0),s.id===z.id&&r.next(!1)})}),n=R.combineLatest([e,this._selectionManagerService.selectionMoveEnd$.pipe(W.map(r=>r?r.map(s=>s.range):[]))]);this.disposeWithMe(i.toDisposable(n.pipe(W.switchMap(([r,s])=>new R.Observable(o=>{const c=new i.DisposableCollection;return r&&s.length&&o.next({selectionRanges:s,disposableCollection:c}),()=>{c.dispose()}})),W.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:r,selectionRanges:s})=>{var c,u;const o=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);this.openPanel(),r.add(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:i.InterceptorEffectEnum.Value|i.InterceptorEffectEnum.Style,handler:(a,d,v)=>{const{row:h,col:f}=d,g=v(a)||{};if(s.find(y=>y.startColumn<=f&&y.endColumn>=f&&y.startRow<=h&&y.endRow>=h)){const y=d.worksheet.getCellRaw(h,f),p=y==null?void 0:y.v,P=y==null?void 0:y.t;if(p==null||P!==i.CellValueType.NUMBER||this._previewPattern===null)return g;const b=m.getPatternPreviewIgnoreGeneral(this._previewPattern,p,this._sheetsNumfmtCellContentController.local);if(b.color){const D=this._themeService.getCurrentTheme()[`${b.color}500`];return{...g,v:b.result,t:i.CellValueType.STRING,s:{cl:{rgb:D}}}}return{...g,v:b.result,t:i.CellValueType.STRING}}return g}})),(u=(c=this._renderManagerService.getRenderById(o.getUnitId()))==null?void 0:c.mainComponent)==null||u.makeDirty()})))}_commandExecutedListener(){const e=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id];this.disposeWithMe(new R.Observable(n=>{const r=this._commandService.onCommandExecuted(s=>{if(e.includes(s.id)){const o=s.params;n.next(o.unitId)}});return()=>r.dispose()}).pipe(W.debounceTime(16)).subscribe(n=>this._forceUpdate(n)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{var n;e||((n=this._sidebarDisposable)==null||n.dispose(),this._sidebarDisposable=null)})}};k=Qe([j(0,i.Inject(S.SheetInterceptorService)),j(1,i.Inject(i.ThemeService)),j(2,i.IUniverInstanceService),j(3,i.ICommandService),j(4,i.Inject(S.SheetsSelectionsService)),j(5,oe.IRenderManagerService),j(6,S.INumfmtService),j(7,i.Inject(I.ComponentManager)),j(8,I.ISidebarService),j(9,i.Inject(i.LocaleService)),j(10,i.Inject(m.SheetsNumfmtCellContentController))],k);var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(t,e,n,r)=>{for(var s=r>1?void 0:r?tt(e,n):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&et(e,n,s),s},F=(t,e)=>(n,r)=>e(n,r,t);const rt=()=>{let t=[];return{add:(s,o,c,u,a)=>t.push({unitId:s,subUnitId:o,row:c,col:u,value:a}),getEffects:()=>t,clean:()=>{t=[]}}};let B=class extends i.Disposable{constructor(e,n,r,s,o){super();A(this,"_collectEffectMutation",rt());this._sheetInterceptorService=e,this._numfmtService=n,this._univerInstanceService=r,this._injector=s,this._editorBridgeService=o,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(i.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.BEFORE_CELL_EDIT,{handler:(e,n,r)=>{const s=n.row,o=n.col,c=this._numfmtService.getValue(n.unitId,n.subUnitId,s,o);if(c)switch(m.getPatternType(c.pattern)){case"scientific":case"currency":case"grouped":case"number":{const a=n.worksheet.getCellRaw(s,o);return r&&r(a)}case"percent":case"date":case"time":case"datetime":default:return r&&r(e)}return r(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(i.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.AFTER_CELL_EDIT,{handler:(e,n,r)=>{var v,h,f,g;this._collectEffectMutation.clean();const s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),o=(v=s&&m.getPatternType(s.pattern))!=null?v:"",c=()=>{s&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,null)};if(!(e!=null&&e.v)&&!(e!=null&&e.p)||(s==null?void 0:s.pattern)===ee.DEFAULT_TEXT_FORMAT||e.t===i.CellValueType.FORCE_STRING)return r(e);const u=(h=e.p)==null?void 0:h.body,a=(g=(f=e==null?void 0:e.p)==null?void 0:f.body)!=null&&g.dataStream?e.p.body.dataStream.replace(/\r\n$/,""):String(e.v),d=i.numfmt.parseDate(a)||i.numfmt.parseTime(a)||i.numfmt.parseNumber(a);if(u)if(it(u)){const{dataStream:y}=u,p=y.replace(/\r\n$/,""),P=Number(p);if(Number.isNaN(P)&&!d)return r(e)}else return r(e);if(d){d.z&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:d.z});const y=Number(d.v);return r({...e,p:void 0,v:y,t:i.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(o)||!st(a))&&c();return r(e)}})))}_initInterceptorCommands(){const e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(n){var r;switch(n.id){case S.SetRangeValuesCommand.id:{const s=e._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=s.getUnitId(),c=(r=s.getActiveSheet())==null?void 0:r.getSheetId();if(!c)return{redos:[],undos:[]};const u=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!u.length)return{redos:[],undos:[]};const a=u.filter(f=>{var g;return!!((g=f.value)!=null&&g.pattern)}).map(f=>({row:f.row,col:f.col,pattern:f.value.pattern})),d=u.filter(f=>{var g;return!((g=f.value)!=null&&g.pattern)}).map(f=>({startRow:f.row,endColumn:f.col,startColumn:f.col,endRow:f.row})),v=[],h=[];if(a.length){const f={id:S.SetNumfmtMutation.id,params:S.transformCellsToRange(o,c,a)};v.push(f),h.push(...S.factorySetNumfmtUndoMutation(e._injector,f.params))}if(d.length){const f={id:S.RemoveNumfmtMutation.id,params:{unitId:o,subUnitId:c,ranges:d}};v.push(f),h.push(...S.factoryRemoveNumfmtUndoMutation(e._injector,f.params))}return{redos:v,undos:h.reverse()}}}return{redos:[],undos:[]}}}))}};B=nt([F(0,i.Inject(S.SheetInterceptorService)),F(1,i.Inject(S.INumfmtService)),F(2,i.Inject(i.IUniverInstanceService)),F(3,i.Inject(i.Injector)),F(4,i.Optional(M.IEditorBridgeService))],B);function st(t){return/^-?\d+(\.\d+)?$/.test(t)}function it(t){const{textRuns:e=[],paragraphs:n=[],customRanges:r,customBlocks:s=[]}=t,o=["va"];return!(e.some(c=>!!(c.ts&&Object.keys(c.ts).some(a=>o.includes(a))))||n.some(c=>c.bullet)||n.length>=2||r!=null&&r.length||s.length>0)}const V=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:ee.DEFAULT_TEXT_FORMAT},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],ot=t=>({icon:new R.Observable(e=>{const n=t.get(m.MenuCurrencyService);function r(o){return{[m.countryCurrencyMap.US]:"DollarSingle",[m.countryCurrencyMap.RU]:"RoubleSingle",[m.countryCurrencyMap.CN]:"RmbSingle",[m.countryCurrencyMap.AT]:"EuroSingle"}[o]||"DollarSingle"}const s=m.countryCurrencyMap[n.getCurrencySymbol()]||"$";return e.next(r(s)),n.currencySymbol$.subscribe(o=>{const c=m.countryCurrencyMap[o]||"$";e.next(r(c))})}),id:m.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),ct=t=>({icon:"AddDigitsSingle",id:m.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),at=t=>({icon:"ReduceDigitsSingle",id:m.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),lt=t=>({icon:"PercentSingle",id:m.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),ut=t=>{const e=t.get(i.IUniverInstanceService),n=t.get(i.ICommandService),r=t.get(i.LocaleService),s=t.get(S.SheetsSelectionsService),o=M.deriveStateFromActiveSheet$(e,"",({workbook:c,worksheet:u})=>new R.Observable(a=>R.merge(s.selectionMoveEnd$,new R.Observable(d=>{const v=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id],h=n.onCommandExecuted(f=>{v.includes(f.id)&&d.next(null)});return()=>h.dispose()})).subscribe(()=>{var v,h;const d=s.getCurrentSelections();if(d&&d[0]){const f=d[0].range,g=f.startRow,y=f.startColumn,p=(h=c.getStyles().get((v=u.getCell(g,y))==null?void 0:v.s))==null?void 0:h.n,P=p==null?void 0:p.pattern;let b=r.t("sheet.numfmt.general");if(P){const T=V.filter(D=>typeof D=="object"&&D.pattern).find(D=>m.isPatternEqualWithoutDecimal(P,D.pattern));T&&typeof T=="object"&&T.pattern?b=r.t(T.label):b=r.t("sheet.numfmt.moreFmt")}a.next(b)}})));return{label:ue,id:$.id,tooltip:"sheet.numfmt.title",type:I.MenuItemType.SELECTOR,selections:[{label:{name:me,hoverable:!1}}],value$:o,hidden$:I.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetSetCellStylePermission,S.WorksheetEditPermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}},ue="sheet.numfmt.moreNumfmtType",me="sheet.numfmt.moreNumfmtType.options",mt=t=>{var r;const e=i.useDependency(i.LocaleService),n=(r=t.value)!=null?r:e.t("sheet.numfmt.general");return l.jsx("span",{className:"more-numfmt-type",children:n})},dt=()=>{const t=i.useDependency(i.ICommandService),e=i.useDependency(i.LocaleService),n=i.useDependency(I.ILayoutService),r=i.useDependency(m.SheetsNumfmtCellContentController),s=i.useDependency(S.SheetsSelectionsService),o=a=>{const d=s.getCurrentLastSelection();if(!d)return;const v=d.range,h=[];i.Range.foreach(v,(f,g)=>{a?h.push({row:f,col:g,pattern:a,type:m.getPatternType(a)}):h.push({row:f,col:g})}),t.executeCommand(m.SetNumfmtCommand.id,{values:h}),n.focus()},c=a=>{if(a===0)o(null);else if(a===V.length-1)t.executeCommand($.id);else{const d=V[a];d.pattern&&o(d.pattern)}},u=1220;return l.jsx("div",{className:"more-numfmt-type-options",children:V.map((a,d)=>a==="|"?l.jsx("div",{className:"line m-t-4",onClick:v=>v.stopPropagation()},d):l.jsxs("div",{className:"option-item m-t-4",onClick:()=>{c(d)},children:[l.jsx("div",{children:e.t(a.label)}),l.jsx("div",{className:"m-l-26",children:a.pattern?m.getPatternPreview(a.pattern||"",u,r.local).result:""})]},d))})},ht={[I.RibbonStartGroup.FORMULAS_INSERT]:{[m.SetCurrencyCommand.id]:{order:4,menuItemFactory:ot},[m.AddDecimalCommand.id]:{order:5,menuItemFactory:ct},[m.SubtractDecimalCommand.id]:{order:6,menuItemFactory:at},[m.SetPercentCommand.id]:{order:7,menuItemFactory:lt},[$.id]:{order:8,menuItemFactory:ut}}};var ft=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,vt=(t,e,n,r)=>{for(var s=r>1?void 0:r?pt(e,n):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&ft(e,n,s),s},ie=(t,e)=>(n,r)=>e(n,r,t);let q=class extends i.Disposable{constructor(t,e){super(),this._componentManager=t,this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(ht),this.disposeWithMe(this._componentManager.register(ue,mt)),this.disposeWithMe(this._componentManager.register(me,dt))}};q=vt([ie(0,i.Inject(I.ComponentManager)),ie(1,I.IMenuManagerService)],q);var de=Object.defineProperty,St=Object.getOwnPropertyDescriptor,gt=(t,e,n)=>e in t?de(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_t=(t,e,n,r)=>{for(var s=r>1?void 0:r?St(e,n):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(r?c(e,n,s):c(s))||s);return r&&s&&de(e,n,s),s},J=(t,e)=>(n,r)=>e(n,r,t),he=(t,e,n)=>gt(t,typeof e!="symbol"?e+"":e,n);const yt="SHEET_NUMFMT_UI_PLUGIN";exports.UniverSheetsNumfmtUIPlugin=class extends i.Plugin{constructor(e=ne,n,r,s){super(),this._config=e,this._injector=n,this._configService=r,this._renderManagerService=s;const{menu:o,...c}=i.merge({},ne,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(I.UI_PLUGIN_CONFIG_KEY,c)}onStarting(){i.registerDependencies(this._injector,[[k],[B],[L],[q]])}onRendered(){this._registerRenderModules(),i.touchDependencies(this._injector,[[k],[B],[q]])}_registerRenderModules(){[[Q]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(i.UniverInstanceType.UNIVER_SHEET,n))})}};he(exports.UniverSheetsNumfmtUIPlugin,"pluginName",yt);he(exports.UniverSheetsNumfmtUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtUIPlugin=_t([i.DependentOn(M.UniverSheetsUIPlugin,m.UniverSheetsNumfmtPlugin),J(1,i.Inject(i.Injector)),J(2,i.IConfigService),J(3,oe.IRenderManagerService)],exports.UniverSheetsNumfmtUIPlugin);
1
+ "use strict";var ve=Object.defineProperty;var Se=(t,e,n)=>e in t?ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var A=(t,e,n)=>Se(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),oe=require("@univerjs/engine-render"),m=require("@univerjs/sheets-numfmt"),M=require("@univerjs/sheets-ui"),b=require("@univerjs/ui"),ge=require("@univerjs/engine-formula"),ee=require("@univerjs/engine-numfmt"),S=require("@univerjs/sheets"),R=require("rxjs"),W=require("rxjs/operators"),l=require("react/jsx-runtime"),_=require("react"),E=require("@univerjs/design"),ne={};var _e=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,be=(t,e,n,r)=>{for(var s=r>1?void 0:r?ye(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(s=(r?o(e,n,s):o(s))||s);return r&&s&&_e(e,n,s),s},U=(t,e)=>(n,r)=>e(n,r,t);const Z="SHEET_NUMFMT_ALERT";let Q=class extends c.Disposable{constructor(t,e,n,r,s,i,o){super(),this._context=t,this._hoverManagerService=e,this._cellAlertManagerService=n,this._localeService=r,this._formulaDataModel=s,this._zenZoneService=i,this._numfmtService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(R.debounceTime(100)).subscribe(t=>{var e;if(t){const n=t.location,r=this._context.unit,s=r.getActiveSheet();if(!s)return;const i=n.unitId,o=n.subUnitId;let u;const a=s.getCell(n.row,n.col);if(a!=null&&a.s){const d=r.getStyles().get(a.s);d!=null&&d.n&&(u=d.n)}if(u||(u=this._numfmtService.getValue(i,o,n.row,n.col)),!u){this._hideAlert();return}if(u.pattern===ee.DEFAULT_TEXT_FORMAT&&(a!=null&&a.v)&&c.isRealNum(a.v)){const d=this._cellAlertManagerService.currentAlert.get(Z),v=(e=d==null?void 0:d.alert)==null?void 0:e.location;if(v&&v.row===n.row&&v.col===n.col&&v.subUnitId===n.subUnitId&&v.unitId===n.unitId)return;this._cellAlertManagerService.showAlert({type:M.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n,width:200,height:74,key:Z});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(Z)}};Q=be([U(1,c.Inject(M.HoverManagerService)),U(2,c.Inject(M.CellAlertManagerService)),U(3,c.Inject(c.LocaleService)),U(4,c.Inject(ge.FormulaDataModel)),U(5,b.IZenZoneService),U(6,c.Inject(S.INumfmtService))],Q);const z={id:"sheet.operation.close.numfmt.panel",type:c.CommandType.OPERATION,handler:()=>!0},$={id:"sheet.operation.open.numfmt.panel",type:c.CommandType.OPERATION,handler:t=>(t.get(k).openPanel(),!0)};var Ce=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Pe=(t,e,n,r)=>{for(var s=r>1?void 0:r?Ie(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(s=(r?o(e,n,s):o(s))||s);return r&&s&&Ce(e,n,s),s},Te=(t,e)=>(n,r)=>e(n,r,t);const te=_.createContext([]);let L=class{constructor(t){this._localStorageService=t}_getKey(t){return`userHabitController_${t}`}async addHabit(t,e){const n=this._getKey(t);return this._localStorageService.getItem(n).then(r=>{r||this._localStorageService.setItem(n,e)})}markHabit(t,e){const n=this._getKey(t);this._localStorageService.getItem(n).then(r=>{if(r){const s=r.findIndex(i=>i===e);s>-1&&r.splice(s,1),r.unshift(e),this._localStorageService.setItem(n,r)}})}async getHabit(t,e){const n=this._getKey(t),r=await this._localStorageService.getItem(n);if(e&&r){const s=r.map((i,o,u)=>{const a=u.length;return{value:i,priority:a-o}});return e.sort((i,o)=>{var d,v;const u=((d=s.find(h=>h.value===i))==null?void 0:d.priority)||-1;return(((v=s.find(h=>h.value===o))==null?void 0:v.priority)||-1)-u})}return r||[]}deleteHabit(t){this._localStorageService.removeItem(t)}};L=Pe([Te(0,c.Inject(c.ILocalStorageService))],L);const re="numfmtCurrency",Ne=t=>{const e=b.useDependency(L),[n,r]=_.useState(m.currencySymbols);return _.useEffect(()=>{e.addHabit("numfmtCurrency",[]).then(()=>{e.getHabit(re,[...m.currencySymbols]).then(i=>{r(i),t(i)})})},[]),{userHabitCurrency:n,mark:i=>{e.markHabit(re,i)}}},Ee=()=>{const t=_.useRef([]),[e,n]=_.useState({});return _.useEffect(()=>{t.current.forEach(s=>{s()}),t.current=[]},[e]),s=>{t.current.push(s),n({})}},Me=t=>!!m.getCurrencyType(t)&&t.startsWith("_("),je=t=>{const{defaultPattern:e,action:n,onChange:r}=t,[s,i]=_.useState(()=>m.getDecimalFromPattern(e||"",2)),o=_.useContext(te),[u,a]=_.useState(()=>m.getCurrencyType(e)||o[0]),d=_.useMemo(()=>o.map(y=>({label:y,value:y})),[]),h=b.useDependency(c.LocaleService).t;n.current=()=>m.setPatternDecimal(`_("${u}"* #,##0${s>0?".0":""}_)`,s);const f=y=>{a(y),r(m.setPatternDecimal(`_("${y}"* #,##0${s>0?".0":""}_)`,s))},g=y=>{const p=y||0;i(p),r(m.setPatternDecimal(`_("${u}"* #,##0${p>0?".0":""}_)`,p))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:h("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(E.InputNumber,{value:s,max:20,min:0,onChange:g})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:h("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(E.Select,{onChange:f,options:d,value:u})})]})]}),l.jsx("div",{className:"describe m-t-14",children:h("sheet.numfmt.accountingDes")})]})},De=t=>!!m.getCurrencyType(t)&&!t.startsWith("_("),Re=t=>{const n=b.useDependency(c.LocaleService).t,r=_.useContext(te),[s,i]=_.useState(()=>m.getCurrencyType(t.defaultPattern)||r[0]),[o,u]=_.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",2)),[a,d]=_.useState(()=>{var C;const p=m.getCurrencyFormatOptions(s);return((C=p.find(T=>m.isPatternEqualWithoutDecimal(T.value,t.defaultPattern)))==null?void 0:C.value)||p[0].value}),v=_.useMemo(()=>m.getCurrencyFormatOptions(s),[s]),h=_.useMemo(()=>r.map(p=>({label:p,value:p})),[r]);t.action.current=()=>m.setPatternDecimal(a,o);const f=p=>{if(p===void 0)return;i(p);const P=m.getCurrencyFormatOptions(p)[0].value;d(P),t.onChange(m.setPatternDecimal(P,o))},g=p=>{p!==void 0&&(d(p),t.onChange(m.setPatternDecimal(p,o)))},y=p=>{u(p||0),t.onChange(m.setPatternDecimal(a,p||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:n("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(E.InputNumber,{value:o,max:20,min:0,onChange:y})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:n("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(E.Select,{onChange:f,options:h,value:s})})]})]}),l.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.negType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.SelectList,{onChange:g,options:v,value:a})}),l.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.currencyDes")})]})};var N=function(){return N=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},N.apply(this,arguments)},xe=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n},ce=_.forwardRef(function(t,e){var n=t.icon,r=t.id,s=t.className,i=t.extend,o=xe(t,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),a=_.useRef("_".concat(we()));return ae(n,"".concat(r),{defIds:n.defIds,idSuffix:a.current},N({ref:e,className:u},o),i)});function ae(t,e,n,r,s){return _.createElement(t.tag,N(N({key:e},Oe(t,n,s)),r),(Ue(t,n).children||[]).map(function(i,o){return ae(i,"".concat(e,"-").concat(t.tag,"-").concat(o),n,void 0,s)}))}function Oe(t,e,n){var r=N({},t.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(i){var o=i[0],u=i[1];typeof u=="string"&&(r[o]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Ue(t,e){var n,r=e.defIds;return!r||r.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?N(N({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?N(N({},s),{attrs:N(N({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function we(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var Fe={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"}}]},le=_.forwardRef(function(t,e){return _.createElement(ce,Object.assign({},t,{id:"check-mark-single",ref:e,icon:Fe}))});le.displayName="CheckMarkSingle";const $e="univer-custom-format-title",Le="univer-custom-format-input",ke="univer-custom-format-history-list",He="univer-custom-format-history-list-item",Ae="univer-custom-format-history-list-item-icon-wrap",We="univer-custom-format-des",x={customFormatTitle:$e,customFormatInput:Le,customFormatHistoryList:ke,customFormatHistoryListItem:He,customFormatHistoryListItemIconWrap:Ae,customFormatDes:We},Y="customFormat",X="numfmt_custom_pattern";function Ve(t){const{defaultPattern:e,action:n,onChange:r}=t,s=b.useDependency(L),i=b.useDependency(c.ILocalStorageService),o=b.useDependency(c.LocaleService),[u,a]=_.useState(e);n.current=()=>(s.markHabit(Y,u),i.getItem(X).then((g=[])=>{const y=[...new Set([u,...g||[]])].splice(0,10).filter(p=>!!p);i.setItem(X,y)}),u);const[d,v]=_.useState([]);_.useEffect(()=>{i.getItem(X).then(g=>{const y=[...m.CURRENCYFORMAT.map(p=>p.suffix("$")),...m.DATEFMTLISG.map(p=>p.suffix),...m.NUMBERFORMAT.map(p=>p.suffix)];y.push(...g||[]),s.addHabit(Y,[]).finally(()=>{s.getHabit(Y,y).then(p=>{v([...new Set(p)])})})})},[]);const h=g=>{a(g),r(g)},f=()=>{r(u)};return l.jsxs("div",{className:x.customFormat,children:[l.jsx("div",{className:x.customFormatTitle,children:o.t("sheet.numfmt.customFormat")}),l.jsx(E.Input,{placeholder:o.t("sheet.numfmt.customFormat"),onBlur:f,value:u,onChange:a,className:x.customFormatInput}),l.jsx("div",{className:x.customFormatHistoryList,children:d.map(g=>l.jsxs("div",{onClick:()=>h(g),className:x.customFormatHistoryListItem,children:[l.jsx("div",{className:x.customFormatHistoryListItemIconWrap,children:u===g&&l.jsx(le,{})}),l.jsx("div",{children:g})]},g))}),l.jsx("div",{className:x.customFormatDes,children:o.t("sheet.numfmt.customFormatDes")})]})}const Be=t=>{const e=c.numfmt.getInfo(t);return m.getDateFormatOptions().map(n=>n.value).includes(t)||["date","datetime","time"].includes(e.type)},qe=t=>{const e=_.useMemo(m.getDateFormatOptions,[]),r=b.useDependency(c.LocaleService).t,[s,i]=_.useState(()=>{if(t.defaultPattern){const u=e.find(a=>a.value===t.defaultPattern);if(u)return u.value}return e[0].value});t.action.current=()=>s;const o=u=>{u!==void 0&&(i(u),t.onChange(u))};return l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.dateType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.SelectList,{value:s,options:e,onChange:o})}),l.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.dateDes")})]})},Ge=t=>!t,Ke=t=>{const n=b.useDependency(c.LocaleService).t;return t.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.generalDes")})})},Ze=t=>m.getNumberFormatOptions().some(e=>m.isPatternEqualWithoutDecimal(e.value,t)),ze=t=>{const e=b.useDependency(c.LocaleService),n=_.useMemo(m.getNumberFormatOptions,[]),[r,s]=_.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",0)),[i,o]=_.useState(()=>{const h=n.find(f=>m.isPatternEqualWithoutDecimal(f.value,t.defaultPattern||""));return(h==null?void 0:h.value)||n[0].value}),u=_.useMemo(()=>m.setPatternDecimal(i,Number(r||0)),[i,r]),a=_.useMemo(()=>!m.isPatternHasDecimal(i),[i]),d=h=>{s(h||0),t.onChange(m.setPatternDecimal(i,Number(h||0)))},v=h=>{h!==void 0&&(s(m.getDecimalFromPattern(h,0)),o(h),t.onChange(h))};return t.action.current=()=>u,l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:e.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.InputNumber,{disabled:a,value:r,max:20,min:0,onChange:d})}),l.jsxs("div",{className:"m-t-16 label",children:[" ",e.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.SelectList,{onChange:v,options:n,value:i})}),l.jsx("div",{className:"describe m-t-14",children:e.t("sheet.numfmt.thousandthPercentileDes")})]})},Ye=t=>{const{defaultValue:e,defaultPattern:n,row:r,col:s}=t.value,i=b.useDependency(c.LocaleService),o=_.useRef(()=>""),u=i.t,a=Ee(),d=_.useMemo(()=>[{label:"sheet.numfmt.general",component:Ke},{label:"sheet.numfmt.accounting",component:je},{label:"sheet.numfmt.currency",component:Re},{label:"sheet.numfmt.date",component:qe},{label:"sheet.numfmt.thousandthPercentile",component:ze},{label:"sheet.numfmt.customFormat",component:Ve}].map(I=>({...I,label:u(I.label)})),[]),[v,h]=_.useState(C),[f,g]=_.useState(()=>`${r}_${s}`),{mark:y,userHabitCurrency:p}=Ne(()=>g(`${r}_${s}_userCurrency'`)),P=_.useMemo(()=>{var I;return(I=d.find(O=>O.label===v))==null?void 0:I.component},[v]);function C(){return[Ge,Me,De,Be,Ze].reduce((O,fe,pe)=>O||(fe(n)?d[pe].label:""),"")||d[0].label}const T=d.map(I=>({label:I.label,value:I.label})),D=I=>{h(I),a(()=>t.onChange({type:"change",value:o.current()||""}))},H=I=>{t.onChange({type:"change",value:I})},G=()=>{const I=o.current()||"",O=m.getCurrencyType(I);O&&y(O),t.onChange({type:"confirm",value:I})},w=()=>{t.onChange({type:"cancel",value:""})},K={onChange:H,defaultValue:e,defaultPattern:n,action:o};return _.useEffect(()=>{h(C()),g(`${r}_${s}`)},[r,s]),l.jsxs("div",{className:"numfmt-panel p-b-20",children:[l.jsxs("div",{children:[l.jsx("div",{className:"label m-t-14",children:u("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(E.Select,{onChange:D,options:T,value:v,style:{width:"100%"}})}),l.jsx("div",{children:P&&l.jsx(te.Provider,{value:p,children:_.createElement(P,{...K,key:f})})})]}),l.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[l.jsx(E.Button,{size:"small",onClick:w,className:"m-r-12",children:u("sheet.numfmt.cancel")}),l.jsx(E.Button,{type:"primary",size:"small",onClick:G,children:u("sheet.numfmt.confirm")})]})]})};var Xe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(t,e,n,r)=>{for(var s=r>1?void 0:r?Je(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(s=(r?o(e,n,s):o(s))||s);return r&&s&&Xe(e,n,s),s},j=(t,e)=>(n,r)=>e(n,r,t);const se="SHEET_NUMFMT_PANEL";let k=class extends c.Disposable{constructor(e,n,r,s,i,o,u,a,d,v,h){super();A(this,"_previewPattern","");A(this,"_sidebarDisposable",null);this._sheetInterceptorService=e,this._themeService=n,this._univerInstanceService=r,this._commandService=s,this._selectionManagerService=i,this._renderManagerService=o,this._numfmtService=u,this._componentManager=a,this._sidebarService=d,this._localeService=v,this._sheetsNumfmtCellContentController=h,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(R.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var P;const e=this._sidebarService,n=this._selectionManagerService,r=this._commandService,s=this._univerInstanceService,i=this._numfmtService,o=this._localeService,a=(((P=n.getCurrentSelections())==null?void 0:P.map(C=>C.range))||[])[0];if(!a)return!1;const d=s.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),v=d.getActiveSheet();if(!v)return!1;const h=v.getCellRaw(a.startRow,a.startColumn),f=i.getValue(d.getUnitId(),v.getSheetId(),a.startRow,a.startColumn);let g="";f&&(g=f.pattern);const y=(h==null?void 0:h.t)===c.CellValueType.NUMBER?h.v:12345678,p={onChange:C=>{var T;if(C.type==="change")this._previewPattern=C.value,this._forceUpdate();else if(C.type==="confirm"){const D=((T=n.getCurrentSelections())==null?void 0:T.map(w=>w.range))||[],H={values:[]},G=m.getPatternType(C.value);D.forEach(w=>{c.Range.foreach(w,(K,I)=>{H.values.push({row:K,col:I,pattern:C.value,type:G})})}),r.executeCommand(m.SetNumfmtCommand.id,H),e.close()}else C.type==="cancel"&&e.close()},value:{defaultPattern:g,defaultValue:y,row:a.startRow,col:a.startColumn}};return this._sidebarDisposable=e.open({header:{title:o.t("sheet.numfmt.title")},children:{label:se,...p},onClose:()=>{this._forceUpdate(),r.executeCommand(z.id)}}),!0}_forceUpdate(e){var r;const n=this._renderManagerService.getRenderById(e!=null?e:this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET).getUnitId());n==null||n.with(M.SheetSkeletonManagerService).reCalculate(),(r=n==null?void 0:n.mainComponent)==null||r.makeDirty()}_initCommands(){[$,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initPanel(){this._componentManager.register(se,Ye)}_initRealTimeRenderingInterceptor(){const e=new R.Observable(r=>{this._commandService.onCommandExecuted(s=>{s.id===$.id&&r.next(!0),s.id===z.id&&r.next(!1)})}),n=R.combineLatest([e,this._selectionManagerService.selectionMoveEnd$.pipe(W.map(r=>r?r.map(s=>s.range):[]))]);this.disposeWithMe(c.toDisposable(n.pipe(W.switchMap(([r,s])=>new R.Observable(i=>{const o=new c.DisposableCollection;return r&&s.length&&i.next({selectionRanges:s,disposableCollection:o}),()=>{o.dispose()}})),W.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:r,selectionRanges:s})=>{var o,u;const i=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);this.openPanel(),r.add(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:c.InterceptorEffectEnum.Value|c.InterceptorEffectEnum.Style,handler:(a,d,v)=>{const{row:h,col:f}=d,g=v(a)||{};if(s.find(y=>y.startColumn<=f&&y.endColumn>=f&&y.startRow<=h&&y.endRow>=h)){const y=d.worksheet.getCellRaw(h,f),p=y==null?void 0:y.v,P=y==null?void 0:y.t;if(p==null||P!==c.CellValueType.NUMBER||this._previewPattern===null)return g;const C=m.getPatternPreviewIgnoreGeneral(this._previewPattern,p,this._sheetsNumfmtCellContentController.local);if(C.color){const D=this._themeService.getCurrentTheme()[`${C.color}500`];return{...g,v:C.result,t:c.CellValueType.STRING,s:{cl:{rgb:D}}}}return{...g,v:C.result,t:c.CellValueType.STRING}}return g}})),(u=(o=this._renderManagerService.getRenderById(i.getUnitId()))==null?void 0:o.mainComponent)==null||u.makeDirty()})))}_commandExecutedListener(){const e=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id];this.disposeWithMe(new R.Observable(n=>{const r=this._commandService.onCommandExecuted(s=>{if(e.includes(s.id)){const i=s.params;n.next(i.unitId)}});return()=>r.dispose()}).pipe(W.debounceTime(16)).subscribe(n=>this._forceUpdate(n)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{var n;e||((n=this._sidebarDisposable)==null||n.dispose(),this._sidebarDisposable=null)})}};k=Qe([j(0,c.Inject(S.SheetInterceptorService)),j(1,c.Inject(c.ThemeService)),j(2,c.IUniverInstanceService),j(3,c.ICommandService),j(4,c.Inject(S.SheetsSelectionsService)),j(5,oe.IRenderManagerService),j(6,S.INumfmtService),j(7,c.Inject(b.ComponentManager)),j(8,b.ISidebarService),j(9,c.Inject(c.LocaleService)),j(10,c.Inject(m.SheetsNumfmtCellContentController))],k);var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(t,e,n,r)=>{for(var s=r>1?void 0:r?tt(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(s=(r?o(e,n,s):o(s))||s);return r&&s&&et(e,n,s),s},F=(t,e)=>(n,r)=>e(n,r,t);const rt=()=>{let t=[];return{add:(s,i,o,u,a)=>t.push({unitId:s,subUnitId:i,row:o,col:u,value:a}),getEffects:()=>t,clean:()=>{t=[]}}};let B=class extends c.Disposable{constructor(e,n,r,s,i){super();A(this,"_collectEffectMutation",rt());this._sheetInterceptorService=e,this._numfmtService=n,this._univerInstanceService=r,this._injector=s,this._editorBridgeService=i,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(c.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.BEFORE_CELL_EDIT,{handler:(e,n,r)=>{const s=n.row,i=n.col,o=this._numfmtService.getValue(n.unitId,n.subUnitId,s,i);if(o)switch(m.getPatternType(o.pattern)){case"scientific":case"currency":case"grouped":case"number":{const a=n.worksheet.getCellRaw(s,i);return r&&r(a)}case"percent":case"date":case"time":case"datetime":default:return r&&r(e)}return r(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(c.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.AFTER_CELL_EDIT,{handler:(e,n,r)=>{var v,h,f,g;this._collectEffectMutation.clean();const s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),i=(v=s&&m.getPatternType(s.pattern))!=null?v:"",o=()=>{s&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,null)};if(!(e!=null&&e.v)&&!(e!=null&&e.p)||(s==null?void 0:s.pattern)===ee.DEFAULT_TEXT_FORMAT||e.t===c.CellValueType.FORCE_STRING)return r(e);const u=(h=e.p)==null?void 0:h.body,a=(g=(f=e==null?void 0:e.p)==null?void 0:f.body)!=null&&g.dataStream?e.p.body.dataStream.replace(/\r\n$/,""):String(e.v),d=c.numfmt.parseDate(a)||c.numfmt.parseTime(a)||c.numfmt.parseNumber(a);if(u)if(it(u)){const{dataStream:y}=u,p=y.replace(/\r\n$/,""),P=Number(p);if(Number.isNaN(P)&&!d)return r(e)}else return r(e);if(d){d.z&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:d.z});const y=Number(d.v);return r({...e,p:void 0,v:y,t:c.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(i)||!st(a))&&o();return r(e)}})))}_initInterceptorCommands(){const e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(n){var r;switch(n.id){case S.SetRangeValuesCommand.id:{const s=e._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),i=s.getUnitId(),o=(r=s.getActiveSheet())==null?void 0:r.getSheetId();if(!o)return{redos:[],undos:[]};const u=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!u.length)return{redos:[],undos:[]};const a=u.filter(f=>{var g;return!!((g=f.value)!=null&&g.pattern)}).map(f=>({row:f.row,col:f.col,pattern:f.value.pattern})),d=u.filter(f=>{var g;return!((g=f.value)!=null&&g.pattern)}).map(f=>({startRow:f.row,endColumn:f.col,startColumn:f.col,endRow:f.row})),v=[],h=[];if(a.length){const f={id:S.SetNumfmtMutation.id,params:S.transformCellsToRange(i,o,a)};v.push(f),h.push(...S.factorySetNumfmtUndoMutation(e._injector,f.params))}if(d.length){const f={id:S.RemoveNumfmtMutation.id,params:{unitId:i,subUnitId:o,ranges:d}};v.push(f),h.push(...S.factoryRemoveNumfmtUndoMutation(e._injector,f.params))}return{redos:v,undos:h.reverse()}}}return{redos:[],undos:[]}}}))}};B=nt([F(0,c.Inject(S.SheetInterceptorService)),F(1,c.Inject(S.INumfmtService)),F(2,c.Inject(c.IUniverInstanceService)),F(3,c.Inject(c.Injector)),F(4,c.Optional(M.IEditorBridgeService))],B);function st(t){return/^-?\d+(\.\d+)?$/.test(t)}function it(t){const{textRuns:e=[],paragraphs:n=[],customRanges:r,customBlocks:s=[]}=t,i=["va"];return!(e.some(o=>!!(o.ts&&Object.keys(o.ts).some(a=>i.includes(a))))||n.some(o=>o.bullet)||n.length>=2||r!=null&&r.length||s.length>0)}const V=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:ee.DEFAULT_TEXT_FORMAT},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],ot=t=>({icon:new R.Observable(e=>{const n=t.get(m.MenuCurrencyService);function r(i){return{[m.countryCurrencyMap.US]:"DollarSingle",[m.countryCurrencyMap.RU]:"RoubleSingle",[m.countryCurrencyMap.CN]:"RmbSingle",[m.countryCurrencyMap.AT]:"EuroSingle"}[i]||"DollarSingle"}const s=m.countryCurrencyMap[n.getCurrencySymbol()]||"$";return e.next(r(s)),n.currencySymbol$.subscribe(i=>{const o=m.countryCurrencyMap[i]||"$";e.next(r(o))})}),id:m.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:b.MenuItemType.BUTTON,hidden$:b.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),ct=t=>({icon:"AddDigitsSingle",id:m.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:b.MenuItemType.BUTTON,hidden$:b.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),at=t=>({icon:"ReduceDigitsSingle",id:m.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:b.MenuItemType.BUTTON,hidden$:b.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),lt=t=>({icon:"PercentSingle",id:m.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:b.MenuItemType.BUTTON,hidden$:b.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),ut=t=>{const e=t.get(c.IUniverInstanceService),n=t.get(c.ICommandService),r=t.get(c.LocaleService),s=t.get(S.SheetsSelectionsService),i=M.deriveStateFromActiveSheet$(e,"",({workbook:o,worksheet:u})=>new R.Observable(a=>R.merge(s.selectionMoveEnd$,new R.Observable(d=>{const v=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id],h=n.onCommandExecuted(f=>{v.includes(f.id)&&d.next(null)});return()=>h.dispose()})).subscribe(()=>{var v,h;const d=s.getCurrentSelections();if(d&&d[0]){const f=d[0].range,g=f.startRow,y=f.startColumn,p=(h=o.getStyles().get((v=u.getCell(g,y))==null?void 0:v.s))==null?void 0:h.n,P=p==null?void 0:p.pattern;let C=r.t("sheet.numfmt.general");if(P){const T=V.filter(D=>typeof D=="object"&&D.pattern).find(D=>m.isPatternEqualWithoutDecimal(P,D.pattern));T&&typeof T=="object"&&T.pattern?C=r.t(T.label):C=r.t("sheet.numfmt.moreFmt")}a.next(C)}})));return{label:ue,id:$.id,tooltip:"sheet.numfmt.title",type:b.MenuItemType.SELECTOR,selections:[{label:{name:me,hoverable:!1}}],value$:i,hidden$:b.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:M.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetSetCellStylePermission,S.WorksheetEditPermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}},ue="sheet.numfmt.moreNumfmtType",me="sheet.numfmt.moreNumfmtType.options",mt=t=>{var r;const e=b.useDependency(c.LocaleService),n=(r=t.value)!=null?r:e.t("sheet.numfmt.general");return l.jsx("span",{className:"more-numfmt-type",children:n})},dt=()=>{const t=b.useDependency(c.ICommandService),e=b.useDependency(c.LocaleService),n=b.useDependency(b.ILayoutService),r=b.useDependency(m.SheetsNumfmtCellContentController),s=b.useDependency(S.SheetsSelectionsService),i=a=>{const d=s.getCurrentLastSelection();if(!d)return;const v=d.range,h=[];c.Range.foreach(v,(f,g)=>{a?h.push({row:f,col:g,pattern:a,type:m.getPatternType(a)}):h.push({row:f,col:g})}),t.executeCommand(m.SetNumfmtCommand.id,{values:h}),n.focus()},o=a=>{if(a===0)i(null);else if(a===V.length-1)t.executeCommand($.id);else{const d=V[a];d.pattern&&i(d.pattern)}},u=1220;return l.jsx("div",{className:"more-numfmt-type-options",children:V.map((a,d)=>a==="|"?l.jsx("div",{className:"line m-t-4",onClick:v=>v.stopPropagation()},d):l.jsxs("div",{className:"option-item m-t-4",onClick:()=>{o(d)},children:[l.jsx("div",{children:e.t(a.label)}),l.jsx("div",{className:"m-l-26",children:a.pattern?m.getPatternPreview(a.pattern||"",u,r.local).result:""})]},d))})},ht={[b.RibbonStartGroup.FORMULAS_INSERT]:{[m.SetCurrencyCommand.id]:{order:4,menuItemFactory:ot},[m.AddDecimalCommand.id]:{order:5,menuItemFactory:ct},[m.SubtractDecimalCommand.id]:{order:6,menuItemFactory:at},[m.SetPercentCommand.id]:{order:7,menuItemFactory:lt},[$.id]:{order:8,menuItemFactory:ut}}};var ft=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,vt=(t,e,n,r)=>{for(var s=r>1?void 0:r?pt(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(s=(r?o(e,n,s):o(s))||s);return r&&s&&ft(e,n,s),s},ie=(t,e)=>(n,r)=>e(n,r,t);let q=class extends c.Disposable{constructor(t,e){super(),this._componentManager=t,this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(ht),this.disposeWithMe(this._componentManager.register(ue,mt)),this.disposeWithMe(this._componentManager.register(me,dt))}};q=vt([ie(0,c.Inject(b.ComponentManager)),ie(1,b.IMenuManagerService)],q);var de=Object.defineProperty,St=Object.getOwnPropertyDescriptor,gt=(t,e,n)=>e in t?de(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_t=(t,e,n,r)=>{for(var s=r>1?void 0:r?St(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(s=(r?o(e,n,s):o(s))||s);return r&&s&&de(e,n,s),s},J=(t,e)=>(n,r)=>e(n,r,t),he=(t,e,n)=>gt(t,typeof e!="symbol"?e+"":e,n);const yt="SHEET_NUMFMT_UI_PLUGIN";exports.UniverSheetsNumfmtUIPlugin=class extends c.Plugin{constructor(e=ne,n,r,s){super(),this._config=e,this._injector=n,this._configService=r,this._renderManagerService=s;const{menu:i,...o}=c.merge({},ne,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(b.UI_PLUGIN_CONFIG_KEY,o)}onStarting(){c.registerDependencies(this._injector,[[k],[B],[L],[q]])}onRendered(){this._registerRenderModules(),c.touchDependencies(this._injector,[[k],[B],[q]])}_registerRenderModules(){[[Q]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,n))})}};he(exports.UniverSheetsNumfmtUIPlugin,"pluginName",yt);he(exports.UniverSheetsNumfmtUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtUIPlugin=_t([c.DependentOn(M.UniverSheetsUIPlugin,m.UniverSheetsNumfmtPlugin),J(1,c.Inject(c.Injector)),J(2,c.IConfigService),J(3,oe.IRenderManagerService)],exports.UniverSheetsNumfmtUIPlugin);
package/lib/es/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  var dt = Object.defineProperty;
2
2
  var ht = (t, e, n) => e in t ? dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
3
  var J = (t, e, n) => ht(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { Inject as S, LocaleService as P, Disposable as oe, isRealNum as ft, CommandType as xe, ILocalStorageService as ke, useDependency as C, numfmt as Q, UniverInstanceType as T, CellValueType as L, Range as je, toDisposable as ge, DisposableCollection as pt, InterceptorEffectEnum as Ue, ThemeService as vt, IUniverInstanceService as Se, ICommandService as be, Injector as Be, Optional as gt, DependentOn as _t, Plugin as St, merge as bt, registerDependencies as yt, touchDependencies as Ct, IConfigService as It } from "@univerjs/core";
4
+ import { Inject as S, LocaleService as P, Disposable as oe, isRealNum as ft, CommandType as xe, ILocalStorageService as ke, numfmt as Q, UniverInstanceType as T, CellValueType as L, Range as je, toDisposable as ge, DisposableCollection as pt, InterceptorEffectEnum as Ue, ThemeService as vt, IUniverInstanceService as Se, ICommandService as be, Injector as Be, Optional as gt, DependentOn as _t, Plugin as St, merge as bt, registerDependencies as yt, touchDependencies as Ct, IConfigService as It } from "@univerjs/core";
5
5
  import { IRenderManagerService as We } from "@univerjs/engine-render";
6
6
  import { currencySymbols as $e, getDecimalFromPattern as te, getCurrencyType as W, setPatternDecimal as O, getCurrencyFormatOptions as ue, isPatternEqualWithoutDecimal as ce, CURRENCYFORMAT as Nt, DATEFMTLISG as Et, NUMBERFORMAT as Tt, getDateFormatOptions as Ve, getNumberFormatOptions as Ge, isPatternHasDecimal as Pt, getPatternType as ne, SetNumfmtCommand as Ke, getPatternPreviewIgnoreGeneral as Mt, SheetsNumfmtCellContentController as Ze, MenuCurrencyService as wt, countryCurrencyMap as D, SetCurrencyCommand as ze, AddDecimalCommand as Ye, SubtractDecimalCommand as qe, SetPercentCommand as Xe, getPatternPreview as Ot, UniverSheetsNumfmtPlugin as Rt } from "@univerjs/sheets-numfmt";
7
7
  import { HoverManagerService as Ut, CellAlertManagerService as $t, CellAlertType as Dt, SheetSkeletonManagerService as Ft, IEditorBridgeService as Lt, getCurrentRangeDisable$ as V, deriveStateFromActiveSheet$ as Ht, UniverSheetsUIPlugin as At } from "@univerjs/sheets-ui";
8
- import { IZenZoneService as xt, ComponentManager as Je, ISidebarService as kt, MenuItemType as G, getMenuHiddenObservable as K, ILayoutService as jt, RibbonStartGroup as Bt, IMenuManagerService as Wt, UI_PLUGIN_CONFIG_KEY as Vt } from "@univerjs/ui";
8
+ import { IZenZoneService as xt, useDependency as C, ComponentManager as Je, ISidebarService as kt, MenuItemType as G, getMenuHiddenObservable as K, ILayoutService as jt, RibbonStartGroup as Bt, IMenuManagerService as Wt, UI_PLUGIN_CONFIG_KEY as Vt } from "@univerjs/ui";
9
9
  import { FormulaDataModel as Gt } from "@univerjs/engine-formula";
10
10
  import { DEFAULT_TEXT_FORMAT as ye } from "@univerjs/engine-numfmt";
11
11
  import { INumfmtService as Ce, INTERCEPTOR_POINT as Kt, RemoveNumfmtMutation as Ie, SetNumfmtMutation as Ne, SheetInterceptorService as Qe, SheetsSelectionsService as Ee, BEFORE_CELL_EDIT as Zt, AFTER_CELL_EDIT as zt, SetRangeValuesCommand as Yt, transformCellsToRange as qt, factorySetNumfmtUndoMutation as Xt, factoryRemoveNumfmtUndoMutation as Jt, WorkbookEditablePermission as Z, WorksheetEditPermission as z, WorksheetSetCellStylePermission as Y, RangeProtectionPermissionEditPoint as q } from "@univerjs/sheets";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2023-present DreamNum Inc.
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2023-present DreamNum Inc.
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2023-present DreamNum Inc.
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2023-present DreamNum Inc.
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2023-present DreamNum Inc.
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(C,s){typeof exports=="object"&&typeof module<"u"?s(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"],s):(C=typeof globalThis<"u"?globalThis:C||self,s(C.UniverSheetsNumfmtUi={},C.UniverCore,C.UniverEngineRender,C.UniverSheetsNumfmt,C.UniverSheetsUi,C.UniverUi,C.UniverEngineFormula,C.UniverEngineNumfmt,C.UniverSheets,C.rxjs,C.rxjs.operators,C.React,C.React,C.UniverDesign))})(this,function(C,s,F,m,E,I,ve,Z,S,N,x,l,y,M){"use strict";var ft=Object.defineProperty;var vt=(C,s,F)=>s in C?ft(C,s,{enumerable:!0,configurable:!0,writable:!0,value:F}):C[s]=F;var K=(C,s,F)=>vt(C,typeof s!="symbol"?s+"":s,F);const ie={};var he=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,ge=(t,e,r,n)=>{for(var i=n>1?void 0:n?Se(e,r):e,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(e,r,i):o(i))||i);return n&&i&&he(e,r,i),i},L=(t,e)=>(r,n)=>e(r,n,t);const z="SHEET_NUMFMT_ALERT";let Y=class extends s.Disposable{constructor(t,e,r,n,i,a,o){super(),this._context=t,this._hoverManagerService=e,this._cellAlertManagerService=r,this._localeService=n,this._formulaDataModel=i,this._zenZoneService=a,this._numfmtService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(N.debounceTime(100)).subscribe(t=>{var e;if(t){const r=t.location,n=this._context.unit,i=n.getActiveSheet();if(!i)return;const a=r.unitId,o=r.subUnitId;let u;const c=i.getCell(r.row,r.col);if(c!=null&&c.s){const d=n.getStyles().get(c.s);d!=null&&d.n&&(u=d.n)}if(u||(u=this._numfmtService.getValue(a,o,r.row,r.col)),!u){this._hideAlert();return}if(u.pattern===Z.DEFAULT_TEXT_FORMAT&&(c!=null&&c.v)&&s.isRealNum(c.v)){const d=this._cellAlertManagerService.currentAlert.get(z),h=(e=d==null?void 0:d.alert)==null?void 0:e.location;if(h&&h.row===r.row&&h.col===r.col&&h.subUnitId===r.subUnitId&&h.unitId===r.unitId)return;this._cellAlertManagerService.showAlert({type:E.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(t=>{t&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(z)}};Y=ge([L(1,s.Inject(E.HoverManagerService)),L(2,s.Inject(E.CellAlertManagerService)),L(3,s.Inject(s.LocaleService)),L(4,s.Inject(ve.FormulaDataModel)),L(5,I.IZenZoneService),L(6,s.Inject(S.INumfmtService))],Y);const X={id:"sheet.operation.close.numfmt.panel",type:s.CommandType.OPERATION,handler:()=>!0},H={id:"sheet.operation.open.numfmt.panel",type:s.CommandType.OPERATION,handler:t=>(t.get(A).openPanel(),!0)};var ye=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ce=(t,e,r,n)=>{for(var i=n>1?void 0:n?_e(e,r):e,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(e,r,i):o(i))||i);return n&&i&&ye(e,r,i),i},be=(t,e)=>(r,n)=>e(r,n,t);const J=y.createContext([]);let k=class{constructor(t){this._localStorageService=t}_getKey(t){return`userHabitController_${t}`}async addHabit(t,e){const r=this._getKey(t);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,e)})}markHabit(t,e){const r=this._getKey(t);this._localStorageService.getItem(r).then(n=>{if(n){const i=n.findIndex(a=>a===e);i>-1&&n.splice(i,1),n.unshift(e),this._localStorageService.setItem(r,n)}})}async getHabit(t,e){const r=this._getKey(t),n=await this._localStorageService.getItem(r);if(e&&n){const i=n.map((a,o,u)=>{const c=u.length;return{value:a,priority:c-o}});return e.sort((a,o)=>{var d,h;const u=((d=i.find(p=>p.value===a))==null?void 0:d.priority)||-1;return(((h=i.find(p=>p.value===o))==null?void 0:h.priority)||-1)-u})}return n||[]}deleteHabit(t){this._localStorageService.removeItem(t)}};k=Ce([be(0,s.Inject(s.ILocalStorageService))],k);const se="numfmtCurrency",Ie=t=>{const e=s.useDependency(k),[r,n]=y.useState(m.currencySymbols);return y.useEffect(()=>{e.addHabit("numfmtCurrency",[]).then(()=>{e.getHabit(se,[...m.currencySymbols]).then(a=>{n(a),t(a)})})},[]),{userHabitCurrency:r,mark:a=>{e.markHabit(se,a)}}},Te=()=>{const t=y.useRef([]),[e,r]=y.useState({});return y.useEffect(()=>{t.current.forEach(i=>{i()}),t.current=[]},[e]),i=>{t.current.push(i),r({})}},Pe=t=>!!m.getCurrencyType(t)&&t.startsWith("_("),Ee=t=>{const{defaultPattern:e,action:r,onChange:n}=t,[i,a]=y.useState(()=>m.getDecimalFromPattern(e||"",2)),o=y.useContext(J),[u,c]=y.useState(()=>m.getCurrencyType(e)||o[0]),d=y.useMemo(()=>o.map(_=>({label:_,value:_})),[]),p=s.useDependency(s.LocaleService).t;r.current=()=>m.setPatternDecimal(`_("${u}"* #,##0${i>0?".0":""}_)`,i);const f=_=>{c(_),n(m.setPatternDecimal(`_("${_}"* #,##0${i>0?".0":""}_)`,i))},g=_=>{const v=_||0;a(v),n(m.setPatternDecimal(`_("${u}"* #,##0${v>0?".0":""}_)`,v))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:p("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(M.InputNumber,{value:i,max:20,min:0,onChange:g})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:p("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(M.Select,{onChange:f,options:d,value:u})})]})]}),l.jsx("div",{className:"describe m-t-14",children:p("sheet.numfmt.accountingDes")})]})},Me=t=>!!m.getCurrencyType(t)&&!t.startsWith("_("),De=t=>{const r=s.useDependency(s.LocaleService).t,n=y.useContext(J),[i,a]=y.useState(()=>m.getCurrencyType(t.defaultPattern)||n[0]),[o,u]=y.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",2)),[c,d]=y.useState(()=>{var b;const v=m.getCurrencyFormatOptions(i);return((b=v.find(O=>m.isPatternEqualWithoutDecimal(O.value,t.defaultPattern)))==null?void 0:b.value)||v[0].value}),h=y.useMemo(()=>m.getCurrencyFormatOptions(i),[i]),p=y.useMemo(()=>n.map(v=>({label:v,value:v})),[n]);t.action.current=()=>m.setPatternDecimal(c,o);const f=v=>{if(v===void 0)return;a(v);const P=m.getCurrencyFormatOptions(v)[0].value;d(P),t.onChange(m.setPatternDecimal(P,o))},g=v=>{v!==void 0&&(d(v),t.onChange(m.setPatternDecimal(v,o)))},_=v=>{u(v||0),t.onChange(m.setPatternDecimal(c,v||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(M.InputNumber,{value:o,max:20,min:0,onChange:_})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(M.Select,{onChange:f,options:p,value:i})})]})]}),l.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.SelectList,{onChange:g,options:h,value:c})}),l.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})};var D=function(){return D=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},D.apply(this,arguments)},Oe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},ae=y.forwardRef(function(t,e){var r=t.icon,n=t.id,i=t.className,a=t.extend,o=Oe(t,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=y.useRef("_".concat(we()));return oe(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},D({ref:e,className:u},o),a)});function oe(t,e,r,n,i){return y.createElement(t.tag,D(D({key:e},Ue(t,r,i)),n),(Ne(t,r).children||[]).map(function(a,o){return oe(a,"".concat(e,"-").concat(t.tag,"-").concat(o),r,void 0,i)}))}function Ue(t,e,r){var n=D({},t.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var i=e.defIds;return!i||i.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],u=a[1];typeof u=="string"&&(n[o]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Ne(t,e){var r,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?D(D({},t),{children:t.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+e.idSuffix})}):i})}):t}function we(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var Fe={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(t,e){return y.createElement(ae,Object.assign({},t,{id:"check-mark-single",ref:e,icon:Fe}))});ce.displayName="CheckMarkSingle";const j={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 je(t){const{defaultPattern:e,action:r,onChange:n}=t,i=s.useDependency(k),a=s.useDependency(s.ILocalStorageService),o=s.useDependency(s.LocaleService),[u,c]=y.useState(e);r.current=()=>(i.markHabit(Q,u),a.getItem(ee).then((g=[])=>{const _=[...new Set([u,...g||[]])].splice(0,10).filter(v=>!!v);a.setItem(ee,_)}),u);const[d,h]=y.useState([]);y.useEffect(()=>{a.getItem(ee).then(g=>{const _=[...m.CURRENCYFORMAT.map(v=>v.suffix("$")),...m.DATEFMTLISG.map(v=>v.suffix),...m.NUMBERFORMAT.map(v=>v.suffix)];_.push(...g||[]),i.addHabit(Q,[]).finally(()=>{i.getHabit(Q,_).then(v=>{h([...new Set(v)])})})})},[]);const p=g=>{c(g),n(g)},f=()=>{n(u)};return l.jsxs("div",{className:j.customFormat,children:[l.jsx("div",{className:j.customFormatTitle,children:o.t("sheet.numfmt.customFormat")}),l.jsx(M.Input,{placeholder:o.t("sheet.numfmt.customFormat"),onBlur:f,value:u,onChange:c,className:j.customFormatInput}),l.jsx("div",{className:j.customFormatHistoryList,children:d.map(g=>l.jsxs("div",{onClick:()=>p(g),className:j.customFormatHistoryListItem,children:[l.jsx("div",{className:j.customFormatHistoryListItemIconWrap,children:u===g&&l.jsx(ce,{})}),l.jsx("div",{children:g})]},g))}),l.jsx("div",{className:j.customFormatDes,children:o.t("sheet.numfmt.customFormatDes")})]})}const Le=t=>{const e=s.numfmt.getInfo(t);return m.getDateFormatOptions().map(r=>r.value).includes(t)||["date","datetime","time"].includes(e.type)},$e=t=>{const e=y.useMemo(m.getDateFormatOptions,[]),n=s.useDependency(s.LocaleService).t,[i,a]=y.useState(()=>{if(t.defaultPattern){const u=e.find(c=>c.value===t.defaultPattern);if(u)return u.value}return e[0].value});t.action.current=()=>i;const o=u=>{u!==void 0&&(a(u),t.onChange(u))};return l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.dateType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.SelectList,{value:i,options:e,onChange:o})}),l.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},He=t=>!t,ke=t=>{const r=s.useDependency(s.LocaleService).t;return t.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},Ae=t=>m.getNumberFormatOptions().some(e=>m.isPatternEqualWithoutDecimal(e.value,t)),Re=t=>{const e=s.useDependency(s.LocaleService),r=y.useMemo(m.getNumberFormatOptions,[]),[n,i]=y.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",0)),[a,o]=y.useState(()=>{const p=r.find(f=>m.isPatternEqualWithoutDecimal(f.value,t.defaultPattern||""));return(p==null?void 0:p.value)||r[0].value}),u=y.useMemo(()=>m.setPatternDecimal(a,Number(n||0)),[a,n]),c=y.useMemo(()=>!m.isPatternHasDecimal(a),[a]),d=p=>{i(p||0),t.onChange(m.setPatternDecimal(a,Number(p||0)))},h=p=>{p!==void 0&&(i(m.getDecimalFromPattern(p,0)),o(p),t.onChange(p))};return t.action.current=()=>u,l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:e.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.InputNumber,{disabled:c,value:n,max:20,min:0,onChange:d})}),l.jsxs("div",{className:"m-t-16 label",children:[" ",e.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.SelectList,{onChange:h,options:r,value:a})}),l.jsx("div",{className:"describe m-t-14",children:e.t("sheet.numfmt.thousandthPercentileDes")})]})},We=t=>{const{defaultValue:e,defaultPattern:r,row:n,col:i}=t.value,a=s.useDependency(s.LocaleService),o=y.useRef(()=>""),u=a.t,c=Te(),d=y.useMemo(()=>[{label:"sheet.numfmt.general",component:ke},{label:"sheet.numfmt.accounting",component:Ee},{label:"sheet.numfmt.currency",component:De},{label:"sheet.numfmt.date",component:$e},{label:"sheet.numfmt.thousandthPercentile",component:Re},{label:"sheet.numfmt.customFormat",component:je}].map(T=>({...T,label:u(T.label)})),[]),[h,p]=y.useState(b),[f,g]=y.useState(()=>`${n}_${i}`),{mark:_,userHabitCurrency:v}=Ie(()=>g(`${n}_${i}_userCurrency'`)),P=y.useMemo(()=>{var T;return(T=d.find($=>$.label===h))==null?void 0:T.component},[h]);function b(){return[He,Pe,Me,Le,Ae].reduce(($,dt,pt)=>$||(dt(r)?d[pt].label:""),"")||d[0].label}const O=d.map(T=>({label:T.label,value:T.label})),w=T=>{p(T),c(()=>t.onChange({type:"change",value:o.current()||""}))},G=T=>{t.onChange({type:"change",value:T})},ne=()=>{const T=o.current()||"",$=m.getCurrencyType(T);$&&_($),t.onChange({type:"confirm",value:T})},W=()=>{t.onChange({type:"cancel",value:""})},re={onChange:G,defaultValue:e,defaultPattern:r,action:o};return y.useEffect(()=>{p(b()),g(`${n}_${i}`)},[n,i]),l.jsxs("div",{className:"numfmt-panel p-b-20",children:[l.jsxs("div",{children:[l.jsx("div",{className:"label m-t-14",children:u("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.Select,{onChange:w,options:O,value:h,style:{width:"100%"}})}),l.jsx("div",{children:P&&l.jsx(J.Provider,{value:v,children:y.createElement(P,{...re,key:f})})})]}),l.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[l.jsx(M.Button,{size:"small",onClick:W,className:"m-r-12",children:u("sheet.numfmt.cancel")}),l.jsx(M.Button,{type:"primary",size:"small",onClick:ne,children:u("sheet.numfmt.confirm")})]})]})};var xe=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,Be=(t,e,r,n)=>{for(var i=n>1?void 0:n?Ve(e,r):e,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(e,r,i):o(i))||i);return n&&i&&xe(e,r,i),i},U=(t,e)=>(r,n)=>e(r,n,t);const le="SHEET_NUMFMT_PANEL";let A=class extends s.Disposable{constructor(e,r,n,i,a,o,u,c,d,h,p){super();K(this,"_previewPattern","");K(this,"_sidebarDisposable",null);this._sheetInterceptorService=e,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=a,this._renderManagerService=o,this._numfmtService=u,this._componentManager=c,this._sidebarService=d,this._localeService=h,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 P;const e=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,a=this._numfmtService,o=this._localeService,c=(((P=r.getCurrentSelections())==null?void 0:P.map(b=>b.range))||[])[0];if(!c)return!1;const d=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),h=d.getActiveSheet();if(!h)return!1;const p=h.getCellRaw(c.startRow,c.startColumn),f=a.getValue(d.getUnitId(),h.getSheetId(),c.startRow,c.startColumn);let g="";f&&(g=f.pattern);const _=(p==null?void 0:p.t)===s.CellValueType.NUMBER?p.v:12345678,v={onChange:b=>{var O;if(b.type==="change")this._previewPattern=b.value,this._forceUpdate();else if(b.type==="confirm"){const w=((O=r.getCurrentSelections())==null?void 0:O.map(W=>W.range))||[],G={values:[]},ne=m.getPatternType(b.value);w.forEach(W=>{s.Range.foreach(W,(re,T)=>{G.values.push({row:re,col:T,pattern:b.value,type:ne})})}),n.executeCommand(m.SetNumfmtCommand.id,G),e.close()}else b.type==="cancel"&&e.close()},value:{defaultPattern:g,defaultValue:_,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=e.open({header:{title:o.t("sheet.numfmt.title")},children:{label:le,...v},onClose:()=>{this._forceUpdate(),n.executeCommand(X.id)}}),!0}_forceUpdate(e){var n;const r=this._renderManagerService.getRenderById(e!=null?e:this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(E.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[H,X].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initPanel(){this._componentManager.register(le,We)}_initRealTimeRenderingInterceptor(){const e=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([e,this._selectionManagerService.selectionMoveEnd$.pipe(x.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(s.toDisposable(r.pipe(x.switchMap(([n,i])=>new N.Observable(a=>{const o=new s.DisposableCollection;return n&&i.length&&a.next({selectionRanges:i,disposableCollection:o}),()=>{o.dispose()}})),x.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var o,u;const a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:s.InterceptorEffectEnum.Value|s.InterceptorEffectEnum.Style,handler:(c,d,h)=>{const{row:p,col:f}=d,g=h(c)||{};if(i.find(_=>_.startColumn<=f&&_.endColumn>=f&&_.startRow<=p&&_.endRow>=p)){const _=d.worksheet.getCellRaw(p,f),v=_==null?void 0:_.v,P=_==null?void 0:_.t;if(v==null||P!==s.CellValueType.NUMBER||this._previewPattern===null)return g;const b=m.getPatternPreviewIgnoreGeneral(this._previewPattern,v,this._sheetsNumfmtCellContentController.local);if(b.color){const w=this._themeService.getCurrentTheme()[`${b.color}500`];return{...g,v:b.result,t:s.CellValueType.STRING,s:{cl:{rgb:w}}}}return{...g,v:b.result,t:s.CellValueType.STRING}}return g}})),(u=(o=this._renderManagerService.getRenderById(a.getUnitId()))==null?void 0:o.mainComponent)==null||u.makeDirty()})))}_commandExecutedListener(){const e=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id];this.disposeWithMe(new N.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(e.includes(i.id)){const a=i.params;r.next(a.unitId)}});return()=>n.dispose()}).pipe(x.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{var r;e||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};A=Be([U(0,s.Inject(S.SheetInterceptorService)),U(1,s.Inject(s.ThemeService)),U(2,s.IUniverInstanceService),U(3,s.ICommandService),U(4,s.Inject(S.SheetsSelectionsService)),U(5,F.IRenderManagerService),U(6,S.INumfmtService),U(7,s.Inject(I.ComponentManager)),U(8,I.ISidebarService),U(9,s.Inject(s.LocaleService)),U(10,s.Inject(m.SheetsNumfmtCellContentController))],A);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Ke=(t,e,r,n)=>{for(var i=n>1?void 0:n?Ge(e,r):e,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(e,r,i):o(i))||i);return n&&i&&qe(e,r,i),i},R=(t,e)=>(r,n)=>e(r,n,t);const Ze=()=>{let t=[];return{add:(i,a,o,u,c)=>t.push({unitId:i,subUnitId:a,row:o,col:u,value:c}),getEffects:()=>t,clean:()=>{t=[]}}};let V=class extends s.Disposable{constructor(e,r,n,i,a){super();K(this,"_collectEffectMutation",Ze());this._sheetInterceptorService=e,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=a,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.BEFORE_CELL_EDIT,{handler:(e,r,n)=>{const i=r.row,a=r.col,o=this._numfmtService.getValue(r.unitId,r.subUnitId,i,a);if(o)switch(m.getPatternType(o.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(e)}return n(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.AFTER_CELL_EDIT,{handler:(e,r,n)=>{var h,p,f,g;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),a=(h=i&&m.getPatternType(i.pattern))!=null?h:"",o=()=>{i&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(e!=null&&e.v)&&!(e!=null&&e.p)||(i==null?void 0:i.pattern)===Z.DEFAULT_TEXT_FORMAT||e.t===s.CellValueType.FORCE_STRING)return n(e);const u=(p=e.p)==null?void 0:p.body,c=(g=(f=e==null?void 0:e.p)==null?void 0:f.body)!=null&&g.dataStream?e.p.body.dataStream.replace(/\r\n$/,""):String(e.v),d=s.numfmt.parseDate(c)||s.numfmt.parseTime(c)||s.numfmt.parseNumber(c);if(u)if(Ye(u)){const{dataStream:_}=u,v=_.replace(/\r\n$/,""),P=Number(v);if(Number.isNaN(P)&&!d)return n(e)}else return n(e);if(d){d.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:d.z});const _=Number(d.v);return n({...e,p:void 0,v:_,t:s.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(a)||!ze(c))&&o();return n(e)}})))}_initInterceptorCommands(){const e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case S.SetRangeValuesCommand.id:{const i=e._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),a=i.getUnitId(),o=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!o)return{redos:[],undos:[]};const u=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!u.length)return{redos:[],undos:[]};const c=u.filter(f=>{var g;return!!((g=f.value)!=null&&g.pattern)}).map(f=>({row:f.row,col:f.col,pattern:f.value.pattern})),d=u.filter(f=>{var g;return!((g=f.value)!=null&&g.pattern)}).map(f=>({startRow:f.row,endColumn:f.col,startColumn:f.col,endRow:f.row})),h=[],p=[];if(c.length){const f={id:S.SetNumfmtMutation.id,params:S.transformCellsToRange(a,o,c)};h.push(f),p.push(...S.factorySetNumfmtUndoMutation(e._injector,f.params))}if(d.length){const f={id:S.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:o,ranges:d}};h.push(f),p.push(...S.factoryRemoveNumfmtUndoMutation(e._injector,f.params))}return{redos:h,undos:p.reverse()}}}return{redos:[],undos:[]}}}))}};V=Ke([R(0,s.Inject(S.SheetInterceptorService)),R(1,s.Inject(S.INumfmtService)),R(2,s.Inject(s.IUniverInstanceService)),R(3,s.Inject(s.Injector)),R(4,s.Optional(E.IEditorBridgeService))],V);function ze(t){return/^-?\d+(\.\d+)?$/.test(t)}function Ye(t){const{textRuns:e=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=t,a=["va"];return!(e.some(o=>!!(o.ts&&Object.keys(o.ts).some(c=>a.includes(c))))||r.some(o=>o.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const B=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:Z.DEFAULT_TEXT_FORMAT},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Xe=t=>({icon:new N.Observable(e=>{const r=t.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 e.next(n(i)),r.currencySymbol$.subscribe(a=>{const o=m.countryCurrencyMap[a]||"$";e.next(n(o))})}),id:m.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Je=t=>({icon:"AddDigitsSingle",id:m.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Qe=t=>({icon:"ReduceDigitsSingle",id:m.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),et=t=>({icon:"PercentSingle",id:m.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:I.MenuItemType.BUTTON,hidden$:I.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),tt=t=>{const e=t.get(s.IUniverInstanceService),r=t.get(s.ICommandService),n=t.get(s.LocaleService),i=t.get(S.SheetsSelectionsService),a=E.deriveStateFromActiveSheet$(e,"",({workbook:o,worksheet:u})=>new N.Observable(c=>N.merge(i.selectionMoveEnd$,new N.Observable(d=>{const h=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id],p=r.onCommandExecuted(f=>{h.includes(f.id)&&d.next(null)});return()=>p.dispose()})).subscribe(()=>{var h,p;const d=i.getCurrentSelections();if(d&&d[0]){const f=d[0].range,g=f.startRow,_=f.startColumn,v=(p=o.getStyles().get((h=u.getCell(g,_))==null?void 0:h.s))==null?void 0:p.n,P=v==null?void 0:v.pattern;let b=n.t("sheet.numfmt.general");if(P){const O=B.filter(w=>typeof w=="object"&&w.pattern).find(w=>m.isPatternEqualWithoutDecimal(P,w.pattern));O&&typeof O=="object"&&O.pattern?b=n.t(O.label):b=n.t("sheet.numfmt.moreFmt")}c.next(b)}})));return{label:ue,id:H.id,tooltip:"sheet.numfmt.title",type:I.MenuItemType.SELECTOR,selections:[{label:{name:me,hoverable:!1}}],value$:a,hidden$:I.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetSetCellStylePermission,S.WorksheetEditPermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}},ue="sheet.numfmt.moreNumfmtType",me="sheet.numfmt.moreNumfmtType.options",nt=t=>{var n;const e=s.useDependency(s.LocaleService),r=(n=t.value)!=null?n:e.t("sheet.numfmt.general");return l.jsx("span",{className:"more-numfmt-type",children:r})},rt=()=>{const t=s.useDependency(s.ICommandService),e=s.useDependency(s.LocaleService),r=s.useDependency(I.ILayoutService),n=s.useDependency(m.SheetsNumfmtCellContentController),i=s.useDependency(S.SheetsSelectionsService),a=c=>{const d=i.getCurrentLastSelection();if(!d)return;const h=d.range,p=[];s.Range.foreach(h,(f,g)=>{c?p.push({row:f,col:g,pattern:c,type:m.getPatternType(c)}):p.push({row:f,col:g})}),t.executeCommand(m.SetNumfmtCommand.id,{values:p}),r.focus()},o=c=>{if(c===0)a(null);else if(c===B.length-1)t.executeCommand(H.id);else{const d=B[c];d.pattern&&a(d.pattern)}},u=1220;return l.jsx("div",{className:"more-numfmt-type-options",children:B.map((c,d)=>c==="|"?l.jsx("div",{className:"line m-t-4",onClick:h=>h.stopPropagation()},d):l.jsxs("div",{className:"option-item m-t-4",onClick:()=>{o(d)},children:[l.jsx("div",{children:e.t(c.label)}),l.jsx("div",{className:"m-l-26",children:c.pattern?m.getPatternPreview(c.pattern||"",u,n.local).result:""})]},d))})},it={[I.RibbonStartGroup.FORMULAS_INSERT]:{[m.SetCurrencyCommand.id]:{order:4,menuItemFactory:Xe},[m.AddDecimalCommand.id]:{order:5,menuItemFactory:Je},[m.SubtractDecimalCommand.id]:{order:6,menuItemFactory:Qe},[m.SetPercentCommand.id]:{order:7,menuItemFactory:et},[H.id]:{order:8,menuItemFactory:tt}}};var st=Object.defineProperty,at=Object.getOwnPropertyDescriptor,ot=(t,e,r,n)=>{for(var i=n>1?void 0:n?at(e,r):e,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(e,r,i):o(i))||i);return n&&i&&st(e,r,i),i},de=(t,e)=>(r,n)=>e(r,n,t);let q=class extends s.Disposable{constructor(t,e){super(),this._componentManager=t,this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(it),this.disposeWithMe(this._componentManager.register(ue,nt)),this.disposeWithMe(this._componentManager.register(me,rt))}};q=ot([de(0,s.Inject(I.ComponentManager)),de(1,I.IMenuManagerService)],q);var pe=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,lt=(t,e,r)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e,r,n)=>{for(var i=n>1?void 0:n?ct(e,r):e,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(e,r,i):o(i))||i);return n&&i&&pe(e,r,i),i},te=(t,e)=>(r,n)=>e(r,n,t),fe=(t,e,r)=>lt(t,typeof e!="symbol"?e+"":e,r);const mt="SHEET_NUMFMT_UI_PLUGIN";C.UniverSheetsNumfmtUIPlugin=class extends s.Plugin{constructor(e=ie,r,n,i){super(),this._config=e,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:a,...o}=s.merge({},ie,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(I.UI_PLUGIN_CONFIG_KEY,o)}onStarting(){s.registerDependencies(this._injector,[[A],[V],[k],[q]])}onRendered(){this._registerRenderModules(),s.touchDependencies(this._injector,[[A],[V],[q]])}_registerRenderModules(){[[Y]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,r))})}},fe(C.UniverSheetsNumfmtUIPlugin,"pluginName",mt),fe(C.UniverSheetsNumfmtUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),C.UniverSheetsNumfmtUIPlugin=ut([s.DependentOn(E.UniverSheetsUIPlugin,m.UniverSheetsNumfmtPlugin),te(1,s.Inject(s.Injector)),te(2,s.IConfigService),te(3,F.IRenderManagerService)],C.UniverSheetsNumfmtUIPlugin),Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
1
+ (function(b,s){typeof exports=="object"&&typeof module<"u"?s(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"],s):(b=typeof globalThis<"u"?globalThis:b||self,s(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,s,F,m,E,C,ve,Z,S,N,x,l,y,M){"use strict";var ft=Object.defineProperty;var vt=(b,s,F)=>s in b?ft(b,s,{enumerable:!0,configurable:!0,writable:!0,value:F}):b[s]=F;var K=(b,s,F)=>vt(b,typeof s!="symbol"?s+"":s,F);const ie={};var he=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,ge=(t,e,r,n)=>{for(var i=n>1?void 0:n?Se(e,r):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(i=(n?a(e,r,i):a(i))||i);return n&&i&&he(e,r,i),i},L=(t,e)=>(r,n)=>e(r,n,t);const z="SHEET_NUMFMT_ALERT";let Y=class extends s.Disposable{constructor(t,e,r,n,i,o,a){super(),this._context=t,this._hoverManagerService=e,this._cellAlertManagerService=r,this._localeService=n,this._formulaDataModel=i,this._zenZoneService=o,this._numfmtService=a,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(N.debounceTime(100)).subscribe(t=>{var e;if(t){const r=t.location,n=this._context.unit,i=n.getActiveSheet();if(!i)return;const o=r.unitId,a=r.subUnitId;let u;const c=i.getCell(r.row,r.col);if(c!=null&&c.s){const d=n.getStyles().get(c.s);d!=null&&d.n&&(u=d.n)}if(u||(u=this._numfmtService.getValue(o,a,r.row,r.col)),!u){this._hideAlert();return}if(u.pattern===Z.DEFAULT_TEXT_FORMAT&&(c!=null&&c.v)&&s.isRealNum(c.v)){const d=this._cellAlertManagerService.currentAlert.get(z),h=(e=d==null?void 0:d.alert)==null?void 0:e.location;if(h&&h.row===r.row&&h.col===r.col&&h.subUnitId===r.subUnitId&&h.unitId===r.unitId)return;this._cellAlertManagerService.showAlert({type:E.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(t=>{t&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(z)}};Y=ge([L(1,s.Inject(E.HoverManagerService)),L(2,s.Inject(E.CellAlertManagerService)),L(3,s.Inject(s.LocaleService)),L(4,s.Inject(ve.FormulaDataModel)),L(5,C.IZenZoneService),L(6,s.Inject(S.INumfmtService))],Y);const X={id:"sheet.operation.close.numfmt.panel",type:s.CommandType.OPERATION,handler:()=>!0},H={id:"sheet.operation.open.numfmt.panel",type:s.CommandType.OPERATION,handler:t=>(t.get(A).openPanel(),!0)};var ye=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ce=(t,e,r,n)=>{for(var i=n>1?void 0:n?_e(e,r):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(i=(n?a(e,r,i):a(i))||i);return n&&i&&ye(e,r,i),i},be=(t,e)=>(r,n)=>e(r,n,t);const J=y.createContext([]);let k=class{constructor(t){this._localStorageService=t}_getKey(t){return`userHabitController_${t}`}async addHabit(t,e){const r=this._getKey(t);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,e)})}markHabit(t,e){const r=this._getKey(t);this._localStorageService.getItem(r).then(n=>{if(n){const i=n.findIndex(o=>o===e);i>-1&&n.splice(i,1),n.unshift(e),this._localStorageService.setItem(r,n)}})}async getHabit(t,e){const r=this._getKey(t),n=await this._localStorageService.getItem(r);if(e&&n){const i=n.map((o,a,u)=>{const c=u.length;return{value:o,priority:c-a}});return e.sort((o,a)=>{var d,h;const u=((d=i.find(p=>p.value===o))==null?void 0:d.priority)||-1;return(((h=i.find(p=>p.value===a))==null?void 0:h.priority)||-1)-u})}return n||[]}deleteHabit(t){this._localStorageService.removeItem(t)}};k=Ce([be(0,s.Inject(s.ILocalStorageService))],k);const oe="numfmtCurrency",Ie=t=>{const e=C.useDependency(k),[r,n]=y.useState(m.currencySymbols);return y.useEffect(()=>{e.addHabit("numfmtCurrency",[]).then(()=>{e.getHabit(oe,[...m.currencySymbols]).then(o=>{n(o),t(o)})})},[]),{userHabitCurrency:r,mark:o=>{e.markHabit(oe,o)}}},Te=()=>{const t=y.useRef([]),[e,r]=y.useState({});return y.useEffect(()=>{t.current.forEach(i=>{i()}),t.current=[]},[e]),i=>{t.current.push(i),r({})}},Pe=t=>!!m.getCurrencyType(t)&&t.startsWith("_("),Ee=t=>{const{defaultPattern:e,action:r,onChange:n}=t,[i,o]=y.useState(()=>m.getDecimalFromPattern(e||"",2)),a=y.useContext(J),[u,c]=y.useState(()=>m.getCurrencyType(e)||a[0]),d=y.useMemo(()=>a.map(_=>({label:_,value:_})),[]),p=C.useDependency(s.LocaleService).t;r.current=()=>m.setPatternDecimal(`_("${u}"* #,##0${i>0?".0":""}_)`,i);const f=_=>{c(_),n(m.setPatternDecimal(`_("${_}"* #,##0${i>0?".0":""}_)`,i))},g=_=>{const v=_||0;o(v),n(m.setPatternDecimal(`_("${u}"* #,##0${v>0?".0":""}_)`,v))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:p("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(M.InputNumber,{value:i,max:20,min:0,onChange:g})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:p("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(M.Select,{onChange:f,options:d,value:u})})]})]}),l.jsx("div",{className:"describe m-t-14",children:p("sheet.numfmt.accountingDes")})]})},Me=t=>!!m.getCurrencyType(t)&&!t.startsWith("_("),De=t=>{const r=C.useDependency(s.LocaleService).t,n=y.useContext(J),[i,o]=y.useState(()=>m.getCurrencyType(t.defaultPattern)||n[0]),[a,u]=y.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",2)),[c,d]=y.useState(()=>{var I;const v=m.getCurrencyFormatOptions(i);return((I=v.find(O=>m.isPatternEqualWithoutDecimal(O.value,t.defaultPattern)))==null?void 0:I.value)||v[0].value}),h=y.useMemo(()=>m.getCurrencyFormatOptions(i),[i]),p=y.useMemo(()=>n.map(v=>({label:v,value:v})),[n]);t.action.current=()=>m.setPatternDecimal(c,a);const f=v=>{if(v===void 0)return;o(v);const P=m.getCurrencyFormatOptions(v)[0].value;d(P),t.onChange(m.setPatternDecimal(P,a))},g=v=>{v!==void 0&&(d(v),t.onChange(m.setPatternDecimal(v,a)))},_=v=>{u(v||0),t.onChange(m.setPatternDecimal(c,v||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"m-t-16 options",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8 w-120",children:l.jsx(M.InputNumber,{value:a,max:20,min:0,onChange:_})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"m-t-8 w-140",children:l.jsx(M.Select,{onChange:f,options:p,value:i})})]})]}),l.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.SelectList,{onChange:g,options:h,value:c})}),l.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})};var D=function(){return D=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},D.apply(this,arguments)},Oe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},se=y.forwardRef(function(t,e){var r=t.icon,n=t.id,i=t.className,o=t.extend,a=Oe(t,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=y.useRef("_".concat(we()));return ae(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},D({ref:e,className:u},a),o)});function ae(t,e,r,n,i){return y.createElement(t.tag,D(D({key:e},Ue(t,r,i)),n),(Ne(t,r).children||[]).map(function(o,a){return ae(o,"".concat(e,"-").concat(t.tag,"-").concat(a),r,void 0,i)}))}function Ue(t,e,r){var n=D({},t.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var i=e.defIds;return!i||i.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var a=o[0],u=o[1];typeof u=="string"&&(n[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Ne(t,e){var r,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?D(D({},t),{children:t.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+e.idSuffix})}):i})}):t}function we(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var Fe={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(t,e){return y.createElement(se,Object.assign({},t,{id:"check-mark-single",ref:e,icon:Fe}))});ce.displayName="CheckMarkSingle";const j={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 je(t){const{defaultPattern:e,action:r,onChange:n}=t,i=C.useDependency(k),o=C.useDependency(s.ILocalStorageService),a=C.useDependency(s.LocaleService),[u,c]=y.useState(e);r.current=()=>(i.markHabit(Q,u),o.getItem(ee).then((g=[])=>{const _=[...new Set([u,...g||[]])].splice(0,10).filter(v=>!!v);o.setItem(ee,_)}),u);const[d,h]=y.useState([]);y.useEffect(()=>{o.getItem(ee).then(g=>{const _=[...m.CURRENCYFORMAT.map(v=>v.suffix("$")),...m.DATEFMTLISG.map(v=>v.suffix),...m.NUMBERFORMAT.map(v=>v.suffix)];_.push(...g||[]),i.addHabit(Q,[]).finally(()=>{i.getHabit(Q,_).then(v=>{h([...new Set(v)])})})})},[]);const p=g=>{c(g),n(g)},f=()=>{n(u)};return l.jsxs("div",{className:j.customFormat,children:[l.jsx("div",{className:j.customFormatTitle,children:a.t("sheet.numfmt.customFormat")}),l.jsx(M.Input,{placeholder:a.t("sheet.numfmt.customFormat"),onBlur:f,value:u,onChange:c,className:j.customFormatInput}),l.jsx("div",{className:j.customFormatHistoryList,children:d.map(g=>l.jsxs("div",{onClick:()=>p(g),className:j.customFormatHistoryListItem,children:[l.jsx("div",{className:j.customFormatHistoryListItemIconWrap,children:u===g&&l.jsx(ce,{})}),l.jsx("div",{children:g})]},g))}),l.jsx("div",{className:j.customFormatDes,children:a.t("sheet.numfmt.customFormatDes")})]})}const Le=t=>{const e=s.numfmt.getInfo(t);return m.getDateFormatOptions().map(r=>r.value).includes(t)||["date","datetime","time"].includes(e.type)},$e=t=>{const e=y.useMemo(m.getDateFormatOptions,[]),n=C.useDependency(s.LocaleService).t,[i,o]=y.useState(()=>{if(t.defaultPattern){const u=e.find(c=>c.value===t.defaultPattern);if(u)return u.value}return e[0].value});t.action.current=()=>i;const a=u=>{u!==void 0&&(o(u),t.onChange(u))};return l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.dateType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.SelectList,{value:i,options:e,onChange:a})}),l.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},He=t=>!t,ke=t=>{const r=C.useDependency(s.LocaleService).t;return t.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},Ae=t=>m.getNumberFormatOptions().some(e=>m.isPatternEqualWithoutDecimal(e.value,t)),Re=t=>{const e=C.useDependency(s.LocaleService),r=y.useMemo(m.getNumberFormatOptions,[]),[n,i]=y.useState(()=>m.getDecimalFromPattern(t.defaultPattern||"",0)),[o,a]=y.useState(()=>{const p=r.find(f=>m.isPatternEqualWithoutDecimal(f.value,t.defaultPattern||""));return(p==null?void 0:p.value)||r[0].value}),u=y.useMemo(()=>m.setPatternDecimal(o,Number(n||0)),[o,n]),c=y.useMemo(()=>!m.isPatternHasDecimal(o),[o]),d=p=>{i(p||0),t.onChange(m.setPatternDecimal(o,Number(p||0)))},h=p=>{p!==void 0&&(i(m.getDecimalFromPattern(p,0)),a(p),t.onChange(p))};return t.action.current=()=>u,l.jsxs("div",{children:[l.jsx("div",{className:"m-t-16 label",children:e.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.InputNumber,{disabled:c,value:n,max:20,min:0,onChange:d})}),l.jsxs("div",{className:"m-t-16 label",children:[" ",e.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.SelectList,{onChange:h,options:r,value:o})}),l.jsx("div",{className:"describe m-t-14",children:e.t("sheet.numfmt.thousandthPercentileDes")})]})},We=t=>{const{defaultValue:e,defaultPattern:r,row:n,col:i}=t.value,o=C.useDependency(s.LocaleService),a=y.useRef(()=>""),u=o.t,c=Te(),d=y.useMemo(()=>[{label:"sheet.numfmt.general",component:ke},{label:"sheet.numfmt.accounting",component:Ee},{label:"sheet.numfmt.currency",component:De},{label:"sheet.numfmt.date",component:$e},{label:"sheet.numfmt.thousandthPercentile",component:Re},{label:"sheet.numfmt.customFormat",component:je}].map(T=>({...T,label:u(T.label)})),[]),[h,p]=y.useState(I),[f,g]=y.useState(()=>`${n}_${i}`),{mark:_,userHabitCurrency:v}=Ie(()=>g(`${n}_${i}_userCurrency'`)),P=y.useMemo(()=>{var T;return(T=d.find($=>$.label===h))==null?void 0:T.component},[h]);function I(){return[He,Pe,Me,Le,Ae].reduce(($,dt,pt)=>$||(dt(r)?d[pt].label:""),"")||d[0].label}const O=d.map(T=>({label:T.label,value:T.label})),w=T=>{p(T),c(()=>t.onChange({type:"change",value:a.current()||""}))},G=T=>{t.onChange({type:"change",value:T})},ne=()=>{const T=a.current()||"",$=m.getCurrencyType(T);$&&_($),t.onChange({type:"confirm",value:T})},W=()=>{t.onChange({type:"cancel",value:""})},re={onChange:G,defaultValue:e,defaultPattern:r,action:a};return y.useEffect(()=>{p(I()),g(`${n}_${i}`)},[n,i]),l.jsxs("div",{className:"numfmt-panel p-b-20",children:[l.jsxs("div",{children:[l.jsx("div",{className:"label m-t-14",children:u("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"m-t-8",children:l.jsx(M.Select,{onChange:w,options:O,value:h,style:{width:"100%"}})}),l.jsx("div",{children:P&&l.jsx(J.Provider,{value:v,children:y.createElement(P,{...re,key:f})})})]}),l.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[l.jsx(M.Button,{size:"small",onClick:W,className:"m-r-12",children:u("sheet.numfmt.cancel")}),l.jsx(M.Button,{type:"primary",size:"small",onClick:ne,children:u("sheet.numfmt.confirm")})]})]})};var xe=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,Be=(t,e,r,n)=>{for(var i=n>1?void 0:n?Ve(e,r):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(i=(n?a(e,r,i):a(i))||i);return n&&i&&xe(e,r,i),i},U=(t,e)=>(r,n)=>e(r,n,t);const le="SHEET_NUMFMT_PANEL";let A=class extends s.Disposable{constructor(e,r,n,i,o,a,u,c,d,h,p){super();K(this,"_previewPattern","");K(this,"_sidebarDisposable",null);this._sheetInterceptorService=e,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=o,this._renderManagerService=a,this._numfmtService=u,this._componentManager=c,this._sidebarService=d,this._localeService=h,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 P;const e=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,o=this._numfmtService,a=this._localeService,c=(((P=r.getCurrentSelections())==null?void 0:P.map(I=>I.range))||[])[0];if(!c)return!1;const d=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),h=d.getActiveSheet();if(!h)return!1;const p=h.getCellRaw(c.startRow,c.startColumn),f=o.getValue(d.getUnitId(),h.getSheetId(),c.startRow,c.startColumn);let g="";f&&(g=f.pattern);const _=(p==null?void 0:p.t)===s.CellValueType.NUMBER?p.v:12345678,v={onChange:I=>{var O;if(I.type==="change")this._previewPattern=I.value,this._forceUpdate();else if(I.type==="confirm"){const w=((O=r.getCurrentSelections())==null?void 0:O.map(W=>W.range))||[],G={values:[]},ne=m.getPatternType(I.value);w.forEach(W=>{s.Range.foreach(W,(re,T)=>{G.values.push({row:re,col:T,pattern:I.value,type:ne})})}),n.executeCommand(m.SetNumfmtCommand.id,G),e.close()}else I.type==="cancel"&&e.close()},value:{defaultPattern:g,defaultValue:_,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=e.open({header:{title:a.t("sheet.numfmt.title")},children:{label:le,...v},onClose:()=>{this._forceUpdate(),n.executeCommand(X.id)}}),!0}_forceUpdate(e){var n;const r=this._renderManagerService.getRenderById(e!=null?e:this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(E.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[H,X].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initPanel(){this._componentManager.register(le,We)}_initRealTimeRenderingInterceptor(){const e=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([e,this._selectionManagerService.selectionMoveEnd$.pipe(x.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(s.toDisposable(r.pipe(x.switchMap(([n,i])=>new N.Observable(o=>{const a=new s.DisposableCollection;return n&&i.length&&o.next({selectionRanges:i,disposableCollection:a}),()=>{a.dispose()}})),x.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var a,u;const o=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:s.InterceptorEffectEnum.Value|s.InterceptorEffectEnum.Style,handler:(c,d,h)=>{const{row:p,col:f}=d,g=h(c)||{};if(i.find(_=>_.startColumn<=f&&_.endColumn>=f&&_.startRow<=p&&_.endRow>=p)){const _=d.worksheet.getCellRaw(p,f),v=_==null?void 0:_.v,P=_==null?void 0:_.t;if(v==null||P!==s.CellValueType.NUMBER||this._previewPattern===null)return g;const I=m.getPatternPreviewIgnoreGeneral(this._previewPattern,v,this._sheetsNumfmtCellContentController.local);if(I.color){const w=this._themeService.getCurrentTheme()[`${I.color}500`];return{...g,v:I.result,t:s.CellValueType.STRING,s:{cl:{rgb:w}}}}return{...g,v:I.result,t:s.CellValueType.STRING}}return g}})),(u=(a=this._renderManagerService.getRenderById(o.getUnitId()))==null?void 0:a.mainComponent)==null||u.makeDirty()})))}_commandExecutedListener(){const e=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id];this.disposeWithMe(new N.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(e.includes(i.id)){const o=i.params;r.next(o.unitId)}});return()=>n.dispose()}).pipe(x.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{var r;e||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};A=Be([U(0,s.Inject(S.SheetInterceptorService)),U(1,s.Inject(s.ThemeService)),U(2,s.IUniverInstanceService),U(3,s.ICommandService),U(4,s.Inject(S.SheetsSelectionsService)),U(5,F.IRenderManagerService),U(6,S.INumfmtService),U(7,s.Inject(C.ComponentManager)),U(8,C.ISidebarService),U(9,s.Inject(s.LocaleService)),U(10,s.Inject(m.SheetsNumfmtCellContentController))],A);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Ke=(t,e,r,n)=>{for(var i=n>1?void 0:n?Ge(e,r):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(i=(n?a(e,r,i):a(i))||i);return n&&i&&qe(e,r,i),i},R=(t,e)=>(r,n)=>e(r,n,t);const Ze=()=>{let t=[];return{add:(i,o,a,u,c)=>t.push({unitId:i,subUnitId:o,row:a,col:u,value:c}),getEffects:()=>t,clean:()=>{t=[]}}};let V=class extends s.Disposable{constructor(e,r,n,i,o){super();K(this,"_collectEffectMutation",Ze());this._sheetInterceptorService=e,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=o,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.BEFORE_CELL_EDIT,{handler:(e,r,n)=>{const i=r.row,o=r.col,a=this._numfmtService.getValue(r.unitId,r.subUnitId,i,o);if(a)switch(m.getPatternType(a.pattern)){case"scientific":case"currency":case"grouped":case"number":{const c=r.worksheet.getCellRaw(i,o);return n&&n(c)}case"percent":case"date":case"time":case"datetime":default:return n&&n(e)}return n(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(S.AFTER_CELL_EDIT,{handler:(e,r,n)=>{var h,p,f,g;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),o=(h=i&&m.getPatternType(i.pattern))!=null?h:"",a=()=>{i&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(e!=null&&e.v)&&!(e!=null&&e.p)||(i==null?void 0:i.pattern)===Z.DEFAULT_TEXT_FORMAT||e.t===s.CellValueType.FORCE_STRING)return n(e);const u=(p=e.p)==null?void 0:p.body,c=(g=(f=e==null?void 0:e.p)==null?void 0:f.body)!=null&&g.dataStream?e.p.body.dataStream.replace(/\r\n$/,""):String(e.v),d=s.numfmt.parseDate(c)||s.numfmt.parseTime(c)||s.numfmt.parseNumber(c);if(u)if(Ye(u)){const{dataStream:_}=u,v=_.replace(/\r\n$/,""),P=Number(v);if(Number.isNaN(P)&&!d)return n(e)}else return n(e);if(d){d.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:d.z});const _=Number(d.v);return n({...e,p:void 0,v:_,t:s.CellValueType.NUMBER})}else(["date","time","datetime","percent"].includes(o)||!ze(c))&&a();return n(e)}})))}_initInterceptorCommands(){const e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case S.SetRangeValuesCommand.id:{const i=e._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),o=i.getUnitId(),a=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!a)return{redos:[],undos:[]};const u=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!u.length)return{redos:[],undos:[]};const c=u.filter(f=>{var g;return!!((g=f.value)!=null&&g.pattern)}).map(f=>({row:f.row,col:f.col,pattern:f.value.pattern})),d=u.filter(f=>{var g;return!((g=f.value)!=null&&g.pattern)}).map(f=>({startRow:f.row,endColumn:f.col,startColumn:f.col,endRow:f.row})),h=[],p=[];if(c.length){const f={id:S.SetNumfmtMutation.id,params:S.transformCellsToRange(o,a,c)};h.push(f),p.push(...S.factorySetNumfmtUndoMutation(e._injector,f.params))}if(d.length){const f={id:S.RemoveNumfmtMutation.id,params:{unitId:o,subUnitId:a,ranges:d}};h.push(f),p.push(...S.factoryRemoveNumfmtUndoMutation(e._injector,f.params))}return{redos:h,undos:p.reverse()}}}return{redos:[],undos:[]}}}))}};V=Ke([R(0,s.Inject(S.SheetInterceptorService)),R(1,s.Inject(S.INumfmtService)),R(2,s.Inject(s.IUniverInstanceService)),R(3,s.Inject(s.Injector)),R(4,s.Optional(E.IEditorBridgeService))],V);function ze(t){return/^-?\d+(\.\d+)?$/.test(t)}function Ye(t){const{textRuns:e=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=t,o=["va"];return!(e.some(a=>!!(a.ts&&Object.keys(a.ts).some(c=>o.includes(c))))||r.some(a=>a.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const B=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:Z.DEFAULT_TEXT_FORMAT},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Xe=t=>({icon:new N.Observable(e=>{const r=t.get(m.MenuCurrencyService);function n(o){return{[m.countryCurrencyMap.US]:"DollarSingle",[m.countryCurrencyMap.RU]:"RoubleSingle",[m.countryCurrencyMap.CN]:"RmbSingle",[m.countryCurrencyMap.AT]:"EuroSingle"}[o]||"DollarSingle"}const i=m.countryCurrencyMap[r.getCurrencySymbol()]||"$";return e.next(n(i)),r.currencySymbol$.subscribe(o=>{const a=m.countryCurrencyMap[o]||"$";e.next(n(a))})}),id:m.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Je=t=>({icon:"AddDigitsSingle",id:m.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),Qe=t=>({icon:"ReduceDigitsSingle",id:m.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),et=t=>({icon:"PercentSingle",id:m.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:C.MenuItemType.BUTTON,hidden$:C.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetEditPermission,S.WorksheetSetCellStylePermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}),tt=t=>{const e=t.get(s.IUniverInstanceService),r=t.get(s.ICommandService),n=t.get(s.LocaleService),i=t.get(S.SheetsSelectionsService),o=E.deriveStateFromActiveSheet$(e,"",({workbook:a,worksheet:u})=>new N.Observable(c=>N.merge(i.selectionMoveEnd$,new N.Observable(d=>{const h=[S.RemoveNumfmtMutation.id,S.SetNumfmtMutation.id],p=r.onCommandExecuted(f=>{h.includes(f.id)&&d.next(null)});return()=>p.dispose()})).subscribe(()=>{var h,p;const d=i.getCurrentSelections();if(d&&d[0]){const f=d[0].range,g=f.startRow,_=f.startColumn,v=(p=a.getStyles().get((h=u.getCell(g,_))==null?void 0:h.s))==null?void 0:p.n,P=v==null?void 0:v.pattern;let I=n.t("sheet.numfmt.general");if(P){const O=B.filter(w=>typeof w=="object"&&w.pattern).find(w=>m.isPatternEqualWithoutDecimal(P,w.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:H.id,tooltip:"sheet.numfmt.title",type:C.MenuItemType.SELECTOR,selections:[{label:{name:me,hoverable:!1}}],value$:o,hidden$:C.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[S.WorkbookEditablePermission],worksheetTypes:[S.WorksheetSetCellStylePermission,S.WorksheetEditPermission],rangeTypes:[S.RangeProtectionPermissionEditPoint]})}},ue="sheet.numfmt.moreNumfmtType",me="sheet.numfmt.moreNumfmtType.options",nt=t=>{var n;const e=C.useDependency(s.LocaleService),r=(n=t.value)!=null?n:e.t("sheet.numfmt.general");return l.jsx("span",{className:"more-numfmt-type",children:r})},rt=()=>{const t=C.useDependency(s.ICommandService),e=C.useDependency(s.LocaleService),r=C.useDependency(C.ILayoutService),n=C.useDependency(m.SheetsNumfmtCellContentController),i=C.useDependency(S.SheetsSelectionsService),o=c=>{const d=i.getCurrentLastSelection();if(!d)return;const h=d.range,p=[];s.Range.foreach(h,(f,g)=>{c?p.push({row:f,col:g,pattern:c,type:m.getPatternType(c)}):p.push({row:f,col:g})}),t.executeCommand(m.SetNumfmtCommand.id,{values:p}),r.focus()},a=c=>{if(c===0)o(null);else if(c===B.length-1)t.executeCommand(H.id);else{const d=B[c];d.pattern&&o(d.pattern)}},u=1220;return l.jsx("div",{className:"more-numfmt-type-options",children:B.map((c,d)=>c==="|"?l.jsx("div",{className:"line m-t-4",onClick:h=>h.stopPropagation()},d):l.jsxs("div",{className:"option-item m-t-4",onClick:()=>{a(d)},children:[l.jsx("div",{children:e.t(c.label)}),l.jsx("div",{className:"m-l-26",children:c.pattern?m.getPatternPreview(c.pattern||"",u,n.local).result:""})]},d))})},it={[C.RibbonStartGroup.FORMULAS_INSERT]:{[m.SetCurrencyCommand.id]:{order:4,menuItemFactory:Xe},[m.AddDecimalCommand.id]:{order:5,menuItemFactory:Je},[m.SubtractDecimalCommand.id]:{order:6,menuItemFactory:Qe},[m.SetPercentCommand.id]:{order:7,menuItemFactory:et},[H.id]:{order:8,menuItemFactory:tt}}};var ot=Object.defineProperty,st=Object.getOwnPropertyDescriptor,at=(t,e,r,n)=>{for(var i=n>1?void 0:n?st(e,r):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(i=(n?a(e,r,i):a(i))||i);return n&&i&&ot(e,r,i),i},de=(t,e)=>(r,n)=>e(r,n,t);let q=class extends s.Disposable{constructor(t,e){super(),this._componentManager=t,this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(it),this.disposeWithMe(this._componentManager.register(ue,nt)),this.disposeWithMe(this._componentManager.register(me,rt))}};q=at([de(0,s.Inject(C.ComponentManager)),de(1,C.IMenuManagerService)],q);var pe=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,lt=(t,e,r)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e,r,n)=>{for(var i=n>1?void 0:n?ct(e,r):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(i=(n?a(e,r,i):a(i))||i);return n&&i&&pe(e,r,i),i},te=(t,e)=>(r,n)=>e(r,n,t),fe=(t,e,r)=>lt(t,typeof e!="symbol"?e+"":e,r);const mt="SHEET_NUMFMT_UI_PLUGIN";b.UniverSheetsNumfmtUIPlugin=class extends s.Plugin{constructor(e=ie,r,n,i){super(),this._config=e,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:o,...a}=s.merge({},ie,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(C.UI_PLUGIN_CONFIG_KEY,a)}onStarting(){s.registerDependencies(this._injector,[[A],[V],[k],[q]])}onRendered(){this._registerRenderModules(),s.touchDependencies(this._injector,[[A],[V],[q]])}_registerRenderModules(){[[Y]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,r))})}},fe(b.UniverSheetsNumfmtUIPlugin,"pluginName",mt),fe(b.UniverSheetsNumfmtUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),b.UniverSheetsNumfmtUIPlugin=ut([s.DependentOn(E.UniverSheetsUIPlugin,m.UniverSheetsNumfmtPlugin),te(1,s.Inject(s.Injector)),te(2,s.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.0-alpha.0",
3
+ "version": "0.6.0-experimental.20250212-dbe9830",
4
4
  "private": false,
5
5
  "description": "UniverSheet numfmt plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,25 +55,25 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@univerjs/icons": "^0.2.14",
58
- "@univerjs/core": "0.6.0-alpha.0",
59
- "@univerjs/design": "0.6.0-alpha.0",
60
- "@univerjs/engine-formula": "0.6.0-alpha.0",
61
- "@univerjs/engine-render": "0.6.0-alpha.0",
62
- "@univerjs/sheets": "0.6.0-alpha.0",
63
- "@univerjs/sheets-numfmt": "0.6.0-alpha.0",
64
- "@univerjs/engine-numfmt": "0.6.0-alpha.0",
65
- "@univerjs/ui": "0.6.0-alpha.0",
66
- "@univerjs/sheets-ui": "0.6.0-alpha.0"
58
+ "@univerjs/core": "0.6.0-experimental.20250212-dbe9830",
59
+ "@univerjs/design": "0.6.0-experimental.20250212-dbe9830",
60
+ "@univerjs/engine-formula": "0.6.0-experimental.20250212-dbe9830",
61
+ "@univerjs/sheets": "0.6.0-experimental.20250212-dbe9830",
62
+ "@univerjs/engine-render": "0.6.0-experimental.20250212-dbe9830",
63
+ "@univerjs/sheets-ui": "0.6.0-experimental.20250212-dbe9830",
64
+ "@univerjs/engine-numfmt": "0.6.0-experimental.20250212-dbe9830",
65
+ "@univerjs/sheets-numfmt": "0.6.0-experimental.20250212-dbe9830",
66
+ "@univerjs/ui": "0.6.0-experimental.20250212-dbe9830"
67
67
  },
68
68
  "devDependencies": {
69
- "less": "^4.2.1",
70
- "postcss": "^8.4.49",
69
+ "less": "^4.2.2",
70
+ "postcss": "^8.5.1",
71
71
  "react": "18.3.1",
72
72
  "rxjs": "^7.8.1",
73
73
  "tailwindcss": "^3.4.17",
74
74
  "typescript": "^5.7.3",
75
- "vite": "^6.0.7",
76
- "vitest": "^2.1.8",
75
+ "vite": "^6.0.11",
76
+ "vitest": "^3.0.4",
77
77
  "@univerjs-infra/shared": "0.6.0-alpha.0"
78
78
  },
79
79
  "scripts": {
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS