Skip to content

Commit

Permalink
feat(sheets): filter (#1465)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: YuHong <csuzyh@gmail.com>
  • Loading branch information
wzhudev and yuhongz committed Apr 25, 2024
1 parent 63b1e83 commit 1f03b7a
Show file tree
Hide file tree
Showing 190 changed files with 14,450 additions and 2,615 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"endindex",
"esbuild",
"evented",
"excalidraw",
"execa",
"EXTRALIGHT",
"FONTFACE",
Expand Down Expand Up @@ -70,6 +71,7 @@
"numfmt",
"opencollective",
"opentype",
"OOXML",
"Overlines",
"Pacifico",
"Plass",
Expand Down
2 changes: 2 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"@univerjs/sheets-conditional-formatting": "workspace:*",
"@univerjs/sheets-conditional-formatting-ui": "workspace:*",
"@univerjs/sheets-data-validation": "workspace:*",
"@univerjs/sheets-filter": "workspace:*",
"@univerjs/sheets-filter-ui": "workspace:*",
"@univerjs/sheets-find-replace": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
"@univerjs/sheets-numfmt": "workspace:*",
Expand Down
163 changes: 161 additions & 2 deletions examples/src/data/sheets/demo/default-workbook-data-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13976,6 +13976,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
5: {
5: {
s: 'uJSelZ11',
v: 'sadf',
},
6: {
s: 'uJSelZ11',
Expand All @@ -13993,6 +13994,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
6: {
5: {
s: 'uJSelZ22',
v: '123123',
},
6: {
s: 'uJSelZ22',
Expand All @@ -14005,8 +14007,100 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
},
},
10: {},
11: {},
11: {
4: {
v: 123,
t: 2,
},
},
12: {
4: {
v: '123tu',
t: 1,
},
5: {
v: 'sdfj',
t: 1,
},
},
13: {
4: {
v: 'ghj',
t: 1,
},
5: {
v: 'ghk',
t: 1,
},
},
17: {
4: {
v: 'fh',
t: 1,
},
5: {
v: 'jk',
t: 1,
},
},
18: {
4: {
v: 'dfg',
t: 1,
},
5: {
v: 'l',
t: 1,
},
},
19: {
4: {
v: 'sdfg',
t: 1,
},
5: {
v: 'h',
t: 1,
},
},
20: {
4: {
v: 'fdgh',
t: 1,
},
5: {
v: 345,
t: 2,
},
},
21: {
4: {
v: 'sgh',
t: 1,
},
5: {
v: 'fgs',
t: 1,
},
},
22: {
4: {
v: 'sdfh',
t: 1,
},
5: {
v: 'gth',
t: 1,
},
},
23: {
5: {
v: 'iop',
t: 1,
},
},
},

freeze: {
xSplit: 0,
ySplit: 0,
Expand All @@ -14019,6 +14113,21 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
defaultRowHeight: 19,
mergeData: [],
rowData: {
11: {
hd: 0,
h: 19,
ah: 19,
},
12: {
hd: 0,
h: 19,
ah: 19,
},
13: {
hd: 0,
h: 19,
ah: 19,
},
14: {
hd: 1,
},
Expand All @@ -14028,6 +14137,41 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
16: {
hd: 1,
},
17: {
hd: 0,
h: 19,
ah: 19,
},
18: {
hd: 0,
h: 19,
ah: 19,
},
19: {
hd: 0,
h: 19,
ah: 19,
},
20: {
hd: 0,
h: 19,
ah: 19,
},
21: {
hd: 0,
h: 19,
ah: 19,
},
22: {
hd: 0,
h: 19,
ah: 19,
},
23: {
hd: 0,
h: 19,
ah: 19,
},
},
columnData: {},
showGridlines: 1,
Expand All @@ -14039,7 +14183,9 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: 0,
},
selections: ['A1'],
selections: [
'A1',
],
rightToLeft: 0,
},
'sheet-0010': {
Expand Down Expand Up @@ -23400,6 +23546,19 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
'sheet-0011': dataValidation,
}),
},
{
name: 'SHEET_AUTO_FILTER',
data: JSON.stringify({
'sheet-0011': {
ref: {
startRow: 11,
endRow: 23,
startColumn: 4,
endColumn: 6,
},
},
}),
},
],
// namedRanges: [
// {
Expand Down
2 changes: 2 additions & 0 deletions examples/src/sheets/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import type { Plugin, PluginCtor } from '@univerjs/core';
import { UniverSheetsFilterUIPlugin } from '@univerjs/sheets-filter-ui';
import { UniverUniscriptPlugin } from '@univerjs/uniscript';

export default function getLazyPlugins(): Array<[PluginCtor<Plugin>] | [PluginCtor<Plugin>, unknown]> {
Expand All @@ -31,5 +32,6 @@ export default function getLazyPlugins(): Array<[PluginCtor<Plugin>] | [PluginCt
},
},
],
[UniverSheetsFilterUIPlugin],
];
}
8 changes: 5 additions & 3 deletions examples/src/sheets/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import { enUS as UniverSheetsFormulaEnUS } from '@univerjs/sheets-formula';
import { enUS as UniverSheetsDataValidationEnUS } from '@univerjs/sheets-data-validation';
import { enUS as UniverSheetsConditionalFormattingUIEnUS } from '@univerjs/sheets-conditional-formatting-ui';
import { enUS as UniverSheetsZenEditorEnUS } from '@univerjs/sheets-zen-editor';
import { enUS as UniverUiEnUS } from '@univerjs/ui';
import { enUS as UniverUIEnUS } from '@univerjs/ui';
import { enUS as UniverSheetsFilterUIEnUS } from '@univerjs/sheets-filter-ui';

