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

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 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);
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.locale$,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.locale);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.locale).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);
@@ -0,0 +1 @@
1
+ "use strict";const e={sheet:{numfmt:{title:"Format de nombre",numfmtType:"Tipus de format",cancel:"Cancel·lar",confirm:"Confirmar",general:"General",accounting:"Comptabilitat",text:"Text",number:"Nombre",percent:"Percentatge",scientific:"Científic",currency:"Moneda",date:"Data",time:"Hora",thousandthPercentile:"Separador de milers",preview:"Previsualització",dateTime:"Data i hora",decimalLength:"Decimals",currencyType:"Símbol de moneda",moreFmt:"Formats",financialValue:"Valor financer",roundingCurrency:"Arrodonir la moneda",timeDuration:"Durada",currencyDes:"El format de moneda s'utilitza per representar valors monetaris generals. El format de comptabilitat alinea una columna de valors amb els punts decimals.",accountingDes:"El format de nombre de comptabilitat alinea una columna de valors amb símbols de moneda i punts decimals.",dateType:"Tipus de data",dateDes:"El format de data presenta valors de sèries de data i hora com a valors de data.",negType:"Tipus de nombre negatiu",generalDes:"El format regular no conté cap format de nombre específic.",thousandthPercentileDes:"El format de separador de milers s'utilitza per a la representació de nombres ordinaris. Els formats monetaris i de comptabilitat proporcionen un format especialitzat per a càlculs de valors monetaris.",addDecimal:"Augmentar decimals",subtractDecimal:"Disminuir decimals",customFormat:"Format personalitzat",customFormatDes:"Genera formats de nombre personalitzats basats en els existents."}}};module.exports=e;
@@ -0,0 +1 @@
1
+ "use strict";const e={sheet:{numfmt:{title:"Formato de número",numfmtType:"Tipos de formato",cancel:"Cancelar",confirm:"Confirmar",general:"General",accounting:"Contabilidad",text:"Texto",number:"Número",percent:"Porcentaje",scientific:"Científico",currency:"Moneda",date:"Fecha",time:"Hora",thousandthPercentile:"Separador de miles",preview:"Vista previa",dateTime:"Fecha y hora",decimalLength:"Decimales",currencyType:"Símbolo de moneda",moreFmt:"Formatos",financialValue:"Valor financiero",roundingCurrency:"Redondear la moneda",timeDuration:"Duración",currencyDes:"El formato de moneda se utiliza para representar valores monetarios generales. El formato de contabilidad alinea una columna de valores con los puntos decimales.",accountingDes:"El formato de número de contabilidad alinea una columna de valores con símbolos de moneda y puntos decimales.",dateType:"Tipo de fecha",dateDes:"El formato de fecha presenta valores de series de fecha y hora como valores de fecha.",negType:"Tipo de número negativo",generalDes:"El formato regular no contiene ningún formato de número específico.",thousandthPercentileDes:"El formato de separador de miles se utiliza para la representación de números ordinarios. Los formatos monetarios y de contabilidad proporcionan un formato especializado para cálculos de valores monetarios.",addDecimal:"Aumentar decimales",subtractDecimal:"Disminuir decimales",customFormat:"Formato personalizado",customFormatDes:"Generar formatos de número personalizados basados en los existentes."}}};module.exports=e;
package/lib/es/index.js CHANGED
@@ -524,7 +524,7 @@ let B = class extends ie {
524
524
  this._sheetInterceptorService = t, this._themeService = r, this._univerInstanceService = n, this._commandService = i, this._selectionManagerService = s, this._renderManagerService = o, this._numfmtService = a, this._componentManager = c, this._sidebarService = u, this._localeService = h, this._sheetsNumfmtCellContentController = l, this._initRealTimeRenderingInterceptor(), this._initPanel(), this._initCommands(), this._initCloseListener(), this._commandExecutedListener(), this._initNumfmtLocalChange();
525
525
  }
