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(numfmt): refactor less to tailwindcss (#5069)
Wenzhao Hu433191b16607
diff --git a/packages-experimental/debugger/src/controllers/dark-mode.controller.ts b/packages-experimental/debugger/src/controllers/dark-mode.controller.tsindex e54eca5737..73068b7db3 100644--- a/packages-experimental/debugger/src/controllers/dark-mode.controller.ts+++ b/packages-experimental/debugger/src/controllers/dark-mode.controller.ts@@ -18,14 +18,14 @@ import { ILocalStorageService, Inject, RxDisposable, ThemeService } from '@univeexport class DarkModeController extends RxDisposable {constructor(- @Inject(ILocalStorageService) private _localStorageService: ILocalStorageService,- @Inject(ThemeService) private _themeService: ThemeService+ @ILocalStorageService private _localStorageService: ILocalStorageService,+ @Inject(ThemeService) themeService: ThemeService) {super();this._localStorageService.getItem('local.darkMode').then((darkMode) => {if (darkMode === 'dark') {- _themeService.setDarkMode(true);+ themeService.setDarkMode(true);}});}diff --git a/packages/sheets-numfmt-ui/src/controllers/menu.ts b/packages/sheets-numfmt-ui/src/controllers/menu.tsindex a6a726c569..105e6c2f75 100644--- a/packages/sheets-numfmt-ui/src/controllers/menu.ts+++ b/packages/sheets-numfmt-ui/src/controllers/menu.ts@@ -32,7 +32,7 @@ import { deriveStateFromActiveSheet$, getCurrentRangeDisable$ } from '@univerjs/import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';import { filter, merge, Observable } from 'rxjs';import { OpenNumfmtPanelOperator } from '../commands/operations/open.numfmt.panel.operation';-import { MORE_NUMFMT_TYPE_KEY, OPTIONS_KEY } from '../views/components/more-numfmt-type/MoreNumfmtType';+import { MORE_NUMFMT_TYPE_KEY, OPTIONS_KEY } from '../views/components/MoreNumfmtType';export const MENU_OPTIONS: Array<{ label: string; pattern: string | null } | '|'> = [{diff --git a/packages/sheets-numfmt-ui/src/controllers/numfmt.menu.controller.ts b/packages/sheets-numfmt-ui/src/controllers/numfmt.menu.controller.tsindex a2081ff590..126b346f21 100644--- a/packages/sheets-numfmt-ui/src/controllers/numfmt.menu.controller.ts+++ b/packages/sheets-numfmt-ui/src/controllers/numfmt.menu.controller.ts@@ -17,7 +17,7 @@import { Disposable, Inject } from '@univerjs/core';import { ComponentManager, IMenuManagerService } from '@univerjs/ui';-import { MORE_NUMFMT_TYPE_KEY, MoreNumfmtType, Options, OPTIONS_KEY } from '../views/components/more-numfmt-type/MoreNumfmtType';+import { MORE_NUMFMT_TYPE_KEY, MoreNumfmtType, Options, OPTIONS_KEY } from '../views/components/MoreNumfmtType';import { menuSchema } from './menu.schema';export class NumfmtMenuController extends Disposable {diff --git a/packages/sheets-numfmt-ui/src/views/components/accounting/index.tsx b/packages/sheets-numfmt-ui/src/views/components/Accounting.tsxsimilarity index 95%rename from packages/sheets-numfmt-ui/src/views/components/accounting/index.tsxrename to packages/sheets-numfmt-ui/src/views/components/Accounting.tsxindex 60f5720cfc..6426bf89b7 100644--- a/packages/sheets-numfmt-ui/src/views/components/accounting/index.tsx+++ b/packages/sheets-numfmt-ui/src/views/components/Accounting.tsx@@ -15,13 +15,13 @@*/import type { FC } from 'react';-import type { IBusinessComponentProps } from '../interface';+import type { IBusinessComponentProps } from './interface';import { LocaleService } from '@univerjs/core';import { InputNumber, Select } from '@univerjs/design';import { getCurrencyType, getDecimalFromPattern, setPatternDecimal } from '@univerjs/sheets-numfmt';import { useDependency } from '@univerjs/ui';import { useContext, useMemo, useState } from 'react';-import { UserHabitCurrencyContext } from '../../../controllers/user-habit.controller';+import { UserHabitCurrencyContext } from '../../controllers/user-habit.controller';export const isAccountingPanel = (pattern: string) => {const type = getCurrencyType(pattern);diff --git a/packages/sheets-numfmt-ui/src/views/components/currency/index.tsx b/packages/sheets-numfmt-ui/src/views/components/Currency.tsxsimilarity index 96%rename from packages/sheets-numfmt-ui/src/views/components/currency/index.tsxrename to packages/sheets-numfmt-ui/src/views/components/Currency.tsxindex a9dbb86913..ab0b7f7eb9 100644--- a/packages/sheets-numfmt-ui/src/views/components/currency/index.tsx+++ b/packages/sheets-numfmt-ui/src/views/components/Currency.tsx@@ -15,13 +15,13 @@*/import type { FC } from 'react';-import type { IBusinessComponentProps } from '../interface';+import type { IBusinessComponentProps } from './interface';import { LocaleService } from '@univerjs/core';import { InputNumber, Select, SelectList } from '@univerjs/design';import { getCurrencyFormatOptions, getCurrencyType, getDecimalFromPattern, isPatternEqualWithoutDecimal, setPatternDecimal } from '@univerjs/sheets-numfmt';import { useDependency } from '@univerjs/ui';import { useContext, useMemo, useState } from 'react';-import { UserHabitCurrencyContext } from '../../../controllers/user-habit.controller';+import { UserHabitCurrencyContext } from '../../controllers/user-habit.controller';export const isCurrencyPanel = (pattern: string) => {const type = getCurrencyType(pattern);diff --git a/packages/sheets-numfmt-ui/src/views/components/custom-format/index.tsx b/packages/sheets-numfmt-ui/src/views/components/CustomFormat.tsxsimilarity index 69%rename from packages/sheets-numfmt-ui/src/views/components/custom-format/index.tsxrename to packages/sheets-numfmt-ui/src/views/components/CustomFormat.tsxindex 7c79f62959..97f6ca4ce9 100644--- a/packages/sheets-numfmt-ui/src/views/components/custom-format/index.tsx+++ b/packages/sheets-numfmt-ui/src/views/components/CustomFormat.tsx@@ -14,15 +14,14 @@* limitations under the License.*/-import type { IBusinessComponentProps } from '../interface';+import type { IBusinessComponentProps } from './interface';import { ILocalStorageService, LocaleService } from '@univerjs/core';import { Input } from '@univerjs/design';import { CheckMarkSingle } from '@univerjs/icons';import { CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT } from '@univerjs/sheets-numfmt';import { useDependency } from '@univerjs/ui';import React, { useEffect, useState } from 'react';-import { UserHabitController } from '../../../controllers/user-habit.controller';-import styles from './index.module.less';+import { UserHabitController } from '../../controllers/user-habit.controller';const key = 'customFormat';const historyPatternKey = 'numfmt_custom_pattern';@@ -70,13 +69,31 @@ export function CustomFormat(props: IBusinessComponentProps) {};return (- <div className={styles.customFormat}>- <div className={styles.customFormatTitle}>{localeService.t('sheet.numfmt.customFormat')}</div>- <Input placeholder={localeService.t('sheet.numfmt.customFormat')} onBlur={handleBlur} value={pattern} onChange={patternSet} className={styles.customFormatInput} />- <div className={styles.customFormatHistoryList}>+ <div>+ <div className="univer-mt-4 univer-text-sm univer-text-gray-400">{localeService.t('sheet.numfmt.customFormat')}</div>+ <Input+ placeholder={localeService.t('sheet.numfmt.customFormat')}+ onBlur={handleBlur}+ value={pattern}+ onChange={patternSet}+ className="univer-mt-2 univer-w-full"+ />+ <div+ className={`+ univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-border+ univer-border-solid univer-border-gray-200 univer-p-2+ `}+ >{options.map((p) => (- <div key={p} onClick={() => handleClick(p as string)} className={styles.customFormatHistoryListItem}>- <div className={styles.customFormatHistoryListItemIconWrap}>+ <div+ key={p}+ onClick={() => handleClick(p as string)}+ className={`+ univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5+ univer-text-sm+ `}+ >+ <div className="univer-flex univer-w-4 univer-items-center univer-text-primary-600">{pattern === p && <CheckMarkSingle />}</div><div>@@ -85,7 +102,7 @@ export function CustomFormat(props: IBusinessComponentProps) {</div>))}</div>- <div className={styles.customFormatDes}>+ <div className="univer-mt-3 univer-text-sm univer-text-gray-600">{localeService.t('sheet.numfmt.customFormatDes')}</div></div>diff --git a/packages/sheets-numfmt-ui/src/views/components/date/index.tsx b/packages/sheets-numfmt-ui/src/views/components/Date.tsxsimilarity index 97%rename from packages/sheets-numfmt-ui/src/views/components/date/index.tsxrename to packages/sheets-numfmt-ui/src/views/components/Date.tsxindex ca0533631a..5de57805bf 100644--- a/packages/sheets-numfmt-ui/src/views/components/date/index.tsx+++ b/packages/sheets-numfmt-ui/src/views/components/Date.tsx@@ -15,7 +15,7 @@*/import type { FC } from 'react';-import type { IBusinessComponentProps } from '../interface';+import type { IBusinessComponentProps } from './interface';import { LocaleService, numfmt } from '@univerjs/core';import { SelectList } from '@univerjs/design';import { getDateFormatOptions } from '@univerjs/sheets-numfmt';diff --git a/packages/sheets-numfmt-ui/src/views/components/general/index.tsx b/packages/sheets-numfmt-ui/src/views/components/General.tsxsimilarity index 93%rename from packages/sheets-numfmt-ui/src/views/components/general/index.tsxrename to packages/sheets-numfmt-ui/src/views/components/General.tsxindex 2ce70d1de0..35c61fcc2c 100644--- a/packages/sheets-numfmt-ui/src/views/components/general/index.tsx+++ b/packages/sheets-numfmt-ui/src/views/components/General.tsx@@ -15,7 +15,7 @@*/import type { FC } from 'react';-import type { IBusinessComponentProps } from '../interface';+import type { IBusinessComponentProps } from './interface';import { LocaleService } from '@univerjs/core';import { useDependency } from '@univerjs/ui';@@ -25,6 +25,7 @@ export const GeneralPanel: FC<IBusinessComponentProps> = (props) => {const localeService = useDependency(LocaleService);const t = localeService.t;+ // FIXME: WTFprops.action.current = () => '';return (diff --git a/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx b/packages/sheets-numfmt-ui/src/views/components/MoreNumfmtType.tsxsimilarity index 96%rename from packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsxrename to packages/sheets-numfmt-ui/src/views/components/MoreNumfmtType.tsxindex 5f1a6e4a13..89e943c439 100644--- a/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx+++ b/packages/sheets-numfmt-ui/src/views/components/MoreNumfmtType.tsx@@ -20,8 +20,8 @@ import { Separator } from '@univerjs/design';import { SheetsSelectionsService } from '@univerjs/sheets';import { getPatternPreview, getPatternType, SetNumfmtCommand, SheetsNumfmtCellContentController } from '@univerjs/sheets-numfmt';import { ILayoutService, useDependency } from '@univerjs/ui';-import { OpenNumfmtPanelOperator } from '../../../commands/operations/open.numfmt.panel.operation';-import { MENU_OPTIONS } from '../../../controllers/menu';+import { OpenNumfmtPanelOperator } from '../../commands/operations/open.numfmt.panel.operation';+import { MENU_OPTIONS } from '../../controllers/menu';export const MORE_NUMFMT_TYPE_KEY = 'sheet.numfmt.moreNumfmtType';export const OPTIONS_KEY = 'sheet.numfmt.moreNumfmtType.options';diff --git a/packages/sheets-numfmt-ui/src/views/components/thousandth-percentile/index.tsx b/packages/sheets-numfmt-ui/src/views/components/ThousandthPercentile.tsxsimilarity index 98%rename from packages/sheets-numfmt-ui/src/views/components/thousandth-percentile/index.tsxrename to packages/sheets-numfmt-ui/src/views/components/ThousandthPercentile.tsxindex 7725f33618..c8b452237b 100644--- a/packages/sheets-numfmt-ui/src/views/components/thousandth-percentile/index.tsx+++ b/packages/sheets-numfmt-ui/src/views/components/ThousandthPercentile.tsx@@ -15,7 +15,7 @@*/import type { FC } from 'react';-import type { IBusinessComponentProps } from '../interface';+import type { IBusinessComponentProps } from './interface';import { LocaleService } from '@univerjs/core';import { InputNumber, SelectList } from '@univerjs/design';import { getDecimalFromPattern, getNumberFormatOptions, isPatternEqualWithoutDecimal, isPatternHasDecimal, setPatternDecimal } from '@univerjs/sheets-numfmt';diff --git a/packages/sheets-numfmt-ui/src/views/components/custom-format/index.module.less b/packages/sheets-numfmt-ui/src/views/components/custom-format/index.module.lessdeleted file mode 100644index ce5437ebc8..0000000000--- a/packages/sheets-numfmt-ui/src/views/components/custom-format/index.module.less+++ /dev/null@@ -1,41 +0,0 @@-.custom-format {- &-title {- margin-top: 16px;- }-- &-input {- margin-top: 8px;- width: 100%;- }-- &-history-list {- margin-top: 8px;- padding: 8px;- border-radius: 8px;- border: 1px solid var(---Grey-200, #e5e5e5);- max-height: 400px;- overflow: auto;- &-item {- padding: 6px 0px;- display: flex;- gap: 6px;- align-items: center;- cursor: pointer;- &-icon-wrap {- width: 16px;- display: flex;- align-items: center;- color: #274fee;- }- }- }-- &-des {- margin-top: 8px;- color: var(---Grey-600, #7a7a7a);- font-size: 12px;- font-style: normal;- font-weight: 400;- line-height: 16px;- }-}diff --git a/packages/sheets-numfmt-ui/src/views/components/index.tsx b/packages/sheets-numfmt-ui/src/views/components/index.tsxindex 420a9369e0..392a410cf1 100644--- a/packages/sheets-numfmt-ui/src/views/components/index.tsx+++ b/packages/sheets-numfmt-ui/src/views/components/index.tsx@@ -21,21 +21,22 @@ import { LocaleService } from '@univerjs/core';import { Button, Select } from '@univerjs/design';import { getCurrencyType } from '@univerjs/sheets-numfmt';import { useDependency } from '@univerjs/ui';-import { useEffect, useMemo, useRef, useState } from 'react';+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { UserHabitCurrencyContext } from '../../controllers/user-habit.controller';import { useCurrencyOptions } from '../hooks/use-currency-options';import { useNextTick } from '../hooks/use-next-tick';-import { AccountingPanel, isAccountingPanel } from './accounting';-import { CurrencyPanel, isCurrencyPanel } from './currency';-import { CustomFormat } from './custom-format';-import { DatePanel, isDatePanel } from './date';-import { GeneralPanel, isGeneralPanel } from './general';-import { isThousandthPercentilePanel, ThousandthPercentilePanel } from './thousandth-percentile';+import { AccountingPanel, isAccountingPanel } from './Accounting';+import { CurrencyPanel, isCurrencyPanel } from './Currency';+import { CustomFormat } from './CustomFormat';+import { DatePanel, isDatePanel } from './Date';+import { GeneralPanel, isGeneralPanel } from './General';+import { isThousandthPercentilePanel, ThousandthPercentilePanel } from './ThousandthPercentile';export interface ISheetNumfmtPanelProps {value: { defaultValue: number; defaultPattern: string; row: number; col: number };onChange: (config: { type: 'change' | 'cancel' | 'confirm'; value: string }) => void;}+export const SheetNumfmtPanel: FC<ISheetNumfmtPanelProps> = (props) => {const { defaultValue, defaultPattern, row, col } = props.value;const localeService = useDependency(LocaleService);@@ -79,9 +80,9 @@ export const SheetNumfmtPanel: FC<ISheetNumfmtPanelProps> = (props) => {nextTick(() => props.onChange({ type: 'change', value: getCurrentPattern.current() || '' }));};- const handleChange = (v: string) => {+ const handleChange = useCallback((v: string) => {props.onChange({ type: 'change', value: v });- };+ }, []);const handleConfirm = () => {const pattern = getCurrentPattern.current() || '';@@ -91,6 +92,7 @@ export const SheetNumfmtPanel: FC<ISheetNumfmtPanelProps> = (props) => {}props.onChange({ type: 'confirm', value: pattern });};+const handleCancel = () => {props.onChange({ type: 'cancel', value: '' });};diff --git a/packages/sheets-numfmt-ui/src/views/components/stories/Panel.stories.tsx b/packages/sheets-numfmt-ui/src/views/components/stories/Panel.stories.tsxindex 24656cbf7c..32226114b1 100644--- a/packages/sheets-numfmt-ui/src/views/components/stories/Panel.stories.tsx+++ b/packages/sheets-numfmt-ui/src/views/components/stories/Panel.stories.tsx@@ -35,7 +35,7 @@ const meta: Meta = {export default meta;-export const Test: StoryObj<ISheetNumfmtPanelProps> = {+export const NumfmtPanel: StoryObj<ISheetNumfmtPanelProps> = {render() {const { injector } = useContext(RediContext);@@ -57,12 +57,14 @@ export const Test: StoryObj<ISheetNumfmtPanelProps> = {return (<RediContext.Provider value={{ injector: inject }}>- <SheetNumfmtPanel- value={{ defaultPattern: '', defaultValue: 123123, row: 2, col: 3 }}- onChange={(_pattern) => {+ <div className="univer-w-[340px]">+ <SheetNumfmtPanel+ value={{ defaultPattern: '', defaultValue: 123123, row: 2, col: 3 }}+ onChange={(_pattern) => {// empty- }}- />+ }}+ />+ </div></RediContext.Provider>);},