@univerjs/preset-sheets-filter 0.6.10-nightly.202504151606 → 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.
Files changed (2) hide show
  1. package/lib/umd/index.js +1 -1
  2. package/package.json +4 -4
package/lib/umd/index.js CHANGED
@@ -19,7 +19,7 @@
19
19
  univer-items-center univer-justify-between univer-text-[13px] univer-text-primary-500
20
20
  `,children:[d.jsx("span",{className:R.sheetsFilterPanelValuesItemCount,children:`(${v.count})`}),d.jsx("a",{className:`
21
21
  univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5
22
- `,onClick:()=>{const O=[];v.children?v.children.forEach(E=>{E.children?E.children.forEach(A=>{O.push(A.key)}):O.push(E.key)}):O.push(v.key),e.onFilterOnly(O)},children:l})]})})})]})]})}function pt(){var A;const t=T.useDependency(x),e=T.useDependency(c.LocaleService),r=T.useDependency(c.ICommandService),i=T.useObservable(t.filterBy$,void 0,!0),s=T.useObservable(t.filterByModel$,void 0,!1),l=T.useObservable(()=>(s==null?void 0:s.canApply$)||C.of(!1),void 0,!1,[s]),n=dt(e),o=!T.useObservable(t.hasCriteria$),a=y.useCallback(P=>{r.executeCommand(Ne.id,{filterBy:P})},[r]),h=y.useCallback(async()=>{await(s==null?void 0:s.clear()),r.executeCommand(J.id)},[s,r]),m=y.useCallback(()=>{r.executeCommand(J.id)},[r]),f=y.useCallback(async()=>{await(s==null?void 0:s.apply()),r.executeCommand(J.id)},[s,r]),v=(A=T.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:A.getRange(),O=t.col,E=T.useComponentsOfPart($.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{className:R.sheetsFilterPanel,children:[d.jsx(T.ComponentContainer,{components:E,sharedProps:{range:v,colIndex:O,onClose:m}}),d.jsx("div",{className:R.sheetsFilterPanelHeader,children:d.jsx(L.Segmented,{value:i,items:n,onChange:P=>a(P)})}),s?d.jsx("div",{className:R.sheetsFilterPanelContent,children:i===me.VALUES?d.jsx(mt,{model:s}):d.jsx(ct,{model:s})}):d.jsx("div",{style:{flex:1}}),d.jsxs("div",{className:R.sheetsFilterPanelFooter,children:[d.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:R.sheetsFilterPanelFooterPrimaryButtons,children:[d.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(L.Button,{disabled:!l,type:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function dt(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:me.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:me.CONDITIONS}],[e,t])}function ft(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:T.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:$.getObservableWithExclusiveRange$(t,$.getCurrentRangeDisable$(t,{worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission],rangeTypes:[I.RangeProtectionPermissionViewPoint]}))}}function _t(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}function vt(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}const St={[T.RibbonStartGroup.FORMULAS_INSERT]:{[u.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:ft,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:_t},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:vt}}}},Y=16,gt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class We{static drawNoCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.lineCap="square",e.strokeStyle=i,e.scale(r/Y,r/Y),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.scale(r/Y,r/Y),e.fillStyle=i,e.fill(gt),e.restore()}}var Ct=Object.getOwnPropertyDescriptor,Tt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ct(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},ye=(t,e)=>(r,i)=>e(r,i,t);const j=16,fe=1;let Ae=class extends ie.Shape{constructor(e,r,i,s,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=i,this._commandService=s,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(n=>this.onPointerDown(n)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,i=this._cellWidth,s=j-i,l=j-r;e.save();const n=new Path2D;n.rect(s,l,i,r),e.clip(n);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?We.drawHasCriteria(e,j,a,h):We.drawNoCriteria(e,j,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:s}=this._filterParams;this._contextService.getContextValue(z)||!this._commandService.hasCommand(oe.id)||setTimeout(()=>{this._commandService.executeCommand(oe.id,{unitId:i,subUnitId:s,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Ae=Tt([ye(2,c.IContextService),ye(3,c.ICommandService),ye(4,c.Inject(c.ThemeService))],Ae);var Et=Object.getOwnPropertyDescriptor,Ft=(t,e,r,i)=>{for(var s=i>1?void 0:i?Et(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},K=(t,e)=>(r,i)=>e(r,i,t);const Ot=1e3,It=5e3;let be=class extends c.RxDisposable{constructor(e,r,i,s,l,n,o,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=s,this._themeService=l,this._sheetInterceptorService=n,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var o,a;if(!e)return C.of(null);const{unit:r,unitId:i}=this._context,s=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,s))!=null?a:void 0,n=()=>({unitId:i,worksheetId:s,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([h])=>{var m;return h.type===c.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===I.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(n),C.startWith(n()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:s,columnHeaderHeight:l}=r,n=this._filterRangeShape=new $.SelectionControl(i,Ot,this._themeService,{rowHeaderWidth:s,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=$.attachSelectionWithCoord(o,r);n.updateRangeBySelectionWithCoord(a),n.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:s,skeleton:l,worksheetId:n}=e,{scene:o}=this._context;this._interceptCellContent(s,n,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const F=`sheets-filter-button-${f}`,v=$.getCoordByCell(m,f,o,l),{startX:O,startY:E,endX:A,endY:P}=v,U=A-O,M=P-E;if(M<=fe||U<=fe)continue;const B=!!i.getFilterColumn(f),V=A-j-fe,Se=P-j-fe,ge={left:V,top:Se,height:j,width:j,zIndex:It,cellHeight:M,cellWidth:U,filterParams:{unitId:s,subUnitId:n,col:f,hasCriteria:B}},w=this._injector.createInstance(Ae,F,ge);this._filterButtonShapes.push(w)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:s,startColumn:l,endColumn:n}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:F,subUnitId:v}=a;return F!==e||v!==r||m!==s||f<l||f>n?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:j}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};be=Ft([K(1,c.Inject(c.Injector)),K(2,c.Inject($.SheetSkeletonManagerService)),K(3,c.Inject(u.SheetsFilterService)),K(4,c.Inject(c.ThemeService)),K(5,c.Inject(I.SheetInterceptorService)),K(6,c.ICommandService),K(7,$.ISheetSelectionRenderService)],be);var Pt=Object.getOwnPropertyDescriptor,Nt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Pt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Qe=(t,e)=>(r,i)=>e(r,i,t);let ae=class extends c.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[be]))}};ae=Nt([Qe(0,ie.IRenderManagerService),Qe(1,c.Inject($.SheetsRenderService))],ae);const yt={id:u.SmartToggleSheetsFilterCommand.id,binding:T.KeyCode.L|T.MetaKeys.CTRL_COMMAND|T.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:$.whenSheetEditorFocused,group:"4_sheet-edit"};var At=Object.getOwnPropertyDescriptor,bt=(t,e,r,i)=>{for(var s=i>1?void 0:i?At(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},D=(t,e)=>(r,i)=>e(r,i,t);const je="FILTER_PANEL_POPUP";let _e=class extends ae{constructor(e,r,i,s,l,n,o,a,h,m,f,F,v){super(v,F);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=s,this._sheetsFilterService=l,this._localeService=n,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[yt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Ne,oe,J].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(St)}_initUI(){this.disposeWithMe(this._componentManager.register(je,pt)),this.disposeWithMe(this._componentManager.register("FilterSingle",Ve)),this.disposeWithMe(this._contextService.subscribeContextValue$(z).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:L.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),i=this._sheetsFilterPanelService.col,{startRow:s}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(s,i,{componentKey:je,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(J.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};_e=bt([D(0,c.Inject(c.Injector)),D(1,c.Inject(T.ComponentManager)),D(2,c.Inject(x)),D(3,c.Inject($.SheetCanvasPopManagerService)),D(4,c.Inject(u.SheetsFilterService)),D(5,c.Inject(c.LocaleService)),D(6,T.IShortcutService),D(7,c.ICommandService),D(8,T.IMenuManagerService),D(9,c.IContextService),D(10,T.IMessageService),D(11,c.Inject($.SheetsRenderService)),D(12,ie.IRenderManagerService)],_e);var Rt=Object.defineProperty,Mt=Object.getOwnPropertyDescriptor,Lt=(t,e,r)=>e in t?Rt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ut=(t,e,r,i)=>{for(var s=i>1?void 0:i?Mt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Re=(t,e)=>(r,i)=>e(r,i,t),Ge=(t,e,r)=>Lt(t,typeof e!="symbol"?e+"":e,r);const wt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends c.Plugin{constructor(e=ce,r,i,s){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=s;const{menu:l,...n}=c.merge({},ce,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ue,n)}onStarting(){[[x],[te],[_e]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([ue,{useFactory:()=>Q.toModule(this._rpcChannelService.requestChannel(Fe))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(_e)}},Ge(_.UniverSheetsFilterUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ge(_.UniverSheetsFilterUIPlugin,"pluginName",wt),_.UniverSheetsFilterUIPlugin=Ut([c.DependentOn(u.UniverSheetsFilterPlugin),Re(1,c.Inject(c.Injector)),Re(2,c.IConfigService),Re(3,c.Optional(Q.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var $t=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,Ht=(t,e,r)=>e in t?$t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Dt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},xe=(t,e)=>(r,i)=>e(r,i,t),Ye=(t,e,r)=>Ht(t,typeof e!="symbol"?e+"":e,r);const Bt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=ce,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:s,...l}=c.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Ue,l)}onStarting(){[[te],[ae]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ae)}},Ye(_.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ye(_.UniverSheetsFilterMobileUIPlugin,"pluginName",Bt),_.UniverSheetsFilterMobileUIPlugin=kt([c.DependentOn(u.UniverSheetsFilterPlugin),xe(1,c.Inject(c.Injector)),xe(2,c.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var Vt=Object.getOwnPropertyDescriptor,Wt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Vt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},qe=(t,e)=>(r,i)=>e(r,i,t);_.UniverSheetsFilterUIWorkerPlugin=(ve=class extends c.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[ue,{useClass:Oe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Fe,Q.fromModule(this._injector.get(ue)))}},S(ve,"type",c.UniverInstanceType.UNIVER_SHEET),S(ve,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),ve),_.UniverSheetsFilterUIWorkerPlugin=Wt([qe(1,c.Inject(c.Injector)),qe(2,Q.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Ne,_.CloseFilterPanelOperation=J,_.OpenFilterPanelOperation=oe,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
22
+ `,onClick:()=>{const O=[];v.children?v.children.forEach(E=>{E.children?E.children.forEach(A=>{O.push(A.key)}):O.push(E.key)}):O.push(v.key),e.onFilterOnly(O)},children:l})]})})})]})]})}function pt(){var A;const t=T.useDependency(x),e=T.useDependency(c.LocaleService),r=T.useDependency(c.ICommandService),i=T.useObservable(t.filterBy$,void 0,!0),s=T.useObservable(t.filterByModel$,void 0,!1),l=T.useObservable(()=>(s==null?void 0:s.canApply$)||C.of(!1),void 0,!1,[s]),n=dt(e),o=!T.useObservable(t.hasCriteria$),a=y.useCallback(P=>{r.executeCommand(Ne.id,{filterBy:P})},[r]),h=y.useCallback(async()=>{await(s==null?void 0:s.clear()),r.executeCommand(J.id)},[s,r]),m=y.useCallback(()=>{r.executeCommand(J.id)},[r]),f=y.useCallback(async()=>{await(s==null?void 0:s.apply()),r.executeCommand(J.id)},[s,r]),v=(A=T.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:A.getRange(),O=t.col,E=T.useComponentsOfPart($.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{className:R.sheetsFilterPanel,children:[d.jsx(T.ComponentContainer,{components:E,sharedProps:{range:v,colIndex:O,onClose:m}}),d.jsx("div",{className:R.sheetsFilterPanelHeader,children:d.jsx(L.Segmented,{value:i,items:n,onChange:P=>a(P)})}),s?d.jsx("div",{className:R.sheetsFilterPanelContent,children:i===me.VALUES?d.jsx(mt,{model:s}):d.jsx(ct,{model:s})}):d.jsx("div",{style:{flex:1}}),d.jsxs("div",{className:R.sheetsFilterPanelFooter,children:[d.jsx(L.Button,{variant:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:R.sheetsFilterPanelFooterPrimaryButtons,children:[d.jsx(L.Button,{variant:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(L.Button,{disabled:!l,variant:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function dt(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:me.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:me.CONDITIONS}],[e,t])}function ft(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:T.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:$.getObservableWithExclusiveRange$(t,$.getCurrentRangeDisable$(t,{worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission],rangeTypes:[I.RangeProtectionPermissionViewPoint]}))}}function _t(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}function vt(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}const St={[T.RibbonStartGroup.FORMULAS_INSERT]:{[u.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:ft,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:_t},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:vt}}}},Y=16,gt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class We{static drawNoCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.lineCap="square",e.strokeStyle=i,e.scale(r/Y,r/Y),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.scale(r/Y,r/Y),e.fillStyle=i,e.fill(gt),e.restore()}}var Ct=Object.getOwnPropertyDescriptor,Tt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ct(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},ye=(t,e)=>(r,i)=>e(r,i,t);const j=16,fe=1;let Ae=class extends ie.Shape{constructor(e,r,i,s,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=i,this._commandService=s,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(n=>this.onPointerDown(n)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,i=this._cellWidth,s=j-i,l=j-r;e.save();const n=new Path2D;n.rect(s,l,i,r),e.clip(n);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?We.drawHasCriteria(e,j,a,h):We.drawNoCriteria(e,j,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:s}=this._filterParams;this._contextService.getContextValue(z)||!this._commandService.hasCommand(oe.id)||setTimeout(()=>{this._commandService.executeCommand(oe.id,{unitId:i,subUnitId:s,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Ae=Tt([ye(2,c.IContextService),ye(3,c.ICommandService),ye(4,c.Inject(c.ThemeService))],Ae);var Et=Object.getOwnPropertyDescriptor,Ft=(t,e,r,i)=>{for(var s=i>1?void 0:i?Et(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},K=(t,e)=>(r,i)=>e(r,i,t);const Ot=1e3,It=5e3;let be=class extends c.RxDisposable{constructor(e,r,i,s,l,n,o,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=s,this._themeService=l,this._sheetInterceptorService=n,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var o,a;if(!e)return C.of(null);const{unit:r,unitId:i}=this._context,s=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,s))!=null?a:void 0,n=()=>({unitId:i,worksheetId:s,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([h])=>{var m;return h.type===c.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===I.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(n),C.startWith(n()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:s,columnHeaderHeight:l}=r,n=this._filterRangeShape=new $.SelectionControl(i,Ot,this._themeService,{rowHeaderWidth:s,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=$.attachSelectionWithCoord(o,r);n.updateRangeBySelectionWithCoord(a),n.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:s,skeleton:l,worksheetId:n}=e,{scene:o}=this._context;this._interceptCellContent(s,n,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const F=`sheets-filter-button-${f}`,v=$.getCoordByCell(m,f,o,l),{startX:O,startY:E,endX:A,endY:P}=v,U=A-O,M=P-E;if(M<=fe||U<=fe)continue;const B=!!i.getFilterColumn(f),V=A-j-fe,Se=P-j-fe,ge={left:V,top:Se,height:j,width:j,zIndex:It,cellHeight:M,cellWidth:U,filterParams:{unitId:s,subUnitId:n,col:f,hasCriteria:B}},w=this._injector.createInstance(Ae,F,ge);this._filterButtonShapes.push(w)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:s,startColumn:l,endColumn:n}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:F,subUnitId:v}=a;return F!==e||v!==r||m!==s||f<l||f>n?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:j}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};be=Ft([K(1,c.Inject(c.Injector)),K(2,c.Inject($.SheetSkeletonManagerService)),K(3,c.Inject(u.SheetsFilterService)),K(4,c.Inject(c.ThemeService)),K(5,c.Inject(I.SheetInterceptorService)),K(6,c.ICommandService),K(7,$.ISheetSelectionRenderService)],be);var Pt=Object.getOwnPropertyDescriptor,Nt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Pt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Qe=(t,e)=>(r,i)=>e(r,i,t);let ae=class extends c.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[be]))}};ae=Nt([Qe(0,ie.IRenderManagerService),Qe(1,c.Inject($.SheetsRenderService))],ae);const yt={id:u.SmartToggleSheetsFilterCommand.id,binding:T.KeyCode.L|T.MetaKeys.CTRL_COMMAND|T.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:$.whenSheetEditorFocused,group:"4_sheet-edit"};var At=Object.getOwnPropertyDescriptor,bt=(t,e,r,i)=>{for(var s=i>1?void 0:i?At(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},D=(t,e)=>(r,i)=>e(r,i,t);const je="FILTER_PANEL_POPUP";let _e=class extends ae{constructor(e,r,i,s,l,n,o,a,h,m,f,F,v){super(v,F);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=s,this._sheetsFilterService=l,this._localeService=n,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[yt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Ne,oe,J].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(St)}_initUI(){this.disposeWithMe(this._componentManager.register(je,pt)),this.disposeWithMe(this._componentManager.register("FilterSingle",Ve)),this.disposeWithMe(this._contextService.subscribeContextValue$(z).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:L.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),i=this._sheetsFilterPanelService.col,{startRow:s}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(s,i,{componentKey:je,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(J.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};_e=bt([D(0,c.Inject(c.Injector)),D(1,c.Inject(T.ComponentManager)),D(2,c.Inject(x)),D(3,c.Inject($.SheetCanvasPopManagerService)),D(4,c.Inject(u.SheetsFilterService)),D(5,c.Inject(c.LocaleService)),D(6,T.IShortcutService),D(7,c.ICommandService),D(8,T.IMenuManagerService),D(9,c.IContextService),D(10,T.IMessageService),D(11,c.Inject($.SheetsRenderService)),D(12,ie.IRenderManagerService)],_e);var Rt=Object.defineProperty,Mt=Object.getOwnPropertyDescriptor,Lt=(t,e,r)=>e in t?Rt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ut=(t,e,r,i)=>{for(var s=i>1?void 0:i?Mt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Re=(t,e)=>(r,i)=>e(r,i,t),Ge=(t,e,r)=>Lt(t,typeof e!="symbol"?e+"":e,r);const wt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends c.Plugin{constructor(e=ce,r,i,s){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=s;const{menu:l,...n}=c.merge({},ce,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ue,n)}onStarting(){[[x],[te],[_e]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([ue,{useFactory:()=>Q.toModule(this._rpcChannelService.requestChannel(Fe))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(_e)}},Ge(_.UniverSheetsFilterUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ge(_.UniverSheetsFilterUIPlugin,"pluginName",wt),_.UniverSheetsFilterUIPlugin=Ut([c.DependentOn(u.UniverSheetsFilterPlugin),Re(1,c.Inject(c.Injector)),Re(2,c.IConfigService),Re(3,c.Optional(Q.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var $t=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,Ht=(t,e,r)=>e in t?$t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Dt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},xe=(t,e)=>(r,i)=>e(r,i,t),Ye=(t,e,r)=>Ht(t,typeof e!="symbol"?e+"":e,r);const Bt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=ce,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:s,...l}=c.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Ue,l)}onStarting(){[[te],[ae]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ae)}},Ye(_.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ye(_.UniverSheetsFilterMobileUIPlugin,"pluginName",Bt),_.UniverSheetsFilterMobileUIPlugin=kt([c.DependentOn(u.UniverSheetsFilterPlugin),xe(1,c.Inject(c.Injector)),xe(2,c.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var Vt=Object.getOwnPropertyDescriptor,Wt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Vt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},qe=(t,e)=>(r,i)=>e(r,i,t);_.UniverSheetsFilterUIWorkerPlugin=(ve=class extends c.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[ue,{useClass:Oe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Fe,Q.fromModule(this._injector.get(ue)))}},S(ve,"type",c.UniverInstanceType.UNIVER_SHEET),S(ve,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),ve),_.UniverSheetsFilterUIWorkerPlugin=Wt([qe(1,c.Inject(c.Injector)),qe(2,Q.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Ne,_.CloseFilterPanelOperation=J,_.OpenFilterPanelOperation=oe,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
23
23
 
24
24
 
25
25
  // index
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-filter",
3
- "version": "0.6.10-nightly.202504151606",
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-filter": "0.6.10-nightly.202504151606",
61
- "@univerjs/sheets-filter-ui": "0.6.10-nightly.202504151606"
60
+ "@univerjs/sheets-filter": "0.6.10-nightly.202504161609",
61
+ "@univerjs/sheets-filter-ui": "0.6.10-nightly.202504161609"
62
62
  },
63
63
  "devDependencies": {
64
- "@univerjs/core": "0.6.10-nightly.202504151606",
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",