@univerjs/preset-sheets-conditional-formatting 0.6.10-nightly.202504141607 → 0.6.10-nightly.202504161609
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/umd/index.js
CHANGED
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
`,children:[R.jsx(Ge.RangeSelector,{unitId:u,subUnitId:y,initialValue:T,onChange:(N,U)=>f(U),onVerify:g}),p&&R.jsx("div",{className:F.cfErrorText,children:p})]}),R.jsx("div",{className:A.title,children:e.t("sheet.cf.panel.styleType")}),R.jsx("div",{className:A.mTBase,children:R.jsx(Z.Select,{className:F.width100,value:w,options:E,onChange:N=>S(N)})}),R.jsx(i,{interceptorManager:h,rule:(D=t.rule)==null?void 0:D.rule,onChange:s}),R.jsxs("div",{className:`
|
|
160
160
|
${A.mTBase}
|
|
161
161
|
${F.btnList}
|
|
162
|
-
`,children:[R.jsx(Z.Button,{size:"small",onClick:l,children:e.t("sheet.cf.panel.cancel")}),R.jsx(Z.Button,{className:A.mLSm,size:"small",type:"primary",onClick:b,children:e.t("sheet.cf.panel.submit")})]})]})},Va=t=>{const[e,n]=V.useState(t.rule),[r,a]=V.useState(!!t.rule),o=()=>{a(!0)},u=()=>{a(!1),n(void 0)},y=p=>{n(p),a(!0)};return R.jsx("div",{className:A.conditionalFormattingWrap,children:r?R.jsx(La,{onCancel:u,rule:e}):R.jsx(Ca,{onClick:y,onCreate:o})})};var Ua=Object.getOwnPropertyDescriptor,za=(t,e,n,r)=>{for(var a=r>1?void 0:r?Ua(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},at=(t,e)=>(n,r)=>e(n,r,t);const Pt="sheet.conditional.formatting.panel";let ot=class extends _.Disposable{constructor(e,n,r,a,o){super();xe(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=a,this._localeService=o,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_.UniverInstanceType.UNIVER_SHEET).subscribe(u=>{var y;u||(y=this._sidebarDisposable)==null||y.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(u=>{u.id===Pt&&(u.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const n={id:Pt,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Pt,rule:e,key:_.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this._componentManager.register(Pt,Va)}};ot=za([at(0,_.IUniverInstanceService),at(1,_.Inject(_.Injector)),at(2,_.Inject(Q.ComponentManager)),at(3,_.Inject(Q.ISidebarService)),at(4,_.Inject(_.LocaleService))],ot);var ye=(t=>(t[t.createRule=1]="createRule",t[t.viewRule=2]="viewRule",t[t.highlightCell=3]="highlightCell",t[t.rank=4]="rank",t[t.formula=5]="formula",t[t.colorScale=6]="colorScale",t[t.dataBar=7]="dataBar",t[t.icon=8]="icon",t[t.clearRangeRules=9]="clearRangeRules",t[t.clearWorkSheetRules=10]="clearWorkSheetRules",t))(ye||{});const it={id:"sheet.operation.open.conditional.formatting.panel",type:_.CommandType.OPERATION,handler:(t,e)=>{var y;const n=t.get(ot),r=t.get(Y.SheetsSelectionsService),a=t.get(_.ICommandService),o=((y=r.getCurrentSelections())==null?void 0:y.map(p=>p.range))||[];switch(e.value){case 3:{n.openPanel({...c.createDefaultRule(),ranges:o});break}case 4:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.rank}};n.openPanel(p);break}case 5:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.formula,value:"="}};n.openPanel(p);break}case 6:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.colorScale,config:[]}};n.openPanel(p);break}case 7:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.dataBar,isShowValue:!0}};n.openPanel(p);break}case 8:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.iconSet,config:[],isShowValue:!0}};n.openPanel(p);break}case 2:{n.openPanel();break}case 1:{n.openPanel({...c.createDefaultRule(),ranges:o});break}case 9:{a.executeCommand(c.ClearRangeCfCommand.id,{ranges:o});break}case 10:{a.executeCommand(c.ClearWorksheetCfCommand.id);break}}return!0}};var ka=Object.getOwnPropertyDescriptor,Aa=(t,e,n,r)=>{for(var a=r>1?void 0:r?ka(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},st=(t,e)=>(n,r)=>e(n,r,t);let lt=class extends _.Disposable{constructor(e,n,r,a,o){super();xe(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=n,this._injector=r,this._conditionalFormattingViewModel=a,this._univerInstanceService=o,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:c.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,n,r)=>this._collectConditionalRule(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=pe.COPY_TYPE.COPY,pasteType:u}=a,{range:y}=e||{},{range:p}=n;return this._generateConditionalFormattingMutations(p,{copyType:o,pasteType:u,copyRange:y})}}))}_collectConditionalRule(e,n,r){const a=new _.ObjectMatrix,o={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:n,cfMap:o}};const u=this._injector.invoke(m=>Y.rangeToDiscreteRange(r,m,e,n));if(!u)return;const{rows:y,cols:p}=u,C=new Set;y.forEach((m,T)=>{p.forEach((E,w)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,n,m,E);S&&(S.forEach(I=>C.add(I.cfId)),a.setValue(T,w,S.map(I=>I.cfId)))})}),C.forEach(m=>{const T=this._conditionalFormattingRuleModel.getRule(e,n,m);T&&(o[m]=T.rule)})}_generateConditionalFormattingMutations(e,n){const r=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),a=r.getActiveSheet(),o=r.getUnitId();if(!a)return{redos:[],undos:[]};const u=a.getSheetId();if(n.copyType===pe.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!n.copyRange)return{redos:[],undos:[]};if(![pe.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,pe.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,pe.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(n.pasteType))return{redos:[],undos:[]};const{ranges:[p,C],mapFunc:m}=pe.virtualizeDiscreteRanges([n.copyRange,e]),T=pe.getRepeatRange(p,C,!0),E={};_.Range.foreach(C,(l,g)=>{const{row:d,col:v}=m(l,g),D=this._conditionalFormattingViewModel.getCellCfs(o,u,d,v);D&&D.forEach(N=>{if(!E[N.cfId]){const U=new _.ObjectMatrix;E[N.cfId]=U;const z=this._conditionalFormattingRuleModel.getRule(o,u,N.cfId);z==null||z.ranges.forEach(O=>{_.Range.foreach(O,(L,B)=>{U.setValue(L,B,1)})})}E[N.cfId].realDeleteValue(d,v)})});const{matrix:w,info:S}=this._copyInfo,I=[];let h=this._conditionalFormattingRuleModel.createCfId(o,u);const i={},s=l=>{if(i[l])return i[l];const g=S==null?void 0:S.cfMap[l],d=[...this._conditionalFormattingRuleModel.getSubunitRules(o,u)||[],...I].find(v=>_.Tools.diffValue(v.rule,g));if(d)return i[l]=d,d;{const v={rule:g,cfId:h,ranges:[],stopIfTrue:!1};return i[l]=v,I.push(v),h=`${Number(h)+1}`,v}};T.forEach(l=>{w&&w.forValue((g,d,v)=>{const D=_.Rectangle.getPositionRange({startRow:g,endRow:g,startColumn:d,endColumn:d},l.startRange),{row:N,col:U}=m(D.startRow,D.startColumn);v.forEach(z=>{if(!E[z]){const O=s(z),L=new _.ObjectMatrix;E[z]=L,O.ranges.forEach(B=>{_.Range.foreach(B,(G,ee)=>{L.setValue(G,ee,1)})})}E[z].setValue(N,U,1)})})});const f=[],b=[];for(const l in E){const g=E[l],d=Y.findAllRectangle(Y.createTopMatrixFromMatrix(g));if(!d.length){const v={unitId:o,subUnitId:u,cfId:l};f.push({id:c.DeleteConditionalRuleMutation.id,params:v}),b.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,v))}if(I.some(v=>v.cfId===l)){const v=s(l),D={unitId:o,subUnitId:u,rule:{...v,ranges:d}};f.push({id:c.AddConditionalRuleMutation.id,params:D}),b.push(c.AddConditionalRuleMutationUndoFactory(this._injector,D))}else{const v=this._conditionalFormattingRuleModel.getRule(o,u,l);if(!v)continue;const D={unitId:o,subUnitId:u,rule:{...v,ranges:d}};f.push({id:c.SetConditionalRuleMutation.id,params:D}),b.push(...c.setConditionalRuleMutationUndoFactory(this._injector,D))}}return{redos:f,undos:b}}};lt=Aa([st(0,_.Inject(pe.ISheetClipboardService)),st(1,_.Inject(c.ConditionalFormattingRuleModel)),st(2,_.Inject(_.Injector)),st(3,_.Inject(c.ConditionalFormattingViewModel)),st(4,_.Inject(_.IUniverInstanceService))],lt);var Wa=Object.getOwnPropertyDescriptor,ja=(t,e,n,r)=>{for(var a=r>1?void 0:r?Wa(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},lr=(t,e)=>(n,r)=>e(n,r,t);let ct=class extends _.Disposable{constructor(t,e,n){super(),this._localeService=t,this._commandService=e,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===c.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},t.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};ct=ja([lr(0,_.Inject(_.LocaleService)),lr(1,_.ICommandService),lr(2,_.Inject(Y.SheetPermissionCheckController))],ct);var Ha=Object.getOwnPropertyDescriptor,Ba=(t,e,n,r)=>{for(var a=r>1?void 0:r?Ha(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},xt=(t,e)=>(n,r)=>e(n,r,t);let ut=class extends _.Disposable{constructor(t,e,n,r){super(),this._conditionalFormattingRuleModel=t,this._univerInstanceService=e,this._injector=n,this._refRangeService=r,this._initRefRange()}_initRefRange(){const t=new Map,e=(r,a,o)=>`${r}_${a}_${o}`,n=(r,a,o)=>{const u=p=>{const C=[...o.ranges],m=C.map(E=>Y.handleDefaultRangeChangeWithEffectRefCommands(E,p)).filter(E=>!!E);if(c.isRangesEqual(m,C))return{redos:[],undos:[]};if(m.length){const E={unitId:r,subUnitId:a,rule:{...o,ranges:m}},w=[{id:c.SetConditionalRuleMutation.id,params:E}],S=c.setConditionalRuleMutationUndoFactory(this._injector,E);return{redos:w,undos:S}}else{const E={unitId:r,subUnitId:a,cfId:o.cfId},w=[{id:c.DeleteConditionalRuleMutation.id,params:E}],S=c.DeleteConditionalRuleMutationUndoFactory(this._injector,E);return{redos:w,undos:S}}},y=[];o.ranges.forEach(p=>{const C=this._refRangeService.registerRefRange(p,u);y.push(()=>C.dispose())}),t.set(e(r,a,o.cfId),()=>y.forEach(p=>p()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(r=>{const{unitId:a,subUnitId:o,rule:u}=r,y=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),p=y.getActiveSheet();if(!(r.unitId!==y.getUnitId()||r.subUnitId!==(p==null?void 0:p.getSheetId())))switch(r.type){case"add":{n(r.unitId,r.subUnitId,r.rule);break}case"delete":{const C=t.get(e(a,o,u.cfId));C&&C();break}case"set":{const C=t.get(e(a,o,u.cfId));C&&C(),n(r.unitId,r.subUnitId,r.rule)}}})),this.disposeWithMe(_.toDisposable(()=>{t.forEach(r=>{r()}),t.clear()}))}};ut=Ba([xt(0,_.Inject(c.ConditionalFormattingRuleModel)),xt(1,_.Inject(_.IUniverInstanceService)),xt(2,_.Inject(_.Injector)),xt(3,_.Inject(Y.RefRangeService))],ut);var Fa=Object.getOwnPropertyDescriptor,Ga=(t,e,n,r)=>{for(var a=r>1?void 0:r?Fa(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},He=(t,e)=>(n,r)=>e(n,r,t);let dt=class extends _.Disposable{constructor(e,n,r,a,o,u){super();xe(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=n,this._univerInstanceService=r,this._renderManagerService=a,this._conditionalFormattingViewModel=o,this._conditionalFormattingRuleModel=u,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var n,r,a;const e=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getUnitId();(n=this._renderManagerService.getRenderById(e))==null||n.with(pe.SheetSkeletonManagerService).reCalculate(),(a=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.mainComponent)==null||a.makeDirty()}_initSkeleton(){this.disposeWithMe(Ce.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(qe.bufferTime(16),qe.filter(e=>!!e.length),qe.filter(e=>{const n=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();return r?e.filter(a=>a.unitId===n.getUnitId()&&a.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:_.InterceptorEffectEnum.Style,handler:(e,n,r)=>{const a=this._conditionalFormattingService.composeStyle(n.unitId,n.subUnitId,n.row,n.col);if(!a)return r(e);const o=n.workbook.getStyles(),y={...(typeof(e==null?void 0:e.s)=="string"?o.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},p={...e,s:y};return a.style&&Object.assign(y,a.style),p.fontRenderExtension||(p.fontRenderExtension={},a.isShowValue!==void 0&&(p.fontRenderExtension.isSkip=!a.isShowValue)),a.dataBar&&(p.dataBar=a.dataBar),a.iconSet&&(p.iconSet=a.iconSet,p.fontRenderExtension.leftOffset=c.DEFAULT_PADDING+c.DEFAULT_WIDTH),r(p)},priority:10}))}};dt=Ga([He(0,_.Inject(Y.SheetInterceptorService)),He(1,_.Inject(c.ConditionalFormattingService)),He(2,_.Inject(_.IUniverInstanceService)),He(3,_.Inject(hr.IRenderManagerService)),He(4,_.Inject(c.ConditionalFormattingViewModel)),He(5,_.Inject(c.ConditionalFormattingRuleModel))],dt);const yn="sheets-conditional-formatting-ui.config",Dt={};var qa=Object.defineProperty,Xa=Object.getOwnPropertyDescriptor,Ya=(t,e,n)=>e in t?qa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ka=(t,e,n,r)=>{for(var a=r>1?void 0:r?Xa(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},cr=(t,e)=>(n,r)=>e(n,r,t),bn=(t,e,n)=>Ya(t,typeof e!="symbol"?e+"":e,n);K.UniverSheetsConditionalFormattingMobileUIPlugin=class extends _.Plugin{constructor(e=Dt,n,r,a){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=a;const{menu:o,...u}=_.merge({},Dt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yn,u),this._initCommand(),this._injector.add([dt]),this._injector.add([ut]),this._injector.add([lt]),this._injector.add([ct]),this._injector.add([Ae])}_initCommand(){[At,Wt,jt,Ht,Bt,Ft,Gt,qt,Xt,it].forEach(e=>{this._commandService.registerCommand(e)})}},bn(K.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${c.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),bn(K.UniverSheetsConditionalFormattingMobileUIPlugin,"type",_.UniverInstanceType.UNIVER_SHEET),K.UniverSheetsConditionalFormattingMobileUIPlugin=Ka([_.DependentOn(c.UniverSheetsConditionalFormattingPlugin),cr(1,_.Inject(_.Injector)),cr(2,_.Inject(_.ICommandService)),cr(3,_.IConfigService)],K.UniverSheetsConditionalFormattingMobileUIPlugin);var Za=Object.getOwnPropertyDescriptor,$a=(t,e,n,r)=>{for(var a=r>1?void 0:r?Za(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},ft=(t,e)=>(n,r)=>e(n,r,t);let Mt=class extends _.Disposable{constructor(t,e,n,r,a){super(),this._injector=t,this._univerInstanceService=e,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=a,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(a,o,u,y,p)=>{var w;const C=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getUnitId(),m=(w=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:w.getSheetId();if(!C||!m)return;const T={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},E={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row};_.Range.foreach(u,(S,I)=>{const h=_.Rectangle.getPositionRange({startRow:S,startColumn:I,endColumn:I,endRow:S},T),i=_.Rectangle.getPositionRange({startRow:S,startColumn:I,endColumn:I,endRow:S},E),{row:s,col:f}=p(h.startRow,h.startColumn),b=this._conditionalFormattingViewModel.getCellCfs(C,m,s,f),{row:l,col:g}=p(i.startRow,i.startColumn),d=this._conditionalFormattingViewModel.getCellCfs(C,m,l,g);d&&d.forEach(v=>{let D=y.get(v.cfId);if(!y.get(v.cfId)){const N=this._conditionalFormattingRuleModel.getRule(C,m,v.cfId);if(!N)return;D=new _.ObjectMatrix,N.ranges.forEach(U=>{_.Range.foreach(U,(z,O)=>{D.setValue(z,O,1)})}),y.set(v.cfId,D)}D.realDeleteValue(l,g)}),b&&b.forEach(v=>{let D=y.get(v.cfId);if(!y.get(v.cfId)){const N=this._conditionalFormattingRuleModel.getRule(C,m,v.cfId);if(!N)return;D=new _.ObjectMatrix,N.ranges.forEach(U=>{_.Range.foreach(U,(z,O)=>{D.setValue(z,O,1)})}),y.set(v.cfId,D)}D.setValue(l,g,1)})})},n=(a,o)=>{var i,s,f;const u=(i=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getUnitId(),y=(f=(s=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getActiveSheet())==null?void 0:f.getSheetId(),p=new Map,C=[],m=[];if(!u||!y)return t();const T=pe.virtualizeDiscreteRanges([a,o]),[E,w]=T.ranges,{mapFunc:S}=T,I={row:E.startRow,col:E.startColumn};return pe.getAutoFillRepeatRange(E,w).forEach(b=>{e(I,b.repeatStartCell,b.relativeRange,p,S)}),p.forEach((b,l)=>{const g=this._conditionalFormattingRuleModel.getRule(u,y,l);if(!g)return;const d=Y.findAllRectangle(Y.createTopMatrixFromMatrix(b));if(d.length){const v={unitId:u,subUnitId:y,rule:{...g,ranges:d}};C.push({id:c.SetConditionalRuleMutation.id,params:v}),m.push(...c.setConditionalRuleMutationUndoFactory(this._injector,v))}else{const v={unitId:u,subUnitId:y,cfId:g.cfId};C.push({id:c.DeleteConditionalRuleMutation.id,params:v}),m.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,v))}}),{undos:m,redos:C}},r={id:c.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(a,o,u)=>{if(u===pe.APPLY_TYPE.COPY||u===pe.APPLY_TYPE.ONLY_FORMAT||u===pe.APPLY_TYPE.SERIES){const{source:y,target:p}=a;return n(y,p)}return t()}};this.disposeWithMe(this._autoFillService.addHook(r))}};Mt=$a([ft(0,_.Inject(_.Injector)),ft(1,_.Inject(_.IUniverInstanceService)),ft(2,_.Inject(pe.IAutoFillService)),ft(3,_.Inject(c.ConditionalFormattingRuleModel)),ft(4,_.Inject(c.ConditionalFormattingViewModel))],Mt);var Ja=Object.getOwnPropertyDescriptor,Qa=(t,e,n,r)=>{for(var a=r>1?void 0:r?Ja(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},pt=(t,e)=>(n,r)=>e(n,r,t);K.ConditionalFormattingClearController=class extends _.Disposable{constructor(e,n,r,a,o){super(),this._injector=e,this._univerInstanceService=n,this._sheetInterceptorService=r,this._selectionManagerService=a,this._conditionalFormattingRuleModel=o,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var o;const n=[],r=[],a={redos:n,undos:r};if([Y.ClearSelectionFormatCommand.id,Y.ClearSelectionAllCommand.id].includes(e.id)){const u=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(S=>S.range);if(!u)return a;const y=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),p=y.getActiveSheet();if(!p)return a;const C=y.getUnitId(),m=p.getSheetId(),T=this._conditionalFormattingRuleModel.getSubunitRules(C,m);if(!T||!T.length)return a;const{redos:E,undos:w}=Sn(this._injector,T,u,C,m);n.push(...E),r.push(...w)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:n,ranges:r})=>{const a=[],o=[],u={redos:a,undos:o};if(!r||!r.length)return u;const y=this._conditionalFormattingRuleModel.getSubunitRules(e,n);if(!y||!y.length)return u;const{redos:p,undos:C}=Sn(this._injector,y,r,e,n);return a.push(...p),o.push(...C),u}}))}},K.ConditionalFormattingClearController=Qa([pt(0,_.Inject(_.Injector)),pt(1,_.Inject(_.IUniverInstanceService)),pt(2,_.Inject(Y.SheetInterceptorService)),pt(3,_.Inject(Y.SheetsSelectionsService)),pt(4,_.Inject(c.ConditionalFormattingRuleModel))],K.ConditionalFormattingClearController);function Sn(t,e,n,r,a){const o=[],u=[];return e.filter(y=>n.some(p=>y.ranges.some(C=>_.Rectangle.getIntersects(C,p)))).forEach(y=>{const C=new Y.RangeMergeUtil().add(...y.ranges).subtract(...n).merge();if(C.length){const m={id:c.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:a,rule:{...y,ranges:C}}},T=c.setConditionalRuleMutationUndoFactory(t,m.params);o.push(m),u.push(...T)}else{const m={id:c.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:a,cfId:y.cfId}},T=c.DeleteConditionalRuleMutationUndoFactory(t,m.params);o.push(m),u.push(...T)}}),{redos:o,undos:u}}var eo=Object.getOwnPropertyDescriptor,to=(t,e,n,r)=>{for(var a=r>1?void 0:r?eo(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},Cn=(t,e)=>(n,r)=>e(n,r,t);let Nt=class extends _.Disposable{constructor(t,e){super(),this._sheetInterceptorService=t,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(_.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(Y.AFTER_CELL_EDIT,{handler:(t,e,n)=>{var u,y,p;t||n(t);const r=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),a=(u=r==null?void 0:r.style)!=null?u:{},o=Object.keys(a);if(t!=null&&t.p)return(p=(y=t.p.body)==null?void 0:y.textRuns)==null||p.forEach(C=>{C.ts&&o.forEach(m=>{var T;(T=C.ts)==null||delete T[m]})}),n(t);{const C={...(typeof(t==null?void 0:t.s)=="string"?e.workbook.getStyles().get(t.s):t==null?void 0:t.s)||{}};o.forEach(T=>{delete C[T]});const m={...t,s:{...C}};return n(m)}}})))}};Nt=to([Cn(0,_.Inject(Y.SheetInterceptorService)),Cn(1,_.Inject(c.ConditionalFormattingService))],Nt);const Tn=[Y.SetWorksheetActiveOperation.id,c.AddConditionalRuleMutation.id,c.SetConditionalRuleMutation.id,c.DeleteConditionalRuleMutation.id,c.MoveConditionalRuleMutation.id],ht=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:ye.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:ye.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:ye.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:ye.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:ye.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:ye.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:ye.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:ye.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:ye.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:ye.clearWorkSheetRules}],ro=t=>{const e=t.get(Y.SheetsSelectionsService),n=t.get(_.ICommandService),r=t.get(_.IUniverInstanceService),a=t.get(c.ConditionalFormattingRuleModel),o=new Ce.Observable(p=>Ce.merge(e.selectionMoveEnd$,e.selectionSet$,new Ce.Observable(C=>{const m=n.onCommandExecuted(T=>{var I;const{id:E,params:w}=T,S=(I=r.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getUnitId();Tn.includes(E)&&w.unitId===S&&C.next(null)});return()=>m.dispose()})).pipe(qe.debounceTime(16)).subscribe(()=>{var I;const C=((I=e.getCurrentSelections())==null?void 0:I.map(h=>h.range))||[],m=r.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET);if(!m)return;const T=m.getActiveSheet();if(!T)return;const S=(a.getSubunitRules(m.getUnitId(),T.getSheetId())||[]).filter(h=>h.ranges.some(i=>C.some(s=>_.Rectangle.intersects(s,i)))).map(h=>h.ranges).every(h=>Y.checkRangesEditablePermission(t,m.getUnitId(),T.getSheetId(),h));p.next(S)})),u=new Ce.Observable(p=>new Ce.Observable(C=>{const m=n.onCommandExecuted(T=>{var I;const{id:E,params:w}=T,S=(I=r.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getUnitId();Tn.includes(E)&&w.unitId===S&&C.next(null)});return()=>m.dispose()}).pipe(qe.debounceTime(16)).subscribe(()=>{const C=r.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET);if(!C)return;const m=C.getActiveSheet();if(!m)return;const T=a.getSubunitRules(C.getUnitId(),m.getSheetId())||[];if(!T.length)return p.next(!1),!1;const E=T.map(w=>w.ranges).every(w=>Y.checkRangesEditablePermission(t,C.getUnitId(),m.getSheetId(),w));p.next(E)})),y=new Ce.Observable(p=>{o.subscribe(C=>{const m=ht.find(T=>T.value===ye.clearRangeRules);m&&(m.disabled=!C,p.next(ht))}),u.subscribe(C=>{const m=ht.find(T=>T.value===ye.clearWorkSheetRules);m&&(m.disabled=!C,p.next(ht))}),p.next(ht)});return{id:it.id,type:Q.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:y,hidden$:Q.getMenuHiddenObservable(t,_.UniverInstanceType.UNIVER_SHEET),disabled$:pe.getCurrentRangeDisable$(t,{workbookTypes:[Y.WorkbookEditablePermission],worksheetTypes:[Y.WorksheetSetCellStylePermission,Y.WorksheetEditPermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint]})}},no={[Q.RibbonStartGroup.FORMULAS_INSERT]:{[it.id]:{order:0,menuItemFactory:ro}}};var ao=Object.getOwnPropertyDescriptor,oo=(t,e,n,r)=>{for(var a=r>1?void 0:r?ao(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},wn=(t,e)=>(n,r)=>e(n,r,t);let Lt=class extends _.Disposable{constructor(e,n){super();xe(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=n,this._menuManagerService.mergeMenu(no)}};Lt=oo([wn(0,_.Inject(_.Injector)),wn(1,Q.IMenuManagerService)],Lt);var io=Object.getOwnPropertyDescriptor,so=(t,e,n,r)=>{for(var a=r>1?void 0:r?io(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},Be=(t,e)=>(n,r)=>e(n,r,t);const lo=(t,e)=>{const n=m=>m.endRow-m.startRow+1,r=m=>m.endColumn-m.startColumn+1,a=n(e)%n(t),o=r(e)%r(t),u=Math.floor(n(e)/n(t)),y=Math.floor(r(e)/r(t)),p=[],C={startRow:0,endRow:n(t)-1,startColumn:0,endColumn:r(t)-1};if(n(e)===1&&r(e)===1){const m={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return p.push({repeatRelativeRange:C,startRange:m}),p}for(let m=0;m<u+(a?.1:0);m++)for(let T=0;T<y+(o?.1:0);T++){const E=n(t)*m,w=r(t)*T,S={startRow:E+e.startRow,endRow:E+e.startRow,startColumn:w+e.startColumn,endColumn:w+e.startColumn};let I=C;m===u&&a&&(I={...I},I.endRow=I.endRow-(n(t)-a)),T===y&&o&&(I={...I},I.endColumn=I.endColumn-(r(t)-o)),p.push({repeatRelativeRange:I,startRange:S})}return p};let Vt=class extends _.Disposable{constructor(e,n,r,a,o,u){super();xe(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=n,this._formatPainterService=r,this._sheetsSelectionsService=a,this._conditionalFormattingRuleModel=o,this._conditionalFormattingViewModel=u,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),n=(o,u,y,p,C)=>{const{unitId:m,subUnitId:T}=this._painterConfig,{targetUnitId:E,targetSubUnitId:w}=C,S={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},I={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};_.Range.foreach(y,(h,i)=>{const s=_.Rectangle.getPositionRange({startRow:h,startColumn:i,endColumn:i,endRow:h},S),f=_.Rectangle.getPositionRange({startRow:h,startColumn:i,endColumn:i,endRow:h},I),b=this._conditionalFormattingViewModel.getCellCfs(m,T,s.startRow,s.startColumn),l=this._conditionalFormattingViewModel.getCellCfs(E,w,f.startRow,f.startColumn);l&&l.forEach(g=>{let d=p.get(g.cfId);if(!p.get(g.cfId)){const v=this._conditionalFormattingRuleModel.getRule(E,w,g.cfId);if(!v)return;d=new _.ObjectMatrix,v.ranges.forEach(D=>{_.Range.foreach(D,(N,U)=>{d.setValue(N,U,1)})}),p.set(g.cfId,d)}d.realDeleteValue(f.startRow,f.startColumn)}),b&&b.forEach(g=>{const d=p.get(g.cfId);d&&d.setValue(f.startRow,f.startColumn,1)})})},r=(o,u,y)=>{var s;const{range:p,unitId:C,subUnitId:m}=this._painterConfig,T=o!==C||m!==u,E=new Map,w=[],S=[];if(!o||!u||!C||!m)return e();const I=(s=this._conditionalFormattingRuleModel.getSubunitRules(C,m))!=null?s:[];I==null||I.forEach(f=>{const{ranges:b,cfId:l}=f;if(b.some(g=>_.Rectangle.intersects(p,g))){const g=new _.ObjectMatrix;T||b.forEach(d=>{_.Range.foreach(d,(v,D)=>{g.setValue(v,D,1)})}),E.set(l,g)}});const h={row:p.startRow,col:p.startColumn};return lo(p,y).forEach(f=>{n(h,{row:f.startRange.startRow,col:f.startRange.startColumn},f.repeatRelativeRange,E,{targetUnitId:o,targetSubUnitId:u})}),E.forEach((f,b)=>{if(T){const l=this._conditionalFormattingRuleModel.getRule(o,u,b),g=Y.findAllRectangle(Y.createTopMatrixFromMatrix(f));if(l)if(g.length){const d={unitId:o,subUnitId:u,rule:{...l,ranges:g}};w.push({id:c.SetConditionalRuleMutation.id,params:d}),S.push(...c.setConditionalRuleMutationUndoFactory(this._injector,d))}else{const d={unitId:o,subUnitId:u,cfId:l.cfId};w.push({id:c.DeleteConditionalRuleMutation.id,params:d}),S.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,d))}else if(g.length){const d=this._conditionalFormattingRuleModel.getRule(C,m,b);if(d){const v={unitId:o,subUnitId:u,rule:{..._.Tools.deepClone(d),cfId:this._conditionalFormattingRuleModel.createCfId(o,u),ranges:g}};w.push({id:c.AddConditionalRuleMutation.id,params:v}),S.push(c.AddConditionalRuleMutationUndoFactory(this._injector,v))}}}else{const l=this._conditionalFormattingRuleModel.getRule(C,m,b);if(!l)return;const g=Y.findAllRectangle(Y.createTopMatrixFromMatrix(f));if(g.length){const d={unitId:C,subUnitId:m,rule:{...l,ranges:g}};w.push({id:c.SetConditionalRuleMutation.id,params:d}),S.push(...c.setConditionalRuleMutationUndoFactory(this._injector,d))}else{const d={unitId:C,subUnitId:m,cfId:l.cfId};w.push({id:c.DeleteConditionalRuleMutation.id,params:d}),S.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,d))}}}),{undos:S,redos:w}},a={id:c.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:o=>{var u,y,p;switch(o){case pe.FormatPainterStatus.INFINITE:case pe.FormatPainterStatus.ONCE:{const C=(u=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:u.getUnitId(),m=(p=(y=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getActiveSheet())==null?void 0:p.getSheetId(),T=this._sheetsSelectionsService.getCurrentLastSelection(),E=T==null?void 0:T.range;C&&m&&E&&(this._painterConfig={unitId:C,subUnitId:m,range:E});break}case pe.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(o,u,y)=>this._painterConfig?r(o,u,y):{redos:[],undos:[]}};this._formatPainterService.addHook(a)}};Vt=so([Be(0,_.Inject(_.Injector)),Be(1,_.Inject(_.IUniverInstanceService)),Be(2,_.Inject(pe.IFormatPainterService)),Be(3,_.Inject(Y.SheetsSelectionsService)),Be(4,_.Inject(c.ConditionalFormattingRuleModel)),Be(5,_.Inject(c.ConditionalFormattingViewModel))],Vt);var co=Object.getOwnPropertyDescriptor,uo=(t,e,n,r)=>{for(var a=r>1?void 0:r?co(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},ur=(t,e)=>(n,r)=>e(n,r,t);let Ut=class extends _.Disposable{constructor(t,e,n){super(),this._conditionalFormattingViewModel=t,this._univerInstanceService=e,this._renderManagerService=n,this._init()}_init(){const t=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),e=n=>{const r=n.getUnitId(),a=this._renderManagerService.getRenderById(r);if(!a)return;const o=a.with(pe.SheetSkeletonManagerService);this.disposeWithMe(o.currentSkeleton$.subscribe(u=>{if(u){const y=u.skeleton.rowColumnSegment,p=y.endColumn-y.startColumn+1,m=(y.endRow-y.startRow+1)*p*9,T=Math.max(c.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,m);this._conditionalFormattingViewModel.setCacheLength(T)}}))};t&&e(t),this._univerInstanceService.getCurrentTypeOfUnit$(_.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{n&&e(n)})}};Ut=uo([ur(0,_.Inject(c.ConditionalFormattingViewModel)),ur(1,_.IUniverInstanceService),ur(2,hr.IRenderManagerService)],Ut);var fo=Object.defineProperty,po=Object.getOwnPropertyDescriptor,ho=(t,e,n)=>e in t?fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,go=(t,e,n,r)=>{for(var a=r>1?void 0:r?po(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},dr=(t,e)=>(n,r)=>e(n,r,t),In=(t,e,n)=>ho(t,typeof e!="symbol"?e+"":e,n);K.UniverSheetsConditionalFormattingUIPlugin=class extends _.Plugin{constructor(e=Dt,n,r,a){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=a;const{menu:o,...u}=_.merge({},Dt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yn,u),this._initCommand()}onStarting(){_.registerDependencies(this._injector,[[dt],[ut],[lt],[Mt],[ct],[ot],[Lt],[Ae],[Nt],[K.ConditionalFormattingClearController],[Vt],[Ut]]),_.touchDependencies(this._injector,[[dt]])}onReady(){_.touchDependencies(this._injector,[[Lt],[ot]])}onRendered(){_.touchDependencies(this._injector,[[Mt],[K.ConditionalFormattingClearController],[lt],[Nt],[Ae],[Vt],[ct],[ut],[Ut]])}_initCommand(){[At,Wt,jt,Ht,Bt,Ft,Gt,qt,Xt,it].forEach(e=>{this._commandService.registerCommand(e)})}},In(K.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${c.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),In(K.UniverSheetsConditionalFormattingUIPlugin,"type",_.UniverInstanceType.UNIVER_SHEET),K.UniverSheetsConditionalFormattingUIPlugin=go([_.DependentOn(c.UniverSheetsConditionalFormattingPlugin),dr(1,_.Inject(_.Injector)),dr(2,_.Inject(_.ICommandService)),dr(3,_.IConfigService)],K.UniverSheetsConditionalFormattingUIPlugin),K.AddAverageCfCommand=At,K.AddColorScaleConditionalRuleCommand=Wt,K.AddDataBarConditionalRuleCommand=jt,K.AddDuplicateValuesCfCommand=Ht,K.AddNumberCfCommand=Bt,K.AddRankCfCommand=Ft,K.AddTextCfCommand=Gt,K.AddTimePeriodCfCommand=qt,K.AddUniqueValuesCfCommand=Xt,K.OpenConditionalFormattingOperator=it,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})});
|
|
162
|
+
`,children:[R.jsx(Z.Button,{size:"small",onClick:l,children:e.t("sheet.cf.panel.cancel")}),R.jsx(Z.Button,{className:A.mLSm,size:"small",variant:"primary",onClick:b,children:e.t("sheet.cf.panel.submit")})]})]})},Va=t=>{const[e,n]=V.useState(t.rule),[r,a]=V.useState(!!t.rule),o=()=>{a(!0)},u=()=>{a(!1),n(void 0)},y=p=>{n(p),a(!0)};return R.jsx("div",{className:A.conditionalFormattingWrap,children:r?R.jsx(La,{onCancel:u,rule:e}):R.jsx(Ca,{onClick:y,onCreate:o})})};var Ua=Object.getOwnPropertyDescriptor,za=(t,e,n,r)=>{for(var a=r>1?void 0:r?Ua(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},at=(t,e)=>(n,r)=>e(n,r,t);const Pt="sheet.conditional.formatting.panel";let ot=class extends _.Disposable{constructor(e,n,r,a,o){super();xe(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=a,this._localeService=o,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_.UniverInstanceType.UNIVER_SHEET).subscribe(u=>{var y;u||(y=this._sidebarDisposable)==null||y.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(u=>{u.id===Pt&&(u.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const n={id:Pt,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Pt,rule:e,key:_.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this._componentManager.register(Pt,Va)}};ot=za([at(0,_.IUniverInstanceService),at(1,_.Inject(_.Injector)),at(2,_.Inject(Q.ComponentManager)),at(3,_.Inject(Q.ISidebarService)),at(4,_.Inject(_.LocaleService))],ot);var ye=(t=>(t[t.createRule=1]="createRule",t[t.viewRule=2]="viewRule",t[t.highlightCell=3]="highlightCell",t[t.rank=4]="rank",t[t.formula=5]="formula",t[t.colorScale=6]="colorScale",t[t.dataBar=7]="dataBar",t[t.icon=8]="icon",t[t.clearRangeRules=9]="clearRangeRules",t[t.clearWorkSheetRules=10]="clearWorkSheetRules",t))(ye||{});const it={id:"sheet.operation.open.conditional.formatting.panel",type:_.CommandType.OPERATION,handler:(t,e)=>{var y;const n=t.get(ot),r=t.get(Y.SheetsSelectionsService),a=t.get(_.ICommandService),o=((y=r.getCurrentSelections())==null?void 0:y.map(p=>p.range))||[];switch(e.value){case 3:{n.openPanel({...c.createDefaultRule(),ranges:o});break}case 4:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.rank}};n.openPanel(p);break}case 5:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.formula,value:"="}};n.openPanel(p);break}case 6:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.colorScale,config:[]}};n.openPanel(p);break}case 7:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.dataBar,isShowValue:!0}};n.openPanel(p);break}case 8:{const p={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.iconSet,config:[],isShowValue:!0}};n.openPanel(p);break}case 2:{n.openPanel();break}case 1:{n.openPanel({...c.createDefaultRule(),ranges:o});break}case 9:{a.executeCommand(c.ClearRangeCfCommand.id,{ranges:o});break}case 10:{a.executeCommand(c.ClearWorksheetCfCommand.id);break}}return!0}};var ka=Object.getOwnPropertyDescriptor,Aa=(t,e,n,r)=>{for(var a=r>1?void 0:r?ka(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},st=(t,e)=>(n,r)=>e(n,r,t);let lt=class extends _.Disposable{constructor(e,n,r,a,o){super();xe(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=n,this._injector=r,this._conditionalFormattingViewModel=a,this._univerInstanceService=o,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:c.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,n,r)=>this._collectConditionalRule(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=pe.COPY_TYPE.COPY,pasteType:u}=a,{range:y}=e||{},{range:p}=n;return this._generateConditionalFormattingMutations(p,{copyType:o,pasteType:u,copyRange:y})}}))}_collectConditionalRule(e,n,r){const a=new _.ObjectMatrix,o={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:n,cfMap:o}};const u=this._injector.invoke(m=>Y.rangeToDiscreteRange(r,m,e,n));if(!u)return;const{rows:y,cols:p}=u,C=new Set;y.forEach((m,T)=>{p.forEach((E,w)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,n,m,E);S&&(S.forEach(I=>C.add(I.cfId)),a.setValue(T,w,S.map(I=>I.cfId)))})}),C.forEach(m=>{const T=this._conditionalFormattingRuleModel.getRule(e,n,m);T&&(o[m]=T.rule)})}_generateConditionalFormattingMutations(e,n){const r=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),a=r.getActiveSheet(),o=r.getUnitId();if(!a)return{redos:[],undos:[]};const u=a.getSheetId();if(n.copyType===pe.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!n.copyRange)return{redos:[],undos:[]};if(![pe.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,pe.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,pe.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(n.pasteType))return{redos:[],undos:[]};const{ranges:[p,C],mapFunc:m}=pe.virtualizeDiscreteRanges([n.copyRange,e]),T=pe.getRepeatRange(p,C,!0),E={};_.Range.foreach(C,(l,g)=>{const{row:d,col:v}=m(l,g),D=this._conditionalFormattingViewModel.getCellCfs(o,u,d,v);D&&D.forEach(N=>{if(!E[N.cfId]){const U=new _.ObjectMatrix;E[N.cfId]=U;const z=this._conditionalFormattingRuleModel.getRule(o,u,N.cfId);z==null||z.ranges.forEach(O=>{_.Range.foreach(O,(L,B)=>{U.setValue(L,B,1)})})}E[N.cfId].realDeleteValue(d,v)})});const{matrix:w,info:S}=this._copyInfo,I=[];let h=this._conditionalFormattingRuleModel.createCfId(o,u);const i={},s=l=>{if(i[l])return i[l];const g=S==null?void 0:S.cfMap[l],d=[...this._conditionalFormattingRuleModel.getSubunitRules(o,u)||[],...I].find(v=>_.Tools.diffValue(v.rule,g));if(d)return i[l]=d,d;{const v={rule:g,cfId:h,ranges:[],stopIfTrue:!1};return i[l]=v,I.push(v),h=`${Number(h)+1}`,v}};T.forEach(l=>{w&&w.forValue((g,d,v)=>{const D=_.Rectangle.getPositionRange({startRow:g,endRow:g,startColumn:d,endColumn:d},l.startRange),{row:N,col:U}=m(D.startRow,D.startColumn);v.forEach(z=>{if(!E[z]){const O=s(z),L=new _.ObjectMatrix;E[z]=L,O.ranges.forEach(B=>{_.Range.foreach(B,(G,ee)=>{L.setValue(G,ee,1)})})}E[z].setValue(N,U,1)})})});const f=[],b=[];for(const l in E){const g=E[l],d=Y.findAllRectangle(Y.createTopMatrixFromMatrix(g));if(!d.length){const v={unitId:o,subUnitId:u,cfId:l};f.push({id:c.DeleteConditionalRuleMutation.id,params:v}),b.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,v))}if(I.some(v=>v.cfId===l)){const v=s(l),D={unitId:o,subUnitId:u,rule:{...v,ranges:d}};f.push({id:c.AddConditionalRuleMutation.id,params:D}),b.push(c.AddConditionalRuleMutationUndoFactory(this._injector,D))}else{const v=this._conditionalFormattingRuleModel.getRule(o,u,l);if(!v)continue;const D={unitId:o,subUnitId:u,rule:{...v,ranges:d}};f.push({id:c.SetConditionalRuleMutation.id,params:D}),b.push(...c.setConditionalRuleMutationUndoFactory(this._injector,D))}}return{redos:f,undos:b}}};lt=Aa([st(0,_.Inject(pe.ISheetClipboardService)),st(1,_.Inject(c.ConditionalFormattingRuleModel)),st(2,_.Inject(_.Injector)),st(3,_.Inject(c.ConditionalFormattingViewModel)),st(4,_.Inject(_.IUniverInstanceService))],lt);var Wa=Object.getOwnPropertyDescriptor,ja=(t,e,n,r)=>{for(var a=r>1?void 0:r?Wa(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},lr=(t,e)=>(n,r)=>e(n,r,t);let ct=class extends _.Disposable{constructor(t,e,n){super(),this._localeService=t,this._commandService=e,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===c.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},t.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};ct=ja([lr(0,_.Inject(_.LocaleService)),lr(1,_.ICommandService),lr(2,_.Inject(Y.SheetPermissionCheckController))],ct);var Ha=Object.getOwnPropertyDescriptor,Ba=(t,e,n,r)=>{for(var a=r>1?void 0:r?Ha(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},xt=(t,e)=>(n,r)=>e(n,r,t);let ut=class extends _.Disposable{constructor(t,e,n,r){super(),this._conditionalFormattingRuleModel=t,this._univerInstanceService=e,this._injector=n,this._refRangeService=r,this._initRefRange()}_initRefRange(){const t=new Map,e=(r,a,o)=>`${r}_${a}_${o}`,n=(r,a,o)=>{const u=p=>{const C=[...o.ranges],m=C.map(E=>Y.handleDefaultRangeChangeWithEffectRefCommands(E,p)).filter(E=>!!E);if(c.isRangesEqual(m,C))return{redos:[],undos:[]};if(m.length){const E={unitId:r,subUnitId:a,rule:{...o,ranges:m}},w=[{id:c.SetConditionalRuleMutation.id,params:E}],S=c.setConditionalRuleMutationUndoFactory(this._injector,E);return{redos:w,undos:S}}else{const E={unitId:r,subUnitId:a,cfId:o.cfId},w=[{id:c.DeleteConditionalRuleMutation.id,params:E}],S=c.DeleteConditionalRuleMutationUndoFactory(this._injector,E);return{redos:w,undos:S}}},y=[];o.ranges.forEach(p=>{const C=this._refRangeService.registerRefRange(p,u);y.push(()=>C.dispose())}),t.set(e(r,a,o.cfId),()=>y.forEach(p=>p()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(r=>{const{unitId:a,subUnitId:o,rule:u}=r,y=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),p=y.getActiveSheet();if(!(r.unitId!==y.getUnitId()||r.subUnitId!==(p==null?void 0:p.getSheetId())))switch(r.type){case"add":{n(r.unitId,r.subUnitId,r.rule);break}case"delete":{const C=t.get(e(a,o,u.cfId));C&&C();break}case"set":{const C=t.get(e(a,o,u.cfId));C&&C(),n(r.unitId,r.subUnitId,r.rule)}}})),this.disposeWithMe(_.toDisposable(()=>{t.forEach(r=>{r()}),t.clear()}))}};ut=Ba([xt(0,_.Inject(c.ConditionalFormattingRuleModel)),xt(1,_.Inject(_.IUniverInstanceService)),xt(2,_.Inject(_.Injector)),xt(3,_.Inject(Y.RefRangeService))],ut);var Fa=Object.getOwnPropertyDescriptor,Ga=(t,e,n,r)=>{for(var a=r>1?void 0:r?Fa(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},He=(t,e)=>(n,r)=>e(n,r,t);let dt=class extends _.Disposable{constructor(e,n,r,a,o,u){super();xe(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=n,this._univerInstanceService=r,this._renderManagerService=a,this._conditionalFormattingViewModel=o,this._conditionalFormattingRuleModel=u,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var n,r,a;const e=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getUnitId();(n=this._renderManagerService.getRenderById(e))==null||n.with(pe.SheetSkeletonManagerService).reCalculate(),(a=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.mainComponent)==null||a.makeDirty()}_initSkeleton(){this.disposeWithMe(Ce.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(qe.bufferTime(16),qe.filter(e=>!!e.length),qe.filter(e=>{const n=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();return r?e.filter(a=>a.unitId===n.getUnitId()&&a.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:_.InterceptorEffectEnum.Style,handler:(e,n,r)=>{const a=this._conditionalFormattingService.composeStyle(n.unitId,n.subUnitId,n.row,n.col);if(!a)return r(e);const o=n.workbook.getStyles(),y={...(typeof(e==null?void 0:e.s)=="string"?o.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},p={...e,s:y};return a.style&&Object.assign(y,a.style),p.fontRenderExtension||(p.fontRenderExtension={},a.isShowValue!==void 0&&(p.fontRenderExtension.isSkip=!a.isShowValue)),a.dataBar&&(p.dataBar=a.dataBar),a.iconSet&&(p.iconSet=a.iconSet,p.fontRenderExtension.leftOffset=c.DEFAULT_PADDING+c.DEFAULT_WIDTH),r(p)},priority:10}))}};dt=Ga([He(0,_.Inject(Y.SheetInterceptorService)),He(1,_.Inject(c.ConditionalFormattingService)),He(2,_.Inject(_.IUniverInstanceService)),He(3,_.Inject(hr.IRenderManagerService)),He(4,_.Inject(c.ConditionalFormattingViewModel)),He(5,_.Inject(c.ConditionalFormattingRuleModel))],dt);const yn="sheets-conditional-formatting-ui.config",Dt={};var qa=Object.defineProperty,Xa=Object.getOwnPropertyDescriptor,Ya=(t,e,n)=>e in t?qa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ka=(t,e,n,r)=>{for(var a=r>1?void 0:r?Xa(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},cr=(t,e)=>(n,r)=>e(n,r,t),bn=(t,e,n)=>Ya(t,typeof e!="symbol"?e+"":e,n);K.UniverSheetsConditionalFormattingMobileUIPlugin=class extends _.Plugin{constructor(e=Dt,n,r,a){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=a;const{menu:o,...u}=_.merge({},Dt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yn,u),this._initCommand(),this._injector.add([dt]),this._injector.add([ut]),this._injector.add([lt]),this._injector.add([ct]),this._injector.add([Ae])}_initCommand(){[At,Wt,jt,Ht,Bt,Ft,Gt,qt,Xt,it].forEach(e=>{this._commandService.registerCommand(e)})}},bn(K.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${c.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),bn(K.UniverSheetsConditionalFormattingMobileUIPlugin,"type",_.UniverInstanceType.UNIVER_SHEET),K.UniverSheetsConditionalFormattingMobileUIPlugin=Ka([_.DependentOn(c.UniverSheetsConditionalFormattingPlugin),cr(1,_.Inject(_.Injector)),cr(2,_.Inject(_.ICommandService)),cr(3,_.IConfigService)],K.UniverSheetsConditionalFormattingMobileUIPlugin);var Za=Object.getOwnPropertyDescriptor,$a=(t,e,n,r)=>{for(var a=r>1?void 0:r?Za(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},ft=(t,e)=>(n,r)=>e(n,r,t);let Mt=class extends _.Disposable{constructor(t,e,n,r,a){super(),this._injector=t,this._univerInstanceService=e,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=a,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(a,o,u,y,p)=>{var w;const C=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getUnitId(),m=(w=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:w.getSheetId();if(!C||!m)return;const T={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},E={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row};_.Range.foreach(u,(S,I)=>{const h=_.Rectangle.getPositionRange({startRow:S,startColumn:I,endColumn:I,endRow:S},T),i=_.Rectangle.getPositionRange({startRow:S,startColumn:I,endColumn:I,endRow:S},E),{row:s,col:f}=p(h.startRow,h.startColumn),b=this._conditionalFormattingViewModel.getCellCfs(C,m,s,f),{row:l,col:g}=p(i.startRow,i.startColumn),d=this._conditionalFormattingViewModel.getCellCfs(C,m,l,g);d&&d.forEach(v=>{let D=y.get(v.cfId);if(!y.get(v.cfId)){const N=this._conditionalFormattingRuleModel.getRule(C,m,v.cfId);if(!N)return;D=new _.ObjectMatrix,N.ranges.forEach(U=>{_.Range.foreach(U,(z,O)=>{D.setValue(z,O,1)})}),y.set(v.cfId,D)}D.realDeleteValue(l,g)}),b&&b.forEach(v=>{let D=y.get(v.cfId);if(!y.get(v.cfId)){const N=this._conditionalFormattingRuleModel.getRule(C,m,v.cfId);if(!N)return;D=new _.ObjectMatrix,N.ranges.forEach(U=>{_.Range.foreach(U,(z,O)=>{D.setValue(z,O,1)})}),y.set(v.cfId,D)}D.setValue(l,g,1)})})},n=(a,o)=>{var i,s,f;const u=(i=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getUnitId(),y=(f=(s=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getActiveSheet())==null?void 0:f.getSheetId(),p=new Map,C=[],m=[];if(!u||!y)return t();const T=pe.virtualizeDiscreteRanges([a,o]),[E,w]=T.ranges,{mapFunc:S}=T,I={row:E.startRow,col:E.startColumn};return pe.getAutoFillRepeatRange(E,w).forEach(b=>{e(I,b.repeatStartCell,b.relativeRange,p,S)}),p.forEach((b,l)=>{const g=this._conditionalFormattingRuleModel.getRule(u,y,l);if(!g)return;const d=Y.findAllRectangle(Y.createTopMatrixFromMatrix(b));if(d.length){const v={unitId:u,subUnitId:y,rule:{...g,ranges:d}};C.push({id:c.SetConditionalRuleMutation.id,params:v}),m.push(...c.setConditionalRuleMutationUndoFactory(this._injector,v))}else{const v={unitId:u,subUnitId:y,cfId:g.cfId};C.push({id:c.DeleteConditionalRuleMutation.id,params:v}),m.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,v))}}),{undos:m,redos:C}},r={id:c.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(a,o,u)=>{if(u===pe.APPLY_TYPE.COPY||u===pe.APPLY_TYPE.ONLY_FORMAT||u===pe.APPLY_TYPE.SERIES){const{source:y,target:p}=a;return n(y,p)}return t()}};this.disposeWithMe(this._autoFillService.addHook(r))}};Mt=$a([ft(0,_.Inject(_.Injector)),ft(1,_.Inject(_.IUniverInstanceService)),ft(2,_.Inject(pe.IAutoFillService)),ft(3,_.Inject(c.ConditionalFormattingRuleModel)),ft(4,_.Inject(c.ConditionalFormattingViewModel))],Mt);var Ja=Object.getOwnPropertyDescriptor,Qa=(t,e,n,r)=>{for(var a=r>1?void 0:r?Ja(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},pt=(t,e)=>(n,r)=>e(n,r,t);K.ConditionalFormattingClearController=class extends _.Disposable{constructor(e,n,r,a,o){super(),this._injector=e,this._univerInstanceService=n,this._sheetInterceptorService=r,this._selectionManagerService=a,this._conditionalFormattingRuleModel=o,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var o;const n=[],r=[],a={redos:n,undos:r};if([Y.ClearSelectionFormatCommand.id,Y.ClearSelectionAllCommand.id].includes(e.id)){const u=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(S=>S.range);if(!u)return a;const y=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),p=y.getActiveSheet();if(!p)return a;const C=y.getUnitId(),m=p.getSheetId(),T=this._conditionalFormattingRuleModel.getSubunitRules(C,m);if(!T||!T.length)return a;const{redos:E,undos:w}=Sn(this._injector,T,u,C,m);n.push(...E),r.push(...w)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:n,ranges:r})=>{const a=[],o=[],u={redos:a,undos:o};if(!r||!r.length)return u;const y=this._conditionalFormattingRuleModel.getSubunitRules(e,n);if(!y||!y.length)return u;const{redos:p,undos:C}=Sn(this._injector,y,r,e,n);return a.push(...p),o.push(...C),u}}))}},K.ConditionalFormattingClearController=Qa([pt(0,_.Inject(_.Injector)),pt(1,_.Inject(_.IUniverInstanceService)),pt(2,_.Inject(Y.SheetInterceptorService)),pt(3,_.Inject(Y.SheetsSelectionsService)),pt(4,_.Inject(c.ConditionalFormattingRuleModel))],K.ConditionalFormattingClearController);function Sn(t,e,n,r,a){const o=[],u=[];return e.filter(y=>n.some(p=>y.ranges.some(C=>_.Rectangle.getIntersects(C,p)))).forEach(y=>{const C=new Y.RangeMergeUtil().add(...y.ranges).subtract(...n).merge();if(C.length){const m={id:c.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:a,rule:{...y,ranges:C}}},T=c.setConditionalRuleMutationUndoFactory(t,m.params);o.push(m),u.push(...T)}else{const m={id:c.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:a,cfId:y.cfId}},T=c.DeleteConditionalRuleMutationUndoFactory(t,m.params);o.push(m),u.push(...T)}}),{redos:o,undos:u}}var eo=Object.getOwnPropertyDescriptor,to=(t,e,n,r)=>{for(var a=r>1?void 0:r?eo(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},Cn=(t,e)=>(n,r)=>e(n,r,t);let Nt=class extends _.Disposable{constructor(t,e){super(),this._sheetInterceptorService=t,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(_.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(Y.AFTER_CELL_EDIT,{handler:(t,e,n)=>{var u,y,p;t||n(t);const r=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),a=(u=r==null?void 0:r.style)!=null?u:{},o=Object.keys(a);if(t!=null&&t.p)return(p=(y=t.p.body)==null?void 0:y.textRuns)==null||p.forEach(C=>{C.ts&&o.forEach(m=>{var T;(T=C.ts)==null||delete T[m]})}),n(t);{const C={...(typeof(t==null?void 0:t.s)=="string"?e.workbook.getStyles().get(t.s):t==null?void 0:t.s)||{}};o.forEach(T=>{delete C[T]});const m={...t,s:{...C}};return n(m)}}})))}};Nt=to([Cn(0,_.Inject(Y.SheetInterceptorService)),Cn(1,_.Inject(c.ConditionalFormattingService))],Nt);const Tn=[Y.SetWorksheetActiveOperation.id,c.AddConditionalRuleMutation.id,c.SetConditionalRuleMutation.id,c.DeleteConditionalRuleMutation.id,c.MoveConditionalRuleMutation.id],ht=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:ye.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:ye.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:ye.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:ye.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:ye.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:ye.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:ye.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:ye.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:ye.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:ye.clearWorkSheetRules}],ro=t=>{const e=t.get(Y.SheetsSelectionsService),n=t.get(_.ICommandService),r=t.get(_.IUniverInstanceService),a=t.get(c.ConditionalFormattingRuleModel),o=new Ce.Observable(p=>Ce.merge(e.selectionMoveEnd$,e.selectionSet$,new Ce.Observable(C=>{const m=n.onCommandExecuted(T=>{var I;const{id:E,params:w}=T,S=(I=r.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getUnitId();Tn.includes(E)&&w.unitId===S&&C.next(null)});return()=>m.dispose()})).pipe(qe.debounceTime(16)).subscribe(()=>{var I;const C=((I=e.getCurrentSelections())==null?void 0:I.map(h=>h.range))||[],m=r.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET);if(!m)return;const T=m.getActiveSheet();if(!T)return;const S=(a.getSubunitRules(m.getUnitId(),T.getSheetId())||[]).filter(h=>h.ranges.some(i=>C.some(s=>_.Rectangle.intersects(s,i)))).map(h=>h.ranges).every(h=>Y.checkRangesEditablePermission(t,m.getUnitId(),T.getSheetId(),h));p.next(S)})),u=new Ce.Observable(p=>new Ce.Observable(C=>{const m=n.onCommandExecuted(T=>{var I;const{id:E,params:w}=T,S=(I=r.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getUnitId();Tn.includes(E)&&w.unitId===S&&C.next(null)});return()=>m.dispose()}).pipe(qe.debounceTime(16)).subscribe(()=>{const C=r.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET);if(!C)return;const m=C.getActiveSheet();if(!m)return;const T=a.getSubunitRules(C.getUnitId(),m.getSheetId())||[];if(!T.length)return p.next(!1),!1;const E=T.map(w=>w.ranges).every(w=>Y.checkRangesEditablePermission(t,C.getUnitId(),m.getSheetId(),w));p.next(E)})),y=new Ce.Observable(p=>{o.subscribe(C=>{const m=ht.find(T=>T.value===ye.clearRangeRules);m&&(m.disabled=!C,p.next(ht))}),u.subscribe(C=>{const m=ht.find(T=>T.value===ye.clearWorkSheetRules);m&&(m.disabled=!C,p.next(ht))}),p.next(ht)});return{id:it.id,type:Q.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:y,hidden$:Q.getMenuHiddenObservable(t,_.UniverInstanceType.UNIVER_SHEET),disabled$:pe.getCurrentRangeDisable$(t,{workbookTypes:[Y.WorkbookEditablePermission],worksheetTypes:[Y.WorksheetSetCellStylePermission,Y.WorksheetEditPermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint]})}},no={[Q.RibbonStartGroup.FORMULAS_INSERT]:{[it.id]:{order:0,menuItemFactory:ro}}};var ao=Object.getOwnPropertyDescriptor,oo=(t,e,n,r)=>{for(var a=r>1?void 0:r?ao(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},wn=(t,e)=>(n,r)=>e(n,r,t);let Lt=class extends _.Disposable{constructor(e,n){super();xe(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=n,this._menuManagerService.mergeMenu(no)}};Lt=oo([wn(0,_.Inject(_.Injector)),wn(1,Q.IMenuManagerService)],Lt);var io=Object.getOwnPropertyDescriptor,so=(t,e,n,r)=>{for(var a=r>1?void 0:r?io(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},Be=(t,e)=>(n,r)=>e(n,r,t);const lo=(t,e)=>{const n=m=>m.endRow-m.startRow+1,r=m=>m.endColumn-m.startColumn+1,a=n(e)%n(t),o=r(e)%r(t),u=Math.floor(n(e)/n(t)),y=Math.floor(r(e)/r(t)),p=[],C={startRow:0,endRow:n(t)-1,startColumn:0,endColumn:r(t)-1};if(n(e)===1&&r(e)===1){const m={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return p.push({repeatRelativeRange:C,startRange:m}),p}for(let m=0;m<u+(a?.1:0);m++)for(let T=0;T<y+(o?.1:0);T++){const E=n(t)*m,w=r(t)*T,S={startRow:E+e.startRow,endRow:E+e.startRow,startColumn:w+e.startColumn,endColumn:w+e.startColumn};let I=C;m===u&&a&&(I={...I},I.endRow=I.endRow-(n(t)-a)),T===y&&o&&(I={...I},I.endColumn=I.endColumn-(r(t)-o)),p.push({repeatRelativeRange:I,startRange:S})}return p};let Vt=class extends _.Disposable{constructor(e,n,r,a,o,u){super();xe(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=n,this._formatPainterService=r,this._sheetsSelectionsService=a,this._conditionalFormattingRuleModel=o,this._conditionalFormattingViewModel=u,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),n=(o,u,y,p,C)=>{const{unitId:m,subUnitId:T}=this._painterConfig,{targetUnitId:E,targetSubUnitId:w}=C,S={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},I={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};_.Range.foreach(y,(h,i)=>{const s=_.Rectangle.getPositionRange({startRow:h,startColumn:i,endColumn:i,endRow:h},S),f=_.Rectangle.getPositionRange({startRow:h,startColumn:i,endColumn:i,endRow:h},I),b=this._conditionalFormattingViewModel.getCellCfs(m,T,s.startRow,s.startColumn),l=this._conditionalFormattingViewModel.getCellCfs(E,w,f.startRow,f.startColumn);l&&l.forEach(g=>{let d=p.get(g.cfId);if(!p.get(g.cfId)){const v=this._conditionalFormattingRuleModel.getRule(E,w,g.cfId);if(!v)return;d=new _.ObjectMatrix,v.ranges.forEach(D=>{_.Range.foreach(D,(N,U)=>{d.setValue(N,U,1)})}),p.set(g.cfId,d)}d.realDeleteValue(f.startRow,f.startColumn)}),b&&b.forEach(g=>{const d=p.get(g.cfId);d&&d.setValue(f.startRow,f.startColumn,1)})})},r=(o,u,y)=>{var s;const{range:p,unitId:C,subUnitId:m}=this._painterConfig,T=o!==C||m!==u,E=new Map,w=[],S=[];if(!o||!u||!C||!m)return e();const I=(s=this._conditionalFormattingRuleModel.getSubunitRules(C,m))!=null?s:[];I==null||I.forEach(f=>{const{ranges:b,cfId:l}=f;if(b.some(g=>_.Rectangle.intersects(p,g))){const g=new _.ObjectMatrix;T||b.forEach(d=>{_.Range.foreach(d,(v,D)=>{g.setValue(v,D,1)})}),E.set(l,g)}});const h={row:p.startRow,col:p.startColumn};return lo(p,y).forEach(f=>{n(h,{row:f.startRange.startRow,col:f.startRange.startColumn},f.repeatRelativeRange,E,{targetUnitId:o,targetSubUnitId:u})}),E.forEach((f,b)=>{if(T){const l=this._conditionalFormattingRuleModel.getRule(o,u,b),g=Y.findAllRectangle(Y.createTopMatrixFromMatrix(f));if(l)if(g.length){const d={unitId:o,subUnitId:u,rule:{...l,ranges:g}};w.push({id:c.SetConditionalRuleMutation.id,params:d}),S.push(...c.setConditionalRuleMutationUndoFactory(this._injector,d))}else{const d={unitId:o,subUnitId:u,cfId:l.cfId};w.push({id:c.DeleteConditionalRuleMutation.id,params:d}),S.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,d))}else if(g.length){const d=this._conditionalFormattingRuleModel.getRule(C,m,b);if(d){const v={unitId:o,subUnitId:u,rule:{..._.Tools.deepClone(d),cfId:this._conditionalFormattingRuleModel.createCfId(o,u),ranges:g}};w.push({id:c.AddConditionalRuleMutation.id,params:v}),S.push(c.AddConditionalRuleMutationUndoFactory(this._injector,v))}}}else{const l=this._conditionalFormattingRuleModel.getRule(C,m,b);if(!l)return;const g=Y.findAllRectangle(Y.createTopMatrixFromMatrix(f));if(g.length){const d={unitId:C,subUnitId:m,rule:{...l,ranges:g}};w.push({id:c.SetConditionalRuleMutation.id,params:d}),S.push(...c.setConditionalRuleMutationUndoFactory(this._injector,d))}else{const d={unitId:C,subUnitId:m,cfId:l.cfId};w.push({id:c.DeleteConditionalRuleMutation.id,params:d}),S.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,d))}}}),{undos:S,redos:w}},a={id:c.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:o=>{var u,y,p;switch(o){case pe.FormatPainterStatus.INFINITE:case pe.FormatPainterStatus.ONCE:{const C=(u=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:u.getUnitId(),m=(p=(y=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getActiveSheet())==null?void 0:p.getSheetId(),T=this._sheetsSelectionsService.getCurrentLastSelection(),E=T==null?void 0:T.range;C&&m&&E&&(this._painterConfig={unitId:C,subUnitId:m,range:E});break}case pe.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(o,u,y)=>this._painterConfig?r(o,u,y):{redos:[],undos:[]}};this._formatPainterService.addHook(a)}};Vt=so([Be(0,_.Inject(_.Injector)),Be(1,_.Inject(_.IUniverInstanceService)),Be(2,_.Inject(pe.IFormatPainterService)),Be(3,_.Inject(Y.SheetsSelectionsService)),Be(4,_.Inject(c.ConditionalFormattingRuleModel)),Be(5,_.Inject(c.ConditionalFormattingViewModel))],Vt);var co=Object.getOwnPropertyDescriptor,uo=(t,e,n,r)=>{for(var a=r>1?void 0:r?co(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},ur=(t,e)=>(n,r)=>e(n,r,t);let Ut=class extends _.Disposable{constructor(t,e,n){super(),this._conditionalFormattingViewModel=t,this._univerInstanceService=e,this._renderManagerService=n,this._init()}_init(){const t=this._univerInstanceService.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),e=n=>{const r=n.getUnitId(),a=this._renderManagerService.getRenderById(r);if(!a)return;const o=a.with(pe.SheetSkeletonManagerService);this.disposeWithMe(o.currentSkeleton$.subscribe(u=>{if(u){const y=u.skeleton.rowColumnSegment,p=y.endColumn-y.startColumn+1,m=(y.endRow-y.startRow+1)*p*9,T=Math.max(c.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,m);this._conditionalFormattingViewModel.setCacheLength(T)}}))};t&&e(t),this._univerInstanceService.getCurrentTypeOfUnit$(_.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{n&&e(n)})}};Ut=uo([ur(0,_.Inject(c.ConditionalFormattingViewModel)),ur(1,_.IUniverInstanceService),ur(2,hr.IRenderManagerService)],Ut);var fo=Object.defineProperty,po=Object.getOwnPropertyDescriptor,ho=(t,e,n)=>e in t?fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,go=(t,e,n,r)=>{for(var a=r>1?void 0:r?po(e,n):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(a=u(a)||a);return a},dr=(t,e)=>(n,r)=>e(n,r,t),In=(t,e,n)=>ho(t,typeof e!="symbol"?e+"":e,n);K.UniverSheetsConditionalFormattingUIPlugin=class extends _.Plugin{constructor(e=Dt,n,r,a){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=a;const{menu:o,...u}=_.merge({},Dt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yn,u),this._initCommand()}onStarting(){_.registerDependencies(this._injector,[[dt],[ut],[lt],[Mt],[ct],[ot],[Lt],[Ae],[Nt],[K.ConditionalFormattingClearController],[Vt],[Ut]]),_.touchDependencies(this._injector,[[dt]])}onReady(){_.touchDependencies(this._injector,[[Lt],[ot]])}onRendered(){_.touchDependencies(this._injector,[[Mt],[K.ConditionalFormattingClearController],[lt],[Nt],[Ae],[Vt],[ct],[ut],[Ut]])}_initCommand(){[At,Wt,jt,Ht,Bt,Ft,Gt,qt,Xt,it].forEach(e=>{this._commandService.registerCommand(e)})}},In(K.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${c.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),In(K.UniverSheetsConditionalFormattingUIPlugin,"type",_.UniverInstanceType.UNIVER_SHEET),K.UniverSheetsConditionalFormattingUIPlugin=go([_.DependentOn(c.UniverSheetsConditionalFormattingPlugin),dr(1,_.Inject(_.Injector)),dr(2,_.Inject(_.ICommandService)),dr(3,_.IConfigService)],K.UniverSheetsConditionalFormattingUIPlugin),K.AddAverageCfCommand=At,K.AddColorScaleConditionalRuleCommand=Wt,K.AddDataBarConditionalRuleCommand=jt,K.AddDuplicateValuesCfCommand=Ht,K.AddNumberCfCommand=Bt,K.AddRankCfCommand=Ft,K.AddTextCfCommand=Gt,K.AddTimePeriodCfCommand=qt,K.AddUniqueValuesCfCommand=Xt,K.OpenConditionalFormattingOperator=it,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})});
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
// index
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-sheets-conditional-formatting",
|
|
3
|
-
"version": "0.6.10-nightly.
|
|
3
|
+
"version": "0.6.10-nightly.202504161609",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"rxjs": ">=7.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@univerjs/sheets-conditional-formatting": "0.6.10-nightly.
|
|
61
|
-
"@univerjs/sheets-conditional-formatting-ui": "0.6.10-nightly.
|
|
60
|
+
"@univerjs/sheets-conditional-formatting": "0.6.10-nightly.202504161609",
|
|
61
|
+
"@univerjs/sheets-conditional-formatting-ui": "0.6.10-nightly.202504161609"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@univerjs/core": "0.6.10-nightly.
|
|
64
|
+
"@univerjs/core": "0.6.10-nightly.202504161609",
|
|
65
65
|
"react": "18.3.1",
|
|
66
66
|
"react-dom": "18.3.1",
|
|
67
67
|
"typescript": "^5.8.2",
|