526
526
  _initNumfmtLocalChange() {
527
- this.disposeWithMe(et(this._sheetsNumfmtCellContentController.local$, this._localeService.currentLocale$).subscribe(() => {
527
+ this.disposeWithMe(et(this._sheetsNumfmtCellContentController.locale$, this._localeService.currentLocale$).subscribe(() => {
528
528
  this._forceUpdate();
529
529
  }));
530
530
  }
@@ -639,7 +639,7 @@ let B = class extends ie {
639
639
  const m = u.worksheet.getCellRaw(l, f), S = m == null ? void 0 : m.v, g = m == null ? void 0 : m.t;
640
640
  if (S == null || g !== U.NUMBER || this._previewPattern === null)
641
641
  return v;
642
- const y = Ot(this._previewPattern, S, this._sheetsNumfmtCellContentController.local);
642
+ const y = Ot(this._previewPattern, S, this._sheetsNumfmtCellContentController.locale);
643
643
  if (y.color) {
644
644
  const x = (p = this._themeService.getColorFromTheme(`${y.color}.500`)) != null ? p : y.color;
645
645
  return {
@@ -1080,7 +1080,7 @@ const Q = [
1080
1080
  },
1081
1081
  children: [
1082
1082
  /* @__PURE__ */ d("span", { children: t.t(c.label) }),
1083
- /* @__PURE__ */ d("span", { className: "univer-text-xs univer-text-gray-500", children: c.pattern ? kt(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.locale).result.trim() : "" })
1084
1084
  ]
1085
1085
  },
1086
1086
  u
@@ -0,0 +1,42 @@
1
+ const e = {
2
+ sheet: {
3
+ numfmt: {
4
+ title: "Format de nombre",
5
+ numfmtType: "Tipus de format",
6
+ cancel: "Cancel·lar",
7
+ confirm: "Confirmar",
8
+ general: "General",
9
+ accounting: "Comptabilitat",
10
+ text: "Text",
11
+ number: "Nombre",
12
+ percent: "Percentatge",
13
+ scientific: "Científic",
14
+ currency: "Moneda",
15
+ date: "Data",
16
+ time: "Hora",
17
+ thousandthPercentile: "Separador de milers",
18
+ preview: "Previsualització",
19
+ dateTime: "Data i hora",
20
+ decimalLength: "Decimals",
21
+ currencyType: "Símbol de moneda",
22
+ moreFmt: "Formats",
23
+ financialValue: "Valor financer",
24
+ roundingCurrency: "Arrodonir la moneda",
25
+ timeDuration: "Durada",
26
+ currencyDes: "El format de moneda s'utilitza per representar valors monetaris generals. El format de comptabilitat alinea una columna de valors amb els punts decimals.",
27
+ accountingDes: "El format de nombre de comptabilitat alinea una columna de valors amb símbols de moneda i punts decimals.",
28
+ dateType: "Tipus de data",
29
+ dateDes: "El format de data presenta valors de sèries de data i hora com a valors de data.",
30
+ negType: "Tipus de nombre negatiu",
31
+ generalDes: "El format regular no conté cap format de nombre específic.",
32
+ thousandthPercentileDes: "El format de separador de milers s'utilitza per a la representació de nombres ordinaris. Els formats monetaris i de comptabilitat proporcionen un format especialitzat per a càlculs de valors monetaris.",
33
+ addDecimal: "Augmentar decimals",
34
+ subtractDecimal: "Disminuir decimals",
35
+ customFormat: "Format personalitzat",
36
+ customFormatDes: "Genera formats de nombre personalitzats basats en els existents."
37
+ }
38
+ }
39
+ };
40
+ export {
41
+ e as default
42
+ };
@@ -0,0 +1,42 @@
1
+ const e = {
2
+ sheet: {
3
+ numfmt: {
4
+ title: "Formato de número",
5
+ numfmtType: "Tipos de formato",
6
+ cancel: "Cancelar",
7
+ confirm: "Confirmar",
8
+ general: "General",
9
+ accounting: "Contabilidad",
10
+ text: "Texto",
11
+ number: "Número",
12
+ percent: "Porcentaje",
13
+ scientific: "Científico",
14
+ currency: "Moneda",
15
+ date: "Fecha",
16
+ time: "Hora",
17
+ thousandthPercentile: "Separador de miles",
18
+ preview: "Vista previa",
19
+ dateTime: "Fecha y hora",
20
+ decimalLength: "Decimales",
21
+ currencyType: "Símbolo de moneda",
22
+ moreFmt: "Formatos",
23
+ financialValue: "Valor financiero",
24
+ roundingCurrency: "Redondear la moneda",
25
+ timeDuration: "Duración",
26
+ currencyDes: "El formato de moneda se utiliza para representar valores monetarios generales. El formato de contabilidad alinea una columna de valores con los puntos decimales.",
27
+ accountingDes: "El formato de número de contabilidad alinea una columna de valores con símbolos de moneda y puntos decimales.",
28
+ dateType: "Tipo de fecha",
29
+ dateDes: "El formato de fecha presenta valores de series de fecha y hora como valores de fecha.",
30
+ negType: "Tipo de número negativo",
31
+ generalDes: "El formato regular no contiene ningún formato de número específico.",
32
+ thousandthPercentileDes: "El formato de separador de miles se utiliza para la representación de números ordinarios. Los formatos monetarios y de contabilidad proporcionan un formato especializado para cálculos de valores monetarios.",
33
+ addDecimal: "Aumentar decimales",
34
+ subtractDecimal: "Disminuir decimales",
35
+ customFormat: "Formato personalizado",
36
+ customFormatDes: "Generar formatos de número personalizados basados en los existentes."
37
+ }
38
+ }
39
+ };
40
+ export {
41
+ e as default
42
+ };
package/lib/index.js CHANGED
@@ -524,7 +524,7 @@ let B = class extends ie {
524
524
  this._sheetInterceptorService = t, this._themeService = r, this._univerInstanceService = n, this._commandService = i, this._selectionManagerService = s, this._renderManagerService = o, this._numfmtService = a, this._componentManager = c, this._sidebarService = u, this._localeService = h, this._sheetsNumfmtCellContentController = l, this._initRealTimeRenderingInterceptor(), this._initPanel(), this._initCommands(), this._initCloseListener(), this._commandExecutedListener(), this._initNumfmtLocalChange();
525
525
  }
526
526
  _initNumfmtLocalChange() {
527
- this.disposeWithMe(et(this._sheetsNumfmtCellContentController.local$, this._localeService.currentLocale$).subscribe(() => {
527
+ this.disposeWithMe(et(this._sheetsNumfmtCellContentController.locale$, this._localeService.currentLocale$).subscribe(() => {
528
528
  this._forceUpdate();
529
529
  }));
530
530
  }
@@ -639,7 +639,7 @@ let B = class extends ie {
639
639
  const m = u.worksheet.getCellRaw(l, f), S = m == null ? void 0 : m.v, g = m == null ? void 0 : m.t;
640
640
  if (S == null || g !== U.NUMBER || this._previewPattern === null)
641
641
  return v;
642
- const y = Ot(this._previewPattern, S, this._sheetsNumfmtCellContentController.local);
642
+ const y = Ot(this._previewPattern, S, this._sheetsNumfmtCellContentController.locale);
643
643
  if (y.color) {
644
644
  const x = (p = this._themeService.getColorFromTheme(`${y.color}.500`)) != null ? p : y.color;
645
645
  return {
@@ -1080,7 +1080,7 @@ const Q = [
1080
1080
  },
1081
1081
  children: [
1082
1082
  /* @__PURE__ */ d("span", { children: t.t(c.label) }),
1083
- /* @__PURE__ */ d("span", { className: "univer-text-xs univer-text-gray-500", children: c.pattern ? kt(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.locale).result.trim() : "" })
1084
1084
  ]
1085
1085
  },
1086
1086
  u
@@ -0,0 +1,42 @@
1
+ const e = {
2
+ sheet: {
3
+ numfmt: {
4
+ title: "Format de nombre",
5
+ numfmtType: "Tipus de format",
6
+ cancel: "Cancel·lar",
7
+ confirm: "Confirmar",
8
+ general: "General",
9
+ accounting: "Comptabilitat",
10
+ text: "Text",
11
+ number: "Nombre",
12
+ percent: "Percentatge",
13
+ scientific: "Científic",
14
+ currency: "Moneda",
15
+ date: "Data",
16
+ time: "Hora",
17
+ thousandthPercentile: "Separador de milers",
18
+ preview: "Previsualització",
19
+ dateTime: "Data i hora",
20
+ decimalLength: "Decimals",
21
+ currencyType: "Símbol de moneda",
22
+ moreFmt: "Formats",
23
+ financialValue: "Valor financer",
24
+ roundingCurrency: "Arrodonir la moneda",
25
+ timeDuration: "Durada",
26
+ currencyDes: "El format de moneda s'utilitza per representar valors monetaris generals. El format de comptabilitat alinea una columna de valors amb els punts decimals.",
27
+ accountingDes: "El format de nombre de comptabilitat alinea una columna de valors amb símbols de moneda i punts decimals.",
28
+ dateType: "Tipus de data",
29
+ dateDes: "El format de data presenta valors de sèries de data i hora com a valors de data.",
30
+ negType: "Tipus de nombre negatiu",
31
+ generalDes: "El format regular no conté cap format de nombre específic.",
32
+ thousandthPercentileDes: "El format de separador de milers s'utilitza per a la representació de nombres ordinaris. Els formats monetaris i de comptabilitat proporcionen un format especialitzat per a càlculs de valors monetaris.",
33
+ addDecimal: "Augmentar decimals",
34
+ subtractDecimal: "Disminuir decimals",
35
+ customFormat: "Format personalitzat",
36
+ customFormatDes: "Genera formats de nombre personalitzats basats en els existents."
37
+ }
38
+ }
39
+ };
40
+ export {
41
+ e as default
42
+ };
@@ -0,0 +1,42 @@
1
+ const e = {
2
+ sheet: {
3
+ numfmt: {
4
+ title: "Formato de número",
5
+ numfmtType: "Tipos de formato",
6
+ cancel: "Cancelar",
7
+ confirm: "Confirmar",
8
+ general: "General",
9
+ accounting: "Contabilidad",
10
+ text: "Texto",
11
+ number: "Número",
12
+ percent: "Porcentaje",
13
+ scientific: "Científico",
14
+ currency: "Moneda",
15
+ date: "Fecha",
16
+ time: "Hora",
17
+ thousandthPercentile: "Separador de miles",
18
+ preview: "Vista previa",
19
+ dateTime: "Fecha y hora",
20
+ decimalLength: "Decimales",
21
+ currencyType: "Símbolo de moneda",
22
+ moreFmt: "Formatos",
23
+ financialValue: "Valor financiero",
24
+ roundingCurrency: "Redondear la moneda",
25
+ timeDuration: "Duración",
26
+ currencyDes: "El formato de moneda se utiliza para representar valores monetarios generales. El formato de contabilidad alinea una columna de valores con los puntos decimales.",
27
+ accountingDes: "El formato de número de contabilidad alinea una columna de valores con símbolos de moneda y puntos decimales.",
28
+ dateType: "Tipo de fecha",
29
+ dateDes: "El formato de fecha presenta valores de series de fecha y hora como valores de fecha.",
30
+ negType: "Tipo de número negativo",
31
+ generalDes: "El formato regular no contiene ningún formato de número específico.",
32
+ thousandthPercentileDes: "El formato de separador de miles se utiliza para la representación de números ordinarios. Los formatos monetarios y de contabilidad proporcionan un formato especializado para cálculos de valores monetarios.",
33
+ addDecimal: "Aumentar decimales",
34
+ subtractDecimal: "Disminuir decimales",
35
+ customFormat: "Formato personalizado",
36
+ customFormatDes: "Generar formatos de número personalizados basados en los existentes."
37
+ }
38
+ }
39
+ };
40
+ export {
41
+ e as default
42
+ };
@@ -0,0 +1,3 @@
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
+ export default locale;
@@ -0,0 +1,3 @@
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
+ export default locale;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
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"})});
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.locale$,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.locale);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.locale).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"})});
@@ -0,0 +1 @@
1
+ (function(e,a){typeof exports=="object"&&typeof module<"u"?module.exports=a():typeof define=="function"&&define.amd?define(a):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsNumfmtUiCaES=a())})(this,function(){"use strict";return{sheet:{numfmt:{title:"Format de nombre",numfmtType:"Tipus de format",cancel:"Cancel·lar",confirm:"Confirmar",general:"General",accounting:"Comptabilitat",text:"Text",number:"Nombre",percent:"Percentatge",scientific:"Científic",currency:"Moneda",date:"Data",time:"Hora",thousandthPercentile:"Separador de milers",preview:"Previsualització",dateTime:"Data i hora",decimalLength:"Decimals",currencyType:"Símbol de moneda",moreFmt:"Formats",financialValue:"Valor financer",roundingCurrency:"Arrodonir la moneda",timeDuration:"Durada",currencyDes:"El format de moneda s'utilitza per representar valors monetaris generals. El format de comptabilitat alinea una columna de valors amb els punts decimals.",accountingDes:"El format de nombre de comptabilitat alinea una columna de valors amb símbols de moneda i punts decimals.",dateType:"Tipus de data",dateDes:"El format de data presenta valors de sèries de data i hora com a valors de data.",negType:"Tipus de nombre negatiu",generalDes:"El format regular no conté cap format de nombre específic.",thousandthPercentileDes:"El format de separador de milers s'utilitza per a la representació de nombres ordinaris. Els formats monetaris i de comptabilitat proporcionen un format especialitzat per a càlculs de valors monetaris.",addDecimal:"Augmentar decimals",subtractDecimal:"Disminuir decimals",customFormat:"Format personalitzat",customFormatDes:"Genera formats de nombre personalitzats basats en els existents."}}}});
@@ -0,0 +1 @@
1
+ (function(e,o){typeof exports=="object"&&typeof module<"u"?module.exports=o():typeof define=="function"&&define.amd?define(o):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsNumfmtUiEsES=o())})(this,function(){"use strict";return{sheet:{numfmt:{title:"Formato de número",numfmtType:"Tipos de formato",cancel:"Cancelar",confirm:"Confirmar",general:"General",accounting:"Contabilidad",text:"Texto",number:"Número",percent:"Porcentaje",scientific:"Científico",currency:"Moneda",date:"Fecha",time:"Hora",thousandthPercentile:"Separador de miles",preview:"Vista previa",dateTime:"Fecha y hora",decimalLength:"Decimales",currencyType:"Símbolo de moneda",moreFmt:"Formatos",financialValue:"Valor financiero",roundingCurrency:"Redondear la moneda",timeDuration:"Duración",currencyDes:"El formato de moneda se utiliza para representar valores monetarios generales. El formato de contabilidad alinea una columna de valores con los puntos decimales.",accountingDes:"El formato de número de contabilidad alinea una columna de valores con símbolos de moneda y puntos decimales.",dateType:"Tipo de fecha",dateDes:"El formato de fecha presenta valores de series de fecha y hora como valores de fecha.",negType:"Tipo de número negativo",generalDes:"El formato regular no contiene ningún formato de número específico.",thousandthPercentileDes:"El formato de separador de miles se utiliza para la representación de números ordinarios. Los formatos monetarios y de contabilidad proporcionan un formato especializado para cálculos de valores monetarios.",addDecimal:"Aumentar decimales",subtractDecimal:"Disminuir decimales",customFormat:"Formato personalizado",customFormatDes:"Generar formatos de número personalizados basados en los existentes."}}}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt-ui",
3
- "version": "0.9.2-nightly.202507141607",
3
+ "version": "0.9.2-nightly.202507151607",
4
4
  "private": false,
5
5
  "description": "UniverSheet numfmt plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,13 +55,13 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@univerjs/icons": "^0.4.6",
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"
58
+ "@univerjs/design": "0.9.2-nightly.202507151607",
59
+ "@univerjs/engine-render": "0.9.2-nightly.202507151607",
60
+ "@univerjs/sheets": "0.9.2-nightly.202507151607",
61
+ "@univerjs/sheets-numfmt": "0.9.2-nightly.202507151607",
62
+ "@univerjs/sheets-ui": "0.9.2-nightly.202507151607",
63
+ "@univerjs/ui": "0.9.2-nightly.202507151607",
64
+ "@univerjs/core": "0.9.2-nightly.202507151607"
65
65
  },
66
66
  "devDependencies": {
67
67
  "postcss": "^8.5.6",
@@ -71,8 +71,8 @@
71
71
  "typescript": "^5.8.3",
72
72
  "vite": "^6.3.5",
73
73
  "vitest": "^3.2.4",
74
- "@univerjs-infra/shared": "0.9.2",
75
- "@univerjs/engine-formula": "0.9.2-nightly.202507141607"
74
+ "@univerjs/engine-formula": "0.9.2-nightly.202507151607",
75
+ "@univerjs-infra/shared": "0.9.2"
76
76
  },
77
77
  "scripts": {
78
78
  "test": "vitest run",