@univerjs/sheets-numfmt-ui 0.9.2 → 0.9.3

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