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
refactor(sort): move styles to tailwindcss (#5081)
Wenzhao Hu3053ed0f1d36
diff --git a/packages/design/src/components/button/index.ts b/packages/design/src/components/button/index.tsindex 3ef196b383..f8685c9805 100644--- a/packages/design/src/components/button/index.ts+++ b/packages/design/src/components/button/index.ts@@ -15,3 +15,4 @@*/export { Button, type IButtonProps } from './Button';+export { ButtonGroup, type IButtonGroupProps } from './ButtonGroup';diff --git a/packages/design/src/index.ts b/packages/design/src/index.tsindex 6c5fe680ed..bcae316366 100644--- a/packages/design/src/index.ts+++ b/packages/design/src/index.ts@@ -17,7 +17,7 @@import './global.css';export { Avatar, type IAvatarProps } from './components/avatar';-export { Button, type IButtonProps } from './components/button';+export { Button, ButtonGroup, type IButtonGroupProps, type IButtonProps } from './components/button';export { CascaderList, type ICascaderListProps, type ICascaderOption } from './components/cascader-list';export { Checkbox, type ICheckboxProps } from './components/checkbox';export { CheckboxGroup, type ICheckboxGroupProps } from './components/checkbox-group';diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsxindex 113b9663db..25debb9a78 100644--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx@@ -65,7 +65,7 @@ export function FilterByCondition(props: { model: ByConditionsModel }) {<Select value={operator} options={secondaryOptions} onChange={(operator) => onFormParamsChange({ [name]: operator as FilterOperator })} />{shouldRenderInput && (<div>- <Input value={val} placeholder={placeholder} onChange={(value) => onFormParamsChange({ [name === 'operator1' ? 'val1' : 'val2']: value })} />+ <Input className="univer-mt-2" value={val} placeholder={placeholder} onChange={(value) => onFormParamsChange({ [name === 'operator1' ? 'val1' : 'val2']: value })} /></div>)}</>@@ -87,14 +87,14 @@ export function FilterByCondition(props: { model: ByConditionsModel }) {data-univer-comp-sheets-filter-panel-conditions-container-innerclassName={`univer-flex-grow univer-overflow-hidden univer-rounded-md univer-border- univer-border-gray-200 univer-p-2+ univer-border-gray-200 univer-p-2 univer-border-solid univer-mt-2`}>{condition.numOfParameters >= 1 && renderSecondaryCondition(formParams.operator1!, formParams.val1 ?? '', 'operator1')}{condition.numOfParameters >= 2 && renderSecondaryCondition(formParams.operator2!, formParams.val2 ?? '', 'operator2')}<divdata-univer-comp-sheets-filter-panel-conditions-desc- className="univer-mt-[-6px] univer-text-xs univer-text-gray-500"+ className="univer-mt-2 univer-text-xs univer-text-gray-500">{localeService.t('sheets-filter.panel.?')}<br />diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsxindex 2c7d72e74d..13dcbdea23 100644--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx@@ -15,13 +15,13 @@*/import type { Meta } from '@storybook/react';-import type { Injector, IWorkbookData } from '@univerjs/core';+import type { IWorkbookData } from '@univerjs/core';import type { IOpenFilterPanelOperationParams } from '../../commands/operations/sheets-filter.operation';-import { CommandType, ICommandService, ILogService, LocaleService, LocaleType, LogLevel, Plugin, Univer, UniverInstanceType } from '@univerjs/core';+import { CommandType, ICommandService, ILogService, Inject, Injector, LocaleService, LocaleType, LogLevel, Plugin, registerDependencies, Univer, UniverInstanceType } from '@univerjs/core';import { RefRangeService, SheetInterceptorService, SheetsSelectionsService, WorksheetProtectionPointModel } from '@univerjs/sheets';import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SetSheetsFilterCriteriaCommand, SmartToggleSheetsFilterCommand, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';import { SetCellEditVisibleOperation } from '@univerjs/sheets-ui';-import { IShortcutService, RediContext, ShortcutService } from '@univerjs/ui';+import { IShortcutService, IUIPartsService, RediContext, ShortcutService, UIPartsService } from '@univerjs/ui';import React, { useState } from 'react';import { WithCustomFilterModelFactory, WithValuesFilterModelFactory } from '../../__testing__/data';import { ChangeFilterByOperation, CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';@@ -53,21 +53,27 @@ function createFilterStorybookBed(workbookData: IWorkbookData, locale: LocaleTypstatic override type = UniverInstanceType.UNIVER_SHEET;static override pluginName = 'test-plugin';- constructor(_config: unknown, override readonly _injector: Injector) {+ constructor(+ _config: unknown,+ @Inject(Injector) protected readonly _injector: Injector+ ) {super();}override onStarting(): void {const injector = this._injector;- injector.add([SheetsSelectionsService]);- injector.add([IShortcutService, { useClass: ShortcutService }]);- injector.add([WorksheetProtectionPointModel]);- injector.add([SheetInterceptorService]);- injector.add([SheetsFilterPanelService]);- injector.add([RefRangeService]);- const commandService = injector.get(ICommandService);+ registerDependencies(injector, [+ [SheetsSelectionsService],+ [IShortcutService, { useClass: ShortcutService }],+ [IUIPartsService, { useClass: UIPartsService }],+ [WorksheetProtectionPointModel],+ [SheetInterceptorService],+ [SheetsFilterPanelService],+ [RefRangeService],+ ]);+ const commandService = injector.get(ICommandService);[FakeCetCellEditVisibleOperation,SmartToggleSheetsFilterCommand,@@ -78,7 +84,10 @@ function createFilterStorybookBed(workbookData: IWorkbookData, locale: LocaleTypCloseFilterPanelOperation,ChangeFilterByOperation,].forEach((command) => commandService.registerCommand(command));+ }+ override onReady(): void {+ const commandService = injector.get(ICommandService);commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {unitId: 'test',subUnitId: 'sheet1',@@ -87,8 +96,8 @@ function createFilterStorybookBed(workbookData: IWorkbookData, locale: LocaleTyp}}- univer.registerPlugin(UniverSheetsFilterPlugin);univer.registerPlugin(TestPlugin);+ univer.registerPlugin(UniverSheetsFilterPlugin);injector.get(LocaleService).setLocale(locale);injector.get(LocaleService).load({ enUS, zhCN, ruRU });@@ -99,8 +108,6 @@ function createFilterStorybookBed(workbookData: IWorkbookData, locale: LocaleTypreturn { univer, injector, sheet };}-// TODO@ybzky: not working properly-export const FilterWithConditions = {render() {const [bed] = useState(() => createFilterStorybookBed(WithCustomFilterModelFactory()));diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsxindex e7477e9395..3558be2a68 100644--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx@@ -72,8 +72,8 @@ export function FilterPanel() {<divdata-u-comp-sheets-filter-panelclassName={`- 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+ univer-box-border univer-flex univer-h-[432px] univer-w-[312px] univer-flex-col univer-rounded-lg+ univer-bg-white univer-p-4 univer-shadow-lgdark:univer-bg-black`}>@@ -95,7 +95,7 @@ export function FilterPanel() {? (<divdata-u-comp-sheets-filter-panel-content- className="univer-flex-shrink univer-flex-grow univer-overflow-hidden univer-pt-2"+ className="univer-flex-shrink univer-flex-grow univer-pt-2">{filterBy === FilterBy.VALUES? <FilterByValue model={filterByModel as ByValuesModel} />diff --git a/packages/sheets-filter-ui/src/views/components/index.module.less b/packages/sheets-filter-ui/src/views/components/index.module.lessdeleted file mode 100644index 362dfd8f68..0000000000--- a/packages/sheets-filter-ui/src/views/components/index.module.less+++ /dev/null@@ -1,176 +0,0 @@-.sheets-filter-panel {- display: flex;- width: 312px;- height: 432px;- flex-direction: column;- background: rgb(var(--bg-color-secondary));- border-radius: 10px;- box-sizing: border-box;- box-shadow: var(--box-shadow-lg);- padding: 16px;- overflow: hidden;-- &-header {- flex-grow: 0;- flex-shrink: 0;- margin-bottom: 4px;- }-- &-content {- flex-grow: 1;- flex-shrink: 1;- overflow: hidden;- padding-top: 8px;- }-- &-select-all {- font-size: 13px;- margin-right: 4px;-- &-count {- font-size: 13px;- color: rgb(var(--grey-400));- }- }-- &-values {- &-container {- display: flex;- height: 100%;- flex-direction: column;-- > .input-affix-wrapper {- flex: 0 0 32px;- }-- .select,- .input-affix-wrapper,- .radio-group {- width: 100%;- }- }-- &-find {- height: 32px;- margin-bottom: 8px;- }-- &-virtual {- flex-grow: 1;- }-- &-item {- box-sizing: border-box;- height: 32px;- padding: 2px 0;- width: 100%;-- &-inner {- align-items: center;- padding: 0 2px 0 20px;- line-height: 28px;- box-sizing: border-box;- border-radius: 6px;- height: 28px;- display: flex;- font-size: 13px;-- &:hover {- background-color: rgb(var(--grey-50));-- .sheets-filter-panel-values-item-count {- margin-right: 2px;- }-- .sheets-filter-panel-values-item-exclude-button {- box-sizing: border-box;- margin-left: auto;- display: inline-block;- height: 24px;- font-size: 12px;- line-height: 12px;-- &:hover {- background-color: rgb(var(--hyacinth-50));- }-- &:active {- background-color: rgb(var(--hyacinth-100));- }- }- }- }-- &-text {- display: inline-block;- height: 100%;- margin: 0 4px;- flex-shrink: 1;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- }-- &-count {- color: rgb(var(--grey-400));- }-- &-exclude-button {- display: none;- }- }- }-- &-conditions {- &-container {- display: flex;- flex-direction: column;- height: 100%;-- .select,- .input-affix-wrapper,- .radio-group {- width: 100%;- margin-bottom: 8px;- }-- &-inner {- flex-grow: 1;- border-radius: 6px;- border: 1px solid rgb(var(--grey-200));- overflow: hidden;- padding: 8px;- }- }-- &-desc {- margin-top: -6px;- color: rgb(var(--grey-500));- font-size: 12px;- line-height: 18px;- }- }-- &-footer {- margin-top: 16px;- flex-grow: 0;- flex-shrink: 0;- display: inline-flex;- flex-wrap: nowrap;- overflow: hidden;-- justify-content: space-between;- }-- .select {- width: 100%;- }-- .input {- width: 100%;- }-- .form-dual-column-layout {- margin-bottom: 8px;- }-}diff --git a/packages/sheets-sort-ui/src/services/sheets-sort-ui.service.tsx b/packages/sheets-sort-ui/src/services/sheets-sort-ui.service.tsxindex 916d47b735..53c4e83065 100644--- a/packages/sheets-sort-ui/src/services/sheets-sort-ui.service.tsx+++ b/packages/sheets-sort-ui/src/services/sheets-sort-ui.service.tsx@@ -61,6 +61,7 @@ const SORT_ERROR_MESSAGE = {export class SheetsSortUIService extends Disposable {private readonly _customSortState$ = new BehaviorSubject<Nullable<ICustomSortState>>(null);readonly customSortState$ = this._customSortState$.asObservable();+constructor(@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,@IConfirmService private readonly _confirmService: IConfirmService,diff --git a/packages/sheets-sort-ui/src/views/CustomSortPanel.tsx b/packages/sheets-sort-ui/src/views/CustomSortPanel.tsxindex 947232c5e4..b8a3617c19 100644--- a/packages/sheets-sort-ui/src/views/CustomSortPanel.tsx+++ b/packages/sheets-sort-ui/src/views/CustomSortPanel.tsx@@ -16,16 +16,15 @@import type { IRange, Nullable } from '@univerjs/core';import type { IOrderRule } from '@univerjs/sheets-sort';+import type { ICustomSortState } from '../services/sheets-sort-ui.service';import { LocaleService, LocaleType, throttle } from '@univerjs/core';-import { Button, Checkbox, clsx, DraggableList, Dropdown, Radio, RadioGroup } from '@univerjs/design';+import { Button, Checkbox, DraggableList, Dropdown, Radio, RadioGroup } from '@univerjs/design';import { CheckMarkSingle, DeleteEmptySingle, IncreaseSingle, MoreDownSingle, SequenceSingle } from '@univerjs/icons';import { SheetsSortService, SortType } from '@univerjs/sheets-sort';-import { useDependency } from '@univerjs/ui';+import { useDependency, useObservable } from '@univerjs/ui';import { useCallback, useEffect, useRef, useState } from 'react';import { SheetsSortUIService } from '../services/sheets-sort-ui.service';-import styles from './index.module.less';-export interface ICustomSortPanelProps {range: IRange;onListChange: (value: IOrderRule[]) => void;@@ -33,18 +32,25 @@ export interface ICustomSortPanelProps {export function CustomSortPanel() {const sheetsSortUIService = useDependency(SheetsSortUIService);+ const state = useObservable(sheetsSortUIService.customSortState$);++ if (!state || !state.location) {+ return null;+ }++ return <CustomSortPanelImpl state={state} />;+}++function CustomSortPanelImpl({ state }: { state: ICustomSortState }) {const sheetsSortService = useDependency(SheetsSortService);const localeService = useDependency(LocaleService);+ const sheetsSortUIService = useDependency(SheetsSortUIService);const [hasTitle, setHasTitle] = useState(false);const [scrollPosition, setScrollPosition] = useState(0);const listEndRef = useRef<HTMLDivElement>(null);- const state = sheetsSortUIService.customSortState();- if (!state || !state.location) {- return null;- }- const { range, unitId, subUnitId } = state.location;+ const { range, unitId, subUnitId } = state.location!;const titles = sheetsSortUIService.getTitles(hasTitle);@@ -104,36 +110,42 @@ export function CustomSortPanel() {const dragList = list.map((item) => ({ ...item, id: `${item.colIndex}` }));return (- <div className={styles.customSortPanelContainer}>- <div className={styles.customSortPanelContent} onMouseDown={(e) => { e.stopPropagation(); }}>- <div className={styles.customSortPanelExt}>- <div className={styles.firstRowCheck}>- <Checkbox checked={hasTitle} onChange={(value) => setTitle(!!value)}>- {localeService.t('sheets-sort.dialog.first-row-check')}- </Checkbox>- </div>+ <div>+ <div onMouseDown={(e) => { e.stopPropagation(); }}>+ <div className="univer-flex univer-items-center univer-justify-between">+ <Checkbox checked={hasTitle} onChange={(value) => setTitle(!!value)}>+ {localeService.t('sheets-sort.dialog.first-row-check')}+ </Checkbox>{canNew? (- <div className={styles.addCondition} onClick={newItem}>+ <div+ className={`+ univer-flex univer-cursor-pointer univer-select-none univer-items-center+ univer-text-base+ `}+ onClick={newItem}+ ><IncreaseSingle />- <span className={styles.addConditionText}>{localeService.t('sheets-sort.dialog.add-condition')}</span>+ <span className="univer-ml-1.5">{localeService.t('sheets-sort.dialog.add-condition')}</span></div>): (<divclassName={`- ${styles.addCondition}- ${styles.addConditionDisable}+ univer-flex univer-cursor-pointer univer-select-none univer-items-center+ univer-text-base univer-text-primary-500+ disabled:univer-cursor-not-allowed disabled:univer-divide-opacity-30+ disabled:univer-text-gray-800`}><IncreaseSingle />- <span className={styles.addConditionText}>{localeService.t('sheets-sort.dialog.add-condition')}</span>+ <span className="univer-ml-1.5 univer-text-xs">{localeService.t('sheets-sort.dialog.add-condition')}</span></div>)}</div><div- className={styles.conditionList}+ className="univer-max-h-[310px] univer-overflow-y-auto univer-overflow-x-hidden"onScroll={(e) => {const position = e.currentTarget.scrollTop;setScrollPosition(position);@@ -144,7 +156,7 @@ export function CustomSortPanel() {list={dragList}onListChange={setList}idKey="id"- draggableHandle={`.${styles.customSortPanelItemHandler}`}+ draggableHandle='[data-u-comp="sort-panel-item-handler"]'itemRender={(item) => (<SortOptionItemtitles={titles}@@ -159,15 +171,15 @@ export function CustomSortPanel() {/></div></div>- <div className={styles.customSortPanelFooter}>+ <div className="univer-mt-5 univer-flex univer-justify-end"><Button- className={styles.customSortPanelFooterBtn}+ className="univer-ml-3"onClick={() => cancel()}>{localeService.t('sheets-sort.dialog.cancel')}</Button><Button- className={styles.customSortPanelFooterBtn}+ className="univer-ml-3"variant="primary"onClick={() => apply(list, hasTitle)}>@@ -211,28 +223,49 @@ export function SortOptionItem(props: ISortOptionItemProps) {const showDelete = list.length > 1;const itemLabel = titles.find((title) => title.index === item.colIndex)?.label;- const radioClass = localeService.getCurrentLocale() === LocaleType.ZH_CN ? styles.customSortPanelItemOrderRadioCn : styles.customSortPanelItemOrderRadio;+ const radioClass = localeService.getCurrentLocale() === LocaleType.ZH_CN ? 'univer-flex univer-px-5' : 'univer-flex univer-px-2.5';return (- <div className={styles.customSortPanelItem}>- <div className={styles.customSortPanelItemHead}>- <div className={styles.customSortPanelItemHandler}>+ <div className="univer-flex univer-items-center">+ <div className="univer-flex univer-items-center">+ <div+ data-u-comp="sort-panel-item-handler"+ className={`+ univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-text-base+ univer-text-gray-700+ `}+ ><SequenceSingle /></div>- <div className={styles.customSortPanelItemColumn}>+ <div>+ {/* TODO@wzhudev: change it to the Select component later. */}<Dropdownalign="start"overlay={(- <ul className={clsx(styles.customSortColMenu, 'univer-theme')}>+ <ul+ className={`+ univer-my-0 univer-box-border univer-grid univer-max-h-[310px] univer-items-center+ univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-rounded-lg+ univer-p-1 univer-theme univer-border univer-bg-white univer-text-base+ univer-shadow-lg+ `}+ >{availableMenu.map((menuItem) => (<likey={menuItem.index}onClick={() => handleChangeColIndex(menuItem)}- className={styles.customSortColMenuItem}+ className={`+ univer-relative univer-box-border univer-flex univer-h-7 univer-cursor-pointer+ univer-list-none univer-items-center univer-justify-between univer-rounded+ univer-px-2 univer-text-sm univer-transition-all+ hover:univer-bg-gray-100+ `}>- <span className={styles.customSortColMenuItemDesc}>+ <span+ className="univer-max-w-[220px] univer-truncate"+ >{menuItem.label}</span>- <span className={styles.customSortColMenuItemCheck}>+ <span>{menuItem.index === item.colIndex && (<CheckMarkSingle />)}@@ -244,14 +277,27 @@ export function SortOptionItem(props: ISortOptionItemProps) {open={visible}onOpenChange={onVisibleChange}>- <div className={styles.customSortPanelItemColumnInput}>- <span className={styles.customSortPanelItemColumnInputText}>{itemLabel}</span>- <MoreDownSingle className={styles.customSortPanelItemColumnInputDropdown} />+ <div+ className={`+ univer-ml-2 univer-flex univer-w-[236px] univer-items-center univer-justify-between+ univer-overflow-hidden univer-rounded-md univer-border univer-border-gray-200+ univer-px-2.5 univer-py-1.5 univer-text-sm univer-text-gray-900+ `}+ >+ <span+ className={`+ univer-max-w-[220px] univer-overflow-hidden univer-text-ellipsis+ univer-whitespace-nowrap+ `}+ >+ {itemLabel}+ </span>+ <MoreDownSingle className="univer-size-4 univer-text-gray-600" /></div></Dropdown></div></div>- <div className={styles.customSortPanelItemOrder}>+ <div><RadioGroupclassName={radioClass}value={item.type}@@ -263,8 +309,8 @@ export function SortOptionItem(props: ISortOptionItemProps) {<Radio value={SortType.DESC}>{localeService.t('sheets-sort.general.sort-desc')}</Radio></RadioGroup></div>- <div className={styles.customSortPanelItemRemove}>- { showDelete && <DeleteEmptySingle onClick={() => onChange(null, currentIndex)} />}+ <div className="univer-absolute univer-right-0 univer-cursor-pointer univer-text-sm univer-s-[14px]">+ {showDelete && <DeleteEmptySingle onClick={() => onChange(null, currentIndex)} />}</div></div>);diff --git a/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx b/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsxindex dccb1bb7a3..5096373d34 100644--- a/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx+++ b/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx@@ -16,12 +16,12 @@import type { IRange } from '@univerjs/core';import { IUniverInstanceService, LocaleService } from '@univerjs/core';+import { Button, ButtonGroup } from '@univerjs/design';import { AscendingSingle, DescendingSingle } from '@univerjs/icons';import { getSheetCommandTarget } from '@univerjs/sheets';import { useDependency } from '@univerjs/ui';import React, { useCallback } from 'react';import { SheetsSortUIService } from '../services/sheets-sort-ui.service';-import styles from './index.module.less';export interface IEmbedSortBtnProps {range: IRange;@@ -42,40 +42,22 @@ export default function EmbedSortBtn(props: IEmbedSortBtnProps) {const noTitleRange = { ...range, startRow: range.startRow + 1 };sheetsSortUIService.triggerSortDirectly(asc, false, { unitId, subUnitId, range: noTitleRange, colIndex });} else {- console.warn(`Cannot find the target to sort. unitId: ${unitId}, subUnitId: ${subUnitId}, range: ${range}, colIndex: ${colIndex}`);+ throw new Error(`Cannot find the target to sort. unitId: ${unitId}, subUnitId: ${subUnitId}, range: ${range}, colIndex: ${colIndex}`);}onClose();}, [range, colIndex, sheetsSortUIService, univerInstanceService, onClose]);return (- <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- `}- >- <div- className={`- ${styles.embedSortBtn}- ${styles.embedSortBtnAsc}- `}- onClick={() => apply(true)}- >- <AscendingSingle className={styles.embedSortBtnIcon} />+ <ButtonGroup className="univer-mb-3 univer-w-full">+ <Button className="univer-w-1/2" onClick={() => apply(true)}>+ <AscendingSingle className="univer-mr-1" />{localeService.t('sheets-sort.general.sort-asc')}- </div>- <div- className={`- ${styles.embedSortBtn}- ${styles.embedSortBtnDesc}- `}- onClick={() => apply(false)}- >- <DescendingSingle className={styles.embedSortBtnIcon} />+ </Button>+ <Button className="univer-w-1/2" onClick={() => apply(false)}>+ <DescendingSingle className="univer-mr-1" />{localeService.t('sheets-sort.general.sort-desc')}- </div>- </div>+ </Button>+ </ButtonGroup>);}diff --git a/packages/sheets-sort-ui/src/views/ExtendConfirm.tsx b/packages/sheets-sort-ui/src/views/ExtendConfirm.tsxindex 23610d0381..1b52fcb1bd 100644--- a/packages/sheets-sort-ui/src/views/ExtendConfirm.tsx+++ b/packages/sheets-sort-ui/src/views/ExtendConfirm.tsx@@ -18,7 +18,6 @@ import { LocaleService } from '@univerjs/core';import { Radio, RadioGroup } from '@univerjs/design';import { useDependency } from '@univerjs/ui';import { useState } from 'react';-import styles from './index.module.less';export interface IExtendConfirmProps {onChange: (value: string) => void;@@ -34,7 +33,7 @@ export const ExtendConfirm = (props: IExtendConfirmProps) => {</div><RadioGroup- className={styles.extendConfirmRadioGroup}+ className="univer-mt-4"value={extend}direction="vertical"onChange={(value) => {@@ -42,9 +41,7 @@ export const ExtendConfirm = (props: IExtendConfirmProps) => {props.onChange(value as string);}}>- <Radio- value="0"- >+ <Radio value="0">{localeService.t('sheets-sort.dialog.sort-reminder-no')}</Radio><Radio value="1">diff --git a/packages/sheets-sort-ui/src/views/index.module.less b/packages/sheets-sort-ui/src/views/index.module.lessdeleted file mode 100644index 04f9b805de..0000000000--- a/packages/sheets-sort-ui/src/views/index.module.less+++ /dev/null@@ -1,208 +0,0 @@-.extend-confirm-radio-group {- margin-top: 16px;-}--.custom-sort-panel-container {- .custom-sort-panel-ext {- display: flex;- justify-content: space-between;- align-items: center;-- .add-condition {- color: var(---Hyacinth-Blue-500, #274fee);- font-size: 16px;- display: flex;- align-items: center;- cursor: pointer;- user-select: none;- &-text {- margin-left: 6px;- font-size: 12px;- }- &-disable {- color: var(---Black, #1e222b);- opacity: 0.3;- cursor: not-allowed;- }- }- }-- .custom-sort-panel-footer {- margin-top: 20px;- display: flex;- justify-content: end;- &-btn {- margin-left: 12px;- }- }-- .custom-sort-panel-item {- display: flex;- align-items: center;- border-bottom: 1px solid var(--gray-200);-- &-head {- display: flex;- align-items: center;- }-- &-handler {- font-size: 16px;- display: flex;- align-items: center;- justify-content: center;- color: #1e222b;- cursor: pointer;- }- &-remove {- font-size: 14px;- color: #4b4b4b;- cursor: pointer;- width: 14px;- height: 14px;- position: absolute;- right: 0;- }- &-column-input {- display: flex;- width: 236px;- padding: 6px 10px;- justify-content: space-between;- align-items: center;- margin-left: 8px;- border-radius: 6px;- border: 1px solid var(---Grey-200, #e5e5e5);- background: var(---White, #fff);- color: var(---Black, #1e222b);- font-family: 'PingFang SC';- font-size: 13px;- font-style: normal;- font-weight: 400;- line-height: 20px;- overflow: hidden;- &-dropdown {- width: 16px;- height: 16px;- color: #4b4b4b;- }- }- &-column-input-text {- max-width: 220px;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- }- &-order-radio {- display: flex;- padding: 0 10px;- }- &-order-radio-cn {- display: flex;- padding: 0 20px;- }- }-- .condition-list {- max-height: 310px;- overflow-y: auto;- overflow-x: hidden;- }-}--.embed-sort-btn-container {- .embed-sort-btn {- font-size: 13px;- font-style: normal;- font-weight: 400;- display: flex;- width: 140px;- padding: 6px 0px;- justify-content: center;- align-items: center;- gap: 4px;- border: 1px solid var(---Grey-200, #e5e5e5);- cursor: default;-- &:active {- background: rgba(30, 34, 43, 0.09);- }- &:hover {- background: var(--black-6, rgba(30, 34, 43, 0.06));- }- }- .embed-sort-btn-asc {- border-radius: 6px 0px 0px 6px;- }- .embed-sort-btn-desc {- border-radius: 0px 6px 6px 0px;- margin-left: -1px;- }- .embed-sort-btn-icon {- font-size: 16px;- color: #1e222b;- margin-right: 4px;- }-}--.custom-sort-col-menu {- display: grid;- gap: var(--margin-xxs);- align-items: center;-- box-sizing: border-box;- margin-top: 0;- margin-bottom: 0;- padding: var(--padding-sm);-- font-size: var(--font-size-base);-- background: var(---White, #fff);- border: 1px solid var(--black-6, rgba(30, 34, 43, 0.06));- border-radius: var(--Radius-4, 8px);- box-shadow: 0px 4px 12px 2px rgba(30, 34, 43, 0.1);-- max-height: 310px;- overflow-y: auto;- overflow-x: hidden;-- li {- list-style: none;- }-- &-item {- cursor: pointer;-- position: relative;-- display: flex;- align-items: center;- justify-content: space-between;-- box-sizing: border-box;- height: 28px;- padding: 0px 8px;-- font-size: 13px;- font-weight: 400;- font-style: normal;- line-height: 20px; /* 153.846% */- color: var(---Black, #1e222b);- text-align: left;-- border-radius: 4px;- border-radius: var(--border-radius-base);-- transition: background 0.2s;-- &:hover {- background: #f5f5f5;- }-- &-desc {- max-width: 220px;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- }- }-}diff --git a/packages/sheets-sort-ui/src/views/sheets-sort-ui.stories.tsx b/packages/sheets-sort-ui/src/views/sheets-sort-ui.stories.tsxnew file mode 100644index 0000000000..49bba44b83--- /dev/null+++ b/packages/sheets-sort-ui/src/views/sheets-sort-ui.stories.tsx@@ -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 { Meta } from '@storybook/react';+import type { IWorkbookData } from '@univerjs/core';+import type {+ ISetSelectionsOperationParams,+} from '@univerjs/sheets';+import {+ ICommandService,+ ILogService,+ Inject,+ Injector,+ LocaleService,+ LocaleType,+ LogLevel,+ Plugin,+ registerDependencies,+ Univer,+ UniverInstanceType,+} from '@univerjs/core';+import {+ SetSelectionsOperation,+} from '@univerjs/sheets';+import { UniverSheetsSortPlugin } from '@univerjs/sheets-sort';+import {+ IConfirmService,+ IShortcutService,+ IUIPartsService,+ RediContext,+ ShortcutService,+ TestConfirmService,+ UIPartsService,+} from '@univerjs/ui';+import React, { useState } from 'react';+import { SortRangeCustomCommand } from '../commands/commands/sheets-sort.command';+import enUS from '../locale/en-US';+import { SheetsSortUIService } from '../services/sheets-sort-ui.service';+import { CustomSortPanel } from './CustomSortPanel';++const meta: Meta<typeof CustomSortPanel> = {+ title: 'CustomSortPanel',+ component: CustomSortPanel,+ tags: ['autodocs'],+};++export default meta;++function createSortStorybookBed(workbookData: IWorkbookData, locale: LocaleType = LocaleType.EN_US) {+ const univer = new Univer({+ locale: LocaleType.EN_US,+ locales: {+ [LocaleType.EN_US]: enUS,+ },+ });++ const injector = univer.__getInjector();++ class TestPlugin extends Plugin {+ static override type = UniverInstanceType.UNIVER_SHEET;+ static override pluginName = 'test-plugin';++ constructor(+ _config: unknown,+ @Inject(Injector) protected readonly _injector: Injector+ ) {+ super();+ }++ override onStarting(): void {+ registerDependencies(this._injector, [+ [IShortcutService, { useClass: ShortcutService }],+ [IUIPartsService, { useClass: UIPartsService }],+ [SheetsSortUIService],+ [IConfirmService, { useClass: TestConfirmService }],+ ]);++ const commandService = this._injector.get(ICommandService);+ [+ SortRangeCustomCommand,+ ].forEach((command) => commandService.registerCommand(command));+ }++ override onReady(): void {+ const commandService = this._injector.get(ICommandService);+ commandService.executeCommand(SetSelectionsOperation.id, {+ unitId: 'test',+ subUnitId: 'sheet-01',+ selections: [{+ range: { endRow: 2, startColumn: 0, endColumn: 0, startRow: 0 },+ primary: { endRow: 0, startColumn: 0, endColumn: 0, startRow: 0, actualColumn: 0, actualRow: 0, isMerged: false, isMergedMainCell: false },+ }],+ } as ISetSelectionsOperationParams);+ commandService.executeCommand(SortRangeCustomCommand.id);+ }+ }++ univer.registerPlugin(UniverSheetsSortPlugin);+ univer.registerPlugin(TestPlugin);++ injector.get(LocaleService).setLocale(locale);+ // injector.get(LocaleService).load({ enUS, zhCN, ruRU });+ injector.get(ILogService).setLogLevel(LogLevel.VERBOSE);++ const sheet = univer.createUnit(UniverInstanceType.UNIVER_SHEET, workbookData);++ //++ return { univer, injector, sheet };+}++export const Demo = {+ render() {+ const [bed] = useState(() => createSortStorybookBed(createSortSnapshot()));+ const { injector } = bed;++ return (+ <RediContext.Provider value={{ injector }}>+ <div className="univer-w-[640px]">+ <CustomSortPanel />+ </div>+ </RediContext.Provider>+ );+ },+};++function createSortSnapshot(): IWorkbookData {+ return {+ id: 'test',+ appVersion: '',+ name: 'Sort Storybook',+ locale: LocaleType.EN_US,+ sheetOrder: ['sheet-01'],+ styles: {},+ sheets: {+ 'sheet-01': {+ name: 'Sheet 1',+ id: 'sheet-01',+ cellData: {+ 0: {+ 0: { v: 1 },+ },+ 1: {+ 0: { v: 2 },+ },+ 2: {+ 0: { v: 3 },+ },+ },+ },+ },+ };+}diff --git a/packages/sheets-sort/src/plugin.ts b/packages/sheets-sort/src/plugin.tsindex 656d699acb..5f9f6b9367 100644--- a/packages/sheets-sort/src/plugin.ts+++ b/packages/sheets-sort/src/plugin.ts@@ -17,13 +17,16 @@import type { Dependency } from '@univerjs/core';import type { IUniverSheetsSortConfig } from './controllers/config.schema';-import { IConfigService, Inject, Injector, merge, Plugin, UniverInstanceType } from '@univerjs/core';+import { DependentOn, IConfigService, Inject, Injector, merge, Plugin, UniverInstanceType } from '@univerjs/core';+import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';+import { UniverSheetsPlugin } from '@univerjs/sheets';import { defaultPluginConfig, SHEETS_SORT_PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { SheetsSortController } from './controllers/sheets-sort.controller';import { SheetsSortService } from './services/sheets-sort.service';const NAME = 'SHEET_SORT_PLUGIN';+@DependentOn(UniverSheetsPlugin, UniverFormulaEnginePlugin)export class UniverSheetsSortPlugin extends Plugin {static override type = UniverInstanceType.UNIVER_SHEET;static override pluginName = NAME;diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.tsindex f3148871a4..00a72c70c7 100644--- a/packages/ui/src/index.ts+++ b/packages/ui/src/index.ts@@ -57,7 +57,7 @@ export {imageMimeTypeSet,PLAIN_TEXT_CLIPBOARD_MIME_TYPE,} from './services/clipboard/clipboard-interface.service';-export { IConfirmService } from './services/confirm/confirm.service';+export { IConfirmService, TestConfirmService } from './services/confirm/confirm.service';export { DesktopConfirmService } from './services/confirm/desktop-confirm.service';export {ContextMenuService,diff --git a/packages/ui/src/services/confirm/confirm.service.ts b/packages/ui/src/services/confirm/confirm.service.tsindex 38781a6d5e..c0a9febad0 100644--- a/packages/ui/src/services/confirm/confirm.service.ts+++ b/packages/ui/src/services/confirm/confirm.service.ts@@ -15,10 +15,9 @@*/import type { IDisposable } from '@univerjs/core';-import type { Subject } from 'rxjs';import type { IConfirmPartMethodOptions } from '../../views/components/confirm-part/interface';-import { createIdentifier } from '@univerjs/core';+import { Subject } from 'rxjs';export const IConfirmService = createIdentifier<IConfirmService>('univer.confirm-service');export interface IConfirmService {@@ -28,3 +27,26 @@ export interface IConfirmService {confirm(params: IConfirmPartMethodOptions): Promise<boolean>;close(id: string): void;}++/**+ * This is a mock service for testing purposes.+ */+export class TestConfirmService implements IConfirmService, IDisposable {+ readonly confirmOptions$ = new Subject<IConfirmPartMethodOptions[]>();++ dispose(): void {+ this.confirmOptions$.complete();+ }++ open(_params: IConfirmPartMethodOptions): IDisposable {+ throw new Error('This is not implemented in the test service!');+ }++ confirm(_params: IConfirmPartMethodOptions): Promise<boolean> {+ return Promise.resolve(true);+ }++ close(_id: string): IDisposable {+ throw new Error('This is not implemented in the test service!');+ }+}