@univerjs/sheets-numfmt-ui 0.9.2-nightly.202507131606 → 0.9.2-nightly.202507141607

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 fe=(e,t,r)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var H=(e,t,r)=>fe(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),se=require("@univerjs/engine-render"),d=require("@univerjs/sheets-numfmt"),P=require("@univerjs/sheets-ui"),q=require("@univerjs/engine-numfmt"),g=require("@univerjs/sheets"),_=require("@univerjs/ui"),D=require("rxjs"),A=require("rxjs/operators"),l=require("react/jsx-runtime"),y=require("react"),E=require("@univerjs/design"),te={};var pe=Object.getOwnPropertyDescriptor,ge=(e,t,r,n)=>{for(var i=n>1?void 0:n?pe(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},O=(e,t)=>(r,n)=>t(r,n,e);const Z="SHEET_NUMFMT_ALERT";let Q=class extends a.Disposable{constructor(e,t,r,n,i,s,c){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=r,this._localeService=n,this._zenZoneService=i,this._numfmtService=s,this._configService=c,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(D.debounceTime(100)).subscribe(e=>{var t,r;if(e){const n=e.location,i=this._context.unit,s=i.getActiveSheet();if(!s)return;const c=n.unitId,u=n.subUnitId;let o;const h=s.getCell(n.row,n.col);if(h!=null&&h.s){const f=i.getStyles().get(h.s);f!=null&&f.n&&(o=f.n)}if(o||(o=this._numfmtService.getValue(c,u,n.row,n.col)),!o){this._hideAlert();return}if(q.isTextFormat(o.pattern)&&(h!=null&&h.v)&&a.isRealNum(h.v)){if((t=this._configService.getConfig(d.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&t.disableTextFormatAlert)return;const f=this._cellAlertManagerService.currentAlert.get(Z),m=(r=f==null?void 0:f.alert)==null?void 0:r.location;if(m&&m.row===n.row&&m.col===n.col&&m.subUnitId===n.subUnitId&&m.unitId===n.unitId)return;this._cellAlertManagerService.showAlert({type:P.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(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(Z)}};Q=ge([O(1,a.Inject(P.HoverManagerService)),O(2,a.Inject(P.CellAlertManagerService)),O(3,a.Inject(a.LocaleService)),O(4,_.IZenZoneService),O(5,a.Inject(g.INumfmtService)),O(6,a.IConfigService)],Q);const Y={id:"sheet.operation.close.numfmt.panel",type:a.CommandType.OPERATION,handler:()=>!0},$={id:"sheet.operation.open.numfmt.panel",type:a.CommandType.OPERATION,handler:e=>(e.get(F).openPanel(),!0)};var Se=Object.getOwnPropertyDescriptor,ye=(e,t,r,n)=>{for(var i=n>1?void 0:n?Se(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},_e=(e,t)=>(r,n)=>t(r,n,e);const ee=y.createContext([]);let L=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const r=this._getKey(e);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,t)})}markHabit(e,t){const r=this._getKey(e);this._localStorageService.getItem(r).then(n=>{if(n){const i=n.findIndex(s=>s===t);i>-1&&n.splice(i,1),n.unshift(t),this._localStorageService.setItem(r,n)}})}async getHabit(e,t){const r=this._getKey(e),n=await this._localStorageService.getItem(r);if(t&&n){const i=n.map((s,c,u)=>{const o=u.length;return{value:s,priority:o-c}});return t.sort((s,c)=>{var h,f;const u=((h=i.find(m=>m.value===s))==null?void 0:h.priority)||-1;return(((f=i.find(m=>m.value===c))==null?void 0:f.priority)||-1)-u})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};L=ye([_e(0,a.Inject(a.ILocalStorageService))],L);const ne="numfmtCurrency",Ce=e=>{const t=_.useDependency(L),[r,n]=y.useState(d.currencySymbols);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(ne,[...d.currencySymbols]).then(s=>{n(s),e&&e(s)})})},[]),{userHabitCurrency:r,mark:s=>{t.markHabit(ne,s)}}},be=()=>{const e=y.useRef([]),[t,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[t]),i=>{e.current.push(i),r({})}},Ie=e=>!!d.getCurrencyType(e)&&e.startsWith("_("),xe=e=>{const{defaultPattern:t,action:r,onChange:n}=e,[i,s]=y.useState(()=>d.getDecimalFromPattern(t||"",2)),c=y.useContext(ee),[u,o]=y.useState(()=>d.getCurrencyType(t)||c[0]),h=y.useMemo(()=>c.map(C=>({label:C,value:C})),[]),m=_.useDependency(a.LocaleService).t;r.current=()=>d.setPatternDecimal(`_("${u}"* #,##0${i>0?".0":""}_)`,i);const p=C=>{o(C),n(d.setPatternDecimal(`_("${C}"* #,##0${i>0?".0":""}_)`,i))},S=C=>{const v=C||0;s(v),n(d.setPatternDecimal(`_("${u}"* #,##0${v>0?".0":""}_)`,v))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:i,step:1,precision:0,max:20,min:0,onChange:S})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{options:h,value:u,onChange:p})})]})]}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.accountingDes")})]})},Ne=e=>!!d.getCurrencyType(e)&&!e.startsWith("_("),Ee=e=>{const r=_.useDependency(a.LocaleService).t,n=y.useContext(ee),[i,s]=y.useState(()=>d.getCurrencyType(e.defaultPattern)||n[0]),[c,u]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",2)),[o,h]=y.useState(()=>{var b;const v=d.getCurrencyFormatOptions(i);return((b=v.find(N=>a.isPatternEqualWithoutDecimal(N.value,e.defaultPattern)))==null?void 0:b.value)||v[0].value}),f=y.useMemo(()=>d.getCurrencyFormatOptions(i),[i]),m=y.useMemo(()=>n.map(v=>({label:v,value:v})),[n]);e.action.current=()=>d.setPatternDecimal(o,c);const p=v=>{if(v===void 0)return;s(v);const x=d.getCurrencyFormatOptions(v)[0].value;h(x),e.onChange(d.setPatternDecimal(x,c))},S=v=>{v!==void 0&&(h(v),e.onChange(d.setPatternDecimal(v,c)))},C=v=>{u(v||0),e.onChange(d.setPatternDecimal(o,v||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:c,max:20,min:0,onChange:C})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{value:i,options:m,onChange:p})})]})]}),l.jsx("div",{className:"label univer-mt-4",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:o,options:f,onChange:S})}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyDes")})]})};var T=function(){return T=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},T.apply(this,arguments)},Te=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},ce=y.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,s=e.extend,c=Te(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),o=y.useRef("_".concat(je()));return ae(r,"".concat(n),{defIds:r.defIds,idSuffix:o.current},T({ref:t,className:u},c),s)});function ae(e,t,r,n,i){return y.createElement(e.tag,T(T({key:t},Pe(e,r,i)),n),(Me(e,r).children||[]).map(function(s,c){return ae(s,"".concat(t,"-").concat(e.tag,"-").concat(c),r,void 0,i)}))}function Pe(e,t,r){var n=T({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(s){var c=s[0],u=s[1];c==="mask"&&typeof u=="string"&&(n[c]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var c=s[0],u=s[1];typeof u=="string"&&(n[c]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Me(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?T(T({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.includes(i.attrs.id)?T(T({},i),{attrs:T(T({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function je(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var De={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},oe=y.forwardRef(function(e,t){return y.createElement(ce,Object.assign({},e,{id:"check-mark-icon",ref:t,icon:De}))});oe.displayName="CheckMarkIcon";const z="customFormat",X="numfmt_custom_pattern";function Re(e){const{defaultPattern:t,action:r,onChange:n}=e,i=_.useDependency(L),s=_.useDependency(a.ILocalStorageService),c=_.useDependency(a.LocaleService),[u,o]=y.useState(t);r.current=()=>(i.markHabit(z,u),s.getItem(X).then((S=[])=>{const C=[...new Set([u,...S||[]])].splice(0,10).filter(v=>!!v);s.setItem(X,C)}),u);const[h,f]=y.useState([]);y.useEffect(()=>{s.getItem(X).then(S=>{const C=[...d.CURRENCYFORMAT.map(v=>v.suffix("$")),...d.DATEFMTLISG.map(v=>v.suffix),...d.NUMBERFORMAT.map(v=>v.suffix)];C.push(...S||[]),i.addHabit(z,[]).finally(()=>{i.getHabit(z,C).then(v=>{f([...new Set(v)])})})})},[]);const m=S=>{o(S),n(S)},p=()=>{n(u)};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:c.t("sheet.numfmt.customFormat")}),l.jsx(E.Input,{placeholder:c.t("sheet.numfmt.customFormat"),onBlur:p,value:u,onChange:o,className:"univer-mt-2 univer-w-full"}),l.jsx("div",{className:E.clsx("univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2",E.borderClassName),children:h.map(S=>l.jsxs("div",{onClick:()=>m(S),className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-w-4 univer-items-center univer-text-primary-600",children:u===S&&l.jsx(oe,{})}),l.jsx("div",{children:S})]},S))}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:c.t("sheet.numfmt.customFormatDes")})]})}const we=e=>{const t=a.numfmt.getFormatInfo(e);return d.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)};function Oe(e){const{onChange:t,defaultPattern:r}=e,n=y.useMemo(d.getDateFormatOptions,[]),i=_.useDependency(a.LocaleService),[s,c]=y.useState(()=>{if(r){const o=n.find(h=>h.value===r);if(o)return o.value}return n[0].value});e.action.current=()=>s;const u=o=>{o!==void 0&&(c(o),t(o))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:i.t("sheet.numfmt.dateType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:s,options:n,onChange:u})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.numfmt.dateDes")})]})}const Ue=e=>!e,ke=e=>{const r=_.useDependency(a.LocaleService).t;return e.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:r("sheet.numfmt.generalDes")})})},$e=e=>d.getNumberFormatOptions().some(t=>a.isPatternEqualWithoutDecimal(t.value,e));function Le(e){const t=_.useDependency(a.LocaleService),r=y.useMemo(d.getNumberFormatOptions,[]),[n,i]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",0)),[s,c]=y.useState(()=>{const m=r.find(p=>a.isPatternEqualWithoutDecimal(p.value,e.defaultPattern||""));return(m==null?void 0:m.value)||r[0].value}),u=y.useMemo(()=>d.setPatternDecimal(s,Number(n||0)),[s,n]),o=y.useMemo(()=>!d.isPatternHasDecimal(s),[s]),h=m=>{i(m||0),e.onChange(d.setPatternDecimal(s,Number(m||0)))},f=m=>{m!==void 0&&(i(d.getDecimalFromPattern(m,0)),c(m),e.onChange(m))};return e.action.current=()=>u,l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:t.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.InputNumber,{disabled:o,value:n,max:20,min:0,onChange:h})}),l.jsxs("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:[" ",t.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{onChange:f,options:r,value:s})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})}const Fe=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:i}=e.value,s=_.useDependency(a.LocaleService),c=y.useRef(()=>""),u=s.t,o=be(),h=y.useMemo(()=>[{label:"sheet.numfmt.general",component:ke},{label:"sheet.numfmt.accounting",component:xe},{label:"sheet.numfmt.currency",component:Ee},{label:"sheet.numfmt.date",component:Oe},{label:"sheet.numfmt.thousandthPercentile",component:Le},{label:"sheet.numfmt.customFormat",component:Re}].map(I=>({...I,label:u(I.label)})),[]),[f,m]=y.useState(b),[p,S]=y.useState(()=>`${n}_${i}`),{mark:C,userHabitCurrency:v}=Ce(()=>S(`${n}_${i}_userCurrency'`)),x=y.useMemo(()=>{var I;return(I=h.find(w=>w.label===f))==null?void 0:I.component},[f]);function b(){return[Ue,Ie,Ne,we,$e].reduce((w,de,he)=>w||(de(r)?h[he].label:""),"")||h[0].label}const N=h.map(I=>({label:I.label,value:I.label})),j=I=>{m(I),o(()=>e.onChange({type:"change",value:c.current()||""}))},R=y.useCallback(I=>{e.onChange({type:"change",value:I})},[]),G=()=>{const I=c.current()||"",w=d.getCurrencyType(I);w&&C(w),e.onChange({type:"confirm",value:I})},U=()=>{e.onChange({type:"cancel",value:""})},K={onChange:R,defaultValue:t,defaultPattern:r,action:c};return y.useEffect(()=>{m(b()),S(`${n}_${i}`)},[n,i]),l.jsxs("div",{className:E.clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5",E.scrollbarClassName),children:[l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3.5 univer-text-sm univer-text-gray-400",children:u("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.Select,{className:"univer-w-full",value:f,options:N,onChange:j})}),l.jsx("div",{children:x&&l.jsx(ee.Provider,{value:v,children:y.createElement(x,{...K,key:p})})})]}),l.jsxs("div",{className:"univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end",children:[l.jsx(E.Button,{onClick:U,className:"univer-mr-3",children:u("sheet.numfmt.cancel")}),l.jsx(E.Button,{variant:"primary",onClick:G,children:u("sheet.numfmt.confirm")})]})]})};var He=Object.getOwnPropertyDescriptor,Ae=(e,t,r,n)=>{for(var i=n>1?void 0:n?He(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},M=(e,t)=>(r,n)=>t(r,n,e);const re="SHEET_NUMFMT_PANEL";let F=class extends a.Disposable{constructor(t,r,n,i,s,c,u,o,h,f,m){super();H(this,"_previewPattern","");H(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=s,this._renderManagerService=c,this._numfmtService=u,this._componentManager=o,this._sidebarService=h,this._localeService=f,this._sheetsNumfmtCellContentController=m,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(D.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var x;const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,s=this._numfmtService,c=this._localeService,o=(((x=r.getCurrentSelections())==null?void 0:x.map(b=>b.range))||[])[0];if(!o)return!1;const h=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),f=h.getActiveSheet();if(!f)return!1;const m=f.getCellRaw(o.startRow,o.startColumn),p=s.getValue(h.getUnitId(),f.getSheetId(),o.startRow,o.startColumn);let S="";p&&(S=p.pattern);const C=(m==null?void 0:m.t)===a.CellValueType.NUMBER?m.v:12345678,v={onChange:b=>{var N;if(b.type==="change")this._previewPattern=b.value,this._forceUpdate();else if(b.type==="confirm"){const j=((N=r.getCurrentSelections())==null?void 0:N.map(U=>U.range))||[],R={values:[]},G=d.getPatternType(b.value);j.forEach(U=>{a.Range.foreach(U,(K,I)=>{R.values.push({row:K,col:I,pattern:b.value,type:G})})}),n.executeCommand(d.SetNumfmtCommand.id,R),t.close()}else b.type==="cancel"&&t.close()},value:{defaultPattern:S,defaultValue:C,row:o.startRow,col:o.startColumn}};return this._sidebarDisposable=t.open({header:{title:c.t("sheet.numfmt.title")},children:{label:re,...v},onClose:()=>{this._forceUpdate(),n.executeCommand(Y.id)}}),!0}_forceUpdate(t){var n;const r=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(P.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[$,Y].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this.disposeWithMe(this._componentManager.register(re,Fe))}_initRealTimeRenderingInterceptor(){const t=new D.Observable(n=>{this._commandService.onCommandExecuted(i=>{i.id===$.id&&n.next(!0),i.id===Y.id&&n.next(!1)})}),r=D.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(A.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(a.toDisposable(r.pipe(A.switchMap(([n,i])=>new D.Observable(s=>{const c=new a.DisposableCollection;return n&&i.length&&s.next({selectionRanges:i,disposableCollection:c}),()=>{c.dispose()}})),A.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var c,u;const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(g.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:a.InterceptorEffectEnum.Value|a.InterceptorEffectEnum.Style,handler:(o,h,f)=>{var C;const{row:m,col:p}=h,S=f(o)||{};if(i.find(v=>v.startColumn<=p&&v.endColumn>=p&&v.startRow<=m&&v.endRow>=m)){const v=h.worksheet.getCellRaw(m,p),x=v==null?void 0:v.v,b=v==null?void 0:v.t;if(x==null||b!==a.CellValueType.NUMBER||this._previewPattern===null)return S;const N=d.getPatternPreviewIgnoreGeneral(this._previewPattern,x,this._sheetsNumfmtCellContentController.local);if(N.color){const j=(C=this._themeService.getColorFromTheme(`${N.color}.500`))!=null?C:N.color;return{...S,v:N.result,t:a.CellValueType.STRING,s:{cl:{rgb:j}}}}return{...S,v:N.result,t:a.CellValueType.STRING}}return S}})),(u=(c=this._renderManagerService.getRenderById(s.getUnitId()))==null?void 0:c.mainComponent)==null||u.makeDirty()})))}_commandExecutedListener(){const t=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id];this.disposeWithMe(new D.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(t.includes(i.id)){const s=i.params;r.next(s.unitId)}});return()=>n.dispose()}).pipe(A.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};F=Ae([M(0,a.Inject(g.SheetInterceptorService)),M(1,a.Inject(a.ThemeService)),M(2,a.IUniverInstanceService),M(3,a.ICommandService),M(4,a.Inject(g.SheetsSelectionsService)),M(5,se.IRenderManagerService),M(6,g.INumfmtService),M(7,a.Inject(_.ComponentManager)),M(8,_.ISidebarService),M(9,a.Inject(a.LocaleService)),M(10,a.Inject(d.SheetsNumfmtCellContentController))],F);var We=Object.getOwnPropertyDescriptor,Ve=(e,t,r,n)=>{for(var i=n>1?void 0:n?We(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},k=(e,t)=>(r,n)=>t(r,n,e);const Be=()=>{let e=[];return{add:(i,s,c,u,o)=>e.push({unitId:i,subUnitId:s,row:c,col:u,value:o}),getEffects:()=>e,clean:()=>{e=[]}}};let V=class extends a.Disposable{constructor(t,r,n,i,s){super();H(this,"_collectEffectMutation",Be());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=s,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(a.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const i=r.row,s=r.col,c=this._numfmtService.getValue(r.unitId,r.subUnitId,i,s);if(c)switch(d.getPatternType(c.pattern)){case"scientific":case"currency":case"grouped":case"number":{const o=r.worksheet.getCellRaw(i,s);return n&&n(o)}case"percent":case"date":case"time":case"datetime":default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(a.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(t,r,n)=>{var o,h,f;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col);if(!(t!=null&&t.v)&&!(t!=null&&t.p)||q.isTextFormat(i==null?void 0:i.pattern)||t.t===a.CellValueType.FORCE_STRING)return n(t);const s=(o=t.p)==null?void 0:o.body,c=(f=(h=t==null?void 0:t.p)==null?void 0:h.body)!=null&&f.dataStream?t.p.body.dataStream.replace(/\r\n$/,""):String(t.v),u=a.numfmt.parseDate(c)||a.numfmt.parseTime(c)||a.numfmt.parseNumber(c);if(s)if(qe(s)){const{dataStream:m}=s,p=m.replace(/\r\n$/,""),S=Number(p);if(Number.isNaN(S)&&!u)return n(t)}else return n(t);if(u){if(!u.z&&a.willLoseNumericPrecision(c))return n({...t,p:void 0,v:c,t:a.CellValueType.FORCE_STRING});u.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:u.z});const m=Number(u.v);return n({...t,p:void 0,v:m,t:a.CellValueType.NUMBER})}return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case g.SetRangeValuesCommand.id:{const i=t._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=i.getUnitId(),c=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!c)return{redos:[],undos:[]};const u=t._collectEffectMutation.getEffects();if(t._collectEffectMutation.clean(),!u.length)return{redos:[],undos:[]};const o=u.filter(p=>{var S;return!!((S=p.value)!=null&&S.pattern)}).map(p=>({row:p.row,col:p.col,pattern:p.value.pattern})),h=u.filter(p=>{var S;return!((S=p.value)!=null&&S.pattern)}).map(p=>({startRow:p.row,endColumn:p.col,startColumn:p.col,endRow:p.row})),f=[],m=[];if(o.length){const p={id:g.SetNumfmtMutation.id,params:g.transformCellsToRange(s,c,o)};f.push(p),m.push(...g.factorySetNumfmtUndoMutation(t._injector,p.params))}if(h.length){const p={id:g.RemoveNumfmtMutation.id,params:{unitId:s,subUnitId:c,ranges:h}};f.push(p),m.push(...g.factoryRemoveNumfmtUndoMutation(t._injector,p.params))}return{redos:f,undos:m.reverse()}}}return{redos:[],undos:[]}}}))}};V=Ve([k(0,a.Inject(g.SheetInterceptorService)),k(1,a.Inject(g.INumfmtService)),k(2,a.Inject(a.IUniverInstanceService)),k(3,a.Inject(a.Injector)),k(4,a.Optional(P.IEditorBridgeService))],V);function qe(e){const{textRuns:t=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=e,s=["va"];return!(t.some(c=>!!(c.ts&&Object.keys(c.ts).some(o=>s.includes(o))))||r.some(c=>c.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const W=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:q.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},{label:"sheet.numfmt.percent",pattern:"0.00%"},{label:"sheet.numfmt.scientific",pattern:"0.00E+00"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Ge=e=>({icon:new D.Observable(t=>{var s;const r=e.get(d.MenuCurrencyService);function n(c){var o;return(o={[d.countryCurrencyMap.US]:"DollarIcon",[d.countryCurrencyMap.RU]:"RoubleIcon",[d.countryCurrencyMap.CN]:"RmbIcon",[d.countryCurrencyMap.AT]:"EuroIcon"}[c])!=null?o:"DollarIcon"}const i=(s=d.countryCurrencyMap[r.getCurrencySymbol()])!=null?s:"$";return t.next(n(i)),r.currencySymbol$.subscribe(c=>{var o;const u=(o=d.countryCurrencyMap[c])!=null?o:"$";t.next(n(u))})}),id:d.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ke=e=>({icon:"AddDigitsIcon",id:d.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ze=e=>({icon:"ReduceDigitsIcon",id:d.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ye=e=>({icon:"PercentIcon",id:d.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),ze=e=>{const t=e.get(a.IUniverInstanceService),r=e.get(a.ICommandService),n=e.get(a.LocaleService),i=e.get(g.SheetsSelectionsService),s=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id],c=P.deriveStateFromActiveSheet$(t,"",({workbook:u,worksheet:o})=>new D.Observable(h=>D.merge(i.selectionMoveEnd$,a.fromCallback(r.onCommandExecuted.bind(r)).pipe(D.filter(([f])=>s.includes(f.id)))).subscribe(()=>{var m,p;const f=i.getCurrentSelections();if(f&&f[0]){const S=f[0].range,C=S.startRow,v=S.startColumn,x=(p=u.getStyles().get((m=o.getCell(C,v))==null?void 0:m.s))==null?void 0:p.n,b=x==null?void 0:x.pattern;let N=n.t("sheet.numfmt.general");if(q.isDefaultFormat(b)){h.next(N);return}if(b){const j=W.filter(R=>typeof R=="object"&&R.pattern).find(R=>a.isPatternEqualWithoutDecimal(b,R.pattern));j&&typeof j=="object"&&j.pattern?N=n.t(j.label):N=n.t("sheet.numfmt.moreFmt")}h.next(N)}})));return{label:le,id:$.id,tooltip:"sheet.numfmt.title",type:_.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:ue,hoverable:!1,selectable:!1}}],value$:c,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetSetCellStylePermission,g.WorksheetEditPermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}},le="sheet.numfmt.moreNumfmtType",ue="sheet.numfmt.moreNumfmtType.options",Xe=e=>{const{value:t}=e,r=_.useDependency(a.LocaleService),n=t!=null?t:r.t("sheet.numfmt.general");return l.jsx("span",{className:"univer-text-sm",children:n})},Je=()=>{const e=_.useDependency(a.ICommandService),t=_.useDependency(a.LocaleService),r=_.useDependency(_.ILayoutService),n=_.useDependency(d.SheetsNumfmtCellContentController),i=_.useDependency(g.SheetsSelectionsService),s=o=>{const h=i.getCurrentLastSelection();if(!h)return;const f=h.range,m=[];a.Range.foreach(f,(p,S)=>{o?m.push({row:p,col:S,pattern:o,type:d.getPatternType(o)}):m.push({row:p,col:S})}),e.executeCommand(d.SetNumfmtCommand.id,{values:m}),r.focus()},c=o=>{if(o===0)s(null);else if(o===W.length-1)e.executeCommand($.id),r.focus();else{const h=W[o];h.pattern&&s(h.pattern)}},u=1220;return l.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:W.map((o,h)=>o==="|"?l.jsx(E.Separator,{},h):l.jsxs("div",{className:"univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",onClick:()=>{c(h)},children:[l.jsx("span",{children:t.t(o.label)}),l.jsx("span",{className:"univer-text-xs univer-text-gray-500",children:o.pattern?d.getPatternPreview(o.pattern||"",u,n.local).result.trim():""})]},h))})},Qe={[_.RibbonDataGroup.FORMULAS]:{[d.SetCurrencyCommand.id]:{order:0,menuItemFactory:Ge},[d.AddDecimalCommand.id]:{order:1,menuItemFactory:Ke},[d.SubtractDecimalCommand.id]:{order:2,menuItemFactory:Ze},[d.SetPercentCommand.id]:{order:3,menuItemFactory:Ye},[$.id]:{order:4,menuItemFactory:ze}}};var et=Object.getOwnPropertyDescriptor,tt=(e,t,r,n)=>{for(var i=n>1?void 0:n?et(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},ie=(e,t)=>(r,n)=>t(r,n,e);let B=class extends a.Disposable{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Qe),[[le,Xe],[ue,Je]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};B=tt([ie(0,a.Inject(_.ComponentManager)),ie(1,_.IMenuManagerService)],B);var nt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,it=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,st=(e,t,r,n)=>{for(var i=n>1?void 0:n?rt(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},J=(e,t)=>(r,n)=>t(r,n,e),me=(e,t,r)=>it(e,typeof t!="symbol"?t+"":t,r);const ct="SHEET_NUMFMT_UI_PLUGIN";exports.UniverSheetsNumfmtUIPlugin=class extends a.Plugin{constructor(t=te,r,n,i){super(),this._config=t,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:s,...c}=a.merge({},te,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig("sheets-numfmt-ui.config",c)}onStarting(){a.registerDependencies(this._injector,[[F],[V],[L],[B]])}onRendered(){this._registerRenderModules(),a.touchDependencies(this._injector,[[F],[V],[B]])}_registerRenderModules(){[[Q]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,r))})}};me(exports.UniverSheetsNumfmtUIPlugin,"pluginName",ct);me(exports.UniverSheetsNumfmtUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtUIPlugin=st([a.DependentOn(P.UniverSheetsUIPlugin,d.UniverSheetsNumfmtPlugin),J(1,a.Inject(a.Injector)),J(2,a.IConfigService),J(3,se.IRenderManagerService)],exports.UniverSheetsNumfmtUIPlugin);
1
+ "use strict";var he=Object.defineProperty;var ve=(e,t,r)=>t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var H=(e,t,r)=>ve(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),ie=require("@univerjs/engine-render"),d=require("@univerjs/sheets-numfmt"),P=require("@univerjs/sheets-ui"),g=require("@univerjs/sheets"),_=require("@univerjs/ui"),D=require("rxjs"),A=require("rxjs/operators"),l=require("react/jsx-runtime"),y=require("react"),E=require("@univerjs/design"),ee={};var fe=Object.getOwnPropertyDescriptor,pe=(e,t,r,n)=>{for(var i=n>1?void 0:n?fe(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},O=(e,t)=>(r,n)=>t(r,n,e);const K="SHEET_NUMFMT_ALERT";let J=class extends c.Disposable{constructor(e,t,r,n,i,s,a){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=r,this._localeService=n,this._zenZoneService=i,this._numfmtService=s,this._configService=a,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(D.debounceTime(100)).subscribe(e=>{var t,r;if(e){const n=e.location,i=this._context.unit,s=i.getActiveSheet();if(!s)return;const a=n.unitId,u=n.subUnitId;let o;const h=s.getCell(n.row,n.col);if(h!=null&&h.s){const f=i.getStyles().get(h.s);f!=null&&f.n&&(o=f.n)}if(o||(o=this._numfmtService.getValue(a,u,n.row,n.col)),!o){this._hideAlert();return}if(c.isTextFormat(o.pattern)&&(h!=null&&h.v)&&c.isRealNum(h.v)){if((t=this._configService.getConfig(d.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&t.disableTextFormatAlert)return;const f=this._cellAlertManagerService.currentAlert.get(K),m=(r=f==null?void 0:f.alert)==null?void 0:r.location;if(m&&m.row===n.row&&m.col===n.col&&m.subUnitId===n.subUnitId&&m.unitId===n.unitId)return;this._cellAlertManagerService.showAlert({type:P.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n,width:200,height:74,key:K});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(K)}};J=pe([O(1,c.Inject(P.HoverManagerService)),O(2,c.Inject(P.CellAlertManagerService)),O(3,c.Inject(c.LocaleService)),O(4,_.IZenZoneService),O(5,c.Inject(g.INumfmtService)),O(6,c.IConfigService)],J);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:e=>(e.get(F).openPanel(),!0)};var ge=Object.getOwnPropertyDescriptor,Se=(e,t,r,n)=>{for(var i=n>1?void 0:n?ge(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},ye=(e,t)=>(r,n)=>t(r,n,e);const Q=y.createContext([]);let L=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const r=this._getKey(e);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,t)})}markHabit(e,t){const r=this._getKey(e);this._localStorageService.getItem(r).then(n=>{if(n){const i=n.findIndex(s=>s===t);i>-1&&n.splice(i,1),n.unshift(t),this._localStorageService.setItem(r,n)}})}async getHabit(e,t){const r=this._getKey(e),n=await this._localStorageService.getItem(r);if(t&&n){const i=n.map((s,a,u)=>{const o=u.length;return{value:s,priority:o-a}});return t.sort((s,a)=>{var h,f;const u=((h=i.find(m=>m.value===s))==null?void 0:h.priority)||-1;return(((f=i.find(m=>m.value===a))==null?void 0:f.priority)||-1)-u})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};L=Se([ye(0,c.Inject(c.ILocalStorageService))],L);const te="numfmtCurrency",_e=e=>{const t=_.useDependency(L),[r,n]=y.useState(d.currencySymbols);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(te,[...d.currencySymbols]).then(s=>{n(s),e&&e(s)})})},[]),{userHabitCurrency:r,mark:s=>{t.markHabit(te,s)}}},Ce=()=>{const e=y.useRef([]),[t,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[t]),i=>{e.current.push(i),r({})}},be=e=>!!d.getCurrencyType(e)&&e.startsWith("_("),Ie=e=>{const{defaultPattern:t,action:r,onChange:n}=e,[i,s]=y.useState(()=>d.getDecimalFromPattern(t||"",2)),a=y.useContext(Q),[u,o]=y.useState(()=>d.getCurrencyType(t)||a[0]),h=y.useMemo(()=>a.map(C=>({label:C,value:C})),[]),m=_.useDependency(c.LocaleService).t;r.current=()=>d.setPatternDecimal(`_("${u}"* #,##0${i>0?".0":""}_)`,i);const p=C=>{o(C),n(d.setPatternDecimal(`_("${C}"* #,##0${i>0?".0":""}_)`,i))},S=C=>{const v=C||0;s(v),n(d.setPatternDecimal(`_("${u}"* #,##0${v>0?".0":""}_)`,v))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:i,step:1,precision:0,max:20,min:0,onChange:S})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{options:h,value:u,onChange:p})})]})]}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.accountingDes")})]})},xe=e=>!!d.getCurrencyType(e)&&!e.startsWith("_("),Ne=e=>{const r=_.useDependency(c.LocaleService).t,n=y.useContext(Q),[i,s]=y.useState(()=>d.getCurrencyType(e.defaultPattern)||n[0]),[a,u]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",2)),[o,h]=y.useState(()=>{var b;const v=d.getCurrencyFormatOptions(i);return((b=v.find(N=>c.isPatternEqualWithoutDecimal(N.value,e.defaultPattern)))==null?void 0:b.value)||v[0].value}),f=y.useMemo(()=>d.getCurrencyFormatOptions(i),[i]),m=y.useMemo(()=>n.map(v=>({label:v,value:v})),[n]);e.action.current=()=>d.setPatternDecimal(o,a);const p=v=>{if(v===void 0)return;s(v);const x=d.getCurrencyFormatOptions(v)[0].value;h(x),e.onChange(d.setPatternDecimal(x,a))},S=v=>{v!==void 0&&(h(v),e.onChange(d.setPatternDecimal(v,a)))},C=v=>{u(v||0),e.onChange(d.setPatternDecimal(o,v||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:a,max:20,min:0,onChange:C})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{value:i,options:m,onChange:p})})]})]}),l.jsx("div",{className:"label univer-mt-4",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:o,options:f,onChange:S})}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyDes")})]})};var T=function(){return T=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},T.apply(this,arguments)},Ee=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},se=y.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,s=e.extend,a=Ee(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),o=y.useRef("_".concat(Me()));return ce(r,"".concat(n),{defIds:r.defIds,idSuffix:o.current},T({ref:t,className:u},a),s)});function ce(e,t,r,n,i){return y.createElement(e.tag,T(T({key:t},Te(e,r,i)),n),(Pe(e,r).children||[]).map(function(s,a){return ce(s,"".concat(t,"-").concat(e.tag,"-").concat(a),r,void 0,i)}))}function Te(e,t,r){var n=T({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],u=s[1];a==="mask"&&typeof u=="string"&&(n[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],u=s[1];typeof u=="string"&&(n[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Pe(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?T(T({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.includes(i.attrs.id)?T(T({},i),{attrs:T(T({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function Me(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var je={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},ae=y.forwardRef(function(e,t){return y.createElement(se,Object.assign({},e,{id:"check-mark-icon",ref:t,icon:je}))});ae.displayName="CheckMarkIcon";const Y="customFormat",z="numfmt_custom_pattern";function De(e){const{defaultPattern:t,action:r,onChange:n}=e,i=_.useDependency(L),s=_.useDependency(c.ILocalStorageService),a=_.useDependency(c.LocaleService),[u,o]=y.useState(t);r.current=()=>(i.markHabit(Y,u),s.getItem(z).then((S=[])=>{const C=[...new Set([u,...S||[]])].splice(0,10).filter(v=>!!v);s.setItem(z,C)}),u);const[h,f]=y.useState([]);y.useEffect(()=>{s.getItem(z).then(S=>{const C=[...d.CURRENCYFORMAT.map(v=>v.suffix("$")),...d.DATEFMTLISG.map(v=>v.suffix),...d.NUMBERFORMAT.map(v=>v.suffix)];C.push(...S||[]),i.addHabit(Y,[]).finally(()=>{i.getHabit(Y,C).then(v=>{f([...new Set(v)])})})})},[]);const m=S=>{o(S),n(S)},p=()=>{n(u)};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:a.t("sheet.numfmt.customFormat")}),l.jsx(E.Input,{placeholder:a.t("sheet.numfmt.customFormat"),onBlur:p,value:u,onChange:o,className:"univer-mt-2 univer-w-full"}),l.jsx("div",{className:E.clsx("univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2",E.borderClassName),children:h.map(S=>l.jsxs("div",{onClick:()=>m(S),className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-w-4 univer-items-center univer-text-primary-600",children:u===S&&l.jsx(ae,{})}),l.jsx("div",{children:S})]},S))}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:a.t("sheet.numfmt.customFormatDes")})]})}const Re=e=>{const t=c.numfmt.getFormatInfo(e);return d.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)};function we(e){const{onChange:t,defaultPattern:r}=e,n=y.useMemo(d.getDateFormatOptions,[]),i=_.useDependency(c.LocaleService),[s,a]=y.useState(()=>{if(r){const o=n.find(h=>h.value===r);if(o)return o.value}return n[0].value});e.action.current=()=>s;const u=o=>{o!==void 0&&(a(o),t(o))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:i.t("sheet.numfmt.dateType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:s,options:n,onChange:u})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.numfmt.dateDes")})]})}const Oe=e=>!e,Ue=e=>{const r=_.useDependency(c.LocaleService).t;return e.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:r("sheet.numfmt.generalDes")})})},ke=e=>d.getNumberFormatOptions().some(t=>c.isPatternEqualWithoutDecimal(t.value,e));function $e(e){const t=_.useDependency(c.LocaleService),r=y.useMemo(d.getNumberFormatOptions,[]),[n,i]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",0)),[s,a]=y.useState(()=>{const m=r.find(p=>c.isPatternEqualWithoutDecimal(p.value,e.defaultPattern||""));return(m==null?void 0:m.value)||r[0].value}),u=y.useMemo(()=>d.setPatternDecimal(s,Number(n||0)),[s,n]),o=y.useMemo(()=>!d.isPatternHasDecimal(s),[s]),h=m=>{i(m||0),e.onChange(d.setPatternDecimal(s,Number(m||0)))},f=m=>{m!==void 0&&(i(d.getDecimalFromPattern(m,0)),a(m),e.onChange(m))};return e.action.current=()=>u,l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:t.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.InputNumber,{disabled:o,value:n,max:20,min:0,onChange:h})}),l.jsxs("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:[" ",t.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{onChange:f,options:r,value:s})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})}const Le=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:i}=e.value,s=_.useDependency(c.LocaleService),a=y.useRef(()=>""),u=s.t,o=Ce(),h=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Ue},{label:"sheet.numfmt.accounting",component:Ie},{label:"sheet.numfmt.currency",component:Ne},{label:"sheet.numfmt.date",component:we},{label:"sheet.numfmt.thousandthPercentile",component:$e},{label:"sheet.numfmt.customFormat",component:De}].map(I=>({...I,label:u(I.label)})),[]),[f,m]=y.useState(b),[p,S]=y.useState(()=>`${n}_${i}`),{mark:C,userHabitCurrency:v}=_e(()=>S(`${n}_${i}_userCurrency'`)),x=y.useMemo(()=>{var I;return(I=h.find(w=>w.label===f))==null?void 0:I.component},[f]);function b(){return[Oe,be,xe,Re,ke].reduce((w,me,de)=>w||(me(r)?h[de].label:""),"")||h[0].label}const N=h.map(I=>({label:I.label,value:I.label})),j=I=>{m(I),o(()=>e.onChange({type:"change",value:a.current()||""}))},R=y.useCallback(I=>{e.onChange({type:"change",value:I})},[]),q=()=>{const I=a.current()||"",w=d.getCurrencyType(I);w&&C(w),e.onChange({type:"confirm",value:I})},U=()=>{e.onChange({type:"cancel",value:""})},G={onChange:R,defaultValue:t,defaultPattern:r,action:a};return y.useEffect(()=>{m(b()),S(`${n}_${i}`)},[n,i]),l.jsxs("div",{className:E.clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5",E.scrollbarClassName),children:[l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3.5 univer-text-sm univer-text-gray-400",children:u("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.Select,{className:"univer-w-full",value:f,options:N,onChange:j})}),l.jsx("div",{children:x&&l.jsx(Q.Provider,{value:v,children:y.createElement(x,{...G,key:p})})})]}),l.jsxs("div",{className:"univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end",children:[l.jsx(E.Button,{onClick:U,className:"univer-mr-3",children:u("sheet.numfmt.cancel")}),l.jsx(E.Button,{variant:"primary",onClick:q,children:u("sheet.numfmt.confirm")})]})]})};var Fe=Object.getOwnPropertyDescriptor,He=(e,t,r,n)=>{for(var i=n>1?void 0:n?Fe(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},M=(e,t)=>(r,n)=>t(r,n,e);const ne="SHEET_NUMFMT_PANEL";let F=class extends c.Disposable{constructor(t,r,n,i,s,a,u,o,h,f,m){super();H(this,"_previewPattern","");H(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=s,this._renderManagerService=a,this._numfmtService=u,this._componentManager=o,this._sidebarService=h,this._localeService=f,this._sheetsNumfmtCellContentController=m,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(D.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var x;const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,s=this._numfmtService,a=this._localeService,o=(((x=r.getCurrentSelections())==null?void 0:x.map(b=>b.range))||[])[0];if(!o)return!1;const h=i.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),f=h.getActiveSheet();if(!f)return!1;const m=f.getCellRaw(o.startRow,o.startColumn),p=s.getValue(h.getUnitId(),f.getSheetId(),o.startRow,o.startColumn);let S="";p&&(S=p.pattern);const C=(m==null?void 0:m.t)===c.CellValueType.NUMBER?m.v:12345678,v={onChange:b=>{var N;if(b.type==="change")this._previewPattern=b.value,this._forceUpdate();else if(b.type==="confirm"){const j=((N=r.getCurrentSelections())==null?void 0:N.map(U=>U.range))||[],R={values:[]},q=d.getPatternType(b.value);j.forEach(U=>{c.Range.foreach(U,(G,I)=>{R.values.push({row:G,col:I,pattern:b.value,type:q})})}),n.executeCommand(d.SetNumfmtCommand.id,R),t.close()}else b.type==="cancel"&&t.close()},value:{defaultPattern:S,defaultValue:C,row:o.startRow,col:o.startColumn}};return this._sidebarDisposable=t.open({header:{title:a.t("sheet.numfmt.title")},children:{label:ne,...v},onClose:()=>{this._forceUpdate(),n.executeCommand(Z.id)}}),!0}_forceUpdate(t){var n;const r=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(P.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[$,Z].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this.disposeWithMe(this._componentManager.register(ne,Le))}_initRealTimeRenderingInterceptor(){const t=new D.Observable(n=>{this._commandService.onCommandExecuted(i=>{i.id===$.id&&n.next(!0),i.id===Z.id&&n.next(!1)})}),r=D.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(A.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(c.toDisposable(r.pipe(A.switchMap(([n,i])=>new D.Observable(s=>{const a=new c.DisposableCollection;return n&&i.length&&s.next({selectionRanges:i,disposableCollection:a}),()=>{a.dispose()}})),A.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var a,u;const s=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(g.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:c.InterceptorEffectEnum.Value|c.InterceptorEffectEnum.Style,handler:(o,h,f)=>{var C;const{row:m,col:p}=h,S=f(o)||{};if(i.find(v=>v.startColumn<=p&&v.endColumn>=p&&v.startRow<=m&&v.endRow>=m)){const v=h.worksheet.getCellRaw(m,p),x=v==null?void 0:v.v,b=v==null?void 0:v.t;if(x==null||b!==c.CellValueType.NUMBER||this._previewPattern===null)return S;const N=d.getPatternPreviewIgnoreGeneral(this._previewPattern,x,this._sheetsNumfmtCellContentController.local);if(N.color){const j=(C=this._themeService.getColorFromTheme(`${N.color}.500`))!=null?C:N.color;return{...S,v:N.result,t:c.CellValueType.STRING,s:{cl:{rgb:j}}}}return{...S,v:N.result,t:c.CellValueType.STRING}}return S}})),(u=(a=this._renderManagerService.getRenderById(s.getUnitId()))==null?void 0:a.mainComponent)==null||u.makeDirty()})))}_commandExecutedListener(){const t=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id];this.disposeWithMe(new D.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(t.includes(i.id)){const s=i.params;r.next(s.unitId)}});return()=>n.dispose()}).pipe(A.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};F=He([M(0,c.Inject(g.SheetInterceptorService)),M(1,c.Inject(c.ThemeService)),M(2,c.IUniverInstanceService),M(3,c.ICommandService),M(4,c.Inject(g.SheetsSelectionsService)),M(5,ie.IRenderManagerService),M(6,g.INumfmtService),M(7,c.Inject(_.ComponentManager)),M(8,_.ISidebarService),M(9,c.Inject(c.LocaleService)),M(10,c.Inject(d.SheetsNumfmtCellContentController))],F);var Ae=Object.getOwnPropertyDescriptor,We=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ae(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},k=(e,t)=>(r,n)=>t(r,n,e);const Ve=()=>{let e=[];return{add:(i,s,a,u,o)=>e.push({unitId:i,subUnitId:s,row:a,col:u,value:o}),getEffects:()=>e,clean:()=>{e=[]}}};let V=class extends c.Disposable{constructor(t,r,n,i,s){super();H(this,"_collectEffectMutation",Ve());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=s,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(c.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const i=r.row,s=r.col,a=this._numfmtService.getValue(r.unitId,r.subUnitId,i,s);if(a)switch(d.getPatternType(a.pattern)){case"scientific":case"currency":case"grouped":case"number":{const o=r.worksheet.getCellRaw(i,s);return n&&n(o)}case"percent":case"date":case"time":case"datetime":default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(c.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(t,r,n)=>{var o,h,f;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col);if(!(t!=null&&t.v)&&!(t!=null&&t.p)||c.isTextFormat(i==null?void 0:i.pattern)||t.t===c.CellValueType.FORCE_STRING)return n(t);const s=(o=t.p)==null?void 0:o.body,a=(f=(h=t==null?void 0:t.p)==null?void 0:h.body)!=null&&f.dataStream?t.p.body.dataStream.replace(/\r\n$/,""):String(t.v),u=c.numfmt.parseDate(a)||c.numfmt.parseTime(a)||c.numfmt.parseNumber(a);if(s)if(Be(s)){const{dataStream:m}=s,p=m.replace(/\r\n$/,""),S=Number(p);if(Number.isNaN(S)&&!u)return n(t)}else return n(t);if(u){if(!u.z&&c.willLoseNumericPrecision(a))return n({...t,p:void 0,v:a,t:c.CellValueType.FORCE_STRING});u.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:u.z});const m=Number(u.v);return n({...t,p:void 0,v:m,t:c.CellValueType.NUMBER})}return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case g.SetRangeValuesCommand.id:{const i=t._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),s=i.getUnitId(),a=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!a)return{redos:[],undos:[]};const u=t._collectEffectMutation.getEffects();if(t._collectEffectMutation.clean(),!u.length)return{redos:[],undos:[]};const o=u.filter(p=>{var S;return!!((S=p.value)!=null&&S.pattern)}).map(p=>({row:p.row,col:p.col,pattern:p.value.pattern})),h=u.filter(p=>{var S;return!((S=p.value)!=null&&S.pattern)}).map(p=>({startRow:p.row,endColumn:p.col,startColumn:p.col,endRow:p.row})),f=[],m=[];if(o.length){const p={id:g.SetNumfmtMutation.id,params:g.transformCellsToRange(s,a,o)};f.push(p),m.push(...g.factorySetNumfmtUndoMutation(t._injector,p.params))}if(h.length){const p={id:g.RemoveNumfmtMutation.id,params:{unitId:s,subUnitId:a,ranges:h}};f.push(p),m.push(...g.factoryRemoveNumfmtUndoMutation(t._injector,p.params))}return{redos:f,undos:m.reverse()}}}return{redos:[],undos:[]}}}))}};V=We([k(0,c.Inject(g.SheetInterceptorService)),k(1,c.Inject(g.INumfmtService)),k(2,c.Inject(c.IUniverInstanceService)),k(3,c.Inject(c.Injector)),k(4,c.Optional(P.IEditorBridgeService))],V);function Be(e){const{textRuns:t=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=e,s=["va"];return!(t.some(a=>!!(a.ts&&Object.keys(a.ts).some(o=>s.includes(o))))||r.some(a=>a.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const W=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:c.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},{label:"sheet.numfmt.percent",pattern:"0.00%"},{label:"sheet.numfmt.scientific",pattern:"0.00E+00"},"|",{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:""}],qe=e=>({icon:new D.Observable(t=>{var s;const r=e.get(d.MenuCurrencyService);function n(a){var o;return(o={[d.countryCurrencyMap.US]:"DollarIcon",[d.countryCurrencyMap.RU]:"RoubleIcon",[d.countryCurrencyMap.CN]:"RmbIcon",[d.countryCurrencyMap.AT]:"EuroIcon"}[a])!=null?o:"DollarIcon"}const i=(s=d.countryCurrencyMap[r.getCurrencySymbol()])!=null?s:"$";return t.next(n(i)),r.currencySymbol$.subscribe(a=>{var o;const u=(o=d.countryCurrencyMap[a])!=null?o:"$";t.next(n(u))})}),id:d.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ge=e=>({icon:"AddDigitsIcon",id:d.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ke=e=>({icon:"ReduceDigitsIcon",id:d.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ze=e=>({icon:"PercentIcon",id:d.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ye=e=>{const t=e.get(c.IUniverInstanceService),r=e.get(c.ICommandService),n=e.get(c.LocaleService),i=e.get(g.SheetsSelectionsService),s=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id],a=P.deriveStateFromActiveSheet$(t,"",({workbook:u,worksheet:o})=>new D.Observable(h=>D.merge(i.selectionMoveEnd$,c.fromCallback(r.onCommandExecuted.bind(r)).pipe(D.filter(([f])=>s.includes(f.id)))).subscribe(()=>{var m,p;const f=i.getCurrentSelections();if(f&&f[0]){const S=f[0].range,C=S.startRow,v=S.startColumn,x=(p=u.getStyles().get((m=o.getCell(C,v))==null?void 0:m.s))==null?void 0:p.n,b=x==null?void 0:x.pattern;let N=n.t("sheet.numfmt.general");if(c.isDefaultFormat(b)){h.next(N);return}if(b){const j=W.filter(R=>typeof R=="object"&&R.pattern).find(R=>c.isPatternEqualWithoutDecimal(b,R.pattern));j&&typeof j=="object"&&j.pattern?N=n.t(j.label):N=n.t("sheet.numfmt.moreFmt")}h.next(N)}})));return{label:oe,id:$.id,tooltip:"sheet.numfmt.title",type:_.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:le,hoverable:!1,selectable:!1}}],value$:a,hidden$:_.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetSetCellStylePermission,g.WorksheetEditPermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}},oe="sheet.numfmt.moreNumfmtType",le="sheet.numfmt.moreNumfmtType.options",ze=e=>{const{value:t}=e,r=_.useDependency(c.LocaleService),n=t!=null?t:r.t("sheet.numfmt.general");return l.jsx("span",{className:"univer-text-sm",children:n})},Xe=()=>{const e=_.useDependency(c.ICommandService),t=_.useDependency(c.LocaleService),r=_.useDependency(_.ILayoutService),n=_.useDependency(d.SheetsNumfmtCellContentController),i=_.useDependency(g.SheetsSelectionsService),s=o=>{const h=i.getCurrentLastSelection();if(!h)return;const f=h.range,m=[];c.Range.foreach(f,(p,S)=>{o?m.push({row:p,col:S,pattern:o,type:d.getPatternType(o)}):m.push({row:p,col:S})}),e.executeCommand(d.SetNumfmtCommand.id,{values:m}),r.focus()},a=o=>{if(o===0)s(null);else if(o===W.length-1)e.executeCommand($.id),r.focus();else{const h=W[o];h.pattern&&s(h.pattern)}},u=1220;return l.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:W.map((o,h)=>o==="|"?l.jsx(E.Separator,{},h):l.jsxs("div",{className:"univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",onClick:()=>{a(h)},children:[l.jsx("span",{children:t.t(o.label)}),l.jsx("span",{className:"univer-text-xs univer-text-gray-500",children:o.pattern?d.getPatternPreview(o.pattern||"",u,n.local).result.trim():""})]},h))})},Je={[_.RibbonDataGroup.FORMULAS]:{[d.SetCurrencyCommand.id]:{order:0,menuItemFactory:qe},[d.AddDecimalCommand.id]:{order:1,menuItemFactory:Ge},[d.SubtractDecimalCommand.id]:{order:2,menuItemFactory:Ke},[d.SetPercentCommand.id]:{order:3,menuItemFactory:Ze},[$.id]:{order:4,menuItemFactory:Ye}}};var Qe=Object.getOwnPropertyDescriptor,et=(e,t,r,n)=>{for(var i=n>1?void 0:n?Qe(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},re=(e,t)=>(r,n)=>t(r,n,e);let B=class extends c.Disposable{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Je),[[oe,ze],[le,Xe]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};B=et([re(0,c.Inject(_.ComponentManager)),re(1,_.IMenuManagerService)],B);var tt=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(e,t,r)=>t in e?tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,it=(e,t,r,n)=>{for(var i=n>1?void 0:n?nt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},X=(e,t)=>(r,n)=>t(r,n,e),ue=(e,t,r)=>rt(e,typeof t!="symbol"?t+"":t,r);const st="SHEET_NUMFMT_UI_PLUGIN";exports.UniverSheetsNumfmtUIPlugin=class extends c.Plugin{constructor(t=ee,r,n,i){super(),this._config=t,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:s,...a}=c.merge({},ee,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig("sheets-numfmt-ui.config",a)}onStarting(){c.registerDependencies(this._injector,[[F],[V],[L],[B]])}onRendered(){this._registerRenderModules(),c.touchDependencies(this._injector,[[F],[V],[B]])}_registerRenderModules(){[[J]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,r))})}};ue(exports.UniverSheetsNumfmtUIPlugin,"pluginName",st);ue(exports.UniverSheetsNumfmtUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtUIPlugin=it([c.DependentOn(P.UniverSheetsUIPlugin,d.UniverSheetsNumfmtPlugin),X(1,c.Inject(c.Injector)),X(2,c.IConfigService),X(3,ie.IRenderManagerService)],exports.UniverSheetsNumfmtUIPlugin);
package/lib/es/index.js CHANGED
@@ -1,11 +1,10 @@
1
1
  var dt = Object.defineProperty;
2
2
  var ht = (e, t, r) => t in e ? dt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var q = (e, t, r) => ht(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Inject as C, LocaleService as M, IConfigService as Fe, Disposable as ie, isRealNum as ft, CommandType as Ae, ILocalStorageService as Le, isPatternEqualWithoutDecimal as se, numfmt as J, ThemeService as vt, IUniverInstanceService as ge, ICommandService as _e, UniverInstanceType as T, CellValueType as U, toDisposable as ve, DisposableCollection as pt, InterceptorEffectEnum as Pe, Range as He, Injector as je, Optional as gt, willLoseNumericPrecision as _t, fromCallback as St, DependentOn as yt, Plugin as Ct, merge as bt, registerDependencies as It, touchDependencies as Nt } from "@univerjs/core";
5
- import { IRenderManagerService as Be } from "@univerjs/engine-render";
6
- import { SHEETS_NUMFMT_PLUGIN_CONFIG_KEY as Et, currencySymbols as Re, getDecimalFromPattern as ee, getCurrencyType as V, setPatternDecimal as R, getCurrencyFormatOptions as le, CURRENCYFORMAT as Tt, DATEFMTLISG as Mt, NUMBERFORMAT as wt, getDateFormatOptions as Ve, getNumberFormatOptions as We, isPatternHasDecimal as xt, SheetsNumfmtCellContentController as Ge, getPatternPreviewIgnoreGeneral as Pt, getPatternType as Se, SetNumfmtCommand as Ke, SetPercentCommand as Ze, SubtractDecimalCommand as Ye, AddDecimalCommand as ze, SetCurrencyCommand as Xe, MenuCurrencyService as Rt, countryCurrencyMap as D, getPatternPreview as Ot, UniverSheetsNumfmtPlugin as Ut } from "@univerjs/sheets-numfmt";
7
- import { HoverManagerService as kt, CellAlertManagerService as Dt, CellAlertType as $t, SheetSkeletonManagerService as Ft, IEditorBridgeService as At, deriveStateFromActiveSheet$ as Lt, getCurrentRangeDisable$ as W, UniverSheetsUIPlugin as Ht } from "@univerjs/sheets-ui";
8
- import { isTextFormat as qe, isDefaultFormat as jt, DEFAULT_TEXT_FORMAT_EXCEL as Bt } from "@univerjs/engine-numfmt";
4
+ import { Inject as C, LocaleService as M, IConfigService as Fe, Disposable as ie, isTextFormat as Ae, isRealNum as ft, CommandType as Le, ILocalStorageService as He, isPatternEqualWithoutDecimal as se, numfmt as J, ThemeService as vt, IUniverInstanceService as ge, ICommandService as _e, UniverInstanceType as T, CellValueType as U, toDisposable as ve, DisposableCollection as pt, InterceptorEffectEnum as Pe, Range as je, Injector as Be, Optional as gt, willLoseNumericPrecision as _t, fromCallback as St, isDefaultFormat as yt, DEFAULT_TEXT_FORMAT_EXCEL as Ct, DependentOn as bt, Plugin as It, merge as Nt, registerDependencies as Et, touchDependencies as Tt } from "@univerjs/core";
5
+ import { IRenderManagerService as Ve } from "@univerjs/engine-render";
6
+ import { SHEETS_NUMFMT_PLUGIN_CONFIG_KEY as Mt, currencySymbols as Re, getDecimalFromPattern as ee, getCurrencyType as V, setPatternDecimal as R, getCurrencyFormatOptions as le, CURRENCYFORMAT as wt, DATEFMTLISG as xt, NUMBERFORMAT as Pt, getDateFormatOptions as We, getNumberFormatOptions as Ge, isPatternHasDecimal as Rt, SheetsNumfmtCellContentController as Ke, getPatternPreviewIgnoreGeneral as Ot, getPatternType as Se, SetNumfmtCommand as Ze, SetPercentCommand as Ye, SubtractDecimalCommand as ze, AddDecimalCommand as Xe, SetCurrencyCommand as qe, MenuCurrencyService as Ut, countryCurrencyMap as D, getPatternPreview as kt, UniverSheetsNumfmtPlugin as Dt } from "@univerjs/sheets-numfmt";
7
+ import { HoverManagerService as $t, CellAlertManagerService as Ft, CellAlertType as At, SheetSkeletonManagerService as Lt, IEditorBridgeService as Ht, deriveStateFromActiveSheet$ as jt, getCurrentRangeDisable$ as W, UniverSheetsUIPlugin as Bt } from "@univerjs/sheets-ui";
9
8
  import { INumfmtService as ye, SheetInterceptorService as Je, SheetsSelectionsService as Ce, INTERCEPTOR_POINT as Vt, RemoveNumfmtMutation as be, SetNumfmtMutation as Ie, BEFORE_CELL_EDIT as Wt, AFTER_CELL_EDIT as Gt, SetRangeValuesCommand as Kt, transformCellsToRange as Zt, factorySetNumfmtUndoMutation as Yt, factoryRemoveNumfmtUndoMutation as zt, RangeProtectionPermissionEditPoint as G, WorksheetSetCellStylePermission as K, WorksheetEditPermission as Z, WorkbookEditablePermission as Y } from "@univerjs/sheets";
10
9
  import { IZenZoneService as Xt, useDependency as I, ComponentManager as Qe, ISidebarService as qt, getMenuHiddenObservable as z, MenuItemType as X, ILayoutService as Jt, RibbonDataGroup as Qt, IMenuManagerService as en } from "@univerjs/ui";
11
10
  import { debounceTime as tn, merge as et, Observable as L, combineLatest as nn, filter as rn } from "rxjs";
@@ -44,14 +43,14 @@ let pe = class extends ie {
44
43
  this._hideAlert();
45
44
  return;
46
45
  }
47
- if (qe(c.pattern) && (u != null && u.v) && ft(u.v)) {
48
- if ((t = this._configService.getConfig(Et)) != null && t.disableTextFormatAlert)
46
+ if (Ae(c.pattern) && (u != null && u.v) && ft(u.v)) {
47
+ if ((t = this._configService.getConfig(Mt)) != null && t.disableTextFormatAlert)
49
48
  return;
50
49
  const h = this._cellAlertManagerService.currentAlert.get(ue), l = (r = h == null ? void 0 : h.alert) == null ? void 0 : r.location;
51
50
  if (l && l.row === n.row && l.col === n.col && l.subUnitId === n.subUnitId && l.unitId === n.unitId)
52
51
  return;
53
52
  this._cellAlertManagerService.showAlert({
54
- type: $t.ERROR,
53
+ type: At.ERROR,
55
54
  title: this._localeService.t("info.error"),
56
55
  message: this._localeService.t("info.forceStringInfo"),
57
56
  location: n,
@@ -75,8 +74,8 @@ let pe = class extends ie {
75
74
  }
76
75
  };
77
76
  pe = pn([
78
- $(1, C(kt)),
79
- $(2, C(Dt)),
77
+ $(1, C($t)),
78
+ $(2, C(Ft)),
80
79
  $(3, C(M)),
81
80
  $(4, Xt),
82
81
  $(5, C(ye)),
@@ -84,14 +83,14 @@ pe = pn([
84
83
  ], pe);
85
84
  const me = {
86
85
  id: "sheet.operation.close.numfmt.panel",
87
- type: Ae.OPERATION,
86
+ type: Le.OPERATION,
88
87
  handler: () => (
89
88
  // do nothing, just notify panel is closed
90
89
  !0
91
90
  )
92
91
  }, H = {
93
92
  id: "sheet.operation.open.numfmt.panel",
94
- type: Ae.OPERATION,
93
+ type: Le.OPERATION,
95
94
  handler: (e) => (e.get(B).openPanel(), !0)
96
95
  };
97
96
  var gn = Object.getOwnPropertyDescriptor, _n = (e, t, r, n) => {
@@ -145,7 +144,7 @@ let j = class {
145
144
  }
146
145
  };
147
146
  j = _n([
148
- Sn(0, C(Le))
147
+ Sn(0, C(He))
149
148
  ], j);
150
149
  const ke = "numfmtCurrency", yn = (e) => {
151
150
  const t = I(j), [r, n] = N(Re);
@@ -311,7 +310,7 @@ var Pn = { tag: "svg", attrs: { xmlns: "http://www.w3.org/2000/svg", fill: "none
311
310
  ot.displayName = "CheckMarkIcon";
312
311
  const de = "customFormat", he = "numfmt_custom_pattern";
313
312
  function Rn(e) {
314
- const { defaultPattern: t, action: r, onChange: n } = e, i = I(j), s = I(Le), o = I(M), [a, c] = N(t);
313
+ const { defaultPattern: t, action: r, onChange: n } = e, i = I(j), s = I(He), o = I(M), [a, c] = N(t);
315
314
  r.current = () => (i.markHabit(de, a), s.getItem(he).then((v = []) => {
316
315
  const p = [.../* @__PURE__ */ new Set([a, ...v || []])].splice(0, 10).filter((m) => !!m);
317
316
  s.setItem(he, p);
@@ -320,9 +319,9 @@ function Rn(e) {
320
319
  oe(() => {
321
320
  s.getItem(he).then((v) => {
322
321
  const p = [
323
- ...Tt.map((m) => m.suffix("$")),
324
- ...Mt.map((m) => m.suffix),
325
- ...wt.map((m) => m.suffix)
322
+ ...wt.map((m) => m.suffix("$")),
323
+ ...xt.map((m) => m.suffix),
324
+ ...Pt.map((m) => m.suffix)
326
325
  ];
327
326
  p.push(...v || []), i.addHabit(de, []).finally(() => {
328
327
  i.getHabit(de, p).then((m) => {
@@ -377,10 +376,10 @@ function Rn(e) {
377
376
  }
378
377
  const On = (e) => {
379
378
  const t = J.getFormatInfo(e);
380
- return Ve().map((r) => r.value).includes(e) || ["date", "datetime", "time"].includes(t.type);
379
+ return We().map((r) => r.value).includes(e) || ["date", "datetime", "time"].includes(t.type);
381
380
  };
382
381
  function Un(e) {
383
- const { onChange: t, defaultPattern: r } = e, n = O(Ve, []), i = I(M), [s, o] = N(() => {
382
+ const { onChange: t, defaultPattern: r } = e, n = O(We, []), i = I(M), [s, o] = N(() => {
384
383
  if (r) {
385
384
  const c = n.find((u) => u.value === r);
386
385
  if (c)
@@ -413,12 +412,12 @@ const kn = (e) => !e, Dn = (e) => {
413
412
  children: r("sheet.numfmt.generalDes")
414
413
  }
415
414
  ) });
416
- }, $n = (e) => We().some((t) => se(t.value, e));
415
+ }, $n = (e) => Ge().some((t) => se(t.value, e));
417
416
  function Fn(e) {
418
- const t = I(M), r = O(We, []), [n, i] = N(() => ee(e.defaultPattern || "", 0)), [s, o] = N(() => {
417
+ const t = I(M), r = O(Ge, []), [n, i] = N(() => ee(e.defaultPattern || "", 0)), [s, o] = N(() => {
419
418
  const l = r.find((f) => se(f.value, e.defaultPattern || ""));
420
419
  return (l == null ? void 0 : l.value) || r[0].value;
421
- }), a = O(() => R(s, Number(n || 0)), [s, n]), c = O(() => !xt(s), [s]), u = (l) => {
420
+ }), a = O(() => R(s, Number(n || 0)), [s, n]), c = O(() => !Rt(s), [s]), u = (l) => {
422
421
  i(l || 0), e.onChange(R(s, Number(l || 0)));
423
422
  }, h = (l) => {
424
423
  l !== void 0 && (i(ee(l, 0)), o(l), e.onChange(l));
@@ -553,7 +552,7 @@ let B = class extends ie {
553
552
  else if (g.type === "confirm") {
554
553
  const x = ((y = r.getCurrentSelections()) == null ? void 0 : y.map((F) => F.range)) || [], P = { values: [] }, ce = Se(g.value);
555
554
  x.forEach((F) => {
556
- He.foreach(F, (ae, _) => {
555
+ je.foreach(F, (ae, _) => {
557
556
  P.values.push({
558
557
  row: ae,
559
558
  col: _,
@@ -561,7 +560,7 @@ let B = class extends ie {
561
560
  type: ce
562
561
  });
563
562
  });
564
- }), n.executeCommand(Ke.id, P), t.close();
563
+ }), n.executeCommand(Ze.id, P), t.close();
565
564
  } else g.type === "cancel" && t.close();
566
565
  },
567
566
  value: { defaultPattern: v, defaultValue: p, row: c.startRow, col: c.startColumn }
@@ -583,7 +582,7 @@ let B = class extends ie {
583
582
  const r = this._renderManagerService.getRenderById(
584
583
  t != null ? t : this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET).getUnitId()
585
584
  );
586
- r == null || r.with(Ft).reCalculate(), (n = r == null ? void 0 : r.mainComponent) == null || n.makeDirty();
585
+ r == null || r.with(Lt).reCalculate(), (n = r == null ? void 0 : r.mainComponent) == null || n.makeDirty();
587
586
  }
588
587
  _initCommands() {
589
588
  [
@@ -640,7 +639,7 @@ let B = class extends ie {
640
639
  const m = u.worksheet.getCellRaw(l, f), S = m == null ? void 0 : m.v, g = m == null ? void 0 : m.t;
641
640
  if (S == null || g !== U.NUMBER || this._previewPattern === null)
642
641
  return v;
643
- const y = Pt(this._previewPattern, S, this._sheetsNumfmtCellContentController.local);
642
+ const y = Ot(this._previewPattern, S, this._sheetsNumfmtCellContentController.local);
644
643
  if (y.color) {
645
644
  const x = (p = this._themeService.getColorFromTheme(`${y.color}.500`)) != null ? p : y.color;
646
645
  return {
@@ -691,12 +690,12 @@ B = Hn([
691
690
  w(2, ge),
692
691
  w(3, _e),
693
692
  w(4, C(Ce)),
694
- w(5, Be),
693
+ w(5, Ve),
695
694
  w(6, ye),
696
695
  w(7, C(Qe)),
697
696
  w(8, qt),
698
697
  w(9, C(M)),
699
- w(10, C(Ge))
698
+ w(10, C(Ke))
700
699
  ], B);
701
700
  var jn = Object.getOwnPropertyDescriptor, Bn = (e, t, r, n) => {
702
701
  for (var i = n > 1 ? void 0 : n ? jn(t, r) : t, s = e.length - 1, o; s >= 0; s--)
@@ -773,7 +772,7 @@ let te = class extends ie {
773
772
  r.row,
774
773
  r.col
775
774
  );
776
- if (!(t != null && t.v) && !(t != null && t.p) || qe(i == null ? void 0 : i.pattern) || t.t === U.FORCE_STRING)
775
+ if (!(t != null && t.v) && !(t != null && t.p) || Ae(i == null ? void 0 : i.pattern) || t.t === U.FORCE_STRING)
777
776
  return n(t);
778
777
  const s = (c = t.p) == null ? void 0 : c.body, o = (h = (u = t == null ? void 0 : t.p) == null ? void 0 : u.body) != null && h.dataStream ? t.p.body.dataStream.replace(/\r\n$/, "") : String(t.v), a = J.parseDate(o) || J.parseTime(o) || J.parseNumber(o);
779
778
  if (s)
@@ -882,8 +881,8 @@ te = Bn([
882
881
  A(0, C(Je)),
883
882
  A(1, C(ye)),
884
883
  A(2, C(ge)),
885
- A(3, C(je)),
886
- A(4, gt(At))
884
+ A(3, C(Be)),
885
+ A(4, gt(Ht))
887
886
  ], te);
888
887
  function Wn(e) {
889
888
  const { textRuns: t = [], paragraphs: r = [], customRanges: n, customBlocks: i = [] } = e, s = ["va"];
@@ -896,7 +895,7 @@ const Q = [
896
895
  },
897
896
  {
898
897
  label: "sheet.numfmt.text",
899
- pattern: Bt
898
+ pattern: Ct
900
899
  },
901
900
  "|",
902
901
  {
@@ -953,7 +952,7 @@ const Q = [
953
952
  ], Gn = (e) => ({
954
953
  icon: new L((t) => {
955
954
  var s;
956
- const r = e.get(Rt);
955
+ const r = e.get(Ut);
957
956
  function n(o) {
958
957
  var c;
959
958
  return (c = {
@@ -970,7 +969,7 @@ const Q = [
970
969
  t.next(n(a));
971
970
  });
972
971
  }),
973
- id: Xe.id,
972
+ id: qe.id,
974
973
  title: "sheet.numfmt.currency",
975
974
  tooltip: "sheet.numfmt.currency",
976
975
  type: X.BUTTON,
@@ -978,7 +977,7 @@ const Q = [
978
977
  disabled$: W(e, { workbookTypes: [Y], worksheetTypes: [Z, K], rangeTypes: [G] })
979
978
  }), Kn = (e) => ({
980
979
  icon: "AddDigitsIcon",
981
- id: ze.id,
980
+ id: Xe.id,
982
981
  title: "sheet.numfmt.addDecimal",
983
982
  tooltip: "sheet.numfmt.addDecimal",
984
983
  type: X.BUTTON,
@@ -986,7 +985,7 @@ const Q = [
986
985
  disabled$: W(e, { workbookTypes: [Y], worksheetTypes: [Z, K], rangeTypes: [G] })
987
986
  }), Zn = (e) => ({
988
987
  icon: "ReduceDigitsIcon",
989
- id: Ye.id,
988
+ id: ze.id,
990
989
  title: "sheet.numfmt.subtractDecimal",
991
990
  tooltip: "sheet.numfmt.subtractDecimal",
992
991
  type: X.BUTTON,
@@ -994,14 +993,14 @@ const Q = [
994
993
  disabled$: W(e, { workbookTypes: [Y], worksheetTypes: [Z, K], rangeTypes: [G] })
995
994
  }), Yn = (e) => ({
996
995
  icon: "PercentIcon",
997
- id: Ze.id,
996
+ id: Ye.id,
998
997
  title: "sheet.numfmt.percent",
999
998
  tooltip: "sheet.numfmt.percent",
1000
999
  type: X.BUTTON,
1001
1000
  hidden$: z(e, T.UNIVER_SHEET),
1002
1001
  disabled$: W(e, { workbookTypes: [Y], worksheetTypes: [Z, K], rangeTypes: [G] })
1003
1002
  }), zn = (e) => {
1004
- const t = e.get(ge), r = e.get(_e), n = e.get(M), i = e.get(Ce), s = [be.id, Ie.id], o = Lt(
1003
+ const t = e.get(ge), r = e.get(_e), n = e.get(M), i = e.get(Ce), s = [be.id, Ie.id], o = jt(
1005
1004
  t,
1006
1005
  "",
1007
1006
  ({ workbook: a, worksheet: c }) => new L(
@@ -1016,7 +1015,7 @@ const Q = [
1016
1015
  if (h && h[0]) {
1017
1016
  const v = h[0].range, p = v.startRow, m = v.startColumn, S = (f = a.getStyles().get((l = c.getCell(p, m)) == null ? void 0 : l.s)) == null ? void 0 : f.n, g = S == null ? void 0 : S.pattern;
1018
1017
  let y = n.t("sheet.numfmt.general");
1019
- if (jt(g)) {
1018
+ if (yt(g)) {
1020
1019
  u.next(y);
1021
1020
  return;
1022
1021
  }
@@ -1054,14 +1053,14 @@ const Q = [
1054
1053
  const { value: t } = e, r = I(M), n = t != null ? t : r.t("sheet.numfmt.general");
1055
1054
  return /* @__PURE__ */ d("span", { className: "univer-text-sm", children: n });
1056
1055
  }, qn = () => {
1057
- const e = I(_e), t = I(M), r = I(Jt), n = I(Ge), i = I(Ce), s = (c) => {
1056
+ const e = I(_e), t = I(M), r = I(Jt), n = I(Ke), i = I(Ce), s = (c) => {
1058
1057
  const u = i.getCurrentLastSelection();
1059
1058
  if (!u)
1060
1059
  return;
1061
1060
  const h = u.range, l = [];
1062
- He.foreach(h, (f, v) => {
1061
+ je.foreach(h, (f, v) => {
1063
1062
  c ? l.push({ row: f, col: v, pattern: c, type: Se(c) }) : l.push({ row: f, col: v });
1064
- }), e.executeCommand(Ke.id, { values: l }), r.focus();
1063
+ }), e.executeCommand(Ze.id, { values: l }), r.focus();
1065
1064
  }, o = (c) => {
1066
1065
  if (c === 0)
1067
1066
  s(null);
@@ -1081,26 +1080,26 @@ const Q = [
1081
1080
  },
1082
1081
  children: [
1083
1082
  /* @__PURE__ */ d("span", { children: t.t(c.label) }),
1084
- /* @__PURE__ */ d("span", { className: "univer-text-xs univer-text-gray-500", children: c.pattern ? Ot(c.pattern || "", a, n.local).result.trim() : "" })
1083
+ /* @__PURE__ */ d("span", { className: "univer-text-xs univer-text-gray-500", children: c.pattern ? kt(c.pattern || "", a, n.local).result.trim() : "" })
1085
1084
  ]
1086
1085
  },
1087
1086
  u
1088
1087
  )) });
1089
1088
  }, Jn = {
1090
1089
  [Qt.FORMULAS]: {
1091
- [Xe.id]: {
1090
+ [qe.id]: {
1092
1091
  order: 0,
1093
1092
  menuItemFactory: Gn
1094
1093
  },
1095
- [ze.id]: {
1094
+ [Xe.id]: {
1096
1095
  order: 1,
1097
1096
  menuItemFactory: Kn
1098
1097
  },
1099
- [Ye.id]: {
1098
+ [ze.id]: {
1100
1099
  order: 2,
1101
1100
  menuItemFactory: Zn
1102
1101
  },
1103
- [Ze.id]: {
1102
+ [Ye.id]: {
1104
1103
  order: 3,
1105
1104
  menuItemFactory: Yn
1106
1105
  },
@@ -1140,10 +1139,10 @@ var tr = Object.defineProperty, nr = Object.getOwnPropertyDescriptor, rr = (e, t
1140
1139
  return i;
1141
1140
  }, fe = (e, t) => (r, n) => t(r, n, e), lt = (e, t, r) => rr(e, typeof t != "symbol" ? t + "" : t, r);
1142
1141
  const sr = "SHEET_NUMFMT_UI_PLUGIN";
1143
- let re = class extends Ct {
1142
+ let re = class extends It {
1144
1143
  constructor(e = Ue, t, r, n) {
1145
1144
  super(), this._config = e, this._injector = t, this._configService = r, this._renderManagerService = n;
1146
- const { menu: i, ...s } = bt(
1145
+ const { menu: i, ...s } = Nt(
1147
1146
  {},
1148
1147
  Ue,
1149
1148
  this._config
@@ -1151,7 +1150,7 @@ let re = class extends Ct {
1151
1150
  i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig("sheets-numfmt-ui.config", s);
1152
1151
  }
1153
1152
  onStarting() {
1154
- It(this._injector, [
1153
+ Et(this._injector, [
1155
1154
  [B],
1156
1155
  [te],
1157
1156
  [j],
@@ -1159,7 +1158,7 @@ let re = class extends Ct {
1159
1158
  ]);
1160
1159
  }
1161
1160
  onRendered() {
1162
- this._registerRenderModules(), Nt(this._injector, [
1161
+ this._registerRenderModules(), Tt(this._injector, [
1163
1162
  [B],
1164
1163
  [te],
1165
1164
  [ne]
@@ -1176,10 +1175,10 @@ let re = class extends Ct {
1176
1175
  lt(re, "pluginName", sr);
1177
1176
  lt(re, "type", T.UNIVER_SHEET);
1178
1177
  re = ir([
1179
- yt(Ht, Ut),
1180
- fe(1, C(je)),
1178
+ bt(Bt, Dt),
1179
+ fe(1, C(Be)),
1181
1180
  fe(2, Fe),
1182
- fe(3, Be)
1181
+ fe(3, Ve)
1183
1182
  ], re);
1184
1183
  export {
1185
1184
  re as UniverSheetsNumfmtUIPlugin
package/lib/index.js CHANGED
@@ -1,11 +1,10 @@
1
1
  var dt = Object.defineProperty;
2
2
  var ht = (e, t, r) => t in e ? dt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var q = (e, t, r) => ht(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Inject as C, LocaleService as M, IConfigService as Fe, Disposable as ie, isRealNum as ft, CommandType as Ae, ILocalStorageService as Le, isPatternEqualWithoutDecimal as se, numfmt as J, ThemeService as vt, IUniverInstanceService as ge, ICommandService as _e, UniverInstanceType as T, CellValueType as U, toDisposable as ve, DisposableCollection as pt, InterceptorEffectEnum as Pe, Range as He, Injector as je, Optional as gt, willLoseNumericPrecision as _t, fromCallback as St, DependentOn as yt, Plugin as Ct, merge as bt, registerDependencies as It, touchDependencies as Nt } from "@univerjs/core";
5
- import { IRenderManagerService as Be } from "@univerjs/engine-render";
6
- import { SHEETS_NUMFMT_PLUGIN_CONFIG_KEY as Et, currencySymbols as Re, getDecimalFromPattern as ee, getCurrencyType as V, setPatternDecimal as R, getCurrencyFormatOptions as le, CURRENCYFORMAT as Tt, DATEFMTLISG as Mt, NUMBERFORMAT as wt, getDateFormatOptions as Ve, getNumberFormatOptions as We, isPatternHasDecimal as xt, SheetsNumfmtCellContentController as Ge, getPatternPreviewIgnoreGeneral as Pt, getPatternType as Se, SetNumfmtCommand as Ke, SetPercentCommand as Ze, SubtractDecimalCommand as Ye, AddDecimalCommand as ze, SetCurrencyCommand as Xe, MenuCurrencyService as Rt, countryCurrencyMap as D, getPatternPreview as Ot, UniverSheetsNumfmtPlugin as Ut } from "@univerjs/sheets-numfmt";
7
- import { HoverManagerService as kt, CellAlertManagerService as Dt, CellAlertType as $t, SheetSkeletonManagerService as Ft, IEditorBridgeService as At, deriveStateFromActiveSheet$ as Lt, getCurrentRangeDisable$ as W, UniverSheetsUIPlugin as Ht } from "@univerjs/sheets-ui";
8
- import { isTextFormat as qe, isDefaultFormat as jt, DEFAULT_TEXT_FORMAT_EXCEL as Bt } from "@univerjs/engine-numfmt";
4
+ import { Inject as C, LocaleService as M, IConfigService as Fe, Disposable as ie, isTextFormat as Ae, isRealNum as ft, CommandType as Le, ILocalStorageService as He, isPatternEqualWithoutDecimal as se, numfmt as J, ThemeService as vt, IUniverInstanceService as ge, ICommandService as _e, UniverInstanceType as T, CellValueType as U, toDisposable as ve, DisposableCollection as pt, InterceptorEffectEnum as Pe, Range as je, Injector as Be, Optional as gt, willLoseNumericPrecision as _t, fromCallback as St, isDefaultFormat as yt, DEFAULT_TEXT_FORMAT_EXCEL as Ct, DependentOn as bt, Plugin as It, merge as Nt, registerDependencies as Et, touchDependencies as Tt } from "@univerjs/core";
5
+ import { IRenderManagerService as Ve } from "@univerjs/engine-render";
6
+ import { SHEETS_NUMFMT_PLUGIN_CONFIG_KEY as Mt, currencySymbols as Re, getDecimalFromPattern as ee, getCurrencyType as V, setPatternDecimal as R, getCurrencyFormatOptions as le, CURRENCYFORMAT as wt, DATEFMTLISG as xt, NUMBERFORMAT as Pt, getDateFormatOptions as We, getNumberFormatOptions as Ge, isPatternHasDecimal as Rt, SheetsNumfmtCellContentController as Ke, getPatternPreviewIgnoreGeneral as Ot, getPatternType as Se, SetNumfmtCommand as Ze, SetPercentCommand as Ye, SubtractDecimalCommand as ze, AddDecimalCommand as Xe, SetCurrencyCommand as qe, MenuCurrencyService as Ut, countryCurrencyMap as D, getPatternPreview as kt, UniverSheetsNumfmtPlugin as Dt } from "@univerjs/sheets-numfmt";
7
+ import { HoverManagerService as $t, CellAlertManagerService as Ft, CellAlertType as At, SheetSkeletonManagerService as Lt, IEditorBridgeService as Ht, deriveStateFromActiveSheet$ as jt, getCurrentRangeDisable$ as W, UniverSheetsUIPlugin as Bt } from "@univerjs/sheets-ui";
9
8
  import { INumfmtService as ye, SheetInterceptorService as Je, SheetsSelectionsService as Ce, INTERCEPTOR_POINT as Vt, RemoveNumfmtMutation as be, SetNumfmtMutation as Ie, BEFORE_CELL_EDIT as Wt, AFTER_CELL_EDIT as Gt, SetRangeValuesCommand as Kt, transformCellsToRange as Zt, factorySetNumfmtUndoMutation as Yt, factoryRemoveNumfmtUndoMutation as zt, RangeProtectionPermissionEditPoint as G, WorksheetSetCellStylePermission as K, WorksheetEditPermission as Z, WorkbookEditablePermission as Y } from "@univerjs/sheets";
10
9
  import { IZenZoneService as Xt, useDependency as I, ComponentManager as Qe, ISidebarService as qt, getMenuHiddenObservable as z, MenuItemType as X, ILayoutService as Jt, RibbonDataGroup as Qt, IMenuManagerService as en } from "@univerjs/ui";
11
10
  import { debounceTime as tn, merge as et, Observable as L, combineLatest as nn, filter as rn } from "rxjs";
@@ -44,14 +43,14 @@ let pe = class extends ie {
44
43
  this._hideAlert();
45
44
  return;
46
45
  }
47
- if (qe(c.pattern) && (u != null && u.v) && ft(u.v)) {
48
- if ((t = this._configService.getConfig(Et)) != null && t.disableTextFormatAlert)
46
+ if (Ae(c.pattern) && (u != null && u.v) && ft(u.v)) {
47
+ if ((t = this._configService.getConfig(Mt)) != null && t.disableTextFormatAlert)
49
48
  return;
50
49
  const h = this._cellAlertManagerService.currentAlert.get(ue), l = (r = h == null ? void 0 : h.alert) == null ? void 0 : r.location;
51
50
  if (l && l.row === n.row && l.col === n.col && l.subUnitId === n.subUnitId && l.unitId === n.unitId)
52
51
  return;
53
52
  this._cellAlertManagerService.showAlert({
54
- type: $t.ERROR,
53
+ type: At.ERROR,
55
54
  title: this._localeService.t("info.error"),
56
55
  message: this._localeService.t("info.forceStringInfo"),
57
56
  location: n,
@@ -75,8 +74,8 @@ let pe = class extends ie {
75
74
  }
76
75
  };
77
76
  pe = pn([
78
- $(1, C(kt)),
79
- $(2, C(Dt)),
77
+ $(1, C($t)),
78
+ $(2, C(Ft)),
80
79
  $(3, C(M)),
81
80
  $(4, Xt),
82
81
  $(5, C(ye)),
@@ -84,14 +83,14 @@ pe = pn([
84
83
  ], pe);
85
84
  const me = {
86
85
  id: "sheet.operation.close.numfmt.panel",
87
- type: Ae.OPERATION,
86
+ type: Le.OPERATION,
88
87
  handler: () => (
89
88
  // do nothing, just notify panel is closed
90
89
  !0
91
90
  )
92
91
  }, H = {
93
92
  id: "sheet.operation.open.numfmt.panel",
94
- type: Ae.OPERATION,
93
+ type: Le.OPERATION,
95
94
  handler: (e) => (e.get(B).openPanel(), !0)
96
95
  };
97
96
  var gn = Object.getOwnPropertyDescriptor, _n = (e, t, r, n) => {
@@ -145,7 +144,7 @@ let j = class {
145
144
  }
146
145
  };
147
146
  j = _n([
148
- Sn(0, C(Le))
147
+ Sn(0, C(He))
149
148
  ], j);
150
149
  const ke = "numfmtCurrency", yn = (e) => {
151
150
  const t = I(j), [r, n] = N(Re);
@@ -311,7 +310,7 @@ var Pn = { tag: "svg", attrs: { xmlns: "http://www.w3.org/2000/svg", fill: "none
311
310
  ot.displayName = "CheckMarkIcon";
312
311
  const de = "customFormat", he = "numfmt_custom_pattern";
313
312
  function Rn(e) {
314
- const { defaultPattern: t, action: r, onChange: n } = e, i = I(j), s = I(Le), o = I(M), [a, c] = N(t);
313
+ const { defaultPattern: t, action: r, onChange: n } = e, i = I(j), s = I(He), o = I(M), [a, c] = N(t);
315
314
  r.current = () => (i.markHabit(de, a), s.getItem(he).then((v = []) => {
316
315
  const p = [.../* @__PURE__ */ new Set([a, ...v || []])].splice(0, 10).filter((m) => !!m);
317
316
  s.setItem(he, p);
@@ -320,9 +319,9 @@ function Rn(e) {
320
319
  oe(() => {
321
320
  s.getItem(he).then((v) => {
322
321
  const p = [
323
- ...Tt.map((m) => m.suffix("$")),
324
- ...Mt.map((m) => m.suffix),
325
- ...wt.map((m) => m.suffix)
322
+ ...wt.map((m) => m.suffix("$")),
323
+ ...xt.map((m) => m.suffix),
324
+ ...Pt.map((m) => m.suffix)
326
325
  ];
327
326
  p.push(...v || []), i.addHabit(de, []).finally(() => {
328
327
  i.getHabit(de, p).then((m) => {
@@ -377,10 +376,10 @@ function Rn(e) {
377
376
  }
378
377
  const On = (e) => {
379
378
  const t = J.getFormatInfo(e);
380
- return Ve().map((r) => r.value).includes(e) || ["date", "datetime", "time"].includes(t.type);
379
+ return We().map((r) => r.value).includes(e) || ["date", "datetime", "time"].includes(t.type);
381
380
  };
382
381
  function Un(e) {
383
- const { onChange: t, defaultPattern: r } = e, n = O(Ve, []), i = I(M), [s, o] = N(() => {
382
+ const { onChange: t, defaultPattern: r } = e, n = O(We, []), i = I(M), [s, o] = N(() => {
384
383
  if (r) {
385
384
  const c = n.find((u) => u.value === r);
386
385
  if (c)
@@ -413,12 +412,12 @@ const kn = (e) => !e, Dn = (e) => {
413
412
  children: r("sheet.numfmt.generalDes")
414
413
  }
415
414
  ) });
416
- }, $n = (e) => We().some((t) => se(t.value, e));
415
+ }, $n = (e) => Ge().some((t) => se(t.value, e));
417
416
  function Fn(e) {
418
- const t = I(M), r = O(We, []), [n, i] = N(() => ee(e.defaultPattern || "", 0)), [s, o] = N(() => {
417
+ const t = I(M), r = O(Ge, []), [n, i] = N(() => ee(e.defaultPattern || "", 0)), [s, o] = N(() => {
419
418
  const l = r.find((f) => se(f.value, e.defaultPattern || ""));
420
419
  return (l == null ? void 0 : l.value) || r[0].value;
421
- }), a = O(() => R(s, Number(n || 0)), [s, n]), c = O(() => !xt(s), [s]), u = (l) => {
420
+ }), a = O(() => R(s, Number(n || 0)), [s, n]), c = O(() => !Rt(s), [s]), u = (l) => {
422
421
  i(l || 0), e.onChange(R(s, Number(l || 0)));
423
422
  }, h = (l) => {
424
423
  l !== void 0 && (i(ee(l, 0)), o(l), e.onChange(l));
@@ -553,7 +552,7 @@ let B = class extends ie {
553
552
  else if (g.type === "confirm") {
554
553
  const x = ((y = r.getCurrentSelections()) == null ? void 0 : y.map((F) => F.range)) || [], P = { values: [] }, ce = Se(g.value);
555
554
  x.forEach((F) => {
556
- He.foreach(F, (ae, _) => {
555
+ je.foreach(F, (ae, _) => {
557
556
  P.values.push({
558
557
  row: ae,
559
558
  col: _,
@@ -561,7 +560,7 @@ let B = class extends ie {
561
560
  type: ce
562
561
  });
563
562
  });
564
- }), n.executeCommand(Ke.id, P), t.close();
563
+ }), n.executeCommand(Ze.id, P), t.close();
565
564
  } else g.type === "cancel" && t.close();
566
565
  },
567
566
  value: { defaultPattern: v, defaultValue: p, row: c.startRow, col: c.startColumn }
@@ -583,7 +582,7 @@ let B = class extends ie {
583
582
  const r = this._renderManagerService.getRenderById(
584
583
  t != null ? t : this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET).getUnitId()
585
584
  );
586
- r == null || r.with(Ft).reCalculate(), (n = r == null ? void 0 : r.mainComponent) == null || n.makeDirty();
585
+ r == null || r.with(Lt).reCalculate(), (n = r == null ? void 0 : r.mainComponent) == null || n.makeDirty();
587
586
  }
588
587
  _initCommands() {
589
588
  [
@@ -640,7 +639,7 @@ let B = class extends ie {
640
639
  const m = u.worksheet.getCellRaw(l, f), S = m == null ? void 0 : m.v, g = m == null ? void 0 : m.t;
641
640
  if (S == null || g !== U.NUMBER || this._previewPattern === null)
642
641
  return v;
643
- const y = Pt(this._previewPattern, S, this._sheetsNumfmtCellContentController.local);
642
+ const y = Ot(this._previewPattern, S, this._sheetsNumfmtCellContentController.local);
644
643
  if (y.color) {
645
644
  const x = (p = this._themeService.getColorFromTheme(`${y.color}.500`)) != null ? p : y.color;
646
645
  return {
@@ -691,12 +690,12 @@ B = Hn([
691
690
  w(2, ge),
692
691
  w(3, _e),
693
692
  w(4, C(Ce)),
694
- w(5, Be),
693
+ w(5, Ve),
695
694
  w(6, ye),
696
695
  w(7, C(Qe)),
697
696
  w(8, qt),
698
697
  w(9, C(M)),
699
- w(10, C(Ge))
698
+ w(10, C(Ke))
700
699
  ], B);
701
700
  var jn = Object.getOwnPropertyDescriptor, Bn = (e, t, r, n) => {
702
701
  for (var i = n > 1 ? void 0 : n ? jn(t, r) : t, s = e.length - 1, o; s >= 0; s--)
@@ -773,7 +772,7 @@ let te = class extends ie {
773
772
  r.row,
774
773
  r.col
775
774
  );
776
- if (!(t != null && t.v) && !(t != null && t.p) || qe(i == null ? void 0 : i.pattern) || t.t === U.FORCE_STRING)
775
+ if (!(t != null && t.v) && !(t != null && t.p) || Ae(i == null ? void 0 : i.pattern) || t.t === U.FORCE_STRING)
777
776
  return n(t);
778
777
  const s = (c = t.p) == null ? void 0 : c.body, o = (h = (u = t == null ? void 0 : t.p) == null ? void 0 : u.body) != null && h.dataStream ? t.p.body.dataStream.replace(/\r\n$/, "") : String(t.v), a = J.parseDate(o) || J.parseTime(o) || J.parseNumber(o);
779
778
  if (s)
@@ -882,8 +881,8 @@ te = Bn([
882
881
  A(0, C(Je)),
883
882
  A(1, C(ye)),
884
883
  A(2, C(ge)),
885
- A(3, C(je)),
886
- A(4, gt(At))
884
+ A(3, C(Be)),
885
+ A(4, gt(Ht))
887
886
  ], te);
888
887
  function Wn(e) {
889
888
  const { textRuns: t = [], paragraphs: r = [], customRanges: n, customBlocks: i = [] } = e, s = ["va"];
@@ -896,7 +895,7 @@ const Q = [
896
895
  },
897
896
  {
898
897
  label: "sheet.numfmt.text",
899
- pattern: Bt
898
+ pattern: Ct
900
899
  },
901
900
  "|",
902
901
  {
@@ -953,7 +952,7 @@ const Q = [
953
952
  ], Gn = (e) => ({
954
953
  icon: new L((t) => {
955
954
  var s;
956
- const r = e.get(Rt);
955
+ const r = e.get(Ut);
957
956
  function n(o) {
958
957
  var c;
959
958
  return (c = {
@@ -970,7 +969,7 @@ const Q = [
970
969
  t.next(n(a));
971
970
  });
972
971
  }),
973
- id: Xe.id,
972
+ id: qe.id,
974
973
  title: "sheet.numfmt.currency",
975
974
  tooltip: "sheet.numfmt.currency",
976
975
  type: X.BUTTON,
@@ -978,7 +977,7 @@ const Q = [
978
977
  disabled$: W(e, { workbookTypes: [Y], worksheetTypes: [Z, K], rangeTypes: [G] })
979
978
  }), Kn = (e) => ({
980
979
  icon: "AddDigitsIcon",
981
- id: ze.id,
980
+ id: Xe.id,
982
981
  title: "sheet.numfmt.addDecimal",
983
982
  tooltip: "sheet.numfmt.addDecimal",
984
983
  type: X.BUTTON,
@@ -986,7 +985,7 @@ const Q = [
986
985
  disabled$: W(e, { workbookTypes: [Y], worksheetTypes: [Z, K], rangeTypes: [G] })
987
986
  }), Zn = (e) => ({
988
987
  icon: "ReduceDigitsIcon",
989
- id: Ye.id,
988
+ id: ze.id,
990
989
  title: "sheet.numfmt.subtractDecimal",
991
990
  tooltip: "sheet.numfmt.subtractDecimal",
992
991
  type: X.BUTTON,
@@ -994,14 +993,14 @@ const Q = [
994
993
  disabled$: W(e, { workbookTypes: [Y], worksheetTypes: [Z, K], rangeTypes: [G] })
995
994
  }), Yn = (e) => ({
996
995
  icon: "PercentIcon",
997
- id: Ze.id,
996
+ id: Ye.id,
998
997
  title: "sheet.numfmt.percent",
999
998
  tooltip: "sheet.numfmt.percent",
1000
999
  type: X.BUTTON,
1001
1000
  hidden$: z(e, T.UNIVER_SHEET),
1002
1001
  disabled$: W(e, { workbookTypes: [Y], worksheetTypes: [Z, K], rangeTypes: [G] })
1003
1002
  }), zn = (e) => {
1004
- const t = e.get(ge), r = e.get(_e), n = e.get(M), i = e.get(Ce), s = [be.id, Ie.id], o = Lt(
1003
+ const t = e.get(ge), r = e.get(_e), n = e.get(M), i = e.get(Ce), s = [be.id, Ie.id], o = jt(
1005
1004
  t,
1006
1005
  "",
1007
1006
  ({ workbook: a, worksheet: c }) => new L(
@@ -1016,7 +1015,7 @@ const Q = [
1016
1015
  if (h && h[0]) {
1017
1016
  const v = h[0].range, p = v.startRow, m = v.startColumn, S = (f = a.getStyles().get((l = c.getCell(p, m)) == null ? void 0 : l.s)) == null ? void 0 : f.n, g = S == null ? void 0 : S.pattern;
1018
1017
  let y = n.t("sheet.numfmt.general");
1019
- if (jt(g)) {
1018
+ if (yt(g)) {
1020
1019
  u.next(y);
1021
1020
  return;
1022
1021
  }
@@ -1054,14 +1053,14 @@ const Q = [
1054
1053
  const { value: t } = e, r = I(M), n = t != null ? t : r.t("sheet.numfmt.general");
1055
1054
  return /* @__PURE__ */ d("span", { className: "univer-text-sm", children: n });
1056
1055
  }, qn = () => {
1057
- const e = I(_e), t = I(M), r = I(Jt), n = I(Ge), i = I(Ce), s = (c) => {
1056
+ const e = I(_e), t = I(M), r = I(Jt), n = I(Ke), i = I(Ce), s = (c) => {
1058
1057
  const u = i.getCurrentLastSelection();
1059
1058
  if (!u)
1060
1059
  return;
1061
1060
  const h = u.range, l = [];
1062
- He.foreach(h, (f, v) => {
1061
+ je.foreach(h, (f, v) => {
1063
1062
  c ? l.push({ row: f, col: v, pattern: c, type: Se(c) }) : l.push({ row: f, col: v });
1064
- }), e.executeCommand(Ke.id, { values: l }), r.focus();
1063
+ }), e.executeCommand(Ze.id, { values: l }), r.focus();
1065
1064
  }, o = (c) => {
1066
1065
  if (c === 0)
1067
1066
  s(null);
@@ -1081,26 +1080,26 @@ const Q = [
1081
1080
  },
1082
1081
  children: [
1083
1082
  /* @__PURE__ */ d("span", { children: t.t(c.label) }),
1084
- /* @__PURE__ */ d("span", { className: "univer-text-xs univer-text-gray-500", children: c.pattern ? Ot(c.pattern || "", a, n.local).result.trim() : "" })
1083
+ /* @__PURE__ */ d("span", { className: "univer-text-xs univer-text-gray-500", children: c.pattern ? kt(c.pattern || "", a, n.local).result.trim() : "" })
1085
1084
  ]
1086
1085
  },
1087
1086
  u
1088
1087
  )) });
1089
1088
  }, Jn = {
1090
1089
  [Qt.FORMULAS]: {
1091
- [Xe.id]: {
1090
+ [qe.id]: {
1092
1091
  order: 0,
1093
1092
  menuItemFactory: Gn
1094
1093
  },
1095
- [ze.id]: {
1094
+ [Xe.id]: {
1096
1095
  order: 1,
1097
1096
  menuItemFactory: Kn
1098
1097
  },
1099
- [Ye.id]: {
1098
+ [ze.id]: {
1100
1099
  order: 2,
1101
1100
  menuItemFactory: Zn
1102
1101
  },
1103
- [Ze.id]: {
1102
+ [Ye.id]: {
1104
1103
  order: 3,
1105
1104
  menuItemFactory: Yn
1106
1105
  },
@@ -1140,10 +1139,10 @@ var tr = Object.defineProperty, nr = Object.getOwnPropertyDescriptor, rr = (e, t
1140
1139
  return i;
1141
1140
  }, fe = (e, t) => (r, n) => t(r, n, e), lt = (e, t, r) => rr(e, typeof t != "symbol" ? t + "" : t, r);
1142
1141
  const sr = "SHEET_NUMFMT_UI_PLUGIN";
1143
- let re = class extends Ct {
1142
+ let re = class extends It {
1144
1143
  constructor(e = Ue, t, r, n) {
1145
1144
  super(), this._config = e, this._injector = t, this._configService = r, this._renderManagerService = n;
1146
- const { menu: i, ...s } = bt(
1145
+ const { menu: i, ...s } = Nt(
1147
1146
  {},
1148
1147
  Ue,
1149
1148
  this._config
@@ -1151,7 +1150,7 @@ let re = class extends Ct {
1151
1150
  i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig("sheets-numfmt-ui.config", s);
1152
1151
  }
1153
1152
  onStarting() {
1154
- It(this._injector, [
1153
+ Et(this._injector, [
1155
1154
  [B],
1156
1155
  [te],
1157
1156
  [j],
@@ -1159,7 +1158,7 @@ let re = class extends Ct {
1159
1158
  ]);
1160
1159
  }
1161
1160
  onRendered() {
1162
- this._registerRenderModules(), Nt(this._injector, [
1161
+ this._registerRenderModules(), Tt(this._injector, [
1163
1162
  [B],
1164
1163
  [te],
1165
1164
  [ne]
@@ -1176,10 +1175,10 @@ let re = class extends Ct {
1176
1175
  lt(re, "pluginName", sr);
1177
1176
  lt(re, "type", T.UNIVER_SHEET);
1178
1177
  re = ir([
1179
- yt(Ht, Ut),
1180
- fe(1, C(je)),
1178
+ bt(Bt, Dt),
1179
+ fe(1, C(Be)),
1181
1180
  fe(2, Fe),
1182
- fe(3, Be)
1181
+ fe(3, Ve)
1183
1182
  ], re);
1184
1183
  export {
1185
1184
  re as UniverSheetsNumfmtUIPlugin
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/engine-numfmt"),require("@univerjs/sheets"),require("@univerjs/ui"),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/engine-numfmt","@univerjs/sheets","@univerjs/ui","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.UniverEngineNumfmt,C.UniverSheets,C.UniverUi,C.rxjs,C.rxjs.operators,C.React,C.React,C.UniverDesign))})(this,function(C,s,k,d,D,W,g,_,x,V,l,y,T){"use strict";var st=Object.defineProperty;var ot=(C,s,k)=>s in C?st(C,s,{enumerable:!0,configurable:!0,writable:!0,value:k}):C[s]=k;var K=(C,s,k)=>ot(C,typeof s!="symbol"?s+"":s,k);const re={};var ve=Object.getOwnPropertyDescriptor,pe=(e,n,r,t)=>{for(var i=t>1?void 0:t?ve(n,r):n,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},j=(e,n)=>(r,t)=>n(r,t,e);const Z="SHEET_NUMFMT_ALERT";let Y=class extends s.Disposable{constructor(e,n,r,t,i,a,o){super(),this._context=e,this._hoverManagerService=n,this._cellAlertManagerService=r,this._localeService=t,this._zenZoneService=i,this._numfmtService=a,this._configService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(x.debounceTime(100)).subscribe(e=>{var n,r;if(e){const t=e.location,i=this._context.unit,a=i.getActiveSheet();if(!a)return;const o=t.unitId,u=t.subUnitId;let c;const v=a.getCell(t.row,t.col);if(v!=null&&v.s){const f=i.getStyles().get(v.s);f!=null&&f.n&&(c=f.n)}if(c||(c=this._numfmtService.getValue(o,u,t.row,t.col)),!c){this._hideAlert();return}if(W.isTextFormat(c.pattern)&&(v!=null&&v.v)&&s.isRealNum(v.v)){if((n=this._configService.getConfig(d.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&n.disableTextFormatAlert)return;const f=this._cellAlertManagerService.currentAlert.get(Z),m=(r=f==null?void 0:f.alert)==null?void 0:r.location;if(m&&m.row===t.row&&m.col===t.col&&m.subUnitId===t.subUnitId&&m.unitId===t.unitId)return;this._cellAlertManagerService.showAlert({type:D.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:t,width:200,height:74,key:Z});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(Z)}};Y=pe([j(1,s.Inject(D.HoverManagerService)),j(2,s.Inject(D.CellAlertManagerService)),j(3,s.Inject(s.LocaleService)),j(4,_.IZenZoneService),j(5,s.Inject(g.INumfmtService)),j(6,s.IConfigService)],Y);const z={id:"sheet.operation.close.numfmt.panel",type:s.CommandType.OPERATION,handler:()=>!0},L={id:"sheet.operation.open.numfmt.panel",type:s.CommandType.OPERATION,handler:e=>(e.get(H).openPanel(),!0)};var fe=Object.getOwnPropertyDescriptor,he=(e,n,r,t)=>{for(var i=t>1?void 0:t?fe(n,r):n,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},ge=(e,n)=>(r,t)=>n(r,t,e);const X=y.createContext([]);let F=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,n){const r=this._getKey(e);return this._localStorageService.getItem(r).then(t=>{t||this._localStorageService.setItem(r,n)})}markHabit(e,n){const r=this._getKey(e);this._localStorageService.getItem(r).then(t=>{if(t){const i=t.findIndex(a=>a===n);i>-1&&t.splice(i,1),t.unshift(n),this._localStorageService.setItem(r,t)}})}async getHabit(e,n){const r=this._getKey(e),t=await this._localStorageService.getItem(r);if(n&&t){const i=t.map((a,o,u)=>{const c=u.length;return{value:a,priority:c-o}});return n.sort((a,o)=>{var v,f;const u=((v=i.find(m=>m.value===a))==null?void 0:v.priority)||-1;return(((f=i.find(m=>m.value===o))==null?void 0:f.priority)||-1)-u})}return t||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};F=he([ge(0,s.Inject(s.ILocalStorageService))],F);const ie="numfmtCurrency",Se=e=>{const n=_.useDependency(F),[r,t]=y.useState(d.currencySymbols);return y.useEffect(()=>{n.addHabit("numfmtCurrency",[]).then(()=>{n.getHabit(ie,[...d.currencySymbols]).then(a=>{t(a),e&&e(a)})})},[]),{userHabitCurrency:r,mark:a=>{n.markHabit(ie,a)}}},ye=()=>{const e=y.useRef([]),[n,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[n]),i=>{e.current.push(i),r({})}},_e=e=>!!d.getCurrencyType(e)&&e.startsWith("_("),Ce=e=>{const{defaultPattern:n,action:r,onChange:t}=e,[i,a]=y.useState(()=>d.getDecimalFromPattern(n||"",2)),o=y.useContext(X),[u,c]=y.useState(()=>d.getCurrencyType(n)||o[0]),v=y.useMemo(()=>o.map(b=>({label:b,value:b})),[]),m=_.useDependency(s.LocaleService).t;r.current=()=>d.setPatternDecimal(`_("${u}"* #,##0${i>0?".0":""}_)`,i);const h=b=>{c(b),t(d.setPatternDecimal(`_("${b}"* #,##0${i>0?".0":""}_)`,i))},S=b=>{const p=b||0;a(p),t(d.setPatternDecimal(`_("${u}"* #,##0${p>0?".0":""}_)`,p))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(T.InputNumber,{value:i,step:1,precision:0,max:20,min:0,onChange:S})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(T.Select,{options:v,value:u,onChange:h})})]})]}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.accountingDes")})]})},be=e=>!!d.getCurrencyType(e)&&!e.startsWith("_("),Ie=e=>{const r=_.useDependency(s.LocaleService).t,t=y.useContext(X),[i,a]=y.useState(()=>d.getCurrencyType(e.defaultPattern)||t[0]),[o,u]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",2)),[c,v]=y.useState(()=>{var I;const p=d.getCurrencyFormatOptions(i);return((I=p.find(M=>s.isPatternEqualWithoutDecimal(M.value,e.defaultPattern)))==null?void 0:I.value)||p[0].value}),f=y.useMemo(()=>d.getCurrencyFormatOptions(i),[i]),m=y.useMemo(()=>t.map(p=>({label:p,value:p})),[t]);e.action.current=()=>d.setPatternDecimal(c,o);const h=p=>{if(p===void 0)return;a(p);const P=d.getCurrencyFormatOptions(p)[0].value;v(P),e.onChange(d.setPatternDecimal(P,o))},S=p=>{p!==void 0&&(v(p),e.onChange(d.setPatternDecimal(p,o)))},b=p=>{u(p||0),e.onChange(d.setPatternDecimal(c,p||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(T.InputNumber,{value:o,max:20,min:0,onChange:b})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(T.Select,{value:i,options:m,onChange:h})})]})]}),l.jsx("div",{className:"label univer-mt-4",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.SelectList,{value:c,options:f,onChange:S})}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyDes")})]})};var w=function(){return w=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},w.apply(this,arguments)},Ee=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(e);i<t.length;i++)n.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(r[t[i]]=e[t[i]]);return r},ae=y.forwardRef(function(e,n){var r=e.icon,t=e.id,i=e.className,a=e.extend,o=Ee(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),c=y.useRef("_".concat(Me()));return se(r,"".concat(t),{defIds:r.defIds,idSuffix:c.current},w({ref:n,className:u},o),a)});function se(e,n,r,t,i){return y.createElement(e.tag,w(w({key:n},Te(e,r,i)),t),(Pe(e,r).children||[]).map(function(a,o){return se(a,"".concat(n,"-").concat(e.tag,"-").concat(o),r,void 0,i)}))}function Te(e,n,r){var t=w({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1),e.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(a){var o=a[0],u=a[1];o==="mask"&&typeof u=="string"&&(t[o]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(a){var o=a[0],u=a[1];typeof u=="string"&&(t[o]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Pe(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?w(w({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.includes(i.attrs.id)?w(w({},i),{attrs:w(w({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function Me(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var De={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},oe=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"check-mark-icon",ref:n,icon:De}))});oe.displayName="CheckMarkIcon";const J="customFormat",Q="numfmt_custom_pattern";function we(e){const{defaultPattern:n,action:r,onChange:t}=e,i=_.useDependency(F),a=_.useDependency(s.ILocalStorageService),o=_.useDependency(s.LocaleService),[u,c]=y.useState(n);r.current=()=>(i.markHabit(J,u),a.getItem(Q).then((S=[])=>{const b=[...new Set([u,...S||[]])].splice(0,10).filter(p=>!!p);a.setItem(Q,b)}),u);const[v,f]=y.useState([]);y.useEffect(()=>{a.getItem(Q).then(S=>{const b=[...d.CURRENCYFORMAT.map(p=>p.suffix("$")),...d.DATEFMTLISG.map(p=>p.suffix),...d.NUMBERFORMAT.map(p=>p.suffix)];b.push(...S||[]),i.addHabit(J,[]).finally(()=>{i.getHabit(J,b).then(p=>{f([...new Set(p)])})})})},[]);const m=S=>{c(S),t(S)},h=()=>{t(u)};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:o.t("sheet.numfmt.customFormat")}),l.jsx(T.Input,{placeholder:o.t("sheet.numfmt.customFormat"),onBlur:h,value:u,onChange:c,className:"univer-mt-2 univer-w-full"}),l.jsx("div",{className:T.clsx("univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2",T.borderClassName),children:v.map(S=>l.jsxs("div",{onClick:()=>m(S),className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-w-4 univer-items-center univer-text-primary-600",children:u===S&&l.jsx(oe,{})}),l.jsx("div",{children:S})]},S))}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:o.t("sheet.numfmt.customFormatDes")})]})}const Ne=e=>{const n=s.numfmt.getFormatInfo(e);return d.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(n.type)};function xe(e){const{onChange:n,defaultPattern:r}=e,t=y.useMemo(d.getDateFormatOptions,[]),i=_.useDependency(s.LocaleService),[a,o]=y.useState(()=>{if(r){const c=t.find(v=>v.value===r);if(c)return c.value}return t[0].value});e.action.current=()=>a;const u=c=>{c!==void 0&&(o(c),n(c))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:i.t("sheet.numfmt.dateType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.SelectList,{value:a,options:t,onChange:u})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.numfmt.dateDes")})]})}const Oe=e=>!e,Ue=e=>{const r=_.useDependency(s.LocaleService).t;return e.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:r("sheet.numfmt.generalDes")})})},ke=e=>d.getNumberFormatOptions().some(n=>s.isPatternEqualWithoutDecimal(n.value,e));function je(e){const n=_.useDependency(s.LocaleService),r=y.useMemo(d.getNumberFormatOptions,[]),[t,i]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",0)),[a,o]=y.useState(()=>{const m=r.find(h=>s.isPatternEqualWithoutDecimal(h.value,e.defaultPattern||""));return(m==null?void 0:m.value)||r[0].value}),u=y.useMemo(()=>d.setPatternDecimal(a,Number(t||0)),[a,t]),c=y.useMemo(()=>!d.isPatternHasDecimal(a),[a]),v=m=>{i(m||0),e.onChange(d.setPatternDecimal(a,Number(m||0)))},f=m=>{m!==void 0&&(i(d.getDecimalFromPattern(m,0)),o(m),e.onChange(m))};return e.action.current=()=>u,l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:n.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.InputNumber,{disabled:c,value:t,max:20,min:0,onChange:v})}),l.jsxs("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:[" ",n.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.SelectList,{onChange:f,options:r,value:a})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.numfmt.thousandthPercentileDes")})]})}const $e=e=>{const{defaultValue:n,defaultPattern:r,row:t,col:i}=e.value,a=_.useDependency(s.LocaleService),o=y.useRef(()=>""),u=a.t,c=ye(),v=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Ue},{label:"sheet.numfmt.accounting",component:Ce},{label:"sheet.numfmt.currency",component:Ie},{label:"sheet.numfmt.date",component:xe},{label:"sheet.numfmt.thousandthPercentile",component:je},{label:"sheet.numfmt.customFormat",component:we}].map(E=>({...E,label:u(E.label)})),[]),[f,m]=y.useState(I),[h,S]=y.useState(()=>`${t}_${i}`),{mark:b,userHabitCurrency:p}=Se(()=>S(`${t}_${i}_userCurrency'`)),P=y.useMemo(()=>{var E;return(E=v.find($=>$.label===f))==null?void 0:E.component},[f]);function I(){return[Oe,_e,be,Ne,ke].reduce(($,it,at)=>$||(it(r)?v[at].label:""),"")||v[0].label}const M=v.map(E=>({label:E.label,value:E.label})),O=E=>{m(E),c(()=>e.onChange({type:"change",value:o.current()||""}))},U=y.useCallback(E=>{e.onChange({type:"change",value:E})},[]),te=()=>{const E=o.current()||"",$=d.getCurrencyType(E);$&&b($),e.onChange({type:"confirm",value:E})},R=()=>{e.onChange({type:"cancel",value:""})},ne={onChange:U,defaultValue:n,defaultPattern:r,action:o};return y.useEffect(()=>{m(I()),S(`${t}_${i}`)},[t,i]),l.jsxs("div",{className:T.clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5",T.scrollbarClassName),children:[l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3.5 univer-text-sm univer-text-gray-400",children:u("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.Select,{className:"univer-w-full",value:f,options:M,onChange:O})}),l.jsx("div",{children:P&&l.jsx(X.Provider,{value:p,children:y.createElement(P,{...ne,key:h})})})]}),l.jsxs("div",{className:"univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end",children:[l.jsx(T.Button,{onClick:R,className:"univer-mr-3",children:u("sheet.numfmt.cancel")}),l.jsx(T.Button,{variant:"primary",onClick:te,children:u("sheet.numfmt.confirm")})]})]})};var Le=Object.getOwnPropertyDescriptor,Fe=(e,n,r,t)=>{for(var i=t>1?void 0:t?Le(n,r):n,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},N=(e,n)=>(r,t)=>n(r,t,e);const ce="SHEET_NUMFMT_PANEL";let H=class extends s.Disposable{constructor(n,r,t,i,a,o,u,c,v,f,m){super();K(this,"_previewPattern","");K(this,"_sidebarDisposable",null);this._sheetInterceptorService=n,this._themeService=r,this._univerInstanceService=t,this._commandService=i,this._selectionManagerService=a,this._renderManagerService=o,this._numfmtService=u,this._componentManager=c,this._sidebarService=v,this._localeService=f,this._sheetsNumfmtCellContentController=m,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(x.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var P;const n=this._sidebarService,r=this._selectionManagerService,t=this._commandService,i=this._univerInstanceService,a=this._numfmtService,o=this._localeService,c=(((P=r.getCurrentSelections())==null?void 0:P.map(I=>I.range))||[])[0];if(!c)return!1;const v=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),f=v.getActiveSheet();if(!f)return!1;const m=f.getCellRaw(c.startRow,c.startColumn),h=a.getValue(v.getUnitId(),f.getSheetId(),c.startRow,c.startColumn);let S="";h&&(S=h.pattern);const b=(m==null?void 0:m.t)===s.CellValueType.NUMBER?m.v:12345678,p={onChange:I=>{var M;if(I.type==="change")this._previewPattern=I.value,this._forceUpdate();else if(I.type==="confirm"){const O=((M=r.getCurrentSelections())==null?void 0:M.map(R=>R.range))||[],U={values:[]},te=d.getPatternType(I.value);O.forEach(R=>{s.Range.foreach(R,(ne,E)=>{U.values.push({row:ne,col:E,pattern:I.value,type:te})})}),t.executeCommand(d.SetNumfmtCommand.id,U),n.close()}else I.type==="cancel"&&n.close()},value:{defaultPattern:S,defaultValue:b,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=n.open({header:{title:o.t("sheet.numfmt.title")},children:{label:ce,...p},onClose:()=>{this._forceUpdate(),t.executeCommand(z.id)}}),!0}_forceUpdate(n){var t;const r=this._renderManagerService.getRenderById(n!=null?n:this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(D.SheetSkeletonManagerService).reCalculate(),(t=r==null?void 0:r.mainComponent)==null||t.makeDirty()}_initCommands(){[L,z].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initPanel(){this.disposeWithMe(this._componentManager.register(ce,$e))}_initRealTimeRenderingInterceptor(){const n=new x.Observable(t=>{this._commandService.onCommandExecuted(i=>{i.id===L.id&&t.next(!0),i.id===z.id&&t.next(!1)})}),r=x.combineLatest([n,this._selectionManagerService.selectionMoveEnd$.pipe(V.map(t=>t?t.map(i=>i.range):[]))]);this.disposeWithMe(s.toDisposable(r.pipe(V.switchMap(([t,i])=>new x.Observable(a=>{const o=new s.DisposableCollection;return t&&i.length&&a.next({selectionRanges:i,disposableCollection:o}),()=>{o.dispose()}})),V.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:t,selectionRanges:i})=>{var o,u;const a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this.openPanel(),t.add(this._sheetInterceptorService.intercept(g.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:s.InterceptorEffectEnum.Value|s.InterceptorEffectEnum.Style,handler:(c,v,f)=>{var b;const{row:m,col:h}=v,S=f(c)||{};if(i.find(p=>p.startColumn<=h&&p.endColumn>=h&&p.startRow<=m&&p.endRow>=m)){const p=v.worksheet.getCellRaw(m,h),P=p==null?void 0:p.v,I=p==null?void 0:p.t;if(P==null||I!==s.CellValueType.NUMBER||this._previewPattern===null)return S;const M=d.getPatternPreviewIgnoreGeneral(this._previewPattern,P,this._sheetsNumfmtCellContentController.local);if(M.color){const O=(b=this._themeService.getColorFromTheme(`${M.color}.500`))!=null?b:M.color;return{...S,v:M.result,t:s.CellValueType.STRING,s:{cl:{rgb:O}}}}return{...S,v:M.result,t:s.CellValueType.STRING}}return S}})),(u=(o=this._renderManagerService.getRenderById(a.getUnitId()))==null?void 0:o.mainComponent)==null||u.makeDirty()})))}_commandExecutedListener(){const n=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id];this.disposeWithMe(new x.Observable(r=>{const t=this._commandService.onCommandExecuted(i=>{if(n.includes(i.id)){const a=i.params;r.next(a.unitId)}});return()=>t.dispose()}).pipe(V.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{var r;n||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};H=Fe([N(0,s.Inject(g.SheetInterceptorService)),N(1,s.Inject(s.ThemeService)),N(2,s.IUniverInstanceService),N(3,s.ICommandService),N(4,s.Inject(g.SheetsSelectionsService)),N(5,k.IRenderManagerService),N(6,g.INumfmtService),N(7,s.Inject(_.ComponentManager)),N(8,_.ISidebarService),N(9,s.Inject(s.LocaleService)),N(10,s.Inject(d.SheetsNumfmtCellContentController))],H);var He=Object.getOwnPropertyDescriptor,Ae=(e,n,r,t)=>{for(var i=t>1?void 0:t?He(n,r):n,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},A=(e,n)=>(r,t)=>n(r,t,e);const Re=()=>{let e=[];return{add:(i,a,o,u,c)=>e.push({unitId:i,subUnitId:a,row:o,col:u,value:c}),getEffects:()=>e,clean:()=>{e=[]}}};let B=class extends s.Disposable{constructor(n,r,t,i,a){super();K(this,"_collectEffectMutation",Re());this._sheetInterceptorService=n,this._numfmtService=r,this._univerInstanceService=t,this._injector=i,this._editorBridgeService=a,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.BEFORE_CELL_EDIT,{handler:(n,r,t)=>{const i=r.row,a=r.col,o=this._numfmtService.getValue(r.unitId,r.subUnitId,i,a);if(o)switch(d.getPatternType(o.pattern)){case"scientific":case"currency":case"grouped":case"number":{const c=r.worksheet.getCellRaw(i,a);return t&&t(c)}case"percent":case"date":case"time":case"datetime":default:return t&&t(n)}return t(n)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(n,r,t)=>{var c,v,f;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col);if(!(n!=null&&n.v)&&!(n!=null&&n.p)||W.isTextFormat(i==null?void 0:i.pattern)||n.t===s.CellValueType.FORCE_STRING)return t(n);const a=(c=n.p)==null?void 0:c.body,o=(f=(v=n==null?void 0:n.p)==null?void 0:v.body)!=null&&f.dataStream?n.p.body.dataStream.replace(/\r\n$/,""):String(n.v),u=s.numfmt.parseDate(o)||s.numfmt.parseTime(o)||s.numfmt.parseNumber(o);if(a)if(We(a)){const{dataStream:m}=a,h=m.replace(/\r\n$/,""),S=Number(h);if(Number.isNaN(S)&&!u)return t(n)}else return t(n);if(u){if(!u.z&&s.willLoseNumericPrecision(o))return t({...n,p:void 0,v:o,t:s.CellValueType.FORCE_STRING});u.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:u.z});const m=Number(u.v);return t({...n,p:void 0,v:m,t:s.CellValueType.NUMBER})}return t(n)}})))}_initInterceptorCommands(){const n=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var t;switch(r.id){case g.SetRangeValuesCommand.id:{const i=n._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),a=i.getUnitId(),o=(t=i.getActiveSheet())==null?void 0:t.getSheetId();if(!o)return{redos:[],undos:[]};const u=n._collectEffectMutation.getEffects();if(n._collectEffectMutation.clean(),!u.length)return{redos:[],undos:[]};const c=u.filter(h=>{var S;return!!((S=h.value)!=null&&S.pattern)}).map(h=>({row:h.row,col:h.col,pattern:h.value.pattern})),v=u.filter(h=>{var S;return!((S=h.value)!=null&&S.pattern)}).map(h=>({startRow:h.row,endColumn:h.col,startColumn:h.col,endRow:h.row})),f=[],m=[];if(c.length){const h={id:g.SetNumfmtMutation.id,params:g.transformCellsToRange(a,o,c)};f.push(h),m.push(...g.factorySetNumfmtUndoMutation(n._injector,h.params))}if(v.length){const h={id:g.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:o,ranges:v}};f.push(h),m.push(...g.factoryRemoveNumfmtUndoMutation(n._injector,h.params))}return{redos:f,undos:m.reverse()}}}return{redos:[],undos:[]}}}))}};B=Ae([A(0,s.Inject(g.SheetInterceptorService)),A(1,s.Inject(g.INumfmtService)),A(2,s.Inject(s.IUniverInstanceService)),A(3,s.Inject(s.Injector)),A(4,s.Optional(D.IEditorBridgeService))],B);function We(e){const{textRuns:n=[],paragraphs:r=[],customRanges:t,customBlocks:i=[]}=e,a=["va"];return!(n.some(o=>!!(o.ts&&Object.keys(o.ts).some(c=>a.includes(c))))||r.some(o=>o.bullet)||r.length>=2||t!=null&&t.length||i.length>0)}const q=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:W.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},{label:"sheet.numfmt.percent",pattern:"0.00%"},{label:"sheet.numfmt.scientific",pattern:"0.00E+00"},"|",{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:""}],Ve=e=>({icon:new x.Observable(n=>{var a;const r=e.get(d.MenuCurrencyService);function t(o){var c;return(c={[d.countryCurrencyMap.US]:"DollarIcon",[d.countryCurrencyMap.RU]:"RoubleIcon",[d.countryCurrencyMap.CN]:"RmbIcon",[d.countryCurrencyMap.AT]:"EuroIcon"}[o])!=null?c:"DollarIcon"}const i=(a=d.countryCurrencyMap[r.getCurrencySymbol()])!=null?a:"$";return n.next(t(i)),r.currencySymbol$.subscribe(o=>{var c;const u=(c=d.countryCurrencyMap[o])!=null?c:"$";n.next(t(u))})}),id:d.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Be=e=>({icon:"AddDigitsIcon",id:d.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),qe=e=>({icon:"ReduceDigitsIcon",id:d.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ge=e=>({icon:"PercentIcon",id:d.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ke=e=>{const n=e.get(s.IUniverInstanceService),r=e.get(s.ICommandService),t=e.get(s.LocaleService),i=e.get(g.SheetsSelectionsService),a=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id],o=D.deriveStateFromActiveSheet$(n,"",({workbook:u,worksheet:c})=>new x.Observable(v=>x.merge(i.selectionMoveEnd$,s.fromCallback(r.onCommandExecuted.bind(r)).pipe(x.filter(([f])=>a.includes(f.id)))).subscribe(()=>{var m,h;const f=i.getCurrentSelections();if(f&&f[0]){const S=f[0].range,b=S.startRow,p=S.startColumn,P=(h=u.getStyles().get((m=c.getCell(b,p))==null?void 0:m.s))==null?void 0:h.n,I=P==null?void 0:P.pattern;let M=t.t("sheet.numfmt.general");if(W.isDefaultFormat(I)){v.next(M);return}if(I){const O=q.filter(U=>typeof U=="object"&&U.pattern).find(U=>s.isPatternEqualWithoutDecimal(I,U.pattern));O&&typeof O=="object"&&O.pattern?M=t.t(O.label):M=t.t("sheet.numfmt.moreFmt")}v.next(M)}})));return{label:le,id:L.id,tooltip:"sheet.numfmt.title",type:_.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:ue,hoverable:!1,selectable:!1}}],value$:o,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetSetCellStylePermission,g.WorksheetEditPermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}},le="sheet.numfmt.moreNumfmtType",ue="sheet.numfmt.moreNumfmtType.options",Ze=e=>{const{value:n}=e,r=_.useDependency(s.LocaleService),t=n!=null?n:r.t("sheet.numfmt.general");return l.jsx("span",{className:"univer-text-sm",children:t})},Ye=()=>{const e=_.useDependency(s.ICommandService),n=_.useDependency(s.LocaleService),r=_.useDependency(_.ILayoutService),t=_.useDependency(d.SheetsNumfmtCellContentController),i=_.useDependency(g.SheetsSelectionsService),a=c=>{const v=i.getCurrentLastSelection();if(!v)return;const f=v.range,m=[];s.Range.foreach(f,(h,S)=>{c?m.push({row:h,col:S,pattern:c,type:d.getPatternType(c)}):m.push({row:h,col:S})}),e.executeCommand(d.SetNumfmtCommand.id,{values:m}),r.focus()},o=c=>{if(c===0)a(null);else if(c===q.length-1)e.executeCommand(L.id),r.focus();else{const v=q[c];v.pattern&&a(v.pattern)}},u=1220;return l.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:q.map((c,v)=>c==="|"?l.jsx(T.Separator,{},v):l.jsxs("div",{className:"univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",onClick:()=>{o(v)},children:[l.jsx("span",{children:n.t(c.label)}),l.jsx("span",{className:"univer-text-xs univer-text-gray-500",children:c.pattern?d.getPatternPreview(c.pattern||"",u,t.local).result.trim():""})]},v))})},ze={[_.RibbonDataGroup.FORMULAS]:{[d.SetCurrencyCommand.id]:{order:0,menuItemFactory:Ve},[d.AddDecimalCommand.id]:{order:1,menuItemFactory:Be},[d.SubtractDecimalCommand.id]:{order:2,menuItemFactory:qe},[d.SetPercentCommand.id]:{order:3,menuItemFactory:Ge},[L.id]:{order:4,menuItemFactory:Ke}}};var Xe=Object.getOwnPropertyDescriptor,Je=(e,n,r,t)=>{for(var i=t>1?void 0:t?Xe(n,r):n,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},me=(e,n)=>(r,t)=>n(r,t,e);let G=class extends s.Disposable{constructor(e,n){super(),this._componentManager=e,this._menuManagerService=n,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(ze),[[le,Ze],[ue,Ye]].forEach(([e,n])=>{this.disposeWithMe(this._componentManager.register(e,n))})}};G=Je([me(0,s.Inject(_.ComponentManager)),me(1,_.IMenuManagerService)],G);var Qe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(e,n,r)=>n in e?Qe(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,nt=(e,n,r,t)=>{for(var i=t>1?void 0:t?et(n,r):n,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},ee=(e,n)=>(r,t)=>n(r,t,e),de=(e,n,r)=>tt(e,typeof n!="symbol"?n+"":n,r);const rt="SHEET_NUMFMT_UI_PLUGIN";C.UniverSheetsNumfmtUIPlugin=class extends s.Plugin{constructor(n=re,r,t,i){super(),this._config=n,this._injector=r,this._configService=t,this._renderManagerService=i;const{menu:a,...o}=s.merge({},re,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig("sheets-numfmt-ui.config",o)}onStarting(){s.registerDependencies(this._injector,[[H],[B],[F],[G]])}onRendered(){this._registerRenderModules(),s.touchDependencies(this._injector,[[H],[B],[G]])}_registerRenderModules(){[[Y]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,r))})}},de(C.UniverSheetsNumfmtUIPlugin,"pluginName",rt),de(C.UniverSheetsNumfmtUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),C.UniverSheetsNumfmtUIPlugin=nt([s.DependentOn(D.UniverSheetsUIPlugin,d.UniverSheetsNumfmtPlugin),ee(1,s.Inject(s.Injector)),ee(2,s.IConfigService),ee(3,k.IRenderManagerService)],C.UniverSheetsNumfmtUIPlugin),Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
1
+ (function(C,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/sheets"),require("@univerjs/ui"),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/sheets","@univerjs/ui","rxjs","rxjs/operators","react/jsx-runtime","react","@univerjs/design"],a):(C=typeof globalThis<"u"?globalThis:C||self,a(C.UniverSheetsNumfmtUi={},C.UniverCore,C.UniverEngineRender,C.UniverSheetsNumfmt,C.UniverSheetsUi,C.UniverSheets,C.UniverUi,C.rxjs,C.rxjs.operators,C.React,C.React,C.UniverDesign))})(this,function(C,a,k,d,D,g,_,x,W,l,y,E){"use strict";var at=Object.defineProperty;var st=(C,a,k)=>a in C?at(C,a,{enumerable:!0,configurable:!0,writable:!0,value:k}):C[a]=k;var G=(C,a,k)=>st(C,typeof a!="symbol"?a+"":a,k);const ne={};var de=Object.getOwnPropertyDescriptor,ve=(e,n,r,t)=>{for(var i=t>1?void 0:t?de(n,r):n,s=e.length-1,o;s>=0;s--)(o=e[s])&&(i=o(i)||i);return i},j=(e,n)=>(r,t)=>n(r,t,e);const K="SHEET_NUMFMT_ALERT";let Z=class extends a.Disposable{constructor(e,n,r,t,i,s,o){super(),this._context=e,this._hoverManagerService=n,this._cellAlertManagerService=r,this._localeService=t,this._zenZoneService=i,this._numfmtService=s,this._configService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(x.debounceTime(100)).subscribe(e=>{var n,r;if(e){const t=e.location,i=this._context.unit,s=i.getActiveSheet();if(!s)return;const o=t.unitId,u=t.subUnitId;let c;const v=s.getCell(t.row,t.col);if(v!=null&&v.s){const f=i.getStyles().get(v.s);f!=null&&f.n&&(c=f.n)}if(c||(c=this._numfmtService.getValue(o,u,t.row,t.col)),!c){this._hideAlert();return}if(a.isTextFormat(c.pattern)&&(v!=null&&v.v)&&a.isRealNum(v.v)){if((n=this._configService.getConfig(d.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&n.disableTextFormatAlert)return;const f=this._cellAlertManagerService.currentAlert.get(K),m=(r=f==null?void 0:f.alert)==null?void 0:r.location;if(m&&m.row===t.row&&m.col===t.col&&m.subUnitId===t.subUnitId&&m.unitId===t.unitId)return;this._cellAlertManagerService.showAlert({type:D.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:t,width:200,height:74,key:K});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(K)}};Z=ve([j(1,a.Inject(D.HoverManagerService)),j(2,a.Inject(D.CellAlertManagerService)),j(3,a.Inject(a.LocaleService)),j(4,_.IZenZoneService),j(5,a.Inject(g.INumfmtService)),j(6,a.IConfigService)],Z);const Y={id:"sheet.operation.close.numfmt.panel",type:a.CommandType.OPERATION,handler:()=>!0},L={id:"sheet.operation.open.numfmt.panel",type:a.CommandType.OPERATION,handler:e=>(e.get(H).openPanel(),!0)};var pe=Object.getOwnPropertyDescriptor,fe=(e,n,r,t)=>{for(var i=t>1?void 0:t?pe(n,r):n,s=e.length-1,o;s>=0;s--)(o=e[s])&&(i=o(i)||i);return i},he=(e,n)=>(r,t)=>n(r,t,e);const z=y.createContext([]);let F=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,n){const r=this._getKey(e);return this._localStorageService.getItem(r).then(t=>{t||this._localStorageService.setItem(r,n)})}markHabit(e,n){const r=this._getKey(e);this._localStorageService.getItem(r).then(t=>{if(t){const i=t.findIndex(s=>s===n);i>-1&&t.splice(i,1),t.unshift(n),this._localStorageService.setItem(r,t)}})}async getHabit(e,n){const r=this._getKey(e),t=await this._localStorageService.getItem(r);if(n&&t){const i=t.map((s,o,u)=>{const c=u.length;return{value:s,priority:c-o}});return n.sort((s,o)=>{var v,f;const u=((v=i.find(m=>m.value===s))==null?void 0:v.priority)||-1;return(((f=i.find(m=>m.value===o))==null?void 0:f.priority)||-1)-u})}return t||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};F=fe([he(0,a.Inject(a.ILocalStorageService))],F);const re="numfmtCurrency",ge=e=>{const n=_.useDependency(F),[r,t]=y.useState(d.currencySymbols);return y.useEffect(()=>{n.addHabit("numfmtCurrency",[]).then(()=>{n.getHabit(re,[...d.currencySymbols]).then(s=>{t(s),e&&e(s)})})},[]),{userHabitCurrency:r,mark:s=>{n.markHabit(re,s)}}},Se=()=>{const e=y.useRef([]),[n,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[n]),i=>{e.current.push(i),r({})}},ye=e=>!!d.getCurrencyType(e)&&e.startsWith("_("),_e=e=>{const{defaultPattern:n,action:r,onChange:t}=e,[i,s]=y.useState(()=>d.getDecimalFromPattern(n||"",2)),o=y.useContext(z),[u,c]=y.useState(()=>d.getCurrencyType(n)||o[0]),v=y.useMemo(()=>o.map(b=>({label:b,value:b})),[]),m=_.useDependency(a.LocaleService).t;r.current=()=>d.setPatternDecimal(`_("${u}"* #,##0${i>0?".0":""}_)`,i);const h=b=>{c(b),t(d.setPatternDecimal(`_("${b}"* #,##0${i>0?".0":""}_)`,i))},S=b=>{const p=b||0;s(p),t(d.setPatternDecimal(`_("${u}"* #,##0${p>0?".0":""}_)`,p))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:i,step:1,precision:0,max:20,min:0,onChange:S})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{options:v,value:u,onChange:h})})]})]}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.accountingDes")})]})},Ce=e=>!!d.getCurrencyType(e)&&!e.startsWith("_("),be=e=>{const r=_.useDependency(a.LocaleService).t,t=y.useContext(z),[i,s]=y.useState(()=>d.getCurrencyType(e.defaultPattern)||t[0]),[o,u]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",2)),[c,v]=y.useState(()=>{var I;const p=d.getCurrencyFormatOptions(i);return((I=p.find(M=>a.isPatternEqualWithoutDecimal(M.value,e.defaultPattern)))==null?void 0:I.value)||p[0].value}),f=y.useMemo(()=>d.getCurrencyFormatOptions(i),[i]),m=y.useMemo(()=>t.map(p=>({label:p,value:p})),[t]);e.action.current=()=>d.setPatternDecimal(c,o);const h=p=>{if(p===void 0)return;s(p);const P=d.getCurrencyFormatOptions(p)[0].value;v(P),e.onChange(d.setPatternDecimal(P,o))},S=p=>{p!==void 0&&(v(p),e.onChange(d.setPatternDecimal(p,o)))},b=p=>{u(p||0),e.onChange(d.setPatternDecimal(c,p||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:o,max:20,min:0,onChange:b})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{value:i,options:m,onChange:h})})]})]}),l.jsx("div",{className:"label univer-mt-4",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:c,options:f,onChange:S})}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyDes")})]})};var w=function(){return w=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},w.apply(this,arguments)},Ie=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(e);i<t.length;i++)n.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(r[t[i]]=e[t[i]]);return r},ie=y.forwardRef(function(e,n){var r=e.icon,t=e.id,i=e.className,s=e.extend,o=Ie(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),c=y.useRef("_".concat(Pe()));return ae(r,"".concat(t),{defIds:r.defIds,idSuffix:c.current},w({ref:n,className:u},o),s)});function ae(e,n,r,t,i){return y.createElement(e.tag,w(w({key:n},Te(e,r,i)),t),(Ee(e,r).children||[]).map(function(s,o){return ae(s,"".concat(n,"-").concat(e.tag,"-").concat(o),r,void 0,i)}))}function Te(e,n,r){var t=w({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1),e.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(s){var o=s[0],u=s[1];o==="mask"&&typeof u=="string"&&(t[o]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(s){var o=s[0],u=s[1];typeof u=="string"&&(t[o]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Ee(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?w(w({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.includes(i.attrs.id)?w(w({},i),{attrs:w(w({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function Pe(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},se=y.forwardRef(function(e,n){return y.createElement(ie,Object.assign({},e,{id:"check-mark-icon",ref:n,icon:Me}))});se.displayName="CheckMarkIcon";const X="customFormat",J="numfmt_custom_pattern";function De(e){const{defaultPattern:n,action:r,onChange:t}=e,i=_.useDependency(F),s=_.useDependency(a.ILocalStorageService),o=_.useDependency(a.LocaleService),[u,c]=y.useState(n);r.current=()=>(i.markHabit(X,u),s.getItem(J).then((S=[])=>{const b=[...new Set([u,...S||[]])].splice(0,10).filter(p=>!!p);s.setItem(J,b)}),u);const[v,f]=y.useState([]);y.useEffect(()=>{s.getItem(J).then(S=>{const b=[...d.CURRENCYFORMAT.map(p=>p.suffix("$")),...d.DATEFMTLISG.map(p=>p.suffix),...d.NUMBERFORMAT.map(p=>p.suffix)];b.push(...S||[]),i.addHabit(X,[]).finally(()=>{i.getHabit(X,b).then(p=>{f([...new Set(p)])})})})},[]);const m=S=>{c(S),t(S)},h=()=>{t(u)};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:o.t("sheet.numfmt.customFormat")}),l.jsx(E.Input,{placeholder:o.t("sheet.numfmt.customFormat"),onBlur:h,value:u,onChange:c,className:"univer-mt-2 univer-w-full"}),l.jsx("div",{className:E.clsx("univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2",E.borderClassName),children:v.map(S=>l.jsxs("div",{onClick:()=>m(S),className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-w-4 univer-items-center univer-text-primary-600",children:u===S&&l.jsx(se,{})}),l.jsx("div",{children:S})]},S))}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:o.t("sheet.numfmt.customFormatDes")})]})}const we=e=>{const n=a.numfmt.getFormatInfo(e);return d.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(n.type)};function Ne(e){const{onChange:n,defaultPattern:r}=e,t=y.useMemo(d.getDateFormatOptions,[]),i=_.useDependency(a.LocaleService),[s,o]=y.useState(()=>{if(r){const c=t.find(v=>v.value===r);if(c)return c.value}return t[0].value});e.action.current=()=>s;const u=c=>{c!==void 0&&(o(c),n(c))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:i.t("sheet.numfmt.dateType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:s,options:t,onChange:u})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.numfmt.dateDes")})]})}const xe=e=>!e,Oe=e=>{const r=_.useDependency(a.LocaleService).t;return e.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:r("sheet.numfmt.generalDes")})})},Ue=e=>d.getNumberFormatOptions().some(n=>a.isPatternEqualWithoutDecimal(n.value,e));function ke(e){const n=_.useDependency(a.LocaleService),r=y.useMemo(d.getNumberFormatOptions,[]),[t,i]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",0)),[s,o]=y.useState(()=>{const m=r.find(h=>a.isPatternEqualWithoutDecimal(h.value,e.defaultPattern||""));return(m==null?void 0:m.value)||r[0].value}),u=y.useMemo(()=>d.setPatternDecimal(s,Number(t||0)),[s,t]),c=y.useMemo(()=>!d.isPatternHasDecimal(s),[s]),v=m=>{i(m||0),e.onChange(d.setPatternDecimal(s,Number(m||0)))},f=m=>{m!==void 0&&(i(d.getDecimalFromPattern(m,0)),o(m),e.onChange(m))};return e.action.current=()=>u,l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:n.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.InputNumber,{disabled:c,value:t,max:20,min:0,onChange:v})}),l.jsxs("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:[" ",n.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{onChange:f,options:r,value:s})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.numfmt.thousandthPercentileDes")})]})}const je=e=>{const{defaultValue:n,defaultPattern:r,row:t,col:i}=e.value,s=_.useDependency(a.LocaleService),o=y.useRef(()=>""),u=s.t,c=Se(),v=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Oe},{label:"sheet.numfmt.accounting",component:_e},{label:"sheet.numfmt.currency",component:be},{label:"sheet.numfmt.date",component:Ne},{label:"sheet.numfmt.thousandthPercentile",component:ke},{label:"sheet.numfmt.customFormat",component:De}].map(T=>({...T,label:u(T.label)})),[]),[f,m]=y.useState(I),[h,S]=y.useState(()=>`${t}_${i}`),{mark:b,userHabitCurrency:p}=ge(()=>S(`${t}_${i}_userCurrency'`)),P=y.useMemo(()=>{var T;return(T=v.find($=>$.label===f))==null?void 0:T.component},[f]);function I(){return[xe,ye,Ce,we,Ue].reduce(($,rt,it)=>$||(rt(r)?v[it].label:""),"")||v[0].label}const M=v.map(T=>({label:T.label,value:T.label})),O=T=>{m(T),c(()=>e.onChange({type:"change",value:o.current()||""}))},U=y.useCallback(T=>{e.onChange({type:"change",value:T})},[]),ee=()=>{const T=o.current()||"",$=d.getCurrencyType(T);$&&b($),e.onChange({type:"confirm",value:T})},R=()=>{e.onChange({type:"cancel",value:""})},te={onChange:U,defaultValue:n,defaultPattern:r,action:o};return y.useEffect(()=>{m(I()),S(`${t}_${i}`)},[t,i]),l.jsxs("div",{className:E.clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5",E.scrollbarClassName),children:[l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3.5 univer-text-sm univer-text-gray-400",children:u("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.Select,{className:"univer-w-full",value:f,options:M,onChange:O})}),l.jsx("div",{children:P&&l.jsx(z.Provider,{value:p,children:y.createElement(P,{...te,key:h})})})]}),l.jsxs("div",{className:"univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end",children:[l.jsx(E.Button,{onClick:R,className:"univer-mr-3",children:u("sheet.numfmt.cancel")}),l.jsx(E.Button,{variant:"primary",onClick:ee,children:u("sheet.numfmt.confirm")})]})]})};var $e=Object.getOwnPropertyDescriptor,Le=(e,n,r,t)=>{for(var i=t>1?void 0:t?$e(n,r):n,s=e.length-1,o;s>=0;s--)(o=e[s])&&(i=o(i)||i);return i},N=(e,n)=>(r,t)=>n(r,t,e);const oe="SHEET_NUMFMT_PANEL";let H=class extends a.Disposable{constructor(n,r,t,i,s,o,u,c,v,f,m){super();G(this,"_previewPattern","");G(this,"_sidebarDisposable",null);this._sheetInterceptorService=n,this._themeService=r,this._univerInstanceService=t,this._commandService=i,this._selectionManagerService=s,this._renderManagerService=o,this._numfmtService=u,this._componentManager=c,this._sidebarService=v,this._localeService=f,this._sheetsNumfmtCellContentController=m,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(x.merge(this._sheetsNumfmtCellContentController.local$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var P;const n=this._sidebarService,r=this._selectionManagerService,t=this._commandService,i=this._univerInstanceService,s=this._numfmtService,o=this._localeService,c=(((P=r.getCurrentSelections())==null?void 0:P.map(I=>I.range))||[])[0];if(!c)return!1;const v=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),f=v.getActiveSheet();if(!f)return!1;const m=f.getCellRaw(c.startRow,c.startColumn),h=s.getValue(v.getUnitId(),f.getSheetId(),c.startRow,c.startColumn);let S="";h&&(S=h.pattern);const b=(m==null?void 0:m.t)===a.CellValueType.NUMBER?m.v:12345678,p={onChange:I=>{var M;if(I.type==="change")this._previewPattern=I.value,this._forceUpdate();else if(I.type==="confirm"){const O=((M=r.getCurrentSelections())==null?void 0:M.map(R=>R.range))||[],U={values:[]},ee=d.getPatternType(I.value);O.forEach(R=>{a.Range.foreach(R,(te,T)=>{U.values.push({row:te,col:T,pattern:I.value,type:ee})})}),t.executeCommand(d.SetNumfmtCommand.id,U),n.close()}else I.type==="cancel"&&n.close()},value:{defaultPattern:S,defaultValue:b,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=n.open({header:{title:o.t("sheet.numfmt.title")},children:{label:oe,...p},onClose:()=>{this._forceUpdate(),t.executeCommand(Y.id)}}),!0}_forceUpdate(n){var t;const r=this._renderManagerService.getRenderById(n!=null?n:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(D.SheetSkeletonManagerService).reCalculate(),(t=r==null?void 0:r.mainComponent)==null||t.makeDirty()}_initCommands(){[L,Y].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initPanel(){this.disposeWithMe(this._componentManager.register(oe,je))}_initRealTimeRenderingInterceptor(){const n=new x.Observable(t=>{this._commandService.onCommandExecuted(i=>{i.id===L.id&&t.next(!0),i.id===Y.id&&t.next(!1)})}),r=x.combineLatest([n,this._selectionManagerService.selectionMoveEnd$.pipe(W.map(t=>t?t.map(i=>i.range):[]))]);this.disposeWithMe(a.toDisposable(r.pipe(W.switchMap(([t,i])=>new x.Observable(s=>{const o=new a.DisposableCollection;return t&&i.length&&s.next({selectionRanges:i,disposableCollection:o}),()=>{o.dispose()}})),W.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:t,selectionRanges:i})=>{var o,u;const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);this.openPanel(),t.add(this._sheetInterceptorService.intercept(g.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:a.InterceptorEffectEnum.Value|a.InterceptorEffectEnum.Style,handler:(c,v,f)=>{var b;const{row:m,col:h}=v,S=f(c)||{};if(i.find(p=>p.startColumn<=h&&p.endColumn>=h&&p.startRow<=m&&p.endRow>=m)){const p=v.worksheet.getCellRaw(m,h),P=p==null?void 0:p.v,I=p==null?void 0:p.t;if(P==null||I!==a.CellValueType.NUMBER||this._previewPattern===null)return S;const M=d.getPatternPreviewIgnoreGeneral(this._previewPattern,P,this._sheetsNumfmtCellContentController.local);if(M.color){const O=(b=this._themeService.getColorFromTheme(`${M.color}.500`))!=null?b:M.color;return{...S,v:M.result,t:a.CellValueType.STRING,s:{cl:{rgb:O}}}}return{...S,v:M.result,t:a.CellValueType.STRING}}return S}})),(u=(o=this._renderManagerService.getRenderById(s.getUnitId()))==null?void 0:o.mainComponent)==null||u.makeDirty()})))}_commandExecutedListener(){const n=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id];this.disposeWithMe(new x.Observable(r=>{const t=this._commandService.onCommandExecuted(i=>{if(n.includes(i.id)){const s=i.params;r.next(s.unitId)}});return()=>t.dispose()}).pipe(W.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{var r;n||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};H=Le([N(0,a.Inject(g.SheetInterceptorService)),N(1,a.Inject(a.ThemeService)),N(2,a.IUniverInstanceService),N(3,a.ICommandService),N(4,a.Inject(g.SheetsSelectionsService)),N(5,k.IRenderManagerService),N(6,g.INumfmtService),N(7,a.Inject(_.ComponentManager)),N(8,_.ISidebarService),N(9,a.Inject(a.LocaleService)),N(10,a.Inject(d.SheetsNumfmtCellContentController))],H);var Fe=Object.getOwnPropertyDescriptor,He=(e,n,r,t)=>{for(var i=t>1?void 0:t?Fe(n,r):n,s=e.length-1,o;s>=0;s--)(o=e[s])&&(i=o(i)||i);return i},A=(e,n)=>(r,t)=>n(r,t,e);const Ae=()=>{let e=[];return{add:(i,s,o,u,c)=>e.push({unitId:i,subUnitId:s,row:o,col:u,value:c}),getEffects:()=>e,clean:()=>{e=[]}}};let V=class extends a.Disposable{constructor(n,r,t,i,s){super();G(this,"_collectEffectMutation",Ae());this._sheetInterceptorService=n,this._numfmtService=r,this._univerInstanceService=t,this._injector=i,this._editorBridgeService=s,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(a.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.BEFORE_CELL_EDIT,{handler:(n,r,t)=>{const i=r.row,s=r.col,o=this._numfmtService.getValue(r.unitId,r.subUnitId,i,s);if(o)switch(d.getPatternType(o.pattern)){case"scientific":case"currency":case"grouped":case"number":{const c=r.worksheet.getCellRaw(i,s);return t&&t(c)}case"percent":case"date":case"time":case"datetime":default:return t&&t(n)}return t(n)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(a.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(n,r,t)=>{var c,v,f;this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col);if(!(n!=null&&n.v)&&!(n!=null&&n.p)||a.isTextFormat(i==null?void 0:i.pattern)||n.t===a.CellValueType.FORCE_STRING)return t(n);const s=(c=n.p)==null?void 0:c.body,o=(f=(v=n==null?void 0:n.p)==null?void 0:v.body)!=null&&f.dataStream?n.p.body.dataStream.replace(/\r\n$/,""):String(n.v),u=a.numfmt.parseDate(o)||a.numfmt.parseTime(o)||a.numfmt.parseNumber(o);if(s)if(Re(s)){const{dataStream:m}=s,h=m.replace(/\r\n$/,""),S=Number(h);if(Number.isNaN(S)&&!u)return t(n)}else return t(n);if(u){if(!u.z&&a.willLoseNumericPrecision(o))return t({...n,p:void 0,v:o,t:a.CellValueType.FORCE_STRING});u.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:u.z});const m=Number(u.v);return t({...n,p:void 0,v:m,t:a.CellValueType.NUMBER})}return t(n)}})))}_initInterceptorCommands(){const n=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var t;switch(r.id){case g.SetRangeValuesCommand.id:{const i=n._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=i.getUnitId(),o=(t=i.getActiveSheet())==null?void 0:t.getSheetId();if(!o)return{redos:[],undos:[]};const u=n._collectEffectMutation.getEffects();if(n._collectEffectMutation.clean(),!u.length)return{redos:[],undos:[]};const c=u.filter(h=>{var S;return!!((S=h.value)!=null&&S.pattern)}).map(h=>({row:h.row,col:h.col,pattern:h.value.pattern})),v=u.filter(h=>{var S;return!((S=h.value)!=null&&S.pattern)}).map(h=>({startRow:h.row,endColumn:h.col,startColumn:h.col,endRow:h.row})),f=[],m=[];if(c.length){const h={id:g.SetNumfmtMutation.id,params:g.transformCellsToRange(s,o,c)};f.push(h),m.push(...g.factorySetNumfmtUndoMutation(n._injector,h.params))}if(v.length){const h={id:g.RemoveNumfmtMutation.id,params:{unitId:s,subUnitId:o,ranges:v}};f.push(h),m.push(...g.factoryRemoveNumfmtUndoMutation(n._injector,h.params))}return{redos:f,undos:m.reverse()}}}return{redos:[],undos:[]}}}))}};V=He([A(0,a.Inject(g.SheetInterceptorService)),A(1,a.Inject(g.INumfmtService)),A(2,a.Inject(a.IUniverInstanceService)),A(3,a.Inject(a.Injector)),A(4,a.Optional(D.IEditorBridgeService))],V);function Re(e){const{textRuns:n=[],paragraphs:r=[],customRanges:t,customBlocks:i=[]}=e,s=["va"];return!(n.some(o=>!!(o.ts&&Object.keys(o.ts).some(c=>s.includes(c))))||r.some(o=>o.bullet)||r.length>=2||t!=null&&t.length||i.length>0)}const B=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:a.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},{label:"sheet.numfmt.percent",pattern:"0.00%"},{label:"sheet.numfmt.scientific",pattern:"0.00E+00"},"|",{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:""}],We=e=>({icon:new x.Observable(n=>{var s;const r=e.get(d.MenuCurrencyService);function t(o){var c;return(c={[d.countryCurrencyMap.US]:"DollarIcon",[d.countryCurrencyMap.RU]:"RoubleIcon",[d.countryCurrencyMap.CN]:"RmbIcon",[d.countryCurrencyMap.AT]:"EuroIcon"}[o])!=null?c:"DollarIcon"}const i=(s=d.countryCurrencyMap[r.getCurrencySymbol()])!=null?s:"$";return n.next(t(i)),r.currencySymbol$.subscribe(o=>{var c;const u=(c=d.countryCurrencyMap[o])!=null?c:"$";n.next(t(u))})}),id:d.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ve=e=>({icon:"AddDigitsIcon",id:d.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Be=e=>({icon:"ReduceDigitsIcon",id:d.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),qe=e=>({icon:"PercentIcon",id:d.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ge=e=>{const n=e.get(a.IUniverInstanceService),r=e.get(a.ICommandService),t=e.get(a.LocaleService),i=e.get(g.SheetsSelectionsService),s=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id],o=D.deriveStateFromActiveSheet$(n,"",({workbook:u,worksheet:c})=>new x.Observable(v=>x.merge(i.selectionMoveEnd$,a.fromCallback(r.onCommandExecuted.bind(r)).pipe(x.filter(([f])=>s.includes(f.id)))).subscribe(()=>{var m,h;const f=i.getCurrentSelections();if(f&&f[0]){const S=f[0].range,b=S.startRow,p=S.startColumn,P=(h=u.getStyles().get((m=c.getCell(b,p))==null?void 0:m.s))==null?void 0:h.n,I=P==null?void 0:P.pattern;let M=t.t("sheet.numfmt.general");if(a.isDefaultFormat(I)){v.next(M);return}if(I){const O=B.filter(U=>typeof U=="object"&&U.pattern).find(U=>a.isPatternEqualWithoutDecimal(I,U.pattern));O&&typeof O=="object"&&O.pattern?M=t.t(O.label):M=t.t("sheet.numfmt.moreFmt")}v.next(M)}})));return{label:ce,id:L.id,tooltip:"sheet.numfmt.title",type:_.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:le,hoverable:!1,selectable:!1}}],value$:o,hidden$:_.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:D.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetSetCellStylePermission,g.WorksheetEditPermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}},ce="sheet.numfmt.moreNumfmtType",le="sheet.numfmt.moreNumfmtType.options",Ke=e=>{const{value:n}=e,r=_.useDependency(a.LocaleService),t=n!=null?n:r.t("sheet.numfmt.general");return l.jsx("span",{className:"univer-text-sm",children:t})},Ze=()=>{const e=_.useDependency(a.ICommandService),n=_.useDependency(a.LocaleService),r=_.useDependency(_.ILayoutService),t=_.useDependency(d.SheetsNumfmtCellContentController),i=_.useDependency(g.SheetsSelectionsService),s=c=>{const v=i.getCurrentLastSelection();if(!v)return;const f=v.range,m=[];a.Range.foreach(f,(h,S)=>{c?m.push({row:h,col:S,pattern:c,type:d.getPatternType(c)}):m.push({row:h,col:S})}),e.executeCommand(d.SetNumfmtCommand.id,{values:m}),r.focus()},o=c=>{if(c===0)s(null);else if(c===B.length-1)e.executeCommand(L.id),r.focus();else{const v=B[c];v.pattern&&s(v.pattern)}},u=1220;return l.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:B.map((c,v)=>c==="|"?l.jsx(E.Separator,{},v):l.jsxs("div",{className:"univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",onClick:()=>{o(v)},children:[l.jsx("span",{children:n.t(c.label)}),l.jsx("span",{className:"univer-text-xs univer-text-gray-500",children:c.pattern?d.getPatternPreview(c.pattern||"",u,t.local).result.trim():""})]},v))})},Ye={[_.RibbonDataGroup.FORMULAS]:{[d.SetCurrencyCommand.id]:{order:0,menuItemFactory:We},[d.AddDecimalCommand.id]:{order:1,menuItemFactory:Ve},[d.SubtractDecimalCommand.id]:{order:2,menuItemFactory:Be},[d.SetPercentCommand.id]:{order:3,menuItemFactory:qe},[L.id]:{order:4,menuItemFactory:Ge}}};var ze=Object.getOwnPropertyDescriptor,Xe=(e,n,r,t)=>{for(var i=t>1?void 0:t?ze(n,r):n,s=e.length-1,o;s>=0;s--)(o=e[s])&&(i=o(i)||i);return i},ue=(e,n)=>(r,t)=>n(r,t,e);let q=class extends a.Disposable{constructor(e,n){super(),this._componentManager=e,this._menuManagerService=n,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Ye),[[ce,Ke],[le,Ze]].forEach(([e,n])=>{this.disposeWithMe(this._componentManager.register(e,n))})}};q=Xe([ue(0,a.Inject(_.ComponentManager)),ue(1,_.IMenuManagerService)],q);var Je=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,et=(e,n,r)=>n in e?Je(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,tt=(e,n,r,t)=>{for(var i=t>1?void 0:t?Qe(n,r):n,s=e.length-1,o;s>=0;s--)(o=e[s])&&(i=o(i)||i);return i},Q=(e,n)=>(r,t)=>n(r,t,e),me=(e,n,r)=>et(e,typeof n!="symbol"?n+"":n,r);const nt="SHEET_NUMFMT_UI_PLUGIN";C.UniverSheetsNumfmtUIPlugin=class extends a.Plugin{constructor(n=ne,r,t,i){super(),this._config=n,this._injector=r,this._configService=t,this._renderManagerService=i;const{menu:s,...o}=a.merge({},ne,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig("sheets-numfmt-ui.config",o)}onStarting(){a.registerDependencies(this._injector,[[H],[V],[F],[q]])}onRendered(){this._registerRenderModules(),a.touchDependencies(this._injector,[[H],[V],[q]])}_registerRenderModules(){[[Z]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,r))})}},me(C.UniverSheetsNumfmtUIPlugin,"pluginName",nt),me(C.UniverSheetsNumfmtUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),C.UniverSheetsNumfmtUIPlugin=tt([a.DependentOn(D.UniverSheetsUIPlugin,d.UniverSheetsNumfmtPlugin),Q(1,a.Inject(a.Injector)),Q(2,a.IConfigService),Q(3,k.IRenderManagerService)],C.UniverSheetsNumfmtUIPlugin),Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt-ui",
3
- "version": "0.9.2-nightly.202507131606",
3
+ "version": "0.9.2-nightly.202507141607",
4
4
  "private": false,
5
5
  "description": "UniverSheet numfmt plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,14 +55,13 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@univerjs/icons": "^0.4.6",
58
- "@univerjs/core": "0.9.2-nightly.202507131606",
59
- "@univerjs/design": "0.9.2-nightly.202507131606",
60
- "@univerjs/engine-numfmt": "0.9.2-nightly.202507131606",
61
- "@univerjs/sheets": "0.9.2-nightly.202507131606",
62
- "@univerjs/ui": "0.9.2-nightly.202507131606",
63
- "@univerjs/engine-render": "0.9.2-nightly.202507131606",
64
- "@univerjs/sheets-numfmt": "0.9.2-nightly.202507131606",
65
- "@univerjs/sheets-ui": "0.9.2-nightly.202507131606"
58
+ "@univerjs/core": "0.9.2-nightly.202507141607",
59
+ "@univerjs/engine-render": "0.9.2-nightly.202507141607",
60
+ "@univerjs/design": "0.9.2-nightly.202507141607",
61
+ "@univerjs/sheets": "0.9.2-nightly.202507141607",
62
+ "@univerjs/sheets-numfmt": "0.9.2-nightly.202507141607",
63
+ "@univerjs/sheets-ui": "0.9.2-nightly.202507141607",
64
+ "@univerjs/ui": "0.9.2-nightly.202507141607"
66
65
  },
67
66
  "devDependencies": {
68
67
  "postcss": "^8.5.6",
@@ -73,7 +72,7 @@
73
72
  "vite": "^6.3.5",
74
73
  "vitest": "^3.2.4",
75
74
  "@univerjs-infra/shared": "0.9.2",
76
- "@univerjs/engine-formula": "0.9.2-nightly.202507131606"
75
+ "@univerjs/engine-formula": "0.9.2-nightly.202507141607"
77
76
  },
78
77
  "scripts": {
79
78
  "test": "vitest run",