export const locales = {
[LocaleType.EN_US]: Tools.deepMerge(
Expand All @@ -36,7 +37,8 @@ export const locales = {
UniverSheetsDataValidationEnUS,
UniverSheetsConditionalFormattingUIEnUS,
UniverSheetsZenEditorEnUS,
UniverUiEnUS,
UniverDesignEnUS
UniverUIEnUS,
UniverDesignEnUS,
UniverSheetsFilterUIEnUS
),
};
17 changes: 14 additions & 3 deletions examples/src/sheets/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { UniverDocsPlugin } from '@univerjs/docs';
import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
import { UniverFindReplacePlugin } from '@univerjs/find-replace';
import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import type { IUniverRPCMainThreadConfig } from '@univerjs/rpc';
import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsPlugin } from '@univerjs/sheets';
Expand All @@ -33,8 +35,8 @@ import { UniverDataValidationPlugin } from '@univerjs/data-validation';
import { UniverSheetsDataValidationPlugin } from '@univerjs/sheets-data-validation';
import { UniverSheetsConditionalFormattingUIPlugin } from '@univerjs/sheets-conditional-formatting-ui';

import { DebuggerPlugin } from '../plugins/debugger';
import { DEFAULT_WORKBOOK_DATA_DEMO } from '../data/sheets/demo/default-workbook-data-demo';
import { DebuggerPlugin } from '../plugins/debugger';
import { locales } from './locales';

/* eslint-disable-next-line node/prefer-global/process */
Expand Down Expand Up @@ -69,7 +71,6 @@ univer.registerPlugin(UniverSheetsUIPlugin);
// sheet feature plugins

univer.registerPlugin(UniverSheetsNumfmtPlugin);
univer.registerPlugin(DebuggerPlugin);
univer.registerPlugin(UniverSheetsZenEditorPlugin);
univer.registerPlugin(UniverFormulaEnginePlugin, {
notExecuteFormula: true,
Expand All @@ -79,10 +80,16 @@ univer.registerPlugin(UniverRPCMainThreadPlugin, {
workerURL: './worker.js',
} as IUniverRPCMainThreadConfig);

// find replace
univer.registerPlugin(UniverFindReplacePlugin);
univer.registerPlugin(UniverSheetsFindReplacePlugin);

// data validation
univer.registerPlugin(UniverDataValidationPlugin);
univer.registerPlugin(UniverSheetsDataValidationPlugin);
univer.registerPlugin(UniverSheetsFindReplacePlugin);

// filter
univer.registerPlugin(UniverSheetsFilterPlugin);

// sheet condition formatting
univer.registerPlugin(UniverSheetsConditionalFormattingUIPlugin);
Expand All @@ -100,6 +107,10 @@ if (!IS_E2E) {
// univer.createUnit(UniverInstanceType.SHEET, DEFAULT_WORKBOOK_DATA_DEMO);
// }, 7000);


// debugger plugin
univer.registerPlugin(DebuggerPlugin);

declare global {
interface Window {
univer?: Univer;
Expand Down
2 changes: 2 additions & 0 deletions examples/src/sheets/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { LocaleType, Univer } from '@univerjs/core';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRPCWorkerThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsPlugin } from '@univerjs/sheets';
import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';

// Univer web worker is also a univer application.
const univer = new Univer({
Expand All @@ -27,6 +28,7 @@ const univer = new Univer({
univer.registerPlugin(UniverSheetsPlugin);
univer.registerPlugin(UniverFormulaEnginePlugin);
univer.registerPlugin(UniverRPCWorkerThreadPlugin);
univer.registerPlugin(UniverSheetsFilterPlugin);

declare let self: WorkerGlobalScope & typeof globalThis & { univer: Univer };
self.univer = univer;
19 changes: 19 additions & 0 deletions packages/core/src/common/boolean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2023-present DreamNum Inc.
*
* 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 function isBooleanString(str: string): boolean {
return ['true', 'false'].includes(str.toLowerCase());
}
4 changes: 2 additions & 2 deletions packages/core/src/common/interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export interface IInterceptor<M, C> {
handler: InterceptorHandler<M, C>;
}

export const createInterceptorKey = <T = any, C = any>(key: string) => {
export function createInterceptorKey<T, C>(key: string): IInterceptor<T, C> {
const symbol = `sheet_interceptor_${key}`;
return symbol as unknown as IInterceptor<T, C>;
return symbol as unknown as IInterceptor<T, C>; // FIXME: priority and handler is completely missing?
};

export type IComposeInterceptors<T = any, C = any> = (
Expand Down
Loading

0 comments on commit 1f03b7a

Please sign in to comment.