Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat: table support (#4831)
ybzky1442329d903a
diff --git a/examples/package.json b/examples/package.jsonindex 3885979b18..4fcd3d9e06 100644--- a/examples/package.json+++ b/examples/package.json@@ -60,6 +60,8 @@"@univerjs/sheets-sort": "workspace:*","@univerjs/sheets-sort-ui": "workspace:*","@univerjs/sheets-source-binding": "workspace:*",+ "@univerjs/sheets-table": "workspace:*",+ "@univerjs/sheets-table-ui": "workspace:*","@univerjs/sheets-thread-comment": "workspace:*","@univerjs/sheets-thread-comment-ui": "workspace:*","@univerjs/sheets-ui": "workspace:*",diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.tsindex c88ded0f74..8068cca3ac 100644--- a/examples/src/sheets/main.ts+++ b/examples/src/sheets/main.ts@@ -38,6 +38,8 @@ import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';import { UniverSheetsNumfmtUIPlugin } from '@univerjs/sheets-numfmt-ui';import { UniverSheetsSortPlugin } from '@univerjs/sheets-sort';import { UniverSheetsBindingSourcePlugin } from '@univerjs/sheets-source-binding';+import { UniverSheetTablePlugin } from '@univerjs/sheets-table';+import { UniverSheetTableUIPlugin } from '@univerjs/sheets-table-ui';import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment';import { UniverSheetsThreadCommentUIPlugin } from '@univerjs/sheets-thread-comment-ui';import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';@@ -66,6 +68,7 @@ import '@univerjs/sheets-zen-editor/facade';import '@univerjs/sheets-source-binding/facade';import '@univerjs/sheets-crosshair-highlight/facade';import '@univerjs/sheets-formula-ui/facade';+import '@univerjs/sheets-table/facade';import '@univerjs/sheets-sort/facade';import '@univerjs/network/facade';import '../global.css';@@ -136,6 +139,9 @@ function createNewInstance() {univer.registerPlugin(UniverSheetsThreadCommentUIPlugin);univer.registerPlugin(UniverSheetsBindingSourcePlugin);univer.registerPlugin(UniverSheetsCustomMenuPlugin);++ univer.registerPlugin(UniverSheetTablePlugin);+ univer.registerPlugin(UniverSheetTableUIPlugin);univer.registerPlugin(UniverNetworkPlugin);// If we are running in e2e platform, we should immediately register the debugger plugin.diff --git a/packages/engine-render/src/components/sheets/sheet.render-skeleton.ts b/packages/engine-render/src/components/sheets/sheet.render-skeleton.tsindex 270ea54913..b5c715667c 100644--- a/packages/engine-render/src/components/sheets/sheet.render-skeleton.ts+++ b/packages/engine-render/src/components/sheets/sheet.render-skeleton.ts@@ -1372,13 +1372,15 @@ export class SpreadsheetSkeleton extends SheetSkeleton {break;}+ const themeStyleBackground = cell.themeStyle?.bd;+const style = this._styles.getStyleByCell(cell);- if (!style) {+ if (!style && !themeStyleBackground) {isAddBorders = false;break;}- const props: Nullable<IBorderStyleData> = style.bd?.[type];+ const props: Nullable<IBorderStyleData> = style?.bd?.[type] ?? themeStyleBackground?.[type];if (props) {const rgb = getColorStyle(props.cl) || COLOR_BLACK_RGB;borders.push({diff --git a/packages/sheets-table-ui/README.md b/packages/sheets-table-ui/README.mdnew file mode 100644index 0000000000..ce33d7531c--- /dev/null+++ b/packages/sheets-table-ui/README.md@@ -0,0 +1,21 @@+# @univerjs/sheets-table-ui++### Installation++```shell+npm i @univerjs/sheets-table-ui+```++### Import++```ts+import { UniverSheetTableUIPlugin } from '@univerjs/sheets-table-ui'++univer.registerPlugin(UniverSheetTableUIPlugin);+```++<!-- Links -->+[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-table-ui?style=flat-square+[npm-version-link]: https://npmjs.com/package/@univerjs/sheets-table-ui+[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-table-ui?style=flat-square+[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-table-ui?style=flat-squarediff --git a/packages/sheets-table-ui/package.json b/packages/sheets-table-ui/package.jsonnew file mode 100644index 0000000000..cc78d330f3--- /dev/null+++ b/packages/sheets-table-ui/package.json@@ -0,0 +1,98 @@+{+ "name": "@univerjs/sheets-table-ui",+ "version": "0.6.6",+ "private": false,+ "description": "A library for connect and bind data from other sources to Univer Sheets",+ "author": "DreamNum <[email protected]>",+ "license": "Apache-2.0",+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/univer"+ },+ "homepage": "https://univer.ai",+ "repository": {+ "type": "git",+ "url": "https://github.com/dream-num/univer"+ },+ "bugs": {+ "url": "https://github.com/dream-num/univer/issues"+ },+ "keywords": [+ "univer",+ "sheets",+ "table"+ ],+ "exports": {+ ".": "./src/index.ts",+ "./*": "./src/*",+ "./facade": "./src/facade/index.ts",+ "./locale/*": "./src/locale/*.ts"+ },+ "main": "./src/index.ts",+ "types": "./lib/types/index.d.ts",+ "publishConfig": {+ "access": "public",+ "main": "./lib/es/index.js",+ "module": "./lib/es/index.js",+ "exports": {+ ".": {+ "import": "./lib/es/index.js",+ "require": "./lib/cjs/index.js",+ "types": "./lib/types/index.d.ts"+ },+ "./*": {+ "import": "./lib/es/*",+ "require": "./lib/cjs/*",+ "types": "./lib/types/index.d.ts"+ },+ "./locale/*": {+ "import": "./lib/es/locale/*.js",+ "require": "./lib/cjs/locale/*.js",+ "types": "./lib/types/locale/*.d.ts"+ },+ "./lib/*": "./lib/*"+ }+ },+ "directories": {+ "lib": "lib"+ },+ "files": [+ "lib"+ ],+ "scripts": {+ "test": "vitest run",+ "test:watch": "vitest",+ "coverage": "vitest run --coverage",+ "lint:types": "tsc --noEmit",+ "build": "univer-cli build"+ },+ "peerDependencies": {+ "react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",+ "rxjs": ">=7.0.0"+ },+ "dependencies": {+ "@univerjs/core": "workspace:*",+ "@univerjs/design": "workspace:*",+ "@univerjs/engine-formula": "workspace:*",+ "@univerjs/engine-render": "workspace:*",+ "@univerjs/icons": "^0.3.2",+ "@univerjs/sheets": "workspace:*",+ "@univerjs/sheets-formula-ui": "workspace:*",+ "@univerjs/sheets-sort": "workspace:*",+ "@univerjs/sheets-table": "workspace:*",+ "@univerjs/sheets-ui": "workspace:*",+ "@univerjs/ui": "workspace:*"+ },+ "devDependencies": {+ "@univerjs-infra/shared": "workspace:*",+ "less": "^4.2.2",+ "postcss": "^8.5.3",+ "react": "18.3.1",+ "react-dom": "18.3.1",+ "rxjs": "^7.8.1",+ "tailwindcss": "^3.4.17",+ "typescript": "^5.7.3",+ "vite": "^6.2.1",+ "vitest": "^3.0.8"+ }+}diff --git a/packages/sheets-table-ui/src/commands/operations/open-table-filter-dialog.opration.ts b/packages/sheets-table-ui/src/commands/operations/open-table-filter-dialog.opration.tsnew file mode 100644index 0000000000..1b78cce790--- /dev/null+++ b/packages/sheets-table-ui/src/commands/operations/open-table-filter-dialog.opration.ts@@ -0,0 +1,85 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand } from '@univerjs/core';+import { CommandType, IContextService } from '@univerjs/core';+import { TableManager } from '@univerjs/sheets-table';+import { SHEETS_TABLE_FILTER_PANEL_OPENED_KEY } from '../../const';+import { SheetsTableComponentController } from '../../controllers/sheet-table-component.controller';++export interface IOpenTableFilterPanelOperationParams {+ row: number;+ col: number;+ unitId: string;+ subUnitId: string;+ tableId: string;+}+export const OpenTableFilterPanelOperation: ICommand<IOpenTableFilterPanelOperationParams> = {+ type: CommandType.OPERATION,+ id: 'sheet.operation.open-table-filter-panel',+ async handler(accessor, params) {+ if (!params) {+ return false;+ }++ const { row, col, unitId, subUnitId, tableId } = params;+ const tableManager = accessor.get(TableManager);+ const contextService = accessor.get(IContextService);+ const sheetsTableComponentController = accessor.get(SheetsTableComponentController);++ const table = tableManager.getTable(unitId, tableId);+ if (!table) {+ return false;+ }+ if (!contextService.getContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY)) {+ sheetsTableComponentController.setCurrentTableFilterInfo({ unitId, subUnitId, row, tableId, column: col });+ contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, true);+ }++ return true;++ // const tableRange = table.getRange();+ // const tableFilter = table.getTableFilterColumn(col - tableRange.startColumn);++ // const dialogServiceProps = {+ // id: UNIVER_SHEET_TABLE_FILTER_PANEL_ID,+ // draggable: true,+ // width: 312,+ // dialogStyles: {+ // header: { padding: '16px 16px 0', height: 0 },+ // body: { padding: '0 16px 16px' },+ // },+ // closable: false,+ // children: {+ // label: SHEETS_TABLE_FILTER_PANEL_OPENED_KEY,+ // unitId,+ // subUnitId,+ // key: `${row}-${col}-${tableId || ''}`,+ // tableFilter,+ // tableId,+ // columnIndex: col - tableRange.startColumn,+ // },++ // onClose: (): void => {+ // dialogService.close(UNIVER_SHEET_TABLE_FILTER_PANEL_ID);+ // },+ // destroyOnClose: true,+ // };+ // dialogService.open(dialogServiceProps);++ // return true;+ },+};diff --git a/packages/sheets-table-ui/src/commands/operations/open-table-selector.operation.ts b/packages/sheets-table-ui/src/commands/operations/open-table-selector.operation.tsnew file mode 100644index 0000000000..5ef17b28e1--- /dev/null+++ b/packages/sheets-table-ui/src/commands/operations/open-table-selector.operation.ts@@ -0,0 +1,107 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IAccessor, IRange } from '@univerjs/core';+import type { IAddSheetTableCommandParams } from '@univerjs/sheets-table';+import { CommandType, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';+import { expandToContinuousRange, getSheetCommandTarget, isSingleCellSelection, SheetsSelectionsService } from '@univerjs/sheets';+import { AddSheetTableCommand } from '@univerjs/sheets-table';+import { IDialogService } from '@univerjs/ui';+import { TABLE_SELECTOR_DIALOG } from '../../const';++export const OpenTableSelectorOperation = {+ type: CommandType.OPERATION,+ id: 'sheet.operation.open-table-selector',+ async handler(accessor: IAccessor) {+ const univerInstanceService = accessor.get(IUniverInstanceService);+ const commandService = accessor.get(ICommandService);++ const target = getSheetCommandTarget(univerInstanceService);+ if (!target) {+ return false;+ }++ const { unitId, subUnitId, worksheet } = target;+ const sheetsSelectionsService = accessor.get(SheetsSelectionsService);++ const lastSelection = sheetsSelectionsService.getCurrentLastSelection();+ const range = lastSelection?.range ?? { startRow: 0, endRow: 0, startColumn: 0, endColumn: 0 };++ const isSingleCell = isSingleCellSelection(lastSelection);+ const extendedRange = isSingleCell ? expandToContinuousRange(range, { up: true, left: true, right: true, down: true }, worksheet) : range;++ const rangeInfo = await openRangeSelector(accessor, unitId, subUnitId, extendedRange);+ if (!rangeInfo) {+ return false;+ }++ commandService.executeCommand<IAddSheetTableCommandParams>(AddSheetTableCommand.id, { ...rangeInfo });++ return true;+ },+};++export interface ITableSelectionInfo {+ unitId: string;+ subUnitId: string;+ range: IRange;+ tableId?: string;+}++export async function openRangeSelector(+ accessor: IAccessor,+ unitId: string,+ subUnitId: string,+ range: IRange,+ tableId?: string+): Promise<ITableSelectionInfo | null> {+ const dialogService = accessor.get(IDialogService);+ const localeService = accessor.get(LocaleService);++ return new Promise((resolve) => {+ const dialogProps = {+ unitId,+ subUnitId,+ range,+ tableId,+ onConfirm: (info: ITableSelectionInfo) => {+ resolve(info);+ dialogService.close(TABLE_SELECTOR_DIALOG);+ },+ onCancel: () => {+ resolve(null);+ dialogService.close(TABLE_SELECTOR_DIALOG);+ },+ };+ dialogService.open({+ id: TABLE_SELECTOR_DIALOG,+ title: { title: localeService.t('sheets-table.selectRange') },+ draggable: true,+ destroyOnClose: true,+ children: {+ label: {+ name: TABLE_SELECTOR_DIALOG,+ props: dialogProps,+ },+ },+ width: 300,+ onClose: () => {+ resolve(null);+ dialogService.close(TABLE_SELECTOR_DIALOG);+ },+ });+ });+}diff --git a/packages/sheets-table-ui/src/const.ts b/packages/sheets-table-ui/src/const.tsnew file mode 100644index 0000000000..f3ce1c8d37--- /dev/null+++ b/packages/sheets-table-ui/src/const.ts@@ -0,0 +1,32 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export const PLUGIN_NAME = 'SHEET_TABLE_UI_PLUGIN';+export const SHEETS_TABLE_FILTER_PANEL_OPENED_KEY = 'SHEETS_TABLE_FILTER_PANEL_OPENED_KEY';+export const UNIVER_SHEET_TABLE_FILTER_PANEL_ID = 'UNIVER_SHEET_Table_FILTER_PANEL_ID';++export const TABLE_TOOLBAR_BUTTON = 'TABLE_TOOLBAR_BUTTON';+export const TABLE_SELECTOR_DIALOG = 'TABLE_SELECTOR_DIALOG';++export const SHEET_TABLE_THEME_PANEL_ID = 'SHEET_TABLE_THEME_PANEL_ID';+export const SHEET_TABLE_THEME_PANEL = 'SHEET_TABLE_THEME_PANEL';++export const TABLE_CUSTOM_NAME_PREFIX = 'table-custom-';+export const TABLE_DEFAULT_NAME_PREFIX = 'table-default-';+export const TABLE_DEFAULT_BG_COLOR = 'rgb(255, 255, 255)';+export const TABLE_BORDER_NONE = 'none';+export const TABLE_BORDER_DEFAULT = '1px solid rgb(var(--grey-200))';+export const TABLE_BORDER_SELECTED = '1px solid rgb(var(--blue-500))';diff --git a/packages/sheets-table-ui/src/controllers/config.schema.ts b/packages/sheets-table-ui/src/controllers/config.schema.tsnew file mode 100644index 0000000000..8fe4054696--- /dev/null+++ b/packages/sheets-table-ui/src/controllers/config.schema.ts@@ -0,0 +1,30 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export const SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY = 'sheets-table-ui.config';++export const configSymbol = Symbol(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY);++export interface IUniverSheetsTableUIConfig {+ anchorHeight?: number;+ anchorBackgroundColor?: string;+ hideAnchor?: boolean;+}++export const defaultPluginConfig: IUniverSheetsTableUIConfig = {+ anchorHeight: 24,+ anchorBackgroundColor: 'rgb(134,139,156)',+};diff --git a/packages/sheets-table-ui/src/controllers/menu.schema.ts b/packages/sheets-table-ui/src/controllers/menu.schema.tsnew file mode 100644index 0000000000..6295c48088--- /dev/null+++ b/packages/sheets-table-ui/src/controllers/menu.schema.ts@@ -0,0 +1,58 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { MenuSchemaType } from '@univerjs/ui';+import { SheetTableInsertColCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveRowCommand } from '@univerjs/sheets-table';+import { ContextMenuGroup, ContextMenuPosition, RibbonStartGroup } from '@univerjs/ui';+import { OpenTableSelectorOperation } from '../commands/operations/open-table-selector.operation';+import { SHEET_TABLE_CONTEXT_INSERT_MENU_ID, SHEET_TABLE_CONTEXT_REMOVE_MENU_ID, SheetTableInsertColMenuFactory, SheetTableInsertContextMenuFactory, SheetTableInsertRowMenuFactory, SheetTableRemoveColMenuFactory, SheetTableRemoveContextMenuFactory, SheetTableRemoveRowMenuFactory, sheetTableToolbarInsertMenuFactory } from '../views/menu';++export const menuSchema: MenuSchemaType = {+ [RibbonStartGroup.FORMULAS_VIEW]: {+ [OpenTableSelectorOperation.id]: {+ order: 0,+ menuItemFactory: sheetTableToolbarInsertMenuFactory,+ },+ },+ [ContextMenuPosition.MAIN_AREA]: {+ [ContextMenuGroup.LAYOUT]: {+ [SHEET_TABLE_CONTEXT_INSERT_MENU_ID]: {+ order: 5,+ menuItemFactory: SheetTableInsertContextMenuFactory,+ [SheetTableInsertRowCommand.id]: {+ order: 1,+ menuItemFactory: SheetTableInsertRowMenuFactory,+ },+ [SheetTableInsertColCommand.id]: {+ order: 2,+ menuItemFactory: SheetTableInsertColMenuFactory,+ },+ },+ [SHEET_TABLE_CONTEXT_REMOVE_MENU_ID]: {+ order: 6,+ menuItemFactory: SheetTableRemoveContextMenuFactory,+ [SheetTableRemoveRowCommand.id]: {+ order: 1,+ menuItemFactory: SheetTableRemoveRowMenuFactory,+ },+ [SheetTableRemoveColCommand.id]: {+ order: 2,+ menuItemFactory: SheetTableRemoveColMenuFactory,+ },+ },+ },+ },+};diff --git a/packages/sheets-table-ui/src/controllers/sheet-table-anchor.controller.ts b/packages/sheets-table-ui/src/controllers/sheet-table-anchor.controller.tsnew file mode 100644index 0000000000..768a96cb68--- /dev/null+++ b/packages/sheets-table-ui/src/controllers/sheet-table-anchor.controller.ts@@ -0,0 +1,137 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Workbook } from '@univerjs/core';+import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';+import { Disposable, Inject, Injector, IPermissionService, IUniverInstanceService } from '@univerjs/core';+import { convertTransformToOffsetX, convertTransformToOffsetY, IRenderManagerService, SHEET_VIEWPORT_KEY } from '@univerjs/engine-render';+import { WorkbookEditablePermission, WorkbookPermissionService } from '@univerjs/sheets';+import { TableManager } from '@univerjs/sheets-table';+import { getSheetObject, SheetScrollManagerService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';+import { BuiltInUIPart, connectInjector, IUIPartsService } from '@univerjs/ui';+import { BehaviorSubject, debounceTime, filter, merge } from 'rxjs';+import { SheetTableAnchor } from '../views/components/SheetTableAnchor';++export interface ITableAnchorPosition {+ x: number;+ y: number;+ tableId: string;+ tableName: string;+}++export class SheetTableAnchorController extends Disposable implements IRenderModule {+ private _selectedTable: boolean = false;++ private _anchorPosition$: BehaviorSubject<ITableAnchorPosition[]> = new BehaviorSubject<ITableAnchorPosition[]>([]);+ public anchorPosition$ = this._anchorPosition$.asObservable();++ constructor(+ private readonly _context: IRenderContext<Workbook>,+ @Inject(Injector) private readonly _injector: Injector,+ @Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService,+ @IRenderManagerService private readonly _renderManagerService: IRenderManagerService,+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,+ @IUIPartsService protected readonly _uiPartsService: IUIPartsService,+ @Inject(TableManager) private readonly _tableManager: TableManager,+ @Inject(SheetScrollManagerService) private readonly _scrollManagerService: SheetScrollManagerService,+ @Inject(WorkbookPermissionService) private readonly _workbookPermissionService: WorkbookPermissionService,+ @Inject(IPermissionService) private readonly _permissionService: IPermissionService+ ) {+ super();+ this._initUI();+ this._initTableAnchor();+ }++ private _initUI() {+ this.disposeWithMe(+ this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(SheetTableAnchor, this._injector))+ );+ }++ private _initTableAnchor() {+ this.disposeWithMe(+ merge(+ 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))+ ).subscribe(() => {+ const workbook = this._context.unit;+ const worksheet = workbook.getActiveSheet();+ const subUnitId = worksheet?.getSheetId();+ const tables = this._tableManager.getTableList(this._context.unitId).filter((table) => {+ return table.subUnitId === subUnitId;+ });+ const renderUnit = this._renderManagerService.getRenderById(this._context.unitId);+ if (!renderUnit) {+ this._anchorPosition$.next([]);+ return;+ }++ const workbookEditPermission = this._permissionService.getPermissionPoint(new WorkbookEditablePermission(workbook.getUnitId()).id)?.value;+ if (!workbookEditPermission) {+ this._anchorPosition$.next([]);+ return;+ }++ const tableInfos = tables.reduce((acc, table) => {+ const { startRow, startColumn } = table.range;+ const sheetSkeletonManagerService = renderUnit.with(SheetSkeletonManagerService);+ const sheetObject = getSheetObject(this._univerInstanceService, this._renderManagerService);++ if (!sheetObject) return acc;++ const { scene } = sheetObject;+ const viewport = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);+ if (!viewport) return acc;++ const scaleX = scene?.scaleX;+ const scaleY = scene?.scaleY;+ const scrollXY = scene?.getViewportScrollXY(viewport);+ if (!scaleX || !scene || !scaleY || !scrollXY) return acc;++ const skeleton = sheetSkeletonManagerService.getCurrentSkeleton();+ if (!skeleton) return acc;++ const position = skeleton.getNoMergeCellWithCoordByIndex(startRow, startColumn);++ const startX = convertTransformToOffsetX(position.startX, scaleX, scrollXY);+ // 25 is the height of the anchor, 4 is the offset+ const startY = convertTransformToOffsetY(position.startY, scaleY, scrollXY) - 25 - 4;++ if (startY >= -10 && startX >= 45) {+ acc.push({+ x: startX,+ y: startY,+ tableId: table.id,+ tableName: table.name,+ });+ }++ return acc;+ }, [] as Array<ITableAnchorPosition>);++ this._anchorPosition$.next(tableInfos);+ })+ );+ }+}diff --git a/packages/sheets-table-ui/src/controllers/sheet-table-component.controller.ts b/packages/sheets-table-ui/src/controllers/sheet-table-component.controller.tsnew file mode 100644index 0000000000..6aef159011--- /dev/null+++ b/packages/sheets-table-ui/src/controllers/sheet-table-component.controller.ts@@ -0,0 +1,108 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IDisposable, Nullable } from '@univerjs/core';+import { Disposable, IContextService, Inject } from '@univerjs/core';+import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';+import { ComponentManager, IDialogService } from '@univerjs/ui';+import { distinctUntilChanged, startWith } from 'rxjs';+import { SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, UNIVER_SHEET_TABLE_FILTER_PANEL_ID } from '../const';+import { SheetTableFilterPanel } from '../views/components/SheetTableFilterPanel';++interface ITableFilterPanelInfo {+ unitId: string;+ subUnitId: string;+ tableId: string;+ column: number;+ row: number;+}+export class SheetsTableComponentController extends Disposable {+ private _popupDisposable?: Nullable<IDisposable>;+ private _currentTableFilterInfo: Nullable<ITableFilterPanelInfo> = null;+ constructor(++ @Inject(ComponentManager) private readonly _componentManager: ComponentManager,+ @IContextService private readonly _contextService: IContextService,+ @Inject(SheetCanvasPopManagerService) private _sheetCanvasPopupService: SheetCanvasPopManagerService,+ @Inject(IDialogService) private readonly _dialogService: IDialogService++ ) {+ super();+ this._initComponents();+ this._initUIPopup();+ }++ public setCurrentTableFilterInfo(info: ITableFilterPanelInfo): void {+ this._currentTableFilterInfo = info;+ }++ public clearCurrentTableFilterInfo(): void {+ this._currentTableFilterInfo = null;+ }++ public getCurrentTableFilterInfo(): Nullable<ITableFilterPanelInfo> {+ return this._currentTableFilterInfo;+ }++ private _initComponents() {+ ([+ [SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel],+ ] as const).forEach(([key, component]) => {+ this.disposeWithMe(this._componentManager.register(key, component));+ });+ }++ private _initUIPopup() {+ this.disposeWithMe(this._contextService.subscribeContextValue$(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY)++ .pipe(startWith(undefined), distinctUntilChanged())+ .subscribe((open) => {+ if (open) {+ this._openFilterPopup();+ } else if (open === false) {+ this._closeFilterPopup();+ }+ }));+ }++ public closeFilterPanel(): void {+ this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);+ }++ private _openFilterPopup(): void {+ const currentFilterModel = this._currentTableFilterInfo;+ if (!currentFilterModel) {+ throw new Error('[SheetsFilterUIController]: no filter model when opening filter popup!');+ }++ const { row: startRow, column: col } = currentFilterModel;+ this._popupDisposable = this._sheetCanvasPopupService.attachPopupToCell(startRow, col, {+ componentKey: SHEETS_TABLE_FILTER_PANEL_OPENED_KEY,+ direction: 'horizontal',+ onClickOutside: () => {+ this._dialogService.close(UNIVER_SHEET_TABLE_FILTER_PANEL_ID);+ this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);+ },+ offset: [5, 0],+ });+ }++ private _closeFilterPopup(): void {+ this._popupDisposable?.dispose();+ this._popupDisposable = null;+ this.clearCurrentTableFilterInfo();+ }+}diff --git a/packages/sheets-table-ui/src/controllers/sheet-table-filter-button-render.controller.ts b/packages/sheets-table-ui/src/controllers/sheet-table-filter-button-render.controller.tsnew file mode 100644index 0000000000..4135ee2a12--- /dev/null+++ b/packages/sheets-table-ui/src/controllers/sheet-table-filter-button-render.controller.ts@@ -0,0 +1,176 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IDisposable, IRange, Workbook } from '@univerjs/core';+import type { IRenderContext, IRenderModule, SpreadsheetSkeleton } from '@univerjs/engine-render';+import type { ITableRangeWithState } from '@univerjs/sheets-table';++import type { ISheetsTableFilterButtonShapeProps } from '../views/widgets/table-filter-button.shape';+import { ICommandService, Inject, Injector, InterceptorEffectEnum, RxDisposable, ThemeService } from '@univerjs/core';+import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';+import { TableManager } from '@univerjs/sheets-table';+import { getCoordByCell, ISheetSelectionRenderService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';+import { map, merge, of, startWith, switchMap, takeUntil } from 'rxjs';+import { FILTER_ICON_PADDING, FILTER_ICON_SIZE, SheetsTableFilterButtonShape } from '../views/widgets/table-filter-button.shape';++const SHEETS_FILTER_BUTTON_Z_INDEX = 5000;++interface ISheetsTableFilterRenderParams {+ unitId: string;+ worksheetId: string;+ tableFilterRanges: ITableRangeWithState[];+ skeleton: SpreadsheetSkeleton;+}++/**+ * Show selected range in filter.+ */+export class SheetsTableFilterButtonRenderController extends RxDisposable implements IRenderModule {+ private _buttonRenderDisposable: IDisposable | null = null;+ private _tableFilterButtonShapes: SheetsTableFilterButtonShape[] = [];++ constructor(+ private readonly _context: IRenderContext<Workbook>,+ @Inject(Injector) private readonly _injector: Injector,+ @Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService,+ @Inject(ThemeService) private readonly _themeService: ThemeService,+ @Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService,+ @ICommandService private readonly _commandService: ICommandService,+ @ISheetSelectionRenderService private readonly _selectionRenderService: ISheetSelectionRenderService,+ @Inject(TableManager) private _tableManager: TableManager+ ) {+ super();+ this._initRenderer();+ }++ override dispose(): void {+ super.dispose();+ this._disposeRendering();+ }++ private _initRenderer(): void {+ // Subscribe to skeleton change and filter model change.+ const tableManager = this._tableManager;+ this._sheetSkeletonManagerService.currentSkeleton$.pipe(+ switchMap((skeletonParams) => {+ if (!skeletonParams) return of(null);++ const { unit: workbook, unitId } = this._context;+ const worksheetId = workbook.getActiveSheet()?.getSheetId() || '';+ const getParams = (): ISheetsTableFilterRenderParams => ({+ unitId,+ worksheetId,+ tableFilterRanges: this._tableManager.getSheetFilterRangeWithState(workbook.getUnitId(), worksheetId),+ skeleton: skeletonParams.skeleton,+ });++ return merge(+ tableManager.tableAdd$,+ tableManager.tableNameChanged$,+ tableManager.tableRangeChanged$,+ tableManager.tableThemeChanged$,+ tableManager.tableDelete$,+ tableManager.tableFilterChanged$+ ).pipe(+ map(() => getParams()),+ startWith(getParams())+ );+ }),+ takeUntil(this.dispose$)+ ).subscribe((renderParams) => {+ this._disposeRendering();+ if (!renderParams || !renderParams.tableFilterRanges) {+ return;+ }++ this._renderButtons(renderParams as Required<ISheetsTableFilterRenderParams>);+ });+ }++ private _renderButtons(params: Required<ISheetsTableFilterRenderParams>): void {+ const { tableFilterRanges, unitId, skeleton, worksheetId } = params;+ const { scene } = this._context;++ for (const { range, states, tableId } of tableFilterRanges) {+ const { startRow, startColumn, endColumn } = range;+ this._interceptCellContent(unitId, worksheetId, range);+ for (let col = startColumn; col <= endColumn; col++) {+ const key = `sheets-table-filter-button-${startRow}-${col}`;+ const startPosition = getCoordByCell(startRow, col, scene, skeleton);+ const { startX, startY, endX, endY } = startPosition;+ const cellWidth = endX - startX;+ const cellHeight = endY - startY;+ if (cellHeight <= FILTER_ICON_PADDING || cellWidth <= FILTER_ICON_PADDING) {+ continue;+ }+ const state = states[col - startColumn];+ const iconStartX = endX - FILTER_ICON_SIZE - FILTER_ICON_PADDING;+ const iconStartY = endY - FILTER_ICON_SIZE - FILTER_ICON_PADDING;+ const props: ISheetsTableFilterButtonShapeProps = {+ left: iconStartX,+ top: iconStartY,+ height: FILTER_ICON_SIZE,+ width: FILTER_ICON_SIZE,+ zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,+ cellHeight,+ cellWidth,+ filterParams: { unitId, subUnitId: worksheetId, row: startRow, col, buttonState: state, tableId },+ };+ const buttonShape = this._injector.createInstance(SheetsTableFilterButtonShape, key, props);+ this._tableFilterButtonShapes.push(buttonShape);+ }+ }++ scene.addObjects(this._tableFilterButtonShapes);+ scene.makeDirty();+ }++ private _interceptCellContent(workbookId: string, worksheetId: string, range: IRange): void {+ const { startRow, startColumn, endColumn } = range;+ this._buttonRenderDisposable = this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {+ effect: InterceptorEffectEnum.Style,+ handler: (cell, pos, next) => {+ const { row, col, unitId, subUnitId } = pos;+ if (+ unitId !== workbookId ||+ subUnitId !== worksheetId ||+ row !== startRow ||+ col < startColumn ||+ col > endColumn+ ) {+ return next(cell);+ }++ return next({+ ...cell,+ fontRenderExtension: {+ ...cell?.fontRenderExtension,+ rightOffset: FILTER_ICON_SIZE,+ },+ });+ },+ priority: 10,+ });+ }++ private _disposeRendering(): void {+ this._tableFilterButtonShapes.forEach((s) => s.dispose());+ this._buttonRenderDisposable?.dispose();++ this._buttonRenderDisposable = null;+ this._tableFilterButtonShapes = [];+ }+}diff --git a/packages/sheets-table-ui/src/controllers/sheet-table-menu.controller.ts b/packages/sheets-table-ui/src/controllers/sheet-table-menu.controller.tsnew file mode 100644index 0000000000..98f1b8ac00--- /dev/null+++ b/packages/sheets-table-ui/src/controllers/sheet-table-menu.controller.ts@@ -0,0 +1,48 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { Disposable, Inject } from '@univerjs/core';+import { TableSingle } from '@univerjs/icons';+import { ComponentManager, IMenuManagerService } from '@univerjs/ui';+import { SHEET_TABLE_THEME_PANEL, TABLE_SELECTOR_DIALOG, TABLE_TOOLBAR_BUTTON } from '../const';+import { SheetTableSelector } from '../views/components/SheetTableSelector';+import { SheetTableThemePanel } from '../views/components/SheetTableThemePanel';+import { menuSchema } from './menu.schema';++export class SheetTableMenuController extends Disposable {+ constructor(+ @Inject(ComponentManager) private _componentManager: ComponentManager,+ @Inject(IMenuManagerService) private _menuManagerService: IMenuManagerService+ ) {+ super();+ this._initComponents();+ this._initMenu();+ }++ private _initComponents() {+ ([+ [TABLE_TOOLBAR_BUTTON, TableSingle],+ [TABLE_SELECTOR_DIALOG, SheetTableSelector],+ [SHEET_TABLE_THEME_PANEL, SheetTableThemePanel],+ ] as const).forEach(([key, component]) => {+ this.disposeWithMe(this._componentManager.register(key, component));+ });+ }++ private _initMenu() {+ this._menuManagerService.mergeMenu(menuSchema);+ }+}diff --git a/packages/sheets-table-ui/src/controllers/sheet-table-render.controller.ts b/packages/sheets-table-ui/src/controllers/sheet-table-render.controller.tsnew file mode 100644index 0000000000..0fbb75c5d5--- /dev/null+++ b/packages/sheets-table-ui/src/controllers/sheet-table-render.controller.ts@@ -0,0 +1,68 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Workbook } from '@univerjs/core';++import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';+import { Inject, Injector, RxDisposable } from '@univerjs/core';+import { TableManager } from '@univerjs/sheets-table';+import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';+import { merge } from 'rxjs';+import { SheetTableThemeUIController } from './sheet-table-theme-ui.controller';++/**+ * Show selected range in filter.+ */+export class SheetsTableRenderController extends RxDisposable implements IRenderModule {+ constructor(+ private readonly _context: IRenderContext<Workbook>,+ @Inject(Injector) private readonly _injector: Injector,+ @Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService,+ @Inject(TableManager) private _tableManager: TableManager,+ @Inject(SheetTableThemeUIController) private readonly _sheetTableThemeUIController: SheetTableThemeUIController+ ) {+ super();+ this._initListener();+ }++ private _dirtySkeleton() {+ this._context.mainComponent?.makeDirty();+ const currentParam = this._sheetSkeletonManagerService.getCurrentParam();+ if (currentParam) {+ const param = { ...currentParam, dirty: true };+ this._sheetSkeletonManagerService.reCalculate(param);+ }+ }++ private _initListener(): void {+ const tableManager = this._tableManager;+ const dirtySkeleton = this._dirtySkeleton.bind(this);+ this.disposeWithMe(+ merge(+ tableManager.tableAdd$,+ tableManager.tableDelete$,+ tableManager.tableNameChanged$,+ tableManager.tableRangeChanged$,+ tableManager.tableThemeChanged$,+ tableManager.tableFilterChanged$,+ tableManager.tableInitStatus$,+ this._sheetTableThemeUIController.refreshTable$+ ).subscribe(+ dirtySkeleton+ )+ );+ }+}diff --git a/packages/sheets-table-ui/src/controllers/sheet-table-selection.controller.ts b/packages/sheets-table-ui/src/controllers/sheet-table-selection.controller.tsnew file mode 100644index 0000000000..23cda06ab9--- /dev/null+++ b/packages/sheets-table-ui/src/controllers/sheet-table-selection.controller.ts@@ -0,0 +1,106 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IRange } from '@univerjs/core';+import { Disposable, Inject, IUniverInstanceService, Rectangle } from '@univerjs/core';+import { getPrimaryForRange, getSheetCommandTarget, SetSelectionsOperation, SheetInterceptorService } from '@univerjs/sheets';+import { TableManager } from '@univerjs/sheets-table';+import { SelectAllCommand } from '@univerjs/sheets-ui';++export class SheetTableSelectionController extends Disposable {+ constructor(+ @Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService,+ @Inject(IUniverInstanceService) private readonly _univerInstanceService: IUniverInstanceService,+ @Inject(TableManager) private readonly _tableManager: TableManager+ ) {+ super();+ this._initSelectionChange();+ }++ private _initSelectionChange() {+ this.disposeWithMe(+ this._sheetInterceptorService.interceptCommand({+ getMutations: (command) => {+ if (command.id === SelectAllCommand.id) {+ const target = getSheetCommandTarget(this._univerInstanceService);+ if (!target) {+ return { redos: [], undos: [] };+ }+ const params = command.params as { range: IRange };+ const { range } = params;+ const { unitId, subUnitId, worksheet } = target;+ const subTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ const overlapTable = subTables.find((table) => {+ const tableRange = table.getRange();+ return Rectangle.contains(tableRange, range);+ });++ if (overlapTable) {+ const tableRange = overlapTable.getRange();+ const tableRangeWithoutHeader = {+ ...tableRange,+ startRow: tableRange.startRow + 1,+ };++ if (Rectangle.equals(tableRange, range)) {+ return { undos: [], redos: [] };+ } else if (Rectangle.equals(tableRangeWithoutHeader, range)) {+ return {+ undos: [],+ redos: [+ {+ id: SetSelectionsOperation.id,+ params: {+ unitId,+ subUnitId,+ selections: [+ {+ range: tableRange,+ primary: getPrimaryForRange(tableRange, worksheet),+ },+ ],+ },+ },+ ],+ };+ } else {+ return {+ undos: [],+ redos: [+ {+ id: SetSelectionsOperation.id,+ params: {+ unitId,+ subUnitId,+ selections: [+ {+ range: tableRangeWithoutHeader,+ primary: getPrimaryForRange(tableRangeWithoutHeader, worksheet),+ },+ ],+ },+ },+ ],+ };+ }+ }+ }+ return { redos: [], undos: [] };+ },+ })+ );+ }+}diff --git a/packages/sheets-table-ui/src/controllers/sheet-table-theme-ui.controller.ts b/packages/sheets-table-ui/src/controllers/sheet-table-theme-ui.controller.tsnew file mode 100644index 0000000000..4d2fec548a--- /dev/null+++ b/packages/sheets-table-ui/src/controllers/sheet-table-theme-ui.controller.ts@@ -0,0 +1,47 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ISetRangeThemeMutationParams } from '@univerjs/sheets';+import { Disposable, ICommandService, Inject } from '@univerjs/core';+import { SetRangeThemeMutation } from '@univerjs/sheets';+import { SHEET_TABLE_CUSTOM_THEME_PREFIX } from '@univerjs/sheets-table';+import { Subject } from 'rxjs';++export class SheetTableThemeUIController extends Disposable {+ private _refreshTable = new Subject<number>();+ public refreshTable$ = this._refreshTable.asObservable();++ constructor(+ @Inject(ICommandService) private _commandService: ICommandService+ ) {+ super();+ this._initListener();+ }++ private _initListener() {+ this.disposeWithMe(+ this._commandService.onCommandExecuted((command) => {+ if (command.id === SetRangeThemeMutation.id) {+ const params = command.params as ISetRangeThemeMutationParams;+ const { styleName } = params;+ if (styleName.startsWith(SHEET_TABLE_CUSTOM_THEME_PREFIX)) {+ this._refreshTable.next(Math.random());+ }+ }+ })+ );+ }+}diff --git a/packages/sheets-table-ui/src/index.ts b/packages/sheets-table-ui/src/index.tsnew file mode 100644index 0000000000..b35b4e67bf--- /dev/null+++ b/packages/sheets-table-ui/src/index.ts@@ -0,0 +1,17 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export { UniverSheetTableUIPlugin } from './plugin';diff --git a/packages/sheets-table-ui/src/locale/en-US.ts b/packages/sheets-table-ui/src/locale/en-US.tsnew file mode 100644index 0000000000..93d878ccf0--- /dev/null+++ b/packages/sheets-table-ui/src/locale/en-US.ts@@ -0,0 +1,133 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++const locale = {+ 'sheets-table': {+ title: 'Table',+ selectRange: 'Select Table Range',+ rename: 'Rename Table',+ updateRange: 'Update Table Range',+ tableRangeWithMergeError: 'Table range cannot overlap with merged cells',+ tableRangeWithOtherTableError: 'Table range cannot overlap with other tables',+ tableRangeSingleRowError: 'Table range cannot be a single row',+ updateError: 'Cannot set table range to an area that does not overlap with the original and is not in the same row',+ tableStyle: 'Table Style',+ defaultStyle: 'Default Style',+ customStyle: 'Custom Style',+ customTooMore: 'The number of custom themes exceeds the maximum limit, please delete some unnecessary themes and add them again',+ setTheme: 'Set Table Theme',+ removeTable: 'Remove Table',+ cancel: 'Cancel',+ confirm: 'Confirm',+ header: 'Header',+ footer: 'Footer',+ firstLine: 'First Line',+ secondLine: 'Second Line',+ columnPrefix: 'Column',+ tablePrefix: 'Table',++ insert: {+ main: 'Insert Table',+ row: 'Insert Table Row',+ col: 'Insert Table Column',+ },++ remove: {+ main: 'Remove Table',+ row: 'Remove Table Row',+ col: 'Remove Table Column',+ },+ condition: {+ string: 'Text',+ number: 'Number',+ date: 'Date',++ empty: '(Empty)',+ },+ string: {+ compare: {+ equal: 'Equal to',+ notEqual: 'Not equal to',+ contains: 'Contains',+ notContains: 'Does not contain',+ startsWith: 'Starts with',+ endsWith: 'Ends with',+ },+ },+ number: {+ compare: {+ equal: 'Equal to',+ notEqual: 'Not equal to',+ greaterThan: 'Greater than',+ greaterThanOrEqual: 'Greater than or equal to',+ lessThan: 'Less than',+ lessThanOrEqual: 'Less than or equal to',+ between: 'Between',+ notBetween: 'Not between',+ above: 'Above',+ below: 'Below',+ topN: 'Top {0}',+ },+ },+ date: {+ compare: {+ equal: 'Equal to',+ notEqual: 'Not equal to',+ after: 'After',+ afterOrEqual: 'After or equal to',+ before: 'Before',+ beforeOrEqual: 'Before or equal to',+ between: 'Between',+ notBetween: 'Not between',+ today: 'Today',+ yesterday: 'Yesterday',+ tomorrow: 'Tomorrow',+ thisWeek: 'This week',+ lastWeek: 'Last week',+ nextWeek: 'Next week',+ thisMonth: 'This month',+ lastMonth: 'Last month',+ nextMonth: 'Next month',+ thisQuarter: 'This quarter',+ lastQuarter: 'Last quarter',+ nextQuarter: 'Next quarter',+ thisYear: 'This year',+ nextYear: 'Next year',+ lastYear: 'Last year',+ quarter: 'By quarter',+ month: 'By month',+ q1: 'First quarter',+ q2: 'Second quarter',+ q3: 'Third quarter',+ q4: 'Fourth quarter',+ m1: 'January',+ m2: 'February',+ m3: 'March',+ m4: 'April',+ m5: 'May',+ m6: 'June',+ m7: 'July',+ m8: 'August',+ m9: 'September',+ m10: 'October',+ m11: 'November',+ m12: 'December',+ },+ },+ },+};++export default locale;diff --git a/packages/sheets-table-ui/src/locale/fa-IR.ts b/packages/sheets-table-ui/src/locale/fa-IR.tsnew file mode 100644index 0000000000..b9b0567328--- /dev/null+++ b/packages/sheets-table-ui/src/locale/fa-IR.ts@@ -0,0 +1,135 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++const locale = {+ 'sheets-table': {+ title: 'جدول',+ selectRange: 'انتخاب محدوده جدول',+ rename: 'تغییر نام جدول',+ updateRange: 'بهروزرسانی محدوده جدول',+ tableRangeWithMergeError: 'محدوده جدول نمیتواند با سلولهای ادغامشده همپوشانی داشته باشد',+ tableRangeWithOtherTableError: 'محدوده جدول نمیتواند با جداول دیگر همپوشانی داشته باشد',+ tableRangeSingleRowError: 'محدوده جدول نمیتواند یک ردیف منفرد باشد',+ updateError: 'نمیتوان محدوده جدول را به منطقهای که با اصل همپوشانی ندارد و در یک ردیف نیست تنظیم کرد',+ tableStyle: 'سبک جدول',+ defaultStyle: 'سبک پیشفرض',+ customStyle: 'سبک سفارشی',+ customTooMore: 'تعداد تمهای سفارشی از حد مجاز فراتر رفته است، لطفاً برخی از تمهای غیرضروری را حذف کرده و دوباره اضافه کنید',+ setTheme: 'تنظیم قالب جدول',+ removeTable: 'حذف جدول',+ cancel: 'لغو',+ confirm: 'تأیید',+ header: 'سربرگ',+ footer: 'پاورقی',+ firstLine: 'خط اول',+ secondLine: 'خط دوم',+ columnPrefix: 'ستون',+ tablePrefix: 'جدول',++ insert: {+ main: 'درج جدول',+ row: 'درج ردیف جدول',+ col: 'درج ستون جدول',+ },++ remove: {+ main: 'حذف جدول',+ row: 'حذف ردیف جدول',+ col: 'حذف ستون جدول',+ },++ condition: {+ string: 'متن',+ number: 'عدد',+ date: 'تاریخ',++ empty: '(خالی)',++ },+ string: {+ compare: {+ equal: 'برابر است با',+ notEqual: 'برابر نیست با',+ contains: 'شامل است',+ notContains: 'شامل نیست',+ startsWith: 'شروع میشود با',+ endsWith: 'پایان مییابد با',+ },+ },+ number: {+ compare: {+ equal: 'برابر است با',+ notEqual: 'برابر نیست با',+ greaterThan: 'بزرگتر از',+ greaterThanOrEqual: 'بزرگتر یا مساوی با',+ lessThan: 'کوچکتر از',+ lessThanOrEqual: 'کوچکتر یا مساوی با',+ between: 'بین',+ notBetween: 'خارج از محدوده',+ above: 'بالاتر از',+ below: 'پایینتر از',+ topN: 'برترین {0}',+ },+ },+ date: {+ compare: {+ equal: 'برابر است با',+ notEqual: 'برابر نیست با',+ after: 'بعد از',+ afterOrEqual: 'بعد یا برابر با',+ before: 'قبل از',+ beforeOrEqual: 'قبل یا برابر با',+ between: 'بین',+ notBetween: 'خارج از محدوده',+ today: 'امروز',+ yesterday: 'دیروز',+ tomorrow: 'فردا',+ thisWeek: 'این هفته',+ lastWeek: 'هفته گذشته',+ nextWeek: 'هفته آینده',+ thisMonth: 'این ماه',+ lastMonth: 'ماه گذشته',+ nextMonth: 'ماه آینده',+ thisQuarter: 'این سهماهه',+ lastQuarter: 'سهماهه گذشته',+ nextQuarter: 'سهماهه آینده',+ thisYear: 'امسال',+ nextYear: 'سال آینده',+ lastYear: 'سال گذشته',+ quarter: 'بر اساس سهماهه',+ month: 'بر اساس ماه',+ q1: 'سهماهه اول',+ q2: 'سهماهه دوم',+ q3: 'سهماهه سوم',+ q4: 'سهماهه چهارم',+ m1: 'ژانویه',+ m2: 'فوریه',+ m3: 'مارس',+ m4: 'آوریل',+ m5: 'مه',+ m6: 'ژوئن',+ m7: 'ژوئیه',+ m8: 'اوت',+ m9: 'سپتامبر',+ m10: 'اکتبر',+ m11: 'نوامبر',+ m12: 'دسامبر',+ },+ },+ },+};++export default locale;diff --git a/packages/sheets-table-ui/src/locale/fr-FR.ts b/packages/sheets-table-ui/src/locale/fr-FR.tsnew file mode 100644index 0000000000..7e24eed248--- /dev/null+++ b/packages/sheets-table-ui/src/locale/fr-FR.ts@@ -0,0 +1,134 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++const locale = {+ 'sheets-table': {+ title: 'Tableau',+ selectRange: 'Sélectionner la plage du tableau',+ rename: 'Renommer le tableau',+ updateRange: 'Mettre à jour la plage du tableau',+ tableRangeWithMergeError: 'La plage du tableau ne peut pas chevaucher des cellules fusionnées',+ tableRangeWithOtherTableError: 'La plage du tableau ne peut pas chevaucher d\'autres tableaux',+ tableRangeSingleRowError: 'La plage du tableau ne peut pas être une seule ligne',+ updateError: 'Impossible de définir la plage du tableau sur une zone qui ne chevauche pas l\'original et n\'est pas sur la même ligne',+ tableStyle: 'Style du tableau',+ defaultStyle: 'Style par défaut',+ customStyle: 'Style personnalisé',+ customTooMore: 'Le nombre de thèmes personnalisés dépasse la limite maximale, veuillez supprimer certains thèmes inutiles et les ajouter à nouveau',+ setTheme: 'Définir le thème du tableau',+ removeTable: 'Supprimer le tableau',+ cancel: 'Annuler',+ confirm: 'Confirmer',+ header: 'En-tête',+ footer: 'Pied de page',+ firstLine: 'Première ligne',+ secondLine: 'Deuxième ligne',+ columnPrefix: 'Colonne',+ tablePrefix: 'Tableau',++ insert: {+ main: 'Insérer un tableau',+ row: 'Insérer une ligne de tableau',+ col: 'Insérer une colonne de tableau',+ },++ remove: {+ main: 'Supprimer le tableau',+ row: 'Supprimer une ligne de tableau',+ col: 'Supprimer une colonne de tableau',+ },++ condition: {+ string: 'Texte',+ number: 'Nombre',+ date: 'Date',++ empty: '(Vide)',+ },+ string: {+ compare: {+ equal: 'Égal à',+ notEqual: 'Différent de',+ contains: 'Contient',+ notContains: 'Ne contient pas',+ startsWith: 'Commence par',+ endsWith: 'Se termine par',+ },+ },+ number: {+ compare: {+ equal: 'Égal à',+ notEqual: 'Différent de',+ greaterThan: 'Supérieur à',+ greaterThanOrEqual: 'Supérieur ou égal à',+ lessThan: 'Inférieur à',+ lessThanOrEqual: 'Inférieur ou égal à',+ between: 'Entre',+ notBetween: 'Pas entre',+ above: 'Supérieur à',+ below: 'Inférieur à',+ topN: 'Top {0}',+ },+ },+ date: {+ compare: {+ equal: 'Égal à',+ notEqual: 'Différent de',+ after: 'Après',+ afterOrEqual: 'Après ou égal à',+ before: 'Avant',+ beforeOrEqual: 'Avant ou égal à',+ between: 'Entre',+ notBetween: 'Pas entre',+ today: "Aujourd'hui",+ yesterday: 'Hier',+ tomorrow: 'Demain',+ thisWeek: 'Cette semaine',+ lastWeek: 'La semaine dernière',+ nextWeek: 'La semaine prochaine',+ thisMonth: 'Ce mois-ci',+ lastMonth: 'Le mois dernier',+ nextMonth: 'Le mois prochain',+ thisQuarter: 'Ce trimestre',+ lastQuarter: 'Le trimestre dernier',+ nextQuarter: 'Le trimestre prochain',+ thisYear: 'Cette année',+ nextYear: "L'année prochaine",+ lastYear: "L'année dernière",+ quarter: 'Par trimestre',+ month: 'Par mois',+ q1: 'Premier trimestre',+ q2: 'Deuxième trimestre',+ q3: 'Troisième trimestre',+ q4: 'Quatrième trimestre',+ m1: 'Janvier',+ m2: 'Février',+ m3: 'Mars',+ m4: 'Avril',+ m5: 'Mai',+ m6: 'Juin',+ m7: 'Juillet',+ m8: 'Août',+ m9: 'Septembre',+ m10: 'Octobre',+ m11: 'Novembre',+ m12: 'Décembre',+ },+ },+ },+};++export default locale;diff --git a/packages/sheets-table-ui/src/locale/ru-RU.ts b/packages/sheets-table-ui/src/locale/ru-RU.tsnew file mode 100644index 0000000000..a25fda2bca--- /dev/null+++ b/packages/sheets-table-ui/src/locale/ru-RU.ts@@ -0,0 +1,135 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++const locale = {+ 'sheets-table': {+ title: 'Таблица',+ selectRange: 'Выбрать диапазон таблицы',+ rename: 'Переименовать таблицу',+ updateRange: 'Обновить диапазон таблицы',+ tableRangeWithMergeError: 'Диапазон таблицы не может перекрываться с объединенными ячейками',+ tableRangeWithOtherTableError: 'Диапазон таблицы не может перекрываться с другими таблицами',+ tableRangeSingleRowError: 'Диапазон таблицы не может быть одной строкой',+ updateError: 'Невозможно установить диапазон таблицы в область, которая не перекрывается с исходной и не находится в той же строке',+ tableStyle: 'Стиль таблицы',+ defaultStyle: 'Стиль по умолчанию',+ customStyle: 'Пользовательский стиль',+ customTooMore: 'Количество пользовательских тем превышает максимальный лимит, пожалуйста, удалите некоторые ненужные темы и добавьте снова',+ setTheme: 'Установить тему таблицы',+ removeTable: 'Удалить таблицу',+ cancel: 'Отмена',+ confirm: 'Подтвердить',+ header: 'Заголовок',+ footer: 'Нижний колонтитул',+ firstLine: 'Первая строка',+ secondLine: 'Вторая строка',+ columnPrefix: 'Столбец',+ tablePrefix: 'Таблица',++ insert: {+ main: 'Вставить таблицу',+ row: 'Вставить строку таблицы',+ col: 'Вставить столбец таблицы',+ },++ remove: {+ main: 'Удалить таблицу',+ row: 'Удалить строку таблицы',+ col: 'Удалить столбец таблицы',+ },++ condition: {+ string: 'Текст',+ number: 'Число',+ date: 'Дата',++ empty: '(Пусто)',++ },+ string: {+ compare: {+ equal: 'Равно',+ notEqual: 'Не равно',+ contains: 'Содержит',+ notContains: 'Не содержит',+ startsWith: 'Начинается с',+ endsWith: 'Заканчивается на',+ },+ },+ number: {+ compare: {+ equal: 'Равно',+ notEqual: 'Не равно',+ greaterThan: 'Больше',+ greaterThanOrEqual: 'Больше или равно',+ lessThan: 'Меньше',+ lessThanOrEqual: 'Меньше или равно',+ between: 'Между',+ notBetween: 'Не между',+ above: 'Больше',+ below: 'Меньше',+ topN: 'Топ {0}',+ },+ },+ date: {+ compare: {+ equal: 'Равно',+ notEqual: 'Не равно',+ after: 'После',+ afterOrEqual: 'После или равно',+ before: 'До',+ beforeOrEqual: 'До или равно',+ between: 'Между',+ notBetween: 'Не между',+ today: 'Сегодня',+ yesterday: 'Вчера',+ tomorrow: 'Завтра',+ thisWeek: 'На этой неделе',+ lastWeek: 'На прошлой неделе',+ nextWeek: 'На следующей неделе',+ thisMonth: 'В этом месяце',+ lastMonth: 'В прошлом месяце',+ nextMonth: 'В следующем месяце',+ thisQuarter: 'В этом квартале',+ lastQuarter: 'В прошлом квартале',+ nextQuarter: 'В следующем квартале',+ thisYear: 'В этом году',+ nextYear: 'В следующем году',+ lastYear: 'В прошлом году',+ quarter: 'По кварталам',+ month: 'По месяцам',+ q1: 'Первый квартал',+ q2: 'Второй квартал',+ q3: 'Третий квартал',+ q4: 'Четвертый квартал',+ m1: 'Январь',+ m2: 'Февраль',+ m3: 'Март',+ m4: 'Апрель',+ m5: 'Май',+ m6: 'Июнь',+ m7: 'Июль',+ m8: 'Август',+ m9: 'Сентябрь',+ m10: 'Октябрь',+ m11: 'Ноябрь',+ m12: 'Декабрь',+ },+ },+ },+};++export default locale;diff --git a/packages/sheets-table-ui/src/locale/vi-VN.ts b/packages/sheets-table-ui/src/locale/vi-VN.tsnew file mode 100644index 0000000000..dc2f9b0733--- /dev/null+++ b/packages/sheets-table-ui/src/locale/vi-VN.ts@@ -0,0 +1,135 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++const locale = {+ 'sheets-table': {+ title: 'Bảng',+ selectRange: 'Chọn phạm vi bảng',+ rename: 'Đổi tên bảng',+ updateRange: 'Cập nhật phạm vi bảng',+ tableRangeWithMergeError: 'Phạm vi bảng không thể chồng lấp với các ô đã được hợp nhất',+ tableRangeWithOtherTableError: 'Phạm vi bảng không thể chồng lấp với các bảng khác',+ tableRangeSingleRowError: 'Phạm vi bảng không thể là một hàng đơn lẻ',+ updateError: 'Không thể đặt phạm vi bảng vào khu vực không chồng lấp với bản gốc và không nằm trên cùng một hàng',+ tableStyle: 'Kiểu bảng',+ defaultStyle: 'Kiểu mặc định',+ customStyle: 'Kiểu tùy chỉnh',+ customTooMore: 'Số lượng chủ đề tùy chỉnh vượt quá giới hạn tối đa, vui lòng xóa một số chủ đề không cần thiết và thêm lại',+ setTheme: 'Thiết lập chủ đề bảng',+ removeTable: 'Xóa bảng',+ cancel: 'Hủy',+ confirm: 'Xác nhận',+ header: 'Đầu trang',+ footer: 'Chân trang',+ firstLine: 'Dòng đầu tiên',+ secondLine: 'Dòng thứ hai',+ columnPrefix: 'Cột',+ tablePrefix: 'Bảng',++ insert: {+ main: 'Chèn bảng',+ row: 'Chèn hàng bảng',+ col: 'Chèn cột bảng',+ },++ remove: {+ main: 'Xóa bảng',+ row: 'Xóa hàng bảng',+ col: 'Xóa cột bảng',+ },++ condition: {+ string: 'Văn bản',+ number: 'Số',+ date: 'Ngày',++ empty: '(Trống)',++ },+ string: {+ compare: {+ equal: 'Bằng',+ notEqual: 'Không bằng',+ contains: 'Chứa',+ notContains: 'Không chứa',+ startsWith: 'Bắt đầu với',+ endsWith: 'Kết thúc với',+ },+ },+ number: {+ compare: {+ equal: 'Bằng',+ notEqual: 'Không bằng',+ greaterThan: 'Lớn hơn',+ greaterThanOrEqual: 'Lớn hơn hoặc bằng',+ lessThan: 'Nhỏ hơn',+ lessThanOrEqual: 'Nhỏ hơn hoặc bằng',+ between: 'Trong khoảng',+ notBetween: 'Không trong khoảng',+ above: 'Lớn hơn',+ below: 'Nhỏ hơn',+ topN: 'Top {0}',+ },+ },+ date: {+ compare: {+ equal: 'Bằng',+ notEqual: 'Không bằng',+ after: 'Sau',+ afterOrEqual: 'Sau hoặc bằng',+ before: 'Trước',+ beforeOrEqual: 'Trước hoặc bằng',+ between: 'Trong khoảng',+ notBetween: 'Không trong khoảng',+ today: 'Hôm nay',+ yesterday: 'Hôm qua',+ tomorrow: 'Ngày mai',+ thisWeek: 'Tuần này',+ lastWeek: 'Tuần trước',+ nextWeek: 'Tuần sau',+ thisMonth: 'Tháng này',+ lastMonth: 'Tháng trước',+ nextMonth: 'Tháng sau',+ thisQuarter: 'Quý này',+ lastQuarter: 'Quý trước',+ nextQuarter: 'Quý sau',+ thisYear: 'Năm nay',+ nextYear: 'Năm sau',+ lastYear: 'Năm trước',+ quarter: 'Theo quý',+ month: 'Theo tháng',+ q1: 'Quý 1',+ q2: 'Quý 2',+ q3: 'Quý 3',+ q4: 'Quý 4',+ m1: 'Tháng 1',+ m2: 'Tháng 2',+ m3: 'Tháng 3',+ m4: 'Tháng 4',+ m5: 'Tháng 5',+ m6: 'Tháng 6',+ m7: 'Tháng 7',+ m8: 'Tháng 8',+ m9: 'Tháng 9',+ m10: 'Tháng 10',+ m11: 'Tháng 11',+ m12: 'Tháng 12',+ },+ },+ },+};++export default locale;diff --git a/packages/sheets-table-ui/src/locale/zh-CN.ts b/packages/sheets-table-ui/src/locale/zh-CN.tsnew file mode 100644index 0000000000..f8e7e1e815--- /dev/null+++ b/packages/sheets-table-ui/src/locale/zh-CN.ts@@ -0,0 +1,137 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++const locale = {+ 'sheets-table': {+ title: '表格',+ selectRange: '选择表格范围',+ rename: '重命名表格',+ updateRange: '更新表格范围',+ tableRangeWithMergeError: '表格范围不能与合并单元格重叠',+ tableRangeWithOtherTableError: '表格范围不能与其他表格重叠',+ tableRangeSingleRowError: '表格范围不能是单独的一行',+ updateError: '不能将表格范围设置到和原先不重合且不在同一行的范围',+ tableStyle: '表格样式',+ defaultStyle: '默认样式',+ customStyle: '自定义样式',+ customTooMore: '自定义主题数量超出最大限制,请删除一些无用的主题后再次添加',+ setTheme: '设置表格主题',+ removeTable: '删除表格',+ cancel: '取消',+ confirm: '确认',+ header: '页眉',+ footer: '页脚',+ firstLine: '第一行',+ secondLine: '第二行',+ columnPrefix: '列',+ tablePrefix: '表格',++ insert: {+ main: '表格插入',+ row: '插入表格行',+ col: '插入表格列',+ },++ remove: {+ main: '表格删除',+ row: '删除表格行',+ col: '删除表格列',+ },++ condition: {+ string: '文本',+ number: '数字',+ date: '日期',++ empty: '(空白)',+ },+ string: {+ compare: {+ equal: '等于',+ notEqual: '不等于',+ contains: '包含',+ notContains: '不包含',+ startsWith: '开始于',+ endsWith: '结束于',+ },+ },+ number: {+ compare: {+ equal: '等于',+ notEqual: '不等于',+ greaterThan: '大于',+ greaterThanOrEqual: '大于等于',+ lessThan: '小于',+ lessThanOrEqual: '小于等于',+ between: '介于',+ notBetween: '不介于',+ above: '大于',+ below: '小于',+ topN: '前{0}个',+ },+ },+ date: {+ compare: {+ equal: '等于',+ notEqual: '不等于',+ after: '晚于',+ afterOrEqual: '晚于等于',+ before: '早于',+ beforeOrEqual: '早于等于',+ between: '介于',+ notBetween: '不介于',+ today: '今天',+ yesterday: '昨天',+ tomorrow: '明天',+ thisWeek: '本周',+ lastWeek: '上周',+ nextWeek: '下周',+ thisMonth: '本月',+ lastMonth: '上月',+ nextMonth: '下月',+ thisQuarter: '本季度',+ lastQuarter: '上季度',+ nextQuarter: '下季度',+ thisYear: '今年',+ nextYear: '明年',+ lastYear: '去年',+ quarter: '按季度',+ month: '按月份',++ q1: '第一季度',+ q2: '第二季度',+ q3: '第三季度',+ q4: '第四季度',++ m1: '一月',+ m2: '二月',+ m3: '三月',+ m4: '四月',+ m5: '五月',+ m6: '六月',+ m7: '七月',+ m8: '八月',+ m9: '九月',+ m10: '十月',+ m11: '十一月',+ m12: '十二月',+ },+ },++ },+};++export default locale;diff --git a/packages/sheets-table-ui/src/locale/zh-TW.ts b/packages/sheets-table-ui/src/locale/zh-TW.tsnew file mode 100644index 0000000000..588359816c--- /dev/null+++ b/packages/sheets-table-ui/src/locale/zh-TW.ts@@ -0,0 +1,135 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++const locale = {+ 'sheets-table': {+ title: '表格',+ selectRange: '選擇表格範圍',+ rename: '重命名表格',+ updateRange: '更新表格範圍',+ tableRangeWithMergeError: '表格範圍不能與合併儲存格重疊',+ tableRangeWithOtherTableError: '表格範圍不能與其他表格重疊',+ tableRangeSingleRowError: '表格範圍不能是單獨的一行',+ updateError: '不能將表格範圍設置到和原先不重合且不在同一行的範圍',+ tableStyle: '表格樣式',+ defaultStyle: '預設樣式',+ customStyle: '自定義樣式',+ customTooMore: '自定義主題數量超出最大限制,請刪除一些無用的主題後再次添加',+ setTheme: '設置表格主題',+ removeTable: '刪除表格',+ cancel: '取消',+ confirm: '確認',+ header: '頁首',+ footer: '頁尾',+ firstLine: '第一行',+ secondLine: '第二行',+ columnPrefix: '列',+ tablePrefix: '表格',++ insert: {+ main: '表格插入',+ row: '插入表格行',+ col: '插入表格列',+ },++ remove: {+ main: '表格刪除',+ row: '刪除表格行',+ col: '刪除表格列',+ },++ condition: {+ string: '文字',+ number: '數字',+ date: '日期',++ empty: '(空白)',++ },+ string: {+ compare: {+ equal: '等於',+ notEqual: '不等於',+ contains: '包含',+ notContains: '不包含',+ startsWith: '開始於',+ endsWith: '結束於',+ },+ },+ number: {+ compare: {+ equal: '等於',+ notEqual: '不等於',+ greaterThan: '大於',+ greaterThanOrEqual: '大於等於',+ lessThan: '小於',+ lessThanOrEqual: '小於等於',+ between: '介於',+ notBetween: '不介於',+ above: '大於',+ below: '小於',+ topN: '前{0}個',+ },+ },+ date: {+ compare: {+ equal: '等於',+ notEqual: '不等於',+ after: '晚於',+ afterOrEqual: '晚於等於',+ before: '早於',+ beforeOrEqual: '早於等於',+ between: '介於',+ notBetween: '不介於',+ today: '今天',+ yesterday: '昨天',+ tomorrow: '明天',+ thisWeek: '本週',+ lastWeek: '上週',+ nextWeek: '下週',+ thisMonth: '本月',+ lastMonth: '上月',+ nextMonth: '下月',+ thisQuarter: '本季度',+ lastQuarter: '上季度',+ nextQuarter: '下季度',+ thisYear: '今年',+ nextYear: '明年',+ lastYear: '去年',+ quarter: '按季度',+ month: '按月份',+ q1: '第一季度',+ q2: '第二季度',+ q3: '第三季度',+ q4: '第四季度',+ m1: '一月',+ m2: '二月',+ m3: '三月',+ m4: '四月',+ m5: '五月',+ m6: '六月',+ m7: '七月',+ m8: '八月',+ m9: '九月',+ m10: '十月',+ m11: '十一月',+ m12: '十二月',+ },+ },+ },+};++export default locale;diff --git a/packages/sheets-table-ui/src/plugin.ts b/packages/sheets-table-ui/src/plugin.tsnew file mode 100644index 0000000000..e32d0795d5--- /dev/null+++ b/packages/sheets-table-ui/src/plugin.ts@@ -0,0 +1,95 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsTableUIConfig } from './controllers/config.schema';+import { ICommandService, IConfigService, Inject, Injector, Plugin, registerDependencies, touchDependencies, UniverInstanceType } from '@univerjs/core';+import { IRenderManagerService } from '@univerjs/engine-render';+import { OpenTableFilterPanelOperation } from './commands/operations/open-table-filter-dialog.opration';+import { OpenTableSelectorOperation } from './commands/operations/open-table-selector.operation';+import { PLUGIN_NAME } from './const';+import { SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY } from './controllers/config.schema';+import { SheetTableAnchorController } from './controllers/sheet-table-anchor.controller';+import { SheetsTableComponentController } from './controllers/sheet-table-component.controller';+import { SheetsTableFilterButtonRenderController } from './controllers/sheet-table-filter-button-render.controller';+import { SheetTableMenuController } from './controllers/sheet-table-menu.controller';+import { SheetsTableRenderController } from './controllers/sheet-table-render.controller';+import { SheetTableSelectionController } from './controllers/sheet-table-selection.controller';+import { SheetTableThemeUIController } from './controllers/sheet-table-theme-ui.controller';+import { SheetsTableUiService } from './services/sheets-table-ui-service';++export class UniverSheetTableUIPlugin extends Plugin {+ static override pluginName = PLUGIN_NAME;+ static override type = UniverInstanceType.UNIVER_SHEET;++ constructor(+ private readonly _config: Partial<IUniverSheetsTableUIConfig> = {},+ @Inject(Injector) protected override _injector: Injector,+ @Inject(ICommandService) private _commandService: ICommandService,+ @IConfigService private readonly _configService: IConfigService,+ @IRenderManagerService private readonly _renderManagerService: IRenderManagerService+ ) {+ super();+ this._initRegisterCommand();++ this._configService.setConfig(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY, this._config);+ }++ override onStarting(): void {+ registerDependencies(this._injector, [+ [SheetsTableComponentController],+ [SheetsTableUiService],+ [SheetTableMenuController],+ [SheetTableThemeUIController],+ [SheetTableSelectionController],+ ]);+ }++ override onReady(): void {+ touchDependencies(this._injector, [+ [SheetsTableComponentController],+ [SheetsTableUiService],+ [SheetTableMenuController],+ [SheetTableThemeUIController],+ [SheetTableSelectionController],+ ]);+ }++ override onRendered(): void {+ this._registerRenderModules();+ }++ private _registerRenderModules(): void {+ const renderDependencies: Dependency[] = [+ [SheetsTableFilterButtonRenderController],+ [SheetsTableRenderController],+ ];+ if (this._config.hideAnchor !== true) {+ renderDependencies.push([SheetTableAnchorController]);+ }++ renderDependencies.forEach((m) => {+ this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, m));+ });+ }++ private _initRegisterCommand() {+ [+ OpenTableFilterPanelOperation,+ OpenTableSelectorOperation,+ ].forEach((m) => this._commandService.registerCommand(m));+ }+}diff --git a/packages/sheets-table-ui/src/services/sheets-table-ui-service.ts b/packages/sheets-table-ui/src/services/sheets-table-ui-service.tsnew file mode 100644index 0000000000..73907d899d--- /dev/null+++ b/packages/sheets-table-ui/src/services/sheets-table-ui-service.ts@@ -0,0 +1,166 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Workbook } from '@univerjs/core';+import type { ISetRangeValuesMutationParams } from '@univerjs/sheets';+import type { ISetSheetTableParams, ITableFilterItem } from '@univerjs/sheets-table';+import type { IFilterByValueWithTreeItem, ITableFilterItemList } from '../types';+import { cellToRange, Disposable, ICommandService, Inject, IUniverInstanceService, ObjectMatrix, Rectangle } from '@univerjs/core';+import { SetRangeValuesMutation } from '@univerjs/sheets';+import { isConditionFilter, isManualFilter, SetSheetTableFilterCommand, SheetTableService, TableManager } from '@univerjs/sheets-table';+import { FilterByEnum } from '../types';++interface ISheetTableFilterPanelProps {+ unitId: string;+ subUnitId: string;+ tableFilter: ITableFilterItem | undefined;+ currentFilterBy: FilterByEnum;+ tableId: string;+ columnIndex: number;+}++export class SheetsTableUiService extends Disposable {+ private _itemsCache: Map<string, ITableFilterItemList> = new Map();+ constructor(+ @Inject(TableManager) private _tableManager: TableManager,+ @Inject(SheetTableService) private _sheetTableService: SheetTableService,+ @Inject(IUniverInstanceService) private readonly _univerInstanceService: IUniverInstanceService,+ @ICommandService private readonly _commandService: ICommandService+ ) {+ super();+ this._registerTableFilterChangeEvent();+ }++ private _registerTableFilterChangeEvent() {+ this._commandService.onCommandExecuted((command) => {+ if (command.id === SetRangeValuesMutation.id) {+ const { unitId, subUnitId, cellValue } = command.params as ISetRangeValuesMutationParams;+ const tables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ if (!tables.length) {+ return;+ }+ const matrix = new ObjectMatrix(cellValue);+ matrix.forValue((row, col, _value) => {+ const cellRange = cellToRange(row, col);+ const overlapTable = tables.find((table) => {+ const tableRange = table.getTableFilterRange();+ return Rectangle.intersects(tableRange, cellRange);+ });+ if (overlapTable) {+ const colIndex = col - overlapTable.getRange().startColumn;+ this._itemsCache.delete(overlapTable.getId() + colIndex);+ }+ });+ } else if (command.id === SetSheetTableFilterCommand.id) {+ const { unitId, tableId } = command.params as ISetSheetTableParams;+ const table = this._tableManager.getTable(unitId, tableId);+ if (!table) {+ return;+ }+ const subUnitId = table.getSubunitId();+ const allSubTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ allSubTables.forEach((table) => {+ const range = table.getRange();+ for (let i = range.startColumn; i <= range.endColumn; i++) {+ this._itemsCache.delete(table.getId() + i);+ }+ });+ }+ });+ }++ getTableFilterPanelInitProps(unitId: string, subUnitId: string, tableId: string, column: number): ISheetTableFilterPanelProps {+ const table = this._tableManager.getTable(unitId, tableId)!;++ const tableRange = table.getRange();+ const tableFilter = table.getTableFilterColumn(column - tableRange.startColumn);+ return {+ unitId,+ subUnitId,+ tableFilter,+ currentFilterBy: isConditionFilter(tableFilter) ? FilterByEnum.Condition : FilterByEnum.Items,+ tableId,+ columnIndex: column - tableRange.startColumn,+ };+ }++ getTableFilterCheckedItems(unitId: string, tableId: string, columnIndex: number): string[] {+ const table = this._tableManager.getTable(unitId, tableId);+ const checkedItems: string[] = [];+ if (table) {+ const filter = table.getTableFilterColumn(columnIndex);+ if (filter && isManualFilter(filter)) {+ checkedItems.push(...filter.values);+ }+ }+ return checkedItems;+ }++ setTableFilter(unitId: string, tableId: string, columnIndex: number, tableFilter: ITableFilterItem | undefined) {+ const table = this._tableManager.getTable(unitId, tableId);+ if (!table) {+ return;+ }+ const setTableFilterParams: ISetSheetTableParams = {+ unitId,+ tableId,+ column: columnIndex,+ tableFilter,+ };+ this._commandService.executeCommand(SetSheetTableFilterCommand.id, setTableFilterParams);+ }++ getTableFilterItems(unitId: string, subUnitId: string, tableId: string, columnIndex: number): ITableFilterItemList {+ if (this._itemsCache.has(tableId + columnIndex)) {+ return this._itemsCache.get(tableId + columnIndex) || { data: [], itemsCountMap: new Map(), allItemsCount: 0 };+ }+ const table = this._tableManager.getTable(unitId, tableId);+ if (!table) {+ return { data: [], itemsCountMap: new Map(), allItemsCount: 0 };+ }+ const tableRange = table.getTableFilterRange();+ const { startRow, endRow, startColumn } = tableRange;+ const column = startColumn + columnIndex;+ const worksheet = this._univerInstanceService.getUnit<Workbook>(unitId)?.getSheetBySheetId(subUnitId);+ if (!worksheet) {+ return { data: [], itemsCountMap: new Map(), allItemsCount: 0 };+ }++ const data: IFilterByValueWithTreeItem[] = [];++ const map = new Map<string, number>();+ let allItemsCount = 0;+ for (let row = startRow; row <= endRow; row++) {+ const isFiltered = worksheet.isRowFiltered(row);+ if (isFiltered) {+ continue;+ }+ const stringItem = this._sheetTableService.getCellValueWithConditionType(worksheet, row, column) as string;++ if (!map.has(stringItem)) {+ data.push({+ title: stringItem,+ key: `${column}_${row}`,+ leaf: true,+ });+ }+ allItemsCount++;+ map.set(stringItem, (map.get(stringItem) || 0) + 1);+ }+ this._itemsCache.set(tableId + columnIndex, { data, itemsCountMap: map, allItemsCount });+ return { data, itemsCountMap: map, allItemsCount };+ }+}diff --git a/packages/sheets-table-ui/src/types.ts b/packages/sheets-table-ui/src/types.tsnew file mode 100644index 0000000000..c70541f8ce--- /dev/null+++ b/packages/sheets-table-ui/src/types.ts@@ -0,0 +1,34 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export enum FilterByEnum {+ Items = 'items',+ Condition = 'condition',+}++export interface IFilterByValueWithTreeItem {+ title: string;+ key: string;+ leaf: boolean;+ originValues?: Set<string>;+ children?: IFilterByValueWithTreeItem[];+}++export interface ITableFilterItemList {+ data: IFilterByValueWithTreeItem[];+ itemsCountMap: Map<string, number>;+ allItemsCount: number;+}diff --git a/packages/sheets-table-ui/src/views/components/SheetTableAnchor.tsx b/packages/sheets-table-ui/src/views/components/SheetTableAnchor.tsxnew file mode 100644index 0000000000..8864c5a758--- /dev/null+++ b/packages/sheets-table-ui/src/views/components/SheetTableAnchor.tsx@@ -0,0 +1,287 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IUniverSheetsTableUIConfig } from '../../controllers/config.schema';+import { cellToRange, ICommandService, IConfigService, Injector, IUniverInstanceService, LocaleService, Rectangle } from '@univerjs/core';+import { Dropdown, Input } from '@univerjs/design';+import { DeleteSingle, GridOutlineSingle, MoreDownSingle, PaintBucket, RenameSingle } from '@univerjs/icons';+import { getSheetCommandTarget, SheetRangeThemeModel, SheetsSelectionsService, WorkbookPermissionService } from '@univerjs/sheets';+import { DeleteSheetTableCommand, SetSheetTableCommand, TableManager } from '@univerjs/sheets-table';+import { ISidebarService, useDependency, useObservable } from '@univerjs/ui';+import { useEffect, useState } from 'react';+import { openRangeSelector } from '../../commands/operations/open-table-selector.operation';+import { SHEET_TABLE_THEME_PANEL, SHEET_TABLE_THEME_PANEL_ID } from '../../const';+import { SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY } from '../../controllers/config.schema';+import { SheetTableAnchorController } from '../../controllers/sheet-table-anchor.controller';+import { SheetTableThemeUIController } from '../../controllers/sheet-table-theme-ui.controller';++export const SheetTableAnchor = () => {+ const [inputFocusId, setInputFocusId] = useState<string>('');+ const [inputValue, setInputValue] = useState<string>('');+ const sidebarService = useDependency(ISidebarService);+ const [openStates, setOpenStates] = useState<Record<string, boolean>>({});+ const injector = useDependency(Injector);+ const sheetTableAnchor = useDependency(SheetTableAnchorController);+ const anchorPosition = useObservable(sheetTableAnchor.anchorPosition$);+ const commandService = useDependency(ICommandService);+ const univerInstanceService = useDependency(IUniverInstanceService);+ const workbookPermissionService = useDependency(WorkbookPermissionService);+ const workbookPermissionInitState = useObservable(workbookPermissionService.unitPermissionInitStateChange$, false);+ const tableManager = useDependency(TableManager);+ const rangeThemeModel = useDependency(SheetRangeThemeModel);+ const sheetTableThemeUIController = useDependency(SheetTableThemeUIController);+ const tableRefresh$ = useObservable(sheetTableThemeUIController.refreshTable$);+ const localeService = useDependency(LocaleService);+ const sheetsSelectionService = useDependency(SheetsSelectionsService);+ const selections = useObservable(sheetsSelectionService.selectionChanged$, [{ range: cellToRange(0, 0), primary: null }]);++ const [, setRefresh] = useState(Math.random());+ const configService = useDependency(IConfigService);+ const tableConfig = configService.getConfig<IUniverSheetsTableUIConfig>(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY);+ const anchorHeight = tableConfig?.anchorHeight ?? 24;+ const anchorBackgroundColor = tableConfig?.anchorBackgroundColor ?? 'rgb(53,91,183)';++ const updateOpenState = (tableId: string, isOpen: boolean) => {+ setOpenStates((prev) => ({+ ...prev,+ [tableId]: isOpen,+ }));+ };++ useEffect(() => {+ setRefresh(Math.random());+ }, [tableRefresh$]);++ if (!anchorPosition?.length) {+ return null;+ }++ const target = getSheetCommandTarget(univerInstanceService);++ if (!target) return null;++ const { unitId, subUnitId } = target;++ const handleChangeTableName = (tableId: string, name: string) => {+ const originName = tableManager.getTableById(unitId, tableId)?.getDisplayName();+ if (originName === name) {+ setInputFocusId('');+ setInputValue('');+ return;+ }+ commandService.executeCommand(SetSheetTableCommand.id, {+ tableId,+ unitId,+ name,+ });+ setInputValue('');+ setInputFocusId('');+ };++ const handleChangeRange = async (tableId: string) => {+ const table = tableManager.getTableById(unitId, tableId);+ if (!table) return;+ const range = table.getRange();+ const selection = await openRangeSelector(injector, unitId, subUnitId, range, tableId);+ if (!selection) return;+ commandService.executeCommand(SetSheetTableCommand.id, {+ tableId,+ unitId,+ updateRange: {+ newRange: selection.range,+ },+ });+ };++ if (!workbookPermissionInitState) {+ return null;+ }++ return (+ <div+ className="univer-absolute univer-z-50 univer-h-0 univer-w-0"+ style={{+ }}+ >+ {anchorPosition.map((item) => {+ const table = tableManager.getTableById(unitId, item.tableId);+ if (!table) return null;+ const rangeTheme = rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId());+ const headerBgColor = rangeTheme?.getHeaderRowStyle()?.bg?.rgb ?? anchorBackgroundColor;+ const headerCl = rangeTheme?.getHeaderRowStyle()?.cl?.rgb ?? 'rgb(255, 255, 255)';+ const headerTextColor = headerCl;+ const tableRange = table.getRange();++ if (!selections?.length) {+ return null;+ }++ const lastSelection = selections[selections.length - 1];+ const lastRange = lastSelection.range;++ const overlap = Rectangle.intersects(tableRange, lastRange);+ const shouldHidden = !overlap && item.y <= 20;++ return (+ <div+ key={item.tableId}+ className={`+ univer-absolute univer-box-border univer-flex+ ${anchorHeight+ ? `+ univer-h-[${anchorHeight}px]+ `+ : 'univer-h-[24px]'}+ univer-cursor-pointer univer-items-center univer-rounded-xl univer-border univer-border-solid+ univer-border-gray-500 univer-pl-2 univer-pr-2 univer-shadow-xs+ `}+ style={{+ left: item.x,+ top: Math.max(item.y, 0),+ backgroundColor: headerBgColor,+ color: headerTextColor,+ borderWidth: '0.5px',+ display: shouldHidden ? 'none' : 'flex',+ }}+ >+ <div className="univer-text-nowrap">+ {inputFocusId === item.tableId+ ? (+ <Input+ className="univer-h-[18px] univer-min-w-16 univer-rounded-none"+ inputClass="univer-h-[18px] univer-w-[80px]"+ value={inputValue}+ onChange={(v) => setInputValue(v)}+ onBlur={() => handleChangeTableName(item.tableId, inputValue)}+ onKeyDown={(e) => {+ if (e.key === 'Enter') {+ handleChangeTableName(item.tableId, inputValue);+ }+ }}+ autoFocus={inputFocusId === item.tableId}+ />+ )+ : (+ <div className="univer-h-[18px] univer-max-w-24 univer-truncate univer-text-sm">+ {item.tableName}+ </div>+ )}+ </div>+ <Dropdown+ open={openStates[item.tableId] ?? false}+ onOpenChange={(isOpen) => {+ updateOpenState(item.tableId, isOpen);+ }}+ key={item.tableId}+ overlay={(+ <div className="univer-pb-2 univer-pt-2">+ <div+ className={`+ univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center+ univer-pb-1 univer-pl-2 univer-pr-2 univer-pt-1 univer-text-sm+ hover:univer-bg-gray-200+ `}+ onClick={() => {+ setInputFocusId(item.tableId);+ setInputValue(item.tableName);+ }}+ >+ <RenameSingle className="univer-mr-2" />+ {localeService.t('sheets-table.rename')}+ </div>+ <div+ className={`+ univer-mb-1 univer-mt-1 univer-h-[1px] univer-w-full univer-bg-gray-200+ `}+ />+ <div+ onClick={() => handleChangeRange(item.tableId)}+ className={`+ univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center+ univer-pb-1 univer-pl-2 univer-pr-2 univer-pt-1 univer-text-sm+ hover:univer-bg-gray-200+ `}+ >+ <GridOutlineSingle className="univer-mr-2" />+ {localeService.t('sheets-table.updateRange')}+ </div>+ <div+ className={`+ univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center+ univer-pb-1 univer-pl-2 univer-pr-2 univer-pt-1 univer-text-sm+ hover:univer-bg-gray-200+ `}+ onClick={() => {+ updateOpenState(item.tableId, false);+ const table = tableManager.getTableById(unitId, item.tableId);+ if (!table) return;+ const tableConfig = table.getTableConfig();+ const sidebarConfig = {+ id: SHEET_TABLE_THEME_PANEL_ID,+ header: { title: localeService.t('sheets-table.tableStyle') },+ children: {+ label: SHEET_TABLE_THEME_PANEL,+ oldConfig: tableConfig,+ unitId,+ subUnitId,+ tableId: item.tableId,+ },+ width: 330,+ };+ sidebarService.open(sidebarConfig);+ }}+ >+ <PaintBucket+ extend={{ colorChannel1: 'rgb(53,91,183)' }}+ className="univer-mr-2"+ />+ {localeService.t('sheets-table.setTheme')}+ </div>+ <div+ className={`+ univer-mb-1 univer-mt-1 univer-h-[1px] univer-w-full univer-bg-gray-200+ `}+ />+ <div+ className={`+ univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center+ univer-pb-1 univer-pl-2 univer-pr-2 univer-pt-1 univer-text-sm+ hover:univer-bg-gray-200+ `}+ onClick={() => {+ updateOpenState(item.tableId, false);+ commandService.executeCommand(DeleteSheetTableCommand.id, {+ tableId: item.tableId,+ subUnitId,+ unitId,+ });+ }}+ >+ <DeleteSingle className="univer-mr-2" />+ {localeService.t('sheets-table.removeTable')}+ </div>+ </div>+ )}+ align="start"+ >+ <MoreDownSingle />+ </Dropdown>+ </div>+ );+ })}+ </div>+ );+};diff --git a/packages/sheets-table-ui/src/views/components/SheetTableConditionPanel.tsx b/packages/sheets-table-ui/src/views/components/SheetTableConditionPanel.tsxnew file mode 100644index 0000000000..704ea2460c--- /dev/null+++ b/packages/sheets-table-ui/src/views/components/SheetTableConditionPanel.tsx@@ -0,0 +1,207 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ITableFilterItem } from '@univerjs/sheets-table';+import type { IConditionCompareTypeEnum, IConditionExpect, IConditionInfo, ITableConditionTypeEnumWithoutLogic } from './type';+import { dayjs, Injector, LocaleService } from '@univerjs/core';+import { CascaderList, DatePicker, DateRangePicker, Input, InputNumber, Select } from '@univerjs/design';+import { TableConditionTypeEnum, TableDateCompareTypeEnum, TableStringCompareTypeEnum } from '@univerjs/sheets-table';+import { useDependency } from '@univerjs/ui';+import { useState } from 'react';+import { ConditionSubComponentEnum } from './type';+import { datePickerSet, getCascaderListOptions, getConditionDateSelect, getSubComponentType } from './util';++interface IConditionFilterProps {+ unitId: string;+ subUnitId: string;+ tableFilter: ITableFilterItem | undefined;+ tableId: string;+ columnIndex: number;+ conditionInfo: IConditionInfo;+ onChange: (conditionInfo: IConditionInfo) => void;+}++export const SheetTableConditionPanel = (props: IConditionFilterProps) => {+ const { conditionInfo, onChange } = props;+ const localeService = useDependency(LocaleService);++ const [version, setVersion] = useState(Math.random());++ const injector = useDependency(Injector);++ const cascaderOptions = getCascaderListOptions(injector);++ const handleChange = (value: string[]) => {+ const type = value[0] as ITableConditionTypeEnumWithoutLogic;+ const compare = value[1] as IConditionCompareTypeEnum;+ if (compare) {+ setVersion(Math.random());+ };+ const info: IConditionExpect = {};+ if (type === TableConditionTypeEnum.Date) {+ if (compare === TableDateCompareTypeEnum.Quarter) {+ info.dateSelect = TableDateCompareTypeEnum.Q1;+ } else if (compare === TableDateCompareTypeEnum.Month) {+ info.dateSelect = TableDateCompareTypeEnum.M1;+ } else if (datePickerSet.has(compare)) {+ info.date = new Date();+ } else {+ info.dateRange = [new Date(), new Date()];+ }+ } else if (type === TableConditionTypeEnum.Number) {+ info.number = 0;+ } else if (type === TableConditionTypeEnum.String) {+ info.string = '';+ }+ handleConditionInfo(info, value[0] as ITableConditionTypeEnumWithoutLogic, (value[1] as IConditionCompareTypeEnum ?? TableStringCompareTypeEnum.Equal));+ };++ const subComponentType = getSubComponentType(conditionInfo.type, conditionInfo.compare);++ let selectType = '';+ if (conditionInfo.compare) {+ selectType = `${localeService.t(`sheets-table.condition.${conditionInfo.type}`)} - ${localeService.t(`sheets-table.${conditionInfo.type}.compare.${conditionInfo.compare}`)}`;+ } else {+ selectType = localeService.t(`sheets-table.condition.${conditionInfo.type}`);+ }++ const handleConditionInfo = (info: IConditionExpect, type?: ITableConditionTypeEnumWithoutLogic, compare?: IConditionCompareTypeEnum) => {+ onChange({+ type: type ?? conditionInfo.type,+ compare: compare ?? conditionInfo.compare,+ info,+ });+ };++ const conditionDateOptions = getConditionDateSelect(injector, conditionInfo.compare as TableDateCompareTypeEnum);++ return (+ <div>+ <Select+ className="univer-h-8 univer-w-full"+ dropdownRender={() => (+ <CascaderList+ value={[conditionInfo.type, conditionInfo.compare!]}+ options={cascaderOptions}+ onChange={handleChange}+ contentClassName="univer-flex-1"+ wrapperClassName="univer-max-h-[150px]"+ />+ )}+ value={selectType}+ onChange={() => { }}+ key={version}+ />++ <div className="univer-mt-3 univer-w-full">+ {subComponentType === ConditionSubComponentEnum.Input && (+ <>+ {conditionInfo.type === TableConditionTypeEnum.String+ ? (+ <Input+ className="univer-w-full"+ placeholder="请输入"+ value={conditionInfo.info.string}+ onChange={(v) => handleConditionInfo({ string: v })}+ />+ )+ : (+ <InputNumber+ className="univer-h-7 univer-w-full"+ value={conditionInfo.info.number}+ controls={false}+ onChange={(v) => {+ if (v !== null) {+ handleConditionInfo({ number: v });+ }+ }}+ />+ )}+ </>+ )}+ {!!(subComponentType === ConditionSubComponentEnum.DatePicker) && (+ <div id="univer-table-date-picker-wrapper" style={{ background: '#fff', position: 'relative' }}>+ <DatePicker+ value={dayjs(conditionInfo.info.date)}+ defaultPickerValue={dayjs()}+ onChange={(v) => handleConditionInfo({ date: v.toDate() })}+ getPopupContainer={() => {+ const wrapper = document.getElementById('univer-table-date-picker-wrapper');+ return wrapper || document.body;+ }}+ className="univer-w-full"+ allowClear={false}+ />+ </div>+ )}+ {!!(subComponentType === ConditionSubComponentEnum.DateRange) && (+ <div id="univer-table-date-range-wrapper" style={{ background: '#fff', position: 'relative' }}>+ <DateRangePicker+ value={[dayjs(conditionInfo.info.dateRange?.[0]) ?? dayjs(), dayjs(conditionInfo.info.dateRange?.[1]) ?? dayjs()]}+ defaultPickerValue={[dayjs(), dayjs()]}+ onChange={(v) => {+ if (v) {+ handleConditionInfo({ dateRange: v.map((i) => i?.toDate()) as [Date, Date] });+ } else {+ handleConditionInfo({});+ }+ }}+ getPopupContainer={() => {+ const wrapper = document.getElementById('univer-table-date-range-wrapper');+ return wrapper || document.body;+ }}+ classNames={{ popup: 'univer-w-[400px]' }}+ allowClear={false}+ />+ </div>+ )}+ {subComponentType === ConditionSubComponentEnum.Inputs && (+ <div className="univer-flex univer-items-center univer-gap-2">+ <InputNumber+ className="univer-h-7 univer-w-full"+ value={conditionInfo.info.numberRange?.[0]}+ onChange={(v) => {+ if (v !== null) {+ handleConditionInfo({ numberRange: [v, conditionInfo.info.numberRange?.[1]] });+ }+ }}+ controls={false}+ />+ <span> - </span>+ <InputNumber+ className="univer-h-7 univer-w-full"+ value={conditionInfo.info.numberRange?.[1]}+ controls={false}+ onChange={(v) => {+ if (v !== null) {+ handleConditionInfo({ numberRange: [conditionInfo.info.numberRange?.[0], v] });+ }+ }}+ />+ </div>+ )}+ {!!(subComponentType === ConditionSubComponentEnum.Select) && (+ <Select+ value={conditionInfo.info.dateSelect ?? conditionDateOptions[0].value}+ options={conditionDateOptions}+ onChange={(v) => handleConditionInfo({ dateSelect: v })}+ className="univer-w-full"+ />+ )}+ </div>+ </div>+ );+};diff --git a/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsx b/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsxnew file mode 100644index 0000000000..3ab726453f--- /dev/null+++ b/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsx@@ -0,0 +1,249 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ISortRangeCommandParams } from '@univerjs/sheets-sort';+import type { ITableConditionFilterItem, ITableManualFilterItem } from '@univerjs/sheets-table';+import type { IConditionInfo } from './type';+import { ICommandService, IPermissionService, LocaleService } from '@univerjs/core';+import { Button, Segmented } from '@univerjs/design';+import { AscendingSingle, DescendingSingle } from '@univerjs/icons';+import { WorkbookEditablePermission } from '@univerjs/sheets';+import { SortRangeCommand, SortType } from '@univerjs/sheets-sort';+import { SheetsTableSortStateEnum, TableColumnFilterTypeEnum, TableDateCompareTypeEnum, TableManager } from '@univerjs/sheets-table';+import { useDependency } from '@univerjs/ui';+import { useMemo, useState } from 'react';+import { SheetsTableComponentController } from '../../controllers/sheet-table-component.controller';+import { SheetsTableUiService } from '../../services/sheets-table-ui-service';+import { FilterByEnum } from '../../types';+import { SheetTableConditionPanel } from './SheetTableConditionPanel';+import { SheetTableItemsFilterPanel } from './SheetTableItemsFilterPanel';+import { getInitConditionInfo } from './util';++export function SheetTableFilterPanel() {+ const localeService = useDependency(LocaleService);+ const filterByItems = useFilterByOptions(localeService);+ const tableUiService = useDependency(SheetsTableUiService);+ const tableManager = useDependency(TableManager);+ const commandService = useDependency(ICommandService);+ const permissionService = useDependency(IPermissionService);+ const sheetsTableComponentController = useDependency(SheetsTableComponentController);++ const tableFilterPanelInfo = sheetsTableComponentController.getCurrentTableFilterInfo()!;+ const props = tableUiService.getTableFilterPanelInitProps(tableFilterPanelInfo.unitId, tableFilterPanelInfo.subUnitId, tableFilterPanelInfo.tableId, tableFilterPanelInfo.column);++ const { unitId, subUnitId, tableId, tableFilter, currentFilterBy, columnIndex } = props;++ const { data } = tableUiService.getTableFilterItems(unitId, subUnitId, tableId, columnIndex);+ const checkedItems = tableUiService.getTableFilterCheckedItems(unitId, tableId, columnIndex);++ const [checkedItemSet, setCheckedItemSet] = useState<Set<string>>(new Set<string>(checkedItems));+ const [filterBy, setFilterBy] = useState(currentFilterBy || FilterByEnum.Items);++ const [conditionInfo, setConditionInfo] = useState<IConditionInfo>(() => {+ const tableFilter = props.tableFilter;+ return getInitConditionInfo(tableFilter) as IConditionInfo;+ });++ const table = tableManager.getTable(unitId, tableId);+ if (!table) return null;++ const tableFilters = table.getTableFilters();+ const sortState = tableFilters.getSortState();+ const isAsc = sortState.columnIndex === columnIndex && sortState.sortState === SheetsTableSortStateEnum.Asc;+ const isDesc = sortState.columnIndex === columnIndex && sortState.sortState === SheetsTableSortStateEnum.Desc;++ const closeDialog = (): void => {+ sheetsTableComponentController.closeFilterPanel();+ };+ const onCancel = () => {+ closeDialog();+ };++ const applySort = (asc: boolean) => {+ const range = table.getTableFilterRange();++ commandService.executeCommand<ISortRangeCommandParams>(SortRangeCommand.id, {+ unitId,+ subUnitId,+ range,+ orderRules: [{ colIndex: columnIndex + range.startColumn, type: asc ? SortType.ASC : SortType.DESC }],+ hasTitle: false,+ });++ tableFilters.setSortState(columnIndex, asc ? SheetsTableSortStateEnum.Asc : SheetsTableSortStateEnum.Desc);+ closeDialog();+ };++ const onApply = () => {+ if (filterBy === FilterByEnum.Items) {+ // do items+ const filteredItems: string[] = [];+ for (const itemInfo of data) {+ if (checkedItemSet.has(itemInfo.title)) {+ filteredItems.push(itemInfo.title);+ }+ }+ const originFilter = table.getTableFilterColumn(columnIndex) as ITableManualFilterItem | undefined;+ if (originFilter) {+ const originValue = originFilter.values;+ if (originValue.join(',') === filteredItems.join(',')) {+ closeDialog();+ return;+ }+ } else if (filteredItems.length === 0) {+ closeDialog();+ return;+ }+ const tableFilter: ITableManualFilterItem = {+ filterType: TableColumnFilterTypeEnum.manual,+ values: filteredItems,+ };+ tableUiService.setTableFilter(unitId, tableId, columnIndex, tableFilter);+ } else {+ let filterInfo;+ if (conditionInfo.compare === TableDateCompareTypeEnum.Quarter || conditionInfo.compare === TableDateCompareTypeEnum.Month) {+ filterInfo = {+ conditionType: conditionInfo.type,+ compareType: Object.values(conditionInfo.info)[0],+ };+ } else {+ filterInfo = {+ conditionType: conditionInfo.type,+ compareType: conditionInfo.compare,+ expectedValue: Object.values(conditionInfo.info)[0],+ };+ }+ const tableFilter: ITableConditionFilterItem = {+ filterType: TableColumnFilterTypeEnum.condition,+ // @ts-ignore+ filterInfo,+ };+ tableUiService.setTableFilter(unitId, tableId, columnIndex, tableFilter);+ }+ closeDialog();+ };+ const onClearFilter = () => {+ tableUiService.setTableFilter(unitId, tableId, columnIndex, undefined);+ closeDialog();+ };++ const workbookEditableId = new WorkbookEditablePermission(unitId).id;+ const editable = permissionService.getPermissionPoint(workbookEditableId)?.value;++ return (+ <div+ className={`+ univer-box-border univer-flex univer-w-[312px] univer-flex-col univer-rounded-[10px] univer-bg-white+ univer-p-4 univer-shadow-lg+ `}+ >+ {editable && (+ <div className="univer-mb-3 univer-flex">+ <div+ className={`+ univer-flex univer-w-[140px] univer-flex-1 univer-cursor-default univer-items-center+ univer-justify-center univer-gap-1 univer-rounded-l-md univer-border univer-border-solid+ univer-border-gray-200 univer-py-1.5 univer-text-[13px] univer-font-normal+ hover:univer-cursor-pointer hover:univer-bg-gray-100+ ${isAsc+ ? 'univer-bg-gray-100'+ : ''}+ `}+ onClick={() => applySort(true)}+ >+ <AscendingSingle className="univer-text-base univer-text-color-[#1e222b] univer-mr-1" />+ {localeService.t('sheets-sort.general.sort-asc')}+ </div>+ <div+ className={`+ univer-flex univer-w-[140px] univer-flex-1 univer-cursor-default univer-items-center+ univer-justify-center univer-gap-1 univer-rounded-r-md univer-border univer-border-solid+ univer-border-gray-200 univer-py-1.5 univer-text-[13px] univer-font-normal+ hover:univer-cursor-pointer hover:univer-bg-gray-100+ ${isDesc+ ? 'univer-bg-gray-100'+ : ''}+ `}+ onClick={() => applySort(false)}+ >+ <DescendingSingle className="univer-text-base univer-text-color-[#1e222b] univer-mr-1" />+ {localeService.t('sheets-sort.general.sort-desc')}+ </div>++ </div>+ )}+ <div className="univer-w-full">+ <Segmented+ value={filterBy}+ items={filterByItems}+ onChange={(value) => setFilterBy(value as FilterByEnum)}+ />+ </div>+ <div className="univer-z-10 univer-h-60 univer-w-[280px]">+ <div className="univer-mt-3 univer-h-full univer-w-full">+ {filterBy === FilterByEnum.Items+ ? (+ <SheetTableItemsFilterPanel+ tableFilter={tableFilter}+ unitId={unitId}+ subUnitId={subUnitId}+ tableId={tableId}+ columnIndex={columnIndex}+ checkedItemSet={checkedItemSet}+ setCheckedItemSet={setCheckedItemSet}+ />+ )+ : (+ <SheetTableConditionPanel+ tableFilter={tableFilter}+ unitId={unitId}+ subUnitId={subUnitId}+ tableId={tableId}+ columnIndex={columnIndex}+ conditionInfo={conditionInfo}+ onChange={setConditionInfo}+ />+ )}+ </div>+ </div>+ <div+ className={`+ univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-wrap-nowrap+ univer-justify-between univer-overflow-hidden+ `}+ >+ <Button+ disabled={tableFilter === undefined}+ onClick={onClearFilter}+ >+ {localeService.t('sheets-filter.panel.clear-filter')}+ </Button>+ <div>+ <Button className="univer-mr-2" onClick={onCancel}>{localeService.t('sheets-filter.panel.cancel')}</Button>+ <Button variant="primary" onClick={onApply}>{localeService.t('sheets-filter.panel.confirm')}</Button>+ </div>+ </div>+ </div>+ );+}++function useFilterByOptions(localeService: LocaleService) {+ const locale = localeService.getCurrentLocale();+ return useMemo(() => [+ { label: localeService.t('sheets-filter.panel.by-values'), value: FilterByEnum.Items },+ { label: localeService.t('sheets-filter.panel.by-conditions'), value: FilterByEnum.Condition },+ ], [locale, localeService]);+}diff --git a/packages/sheets-table-ui/src/views/components/SheetTableItemsFilterPanel.tsx b/packages/sheets-table-ui/src/views/components/SheetTableItemsFilterPanel.tsxnew file mode 100644index 0000000000..ead41af93d--- /dev/null+++ b/packages/sheets-table-ui/src/views/components/SheetTableItemsFilterPanel.tsx@@ -0,0 +1,159 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ITableFilterItem } from '@univerjs/sheets-table';+import { LocaleService } from '@univerjs/core';+import { Checkbox, Input, Scrollbar } from '@univerjs/design';+import { useDependency } from '@univerjs/ui';+import React, { useCallback, useState } from 'react';+import { SheetsTableUiService } from '../../services/sheets-table-ui-service';++interface ISheetTableItemsFilterPanelProps {+ unitId: string;+ subUnitId: string;+ tableFilter: ITableFilterItem | undefined;+ tableId: string;+ columnIndex: number;+ checkedItemSet: Set<string>;+ setCheckedItemSet: React.Dispatch<React.SetStateAction<Set<string>>>;+}++const getCheckedCount = (map: Map<string, number>) => {+ let count = 0;+ map.forEach((value) => {+ count += value;+ });+ return count;+};++export function SheetTableItemsFilterPanel(props: ISheetTableItemsFilterPanelProps) {+ const { unitId, tableId, subUnitId, columnIndex, checkedItemSet, setCheckedItemSet, tableFilter } = props;+ const localeService = useDependency(LocaleService);+ const tableService = useDependency(SheetsTableUiService);++ const { data: items, itemsCountMap, allItemsCount } = tableService.getTableFilterItems(unitId, subUnitId, tableId, columnIndex);++ // const allChecked = tableFilter === undefined ? true : checkedItemSet.size === itemsCountMap.size;+ const [allChecked, setAllChecked] = useState<boolean>(tableFilter === undefined ? true : checkedItemSet.size === itemsCountMap.size);++ const [checkedCount, setCheckedCount] = useState<number>(allChecked ? allItemsCount : getCheckedCount(itemsCountMap));++ const indeterminate = !allChecked && checkedItemSet.size > 0;+ const [searchText, setSearchText] = useState('');++ const onCheckAllToggled = useCallback(() => {+ if (allChecked) {+ checkedItemSet.clear();+ setCheckedItemSet(new Set(checkedItemSet));+ setAllChecked(false);+ } else {+ items.forEach((item) => {+ checkedItemSet.add(item.title);+ });+ setCheckedItemSet(new Set(checkedItemSet));+ setAllChecked(true);+ }+ }, [allChecked]);++ const onSearchValueChange = useCallback((str: string) => {+ }, []);++ const onCheckItemToggled = (key: string) => {+ if (allChecked) {+ setAllChecked(false);+ const newSet = new Set<string>();+ for (const { title } of items) {+ if (key !== title) {+ newSet.add(title);+ }+ }+ setCheckedCount(allItemsCount - itemsCountMap.get(key)!);+ setCheckedItemSet(newSet);+ } else {+ if (checkedItemSet.has(key)) {+ checkedItemSet.delete(key);+ setCheckedCount(checkedCount - itemsCountMap.get(key)!);+ } else {+ checkedItemSet.add(key);+ setCheckedCount(checkedCount + itemsCountMap.get(key)!);+ }+ setCheckedItemSet(new Set(checkedItemSet));+ }+ };++ return (+ <div className="univer-flex univer-h-full univer-flex-col">+ <Input autoFocus value={searchText} placeholder={localeService.t('sheets-filter.panel.search-placeholder')} onChange={onSearchValueChange} />+ <div+ className={`+ 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-border univer-border-solid+ univer-border-gray-200 univer-py-1.5 univer-pl-2+ `}+ >+ <div+ className="univer-h-40 univer-overflow-y-hidden univer-py-1 univer-pl-2"+ >+ <Scrollbar>+ <div className="univer-h-40">+ <div+ className="univer-flex univer-items-center univer-px-2 univer-py-1"+ >+ <Checkbox+ indeterminate={indeterminate}+ disabled={items.length === 0}+ checked={allChecked}+ onChange={onCheckAllToggled}+ />+ <div+ className={`+ univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-items-center+ univer-text-sm+ `}+ >+ <span className="univer-inline-block univer-truncate">{`${localeService.t('sheets-filter.panel.select-all')}`}</span>+ <span className="univer-ml univer-text-gray-400">{`(${allChecked ? allItemsCount : checkedCount}/${allItemsCount})`}</span>+ </div>+ </div>+ {items.map((item) => {+ return (+ <div+ key={item.key}+ className="univer-flex univer-items-center univer-px-2 univer-py-1"+ >+ <Checkbox checked={allChecked || checkedItemSet.has(item.title)} onChange={() => { onCheckItemToggled(item.title); }} />+ <div+ className={`+ univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-items-start+ univer-text-sm+ `}+ >++ <span className="univer-inline-block univer-truncate">{item.title}</span>+ <span className="univer-ml-1 univer-text-gray-400">{`(${itemsCountMap.get(item.title) || 0})`}</span>+ </div>+ </div>+ );+ })}+ </div>+ </Scrollbar>+ </div>++ </div>+ </div>++ );+}diff --git a/packages/sheets-table-ui/src/views/components/SheetTableSelector.tsx b/packages/sheets-table-ui/src/views/components/SheetTableSelector.tsxnew file mode 100644index 0000000000..3859a7d264--- /dev/null+++ b/packages/sheets-table-ui/src/views/components/SheetTableSelector.tsx@@ -0,0 +1,139 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ITableSelectionInfo } from '../../commands/operations/open-table-selector.operation';+import { IUniverInstanceService, LocaleService, Rectangle } from '@univerjs/core';+import { Button } from '@univerjs/design';+import { deserializeRangeWithSheet, serializeRange } from '@univerjs/engine-formula';+import { getSheetCommandTarget } from '@univerjs/sheets';+import { RangeSelector } from '@univerjs/sheets-formula-ui';+import { TableManager } from '@univerjs/sheets-table';+import { useDependency } from '@univerjs/ui';+import { useState } from 'react';++export const SheetTableSelector = (props: ITableSelectionInfo & {+ onConfirm: (info: ITableSelectionInfo) => void;+ onCancel: () => void;+}) => {+ const { unitId, subUnitId, range, onCancel, onConfirm, tableId } = props;++ const tableManager = useDependency(TableManager);+ const [selectedRange, setSelectedRange] = useState(range);+ const [rangeError, setRangeError] = useState('');+ const localeService = useDependency(LocaleService);+ const univerInstanceService = useDependency(IUniverInstanceService);++ return (+ <>+ <RangeSelector+ maxRangeCount={1}+ unitId={unitId}+ subUnitId={subUnitId}+ initialValue={serializeRange(range)}+ onChange={(_, text) => {+ const originValue = serializeRange(range);+ const newRange = deserializeRangeWithSheet(text).range;+ const target = getSheetCommandTarget(univerInstanceService, { unitId, subUnitId });+ if (!target) {+ return;+ }+ const worksheet = target.worksheet;+ const merges = worksheet.getMergeData();+ const hasOverlapWithMerge = merges.some((merge) => {+ return Rectangle.intersects(newRange, merge);+ });++ if (hasOverlapWithMerge) {+ setRangeError(localeService.t('sheets-table.tableRangeWithMergeError'));+ return;+ }++ const hasOverlapWithOtherTable = tableManager.getTablesBySubunitId(unitId, subUnitId).some((table) => {+ if (table.getId() === tableId) {+ return false;+ }+ const tableRange = table.getRange();+ return Rectangle.intersects(newRange, tableRange);+ });++ if (hasOverlapWithOtherTable) {+ setRangeError(localeService.t('sheets-table.tableRangeWithOtherTableError'));+ return;+ }+ const { startRow, endRow } = newRange;+ const isSingleRow = startRow === endRow;+ if (isSingleRow) {+ setRangeError(localeService.t('sheets-table.tableRangeSingleRowError'));+ return;+ }++ if (originValue === text) {+ return;+ }++ if (tableId) {+ const table = tableManager.getTableById(unitId, tableId);+ if (table) {+ const oldRange = table.getRange();+ if (Rectangle.intersects(newRange, oldRange) && oldRange.startRow === newRange.startRow) {+ setSelectedRange(newRange);+ setRangeError('');+ onConfirm({+ unitId,+ subUnitId,+ range: newRange,+ });+ return;+ } else {+ setRangeError(localeService.t('sheets-table.updateError'));+ return;+ }+ }+ }++ setSelectedRange(range);+ setRangeError('');+ }}+ supportAcrossSheet={false}+ />+ {rangeError && (+ <div className="univer-mt-1 univer-text-xs univer-text-red-500">+ {rangeError}+ </div>+ )}++ <div className="univer-mt-4 univer-flex univer-justify-end">+ <Button onClick={onCancel}>{localeService.t('sheets-table.cancel')}</Button>+ <Button+ variant="primary"+ onClick={() => {+ if (rangeError) {+ return;+ }+ onConfirm({+ unitId,+ subUnitId,+ range: selectedRange,+ });+ }}+ className="univer-ml-2"+ >+ {localeService.t('sheets-table.confirm')}+ </Button>+ </div>+ </>+ );+};diff --git a/packages/sheets-table-ui/src/views/components/SheetTableThemePanel.tsx b/packages/sheets-table-ui/src/views/components/SheetTableThemePanel.tsxnew file mode 100644index 0000000000..54f701cdc2--- /dev/null+++ b/packages/sheets-table-ui/src/views/components/SheetTableThemePanel.tsx@@ -0,0 +1,429 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IRangeThemeStyleItem, ISetRangeThemeMutationParams } from '@univerjs/sheets';+import type { IAddTableThemeCommandParams, ISetSheetTableCommandParams, ITableSetConfig } from '@univerjs/sheets-table';+import { ColorKit, ErrorService, ICommandService, LocaleService } from '@univerjs/core';+import { ColorPicker, Dropdown } from '@univerjs/design';+import { DropdownSingle } from '@univerjs/icons';+import { RangeThemeStyle, SetRangeThemeMutation, SheetRangeThemeModel } from '@univerjs/sheets';+import { AddTableThemeCommand, customEmptyThemeWithBorderStyle, processStyleWithBorderStyle, RemoveTableThemeCommand, SetSheetTableCommand, TableManager } from '@univerjs/sheets-table';+import { useDependency, useObservable } from '@univerjs/ui';+import { useEffect, useState } from 'react';+import { TABLE_BORDER_DEFAULT, TABLE_BORDER_NONE, TABLE_BORDER_SELECTED, TABLE_CUSTOM_NAME_PREFIX, TABLE_DEFAULT_BG_COLOR, TABLE_DEFAULT_NAME_PREFIX } from '../../const';+import { SheetTableThemeUIController } from '../../controllers/sheet-table-theme-ui.controller';++export interface ISheetTableThemePanelProps {+ unitId: string;+ subUnitId: string;+ tableId: string;+ oldConfig: ITableSetConfig;+}++interface ITableThemeStyle {+ headerRowStyle?: IRangeThemeStyleItem;+ firstRowStyle?: IRangeThemeStyleItem;+ secondRowStyle?: IRangeThemeStyleItem;+ lastRowStyle?: IRangeThemeStyleItem;+}++export const SheetTableThemePanel = (props: ISheetTableThemePanelProps) => {+ const { unitId, subUnitId, tableId } = props;+ const commandService = useDependency(ICommandService);+ const localeService = useDependency(LocaleService);+ const tableManager = useDependency(TableManager);+ const table = tableManager.getTableById(unitId, tableId);+ const rangeThemeModel = useDependency(SheetRangeThemeModel);+ const sheetTableThemeUIController = useDependency(SheetTableThemeUIController);++ const rangeThemeMapChanged$ = useObservable(rangeThemeModel.rangeThemeMapChange$);+ const tableRefresh$ = useObservable(sheetTableThemeUIController.refreshTable$);++ const errorService = useDependency(ErrorService);++ const [, setRefresh] = useState(Math.random());++ const themeConfig = useObservable(tableManager.tableThemeChanged$, {+ theme: table?.getTableStyleId(),+ oldTheme: table?.getTableStyleId(),+ unitId,+ subUnitId,+ tableId,+ });++ const defaultRangeThemes = rangeThemeModel.getRegisteredRangeThemes().filter((item) => item?.startsWith(TABLE_DEFAULT_NAME_PREFIX));+ const customRangeThemes = rangeThemeModel.getALLRegisteredTheme(unitId).filter((item) => item?.startsWith(TABLE_CUSTOM_NAME_PREFIX));+ const selectedTheme = table?.getTableStyleId();+ const customSelected = customRangeThemes.find((item) => item === selectedTheme);+ const customStyleName = customSelected || customRangeThemes[0];+ const customStyle = rangeThemeModel.getCustomRangeThemeStyle(unitId, customStyleName);+ const headerBg = customStyle?.getHeaderRowStyle()?.bg?.rgb ?? TABLE_DEFAULT_BG_COLOR;+ const firstRowBg = customStyle?.getFirstRowStyle()?.bg?.rgb ?? TABLE_DEFAULT_BG_COLOR;+ const secondRowBg = customStyle?.getSecondRowStyle()?.bg?.rgb ?? TABLE_DEFAULT_BG_COLOR;+ const lastRowBg = customStyle?.getLastRowStyle()?.bg?.rgb ?? TABLE_DEFAULT_BG_COLOR;+ const [hoverCustomId, setHoverCustomId] = useState<string | null>(null);++ const handleThemeChange = (theme: string) => {+ commandService.executeCommand<ISetSheetTableCommandParams>(SetSheetTableCommand.id, {+ unitId,+ tableId,+ theme,+ });+ };++ const handleAddCustomTheme = () => {+ if (customRangeThemes.length >= 11) {+ errorService.emit(localeService.t('sheets-table.customTooMore'));+ return;+ }+ const lastCustomTheme = customRangeThemes[customRangeThemes.length - 1];+ let newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}1`;+ if (lastCustomTheme) {+ const index = Number(lastCustomTheme.split('-')[2]);+ newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}${index + 1}`;+ }+ const newTheme = new RangeThemeStyle(newThemeName, { ...customEmptyThemeWithBorderStyle });+ commandService.executeCommand<IAddTableThemeCommandParams>(AddTableThemeCommand.id, {+ unitId,+ tableId,+ themeStyle: newTheme,+ });+ };++ const setCustomTheme = (themeName: string, tableThemeStyle: ITableThemeStyle) => {+ commandService.executeCommand<ISetRangeThemeMutationParams>(SetRangeThemeMutation.id, {+ unitId,+ subUnitId,+ styleName: themeName,+ style: tableThemeStyle,+ });+ };++ const removeCustomTheme = (themeName: string) => {+ commandService.executeCommand(RemoveTableThemeCommand.id, {+ unitId,+ tableId,+ themeName,+ });+ };++ useEffect(() => {+ setRefresh(Math.random());+ }, [rangeThemeMapChanged$, tableRefresh$]);++ if (!table) return null;++ return (+ <div>+ <h5>{localeService.t('sheets-table.defaultStyle')}</h5>+ <div className="univer-flex univer-gap-2">+ {defaultRangeThemes.map((item) => {+ const rangeThemeItem = rangeThemeModel.getDefaultRangeThemeStyle(item);+ const headerRowBg = rangeThemeItem?.getHeaderRowStyle()?.bg?.rgb || TABLE_DEFAULT_BG_COLOR;+ const firstRowBg = rangeThemeItem?.getFirstRowStyle()?.bg?.rgb || TABLE_DEFAULT_BG_COLOR;+ const secondRowBg = rangeThemeItem?.getSecondRowStyle()?.bg?.rgb || TABLE_DEFAULT_BG_COLOR;+ const lastRowBg = rangeThemeItem?.getLastRowStyle()?.bg?.rgb || TABLE_DEFAULT_BG_COLOR;++ return (+ <div+ key={item}+ className="univer-h-10 univer-w-8 univer-cursor-pointer univer-p-[1px]"+ onClick={() => handleThemeChange(item)}+ style={{+ border: item === themeConfig.theme ? TABLE_BORDER_SELECTED : TABLE_BORDER_DEFAULT,+ }}+ >+ <div className="univer-box-border univer-h-[10px]" style={{ background: headerRowBg, border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}` }} />+ <div className="univer-box-border univer-h-[10px]" style={{ background: firstRowBg, border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}` }} />+ <div className="univer-box-border univer-h-[10px]" style={{ background: secondRowBg, border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}` }} />+ <div className="univer-box-border univer-h-[10px]" style={{ background: lastRowBg, border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}` }} />+ </div>+ );+ })}+ </div>++ <h5>{localeService.t('sheets-table.customStyle')}</h5>+ <div className="univer-w-full univer-rounded-sm univer-border univer-border-solid univer-border-gray-200">+ <div className="univer-flex univer-flex-wrap univer-gap-2 univer-p-2">+ <div+ className={`+ univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid+ univer-border-gray-200 univer-p-[1px] univer-text-center univer-leading-10+ `}+ onClick={handleAddCustomTheme}+ >+ ++ </div>+ {customRangeThemes.map((item) => {+ const rangeThemeItem = rangeThemeModel.getCustomRangeThemeStyle(unitId, item);+ const headerRowBg = rangeThemeItem?.getHeaderRowStyle()?.bg?.rgb;+ const firstRowBg = rangeThemeItem?.getFirstRowStyle()?.bg?.rgb;+ const secondRowBg = rangeThemeItem?.getSecondRowStyle()?.bg?.rgb;+ const lastRowBg = rangeThemeItem?.getLastRowStyle()?.bg?.rgb;++ return (+ <div+ key={item}+ className="univer-relative univer-h-10 univer-w-8 univer-cursor-pointer univer-p-[1px]"+ onClick={() => handleThemeChange(item)}+ style={{+ border: item === themeConfig.theme ? TABLE_BORDER_SELECTED : TABLE_BORDER_DEFAULT,+ }}+ onMouseEnter={() => setHoverCustomId(item)}+ onMouseLeave={() => setHoverCustomId(null)}+ >+ <div className="univer-box-border univer-h-[10px]" style={{ background: headerRowBg ?? TABLE_BORDER_NONE, border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}` }} />+ <div className="univer-box-border univer-h-[10px]" style={{ background: firstRowBg ?? TABLE_BORDER_NONE, border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}` }} />+ <div className="univer-box-border univer-h-[10px]" style={{ background: secondRowBg ?? TABLE_BORDER_NONE, border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}` }} />+ <div className="univer-box-border univer-h-[10px]" style={{ background: lastRowBg ?? TABLE_BORDER_NONE, border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}` }} />++ <div+ className={`+ univer-absolute univer-right-[-3px] univer-top-[-3px] univer-h-3 univer-w-3+ univer-rounded-md univer-bg-gray-200 univer-text-center univer-text-xs+ univer-leading-[10px]+ `}+ style={{ display: hoverCustomId === item ? 'block' : 'none' }}+ onClick={(e) => {+ e.stopPropagation();+ removeCustomTheme(item);+ }}+ >+ x+ </div>+ </div>+ );+ })}+ </div>++ {customSelected && (+ <>+ <div className="univer-h-[1px] univer-w-full univer-bg-gray-200" />+ <div className="univer-flex univer-flex-col univer-gap-2 univer-p-2">+ <div className="univer-flex univer-h-9 univer-gap-2">+ <div+ className={`+ univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-border+ univer-border-solid univer-border-gray-200 univer-text-center univer-leading-9+ `}+ style={{+ background: headerBg,+ color: new ColorKit(headerBg).isDark() ? '#fff' : '#000',+ }}+ >+ {localeService.t('sheets-table.header')}+ </div>+ <Dropdown+ overlay={(+ <div className="univer-p-2">+ <ColorPicker+ value={headerBg}+ onChange={(val) => {+ const headerRowStyle = processStyleWithBorderStyle('headerRowStyle', {+ bg: {+ rgb: val,+ },+ cl: {+ rgb: new ColorKit(val).isDark() ? '#fff' : '#000',+ },+ });+ setCustomTheme(table.getTableStyleId(), { headerRowStyle });+ }}+ />+ </div>+ )}+ >+ <div+ className={`+ univer-flex univer-cursor-pointer univer-items-center univer-gap-2+ univer-rounded-sm univer-border univer-border-solid univer-border-gray-200+ univer-bg-white univer-p-1+ `}+ >+ <div+ className={`+ univer-h-4 univer-w-4 univer-rounded-[8px] univer-border+ univer-border-solid univer-border-gray-200 univer-bg-slate-400+ `}+ style={{+ background: headerBg,+ color: new ColorKit(headerBg).isDark() ? '#fff' : '#000',+ }}+ />+ <DropdownSingle className="univer-h-2 univer-w-2" />+ </div>+ </Dropdown>+ </div>+ <div className="univer-flex univer-h-9 univer-gap-2">+ <div+ className={`+ univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-border+ univer-border-solid univer-border-gray-200 univer-text-center univer-leading-9+ `}+ style={{+ background: firstRowBg,+ color: new ColorKit(firstRowBg).isDark() ? '#fff' : '#000',+ }}+ >+ {localeService.t('sheets-table.firstLine')}+ </div>+ <Dropdown+ overlay={(+ <div className="univer-p-2">+ <ColorPicker+ value={firstRowBg}+ onChange={(val) => {+ setCustomTheme(table.getTableStyleId(), {+ firstRowStyle: {+ bg: {+ rgb: val,+ },+ cl: {+ rgb: new ColorKit(val).isDark() ? '#fff' : '#000',+ },+ },+ });+ }}+ />+ </div>+ )}+ >+ <div+ className={`+ univer-flex univer-cursor-pointer univer-items-center univer-gap-2+ univer-rounded-sm univer-border univer-border-solid univer-border-gray-200+ univer-bg-white univer-p-1+ `}+ >+ <div+ className={`+ univer-h-4 univer-w-4 univer-rounded-[8px] univer-border+ univer-border-solid univer-border-gray-200 univer-bg-slate-400+ `}+ style={{ background: firstRowBg }}+ />+ <DropdownSingle className="univer-h-2 univer-w-2" />+ </div>+ </Dropdown>+ </div>+ <div className="univer-flex univer-h-9 univer-gap-2">+ <div+ className={`+ univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-border+ univer-border-solid univer-border-gray-200 univer-text-center univer-leading-9+ `}+ style={{+ background: secondRowBg,+ color: new ColorKit(secondRowBg).isDark() ? '#fff' : '#000',+ }}+ >+ {localeService.t('sheets-table.secondLine')}+ </div>+ <Dropdown+ overlay={(+ <div className="univer-p-2">+ <ColorPicker+ value={secondRowBg}+ onChange={(val) => setCustomTheme(table.getTableStyleId(), {+ secondRowStyle: {+ bg: {+ rgb: val,+ },+ cl: {+ rgb: new ColorKit(val).isDark() ? '#fff' : '#000',+ },+ },+ })}+ />+ </div>+ )}+ >+ <div+ className={`+ univer-flex univer-cursor-pointer univer-items-center univer-gap-2+ univer-rounded-sm univer-border univer-border-solid univer-border-gray-200+ univer-bg-white univer-p-1+ `}+ >+ <div+ className={`+ univer-h-4 univer-w-4 univer-rounded-[8px] univer-border+ univer-border-solid univer-border-gray-200 univer-bg-slate-400+ `}+ style={{ background: secondRowBg }}+ />+ <DropdownSingle className="univer-h-2 univer-w-2" />+ </div>+ </Dropdown>+ </div>+ <div className="univer-flex univer-h-9 univer-gap-2">+ <div+ className={`+ univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-border+ univer-border-solid univer-border-gray-200 univer-text-center univer-leading-9+ `}+ style={{+ background: lastRowBg,+ color: new ColorKit(lastRowBg).isDark() ? '#fff' : '#000',+ }}+ >+ {localeService.t('sheets-table.footer')}+ </div>+ <Dropdown+ overlay={(+ <div className="univer-p-2">+ <ColorPicker+ value={lastRowBg}+ onChange={(val) => {+ const lastRowStyle = processStyleWithBorderStyle('lastRowStyle', {+ bg: {+ rgb: val,+ },+ cl: {+ rgb: new ColorKit(val).isDark() ? '#fff' : '#000',+ },+ });+ setCustomTheme(table.getTableStyleId(), { lastRowStyle });+ }}+ />+ </div>+ )}+ >+ <div+ className={`+ univer-flex univer-cursor-pointer univer-items-center univer-gap-2+ univer-rounded-sm univer-border univer-border-solid univer-border-gray-200+ univer-bg-white univer-p-1+ `}+ >+ <div+ className={`+ univer-h-4 univer-w-4 univer-rounded-[8px] univer-border+ univer-border-solid univer-border-gray-200 univer-bg-slate-400+ `}+ style={{ background: lastRowBg }}+ />+ <DropdownSingle className="univer-h-2 univer-w-2" />+ </div>+ </Dropdown>+ </div>+ </div>+ </>+ )}+ </div>+ </div>+ );+};diff --git a/packages/sheets-table-ui/src/views/components/type.ts b/packages/sheets-table-ui/src/views/components/type.tsnew file mode 100644index 0000000000..ff978abef7--- /dev/null+++ b/packages/sheets-table-ui/src/views/components/type.ts@@ -0,0 +1,45 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { TableConditionTypeEnum, TableDateCompareTypeEnum, TableNumberCompareTypeEnum, TableStringCompareTypeEnum } from '@univerjs/sheets-table';++export enum ConditionSubComponentEnum {+ DatePicker = 'DatePicker',+ DateRange = 'DateRange',+ Input = 'Input',+ Inputs = 'Inputs',+ Select = 'Select',+ None = 'None',+}++export type IConditionCompareTypeEnum = TableStringCompareTypeEnum | TableDateCompareTypeEnum | TableNumberCompareTypeEnum;++export type ITableConditionTypeEnumWithoutLogic = Exclude<TableConditionTypeEnum, TableConditionTypeEnum.Logic>;++export interface IConditionInfo {+ type: ITableConditionTypeEnumWithoutLogic;+ compare: IConditionCompareTypeEnum;+ info: IConditionExpect;+}++export interface IConditionExpect {+ date?: Date;+ dateRange?: [Date, Date];+ dateSelect?: string;+ number?: number;+ numberRange?: [number?, number?];+ string?: string;+}diff --git a/packages/sheets-table-ui/src/views/components/util.ts b/packages/sheets-table-ui/src/views/components/util.tsnew file mode 100644index 0000000000..e5507919cc--- /dev/null+++ b/packages/sheets-table-ui/src/views/components/util.ts@@ -0,0 +1,423 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++/* eslint-disable max-lines-per-function */++import type { Injector } from '@univerjs/core';+import type { ITableFilterItem } from '@univerjs/sheets-table';+import type { IConditionCompareTypeEnum } from './type';+import { LocaleService } from '@univerjs/core';+import { TableConditionTypeEnum, TableDateCompareTypeEnum, TableNumberCompareTypeEnum, TableStringCompareTypeEnum } from '@univerjs/sheets-table';+import { ConditionSubComponentEnum } from './type';++export function getCascaderListOptions(injector: Injector) {+ const localeService = injector.get(LocaleService);+ const t = localeService.t;+ return [+ {+ value: TableConditionTypeEnum.String,+ label: t(`sheets-table.condition.${TableConditionTypeEnum.String}`),+ children: [+ {+ value: TableStringCompareTypeEnum.Equal,+ label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.Equal}`),+ },+ {+ value: TableStringCompareTypeEnum.NotEqual,+ label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.NotEqual}`),+ },+ {+ value: TableStringCompareTypeEnum.Contains,+ label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.Contains}`),+ },+ {+ value: TableStringCompareTypeEnum.NotContains,+ label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.NotContains}`),+ },+ {+ value: TableStringCompareTypeEnum.StartsWith,+ label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.StartsWith}`),+ },+ {+ value: TableStringCompareTypeEnum.EndsWith,+ label: t(`sheets-table.string.compare.${TableStringCompareTypeEnum.EndsWith}`),+ },+ ],+ },+ {+ value: TableConditionTypeEnum.Number,+ label: t(`sheets-table.condition.${TableConditionTypeEnum.Number}`),+ children: [+ {+ value: TableNumberCompareTypeEnum.Equal,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.Equal}`),+ },+ {+ value: TableNumberCompareTypeEnum.NotEqual,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.NotEqual}`),+ },+ {+ value: TableNumberCompareTypeEnum.GreaterThan,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.GreaterThan}`),+ },+ {+ value: TableNumberCompareTypeEnum.GreaterThanOrEqual,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.GreaterThanOrEqual}`),+ },+ {+ value: TableNumberCompareTypeEnum.LessThan,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.LessThan}`),+ },+ {+ value: TableNumberCompareTypeEnum.LessThanOrEqual,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.LessThanOrEqual}`),+ },+ {+ value: TableNumberCompareTypeEnum.Between,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.Between}`),+ },+ {+ value: TableNumberCompareTypeEnum.NotBetween,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.NotBetween}`),+ },+ {+ value: TableNumberCompareTypeEnum.Above,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.Above}`),+ },+ {+ value: TableNumberCompareTypeEnum.Below,+ label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.Below}`),+ },+ // {+ // value: TableNumberCompareTypeEnum.TopN,+ // label: t(`sheets-table.number.compare.${TableNumberCompareTypeEnum.TopN}`),+ // },+ ],+ },+ {+ value: TableConditionTypeEnum.Date,+ label: t(`sheets-table.condition.${TableConditionTypeEnum.Date}`),+ children: [+ {+ value: TableDateCompareTypeEnum.Equal,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Equal}`),+ },+ {+ value: TableDateCompareTypeEnum.NotEqual,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NotEqual}`),+ },+ {+ value: TableDateCompareTypeEnum.After,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.After}`),+ },+ {+ value: TableDateCompareTypeEnum.AfterOrEqual,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.AfterOrEqual}`),+ },+ {+ value: TableDateCompareTypeEnum.Before,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Before}`),+ },+ {+ value: TableDateCompareTypeEnum.BeforeOrEqual,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.BeforeOrEqual}`),+ },+ {+ value: TableDateCompareTypeEnum.Between,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Between}`),+ },+ {+ value: TableDateCompareTypeEnum.NotBetween,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NotBetween}`),+ },+ {+ value: TableDateCompareTypeEnum.Today,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Today}`),+ },+ {+ value: TableDateCompareTypeEnum.Yesterday,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Yesterday}`),+ },+ {+ value: TableDateCompareTypeEnum.Tomorrow,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Tomorrow}`),+ },+ {+ value: TableDateCompareTypeEnum.ThisWeek,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.ThisWeek}`),+ },+ {+ value: TableDateCompareTypeEnum.LastWeek,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.LastWeek}`),+ },+ {+ value: TableDateCompareTypeEnum.NextWeek,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NextWeek}`),+ },+ {+ value: TableDateCompareTypeEnum.ThisMonth,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.ThisMonth}`),+ },+ {+ value: TableDateCompareTypeEnum.LastMonth,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.LastMonth}`),+ },+ {+ value: TableDateCompareTypeEnum.NextMonth,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NextMonth}`),+ },+ {+ value: TableDateCompareTypeEnum.ThisYear,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.ThisYear}`),+ },+ {+ value: TableDateCompareTypeEnum.LastYear,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.LastYear}`),+ },+ {+ value: TableDateCompareTypeEnum.NextYear,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.NextYear}`),+ },+ {+ value: TableDateCompareTypeEnum.Quarter,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Quarter}`),+ },+ {+ value: TableDateCompareTypeEnum.Month,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Month}`),+ },+ ],+ },+ ];+}++export function getConditionDateSelect(injector: Injector, dateType?: TableDateCompareTypeEnum) {+ if (!dateType) {+ return [];+ }+ const localeService = injector.get(LocaleService);+ const t = localeService.t;+ switch (dateType) {+ case TableDateCompareTypeEnum.Quarter:+ return [+ {+ value: TableDateCompareTypeEnum.Q1,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Q1}`),+ },+ {+ value: TableDateCompareTypeEnum.Q2,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Q2}`),+ },+ {+ value: TableDateCompareTypeEnum.Q3,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Q3}`),+ },+ {+ value: TableDateCompareTypeEnum.Q4,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.Q4}`),+ },+ ];+ case TableDateCompareTypeEnum.Month:+ return [+ {+ value: TableDateCompareTypeEnum.M1,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M1}`),+ },+ {+ value: TableDateCompareTypeEnum.M2,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M2}`),+ },+ {+ value: TableDateCompareTypeEnum.M3,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M3}`),+ },+ {+ value: TableDateCompareTypeEnum.M4,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M4}`),+ },+ {+ value: TableDateCompareTypeEnum.M5,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M5}`),+ },+ {+ value: TableDateCompareTypeEnum.M6,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M6}`),+ },+ {+ value: TableDateCompareTypeEnum.M7,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M7}`),+ },+ {+ value: TableDateCompareTypeEnum.M8,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M8}`),+ },+ {+ value: TableDateCompareTypeEnum.M9,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M9}`),+ },+ {+ value: TableDateCompareTypeEnum.M10,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M10}`),+ },+ {+ value: TableDateCompareTypeEnum.M11,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M11}`),+ },+ {+ value: TableDateCompareTypeEnum.M12,+ label: t(`sheets-table.date.compare.${TableDateCompareTypeEnum.M12}`),+ },+ ];+ default:+ return [];+ }+}++export const datePickerSet: Set<IConditionCompareTypeEnum> = new Set([+ TableDateCompareTypeEnum.Equal,+ TableDateCompareTypeEnum.NotEqual,+ TableDateCompareTypeEnum.After,+ TableDateCompareTypeEnum.AfterOrEqual,+ TableDateCompareTypeEnum.Before,+ TableDateCompareTypeEnum.BeforeOrEqual,+]);++export function getSubComponentType(type: TableConditionTypeEnum, compare?: TableStringCompareTypeEnum | TableNumberCompareTypeEnum | TableDateCompareTypeEnum): ConditionSubComponentEnum {+ if (!compare) {+ return ConditionSubComponentEnum.None;+ }+ if (type === TableConditionTypeEnum.String) {+ return ConditionSubComponentEnum.Input;+ } else if (type === TableConditionTypeEnum.Number) {+ if (compare === TableNumberCompareTypeEnum.Between || compare === TableNumberCompareTypeEnum.NotBetween) {+ return ConditionSubComponentEnum.Inputs;+ } else {+ return ConditionSubComponentEnum.Input;+ }+ } else if (type === TableConditionTypeEnum.Date) {+ if (compare === TableDateCompareTypeEnum.Between || compare === TableDateCompareTypeEnum.NotBetween) {+ return ConditionSubComponentEnum.DateRange;+ } else if (compare === TableDateCompareTypeEnum.Quarter || compare === TableDateCompareTypeEnum.Month) {+ return ConditionSubComponentEnum.Select;+ } else if (datePickerSet.has(compare as TableDateCompareTypeEnum)) {+ return ConditionSubComponentEnum.DatePicker;+ }+ return ConditionSubComponentEnum.None;+ }+ return ConditionSubComponentEnum.None;+}++// eslint-disable-next-line complexity+export function getInitConditionInfo(tableFilter?: ITableFilterItem) {+ if (!tableFilter || tableFilter.filterType !== 'condition') {+ return {+ type: TableConditionTypeEnum.String,+ compareType: TableStringCompareTypeEnum.Equal,+ info: {},+ };+ }++ const filterInfo = tableFilter.filterInfo;+ const { conditionType, compareType } = filterInfo;+ if (conditionType === TableConditionTypeEnum.Date) {+ if (compareType === TableDateCompareTypeEnum.Between || compareType === TableDateCompareTypeEnum.NotBetween) {+ return {+ type: conditionType,+ compare: compareType,+ info: {+ dateRange: filterInfo.expectedValue,+ },+ };+ } 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 {+ type: conditionType,+ compare: compareType,+ info: {},+ };+ } else if (datePickerSet.has(compareType as TableDateCompareTypeEnum)) {+ return {+ type: conditionType,+ compare: compareType,+ info: {+ date: filterInfo.expectedValue,+ },+ };+ } else {+ const quarter = new Set([TableDateCompareTypeEnum.Q1, TableDateCompareTypeEnum.Q2, TableDateCompareTypeEnum.Q3, TableDateCompareTypeEnum.Q4]);+ if (quarter.has(compareType as TableDateCompareTypeEnum)) {+ return {+ type: conditionType,+ compare: TableDateCompareTypeEnum.Quarter,+ info: {+ dateSelect: filterInfo.compareType,+ },+ };+ } else {+ return {+ type: conditionType,+ compare: TableDateCompareTypeEnum.Month,+ info: {+ dateSelect: filterInfo.compareType,+ },+ };+ }+ }+ } else if (conditionType === TableConditionTypeEnum.Number) {+ if (compareType === TableNumberCompareTypeEnum.Between || compareType === TableNumberCompareTypeEnum.NotBetween) {+ return {+ type: conditionType,+ compare: compareType,+ info: {+ numberRange: filterInfo.expectedValue,+ },+ };+ } else {+ return {+ type: conditionType,+ compare: compareType,+ info: {+ number: filterInfo.expectedValue,+ },+ };+ }+ } else if (conditionType === TableConditionTypeEnum.String) {+ return {+ type: conditionType,+ compare: compareType,+ info: {+ string: filterInfo.expectedValue,+ },+ };+ }++ return {+ type: TableConditionTypeEnum.String,+ compare: TableStringCompareTypeEnum.Equal,+ info: {},+ };+}diff --git a/packages/sheets-table-ui/src/views/menu.ts b/packages/sheets-table-ui/src/views/menu.tsnew file mode 100644index 0000000000..fe0289db5f--- /dev/null+++ b/packages/sheets-table-ui/src/views/menu.ts@@ -0,0 +1,156 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IAccessor, Workbook } from '@univerjs/core';+import type { IMenuItem, IMenuSelectorItem } from '@univerjs/ui';+import type { Observable } from 'rxjs';+import { IUniverInstanceService, UniverInstanceType } from '@univerjs/core';+import { SheetsSelectionsService } from '@univerjs/sheets';+import { SheetsTableController, SheetTableInsertColCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveRowCommand } from '@univerjs/sheets-table';+import { MenuItemType } from '@univerjs/ui';+import { of, switchMap } from 'rxjs';+import { OpenTableSelectorOperation } from '../commands/operations/open-table-selector.operation';+import { TABLE_TOOLBAR_BUTTON } from '../const';++export const SHEET_TABLE_CONTEXT_INSERT_MENU_ID = 'sheet.table.context-insert_menu-id';+export const SHEET_TABLE_CONTEXT_REMOVE_MENU_ID = 'sheet.table.context-remove_menu-id';++export function sheetTableToolbarInsertMenuFactory(_accessor: IAccessor): IMenuItem {+ return {+ id: OpenTableSelectorOperation.id,+ type: MenuItemType.BUTTON,+ icon: TABLE_TOOLBAR_BUTTON,+ tooltip: 'sheets-table.title',+ title: 'sheets-table.title',+ };+}++export function SheetTableInsertContextMenuFactory(accessor: IAccessor): IMenuSelectorItem<string> {+ return {+ id: SHEET_TABLE_CONTEXT_INSERT_MENU_ID,+ type: MenuItemType.SUBITEMS,+ icon: 'Insert',+ title: 'sheets-table.insert.main',+ hidden$: getSheetTableRowColOperationHidden$(accessor),+ };+}++export function SheetTableRemoveContextMenuFactory(accessor: IAccessor): IMenuSelectorItem<string> {+ return {+ id: SHEET_TABLE_CONTEXT_REMOVE_MENU_ID,+ type: MenuItemType.SUBITEMS,+ icon: 'Reduce',+ title: 'sheets-table.remove.main',+ hidden$: getSheetTableRowColOperationHidden$(accessor),+ };+}++export function SheetTableInsertRowMenuFactory(accessor: IAccessor) {+ return {+ id: SheetTableInsertRowCommand.id,+ type: MenuItemType.BUTTON,+ title: 'sheets-table.insert.row',+ hidden$: getSheetTableHeaderOperationHidden$(accessor),+ };+}++export function SheetTableInsertColMenuFactory(accessor: IAccessor) {+ return {+ id: SheetTableInsertColCommand.id,+ title: 'sheets-table.insert.col',+ type: MenuItemType.BUTTON,+ };+}++export function SheetTableRemoveRowMenuFactory(accessor: IAccessor) {+ return {+ id: SheetTableRemoveRowCommand.id,+ type: MenuItemType.BUTTON,+ title: 'sheets-table.remove.row',+ hidden$: getSheetTableHeaderOperationHidden$(accessor),+ };+}++export function SheetTableRemoveColMenuFactory(accessor: IAccessor) {+ return {+ id: SheetTableRemoveColCommand.id,+ title: 'sheets-table.remove.col',+ type: MenuItemType.BUTTON,+ };+}++export function getSheetTableRowColOperationHidden$(accessor: IAccessor): Observable<boolean> {+ const sheetsSelectionsService = accessor.get(SheetsSelectionsService);+ const univerInstanceService = accessor.get(IUniverInstanceService);+ const workbook$ = univerInstanceService.getCurrentTypeOfUnit$<Workbook>(UniverInstanceType.UNIVER_SHEET);++ return workbook$.pipe(+ switchMap((workbook) => {+ if (!workbook) return of(true);+ return workbook.activeSheet$.pipe(+ switchMap((sheet) => {+ if (!sheet) return of(true);+ return sheetsSelectionsService.selectionMoveEnd$.pipe(+ switchMap((selections) => {+ if (!selections.length || selections.length > 1) return of(true);+ const selection = selections[0];+ const range = selection.range;+ const sheetsTableController = accessor.get(SheetsTableController);++ const isInTable = sheetsTableController.getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range);+ return of(!isInTable);+ })+ );+ })+ );+ })+ );+}++export function getSheetTableHeaderOperationHidden$(accessor: IAccessor): Observable<boolean> {+ const sheetsSelectionsService = accessor.get(SheetsSelectionsService);+ const univerInstanceService = accessor.get(IUniverInstanceService);+ const workbook$ = univerInstanceService.getCurrentTypeOfUnit$<Workbook>(UniverInstanceType.UNIVER_SHEET);++ return workbook$.pipe(+ switchMap((workbook) => {+ if (!workbook) return of(true);+ return workbook.activeSheet$.pipe(+ switchMap((sheet) => {+ if (!sheet) return of(true);+ return sheetsSelectionsService.selectionMoveEnd$.pipe(+ switchMap((selections) => {+ if (!selections.length || selections.length > 1) return of(true);+ const selection = selections[0];+ const range = selection.range;+ const sheetsTableController = accessor.get(SheetsTableController);++ const isInTable = sheetsTableController.getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range);+ if (!isInTable) {+ return of(true);+ }+ const tableRange = isInTable.getRange();+ if (range.startRow === tableRange.startRow) {+ return of(true);+ }+ return of(false);+ })+ );+ })+ );+ })+ );+}diff --git a/packages/sheets-table-ui/src/views/widgets/drawings.ts b/packages/sheets-table-ui/src/views/widgets/drawings.tsnew file mode 100644index 0000000000..99d07be21f--- /dev/null+++ b/packages/sheets-table-ui/src/views/widgets/drawings.ts@@ -0,0 +1,71 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { UniverRenderingContext2D } from '@univerjs/engine-render';+import { Rect } from '@univerjs/engine-render';++const BUTTON_VIEWPORT = 16;++export 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');++export class TableButton {+ static drawNoSetting(ctx: UniverRenderingContext2D, size: number, fgColor: string, bgColor: string): void {+ ctx.save();++ Rect.drawWith(ctx, {+ radius: 2,+ width: BUTTON_VIEWPORT,+ height: BUTTON_VIEWPORT,+ fill: bgColor,+ });++ ctx.lineCap = 'square';+ ctx.strokeStyle = fgColor;+ ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT);+ ctx.beginPath();+ ctx.lineWidth = 1;+ ctx.lineCap = 'round';+ ctx.moveTo(3, 4);+ ctx.lineTo(13, 4);+ ctx.moveTo(4.5, 8);+ ctx.lineTo(11.5, 8);+ ctx.moveTo(6, 12);+ ctx.lineTo(10, 12);+ ctx.stroke();+ ctx.restore();+ }++ static drawIconByPath(ctx: UniverRenderingContext2D, pathData: string[], fgColor: string, bgColor: string): void {+ ctx.save();+ ctx.strokeStyle = fgColor;+ ctx.fillStyle = bgColor;++ Rect.drawWith(ctx, {+ radius: 2,+ width: BUTTON_VIEWPORT,+ height: BUTTON_VIEWPORT,+ fill: bgColor,+ });++ pathData.forEach((d) => {+ const path = new Path2D(d);+ ctx.fillStyle = fgColor;+ ctx.fill(path, 'evenodd');+ });++ ctx.restore();+ }+}diff --git a/packages/sheets-table-ui/src/views/widgets/icons.ts b/packages/sheets-table-ui/src/views/widgets/icons.tsnew file mode 100644index 0000000000..1700410f67--- /dev/null+++ b/packages/sheets-table-ui/src/views/widgets/icons.ts@@ -0,0 +1,41 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export 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',+];++export 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',+];++export 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',+];++export const filterNoneSortAsc = [+ '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',+];++export const filterNoneSortDesc = [+ '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',+];diff --git a/packages/sheets-table-ui/src/views/widgets/table-filter-button.shape.ts b/packages/sheets-table-ui/src/views/widgets/table-filter-button.shape.tsnew file mode 100644index 0000000000..ec74465b3d--- /dev/null+++ b/packages/sheets-table-ui/src/views/widgets/table-filter-button.shape.ts@@ -0,0 +1,167 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IMouseEvent, IPointerEvent, IShapeProps, UniverRenderingContext2D } from '@univerjs/engine-render';+import type { IOpenTableFilterPanelOperationParams } from '../../commands/operations/open-table-filter-dialog.opration';++import { ICommandService, IContextService, Inject, ThemeService } from '@univerjs/core';+import { Shape } from '@univerjs/engine-render';+import { SheetsTableButtonStateEnum } from '@univerjs/sheets-table';+import { OpenTableFilterPanelOperation } from '../../commands/operations/open-table-filter-dialog.opration';+import { SHEETS_TABLE_FILTER_PANEL_OPENED_KEY } from '../../const';+import { TableButton } from './drawings';+import { filteredSortAsc, filteredSortDesc, filterNoneSortAsc, filterNoneSortDesc, filterPartial } from './icons';++export const FILTER_ICON_SIZE = 16;+export const FILTER_ICON_PADDING = 1;++export interface ISheetsTableFilterButtonShapeProps extends IShapeProps {+ cellWidth: number;+ cellHeight: number;+ filterParams: { row: number; col: number; unitId: string; subUnitId: string; buttonState: SheetsTableButtonStateEnum; tableId: string };+}++/**+ * The widget to render a filter button on canvas.+ */+export class SheetsTableFilterButtonShape extends Shape<ISheetsTableFilterButtonShapeProps> {+ private _cellWidth: number = 0;+ private _cellHeight: number = 0;++ private _filterParams?: { row: number; col: number; unitId: string; subUnitId: string; buttonState: SheetsTableButtonStateEnum; tableId: string };++ private _hovered = false;++ constructor(+ key: string,+ props: ISheetsTableFilterButtonShapeProps,+ @IContextService private readonly _contextService: IContextService,+ @ICommandService private readonly _commandService: ICommandService,+ @Inject(ThemeService) private readonly _themeService: ThemeService+ ) {+ super(key, props);++ this.setShapeProps(props);++ // Here we need to make sure that the event is on the rectangle range.+ this.onPointerDown$.subscribeEvent((evt) => this.onPointerDown(evt));+ this.onPointerEnter$.subscribeEvent(() => this.onPointerEnter());+ this.onPointerLeave$.subscribeEvent(() => this.onPointerLeave());+ }++ setShapeProps(props: Partial<ISheetsTableFilterButtonShapeProps>): void {+ if (typeof props.cellHeight !== 'undefined') {+ this._cellHeight = props.cellHeight;+ }++ if (typeof props.cellWidth !== 'undefined') {+ this._cellWidth = props.cellWidth;+ }++ if (typeof props.filterParams !== 'undefined') {+ this._filterParams = props.filterParams;+ }++ this.transformByState({+ width: props.width!,+ height: props.height!,+ });+ }++ protected override _draw(ctx: UniverRenderingContext2D): void {+ const cellHeight = this._cellHeight;+ const cellWidth = this._cellWidth;++ const left = FILTER_ICON_SIZE - cellWidth;+ const top = FILTER_ICON_SIZE - cellHeight;++ ctx.save();++ const cellRegion = new Path2D();+ cellRegion.rect(left, top, cellWidth, cellHeight);+ ctx.clip(cellRegion);++ const { buttonState } = this._filterParams!;+ const fgColor = this._themeService.getCurrentTheme().primaryColor;+ const bgColor = this._hovered+ ? this._themeService.getCurrentTheme().grey50+ : 'rgba(255, 255, 255, 1.0)';++ let icons;+ switch (buttonState) {+ case SheetsTableButtonStateEnum.FilteredSortNone:+ icons = filterPartial;+ break;++ case SheetsTableButtonStateEnum.FilteredSortAsc:+ icons = filteredSortAsc;+ break;+ case SheetsTableButtonStateEnum.FilteredSortDesc:+ icons = filteredSortDesc;+ break;+ case SheetsTableButtonStateEnum.FilterNoneSortNone:++ break;+ case SheetsTableButtonStateEnum.FilterNoneSortAsc:+ icons = filterNoneSortAsc;+ break;+ case SheetsTableButtonStateEnum.FilterNoneSortDesc:+ icons = filterNoneSortDesc;+ break;+ }+ if (icons) {+ TableButton.drawIconByPath(ctx, icons, fgColor, bgColor);+ } else if (buttonState !== undefined) {+ TableButton.drawNoSetting(ctx, FILTER_ICON_SIZE, fgColor, bgColor);+ }++ ctx.restore();+ }++ onPointerDown(evt: IPointerEvent | IMouseEvent): void {+ // Right click not trigger this event.+ if (evt.button === 2) {+ return;+ }++ const { row, col, unitId, subUnitId, tableId } = this._filterParams!;+ const opened = this._contextService.getContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY);+ if (opened || !this._commandService.hasCommand(OpenTableFilterPanelOperation.id)) {+ return;+ }++ setTimeout(() => {+ const cmdParams: IOpenTableFilterPanelOperationParams = {+ row,+ col,+ unitId,+ subUnitId,+ tableId,+ };+ this._commandService.executeCommand(OpenTableFilterPanelOperation.id, cmdParams);+ }, 200);+ }++ onPointerEnter(): void {+ this._hovered = true;+ this.makeDirty(true);+ }++ onPointerLeave(): void {+ this._hovered = false;+ this.makeDirty(true);+ }+}diff --git a/packages/sheets-table-ui/src/vite-env.d.ts b/packages/sheets-table-ui/src/vite-env.d.tsnew file mode 100644index 0000000000..11f02fe2a0--- /dev/null+++ b/packages/sheets-table-ui/src/vite-env.d.ts@@ -0,0 +1 @@+/// <reference types="vite/client" />diff --git a/packages/sheets-table-ui/tailwind.config.ts b/packages/sheets-table-ui/tailwind.config.tsnew file mode 100644index 0000000000..75967f186f--- /dev/null+++ b/packages/sheets-table-ui/tailwind.config.ts@@ -0,0 +1,27 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Config } from 'tailwindcss';+import preset from '@univerjs-infra/shared/tailwind';++const config: Config = {+ presets: [preset],+ content: [+ './src/**/*.{js,ts,jsx,tsx}',+ ],+};++export default config;diff --git a/packages/sheets-table-ui/tsconfig.json b/packages/sheets-table-ui/tsconfig.jsonnew file mode 100644index 0000000000..c62210cbad--- /dev/null+++ b/packages/sheets-table-ui/tsconfig.json@@ -0,0 +1,9 @@+{+ "extends": "@univerjs-infra/shared/tsconfigs/base",+ "compilerOptions": {+ "rootDir": "src",+ "outDir": "lib/types"+ },+ "references": [{ "path": "./tsconfig.node.json" }],+ "include": ["src"]+}diff --git a/packages/sheets-table-ui/tsconfig.node.json b/packages/sheets-table-ui/tsconfig.node.jsonnew file mode 100644index 0000000000..4947a09903--- /dev/null+++ b/packages/sheets-table-ui/tsconfig.node.json@@ -0,0 +1,4 @@+{+ "extends": "@univerjs-infra/shared/tsconfigs/node",+ "include": ["vitest.config.ts"]+}diff --git a/packages/sheets-table-ui/vitest.config.ts b/packages/sheets-table-ui/vitest.config.tsnew file mode 100644index 0000000000..af97c6d7a2--- /dev/null+++ b/packages/sheets-table-ui/vitest.config.ts@@ -0,0 +1,3 @@+import createConfig from '@univerjs-infra/shared/vitest';++export default createConfig();diff --git a/packages/sheets-table/README.md b/packages/sheets-table/README.mdnew file mode 100644index 0000000000..c927469b6c--- /dev/null+++ b/packages/sheets-table/README.md@@ -0,0 +1,21 @@+# @univerjs/sheets-table++### Installation++```shell+npm i @univerjs/sheets-table+```++### Import++```ts+import { UniverSheetTablePlugin } from '@univerjs/sheets-table';++univer.registerPlugin(UniverSheetTablePlugin);+```++<!-- Links -->+[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-table?style=flat-square+[npm-version-link]: https://npmjs.com/package/@univerjs/sheets-table+[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-table?style=flat-square+[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-table?style=flat-squarediff --git a/packages/sheets-table/package.json b/packages/sheets-table/package.jsonnew file mode 100644index 0000000000..c4f401bb38--- /dev/null+++ b/packages/sheets-table/package.json@@ -0,0 +1,87 @@+{+ "name": "@univerjs/sheets-table",+ "version": "0.6.6",+ "private": false,+ "description": "A library for connect and bind data from other sources to Univer Sheets",+ "author": "DreamNum <[email protected]>",+ "license": "Apache-2.0",+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/univer"+ },+ "homepage": "https://univer.ai",+ "repository": {+ "type": "git",+ "url": "https://github.com/dream-num/univer"+ },+ "bugs": {+ "url": "https://github.com/dream-num/univer/issues"+ },+ "keywords": [+ "univer",+ "sheets",+ "table"+ ],+ "exports": {+ ".": "./src/index.ts",+ "./*": "./src/*",+ "./facade": "./src/facade/index.ts"+ },+ "main": "./src/index.ts",+ "types": "./lib/types/index.d.ts",+ "publishConfig": {+ "access": "public",+ "main": "./lib/es/index.js",+ "module": "./lib/es/index.js",+ "exports": {+ ".": {+ "import": "./lib/es/index.js",+ "require": "./lib/cjs/index.js",+ "types": "./lib/types/index.d.ts"+ },+ "./*": {+ "import": "./lib/es/*",+ "require": "./lib/cjs/*",+ "types": "./lib/types/index.d.ts"+ },+ "./facade": {+ "import": "./lib/es/facade.js",+ "require": "./lib/cjs/facade.js",+ "types": "./lib/types/facade/index.d.ts"+ },+ "./lib/facade": {+ "import": "./lib/es/facade.js",+ "require": "./lib/cjs/facade.js",+ "types": "./lib/types/facade/index.d.ts"+ },+ "./lib/*": "./lib/*"+ }+ },+ "directories": {+ "lib": "lib"+ },+ "files": [+ "lib"+ ],+ "scripts": {+ "test": "vitest run",+ "test:watch": "vitest",+ "coverage": "vitest run --coverage",+ "lint:types": "tsc --noEmit",+ "build": "univer-cli build"+ },+ "peerDependencies": {+ "rxjs": ">=7.0.0"+ },+ "dependencies": {+ "@univerjs/core": "workspace:*",+ "@univerjs/sheets": "workspace:*"+ },+ "devDependencies": {+ "@univerjs-infra/shared": "workspace:*",+ "rxjs": "^7.8.1",+ "typescript": "^5.8.2",+ "vite": "^6.2.1",+ "vitest": "^3.0.8"+ }+}diff --git a/packages/sheets-table/src/commands/commands/add-sheet-table.command.ts b/packages/sheets-table/src/commands/commands/add-sheet-table.command.tsnew file mode 100644index 0000000000..25a8f7c5c4--- /dev/null+++ b/packages/sheets-table/src/commands/commands/add-sheet-table.command.ts@@ -0,0 +1,73 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand, IMutationInfo, IRange } from '@univerjs/core';+import type { ITableOptions } from '../../types/type';+import { CommandType, generateRandomId, ICommandService, IUndoRedoService, LocaleService, sequenceExecute } from '@univerjs/core';+import { TableManager } from '../../model/table-manager';+import { AddSheetTableMutation } from '../mutations/add-sheet-table.mutation';+import { DeleteSheetTableMutation } from '../mutations/delete-sheet-table.mutation';++export interface IAddSheetTableCommandParams {+ unitId: string;+ subUnitId: string;+ range: IRange;+ id?: string;+ name?: string;+ options?: ITableOptions;+}++export const AddSheetTableCommand: ICommand<IAddSheetTableCommandParams> = {+ id: 'sheet.command.add-table',+ type: CommandType.COMMAND,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }+ const undoRedoService = accessor.get(IUndoRedoService);+ const commandService = accessor.get(ICommandService);+ const localeService = accessor.get(LocaleService);+ const tableId = params.id ?? generateRandomId();+ let tableName = params.name;+ if (!tableName) {+ const tableManager = accessor.get(TableManager);+ const tableCount = tableManager.getTableList(params.unitId).length;+ tableName = `${localeService.t('sheets-table.tablePrefix')} ${tableCount + 1}`;+ }++ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];++ const tableManager = accessor.get(TableManager);+ const { unitId, subUnitId, range } = params;+ const header = tableManager.getColumnHeader(unitId, subUnitId, range, localeService.t('sheets-table.columnPrefix'));++ redos.push({ id: AddSheetTableMutation.id, params: { ...params, tableId, name: tableName, header } });+ undos.push({ id: DeleteSheetTableMutation.id, params: { tableId, unitId: params.unitId } });++ const res = sequenceExecute(redos, commandService);++ if (res) {+ undoRedoService.pushUndoRedo({+ unitID: params.unitId,+ undoMutations: undos,+ redoMutations: redos,+ });+ }++ return true;+ },+};diff --git a/packages/sheets-table/src/commands/commands/add-table-theme.command.ts b/packages/sheets-table/src/commands/commands/add-table-theme.command.tsnew file mode 100644index 0000000000..098b85d46c--- /dev/null+++ b/packages/sheets-table/src/commands/commands/add-table-theme.command.ts@@ -0,0 +1,103 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IAccessor, ICommand, IMutationInfo } from '@univerjs/core';+import type { RangeThemeStyle } from '@univerjs/sheets';+import { CommandType, ICommandService, IUndoRedoService, sequenceExecute } from '@univerjs/core';+import { AddRangeThemeMutation, RemoveRangeThemeMutation } from '@univerjs/sheets';+import { TableManager } from '../../model/table-manager';+import { SetSheetTableMutation } from '../mutations/set-sheet-table.mutation';++export interface IAddTableThemeCommandParams {+ unitId: string;+ tableId: string;+ themeStyle: RangeThemeStyle;+}++export const AddTableThemeCommand: ICommand<IAddTableThemeCommandParams> = {+ id: 'sheet.command.add-table-theme',+ type: CommandType.COMMAND,+ handler: (accessor: IAccessor, params) => {+ if (!params) {+ return false;+ }++ const tableManager = accessor.get(TableManager);++ const { unitId, tableId, themeStyle } = params;+ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];++ const table = tableManager.getTableById(unitId, tableId);+ if (!table) return false;+ const subUnitId = table.getSubunitId();++ redos.push({+ id: AddRangeThemeMutation.id,+ params: {+ unitId,+ subUnitId,+ styleJSON: themeStyle.toJson(),+ },+ });++ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId,+ config: {+ theme: themeStyle.getName(),+ },+ },+ });++ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId,+ config: {+ themeStyle: table.getTableStyleId(),+ },+ },+ });++ undos.push({+ id: RemoveRangeThemeMutation.id,+ params: {+ unitId,+ subUnitId,+ styleName: themeStyle.getName(),+ },+ });++ const commandService = accessor.get(ICommandService);+ const res = sequenceExecute(redos, commandService);+ if (res) {+ const undoRedoService = accessor.get(IUndoRedoService);+ undoRedoService.pushUndoRedo({+ unitID: unitId,+ undoMutations: undos,+ redoMutations: redos,+ });+ }++ return true;+ },+};diff --git a/packages/sheets-table/src/commands/commands/delete-sheet-table.command.ts b/packages/sheets-table/src/commands/commands/delete-sheet-table.command.tsnew file mode 100644index 0000000000..68c2f6acf4--- /dev/null+++ b/packages/sheets-table/src/commands/commands/delete-sheet-table.command.ts@@ -0,0 +1,71 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand, IMutationInfo } from '@univerjs/core';+import type { IDeleteSheetTableParams } from '../mutations/delete-sheet-table.mutation';+import { CommandType, ICommandService, IUndoRedoService, sequenceExecute } from '@univerjs/core';++import { TableManager } from '../../model/table-manager';+import { AddSheetTableMutation } from '../mutations/add-sheet-table.mutation';+import { DeleteSheetTableMutation } from '../mutations/delete-sheet-table.mutation';++export const DeleteSheetTableCommand: ICommand<IDeleteSheetTableParams> = {+ id: 'sheet.command.delete-table',+ type: CommandType.COMMAND,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }+ const undoRedoService = accessor.get(IUndoRedoService);+ const commandService = accessor.get(ICommandService);+ const sheetTableManager = accessor.get(TableManager);++ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];++ const tableInstance = sheetTableManager.getTable(params.unitId, params.tableId);+ const tableConfig = tableInstance?.toJSON();++ if (!tableConfig) {+ throw new Error('[TableManager]: Table not found');+ }++ redos.push({ id: DeleteSheetTableMutation.id, params: { ...params } });+ undos.push({+ id: AddSheetTableMutation.id,+ params: {+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ tableId: params.tableId,+ name: tableConfig.name,+ range: tableConfig.range,+ options: tableConfig.options,+ },+ });++ const res = sequenceExecute(redos, commandService);++ if (res) {+ undoRedoService.pushUndoRedo({+ unitID: params.unitId,+ undoMutations: undos,+ redoMutations: redos,+ });+ }++ return true;+ },+};diff --git a/packages/sheets-table/src/commands/commands/remove-table-theme.command.ts b/packages/sheets-table/src/commands/commands/remove-table-theme.command.tsnew file mode 100644index 0000000000..4428454427--- /dev/null+++ b/packages/sheets-table/src/commands/commands/remove-table-theme.command.ts@@ -0,0 +1,79 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand } from '@univerjs/core';+import { CommandType, ICommandService, IUndoRedoService, sequenceExecute } from '@univerjs/core';+import { AddRangeThemeMutation, RemoveRangeThemeMutation, SheetRangeThemeModel } from '@univerjs/sheets';+import { SHEET_TABLE_CUSTOM_THEME_PREFIX } from '../../const';+import { TableManager } from '../../model/table-manager';+import { SetSheetTableMutation } from '../mutations/set-sheet-table.mutation';++export interface IRemoveTableThemeCommandParams {+ unitId: string;+ tableId: string;+ themeName: string;+}++export const RemoveTableThemeCommand: ICommand<IRemoveTableThemeCommandParams> = {+ id: 'sheet.command.remove-table-theme',+ type: CommandType.COMMAND,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }++ const { unitId, tableId, themeName } = params;++ const tableManager = accessor.get(TableManager);+ const rangeThemeModel = accessor.get(SheetRangeThemeModel);+ const table = tableManager.getTableById(unitId, tableId);+ if (!table) return false;+ const subUnitId = table.getSubunitId();++ const redos = [];+ const undos = [];++ const defaultRangeThemes = rangeThemeModel.getRegisteredRangeThemes().filter((item) => item?.startsWith('table-default'));+ const customRangeThemes = rangeThemeModel.getRegisteredRangeThemes().filter((item) => item?.startsWith(SHEET_TABLE_CUSTOM_THEME_PREFIX));++ let shouldBeSelectedTheme = customRangeThemes.find((item) => item !== themeName);+ if (!shouldBeSelectedTheme) {+ shouldBeSelectedTheme = defaultRangeThemes[0];+ }++ redos.push({ id: SetSheetTableMutation.id, params: { unitId, subUnitId, tableId, config: { theme: shouldBeSelectedTheme } } });+ redos.push({ id: RemoveRangeThemeMutation.id, params: { unitId, subUnitId, styleName: themeName } });++ const themeStyle = rangeThemeModel.getDefaultRangeThemeStyle(themeName);+ if (themeStyle) {+ undos.push({ id: AddRangeThemeMutation.id, params: { unitId, subUnitId, styleJSON: themeStyle.toJson() } });+ undos.push({ id: SetSheetTableMutation.id, params: { unitId, subUnitId, tableId, config: { theme: themeName } } });+ }++ const commandService = accessor.get(ICommandService);+ const res = sequenceExecute(redos, commandService);+ if (res) {+ const undoRedoService = accessor.get(IUndoRedoService);+ undoRedoService.pushUndoRedo({+ unitID: unitId,+ redoMutations: redos,+ undoMutations: undos,+ });+ }++ return true;+ },+};diff --git a/packages/sheets-table/src/commands/commands/set-sheet-table.command.ts b/packages/sheets-table/src/commands/commands/set-sheet-table.command.tsnew file mode 100644index 0000000000..15086f1ba5--- /dev/null+++ b/packages/sheets-table/src/commands/commands/set-sheet-table.command.ts@@ -0,0 +1,109 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand } from '@univerjs/core';+import type { ITableSetConfig } from '../../types/type';+import type { ISetSheetTableMutationParams } from '../mutations/set-sheet-table.mutation';+import { CommandType, ICommandService, IUndoRedoService } from '@univerjs/core';+import { TableManager } from '../../model/table-manager';+import { IRangeOperationTypeEnum } from '../../types/type';+import { SetSheetTableMutation } from '../mutations/set-sheet-table.mutation';++export interface ISetSheetTableCommandParams extends ITableSetConfig {+ unitId: string;+ tableId: string;+}++export const SetSheetTableCommand: ICommand<ISetSheetTableCommandParams> = {+ id: 'sheet.command.set-table-config',+ type: CommandType.COMMAND,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }++ const { unitId, tableId, name, updateRange, rowColOperation, theme } = params;++ const tableManager = accessor.get(TableManager);+ const table = tableManager.getTableById(unitId, tableId);++ if (!table) return false;++ const oldTableConfig: ITableSetConfig = {};+ const newTableConfig: ITableSetConfig = {};++ if (name) {+ oldTableConfig.name = table.getDisplayName();+ newTableConfig.name = name;+ }++ if (rowColOperation) {+ oldTableConfig.rowColOperation = {+ operationType: rowColOperation.operationType === IRangeOperationTypeEnum.Insert ? IRangeOperationTypeEnum.Delete : IRangeOperationTypeEnum.Insert,+ rowColType: rowColOperation.rowColType,+ index: rowColOperation.index,+ count: rowColOperation.count,+ };+ newTableConfig.rowColOperation = rowColOperation;+ }++ if (updateRange) {+ oldTableConfig.updateRange = {+ newRange: table.getRange(),+ };+ newTableConfig.updateRange = updateRange;+ }++ if (theme) {+ oldTableConfig.theme = table.getTableStyleId();+ newTableConfig.theme = theme;+ }++ const redoParams = {+ unitId,+ subUnitId: table.getSubunitId(),+ tableId,+ config: newTableConfig,+ };++ const commandService = accessor.get(ICommandService);+ commandService.executeCommand<ISetSheetTableMutationParams>(SetSheetTableMutation.id, redoParams);++ const undoRedoService = accessor.get(IUndoRedoService);+ undoRedoService.pushUndoRedo({+ unitID: unitId,+ undoMutations: [+ {+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId: table.getSubunitId(),+ tableId,+ config: oldTableConfig,+ },+ },+ ],+ redoMutations: [+ {+ id: SetSheetTableMutation.id,+ params: redoParams,+ },+ ],+ });++ return true;+ },+};diff --git a/packages/sheets-table/src/commands/commands/set-table-filter.command.ts b/packages/sheets-table/src/commands/commands/set-table-filter.command.tsnew file mode 100644index 0000000000..f4b162efe0--- /dev/null+++ b/packages/sheets-table/src/commands/commands/set-table-filter.command.ts@@ -0,0 +1,51 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand, IMutationInfo } from '@univerjs/core';+import type { ISetSheetTableParams } from '../mutations/set-table-filter.mutation';+import { CommandType, generateRandomId, ICommandService, IUndoRedoService, sequenceExecute } from '@univerjs/core';+import { SetSheetTableFilterMutation } from '../mutations/set-table-filter.mutation';++export const SetSheetTableFilterCommand: ICommand<ISetSheetTableParams> = {+ id: 'sheet.command.set-table-filter',+ type: CommandType.COMMAND,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }+ const undoRedoService = accessor.get(IUndoRedoService);+ const commandService = accessor.get(ICommandService);+ const tableId = params.tableId || generateRandomId();++ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];++ redos.push({ id: SetSheetTableFilterMutation.id, params: { ...params, tableId } });+ undos.push({ id: SetSheetTableFilterMutation.id, params: { ...params, tableId, tableFilter: undefined } });++ const res = sequenceExecute(redos, commandService);++ if (res) {+ undoRedoService.pushUndoRedo({+ unitID: params.unitId,+ undoMutations: undos,+ redoMutations: redos,+ });+ }++ return true;+ },+};diff --git a/packages/sheets-table/src/commands/commands/sheet-table-row-col.command.ts b/packages/sheets-table/src/commands/commands/sheet-table-row-col.command.tsnew file mode 100644index 0000000000..b2c4ad7436--- /dev/null+++ b/packages/sheets-table/src/commands/commands/sheet-table-row-col.command.ts@@ -0,0 +1,571 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++/* eslint-disable max-lines-per-function */++import type { ICommand, IMutationInfo } from '@univerjs/core';+import type { ITableColumnJson } from '../../types/type';+import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, sequenceExecute } from '@univerjs/core';+import { getMoveRangeUndoRedoMutations, getSheetCommandTarget, InsertColMutation, InsertRowMutation, RemoveColMutation, RemoveRowMutation, SheetsSelectionsService } from '@univerjs/sheets';+import { SheetsTableController } from '../../controllers/sheets-table.controller';+import { TableManager } from '../../model/table-manager';+import { IRangeOperationTypeEnum, IRowColTypeEnum } from '../../types/type';+import { SetSheetTableMutation } from '../mutations/set-sheet-table.mutation';++interface ISheetTableRowColOperationCommandParams {+ tableId: string;+ unitId: string;+ subUnitId: string;+}++export const SheetTableInsertRowCommand: ICommand<ISheetTableRowColOperationCommandParams> = {+ id: 'sheet.command.table-insert-row',+ type: CommandType.COMMAND,+ handler: (accessor) => {+ const univerInstanceService = accessor.get(IUniverInstanceService);+ const target = getSheetCommandTarget(univerInstanceService);++ if (!target) {+ return false;+ }++ const { workbook, worksheet, unitId, subUnitId } = target;++ const sheetsSelectionsService = accessor.get(SheetsSelectionsService);+ const selections = sheetsSelectionsService.getCurrentSelections();+ if (!selections.length || selections.length > 1) {+ return false;+ }++ const tableManager = accessor.get(TableManager);++ const selection = selections[0];+ const range = selection.range;++ const sheetsTableController = accessor.get(SheetsTableController);+ const table = sheetsTableController.getContainerTableWithRange(unitId, subUnitId, range);++ if (!table) return false;++ const insertRowCount = range.endRow - range.startRow + 1;++ const worksheetCount = worksheet.getRowCount();+ const worksheetLastRowIndex = worksheetCount - 1;+ const rowContentIndex = worksheet.getCellMatrix().getDataRange().endRow;++ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];++ if (worksheetLastRowIndex - rowContentIndex < insertRowCount) {+ // should insert row+ redos.push({+ id: InsertRowMutation.id,+ params: {+ unitId,+ subUnitId,+ range: { ...range },+ },+ });+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: {+ ...table.getRange(),+ endRow: table.getRange().endRow + insertRowCount,+ },+ },+ },+ },+ });+ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: table.getRange(),+ },+ },+ },+ });+ undos.push({+ id: RemoveRowMutation.id,+ params: {+ unitId,+ subUnitId,+ range: { ...range },+ },+ });+ } else {+ const oldRange = { ...table.getRange() };+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: {+ ...oldRange,+ endRow: oldRange.endRow + insertRowCount,+ },+ },+ },+ },+ });+ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: { ...oldRange },+ },+ },+ },+ });++ const moveRangeMutations = getMoveRangeUndoRedoMutations(+ accessor,+ {+ unitId,+ subUnitId,+ range: {+ startRow: range.startRow,+ endRow: rowContentIndex,+ startColumn: oldRange.startColumn,+ endColumn: oldRange.endColumn,+ },+ },+ {+ unitId,+ subUnitId,+ range: {+ startRow: range.startRow + insertRowCount,+ endRow: rowContentIndex + insertRowCount,+ startColumn: oldRange.startColumn,+ endColumn: oldRange.endColumn,+ },+ }+ );+ if (moveRangeMutations) {+ redos.push(...moveRangeMutations.redos);+ undos.push(...moveRangeMutations.undos);+ }+ }++ const commandService = accessor.get(ICommandService);+ const res = sequenceExecute(redos, commandService);++ if (res) {+ const undoRedoService = accessor.get(IUndoRedoService);+ undoRedoService.pushUndoRedo({+ unitID: unitId,+ undoMutations: undos,+ redoMutations: redos,+ });+ }++ return true;+ },+};++export const SheetTableInsertColCommand: ICommand<ISheetTableRowColOperationCommandParams> = {+ id: 'sheet.command.table-insert-col',+ type: CommandType.COMMAND,+ handler: (accessor) => {+ const univerInstanceService = accessor.get(IUniverInstanceService);+ const target = getSheetCommandTarget(univerInstanceService);+ if (!target) {+ return false;+ }+ const { worksheet, unitId, subUnitId } = target;+ const sheetsSelectionsService = accessor.get(SheetsSelectionsService);+ const selections = sheetsSelectionsService.getCurrentSelections();+ if (!selections.length || selections.length > 1) {+ return false;+ }+ const selection = selections[0];+ const range = selection.range;+ const sheetsTableController = accessor.get(SheetsTableController);+ const table = sheetsTableController.getContainerTableWithRange(unitId, subUnitId, range);+ if (!table) return false;+ const insertColCount = range.endColumn - range.startColumn + 1;+ const worksheetCount = worksheet.getColumnCount();+ const worksheetLastColIndex = worksheetCount - 1;+ const colContentIndex = worksheet.getCellMatrix().getDataRange().endColumn;+ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];+ if (worksheetLastColIndex - colContentIndex < insertColCount) {+ // should insert col+ redos.push({+ id: InsertColMutation.id,+ params: {+ unitId,+ subUnitId,+ range: { ...range },+ },+ });+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Insert,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: insertColCount,+ },+ },+ },+ });+ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Delete,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: insertColCount,+ },+ },+ },+ });+ undos.push({+ id: RemoveColMutation.id,+ params: {+ unitId,+ subUnitId,+ range: { ...range },+ },+ });+ } else {+ const oldRange = table.getRange();+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Insert,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: insertColCount,+ },+ },+ },+ });+ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Delete,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: insertColCount,+ },+ },+ },+ });++ const moveRangeMutations = getMoveRangeUndoRedoMutations(+ accessor,+ {+ unitId,+ subUnitId,+ range: {+ startRow: oldRange.startRow,+ endRow: oldRange.endRow,+ startColumn: range.startColumn,+ endColumn: colContentIndex,+ },+ },+ {+ unitId,+ subUnitId,+ range: {+ startRow: oldRange.startRow,+ endRow: oldRange.endRow,+ startColumn: range.startColumn + insertColCount,+ endColumn: colContentIndex + insertColCount,+ },+ }+ );+ if (moveRangeMutations) {+ redos.push(...moveRangeMutations.redos);+ undos.push(...moveRangeMutations.undos);+ }+ }+ const commandService = accessor.get(ICommandService);+ const res = sequenceExecute(redos, commandService);+ if (res) {+ const undoRedoService = accessor.get(IUndoRedoService);+ undoRedoService.pushUndoRedo({+ unitID: unitId,+ undoMutations: undos,+ redoMutations: redos,+ });+ }++ return true;+ },+};++export const SheetTableRemoveRowCommand: ICommand<ISheetTableRowColOperationCommandParams> = {+ id: 'sheet.command.table-remove-row',+ type: CommandType.COMMAND,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }++ const univerInstanceService = accessor.get(IUniverInstanceService);+ const target = getSheetCommandTarget(univerInstanceService);+ if (!target) {+ return false;+ }+ const { unitId, subUnitId } = target;+ const sheetsSelectionsService = accessor.get(SheetsSelectionsService);+ const selections = sheetsSelectionsService.getCurrentSelections();+ if (!selections.length || selections.length > 1) {+ return false;+ }+ const selection = selections[0];+ const range = selection.range;+ const sheetsTableController = accessor.get(SheetsTableController);+ const table = sheetsTableController.getContainerTableWithRange(unitId, subUnitId, range);+ if (!table) return false;+ const removeRowCount = range.endRow - range.startRow + 1;+ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];++ const oldRange = table.getRange();+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: {+ ...oldRange,+ endRow: oldRange.endRow - removeRowCount,+ },+ },+ },+ },+ });+ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: { ...oldRange },+ },+ },+ },+ });++ const worksheet = target.worksheet;+ const rowContentIndex = worksheet.getCellMatrix().getDataRange().endRow;+ const moveRangeMutations = getMoveRangeUndoRedoMutations(+ accessor,+ {+ unitId,+ subUnitId,+ range: {+ startRow: range.endRow + 1,+ endRow: rowContentIndex,+ startColumn: oldRange.startColumn,+ endColumn: oldRange.endColumn,+ },+ },+ {+ unitId,+ subUnitId,+ range: {+ startRow: range.startRow,+ endRow: rowContentIndex - removeRowCount,+ startColumn: oldRange.startColumn,+ endColumn: oldRange.endColumn,+ },+ }+ );++ if (moveRangeMutations) {+ redos.push(...moveRangeMutations.redos);+ undos.push(...moveRangeMutations.undos);+ }++ const commandService = accessor.get(ICommandService);+ const res = sequenceExecute(redos, commandService);+ if (res) {+ const undoRedoService = accessor.get(IUndoRedoService);+ undoRedoService.pushUndoRedo({+ unitID: unitId,+ undoMutations: undos,+ redoMutations: redos,+ });+ }++ return true;+ },+};++export const SheetTableRemoveColCommand: ICommand<ISheetTableRowColOperationCommandParams> = {+ id: 'sheet.command.table-remove-col',+ type: CommandType.COMMAND,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }+ const univerInstanceService = accessor.get(IUniverInstanceService);+ const target = getSheetCommandTarget(univerInstanceService);+ if (!target) {+ return false;+ }+ const { workbook, unitId, subUnitId } = target;+ const tableManager = accessor.get(TableManager);+ const sheetsSelectionsService = accessor.get(SheetsSelectionsService);+ const selections = sheetsSelectionsService.getCurrentSelections();+ if (!selections.length || selections.length > 1) {+ return false;+ }+ const selection = selections[0];+ const range = selection.range;+ const sheetsTableController = accessor.get(SheetsTableController);+ const table = sheetsTableController.getContainerTableWithRange(unitId, subUnitId, range);+ if (!table) return false;+ const removeColCount = range.endColumn - range.startColumn + 1;+ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];+ const oldRange = table.getRange();++ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Delete,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: removeColCount,+ },+ },+ },+ });++ const columns: ITableColumnJson[] = [];+ const gap = range.startColumn - oldRange.startColumn;+ for (let i = 0; i < removeColCount; i++) {+ const column = table.getTableInfo().columns[gap + i];+ if (column) {+ columns.push(column);+ }+ }+ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Insert,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: removeColCount,+ columnsJson: columns,+ },+ },+ },+ });++ const worksheet = target.worksheet;+ const colContentIndex = worksheet.getCellMatrix().getDataRange().endColumn;+ const moveRangeMutations = getMoveRangeUndoRedoMutations(+ accessor,+ {+ unitId,+ subUnitId,+ range: {+ startRow: oldRange.startRow,+ endRow: oldRange.endRow,+ startColumn: range.endColumn + 1,+ endColumn: colContentIndex,+ },+ },+ {+ unitId,+ subUnitId,+ range: {+ startRow: oldRange.startRow,+ endRow: oldRange.endRow,+ startColumn: range.startColumn,+ endColumn: colContentIndex - removeColCount,+ },+ }+ );++ if (moveRangeMutations) {+ redos.push(...moveRangeMutations.redos);+ undos.push(...moveRangeMutations.undos);+ }++ const commandService = accessor.get(ICommandService);+ const res = sequenceExecute(redos, commandService);+ if (res) {+ const undoRedoService = accessor.get(IUndoRedoService);+ undoRedoService.pushUndoRedo({+ unitID: unitId,+ undoMutations: undos,+ redoMutations: redos,+ });+ }++ return true;+ },+};diff --git a/packages/sheets-table/src/commands/mutations/add-sheet-table.mutation.ts b/packages/sheets-table/src/commands/mutations/add-sheet-table.mutation.tsnew file mode 100644index 0000000000..7a8aceeafd--- /dev/null+++ b/packages/sheets-table/src/commands/mutations/add-sheet-table.mutation.ts@@ -0,0 +1,42 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IMutation } from '@univerjs/core';+import type { ITableOptions, ITableRange } from '../../types/type';+import { CommandType } from '@univerjs/core';+import { SheetTableService } from '../../services/table-service';++export interface IAddSheetTableParams {+ unitId: string;+ subUnitId: string;+ name: string;+ range: ITableRange;+ // TODO 这里的参数应该聚合 Meta Columns Options 等信息+ options?: ITableOptions;+ tableId?: string;+ header?: string[];+}++export const AddSheetTableMutation: IMutation<IAddSheetTableParams & { tableId: string }> = {+ id: 'sheet.mutation.add-table',+ type: CommandType.MUTATION,+ handler: (accessor, params) => {+ const { tableId, unitId, subUnitId, name, range, header, options } = params;+ const sheetTableService = accessor.get(SheetTableService);+ sheetTableService.addTable(unitId, subUnitId, name, range, header, tableId, options);+ return true;+ },+};diff --git a/packages/sheets-table/src/commands/mutations/delete-sheet-table.mutation.ts b/packages/sheets-table/src/commands/mutations/delete-sheet-table.mutation.tsnew file mode 100644index 0000000000..6a1d763123--- /dev/null+++ b/packages/sheets-table/src/commands/mutations/delete-sheet-table.mutation.ts@@ -0,0 +1,36 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IMutation } from '@univerjs/core';+import { CommandType } from '@univerjs/core';+import { SheetTableService } from '../../services/table-service';++export interface IDeleteSheetTableParams {+ unitId: string;+ subUnitId: string;+ tableId: string;+}++export const DeleteSheetTableMutation: IMutation<IDeleteSheetTableParams> = {+ id: 'sheet.mutation.delete-table',+ type: CommandType.MUTATION,+ handler: (accessor, params) => {+ const { unitId, subUnitId, tableId } = params;+ const sheetTableService = accessor.get(SheetTableService);+ sheetTableService.deleteTable(unitId, subUnitId, tableId);+ return true;+ },+};diff --git a/packages/sheets-table/src/commands/mutations/set-sheet-table.mutation.ts b/packages/sheets-table/src/commands/mutations/set-sheet-table.mutation.tsnew file mode 100644index 0000000000..9d01974e07--- /dev/null+++ b/packages/sheets-table/src/commands/mutations/set-sheet-table.mutation.ts@@ -0,0 +1,43 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IMutation } from '@univerjs/core';+import type { ITableSetConfig } from '../../types/type';+import { CommandType } from '@univerjs/core';+import { TableManager } from '../../model/table-manager';++export interface ISetSheetTableMutationParams {+ unitId: string;+ subUnitId: string;+ tableId: string;+ config: ITableSetConfig;+}++export const SetSheetTableMutation: IMutation<ISetSheetTableMutationParams> = {+ id: 'sheet.mutation.set-sheet-table',+ type: CommandType.MUTATION,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }++ const { unitId, tableId, config } = params;+ const tableManager = accessor.get(TableManager);+ tableManager.setTableByConfig(unitId, tableId, config);++ return true;+ },+};diff --git a/packages/sheets-table/src/commands/mutations/set-table-filter.mutation.ts b/packages/sheets-table/src/commands/mutations/set-table-filter.mutation.tsnew file mode 100644index 0000000000..555d3b788e--- /dev/null+++ b/packages/sheets-table/src/commands/mutations/set-table-filter.mutation.ts@@ -0,0 +1,38 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IMutation } from '@univerjs/core';+import type { ITableFilterItem } from '../../types/type';+import { CommandType } from '@univerjs/core';+import { TableManager } from '../../model/table-manager';++export interface ISetSheetTableParams {+ unitId: string;+ tableId: string;+ column: number;+ tableFilter: ITableFilterItem | undefined;+}++export const SetSheetTableFilterMutation: IMutation<ISetSheetTableParams & { tableId: string }> = {+ id: 'sheet.mutation.set-table-filter',+ type: CommandType.MUTATION,+ handler: (accessor, params) => {+ const { tableId, unitId, column, tableFilter } = params;+ const tableManager = accessor.get(TableManager);+ tableManager.addFilter(unitId, tableId, column, tableFilter);+ return true;+ },+};diff --git a/packages/sheets-table/src/const.ts b/packages/sheets-table/src/const.tsnew file mode 100644index 0000000000..1d185a37db--- /dev/null+++ b/packages/sheets-table/src/const.ts@@ -0,0 +1,20 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export const PLUGIN_NAME = 'SHEET_TABLE_PLUGIN';+export const FEATURE_TABLE_ID = 'SHEET_TABLE';+export const DEFAULT_COLUMN_NAME_PREFIX = 'Column';+export const SHEET_TABLE_CUSTOM_THEME_PREFIX = 'table-custom';diff --git a/packages/sheets-table/src/controllers/sheet-table-range.controller.ts b/packages/sheets-table/src/controllers/sheet-table-range.controller.tsnew file mode 100644index 0000000000..813c7f5eea--- /dev/null+++ b/packages/sheets-table/src/controllers/sheet-table-range.controller.ts@@ -0,0 +1,58 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { Disposable, Inject } from '@univerjs/core';+import { IExclusiveRangeService } from '@univerjs/sheets';+import { FEATURE_TABLE_ID } from '../const';+import { TableManager } from '../model/table-manager';++export class SheetTableRangeController extends Disposable {+ constructor(+ @Inject(TableManager) private _tableManager: TableManager,+ @Inject(IExclusiveRangeService) private _exclusiveRangeService: IExclusiveRangeService+ ) {+ super();+ this._initRangeListener();+ }++ private _initRangeListener() {+ this.disposeWithMe(+ this._tableManager.tableRangeChanged$.subscribe((event) => {+ const { range, tableId, unitId, subUnitId } = event;+ this._exclusiveRangeService.clearExclusiveRangesByGroupId(unitId, subUnitId, FEATURE_TABLE_ID, tableId);+ this._exclusiveRangeService.addExclusiveRange(unitId, subUnitId, FEATURE_TABLE_ID, [{+ range: { ...range },+ groupId: tableId,+ }]);+ })+ );+ this.disposeWithMe(+ this._tableManager.tableAdd$.subscribe((event) => {+ const { tableId, unitId, subUnitId, range } = event;+ this._exclusiveRangeService.addExclusiveRange(unitId, subUnitId, FEATURE_TABLE_ID, [{+ range: { ...range },+ groupId: tableId,+ }]);+ })+ );+ this.disposeWithMe(+ this._tableManager.tableDelete$.subscribe((event) => {+ const { tableId, unitId, subUnitId } = event;+ this._exclusiveRangeService.clearExclusiveRangesByGroupId(unitId, subUnitId, FEATURE_TABLE_ID, tableId);+ })+ );+ }+}diff --git a/packages/sheets-table/src/controllers/sheet-table-ref-range.controller.ts b/packages/sheets-table/src/controllers/sheet-table-ref-range.controller.tsnew file mode 100644index 0000000000..afae5a9a54--- /dev/null+++ b/packages/sheets-table/src/controllers/sheet-table-ref-range.controller.ts@@ -0,0 +1,562 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++/* eslint-disable max-lines-per-function */+/* eslint-disable complexity */++import type { IMutationInfo, Workbook } from '@univerjs/core';+import type { IInsertColCommandParams, IInsertRowCommandParams, IInsertRowMutationParams, IRemoveRowColCommandParams } from '@univerjs/sheets';+import type { ITableColumnJson } from '../types/type';+import { Disposable, ICommandService, Inject, Injector, IUniverInstanceService, LocaleService, Rectangle } from '@univerjs/core';+import { getSheetCommandTarget, InsertColCommand, InsertColMutation, InsertRowCommand, InsertRowMutation, RefRangeService, RemoveColCommand, RemoveColMutation, RemoveRowCommand, RemoveRowMutation, SheetInterceptorService } from '@univerjs/sheets';+import { AddSheetTableMutation } from '../commands/mutations/add-sheet-table.mutation';+import { DeleteSheetTableMutation } from '../commands/mutations/delete-sheet-table.mutation';+import { SetSheetTableMutation } from '../commands/mutations/set-sheet-table.mutation';+import { TableManager } from '../model/table-manager';+import { IRangeOperationTypeEnum, IRowColTypeEnum } from '../types/type';+import { convertCellDataToString, getColumnName } from '../util';++export class SheetTableRefRangeController extends Disposable {+ constructor(+ @Inject(ICommandService) private readonly _commandService: ICommandService,+ @Inject(RefRangeService) private readonly _refRangeService: RefRangeService,+ @Inject(IUniverInstanceService) private readonly _univerInstanceService: IUniverInstanceService,+ @Inject(Injector) private _injector: Injector,+ @Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService,+ @Inject(TableManager) private _tableManager: TableManager,+ @Inject(LocaleService) private _localeService: LocaleService++ ) {+ super();+ this._initCommandInterceptor();+ this._initCommandListener();+ }++ private _initCommandInterceptor() {+ const self = this;+ this._sheetInterceptorService.interceptCommand({+ getMutations(commandInfo) {+ const defaultReturn = { redos: [], undos: [] };+ const { id, params } = commandInfo;+ switch (id) {+ case InsertRowCommand.id:+ return self._generateTableMutationWithInsertRow(params as IInsertRowCommandParams);+ case InsertColCommand.id:+ return self._generateTableMutationWithInsertCol(params as IInsertColCommandParams);+ case RemoveRowCommand.id:+ return self._generateTableMutationWithRemoveRow(params as IRemoveRowColCommandParams);+ case RemoveColCommand.id:+ return self._generateTableMutationWithRemoveCol(params as IRemoveRowColCommandParams);+ }++ return defaultReturn;+ },+ });+ }++ private _generateTableMutationWithInsertRow(insertParams: IInsertRowCommandParams) {+ const undos: IMutationInfo[] = [];+ const redos: IMutationInfo[] = [];++ const target = getSheetCommandTarget(this._univerInstanceService);+ if (!target) {+ return { undos, redos };+ }++ const { unitId, subUnitId } = target;+ const allSubUnitTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ if (!allSubUnitTables.length) {+ return { undos, redos };+ }++ const { range } = insertParams;+ allSubUnitTables.forEach((table) => {+ const tableRange = table.getRange();+ if (range.startRow > tableRange.startRow && range.startRow <= tableRange.endRow) {+ const insertRowCount = range.endRow - range.startRow + 1;+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: {+ ...tableRange,+ endRow: tableRange.endRow + insertRowCount,+ },+ },+ },+ },+ });++ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: {+ ...tableRange,+ },+ },+ },+ },+ });+ }+ });++ return { undos, redos };+ }++ private _generateTableMutationWithInsertCol(insertParams: IInsertColCommandParams) {+ const undos: IMutationInfo[] = [];+ const redos: IMutationInfo[] = [];++ const target = getSheetCommandTarget(this._univerInstanceService);+ if (!target) {+ return { undos, redos };+ }+ const { unitId, subUnitId } = target;+ const allSubUnitTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ if (!allSubUnitTables.length) {+ return { undos, redos };+ }+ const { range } = insertParams;+ allSubUnitTables.forEach((table) => {+ const tableRange = table.getRange();+ if (range.startColumn > tableRange.startColumn && range.startColumn <= tableRange.endColumn) {+ const insertColCount = range.endColumn - range.startColumn + 1;+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Insert,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: insertColCount,+ },+ },+ },+ });++ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Delete,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: insertColCount,+ },+ },+ },+ });+ }+ });++ return { undos, redos };+ }++ private _generateTableMutationWithRemoveRow(removeParams: IRemoveRowColCommandParams) {+ const undos: IMutationInfo[] = [];+ const redos: IMutationInfo[] = [];+ const preRedos: IMutationInfo[] = [];+ const preUndos: IMutationInfo[] = [];++ const target = getSheetCommandTarget(this._univerInstanceService);+ if (!target) {+ return { undos, redos, preRedos, preUndos };+ }+ const { unitId, subUnitId } = target;+ const allSubUnitTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ if (!allSubUnitTables.length) {+ return { undos, redos, preRedos, preUndos };+ }+ const { range } = removeParams;+ const removeRowCount = range.endRow - range.startRow + 1;++ allSubUnitTables.forEach((table) => {+ const tableRange = table.getRange();+ if (Rectangle.intersects(tableRange, range)) {+ if (range.startRow <= tableRange.startRow && range.endRow >= tableRange.startRow) {+ preRedos.push({+ id: DeleteSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ },+ });+ const tableJson = table.toJSON();+ undos.push({+ id: AddSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: tableJson.id,+ name: tableJson.name,+ range: tableJson.range,+ options: tableJson.options,+ },+ });+ } else if (range.startRow > tableRange.startRow && range.startRow <= tableRange.endRow) {+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: {+ ...tableRange,+ endRow: tableRange.endRow - removeRowCount,+ },+ },+ },+ },+ });++ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: {+ ...tableRange,+ },+ },+ },+ },+ });+ } else if (range.startRow < tableRange.endRow && range.endRow >= tableRange.endRow) {+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: {+ ...tableRange,+ endRow: range.startRow - 1,+ },+ },+ },+ },+ });++ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ updateRange: {+ newRange: {+ ...tableRange,+ },+ },+ },+ },+ });+ }+ }+ });++ return { undos, redos, preRedos, preUndos };+ }++ private _generateTableMutationWithRemoveCol(removeParams: IRemoveRowColCommandParams) {+ const undos: IMutationInfo[] = [];+ const redos: IMutationInfo[] = [];+ const preRedos: IMutationInfo[] = [];+ const preUndos: IMutationInfo[] = [];++ const target = getSheetCommandTarget(this._univerInstanceService);+ if (!target) {+ return { undos, redos, preRedos, preUndos };+ }+ const { unitId, subUnitId } = target;+ const allSubUnitTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ if (!allSubUnitTables.length) {+ return { undos, redos, preRedos, preUndos };+ }+ const { range } = removeParams;+ const removeColCount = range.endColumn - range.startColumn + 1;+ allSubUnitTables.forEach((table) => {+ const tableRange = table.getRange();+ if (Rectangle.intersects(tableRange, range)) {+ if (range.startColumn <= tableRange.startColumn && range.endColumn >= tableRange.endColumn) {+ preRedos.push({+ id: DeleteSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ },+ });+ const tableJson = table.toJSON();+ const { startRow, startColumn, endColumn } = tableJson.range;+ const workbook = this._univerInstanceService.getUnit<Workbook>(unitId);+ const worksheet = workbook?.getSheetBySheetId(subUnitId);+ if (!worksheet) {+ return { undos, redos, preRedos, preUndos };+ }+ const header: string[] = [];+ for (let i = startColumn; i <= endColumn; i++) {+ header.push(convertCellDataToString(worksheet?.getCell(startRow, i)) || getColumnName(i - startColumn + 1, this._localeService.t('sheets-table.columnPrefix')));+ }+ undos.push({+ id: AddSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: tableJson.id,+ name: tableJson.name,+ header,+ range: tableJson.range,+ options: tableJson.options,+ },+ });+ } else if (range.startColumn <= tableRange.startColumn && range.endColumn >= tableRange.startColumn) {+ const removeColumnCount = range.endColumn - tableRange.startColumn + 1;+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Delete,+ rowColType: IRowColTypeEnum.Col,+ index: tableRange.startColumn,+ count: removeColumnCount,+ },+ },+ },+ });+ const columns: ITableColumnJson[] = [];+ for (let i = 0; i < removeColumnCount; i++) {+ const column = table.getTableColumnByIndex(i);+ if (column) {+ columns.push(column.toJSON());+ }+ }+ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Insert,+ rowColType: IRowColTypeEnum.Col,+ index: tableRange.startColumn,+ count: removeColumnCount,+ columnsJson: columns,+ },+ },+ },+ });+ } else if (range.startColumn > tableRange.startColumn && range.endColumn > tableRange.endColumn) {+ const removeColumnCount = tableRange.endColumn - range.startColumn + 1;+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Delete,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: removeColumnCount,+ },+ },+ },+ });++ const columns: ITableColumnJson[] = [];+ const gap = range.startColumn - tableRange.startColumn;+ for (let i = 0; i < removeColumnCount; i++) {+ const column = table.getTableColumnByIndex(i + gap);+ if (column) {+ columns.push(column.toJSON());+ }+ }++ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Insert,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: removeColCount,+ columnsJson: columns,+ },+ },+ },+ });+ } else if (range.startColumn > tableRange.startColumn && range.endColumn <= tableRange.endColumn) {+ redos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Delete,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: removeColCount,+ },+ },+ },+ });++ const columns: ITableColumnJson[] = [];+ const gap = range.startColumn - tableRange.startColumn;+ for (let i = 0; i < removeColCount; i++) {+ const column = table.getTableColumnByIndex(i + gap);+ if (column) {+ columns.push(column.toJSON());+ }+ }+ undos.push({+ id: SetSheetTableMutation.id,+ params: {+ unitId,+ subUnitId,+ tableId: table.getId(),+ config: {+ rowColOperation: {+ operationType: IRangeOperationTypeEnum.Insert,+ rowColType: IRowColTypeEnum.Col,+ index: range.startColumn,+ count: removeColCount,+ columnsJson: columns,+ },+ },+ },+ });+ }+ }+ });++ return { undos, redos, preRedos, preUndos };+ }++ private _initCommandListener() {+ this._commandService.onCommandExecuted((commandInfo) => {+ if (commandInfo.id === InsertRowMutation.id) {+ const params = commandInfo.params as IInsertRowMutationParams;+ const { unitId, subUnitId, range } = params;+ const insertCount = range.endRow - range.startRow + 1;+ const allTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ allTables.forEach((table) => {+ const tableRange = table.getRange();+ if (range.startRow <= tableRange.startRow) {+ this._tableManager.updateTableRange(unitId, table.getId(), {+ newRange: {+ ...tableRange,+ startRow: tableRange.startRow + insertCount,+ endRow: tableRange.endRow + insertCount,+ },+ });+ }+ });+ } else if (commandInfo.id === InsertColMutation.id) {+ const params = commandInfo.params as IInsertRowMutationParams;+ const { unitId, subUnitId, range } = params;+ const insertCount = range.endColumn - range.startColumn + 1;+ const allTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ allTables.forEach((table) => {+ const tableRange = table.getRange();+ if (range.startColumn <= tableRange.startColumn) {+ this._tableManager.updateTableRange(unitId, table.getId(), {+ newRange: {+ ...tableRange,+ startColumn: tableRange.startColumn + insertCount,+ endColumn: tableRange.endColumn + insertCount,+ },+ });+ }+ });+ } else if (commandInfo.id === RemoveRowMutation.id) {+ const params = commandInfo.params as IInsertRowMutationParams;+ const { unitId, subUnitId, range } = params;+ const removeCount = range.endRow - range.startRow + 1;+ const allTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ allTables.forEach((table) => {+ const tableRange = table.getRange();+ if (range.startRow < tableRange.startRow) {+ this._tableManager.updateTableRange(unitId, table.getId(), {+ newRange: {+ ...tableRange,+ startRow: tableRange.startRow - removeCount,+ endRow: tableRange.endRow - removeCount,+ },+ });+ }+ });+ } else if (commandInfo.id === RemoveColMutation.id) {+ const params = commandInfo.params as IInsertRowMutationParams;+ const { unitId, subUnitId, range } = params;+ const removeCount = range.endColumn - range.startColumn + 1;+ const allTables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ allTables.forEach((table) => {+ const tableRange = table.getRange();+ if (range.startColumn < tableRange.startColumn) {+ this._tableManager.updateTableRange(unitId, table.getId(), {+ newRange: {+ ...tableRange,+ startColumn: tableRange.startColumn - removeCount,+ endColumn: tableRange.endColumn - removeCount,+ },+ });+ }+ });+ }+ });+ }+}diff --git a/packages/sheets-table/src/controllers/sheet-table-theme.controller.ts b/packages/sheets-table/src/controllers/sheet-table-theme.controller.tsnew file mode 100644index 0000000000..2cd36573e7--- /dev/null+++ b/packages/sheets-table/src/controllers/sheet-table-theme.controller.ts@@ -0,0 +1,108 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { Disposable, Inject } from '@univerjs/core';++import { RangeThemeStyle, SheetRangeThemeModel, SheetRangeThemeService } from '@univerjs/sheets';++import { TableManager } from '../model/table-manager';+import { tableThemeConfig } from './table-theme.factory';++export class SheetsTableThemeController extends Disposable {+ constructor(+ @Inject(TableManager) private _tableManager: TableManager,+ @Inject(SheetRangeThemeService) private _sheetRangeThemeService: SheetRangeThemeService,+ @Inject(SheetRangeThemeModel) private _sheetRangeThemeModel: SheetRangeThemeModel+ ) {+ super();+ this.registerTableChangeEvent();+ this._initDefaultTableTheme();+ }++ registerTableChangeEvent() {+ this.disposeWithMe(+ this._tableManager.tableAdd$.subscribe((event) => {+ const { range, tableId, unitId, subUnitId } = event;+ const table = this._tableManager.getTable(unitId, tableId)!;+ const tableStyleId = table.getTableStyleId() || tableThemeConfig[0].name;+ this._sheetRangeThemeService.registerRangeThemeStyle(tableStyleId, {+ unitId,+ subUnitId,+ range: { ...range },+ });+ })+ );++ this.disposeWithMe(+ this._tableManager.tableRangeChanged$.subscribe((event) => {+ const { range, oldRange, tableId, unitId, subUnitId } = event;+ const table = this._tableManager.getTable(unitId, tableId)!;+ const tableStyleId = table.getTableStyleId() || tableThemeConfig[0].name;+ this._sheetRangeThemeService.removeRangeThemeRule(tableStyleId, {+ unitId,+ subUnitId,+ range: { ...oldRange },+ });+ this._sheetRangeThemeService.registerRangeThemeStyle(tableStyleId, {+ unitId,+ subUnitId,+ range: { ...range },+ });+ })+ );++ this.disposeWithMe(+ this._tableManager.tableThemeChanged$.subscribe((event) => {+ const { theme, oldTheme, tableId, unitId, subUnitId } = event;+ const table = this._tableManager.getTable(unitId, tableId)!;+ const range = table.getRange();+ this._sheetRangeThemeService.removeRangeThemeRule(oldTheme, {+ unitId,+ subUnitId,+ range: { ...range },+ });+ this._sheetRangeThemeService.registerRangeThemeStyle(theme, {+ unitId,+ subUnitId,+ range: { ...range },+ });+ })+ );++ this.disposeWithMe(+ this._tableManager.tableDelete$.subscribe((event) => {+ const { range, unitId, subUnitId, tableStyleId = tableThemeConfig[0].name } = event;+ this._sheetRangeThemeService.removeRangeThemeRule(tableStyleId, {+ unitId,+ subUnitId,+ range: { ...range },+ });+ })+ );+ }++ private _initDefaultTableTheme() {+ for (let i = 0; i < tableThemeConfig.length; i++) {+ const { name, style } = tableThemeConfig[i];+ const rangeThemeStyle = new RangeThemeStyle(name, style);+ this._sheetRangeThemeModel.registerDefaultRangeTheme(rangeThemeStyle);+ }+ }++ override dispose() {+ super.dispose();+ }+}diff --git a/packages/sheets-table/src/controllers/sheets-table.controller.ts b/packages/sheets-table/src/controllers/sheets-table.controller.tsnew file mode 100644index 0000000000..86d5733974--- /dev/null+++ b/packages/sheets-table/src/controllers/sheets-table.controller.ts@@ -0,0 +1,181 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IRange } from '@univerjs/core';++import type { ITableResource } from '../types/type';+import { Disposable, Inject, InterceptorEffectEnum, IResourceManagerService, Rectangle, RTree, UniverInstanceType } from '@univerjs/core';+import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';+import { PLUGIN_NAME } from '../const';+import { TableManager } from '../model/table-manager';++export class SheetsTableController extends Disposable {+ private _tableRangeRTree = new Map<string, RTree>();+ constructor(+ @Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService,+ @Inject(TableManager) private _tableManager: TableManager,+ @Inject(IResourceManagerService) private _resourceManagerService: IResourceManagerService+ ) {+ super();+ this._initSnapshot();+ this.registerTableChangeEvent();+ this.registerTableHeaderInterceptor();+ }++ getContainerTableWithRange(unitId: string, subUnitId: string, range: IRange) {+ const rTree = this._ensureTableRangeRTree(unitId);+ const ids = Array.from(rTree.bulkSearch([{ unitId, sheetId: subUnitId, range }]));+ const wrapperTableId = ids.find((id) => {+ const table = this._tableManager.getTable(unitId, String(id));+ if (table) {+ return Rectangle.contains(table.getRange(), range);+ }+ return false;+ });+ if (wrapperTableId) {+ const table = this._tableManager.getTable(unitId, String(wrapperTableId));+ return table;+ }+ }++ private _ensureTableRangeRTree(unitId: string) {+ if (!this._tableRangeRTree.has(unitId)) {+ this._tableRangeRTree.set(unitId, new RTree());+ }+ return this._tableRangeRTree.get(unitId)!;+ }++ registerTableChangeEvent() {+ this.disposeWithMe(+ this._tableManager.tableAdd$.subscribe((event) => {+ const { range, tableId, unitId, subUnitId } = event;+ const rTree = this._ensureTableRangeRTree(unitId);+ rTree.insert({+ unitId,+ sheetId: subUnitId,+ id: tableId,+ range: { ...range },+ });+ })+ );++ this.disposeWithMe(+ this._tableManager.tableRangeChanged$.subscribe((event) => {+ const { range, tableId, unitId, subUnitId, oldRange } = event;+ const rTree = this._ensureTableRangeRTree(unitId);+ rTree.remove({+ unitId,+ sheetId: subUnitId,+ id: tableId,+ range: { ...oldRange },+ });+ rTree.insert({+ unitId,+ sheetId: subUnitId,+ id: tableId,+ range: { ...range },+ });+ })+ );++ this.disposeWithMe(+ this._tableManager.tableDelete$.subscribe((event) => {+ const { tableId, unitId, subUnitId, range } = event;+ const rTree = this._ensureTableRangeRTree(unitId);+ rTree.remove({+ unitId,+ sheetId: subUnitId,+ id: tableId,+ range: { ...range },+ });+ })+ );+ }++ registerTableHeaderInterceptor() {+ this.disposeWithMe(+ this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {+ effect: InterceptorEffectEnum.Value,+ handler: (cell, context, next) => {+ const { row, col, unitId, subUnitId } = context;+ const rTree = this._ensureTableRangeRTree(unitId);+ const v = cell?.v;+ if (v === undefined && rTree) {+ const ids = Array.from(rTree.bulkSearch([{ unitId, sheetId: subUnitId, range: { startColumn: col, endColumn: col, startRow: row, endRow: row } }]));+ if (ids.length > 0) {+ const table = this._tableManager.getTable(unitId, ids[0] as string);+ if (table) {+ const tableRange = table.getRange();+ const index = col - tableRange.startColumn;+ const tableStartRow = tableRange.startRow;+ if (tableStartRow === row) {+ const columnName = table.getColumnNameByIndex(index);+ const newCell = { ...cell, v: columnName };+ return next(newCell);+ }+ }+ }+ }+ return next(cell);+ },+ })+ );+ }++ private _toJson(unitId: string): ITableResource {+ return this._tableManager.toJSON(unitId);+ }++ private _fromJSON(unitId: string, resources: ITableResource) {+ return this._tableManager.fromJSON(unitId, resources);+ }++ private _deleteUnitId(unitId: string) {+ this._tableManager.deleteUnitId(unitId);+ }++ private _initSnapshot(): void {+ this.disposeWithMe(this._resourceManagerService.registerPluginResource({+ toJson: (unitId: string) => {+ return JSON.stringify(this._toJson(unitId));+ },+ parseJson: (json: string) => {+ if (!json) {+ return {};+ }+ try {+ return JSON.parse(json);+ // eslint-disable-next-line unused-imports/no-unused-vars+ } catch (error) {+ return {};+ }+ },+ businesses: [UniverInstanceType.UNIVER_SHEET],+ pluginName: PLUGIN_NAME,+ onLoad: (unitId, resources) => {+ this._fromJSON(unitId, resources);+ },+ onUnLoad: (unitId) => {+ this._deleteUnitId(unitId);+ },+ }));+ }++ override dispose() {+ super.dispose();+ this._tableRangeRTree.clear();+ }+}diff --git a/packages/sheets-table/src/controllers/table-filter.controller.ts b/packages/sheets-table/src/controllers/table-filter.controller.tsnew file mode 100644index 0000000000..9371dda3a1--- /dev/null+++ b/packages/sheets-table/src/controllers/table-filter.controller.ts@@ -0,0 +1,123 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Workbook } from '@univerjs/core';+import type { Subscription } from 'rxjs';++import { Disposable, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';+import { getSheetCommandTarget, INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';+import { BehaviorSubject, filter, switchMap } from 'rxjs';+import { TableManager } from '../model/table-manager';++export class TableFilterController extends Disposable {+ private readonly _tableFilteredOutRows$ = new BehaviorSubject<Readonly<Set<number>>>(new Set());+ readonly tableFilteredOutRows$ = this._tableFilteredOutRows$.asObservable();++ private _subscription: Subscription | null = null;+ constructor(+ @Inject(TableManager) private _tableManager: TableManager,+ @Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService,+ @Inject(IUniverInstanceService) private readonly _univerInstanceService: IUniverInstanceService+ ) {+ super();+ this.registerFilterChangeEvent();+ this.initTableHiddenRowIntercept();+ this._initFilteredOutRows();+ }++ get tableFilteredOutRows() {+ return this._tableFilteredOutRows$.value;+ }++ set tableFilteredOutRows(value: Set<number>) {+ this._tableFilteredOutRows$.next(value);+ }++ initTableHiddenRowIntercept() {+ this.disposeWithMe(this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.ROW_FILTERED, {+ // 这里需要保证优先级高于sheet的筛选,因为筛选没有next,低于筛选的不会触发interceptor+ priority: 100,+ handler: (filtered, rowLocation, next) => {+ if (filtered) return true;+ const isTableFiltered = this.tableFilteredOutRows.has(rowLocation.row);+ return isTableFiltered ? true : next(isTableFiltered);+ },+ }));+ }++ private _initFilteredOutRows() {+ this._tableManager.tableInitStatus$.pipe(+ filter((initialized) => initialized),+ switchMap(() => {+ return this._univerInstanceService.getCurrentTypeOfUnit$<Workbook>(UniverInstanceType.UNIVER_SHEET);+ }),+ filter((workbook) => workbook !== null && workbook !== undefined),+ switchMap((workbook) => workbook.activeSheet$),+ filter((sheet) => sheet !== null && sheet !== undefined)+ ).subscribe(() => {+ const target = getSheetCommandTarget(this._univerInstanceService);+ if (!target) {+ return;+ }+ const { unitId, subUnitId } = target;+ this.tableFilteredOutRows.clear();+ const tables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ tables.forEach((table) => {+ const tableFilteredRows = table.getTableFilters().getFilterOutRows();+ if (!tableFilteredRows) {+ return;+ }+ for (const row of tableFilteredRows) {+ this.tableFilteredOutRows.add(row);+ }+ });+ });+ }++ registerFilterChangeEvent() {+ this.disposeWithMe(+ this._tableManager.tableFilterChanged$.subscribe((event) => {+ const { unitId, subUnitId, tableId } = event;+ const worksheet = this._univerInstanceService.getUnit<Workbook>(unitId)?.getSheetBySheetId(subUnitId);+ const table = this._tableManager.getTable(unitId, tableId);+ if (!worksheet || !table) {+ return;+ }++ this.tableFilteredOutRows.clear();++ const tableFilter = table.getTableFilters();+ tableFilter.doFilter(worksheet, table.getTableFilterRange());++ const tables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);+ tables.forEach((table) => {+ const tableFilteredRows = table.getTableFilters().getFilterOutRows();+ if (!tableFilteredRows) {+ return;+ }+ for (const row of tableFilteredRows) {+ this.tableFilteredOutRows.add(row);+ }+ });+ })+ );+ }++ override dispose(): void {+ super.dispose();+ this._subscription?.unsubscribe();+ }+}diff --git a/packages/sheets-table/src/controllers/table-theme.factory.ts b/packages/sheets-table/src/controllers/table-theme.factory.tsnew file mode 100644index 0000000000..0089113fc2--- /dev/null+++ b/packages/sheets-table/src/controllers/table-theme.factory.ts@@ -0,0 +1,152 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IRangeThemeStyleItem, IRangeThemeStyleJSON } from '@univerjs/sheets';+import { BorderStyleTypes } from '@univerjs/core';++interface ITableDefaultThemeStyle {+ name: string;+ style: Omit<IRangeThemeStyleJSON, 'name'>;+}+export const tableDefaultBorderStyle = {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'rgb(95 101 116)',+ },+};++export const customEmptyThemeWithBorderStyle: Omit<IRangeThemeStyleJSON, 'name'> = {+ headerRowStyle: {+ bd: {+ t: tableDefaultBorderStyle,+ },+ },+ headerColumnStyle: {+ bd: {+ l: tableDefaultBorderStyle,+ },+ },+ lastColumnStyle: {+ bd: {+ r: tableDefaultBorderStyle,+ },+ },+ lastRowStyle: {+ bd: {+ b: tableDefaultBorderStyle,+ },+ },+};++export const processStyleWithBorderStyle = (key: keyof Omit<IRangeThemeStyleJSON, 'name'>, style: IRangeThemeStyleItem) => {+ if (key === 'headerRowStyle') {+ if (!style.bd) {+ return {+ ...style,+ bd: {+ t: tableDefaultBorderStyle,+ },+ };+ }+ } else if (key === 'lastRowStyle') {+ if (!style.bd) {+ return {+ ...style,+ bd: {+ b: tableDefaultBorderStyle,+ },+ };+ }+ } else if (key === 'lastColumnStyle') {+ if (!style.bd) {+ return {+ ...style,+ bd: {+ r: tableDefaultBorderStyle,+ },+ };+ }+ } else if (key === 'headerColumnStyle') {+ if (!style.bd) {+ return {+ ...style,+ bd: {+ l: tableDefaultBorderStyle,+ },+ };+ }+ }+ return style;+};++const tableDefaultThemeStyleArr = [+ [['#6280F9', '#FFFFFF', '#BAC6F8', '#D2DAFA'], ['#fff']],+ [['#16BDCA', '#FFFFFF', '#EDFAFA', '#AFECEF'], ['#000']],+ [['#31C48D', '#FFFFFF', '#F3FAF7', '#BCF0DA'], ['#fff']],+ [['#AC94FA', '#FFFFFF', '#F6F5FF', '#EDEBFE'], ['#fff']],+ [['#F17EBB', '#FFFFFF', '#FDF2F8', '#FCE8F3'], ['#fff']],+ [['#F98080', '#FFFFFF', '#FDF2F2', '#FDE8E8'], ['#fff']],+];++export const tableThemeConfig: ITableDefaultThemeStyle[] = tableDefaultThemeStyleArr.map((item, index) => {+ const [backgroundArr, colorArr] = item;+ const [headerRowBg, firstRowBg, secondRowBg, lastRowBg] = backgroundArr;+ const [headerCl] = colorArr;+ return {+ name: `table-default-${index}`,+ style: {+ headerRowStyle: {+ bg: {+ rgb: headerRowBg,+ },+ cl: {+ rgb: headerCl,+ },+ bd: {+ t: tableDefaultBorderStyle,+ },+ },+ headerColumnStyle: {+ bd: {+ l: tableDefaultBorderStyle,+ },+ },+ firstRowStyle: {+ bg: {+ rgb: firstRowBg,+ },+ },+ secondRowStyle: {+ bg: {+ rgb: secondRowBg,+ },+ },+ lastRowStyle: {+ bg: {+ rgb: lastRowBg,+ },+ bd: {+ b: tableDefaultBorderStyle,+ },+ },+ lastColumnStyle: {+ bd: {+ r: tableDefaultBorderStyle,+ },+ },+ },+ };+});diff --git a/packages/sheets-table/src/facade/f-workbook.ts b/packages/sheets-table/src/facade/f-workbook.tsnew file mode 100644index 0000000000..9a838a9b9e--- /dev/null+++ b/packages/sheets-table/src/facade/f-workbook.ts@@ -0,0 +1,161 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IAddSheetTableParams, IDeleteSheetTableParams, ISetSheetTableParams, ITableFilterItem, ITableInfo, ITableInfoWithUnitId, ITableOptions, ITableRange } from '@univerjs/sheets-table';+import { AddSheetTableCommand, DeleteSheetTableCommand, SetSheetTableFilterCommand, SheetTableService } from '@univerjs/sheets-table';+import { FWorkbook } from '@univerjs/sheets/facade';++/**+ * @ignore+ */+export interface IFWorkbookSheetsTableMixin {+ /**+ * Get table information+ * @param {string} tableId The table id+ * @returns {ITableInfo} The table information+ * @example+ * ```typescript+ * const fWorkbook = univerAPI.getActiveWorkbook();+ * const fSheet = fWorkbook.getActiveSheet();+ * const id = fWorkbook.addTable('Table1', {+ * unitId: fWorkbook.getId(),+ * subUnitId:fSheet.getSheetId(),+ * range: {+ * startRow: 1,+ * startColumn: 1,+ * endRow: 10,+ * endColumn: 5,+ * },+ * }, { showHeader: true });+ * const tableInfo = fWorkbook.getTableInfo(fWorkbook.getId(), id);+ * ```+ */+ getTableInfo(tableId: string): ITableInfoWithUnitId | undefined;++ getTableInfoByName(tableName: string): ITableInfoWithUnitId | undefined;+ /**+ * Get table list+ * @returns {ITableInfo[]} The table list+ * @example+ * ```typescript+ * const fWorkbook = univerAPI.getActiveWorkbook();+ * const fSheet = fWorkbook.getActiveSheet();+ * const id = fWorkbook.addTable('Table1', {+ * unitId: fWorkbook.getId(),+ * subUnitId:fSheet.getSheetId(),+ * range: {+ * startRow: 1,+ * startColumn: 1,+ * endRow: 10,+ * endColumn: 5,+ * },+ * }, { showHeader: true });+ * const tableList = fWorkbook.getTableList(fWorkbook.getId());+ * ```+ */+ getTableList(): ITableInfo[];+ /**+ * Add table+ * @param {string} tableName The table name+ * @param {ITableRange} rangeInfo The table range information+ * @param {ITableOptions} options The table options+ * @returns {string} The table id+ * @example+ * ```typescript+ * const fWorkbook = univerAPI.getActiveWorkbook();+ * const fSheet = fWorkbook.getActiveSheet();+ * const id = fWorkbook.addTable('Table1', {+ * unitId: fWorkbook.getId(),+ * subUnitId:fSheet.getSheetId(),+ * range: {+ * startRow: 1,+ * startColumn: 1,+ * endRow: 10,+ * endColumn: 5,+ * },+ * }, 'table1' ,{ showHeader: true });+ * ```+ */+ addTable(subUnitId: string, tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): Promise<string | undefined>;+ setTableFilter(tableId: string, column: number, filter: ITableFilterItem | undefined): void;+ removeTable(tableId: string): Promise<boolean>;+}++export class FWorkbookSheetsTableMixin extends FWorkbook implements IFWorkbookSheetsTableMixin {+ override getTableInfo(tableId: string): ITableInfoWithUnitId | undefined {+ const unitId = this.getId();+ const sheetTableService = this._injector.get(SheetTableService);+ return sheetTableService.getTableInfo(unitId, tableId);+ }++ override getTableList(): ITableInfoWithUnitId[] {+ const unitId = this.getId();+ const sheetTableService = this._injector.get(SheetTableService);+ return sheetTableService.getTableList(unitId);+ }++ override async addTable(subUnitId: string, tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): Promise<string | undefined> {+ const sheetTableService = this._injector.get(SheetTableService);++ const addTableParams: IAddSheetTableParams = {+ unitId: this.getId(),+ name: tableName,+ subUnitId,+ range: rangeInfo,+ options,+ tableId,+ };+ const rs = await this._commandService.executeCommand(AddSheetTableCommand.id, addTableParams);+ if (rs) {+ return sheetTableService.getTableList(this.getId()).find((table) => table.name === tableName)?.id;+ }+ return undefined;+ }++ override async removeTable(tableId: string): Promise<boolean> {+ const subUnitId = this.getTableInfo(tableId)?.subUnitId;+ if (!subUnitId) {+ return false;+ }+ const removedTableParams: IDeleteSheetTableParams = {+ unitId: this.getId(),+ subUnitId,+ tableId,+ };+ return this._commandService.executeCommand(DeleteSheetTableCommand.id, removedTableParams);+ }++ override getTableInfoByName(tableName: string): ITableInfoWithUnitId | undefined {+ const tableList = this.getTableList();+ return tableList.find((table) => table.name === tableName);+ }++ override setTableFilter(tableId: string, column: number, filter: ITableFilterItem | undefined): Promise<boolean> {+ const setTableFilterParams: ISetSheetTableParams = {+ unitId: this.getId(),+ tableId,+ column,+ tableFilter: filter,+ };+ return this._commandService.executeCommand(SetSheetTableFilterCommand.id, setTableFilterParams);+ }+}++FWorkbook.extend(FWorkbookSheetsTableMixin);+declare module '@univerjs/sheets/facade' {+ // eslint-disable-next-line ts/naming-convention+ interface FWorkbook extends IFWorkbookSheetsTableMixin { }+}diff --git a/packages/sheets-table/src/facade/f-worksheet.ts b/packages/sheets-table/src/facade/f-worksheet.tsnew file mode 100644index 0000000000..3eaa957b19--- /dev/null+++ b/packages/sheets-table/src/facade/f-worksheet.ts@@ -0,0 +1,56 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ISetSheetTableParams, ITableFilterItem, ITableOptions, ITableRange } from '@univerjs/sheets-table';+import { LocaleService } from '@univerjs/core';+import { SetSheetTableFilterCommand, SheetTableService, TableManager } from '@univerjs/sheets-table';+import { FWorksheet } from '@univerjs/sheets/facade';++/**+ * @ignore+ */+export interface IFWorkSheetTableMixin {+ addTable(tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): string;+ addTableFilter(tableId: string, column: number, filter: ITableFilterItem): Promise<boolean>;+}++export class FWorkSheetTableMixin extends FWorksheet implements IFWorkSheetTableMixin {+ override addTable(tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): string {+ const sheetTableService = this._injector.get(SheetTableService);+ const subUnitId = this.getSheetId();+ const unitId = this.getWorkbook().getUnitId();+ const tableManager = this._injector.get(TableManager);+ const localeService = this._injector.get(LocaleService);+ const header = tableManager.getColumnHeader(unitId, subUnitId, rangeInfo, localeService.t('sheets-table.columnPrefix'));+ return sheetTableService.addTable(unitId, subUnitId, tableName, rangeInfo, header, tableId, options);+ }++ override addTableFilter(tableId: string, column: number, filter: ITableFilterItem): Promise<boolean> {+ const setTableFilterParams: ISetSheetTableParams = {+ unitId: this.getWorkbook().getUnitId(),+ tableId,+ column,+ tableFilter: filter,+ };+ return this._commandService.executeCommand(SetSheetTableFilterCommand.id, setTableFilterParams);+ }+}++FWorksheet.extend(FWorkSheetTableMixin);+declare module '@univerjs/sheets/facade' {+ // eslint-disable-next-line ts/naming-convention+ interface FWorksheet extends IFWorkSheetTableMixin { }+}diff --git a/packages/sheets-table/src/facade/index.ts b/packages/sheets-table/src/facade/index.tsnew file mode 100644index 0000000000..0fedfc331e--- /dev/null+++ b/packages/sheets-table/src/facade/index.ts@@ -0,0 +1,21 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import './f-workbook';+import './f-worksheet';++export type * from './f-workbook';+export type * from './f-worksheet';diff --git a/packages/sheets-table/src/index.ts b/packages/sheets-table/src/index.tsnew file mode 100644index 0000000000..5eb6270d6b--- /dev/null+++ b/packages/sheets-table/src/index.ts@@ -0,0 +1,47 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export { SheetsTableButtonStateEnum, SheetsTableSortStateEnum, TableColumnDataTypeEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableNumberCompareTypeEnum, TableStringCompareTypeEnum } from './types/enum';+export { UniverSheetTablePlugin } from './plugin';+export type { ITableColumnJson, ITableConditionFilterItem, ITableData, ITableFilterItem, ITableInfo, ITableInfoWithUnitId, ITableManualFilterItem, ITableOptions, ITableRange, ITableRangeWithState, TableMetaType, TableRelationTupleType } from './types/type';+export { SheetTableService } from '../src/services/table-service';+export { TableManager } from '../src/model/table-manager';+export { isConditionFilter, isManualFilter } from '../src/util';+export { SheetsTableController } from '../src/controllers/sheets-table.controller';++export { AddSheetTableCommand } from '../src/commands/commands/add-sheet-table.command';+export { AddSheetTableMutation } from '../src/commands/mutations/add-sheet-table.mutation';+export { SetSheetTableFilterCommand } from '../src/commands/commands/set-table-filter.command';+export { SetSheetTableFilterMutation } from '../src/commands/mutations/set-table-filter.mutation';+export { DeleteSheetTableCommand } from '../src/commands/commands/delete-sheet-table.command';+export { DeleteSheetTableMutation } from '../src/commands/mutations/delete-sheet-table.mutation';++export type { ISetSheetTableParams } from '../src/commands/mutations/set-table-filter.mutation';+export type { IAddSheetTableParams } from '../src/commands/mutations/add-sheet-table.mutation';+export type { IDeleteSheetTableParams } from '../src/commands/mutations/delete-sheet-table.mutation';++export type { IAddSheetTableCommandParams } from './commands/commands/add-sheet-table.command';+export { SetSheetTableCommand } from './commands/commands/set-sheet-table.command';+export type { ISetSheetTableCommandParams } from './commands/commands/set-sheet-table.command';+export type { ITableSetConfig } from './types/type';+export { SetSheetTableMutation } from './commands/mutations/set-sheet-table.mutation';+export type { ISetSheetTableMutationParams } from './commands/mutations/set-sheet-table.mutation';+export type { IAddTableThemeCommandParams } from './commands/commands/add-table-theme.command';+export { AddTableThemeCommand } from './commands/commands/add-table-theme.command';+export { RemoveTableThemeCommand } from './commands/commands/remove-table-theme.command';+export { SheetTableInsertColCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveRowCommand } from './commands/commands/sheet-table-row-col.command';+export { customEmptyThemeWithBorderStyle, processStyleWithBorderStyle } from './controllers/table-theme.factory';+export { SHEET_TABLE_CUSTOM_THEME_PREFIX } from './const';diff --git a/packages/sheets-table/src/model/filter-util/condition.ts b/packages/sheets-table/src/model/filter-util/condition.tsnew file mode 100644index 0000000000..299ed1b8b6--- /dev/null+++ b/packages/sheets-table/src/model/filter-util/condition.ts@@ -0,0 +1,156 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IDocumentData, Worksheet } from '@univerjs/core';+import type { TableStringCompareTypeEnum } from '../../types/enum';+import type { ICalculatedOptions, ITableConditionFilterItem, ITableDateFilterInfo, ITableNumberFilterInfo, ITableStringFilterInfo } from '../../types/type';+import { CellValueType } from '@univerjs/core';+import { TableConditionTypeEnum, TableDateCompareTypeEnum, TableNumberCompareTypeEnum } from '../../types/enum';+import { getDateFilterExecuteFunc } from './date-filter-util';+import { getNumberFilterExecuteFunc } from './number-filter-util';+import { getTextFilterExecuteFunc } from './text-filter-util';++type TableConditionCompareType = TableNumberCompareTypeEnum | TableDateCompareTypeEnum | TableStringCompareTypeEnum;++// A dynamic filter returns a result set which might vary due to a change in the data itself or a change in the date on which the filter is being applied+const NumberDynamicFilterCompareTypeSet: Set<TableNumberCompareTypeEnum> = new Set([+ TableNumberCompareTypeEnum.Above,+ TableNumberCompareTypeEnum.Below,+ TableNumberCompareTypeEnum.TopN,+]);++const DateDynamicFilterCompareTypeSet: Set<TableDateCompareTypeEnum> = new Set([+ TableDateCompareTypeEnum.Today,+ TableDateCompareTypeEnum.Yesterday,+ TableDateCompareTypeEnum.Tomorrow,+ TableDateCompareTypeEnum.ThisWeek,+ TableDateCompareTypeEnum.LastWeek,+ TableDateCompareTypeEnum.NextWeek,+ TableDateCompareTypeEnum.ThisMonth,+ TableDateCompareTypeEnum.LastMonth,+ TableDateCompareTypeEnum.NextMonth,+ TableDateCompareTypeEnum.ThisQuarter,+ TableDateCompareTypeEnum.LastQuarter,+ TableDateCompareTypeEnum.NextQuarter,+ TableDateCompareTypeEnum.NextYear,+ TableDateCompareTypeEnum.ThisYear,+ TableDateCompareTypeEnum.LastYear,+ TableDateCompareTypeEnum.YearToDate,+]);++export function isNumberDynamicFilter(compareType: TableConditionCompareType): compareType is TableNumberCompareTypeEnum {+ return NumberDynamicFilterCompareTypeSet.has(compareType as TableNumberCompareTypeEnum);+}++export function isDateDynamicFilter(compareType: TableConditionCompareType): compareType is TableDateCompareTypeEnum {+ return DateDynamicFilterCompareTypeSet.has(compareType as TableDateCompareTypeEnum);+}++export function getConditionExecuteFunc(filter: ITableConditionFilterItem, calculatedOptions: ICalculatedOptions | undefined) {+ if (isNumberDynamicFilter(filter.filterInfo.compareType)) {+ return (value: any) => true;+ } else {+ switch (filter.filterInfo.conditionType) {+ case TableConditionTypeEnum.Date:+ return getDateFilterExecuteFunc(filter.filterInfo as ITableDateFilterInfo);+ case TableConditionTypeEnum.Number:+ return getNumberFilterExecuteFunc(filter.filterInfo as ITableNumberFilterInfo, calculatedOptions);+ case TableConditionTypeEnum.String:+ return getTextFilterExecuteFunc(filter.filterInfo as ITableStringFilterInfo);+ case TableConditionTypeEnum.Logic:+ default:+ return (value: any) => true;+ }+ }+}++export function getCellValueWithConditionType(sheet: Worksheet, row: number, col: number, conditionType: TableConditionTypeEnum) {+ switch (conditionType) {+ case TableConditionTypeEnum.Date:+ {+ const dateNumber = getNumberCellValue(sheet, row, col);+ return dateNumber ? excelSerialToDateTime(dateNumber) : null;+ }+ case TableConditionTypeEnum.Number:+ return getNumberCellValue(sheet, row, col);+ case TableConditionTypeEnum.String:+ default:+ return getStringCellValue(sheet, row, col);+ }+}++export const getStringFromDataStream = (data: IDocumentData): string => {+ const dataStream = data.body?.dataStream.replace(/\r\n$/, '') || '';+ return dataStream;+};++function getStringCellValue(sheet: Worksheet, row: number, col: number) {+ const cellData = sheet.getCell(row, col);+ if (!cellData) return null;+ const { v, t, p } = cellData;+ if (p) {+ return getStringFromDataStream(p);+ }+ if (typeof v === 'string') {+ if (t === CellValueType.BOOLEAN) return v.toUpperCase();+ return v;+ };++ if (typeof v === 'number') {+ if (t === CellValueType.BOOLEAN) return v ? 'TRUE' : 'FALSE';+ return v;+ };++ if (typeof v === 'boolean') return v ? 'TRUE' : 'FALSE';++ if (v === undefined) {+ return '(空白)';+ }++ return String(v);+}+function getNumberCellValue(sheet: Worksheet, row: number, col: number) {+ const cellData = sheet.getCell(row, col);+ if (!cellData) return null;+ const { v, t, p } = cellData;+ if (p) {+ return null;+ }+ if (typeof v === 'string' && t === CellValueType.NUMBER) {+ // use this way to instead of numfmt.parseNumber(v as string).v as number;+ return Number(sheet.getCellRaw(row, col)!.v);+ }+ return Number(v);+}++export function excelSerialToDateTime(serial: number): Date {+ const baseDate = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)); // January 1, 1900, UTC+ const leapDayDate = new Date(Date.UTC(1900, 1, 28, 0, 0, 0)); // February 28, 1900, UTC++ let dayDifference = serial - 1; // Adjust for Excel serial number starting from 1++ // If the serial number corresponds to a date later than February 28, 1900, adjust the day difference+ if (dayDifference > (leapDayDate.getTime() - baseDate.getTime()) / (1000 * 3600 * 24)) {+ dayDifference -= 1;+ }++ if (dayDifference < 0) {+ dayDifference = serial;+ }++ const resultDate = new Date(baseDate.getTime() + dayDifference * (1000 * 3600 * 24));+ return resultDate;+}diff --git a/packages/sheets-table/src/model/filter-util/date-filter-util.ts b/packages/sheets-table/src/model/filter-util/date-filter-util.tsnew file mode 100644index 0000000000..e05d1055ea--- /dev/null+++ b/packages/sheets-table/src/model/filter-util/date-filter-util.ts@@ -0,0 +1,577 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ITableDateFilterInfo } from '../../types/type';+import { TableDateCompareTypeEnum } from '../../types/enum';++/**+ * The provided date is a date in Q1 of the year.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateQ1 = (date: Date): boolean => {+ const month = date.getMonth();+ return month <= 2;+};++/**+ * The provided date is a date in Q2 of the year.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateQ2 = (date: Date): boolean => {+ const month = date.getMonth();+ return month > 2 && month <= 5;+};++/**+ * The provided date is a date in Q3 of the year.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateQ3 = (date: Date): boolean => {+ const month = date.getMonth();+ return month > 5 && month <= 8;+};++/**+ * The provided date is a date in Q4 of the year.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateQ4 = (date: Date): boolean => {+ const month = date.getMonth();+ return month > 8 && month <= 11;+};++/**+ * The provided date is a date in January.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM1 = (date: Date): boolean => {+ return date.getMonth() === 0;+};++/**+ * The provided date is a date in February.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM2 = (date: Date): boolean => {+ return date.getMonth() === 1;+};++/**+ * The provided date is a date in March.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM3 = (date: Date): boolean => {+ return date.getMonth() === 2;+};++/**+ * The provided date is a date in April.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM4 = (date: Date): boolean => {+ return date.getMonth() === 3;+};++/**+ * The provided date is a date in May.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM5 = (date: Date): boolean => {+ return date.getMonth() === 4;+};++/**+ * The provided date is a date in June.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM6 = (date: Date): boolean => {+ return date.getMonth() === 5;+};++/**+ * The provided date is a date in July.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM7 = (date: Date): boolean => {+ return date.getMonth() === 6;+};++/**+ * The provided date is a date in August.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM8 = (date: Date): boolean => {+ return date.getMonth() === 7;+};++/**+ * The provided date is a date in September.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM9 = (date: Date): boolean => {+ return date.getMonth() === 8;+};++/**+ * The provided date is a date in October.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM10 = (date: Date): boolean => {+ return date.getMonth() === 9;+};++/**+ * The provided date is a date in November.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM11 = (date: Date): boolean => {+ return date.getMonth() === 10;+};++/**+ * The provided date is a date in December.+ * @param {Date} date - The date to compare.+ * @returns {boolean} return the date is match+ */+export const dateM12 = (date: Date): boolean => {+ return date.getMonth() === 11;+};++/**+ * The provided date is today.+ * @param {Date} expectedDate - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const today = (expectedDate: Date, anchorTime: Date = new Date()): boolean => {+ return expectedDate.toDateString() === anchorTime.toDateString();+};++/**+ * The provided date is tomorrow.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const tomorrow = (date: Date, anchorTime: Date = new Date()): boolean => {+ const tomorrow = new Date(anchorTime);+ tomorrow.setDate(tomorrow.getDate() + 1);+ return date.toDateString() === tomorrow.toDateString();+};++/**+ * The provided date is yesterday.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const yesterday = (date: Date, anchorTime: Date = new Date()): boolean => {+ const yesterday = new Date(anchorTime);+ yesterday.setDate(yesterday.getDate() - 1);+ return date.toDateString() === yesterday.toDateString();+};++/**+ * Get the start date of the week for the provided date.+ * @param {Date} date - The date to get the week start.+ * @returns {Date} The start date of the week.+ */+const getWeekStart = (date: Date): Date => {+ const day = date.getDay();+ const diff = date.getDate() - day + (day === 0 ? -6 : 1);+ const weekStart = new Date(date);+ weekStart.setDate(diff);+ return weekStart;+};++const perWeek = 7 * 24 * 60 * 60 * 1000;++/**+ * The provided date is in the current week.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const thisWeek = (date: Date, anchorTime: Date = new Date()): boolean => {+ const weekStart = getWeekStart(date);+ const anchorTimeWeekStart = getWeekStart(anchorTime);+ return weekStart.toDateString() === anchorTimeWeekStart.toDateString();+};++/**+ * The provided date is in the next week.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const nextWeek = (date: Date, anchorTime: Date = new Date()): boolean => {+ const weekStart = getWeekStart(date);+ const anchorTimeNextWeekStart = new Date(getWeekStart(anchorTime).getTime() + perWeek);+ return weekStart.toDateString() === anchorTimeNextWeekStart.toDateString();+};++/**+ * The provided date is in the last week.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const lastWeek = (date: Date, anchorTime: Date = new Date()): boolean => {+ const weekStart = getWeekStart(date);+ const anchorTimeLastWeekStart = new Date(getWeekStart(anchorTime).getTime() - perWeek);+ return weekStart.toDateString() === anchorTimeLastWeekStart.toDateString();+};++/**+ * The provided date is in the current month.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const thisMonth = (date: Date, anchorTime: Date = new Date()): boolean => {+ return date.getFullYear() === anchorTime.getFullYear() && date.getMonth() === anchorTime.getMonth();+};++/**+ * Get the start date of the month for the provided date.+ * @param {Date} date - The date to get the month start.+ * @returns {Date} The start date of the month.+ */+const getMonthStart = (date: Date): Date => {+ const monthStart = new Date(date);+ monthStart.setHours(0, 0, 0, 0);+ monthStart.setDate(1);+ return monthStart;+};++/**+ * The provided date is in the next month.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const nextMonth = (date: Date, anchorTime: Date = new Date()): boolean => {+ const nextMonthStart = new Date(anchorTime);+ nextMonthStart.setHours(0, 0, 0, 0);+ nextMonthStart.setMonth(nextMonthStart.getMonth() + 1, 1);++ const monthEnd = new Date(nextMonthStart);+ monthEnd.setMonth(monthEnd.getMonth() + 1, 0);++ const dateTime = date.getTime();++ return dateTime >= nextMonthStart.getTime() && dateTime < monthEnd.getTime();+};++/**+ * The provided date is in the last month.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const lastMonth = (date: Date, anchorTime: Date = new Date()): boolean => {+ const lastMonthStart = getMonthStart(anchorTime);++ const monthEnd = new Date(lastMonthStart);+ monthEnd.setMonth(monthEnd.getMonth() + 1, 0);++ const dateTime = date.getTime();++ return dateTime >= lastMonthStart.getTime() && dateTime < monthEnd.getTime();+};++/**+ * Get the start date of the quarter for the provided date.+ * @param {Date} date - The date to get the quarter start.+ * @returns {Date} The start date of the quarter.+ */+const getQuarterStart = (date: Date): Date => {+ const quarterStart = new Date(date);+ quarterStart.setHours(0, 0, 0, 0);+ quarterStart.setDate(1);+ const month = quarterStart.getMonth();+ quarterStart.setMonth(month - month % 3);+ return quarterStart;+};++/**+ * The provided date is in the current quarter.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const thisQuarter = (date: Date, anchorTime: Date = new Date()): boolean => {+ const quarterStart = getQuarterStart(anchorTime);+ const nextQuarterStart = new Date(quarterStart);+ nextQuarterStart.setMonth(nextQuarterStart.getMonth() + 3);+ const dateTime = date.getTime();+ return dateTime >= quarterStart.getTime() && dateTime < nextQuarterStart.getTime();+};++/**+ * The provided date is in the next quarter.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const nextQuarter = (date: Date, anchorTime: Date = new Date()): boolean => {+ const quarterStart = getQuarterStart(anchorTime);+ const nextQuarterStart = new Date(quarterStart);+ nextQuarterStart.setMonth(nextQuarterStart.getMonth() + 3);+ const nextQuarterEnd = new Date(nextQuarterStart);+ nextQuarterEnd.setMonth(nextQuarterEnd.getMonth() + 3, 0);++ const dateTime = date.getTime();++ return dateTime >= nextQuarterStart.getTime() && dateTime < nextQuarterEnd.getTime();+};++/**+ * The provided date is in the last quarter.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const lastQuarter = (date: Date, anchorTime: Date = new Date()): boolean => {+ const quarterStart = getQuarterStart(anchorTime);+ const lastQuarterStart = new Date(quarterStart);+ lastQuarterStart.setMonth(lastQuarterStart.getMonth() - 3);+ const lastQuarterEnd = new Date(quarterStart);+ lastQuarterEnd.setDate(0);++ const dateTime = date.getTime();++ return dateTime >= lastQuarterStart.getTime() && dateTime < lastQuarterEnd.getTime();+};++/**+ * The provided date is in the current year.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const thisYear = (date: Date, anchorTime: Date = new Date()): boolean => {+ return date.getFullYear() === anchorTime.getFullYear();+};++/**+ * The provided date is in the next year.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const nextYear = (date: Date, anchorTime: Date = new Date()): boolean => {+ return date.getFullYear() === anchorTime.getFullYear() + 1;+};++/**+ * The provided date is in the last year.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const lastYear = (date: Date, anchorTime: Date = new Date()): boolean => {+ return date.getFullYear() === anchorTime.getFullYear() - 1;+};++/**+ * The provided date is in the year to date.+ * @param {Date} date - The date to compare.+ * @param {Date} [anchorTime] - The reference date.+ * @returns {boolean} return the date is match+ */+export const yearToDate = (date: Date, anchorTime: Date = new Date()): boolean => {+ const yearStart = new Date(anchorTime);+ yearStart.setHours(0, 0, 0, 0);+ yearStart.setMonth(0, 1);+ const dateTime = date.getTime();+ return dateTime >= yearStart.getTime() && dateTime < anchorTime.getTime();+};++// eslint-disable-next-line max-lines-per-function, complexity+export function getDateFilterExecuteFunc(filterInfo: ITableDateFilterInfo) {+ switch (filterInfo.compareType) {+ case TableDateCompareTypeEnum.Equal:+ {+ const expected = filterInfo.expectedValue as Date;+ return (date: Date) => date.getTime() === expected.getTime();+ }+ case TableDateCompareTypeEnum.NotEqual:+ {+ const expected = filterInfo.expectedValue as Date;+ return (date: Date) => date.getTime() !== expected.getTime();+ }+ case TableDateCompareTypeEnum.After:+ {+ const expected = filterInfo.expectedValue as Date;+ return (date: Date) => date.getTime() > expected.getTime();+ }+ case TableDateCompareTypeEnum.Before:+ {+ const expected = filterInfo.expectedValue as Date;+ return (date: Date) => date.getTime() < expected.getTime();+ }+ case TableDateCompareTypeEnum.AfterOrEqual:+ {+ const expected = filterInfo.expectedValue as Date;+ return (date: Date) => date.getTime() >= expected.getTime();+ }+ case TableDateCompareTypeEnum.BeforeOrEqual:+ {+ const expected = filterInfo.expectedValue as Date;+ return (date: Date) => date.getTime() <= expected.getTime();+ }+ case TableDateCompareTypeEnum.Between:+ return (date: Date) => {+ const [start, end] = filterInfo.expectedValue as [Date, Date];+ return date.getTime() >= new Date(start).getTime() && date.getTime() <= new Date(end).getTime();+ };+ case TableDateCompareTypeEnum.NotBetween:+ return (date: Date) => {+ const [start, end] = filterInfo.expectedValue as [Date, Date];+ return date.getTime() < new Date(start).getTime() || date.getTime() > new Date(end).getTime();+ };+ case TableDateCompareTypeEnum.Today:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => today(date, anchorTime);+ }+ case TableDateCompareTypeEnum.Yesterday:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => yesterday(date, anchorTime);+ }+ case TableDateCompareTypeEnum.Tomorrow:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => tomorrow(date, anchorTime);+ }+ case TableDateCompareTypeEnum.ThisWeek:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => thisWeek(date, anchorTime);+ }+ case TableDateCompareTypeEnum.LastWeek:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => lastWeek(date, anchorTime);+ }+ case TableDateCompareTypeEnum.NextWeek:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => nextWeek(date, anchorTime);+ }+ case TableDateCompareTypeEnum.ThisMonth:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => thisMonth(date, anchorTime);+ }+ case TableDateCompareTypeEnum.LastMonth:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => lastMonth(date, anchorTime);+ }+ case TableDateCompareTypeEnum.NextMonth:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => nextMonth(date, anchorTime);+ }+ case TableDateCompareTypeEnum.ThisQuarter:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => thisQuarter(date, anchorTime);+ }+ case TableDateCompareTypeEnum.LastQuarter:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => lastQuarter(date, anchorTime);+ }+ case TableDateCompareTypeEnum.NextQuarter:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => nextQuarter(date, anchorTime);+ }+ case TableDateCompareTypeEnum.ThisYear:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => thisYear(date, anchorTime);+ }+ case TableDateCompareTypeEnum.LastYear:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => lastYear(date, anchorTime);+ }+ case TableDateCompareTypeEnum.NextYear:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => nextYear(date, anchorTime);+ }+ case TableDateCompareTypeEnum.YearToDate:+ {+ const anchorTime = filterInfo.anchorTime ? new Date(filterInfo.anchorTime) : new Date();+ return (date: Date) => yearToDate(date, anchorTime);+ }+ case TableDateCompareTypeEnum.M1:+ return dateM1;+ case TableDateCompareTypeEnum.M2:+ return dateM2;+ case TableDateCompareTypeEnum.M3:+ return dateM3;+ case TableDateCompareTypeEnum.M4:+ return dateM4;+ case TableDateCompareTypeEnum.M5:+ return dateM5;+ case TableDateCompareTypeEnum.M6:+ return dateM6;+ case TableDateCompareTypeEnum.M7:+ return dateM7;+ case TableDateCompareTypeEnum.M8:+ return dateM8;+ case TableDateCompareTypeEnum.M9:+ return dateM9;+ case TableDateCompareTypeEnum.M10:+ return dateM10;+ case TableDateCompareTypeEnum.M11:+ return dateM11;+ case TableDateCompareTypeEnum.M12:+ return dateM12;+ case TableDateCompareTypeEnum.Q1:+ return dateQ1;+ case TableDateCompareTypeEnum.Q2:+ return dateQ2;+ case TableDateCompareTypeEnum.Q3:+ return dateQ3;+ case TableDateCompareTypeEnum.Q4:+ return dateQ4;+ default:+ throw new Error('Unsupported compare type');+ }+}diff --git a/packages/sheets-table/src/model/filter-util/manual.ts b/packages/sheets-table/src/model/filter-util/manual.tsnew file mode 100644index 0000000000..35be907815--- /dev/null+++ b/packages/sheets-table/src/model/filter-util/manual.ts@@ -0,0 +1,54 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICellData, Nullable } from '@univerjs/core';+import { BuildTextUtils, CellValueType } from '@univerjs/core';++/**+ * Get pure text in a cell.+ * @param cell+ * @returns pure text in this cell+ */+export function extractPureTextFromCell(cell: Nullable<ICellData>): string {+ if (!cell) {+ return '';+ }++ const richTextValue = cell.p?.body?.dataStream;+ if (richTextValue) {+ return BuildTextUtils.transform.getPlainText(richTextValue);+ }++ const rawValue = cell.v;++ if (typeof rawValue === 'string') {+ if (cell.t === CellValueType.BOOLEAN) {+ return rawValue.toUpperCase();+ }++ // the browser will automatically cache the regular expression, so we don't need to cache it manually+ return rawValue.replace(/[\r\n]/g, '');+ };++ if (typeof rawValue === 'number') {+ if (cell.t === CellValueType.BOOLEAN) return rawValue ? 'TRUE' : 'FALSE';+ return rawValue.toString();+ };++ if (typeof rawValue === 'boolean') return rawValue ? 'TRUE' : 'FALSE';++ return '';+}diff --git a/packages/sheets-table/src/model/filter-util/number-filter-util.ts b/packages/sheets-table/src/model/filter-util/number-filter-util.tsnew file mode 100644index 0000000000..317fb871a4--- /dev/null+++ b/packages/sheets-table/src/model/filter-util/number-filter-util.ts@@ -0,0 +1,139 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICalculatedOptions, ITableNumberFilterInfo } from '../../types/type';+import { TableNumberCompareTypeEnum } from '../../types/enum';+import { getLargestK, getSmallestK } from './top-n';++/**+ * @description Checks if a value is above the average.+ * @param {number} value - The value to check.+ * @param {number} average - The average value.+ * @returns {boolean} A boolean value indicating whether the value is above the average.+ */+export const above = (value: number, average: number): boolean => {+ return value > average;+};++/**+ * @description Checks if a value is below the average.+ * @param {number} value - The value to check.+ * @param {number} average - The average value.+ * @returns {boolean} A boolean value indicating whether the value is below the average.+ */+export const below = (value: number, average: number): boolean => {+ return value < average;+};++/**+ * @description Gets the largest N values from a list and checks if the expected value is included.+ * @param {number[]} list - The list of numbers.+ * @param {number} top - The number of top values to retrieve.+ * @param {number} expectedValue - The expected value to check for inclusion.+ * @returns {boolean} A boolean value indicating whether the expected value is included in the top N values.+ */+export const getTopN = (list: number[], top: number, expectedValue: number): boolean => {+ const heap = getLargestK(list, top);+ return heap.includes(expectedValue);+};++/**+ * @description Gets the smallest N values from a list and checks if the expected value is included.+ * @param {number[]} list - The list of numbers.+ * @param {number} bottom - The number of bottom values to retrieve.+ * @param {number} expectedValue - The expected value to check for inclusion.+ * @returns {boolean} A boolean value indicating whether the expected value is included in the bottom N values.+ */+export const getBottomN = (list: number[], bottom: number, expectedValue: number): boolean => {+ const heap = getSmallestK(list, bottom);+ return heap.includes(expectedValue);+};++export function getNumberFilterExecuteFunc(filter: ITableNumberFilterInfo, calculatedOptions: ICalculatedOptions | undefined) {+ switch (filter.compareType) {+ case TableNumberCompareTypeEnum.Equal:+ {+ const expectedValue = Number(filter.expectedValue);+ return (value: number) => value === expectedValue;+ }+ case TableNumberCompareTypeEnum.NotEqual:+ {+ const expectedValue = Number(filter.expectedValue);+ return (value: number) => value !== expectedValue;+ }+ case TableNumberCompareTypeEnum.GreaterThan:+ {+ const expectedValue = Number(filter.expectedValue);+ return (value: number) => value > expectedValue;+ }+ case TableNumberCompareTypeEnum.GreaterThanOrEqual:+ {+ const expectedValue = Number(filter.expectedValue);+ return (value: number) => value >= expectedValue;+ }+ case TableNumberCompareTypeEnum.LessThan:+ {+ const expectedValue = Number(filter.expectedValue);+ return (value: number) => value < expectedValue;+ }+ case TableNumberCompareTypeEnum.LessThanOrEqual:+ {+ const expectedValue = Number(filter.expectedValue);+ return (value: number) => value <= expectedValue;+ }+ case TableNumberCompareTypeEnum.Between:+ {+ const [min, max] = filter.expectedValue as [number, number];+ const minValue = Number(min);+ const maxValue = Number(max);+ if (minValue > maxValue) {+ return (value: number) => value >= maxValue && value <= minValue;+ }+ return (value: number) => value >= minValue && value <= maxValue;+ }++ case TableNumberCompareTypeEnum.NotBetween:+ {+ const [min, max] = filter.expectedValue as [number, number];+ const minValue = Number(min);+ const maxValue = Number(max);+ if (minValue > maxValue) {+ return (value: number) => value < maxValue || value > minValue;+ }+ return (value: number) => value < minValue || value > maxValue;+ }++ case TableNumberCompareTypeEnum.Above:+ {+ const average = calculatedOptions!.average as number;+ return (value: number) => above(value, average);+ }++ case TableNumberCompareTypeEnum.Below:+ {+ const average = calculatedOptions!.average as number;+ return (value: number) => below(value, average);+ }++ case TableNumberCompareTypeEnum.TopN:+ {+ const list = calculatedOptions!.list as number[];+ const top = Number(filter.expectedValue);++ return (value: number) => getTopN(list, top, value);+ }+ }+}diff --git a/packages/sheets-table/src/model/filter-util/text-filter-util.ts b/packages/sheets-table/src/model/filter-util/text-filter-util.tsnew file mode 100644index 0000000000..c667c021b7--- /dev/null+++ b/packages/sheets-table/src/model/filter-util/text-filter-util.ts@@ -0,0 +1,79 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ITableStringFilterInfo } from '../../types/type';+import { TableStringCompareTypeEnum } from '../../types/enum';++/**+ * Converts a pattern with ? and * to a regular expression.+ * @param {string} pattern - The pattern to convert.+ * @returns {RegExp} The regular expression.+ */+const patternToRegExp = (pattern: string): RegExp => {+ const escapedPattern = pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');+ const regexPattern = escapedPattern.replace(/\\\*/g, '.*').replace(/\\\?/g, '.');+ return new RegExp(`^${regexPattern}$`);+};++export const textEqual = (compareValue: string, expectedValue: string) => {+ const regex = patternToRegExp(expectedValue);+ return regex.test(compareValue);+};++export const textNotEqual = (compareValue: string, expectedValue: string) => {+ const regex = patternToRegExp(expectedValue);+ return !regex.test(compareValue);+};++export const textContain = (compareValue: string, expectedValue: string) => {+ const regex = patternToRegExp(`*${expectedValue}*`);+ return regex.test(compareValue);+};++export const textNotContain = (compareValue: string, expectedValue: string) => {+ const regex = patternToRegExp(`*${expectedValue}*`);+ return !regex.test(compareValue);+};++export const textStartWith = (compareValue: string, expectedValue: string) => {+ const regex = patternToRegExp(`${expectedValue}*`);+ return regex.test(compareValue);+};++export const textEndWith = (compareValue: string, expectedValue: string) => {+ const regex = patternToRegExp(`*${expectedValue}`);+ return regex.test(compareValue);+};++export function getTextFilterExecuteFunc(filter: ITableStringFilterInfo) {+ switch (filter.compareType) {+ case TableStringCompareTypeEnum.Equal:+ return (value: string) => textEqual(value, filter.expectedValue);+ case TableStringCompareTypeEnum.NotEqual:+ return (value: string) => textNotEqual(value, filter.expectedValue);+ case TableStringCompareTypeEnum.Contains:+ return (value: string) => textContain(value, filter.expectedValue);+ case TableStringCompareTypeEnum.NotContains:+ return (value: string) => textNotContain(value, filter.expectedValue);+ case TableStringCompareTypeEnum.StartsWith:+ return (value: string) => textStartWith(value, filter.expectedValue);+ case TableStringCompareTypeEnum.EndsWith:+ return (value: string) => textEndWith(value, filter.expectedValue);+ default:+ console.error(`Unknown filter operator: ${filter.compareType}`);+ return (value: string) => true;+ }+}diff --git a/packages/sheets-table/src/model/filter-util/top-n.ts b/packages/sheets-table/src/model/filter-util/top-n.tsnew file mode 100644index 0000000000..b73d243d05--- /dev/null+++ b/packages/sheets-table/src/model/filter-util/top-n.ts@@ -0,0 +1,266 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++/**+ * @description Represents a heap data structure.+ * A heap is a complete binary tree that satisfies the heap property.+ * The heap property states that the parent node is always smaller or bigger than its children.+ * The root node is the smallest or biggest element in the heap.+ * The heap is used to find the kth largest or smallest element in a list.+ * A array can be used to represent a heap.+ * The root node is at index 0, and the left child of a node at index i is at index 2i + 1.+ * The right child of a node at index i is at index 2i + 2.+ * The parent node of a node at index i is at index (i - 1) / 2.+ * @example+ * const maxHeap = [5, 3, 4, 1, 2];+ * // const minHeap = [6, 8, 7, 10, 9];+ * // the root node in maxHeap is 5+ * // the root child is 3, 4, then the child of 3 is 1, 2+ */+class Heap {+ heap: number[];++ /**+ * Initializes a new instance of the Heap class.+ */+ constructor() {+ this.heap = [];+ }++ /**+ * Swaps the elements at the given indices in the heap.+ * @param index1 The index of the first element.+ * @param index2 The index of the second element.+ */+ swap(index1: number, index2: number) {+ const temp = this.heap[index1];+ this.heap[index1] = this.heap[index2];+ this.heap[index2] = temp;+ }++ /**+ * Returns the index of the parent node for the given index.+ * @param index The index of the node.+ * @returns The index of the parent node.+ */+ getParentIndex(index: number) {+ return Math.floor((index - 1) / 2);+ }++ /**+ * Returns the index of the left child node for the given index.+ * @param index The index of the node.+ * @returns The index of the left child node.+ */+ getLeftIndex(index: number) {+ return index * 2 + 1;+ }++ /**+ * Returns the index of the right child node for the given index.+ * @param index The index of the node.+ * @returns The index of the right child node.+ */+ getRightIndex(index: number) {+ return index * 2 + 2;+ }++ /**+ * Returns the number of elements in the heap.+ * @returns The number of elements in the heap.+ */+ size(): number {+ return this.heap.length;+ }++ /**+ * Returns the minimum value in the heap without removing it.+ * @returns The minimum value in the heap.+ */+ peek(): number {+ return this.heap[0];+ }++ /**+ * @description Returns whether the heap includes the given value.+ * @param {number} value The value to be checked.+ * @returns {boolean} return true if the heap includes the given value+ */+ include(value: number): boolean {+ return this.heap.includes(value);+ }+}++/**+ * @description Represents a min heap data structure.+ * in MinHeap, the parent node is always smaller than its children.+ * The root node is the smallest element in the heap.+ * The min heap is used to find the kth largest element in a list.+ */+class MinHeap extends Heap {+ /**+ * Initializes a new instance of the MinHeap class.+ */+ constructor() {+ super();+ }++ /**+ * Moves the element at the given index up the heap until it satisfies the min heap property.+ * @param index The index of the element to be shifted up.+ */+ shiftUp(index: number) {+ if (index === 0) {+ return;+ }+ const parentIndex = this.getParentIndex(index);+ if (this.heap[parentIndex] > this.heap[index]) {+ this.swap(parentIndex, index);+ this.shiftUp(parentIndex);+ }+ }++ /**+ * Moves the element at the given index down the heap until it satisfies the min heap property.+ * @param index The index of the element to be shifted down.+ */+ shiftDown(index: number) {+ const leftIndex = this.getLeftIndex(index);+ const rightIndex = this.getRightIndex(index);++ if (this.heap[leftIndex] < this.heap[index]) {+ this.swap(leftIndex, index);+ this.shiftDown(leftIndex);+ }++ if (this.heap[rightIndex] < this.heap[index]) {+ this.swap(rightIndex, index);+ this.shiftDown(rightIndex);+ }+ }++ /**+ * Inserts a new value into the min heap.+ * @param value The value to be inserted.+ */+ insert(value: number) {+ this.heap.push(value);+ this.shiftUp(this.heap.length - 1);+ }++ /**+ * Removes and returns the minimum value from the min heap.+ */+ pop() {+ this.heap[0] = this.heap.pop() as number;+ this.shiftDown(0);+ }+}++/**+ * Represents a max heap data structure.+ */+class MaxHeap extends Heap {+ /**+ * Initializes a new instance of the MaxHeap class.+ */+ constructor() {+ super();+ }++ /**+ * Moves the element at the given index up the heap until it satisfies the max heap property.+ * @param index The index of the element to be shifted up.+ */+ shiftUp(index: number) {+ if (index === 0) {+ return;+ }+ const parentIndex = this.getParentIndex(index);+ if (this.heap[parentIndex] < this.heap[index]) {+ this.swap(parentIndex, index);+ this.shiftUp(parentIndex);+ }+ }++ /**+ * Moves the element at the given index down the heap until it satisfies the max heap property.+ * @param index The index of the element to be shifted down.+ */+ shiftDown(index: number) {+ const leftIndex = this.getLeftIndex(index);+ const rightIndex = this.getRightIndex(index);+ if (this.heap[leftIndex] > this.heap[index]) {+ this.swap(leftIndex, index);+ this.shiftDown(leftIndex);+ }+ if (this.heap[rightIndex] > this.heap[index]) {+ this.swap(rightIndex, index);+ this.shiftDown(rightIndex);+ }+ }++ /**+ * Inserts a new value into the max heap.+ * @param value The value to be inserted.+ */+ insert(value: number) {+ this.heap.push(value);+ this.shiftUp(this.heap.length - 1);+ }++ /**+ * Removes and returns the maximum value from the max heap.+ */+ pop() {+ this.heap[0] = this.heap.pop() as number;+ this.shiftDown(0);+ }+}++/**+ * Returns the kth largest element from the given list using a min heap.+ * @param {number[]} list The list of numbers.+ * @param {number} k The value of k.+ * @returns The kth largest element.+ */+export const getLargestK = (list: number[], k: number) => {+ const minHeap = new MinHeap();+ for (const item of list) {+ minHeap.insert(item);+ if (minHeap.size() > k) {+ minHeap.pop();+ }+ }+ return minHeap.heap;+};++/**+ * Returns the kth smallest element from the given list using a max heap.+ * @param {number[]} list The list of numbers.+ * @param {number} k The value of k.+ * @returns The kth smallest element.+ */+export const getSmallestK = (list: number[], k: number) => {+ const max = new MaxHeap();+ for (const item of list) {+ max.insert(item);+ if (max.size() > k) {+ max.pop();+ }+ }+ return max.heap;+};diff --git a/packages/sheets-table/src/model/table-column.ts b/packages/sheets-table/src/model/table-column.tsnew file mode 100644index 0000000000..ed8eb9050f--- /dev/null+++ b/packages/sheets-table/src/model/table-column.ts@@ -0,0 +1,68 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IStyleData } from '@univerjs/core';+import type { TableMetaType } from '../types/type';+import { TableColumnDataTypeEnum } from '../types/enum';++export class TableColumn {+ dataType: TableColumnDataTypeEnum;+ id: string;+ displayName: string;+ formula: string;+ meta: TableMetaType;+ style: IStyleData;+ constructor(id: string, name: string) {+ this.id = id;+ this.displayName = name;+ this.dataType = TableColumnDataTypeEnum.String;+ this.formula = '';+ this.meta = {};+ this.style = {};+ }++ getMeta() {+ return this.meta;+ }++ setMeta(meta: TableMetaType) {+ this.meta = meta;+ }++ getDisplayName() {+ return this.displayName;+ }++ toJSON() {+ return {+ id: this.id,+ displayName: this.displayName,+ dataType: this.dataType,+ formula: this.formula,+ meta: this.meta,+ style: this.style,+ };+ }++ fromJSON(json: any) {+ this.id = json.id;+ this.displayName = json.displayName;+ this.dataType = json.dataType;+ this.formula = json.formula;+ this.meta = json.meta;+ this.style = json.style;+ }+}diff --git a/packages/sheets-table/src/model/table-filter.ts b/packages/sheets-table/src/model/table-filter.tsnew file mode 100644index 0000000000..928d1451cc--- /dev/null+++ b/packages/sheets-table/src/model/table-filter.ts@@ -0,0 +1,156 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICellData, Nullable, Worksheet } from '@univerjs/core';+import type { SheetsTableButtonStateEnum } from '../types/enum';+import type { ICalculatedOptions, ITableFilterItem, ITableFilterJSON, ITableRange } from '../types/type';+import { SheetsTableSortStateEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum } from '../types/enum';+import { getTableFilterState, isConditionFilter } from '../util';+import { getCellValueWithConditionType, getConditionExecuteFunc, isNumberDynamicFilter } from './filter-util/condition';++export class TableFilters {+ private _tableColumnFilterList: (ITableFilterItem | undefined)[];+ private _tableSortInfo: { columnIndex: number; sortState: SheetsTableSortStateEnum };+ private _filterOutRows: Set<number>;+ constructor() {+ this._tableColumnFilterList = [];+ }++ setColumnFilter(columnIndex: number, filter: ITableFilterItem | undefined) {+ if (!filter) {+ this._tableColumnFilterList[columnIndex] = undefined;+ } else {+ this._tableColumnFilterList[columnIndex] = filter;+ }+ }++ setSortState(columnIndex: number, sortState: SheetsTableSortStateEnum) {+ this._tableSortInfo = { columnIndex, sortState };+ }++ getColumnFilter(columnIndex: number): ITableFilterItem | undefined {+ return this._tableColumnFilterList[columnIndex];+ }++ getFilterState(columnIndex: number): SheetsTableButtonStateEnum {+ const sortState = this._tableSortInfo?.columnIndex === columnIndex ? this._tableSortInfo.sortState : SheetsTableSortStateEnum.None;+ return getTableFilterState(this._tableColumnFilterList[columnIndex], sortState);+ }++ getSortState() {+ return this._tableSortInfo ?? {};+ }++ getFilterStates(range: ITableRange): SheetsTableButtonStateEnum[] {+ const states = [];+ const { startColumn, endColumn } = range;+ for (let i = startColumn; i <= endColumn; i++) {+ states.push(this.getFilterState(i - startColumn));+ }+ return states;+ }++ getFilterOutRows() {+ return this._filterOutRows;+ }++ doFilter(sheet: Worksheet, range: ITableRange) {+ const filterOutRows = new Set<number>();+ const tableColumnFilterList = this._tableColumnFilterList;+ for (let i = 0; i < tableColumnFilterList.length; i++) {+ const filter = tableColumnFilterList[i];+ if (filter) {+ this.doColumnFilter(sheet, range, i, filterOutRows);+ }+ }+ this._filterOutRows = filterOutRows;+ return filterOutRows;+ }++ doColumnFilter(sheet: Worksheet, range: ITableRange, columnIndex: number, filterOutRows: Set<number>) {+ const filter = this._tableColumnFilterList[columnIndex];+ if (filter && sheet) {+ const { startRow, endRow, startColumn } = range;+ const column = startColumn + columnIndex;+ const executeFunc = this.getExecuteFunc(sheet, range, columnIndex, filter);+ for (let row = startRow; row <= endRow; row++) {+ // const cellValue = sheet.getCell(row, column);+ const conditionType = isConditionFilter(filter) ? filter.filterInfo.conditionType : TableConditionTypeEnum.String;+ const cellValue = getCellValueWithConditionType(sheet, row, column, conditionType);+ if (cellValue === null) {+ filterOutRows.add(row);+ } else if (!executeFunc(getCellValueWithConditionType(sheet, row, column, conditionType))) {+ filterOutRows.add(row);+ }+ }+ }+ }++ private _getNumberCalculatedOptions(sheet: Worksheet, range: ITableRange, columnIndex: number): ICalculatedOptions {+ const { startRow, endRow, startColumn } = range;+ const column = startColumn + columnIndex;+ const list = [];+ let count = 0;+ let sum = 0;+ for (let row = startRow; row <= endRow; row++) {+ const val = getCellValueWithConditionType(sheet, row, column, TableConditionTypeEnum.Number) as number;+ if (val !== null) {+ list.push(val);+ count++;+ sum += val;+ }+ }+ return {+ list,+ average: count > 0 ? sum / count : 0,+ };+ }++ getExecuteFunc(sheet: Worksheet, range: ITableRange, columnIndex: number, filter: ITableFilterItem): (value: any) => boolean {+ if (filter.filterType === TableColumnFilterTypeEnum.manual) {+ const valuesSet = new Set(filter.values);+ return (value: string) => {+ return valuesSet.has(value);+ };+ } else if (filter.filterType === TableColumnFilterTypeEnum.condition) {+ const isDynamic = isNumberDynamicFilter(filter.filterInfo.compareType);+ const calculatedOptions = isDynamic ? this._getNumberCalculatedOptions(sheet, range, columnIndex) : undefined;+ return getConditionExecuteFunc(filter, calculatedOptions);+ } else {+ return (value: Nullable<ICellData>) => {+ return true;+ };+ }+ }++ toJSON(): ITableFilterJSON {+ return {+ tableColumnFilterList: this._tableColumnFilterList,+ tableSortInfo: this._tableSortInfo,+ };+ }++ fromJSON(json: ITableFilterJSON) {+ this._tableColumnFilterList = json.tableColumnFilterList ?? [];+ if (json.tableSortInfo) {+ this._tableSortInfo = json.tableSortInfo;+ }+ }++ dispose() {+ this._tableColumnFilterList = [];+ }+}diff --git a/packages/sheets-table/src/model/table-manager.ts b/packages/sheets-table/src/model/table-manager.tsnew file mode 100644index 0000000000..c1f3ac4d9a--- /dev/null+++ b/packages/sheets-table/src/model/table-manager.ts@@ -0,0 +1,437 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IRange, Workbook } from '@univerjs/core';+import type { ITableAddedEvent, ITableDeletedEvent, ITableFilterChangedEvent, ITableFilterItem, ITableInfoWithUnitId, ITableJson, ITableNameChangedEvent, ITableOptions, ITableRange, ITableRangeChangedEvent, ITableRangeRowColOperation, ITableRangeUpdate, ITableRangeWithState, ITableResource, ITableSetConfig, ITableThemeChangedEvent } from '../types/type';+import { Disposable, generateRandomId, Inject, IUniverInstanceService, LocaleService } from '@univerjs/core';+import { getSheetCommandTarget } from '@univerjs/sheets';+import { BehaviorSubject, Subject } from 'rxjs';+import { IRangeOperationTypeEnum } from '../types/type';+import { convertCellDataToString, getColumnName } from '../util';+import { Table } from './table';+import { TableColumn } from './table-column';++export class TableManager extends Disposable {+ private _tableMap: Map<string, Map<string, Table>>;++ private _tableAdd$ = new Subject<ITableAddedEvent>();+ public tableAdd$ = this._tableAdd$.asObservable();++ private _tableDelete$ = new Subject<ITableDeletedEvent>();+ public tableDelete$ = this._tableDelete$.asObservable();++ private _tableNameChanged$ = new Subject<ITableNameChangedEvent>();+ public tableNameChanged$ = this._tableNameChanged$.asObservable();++ private _tableRangeChanged$ = new Subject<ITableRangeChangedEvent>();+ public tableRangeChanged$ = this._tableRangeChanged$.asObservable();++ private _tableThemeChanged$ = new Subject<ITableThemeChangedEvent>();+ public tableThemeChanged$ = this._tableThemeChanged$.asObservable();++ private _tableFilterChanged$ = new Subject<ITableFilterChangedEvent>();+ public tableFilterChanged$ = this._tableFilterChanged$.asObservable();++ private _tableInitStatus = new BehaviorSubject<boolean>(false);+ public tableInitStatus$ = this._tableInitStatus.asObservable();++ constructor(+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,+ @Inject(LocaleService) private readonly _localeService: LocaleService+ ) {+ super();+ this._tableMap = new Map();+ }++ private _ensureUnit(unitId: string) {+ if (!this._tableMap.has(unitId)) {+ this._tableMap.set(unitId, new Map());+ }+ return this._tableMap.get(unitId)!;+ }++ getColumnHeader(unitId: string, subUnitId: string, range: ITableRange, prefixText?: string) {+ const worksheet = this._univerInstanceService.getUnit<Workbook>(unitId)?.getSheetBySheetId(subUnitId);++ const { startRow, startColumn, endColumn } = range;+ const header = [];+ const columnText = prefixText ?? 'Column';+ for (let i = startColumn; i <= endColumn; i++) {+ header.push(convertCellDataToString(worksheet?.getCell(startRow, i)) || getColumnName(i - startColumn + 1, columnText));+ }+ return header;+ }++ /**+ * Add a table to univer.+ * @param {string} unitId The unit id of the table.+ * @param {string} subUnitId The subunit id of the table.+ * @param {string} name The table name, it should be unique in the unit or it will be appended with a number.+ * @param {ITableRange} range The range of the table, it contains the unit id and subunit id.+ * @param {ITableOptions} [options] Other options of the table.+ * @returns {string} The table id.+ */+ addTable(unitId: string, subUnitId: string, name: string, range: ITableRange, header?: string[], initId?: string, options?: ITableOptions): string {+ const id = initId ?? generateRandomId();+ const tableHeader = header || this.getColumnHeader(unitId, subUnitId, range);+ const table = new Table(id, name, range, tableHeader, options);+ // set subunit id to table+ table.setSubunitId(subUnitId);+ const unitMap = this._ensureUnit(unitId);+ unitMap.set(id, table);+ this._tableAdd$.next({+ unitId,+ subUnitId,+ range,+ tableName: name,+ tableId: id,+ });++ return id;+ }++ addFilter(unitId: string, tableId: string, column: number, filter: ITableFilterItem | undefined) {+ const table = this.getTable(unitId, tableId);+ if (table) {+ const tableFilter = table.getTableFilters();+ tableFilter.setColumnFilter(column, filter);+ const subUnitId = table.getSubunitId();+ this._tableFilterChanged$.next({+ unitId,+ subUnitId,+ tableId,+ });+ }+ }++ getFilterRanges(unitId: string, subUnitId: string): IRange[] {+ const unitMap = this._tableMap.get(unitId);+ if (!unitMap) {+ return [];+ }+ const filterRanges: IRange[] = [];+ unitMap.forEach((table) => {+ if (table.getSubunitId() === subUnitId && table.isShowHeader()) {+ filterRanges.push(table.getRange());+ }+ });+ return filterRanges;+ }++ getSheetFilterRangeWithState(unitId: string, subUnitId: string): ITableRangeWithState[] {+ const unitMap = this._tableMap.get(unitId);+ if (!unitMap) {+ return [];+ }+ const filterRanges: ITableRangeWithState[] = [];+ unitMap.forEach((table) => {+ if (table.getSubunitId() === subUnitId && table.isShowHeader()) {+ filterRanges.push({+ tableId: table.getId(),+ range: table.getRange(),+ states: table.getFilterStates(table.getRange()),+ });+ }+ });+ return filterRanges;+ }++ getTable(unitId: string, tableId: string) {+ const unitMap = this._tableMap.get(unitId);+ if (!unitMap) {+ return undefined;+ }+ return unitMap.get(tableId);+ }++ /**+ * Get the unique table name, in excel, the table name should be unique because it is used as a reference.+ * @param {string} unitId The unit id of the table.+ * @param {string} baseName The base name of the table.+ * @returns {string} The unique table name+ */+ getUniqueTableName(unitId: string, baseName: string) {+ const unitMap = this._tableMap.get(unitId);+ if (!unitMap) {+ return baseName;+ }+ const tableNamesSet = new Set(Array.from(unitMap.values()).map((table) => table.getDisplayName()));+ let newName = baseName;+ let count = 1;+ while (tableNamesSet.has(newName)) {+ newName = `${baseName}-${count}`;+ count++;+ }+ return newName;+ }++ /**+ * Get table by unit id and table id.+ * @param {string} unitId The unit id of the table.+ * @param {string} tableId The table id.+ * @returns {Table} The table.+ */+ getTableById(unitId: string, tableId: string) {+ return this.getTable(unitId, tableId);+ }++ getTableList(unitId: string): ITableInfoWithUnitId[] {+ const unitMap = this._tableMap.get(unitId);+ if (!unitMap) {+ return [] as ITableInfoWithUnitId[];+ }+ return Array.from(unitMap.values()).map((table) => {+ return { ...table.getTableInfo(), unitId };+ });+ }++ /**+ * Get the table list by unit id and subunit id.+ * @param {string} unitId The unit id of the table.+ * @param {string} subUnitId The subunit id of the table.+ * @returns {Table[]} The table list.+ */+ getTablesBySubunitId(unitId: string, subUnitId: string) {+ const unitMap = this._tableMap.get(unitId);+ if (!unitMap) {+ return [];+ }+ return Array.from(unitMap.values()).filter((table) => table.getSubunitId() === subUnitId);+ }++ getTablesInfoBySubunitId(unitId: string, subUnitId: string) {+ return this.getTablesBySubunitId(unitId, subUnitId).map((table) => {+ return {+ id: table.getId(),+ name: table.getDisplayName(),+ range: table.getRange(),+ };+ });+ }++ deleteTable(unitId: string, tableId: string) {+ const unitMap = this._tableMap.get(unitId);+ const table = unitMap?.get(tableId);+ if (table) {+ const tableInfo = table.getTableInfo();+ const tableStyleId = table.getTableStyleId();+ unitMap?.delete(tableId);+ const { subUnitId, range, name } = tableInfo;+ this._tableDelete$.next({+ unitId,+ subUnitId,+ tableId,+ range,+ tableName: name,+ tableStyleId,+ });+ }+ }++ operationTableRowCol(unitId: string, tableId: string, config: ITableRangeRowColOperation) {+ const table = this.getTableById(unitId, tableId);+ if (!table) return;+ const { operationType, rowColType, index, count, columnsJson } = config;+ const oldRange = table.getRange();+ const newRange = { ...oldRange };+ if (operationType === IRangeOperationTypeEnum.Insert) {+ if (rowColType === 'row') {+ newRange.endRow += count;+ } else if (rowColType === 'column') {+ newRange.endColumn += count;++ for (let i = 0; i < count; i++) {+ // There is no need to enforce column name uniqueness.+ const columnPrefix = this._localeService.t('sheets-table.columnPrefix');+ const column = new TableColumn(generateRandomId(), getColumnName(table.getColumnsCount() + 1 + i, columnPrefix));+ if (columnsJson?.[i]) {+ column.fromJSON(columnsJson[i]);+ }+ const columnIndex = index + i - oldRange.startColumn;+ table.insertColumn(columnIndex, column);+ }+ }+ } else {+ if (rowColType === 'row') {+ newRange.endRow -= count;+ } else if (rowColType === 'column') {+ newRange.endColumn -= count;+ // Remove columns from the end to avoid index shifting+ for (let i = count - 1; i >= 0; i--) {+ const columnIndex = index + i - oldRange.startColumn;+ table.removeColumn(columnIndex);+ }+ }+ }++ table.setRange(newRange);+ this._tableRangeChanged$.next({+ unitId,+ subUnitId: table.getSubunitId(),+ tableId,+ range: newRange,+ oldRange,+ });+ }++ updateTableRange(unitId: string, tableId: string, config: ITableRangeUpdate) {+ const table = this.getTableById(unitId, tableId);+ if (!table) return;+ const oldRange = table.getRange();+ const newRange = config.newRange;+ if (newRange.startColumn < oldRange.startColumn) {+ const diff = oldRange.startColumn - newRange.startColumn;+ const columnPrefix = this._localeService.t('sheets-table.columnPrefix');+ for (let i = 0; i < diff; i++) {+ table.insertColumn(oldRange.startColumn, new TableColumn(generateRandomId(), getColumnName(table.getColumnsCount() + 1, columnPrefix)));+ }+ } else if (newRange.startColumn > oldRange.startColumn) {+ const diff = newRange.startColumn - oldRange.startColumn;+ for (let i = diff - 1; i >= 0; i--) {+ const columnIndex = newRange.startColumn + i - oldRange.startColumn;+ table.removeColumn(columnIndex);+ }+ }++ if (newRange.endColumn < oldRange.endColumn) {+ const diff = oldRange.endColumn - newRange.endColumn;+ for (let i = diff - 1; i >= 0; i--) {+ const columnIndex = newRange.endColumn + i - oldRange.startColumn;+ table.removeColumn(columnIndex);+ }+ } else if (newRange.endColumn > oldRange.endColumn) {+ const diff = newRange.endColumn - oldRange.endColumn;+ for (let i = 0; i < diff; i++) {+ table.insertColumn(oldRange.endColumn, new TableColumn(generateRandomId(), getColumnName(table.getColumnsCount() + 1, 'Column')));+ }+ }++ table.setRange(newRange);+ this._tableRangeChanged$.next({+ unitId,+ subUnitId: table.getSubunitId(),+ tableId,+ range: newRange,+ oldRange,+ });+ }++ setTableByConfig(unitId: string, tableId: string, config: ITableSetConfig) {+ const unitMap = this._tableMap.get(unitId);+ const table = unitMap?.get(tableId);+ if (!table) return;+ const subUnitId = table.getSubunitId();+ const { name, updateRange, rowColOperation, theme, options } = config;+ if (name) {+ const oldTableName = table.getDisplayName();+ table.setDisplayName(name);+ this._tableNameChanged$.next({+ unitId,+ subUnitId,+ tableId,+ tableName: name,+ oldTableName,+ });+ }+ if (rowColOperation) {+ this.operationTableRowCol(unitId, tableId, rowColOperation);+ }+ if (updateRange) {+ this.updateTableRange(unitId, tableId, updateRange);+ }+ if (theme) {+ const oldTheme = table.getTableStyleId() ?? 'default';+ table.setTableStyleId(theme);+ this._tableThemeChanged$.next({+ unitId,+ subUnitId,+ tableId,+ theme,+ oldTheme,+ });+ }++ if (options) {+ if (options.showHeader !== undefined) {+ table.setShowHeader(options.showHeader);+ }+ }+ }++ toJSON(unitId: string): ITableResource {+ const result: ITableResource = {};+ const unitMap = this._tableMap.get(unitId);+ if (unitMap) {+ unitMap.forEach((table) => {+ const subUnitId = table.getSubunitId();+ if (!result[subUnitId]) {+ result[subUnitId] = [] as ITableJson[];+ }+ result[subUnitId].push(table.toJSON());+ });+ }+ return result;+ }++ fromJSON(unitId: string, data: ITableResource) {+ const unitMap = this._ensureUnit(unitId);+ const subUnitIds = Object.keys(data);+ subUnitIds.forEach((subUnitId) => {+ const target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId });+ if (!target) {+ return;+ }+ const sheet = target.worksheet;+ const tables = data[subUnitId];+ tables.forEach((table) => {+ const header = this.getColumnHeader(unitId, subUnitId, table.range);+ const tableInstance = new Table(table.id, table.name, table.range, header, table.options);+ tableInstance.setTableMeta(table.meta);+ if (table.columns.length) {+ tableInstance.setColumns(table.columns);+ }+ if (table.filters) {+ const tableFilter = tableInstance.getTableFilters();+ tableFilter.fromJSON(table.filters);+ tableFilter.doFilter(sheet, tableInstance.getTableFilterRange());+ }+ tableInstance.setSubunitId(subUnitId);+ unitMap.set(table.id, tableInstance);+ this._tableAdd$.next({+ unitId,+ subUnitId,+ range: table.range,+ tableName: table.name,+ tableId: table.id,+ });+ });+ });+ this._tableInitStatus.next(true);+ }++ deleteUnitId(unitId: string) {+ this._tableMap.delete(unitId);+ }++ override dispose() {+ super.dispose();+ this._tableMap.forEach((unitMap) => {+ unitMap.forEach((table) => table.dispose());+ unitMap.clear();+ });+ this._tableMap.clear();+ }+}diff --git a/packages/sheets-table/src/model/table.ts b/packages/sheets-table/src/model/table.tsnew file mode 100644index 0000000000..269ce0d6b6--- /dev/null+++ b/packages/sheets-table/src/model/table.ts@@ -0,0 +1,296 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ITableColumnJson, ITableFilterItem, ITableInfo, ITableJson, ITableOptions, ITableRange } from '../types/type';+import { generateRandomId } from '@univerjs/core';+import { tableThemeConfig } from '../controllers/table-theme.factory';+import { TableColumn } from './table-column';+import { TableFilters } from './table-filter';++export class Table {+ private _id: string;+ private _name: string;+ /**+ * @property {string} tableStyleId The table style id. If the property is empty, the default style will be used.+ */+ private _tableStyleId?: string;+ private _showHeader: boolean;+ private _showFooter: boolean;+ private _range: ITableRange;+ private _columns: Map<string, TableColumn> = new Map();+ private _columnOrder: string[] = [];+ tableMeta: Record<string, any>;+ private _tableFilters: TableFilters;++ private _subUnitId: string;++ constructor(id: string, name: string, range: ITableRange, header: string[], options: ITableOptions = {}) {+ this._id = id;+ this._range = range;+ this._name = name;+ this._tableFilters = new TableFilters();+ this._init(header, options);+ }++ _init(header: string[], options: ITableOptions) {+ this._tableStyleId = options?.tableStyleId;+ this._showHeader = options?.showHeader ?? true;+ // Summarization is not supported yet. Footer is not displayed yet.+ this._showFooter = false;+ // init table columns+ if (options.columns) {+ options.columns.forEach((column) => {+ const id = column.id || generateRandomId();+ const tableColumn = new TableColumn(id, column.displayName);+ tableColumn.fromJSON(column);+ this._columns.set(id, tableColumn);+ this._columnOrder.push(id);+ });+ } else {+ const range = this.getRange();+ const startColumn = range.startColumn;+ const endColumn = range.endColumn;+ for (let i = startColumn; i <= endColumn; i++) {+ const id = generateRandomId();++ const column = new TableColumn(id, header[i - startColumn]);+ this._columns.set(id, column);+ this._columnOrder.push(id);+ }+ }++ // this._tableFilters = new TableFilters();++ if (options.filters) {+ const filters = options.filters;+ filters.forEach((filter, index) => {+ if (filter) {+ this._tableFilters.setColumnFilter(index, filter);+ }+ });+ }+ }++ setTableFilterColumn(columnIndex: number, filter: ITableFilterItem) {+ this._tableFilters.setColumnFilter(columnIndex, filter);+ }++ getTableFilterColumn(columnIndex: number) {+ return this._tableFilters.getColumnFilter(columnIndex);+ }++ getTableFilters() {+ return this._tableFilters;+ }++ getTableFilterRange() {+ const tableRange = this.getRange();+ const showHeader = this.isShowHeader();+ const isShowFooter = this.isShowFooter();+ const { startRow, startColumn, endRow, endColumn } = tableRange;+ const start = showHeader ? startRow + 1 : startRow;+ const end = isShowFooter ? endRow - 1 : endRow;+ return {+ startRow: start,+ startColumn,+ endRow: end,+ endColumn,+ };+ }++ setColumns(columns: ITableColumnJson[]) {+ this._columns.clear();+ this._columnOrder = [];+ columns.forEach((columnJson) => {+ const column = new TableColumn(columnJson.id, columnJson.displayName);+ column.fromJSON(columnJson);+ this._columns.set(columnJson.id, column);+ this._columnOrder.push(columnJson.id);+ });+ }++ getColumnsCount() {+ return this._columnOrder.length;+ }++ insertColumn(index: number, column: TableColumn) {+ const columnId = column.id;+ this._columns.set(columnId, column);+ this._columnOrder.splice(index, 0, columnId);+ }++ removeColumn(index: number) {+ const columnId = this._columnOrder[index];+ this._columns.delete(columnId);+ this._columnOrder.splice(index, 1);+ }++ setTableMeta(meta: Record<string, any>) {+ this.tableMeta = meta;+ }++ getTableMeta() {+ return this.tableMeta;+ }++ getColumn(columnId: string) {+ return this._columns.get(columnId);+ }++ getTableColumnByIndex(index: number) {+ const id = this._columnOrder[index];+ return this.getColumn(id);+ }++ getColumnNameByIndex(index: number) {+ const id = this._columnOrder[index];+ return this.getColumn(id)?.getDisplayName() || '';+ }++ getId() {+ return this._id;+ }++ getRangeInfo() {+ return {+ ...this._range,+ };+ }++ getRange() {+ return { ...this._range };+ }++ setRange(range: ITableRange) {+ this._range = range;+ }++ setDisplayName(name: string) {+ this._name = name;+ }++ getDisplayName() {+ return this._name;+ }++ getSubunitId() {+ return this._subUnitId;+ }++ setSubunitId(subUnitId: string) {+ this._subUnitId = subUnitId;+ }++ getTableStyleId() {+ return this._tableStyleId ?? tableThemeConfig[0].name;+ }++ setTableStyleId(tableStyleId: string) {+ this._tableStyleId = tableStyleId;+ }++ isShowHeader() {+ return this._showHeader ?? true;+ }++ setShowHeader(showHeader: boolean) {+ this._showHeader = showHeader;+ }++ isShowFooter() {+ return this._showFooter ?? false;+ }++ getTableInfo(): ITableInfo {+ return {+ id: this._id,+ subUnitId: this._subUnitId,+ name: this._name,+ range: this.getRangeInfo(),+ meta: this.tableMeta,+ showHeader: this._showHeader,+ columns: this._columnOrder.map((columnId) => this._columns.get(columnId)!.toJSON()),+ };+ }++ getTableConfig() {+ return {+ name: this.getDisplayName(),+ range: this.getRangeInfo(),+ options: {+ showHeader: this._showHeader,+ showFooter: this._showFooter,+ },+ tableStyleId: this._tableStyleId,+ };+ }++ getFilterStates(range: ITableRange) {+ return this._tableFilters.getFilterStates(range);+ }++ toJSON(): ITableJson {+ const columns: ITableColumnJson[] = [];+ this._columns.forEach((column) => {+ columns.push(column.toJSON());+ });+ return {+ id: this._id,+ name: this._name,+ range: this.getRangeInfo(),+ options: {+ showHeader: this._showHeader,+ showFooter: this._showFooter,+ tableStyleId: this._tableStyleId,+ },+ // TODO: support filter+ filters: this._tableFilters.toJSON(),+ columns,+ meta: this.tableMeta,+ };+ }++ fromJSON(json: ITableJson) {+ this._id = json.id;+ this._name = json.name;+ this._range = json.range;+ this.tableMeta = json.meta;+ this._tableStyleId = json.options.tableStyleId || '';+ this._showHeader = json.options.showHeader || true;+ this._showFooter = json.options.showFooter || true;+ const columns = json.columns;+ columns.forEach((column) => {+ const tableColumn = new TableColumn(column.id, column.displayName);+ tableColumn.fromJSON(column);+ this._columns.set(column.id, tableColumn);+ this._columnOrder.push(column.id);+ });+ this._tableFilters = new TableFilters();+ this._tableFilters.fromJSON(json.filters);+ }++ dispose() {+ this._id = '';+ this._name = '';+ this._tableStyleId = '';+ this._showHeader = true;+ this._showFooter = true;+ // @ts-ignore+ delete this._range;+ this._columns.clear();+ this._columnOrder = [];+ }+}diff --git a/packages/sheets-table/src/plugin.ts b/packages/sheets-table/src/plugin.tsnew file mode 100644index 0000000000..0039d453cd--- /dev/null+++ b/packages/sheets-table/src/plugin.ts@@ -0,0 +1,96 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { ICommandService, Inject, Injector, Plugin, registerDependencies, touchDependencies, UniverInstanceType } from '@univerjs/core';+import { AddSheetTableCommand } from './commands/commands/add-sheet-table.command';+import { AddTableThemeCommand } from './commands/commands/add-table-theme.command';+import { DeleteSheetTableCommand } from './commands/commands/delete-sheet-table.command';+import { RemoveTableThemeCommand } from './commands/commands/remove-table-theme.command';+import { SetSheetTableCommand } from './commands/commands/set-sheet-table.command';+import { SetSheetTableFilterCommand } from './commands/commands/set-table-filter.command';+import { SheetTableInsertColCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveRowCommand } from './commands/commands/sheet-table-row-col.command';+import { AddSheetTableMutation } from './commands/mutations/add-sheet-table.mutation';+import { DeleteSheetTableMutation } from './commands/mutations/delete-sheet-table.mutation';+import { SetSheetTableMutation } from './commands/mutations/set-sheet-table.mutation';+import { SetSheetTableFilterMutation } from './commands/mutations/set-table-filter.mutation';+import { PLUGIN_NAME } from './const';+import { SheetTableRangeController } from './controllers/sheet-table-range.controller';+import { SheetTableRefRangeController } from './controllers/sheet-table-ref-range.controller';+import { SheetsTableThemeController } from './controllers/sheet-table-theme.controller';+import { SheetsTableController } from './controllers/sheets-table.controller';+import { TableFilterController } from './controllers/table-filter.controller';+import { TableManager } from './model/table-manager';+import { SheetTableService } from './services/table-service';++export class UniverSheetTablePlugin extends Plugin {+ static override pluginName = PLUGIN_NAME;+ static override type = UniverInstanceType.UNIVER_SHEET;++ constructor(+ private readonly _config = {},+ @Inject(Injector) protected override _injector: Injector,+ @Inject(ICommandService) private _commandService: ICommandService+ ) {+ super();+ this._initRegisterCommand();+ }++ override onStarting(): void {+ registerDependencies(this._injector, [+ [TableManager],+ [SheetsTableThemeController],+ [SheetsTableController],+ [SheetTableService],+ [TableFilterController],+ [SheetTableRangeController],+ [SheetTableRefRangeController],+ ]);++ touchDependencies(this._injector, [+ [SheetTableRangeController],+ [SheetTableRefRangeController],+ [SheetsTableThemeController],+ [SheetsTableController],+ [SheetTableService],+ [TableFilterController],+ ]);+ }++ override onReady(): void {+ touchDependencies(this._injector, [+ [TableManager],+ ]);+ }++ private _initRegisterCommand() {+ [+ AddSheetTableCommand,+ AddSheetTableMutation,+ DeleteSheetTableCommand,+ DeleteSheetTableMutation,+ SetSheetTableFilterMutation,+ SetSheetTableFilterCommand,+ SetSheetTableCommand,+ SetSheetTableMutation,+ AddTableThemeCommand,+ RemoveTableThemeCommand,+ SheetTableInsertRowCommand,+ SheetTableInsertColCommand,+ SheetTableRemoveRowCommand,+ SheetTableRemoveColCommand,+ ].forEach((m) => this._commandService.registerCommand(m));+ }+}diff --git a/packages/sheets-table/src/services/table-service.ts b/packages/sheets-table/src/services/table-service.tsnew file mode 100644index 0000000000..75da49123f--- /dev/null+++ b/packages/sheets-table/src/services/table-service.ts@@ -0,0 +1,77 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Worksheet } from '@univerjs/core';+import type { ITableFilterItem, ITableInfoWithUnitId, ITableOptions, ITableRange, TableMetaType } from '../types/type';+import { Disposable, Inject } from '@univerjs/core';+import { getCellValueWithConditionType } from '../model/filter-util/condition';+import { TableManager } from '../model/table-manager';+import { TableConditionTypeEnum } from '../types/enum';++export class SheetTableService extends Disposable {+ constructor(+ @Inject(TableManager) private _tableManager: TableManager+ ) {+ super();+ }++ getTableInfo(unitId: string, tableId: string): ITableInfoWithUnitId | undefined {+ const table = this._tableManager.getTable(unitId, tableId);+ if (!table) {+ return;+ }+ return {+ unitId,+ ...table.getTableInfo(),+ };+ }++ getTableList(unitId: string): ITableInfoWithUnitId[] {+ return this._tableManager.getTableList(unitId);+ }++ addTable(unitId: string, subUnitId: string, tableName: string, rangeInfo: ITableRange, tableHeader?: string[], tableId?: string, options?: ITableOptions): string {+ return this._tableManager.addTable(unitId, subUnitId, tableName, rangeInfo, tableHeader, tableId, options);+ }++ deleteTable(unitId: string, subUnitId: string, tableId: string) {+ this._tableManager.deleteTable(unitId, tableId);+ }++ getTableMeta(unitId: string, tableId: string): TableMetaType | undefined {+ return this._tableManager.getTable(unitId, tableId)?.getTableMeta();+ }++ setTableMeta(unitId: string, tableId: string, meta: TableMetaType) {+ this._tableManager.getTable(unitId, tableId)?.setTableMeta(meta);+ }++ getTableColumnMeta(unitId: string, tableId: string, index: number): TableMetaType | undefined {+ return this._tableManager.getTable(unitId, tableId)?.getTableColumnByIndex(index)?.getMeta();+ }++ selTableColumnMeta(unitId: string, tableId: string, index: number, meta: TableMetaType) {+ this._tableManager.getTable(unitId, tableId)?.getTableColumnByIndex(index)?.setMeta(meta);+ }++ addFilter(unitId: string, tableId: string, column: number, filter: ITableFilterItem) {+ this._tableManager.addFilter(unitId, tableId, column, filter);+ }++ getCellValueWithConditionType(sheet: Worksheet, row: number, col: number, conditionType: TableConditionTypeEnum = TableConditionTypeEnum.String) {+ return getCellValueWithConditionType(sheet, row, col, conditionType);+ }+}diff --git a/packages/sheets-table/src/types/enum.ts b/packages/sheets-table/src/types/enum.tsnew file mode 100644index 0000000000..b98eb5047a--- /dev/null+++ b/packages/sheets-table/src/types/enum.ts@@ -0,0 +1,128 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export enum TableColumnDataTypeEnum {+ None = 'none',+ String = 'string',+ Number = 'number',+ Date = 'date',+ Bool = 'bool',+ Checkbox = 'checkbox',+ List = 'list',+};++export enum TableColumnFilterTypeEnum {+ manual = 'manual',+ condition = 'condition',+}++export enum TableConditionTypeEnum {+ Date = 'date',+ Number = 'number',+ String = 'string',+ Logic = 'logic',+}++export enum TableNumberCompareTypeEnum {+ Equal = 'equal',+ NotEqual = 'notEqual',+ GreaterThan = 'greaterThan',+ GreaterThanOrEqual = 'greaterThanOrEqual',+ LessThan = 'lessThan',+ LessThanOrEqual = 'lessThanOrEqual',+ Between = 'between',+ NotBetween = 'notBetween',+ Above = 'above',+ Below = 'below',+ TopN = 'topN',+}++export enum TableStringCompareTypeEnum {+ Equal = 'equal',+ NotEqual = 'notEqual',+ Contains = 'contains',+ NotContains = 'notContains',+ StartsWith = 'startsWith',+ EndsWith = 'endsWith',+}++export enum TableDateCompareTypeEnum {+ Equal = 'equal',+ NotEqual = 'notEqual',+ After = 'after',+ AfterOrEqual = 'afterOrEqual',+ Before = 'before',+ BeforeOrEqual = 'beforeOrEqual',+ Between = 'between',+ NotBetween = 'notBetween',++ Today = 'today',+ Yesterday = 'yesterday',+ Tomorrow = 'tomorrow',+ ThisWeek = 'thisWeek',+ LastWeek = 'lastWeek',+ NextWeek = 'nextWeek',+ ThisMonth = 'thisMonth',+ LastMonth = 'lastMonth',+ NextMonth = 'nextMonth',+ ThisQuarter = 'thisQuarter',+ LastQuarter = 'lastQuarter',+ NextQuarter = 'nextQuarter',+ ThisYear = 'thisYear',+ LastYear = 'lastYear',+ NextYear = 'nextYear',+ // YTD+ YearToDate = 'yearToDate',++ Quarter = 'quarter',+ Month = 'month',++ M1 = 'm1',+ M2 = 'm2',+ M3 = 'm3',+ M4 = 'm4',+ M5 = 'm5',+ M6 = 'm6',+ M7 = 'm7',+ M8 = 'm8',+ M9 = 'm9',+ M10 = 'm10',+ M11 = 'm11',+ M12 = 'm12',++ Q1 = 'q1',+ Q2 = 'q2',+ Q3 = 'q3',+ Q4 = 'q4',+}++/**+ * Represents the pivot cell style type enum+ */+export enum SheetsTableButtonStateEnum {+ FilteredSortNone = 1,+ FilteredSortAsc = 2,+ FilteredSortDesc = 3,+ FilterNoneSortNone = 4,+ FilterNoneSortAsc = 5,+ FilterNoneSortDesc = 6,+}++export enum SheetsTableSortStateEnum {+ Asc = 'asc',+ Desc = 'desc',+ None = 'none',+}diff --git a/packages/sheets-table/src/types/type.ts b/packages/sheets-table/src/types/type.tsnew file mode 100644index 0000000000..bbbfb3fc3a--- /dev/null+++ b/packages/sheets-table/src/types/type.ts@@ -0,0 +1,249 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IRange, IStyleData, Nullable } from '@univerjs/core';+import type { SheetsTableButtonStateEnum, SheetsTableSortStateEnum, TableColumnDataTypeEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableNumberCompareTypeEnum, TableStringCompareTypeEnum } from './enum';++export interface ITableRange {+ startRow: number;+ startColumn: number;+ endRow: number;+ endColumn: number;+}++export interface ITableOptions {+ showHeader?: boolean;+ showFooter?: boolean;+ tableStyleId?: string;+ hasTotalRow?: boolean;+ columns?: ITableColumnJson[];+ filters?: ITableFilterItem[];+}++export interface ITableFilterJSON {+ tableColumnFilterList?: (ITableFilterItem | undefined)[];+ tableSortInfo?: { columnIndex: number; sortState: SheetsTableSortStateEnum };+}++export type ITableFilterItem = ITableManualFilterItem | ITableConditionFilterItem;+export type TableMetaType = Record<string, any>;++/**+ * Represents the table filter item, filter data by provided values.+ */+export interface ITableManualFilterItem {+ filterType: TableColumnFilterTypeEnum.manual;+ values: string[];+ isAllSelected?: boolean;+}++/**+ * Represents the table filter item, filter data by provided condition rules.+ */+export interface ITableConditionFilterItem {+ filterType: TableColumnFilterTypeEnum.condition;+ filterInfo: ITableDateFilterInfo | ITableStringFilterInfo | ITableNumberFilterInfo | ITableLogicFilterInfo;+}++export interface ITableDateFilterInfo {+ conditionType: TableConditionTypeEnum.Date;+ compareType: TableDateCompareTypeEnum;+ expectedValue: Date | [Date, Date] | undefined;+ anchorTime?: number;+}++export interface ITableStringFilterInfo {+ conditionType: TableConditionTypeEnum.String;+ compareType: TableStringCompareTypeEnum;+ expectedValue: string;+}++export interface ITableNumberFilterInfo {+ conditionType: TableConditionTypeEnum.Number;+ compareType: TableNumberCompareTypeEnum;+ expectedValue: number | [number, number];+}++export interface ITableLogicFilterInfo {+ conditionType: TableConditionTypeEnum.Logic;+ compareType: TableNumberCompareTypeEnum;+ expectedValue: (ITableDateFilterInfo | ITableStringFilterInfo | ITableNumberFilterInfo)[];+}++export interface ITableAddedEvent {+ unitId: string;+ subUnitId: string;+ tableId: string;+ tableName: string;+ range: ITableRange;+}++export interface ITableRangeUpdate {+ newRange: IRange;+};++export enum IRangeOperationTypeEnum {+ Insert = 'insert',+ Delete = 'delete',+};++export enum IRowColTypeEnum {+ Row = 'row',+ Col = 'column',+}++export interface ITableRangeRowColOperation {+ operationType: IRangeOperationTypeEnum;+ rowColType: IRowColTypeEnum;+ index: number;+ count: number;+ columnsJson?: ITableColumnJson[];+}++export interface ITableSetConfig {+ name?: string;+ updateRange?: ITableRangeUpdate;+ rowColOperation?: ITableRangeRowColOperation;+ theme?: string;+ options?: {+ showHeader?: boolean;+ };+}++interface ITableBaseEvent {+ unitId: string;+ subUnitId: string;+ tableId: string;+}+export interface ITableNameChangedEvent extends ITableBaseEvent {+ tableName: string;+ oldTableName: string;+}++export interface ITableRangeChangedEvent extends ITableBaseEvent {+ range: ITableRange;+ oldRange: ITableRange;+}++export interface ITableThemeChangedEvent extends ITableBaseEvent {+ theme: string;+ oldTheme: string;+}++export type ITableDeletedEvent = ITableAddedEvent & {+ tableStyleId?: string;+};++export interface ITableRangeChangedEvent {+ unitId: string;+ subUnitId: string;+ tableId: string;+ range: ITableRange;+ oldRange: ITableRange;+}++export interface ITableFilterChangedEvent {+ unitId: string;+ subUnitId: string;+ tableId: string;+}+export interface ITableColumnJson {+ dataType: TableColumnDataTypeEnum;+ id: string;+ displayName: string;+ formula: string;+ meta: TableMetaType;+ style: IStyleData;+}++export interface ITableJson {+ id: string;+ name: string;+ range: ITableRange;+ options: ITableOptions;+ filters: ITableFilterJSON;+ columns: ITableColumnJson[];+ meta: TableMetaType;+}++export interface ITableInfo {+ id: string;+ name: string;+ subUnitId: string;+ range: ITableRange;+ meta: TableMetaType;+ columns: ITableColumnJson[];+ showHeader: boolean;+}++export interface ITableInfoWithUnitId extends ITableInfo {+ unitId: string;+}++export interface ITableResource {+ [subUnitId: string]: ITableJson[];+}++export interface ITableRelationItem {+ tableId: string;+ relationColumnId: string;+}++/**+ * Table relation tuple type, first item is the main table, second item is the sub table+ */+export type TableRelationTupleType = [ITableRelationItem, ITableRelationItem];++export type SubTableColumnItem = ITableColumnJson & { tableId: string };++export interface IDateValue {+ /**+ * @description the date value, it stores the number of seconds since January 1, 1970, 00:00:00 UTC, it is same to excel date value+ */+ v: number;+ /**+ * @description only date type has this property, we can use it to format the date+ */+ f: string;+}+type IBlankValue = null | undefined;++export type IDataFieldValue = string | number | boolean | IDateValue | IBlankValue;++/**+ * Represents the table header information, which save the original column id and display name of table.+ */+export interface IHeadersTableInfoList {+ tableId: string;+ columnId: string;+ displayName: string;+}+export interface ITableData {+ headers: string[];+ headersTableInfoList: IHeadersTableInfoList[];+ data: Nullable<IDataFieldValue>[][];+}++export interface ICalculatedOptions {+ average?: number;+ list?: number[];+}++export interface ITableRangeWithState {+ range: ITableRange;+ states: SheetsTableButtonStateEnum[];+ tableId: string;+}diff --git a/packages/sheets-table/src/util.ts b/packages/sheets-table/src/util.tsnew file mode 100644index 0000000000..030378d32d--- /dev/null+++ b/packages/sheets-table/src/util.ts@@ -0,0 +1,99 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICellData, IDocumentData, Nullable } from '@univerjs/core';+import type { ITableConditionFilterItem, ITableFilterItem, ITableManualFilterItem } from './types/type';+import { CellValueType } from '@univerjs/core';+import { SheetsTableButtonStateEnum, SheetsTableSortStateEnum, TableColumnFilterTypeEnum } from './types/enum';++export function getColumnName(columnIndex: number, columnText: string): string {+ return `${columnText} ${columnIndex}`;+}++const BooleanTrue = 'TRUE';+const BooleanFalse = 'FALSE';+export const getStringFromDataStream = (data: IDocumentData): string => {+ const dataStream = data.body?.dataStream.replace(/\r\n$/, '') || '';+ return dataStream;+};++/**+ * transform cell data to dimension name+ * @param cellData the sheet cell data+ * @param styles workBook styles collection+ * @param patternInfoRecord The cache record for pattern info+ * @returns {string} The dimension name+ */+export function convertCellDataToString(cellData: Nullable<ICellData>): string {+ if (cellData) {+ const { v, t, p } = cellData;+ if (p) {+ return getStringFromDataStream(p);+ }+ if ((t === CellValueType.FORCE_STRING || t === CellValueType.STRING) && v !== undefined && v !== null) {+ return String(v);+ } else if (t === CellValueType.BOOLEAN) {+ return v ? BooleanTrue : BooleanFalse;+ } else if (t === CellValueType.NUMBER) {+ return String(v);+ } else {+ // type not set, guess the type is number+ const type = typeof v;+ if (type === 'boolean') {+ return v ? BooleanTrue : BooleanFalse;+ }+ return v === undefined || v === null ? '' : String(v);+ }+ }+ return '';+}++export function getTableFilterState(tableFilter: ITableFilterItem | undefined, sortState: SheetsTableSortStateEnum): SheetsTableButtonStateEnum {+ const hasFilter = tableFilter !== undefined;+ if (hasFilter) {+ switch (sortState) {+ case SheetsTableSortStateEnum.Asc:+ return SheetsTableButtonStateEnum.FilteredSortAsc;+ case SheetsTableSortStateEnum.Desc:+ return SheetsTableButtonStateEnum.FilteredSortDesc;+ default:+ return SheetsTableButtonStateEnum.FilteredSortNone;+ }+ } else {+ switch (sortState) {+ case SheetsTableSortStateEnum.Asc:+ return SheetsTableButtonStateEnum.FilterNoneSortAsc;+ case SheetsTableSortStateEnum.Desc:+ return SheetsTableButtonStateEnum.FilterNoneSortDesc;+ default:+ return SheetsTableButtonStateEnum.FilterNoneSortNone;+ }+ }+}++export function isConditionFilter(filter: ITableFilterItem | undefined): filter is ITableConditionFilterItem {+ if (!filter) {+ return false;+ }+ return filter.filterType === TableColumnFilterTypeEnum.condition;+}++export function isManualFilter(filter: ITableFilterItem | undefined): filter is ITableManualFilterItem {+ if (!filter) {+ return false;+ }+ return filter.filterType === TableColumnFilterTypeEnum.manual;+}diff --git a/packages/sheets-table/tsconfig.json b/packages/sheets-table/tsconfig.jsonnew file mode 100644index 0000000000..c62210cbad--- /dev/null+++ b/packages/sheets-table/tsconfig.json@@ -0,0 +1,9 @@+{+ "extends": "@univerjs-infra/shared/tsconfigs/base",+ "compilerOptions": {+ "rootDir": "src",+ "outDir": "lib/types"+ },+ "references": [{ "path": "./tsconfig.node.json" }],+ "include": ["src"]+}diff --git a/packages/sheets-table/tsconfig.node.json b/packages/sheets-table/tsconfig.node.jsonnew file mode 100644index 0000000000..4947a09903--- /dev/null+++ b/packages/sheets-table/tsconfig.node.json@@ -0,0 +1,4 @@+{+ "extends": "@univerjs-infra/shared/tsconfigs/node",+ "include": ["vitest.config.ts"]+}diff --git a/packages/sheets-table/vitest.config.ts b/packages/sheets-table/vitest.config.tsnew file mode 100644index 0000000000..af97c6d7a2--- /dev/null+++ b/packages/sheets-table/vitest.config.ts@@ -0,0 +1,3 @@+import createConfig from '@univerjs-infra/shared/vitest';++export default createConfig();diff --git a/packages/sheets-ui/src/commands/commands/set-selection.command.ts b/packages/sheets-ui/src/commands/commands/set-selection.command.tsindex 31b54222a6..c16c465498 100644--- a/packages/sheets-ui/src/commands/commands/set-selection.command.ts+++ b/packages/sheets-ui/src/commands/commands/set-selection.command.ts@@ -14,11 +14,11 @@* limitations under the License.*/-import type { ICommand, IRange } from '@univerjs/core';+import type { ICommand, IMutationInfo, IRange } from '@univerjs/core';import type {ISetSelectionsOperationParams,} from '@univerjs/sheets';-import { CommandType, Direction, ICommandService, IUniverInstanceService, RANGE_TYPE, Rectangle, Tools } from '@univerjs/core';+import { CommandType, Direction, ICommandService, IUniverInstanceService, RANGE_TYPE, Rectangle, sequenceExecute, Tools } from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';import {@@ -28,6 +28,7 @@ import {getSheetCommandTarget,SelectionMoveType,SetSelectionsOperation,+ SheetInterceptorService,} from '@univerjs/sheets';import { KeyCode } from '@univerjs/ui';import { SelectAllService } from '../../services/select-all/select-all.service';@@ -387,6 +388,7 @@ export interface ISelectAllCommandParams {export const SelectAllCommand: ICommand<ISelectAllCommandParams> = {id: 'sheet.command.select-all',type: CommandType.COMMAND,+ // eslint-disable-next-line max-lines-per-functionhandler: async (accessor, params = { expandToGapFirst: true, loop: false }) => {const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));if (!target) return false;@@ -445,16 +447,36 @@ export const SelectAllCommand: ICommand<ISelectAllCommandParams> = {selectAllService.rangesStack.push(destRange);}- return accessor.get(ICommandService).executeCommand(SetSelectionsOperation.id, {- unitId,- subUnitId,- reveal: true,- selections: [- {- range: destRange,- primary, // this remains unchanged- },- ],+ const redos: IMutationInfo[] = [];++ redos.push({+ id: SetSelectionsOperation.id,+ params: {+ unitId,+ subUnitId,+ reveal: true,+ selections: [+ {+ range: destRange,+ primary, // this remains unchanged+ },+ ],+ },+ });++ const sheetInterceptorService = accessor.get(SheetInterceptorService);+ const interceptor = sheetInterceptorService.onCommandExecute({+ id: SelectAllCommand.id,+ params: { range },});++ if (interceptor.redos.length) {+ redos.push(...interceptor.redos);+ }++ const commandService = accessor.get(ICommandService);+ sequenceExecute(redos, commandService);++ return true;},};diff --git a/packages/sheets-ui/src/controllers/menu/delete.menu.ts b/packages/sheets-ui/src/controllers/menu/delete.menu.tsindex 88d651dfe0..1f6515a551 100644--- a/packages/sheets-ui/src/controllers/menu/delete.menu.ts+++ b/packages/sheets-ui/src/controllers/menu/delete.menu.ts@@ -45,7 +45,7 @@ export function RemoveColMenuItemFactory(accessor: IAccessor): IMenuButtonItem {type: MenuItemType.BUTTON,icon: 'DeleteColumn',title: 'rightClick.deleteSelectedColumn',- hidden$: getObservableWithExclusiveRange$(accessor, getDeleteMenuHidden$(accessor, 'col')),+ hidden$: getDeleteMenuHidden$(accessor, 'col'),disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetDeleteColumnPermission] }),};}diff --git a/packages/sheets-ui/src/controllers/menu/merge.menu.ts b/packages/sheets-ui/src/controllers/menu/merge.menu.tsindex ece94b6b79..2ef64b589e 100644--- a/packages/sheets-ui/src/controllers/menu/merge.menu.ts+++ b/packages/sheets-ui/src/controllers/menu/merge.menu.ts@@ -28,10 +28,10 @@ import {AddWorksheetMergeVerticalCommand,} from '../../commands/commands/add-worksheet-merge.command';import { getSheetSelectionsDisabled$ } from '../utils/selections-tools';-import { getCurrentRangeDisable$ } from './menu-util';+import { getCurrentRangeDisable$, getObservableWithExclusiveRange$ } from './menu-util';export function CellMergeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {- const editDisabled$ = getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] });+ const editDisabled$ = getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }));const selectionsHasCross$ = getSheetSelectionsDisabled$(accessor);return {diff --git a/packages/sheets/src/commands/mutations/add-range-theme.mutation.ts b/packages/sheets/src/commands/mutations/add-range-theme.mutation.tsnew file mode 100644index 0000000000..94fb695e0c--- /dev/null+++ b/packages/sheets/src/commands/mutations/add-range-theme.mutation.ts@@ -0,0 +1,45 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IAccessor, IMutation } from '@univerjs/core';+import type { IRangeThemeStyleJSON } from '../../model/range-theme-util';+import { CommandType } from '@univerjs/core';+import { SheetRangeThemeModel } from '../../model/range-theme-model';+import { RangeThemeStyle } from '../../model/range-theme-util';++export interface IAddRangeThemeMutationParams {+ styleJSON: IRangeThemeStyleJSON;+ unitId: string;+ subUnitId: string;+}++export const AddRangeThemeMutation: IMutation<IAddRangeThemeMutationParams> = {+ id: 'sheet.mutation.add-range-theme',+ type: CommandType.MUTATION,+ handler: (accessor: IAccessor, params) => {+ if (!params) {+ return false;+ }+ const { styleJSON, unitId } = params;++ const rangeRuleModel = accessor.get(SheetRangeThemeModel);+ const rangeThemeStyle = new RangeThemeStyle(styleJSON.name);+ rangeThemeStyle.fromJson(styleJSON);+ rangeRuleModel.registerRangeThemeStyle(unitId, rangeThemeStyle);++ return true;+ },+};diff --git a/packages/sheets/src/commands/mutations/remove-range-theme.mutation.ts b/packages/sheets/src/commands/mutations/remove-range-theme.mutation.tsnew file mode 100644index 0000000000..98c879a252--- /dev/null+++ b/packages/sheets/src/commands/mutations/remove-range-theme.mutation.ts@@ -0,0 +1,42 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IMutation } from '@univerjs/core';+import { CommandType } from '@univerjs/core';+import { SheetRangeThemeModel } from '../../model/range-theme-model';++export interface IRemoveRangeThemeMutationParams {+ unitId: string;+ subUnitId: string;+ styleName: string;+}++export const RemoveRangeThemeMutation: IMutation<IRemoveRangeThemeMutationParams> = {+ id: 'sheet.mutation.remove-range-theme',+ type: CommandType.MUTATION,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }++ const { styleName, unitId } = params;++ const rangeRuleModel = accessor.get(SheetRangeThemeModel);+ rangeRuleModel.unregisterRangeThemeStyle(unitId, styleName);++ return true;+ },+};diff --git a/packages/sheets/src/commands/mutations/set-range-theme.mutation.ts b/packages/sheets/src/commands/mutations/set-range-theme.mutation.tsnew file mode 100644index 0000000000..c6f818cb58--- /dev/null+++ b/packages/sheets/src/commands/mutations/set-range-theme.mutation.ts@@ -0,0 +1,58 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IMutation } from '@univerjs/core';+import type { IRangeThemeStyleJSON } from '../../model/range-theme-util';+import { CommandType } from '@univerjs/core';+import { SheetRangeThemeModel } from '../../model/range-theme-model';++export interface ISetRangeThemeMutationParams {+ unitId: string;+ subUnitId: string;+ styleName: string;+ style: Omit<IRangeThemeStyleJSON, 'name'>;+}++export const SetRangeThemeMutation: IMutation<ISetRangeThemeMutationParams> = {+ id: 'sheet.mutation.set-range-theme',+ type: CommandType.MUTATION,+ handler: (accessor, params) => {+ if (!params) {+ return false;+ }++ const { unitId, styleName, style } = params;+ const rangeThemeModel = accessor.get(SheetRangeThemeModel);+ const rangeThemeStyle = rangeThemeModel.getRangeThemeStyle(unitId, styleName);+ if (rangeThemeStyle) {+ if (style.headerRowStyle) {+ rangeThemeStyle.setHeaderRowStyle(style.headerRowStyle);+ }+ if (style.firstRowStyle) {+ rangeThemeStyle.setFirstRowStyle(style.firstRowStyle);+ }+ if (style.secondRowStyle) {+ rangeThemeStyle.setSecondRowStyle(style.secondRowStyle);+ }+ if (style.lastRowStyle) {+ rangeThemeStyle.setLastRowStyle(style.lastRowStyle);+ }+ // TODO add other style+ }++ return true;+ },+};diff --git a/packages/sheets/src/controllers/basic-worksheet.controller.ts b/packages/sheets/src/controllers/basic-worksheet.controller.tsindex cb2aa90588..a279543346 100644--- a/packages/sheets/src/controllers/basic-worksheet.controller.ts+++ b/packages/sheets/src/controllers/basic-worksheet.controller.ts@@ -162,6 +162,9 @@ import { SelectRangeCommand, SetSelectionsOperation } from '../commands/operatioimport { SetWorksheetActiveOperation } from '../commands/operations/set-worksheet-active.operation';import { ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY } from './config';import { MAX_CELL_PER_SHEET_DEFAULT, MAX_CELL_PER_SHEET_KEY } from './config/config';+import { SetRangeThemeMutation } from '../commands/mutations/set-range-theme.mutation';+import { RemoveRangeThemeMutation } from '../commands/mutations/remove-range-theme.mutation';+import { AddRangeThemeMutation } from '../commands/mutations/add-range-theme.mutation';export interface IStyleTypeValue<T> {type: keyof IStyleData;@@ -346,6 +349,10 @@ export class BasicWorksheetController extends Disposable implements IDisposableSetWorksheetRangeThemeStyleCommand,DeleteWorksheetRangeThemeStyleCommand,+ AddRangeThemeMutation,+ SetRangeThemeMutation,+ RemoveRangeThemeMutation,+].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));}diff --git a/packages/sheets/src/controllers/permission/sheet-permission-init.controller.ts b/packages/sheets/src/controllers/permission/sheet-permission-init.controller.tsindex 477701a585..a730e55125 100644--- a/packages/sheets/src/controllers/permission/sheet-permission-init.controller.ts+++ b/packages/sheets/src/controllers/permission/sheet-permission-init.controller.ts@@ -157,7 +157,7 @@ export class SheetPermissionInitController extends Disposable {if (!unitId) {return;}- this._authzIoService.allowed({+ return this._authzIoService.allowed({objectID: unitId,objectType: UnitObject.Workbook,unitID: unitId,diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.tsindex 7d4e320aff..1dd3782bc9 100644--- a/packages/sheets/src/index.ts+++ b/packages/sheets/src/index.ts@@ -56,7 +56,14 @@ export { type IUniverSheetsConfig } from './controllers/config.schema';export { MAX_CELL_PER_SHEET_KEY } from './controllers/config/config';export { BorderStyleManagerService, type IBorderInfo } from './services/border-style-manager.service';export { SheetRangeThemeService } from './services/range-theme-service';+export { SheetRangeThemeModel } from './model/range-theme-model';export type { IRangeThemeStyleJSON } from './model/range-theme-util';+export { AddRangeThemeMutation } from './commands/mutations/add-range-theme.mutation';+export type { IAddRangeThemeMutationParams } from './commands/mutations/add-range-theme.mutation';+export { SetRangeThemeMutation } from './commands/mutations/set-range-theme.mutation';+export type { ISetRangeThemeMutationParams } from './commands/mutations/set-range-theme.mutation';+export { RemoveRangeThemeMutation } from './commands/mutations/remove-range-theme.mutation';+export type { IRemoveRangeThemeMutationParams } from './commands/mutations/remove-range-theme.mutation';export * from './services/permission/permission-point';export { WorksheetPermissionService } from './services/permission/worksheet-permission/worksheet-permission.service';export { WorkbookPermissionService } from './services/permission/workbook-permission/workbook-permission.service';@@ -191,6 +198,7 @@ export { handleInsertRangeMutation } from './commands/utils/handle-range-mutatioexport { type ISheetCommandSharedParams } from './commands/utils/interface';export { copyRangeStyles } from './commands/commands/utils/selection-utils';export { RangeThemeStyle } from './model/range-theme-util';+export type { IRangeThemeStyleItem } from './model/range-theme-util';// #region - all commandsdiff --git a/packages/sheets/src/model/range-theme-model.ts b/packages/sheets/src/model/range-theme-model.tsindex b24590ae28..1b6f5afc8d 100644--- a/packages/sheets/src/model/range-theme-model.ts+++ b/packages/sheets/src/model/range-theme-model.ts@@ -17,10 +17,11 @@import type { ICellDataForSheetInterceptor, IRange, Nullable } from '@univerjs/core';import type { IRangeThemeStyleItem, IRangeThemeStyleJSON } from './range-theme-util';import { Disposable, generateRandomId, Inject, InterceptorEffectEnum, IResourceManagerService, RTree, UniverInstanceType } from '@univerjs/core';+import { Subject } from 'rxjs';import { INTERCEPTOR_POINT, RangeThemeInterceptorId } from '../services/sheet-interceptor/interceptor-const';import { SheetInterceptorService } from '../services/sheet-interceptor/sheet-interceptor.service';-import { RangeThemeStyle } from './range-theme-util';+import { RangeThemeStyle } from './range-theme-util';import { buildInThemes } from './range-themes/build-in-theme.factory';import { defaultRangeThemeStyle, defaultRangeThemeStyleJSONWithLastRowStyle } from './range-themes/default';@@ -47,6 +48,10 @@ export class SheetRangeThemeModel extends Disposable {private _rangeThemeStyleRuleMap: Map<string, Map<string, IRangeThemeStyleRule>> = new Map();private _rTreeCollection: Map<string, RTree> = new Map();private _defaultRangeThemeMap: Map<string, RangeThemeStyle> = new Map();++ private _rangeThemeMapChanged$ = new Subject<{ type: 'add' | 'remove'; styleName: string }>();+ public rangeThemeMapChange$ = this._rangeThemeMapChanged$.asObservable();+constructor(@Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService,@Inject(IResourceManagerService) private _resourceManagerService: IResourceManagerService@@ -90,6 +95,10 @@ export class SheetRangeThemeModel extends Disposable {return this._defaultRangeThemeMap.get(name)!;}+ public getCustomRangeThemeStyle(unitId: string, name: string): RangeThemeStyle | undefined {+ return this._ensureRangeThemeStyleMap(unitId).get(name);+ }+/*** Register range theme styles* @param {string} themeName@@ -122,18 +131,25 @@ export class SheetRangeThemeModel extends Disposable {const { unitId, subUnitId, range } = rangeInfo;const rTreeCollection = this._ensureRTreeCollection(unitId);const themes = Array.from(rTreeCollection.bulkSearch([{ unitId, sheetId: subUnitId, range }]));- if (themes[0]) {- const themeRuleMap = this._ensureRangeThemeStyleRuleMap(unitId);- const themeRule = themeRuleMap.get(themes[0] as string);+ const themeRuleMap = this._ensureRangeThemeStyleRuleMap(unitId);+ for (let i = 0; i < themes.length; i++) {+ const themeRule = themeRuleMap.get(themes[i] as string);if (themeRule && themeRule.themeName === themeName) {- themeRuleMap.delete(themes[0] as string);- rTreeCollection.remove({ unitId, sheetId: subUnitId, range, id: themes[0] as string });+ themeRuleMap.delete(themes[i] as string);+ rTreeCollection.remove({ unitId, sheetId: subUnitId, range, id: themes[i] as string });+ break;}}}registerDefaultRangeTheme(rangeThemeStyle: RangeThemeStyle): void {this._defaultRangeThemeMap.set(rangeThemeStyle.getName(), rangeThemeStyle);+ this._rangeThemeMapChanged$.next({ type: 'add', styleName: rangeThemeStyle.getName() });+ }++ unRegisterDefaultRangeTheme(themeName: string): void {+ this._defaultRangeThemeMap.delete(themeName);+ this._rangeThemeMapChanged$.next({ type: 'remove', styleName: themeName });}getRegisteredRangeThemes(): string[] {@@ -147,6 +163,7 @@ export class SheetRangeThemeModel extends Disposable {*/registerRangeThemeStyle(unitId: string, rangeThemeStyle: RangeThemeStyle): void {this._ensureRangeThemeStyleMap(unitId).set(rangeThemeStyle.getName(), rangeThemeStyle);+ this._rangeThemeMapChanged$.next({ type: 'add', styleName: rangeThemeStyle.getName() });}/**@@ -156,14 +173,16 @@ export class SheetRangeThemeModel extends Disposable {*/unregisterRangeThemeStyle(unitId: string, name: string): void {this._ensureRangeThemeStyleMap(unitId).delete(name);+ this._rangeThemeMapChanged$.next({ type: 'remove', styleName: name });}/*** Gets all custom register themes+ * @param {string} unitId Which unit to register the range theme style.* @return {string[]} The array of all custom registered themes.*/- getALLRegisteredTheme(): string[] {- return Array.from(this._rangeThemeStyleMap.keys());+ getALLRegisteredTheme(unitId: string): string[] {+ return Array.from(this._ensureRangeThemeStyleMap(unitId).keys());}getRangeThemeStyle(unitId: string, name: string): RangeThemeStyle {@@ -185,7 +204,9 @@ export class SheetRangeThemeModel extends Disposable {const offsetRow = row - rangeInfo.range.startRow;const offsetCol = col - rangeInfo.range.startColumn;const theme = this.getRangeThemeStyle(unitId, themeName);- return theme.getStyle(offsetRow, offsetCol, row === rangeInfo.range.endRow, col === rangeInfo.range.endColumn);+ if (theme) {+ return theme.getStyle(offsetRow, offsetCol, row === rangeInfo.range.endRow, col === rangeInfo.range.endColumn);+ }}}return undefined;@@ -240,15 +261,17 @@ export class SheetRangeThemeModel extends Disposable {fromJSON(unitId: string, json: ISheetRangeThemeModelJSON) {const { rangeThemeStyleRuleMap: rangeThemeStyleRuleMapJSON, rangeThemeStyleMapJson } = json;- if (rangeThemeStyleRuleMapJSON) {- Object.keys(rangeThemeStyleRuleMapJSON).forEach((key) => {- const ruleMap = rangeThemeStyleRuleMapJSON[key];- const { themeName, rangeInfo } = ruleMap;+ Object.keys(rangeThemeStyleRuleMapJSON).forEach((key) => {+ const ruleMap = rangeThemeStyleRuleMapJSON[key];+ const { themeName, rangeInfo } = ruleMap;+ // TODO Due to design issues, we will skip table-related theme registration.+ // Here the table needs to have its own rangeTheme to be independent+ if (!themeName.startsWith('table')) {this.registerRangeThemeRule(themeName, rangeInfo);const rTreeCollection = this._ensureRTreeCollection(rangeInfo.unitId);rTreeCollection.insert({ unitId: key, sheetId: rangeInfo.subUnitId, range: rangeInfo.range, id: key });- });- }+ }+ });if (rangeThemeStyleMapJson) {Object.keys(rangeThemeStyleMapJson).forEach((key) => {diff --git a/packages/sheets/src/model/range-theme-util.ts b/packages/sheets/src/model/range-theme-util.tsindex 199b4214a1..c525688cff 100644--- a/packages/sheets/src/model/range-theme-util.ts+++ b/packages/sheets/src/model/range-theme-util.ts@@ -17,7 +17,6 @@import type { IStyleData, Nullable } from '@univerjs/core';export type IRangeThemeStyleItem = Pick<IStyleData, 'bg' | 'ol' | 'bd' | 'cl' | 'ht' | 'vt' | 'bl'>;-export interface IRangeThemeStyleJSON {name: string;wholeStyle?: IRangeThemeStyleItem;@@ -179,6 +178,7 @@ export class RangeThemeStyle {setWholeStyle(style: Nullable<IRangeThemeStyleItem>): void {this.wholeStyle = style;+ this._resetStyleCache();}getFirstRowStyle(): Nullable<IRangeThemeStyleItem> {@@ -187,6 +187,7 @@ export class RangeThemeStyle {setFirstRowStyle(style: Nullable<IRangeThemeStyleItem>): void {this.firstRowStyle = style;+ this._resetStyleCache();}getSecondRowStyle(): Nullable<IRangeThemeStyleItem> {@@ -195,6 +196,7 @@ export class RangeThemeStyle {setSecondRowStyle(style: Nullable<IRangeThemeStyleItem>): void {this.secondRowStyle = style;+ this._resetStyleCache();}getLastRowStyle(): Nullable<IRangeThemeStyleItem> {@@ -203,6 +205,7 @@ export class RangeThemeStyle {setLastRowStyle(style: Nullable<IRangeThemeStyleItem>): void {this.lastRowStyle = style;+ this._resetStyleCache();}getFirstColumnStyle(): Nullable<IRangeThemeStyleItem> {@@ -211,6 +214,7 @@ export class RangeThemeStyle {setFirstColumnStyle(style: Nullable<IRangeThemeStyleItem>): void {this.firstColumnStyle = style;+ this._resetStyleCache();}getSecondColumnStyle(): Nullable<IRangeThemeStyleItem> {@@ -219,6 +223,7 @@ export class RangeThemeStyle {setSecondColumnStyle(style: Nullable<IRangeThemeStyleItem>): void {this.secondColumnStyle = style;+ this._resetStyleCache();}getLastColumnStyle(): Nullable<IRangeThemeStyleItem> {@@ -227,6 +232,7 @@ export class RangeThemeStyle {setLastColumnStyle(style: Nullable<IRangeThemeStyleItem>): void {this.lastColumnStyle = style;+ this._resetStyleCache();}getHeaderRowStyle(): Nullable<IRangeThemeStyleItem> {@@ -235,6 +241,7 @@ export class RangeThemeStyle {setHeaderRowStyle(style: Nullable<IRangeThemeStyleItem>): void {this.headerRowStyle = style;+ this._resetStyleCache();}getHeaderColumnStyle(): Nullable<IRangeThemeStyleItem> {@@ -243,6 +250,7 @@ export class RangeThemeStyle {setHeaderColumnStyle(style: Nullable<IRangeThemeStyleItem>): void {this.headerColumnStyle = style;+ this._resetStyleCache();}public getStyle(offsetRow: number, offsetCol: number, isLastRow: boolean, isLastCol: boolean) {@@ -343,6 +351,10 @@ export class RangeThemeStyle {return composeStyles(rs as IStyleData[]);}+ private _resetStyleCache() {+ this._mergeCacheMap.clear();+ }+toJson(): IRangeThemeStyleJSON {const jsonData: IRangeThemeStyleJSON = {name: this._name,diff --git a/packages/sheets/src/services/range-theme-service.ts b/packages/sheets/src/services/range-theme-service.tsindex f4cc0a61d3..b98bee45c8 100644--- a/packages/sheets/src/services/range-theme-service.ts+++ b/packages/sheets/src/services/range-theme-service.ts@@ -41,10 +41,11 @@ export class SheetRangeThemeService extends Disposable {/*** Get custom register themes name list+ * @param {string} unitId Which unit to register the range theme style.* @returns {string[]} The list of custom register themes name.*/- getALLRegisterThemes(): string[] {- return this._sheetRangeThemeModel.getALLRegisteredTheme();+ getALLRegisterThemes(unitId: string): string[] {+ return this._sheetRangeThemeModel.getALLRegisteredTheme(unitId);}/**diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex e47de3d9b2..7cdfa9dd84 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -412,6 +412,12 @@ importers:'@univerjs/sheets-source-binding':specifier: workspace:*version: link:../packages-experimental/sheets-source-binding+ '@univerjs/sheets-table':+ specifier: workspace:*+ version: link:../packages/sheets-table+ '@univerjs/sheets-table-ui':+ specifier: workspace:*+ version: link:../packages/sheets-table-ui'@univerjs/sheets-thread-comment':specifier: workspace:*version: link:../packages/sheets-thread-comment@@ -2820,6 +2826,98 @@ importers:specifier: ^3.1.1version: 3.1.1(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ packages/sheets-table:+ dependencies:+ '@univerjs/core':+ specifier: workspace:*+ version: link:../core+ '@univerjs/sheets':+ specifier: workspace:*+ version: link:../sheets+ devDependencies:+ '@univerjs-infra/shared':+ specifier: workspace:*+ version: link:../../common/shared+ rxjs:+ specifier: ^7.8.1+ version: 7.8.1+ typescript:+ specifier: ^5.8.2+ version: 5.8.3+ vite:+ specifier: ^6.2.1+ version: 6.3.2(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ vitest:+ specifier: ^3.0.8+ version: 3.1.1(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])++ packages/sheets-table-ui:+ dependencies:+ '@univerjs/core':+ specifier: workspace:*+ version: link:../core+ '@univerjs/design':+ specifier: workspace:*+ version: link:../design+ '@univerjs/engine-formula':+ specifier: workspace:*+ version: link:../engine-formula+ '@univerjs/engine-render':+ specifier: workspace:*+ version: link:../engine-render+ '@univerjs/icons':+ specifier: ^0.3.2+ '@univerjs/sheets':+ specifier: workspace:*+ version: link:../sheets+ '@univerjs/sheets-formula-ui':+ specifier: workspace:*+ version: link:../sheets-formula-ui+ '@univerjs/sheets-sort':+ specifier: workspace:*+ version: link:../sheets-sort+ '@univerjs/sheets-table':+ specifier: workspace:*+ version: link:../sheets-table+ '@univerjs/sheets-ui':+ specifier: workspace:*+ version: link:../sheets-ui+ '@univerjs/ui':+ specifier: workspace:*+ version: link:../ui+ devDependencies:+ '@univerjs-infra/shared':+ specifier: workspace:*+ version: link:../../common/shared+ less:+ specifier: ^4.2.2+ version: 4.3.0+ postcss:+ specifier: ^8.5.3+ version: 8.5.3+ react:+ specifier: '19'+ version: 19.0.0+ react-dom:+ specifier: '19'+ version: 19.0.0([email protected])+ rxjs:+ specifier: ^7.8.1+ version: 7.8.1+ tailwindcss:+ specifier: ^3.4.17+ version: 3.4.17+ typescript:+ specifier: ^5.7.3+ version: 5.8.3+ vite:+ specifier: ^6.2.1+ version: 6.3.2(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ vitest:+ specifier: ^3.0.8+ version: 3.1.1(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+packages/sheets-thread-comment:dependencies:'@univerjs/core':@@ -3961,13 +4059,13 @@ packages:resolution: {integrity: sha512-bZXIUjxr0LIuHWshZr/5mtUkOrnh0NKVZEF6ACojW5z7zkJu7s9sV2mMXm8XQDqN4cJzdHYUYzUyEGdfciaLJA==}'@emnapi/[email protected]':- resolution: {integrity: sha512-H+N/FqT07NmLmt6OFFtDfwe8PNygprzBikrEMyQfgqSmT0vzE515Pz7R8izwB9q/zsH/MA64AKoul3sA6/CzVg==}+ resolution: {integrity: sha512-H+N/FqT07NmLmt6OFFtDfwe8PNygprzBikrEMyQfgqSmT0vzE515Pz7R8izwB9q/zsH/MA64AKoul3sA6/CzVg==, tarball: https://registry.npmjs.org/@emnapi/core/-/core-1.4.0.tgz}'@emnapi/[email protected]':- resolution: {integrity: sha512-64WYIf4UYcdLnbKn/umDlNjQDSS8AgZrI/R9+x5ilkUVFxXcA1Ebl+gQLc/6mERA4407Xof0R7wEyEuj091CVw==}+ resolution: {integrity: sha512-64WYIf4UYcdLnbKn/umDlNjQDSS8AgZrI/R9+x5ilkUVFxXcA1Ebl+gQLc/6mERA4407Xof0R7wEyEuj091CVw==, tarball: https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.4.0.tgz}'@emnapi/[email protected]':- resolution: {integrity: sha512-iIBu7mwkq4UQGeMEM8bLwNK962nXdhodeScX4slfQnRhEMMzvYivHhutCIk8uojvmASXXPC2WNEjwxFWk72Oqw==}+ resolution: {integrity: sha512-iIBu7mwkq4UQGeMEM8bLwNK962nXdhodeScX4slfQnRhEMMzvYivHhutCIk8uojvmASXXPC2WNEjwxFWk72Oqw==, tarball: https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.0.1.tgz}'@es-joy/[email protected]':resolution: {integrity: sha512-xjZTSFgECpb9Ohuk5yMX5RhUEbfeQcuOp8IF60e+wyzWEF0M5xeSgqsfLtvPEX8BIyOX9saZqzuGPmZ8oWc+5Q==}@@ -3978,157 +4076,157 @@ packages:engines: {node: '>=18'}'@esbuild/[email protected]':- resolution: {integrity: sha512-wCIboOL2yXZym2cgm6mlA742s9QeJ8DjGVaL39dLN4rRwrOgOyYSnOaFPhKZGLb2ngj4EyfAFjsNJwPXZvseag==}+ resolution: {integrity: sha512-wCIboOL2yXZym2cgm6mlA742s9QeJ8DjGVaL39dLN4rRwrOgOyYSnOaFPhKZGLb2ngj4EyfAFjsNJwPXZvseag==, tarball: https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.2.tgz}engines: {node: '>=18'}cpu: [ppc64]os: [aix]'@esbuild/[email protected]':- resolution: {integrity: sha512-5ZAX5xOmTligeBaeNEPnPaeEuah53Id2tX4c2CVP3JaROTH+j4fnfHCkr1PjXMd78hMst+TlkfKcW/DlTq0i4w==}+ resolution: {integrity: sha512-5ZAX5xOmTligeBaeNEPnPaeEuah53Id2tX4c2CVP3JaROTH+j4fnfHCkr1PjXMd78hMst+TlkfKcW/DlTq0i4w==, tarball: https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.2.tgz}engines: {node: '>=18'}cpu: [arm64]os: [android]'@esbuild/[email protected]':- resolution: {integrity: sha512-NQhH7jFstVY5x8CKbcfa166GoV0EFkaPkCKBQkdPJFvo5u+nGXLEH/ooniLb3QI8Fk58YAx7nsPLozUWfCBOJA==}+ resolution: {integrity: sha512-NQhH7jFstVY5x8CKbcfa166GoV0EFkaPkCKBQkdPJFvo5u+nGXLEH/ooniLb3QI8Fk58YAx7nsPLozUWfCBOJA==, tarball: https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.2.tgz}engines: {node: '>=18'}cpu: [arm]os: [android]'@esbuild/[email protected]':- resolution: {integrity: sha512-Ffcx+nnma8Sge4jzddPHCZVRvIfQ0kMsUsCMcJRHkGJ1cDmhe4SsrYIjLUKn1xpHZybmOqCWwB0zQvsjdEHtkg==}+ resolution: {integrity: sha512-Ffcx+nnma8Sge4jzddPHCZVRvIfQ0kMsUsCMcJRHkGJ1cDmhe4SsrYIjLUKn1xpHZybmOqCWwB0zQvsjdEHtkg==, tarball: https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.2.tgz}engines: {node: '>=18'}cpu: [x64]os: [android]'@esbuild/[email protected]':- resolution: {integrity: sha512-MpM6LUVTXAzOvN4KbjzU/q5smzryuoNjlriAIx+06RpecwCkL9JpenNzpKd2YMzLJFOdPqBpuub6eVRP5IgiSA==}+ resolution: {integrity: sha512-MpM6LUVTXAzOvN4KbjzU/q5smzryuoNjlriAIx+06RpecwCkL9JpenNzpKd2YMzLJFOdPqBpuub6eVRP5IgiSA==, tarball: https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.2.tgz}engines: {node: '>=18'}cpu: [arm64]os: [darwin]'@esbuild/[email protected]':- resolution: {integrity: sha512-5eRPrTX7wFyuWe8FqEFPG2cU0+butQQVNcT4sVipqjLYQjjh8a8+vUTfgBKM88ObB85ahsnTwF7PSIt6PG+QkA==}+ resolution: {integrity: sha512-5eRPrTX7wFyuWe8FqEFPG2cU0+butQQVNcT4sVipqjLYQjjh8a8+vUTfgBKM88ObB85ahsnTwF7PSIt6PG+QkA==, tarball: https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.2.tgz}engines: {node: '>=18'}cpu: [x64]os: [darwin]'@esbuild/[email protected]':- resolution: {integrity: sha512-mLwm4vXKiQ2UTSX4+ImyiPdiHjiZhIaE9QvC7sw0tZ6HoNMjYAqQpGyui5VRIi5sGd+uWq940gdCbY3VLvsO1w==}+ resolution: {integrity: sha512-mLwm4vXKiQ2UTSX4+ImyiPdiHjiZhIaE9QvC7sw0tZ6HoNMjYAqQpGyui5VRIi5sGd+uWq940gdCbY3VLvsO1w==, tarball: https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.2.tgz}engines: {node: '>=18'}cpu: [arm64]os: [freebsd]'@esbuild/[email protected]':- resolution: {integrity: sha512-6qyyn6TjayJSwGpm8J9QYYGQcRgc90nmfdUb0O7pp1s4lTY+9D0H9O02v5JqGApUyiHOtkz6+1hZNvNtEhbwRQ==}+ resolution: {integrity: sha512-6qyyn6TjayJSwGpm8J9QYYGQcRgc90nmfdUb0O7pp1s4lTY+9D0H9O02v5JqGApUyiHOtkz6+1hZNvNtEhbwRQ==, tarball: https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.2.tgz}engines: {node: '>=18'}cpu: [x64]os: [freebsd]'@esbuild/[email protected]':- resolution: {integrity: sha512-gq/sjLsOyMT19I8obBISvhoYiZIAaGF8JpeXu1u8yPv8BE5HlWYobmlsfijFIZ9hIVGYkbdFhEqC0NvM4kNO0g==}+ resolution: {integrity: sha512-gq/sjLsOyMT19I8obBISvhoYiZIAaGF8JpeXu1u8yPv8BE5HlWYobmlsfijFIZ9hIVGYkbdFhEqC0NvM4kNO0g==, tarball: https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.2.tgz}engines: {node: '>=18'}cpu: [arm64]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-UHBRgJcmjJv5oeQF8EpTRZs/1knq6loLxTsjc3nxO9eXAPDLcWW55flrMVc97qFPbmZP31ta1AZVUKQzKTzb0g==}+ resolution: {integrity: sha512-UHBRgJcmjJv5oeQF8EpTRZs/1knq6loLxTsjc3nxO9eXAPDLcWW55flrMVc97qFPbmZP31ta1AZVUKQzKTzb0g==, tarball: https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.2.tgz}engines: {node: '>=18'}cpu: [arm]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-bBYCv9obgW2cBP+2ZWfjYTU+f5cxRoGGQ5SeDbYdFCAZpYWrfjjfYwvUpP8MlKbP0nwZ5gyOU/0aUzZ5HWPuvQ==}+ resolution: {integrity: sha512-bBYCv9obgW2cBP+2ZWfjYTU+f5cxRoGGQ5SeDbYdFCAZpYWrfjjfYwvUpP8MlKbP0nwZ5gyOU/0aUzZ5HWPuvQ==, tarball: https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.2.tgz}engines: {node: '>=18'}cpu: [ia32]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==}+ resolution: {integrity: sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==, tarball: https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.14.54.tgz}engines: {node: '>=12'}cpu: [loong64]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-SHNGiKtvnU2dBlM5D8CXRFdd+6etgZ9dXfaPCeJtz+37PIUlixvlIhI23L5khKXs3DIzAn9V8v+qb1TRKrgT5w==}+ resolution: {integrity: sha512-SHNGiKtvnU2dBlM5D8CXRFdd+6etgZ9dXfaPCeJtz+37PIUlixvlIhI23L5khKXs3DIzAn9V8v+qb1TRKrgT5w==, tarball: https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.2.tgz}engines: {node: '>=18'}cpu: [loong64]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-hDDRlzE6rPeoj+5fsADqdUZl1OzqDYow4TB4Y/3PlKBD0ph1e6uPHzIQcv2Z65u2K0kpeByIyAjCmjn1hJgG0Q==}+ resolution: {integrity: sha512-hDDRlzE6rPeoj+5fsADqdUZl1OzqDYow4TB4Y/3PlKBD0ph1e6uPHzIQcv2Z65u2K0kpeByIyAjCmjn1hJgG0Q==, tarball: https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.2.tgz}engines: {node: '>=18'}cpu: [mips64el]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-tsHu2RRSWzipmUi9UBDEzc0nLc4HtpZEI5Ba+Omms5456x5WaNuiG3u7xh5AO6sipnJ9r4cRWQB2tUjPyIkc6g==}+ resolution: {integrity: sha512-tsHu2RRSWzipmUi9UBDEzc0nLc4HtpZEI5Ba+Omms5456x5WaNuiG3u7xh5AO6sipnJ9r4cRWQB2tUjPyIkc6g==, tarball: https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.2.tgz}engines: {node: '>=18'}cpu: [ppc64]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-k4LtpgV7NJQOml/10uPU0s4SAXGnowi5qBSjaLWMojNCUICNu7TshqHLAEbkBdAszL5TabfvQ48kK84hyFzjnw==}+ resolution: {integrity: sha512-k4LtpgV7NJQOml/10uPU0s4SAXGnowi5qBSjaLWMojNCUICNu7TshqHLAEbkBdAszL5TabfvQ48kK84hyFzjnw==, tarball: https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.2.tgz}engines: {node: '>=18'}cpu: [riscv64]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-GRa4IshOdvKY7M/rDpRR3gkiTNp34M0eLTaC1a08gNrh4u488aPhuZOCpkF6+2wl3zAN7L7XIpOFBhnaE3/Q8Q==}+ resolution: {integrity: sha512-GRa4IshOdvKY7M/rDpRR3gkiTNp34M0eLTaC1a08gNrh4u488aPhuZOCpkF6+2wl3zAN7L7XIpOFBhnaE3/Q8Q==, tarball: https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.2.tgz}engines: {node: '>=18'}cpu: [s390x]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-QInHERlqpTTZ4FRB0fROQWXcYRD64lAoiegezDunLpalZMjcUcld3YzZmVJ2H/Cp0wJRZ8Xtjtj0cEHhYc/uUg==}+ resolution: {integrity: sha512-QInHERlqpTTZ4FRB0fROQWXcYRD64lAoiegezDunLpalZMjcUcld3YzZmVJ2H/Cp0wJRZ8Xtjtj0cEHhYc/uUg==, tarball: https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.2.tgz}engines: {node: '>=18'}cpu: [x64]os: [linux]'@esbuild/[email protected]':- resolution: {integrity: sha512-talAIBoY5M8vHc6EeI2WW9d/CkiO9MQJ0IOWX8hrLhxGbro/vBXJvaQXefW2cP0z0nQVTdQ/eNyGFV1GSKrxfw==}+ resolution: {integrity: sha512-talAIBoY5M8vHc6EeI2WW9d/CkiO9MQJ0IOWX8hrLhxGbro/vBXJvaQXefW2cP0z0nQVTdQ/eNyGFV1GSKrxfw==, tarball: https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.2.tgz}engines: {node: '>=18'}cpu: [arm64]os: [netbsd]'@esbuild/[email protected]':- resolution: {integrity: sha512-voZT9Z+tpOxrvfKFyfDYPc4DO4rk06qamv1a/fkuzHpiVBMOhpjK+vBmWM8J1eiB3OLSMFYNaOaBNLXGChf5tg==}+ resolution: {integrity: sha512-voZT9Z+tpOxrvfKFyfDYPc4DO4rk06qamv1a/fkuzHpiVBMOhpjK+vBmWM8J1eiB3OLSMFYNaOaBNLXGChf5tg==, tarball: https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.2.tgz}engines: {node: '>=18'}cpu: [x64]os: [netbsd]'@esbuild/[email protected]':- resolution: {integrity: sha512-dcXYOC6NXOqcykeDlwId9kB6OkPUxOEqU+rkrYVqJbK2hagWOMrsTGsMr8+rW02M+d5Op5NNlgMmjzecaRf7Tg==}+ resolution: {integrity: sha512-dcXYOC6NXOqcykeDlwId9kB6OkPUxOEqU+rkrYVqJbK2hagWOMrsTGsMr8+rW02M+d5Op5NNlgMmjzecaRf7Tg==, tarball: https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.2.tgz}engines: {node: '>=18'}cpu: [arm64]os: [openbsd]'@esbuild/[email protected]':- resolution: {integrity: sha512-t/TkWwahkH0Tsgoq1Ju7QfgGhArkGLkF1uYz8nQS/PPFlXbP5YgRpqQR3ARRiC2iXoLTWFxc6DJMSK10dVXluw==}+ resolution: {integrity: sha512-t/TkWwahkH0Tsgoq1Ju7QfgGhArkGLkF1uYz8nQS/PPFlXbP5YgRpqQR3ARRiC2iXoLTWFxc6DJMSK10dVXluw==, tarball: https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.2.tgz}engines: {node: '>=18'}cpu: [x64]os: [openbsd]'@esbuild/[email protected]':- resolution: {integrity: sha512-cfZH1co2+imVdWCjd+D1gf9NjkchVhhdpgb1q5y6Hcv9TP6Zi9ZG/beI3ig8TvwT9lH9dlxLq5MQBBgwuj4xvA==}+ resolution: {integrity: sha512-cfZH1co2+imVdWCjd+D1gf9NjkchVhhdpgb1q5y6Hcv9TP6Zi9ZG/beI3ig8TvwT9lH9dlxLq5MQBBgwuj4xvA==, tarball: https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.2.tgz}engines: {node: '>=18'}cpu: [x64]os: [sunos]'@esbuild/[email protected]':- resolution: {integrity: sha512-7Loyjh+D/Nx/sOTzV8vfbB3GJuHdOQyrOryFdZvPHLf42Tk9ivBU5Aedi7iyX+x6rbn2Mh68T4qq1SDqJBQO5Q==}+ resolution: {integrity: sha512-7Loyjh+D/Nx/sOTzV8vfbB3GJuHdOQyrOryFdZvPHLf42Tk9ivBU5Aedi7iyX+x6rbn2Mh68T4qq1SDqJBQO5Q==, tarball: https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.2.tgz}engines: {node: '>=18'}cpu: [arm64]os: [win32]'@esbuild/[email protected]':- resolution: {integrity: sha512-WRJgsz9un0nqZJ4MfhabxaD9Ft8KioqU3JMinOTvobbX6MOSUigSBlogP8QB3uxpJDsFS6yN+3FDBdqE5lg9kg==}+ resolution: {integrity: sha512-WRJgsz9un0nqZJ4MfhabxaD9Ft8KioqU3JMinOTvobbX6MOSUigSBlogP8QB3uxpJDsFS6yN+3FDBdqE5lg9kg==, tarball: https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.2.tgz}engines: {node: '>=18'}cpu: [ia32]os: [win32]'@esbuild/[email protected]':- resolution: {integrity: sha512-kM3HKb16VIXZyIeVrM1ygYmZBKybX8N4p754bw390wGO3Tf2j4L2/WYL+4suWujpgf6GBYs3jv7TyUivdd05JA==}+ resolution: {integrity: sha512-kM3HKb16VIXZyIeVrM1ygYmZBKybX8N4p754bw390wGO3Tf2j4L2/WYL+4suWujpgf6GBYs3jv7TyUivdd05JA==, tarball: https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.2.tgz}engines: {node: '>=18'}cpu: [x64]os: [win32]@@ -4259,11 +4357,11 @@ packages:resolution: {integrity: sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==}'@grpc/[email protected]':- resolution: {integrity: sha512-5tcgUctCG0qoNyfChZifz2tJqbRbXVO9J7X6duFcOjY3HUNCxg5D0ZCK7EP9vIcZ0zRpLU9bWkyCqVCLZ46IbQ==}+ resolution: {integrity: sha512-5tcgUctCG0qoNyfChZifz2tJqbRbXVO9J7X6duFcOjY3HUNCxg5D0ZCK7EP9vIcZ0zRpLU9bWkyCqVCLZ46IbQ==, tarball: https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.10.9.tgz}engines: {node: '>=12.10.0'}'@grpc/[email protected]':- resolution: {integrity: sha512-tMXdRCfYVixjuFK+Hk0Q1s38gV9zDiDJfWL3h1rv4Qc39oILCu1TRTDt7+fGUI8K4G1Fj125Hx/ru3azECWTyQ==}+ resolution: {integrity: sha512-tMXdRCfYVixjuFK+Hk0Q1s38gV9zDiDJfWL3h1rv4Qc39oILCu1TRTDt7+fGUI8K4G1Fj125Hx/ru3azECWTyQ==, tarball: https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.7.15.tgz}engines: {node: '>=6'}hasBin: true@@ -4336,7 +4434,7 @@ packages:resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}'@js-sdsl/[email protected]':- resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==}+ resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==, tarball: https://registry.npmjs.org/@js-sdsl/ordered-map/-/ordered-map-4.4.2.tgz}'@mdx-js/[email protected]':resolution: {integrity: sha512-QjHtSaoameoalGnKDT3FoIl4+9RwyTmo9ZJGBdLOks/YOiWHoRDI3PUwEzOE7kEmGcV3AFcp9K6dYu9rEuKLAQ==}@@ -4358,7 +4456,7 @@ packages:resolution: {integrity: sha512-4aErSrCR/On/e5G2hDP0wjooqDdauzEbIq8hIkIe5pXV0rtWJZvdCEKL0ykZxex+IxIwBp0eGeV48hQN07dXtw==}'@napi-rs/[email protected]':- resolution: {integrity: sha512-OBlgKdX7gin7OIq4fadsjpg+cp2ZphvAIKucHsNfTdJiqdOmOEwQd/bHi0VwNrcw5xpBJyUw6cK/QilCqy1BSg==}+ resolution: {integrity: sha512-OBlgKdX7gin7OIq4fadsjpg+cp2ZphvAIKucHsNfTdJiqdOmOEwQd/bHi0VwNrcw5xpBJyUw6cK/QilCqy1BSg==, tarball: https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.8.tgz}'@nodelib/[email protected]':resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}@@ -4425,7 +4523,7 @@ packages:resolution: {integrity: sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==}'@pkgjs/[email protected]':- resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}+ resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==, tarball: https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz}engines: {node: '>=14'}'@pkgr/[email protected]':@@ -4454,34 +4552,34 @@ packages:engines: {node: '>=12'}'@protobufjs/[email protected]':- resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}+ resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==, tarball: https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz}'@protobufjs/[email protected]':- resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==}+ resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==, tarball: https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz}'@protobufjs/[email protected]':- resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==}+ resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==, tarball: https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz}'@protobufjs/[email protected]':- resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==}+ resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==, tarball: https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz}'@protobufjs/[email protected]':- resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==}+ resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==, tarball: https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz}'@protobufjs/[email protected]':- resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==}+ resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==, tarball: https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz}'@protobufjs/[email protected]':- resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==}+ resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==, tarball: https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz}'@protobufjs/[email protected]':- resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==}+ resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==, tarball: https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz}'@protobufjs/[email protected]':- resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==}+ resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==, tarball: https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz}'@protobufjs/[email protected]':- resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==}+ resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==, tarball: https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz}'@radix-ui/[email protected]':resolution: {integrity: sha512-XnbHrrprsNqZKQhStrSwgRUQzoCI1glLzdw79xiZPoofhGICeZRSQ3dIxAKH1gb3OHfNf4d6f+vAv3kil2eggA==}@@ -4859,102 +4957,102 @@ packages:optional: true'@rollup/[email protected]':- resolution: {integrity: sha512-+Fbls/diZ0RDerhE8kyC6hjADCXA1K4yVNlH0EYfd2XjyH0UGgzaQ8MlT0pCXAThfxv3QUAczHaL+qSv1E4/Cg==}+ resolution: {integrity: sha512-+Fbls/diZ0RDerhE8kyC6hjADCXA1K4yVNlH0EYfd2XjyH0UGgzaQ8MlT0pCXAThfxv3QUAczHaL+qSv1E4/Cg==, tarball: https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.0.tgz}cpu: [arm]os: [android]'@rollup/[email protected]':- resolution: {integrity: sha512-PPA6aEEsTPRz+/4xxAmaoWDqh67N7wFbgFUJGMnanCFs0TV99M0M8QhhaSCks+n6EbQoFvLQgYOGXxlMGQe/6w==}+ resolution: {integrity: sha512-PPA6aEEsTPRz+/4xxAmaoWDqh67N7wFbgFUJGMnanCFs0TV99M0M8QhhaSCks+n6EbQoFvLQgYOGXxlMGQe/6w==, tarball: https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.40.0.tgz}cpu: [arm64]os: [android]'@rollup/[email protected]':- resolution: {integrity: sha512-GwYOcOakYHdfnjjKwqpTGgn5a6cUX7+Ra2HeNj/GdXvO2VJOOXCiYYlRFU4CubFM67EhbmzLOmACKEfvp3J1kQ==}+ resolution: {integrity: sha512-GwYOcOakYHdfnjjKwqpTGgn5a6cUX7+Ra2HeNj/GdXvO2VJOOXCiYYlRFU4CubFM67EhbmzLOmACKEfvp3J1kQ==, tarball: https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.40.0.tgz}cpu: [arm64]os: [darwin]'@rollup/[email protected]':- resolution: {integrity: sha512-CoLEGJ+2eheqD9KBSxmma6ld01czS52Iw0e2qMZNpPDlf7Z9mj8xmMemxEucinev4LgHalDPczMyxzbq+Q+EtA==}+ resolution: {integrity: sha512-CoLEGJ+2eheqD9KBSxmma6ld01czS52Iw0e2qMZNpPDlf7Z9mj8xmMemxEucinev4LgHalDPczMyxzbq+Q+EtA==, tarball: https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.40.0.tgz}cpu: [x64]os: [darwin]'@rollup/[email protected]':- resolution: {integrity: sha512-r7yGiS4HN/kibvESzmrOB/PxKMhPTlz+FcGvoUIKYoTyGd5toHp48g1uZy1o1xQvybwwpqpe010JrcGG2s5nkg==}+ resolution: {integrity: sha512-r7yGiS4HN/kibvESzmrOB/PxKMhPTlz+FcGvoUIKYoTyGd5toHp48g1uZy1o1xQvybwwpqpe010JrcGG2s5nkg==, tarball: https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.40.0.tgz}cpu: [arm64]os: [freebsd]'@rollup/[email protected]':- resolution: {integrity: sha512-mVDxzlf0oLzV3oZOr0SMJ0lSDd3xC4CmnWJ8Val8isp9jRGl5Dq//LLDSPFrasS7pSm6m5xAcKaw3sHXhBjoRw==}+ resolution: {integrity: sha512-mVDxzlf0oLzV3oZOr0SMJ0lSDd3xC4CmnWJ8Val8isp9jRGl5Dq//LLDSPFrasS7pSm6m5xAcKaw3sHXhBjoRw==, tarball: https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.40.0.tgz}cpu: [x64]os: [freebsd]'@rollup/[email protected]':- resolution: {integrity: sha512-y/qUMOpJxBMy8xCXD++jeu8t7kzjlOCkoxxajL58G62PJGBZVl/Gwpm7JK9+YvlB701rcQTzjUZ1JgUoPTnoQA==}+ resolution: {integrity: sha512-y/qUMOpJxBMy8xCXD++jeu8t7kzjlOCkoxxajL58G62PJGBZVl/Gwpm7JK9+YvlB701rcQTzjUZ1JgUoPTnoQA==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.40.0.tgz}cpu: [arm]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-GoCsPibtVdJFPv/BOIvBKO/XmwZLwaNWdyD8TKlXuqp0veo2sHE+A/vpMQ5iSArRUz/uaoj4h5S6Pn0+PdhRjg==}+ resolution: {integrity: sha512-GoCsPibtVdJFPv/BOIvBKO/XmwZLwaNWdyD8TKlXuqp0veo2sHE+A/vpMQ5iSArRUz/uaoj4h5S6Pn0+PdhRjg==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.40.0.tgz}cpu: [arm]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-L5ZLphTjjAD9leJzSLI7rr8fNqJMlGDKlazW2tX4IUF9P7R5TMQPElpH82Q7eNIDQnQlAyiNVfRPfP2vM5Avvg==}+ resolution: {integrity: sha512-L5ZLphTjjAD9leJzSLI7rr8fNqJMlGDKlazW2tX4IUF9P7R5TMQPElpH82Q7eNIDQnQlAyiNVfRPfP2vM5Avvg==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.40.0.tgz}cpu: [arm64]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-ATZvCRGCDtv1Y4gpDIXsS+wfFeFuLwVxyUBSLawjgXK2tRE6fnsQEkE4csQQYWlBlsFztRzCnBvWVfcae/1qxQ==}+ resolution: {integrity: sha512-ATZvCRGCDtv1Y4gpDIXsS+wfFeFuLwVxyUBSLawjgXK2tRE6fnsQEkE4csQQYWlBlsFztRzCnBvWVfcae/1qxQ==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.40.0.tgz}cpu: [arm64]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-wG9e2XtIhd++QugU5MD9i7OnpaVb08ji3P1y/hNbxrQ3sYEelKJOq1UJ5dXczeo6Hj2rfDEL5GdtkMSVLa/AOg==}+ resolution: {integrity: sha512-wG9e2XtIhd++QugU5MD9i7OnpaVb08ji3P1y/hNbxrQ3sYEelKJOq1UJ5dXczeo6Hj2rfDEL5GdtkMSVLa/AOg==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.40.0.tgz}cpu: [loong64]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-vgXfWmj0f3jAUvC7TZSU/m/cOE558ILWDzS7jBhiCAFpY2WEBn5jqgbqvmzlMjtp8KlLcBlXVD2mkTSEQE6Ixw==}+ resolution: {integrity: sha512-vgXfWmj0f3jAUvC7TZSU/m/cOE558ILWDzS7jBhiCAFpY2WEBn5jqgbqvmzlMjtp8KlLcBlXVD2mkTSEQE6Ixw==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.40.0.tgz}cpu: [ppc64]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-uJkYTugqtPZBS3Z136arevt/FsKTF/J9dEMTX/cwR7lsAW4bShzI2R0pJVw+hcBTWF4dxVckYh72Hk3/hWNKvA==}+ resolution: {integrity: sha512-uJkYTugqtPZBS3Z136arevt/FsKTF/J9dEMTX/cwR7lsAW4bShzI2R0pJVw+hcBTWF4dxVckYh72Hk3/hWNKvA==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.40.0.tgz}cpu: [riscv64]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-rKmSj6EXQRnhSkE22+WvrqOqRtk733x3p5sWpZilhmjnkHkpeCgWsFFo0dGnUGeA+OZjRl3+VYq+HyCOEuwcxQ==}+ resolution: {integrity: sha512-rKmSj6EXQRnhSkE22+WvrqOqRtk733x3p5sWpZilhmjnkHkpeCgWsFFo0dGnUGeA+OZjRl3+VYq+HyCOEuwcxQ==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.40.0.tgz}cpu: [riscv64]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-SpnYlAfKPOoVsQqmTFJ0usx0z84bzGOS9anAC0AZ3rdSo3snecihbhFTlJZ8XMwzqAcodjFU4+/SM311dqE5Sw==}+ resolution: {integrity: sha512-SpnYlAfKPOoVsQqmTFJ0usx0z84bzGOS9anAC0AZ3rdSo3snecihbhFTlJZ8XMwzqAcodjFU4+/SM311dqE5Sw==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.40.0.tgz}cpu: [s390x]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-RcDGMtqF9EFN8i2RYN2W+64CdHruJ5rPqrlYw+cgM3uOVPSsnAQps7cpjXe9be/yDp8UC7VLoCoKC8J3Kn2FkQ==}+ resolution: {integrity: sha512-RcDGMtqF9EFN8i2RYN2W+64CdHruJ5rPqrlYw+cgM3uOVPSsnAQps7cpjXe9be/yDp8UC7VLoCoKC8J3Kn2FkQ==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.40.0.tgz}cpu: [x64]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-HZvjpiUmSNx5zFgwtQAV1GaGazT2RWvqeDi0hV+AtC8unqqDSsaFjPxfsO6qPtKRRg25SisACWnJ37Yio8ttaw==}+ resolution: {integrity: sha512-HZvjpiUmSNx5zFgwtQAV1GaGazT2RWvqeDi0hV+AtC8unqqDSsaFjPxfsO6qPtKRRg25SisACWnJ37Yio8ttaw==, tarball: https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.40.0.tgz}cpu: [x64]os: [linux]'@rollup/[email protected]':- resolution: {integrity: sha512-UtZQQI5k/b8d7d3i9AZmA/t+Q4tk3hOC0tMOMSq2GlMYOfxbesxG4mJSeDp0EHs30N9bsfwUvs3zF4v/RzOeTQ==}+ resolution: {integrity: sha512-UtZQQI5k/b8d7d3i9AZmA/t+Q4tk3hOC0tMOMSq2GlMYOfxbesxG4mJSeDp0EHs30N9bsfwUvs3zF4v/RzOeTQ==, tarball: https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.40.0.tgz}cpu: [arm64]os: [win32]'@rollup/[email protected]':- resolution: {integrity: sha512-+m03kvI2f5syIqHXCZLPVYplP8pQch9JHyXKZ3AGMKlg8dCyr2PKHjwRLiW53LTrN/Nc3EqHOKxUxzoSPdKddA==}+ resolution: {integrity: sha512-+m03kvI2f5syIqHXCZLPVYplP8pQch9JHyXKZ3AGMKlg8dCyr2PKHjwRLiW53LTrN/Nc3EqHOKxUxzoSPdKddA==, tarball: https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.40.0.tgz}cpu: [ia32]os: [win32]'@rollup/[email protected]':- resolution: {integrity: sha512-lpPE1cLfP5oPzVjKMx10pgBmKELQnFJXHgvtHCtuJWOv8MxqdEIMNtgHgBFf7Ea2/7EuVwa9fodWUfXAlXZLZQ==}+ resolution: {integrity: sha512-lpPE1cLfP5oPzVjKMx10pgBmKELQnFJXHgvtHCtuJWOv8MxqdEIMNtgHgBFf7Ea2/7EuVwa9fodWUfXAlXZLZQ==, tarball: https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.40.0.tgz}cpu: [x64]os: [win32]@@ -5203,61 +5301,61 @@ packages:eslint: '>=9.0.0''@swc/[email protected]':- resolution: {integrity: sha512-FdGqzAIKVQJu8ROlnHElP59XAUsUzCFSNsou+tY/9ba+lhu8R9v0OI5wXiPErrKGZpQFMmx/BPqqhx3X4SuGNg==}+ resolution: {integrity: sha512-FdGqzAIKVQJu8ROlnHElP59XAUsUzCFSNsou+tY/9ba+lhu8R9v0OI5wXiPErrKGZpQFMmx/BPqqhx3X4SuGNg==, tarball: https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.10.18.tgz}engines: {node: '>=10'}cpu: [arm64]os: [darwin]'@swc/[email protected]':- resolution: {integrity: sha512-RZ73gZRituL/ZVLgrW6BYnQ5g8tuStG4cLUiPGJsUZpUm0ullSH6lHFvZTCBNFTfpQChG6eEhi2IdG6DwFp1lw==}+ resolution: {integrity: sha512-RZ73gZRituL/ZVLgrW6BYnQ5g8tuStG4cLUiPGJsUZpUm0ullSH6lHFvZTCBNFTfpQChG6eEhi2IdG6DwFp1lw==, tarball: https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.10.18.tgz}engines: {node: '>=10'}cpu: [x64]os: [darwin]'@swc/[email protected]':- resolution: {integrity: sha512-8iJqI3EkxJuuq21UHoen1VS+QlS23RvynRuk95K+Q2HBjygetztCGGEc+Xelx9a0uPkDaaAtFvds4JMDqb9SAA==}+ resolution: {integrity: sha512-8iJqI3EkxJuuq21UHoen1VS+QlS23RvynRuk95K+Q2HBjygetztCGGEc+Xelx9a0uPkDaaAtFvds4JMDqb9SAA==, tarball: https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.10.18.tgz}engines: {node: '>=10'}cpu: [arm]os: [linux]'@swc/[email protected]':- resolution: {integrity: sha512-8f1kSktWzMB6PG+r8lOlCfXz5E8Qhsmfwonn77T/OfjvGwQaWrcoASh2cdjpk3dydbf8jsKGPQE1lSc7GyjXRQ==}+ resolution: {integrity: sha512-8f1kSktWzMB6PG+r8lOlCfXz5E8Qhsmfwonn77T/OfjvGwQaWrcoASh2cdjpk3dydbf8jsKGPQE1lSc7GyjXRQ==, tarball: https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.10.18.tgz}engines: {node: '>=10'}cpu: [arm64]os: [linux]'@swc/[email protected]':- resolution: {integrity: sha512-4rv+E4VLdgQw6zjbTAauCAEExxChvxMpBUMCiZweTNPKbJJ2dY6BX2WGJ1ea8+RcgqR/Xysj3AFbOz1LBz6dGA==}+ resolution: {integrity: sha512-4rv+E4VLdgQw6zjbTAauCAEExxChvxMpBUMCiZweTNPKbJJ2dY6BX2WGJ1ea8+RcgqR/Xysj3AFbOz1LBz6dGA==, tarball: https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.10.18.tgz}engines: {node: '>=10'}cpu: [arm64]os: [linux]'@swc/[email protected]':- resolution: {integrity: sha512-vTNmyRBVP+sZca+vtwygYPGTNudTU6Gl6XhaZZ7cEUTBr8xvSTgEmYXoK/2uzyXpaTUI4Bmtp1x81cGN0mMoLQ==}+ resolution: {integrity: sha512-vTNmyRBVP+sZca+vtwygYPGTNudTU6Gl6XhaZZ7cEUTBr8xvSTgEmYXoK/2uzyXpaTUI4Bmtp1x81cGN0mMoLQ==, tarball: https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.10.18.tgz}engines: {node: '>=10'}cpu: [x64]os: [linux]'@swc/[email protected]':- resolution: {integrity: sha512-1TZPReKhFCeX776XaT6wegknfg+g3zODve+r4oslFHI+g7cInfWlxoGNDS3niPKyuafgCdOjme2g3OF+zzxfsQ==}+ resolution: {integrity: sha512-1TZPReKhFCeX776XaT6wegknfg+g3zODve+r4oslFHI+g7cInfWlxoGNDS3niPKyuafgCdOjme2g3OF+zzxfsQ==, tarball: https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.10.18.tgz}engines: {node: '>=10'}cpu: [x64]os: [linux]'@swc/[email protected]':- resolution: {integrity: sha512-o/2CsaWSN3bkzVQ6DA+BiFKSVEYvhWGA1h+wnL2zWmIDs2Knag54sOEXZkCaf8YQyZesGeXJtPEy9hh/vjJgkA==}+ resolution: {integrity: sha512-o/2CsaWSN3bkzVQ6DA+BiFKSVEYvhWGA1h+wnL2zWmIDs2Knag54sOEXZkCaf8YQyZesGeXJtPEy9hh/vjJgkA==, tarball: https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.10.18.tgz}engines: {node: '>=10'}cpu: [arm64]os: [win32]'@swc/[email protected]':- resolution: {integrity: sha512-eTPASeJtk4mJDfWiYEiOC6OYUi/N7meHbNHcU8e+aKABonhXrIo/FmnTE8vsUtC6+jakT1TQBdiQ8fzJ1kJVwA==}+ resolution: {integrity: sha512-eTPASeJtk4mJDfWiYEiOC6OYUi/N7meHbNHcU8e+aKABonhXrIo/FmnTE8vsUtC6+jakT1TQBdiQ8fzJ1kJVwA==, tarball: https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.10.18.tgz}engines: {node: '>=10'}cpu: [ia32]os: [win32]'@swc/[email protected]':- resolution: {integrity: sha512-1Dud8CDBnc34wkBOboFBQud9YlV1bcIQtKSg7zC8LtwR3h+XAaCayZPkpGmmAlCv1DLQPvkF+s0JcaVC9mfffQ==}+ resolution: {integrity: sha512-1Dud8CDBnc34wkBOboFBQud9YlV1bcIQtKSg7zC8LtwR3h+XAaCayZPkpGmmAlCv1DLQPvkF+s0JcaVC9mfffQ==, tarball: https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.10.18.tgz}engines: {node: '>=10'}cpu: [x64]os: [win32]@@ -5325,7 +5423,7 @@ packages:resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==}'@tybys/[email protected]':- resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==}+ resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==, tarball: https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.9.0.tgz}'@types/[email protected]':resolution: {integrity: sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==}@@ -5578,77 +5676,77 @@ packages:rxjs: '>=7.8''@unrs/[email protected]':- resolution: {integrity: sha512-8Tv+Bsd0BjGwfEedIyor4inw8atppRxM5BdUnIt+3mAm/QXUm7Dw74CHnXpfZKXkp07EXJGiA8hStqCINAWhdw==}+ resolution: {integrity: sha512-8Tv+Bsd0BjGwfEedIyor4inw8atppRxM5BdUnIt+3mAm/QXUm7Dw74CHnXpfZKXkp07EXJGiA8hStqCINAWhdw==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-darwin-arm64/-/resolver-binding-darwin-arm64-1.4.1.tgz}cpu: [arm64]os: [darwin]'@unrs/[email protected]':- resolution: {integrity: sha512-X8c3PhWziEMKAzZz+YAYWfwawi5AEgzy/hmfizAB4C70gMHLKmInJcp1270yYAOs7z07YVFI220pp50z24Jk3A==}+ resolution: {integrity: sha512-X8c3PhWziEMKAzZz+YAYWfwawi5AEgzy/hmfizAB4C70gMHLKmInJcp1270yYAOs7z07YVFI220pp50z24Jk3A==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-darwin-x64/-/resolver-binding-darwin-x64-1.4.1.tgz}cpu: [x64]os: [darwin]'@unrs/[email protected]':- resolution: {integrity: sha512-UUr/nREy1UdtxXQnmLaaTXFGOcGxPwNIzeJdb3KXai3TKtC1UgNOB9s8KOA4TaxOUBR/qVgL5BvBwmUjD5yuVA==}+ resolution: {integrity: sha512-UUr/nREy1UdtxXQnmLaaTXFGOcGxPwNIzeJdb3KXai3TKtC1UgNOB9s8KOA4TaxOUBR/qVgL5BvBwmUjD5yuVA==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-freebsd-x64/-/resolver-binding-freebsd-x64-1.4.1.tgz}cpu: [x64]os: [freebsd]'@unrs/[email protected]':- resolution: {integrity: sha512-e3pII53dEeS8inkX6A1ad2UXE0nuoWCqik4kOxaDnls0uJUq0ntdj5d9IYd+bv5TDwf9DSge/xPOvCmRYH+Tsw==}+ resolution: {integrity: sha512-e3pII53dEeS8inkX6A1ad2UXE0nuoWCqik4kOxaDnls0uJUq0ntdj5d9IYd+bv5TDwf9DSge/xPOvCmRYH+Tsw==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-linux-arm-gnueabihf/-/resolver-binding-linux-arm-gnueabihf-1.4.1.tgz}cpu: [arm]os: [linux]'@unrs/[email protected]':- resolution: {integrity: sha512-e/AKKd9gR+HNmVyDEPI/PIz2t0DrA3cyonHNhHVjrkxe8pMCiYiqhtn1+h+yIpHUtUlM6Y1FNIdivFa+r7wrEQ==}+ resolution: {integrity: sha512-e/AKKd9gR+HNmVyDEPI/PIz2t0DrA3cyonHNhHVjrkxe8pMCiYiqhtn1+h+yIpHUtUlM6Y1FNIdivFa+r7wrEQ==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-linux-arm-musleabihf/-/resolver-binding-linux-arm-musleabihf-1.4.1.tgz}cpu: [arm]os: [linux]'@unrs/[email protected]':- resolution: {integrity: sha512-vtIu34luF1jRktlHtiwm2mjuE8oJCsFiFr8hT5+tFQdqFKjPhbJXn83LswKsOhy0GxAEevpXDI4xxEwkjuXIPA==}+ resolution: {integrity: sha512-vtIu34luF1jRktlHtiwm2mjuE8oJCsFiFr8hT5+tFQdqFKjPhbJXn83LswKsOhy0GxAEevpXDI4xxEwkjuXIPA==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-linux-arm64-gnu/-/resolver-binding-linux-arm64-gnu-1.4.1.tgz}cpu: [arm64]os: [linux]'@unrs/[email protected]':- resolution: {integrity: sha512-H3PaOuGyhFXiyJd+09uPhGl4gocmhyi1BRzvsP8Lv5AQO3p3/ZY7WjV4t2NkBksm9tMjf3YbOVHyPWi2eWsNYw==}+ resolution: {integrity: sha512-H3PaOuGyhFXiyJd+09uPhGl4gocmhyi1BRzvsP8Lv5AQO3p3/ZY7WjV4t2NkBksm9tMjf3YbOVHyPWi2eWsNYw==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-linux-arm64-musl/-/resolver-binding-linux-arm64-musl-1.4.1.tgz}cpu: [arm64]os: [linux]'@unrs/[email protected]':- resolution: {integrity: sha512-4+GmJcaaFntCi1S01YByqp8wLMjV/FyQyHVGm0vedIhL1Vfx7uHkz/sZmKsidRwokBGuxi92GFmSzqT2O8KcNA==}+ resolution: {integrity: sha512-4+GmJcaaFntCi1S01YByqp8wLMjV/FyQyHVGm0vedIhL1Vfx7uHkz/sZmKsidRwokBGuxi92GFmSzqT2O8KcNA==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-linux-ppc64-gnu/-/resolver-binding-linux-ppc64-gnu-1.4.1.tgz}cpu: [ppc64]os: [linux]'@unrs/[email protected]':- resolution: {integrity: sha512-6RDQVCmtFYTlhy89D5ixTqo9bTQqFhvNN0Ey1wJs5r+01Dq15gPHRXv2jF2bQATtMrOfYwv+R2ZR9ew1N1N3YQ==}+ resolution: {integrity: sha512-6RDQVCmtFYTlhy89D5ixTqo9bTQqFhvNN0Ey1wJs5r+01Dq15gPHRXv2jF2bQATtMrOfYwv+R2ZR9ew1N1N3YQ==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-linux-s390x-gnu/-/resolver-binding-linux-s390x-gnu-1.4.1.tgz}cpu: [s390x]os: [linux]'@unrs/[email protected]':- resolution: {integrity: sha512-XpU9uzIkD86+19NjCXxlVPISMUrVXsXo5htxtuG+uJ59p5JauSRZsIxQxzzfKzkxEjdvANPM/lS1HFoX6A6QeA==}+ resolution: {integrity: sha512-XpU9uzIkD86+19NjCXxlVPISMUrVXsXo5htxtuG+uJ59p5JauSRZsIxQxzzfKzkxEjdvANPM/lS1HFoX6A6QeA==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-linux-x64-gnu/-/resolver-binding-linux-x64-gnu-1.4.1.tgz}cpu: [x64]os: [linux]'@unrs/[email protected]':- resolution: {integrity: sha512-3CDjG/spbTKCSHl66QP2ekHSD+H34i7utuDIM5gzoNBcZ1gTO0Op09Wx5cikXnhORRf9+HyDWzm37vU1PLSM1A==}+ resolution: {integrity: sha512-3CDjG/spbTKCSHl66QP2ekHSD+H34i7utuDIM5gzoNBcZ1gTO0Op09Wx5cikXnhORRf9+HyDWzm37vU1PLSM1A==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-linux-x64-musl/-/resolver-binding-linux-x64-musl-1.4.1.tgz}cpu: [x64]os: [linux]'@unrs/[email protected]':- resolution: {integrity: sha512-50tYhvbCTnuzMn7vmP8IV2UKF7ITo1oihygEYq9wW2DUb/Y+QMqBHJUSCABRngATjZ4shOK6f2+s0gQX6ElENQ==}+ resolution: {integrity: sha512-50tYhvbCTnuzMn7vmP8IV2UKF7ITo1oihygEYq9wW2DUb/Y+QMqBHJUSCABRngATjZ4shOK6f2+s0gQX6ElENQ==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-wasm32-wasi/-/resolver-binding-wasm32-wasi-1.4.1.tgz}engines: {node: '>=14.0.0'}cpu: [wasm32]'@unrs/[email protected]':- resolution: {integrity: sha512-KyJiIne/AqV4IW0wyQO34wSMuJwy3VxVQOfIXIPyQ/Up6y/zi2P/WwXb78gHsLiGRUqCA9LOoCX+6dQZde0g1g==}+ resolution: {integrity: sha512-KyJiIne/AqV4IW0wyQO34wSMuJwy3VxVQOfIXIPyQ/Up6y/zi2P/WwXb78gHsLiGRUqCA9LOoCX+6dQZde0g1g==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-win32-arm64-msvc/-/resolver-binding-win32-arm64-msvc-1.4.1.tgz}cpu: [arm64]os: [win32]'@unrs/[email protected]':- resolution: {integrity: sha512-y2NUD7pygrBolN2NoXUrwVqBpKPhF8DiSNE5oB5/iFO49r2DpoYqdj5HPb3F42fPBH5qNqj6Zg63+xCEzAD2hw==}+ resolution: {integrity: sha512-y2NUD7pygrBolN2NoXUrwVqBpKPhF8DiSNE5oB5/iFO49r2DpoYqdj5HPb3F42fPBH5qNqj6Zg63+xCEzAD2hw==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-win32-ia32-msvc/-/resolver-binding-win32-ia32-msvc-1.4.1.tgz}cpu: [ia32]os: [win32]'@unrs/[email protected]':- resolution: {integrity: sha512-hVXaObGI2lGFmrtT77KSbPQ3I+zk9IU500wobjk0+oX59vg/0VqAzABNtt3YSQYgXTC2a/LYxekLfND/wlt0yQ==}+ resolution: {integrity: sha512-hVXaObGI2lGFmrtT77KSbPQ3I+zk9IU500wobjk0+oX59vg/0VqAzABNtt3YSQYgXTC2a/LYxekLfND/wlt0yQ==, tarball: https://registry.npmjs.org/@unrs/resolver-binding-win32-x64-msvc/-/resolver-binding-win32-x64-msvc-1.4.1.tgz}cpu: [x64]os: [win32]@@ -6992,7 +7090,7 @@ packages:engines: {node: '>=18'}- resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==}+ resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==, tarball: https://registry.npmjs.org/errno/-/errno-0.1.8.tgz}hasBin: true@@ -7045,97 +7143,97 @@ packages:resolution: {integrity: sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==}- resolution: {integrity: sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==}+ resolution: {integrity: sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==, tarball: https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.54.tgz}engines: {node: '>=12'}cpu: [x64]os: [android]- resolution: {integrity: sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==}+ resolution: {integrity: sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==, tarball: https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.54.tgz}engines: {node: '>=12'}cpu: [arm64]os: [android]- resolution: {integrity: sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==}+ resolution: {integrity: sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==, tarball: https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.54.tgz}engines: {node: '>=12'}cpu: [x64]os: [darwin]- resolution: {integrity: sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==}+ resolution: {integrity: sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==, tarball: https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.54.tgz}engines: {node: '>=12'}cpu: [arm64]os: [darwin]- resolution: {integrity: sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==}+ resolution: {integrity: sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==, tarball: https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.54.tgz}engines: {node: '>=12'}cpu: [x64]os: [freebsd]- resolution: {integrity: sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==}+ resolution: {integrity: sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==, tarball: https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.54.tgz}engines: {node: '>=12'}cpu: [arm64]os: [freebsd]- resolution: {integrity: sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==}+ resolution: {integrity: sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==, tarball: https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.54.tgz}engines: {node: '>=12'}cpu: [ia32]os: [linux]- resolution: {integrity: sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==}+ resolution: {integrity: sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==, tarball: https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz}engines: {node: '>=12'}cpu: [x64]os: [linux]- resolution: {integrity: sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==}+ resolution: {integrity: sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==, tarball: https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.54.tgz}engines: {node: '>=12'}cpu: [arm64]os: [linux]- resolution: {integrity: sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==}+ resolution: {integrity: sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==, tarball: https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.54.tgz}engines: {node: '>=12'}cpu: [arm]os: [linux]- resolution: {integrity: sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==}+ resolution: {integrity: sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==, tarball: https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.54.tgz}engines: {node: '>=12'}cpu: [mips64el]os: [linux]- resolution: {integrity: sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==}+ resolution: {integrity: sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==, tarball: https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.54.tgz}engines: {node: '>=12'}cpu: [ppc64]os: [linux]- resolution: {integrity: sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==}+ resolution: {integrity: sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==, tarball: https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.54.tgz}engines: {node: '>=12'}cpu: [riscv64]os: [linux]- resolution: {integrity: sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==}+ resolution: {integrity: sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==, tarball: https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.54.tgz}engines: {node: '>=12'}cpu: [s390x]os: [linux]- resolution: {integrity: sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==}+ resolution: {integrity: sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==, tarball: https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.54.tgz}engines: {node: '>=12'}cpu: [x64]os: [netbsd]- resolution: {integrity: sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==}+ resolution: {integrity: sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==, tarball: https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.54.tgz}engines: {node: '>=12'}cpu: [x64]os: [openbsd]@@ -7180,25 +7278,25 @@ packages:resolution: {integrity: sha512-XPEKf4FjLjEVLv/dJH4UxDzXCrFHYpD93DBO8B+izdZARW5b7nNKQbnKv3J+7VDWJbgCU+hzfgIh2AuIZzlmXQ==}- resolution: {integrity: sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==}+ resolution: {integrity: sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==, tarball: https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.54.tgz}engines: {node: '>=12'}cpu: [x64]os: [sunos]- resolution: {integrity: sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==}+ resolution: {integrity: sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==, tarball: https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.54.tgz}engines: {node: '>=12'}cpu: [ia32]os: [win32]- resolution: {integrity: sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==}+ resolution: {integrity: sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==, tarball: https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.54.tgz}engines: {node: '>=12'}cpu: [x64]os: [win32]- resolution: {integrity: sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==}+ resolution: {integrity: sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==, tarball: https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.54.tgz}engines: {node: '>=12'}cpu: [arm64]os: [win32]@@ -7750,12 +7848,12 @@ packages:resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}- resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}+ resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==, tarball: https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz}engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}os: [darwin]- resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}+ resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==, tarball: https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz}engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}os: [darwin]@@ -8052,7 +8150,7 @@ packages:engines: {node: '>= 4'}- resolution: {integrity: sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==}+ resolution: {integrity: sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==, tarball: https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz}engines: {node: '>=0.10.0'}hasBin: true@@ -8667,7 +8765,7 @@ packages:engines: {node: '>=18'}- resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==}+ resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==, tarball: https://registry.npmjs.org/long/-/long-5.3.2.tgz}resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}@@ -8715,7 +8813,7 @@ packages:resolution: {integrity: sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==}- resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==}+ resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==, tarball: https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz}engines: {node: '>=6'}@@ -8907,7 +9005,7 @@ packages:engines: {node: '>= 0.6'}- resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}+ resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==, tarball: https://registry.npmjs.org/mime/-/mime-1.6.0.tgz}engines: {node: '>=4'}hasBin: true@@ -9012,7 +9110,7 @@ packages:engines: {node: '>=18'}- resolution: {integrity: sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==}+ resolution: {integrity: sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==, tarball: https://registry.npmjs.org/needle/-/needle-3.3.1.tgz}engines: {node: '>= 4.4.x'}hasBin: true@@ -9702,7 +9800,7 @@ packages:resolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==}- resolution: {integrity: sha512-Z2E/kOY1QjoMlCytmexzYfDm/w5fKAiRwpSzGtdnXW1zC88Z2yXazHHrOtwCzn+7wSxyE8PYM4rvVcMphF9sOA==}+ resolution: {integrity: sha512-Z2E/kOY1QjoMlCytmexzYfDm/w5fKAiRwpSzGtdnXW1zC88Z2yXazHHrOtwCzn+7wSxyE8PYM4rvVcMphF9sOA==, tarball: https://registry.npmjs.org/protobufjs/-/protobufjs-7.5.0.tgz}engines: {node: '>=12.0.0'}@@ -10361,7 +10459,7 @@ packages:resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==}- resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}+ resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==, tarball: https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz}engines: {node: '>=0.10.0'}@@ -10739,32 +10837,32 @@ packages:hasBin: true- resolution: {integrity: sha512-fP1hhI9zY8hv0idym3hAaXdPi80TLovmGmgZFocVAykFtOxF+GlfIgM/l4iLAV9ObIO4SUXPVWHeBZQQ+Hpjag==}+ resolution: {integrity: sha512-fP1hhI9zY8hv0idym3hAaXdPi80TLovmGmgZFocVAykFtOxF+GlfIgM/l4iLAV9ObIO4SUXPVWHeBZQQ+Hpjag==, tarball: https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-2.5.0.tgz}cpu: [x64]os: [darwin]- resolution: {integrity: sha512-p9sYq7kXH7qeJwIQE86cOWv/xNqvow846l6c/qWc26Ib1ci5W7V0sI5thsrP3eH+VA0d+SHalTKg5SQXgNQBWA==}+ resolution: {integrity: sha512-p9sYq7kXH7qeJwIQE86cOWv/xNqvow846l6c/qWc26Ib1ci5W7V0sI5thsrP3eH+VA0d+SHalTKg5SQXgNQBWA==, tarball: https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-2.5.0.tgz}cpu: [arm64]os: [darwin]- resolution: {integrity: sha512-1iEln2GWiF3iPPPS1HQJT6ZCFXynJPd89gs9SkggH2EJsj3eRUSVMmMC8y6d7bBbhBFsiGGazwFIYrI12zs6uQ==}+ resolution: {integrity: sha512-1iEln2GWiF3iPPPS1HQJT6ZCFXynJPd89gs9SkggH2EJsj3eRUSVMmMC8y6d7bBbhBFsiGGazwFIYrI12zs6uQ==, tarball: https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-2.5.0.tgz}cpu: [x64]os: [linux]- resolution: {integrity: sha512-bKBcbvuQHmsX116KcxHJuAcppiiBOfivOObh2O5aXNER6mce7YDDQJy00xQQNp1DhEfcSV2uOsvb3O3nN2cbcA==}+ resolution: {integrity: sha512-bKBcbvuQHmsX116KcxHJuAcppiiBOfivOObh2O5aXNER6mce7YDDQJy00xQQNp1DhEfcSV2uOsvb3O3nN2cbcA==, tarball: https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-2.5.0.tgz}cpu: [arm64]os: [linux]- resolution: {integrity: sha512-9BCo8oQ7BO7J0K913Czbc3tw8QwLqn2nTe4E47k6aVYkM12ASTScweXPTuaPFP5iYXAT6z5Dsniw704Ixa5eGg==}+ resolution: {integrity: sha512-9BCo8oQ7BO7J0K913Czbc3tw8QwLqn2nTe4E47k6aVYkM12ASTScweXPTuaPFP5iYXAT6z5Dsniw704Ixa5eGg==, tarball: https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-2.5.0.tgz}cpu: [x64]os: [win32]- resolution: {integrity: sha512-OUHCV+ueXa3UzfZ4co/ueIHgeq9B2K48pZwIxKSm5VaLVuv8M13MhM7unukW09g++dpdrrE1w4IOVgxKZ0/exg==}+ resolution: {integrity: sha512-OUHCV+ueXa3UzfZ4co/ueIHgeq9B2K48pZwIxKSm5VaLVuv8M13MhM7unukW09g++dpdrrE1w4IOVgxKZ0/exg==, tarball: https://registry.npmjs.org/turbo-windows-arm64/-/turbo-windows-arm64-2.5.0.tgz}cpu: [arm64]os: [win32]@@ -10820,7 +10918,7 @@ packages:hasBin: true- resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==}+ resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==, tarball: https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz}engines: {node: '>=14.17'}hasBin: true@@ -10833,7 +10931,7 @@ packages:resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==}- resolution: {integrity: sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==}+ resolution: {integrity: sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==, tarball: https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz}engines: {node: '>=0.8.0'}hasBin: true@@ -11070,7 +11168,7 @@ packages:eslint: ^8.57.0 || ^9.0.0- resolution: {integrity: sha512-f0ZgN+mZ5KFgVv9wz0f4OgVKukoXtS3nwET4c2vLBGQR50aI8G0cqbFtLlX9Yiyg3LFGBitruPHt2PxwTduJEw==}+ resolution: {integrity: sha512-f0ZgN+mZ5KFgVv9wz0f4OgVKukoXtS3nwET4c2vLBGQR50aI8G0cqbFtLlX9Yiyg3LFGBitruPHt2PxwTduJEw==, tarball: https://registry.npmjs.org/vue/-/vue-3.4.38.tgz}peerDependencies:typescript: '*'peerDependenciesMeta: