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(filter-ui): refactor less to tailwindcss (#5063)
Wenzhao Hu1783aca0cd67
diff --git a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.pngindex b75c3f2057..6c87f303fb 100644Binary files a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png and b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png differdiff --git a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.pngindex f9f987a6bc..1c5c0270d9 100644Binary files a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png differdiff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.pngindex f9f987a6bc..d532b2f213 100644Binary files a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png differdiff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsxindex 0b449de0d8..113b9663db 100644--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx@@ -24,8 +24,6 @@ import { useDependency, useObservable } from '@univerjs/ui';import React, { useCallback, useMemo } from 'react';import { FilterConditionItems } from '../../models/conditions';-import styles from './index.module.less';-/*** Filter by conditions.*/@@ -75,17 +73,29 @@ export function FilterByCondition(props: { model: ByConditionsModel }) {}return (- <div className={styles.sheetsFilterPanelConditionsContainer}>+ <div+ data-univer-comp-sheets-filter-panel-conditions-container+ className="univer-flex univer-h-full univer-flex-col"+ >{/* primary condition */}{(condition && formParams) && (<><Select value={condition.operator} options={primaryOptions} onChange={onPrimaryConditionChange} />{FilterConditionItems.getItemByOperator(condition.operator).numOfParameters !== 0? (- <div className={styles.sheetsFilterPanelConditionsContainerInner}>+ <div+ data-univer-comp-sheets-filter-panel-conditions-container-inner+ className={`+ univer-flex-grow univer-overflow-hidden univer-rounded-md univer-border+ univer-border-gray-200 univer-p-2+ `}+ >{condition.numOfParameters >= 1 && renderSecondaryCondition(formParams.operator1!, formParams.val1 ?? '', 'operator1')}{condition.numOfParameters >= 2 && renderSecondaryCondition(formParams.operator2!, formParams.val2 ?? '', 'operator2')}- <div className={styles.sheetsFilterPanelConditionsDesc}>+ <div+ data-univer-comp-sheets-filter-panel-conditions-desc+ className="univer-mt-[-6px] univer-text-xs univer-text-gray-500"+ >{localeService.t('sheets-filter.panel.?')}<br />{localeService.t('sheets-filter.panel.*')}@@ -140,9 +150,7 @@ function usePrimaryOptions(localeService: LocaleService): ISelectProps['options'{ label: localeService.t(FilterConditionItems.CUSTOM.label), value: FilterConditionItems.CUSTOM.operator },],},- ] as ISelectProps['options'],- // eslint-disable-next-line react-hooks/exhaustive-deps- [locale, localeService]);+ ] as ISelectProps['options'], [locale, localeService]);}function useSecondaryOptions(localeService: LocaleService): ISelectProps['options'] {@@ -150,7 +158,5 @@ function useSecondaryOptions(localeService: LocaleService): ISelectProps['optionreturn useMemo(() => FilterConditionItems.ALL_CONDITIONS.filter((c) => c.numOfParameters !== 2)- .map((c) => ({ label: localeService.t(c.label), value: c.operator })) as ISelectProps['options'],- // eslint-disable-next-line react-hooks/exhaustive-deps- [locale, localeService]);+ .map((c) => ({ label: localeService.t(c.label), value: c.operator })) as ISelectProps['options'], [locale, localeService]);}diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterByValuesPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterByValuesPanel.tsxindex 1a49d2dbfd..4acde672de 100644--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterByValuesPanel.tsx+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterByValuesPanel.tsx@@ -20,7 +20,6 @@ import { Checkbox, Input, Tree } from '@univerjs/design';import { useDependency, useObservable } from '@univerjs/ui';import React, { useCallback } from 'react';import { statisticFilterByValueItems } from '../../models/utils';-import styles from './index.module.less';/*** Filter by values.@@ -62,7 +61,10 @@ export function FilterByValue(props: { model: ByValuesModel }) {}return (- <div className={styles.sheetsFilterPanelValuesContainer}>+ <div+ data-univer-comp-sheets-filter-panel-values-container+ className="univer-flex univer-h-full univer-flex-col"+ ><InputautoFocusvalue={searchText}@@ -70,29 +72,52 @@ export function FilterByValue(props: { model: ByValuesModel }) {onChange={onSearchValueChange}/><div+ data-univer-comp-sheets-filter-panelclassName={`univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hiddenuniver-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-px-2 univer-py-2.5`}>- {/* The on-top select all button */}- <div className={styles.sheetsFilterPanelValuesItem}>- <div className={styles.sheetsFilterPanelValuesItemInner}>+ {/* The on-top "Select All" button */}+ <div+ data-univer-comp-sheets-filter-panel-values-item+ className="univer-box-border univer-h-8 univer-w-full univer-py-0.5"+ >+ <div+ data-univer-comp-sheets-filter-panel-values-item-inner+ className={`+ univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-pb-0+ univer-pl-5 univer-pr-0.5 univer-pt-0 univer-text-[13px]+ `}+ ><Checkboxindeterminate={indeterminate}disabled={items.length === 0}checked={allChecked}onChange={onCheckAllToggled}/>- <span className={styles.sheetsFilterPanelValuesItemText}>+ <span+ data-univer-comp-sheets-filter-panel-values-item-text+ className={`+ univer-mx-1 univer-inline-block univer-flex-shrink univer-overflow-hidden+ univer-text-ellipsis univer-whitespace-nowrap univer-text-gray-950+ dark:univer-text-white+ `}+ >{`${localeService.t('sheets-filter.panel.select-all')}`}</span>- <span className={styles.sheetsFilterPanelValuesItemCount}>+ <span+ data-univer-comp-sheets-filter-panel-values-item-count+ className={`+ univer-text-gray-400+ dark:univer-text-gray-500+ `}+ >{`(${stat.checked}/${stat.checked + stat.unchecked})`}</span></div></div>- <div className={styles.sheetsFilterPanelValuesVirtual}>+ <div data-univer-comp-sheets-filter-panel-values-virtual className="univer-flex-grow"><Treedata={items}defaultExpandAll={false}@@ -107,6 +132,8 @@ export function FilterByValue(props: { model: ByValuesModel }) {univer-pr-2 univer-border-box univer-max-w-[245px] univer-rounded-md[&:hover_a]:univer-inline-blockhover:univer-bg-gray-50 univer-h-full+ univer-text-gray-950+ dark:univer-text-white`}attachRender={(item) => (<div@@ -115,7 +142,15 @@ export function FilterByValue(props: { model: ByValuesModel }) {univer-items-center univer-justify-between univer-text-[13px] univer-text-primary-500`}>- <span className={styles.sheetsFilterPanelValuesItemCount}>{`(${item.count})`}</span>+ <span+ data-univer-comp-sheets-filter-panel-values-item-count+ className={`+ univer-text-gray-400+ dark:univer-text-gray-500+ `}+ >+ {`(${item.count})`}+ </span><aclassName={`univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsxindex b99221c0d8..e7477e9395 100644--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx@@ -24,7 +24,6 @@ import { useCallback, useMemo } from 'react';import { of } from 'rxjs';import { ChangeFilterByOperation, CloseFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';import { FilterBy, SheetsFilterPanelService } from '../../services/sheets-filter-panel.service';-import styles from './index.module.less';import { FilterByCondition } from './SheetsFilterByConditionsPanel';import { FilterByValue } from './SheetsFilterByValuesPanel';@@ -70,12 +69,22 @@ export function FilterPanel() {const FilterPanelEmbedPointPart = useComponentsOfPart(SheetsUIPart.FILTER_PANEL_EMBED_POINT);return (- <div className={styles.sheetsFilterPanel}>+ <div+ data-u-comp-sheets-filter-panel+ className={`+ univer-box-border univer-flex univer-h-[432px] univer-w-[312px] univer-flex-col univer-overflow-hidden+ univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg+ dark:univer-bg-black+ `}+ ><ComponentContainercomponents={FilterPanelEmbedPointPart}sharedProps={{ range, colIndex, onClose: onCancel }}/>- <div className={styles.sheetsFilterPanelHeader}>+ <div+ data-u-comp-sheets-filter-panel-header+ className="univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0"+ ><Segmentedvalue={filterBy}items={items}@@ -84,7 +93,10 @@ export function FilterPanel() {</div>{filterByModel? (- <div className={styles.sheetsFilterPanelContent}>+ <div+ data-u-comp-sheets-filter-panel-content+ className="univer-flex-shrink univer-flex-grow univer-overflow-hidden univer-pt-2"+ >{filterBy === FilterBy.VALUES? <FilterByValue model={filterByModel as ByValuesModel} />: <FilterByCondition model={filterByModel as ByConditionsModel} />}@@ -93,7 +105,13 @@ export function FilterPanel() {: (<div style={{ flex: 1 }} />)}- <div className={styles.sheetsFilterPanelFooter}>+ <div+ data-u-comp-sheets-filter-panel-footer+ className={`+ univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrap+ univer-justify-between univer-overflow-hidden+ `}+ ><Button variant="link" onClick={onClearCriteria} disabled={clearFilterDisabled}>{localeService.t('sheets-filter.panel.clear-filter')}</Button>diff --git a/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx b/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsxindex 2e6498bf6f..dccb1bb7a3 100644--- a/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx+++ b/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx@@ -29,8 +29,8 @@ export interface IEmbedSortBtnProps {onClose: () => void;}-export default function EmbedSortBtn(props: any) {- const { range, colIndex, onClose } = props as IEmbedSortBtnProps;+export default function EmbedSortBtn(props: IEmbedSortBtnProps) {+ const { range, colIndex, onClose } = props;const sheetsSortUIService = useDependency(SheetsSortUIService);const univerInstanceService = useDependency(IUniverInstanceService);@@ -44,11 +44,18 @@ export default function EmbedSortBtn(props: any) {} else {console.warn(`Cannot find the target to sort. unitId: ${unitId}, subUnitId: ${subUnitId}, range: ${range}, colIndex: ${colIndex}`);}+onClose();}, [range, colIndex, sheetsSortUIService, univerInstanceService, onClose]);return (- <div className={styles.embedSortBtnContainer}>+ <div+ data-univer-comp-embed-sort-btn-container+ className={`+ univer-mb-3 univer-flex univer-w-full univer-items-center univer-justify-center univer-py-[6px]+ univer-text-sm+ `}+ ><divclassName={`${styles.embedSortBtn}diff --git a/packages/sheets-sort-ui/src/views/index.module.less b/packages/sheets-sort-ui/src/views/index.module.lessindex f477a55cee..04f9b805de 100644--- a/packages/sheets-sort-ui/src/views/index.module.less+++ b/packages/sheets-sort-ui/src/views/index.module.less@@ -110,8 +110,6 @@}.embed-sort-btn-container {- display: flex;- margin-bottom: 12px;.embed-sort-btn {font-size: 13px;font-style: normal;diff --git a/packages/sheets/src/commands/commands/utils/target-util.ts b/packages/sheets/src/commands/commands/utils/target-util.tsindex 510146d8c8..7bc8c7e8f4 100644--- a/packages/sheets/src/commands/commands/utils/target-util.ts+++ b/packages/sheets/src/commands/commands/utils/target-util.ts@@ -14,7 +14,8 @@* limitations under the License.*/-import { type IUniverInstanceService, type Nullable, UniverInstanceType, type Workbook, type Worksheet } from '@univerjs/core';+import type { IUniverInstanceService, Nullable, Workbook, Worksheet } from '@univerjs/core';+import { UniverInstanceType } from '@univerjs/core';export function getSheetCommandTargetWorkbook(univerInstanceService: IUniverInstanceService, params: { unitId?: string }): Nullable<{workbook: Workbook;@@ -22,8 +23,8 @@ export function getSheetCommandTargetWorkbook(univerInstanceService: IUniverInst}> {const { unitId } = params;const workbook = unitId- ? univerInstanceService.getUniverSheetInstance(unitId)- : univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET);+ ? univerInstanceService.getUnit<Workbook>(unitId, UniverInstanceType.UNIVER_SHEET)+ : univerInstanceService.getCurrentUnitOfType<Workbook>(UniverInstanceType.UNIVER_SHEET);if (!workbook) return null;@@ -54,8 +55,8 @@ export function getSheetCommandTarget(univerInstanceService: IUniverInstanceServconst { unitId, subUnitId } = params;const workbook = unitId- ? univerInstanceService.getUniverSheetInstance(unitId)- : univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET);+ ? univerInstanceService.getUnit<Workbook>(unitId, UniverInstanceType.UNIVER_SHEET)+ : univerInstanceService.getCurrentUnitOfType<Workbook>(UniverInstanceType.UNIVER_SHEET);if (!workbook) return null;const worksheet = subUnitId ? workbook.getSheetBySheetId(subUnitId) : workbook.getActiveSheet(true);@@ -74,7 +75,7 @@ export function getSheetCommandTarget(univerInstanceService: IUniverInstanceServexport function getSheetMutationTarget(univerInstanceService: IUniverInstanceService, params: { unitId: string; subUnitId: string }): Nullable<Pick<IResult, 'workbook' | 'worksheet'>> {const { unitId, subUnitId } = params;- const workbook = univerInstanceService.getUniverSheetInstance(unitId);+ const workbook = univerInstanceService.getUnit<Workbook>(unitId, UniverInstanceType.UNIVER_SHEET);if (!workbook) return null;const worksheet = workbook.getSheetBySheetId(subUnitId);diff --git a/packages/ui/src/services/parts/parts.service.ts b/packages/ui/src/services/parts/parts.service.tsindex 1c9f46fda1..647797fe0b 100644--- a/packages/ui/src/services/parts/parts.service.ts+++ b/packages/ui/src/services/parts/parts.service.ts@@ -15,9 +15,10 @@*/import type { IDisposable } from '@univerjs/core';+import type { Observable } from 'rxjs';import type { ComponentType } from '../../common/component-manager';import { createIdentifier, Disposable, toDisposable } from '@univerjs/core';-import { type Observable, Subject } from 'rxjs';+import { Subject } from 'rxjs';export type ComponentRenderer = () => ComponentType;type ComponentPartKey = BuiltInUIPart | string;@@ -76,7 +77,7 @@ export class UIPartsService extends Disposable implements IUIPartsService {return this._uiVisible.get(part) ?? true;}- registerComponent(part: ComponentPartKey, componentFactory: () => React.ComponentType): IDisposable {+ registerComponent<T>(part: ComponentPartKey, componentFactory: () => React.ComponentType<T>): IDisposable {const componentType = componentFactory();const components = (this._componentsByPart.get(part)diff --git a/packages/ui/src/views/components/ribbon/ToolbarItem.tsx b/packages/ui/src/views/components/ribbon/ToolbarItem.tsxindex b2ed9134fe..45270cacb0 100644--- a/packages/ui/src/views/components/ribbon/ToolbarItem.tsx+++ b/packages/ui/src/views/components/ribbon/ToolbarItem.tsx@@ -240,12 +240,16 @@ export const ToolbarItem = forwardRef<ITooltipWrapperRef, IDisplayMenuItem<IMenu}return !hidden && (- <TooltipWrapper- ref={ref}- title={tooltipTitle}- placement="bottom"- >- {renderItem()}- </TooltipWrapper>+ tooltipTitle+ ? (+ <TooltipWrapper+ ref={ref}+ title={tooltipTitle}+ placement="bottom"+ >+ {renderItem()}+ </TooltipWrapper>+ )+ : renderItem());});