@univerjs/sheets-table-ui 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2569 -1
- package/lib/cjs/locale/ca-ES.js +119 -1
- package/lib/cjs/locale/en-US.js +134 -1
- package/lib/cjs/locale/es-ES.js +119 -1
- package/lib/cjs/locale/fa-IR.js +119 -1
- package/lib/cjs/locale/fr-FR.js +119 -1
- package/lib/cjs/locale/ja-JP.js +119 -1
- package/lib/cjs/locale/ko-KR.js +119 -1
- package/lib/cjs/locale/ru-RU.js +119 -1
- package/lib/cjs/locale/sk-SK.js +119 -1
- package/lib/cjs/locale/vi-VN.js +119 -1
- package/lib/cjs/locale/zh-CN.js +119 -1
- package/lib/cjs/locale/zh-TW.js +119 -1
- package/lib/es/index.js +2563 -1
- package/lib/es/locale/ca-ES.js +118 -1
- package/lib/es/locale/en-US.js +133 -1
- package/lib/es/locale/es-ES.js +118 -1
- package/lib/es/locale/fa-IR.js +118 -1
- package/lib/es/locale/fr-FR.js +118 -1
- package/lib/es/locale/ja-JP.js +118 -1
- package/lib/es/locale/ko-KR.js +118 -1
- package/lib/es/locale/ru-RU.js +118 -1
- package/lib/es/locale/sk-SK.js +118 -1
- package/lib/es/locale/vi-VN.js +118 -1
- package/lib/es/locale/zh-CN.js +118 -1
- package/lib/es/locale/zh-TW.js +118 -1
- package/lib/index.js +2563 -1
- package/lib/locale/ca-ES.js +118 -1
- package/lib/locale/en-US.js +133 -1
- package/lib/locale/es-ES.js +118 -1
- package/lib/locale/fa-IR.js +118 -1
- package/lib/locale/fr-FR.js +118 -1
- package/lib/locale/ja-JP.js +118 -1
- package/lib/locale/ko-KR.js +118 -1
- package/lib/locale/ru-RU.js +118 -1
- package/lib/locale/sk-SK.js +118 -1
- package/lib/locale/vi-VN.js +118 -1
- package/lib/locale/zh-CN.js +118 -1
- package/lib/locale/zh-TW.js +118 -1
- package/lib/umd/index.js +1 -1
- package/package.json +14 -14
package/lib/es/index.js
CHANGED
|
@@ -1 +1,2563 @@
|
|
|
1
|
-
import{ColorKit as e,CommandType as t,DependentOn as n,Disposable as r,ErrorService as i,ICommandService as a,IConfigService as o,IContextService as s,IPermissionService as c,IUniverInstanceService as l,Inject as u,Injector as d,InterceptorEffectEnum as f,LocaleService as p,ObjectMatrix as m,Plugin as h,Rectangle as g,RxDisposable as _,ThemeService as v,UniverInstanceType as y,VerticalAlign as b,cellToRange as x,merge as S,registerDependencies as C,touchDependencies as w}from"@univerjs/core";import{IRenderManagerService as T,Rect as ee,SHEET_VIEWPORT_KEY as E,Shape as D,convertTransformToOffsetX as te,convertTransformToOffsetY as O}from"@univerjs/engine-render";import{AddSheetTableCommand as ne,AddTableThemeCommand as k,DeleteSheetTableCommand as A,RemoveTableThemeCommand as re,SHEET_TABLE_CUSTOM_THEME_PREFIX as j,SetSheetTableCommand as ie,SetSheetTableFilterCommand as ae,SheetTableInsertColCommand as oe,SheetTableInsertRowCommand as se,SheetTableRemoveColCommand as ce,SheetTableRemoveRowCommand as le,SheetTableService as ue,SheetsTableButtonStateEnum as de,SheetsTableController as fe,SheetsTableSortStateEnum as pe,TableColumnFilterTypeEnum as me,TableConditionTypeEnum as M,TableDateCompareTypeEnum as N,TableManager as P,TableNumberCompareTypeEnum as F,TableStringCompareTypeEnum as I,UniverSheetsTablePlugin as he,customEmptyThemeWithBorderStyle as ge,isConditionFilter as _e,isManualTableFilter as ve,processStyleWithBorderStyle as ye}from"@univerjs/sheets-table";import{SelectAllCommand as be,SetScrollOperation as xe,SetZoomRatioOperation as Se,SheetCanvasPopManagerService as Ce,SheetScrollManagerService as we,SheetSkeletonManagerService as Te,getCoordByCell as Ee,getCurrentRangeDisable$ as De,getSheetObject as Oe}from"@univerjs/sheets-ui";import{BuiltInUIPart as ke,ComponentManager as Ae,ContextMenuGroup as je,ContextMenuPosition as Me,IDialogService as Ne,IMenuManagerService as Pe,ISidebarService as Fe,IUIPartsService as Ie,MenuItemType as L,RibbonDataGroup as Le,connectInjector as Re,getMenuHiddenObservable as ze,useDependency as R,useObservable as z}from"@univerjs/ui";import{BehaviorSubject as Be,Subject as Ve,debounceTime as He,distinctUntilChanged as Ue,filter as We,map as Ge,merge as Ke,of as B,startWith as qe,switchMap as V,takeUntil as Je}from"rxjs";import{Button as Ye,ButtonGroup as Xe,CascaderList as Ze,Checkbox as Qe,ColorPicker as $e,DatePicker as et,DateRangePicker as tt,Dropdown as nt,Input as rt,InputNumber as it,Segmented as at,Select as ot,borderClassName as H,clsx as U,scrollbarClassName as st}from"@univerjs/design";import{AscendingIcon as ct,DeleteIcon as lt,DescendingIcon as ut,DropdownIcon as dt,GridOutlineIcon as ft,MoreDownIcon as pt,PaintBucketDoubleIcon as mt,RenameIcon as ht,TableIcon as gt}from"@univerjs/icons";import{INTERCEPTOR_POINT as _t,RangeThemeStyle as vt,SetRangeThemeMutation as yt,SetRangeValuesMutation as bt,SetSelectionsOperation as xt,SetVerticalTextAlignCommand as St,SheetInterceptorService as Ct,SheetRangeThemeModel as wt,SheetsSelectionsService as Tt,WorkbookEditablePermission as Et,WorkbookPermissionService as Dt,expandToContinuousRange as Ot,getPrimaryForRange as kt,getSheetCommandTarget as At,isSingleCellSelection as jt}from"@univerjs/sheets";import{SortRangeCommand as Mt,SortType as Nt}from"@univerjs/sheets-sort";import{useCallback as Pt,useEffect as Ft,useMemo as It,useState as W}from"react";import{Fragment as Lt,jsx as G,jsxs as K}from"react/jsx-runtime";import{deserializeRangeWithSheet as Rt,serializeRange as zt}from"@univerjs/engine-formula";import{RangeSelector as Bt}from"@univerjs/sheets-formula-ui";var Vt=`@univerjs/sheets-table-ui`,Ht=`0.20.1`;const Ut=`SHEETS_TABLE_FILTER_PANEL_OPENED_KEY`,Wt=`TABLE_TOOLBAR_BUTTON`,Gt=`TABLE_SELECTOR_DIALOG`,Kt=`SHEET_TABLE_THEME_PANEL`,qt=`table-custom-`,Jt=`rgb(255, 255, 255)`,q=`none`,J=`1px solid rgb(var(--grey-200))`;let Yt=function(e){return e.Items=`items`,e.Condition=`condition`,e}({});function Xt(e){"@babel/helpers - typeof";return Xt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Xt(e)}function Zt(e,t){if(Xt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Xt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Qt(e){var t=Zt(e,`string`);return Xt(t)==`symbol`?t:t+``}function Y(e,t,n){return(t=Qt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function X(e,t){return function(n,r){t(n,r,e)}}function Z(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let $t=class extends r{constructor(e,t,n,r,i){super(),this._tableManager=e,this._sheetTableService=t,this._univerInstanceService=n,this._commandService=r,this._localeService=i,Y(this,`_itemsCache`,new Map),this._registerTableFilterChangeEvent()}_registerTableFilterChangeEvent(){this._commandService.onCommandExecuted(e=>{if(e.id===bt.id){let{unitId:t,subUnitId:n,cellValue:r}=e.params,i=this._tableManager.getTablesBySubunitId(t,n);if(!i.length)return;new m(r).forValue((e,t,n)=>{let r=x(e,t),a=i.find(e=>{let t=e.getTableFilterRange();return g.intersects(t,r)});if(a){let e=t-a.getRange().startColumn;this._itemsCache.delete(a.getId()+e)}})}else if(e.id===ae.id){let{unitId:t,tableId:n}=e.params,r=this._tableManager.getTable(t,n);if(!r)return;let i=r.getSubunitId();this._tableManager.getTablesBySubunitId(t,i).forEach(e=>{let t=e.getRange();for(let n=t.startColumn;n<=t.endColumn;n++)this._itemsCache.delete(e.getId()+n)})}})}getTableFilterPanelInitProps(e,t,n,r){let i=this._tableManager.getTable(e,n),a=i.getRange(),o=i.getTableFilterColumn(r-a.startColumn);return{unitId:e,subUnitId:t,tableFilter:o,currentFilterBy:_e(o)?Yt.Condition:Yt.Items,tableId:n,columnIndex:r-a.startColumn}}getTableFilterCheckedItems(e,t,n){let r=this._tableManager.getTable(e,t),i=[];if(r){let e=r.getTableFilterColumn(n);e&&ve(e)&&i.push(...e.values)}return i}setTableFilter(e,t,n,r){if(!this._tableManager.getTable(e,t))return;let i={unitId:e,tableId:t,column:n,tableFilter:r};this._commandService.executeCommand(ae.id,i)}getTableFilterItems(e,t,n,r){var i;if(this._itemsCache.has(n+r))return this._itemsCache.get(n+r)||{data:[],itemsCountMap:new Map,allItemsCount:0};let a=this._tableManager.getTable(e,n);if(!a)return{data:[],itemsCountMap:new Map,allItemsCount:0};let{startRow:o,endRow:s,startColumn:c}=a.getTableFilterRange(),l=c+r,u=(i=this._univerInstanceService.getUnit(e))==null?void 0:i.getSheetBySheetId(t);if(!u)return{data:[],itemsCountMap:new Map,allItemsCount:0};let d=[],f=new Map,p=0;for(let e=o;e<=s;e++){if(u.isRowFiltered(e))continue;let t=this._sheetTableService.getCellValueWithConditionType(u,e,l);t===void 0&&(t=this._localeService.t(`sheets-table.condition.empty`)),f.has(t)||d.push({title:t,key:`${l}_${e}`,leaf:!0}),p++,f.set(t,(f.get(t)||0)+1)}return this._itemsCache.set(n+r,{data:d,itemsCountMap:f,allItemsCount:p}),{data:d,itemsCountMap:f,allItemsCount:p}}};$t=Z([X(0,u(P)),X(1,u(ue)),X(2,u(l)),X(3,a),X(4,u(p))],$t);let Q=function(e){return e.DatePicker=`DatePicker`,e.DateRange=`DateRange`,e.Input=`Input`,e.Inputs=`Inputs`,e.Select=`Select`,e.None=`None`,e}({});function en(e){let t=e.get(p).t;return[{value:M.String,label:t(`sheets-table.condition.${M.String}`),children:[{value:I.Equal,label:t(`sheets-table.string.compare.${I.Equal}`)},{value:I.NotEqual,label:t(`sheets-table.string.compare.${I.NotEqual}`)},{value:I.Contains,label:t(`sheets-table.string.compare.${I.Contains}`)},{value:I.NotContains,label:t(`sheets-table.string.compare.${I.NotContains}`)},{value:I.StartsWith,label:t(`sheets-table.string.compare.${I.StartsWith}`)},{value:I.EndsWith,label:t(`sheets-table.string.compare.${I.EndsWith}`)}]},{value:M.Number,label:t(`sheets-table.condition.${M.Number}`),children:[{value:F.Equal,label:t(`sheets-table.number.compare.${F.Equal}`)},{value:F.NotEqual,label:t(`sheets-table.number.compare.${F.NotEqual}`)},{value:F.GreaterThan,label:t(`sheets-table.number.compare.${F.GreaterThan}`)},{value:F.GreaterThanOrEqual,label:t(`sheets-table.number.compare.${F.GreaterThanOrEqual}`)},{value:F.LessThan,label:t(`sheets-table.number.compare.${F.LessThan}`)},{value:F.LessThanOrEqual,label:t(`sheets-table.number.compare.${F.LessThanOrEqual}`)},{value:F.Between,label:t(`sheets-table.number.compare.${F.Between}`)},{value:F.NotBetween,label:t(`sheets-table.number.compare.${F.NotBetween}`)},{value:F.Above,label:t(`sheets-table.number.compare.${F.Above}`)},{value:F.Below,label:t(`sheets-table.number.compare.${F.Below}`)}]},{value:M.Date,label:t(`sheets-table.condition.${M.Date}`),children:[{value:N.Equal,label:t(`sheets-table.date.compare.${N.Equal}`)},{value:N.NotEqual,label:t(`sheets-table.date.compare.${N.NotEqual}`)},{value:N.After,label:t(`sheets-table.date.compare.${N.After}`)},{value:N.AfterOrEqual,label:t(`sheets-table.date.compare.${N.AfterOrEqual}`)},{value:N.Before,label:t(`sheets-table.date.compare.${N.Before}`)},{value:N.BeforeOrEqual,label:t(`sheets-table.date.compare.${N.BeforeOrEqual}`)},{value:N.Between,label:t(`sheets-table.date.compare.${N.Between}`)},{value:N.NotBetween,label:t(`sheets-table.date.compare.${N.NotBetween}`)},{value:N.Today,label:t(`sheets-table.date.compare.${N.Today}`)},{value:N.Yesterday,label:t(`sheets-table.date.compare.${N.Yesterday}`)},{value:N.Tomorrow,label:t(`sheets-table.date.compare.${N.Tomorrow}`)},{value:N.ThisWeek,label:t(`sheets-table.date.compare.${N.ThisWeek}`)},{value:N.LastWeek,label:t(`sheets-table.date.compare.${N.LastWeek}`)},{value:N.NextWeek,label:t(`sheets-table.date.compare.${N.NextWeek}`)},{value:N.ThisMonth,label:t(`sheets-table.date.compare.${N.ThisMonth}`)},{value:N.LastMonth,label:t(`sheets-table.date.compare.${N.LastMonth}`)},{value:N.NextMonth,label:t(`sheets-table.date.compare.${N.NextMonth}`)},{value:N.ThisYear,label:t(`sheets-table.date.compare.${N.ThisYear}`)},{value:N.LastYear,label:t(`sheets-table.date.compare.${N.LastYear}`)},{value:N.NextYear,label:t(`sheets-table.date.compare.${N.NextYear}`)},{value:N.Quarter,label:t(`sheets-table.date.compare.${N.Quarter}`)},{value:N.Month,label:t(`sheets-table.date.compare.${N.Month}`)}]}]}function tn(e,t){if(!t)return[];let n=e.get(p).t;switch(t){case N.Quarter:return[{value:N.Q1,label:n(`sheets-table.date.compare.${N.Q1}`)},{value:N.Q2,label:n(`sheets-table.date.compare.${N.Q2}`)},{value:N.Q3,label:n(`sheets-table.date.compare.${N.Q3}`)},{value:N.Q4,label:n(`sheets-table.date.compare.${N.Q4}`)}];case N.Month:return[{value:N.M1,label:n(`sheets-table.date.compare.${N.M1}`)},{value:N.M2,label:n(`sheets-table.date.compare.${N.M2}`)},{value:N.M3,label:n(`sheets-table.date.compare.${N.M3}`)},{value:N.M4,label:n(`sheets-table.date.compare.${N.M4}`)},{value:N.M5,label:n(`sheets-table.date.compare.${N.M5}`)},{value:N.M6,label:n(`sheets-table.date.compare.${N.M6}`)},{value:N.M7,label:n(`sheets-table.date.compare.${N.M7}`)},{value:N.M8,label:n(`sheets-table.date.compare.${N.M8}`)},{value:N.M9,label:n(`sheets-table.date.compare.${N.M9}`)},{value:N.M10,label:n(`sheets-table.date.compare.${N.M10}`)},{value:N.M11,label:n(`sheets-table.date.compare.${N.M11}`)},{value:N.M12,label:n(`sheets-table.date.compare.${N.M12}`)}];default:return[]}}const nn=new Set([N.Equal,N.NotEqual,N.After,N.AfterOrEqual,N.Before,N.BeforeOrEqual]);function rn(e,t){return t?e===M.String?Q.Input:e===M.Number?t===F.Between||t===F.NotBetween?Q.Inputs:Q.Input:e===M.Date?t===N.Between||t===N.NotBetween?Q.DateRange:t===N.Quarter||t===N.Month?Q.Select:nn.has(t)?Q.DatePicker:Q.None:Q.None:Q.None}function an(e){if(!e||e.filterType!==`condition`)return{type:M.String,compareType:I.Equal,info:{}};let t=e.filterInfo,{conditionType:n,compareType:r}=t;if(n===M.Date)if(r===N.Between||r===N.NotBetween){let e;return Array.isArray(t.expectedValue)&&(e=t.expectedValue.map(e=>typeof e==`string`?new Date(e):e)),{type:n,compare:r,info:{dateRange:e}}}else if(r===N.Today||r===N.Yesterday||r===N.Tomorrow||r===N.ThisWeek||r===N.LastWeek||r===N.NextWeek||r===N.ThisMonth||r===N.LastMonth||r===N.NextMonth||r===N.ThisYear||r===N.LastYear||r===N.NextYear)return{type:n,compare:r,info:{}};else if(nn.has(r)){let e;if(typeof t.expectedValue==`string`)e=new Date(t.expectedValue);else if(Array.isArray(t.expectedValue))for(let e=0;e<t.expectedValue.length;e++)typeof t.expectedValue[e]==`string`&&(t.expectedValue[e]=new Date(t.expectedValue[e]));return{type:n,compare:r,info:{date:e}}}else if(new Set([N.Q1,N.Q2,N.Q3,N.Q4]).has(r))return{type:n,compare:N.Quarter,info:{dateSelect:t.compareType}};else return{type:n,compare:N.Month,info:{dateSelect:t.compareType}};else if(n===M.Number)return r===F.Between||r===F.NotBetween?{type:n,compare:r,info:{numberRange:t.expectedValue}}:{type:n,compare:r,info:{number:t.expectedValue}};else if(n===M.String)return{type:n,compare:r,info:{string:t.expectedValue}};return{type:M.String,compare:I.Equal,info:{}}}const on=e=>{var t,n,r,i,a,o,s,c;let{conditionInfo:l,onChange:u}=e,f=R(p),[m,h]=W(!1),g=R(d),_=en(g),v=(e,t,n)=>{u({type:t==null?l.type:t,compare:n==null?l.compare:n,info:e})},y=e=>{var t;let n=e[0],r=e[1];r&&h(!1);let i={};n===M.Date?r===N.Quarter?i.dateSelect=N.Q1:r===N.Month?i.dateSelect=N.M1:nn.has(r)?i.date=new Date:i.dateRange=[new Date,new Date]:n===M.Number?i.number=0:n===M.String&&(i.string=``),v(i,e[0],(t=e[1])==null?I.Equal:t)},b=rn(l.type,l.compare),x=``;x=l.compare?`${f.t(`sheets-table.condition.${l.type}`)} - ${f.t(`sheets-table.${l.type}.compare.${l.compare}`)}`:f.t(`sheets-table.condition.${l.type}`);let S=tn(g,l.compare);return K(`div`,{children:[G(nt,{align:`start`,open:m,onOpenChange:h,overlay:G(Ze,{value:[l.type,l.compare],options:_,onChange:y,contentClassName:`univer-flex-1`,wrapperClassName:`!univer-h-[150px]`}),children:K(`div`,{className:U(`univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-2 univer-text-sm univer-transition-colors univer-duration-200 hover:univer-border-primary-600 focus:univer-border-primary-600 focus:univer-outline-none focus:univer-ring-2 dark:!univer-bg-gray-700 dark:!univer-text-white`,H),children:[G(`span`,{children:x}),G(pt,{})]})}),K(`div`,{className:`univer-mt-3 univer-w-full`,children:[b===Q.Input&&G(Lt,{children:l.type===M.String?G(rt,{className:`univer-w-full`,placeholder:`请输入`,value:l.info.string,onChange:e=>v({string:e})}):G(it,{className:`univer-h-7 univer-w-full`,value:l.info.number,controls:!1,onChange:e=>{e!==null&&v({number:e})}})}),b===Q.DatePicker&&G(`div`,{id:`univer-table-date-picker-wrapper`,children:G(et,{className:`univer-w-full`,value:(t=l.info.date)==null?new Date:t,onValueChange:e=>v({date:e})})}),b===Q.DateRange&&G(`div`,{id:`univer-table-date-range-wrapper`,children:G(tt,{className:`univer-w-full`,value:[(n=(r=l.info.dateRange)==null?void 0:r[0])==null?new Date:n,(i=(a=l.info.dateRange)==null?void 0:a[1])==null?new Date:i],onValueChange:e=>{v(e?{dateRange:e}:{})}})}),b===Q.Inputs&&K(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:[G(it,{className:`univer-w-full`,value:(o=l.info.numberRange)==null?void 0:o[0],onChange:e=>{if(e!==null){var t;v({numberRange:[e,(t=l.info.numberRange)==null?void 0:t[1]]})}},controls:!1}),G(`span`,{children:` - `}),G(it,{className:`univer-w-full`,value:(s=l.info.numberRange)==null?void 0:s[1],controls:!1,onChange:e=>{if(e!==null){var t;v({numberRange:[(t=l.info.numberRange)==null?void 0:t[0],e]})}}})]}),b===Q.Select&&G(ot,{className:`univer-w-full`,value:(c=l.info.dateSelect)==null?S[0].value:c,options:S,onChange:e=>v({dateSelect:e})})]})]})},sn=e=>{let t=0;return e.forEach(e=>{t+=e}),t};function cn(e){let{unitId:t,tableId:n,subUnitId:r,columnIndex:i,checkedItemSet:a,setCheckedItemSet:o,tableFilter:s}=e,c=R(p),{data:l,itemsCountMap:u,allItemsCount:d}=R($t).getTableFilterItems(t,r,n,i),[f,m]=W(s===void 0?!0:a.size===u.size),[h,g]=W(f?d:sn(u)),_=!f&&a.size>0,[v,y]=W(``),b=It(()=>v?l.filter(e=>String(e.title).toLowerCase().includes(v.toLowerCase())):l,[v,l]),x=Pt(()=>{f?(a.clear(),o(new Set(a)),m(!1)):(b.forEach(e=>{a.add(e.title)}),o(new Set(a)),m(!0))},[f]),S=Pt(e=>{e===``?(m(!0),l.forEach(e=>{a.add(e.title)}),g(d)):(a.clear(),m(!1),g(0)),y(e)},[]),C=e=>{if(f){m(!1);let t=new Set;for(let{title:n}of l)e!==n&&t.add(n);g(d-u.get(e)),o(t)}else a.has(e)?(a.delete(e),g(h-u.get(e))):(a.add(e),g(h+u.get(e))),o(new Set(a))};return K(`div`,{className:`univer-flex univer-h-full univer-flex-col`,children:[G(rt,{autoFocus:!0,value:v,placeholder:c.t(`sheets-table.filter.search-placeholder`),onChange:S}),G(`div`,{className:U(`univer-mt-2 univer-box-border univer-flex univer-h-[180px] univer-max-h-[180px] univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-py-1.5 univer-pl-2`,H),children:G(`div`,{className:U(`univer-h-40 univer-overflow-y-auto univer-py-1 univer-pl-2`,st),children:K(`div`,{className:`univer-h-full`,children:[G(`div`,{className:`univer-flex univer-items-center univer-px-2 univer-py-1`,children:G(Qe,{indeterminate:_,disabled:l.length===0,checked:f,onChange:x,children:K(`div`,{className:`univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm`,children:[G(`span`,{className:`univer-inline-block univer-truncate`,children:`${c.t(`sheets-table.filter.select-all`)}`}),G(`span`,{className:`univer-ml univer-text-gray-400`,children:`(${h}/${v?b.length:d})`})]})})}),b.map(e=>G(`div`,{className:`univer-flex univer-items-center univer-px-2 univer-py-1`,children:G(Qe,{checked:f||a.has(e.title),onChange:()=>{C(e.title)},children:K(`div`,{className:`univer-flex univer-h-5 univer-flex-1 univer-text-sm`,children:[G(`span`,{className:`univer-inline-block univer-truncate`,children:e.title}),G(`span`,{className:`univer-ml-1 univer-text-gray-400`,children:`(${u.get(e.title)||0})`})]})})},e.key))]})})})]})}function ln(){var e;let t=R(p),n=un(t),r=R($t),i=R(P),o=R(a),s=R(c),l=R(dn),u=l.getCurrentTableFilterInfo(),d=r.getTableFilterPanelInitProps(u.unitId,u.subUnitId,u.tableId,u.column),{unitId:f,subUnitId:m,tableId:h,tableFilter:g,currentFilterBy:_,columnIndex:v}=d,{data:y}=r.getTableFilterItems(f,m,h,v),b=r.getTableFilterCheckedItems(f,h,v),[x,S]=W(new Set(b)),[C,w]=W(_||Yt.Items),[T,ee]=W(()=>{let e=d.tableFilter;return an(e)}),E=i.getTable(f,h);if(!E)return null;let D=E.getTableFilters(),te=D.getSortState();te.columnIndex===v&&(te.sortState,pe.Asc),te.columnIndex===v&&(te.sortState,pe.Desc);let O=()=>{l.closeFilterPanel()},ne=()=>{O()},k=e=>{let t=E.getTableFilterRange();o.executeCommand(Mt.id,{unitId:f,subUnitId:m,range:t,orderRules:[{colIndex:v+t.startColumn,type:e?Nt.ASC:Nt.DESC}],hasTitle:!1}),D.setSortState(v,e?pe.Asc:pe.Desc),O()},A=()=>{if(C===Yt.Items){let e=[];for(let t of y)x.has(t.title)&&e.push(t.title);let t=E.getTableFilterColumn(v);if(t){if(t.values.join(`,`)===e.join(`,`)){O();return}}else if(e.length===0){O();return}let n={filterType:me.manual,values:e};r.setTableFilter(f,h,v,n)}else{let e;e=T.compare===N.Quarter||T.compare===N.Month?{conditionType:T.type,compareType:Object.values(T.info)[0]}:{conditionType:T.type,compareType:T.compare,expectedValue:Object.values(T.info)[0]};let t={filterType:me.condition,filterInfo:e};r.setTableFilter(f,h,v,t)}O()},re=()=>{r.setTableFilter(f,h,v,void 0),O()},j=new Et(f).id;return K(`div`,{className:`univer-box-border univer-flex univer-min-w-[312px] univer-flex-col univer-rounded-[10px] univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700`,children:[((e=s.getPermissionPoint(j))==null?void 0:e.value)&&G(`div`,{className:`univer-mb-3 univer-flex`,children:K(Xe,{className:`univer-mb-3 !univer-flex univer-w-full`,children:[K(Ye,{className:`univer-w-1/2`,onClick:()=>k(!0),children:[G(ct,{className:`univer-mr-1`}),t.t(`sheets-sort.general.sort-asc`)]}),K(Ye,{className:`univer-w-1/2`,onClick:()=>k(!1),children:[G(ut,{className:`univer-mr-1`}),t.t(`sheets-sort.general.sort-desc`)]})]})}),G(`div`,{className:`univer-w-full`,children:G(at,{value:C,items:n,onChange:e=>w(e)})}),G(`div`,{className:`univer-z-10 univer-h-60`,children:G(`div`,{className:`univer-mt-3 univer-size-full`,children:C===Yt.Items?G(cn,{tableFilter:g,unitId:f,subUnitId:m,tableId:h,columnIndex:v,checkedItemSet:x,setCheckedItemSet:S}):G(on,{tableFilter:g,unitId:f,subUnitId:m,tableId:h,columnIndex:v,conditionInfo:T,onChange:ee})})}),K(`div`,{className:`univer-flex-wrap-nowrap univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-justify-between univer-gap-6 univer-overflow-hidden`,children:[G(Ye,{disabled:g===void 0,onClick:re,children:t.t(`sheets-table.filter.clear-filter`)}),K(`div`,{children:[G(Ye,{className:`univer-mr-2`,onClick:ne,children:t.t(`sheets-table.filter.cancel`)}),G(Ye,{variant:`primary`,onClick:A,children:t.t(`sheets-table.filter.confirm`)})]})]})]})}function un(e){return It(()=>[{label:e.t(`sheets-table.filter.by-values`),value:Yt.Items},{label:e.t(`sheets-table.filter.by-conditions`),value:Yt.Condition}],[e.getCurrentLocale(),e])}let dn=class extends r{constructor(e,t,n,r){super(),this._componentManager=e,this._contextService=t,this._sheetCanvasPopupService=n,this._dialogService=r,Y(this,`_popupDisposable`,void 0),Y(this,`_currentTableFilterInfo`,null),this._initComponents(),this._initUIPopup()}setCurrentTableFilterInfo(e){this._currentTableFilterInfo=e}clearCurrentTableFilterInfo(){this._currentTableFilterInfo=null}getCurrentTableFilterInfo(){return this._currentTableFilterInfo}_initComponents(){[[Ut,ln]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initUIPopup(){this.disposeWithMe(this._contextService.subscribeContextValue$(Ut).pipe(qe(void 0),Ue()).subscribe(e=>{e?this._openFilterPopup():e===!1&&this._closeFilterPopup()}))}closeFilterPanel(){this._contextService.setContextValue(Ut,!1)}_openFilterPopup(){let e=this._currentTableFilterInfo;if(!e)throw Error(`[SheetsFilterUIController]: no filter model when opening filter popup!`);let{row:t,column:n}=e;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(t,n,{componentKey:Ut,direction:`horizontal`,onClickOutside:()=>{this._dialogService.close(`UNIVER_SHEET_Table_FILTER_PANEL_ID`),this._contextService.setContextValue(Ut,!1)},offset:[5,0],portal:!0})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null,this.clearCurrentTableFilterInfo()}};dn=Z([X(0,u(Ae)),X(1,s),X(2,u(Ce)),X(3,u(Ne))],dn);const fn={type:t.OPERATION,id:`sheet.operation.open-table-filter-panel`,async handler(e,t){if(!t)return!1;let{row:n,col:r,unitId:i,subUnitId:a,tableId:o}=t,c=e.get(P),l=e.get(s),u=e.get(dn);return c.getTable(i,o)?(l.getContextValue(`SHEETS_TABLE_FILTER_PANEL_OPENED_KEY`)||(u.setCurrentTableFilterInfo({unitId:i,subUnitId:a,row:n,tableId:o,column:r}),l.setContextValue(Ut,!0)),!0):!1}},pn={type:t.OPERATION,id:`sheet.operation.open-table-selector`,async handler(e){var t;let n=e.get(l),r=e.get(a),i=At(n);if(!i)return!1;let{unitId:o,subUnitId:s,worksheet:c}=i,u=e.get(Tt).getCurrentLastSelection(),d=(t=u==null?void 0:u.range)==null?{startRow:0,endRow:0,startColumn:0,endColumn:0}:t,f=await mn(e,o,s,jt(u)?Ot(d,{up:!0,left:!0,right:!0,down:!0},c):d);return f?(r.executeCommand(ne.id,{...f}),!0):!1}};async function mn(e,t,n,r,i){let a=e.get(Ne),o=e.get(p);return new Promise(e=>{let s={unitId:t,subUnitId:n,range:r,tableId:i,onConfirm:t=>{e(t),a.close(Gt)},onCancel:()=>{e(null),a.close(Gt)}};a.open({id:Gt,title:{title:o.t(`sheets-table.selectRange`)},draggable:!0,destroyOnClose:!0,mask:!1,maskClosable:!1,children:{label:{name:Gt,props:s}},width:300,onClose:()=>{e(null),a.close(Gt)}})})}const hn=`sheets-table-ui.config`;Symbol(hn);const gn={anchorHeight:24,anchorBackgroundColor:`rgb(134,139,156)`};let _n=class extends r{constructor(e){super(),this._commandService=e,Y(this,`_refreshTable`,new Ve),Y(this,`refreshTable$`,this._refreshTable.asObservable()),this._initListener()}_initListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===yt.id){let{styleName:t}=e.params;t.startsWith(j)&&this._refreshTable.next(Math.random())}}))}};_n=Z([X(0,u(a))],_n);const vn=()=>{var e,t;let[n,r]=W(``),[i,s]=W(``),c=R(Fe),[u,f]=W({}),m=R(d),h=z(R(yn).anchorPosition$),_=R(a),v=R(l),y=z(R(Dt).unitPermissionInitStateChange$,!1),b=R(P),S=R(wt),C=z(R(_n).refreshTable$),w=R(p),T=z(R(Tt).selectionChanged$,[{range:x(0,0),primary:null}]),[,ee]=W(Math.random()),E=R(o).getConfig(hn),D=(e=E==null?void 0:E.anchorHeight)==null?24:e,te=(t=E==null?void 0:E.anchorBackgroundColor)==null?`rgb(53,91,183)`:t,O=(e,t)=>{f(n=>({...n,[e]:t}))};if(Ft(()=>{ee(Math.random())},[C]),!(h!=null&&h.length))return null;let ne=At(v);if(!ne)return null;let{unitId:k,subUnitId:re}=ne,j=(e,t)=>{var n;if(((n=b.getTableById(k,e))==null?void 0:n.getDisplayName())===t){r(``),s(``);return}_.executeCommand(ie.id,{tableId:e,unitId:k,name:t}),s(``),r(``)},ae=async e=>{let t=b.getTableById(k,e);if(!t)return;let n=await mn(m,k,re,t.getRange(),e);n&&_.executeCommand(ie.id,{tableId:e,unitId:k,updateRange:{newRange:n.range}})};return y?G(`div`,{className:`univer-absolute univer-z-50 univer-size-0`,children:h.map(e=>{var t,a,o,l,d;let f=b.getTableById(k,e.tableId);if(!f)return null;let p=S.getRangeThemeStyle(k,f.getTableStyleId()),m=(t=p==null||(a=p.getHeaderRowStyle())==null||(a=a.bg)==null?void 0:a.rgb)==null?te:t,h=(o=p==null||(l=p.getHeaderRowStyle())==null||(l=l.cl)==null?void 0:l.rgb)==null?`rgb(255, 255, 255)`:o,v=f.getRange();if(!(T!=null&&T.length))return null;let y=T[T.length-1].range,x=!g.intersects(v,y)&&e.y<=20;return K(`div`,{className:U(`univer-shadow-xs univer-absolute univer-box-border univer-cursor-pointer univer-items-center univer-rounded-xl univer-px-2`,H,{"univer-flex":!x,"univer-hidden":x}),style:{left:e.x,top:Math.max(e.y,0),backgroundColor:m,color:h,borderWidth:`0.5px`,height:D?`${D}px`:`24px`},children:[G(`div`,{className:`univer-text-nowrap`,children:n===e.tableId?G(rt,{className:`univer-h-[18px] univer-min-w-16 univer-rounded-none`,inputClass:`univer-h-[18px] univer-w-[80px]`,value:i,onChange:e=>s(e),onBlur:()=>j(e.tableId,i),onKeyDown:t=>{t.key===`Enter`&&j(e.tableId,i)},autoFocus:n===e.tableId}):G(`div`,{className:`univer-h-[18px] univer-max-w-24 univer-truncate univer-text-sm`,children:e.tableName})}),G(nt,{align:`start`,overlay:K(`div`,{className:`univer-py-2`,children:[K(`div`,{className:`univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200`,onClick:()=>{r(e.tableId),s(e.tableName)},children:[G(ht,{}),w.t(`sheets-table.rename`)]}),G(`div`,{className:`univer-my-1 univer-h-px univer-w-full univer-bg-gray-200`}),K(`div`,{onClick:()=>ae(e.tableId),className:`univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200`,children:[G(ft,{}),w.t(`sheets-table.updateRange`)]}),K(`div`,{className:`univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200`,onClick:()=>{O(e.tableId,!1);let t=b.getTableById(k,e.tableId);if(!t)return;let n=t.getTableConfig(),r={id:`SHEET_TABLE_THEME_PANEL_ID`,header:{title:w.t(`sheets-table.tableStyle`)},children:{label:Kt,oldConfig:n,unitId:k,subUnitId:re,tableId:e.tableId},width:330};c.open(r)},children:[G(mt,{extend:{colorChannel1:`rgb(53,91,183)`}}),w.t(`sheets-table.setTheme`)]}),G(`div`,{className:`univer-my-1 univer-h-px univer-w-full univer-bg-gray-200`}),K(`div`,{className:`univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200`,onClick:()=>{O(e.tableId,!1),_.executeCommand(A.id,{tableId:e.tableId,subUnitId:re,unitId:k})},children:[G(lt,{className:`univer-mr-2`}),w.t(`sheets-table.removeTable`)]})]}),open:(d=u[e.tableId])==null?!1:d,onOpenChange:t=>{O(e.tableId,t)},children:G(`div`,{children:G(pt,{})})},e.tableId)]},e.tableId)})}):null};let yn=class extends r{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._context=e,this._injector=t,this._sheetSkeletonManagerService=n,this._renderManagerService=r,this._commandService=i,this._univerInstanceService=a,this._uiPartsService=o,this._tableManager=s,this._scrollManagerService=c,this._workbookPermissionService=l,this._permissionService=u,Y(this,`_anchorVisible$`,new Be(!0)),Y(this,`_timer`,void 0),Y(this,`_anchorPosition$`,new Be([])),Y(this,`anchorPosition$`,this._anchorPosition$.asObservable()),this._initUI(),this._initListener(),this._initTableAnchor()}_initUI(){this.disposeWithMe(this._uiPartsService.registerComponent(ke.CONTENT,()=>Re(vn,this._injector)))}_initListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{(e.id===Se.id||e.id===xe.id)&&(this._anchorVisible$.next(!1),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this._anchorVisible$.next(!0)},300))}))}_initTableAnchor(){this.disposeWithMe(Ke(this._context.unit.activeSheet$,this._sheetSkeletonManagerService.currentSkeleton$,this._scrollManagerService.validViewportScrollInfo$,this._tableManager.tableAdd$,this._tableManager.tableDelete$,this._tableManager.tableNameChanged$,this._tableManager.tableRangeChanged$,this._tableManager.tableThemeChanged$,this._workbookPermissionService.unitPermissionInitStateChange$.pipe(We(e=>e)),this._permissionService.permissionPointUpdate$.pipe(He(300)),this._anchorVisible$).subscribe(()=>{var e;if(!this._anchorVisible$.getValue()){this._anchorPosition$.next([]);return}let t=this._context.unit,n=t.getActiveSheet(),r=n==null?void 0:n.getSheetId(),i=this._tableManager.getTableList(this._context.unitId).filter(e=>e.subUnitId===r),a=this._renderManagerService.getRenderById(this._context.unitId);if(!a){this._anchorPosition$.next([]);return}if(!((e=this._permissionService.getPermissionPoint(new Et(t.getUnitId()).id))!=null&&e.value)){this._anchorPosition$.next([]);return}let o=i.reduce((e,t)=>{let{startRow:n,startColumn:r}=t.range,i=a.with(Te),o=Oe(this._univerInstanceService,this._renderManagerService);if(!o)return e;let{scene:s}=o,c=s.getViewport(E.VIEW_MAIN);if(!c)return e;let l=s==null?void 0:s.scaleX,u=s==null?void 0:s.scaleY,d=s==null?void 0:s.getViewportScrollXY(c);if(!l||!s||!u||!d)return e;let f=i.getCurrentSkeleton();if(!f)return e;let p=f.getNoMergeCellWithCoordByIndex(n,r),m=te(p.startX,l,d),h=O(p.startY,u,d)-25-4;return h>=-10&&m>=45&&e.push({x:m,y:h,tableId:t.id,tableName:t.name}),e},[]);this._anchorPosition$.next(o)}))}};yn=Z([X(1,u(d)),X(2,u(Te)),X(3,T),X(4,a),X(5,l),X(6,Ie),X(7,u(P)),X(8,u(we)),X(9,u(Dt)),X(10,u(c))],yn),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`);var bn=class{static drawNoSetting(e,t,n,r){e.save(),ee.drawWith(e,{radius:2,width:16,height:16,fill:r}),e.lineCap=`square`,e.strokeStyle=n,e.scale(t/16,t/16),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 drawIconByPath(e,t,n,r){e.save(),e.strokeStyle=n,e.fillStyle=r,ee.drawWith(e,{radius:2,width:16,height:16,fill:r}),t.forEach(t=>{let r=new Path2D(t);e.fillStyle=n,e.fill(r,`evenodd`)}),e.restore()}};const xn=[`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`],Sn=[`M12.4008 13.1831C12.6907 13.1831 12.9258 12.9481 12.9258 12.6581V4.60873L14.013 5.69597C14.218 5.901 14.5505 5.901 14.7555 5.69597C14.9605 5.49094 14.9605 5.15853 14.7555 4.95351L12.7721 2.97017C12.5671 2.76515 12.2347 2.76515 12.0297 2.97017L10.0463 4.95351C9.84132 5.15853 9.84132 5.49094 10.0463 5.69597C10.2514 5.901 10.5838 5.901 10.7888 5.69597L11.8758 4.60901V12.6581C11.8758 12.9481 12.1108 13.1831 12.4008 13.1831Z`,`M1.28069 4.85447C0.842195 4.33439 1.21191 3.5391 1.89218 3.5391H8.59333C9.2736 3.5391 9.64331 4.33439 9.20482 4.85447L6.51052 8.0501V11.6601C6.51052 12.2245 5.94174 12.6114 5.41683 12.404L4.48092 12.0343C4.1756 11.9136 3.97498 11.6187 3.97498 11.2904V8.0501L1.28069 4.85447Z`],Cn=[`M12.4008 2.81641C12.6907 2.81641 12.9258 3.05146 12.9258 3.34141V11.3908L14.013 10.3036C14.218 10.0986 14.5505 10.0986 14.7555 10.3036C14.9605 10.5086 14.9605 10.841 14.7555 11.046L12.7721 13.0294C12.5671 13.2344 12.2347 13.2344 12.0297 13.0294L10.0463 11.046C9.84132 10.841 9.84132 10.5086 10.0463 10.3036C10.2514 10.0986 10.5838 10.0986 10.7888 10.3036L11.8758 11.3905V3.34141C11.8758 3.05146 12.1108 2.81641 12.4008 2.81641Z`,`M1.28069 4.85444C0.842195 4.33435 1.21191 3.53906 1.89218 3.53906H8.59333C9.2736 3.53906 9.64331 4.33435 9.20482 4.85443L6.51052 8.05006V11.6601C6.51052 12.2245 5.94174 12.6113 5.41683 12.404L4.48092 12.0342C4.1756 11.9136 3.97498 11.6186 3.97498 11.2903V8.05006L1.28069 4.85444Z`],wn=[`M11.9003 13.7046C11.9003 13.9969 11.6633 14.2339 11.371 14.2339C11.0787 14.2339 10.8417 13.9969 10.8417 13.7046V3.57272L9.74577 4.66862C9.53906 4.87534 9.20391 4.87534 8.9972 4.66862C8.79048 4.46191 8.79048 4.12676 8.9972 3.92005L10.9969 1.92039C11.2036 1.71368 11.5387 1.71368 11.7454 1.92039L13.7451 3.92005C13.9518 4.12676 13.9518 4.46191 13.7451 4.66862C13.5384 4.87534 13.2032 4.87534 12.9965 4.66862L11.9003 3.57243V13.7046Z`,`M2.69779 10.0113C2.40546 10.0113 2.16847 9.77429 2.16847 9.48196C2.16847 9.18962 2.40546 8.95264 2.69779 8.95264H6.67804C6.89213 8.95264 7.08514 9.0816 7.16707 9.2794C7.249 9.47719 7.20371 9.70486 7.05233 9.85624L3.97569 12.9329H6.67804C6.97038 12.9329 7.20736 13.1699 7.20736 13.4622C7.20736 13.7545 6.97038 13.9915 6.67804 13.9915H2.69779C2.4837 13.9915 2.29069 13.8626 2.20876 13.6648C2.12684 13.467 2.17212 13.2393 2.32351 13.0879L5.40015 10.0113H2.69779Z`,`M5.51638 2.58693C5.23363 1.81542 4.14248 1.81543 3.85973 2.58693L2.13245 7.29995C2.03185 7.57443 2.17281 7.87849 2.4473 7.97909C2.72178 8.07969 3.02584 7.93872 3.12644 7.66424L3.64346 6.25351L3.64504 6.25351H5.73266L6.24968 7.66424C6.35027 7.93872 6.65433 8.07969 6.92882 7.97909C7.2033 7.87849 7.34426 7.57443 7.24367 7.29995L5.51638 2.58693ZM5.34467 5.19487L4.68806 3.40325L4.03144 5.19487H5.34467Z`],Tn=[`M11.9003 2.29495C11.9003 2.00261 11.6633 1.76562 11.371 1.76562C11.0787 1.76562 10.8417 2.00261 10.8417 2.29495V12.4268L9.74577 11.3309C9.53906 11.1242 9.20391 11.1242 8.9972 11.3309C8.79048 11.5376 8.79048 11.8727 8.9972 12.0795L10.9969 14.0791C11.2036 14.2858 11.5387 14.2858 11.7454 14.0791L13.7451 12.0795C13.9518 11.8727 13.9518 11.5376 13.7451 11.3309C13.5384 11.1242 13.2032 11.1242 12.9965 11.3309L11.9003 12.4271V2.29495Z`,`M2.69792 10.0113C2.40558 10.0113 2.16859 9.77429 2.16859 9.48196C2.16859 9.18962 2.40558 8.95264 2.69792 8.95264H6.67816C6.89225 8.95264 7.08526 9.0816 7.16719 9.2794C7.24912 9.47719 7.20384 9.70486 7.05245 9.85624L3.97581 12.9329H6.67816C6.9705 12.9329 7.20749 13.1699 7.20749 13.4622C7.20749 13.7545 6.9705 13.9915 6.67816 13.9915H2.69792C2.48383 13.9915 2.29082 13.8626 2.20889 13.6648C2.12696 13.467 2.17224 13.2393 2.32363 13.0879L5.40027 10.0113H2.69792Z`,`M5.5165 2.58693C5.23375 1.81542 4.1426 1.81543 3.85985 2.58693L2.13257 7.29995C2.03197 7.57443 2.17294 7.8785 2.44742 7.97909C2.7219 8.07969 3.02596 7.93872 3.12656 7.66424L3.64358 6.25351L3.64516 6.25351H5.73278L6.2498 7.66424C6.35039 7.93872 6.65446 8.07969 6.92894 7.97909C7.20342 7.8785 7.34438 7.57443 7.24379 7.29995L5.5165 2.58693ZM5.34479 5.19487L4.68818 3.40325L4.03156 5.19487H5.34479Z`];let En=class extends D{constructor(e,t,n,r,i){super(e,t),this._contextService=n,this._commandService=r,this._themeService=i,Y(this,`_cellWidth`,0),Y(this,`_cellHeight`,0),Y(this,`_filterParams`,void 0),Y(this,`_hovered`,!1),this.setShapeProps(t),this.onPointerDown$.subscribeEvent(e=>this.onPointerDown(e)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){e.cellHeight!==void 0&&(this._cellHeight=e.cellHeight),e.cellWidth!==void 0&&(this._cellWidth=e.cellWidth),e.filterParams!==void 0&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){let t=this._cellHeight,n=this._cellWidth,r=16-n,i=16-t;e.save();let a=new Path2D;a.rect(r,i,n,t),e.clip(a);let{buttonState:o}=this._filterParams,s=this._themeService.getColorFromTheme(`primary.600`),c=this._hovered?this._themeService.getColorFromTheme(`gray.50`):`rgba(255, 255, 255, 1.0)`,l;switch(o){case de.FilteredSortNone:l=xn;break;case de.FilteredSortAsc:l=Sn;break;case de.FilteredSortDesc:l=Cn;break;case de.FilterNoneSortNone:break;case de.FilterNoneSortAsc:l=wn;break;case de.FilterNoneSortDesc:l=Tn;break}l?bn.drawIconByPath(e,l,s,c):o!==void 0&&bn.drawNoSetting(e,16,s,c),e.restore()}onPointerDown(e){if(e.button===2)return;let{row:t,col:n,unitId:r,subUnitId:i,tableId:a}=this._filterParams;this._contextService.getContextValue(`SHEETS_TABLE_FILTER_PANEL_OPENED_KEY`)||!this._commandService.hasCommand(fn.id)||setTimeout(()=>{let e={row:t,col:n,unitId:r,subUnitId:i,tableId:a};this._commandService.executeCommand(fn.id,e)},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};En=Z([X(2,s),X(3,a),X(4,u(v))],En);const Dn=(e,t,n,r)=>{switch(r){case b.TOP:return e+1;case b.MIDDLE:return e+Math.max(0,(n-16)/2);case b.BOTTOM:default:return t-16-1}};let On=class extends _{constructor(e,t,n,r,i,a){super(),this._context=e,this._injector=t,this._sheetSkeletonManagerService=n,this._sheetInterceptorService=r,this._tableManager=i,this._commandService=a,Y(this,`_buttonRenderDisposable`,null),Y(this,`_tableFilterButtonShapes`,[]),this._initRenderer(),this._initCommandExecuted()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){let e=this._tableManager;this._sheetSkeletonManagerService.currentSkeleton$.pipe(V(t=>{var n;if(!t)return B(null);let{unit:r,unitId:i}=this._context,a=((n=r.getActiveSheet())==null?void 0:n.getSheetId())||``,o=()=>({unitId:i,worksheetId:a,tableFilterRanges:this._tableManager.getSheetFilterRangeWithState(r.getUnitId(),a),skeleton:t.skeleton});return Ke(e.tableAdd$,e.tableNameChanged$,e.tableRangeChanged$,e.tableThemeChanged$,e.tableDelete$,e.tableFilterChanged$).pipe(Ge(()=>o()),qe(o()))}),Je(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.tableFilterRanges)&&this._renderButtons(e)})}_initCommandExecuted(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t;if(e.id!==St.id)return;let{unit:n,unitId:r}=this._context,i=((t=n.getActiveSheet())==null?void 0:t.getSheetId())||``,a=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!a)return;let o={unitId:r,worksheetId:i,tableFilterRanges:this._tableManager.getSheetFilterRangeWithState(n.getUnitId(),i),skeleton:a};this._disposeRendering(),!(!o||!o.tableFilterRanges)&&this._renderButtons(o)}))}_renderButtons(e){let{tableFilterRanges:t,unitId:n,skeleton:r,worksheetId:i}=e,{unit:a,scene:o}=this._context,s=a.getSheetBySheetId(i);if(s){for(let{range:e,states:a,tableId:c}of t){let{startRow:t,startColumn:l,endColumn:u}=e;this._interceptCellContent(n,i,e);for(let e=l;e<=u;e++){let u=`sheets-table-filter-button-${t}-${e}`,d=Ee(t,e,o,r),f=s.getCellStyle(t,e),p=(f==null?void 0:f.vt)||b.BOTTOM,{startX:m,startY:h,endX:g,endY:_}=d,v=g-m,y=_-h;if(y<=1||v<=1)continue;let x=a[e-l],S={left:g-16-1,top:Dn(h,_,y,p),height:16,width:16,zIndex:5e3,cellHeight:y,cellWidth:v,filterParams:{unitId:n,subUnitId:i,row:t,col:e,buttonState:x,tableId:c}},C=this._injector.createInstance(En,u,S);this._tableFilterButtonShapes.push(C)}}o.addObjects(this._tableFilterButtonShapes),o.makeDirty()}}_interceptCellContent(e,t,n){let{startRow:r,startColumn:i,endColumn:a}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(_t.CELL_CONTENT,{effect:f.Style,handler:(n,o,s)=>{let{row:c,col:l,unitId:u,subUnitId:d}=o;return u!==e||d!==t||c!==r||l<i||l>a?s(n):((!n||n===o.rawData)&&(n={...o.rawData}),n.fontRenderExtension={...n==null?void 0:n.fontRenderExtension,rightOffset:16},s(n))},priority:10})}_disposeRendering(){var e;this._tableFilterButtonShapes.forEach(e=>e.dispose()),(e=this._buttonRenderDisposable)==null||e.dispose(),this._buttonRenderDisposable=null,this._tableFilterButtonShapes=[]}};On=Z([X(1,u(d)),X(2,u(Te)),X(3,u(Ct)),X(4,u(P)),X(5,a)],On);let kn=class extends _{constructor(e,t,n,r,i){super(),this._context=e,this._injector=t,this._sheetSkeletonManagerService=n,this._tableManager=r,this._sheetTableThemeUIController=i,this._initListener()}_dirtySkeleton(){var e;(e=this._context.mainComponent)==null||e.makeDirty();let t=this._sheetSkeletonManagerService.getCurrentParam();if(t){let e={...t,dirty:!0};this._sheetSkeletonManagerService.reCalculate(e)}}_initListener(){let e=this._tableManager,t=this._dirtySkeleton.bind(this);this.disposeWithMe(Ke(e.tableAdd$,e.tableDelete$,e.tableNameChanged$,e.tableRangeChanged$,e.tableThemeChanged$,e.tableFilterChanged$,e.tableInitStatus$,this._sheetTableThemeUIController.refreshTable$).subscribe(t))}};kn=Z([X(1,u(d)),X(2,u(Te)),X(3,u(P)),X(4,u(_n))],kn);let An=class extends r{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._tableManager=n,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===be.id){let t=At(this._univerInstanceService);if(!t)return{redos:[],undos:[]};let{range:n}=e.params,{unitId:r,subUnitId:i,worksheet:a}=t,o=this._tableManager.getTablesBySubunitId(r,i).find(e=>{let t=e.getRange();return g.contains(t,n)});if(o){let e=o.getRange(),t={...e,startRow:e.startRow+1};return g.equals(e,n)?{undos:[],redos:[]}:g.equals(t,n)?{undos:[],redos:[{id:xt.id,params:{unitId:r,subUnitId:i,selections:[{range:e,primary:kt(e,a)}]}}]}:{undos:[],redos:[{id:xt.id,params:{unitId:r,subUnitId:i,selections:[{range:t,primary:kt(t,a)}]}}]}}}return{redos:[],undos:[]}}}))}};An=Z([X(0,u(Ct)),X(1,u(l)),X(2,u(P))],An);const jn=e=>{let{unitId:t,subUnitId:n,range:r,onCancel:i,onConfirm:a,tableId:o}=e,s=R(P),[c,u]=W(r),[d,f]=W(``),m=R(p),h=R(l);return K(Lt,{children:[G(Bt,{maxRangeCount:1,unitId:t,subUnitId:n,initialValue:zt(r),onChange:(e,i)=>{let c=zt(r),l=Rt(i).range,d=At(h,{unitId:t,subUnitId:n});if(!d)return;if(d.worksheet.getMergeData().some(e=>g.intersects(l,e))){f(m.t(`sheets-table.tableRangeWithMergeError`));return}if(s.getTablesBySubunitId(t,n).some(e=>{if(e.getId()===o)return!1;let t=e.getRange();return g.intersects(l,t)})){f(m.t(`sheets-table.tableRangeWithOtherTableError`));return}let{startRow:p,endRow:_}=l;if(p===_){f(m.t(`sheets-table.tableRangeSingleRowError`));return}if(c!==i){if(o){let e=s.getTableById(t,o);if(e){let r=e.getRange();if(g.intersects(l,r)&&r.startRow===l.startRow){u(l),f(``),a({unitId:t,subUnitId:n,range:l});return}else{f(m.t(`sheets-table.updateError`));return}}}u(l),f(``)}},supportAcrossSheet:!1}),d&&G(`div`,{className:`univer-mt-1 univer-text-xs univer-text-red-500`,children:d}),K(`div`,{className:`univer-mt-4 univer-flex univer-justify-end`,children:[G(Ye,{onClick:i,children:m.t(`sheets-table.cancel`)}),G(Ye,{variant:`primary`,onClick:()=>{d||a({unitId:t,subUnitId:n,range:c})},className:`univer-ml-2`,children:m.t(`sheets-table.confirm`)})]})]})},Mn=t=>{var n,r,o,s,c,l,u,d;let{unitId:f,subUnitId:m,tableId:h}=t,g=R(a),_=R(p),v=R(P),y=v.getTableById(f,h),b=R(wt),x=R(_n),S=z(b.rangeThemeMapChange$),C=z(x.refreshTable$),w=R(i),[,T]=W(Math.random()),ee=z(v.tableThemeChanged$,{theme:y==null?void 0:y.getTableStyleId(),oldTheme:y==null?void 0:y.getTableStyleId(),unitId:f,subUnitId:m,tableId:h}),E=b.getRegisteredRangeThemes().filter(e=>e==null?void 0:e.startsWith(`table-default-`)),D=b.getALLRegisteredTheme(f).filter(e=>e==null?void 0:e.startsWith(qt)),te=y==null?void 0:y.getTableStyleId(),O=D.find(e=>e===te),ne=O||D[0],A=b.getCustomRangeThemeStyle(f,ne),j=(n=A==null||(r=A.getHeaderRowStyle())==null||(r=r.bg)==null?void 0:r.rgb)==null?Jt:n,ae=(o=A==null||(s=A.getFirstRowStyle())==null||(s=s.bg)==null?void 0:s.rgb)==null?Jt:o,oe=(c=A==null||(l=A.getSecondRowStyle())==null||(l=l.bg)==null?void 0:l.rgb)==null?Jt:c,se=(u=A==null||(d=A.getLastRowStyle())==null||(d=d.bg)==null?void 0:d.rgb)==null?Jt:u,[ce,le]=W(null),ue=e=>{g.executeCommand(ie.id,{unitId:f,tableId:h,theme:e})},de=()=>{if(D.length>=11){w.emit(_.t(`sheets-table.customTooMore`));return}let e=D[D.length-1],t=`${qt}1`;e&&(t=`${qt}${Number(e.split(`-`)[2])+1}`);let n=new vt(t,{...ge});g.executeCommand(k.id,{unitId:f,tableId:h,themeStyle:n})},fe=(e,t)=>{g.executeCommand(yt.id,{unitId:f,subUnitId:m,styleName:e,style:t})},pe=e=>{g.executeCommand(re.id,{unitId:f,tableId:h,themeName:e})};if(Ft(()=>{T(Math.random())},[S,C]),!y)return null;let me=new e(j).isDark(),M=new e(ae).isDark(),N=new e(oe).isDark(),F=new e(se).isDark();return K(`div`,{children:[G(`h5`,{children:_.t(`sheets-table.defaultStyle`)}),G(`div`,{className:`univer-flex univer-gap-2`,children:E.map(e=>{var t,n,r,i;let a=b.getDefaultRangeThemeStyle(e),o=(a==null||(t=a.getHeaderRowStyle())==null||(t=t.bg)==null?void 0:t.rgb)||`rgb(255, 255, 255)`,s=(a==null||(n=a.getFirstRowStyle())==null||(n=n.bg)==null?void 0:n.rgb)||`rgb(255, 255, 255)`,c=(a==null||(r=a.getSecondRowStyle())==null||(r=r.bg)==null?void 0:r.rgb)||`rgb(255, 255, 255)`,l=(a==null||(i=a.getLastRowStyle())==null||(i=i.bg)==null?void 0:i.rgb)||`rgb(255, 255, 255)`;return K(`div`,{className:U(`univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px [&>div]:univer-box-border [&>div]:univer-h-2.5`,{"univer-border-blue-500":e===ee.theme}),onClick:()=>ue(e),children:[G(`div`,{style:{background:o,border:`${o?q:J}`}}),G(`div`,{style:{background:s,border:`${s?q:J}`}}),G(`div`,{style:{background:c,border:`${c?q:J}`}}),G(`div`,{style:{background:l,border:`${l?q:J}`}})]},e)})}),G(`h5`,{children:_.t(`sheets-table.customStyle`)}),K(`div`,{className:U(`univer-w-full univer-rounded-sm`,H),children:[K(`div`,{className:`univer-flex univer-flex-wrap univer-gap-2 univer-p-2`,children:[G(`div`,{className:U(`univer-h-10 univer-w-8 univer-cursor-pointer univer-p-px univer-text-center univer-leading-10`,H),onClick:de,children:`+`}),D.map(e=>{var t,n,r,i;let a=b.getCustomRangeThemeStyle(f,e),o=a==null||(t=a.getHeaderRowStyle())==null||(t=t.bg)==null?void 0:t.rgb,s=a==null||(n=a.getFirstRowStyle())==null||(n=n.bg)==null?void 0:n.rgb,c=a==null||(r=a.getSecondRowStyle())==null||(r=r.bg)==null?void 0:r.rgb,l=a==null||(i=a.getLastRowStyle())==null||(i=i.bg)==null?void 0:i.rgb;return K(`div`,{className:U(`univer-relative univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px`,{"univer-border-blue-500":e===ee.theme}),onClick:()=>ue(e),onMouseEnter:()=>le(e),onMouseLeave:()=>le(null),children:[G(`div`,{className:`univer-box-border univer-h-2.5`,style:{background:o==null?q:o,border:`${o?q:J}`}}),G(`div`,{className:`univer-box-border univer-h-2.5`,style:{background:s==null?q:s,border:`${s?q:J}`}}),G(`div`,{className:`univer-box-border univer-h-2.5`,style:{background:c==null?q:c,border:`${c?q:J}`}}),G(`div`,{className:`univer-box-border univer-h-2.5`,style:{background:l==null?q:l,border:`${l?q:J}`}}),G(`div`,{className:`univer-absolute univer-right-[-3px] univer-top-[-3px] univer-size-3 univer-rounded-md univer-bg-gray-200 univer-text-center univer-text-xs univer-leading-[10px]`,style:{display:ce===e?`block`:`none`},onClick:t=>{t.stopPropagation(),pe(e)},children:`x`})]},e)})]}),O&&K(Lt,{children:[G(`div`,{className:`univer-h-px univer-w-full univer-bg-gray-200`}),K(`div`,{className:`univer-flex univer-flex-col univer-gap-2 univer-p-2`,children:[K(`div`,{className:`univer-flex univer-h-9 univer-gap-2`,children:[G(`div`,{className:U(`univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9`,H,{"univer-text-white":me,"univer-text-gray-900":!me}),style:{background:j},children:_.t(`sheets-table.header`)}),G(nt,{overlay:G(`div`,{className:`univer-p-2`,children:G($e,{value:j,onChange:t=>{let n=ye(`headerRowStyle`,{bg:{rgb:t},cl:{rgb:new e(t).isDark()?`#fff`:`#000`}});fe(y.getTableStyleId(),{headerRowStyle:n})}})}),children:K(`div`,{className:U(`univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1`,H),children:[G(`div`,{className:U(`univer-size-4 univer-rounded-lg univer-bg-gray-400`,H,{"univer-text-white":me,"univer-text-gray-900":!me}),style:{background:j}}),G(dt,{className:`univer-size-2`})]})})]}),K(`div`,{className:`univer-flex univer-h-9 univer-gap-2`,children:[G(`div`,{className:U(`univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9`,H,{"univer-text-white":M,"univer-text-gray-900":!M}),style:{background:ae},children:_.t(`sheets-table.firstLine`)}),G(nt,{overlay:G(`div`,{className:`univer-p-2`,children:G($e,{value:ae,onChange:t=>{fe(y.getTableStyleId(),{firstRowStyle:{bg:{rgb:t},cl:{rgb:new e(t).isDark()?`#fff`:`#000`}}})}})}),children:K(`div`,{className:U(`univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1`,H),children:[G(`div`,{className:U(`univer-size-4 univer-rounded-lg univer-bg-gray-400`,H),style:{background:ae}}),G(dt,{className:`univer-size-2`})]})})]}),K(`div`,{className:`univer-flex univer-h-9 univer-gap-2`,children:[G(`div`,{className:U(`univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9`,H,{"univer-text-white":N,"univer-text-gray-900":!N}),style:{background:oe},children:_.t(`sheets-table.secondLine`)}),G(nt,{overlay:G(`div`,{className:`univer-p-2`,children:G($e,{value:oe,onChange:t=>fe(y.getTableStyleId(),{secondRowStyle:{bg:{rgb:t},cl:{rgb:new e(t).isDark()?`#fff`:`#000`}}})})}),children:K(`div`,{className:U(`univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1`,H),children:[G(`div`,{className:U(`univer-size-4 univer-rounded-lg univer-bg-gray-400`,H),style:{background:oe}}),G(dt,{className:`univer-size-2`})]})})]}),K(`div`,{className:`univer-flex univer-h-9 univer-gap-2`,children:[G(`div`,{className:U(`univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9`,H,{"univer-text-white":F,"univer-text-gray-900":!F}),style:{background:se},children:_.t(`sheets-table.footer`)}),G(nt,{overlay:G(`div`,{className:`univer-p-2`,children:G($e,{value:se,onChange:t=>{let n=ye(`lastRowStyle`,{bg:{rgb:t},cl:{rgb:new e(t).isDark()?`#fff`:`#000`}});fe(y.getTableStyleId(),{lastRowStyle:n})}})}),children:K(`div`,{className:U(`univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1`,H),children:[G(`div`,{className:U(`univer-size-4 univer-rounded-lg univer-bg-gray-400`,H),style:{background:se}}),G(dt,{className:`univer-size-2`})]})})]})]})]})]})]})},Nn=`sheet.table.context-insert_menu-id`,Pn=`sheet.table.context-remove_menu-id`;function Fn(e){return{id:pn.id,type:L.BUTTON,icon:Wt,tooltip:`sheets-table.title`,title:`sheets-table.title`,hidden$:ze(e,y.UNIVER_SHEET),disabled$:De(e,{},!0)}}function In(e){return{id:Nn,type:L.SUBITEMS,icon:`InsertDoubleIcon`,title:`sheets-table.insert.main`,hidden$:Hn(e)}}function Ln(e){return{id:Pn,type:L.SUBITEMS,icon:`ReduceDoubleIcon`,title:`sheets-table.remove.main`,hidden$:Hn(e)}}function Rn(e){return{id:se.id,type:L.BUTTON,title:`sheets-table.insert.row`,hidden$:Un(e)}}function zn(e){return{id:oe.id,title:`sheets-table.insert.col`,type:L.BUTTON}}function Bn(e){return{id:le.id,type:L.BUTTON,title:`sheets-table.remove.row`,hidden$:Un(e)}}function Vn(e){return{id:ce.id,title:`sheets-table.remove.col`,type:L.BUTTON}}function Hn(e){let t=e.get(Tt);return e.get(l).getCurrentTypeOfUnit$(y.UNIVER_SHEET).pipe(V(n=>n?n.activeSheet$.pipe(V(r=>r?t.selectionMoveEnd$.pipe(V(t=>{if(!t.length||t.length>1)return B(!0);let i=t[0].range;return B(!e.get(fe).getContainerTableWithRange(n.getUnitId(),r.getSheetId(),i))})):B(!0))):B(!0)))}function Un(e){let t=e.get(Tt);return e.get(l).getCurrentTypeOfUnit$(y.UNIVER_SHEET).pipe(V(n=>n?n.activeSheet$.pipe(V(r=>r?t.selectionMoveEnd$.pipe(V(t=>{if(!t.length||t.length>1)return B(!0);let i=t[0].range,a=e.get(fe).getContainerTableWithRange(n.getUnitId(),r.getSheetId(),i);if(!a)return B(!0);let o=a.getRange();return i.startRow===o.startRow?B(!0):B(!1)})):B(!0))):B(!0)))}const Wn={[Le.ORGANIZATION]:{[pn.id]:{order:0,menuItemFactory:Fn}},[Me.MAIN_AREA]:{[je.LAYOUT]:{[Nn]:{order:5,menuItemFactory:In,[se.id]:{order:1,menuItemFactory:Rn},[oe.id]:{order:2,menuItemFactory:zn}},[Pn]:{order:6,menuItemFactory:Ln,[le.id]:{order:1,menuItemFactory:Bn},[ce.id]:{order:2,menuItemFactory:Vn}}}}};let Gn=class extends r{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initComponents(),this._initMenu()}_initComponents(){[[Wt,gt],[Gt,jn],[Kt,Mn]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initMenu(){this._menuManagerService.mergeMenu(Wn)}};Gn=Z([X(0,u(Ae)),X(1,u(Pe))],Gn);let $=class extends h{constructor(e=gn,t,n,r,i){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=r,this._renderManagerService=i;let{menu:a,...o}=S({},gn,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(hn,o),this._initRegisterCommand()}onStarting(){C(this._injector,[[dn],[$t],[Gn],[_n],[An]])}onReady(){w(this._injector,[[dn],[$t],[Gn],[_n],[An]])}onRendered(){this._registerRenderModules()}_registerRenderModules(){let e=[[On],[kn]];this._config.hideAnchor!==!0&&e.push([yn]),e.forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(y.UNIVER_SHEET,e))})}_initRegisterCommand(){[fn,pn].forEach(e=>this._commandService.registerCommand(e))}};Y($,`pluginName`,`SHEET_TABLE_UI_PLUGIN`),Y($,`packageName`,Vt),Y($,`version`,Ht),Y($,`type`,y.UNIVER_SHEET),$=Z([n(he),X(1,u(d)),X(2,u(a)),X(3,o),X(4,T)],$);export{$ as UniverSheetsTableUIPlugin};
|
|
1
|
+
import { ColorKit, CommandType, DependentOn, Disposable, ErrorService, ICommandService, IConfigService, IContextService, IPermissionService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, Rectangle, RxDisposable, ThemeService, UniverInstanceType, VerticalAlign, cellToRange, merge, registerDependencies, touchDependencies } from "@univerjs/core";
|
|
2
|
+
import { IRenderManagerService, Rect, SHEET_VIEWPORT_KEY, Shape, convertTransformToOffsetX, convertTransformToOffsetY } from "@univerjs/engine-render";
|
|
3
|
+
import { AddSheetTableCommand, AddTableThemeCommand, DeleteSheetTableCommand, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SheetTableInsertColCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableButtonStateEnum, SheetsTableController, SheetsTableSortStateEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, customEmptyThemeWithBorderStyle, isConditionFilter, isManualTableFilter, processStyleWithBorderStyle } from "@univerjs/sheets-table";
|
|
4
|
+
import { SelectAllCommand, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetScrollManagerService, SheetSkeletonManagerService, getCoordByCell, getCurrentRangeDisable$, getSheetObject } from "@univerjs/sheets-ui";
|
|
5
|
+
import { BuiltInUIPart, ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IMenuManagerService, ISidebarService, IUIPartsService, MenuItemType, RibbonDataGroup, connectInjector, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
6
|
+
import { BehaviorSubject, Subject, debounceTime, distinctUntilChanged, filter, map, merge as merge$1, of, startWith, switchMap, takeUntil } from "rxjs";
|
|
7
|
+
import { Button, ButtonGroup, CascaderList, Checkbox, ColorPicker, DatePicker, DateRangePicker, Dropdown, Input, InputNumber, Segmented, Select, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
|
|
8
|
+
import { AscendingIcon, DeleteIcon, DescendingIcon, DropdownIcon, GridOutlineIcon, MoreDownIcon, PaintBucketDoubleIcon, RenameIcon, TableIcon } from "@univerjs/icons";
|
|
9
|
+
import { INTERCEPTOR_POINT, RangeThemeStyle, SetRangeThemeMutation, SetRangeValuesMutation, SetSelectionsOperation, SetVerticalTextAlignCommand, SheetInterceptorService, SheetRangeThemeModel, SheetsSelectionsService, WorkbookEditablePermission, WorkbookPermissionService, expandToContinuousRange, getPrimaryForRange, getSheetCommandTarget, isSingleCellSelection } from "@univerjs/sheets";
|
|
10
|
+
import { SortRangeCommand, SortType } from "@univerjs/sheets-sort";
|
|
11
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
12
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
|
|
14
|
+
import { RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
15
|
+
|
|
16
|
+
//#region package.json
|
|
17
|
+
var name = "@univerjs/sheets-table-ui";
|
|
18
|
+
var version = "0.21.0";
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/const.ts
|
|
22
|
+
/**
|
|
23
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
24
|
+
*
|
|
25
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
* you may not use this file except in compliance with the License.
|
|
27
|
+
* You may obtain a copy of the License at
|
|
28
|
+
*
|
|
29
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
32
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
|
+
* See the License for the specific language governing permissions and
|
|
35
|
+
* limitations under the License.
|
|
36
|
+
*/
|
|
37
|
+
const PLUGIN_NAME = "SHEET_TABLE_UI_PLUGIN";
|
|
38
|
+
const SHEETS_TABLE_FILTER_PANEL_OPENED_KEY = "SHEETS_TABLE_FILTER_PANEL_OPENED_KEY";
|
|
39
|
+
const UNIVER_SHEET_TABLE_FILTER_PANEL_ID = "UNIVER_SHEET_Table_FILTER_PANEL_ID";
|
|
40
|
+
const TABLE_TOOLBAR_BUTTON = "TABLE_TOOLBAR_BUTTON";
|
|
41
|
+
const TABLE_SELECTOR_DIALOG = "TABLE_SELECTOR_DIALOG";
|
|
42
|
+
const SHEET_TABLE_THEME_PANEL_ID = "SHEET_TABLE_THEME_PANEL_ID";
|
|
43
|
+
const SHEET_TABLE_THEME_PANEL = "SHEET_TABLE_THEME_PANEL";
|
|
44
|
+
const TABLE_CUSTOM_NAME_PREFIX = "table-custom-";
|
|
45
|
+
const TABLE_DEFAULT_NAME_PREFIX = "table-default-";
|
|
46
|
+
const TABLE_DEFAULT_BG_COLOR = "rgb(255, 255, 255)";
|
|
47
|
+
const TABLE_BORDER_NONE = "none";
|
|
48
|
+
const TABLE_BORDER_DEFAULT = "1px solid rgb(var(--grey-200))";
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/types.ts
|
|
52
|
+
/**
|
|
53
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
54
|
+
*
|
|
55
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
56
|
+
* you may not use this file except in compliance with the License.
|
|
57
|
+
* You may obtain a copy of the License at
|
|
58
|
+
*
|
|
59
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
60
|
+
*
|
|
61
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
62
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
63
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
64
|
+
* See the License for the specific language governing permissions and
|
|
65
|
+
* limitations under the License.
|
|
66
|
+
*/
|
|
67
|
+
let FilterByEnum = /* @__PURE__ */ function(FilterByEnum) {
|
|
68
|
+
FilterByEnum["Items"] = "items";
|
|
69
|
+
FilterByEnum["Condition"] = "condition";
|
|
70
|
+
return FilterByEnum;
|
|
71
|
+
}({});
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
|
|
75
|
+
function _typeof(o) {
|
|
76
|
+
"@babel/helpers - typeof";
|
|
77
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
78
|
+
return typeof o;
|
|
79
|
+
} : function(o) {
|
|
80
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
81
|
+
}, _typeof(o);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
|
|
86
|
+
function toPrimitive(t, r) {
|
|
87
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
88
|
+
var e = t[Symbol.toPrimitive];
|
|
89
|
+
if (void 0 !== e) {
|
|
90
|
+
var i = e.call(t, r || "default");
|
|
91
|
+
if ("object" != _typeof(i)) return i;
|
|
92
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
93
|
+
}
|
|
94
|
+
return ("string" === r ? String : Number)(t);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
|
|
99
|
+
function toPropertyKey(t) {
|
|
100
|
+
var i = toPrimitive(t, "string");
|
|
101
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
|
|
106
|
+
function _defineProperty(e, r, t) {
|
|
107
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
108
|
+
value: t,
|
|
109
|
+
enumerable: !0,
|
|
110
|
+
configurable: !0,
|
|
111
|
+
writable: !0
|
|
112
|
+
}) : e[r] = t, e;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
|
|
117
|
+
function __decorateParam(paramIndex, decorator) {
|
|
118
|
+
return function(target, key) {
|
|
119
|
+
decorator(target, key, paramIndex);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
|
|
125
|
+
function __decorate(decorators, target, key, desc) {
|
|
126
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
127
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
128
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
129
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/services/sheets-table-ui-service.ts
|
|
134
|
+
let SheetsTableUiService = class SheetsTableUiService extends Disposable {
|
|
135
|
+
constructor(_tableManager, _sheetTableService, _univerInstanceService, _commandService, _localeService) {
|
|
136
|
+
super();
|
|
137
|
+
this._tableManager = _tableManager;
|
|
138
|
+
this._sheetTableService = _sheetTableService;
|
|
139
|
+
this._univerInstanceService = _univerInstanceService;
|
|
140
|
+
this._commandService = _commandService;
|
|
141
|
+
this._localeService = _localeService;
|
|
142
|
+
_defineProperty(this, "_itemsCache", /* @__PURE__ */ new Map());
|
|
143
|
+
this._registerTableFilterChangeEvent();
|
|
144
|
+
}
|
|
145
|
+
_registerTableFilterChangeEvent() {
|
|
146
|
+
this._commandService.onCommandExecuted((command) => {
|
|
147
|
+
if (command.id === SetRangeValuesMutation.id) {
|
|
148
|
+
const { unitId, subUnitId, cellValue } = command.params;
|
|
149
|
+
const tables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);
|
|
150
|
+
if (!tables.length) return;
|
|
151
|
+
new ObjectMatrix(cellValue).forValue((row, col, _value) => {
|
|
152
|
+
const cellRange = cellToRange(row, col);
|
|
153
|
+
const overlapTable = tables.find((table) => {
|
|
154
|
+
const tableRange = table.getTableFilterRange();
|
|
155
|
+
return Rectangle.intersects(tableRange, cellRange);
|
|
156
|
+
});
|
|
157
|
+
if (overlapTable) {
|
|
158
|
+
const colIndex = col - overlapTable.getRange().startColumn;
|
|
159
|
+
this._itemsCache.delete(overlapTable.getId() + colIndex);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
} else if (command.id === SetSheetTableFilterCommand.id) {
|
|
163
|
+
const { unitId, tableId } = command.params;
|
|
164
|
+
const table = this._tableManager.getTable(unitId, tableId);
|
|
165
|
+
if (!table) return;
|
|
166
|
+
const subUnitId = table.getSubunitId();
|
|
167
|
+
this._tableManager.getTablesBySubunitId(unitId, subUnitId).forEach((table) => {
|
|
168
|
+
const range = table.getRange();
|
|
169
|
+
for (let i = range.startColumn; i <= range.endColumn; i++) this._itemsCache.delete(table.getId() + i);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
getTableFilterPanelInitProps(unitId, subUnitId, tableId, column) {
|
|
175
|
+
const table = this._tableManager.getTable(unitId, tableId);
|
|
176
|
+
const tableRange = table.getRange();
|
|
177
|
+
const tableFilter = table.getTableFilterColumn(column - tableRange.startColumn);
|
|
178
|
+
return {
|
|
179
|
+
unitId,
|
|
180
|
+
subUnitId,
|
|
181
|
+
tableFilter,
|
|
182
|
+
currentFilterBy: isConditionFilter(tableFilter) ? FilterByEnum.Condition : FilterByEnum.Items,
|
|
183
|
+
tableId,
|
|
184
|
+
columnIndex: column - tableRange.startColumn
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
getTableFilterCheckedItems(unitId, tableId, columnIndex) {
|
|
188
|
+
const table = this._tableManager.getTable(unitId, tableId);
|
|
189
|
+
const checkedItems = [];
|
|
190
|
+
if (table) {
|
|
191
|
+
const filter = table.getTableFilterColumn(columnIndex);
|
|
192
|
+
if (filter && isManualTableFilter(filter)) checkedItems.push(...filter.values);
|
|
193
|
+
}
|
|
194
|
+
return checkedItems;
|
|
195
|
+
}
|
|
196
|
+
setTableFilter(unitId, tableId, columnIndex, tableFilter) {
|
|
197
|
+
if (!this._tableManager.getTable(unitId, tableId)) return;
|
|
198
|
+
const setTableFilterParams = {
|
|
199
|
+
unitId,
|
|
200
|
+
tableId,
|
|
201
|
+
column: columnIndex,
|
|
202
|
+
tableFilter
|
|
203
|
+
};
|
|
204
|
+
this._commandService.executeCommand(SetSheetTableFilterCommand.id, setTableFilterParams);
|
|
205
|
+
}
|
|
206
|
+
getTableFilterItems(unitId, subUnitId, tableId, columnIndex) {
|
|
207
|
+
var _this$_univerInstance;
|
|
208
|
+
if (this._itemsCache.has(tableId + columnIndex)) return this._itemsCache.get(tableId + columnIndex) || {
|
|
209
|
+
data: [],
|
|
210
|
+
itemsCountMap: /* @__PURE__ */ new Map(),
|
|
211
|
+
allItemsCount: 0
|
|
212
|
+
};
|
|
213
|
+
const table = this._tableManager.getTable(unitId, tableId);
|
|
214
|
+
if (!table) return {
|
|
215
|
+
data: [],
|
|
216
|
+
itemsCountMap: /* @__PURE__ */ new Map(),
|
|
217
|
+
allItemsCount: 0
|
|
218
|
+
};
|
|
219
|
+
const { startRow, endRow, startColumn } = table.getTableFilterRange();
|
|
220
|
+
const column = startColumn + columnIndex;
|
|
221
|
+
const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
|
|
222
|
+
if (!worksheet) return {
|
|
223
|
+
data: [],
|
|
224
|
+
itemsCountMap: /* @__PURE__ */ new Map(),
|
|
225
|
+
allItemsCount: 0
|
|
226
|
+
};
|
|
227
|
+
const data = [];
|
|
228
|
+
const map = /* @__PURE__ */ new Map();
|
|
229
|
+
let allItemsCount = 0;
|
|
230
|
+
for (let row = startRow; row <= endRow; row++) {
|
|
231
|
+
if (worksheet.isRowFiltered(row)) continue;
|
|
232
|
+
let stringItem = this._sheetTableService.getCellValueWithConditionType(worksheet, row, column);
|
|
233
|
+
if (stringItem === void 0) stringItem = this._localeService.t("sheets-table.condition.empty");
|
|
234
|
+
if (!map.has(stringItem)) data.push({
|
|
235
|
+
title: stringItem,
|
|
236
|
+
key: `${column}_${row}`,
|
|
237
|
+
leaf: true
|
|
238
|
+
});
|
|
239
|
+
allItemsCount++;
|
|
240
|
+
map.set(stringItem, (map.get(stringItem) || 0) + 1);
|
|
241
|
+
}
|
|
242
|
+
this._itemsCache.set(tableId + columnIndex, {
|
|
243
|
+
data,
|
|
244
|
+
itemsCountMap: map,
|
|
245
|
+
allItemsCount
|
|
246
|
+
});
|
|
247
|
+
return {
|
|
248
|
+
data,
|
|
249
|
+
itemsCountMap: map,
|
|
250
|
+
allItemsCount
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
SheetsTableUiService = __decorate([
|
|
255
|
+
__decorateParam(0, Inject(TableManager)),
|
|
256
|
+
__decorateParam(1, Inject(SheetTableService)),
|
|
257
|
+
__decorateParam(2, Inject(IUniverInstanceService)),
|
|
258
|
+
__decorateParam(3, ICommandService),
|
|
259
|
+
__decorateParam(4, Inject(LocaleService))
|
|
260
|
+
], SheetsTableUiService);
|
|
261
|
+
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/views/components/type.ts
|
|
264
|
+
let ConditionSubComponentEnum = /* @__PURE__ */ function(ConditionSubComponentEnum) {
|
|
265
|
+
ConditionSubComponentEnum["DatePicker"] = "DatePicker";
|
|
266
|
+
ConditionSubComponentEnum["DateRange"] = "DateRange";
|
|
267
|
+
ConditionSubComponentEnum["Input"] = "Input";
|
|
268
|
+
ConditionSubComponentEnum["Inputs"] = "Inputs";
|
|
269
|
+
ConditionSubComponentEnum["Select"] = "Select";
|
|
270
|
+
ConditionSubComponentEnum["None"] = "None";
|
|
271
|
+
return ConditionSubComponentEnum;
|
|
272
|
+
}({});
|
|
273
|
+
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/views/components/util.ts
|
|
276
|
+
function getCascaderListOptions(injector) {
|
|
277
|
+
const t = injector.get(LocaleService).t;
|
|
278
|
+
return [
|
|
279
|
+
{
|
|
280
|
+
value: TableConditionTypeEnum.String,
|
|
281
|
+
label: t(`sheets-table.condition.${TableConditionTypeEnum.String}`),
|
|
282
|
+
children: [
|
|
283
|
+
{
|
|
284
|
+
value: TableStringCompareTypeEnum.Equal,
|
|
285
|
+
label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.Equal}`)
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
value: TableStringCompareTypeEnum.NotEqual,
|
|
289
|
+
label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.NotEqual}`)
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
value: TableStringCompareTypeEnum.Contains,
|
|
293
|
+
label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.Contains}`)
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
value: TableStringCompareTypeEnum.NotContains,
|
|
297
|
+
label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.NotContains}`)
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
value: TableStringCompareTypeEnum.StartsWith,
|
|
301
|
+
label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.StartsWith}`)
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
value: TableStringCompareTypeEnum.EndsWith,
|
|
305
|
+
label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.EndsWith}`)
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
value: TableConditionTypeEnum.Number,
|
|
311
|
+
label: t(`sheets-table.condition.${TableConditionTypeEnum.Number}`),
|
|
312
|
+
children: [
|
|
313
|
+
{
|
|
314
|
+
value: TableNumberCompareTypeEnum.Equal,
|
|
315
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.Equal}`)
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
value: TableNumberCompareTypeEnum.NotEqual,
|
|
319
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.NotEqual}`)
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
value: TableNumberCompareTypeEnum.GreaterThan,
|
|
323
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.GreaterThan}`)
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
value: TableNumberCompareTypeEnum.GreaterThanOrEqual,
|
|
327
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.GreaterThanOrEqual}`)
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
value: TableNumberCompareTypeEnum.LessThan,
|
|
331
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.LessThan}`)
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
value: TableNumberCompareTypeEnum.LessThanOrEqual,
|
|
335
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.LessThanOrEqual}`)
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
value: TableNumberCompareTypeEnum.Between,
|
|
339
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.Between}`)
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
value: TableNumberCompareTypeEnum.NotBetween,
|
|
343
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.NotBetween}`)
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
value: TableNumberCompareTypeEnum.Above,
|
|
347
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.Above}`)
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
value: TableNumberCompareTypeEnum.Below,
|
|
351
|
+
label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.Below}`)
|
|
352
|
+
}
|
|
353
|
+
]
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
value: TableConditionTypeEnum.Date,
|
|
357
|
+
label: t(`sheets-table.condition.${TableConditionTypeEnum.Date}`),
|
|
358
|
+
children: [
|
|
359
|
+
{
|
|
360
|
+
value: TableDateCompareTypeEnum.Equal,
|
|
361
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Equal}`)
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
value: TableDateCompareTypeEnum.NotEqual,
|
|
365
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NotEqual}`)
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
value: TableDateCompareTypeEnum.After,
|
|
369
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.After}`)
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
value: TableDateCompareTypeEnum.AfterOrEqual,
|
|
373
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.AfterOrEqual}`)
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
value: TableDateCompareTypeEnum.Before,
|
|
377
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Before}`)
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
value: TableDateCompareTypeEnum.BeforeOrEqual,
|
|
381
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.BeforeOrEqual}`)
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
value: TableDateCompareTypeEnum.Between,
|
|
385
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Between}`)
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
value: TableDateCompareTypeEnum.NotBetween,
|
|
389
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NotBetween}`)
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
value: TableDateCompareTypeEnum.Today,
|
|
393
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Today}`)
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
value: TableDateCompareTypeEnum.Yesterday,
|
|
397
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Yesterday}`)
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
value: TableDateCompareTypeEnum.Tomorrow,
|
|
401
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Tomorrow}`)
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
value: TableDateCompareTypeEnum.ThisWeek,
|
|
405
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.ThisWeek}`)
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
value: TableDateCompareTypeEnum.LastWeek,
|
|
409
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.LastWeek}`)
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
value: TableDateCompareTypeEnum.NextWeek,
|
|
413
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NextWeek}`)
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
value: TableDateCompareTypeEnum.ThisMonth,
|
|
417
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.ThisMonth}`)
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
value: TableDateCompareTypeEnum.LastMonth,
|
|
421
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.LastMonth}`)
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
value: TableDateCompareTypeEnum.NextMonth,
|
|
425
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NextMonth}`)
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
value: TableDateCompareTypeEnum.ThisYear,
|
|
429
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.ThisYear}`)
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
value: TableDateCompareTypeEnum.LastYear,
|
|
433
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.LastYear}`)
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
value: TableDateCompareTypeEnum.NextYear,
|
|
437
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NextYear}`)
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
value: TableDateCompareTypeEnum.Quarter,
|
|
441
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Quarter}`)
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
value: TableDateCompareTypeEnum.Month,
|
|
445
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Month}`)
|
|
446
|
+
}
|
|
447
|
+
]
|
|
448
|
+
}
|
|
449
|
+
];
|
|
450
|
+
}
|
|
451
|
+
function getConditionDateSelect(injector, dateType) {
|
|
452
|
+
if (!dateType) return [];
|
|
453
|
+
const t = injector.get(LocaleService).t;
|
|
454
|
+
switch (dateType) {
|
|
455
|
+
case TableDateCompareTypeEnum.Quarter: return [
|
|
456
|
+
{
|
|
457
|
+
value: TableDateCompareTypeEnum.Q1,
|
|
458
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Q1}`)
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
value: TableDateCompareTypeEnum.Q2,
|
|
462
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Q2}`)
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
value: TableDateCompareTypeEnum.Q3,
|
|
466
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Q3}`)
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
value: TableDateCompareTypeEnum.Q4,
|
|
470
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Q4}`)
|
|
471
|
+
}
|
|
472
|
+
];
|
|
473
|
+
case TableDateCompareTypeEnum.Month: return [
|
|
474
|
+
{
|
|
475
|
+
value: TableDateCompareTypeEnum.M1,
|
|
476
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M1}`)
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
value: TableDateCompareTypeEnum.M2,
|
|
480
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M2}`)
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
value: TableDateCompareTypeEnum.M3,
|
|
484
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M3}`)
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
value: TableDateCompareTypeEnum.M4,
|
|
488
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M4}`)
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
value: TableDateCompareTypeEnum.M5,
|
|
492
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M5}`)
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
value: TableDateCompareTypeEnum.M6,
|
|
496
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M6}`)
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
value: TableDateCompareTypeEnum.M7,
|
|
500
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M7}`)
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
value: TableDateCompareTypeEnum.M8,
|
|
504
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M8}`)
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
value: TableDateCompareTypeEnum.M9,
|
|
508
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M9}`)
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
value: TableDateCompareTypeEnum.M10,
|
|
512
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M10}`)
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
value: TableDateCompareTypeEnum.M11,
|
|
516
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M11}`)
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
value: TableDateCompareTypeEnum.M12,
|
|
520
|
+
label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M12}`)
|
|
521
|
+
}
|
|
522
|
+
];
|
|
523
|
+
default: return [];
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const datePickerSet = new Set([
|
|
527
|
+
TableDateCompareTypeEnum.Equal,
|
|
528
|
+
TableDateCompareTypeEnum.NotEqual,
|
|
529
|
+
TableDateCompareTypeEnum.After,
|
|
530
|
+
TableDateCompareTypeEnum.AfterOrEqual,
|
|
531
|
+
TableDateCompareTypeEnum.Before,
|
|
532
|
+
TableDateCompareTypeEnum.BeforeOrEqual
|
|
533
|
+
]);
|
|
534
|
+
function getSubComponentType(type, compare) {
|
|
535
|
+
if (!compare) return ConditionSubComponentEnum.None;
|
|
536
|
+
if (type === TableConditionTypeEnum.String) return ConditionSubComponentEnum.Input;
|
|
537
|
+
else if (type === TableConditionTypeEnum.Number) if (compare === TableNumberCompareTypeEnum.Between || compare === TableNumberCompareTypeEnum.NotBetween) return ConditionSubComponentEnum.Inputs;
|
|
538
|
+
else return ConditionSubComponentEnum.Input;
|
|
539
|
+
else if (type === TableConditionTypeEnum.Date) {
|
|
540
|
+
if (compare === TableDateCompareTypeEnum.Between || compare === TableDateCompareTypeEnum.NotBetween) return ConditionSubComponentEnum.DateRange;
|
|
541
|
+
else if (compare === TableDateCompareTypeEnum.Quarter || compare === TableDateCompareTypeEnum.Month) return ConditionSubComponentEnum.Select;
|
|
542
|
+
else if (datePickerSet.has(compare)) return ConditionSubComponentEnum.DatePicker;
|
|
543
|
+
return ConditionSubComponentEnum.None;
|
|
544
|
+
}
|
|
545
|
+
return ConditionSubComponentEnum.None;
|
|
546
|
+
}
|
|
547
|
+
function getInitConditionInfo(tableFilter) {
|
|
548
|
+
if (!tableFilter || tableFilter.filterType !== "condition") return {
|
|
549
|
+
type: TableConditionTypeEnum.String,
|
|
550
|
+
compareType: TableStringCompareTypeEnum.Equal,
|
|
551
|
+
info: {}
|
|
552
|
+
};
|
|
553
|
+
const filterInfo = tableFilter.filterInfo;
|
|
554
|
+
const { conditionType, compareType } = filterInfo;
|
|
555
|
+
if (conditionType === TableConditionTypeEnum.Date) if (compareType === TableDateCompareTypeEnum.Between || compareType === TableDateCompareTypeEnum.NotBetween) {
|
|
556
|
+
let dateRange;
|
|
557
|
+
if (Array.isArray(filterInfo.expectedValue)) dateRange = filterInfo.expectedValue.map((i) => typeof i === "string" ? new Date(i) : i);
|
|
558
|
+
return {
|
|
559
|
+
type: conditionType,
|
|
560
|
+
compare: compareType,
|
|
561
|
+
info: { dateRange }
|
|
562
|
+
};
|
|
563
|
+
} else if (compareType === TableDateCompareTypeEnum.Today || compareType === TableDateCompareTypeEnum.Yesterday || compareType === TableDateCompareTypeEnum.Tomorrow || compareType === TableDateCompareTypeEnum.ThisWeek || compareType === TableDateCompareTypeEnum.LastWeek || compareType === TableDateCompareTypeEnum.NextWeek || compareType === TableDateCompareTypeEnum.ThisMonth || compareType === TableDateCompareTypeEnum.LastMonth || compareType === TableDateCompareTypeEnum.NextMonth || compareType === TableDateCompareTypeEnum.ThisYear || compareType === TableDateCompareTypeEnum.LastYear || compareType === TableDateCompareTypeEnum.NextYear) return {
|
|
564
|
+
type: conditionType,
|
|
565
|
+
compare: compareType,
|
|
566
|
+
info: {}
|
|
567
|
+
};
|
|
568
|
+
else if (datePickerSet.has(compareType)) {
|
|
569
|
+
let date;
|
|
570
|
+
if (typeof filterInfo.expectedValue === "string") date = new Date(filterInfo.expectedValue);
|
|
571
|
+
else if (Array.isArray(filterInfo.expectedValue)) {
|
|
572
|
+
for (let i = 0; i < filterInfo.expectedValue.length; i++) if (typeof filterInfo.expectedValue[i] === "string") filterInfo.expectedValue[i] = new Date(filterInfo.expectedValue[i]);
|
|
573
|
+
}
|
|
574
|
+
return {
|
|
575
|
+
type: conditionType,
|
|
576
|
+
compare: compareType,
|
|
577
|
+
info: { date }
|
|
578
|
+
};
|
|
579
|
+
} else if (new Set([
|
|
580
|
+
TableDateCompareTypeEnum.Q1,
|
|
581
|
+
TableDateCompareTypeEnum.Q2,
|
|
582
|
+
TableDateCompareTypeEnum.Q3,
|
|
583
|
+
TableDateCompareTypeEnum.Q4
|
|
584
|
+
]).has(compareType)) return {
|
|
585
|
+
type: conditionType,
|
|
586
|
+
compare: TableDateCompareTypeEnum.Quarter,
|
|
587
|
+
info: { dateSelect: filterInfo.compareType }
|
|
588
|
+
};
|
|
589
|
+
else return {
|
|
590
|
+
type: conditionType,
|
|
591
|
+
compare: TableDateCompareTypeEnum.Month,
|
|
592
|
+
info: { dateSelect: filterInfo.compareType }
|
|
593
|
+
};
|
|
594
|
+
else if (conditionType === TableConditionTypeEnum.Number) if (compareType === TableNumberCompareTypeEnum.Between || compareType === TableNumberCompareTypeEnum.NotBetween) return {
|
|
595
|
+
type: conditionType,
|
|
596
|
+
compare: compareType,
|
|
597
|
+
info: { numberRange: filterInfo.expectedValue }
|
|
598
|
+
};
|
|
599
|
+
else return {
|
|
600
|
+
type: conditionType,
|
|
601
|
+
compare: compareType,
|
|
602
|
+
info: { number: filterInfo.expectedValue }
|
|
603
|
+
};
|
|
604
|
+
else if (conditionType === TableConditionTypeEnum.String) return {
|
|
605
|
+
type: conditionType,
|
|
606
|
+
compare: compareType,
|
|
607
|
+
info: { string: filterInfo.expectedValue }
|
|
608
|
+
};
|
|
609
|
+
return {
|
|
610
|
+
type: TableConditionTypeEnum.String,
|
|
611
|
+
compare: TableStringCompareTypeEnum.Equal,
|
|
612
|
+
info: {}
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/views/components/SheetTableConditionPanel.tsx
|
|
618
|
+
const SheetTableConditionPanel = (props) => {
|
|
619
|
+
var _conditionInfo$info$d, _conditionInfo$info$d2, _conditionInfo$info$d3, _conditionInfo$info$d4, _conditionInfo$info$d5, _conditionInfo$info$n, _conditionInfo$info$n3, _conditionInfo$info$d6;
|
|
620
|
+
const { conditionInfo, onChange } = props;
|
|
621
|
+
const localeService = useDependency(LocaleService);
|
|
622
|
+
const [conditionVisible, setConditionVisible] = useState(false);
|
|
623
|
+
const injector = useDependency(Injector);
|
|
624
|
+
const cascaderOptions = getCascaderListOptions(injector);
|
|
625
|
+
const handleConditionInfo = (info, type, compare) => {
|
|
626
|
+
onChange({
|
|
627
|
+
type: type !== null && type !== void 0 ? type : conditionInfo.type,
|
|
628
|
+
compare: compare !== null && compare !== void 0 ? compare : conditionInfo.compare,
|
|
629
|
+
info
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
const handleChange = (value) => {
|
|
633
|
+
var _ref;
|
|
634
|
+
const type = value[0];
|
|
635
|
+
const compare = value[1];
|
|
636
|
+
if (compare) setConditionVisible(false);
|
|
637
|
+
const info = {};
|
|
638
|
+
if (type === TableConditionTypeEnum.Date) if (compare === TableDateCompareTypeEnum.Quarter) info.dateSelect = TableDateCompareTypeEnum.Q1;
|
|
639
|
+
else if (compare === TableDateCompareTypeEnum.Month) info.dateSelect = TableDateCompareTypeEnum.M1;
|
|
640
|
+
else if (datePickerSet.has(compare)) info.date = /* @__PURE__ */ new Date();
|
|
641
|
+
else info.dateRange = [/* @__PURE__ */ new Date(), /* @__PURE__ */ new Date()];
|
|
642
|
+
else if (type === TableConditionTypeEnum.Number) info.number = 0;
|
|
643
|
+
else if (type === TableConditionTypeEnum.String) info.string = "";
|
|
644
|
+
handleConditionInfo(info, value[0], (_ref = value[1]) !== null && _ref !== void 0 ? _ref : TableStringCompareTypeEnum.Equal);
|
|
645
|
+
};
|
|
646
|
+
const subComponentType = getSubComponentType(conditionInfo.type, conditionInfo.compare);
|
|
647
|
+
let selectType = "";
|
|
648
|
+
if (conditionInfo.compare) selectType = `${localeService.t(`sheets-table.condition.${conditionInfo.type}`)} - ${localeService.t(`sheets-table.${conditionInfo.type}.compare.${conditionInfo.compare}`)}`;
|
|
649
|
+
else selectType = localeService.t(`sheets-table.condition.${conditionInfo.type}`);
|
|
650
|
+
const conditionDateOptions = getConditionDateSelect(injector, conditionInfo.compare);
|
|
651
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Dropdown, {
|
|
652
|
+
align: "start",
|
|
653
|
+
open: conditionVisible,
|
|
654
|
+
onOpenChange: setConditionVisible,
|
|
655
|
+
overlay: /* @__PURE__ */ jsx(CascaderList, {
|
|
656
|
+
value: [conditionInfo.type, conditionInfo.compare],
|
|
657
|
+
options: cascaderOptions,
|
|
658
|
+
onChange: handleChange,
|
|
659
|
+
contentClassName: "univer-flex-1",
|
|
660
|
+
wrapperClassName: "!univer-h-[150px]"
|
|
661
|
+
}),
|
|
662
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
663
|
+
className: clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-2 univer-text-sm univer-transition-colors univer-duration-200 hover:univer-border-primary-600 focus:univer-border-primary-600 focus:univer-outline-none focus:univer-ring-2 dark:!univer-bg-gray-700 dark:!univer-text-white", borderClassName),
|
|
664
|
+
children: [/* @__PURE__ */ jsx("span", { children: selectType }), /* @__PURE__ */ jsx(MoreDownIcon, {})]
|
|
665
|
+
})
|
|
666
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
667
|
+
className: "univer-mt-3 univer-w-full",
|
|
668
|
+
children: [
|
|
669
|
+
subComponentType === ConditionSubComponentEnum.Input && /* @__PURE__ */ jsx(Fragment, { children: conditionInfo.type === TableConditionTypeEnum.String ? /* @__PURE__ */ jsx(Input, {
|
|
670
|
+
className: "univer-w-full",
|
|
671
|
+
placeholder: "请输入",
|
|
672
|
+
value: conditionInfo.info.string,
|
|
673
|
+
onChange: (v) => handleConditionInfo({ string: v })
|
|
674
|
+
}) : /* @__PURE__ */ jsx(InputNumber, {
|
|
675
|
+
className: "univer-h-7 univer-w-full",
|
|
676
|
+
value: conditionInfo.info.number,
|
|
677
|
+
controls: false,
|
|
678
|
+
onChange: (v) => {
|
|
679
|
+
if (v !== null) handleConditionInfo({ number: v });
|
|
680
|
+
}
|
|
681
|
+
}) }),
|
|
682
|
+
!!(subComponentType === ConditionSubComponentEnum.DatePicker) && /* @__PURE__ */ jsx("div", {
|
|
683
|
+
id: "univer-table-date-picker-wrapper",
|
|
684
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
685
|
+
className: "univer-w-full",
|
|
686
|
+
value: (_conditionInfo$info$d = conditionInfo.info.date) !== null && _conditionInfo$info$d !== void 0 ? _conditionInfo$info$d : /* @__PURE__ */ new Date(),
|
|
687
|
+
onValueChange: (v) => handleConditionInfo({ date: v })
|
|
688
|
+
})
|
|
689
|
+
}),
|
|
690
|
+
!!(subComponentType === ConditionSubComponentEnum.DateRange) && /* @__PURE__ */ jsx("div", {
|
|
691
|
+
id: "univer-table-date-range-wrapper",
|
|
692
|
+
children: /* @__PURE__ */ jsx(DateRangePicker, {
|
|
693
|
+
className: "univer-w-full",
|
|
694
|
+
value: [(_conditionInfo$info$d2 = (_conditionInfo$info$d3 = conditionInfo.info.dateRange) === null || _conditionInfo$info$d3 === void 0 ? void 0 : _conditionInfo$info$d3[0]) !== null && _conditionInfo$info$d2 !== void 0 ? _conditionInfo$info$d2 : /* @__PURE__ */ new Date(), (_conditionInfo$info$d4 = (_conditionInfo$info$d5 = conditionInfo.info.dateRange) === null || _conditionInfo$info$d5 === void 0 ? void 0 : _conditionInfo$info$d5[1]) !== null && _conditionInfo$info$d4 !== void 0 ? _conditionInfo$info$d4 : /* @__PURE__ */ new Date()],
|
|
695
|
+
onValueChange: (v) => {
|
|
696
|
+
if (v) handleConditionInfo({ dateRange: v });
|
|
697
|
+
else handleConditionInfo({});
|
|
698
|
+
}
|
|
699
|
+
})
|
|
700
|
+
}),
|
|
701
|
+
subComponentType === ConditionSubComponentEnum.Inputs && /* @__PURE__ */ jsxs("div", {
|
|
702
|
+
className: "univer-flex univer-items-center univer-gap-2",
|
|
703
|
+
children: [
|
|
704
|
+
/* @__PURE__ */ jsx(InputNumber, {
|
|
705
|
+
className: "univer-w-full",
|
|
706
|
+
value: (_conditionInfo$info$n = conditionInfo.info.numberRange) === null || _conditionInfo$info$n === void 0 ? void 0 : _conditionInfo$info$n[0],
|
|
707
|
+
onChange: (v) => {
|
|
708
|
+
if (v !== null) {
|
|
709
|
+
var _conditionInfo$info$n2;
|
|
710
|
+
handleConditionInfo({ numberRange: [v, (_conditionInfo$info$n2 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n2 === void 0 ? void 0 : _conditionInfo$info$n2[1]] });
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
controls: false
|
|
714
|
+
}),
|
|
715
|
+
/* @__PURE__ */ jsx("span", { children: " - " }),
|
|
716
|
+
/* @__PURE__ */ jsx(InputNumber, {
|
|
717
|
+
className: "univer-w-full",
|
|
718
|
+
value: (_conditionInfo$info$n3 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n3 === void 0 ? void 0 : _conditionInfo$info$n3[1],
|
|
719
|
+
controls: false,
|
|
720
|
+
onChange: (v) => {
|
|
721
|
+
if (v !== null) {
|
|
722
|
+
var _conditionInfo$info$n4;
|
|
723
|
+
handleConditionInfo({ numberRange: [(_conditionInfo$info$n4 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n4 === void 0 ? void 0 : _conditionInfo$info$n4[0], v] });
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
})
|
|
727
|
+
]
|
|
728
|
+
}),
|
|
729
|
+
!!(subComponentType === ConditionSubComponentEnum.Select) && /* @__PURE__ */ jsx(Select, {
|
|
730
|
+
className: "univer-w-full",
|
|
731
|
+
value: (_conditionInfo$info$d6 = conditionInfo.info.dateSelect) !== null && _conditionInfo$info$d6 !== void 0 ? _conditionInfo$info$d6 : conditionDateOptions[0].value,
|
|
732
|
+
options: conditionDateOptions,
|
|
733
|
+
onChange: (v) => handleConditionInfo({ dateSelect: v })
|
|
734
|
+
})
|
|
735
|
+
]
|
|
736
|
+
})] });
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/views/components/SheetTableItemsFilterPanel.tsx
|
|
741
|
+
const getCheckedCount = (map) => {
|
|
742
|
+
let count = 0;
|
|
743
|
+
map.forEach((value) => {
|
|
744
|
+
count += value;
|
|
745
|
+
});
|
|
746
|
+
return count;
|
|
747
|
+
};
|
|
748
|
+
function SheetTableItemsFilterPanel(props) {
|
|
749
|
+
const { unitId, tableId, subUnitId, columnIndex, checkedItemSet, setCheckedItemSet, tableFilter } = props;
|
|
750
|
+
const localeService = useDependency(LocaleService);
|
|
751
|
+
const { data: items, itemsCountMap, allItemsCount } = useDependency(SheetsTableUiService).getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
752
|
+
const [allChecked, setAllChecked] = useState(tableFilter === void 0 ? true : checkedItemSet.size === itemsCountMap.size);
|
|
753
|
+
const [checkedCount, setCheckedCount] = useState(allChecked ? allItemsCount : getCheckedCount(itemsCountMap));
|
|
754
|
+
const indeterminate = !allChecked && checkedItemSet.size > 0;
|
|
755
|
+
const [searchText, setSearchText] = useState("");
|
|
756
|
+
const displayItems = useMemo(() => {
|
|
757
|
+
return searchText ? items.filter((item) => {
|
|
758
|
+
return String(item.title).toLowerCase().includes(searchText.toLowerCase());
|
|
759
|
+
}) : items;
|
|
760
|
+
}, [searchText, items]);
|
|
761
|
+
const onCheckAllToggled = useCallback(() => {
|
|
762
|
+
if (allChecked) {
|
|
763
|
+
checkedItemSet.clear();
|
|
764
|
+
setCheckedItemSet(new Set(checkedItemSet));
|
|
765
|
+
setAllChecked(false);
|
|
766
|
+
} else {
|
|
767
|
+
displayItems.forEach((item) => {
|
|
768
|
+
checkedItemSet.add(item.title);
|
|
769
|
+
});
|
|
770
|
+
setCheckedItemSet(new Set(checkedItemSet));
|
|
771
|
+
setAllChecked(true);
|
|
772
|
+
}
|
|
773
|
+
}, [allChecked]);
|
|
774
|
+
const onSearchValueChange = useCallback((str) => {
|
|
775
|
+
if (str === "") {
|
|
776
|
+
setAllChecked(true);
|
|
777
|
+
items.forEach((item) => {
|
|
778
|
+
checkedItemSet.add(item.title);
|
|
779
|
+
});
|
|
780
|
+
setCheckedCount(allItemsCount);
|
|
781
|
+
} else {
|
|
782
|
+
checkedItemSet.clear();
|
|
783
|
+
setAllChecked(false);
|
|
784
|
+
setCheckedCount(0);
|
|
785
|
+
}
|
|
786
|
+
setSearchText(str);
|
|
787
|
+
}, []);
|
|
788
|
+
const onCheckItemToggled = (key) => {
|
|
789
|
+
if (allChecked) {
|
|
790
|
+
setAllChecked(false);
|
|
791
|
+
const newSet = /* @__PURE__ */ new Set();
|
|
792
|
+
for (const { title } of items) if (key !== title) newSet.add(title);
|
|
793
|
+
setCheckedCount(allItemsCount - itemsCountMap.get(key));
|
|
794
|
+
setCheckedItemSet(newSet);
|
|
795
|
+
} else {
|
|
796
|
+
if (checkedItemSet.has(key)) {
|
|
797
|
+
checkedItemSet.delete(key);
|
|
798
|
+
setCheckedCount(checkedCount - itemsCountMap.get(key));
|
|
799
|
+
} else {
|
|
800
|
+
checkedItemSet.add(key);
|
|
801
|
+
setCheckedCount(checkedCount + itemsCountMap.get(key));
|
|
802
|
+
}
|
|
803
|
+
setCheckedItemSet(new Set(checkedItemSet));
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
807
|
+
className: "univer-flex univer-h-full univer-flex-col",
|
|
808
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
809
|
+
autoFocus: true,
|
|
810
|
+
value: searchText,
|
|
811
|
+
placeholder: localeService.t("sheets-table.filter.search-placeholder"),
|
|
812
|
+
onChange: onSearchValueChange
|
|
813
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
814
|
+
className: clsx("univer-mt-2 univer-box-border univer-flex univer-h-[180px] univer-max-h-[180px] univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-py-1.5 univer-pl-2", borderClassName),
|
|
815
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
816
|
+
className: clsx("univer-h-40 univer-overflow-y-auto univer-py-1 univer-pl-2", scrollbarClassName),
|
|
817
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
818
|
+
className: "univer-h-full",
|
|
819
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
820
|
+
className: "univer-flex univer-items-center univer-px-2 univer-py-1",
|
|
821
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
822
|
+
indeterminate,
|
|
823
|
+
disabled: items.length === 0,
|
|
824
|
+
checked: allChecked,
|
|
825
|
+
onChange: onCheckAllToggled,
|
|
826
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
827
|
+
className: "univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm",
|
|
828
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
829
|
+
className: "univer-inline-block univer-truncate",
|
|
830
|
+
children: `${localeService.t("sheets-table.filter.select-all")}`
|
|
831
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
832
|
+
className: "univer-ml univer-text-gray-400",
|
|
833
|
+
children: `(${checkedCount}/${searchText ? displayItems.length : allItemsCount})`
|
|
834
|
+
})]
|
|
835
|
+
})
|
|
836
|
+
})
|
|
837
|
+
}), displayItems.map((item) => {
|
|
838
|
+
return /* @__PURE__ */ jsx("div", {
|
|
839
|
+
className: "univer-flex univer-items-center univer-px-2 univer-py-1",
|
|
840
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
841
|
+
checked: allChecked || checkedItemSet.has(item.title),
|
|
842
|
+
onChange: () => {
|
|
843
|
+
onCheckItemToggled(item.title);
|
|
844
|
+
},
|
|
845
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
846
|
+
className: "univer-flex univer-h-5 univer-flex-1 univer-text-sm",
|
|
847
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
848
|
+
className: "univer-inline-block univer-truncate",
|
|
849
|
+
children: item.title
|
|
850
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
851
|
+
className: "univer-ml-1 univer-text-gray-400",
|
|
852
|
+
children: `(${itemsCountMap.get(item.title) || 0})`
|
|
853
|
+
})]
|
|
854
|
+
})
|
|
855
|
+
})
|
|
856
|
+
}, item.key);
|
|
857
|
+
})]
|
|
858
|
+
})
|
|
859
|
+
})
|
|
860
|
+
})]
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
//#endregion
|
|
865
|
+
//#region src/views/components/SheetTableFilterPanel.tsx
|
|
866
|
+
function SheetTableFilterPanel() {
|
|
867
|
+
var _permissionService$ge;
|
|
868
|
+
const localeService = useDependency(LocaleService);
|
|
869
|
+
const filterByItems = useFilterByOptions(localeService);
|
|
870
|
+
const tableUiService = useDependency(SheetsTableUiService);
|
|
871
|
+
const tableManager = useDependency(TableManager);
|
|
872
|
+
const commandService = useDependency(ICommandService);
|
|
873
|
+
const permissionService = useDependency(IPermissionService);
|
|
874
|
+
const sheetsTableComponentController = useDependency(SheetsTableComponentController);
|
|
875
|
+
const tableFilterPanelInfo = sheetsTableComponentController.getCurrentTableFilterInfo();
|
|
876
|
+
const props = tableUiService.getTableFilterPanelInitProps(tableFilterPanelInfo.unitId, tableFilterPanelInfo.subUnitId, tableFilterPanelInfo.tableId, tableFilterPanelInfo.column);
|
|
877
|
+
const { unitId, subUnitId, tableId, tableFilter, currentFilterBy, columnIndex } = props;
|
|
878
|
+
const { data } = tableUiService.getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
879
|
+
const checkedItems = tableUiService.getTableFilterCheckedItems(unitId, tableId, columnIndex);
|
|
880
|
+
const [checkedItemSet, setCheckedItemSet] = useState(new Set(checkedItems));
|
|
881
|
+
const [filterBy, setFilterBy] = useState(currentFilterBy || FilterByEnum.Items);
|
|
882
|
+
const [conditionInfo, setConditionInfo] = useState(() => {
|
|
883
|
+
const tableFilter = props.tableFilter;
|
|
884
|
+
return getInitConditionInfo(tableFilter);
|
|
885
|
+
});
|
|
886
|
+
const table = tableManager.getTable(unitId, tableId);
|
|
887
|
+
if (!table) return null;
|
|
888
|
+
const tableFilters = table.getTableFilters();
|
|
889
|
+
const sortState = tableFilters.getSortState();
|
|
890
|
+
sortState.columnIndex === columnIndex && (sortState.sortState, SheetsTableSortStateEnum.Asc);
|
|
891
|
+
sortState.columnIndex === columnIndex && (sortState.sortState, SheetsTableSortStateEnum.Desc);
|
|
892
|
+
const closeDialog = () => {
|
|
893
|
+
sheetsTableComponentController.closeFilterPanel();
|
|
894
|
+
};
|
|
895
|
+
const onCancel = () => {
|
|
896
|
+
closeDialog();
|
|
897
|
+
};
|
|
898
|
+
const applySort = (asc) => {
|
|
899
|
+
const range = table.getTableFilterRange();
|
|
900
|
+
commandService.executeCommand(SortRangeCommand.id, {
|
|
901
|
+
unitId,
|
|
902
|
+
subUnitId,
|
|
903
|
+
range,
|
|
904
|
+
orderRules: [{
|
|
905
|
+
colIndex: columnIndex + range.startColumn,
|
|
906
|
+
type: asc ? SortType.ASC : SortType.DESC
|
|
907
|
+
}],
|
|
908
|
+
hasTitle: false
|
|
909
|
+
});
|
|
910
|
+
tableFilters.setSortState(columnIndex, asc ? SheetsTableSortStateEnum.Asc : SheetsTableSortStateEnum.Desc);
|
|
911
|
+
closeDialog();
|
|
912
|
+
};
|
|
913
|
+
const onApply = () => {
|
|
914
|
+
if (filterBy === FilterByEnum.Items) {
|
|
915
|
+
const filteredItems = [];
|
|
916
|
+
for (const itemInfo of data) if (checkedItemSet.has(itemInfo.title)) filteredItems.push(itemInfo.title);
|
|
917
|
+
const originFilter = table.getTableFilterColumn(columnIndex);
|
|
918
|
+
if (originFilter) {
|
|
919
|
+
if (originFilter.values.join(",") === filteredItems.join(",")) {
|
|
920
|
+
closeDialog();
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
} else if (filteredItems.length === 0) {
|
|
924
|
+
closeDialog();
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
const tableFilter = {
|
|
928
|
+
filterType: TableColumnFilterTypeEnum.manual,
|
|
929
|
+
values: filteredItems
|
|
930
|
+
};
|
|
931
|
+
tableUiService.setTableFilter(unitId, tableId, columnIndex, tableFilter);
|
|
932
|
+
} else {
|
|
933
|
+
let filterInfo;
|
|
934
|
+
if (conditionInfo.compare === TableDateCompareTypeEnum.Quarter || conditionInfo.compare === TableDateCompareTypeEnum.Month) filterInfo = {
|
|
935
|
+
conditionType: conditionInfo.type,
|
|
936
|
+
compareType: Object.values(conditionInfo.info)[0]
|
|
937
|
+
};
|
|
938
|
+
else filterInfo = {
|
|
939
|
+
conditionType: conditionInfo.type,
|
|
940
|
+
compareType: conditionInfo.compare,
|
|
941
|
+
expectedValue: Object.values(conditionInfo.info)[0]
|
|
942
|
+
};
|
|
943
|
+
const tableFilter = {
|
|
944
|
+
filterType: TableColumnFilterTypeEnum.condition,
|
|
945
|
+
filterInfo
|
|
946
|
+
};
|
|
947
|
+
tableUiService.setTableFilter(unitId, tableId, columnIndex, tableFilter);
|
|
948
|
+
}
|
|
949
|
+
closeDialog();
|
|
950
|
+
};
|
|
951
|
+
const onClearFilter = () => {
|
|
952
|
+
tableUiService.setTableFilter(unitId, tableId, columnIndex, void 0);
|
|
953
|
+
closeDialog();
|
|
954
|
+
};
|
|
955
|
+
const workbookEditableId = new WorkbookEditablePermission(unitId).id;
|
|
956
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
957
|
+
className: "univer-box-border univer-flex univer-min-w-[312px] univer-flex-col univer-rounded-[10px] univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
958
|
+
children: [
|
|
959
|
+
((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */ jsx("div", {
|
|
960
|
+
className: "univer-mb-3 univer-flex",
|
|
961
|
+
children: /* @__PURE__ */ jsxs(ButtonGroup, {
|
|
962
|
+
className: "univer-mb-3 !univer-flex univer-w-full",
|
|
963
|
+
children: [/* @__PURE__ */ jsxs(Button, {
|
|
964
|
+
className: "univer-w-1/2",
|
|
965
|
+
onClick: () => applySort(true),
|
|
966
|
+
children: [/* @__PURE__ */ jsx(AscendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-sort.general.sort-asc")]
|
|
967
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
968
|
+
className: "univer-w-1/2",
|
|
969
|
+
onClick: () => applySort(false),
|
|
970
|
+
children: [/* @__PURE__ */ jsx(DescendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-sort.general.sort-desc")]
|
|
971
|
+
})]
|
|
972
|
+
})
|
|
973
|
+
}),
|
|
974
|
+
/* @__PURE__ */ jsx("div", {
|
|
975
|
+
className: "univer-w-full",
|
|
976
|
+
children: /* @__PURE__ */ jsx(Segmented, {
|
|
977
|
+
value: filterBy,
|
|
978
|
+
items: filterByItems,
|
|
979
|
+
onChange: (value) => setFilterBy(value)
|
|
980
|
+
})
|
|
981
|
+
}),
|
|
982
|
+
/* @__PURE__ */ jsx("div", {
|
|
983
|
+
className: "univer-z-10 univer-h-60",
|
|
984
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
985
|
+
className: "univer-mt-3 univer-size-full",
|
|
986
|
+
children: filterBy === FilterByEnum.Items ? /* @__PURE__ */ jsx(SheetTableItemsFilterPanel, {
|
|
987
|
+
tableFilter,
|
|
988
|
+
unitId,
|
|
989
|
+
subUnitId,
|
|
990
|
+
tableId,
|
|
991
|
+
columnIndex,
|
|
992
|
+
checkedItemSet,
|
|
993
|
+
setCheckedItemSet
|
|
994
|
+
}) : /* @__PURE__ */ jsx(SheetTableConditionPanel, {
|
|
995
|
+
tableFilter,
|
|
996
|
+
unitId,
|
|
997
|
+
subUnitId,
|
|
998
|
+
tableId,
|
|
999
|
+
columnIndex,
|
|
1000
|
+
conditionInfo,
|
|
1001
|
+
onChange: setConditionInfo
|
|
1002
|
+
})
|
|
1003
|
+
})
|
|
1004
|
+
}),
|
|
1005
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1006
|
+
className: "univer-flex-wrap-nowrap univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-justify-between univer-gap-6 univer-overflow-hidden",
|
|
1007
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1008
|
+
disabled: tableFilter === void 0,
|
|
1009
|
+
onClick: onClearFilter,
|
|
1010
|
+
children: localeService.t("sheets-table.filter.clear-filter")
|
|
1011
|
+
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Button, {
|
|
1012
|
+
className: "univer-mr-2",
|
|
1013
|
+
onClick: onCancel,
|
|
1014
|
+
children: localeService.t("sheets-table.filter.cancel")
|
|
1015
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1016
|
+
variant: "primary",
|
|
1017
|
+
onClick: onApply,
|
|
1018
|
+
children: localeService.t("sheets-table.filter.confirm")
|
|
1019
|
+
})] })]
|
|
1020
|
+
})
|
|
1021
|
+
]
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
function useFilterByOptions(localeService) {
|
|
1025
|
+
return useMemo(() => [{
|
|
1026
|
+
label: localeService.t("sheets-table.filter.by-values"),
|
|
1027
|
+
value: FilterByEnum.Items
|
|
1028
|
+
}, {
|
|
1029
|
+
label: localeService.t("sheets-table.filter.by-conditions"),
|
|
1030
|
+
value: FilterByEnum.Condition
|
|
1031
|
+
}], [localeService.getCurrentLocale(), localeService]);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
//#endregion
|
|
1035
|
+
//#region src/controllers/sheet-table-component.controller.ts
|
|
1036
|
+
let SheetsTableComponentController = class SheetsTableComponentController extends Disposable {
|
|
1037
|
+
constructor(_componentManager, _contextService, _sheetCanvasPopupService, _dialogService) {
|
|
1038
|
+
super();
|
|
1039
|
+
this._componentManager = _componentManager;
|
|
1040
|
+
this._contextService = _contextService;
|
|
1041
|
+
this._sheetCanvasPopupService = _sheetCanvasPopupService;
|
|
1042
|
+
this._dialogService = _dialogService;
|
|
1043
|
+
_defineProperty(this, "_popupDisposable", void 0);
|
|
1044
|
+
_defineProperty(this, "_currentTableFilterInfo", null);
|
|
1045
|
+
this._initComponents();
|
|
1046
|
+
this._initUIPopup();
|
|
1047
|
+
}
|
|
1048
|
+
setCurrentTableFilterInfo(info) {
|
|
1049
|
+
this._currentTableFilterInfo = info;
|
|
1050
|
+
}
|
|
1051
|
+
clearCurrentTableFilterInfo() {
|
|
1052
|
+
this._currentTableFilterInfo = null;
|
|
1053
|
+
}
|
|
1054
|
+
getCurrentTableFilterInfo() {
|
|
1055
|
+
return this._currentTableFilterInfo;
|
|
1056
|
+
}
|
|
1057
|
+
_initComponents() {
|
|
1058
|
+
[[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel]].forEach(([key, comp]) => {
|
|
1059
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
_initUIPopup() {
|
|
1063
|
+
this.disposeWithMe(this._contextService.subscribeContextValue$(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY).pipe(startWith(void 0), distinctUntilChanged()).subscribe((open) => {
|
|
1064
|
+
if (open) this._openFilterPopup();
|
|
1065
|
+
else if (open === false) this._closeFilterPopup();
|
|
1066
|
+
}));
|
|
1067
|
+
}
|
|
1068
|
+
closeFilterPanel() {
|
|
1069
|
+
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);
|
|
1070
|
+
}
|
|
1071
|
+
_openFilterPopup() {
|
|
1072
|
+
const currentFilterModel = this._currentTableFilterInfo;
|
|
1073
|
+
if (!currentFilterModel) throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");
|
|
1074
|
+
const { row: startRow, column: col } = currentFilterModel;
|
|
1075
|
+
this._popupDisposable = this._sheetCanvasPopupService.attachPopupToCell(startRow, col, {
|
|
1076
|
+
componentKey: SHEETS_TABLE_FILTER_PANEL_OPENED_KEY,
|
|
1077
|
+
direction: "horizontal",
|
|
1078
|
+
onClickOutside: () => {
|
|
1079
|
+
this._dialogService.close(UNIVER_SHEET_TABLE_FILTER_PANEL_ID);
|
|
1080
|
+
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);
|
|
1081
|
+
},
|
|
1082
|
+
offset: [5, 0],
|
|
1083
|
+
portal: true
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
_closeFilterPopup() {
|
|
1087
|
+
var _this$_popupDisposabl;
|
|
1088
|
+
(_this$_popupDisposabl = this._popupDisposable) === null || _this$_popupDisposabl === void 0 || _this$_popupDisposabl.dispose();
|
|
1089
|
+
this._popupDisposable = null;
|
|
1090
|
+
this.clearCurrentTableFilterInfo();
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
SheetsTableComponentController = __decorate([
|
|
1094
|
+
__decorateParam(0, Inject(ComponentManager)),
|
|
1095
|
+
__decorateParam(1, IContextService),
|
|
1096
|
+
__decorateParam(2, Inject(SheetCanvasPopManagerService)),
|
|
1097
|
+
__decorateParam(3, Inject(IDialogService))
|
|
1098
|
+
], SheetsTableComponentController);
|
|
1099
|
+
|
|
1100
|
+
//#endregion
|
|
1101
|
+
//#region src/commands/operations/open-table-filter-dialog.opration.ts
|
|
1102
|
+
const OpenTableFilterPanelOperation = {
|
|
1103
|
+
type: CommandType.OPERATION,
|
|
1104
|
+
id: "sheet.operation.open-table-filter-panel",
|
|
1105
|
+
async handler(accessor, params) {
|
|
1106
|
+
if (!params) return false;
|
|
1107
|
+
const { row, col, unitId, subUnitId, tableId } = params;
|
|
1108
|
+
const tableManager = accessor.get(TableManager);
|
|
1109
|
+
const contextService = accessor.get(IContextService);
|
|
1110
|
+
const sheetsTableComponentController = accessor.get(SheetsTableComponentController);
|
|
1111
|
+
if (!tableManager.getTable(unitId, tableId)) return false;
|
|
1112
|
+
if (!contextService.getContextValue("SHEETS_TABLE_FILTER_PANEL_OPENED_KEY")) {
|
|
1113
|
+
sheetsTableComponentController.setCurrentTableFilterInfo({
|
|
1114
|
+
unitId,
|
|
1115
|
+
subUnitId,
|
|
1116
|
+
row,
|
|
1117
|
+
tableId,
|
|
1118
|
+
column: col
|
|
1119
|
+
});
|
|
1120
|
+
contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, true);
|
|
1121
|
+
}
|
|
1122
|
+
return true;
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
//#endregion
|
|
1127
|
+
//#region src/commands/operations/open-table-selector.operation.ts
|
|
1128
|
+
const OpenTableSelectorOperation = {
|
|
1129
|
+
type: CommandType.OPERATION,
|
|
1130
|
+
id: "sheet.operation.open-table-selector",
|
|
1131
|
+
async handler(accessor) {
|
|
1132
|
+
var _lastSelection$range;
|
|
1133
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
1134
|
+
const commandService = accessor.get(ICommandService);
|
|
1135
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
1136
|
+
if (!target) return false;
|
|
1137
|
+
const { unitId, subUnitId, worksheet } = target;
|
|
1138
|
+
const lastSelection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
1139
|
+
const range = (_lastSelection$range = lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.range) !== null && _lastSelection$range !== void 0 ? _lastSelection$range : {
|
|
1140
|
+
startRow: 0,
|
|
1141
|
+
endRow: 0,
|
|
1142
|
+
startColumn: 0,
|
|
1143
|
+
endColumn: 0
|
|
1144
|
+
};
|
|
1145
|
+
const rangeInfo = await openRangeSelector(accessor, unitId, subUnitId, isSingleCellSelection(lastSelection) ? expandToContinuousRange(range, {
|
|
1146
|
+
up: true,
|
|
1147
|
+
left: true,
|
|
1148
|
+
right: true,
|
|
1149
|
+
down: true
|
|
1150
|
+
}, worksheet) : range);
|
|
1151
|
+
if (!rangeInfo) return false;
|
|
1152
|
+
commandService.executeCommand(AddSheetTableCommand.id, { ...rangeInfo });
|
|
1153
|
+
return true;
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
async function openRangeSelector(accessor, unitId, subUnitId, range, tableId) {
|
|
1157
|
+
const dialogService = accessor.get(IDialogService);
|
|
1158
|
+
const localeService = accessor.get(LocaleService);
|
|
1159
|
+
return new Promise((resolve) => {
|
|
1160
|
+
const dialogProps = {
|
|
1161
|
+
unitId,
|
|
1162
|
+
subUnitId,
|
|
1163
|
+
range,
|
|
1164
|
+
tableId,
|
|
1165
|
+
onConfirm: (info) => {
|
|
1166
|
+
resolve(info);
|
|
1167
|
+
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
1168
|
+
},
|
|
1169
|
+
onCancel: () => {
|
|
1170
|
+
resolve(null);
|
|
1171
|
+
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
dialogService.open({
|
|
1175
|
+
id: TABLE_SELECTOR_DIALOG,
|
|
1176
|
+
title: { title: localeService.t("sheets-table.selectRange") },
|
|
1177
|
+
draggable: true,
|
|
1178
|
+
destroyOnClose: true,
|
|
1179
|
+
mask: false,
|
|
1180
|
+
maskClosable: false,
|
|
1181
|
+
children: { label: {
|
|
1182
|
+
name: TABLE_SELECTOR_DIALOG,
|
|
1183
|
+
props: dialogProps
|
|
1184
|
+
} },
|
|
1185
|
+
width: 300,
|
|
1186
|
+
onClose: () => {
|
|
1187
|
+
resolve(null);
|
|
1188
|
+
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
//#endregion
|
|
1195
|
+
//#region src/config/config.ts
|
|
1196
|
+
const SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY = "sheets-table-ui.config";
|
|
1197
|
+
const configSymbol = Symbol(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY);
|
|
1198
|
+
const defaultPluginConfig = {
|
|
1199
|
+
anchorHeight: 24,
|
|
1200
|
+
anchorBackgroundColor: "rgb(134,139,156)"
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
//#endregion
|
|
1204
|
+
//#region src/controllers/sheet-table-theme-ui.controller.ts
|
|
1205
|
+
let SheetTableThemeUIController = class SheetTableThemeUIController extends Disposable {
|
|
1206
|
+
constructor(_commandService) {
|
|
1207
|
+
super();
|
|
1208
|
+
this._commandService = _commandService;
|
|
1209
|
+
_defineProperty(this, "_refreshTable", new Subject());
|
|
1210
|
+
_defineProperty(this, "refreshTable$", this._refreshTable.asObservable());
|
|
1211
|
+
this._initListener();
|
|
1212
|
+
}
|
|
1213
|
+
_initListener() {
|
|
1214
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
1215
|
+
if (command.id === SetRangeThemeMutation.id) {
|
|
1216
|
+
const { styleName } = command.params;
|
|
1217
|
+
if (styleName.startsWith(SHEET_TABLE_CUSTOM_THEME_PREFIX)) this._refreshTable.next(Math.random());
|
|
1218
|
+
}
|
|
1219
|
+
}));
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
SheetTableThemeUIController = __decorate([__decorateParam(0, Inject(ICommandService))], SheetTableThemeUIController);
|
|
1223
|
+
|
|
1224
|
+
//#endregion
|
|
1225
|
+
//#region src/views/components/SheetTableAnchor.tsx
|
|
1226
|
+
const SheetTableAnchor = () => {
|
|
1227
|
+
var _tableConfig$anchorHe, _tableConfig$anchorBa;
|
|
1228
|
+
const [inputFocusId, setInputFocusId] = useState("");
|
|
1229
|
+
const [inputValue, setInputValue] = useState("");
|
|
1230
|
+
const sidebarService = useDependency(ISidebarService);
|
|
1231
|
+
const [openStates, setOpenStates] = useState({});
|
|
1232
|
+
const injector = useDependency(Injector);
|
|
1233
|
+
const anchorPosition = useObservable(useDependency(SheetTableAnchorController).anchorPosition$);
|
|
1234
|
+
const commandService = useDependency(ICommandService);
|
|
1235
|
+
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
1236
|
+
const workbookPermissionInitState = useObservable(useDependency(WorkbookPermissionService).unitPermissionInitStateChange$, false);
|
|
1237
|
+
const tableManager = useDependency(TableManager);
|
|
1238
|
+
const rangeThemeModel = useDependency(SheetRangeThemeModel);
|
|
1239
|
+
const tableRefresh$ = useObservable(useDependency(SheetTableThemeUIController).refreshTable$);
|
|
1240
|
+
const localeService = useDependency(LocaleService);
|
|
1241
|
+
const selections = useObservable(useDependency(SheetsSelectionsService).selectionChanged$, [{
|
|
1242
|
+
range: cellToRange(0, 0),
|
|
1243
|
+
primary: null
|
|
1244
|
+
}]);
|
|
1245
|
+
const [, setRefresh] = useState(Math.random());
|
|
1246
|
+
const tableConfig = useDependency(IConfigService).getConfig(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY);
|
|
1247
|
+
const anchorHeight = (_tableConfig$anchorHe = tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.anchorHeight) !== null && _tableConfig$anchorHe !== void 0 ? _tableConfig$anchorHe : 24;
|
|
1248
|
+
const anchorBackgroundColor = (_tableConfig$anchorBa = tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.anchorBackgroundColor) !== null && _tableConfig$anchorBa !== void 0 ? _tableConfig$anchorBa : "rgb(53,91,183)";
|
|
1249
|
+
const updateOpenState = (tableId, isOpen) => {
|
|
1250
|
+
setOpenStates((prev) => ({
|
|
1251
|
+
...prev,
|
|
1252
|
+
[tableId]: isOpen
|
|
1253
|
+
}));
|
|
1254
|
+
};
|
|
1255
|
+
useEffect(() => {
|
|
1256
|
+
setRefresh(Math.random());
|
|
1257
|
+
}, [tableRefresh$]);
|
|
1258
|
+
if (!(anchorPosition === null || anchorPosition === void 0 ? void 0 : anchorPosition.length)) return null;
|
|
1259
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
1260
|
+
if (!target) return null;
|
|
1261
|
+
const { unitId, subUnitId } = target;
|
|
1262
|
+
const handleChangeTableName = (tableId, name) => {
|
|
1263
|
+
var _tableManager$getTabl;
|
|
1264
|
+
if (((_tableManager$getTabl = tableManager.getTableById(unitId, tableId)) === null || _tableManager$getTabl === void 0 ? void 0 : _tableManager$getTabl.getDisplayName()) === name) {
|
|
1265
|
+
setInputFocusId("");
|
|
1266
|
+
setInputValue("");
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
commandService.executeCommand(SetSheetTableCommand.id, {
|
|
1270
|
+
tableId,
|
|
1271
|
+
unitId,
|
|
1272
|
+
name
|
|
1273
|
+
});
|
|
1274
|
+
setInputValue("");
|
|
1275
|
+
setInputFocusId("");
|
|
1276
|
+
};
|
|
1277
|
+
const handleChangeRange = async (tableId) => {
|
|
1278
|
+
const table = tableManager.getTableById(unitId, tableId);
|
|
1279
|
+
if (!table) return;
|
|
1280
|
+
const selection = await openRangeSelector(injector, unitId, subUnitId, table.getRange(), tableId);
|
|
1281
|
+
if (!selection) return;
|
|
1282
|
+
commandService.executeCommand(SetSheetTableCommand.id, {
|
|
1283
|
+
tableId,
|
|
1284
|
+
unitId,
|
|
1285
|
+
updateRange: { newRange: selection.range }
|
|
1286
|
+
});
|
|
1287
|
+
};
|
|
1288
|
+
if (!workbookPermissionInitState) return null;
|
|
1289
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1290
|
+
className: "univer-absolute univer-z-50 univer-size-0",
|
|
1291
|
+
children: anchorPosition.map((item) => {
|
|
1292
|
+
var _rangeTheme$getHeader, _rangeTheme$getHeader2, _rangeTheme$getHeader3, _rangeTheme$getHeader4, _openStates$item$tabl;
|
|
1293
|
+
const table = tableManager.getTableById(unitId, item.tableId);
|
|
1294
|
+
if (!table) return null;
|
|
1295
|
+
const rangeTheme = rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId());
|
|
1296
|
+
const headerBgColor = (_rangeTheme$getHeader = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader2 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader2 === void 0 || (_rangeTheme$getHeader2 = _rangeTheme$getHeader2.bg) === null || _rangeTheme$getHeader2 === void 0 ? void 0 : _rangeTheme$getHeader2.rgb) !== null && _rangeTheme$getHeader !== void 0 ? _rangeTheme$getHeader : anchorBackgroundColor;
|
|
1297
|
+
const headerTextColor = (_rangeTheme$getHeader3 = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader4 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader4 === void 0 || (_rangeTheme$getHeader4 = _rangeTheme$getHeader4.cl) === null || _rangeTheme$getHeader4 === void 0 ? void 0 : _rangeTheme$getHeader4.rgb) !== null && _rangeTheme$getHeader3 !== void 0 ? _rangeTheme$getHeader3 : "rgb(255, 255, 255)";
|
|
1298
|
+
const tableRange = table.getRange();
|
|
1299
|
+
if (!(selections === null || selections === void 0 ? void 0 : selections.length)) return null;
|
|
1300
|
+
const lastRange = selections[selections.length - 1].range;
|
|
1301
|
+
const shouldHidden = !Rectangle.intersects(tableRange, lastRange) && item.y <= 20;
|
|
1302
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1303
|
+
className: clsx("univer-shadow-xs univer-absolute univer-box-border univer-cursor-pointer univer-items-center univer-rounded-xl univer-px-2", borderClassName, {
|
|
1304
|
+
"univer-flex": !shouldHidden,
|
|
1305
|
+
"univer-hidden": shouldHidden
|
|
1306
|
+
}),
|
|
1307
|
+
style: {
|
|
1308
|
+
left: item.x,
|
|
1309
|
+
top: Math.max(item.y, 0),
|
|
1310
|
+
backgroundColor: headerBgColor,
|
|
1311
|
+
color: headerTextColor,
|
|
1312
|
+
borderWidth: "0.5px",
|
|
1313
|
+
height: anchorHeight ? `${anchorHeight}px` : "24px"
|
|
1314
|
+
},
|
|
1315
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1316
|
+
className: "univer-text-nowrap",
|
|
1317
|
+
children: inputFocusId === item.tableId ? /* @__PURE__ */ jsx(Input, {
|
|
1318
|
+
className: "univer-h-[18px] univer-min-w-16 univer-rounded-none",
|
|
1319
|
+
inputClass: "univer-h-[18px] univer-w-[80px]",
|
|
1320
|
+
value: inputValue,
|
|
1321
|
+
onChange: (v) => setInputValue(v),
|
|
1322
|
+
onBlur: () => handleChangeTableName(item.tableId, inputValue),
|
|
1323
|
+
onKeyDown: (e) => {
|
|
1324
|
+
if (e.key === "Enter") handleChangeTableName(item.tableId, inputValue);
|
|
1325
|
+
},
|
|
1326
|
+
autoFocus: inputFocusId === item.tableId
|
|
1327
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
1328
|
+
className: "univer-h-[18px] univer-max-w-24 univer-truncate univer-text-sm",
|
|
1329
|
+
children: item.tableName
|
|
1330
|
+
})
|
|
1331
|
+
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
1332
|
+
align: "start",
|
|
1333
|
+
overlay: /* @__PURE__ */ jsxs("div", {
|
|
1334
|
+
className: "univer-py-2",
|
|
1335
|
+
children: [
|
|
1336
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1337
|
+
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1338
|
+
onClick: () => {
|
|
1339
|
+
setInputFocusId(item.tableId);
|
|
1340
|
+
setInputValue(item.tableName);
|
|
1341
|
+
},
|
|
1342
|
+
children: [/* @__PURE__ */ jsx(RenameIcon, {}), localeService.t("sheets-table.rename")]
|
|
1343
|
+
}),
|
|
1344
|
+
/* @__PURE__ */ jsx("div", { className: "univer-my-1 univer-h-px univer-w-full univer-bg-gray-200" }),
|
|
1345
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1346
|
+
onClick: () => handleChangeRange(item.tableId),
|
|
1347
|
+
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1348
|
+
children: [/* @__PURE__ */ jsx(GridOutlineIcon, {}), localeService.t("sheets-table.updateRange")]
|
|
1349
|
+
}),
|
|
1350
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1351
|
+
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1352
|
+
onClick: () => {
|
|
1353
|
+
updateOpenState(item.tableId, false);
|
|
1354
|
+
const table = tableManager.getTableById(unitId, item.tableId);
|
|
1355
|
+
if (!table) return;
|
|
1356
|
+
const tableConfig = table.getTableConfig();
|
|
1357
|
+
const sidebarConfig = {
|
|
1358
|
+
id: SHEET_TABLE_THEME_PANEL_ID,
|
|
1359
|
+
header: { title: localeService.t("sheets-table.tableStyle") },
|
|
1360
|
+
children: {
|
|
1361
|
+
label: SHEET_TABLE_THEME_PANEL,
|
|
1362
|
+
oldConfig: tableConfig,
|
|
1363
|
+
unitId,
|
|
1364
|
+
subUnitId,
|
|
1365
|
+
tableId: item.tableId
|
|
1366
|
+
},
|
|
1367
|
+
width: 330
|
|
1368
|
+
};
|
|
1369
|
+
sidebarService.open(sidebarConfig);
|
|
1370
|
+
},
|
|
1371
|
+
children: [/* @__PURE__ */ jsx(PaintBucketDoubleIcon, { extend: { colorChannel1: "rgb(53,91,183)" } }), localeService.t("sheets-table.setTheme")]
|
|
1372
|
+
}),
|
|
1373
|
+
/* @__PURE__ */ jsx("div", { className: "univer-my-1 univer-h-px univer-w-full univer-bg-gray-200" }),
|
|
1374
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1375
|
+
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1376
|
+
onClick: () => {
|
|
1377
|
+
updateOpenState(item.tableId, false);
|
|
1378
|
+
commandService.executeCommand(DeleteSheetTableCommand.id, {
|
|
1379
|
+
tableId: item.tableId,
|
|
1380
|
+
subUnitId,
|
|
1381
|
+
unitId
|
|
1382
|
+
});
|
|
1383
|
+
},
|
|
1384
|
+
children: [/* @__PURE__ */ jsx(DeleteIcon, { className: "univer-mr-2" }), localeService.t("sheets-table.removeTable")]
|
|
1385
|
+
})
|
|
1386
|
+
]
|
|
1387
|
+
}),
|
|
1388
|
+
open: (_openStates$item$tabl = openStates[item.tableId]) !== null && _openStates$item$tabl !== void 0 ? _openStates$item$tabl : false,
|
|
1389
|
+
onOpenChange: (isOpen) => {
|
|
1390
|
+
updateOpenState(item.tableId, isOpen);
|
|
1391
|
+
},
|
|
1392
|
+
children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(MoreDownIcon, {}) })
|
|
1393
|
+
}, item.tableId)]
|
|
1394
|
+
}, item.tableId);
|
|
1395
|
+
})
|
|
1396
|
+
});
|
|
1397
|
+
};
|
|
1398
|
+
|
|
1399
|
+
//#endregion
|
|
1400
|
+
//#region src/controllers/sheet-table-anchor.controller.ts
|
|
1401
|
+
let SheetTableAnchorController = class SheetTableAnchorController extends Disposable {
|
|
1402
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _renderManagerService, _commandService, _univerInstanceService, _uiPartsService, _tableManager, _scrollManagerService, _workbookPermissionService, _permissionService) {
|
|
1403
|
+
super();
|
|
1404
|
+
this._context = _context;
|
|
1405
|
+
this._injector = _injector;
|
|
1406
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1407
|
+
this._renderManagerService = _renderManagerService;
|
|
1408
|
+
this._commandService = _commandService;
|
|
1409
|
+
this._univerInstanceService = _univerInstanceService;
|
|
1410
|
+
this._uiPartsService = _uiPartsService;
|
|
1411
|
+
this._tableManager = _tableManager;
|
|
1412
|
+
this._scrollManagerService = _scrollManagerService;
|
|
1413
|
+
this._workbookPermissionService = _workbookPermissionService;
|
|
1414
|
+
this._permissionService = _permissionService;
|
|
1415
|
+
_defineProperty(this, "_anchorVisible$", new BehaviorSubject(true));
|
|
1416
|
+
_defineProperty(this, "_timer", void 0);
|
|
1417
|
+
_defineProperty(this, "_anchorPosition$", new BehaviorSubject([]));
|
|
1418
|
+
_defineProperty(this, "anchorPosition$", this._anchorPosition$.asObservable());
|
|
1419
|
+
this._initUI();
|
|
1420
|
+
this._initListener();
|
|
1421
|
+
this._initTableAnchor();
|
|
1422
|
+
}
|
|
1423
|
+
_initUI() {
|
|
1424
|
+
this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(SheetTableAnchor, this._injector)));
|
|
1425
|
+
}
|
|
1426
|
+
_initListener() {
|
|
1427
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
1428
|
+
if (command.id === SetZoomRatioOperation.id || command.id === SetScrollOperation.id) {
|
|
1429
|
+
this._anchorVisible$.next(false);
|
|
1430
|
+
if (this._timer) clearTimeout(this._timer);
|
|
1431
|
+
this._timer = setTimeout(() => {
|
|
1432
|
+
this._anchorVisible$.next(true);
|
|
1433
|
+
}, 300);
|
|
1434
|
+
}
|
|
1435
|
+
}));
|
|
1436
|
+
}
|
|
1437
|
+
_initTableAnchor() {
|
|
1438
|
+
this.disposeWithMe(merge$1(this._context.unit.activeSheet$, this._sheetSkeletonManagerService.currentSkeleton$, this._scrollManagerService.validViewportScrollInfo$, this._tableManager.tableAdd$, this._tableManager.tableDelete$, this._tableManager.tableNameChanged$, this._tableManager.tableRangeChanged$, this._tableManager.tableThemeChanged$, this._workbookPermissionService.unitPermissionInitStateChange$.pipe(filter((v) => v)), this._permissionService.permissionPointUpdate$.pipe(debounceTime(300)), this._anchorVisible$).subscribe(() => {
|
|
1439
|
+
var _this$_permissionServ;
|
|
1440
|
+
if (!this._anchorVisible$.getValue()) {
|
|
1441
|
+
this._anchorPosition$.next([]);
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1444
|
+
const workbook = this._context.unit;
|
|
1445
|
+
const worksheet = workbook.getActiveSheet();
|
|
1446
|
+
const subUnitId = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getSheetId();
|
|
1447
|
+
const tables = this._tableManager.getTableList(this._context.unitId).filter((table) => {
|
|
1448
|
+
return table.subUnitId === subUnitId;
|
|
1449
|
+
});
|
|
1450
|
+
const renderUnit = this._renderManagerService.getRenderById(this._context.unitId);
|
|
1451
|
+
if (!renderUnit) {
|
|
1452
|
+
this._anchorPosition$.next([]);
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
if (!((_this$_permissionServ = this._permissionService.getPermissionPoint(new WorkbookEditablePermission(workbook.getUnitId()).id)) === null || _this$_permissionServ === void 0 ? void 0 : _this$_permissionServ.value)) {
|
|
1456
|
+
this._anchorPosition$.next([]);
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
const tableInfos = tables.reduce((acc, table) => {
|
|
1460
|
+
const { startRow, startColumn } = table.range;
|
|
1461
|
+
const sheetSkeletonManagerService = renderUnit.with(SheetSkeletonManagerService);
|
|
1462
|
+
const sheetObject = getSheetObject(this._univerInstanceService, this._renderManagerService);
|
|
1463
|
+
if (!sheetObject) return acc;
|
|
1464
|
+
const { scene } = sheetObject;
|
|
1465
|
+
const viewport = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
1466
|
+
if (!viewport) return acc;
|
|
1467
|
+
const scaleX = scene === null || scene === void 0 ? void 0 : scene.scaleX;
|
|
1468
|
+
const scaleY = scene === null || scene === void 0 ? void 0 : scene.scaleY;
|
|
1469
|
+
const scrollXY = scene === null || scene === void 0 ? void 0 : scene.getViewportScrollXY(viewport);
|
|
1470
|
+
if (!scaleX || !scene || !scaleY || !scrollXY) return acc;
|
|
1471
|
+
const skeleton = sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1472
|
+
if (!skeleton) return acc;
|
|
1473
|
+
const position = skeleton.getNoMergeCellWithCoordByIndex(startRow, startColumn);
|
|
1474
|
+
const startX = convertTransformToOffsetX(position.startX, scaleX, scrollXY);
|
|
1475
|
+
const startY = convertTransformToOffsetY(position.startY, scaleY, scrollXY) - 25 - 4;
|
|
1476
|
+
if (startY >= -10 && startX >= 45) acc.push({
|
|
1477
|
+
x: startX,
|
|
1478
|
+
y: startY,
|
|
1479
|
+
tableId: table.id,
|
|
1480
|
+
tableName: table.name
|
|
1481
|
+
});
|
|
1482
|
+
return acc;
|
|
1483
|
+
}, []);
|
|
1484
|
+
this._anchorPosition$.next(tableInfos);
|
|
1485
|
+
}));
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
SheetTableAnchorController = __decorate([
|
|
1489
|
+
__decorateParam(1, Inject(Injector)),
|
|
1490
|
+
__decorateParam(2, Inject(SheetSkeletonManagerService)),
|
|
1491
|
+
__decorateParam(3, IRenderManagerService),
|
|
1492
|
+
__decorateParam(4, ICommandService),
|
|
1493
|
+
__decorateParam(5, IUniverInstanceService),
|
|
1494
|
+
__decorateParam(6, IUIPartsService),
|
|
1495
|
+
__decorateParam(7, Inject(TableManager)),
|
|
1496
|
+
__decorateParam(8, Inject(SheetScrollManagerService)),
|
|
1497
|
+
__decorateParam(9, Inject(WorkbookPermissionService)),
|
|
1498
|
+
__decorateParam(10, Inject(IPermissionService))
|
|
1499
|
+
], SheetTableAnchorController);
|
|
1500
|
+
|
|
1501
|
+
//#endregion
|
|
1502
|
+
//#region src/views/widgets/drawings.ts
|
|
1503
|
+
const BUTTON_VIEWPORT = 16;
|
|
1504
|
+
const PIVOT_BUTTON_EMPTY = 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");
|
|
1505
|
+
var TableButton = class {
|
|
1506
|
+
static drawNoSetting(ctx, size, fgColor, bgColor) {
|
|
1507
|
+
ctx.save();
|
|
1508
|
+
Rect.drawWith(ctx, {
|
|
1509
|
+
radius: 2,
|
|
1510
|
+
width: BUTTON_VIEWPORT,
|
|
1511
|
+
height: BUTTON_VIEWPORT,
|
|
1512
|
+
fill: bgColor
|
|
1513
|
+
});
|
|
1514
|
+
ctx.lineCap = "square";
|
|
1515
|
+
ctx.strokeStyle = fgColor;
|
|
1516
|
+
ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT);
|
|
1517
|
+
ctx.beginPath();
|
|
1518
|
+
ctx.lineWidth = 1;
|
|
1519
|
+
ctx.lineCap = "round";
|
|
1520
|
+
ctx.moveTo(3, 4);
|
|
1521
|
+
ctx.lineTo(13, 4);
|
|
1522
|
+
ctx.moveTo(4.5, 8);
|
|
1523
|
+
ctx.lineTo(11.5, 8);
|
|
1524
|
+
ctx.moveTo(6, 12);
|
|
1525
|
+
ctx.lineTo(10, 12);
|
|
1526
|
+
ctx.stroke();
|
|
1527
|
+
ctx.restore();
|
|
1528
|
+
}
|
|
1529
|
+
static drawIconByPath(ctx, pathData, fgColor, bgColor) {
|
|
1530
|
+
ctx.save();
|
|
1531
|
+
ctx.strokeStyle = fgColor;
|
|
1532
|
+
ctx.fillStyle = bgColor;
|
|
1533
|
+
Rect.drawWith(ctx, {
|
|
1534
|
+
radius: 2,
|
|
1535
|
+
width: BUTTON_VIEWPORT,
|
|
1536
|
+
height: BUTTON_VIEWPORT,
|
|
1537
|
+
fill: bgColor
|
|
1538
|
+
});
|
|
1539
|
+
pathData.forEach((d) => {
|
|
1540
|
+
const path = new Path2D(d);
|
|
1541
|
+
ctx.fillStyle = fgColor;
|
|
1542
|
+
ctx.fill(path, "evenodd");
|
|
1543
|
+
});
|
|
1544
|
+
ctx.restore();
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
//#endregion
|
|
1549
|
+
//#region src/views/widgets/icons.ts
|
|
1550
|
+
/**
|
|
1551
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1552
|
+
*
|
|
1553
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1554
|
+
* you may not use this file except in compliance with the License.
|
|
1555
|
+
* You may obtain a copy of the License at
|
|
1556
|
+
*
|
|
1557
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1558
|
+
*
|
|
1559
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1560
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1561
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1562
|
+
* See the License for the specific language governing permissions and
|
|
1563
|
+
* limitations under the License.
|
|
1564
|
+
*/
|
|
1565
|
+
const filterPartial = ["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"];
|
|
1566
|
+
const filteredSortAsc = ["M12.4008 13.1831C12.6907 13.1831 12.9258 12.9481 12.9258 12.6581V4.60873L14.013 5.69597C14.218 5.901 14.5505 5.901 14.7555 5.69597C14.9605 5.49094 14.9605 5.15853 14.7555 4.95351L12.7721 2.97017C12.5671 2.76515 12.2347 2.76515 12.0297 2.97017L10.0463 4.95351C9.84132 5.15853 9.84132 5.49094 10.0463 5.69597C10.2514 5.901 10.5838 5.901 10.7888 5.69597L11.8758 4.60901V12.6581C11.8758 12.9481 12.1108 13.1831 12.4008 13.1831Z", "M1.28069 4.85447C0.842195 4.33439 1.21191 3.5391 1.89218 3.5391H8.59333C9.2736 3.5391 9.64331 4.33439 9.20482 4.85447L6.51052 8.0501V11.6601C6.51052 12.2245 5.94174 12.6114 5.41683 12.404L4.48092 12.0343C4.1756 11.9136 3.97498 11.6187 3.97498 11.2904V8.0501L1.28069 4.85447Z"];
|
|
1567
|
+
const filteredSortDesc = ["M12.4008 2.81641C12.6907 2.81641 12.9258 3.05146 12.9258 3.34141V11.3908L14.013 10.3036C14.218 10.0986 14.5505 10.0986 14.7555 10.3036C14.9605 10.5086 14.9605 10.841 14.7555 11.046L12.7721 13.0294C12.5671 13.2344 12.2347 13.2344 12.0297 13.0294L10.0463 11.046C9.84132 10.841 9.84132 10.5086 10.0463 10.3036C10.2514 10.0986 10.5838 10.0986 10.7888 10.3036L11.8758 11.3905V3.34141C11.8758 3.05146 12.1108 2.81641 12.4008 2.81641Z", "M1.28069 4.85444C0.842195 4.33435 1.21191 3.53906 1.89218 3.53906H8.59333C9.2736 3.53906 9.64331 4.33435 9.20482 4.85443L6.51052 8.05006V11.6601C6.51052 12.2245 5.94174 12.6113 5.41683 12.404L4.48092 12.0342C4.1756 11.9136 3.97498 11.6186 3.97498 11.2903V8.05006L1.28069 4.85444Z"];
|
|
1568
|
+
const filterNoneSortAsc = [
|
|
1569
|
+
"M11.9003 13.7046C11.9003 13.9969 11.6633 14.2339 11.371 14.2339C11.0787 14.2339 10.8417 13.9969 10.8417 13.7046V3.57272L9.74577 4.66862C9.53906 4.87534 9.20391 4.87534 8.9972 4.66862C8.79048 4.46191 8.79048 4.12676 8.9972 3.92005L10.9969 1.92039C11.2036 1.71368 11.5387 1.71368 11.7454 1.92039L13.7451 3.92005C13.9518 4.12676 13.9518 4.46191 13.7451 4.66862C13.5384 4.87534 13.2032 4.87534 12.9965 4.66862L11.9003 3.57243V13.7046Z",
|
|
1570
|
+
"M2.69779 10.0113C2.40546 10.0113 2.16847 9.77429 2.16847 9.48196C2.16847 9.18962 2.40546 8.95264 2.69779 8.95264H6.67804C6.89213 8.95264 7.08514 9.0816 7.16707 9.2794C7.249 9.47719 7.20371 9.70486 7.05233 9.85624L3.97569 12.9329H6.67804C6.97038 12.9329 7.20736 13.1699 7.20736 13.4622C7.20736 13.7545 6.97038 13.9915 6.67804 13.9915H2.69779C2.4837 13.9915 2.29069 13.8626 2.20876 13.6648C2.12684 13.467 2.17212 13.2393 2.32351 13.0879L5.40015 10.0113H2.69779Z",
|
|
1571
|
+
"M5.51638 2.58693C5.23363 1.81542 4.14248 1.81543 3.85973 2.58693L2.13245 7.29995C2.03185 7.57443 2.17281 7.87849 2.4473 7.97909C2.72178 8.07969 3.02584 7.93872 3.12644 7.66424L3.64346 6.25351L3.64504 6.25351H5.73266L6.24968 7.66424C6.35027 7.93872 6.65433 8.07969 6.92882 7.97909C7.2033 7.87849 7.34426 7.57443 7.24367 7.29995L5.51638 2.58693ZM5.34467 5.19487L4.68806 3.40325L4.03144 5.19487H5.34467Z"
|
|
1572
|
+
];
|
|
1573
|
+
const filterNoneSortDesc = [
|
|
1574
|
+
"M11.9003 2.29495C11.9003 2.00261 11.6633 1.76562 11.371 1.76562C11.0787 1.76562 10.8417 2.00261 10.8417 2.29495V12.4268L9.74577 11.3309C9.53906 11.1242 9.20391 11.1242 8.9972 11.3309C8.79048 11.5376 8.79048 11.8727 8.9972 12.0795L10.9969 14.0791C11.2036 14.2858 11.5387 14.2858 11.7454 14.0791L13.7451 12.0795C13.9518 11.8727 13.9518 11.5376 13.7451 11.3309C13.5384 11.1242 13.2032 11.1242 12.9965 11.3309L11.9003 12.4271V2.29495Z",
|
|
1575
|
+
"M2.69792 10.0113C2.40558 10.0113 2.16859 9.77429 2.16859 9.48196C2.16859 9.18962 2.40558 8.95264 2.69792 8.95264H6.67816C6.89225 8.95264 7.08526 9.0816 7.16719 9.2794C7.24912 9.47719 7.20384 9.70486 7.05245 9.85624L3.97581 12.9329H6.67816C6.9705 12.9329 7.20749 13.1699 7.20749 13.4622C7.20749 13.7545 6.9705 13.9915 6.67816 13.9915H2.69792C2.48383 13.9915 2.29082 13.8626 2.20889 13.6648C2.12696 13.467 2.17224 13.2393 2.32363 13.0879L5.40027 10.0113H2.69792Z",
|
|
1576
|
+
"M5.5165 2.58693C5.23375 1.81542 4.1426 1.81543 3.85985 2.58693L2.13257 7.29995C2.03197 7.57443 2.17294 7.8785 2.44742 7.97909C2.7219 8.07969 3.02596 7.93872 3.12656 7.66424L3.64358 6.25351L3.64516 6.25351H5.73278L6.2498 7.66424C6.35039 7.93872 6.65446 8.07969 6.92894 7.97909C7.20342 7.8785 7.34438 7.57443 7.24379 7.29995L5.5165 2.58693ZM5.34479 5.19487L4.68818 3.40325L4.03156 5.19487H5.34479Z"
|
|
1577
|
+
];
|
|
1578
|
+
|
|
1579
|
+
//#endregion
|
|
1580
|
+
//#region src/views/widgets/table-filter-button.shape.ts
|
|
1581
|
+
const FILTER_ICON_SIZE = 16;
|
|
1582
|
+
let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends Shape {
|
|
1583
|
+
constructor(key, props, _contextService, _commandService, _themeService) {
|
|
1584
|
+
super(key, props);
|
|
1585
|
+
this._contextService = _contextService;
|
|
1586
|
+
this._commandService = _commandService;
|
|
1587
|
+
this._themeService = _themeService;
|
|
1588
|
+
_defineProperty(this, "_cellWidth", 0);
|
|
1589
|
+
_defineProperty(this, "_cellHeight", 0);
|
|
1590
|
+
_defineProperty(this, "_filterParams", void 0);
|
|
1591
|
+
_defineProperty(this, "_hovered", false);
|
|
1592
|
+
this.setShapeProps(props);
|
|
1593
|
+
this.onPointerDown$.subscribeEvent((evt) => this.onPointerDown(evt));
|
|
1594
|
+
this.onPointerEnter$.subscribeEvent(() => this.onPointerEnter());
|
|
1595
|
+
this.onPointerLeave$.subscribeEvent(() => this.onPointerLeave());
|
|
1596
|
+
}
|
|
1597
|
+
setShapeProps(props) {
|
|
1598
|
+
if (typeof props.cellHeight !== "undefined") this._cellHeight = props.cellHeight;
|
|
1599
|
+
if (typeof props.cellWidth !== "undefined") this._cellWidth = props.cellWidth;
|
|
1600
|
+
if (typeof props.filterParams !== "undefined") this._filterParams = props.filterParams;
|
|
1601
|
+
this.transformByState({
|
|
1602
|
+
width: props.width,
|
|
1603
|
+
height: props.height
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
_draw(ctx) {
|
|
1607
|
+
const cellHeight = this._cellHeight;
|
|
1608
|
+
const cellWidth = this._cellWidth;
|
|
1609
|
+
const left = 16 - cellWidth;
|
|
1610
|
+
const top = 16 - cellHeight;
|
|
1611
|
+
ctx.save();
|
|
1612
|
+
const cellRegion = new Path2D();
|
|
1613
|
+
cellRegion.rect(left, top, cellWidth, cellHeight);
|
|
1614
|
+
ctx.clip(cellRegion);
|
|
1615
|
+
const { buttonState } = this._filterParams;
|
|
1616
|
+
const fgColor = this._themeService.getColorFromTheme("primary.600");
|
|
1617
|
+
const bgColor = this._hovered ? this._themeService.getColorFromTheme("gray.50") : "rgba(255, 255, 255, 1.0)";
|
|
1618
|
+
let icons;
|
|
1619
|
+
switch (buttonState) {
|
|
1620
|
+
case SheetsTableButtonStateEnum.FilteredSortNone:
|
|
1621
|
+
icons = filterPartial;
|
|
1622
|
+
break;
|
|
1623
|
+
case SheetsTableButtonStateEnum.FilteredSortAsc:
|
|
1624
|
+
icons = filteredSortAsc;
|
|
1625
|
+
break;
|
|
1626
|
+
case SheetsTableButtonStateEnum.FilteredSortDesc:
|
|
1627
|
+
icons = filteredSortDesc;
|
|
1628
|
+
break;
|
|
1629
|
+
case SheetsTableButtonStateEnum.FilterNoneSortNone: break;
|
|
1630
|
+
case SheetsTableButtonStateEnum.FilterNoneSortAsc:
|
|
1631
|
+
icons = filterNoneSortAsc;
|
|
1632
|
+
break;
|
|
1633
|
+
case SheetsTableButtonStateEnum.FilterNoneSortDesc:
|
|
1634
|
+
icons = filterNoneSortDesc;
|
|
1635
|
+
break;
|
|
1636
|
+
}
|
|
1637
|
+
if (icons) TableButton.drawIconByPath(ctx, icons, fgColor, bgColor);
|
|
1638
|
+
else if (buttonState !== void 0) TableButton.drawNoSetting(ctx, 16, fgColor, bgColor);
|
|
1639
|
+
ctx.restore();
|
|
1640
|
+
}
|
|
1641
|
+
onPointerDown(evt) {
|
|
1642
|
+
if (evt.button === 2) return;
|
|
1643
|
+
const { row, col, unitId, subUnitId, tableId } = this._filterParams;
|
|
1644
|
+
if (this._contextService.getContextValue("SHEETS_TABLE_FILTER_PANEL_OPENED_KEY") || !this._commandService.hasCommand(OpenTableFilterPanelOperation.id)) return;
|
|
1645
|
+
setTimeout(() => {
|
|
1646
|
+
const cmdParams = {
|
|
1647
|
+
row,
|
|
1648
|
+
col,
|
|
1649
|
+
unitId,
|
|
1650
|
+
subUnitId,
|
|
1651
|
+
tableId
|
|
1652
|
+
};
|
|
1653
|
+
this._commandService.executeCommand(OpenTableFilterPanelOperation.id, cmdParams);
|
|
1654
|
+
}, 200);
|
|
1655
|
+
}
|
|
1656
|
+
onPointerEnter() {
|
|
1657
|
+
this._hovered = true;
|
|
1658
|
+
this.makeDirty(true);
|
|
1659
|
+
}
|
|
1660
|
+
onPointerLeave() {
|
|
1661
|
+
this._hovered = false;
|
|
1662
|
+
this.makeDirty(true);
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
SheetsTableFilterButtonShape = __decorate([
|
|
1666
|
+
__decorateParam(2, IContextService),
|
|
1667
|
+
__decorateParam(3, ICommandService),
|
|
1668
|
+
__decorateParam(4, Inject(ThemeService))
|
|
1669
|
+
], SheetsTableFilterButtonShape);
|
|
1670
|
+
|
|
1671
|
+
//#endregion
|
|
1672
|
+
//#region src/controllers/sheet-table-filter-button-render.controller.ts
|
|
1673
|
+
const SHEETS_FILTER_BUTTON_Z_INDEX = 5e3;
|
|
1674
|
+
const computeIconTop = (startY, endY, cellHeight, verticalAlign) => {
|
|
1675
|
+
switch (verticalAlign) {
|
|
1676
|
+
case VerticalAlign.TOP: return startY + 1;
|
|
1677
|
+
case VerticalAlign.MIDDLE: return startY + Math.max(0, (cellHeight - 16) / 2);
|
|
1678
|
+
case VerticalAlign.BOTTOM:
|
|
1679
|
+
default: return endY - 16 - 1;
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRenderController extends RxDisposable {
|
|
1683
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetInterceptorService, _tableManager, _commandService) {
|
|
1684
|
+
super();
|
|
1685
|
+
this._context = _context;
|
|
1686
|
+
this._injector = _injector;
|
|
1687
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1688
|
+
this._sheetInterceptorService = _sheetInterceptorService;
|
|
1689
|
+
this._tableManager = _tableManager;
|
|
1690
|
+
this._commandService = _commandService;
|
|
1691
|
+
_defineProperty(this, "_buttonRenderDisposable", null);
|
|
1692
|
+
_defineProperty(this, "_tableFilterButtonShapes", []);
|
|
1693
|
+
this._initRenderer();
|
|
1694
|
+
this._initCommandExecuted();
|
|
1695
|
+
}
|
|
1696
|
+
dispose() {
|
|
1697
|
+
super.dispose();
|
|
1698
|
+
this._disposeRendering();
|
|
1699
|
+
}
|
|
1700
|
+
_initRenderer() {
|
|
1701
|
+
const tableManager = this._tableManager;
|
|
1702
|
+
this._sheetSkeletonManagerService.currentSkeleton$.pipe(switchMap((skeletonParams) => {
|
|
1703
|
+
var _workbook$getActiveSh;
|
|
1704
|
+
if (!skeletonParams) return of(null);
|
|
1705
|
+
const { unit: workbook, unitId } = this._context;
|
|
1706
|
+
const worksheetId = ((_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getSheetId()) || "";
|
|
1707
|
+
const getParams = () => ({
|
|
1708
|
+
unitId,
|
|
1709
|
+
worksheetId,
|
|
1710
|
+
tableFilterRanges: this._tableManager.getSheetFilterRangeWithState(workbook.getUnitId(), worksheetId),
|
|
1711
|
+
skeleton: skeletonParams.skeleton
|
|
1712
|
+
});
|
|
1713
|
+
return merge$1(tableManager.tableAdd$, tableManager.tableNameChanged$, tableManager.tableRangeChanged$, tableManager.tableThemeChanged$, tableManager.tableDelete$, tableManager.tableFilterChanged$).pipe(map(() => getParams()), startWith(getParams()));
|
|
1714
|
+
}), takeUntil(this.dispose$)).subscribe((renderParams) => {
|
|
1715
|
+
this._disposeRendering();
|
|
1716
|
+
if (!renderParams || !renderParams.tableFilterRanges) return;
|
|
1717
|
+
this._renderButtons(renderParams);
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
_initCommandExecuted() {
|
|
1721
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
1722
|
+
var _workbook$getActiveSh2;
|
|
1723
|
+
if (command.id !== SetVerticalTextAlignCommand.id) return;
|
|
1724
|
+
const { unit: workbook, unitId } = this._context;
|
|
1725
|
+
const worksheetId = ((_workbook$getActiveSh2 = workbook.getActiveSheet()) === null || _workbook$getActiveSh2 === void 0 ? void 0 : _workbook$getActiveSh2.getSheetId()) || "";
|
|
1726
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1727
|
+
if (!skeleton) return;
|
|
1728
|
+
const renderParams = {
|
|
1729
|
+
unitId,
|
|
1730
|
+
worksheetId,
|
|
1731
|
+
tableFilterRanges: this._tableManager.getSheetFilterRangeWithState(workbook.getUnitId(), worksheetId),
|
|
1732
|
+
skeleton
|
|
1733
|
+
};
|
|
1734
|
+
this._disposeRendering();
|
|
1735
|
+
if (!renderParams || !renderParams.tableFilterRanges) return;
|
|
1736
|
+
this._renderButtons(renderParams);
|
|
1737
|
+
}));
|
|
1738
|
+
}
|
|
1739
|
+
_renderButtons(params) {
|
|
1740
|
+
const { tableFilterRanges, unitId, skeleton, worksheetId } = params;
|
|
1741
|
+
const { unit: workbook, scene } = this._context;
|
|
1742
|
+
const worksheet = workbook.getSheetBySheetId(worksheetId);
|
|
1743
|
+
if (!worksheet) return;
|
|
1744
|
+
for (const { range, states, tableId } of tableFilterRanges) {
|
|
1745
|
+
const { startRow, startColumn, endColumn } = range;
|
|
1746
|
+
this._interceptCellContent(unitId, worksheetId, range);
|
|
1747
|
+
for (let col = startColumn; col <= endColumn; col++) {
|
|
1748
|
+
const key = `sheets-table-filter-button-${startRow}-${col}`;
|
|
1749
|
+
const startPosition = getCoordByCell(startRow, col, scene, skeleton);
|
|
1750
|
+
const cellStyle = worksheet.getCellStyle(startRow, col);
|
|
1751
|
+
const verticalAlign = (cellStyle === null || cellStyle === void 0 ? void 0 : cellStyle.vt) || VerticalAlign.BOTTOM;
|
|
1752
|
+
const { startX, startY, endX, endY } = startPosition;
|
|
1753
|
+
const cellWidth = endX - startX;
|
|
1754
|
+
const cellHeight = endY - startY;
|
|
1755
|
+
if (cellHeight <= 1 || cellWidth <= 1) continue;
|
|
1756
|
+
const state = states[col - startColumn];
|
|
1757
|
+
const props = {
|
|
1758
|
+
left: endX - 16 - 1,
|
|
1759
|
+
top: computeIconTop(startY, endY, cellHeight, verticalAlign),
|
|
1760
|
+
height: 16,
|
|
1761
|
+
width: 16,
|
|
1762
|
+
zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,
|
|
1763
|
+
cellHeight,
|
|
1764
|
+
cellWidth,
|
|
1765
|
+
filterParams: {
|
|
1766
|
+
unitId,
|
|
1767
|
+
subUnitId: worksheetId,
|
|
1768
|
+
row: startRow,
|
|
1769
|
+
col,
|
|
1770
|
+
buttonState: state,
|
|
1771
|
+
tableId
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
const buttonShape = this._injector.createInstance(SheetsTableFilterButtonShape, key, props);
|
|
1775
|
+
this._tableFilterButtonShapes.push(buttonShape);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
scene.addObjects(this._tableFilterButtonShapes);
|
|
1779
|
+
scene.makeDirty();
|
|
1780
|
+
}
|
|
1781
|
+
_interceptCellContent(workbookId, worksheetId, range) {
|
|
1782
|
+
const { startRow, startColumn, endColumn } = range;
|
|
1783
|
+
this._buttonRenderDisposable = this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
1784
|
+
effect: InterceptorEffectEnum.Style,
|
|
1785
|
+
handler: (cell, pos, next) => {
|
|
1786
|
+
const { row, col, unitId, subUnitId } = pos;
|
|
1787
|
+
if (unitId !== workbookId || subUnitId !== worksheetId || row !== startRow || col < startColumn || col > endColumn) return next(cell);
|
|
1788
|
+
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
1789
|
+
cell.fontRenderExtension = {
|
|
1790
|
+
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
1791
|
+
rightOffset: 16
|
|
1792
|
+
};
|
|
1793
|
+
return next(cell);
|
|
1794
|
+
},
|
|
1795
|
+
priority: 10
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
_disposeRendering() {
|
|
1799
|
+
var _this$_buttonRenderDi;
|
|
1800
|
+
this._tableFilterButtonShapes.forEach((s) => s.dispose());
|
|
1801
|
+
(_this$_buttonRenderDi = this._buttonRenderDisposable) === null || _this$_buttonRenderDi === void 0 || _this$_buttonRenderDi.dispose();
|
|
1802
|
+
this._buttonRenderDisposable = null;
|
|
1803
|
+
this._tableFilterButtonShapes = [];
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
SheetsTableFilterButtonRenderController = __decorate([
|
|
1807
|
+
__decorateParam(1, Inject(Injector)),
|
|
1808
|
+
__decorateParam(2, Inject(SheetSkeletonManagerService)),
|
|
1809
|
+
__decorateParam(3, Inject(SheetInterceptorService)),
|
|
1810
|
+
__decorateParam(4, Inject(TableManager)),
|
|
1811
|
+
__decorateParam(5, ICommandService)
|
|
1812
|
+
], SheetsTableFilterButtonRenderController);
|
|
1813
|
+
|
|
1814
|
+
//#endregion
|
|
1815
|
+
//#region src/controllers/sheet-table-render.controller.ts
|
|
1816
|
+
let SheetsTableRenderController = class SheetsTableRenderController extends RxDisposable {
|
|
1817
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _tableManager, _sheetTableThemeUIController) {
|
|
1818
|
+
super();
|
|
1819
|
+
this._context = _context;
|
|
1820
|
+
this._injector = _injector;
|
|
1821
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1822
|
+
this._tableManager = _tableManager;
|
|
1823
|
+
this._sheetTableThemeUIController = _sheetTableThemeUIController;
|
|
1824
|
+
this._initListener();
|
|
1825
|
+
}
|
|
1826
|
+
_dirtySkeleton() {
|
|
1827
|
+
var _this$_context$mainCo;
|
|
1828
|
+
(_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 || _this$_context$mainCo.makeDirty();
|
|
1829
|
+
const currentParam = this._sheetSkeletonManagerService.getCurrentParam();
|
|
1830
|
+
if (currentParam) {
|
|
1831
|
+
const param = {
|
|
1832
|
+
...currentParam,
|
|
1833
|
+
dirty: true
|
|
1834
|
+
};
|
|
1835
|
+
this._sheetSkeletonManagerService.reCalculate(param);
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
_initListener() {
|
|
1839
|
+
const tableManager = this._tableManager;
|
|
1840
|
+
const dirtySkeleton = this._dirtySkeleton.bind(this);
|
|
1841
|
+
this.disposeWithMe(merge$1(tableManager.tableAdd$, tableManager.tableDelete$, tableManager.tableNameChanged$, tableManager.tableRangeChanged$, tableManager.tableThemeChanged$, tableManager.tableFilterChanged$, tableManager.tableInitStatus$, this._sheetTableThemeUIController.refreshTable$).subscribe(dirtySkeleton));
|
|
1842
|
+
}
|
|
1843
|
+
};
|
|
1844
|
+
SheetsTableRenderController = __decorate([
|
|
1845
|
+
__decorateParam(1, Inject(Injector)),
|
|
1846
|
+
__decorateParam(2, Inject(SheetSkeletonManagerService)),
|
|
1847
|
+
__decorateParam(3, Inject(TableManager)),
|
|
1848
|
+
__decorateParam(4, Inject(SheetTableThemeUIController))
|
|
1849
|
+
], SheetsTableRenderController);
|
|
1850
|
+
|
|
1851
|
+
//#endregion
|
|
1852
|
+
//#region src/controllers/sheet-table-selection.controller.ts
|
|
1853
|
+
let SheetTableSelectionController = class SheetTableSelectionController extends Disposable {
|
|
1854
|
+
constructor(_sheetInterceptorService, _univerInstanceService, _tableManager) {
|
|
1855
|
+
super();
|
|
1856
|
+
this._sheetInterceptorService = _sheetInterceptorService;
|
|
1857
|
+
this._univerInstanceService = _univerInstanceService;
|
|
1858
|
+
this._tableManager = _tableManager;
|
|
1859
|
+
this._initSelectionChange();
|
|
1860
|
+
}
|
|
1861
|
+
_initSelectionChange() {
|
|
1862
|
+
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({ getMutations: (command) => {
|
|
1863
|
+
if (command.id === SelectAllCommand.id) {
|
|
1864
|
+
const target = getSheetCommandTarget(this._univerInstanceService);
|
|
1865
|
+
if (!target) return {
|
|
1866
|
+
redos: [],
|
|
1867
|
+
undos: []
|
|
1868
|
+
};
|
|
1869
|
+
const { range } = command.params;
|
|
1870
|
+
const { unitId, subUnitId, worksheet } = target;
|
|
1871
|
+
const overlapTable = this._tableManager.getTablesBySubunitId(unitId, subUnitId).find((table) => {
|
|
1872
|
+
const tableRange = table.getRange();
|
|
1873
|
+
return Rectangle.contains(tableRange, range);
|
|
1874
|
+
});
|
|
1875
|
+
if (overlapTable) {
|
|
1876
|
+
const tableRange = overlapTable.getRange();
|
|
1877
|
+
const tableRangeWithoutHeader = {
|
|
1878
|
+
...tableRange,
|
|
1879
|
+
startRow: tableRange.startRow + 1
|
|
1880
|
+
};
|
|
1881
|
+
if (Rectangle.equals(tableRange, range)) return {
|
|
1882
|
+
undos: [],
|
|
1883
|
+
redos: []
|
|
1884
|
+
};
|
|
1885
|
+
else if (Rectangle.equals(tableRangeWithoutHeader, range)) return {
|
|
1886
|
+
undos: [],
|
|
1887
|
+
redos: [{
|
|
1888
|
+
id: SetSelectionsOperation.id,
|
|
1889
|
+
params: {
|
|
1890
|
+
unitId,
|
|
1891
|
+
subUnitId,
|
|
1892
|
+
selections: [{
|
|
1893
|
+
range: tableRange,
|
|
1894
|
+
primary: getPrimaryForRange(tableRange, worksheet)
|
|
1895
|
+
}]
|
|
1896
|
+
}
|
|
1897
|
+
}]
|
|
1898
|
+
};
|
|
1899
|
+
else return {
|
|
1900
|
+
undos: [],
|
|
1901
|
+
redos: [{
|
|
1902
|
+
id: SetSelectionsOperation.id,
|
|
1903
|
+
params: {
|
|
1904
|
+
unitId,
|
|
1905
|
+
subUnitId,
|
|
1906
|
+
selections: [{
|
|
1907
|
+
range: tableRangeWithoutHeader,
|
|
1908
|
+
primary: getPrimaryForRange(tableRangeWithoutHeader, worksheet)
|
|
1909
|
+
}]
|
|
1910
|
+
}
|
|
1911
|
+
}]
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
return {
|
|
1916
|
+
redos: [],
|
|
1917
|
+
undos: []
|
|
1918
|
+
};
|
|
1919
|
+
} }));
|
|
1920
|
+
}
|
|
1921
|
+
};
|
|
1922
|
+
SheetTableSelectionController = __decorate([
|
|
1923
|
+
__decorateParam(0, Inject(SheetInterceptorService)),
|
|
1924
|
+
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
1925
|
+
__decorateParam(2, Inject(TableManager))
|
|
1926
|
+
], SheetTableSelectionController);
|
|
1927
|
+
|
|
1928
|
+
//#endregion
|
|
1929
|
+
//#region src/views/components/SheetTableSelector.tsx
|
|
1930
|
+
const SheetTableSelector = (props) => {
|
|
1931
|
+
const { unitId, subUnitId, range, onCancel, onConfirm, tableId } = props;
|
|
1932
|
+
const tableManager = useDependency(TableManager);
|
|
1933
|
+
const [selectedRange, setSelectedRange] = useState(range);
|
|
1934
|
+
const [rangeError, setRangeError] = useState("");
|
|
1935
|
+
const localeService = useDependency(LocaleService);
|
|
1936
|
+
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
1937
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1938
|
+
/* @__PURE__ */ jsx(RangeSelector, {
|
|
1939
|
+
maxRangeCount: 1,
|
|
1940
|
+
unitId,
|
|
1941
|
+
subUnitId,
|
|
1942
|
+
initialValue: serializeRange(range),
|
|
1943
|
+
onChange: (_, text) => {
|
|
1944
|
+
const originValue = serializeRange(range);
|
|
1945
|
+
const newRange = deserializeRangeWithSheet(text).range;
|
|
1946
|
+
const target = getSheetCommandTarget(univerInstanceService, {
|
|
1947
|
+
unitId,
|
|
1948
|
+
subUnitId
|
|
1949
|
+
});
|
|
1950
|
+
if (!target) return;
|
|
1951
|
+
if (target.worksheet.getMergeData().some((merge) => {
|
|
1952
|
+
return Rectangle.intersects(newRange, merge);
|
|
1953
|
+
})) {
|
|
1954
|
+
setRangeError(localeService.t("sheets-table.tableRangeWithMergeError"));
|
|
1955
|
+
return;
|
|
1956
|
+
}
|
|
1957
|
+
if (tableManager.getTablesBySubunitId(unitId, subUnitId).some((table) => {
|
|
1958
|
+
if (table.getId() === tableId) return false;
|
|
1959
|
+
const tableRange = table.getRange();
|
|
1960
|
+
return Rectangle.intersects(newRange, tableRange);
|
|
1961
|
+
})) {
|
|
1962
|
+
setRangeError(localeService.t("sheets-table.tableRangeWithOtherTableError"));
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
const { startRow, endRow } = newRange;
|
|
1966
|
+
if (startRow === endRow) {
|
|
1967
|
+
setRangeError(localeService.t("sheets-table.tableRangeSingleRowError"));
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
if (originValue === text) return;
|
|
1971
|
+
if (tableId) {
|
|
1972
|
+
const table = tableManager.getTableById(unitId, tableId);
|
|
1973
|
+
if (table) {
|
|
1974
|
+
const oldRange = table.getRange();
|
|
1975
|
+
if (Rectangle.intersects(newRange, oldRange) && oldRange.startRow === newRange.startRow) {
|
|
1976
|
+
setSelectedRange(newRange);
|
|
1977
|
+
setRangeError("");
|
|
1978
|
+
onConfirm({
|
|
1979
|
+
unitId,
|
|
1980
|
+
subUnitId,
|
|
1981
|
+
range: newRange
|
|
1982
|
+
});
|
|
1983
|
+
return;
|
|
1984
|
+
} else {
|
|
1985
|
+
setRangeError(localeService.t("sheets-table.updateError"));
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
setSelectedRange(newRange);
|
|
1991
|
+
setRangeError("");
|
|
1992
|
+
},
|
|
1993
|
+
supportAcrossSheet: false
|
|
1994
|
+
}),
|
|
1995
|
+
rangeError && /* @__PURE__ */ jsx("div", {
|
|
1996
|
+
className: "univer-mt-1 univer-text-xs univer-text-red-500",
|
|
1997
|
+
children: rangeError
|
|
1998
|
+
}),
|
|
1999
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2000
|
+
className: "univer-mt-4 univer-flex univer-justify-end",
|
|
2001
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
2002
|
+
onClick: onCancel,
|
|
2003
|
+
children: localeService.t("sheets-table.cancel")
|
|
2004
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
2005
|
+
variant: "primary",
|
|
2006
|
+
onClick: () => {
|
|
2007
|
+
if (rangeError) return;
|
|
2008
|
+
onConfirm({
|
|
2009
|
+
unitId,
|
|
2010
|
+
subUnitId,
|
|
2011
|
+
range: selectedRange
|
|
2012
|
+
});
|
|
2013
|
+
},
|
|
2014
|
+
className: "univer-ml-2",
|
|
2015
|
+
children: localeService.t("sheets-table.confirm")
|
|
2016
|
+
})]
|
|
2017
|
+
})
|
|
2018
|
+
] });
|
|
2019
|
+
};
|
|
2020
|
+
|
|
2021
|
+
//#endregion
|
|
2022
|
+
//#region src/views/components/SheetTableThemePanel.tsx
|
|
2023
|
+
const SheetTableThemePanel = (props) => {
|
|
2024
|
+
var _customStyle$getHeade, _customStyle$getHeade2, _customStyle$getFirst, _customStyle$getFirst2, _customStyle$getSecon, _customStyle$getSecon2, _customStyle$getLastR, _customStyle$getLastR2;
|
|
2025
|
+
const { unitId, subUnitId, tableId } = props;
|
|
2026
|
+
const commandService = useDependency(ICommandService);
|
|
2027
|
+
const localeService = useDependency(LocaleService);
|
|
2028
|
+
const tableManager = useDependency(TableManager);
|
|
2029
|
+
const table = tableManager.getTableById(unitId, tableId);
|
|
2030
|
+
const rangeThemeModel = useDependency(SheetRangeThemeModel);
|
|
2031
|
+
const sheetTableThemeUIController = useDependency(SheetTableThemeUIController);
|
|
2032
|
+
const rangeThemeMapChanged = useObservable(rangeThemeModel.rangeThemeMapChange$);
|
|
2033
|
+
const tableRefresh = useObservable(sheetTableThemeUIController.refreshTable$);
|
|
2034
|
+
const errorService = useDependency(ErrorService);
|
|
2035
|
+
const [, setRefresh] = useState(Math.random());
|
|
2036
|
+
const themeConfig = useObservable(tableManager.tableThemeChanged$, {
|
|
2037
|
+
theme: table === null || table === void 0 ? void 0 : table.getTableStyleId(),
|
|
2038
|
+
oldTheme: table === null || table === void 0 ? void 0 : table.getTableStyleId(),
|
|
2039
|
+
unitId,
|
|
2040
|
+
subUnitId,
|
|
2041
|
+
tableId
|
|
2042
|
+
});
|
|
2043
|
+
const defaultRangeThemes = rangeThemeModel.getRegisteredRangeThemes().filter((item) => item === null || item === void 0 ? void 0 : item.startsWith(TABLE_DEFAULT_NAME_PREFIX));
|
|
2044
|
+
const customRangeThemes = rangeThemeModel.getALLRegisteredTheme(unitId).filter((item) => item === null || item === void 0 ? void 0 : item.startsWith(TABLE_CUSTOM_NAME_PREFIX));
|
|
2045
|
+
const selectedTheme = table === null || table === void 0 ? void 0 : table.getTableStyleId();
|
|
2046
|
+
const customSelected = customRangeThemes.find((item) => item === selectedTheme);
|
|
2047
|
+
const customStyleName = customSelected || customRangeThemes[0];
|
|
2048
|
+
const customStyle = rangeThemeModel.getCustomRangeThemeStyle(unitId, customStyleName);
|
|
2049
|
+
const headerBg = (_customStyle$getHeade = customStyle === null || customStyle === void 0 || (_customStyle$getHeade2 = customStyle.getHeaderRowStyle()) === null || _customStyle$getHeade2 === void 0 || (_customStyle$getHeade2 = _customStyle$getHeade2.bg) === null || _customStyle$getHeade2 === void 0 ? void 0 : _customStyle$getHeade2.rgb) !== null && _customStyle$getHeade !== void 0 ? _customStyle$getHeade : TABLE_DEFAULT_BG_COLOR;
|
|
2050
|
+
const firstRowBg = (_customStyle$getFirst = customStyle === null || customStyle === void 0 || (_customStyle$getFirst2 = customStyle.getFirstRowStyle()) === null || _customStyle$getFirst2 === void 0 || (_customStyle$getFirst2 = _customStyle$getFirst2.bg) === null || _customStyle$getFirst2 === void 0 ? void 0 : _customStyle$getFirst2.rgb) !== null && _customStyle$getFirst !== void 0 ? _customStyle$getFirst : TABLE_DEFAULT_BG_COLOR;
|
|
2051
|
+
const secondRowBg = (_customStyle$getSecon = customStyle === null || customStyle === void 0 || (_customStyle$getSecon2 = customStyle.getSecondRowStyle()) === null || _customStyle$getSecon2 === void 0 || (_customStyle$getSecon2 = _customStyle$getSecon2.bg) === null || _customStyle$getSecon2 === void 0 ? void 0 : _customStyle$getSecon2.rgb) !== null && _customStyle$getSecon !== void 0 ? _customStyle$getSecon : TABLE_DEFAULT_BG_COLOR;
|
|
2052
|
+
const lastRowBg = (_customStyle$getLastR = customStyle === null || customStyle === void 0 || (_customStyle$getLastR2 = customStyle.getLastRowStyle()) === null || _customStyle$getLastR2 === void 0 || (_customStyle$getLastR2 = _customStyle$getLastR2.bg) === null || _customStyle$getLastR2 === void 0 ? void 0 : _customStyle$getLastR2.rgb) !== null && _customStyle$getLastR !== void 0 ? _customStyle$getLastR : TABLE_DEFAULT_BG_COLOR;
|
|
2053
|
+
const [hoverCustomId, setHoverCustomId] = useState(null);
|
|
2054
|
+
const handleThemeChange = (theme) => {
|
|
2055
|
+
commandService.executeCommand(SetSheetTableCommand.id, {
|
|
2056
|
+
unitId,
|
|
2057
|
+
tableId,
|
|
2058
|
+
theme
|
|
2059
|
+
});
|
|
2060
|
+
};
|
|
2061
|
+
const handleAddCustomTheme = () => {
|
|
2062
|
+
if (customRangeThemes.length >= 11) {
|
|
2063
|
+
errorService.emit(localeService.t("sheets-table.customTooMore"));
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
const lastCustomTheme = customRangeThemes[customRangeThemes.length - 1];
|
|
2067
|
+
let newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}1`;
|
|
2068
|
+
if (lastCustomTheme) newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}${Number(lastCustomTheme.split("-")[2]) + 1}`;
|
|
2069
|
+
const newTheme = new RangeThemeStyle(newThemeName, { ...customEmptyThemeWithBorderStyle });
|
|
2070
|
+
commandService.executeCommand(AddTableThemeCommand.id, {
|
|
2071
|
+
unitId,
|
|
2072
|
+
tableId,
|
|
2073
|
+
themeStyle: newTheme
|
|
2074
|
+
});
|
|
2075
|
+
};
|
|
2076
|
+
const setCustomTheme = (themeName, tableThemeStyle) => {
|
|
2077
|
+
commandService.executeCommand(SetRangeThemeMutation.id, {
|
|
2078
|
+
unitId,
|
|
2079
|
+
subUnitId,
|
|
2080
|
+
styleName: themeName,
|
|
2081
|
+
style: tableThemeStyle
|
|
2082
|
+
});
|
|
2083
|
+
};
|
|
2084
|
+
const removeCustomTheme = (themeName) => {
|
|
2085
|
+
commandService.executeCommand(RemoveTableThemeCommand.id, {
|
|
2086
|
+
unitId,
|
|
2087
|
+
tableId,
|
|
2088
|
+
themeName
|
|
2089
|
+
});
|
|
2090
|
+
};
|
|
2091
|
+
useEffect(() => {
|
|
2092
|
+
setRefresh(Math.random());
|
|
2093
|
+
}, [rangeThemeMapChanged, tableRefresh]);
|
|
2094
|
+
if (!table) return null;
|
|
2095
|
+
const headerBgIsDark = new ColorKit(headerBg).isDark();
|
|
2096
|
+
const firstRowBgIsDark = new ColorKit(firstRowBg).isDark();
|
|
2097
|
+
const secondRowBgIsDark = new ColorKit(secondRowBg).isDark();
|
|
2098
|
+
const lastRowBgIsDark = new ColorKit(lastRowBg).isDark();
|
|
2099
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2100
|
+
/* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table.defaultStyle") }),
|
|
2101
|
+
/* @__PURE__ */ jsx("div", {
|
|
2102
|
+
className: "univer-flex univer-gap-2",
|
|
2103
|
+
children: defaultRangeThemes.map((item) => {
|
|
2104
|
+
var _rangeThemeItem$getHe, _rangeThemeItem$getFi, _rangeThemeItem$getSe, _rangeThemeItem$getLa;
|
|
2105
|
+
const rangeThemeItem = rangeThemeModel.getDefaultRangeThemeStyle(item);
|
|
2106
|
+
const headerRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe === void 0 || (_rangeThemeItem$getHe = _rangeThemeItem$getHe.bg) === null || _rangeThemeItem$getHe === void 0 ? void 0 : _rangeThemeItem$getHe.rgb) || "rgb(255, 255, 255)";
|
|
2107
|
+
const firstRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi === void 0 || (_rangeThemeItem$getFi = _rangeThemeItem$getFi.bg) === null || _rangeThemeItem$getFi === void 0 ? void 0 : _rangeThemeItem$getFi.rgb) || "rgb(255, 255, 255)";
|
|
2108
|
+
const secondRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe === void 0 || (_rangeThemeItem$getSe = _rangeThemeItem$getSe.bg) === null || _rangeThemeItem$getSe === void 0 ? void 0 : _rangeThemeItem$getSe.rgb) || "rgb(255, 255, 255)";
|
|
2109
|
+
const lastRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa === void 0 || (_rangeThemeItem$getLa = _rangeThemeItem$getLa.bg) === null || _rangeThemeItem$getLa === void 0 ? void 0 : _rangeThemeItem$getLa.rgb) || "rgb(255, 255, 255)";
|
|
2110
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2111
|
+
className: clsx("univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px [&>div]:univer-box-border [&>div]:univer-h-2.5", { "univer-border-blue-500": item === themeConfig.theme }),
|
|
2112
|
+
onClick: () => handleThemeChange(item),
|
|
2113
|
+
children: [
|
|
2114
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2115
|
+
background: headerRowBg,
|
|
2116
|
+
border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2117
|
+
} }),
|
|
2118
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2119
|
+
background: firstRowBg,
|
|
2120
|
+
border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2121
|
+
} }),
|
|
2122
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2123
|
+
background: secondRowBg,
|
|
2124
|
+
border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2125
|
+
} }),
|
|
2126
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2127
|
+
background: lastRowBg,
|
|
2128
|
+
border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2129
|
+
} })
|
|
2130
|
+
]
|
|
2131
|
+
}, item);
|
|
2132
|
+
})
|
|
2133
|
+
}),
|
|
2134
|
+
/* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table.customStyle") }),
|
|
2135
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2136
|
+
className: clsx("univer-w-full univer-rounded-sm", borderClassName),
|
|
2137
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2138
|
+
className: "univer-flex univer-flex-wrap univer-gap-2 univer-p-2",
|
|
2139
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2140
|
+
className: clsx("univer-h-10 univer-w-8 univer-cursor-pointer univer-p-px univer-text-center univer-leading-10", borderClassName),
|
|
2141
|
+
onClick: handleAddCustomTheme,
|
|
2142
|
+
children: "+"
|
|
2143
|
+
}), customRangeThemes.map((item) => {
|
|
2144
|
+
var _rangeThemeItem$getHe2, _rangeThemeItem$getFi2, _rangeThemeItem$getSe2, _rangeThemeItem$getLa2;
|
|
2145
|
+
const rangeThemeItem = rangeThemeModel.getCustomRangeThemeStyle(unitId, item);
|
|
2146
|
+
const headerRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe2 = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe2 === void 0 || (_rangeThemeItem$getHe2 = _rangeThemeItem$getHe2.bg) === null || _rangeThemeItem$getHe2 === void 0 ? void 0 : _rangeThemeItem$getHe2.rgb;
|
|
2147
|
+
const firstRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi2 = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi2 === void 0 || (_rangeThemeItem$getFi2 = _rangeThemeItem$getFi2.bg) === null || _rangeThemeItem$getFi2 === void 0 ? void 0 : _rangeThemeItem$getFi2.rgb;
|
|
2148
|
+
const secondRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe2 = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe2 === void 0 || (_rangeThemeItem$getSe2 = _rangeThemeItem$getSe2.bg) === null || _rangeThemeItem$getSe2 === void 0 ? void 0 : _rangeThemeItem$getSe2.rgb;
|
|
2149
|
+
const lastRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa2 = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa2 === void 0 || (_rangeThemeItem$getLa2 = _rangeThemeItem$getLa2.bg) === null || _rangeThemeItem$getLa2 === void 0 ? void 0 : _rangeThemeItem$getLa2.rgb;
|
|
2150
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2151
|
+
className: clsx("univer-relative univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px", { "univer-border-blue-500": item === themeConfig.theme }),
|
|
2152
|
+
onClick: () => handleThemeChange(item),
|
|
2153
|
+
onMouseEnter: () => setHoverCustomId(item),
|
|
2154
|
+
onMouseLeave: () => setHoverCustomId(null),
|
|
2155
|
+
children: [
|
|
2156
|
+
/* @__PURE__ */ jsx("div", {
|
|
2157
|
+
className: "univer-box-border univer-h-2.5",
|
|
2158
|
+
style: {
|
|
2159
|
+
background: headerRowBg !== null && headerRowBg !== void 0 ? headerRowBg : TABLE_BORDER_NONE,
|
|
2160
|
+
border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2161
|
+
}
|
|
2162
|
+
}),
|
|
2163
|
+
/* @__PURE__ */ jsx("div", {
|
|
2164
|
+
className: "univer-box-border univer-h-2.5",
|
|
2165
|
+
style: {
|
|
2166
|
+
background: firstRowBg !== null && firstRowBg !== void 0 ? firstRowBg : TABLE_BORDER_NONE,
|
|
2167
|
+
border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2168
|
+
}
|
|
2169
|
+
}),
|
|
2170
|
+
/* @__PURE__ */ jsx("div", {
|
|
2171
|
+
className: "univer-box-border univer-h-2.5",
|
|
2172
|
+
style: {
|
|
2173
|
+
background: secondRowBg !== null && secondRowBg !== void 0 ? secondRowBg : TABLE_BORDER_NONE,
|
|
2174
|
+
border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2175
|
+
}
|
|
2176
|
+
}),
|
|
2177
|
+
/* @__PURE__ */ jsx("div", {
|
|
2178
|
+
className: "univer-box-border univer-h-2.5",
|
|
2179
|
+
style: {
|
|
2180
|
+
background: lastRowBg !== null && lastRowBg !== void 0 ? lastRowBg : TABLE_BORDER_NONE,
|
|
2181
|
+
border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2182
|
+
}
|
|
2183
|
+
}),
|
|
2184
|
+
/* @__PURE__ */ jsx("div", {
|
|
2185
|
+
className: "univer-absolute univer-right-[-3px] univer-top-[-3px] univer-size-3 univer-rounded-md univer-bg-gray-200 univer-text-center univer-text-xs univer-leading-[10px]",
|
|
2186
|
+
style: { display: hoverCustomId === item ? "block" : "none" },
|
|
2187
|
+
onClick: (e) => {
|
|
2188
|
+
e.stopPropagation();
|
|
2189
|
+
removeCustomTheme(item);
|
|
2190
|
+
},
|
|
2191
|
+
children: "x"
|
|
2192
|
+
})
|
|
2193
|
+
]
|
|
2194
|
+
}, item);
|
|
2195
|
+
})]
|
|
2196
|
+
}), customSelected && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { className: "univer-h-px univer-w-full univer-bg-gray-200" }), /* @__PURE__ */ jsxs("div", {
|
|
2197
|
+
className: "univer-flex univer-flex-col univer-gap-2 univer-p-2",
|
|
2198
|
+
children: [
|
|
2199
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2200
|
+
className: "univer-flex univer-h-9 univer-gap-2",
|
|
2201
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2202
|
+
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
2203
|
+
"univer-text-white": headerBgIsDark,
|
|
2204
|
+
"univer-text-gray-900": !headerBgIsDark
|
|
2205
|
+
}),
|
|
2206
|
+
style: { background: headerBg },
|
|
2207
|
+
children: localeService.t("sheets-table.header")
|
|
2208
|
+
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
2209
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
2210
|
+
className: "univer-p-2",
|
|
2211
|
+
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
2212
|
+
value: headerBg,
|
|
2213
|
+
onChange: (val) => {
|
|
2214
|
+
const headerRowStyle = processStyleWithBorderStyle("headerRowStyle", {
|
|
2215
|
+
bg: { rgb: val },
|
|
2216
|
+
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
2217
|
+
});
|
|
2218
|
+
setCustomTheme(table.getTableStyleId(), { headerRowStyle });
|
|
2219
|
+
}
|
|
2220
|
+
})
|
|
2221
|
+
}),
|
|
2222
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2223
|
+
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
2224
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2225
|
+
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName, {
|
|
2226
|
+
"univer-text-white": headerBgIsDark,
|
|
2227
|
+
"univer-text-gray-900": !headerBgIsDark
|
|
2228
|
+
}),
|
|
2229
|
+
style: { background: headerBg }
|
|
2230
|
+
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
2231
|
+
})
|
|
2232
|
+
})]
|
|
2233
|
+
}),
|
|
2234
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2235
|
+
className: "univer-flex univer-h-9 univer-gap-2",
|
|
2236
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2237
|
+
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
2238
|
+
"univer-text-white": firstRowBgIsDark,
|
|
2239
|
+
"univer-text-gray-900": !firstRowBgIsDark
|
|
2240
|
+
}),
|
|
2241
|
+
style: { background: firstRowBg },
|
|
2242
|
+
children: localeService.t("sheets-table.firstLine")
|
|
2243
|
+
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
2244
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
2245
|
+
className: "univer-p-2",
|
|
2246
|
+
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
2247
|
+
value: firstRowBg,
|
|
2248
|
+
onChange: (val) => {
|
|
2249
|
+
setCustomTheme(table.getTableStyleId(), { firstRowStyle: {
|
|
2250
|
+
bg: { rgb: val },
|
|
2251
|
+
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
2252
|
+
} });
|
|
2253
|
+
}
|
|
2254
|
+
})
|
|
2255
|
+
}),
|
|
2256
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2257
|
+
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
2258
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2259
|
+
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
2260
|
+
style: { background: firstRowBg }
|
|
2261
|
+
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
2262
|
+
})
|
|
2263
|
+
})]
|
|
2264
|
+
}),
|
|
2265
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2266
|
+
className: "univer-flex univer-h-9 univer-gap-2",
|
|
2267
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2268
|
+
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
2269
|
+
"univer-text-white": secondRowBgIsDark,
|
|
2270
|
+
"univer-text-gray-900": !secondRowBgIsDark
|
|
2271
|
+
}),
|
|
2272
|
+
style: { background: secondRowBg },
|
|
2273
|
+
children: localeService.t("sheets-table.secondLine")
|
|
2274
|
+
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
2275
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
2276
|
+
className: "univer-p-2",
|
|
2277
|
+
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
2278
|
+
value: secondRowBg,
|
|
2279
|
+
onChange: (val) => setCustomTheme(table.getTableStyleId(), { secondRowStyle: {
|
|
2280
|
+
bg: { rgb: val },
|
|
2281
|
+
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
2282
|
+
} })
|
|
2283
|
+
})
|
|
2284
|
+
}),
|
|
2285
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2286
|
+
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
2287
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2288
|
+
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
2289
|
+
style: { background: secondRowBg }
|
|
2290
|
+
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
2291
|
+
})
|
|
2292
|
+
})]
|
|
2293
|
+
}),
|
|
2294
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2295
|
+
className: "univer-flex univer-h-9 univer-gap-2",
|
|
2296
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2297
|
+
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
2298
|
+
"univer-text-white": lastRowBgIsDark,
|
|
2299
|
+
"univer-text-gray-900": !lastRowBgIsDark
|
|
2300
|
+
}),
|
|
2301
|
+
style: { background: lastRowBg },
|
|
2302
|
+
children: localeService.t("sheets-table.footer")
|
|
2303
|
+
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
2304
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
2305
|
+
className: "univer-p-2",
|
|
2306
|
+
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
2307
|
+
value: lastRowBg,
|
|
2308
|
+
onChange: (val) => {
|
|
2309
|
+
const lastRowStyle = processStyleWithBorderStyle("lastRowStyle", {
|
|
2310
|
+
bg: { rgb: val },
|
|
2311
|
+
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
2312
|
+
});
|
|
2313
|
+
setCustomTheme(table.getTableStyleId(), { lastRowStyle });
|
|
2314
|
+
}
|
|
2315
|
+
})
|
|
2316
|
+
}),
|
|
2317
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2318
|
+
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
2319
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2320
|
+
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
2321
|
+
style: { background: lastRowBg }
|
|
2322
|
+
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
2323
|
+
})
|
|
2324
|
+
})]
|
|
2325
|
+
})
|
|
2326
|
+
]
|
|
2327
|
+
})] })]
|
|
2328
|
+
})
|
|
2329
|
+
] });
|
|
2330
|
+
};
|
|
2331
|
+
|
|
2332
|
+
//#endregion
|
|
2333
|
+
//#region src/menu/menu.ts
|
|
2334
|
+
const SHEET_TABLE_CONTEXT_INSERT_MENU_ID = "sheet.table.context-insert_menu-id";
|
|
2335
|
+
const SHEET_TABLE_CONTEXT_REMOVE_MENU_ID = "sheet.table.context-remove_menu-id";
|
|
2336
|
+
function sheetTableToolbarInsertMenuFactory(accessor) {
|
|
2337
|
+
return {
|
|
2338
|
+
id: OpenTableSelectorOperation.id,
|
|
2339
|
+
type: MenuItemType.BUTTON,
|
|
2340
|
+
icon: TABLE_TOOLBAR_BUTTON,
|
|
2341
|
+
tooltip: "sheets-table.title",
|
|
2342
|
+
title: "sheets-table.title",
|
|
2343
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
2344
|
+
disabled$: getCurrentRangeDisable$(accessor, {}, true)
|
|
2345
|
+
};
|
|
2346
|
+
}
|
|
2347
|
+
function SheetTableInsertContextMenuFactory(accessor) {
|
|
2348
|
+
return {
|
|
2349
|
+
id: SHEET_TABLE_CONTEXT_INSERT_MENU_ID,
|
|
2350
|
+
type: MenuItemType.SUBITEMS,
|
|
2351
|
+
icon: "InsertDoubleIcon",
|
|
2352
|
+
title: "sheets-table.insert.main",
|
|
2353
|
+
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
2354
|
+
};
|
|
2355
|
+
}
|
|
2356
|
+
function SheetTableRemoveContextMenuFactory(accessor) {
|
|
2357
|
+
return {
|
|
2358
|
+
id: SHEET_TABLE_CONTEXT_REMOVE_MENU_ID,
|
|
2359
|
+
type: MenuItemType.SUBITEMS,
|
|
2360
|
+
icon: "ReduceDoubleIcon",
|
|
2361
|
+
title: "sheets-table.remove.main",
|
|
2362
|
+
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
function SheetTableInsertRowMenuFactory(accessor) {
|
|
2366
|
+
return {
|
|
2367
|
+
id: SheetTableInsertRowCommand.id,
|
|
2368
|
+
type: MenuItemType.BUTTON,
|
|
2369
|
+
title: "sheets-table.insert.row",
|
|
2370
|
+
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
function SheetTableInsertColMenuFactory(accessor) {
|
|
2374
|
+
return {
|
|
2375
|
+
id: SheetTableInsertColCommand.id,
|
|
2376
|
+
title: "sheets-table.insert.col",
|
|
2377
|
+
type: MenuItemType.BUTTON
|
|
2378
|
+
};
|
|
2379
|
+
}
|
|
2380
|
+
function SheetTableRemoveRowMenuFactory(accessor) {
|
|
2381
|
+
return {
|
|
2382
|
+
id: SheetTableRemoveRowCommand.id,
|
|
2383
|
+
type: MenuItemType.BUTTON,
|
|
2384
|
+
title: "sheets-table.remove.row",
|
|
2385
|
+
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2386
|
+
};
|
|
2387
|
+
}
|
|
2388
|
+
function SheetTableRemoveColMenuFactory(accessor) {
|
|
2389
|
+
return {
|
|
2390
|
+
id: SheetTableRemoveColCommand.id,
|
|
2391
|
+
title: "sheets-table.remove.col",
|
|
2392
|
+
type: MenuItemType.BUTTON
|
|
2393
|
+
};
|
|
2394
|
+
}
|
|
2395
|
+
function getSheetTableRowColOperationHidden$(accessor) {
|
|
2396
|
+
const sheetsSelectionsService = accessor.get(SheetsSelectionsService);
|
|
2397
|
+
return accessor.get(IUniverInstanceService).getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => {
|
|
2398
|
+
if (!workbook) return of(true);
|
|
2399
|
+
return workbook.activeSheet$.pipe(switchMap((sheet) => {
|
|
2400
|
+
if (!sheet) return of(true);
|
|
2401
|
+
return sheetsSelectionsService.selectionMoveEnd$.pipe(switchMap((selections) => {
|
|
2402
|
+
if (!selections.length || selections.length > 1) return of(true);
|
|
2403
|
+
const range = selections[0].range;
|
|
2404
|
+
return of(!accessor.get(SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range));
|
|
2405
|
+
}));
|
|
2406
|
+
}));
|
|
2407
|
+
}));
|
|
2408
|
+
}
|
|
2409
|
+
function getSheetTableHeaderOperationHidden$(accessor) {
|
|
2410
|
+
const sheetsSelectionsService = accessor.get(SheetsSelectionsService);
|
|
2411
|
+
return accessor.get(IUniverInstanceService).getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => {
|
|
2412
|
+
if (!workbook) return of(true);
|
|
2413
|
+
return workbook.activeSheet$.pipe(switchMap((sheet) => {
|
|
2414
|
+
if (!sheet) return of(true);
|
|
2415
|
+
return sheetsSelectionsService.selectionMoveEnd$.pipe(switchMap((selections) => {
|
|
2416
|
+
if (!selections.length || selections.length > 1) return of(true);
|
|
2417
|
+
const range = selections[0].range;
|
|
2418
|
+
const isInTable = accessor.get(SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range);
|
|
2419
|
+
if (!isInTable) return of(true);
|
|
2420
|
+
const tableRange = isInTable.getRange();
|
|
2421
|
+
if (range.startRow === tableRange.startRow) return of(true);
|
|
2422
|
+
return of(false);
|
|
2423
|
+
}));
|
|
2424
|
+
}));
|
|
2425
|
+
}));
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
//#endregion
|
|
2429
|
+
//#region src/menu/schema.ts
|
|
2430
|
+
const menuSchema = {
|
|
2431
|
+
[RibbonDataGroup.ORGANIZATION]: { [OpenTableSelectorOperation.id]: {
|
|
2432
|
+
order: 0,
|
|
2433
|
+
menuItemFactory: sheetTableToolbarInsertMenuFactory
|
|
2434
|
+
} },
|
|
2435
|
+
[ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.LAYOUT]: {
|
|
2436
|
+
[SHEET_TABLE_CONTEXT_INSERT_MENU_ID]: {
|
|
2437
|
+
order: 5,
|
|
2438
|
+
menuItemFactory: SheetTableInsertContextMenuFactory,
|
|
2439
|
+
[SheetTableInsertRowCommand.id]: {
|
|
2440
|
+
order: 1,
|
|
2441
|
+
menuItemFactory: SheetTableInsertRowMenuFactory
|
|
2442
|
+
},
|
|
2443
|
+
[SheetTableInsertColCommand.id]: {
|
|
2444
|
+
order: 2,
|
|
2445
|
+
menuItemFactory: SheetTableInsertColMenuFactory
|
|
2446
|
+
}
|
|
2447
|
+
},
|
|
2448
|
+
[SHEET_TABLE_CONTEXT_REMOVE_MENU_ID]: {
|
|
2449
|
+
order: 6,
|
|
2450
|
+
menuItemFactory: SheetTableRemoveContextMenuFactory,
|
|
2451
|
+
[SheetTableRemoveRowCommand.id]: {
|
|
2452
|
+
order: 1,
|
|
2453
|
+
menuItemFactory: SheetTableRemoveRowMenuFactory
|
|
2454
|
+
},
|
|
2455
|
+
[SheetTableRemoveColCommand.id]: {
|
|
2456
|
+
order: 2,
|
|
2457
|
+
menuItemFactory: SheetTableRemoveColMenuFactory
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
} }
|
|
2461
|
+
};
|
|
2462
|
+
|
|
2463
|
+
//#endregion
|
|
2464
|
+
//#region src/menu/sheet-table-menu.controller.ts
|
|
2465
|
+
/**
|
|
2466
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2467
|
+
*
|
|
2468
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2469
|
+
* you may not use this file except in compliance with the License.
|
|
2470
|
+
* You may obtain a copy of the License at
|
|
2471
|
+
*
|
|
2472
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2473
|
+
*
|
|
2474
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2475
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2476
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2477
|
+
* See the License for the specific language governing permissions and
|
|
2478
|
+
* limitations under the License.
|
|
2479
|
+
*/
|
|
2480
|
+
let SheetTableMenuController = class SheetTableMenuController extends Disposable {
|
|
2481
|
+
constructor(_componentManager, _menuManagerService) {
|
|
2482
|
+
super();
|
|
2483
|
+
this._componentManager = _componentManager;
|
|
2484
|
+
this._menuManagerService = _menuManagerService;
|
|
2485
|
+
this._initComponents();
|
|
2486
|
+
this._initMenu();
|
|
2487
|
+
}
|
|
2488
|
+
_initComponents() {
|
|
2489
|
+
[
|
|
2490
|
+
[TABLE_TOOLBAR_BUTTON, TableIcon],
|
|
2491
|
+
[TABLE_SELECTOR_DIALOG, SheetTableSelector],
|
|
2492
|
+
[SHEET_TABLE_THEME_PANEL, SheetTableThemePanel]
|
|
2493
|
+
].forEach(([key, comp]) => {
|
|
2494
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
_initMenu() {
|
|
2498
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
2499
|
+
}
|
|
2500
|
+
};
|
|
2501
|
+
SheetTableMenuController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IMenuManagerService))], SheetTableMenuController);
|
|
2502
|
+
|
|
2503
|
+
//#endregion
|
|
2504
|
+
//#region src/plugin.ts
|
|
2505
|
+
let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends Plugin {
|
|
2506
|
+
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService, _renderManagerService) {
|
|
2507
|
+
super();
|
|
2508
|
+
this._config = _config;
|
|
2509
|
+
this._injector = _injector;
|
|
2510
|
+
this._commandService = _commandService;
|
|
2511
|
+
this._configService = _configService;
|
|
2512
|
+
this._renderManagerService = _renderManagerService;
|
|
2513
|
+
const { menu, ...rest } = merge({}, defaultPluginConfig, this._config);
|
|
2514
|
+
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
2515
|
+
this._configService.setConfig(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY, rest);
|
|
2516
|
+
this._initRegisterCommand();
|
|
2517
|
+
}
|
|
2518
|
+
onStarting() {
|
|
2519
|
+
registerDependencies(this._injector, [
|
|
2520
|
+
[SheetsTableComponentController],
|
|
2521
|
+
[SheetsTableUiService],
|
|
2522
|
+
[SheetTableMenuController],
|
|
2523
|
+
[SheetTableThemeUIController],
|
|
2524
|
+
[SheetTableSelectionController]
|
|
2525
|
+
]);
|
|
2526
|
+
}
|
|
2527
|
+
onReady() {
|
|
2528
|
+
touchDependencies(this._injector, [
|
|
2529
|
+
[SheetsTableComponentController],
|
|
2530
|
+
[SheetsTableUiService],
|
|
2531
|
+
[SheetTableMenuController],
|
|
2532
|
+
[SheetTableThemeUIController],
|
|
2533
|
+
[SheetTableSelectionController]
|
|
2534
|
+
]);
|
|
2535
|
+
}
|
|
2536
|
+
onRendered() {
|
|
2537
|
+
this._registerRenderModules();
|
|
2538
|
+
}
|
|
2539
|
+
_registerRenderModules() {
|
|
2540
|
+
const renderDependencies = [[SheetsTableFilterButtonRenderController], [SheetsTableRenderController]];
|
|
2541
|
+
if (this._config.hideAnchor !== true) renderDependencies.push([SheetTableAnchorController]);
|
|
2542
|
+
renderDependencies.forEach((m) => {
|
|
2543
|
+
this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, m));
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
_initRegisterCommand() {
|
|
2547
|
+
[OpenTableFilterPanelOperation, OpenTableSelectorOperation].forEach((m) => this._commandService.registerCommand(m));
|
|
2548
|
+
}
|
|
2549
|
+
};
|
|
2550
|
+
_defineProperty(UniverSheetsTableUIPlugin, "pluginName", PLUGIN_NAME);
|
|
2551
|
+
_defineProperty(UniverSheetsTableUIPlugin, "packageName", name);
|
|
2552
|
+
_defineProperty(UniverSheetsTableUIPlugin, "version", version);
|
|
2553
|
+
_defineProperty(UniverSheetsTableUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
2554
|
+
UniverSheetsTableUIPlugin = __decorate([
|
|
2555
|
+
DependentOn(UniverSheetsTablePlugin),
|
|
2556
|
+
__decorateParam(1, Inject(Injector)),
|
|
2557
|
+
__decorateParam(2, Inject(ICommandService)),
|
|
2558
|
+
__decorateParam(3, IConfigService),
|
|
2559
|
+
__decorateParam(4, IRenderManagerService)
|
|
2560
|
+
], UniverSheetsTableUIPlugin);
|
|
2561
|
+
|
|
2562
|
+
//#endregion
|
|
2563
|
+
export { UniverSheetsTableUIPlugin };
|