Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sheets): filter #1465

Merged
merged 52 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4ec38c4
feat(sheets): support filters for sheet
wzhudev Mar 4, 2024
1c7777f
fix: fix filter rebase error
wzhudev Apr 18, 2024
b61f422
fix: type errors
wzhudev Apr 18, 2024
43a4593
fix: fix merged cells
wzhudev Apr 18, 2024
7fde738
fix: fix panel related issues
wzhudev Apr 18, 2024
b98d344
fix: fix finding
wzhudev Apr 18, 2024
fd13c17
fix: fix removing first row interceptor
wzhudev Apr 18, 2024
fddb995
fix: fix type error
wzhudev Apr 18, 2024
428add2
fix: fix filter skeleton
wzhudev Apr 18, 2024
3c5f812
fix: fix type and lint errors
wzhudev Apr 18, 2024
eec1592
fix: fix tests
wzhudev Apr 18, 2024
79ef022
fix: regex filter matching with more tests
wzhudev Apr 18, 2024
dfe90fd
fix: fix cell empty assertion
wzhudev Apr 18, 2024
9322298
fix: move-range will move filter if its entirely contained
yuhongz Apr 19, 2024
67ed980
fix: rich text has trim
wzhudev Apr 19, 2024
05e07b1
fix: fix cancel click button
wzhudev Apr 19, 2024
be7c231
fix: fix numerical filters
wzhudev Apr 19, 2024
ba60e58
fix: insert/remove row will make filterColumn recalc
yuhongz Apr 19, 2024
13811d7
fix: fix filter performance
wzhudev Apr 19, 2024
75f223b
fix: clipborad copy should use raw celldata
yuhongz Apr 19, 2024
720ed6d
fix: type
yuhongz Apr 19, 2024
d1e5354
fix: type
yuhongz Apr 20, 2024
e9ce82a
fix: filterout rows will shift if insert/remove rows
yuhongz Apr 20, 2024
5beb29c
fix: unexpected null-value
yuhongz Apr 20, 2024
999058e
fix: selection drag not working when filter range exist
yuhongz Apr 20, 2024
d53e324
chore: double registery
yuhongz Apr 22, 2024
65fff99
fix: filterOutRows error if remove one filter column
yuhongz Apr 23, 2024
f493368
fix: close editor when filter panel opens
wzhudev Apr 23, 2024
6cd5905
fix: get cell value for conditioning
wzhudev Apr 23, 2024
1768456
fix: fix operator not_equals
wzhudev Apr 23, 2024
0b81bd8
fix: i18n
yuhongz Apr 23, 2024
b7d4600
chore: update redi
yuhongz Apr 23, 2024
6cbbc3e
fix: lock
yuhongz Apr 23, 2024
fe4ce5a
test: fix
yuhongz Apr 23, 2024
aba71d9
fix: remove row will not remove filter out rows
yuhongz Apr 23, 2024
0bafc23
fix: remove rows will not remove filteroutrows
yuhongz Apr 24, 2024
370b4d8
fix: filterout row will not leak if refresh
yuhongz Apr 24, 2024
819f8ba
feat: not allowed move range when filtered
yuhongz Apr 24, 2024
18227db
fix: lint
yuhongz Apr 24, 2024
8c7351a
fix: lock
yuhongz Apr 24, 2024
b81aa4b
chore: disable e2e test
yuhongz Apr 25, 2024
3edadd3
chore: enable e2e test
yuhongz Apr 25, 2024
2ffc1b9
chore: disable part e2e test
yuhongz Apr 25, 2024
6da096c
fix: memory leak in code and CI
wzhudev Apr 25, 2024
2f0c035
Merge remote-tracking branch 'origin/dev' into wzhudev/feat-filter
wzhudev Apr 25, 2024
e2cde34
fix: move range filter
yuhongz Apr 25, 2024
a0ee2b7
fix: filter out rows leak
yuhongz Apr 25, 2024
92f6b41
fix: first row error
yuhongz Apr 25, 2024
50f15be
fix: filter merged cell
wzhudev Apr 25, 2024
04cc78c
fix: delete row has filteroutrows
yuhongz Apr 25, 2024
d960a09
fix: dv copy paste
yuhongz Apr 25, 2024
e7299e7
fix: cf copy paste
yuhongz Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: false,
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
Loading