Skip to content

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.

refactor: use interface tokens for service injection (#7233)

白熱36e17fe70525
diff --git a/packages/docs-ui/src/views/paragraph-setting/Setting.tsx b/packages/docs-ui/src/views/paragraph-setting/Setting.tsx
index 0c8183c171..2e7f81b171 100644
--- a/packages/docs-ui/src/views/paragraph-setting/Setting.tsx
+++ b/packages/docs-ui/src/views/paragraph-setting/Setting.tsx
@@ -32,28 +32,38 @@ import {
useFirstParagraphLineSpacing,
useFirstParagraphSpaceBelow,
} from './hook/utils';
-import { getLineSpacingInputConfig, getLineSpacingRuleOptions } from './line-spacing';
+import { getLineSpacingInputConfig, LINE_SPACING_RULE_OPTIONS } from './line-spacing';
+
+const ALIGNMENT_OPTIONS = [
+ { label: 'docs-ui.toolbar.alignLeft', value: String(HorizontalAlign.LEFT), icon: <LeftJustifyingIcon /> },
+ { label: 'docs-ui.toolbar.alignCenter', value: String(HorizontalAlign.CENTER), icon: <HorizontallyIcon /> },
+ { label: 'docs-ui.toolbar.alignRight', value: String(HorizontalAlign.RIGHT), icon: <RightJustifyingIcon /> },
+ { label: 'docs-ui.toolbar.alignJustify', value: String(HorizontalAlign.JUSTIFIED), icon: <AlignTextBothIcon /> },
+] satisfies Array<{ label: LocaleKey; value: string; icon: ReactNode }>;
const ParagraphSettingSection = (props: {
- title: ReactNode;
+ titleKey: LocaleKey;
children: ReactNode;
first?: boolean;
}) => {
- const { title, children, first = false } = props;
+ const { titleKey, children, first = false } = props;
+ const localeService = useDependency(LocaleService);
return (
<section className={clsx(!first && 'univer-mt-5')}>
- <div className="univer-text-sm univer-font-medium univer-leading-5">{title}</div>
+ <div className="univer-text-sm univer-font-medium univer-leading-5">{localeService.t(titleKey)}</div>
<div className="univer-mt-3">{children}</div>
</section>
);
};
const ParagraphSettingRow = (props: {
- label: ReactNode;
+ labelKey: LocaleKey;
+ unit?: string;
children: ReactNode;
}) => {
- const { label, children } = props;
+ const { labelKey, unit, children } = props;
+ const localeService = useDependency(LocaleService);
return (
<div
@@ -66,7 +76,8 @@ const ParagraphSettingRow = (props: {
dark:!univer-text-gray-100
"
>
- {label}
+ {localeService.t(labelKey)}
+ {unit}
</div>
<div className="univer-w-full univer-min-w-0">
{children}
@@ -111,15 +122,8 @@ const AutoFocusInputNumber = (props: {
export function ParagraphSetting() {
const localeService = useDependency(LocaleService);
- const alignmentOptions = useMemo(() => [
- { label: localeService.t<LocaleKey>('docs-ui.toolbar.alignLeft'), value: String(HorizontalAlign.LEFT), icon: <LeftJustifyingIcon /> },
- { label: localeService.t<LocaleKey>('docs-ui.toolbar.alignCenter'), value: String(HorizontalAlign.CENTER), icon: <HorizontallyIcon /> },
- { label: localeService.t<LocaleKey>('docs-ui.toolbar.alignRight'), value: String(HorizontalAlign.RIGHT), icon: <RightJustifyingIcon /> },
- { label: localeService.t<LocaleKey>('docs-ui.toolbar.alignJustify'), value: String(HorizontalAlign.JUSTIFIED), icon: <AlignTextBothIcon /> },
- ], []);
-
const currentParagraph = useCurrentParagraph();
- const [horizontalAlignValue, setHorizontalAlign] = useFirstParagraphHorizontalAlign(currentParagraph, alignmentOptions[0].value);
+ const [horizontalAlignValue, setHorizontalAlign] = useFirstParagraphHorizontalAlign(currentParagraph, ALIGNMENT_OPTIONS[0].value);
const [indentStart, setIndentStart] = useFirstParagraphIndentStart(currentParagraph);
const [indentEnd, setIndentEnd] = useFirstParagraphIndentEnd(currentParagraph);
@@ -132,11 +136,11 @@ export function ParagraphSetting() {
const { lineSpacing: [lineSpacing, setLineSpacing], spacingRule: [spacingRule, setSpacingRule] } = useFirstParagraphLineSpacing(currentParagraph);
const lineSpaceConfig = useMemo(() => getLineSpacingInputConfig(spacingRule), [spacingRule]);
- const lineSpacingOptions = useMemo(() => getLineSpacingRuleOptions(localeService), [localeService]);
+ const lineSpacingOptions = LINE_SPACING_RULE_OPTIONS.map((option) => ({ ...option, label: localeService.t(option.label) }));
return (
<div className="univer-box-border univer-w-full">
- <ParagraphSettingSection title={localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.alignment')} first>
+ <ParagraphSettingSection titleKey="docs-ui.doc.paragraphSetting.alignment" first>
<div
className={clsx(`
univer-flex univer-grid-cols-4 univer-items-center univer-justify-around univer-gap-2
@@ -144,9 +148,9 @@ export function ParagraphSetting() {
dark:!univer-bg-gray-900
`, borderClassName)}
>
- {alignmentOptions.map((item) => {
+ {ALIGNMENT_OPTIONS.map((item) => {
return (
- <Tooltip title={item.label} key={item.value} placement="bottom">
+ <Tooltip title={localeService.t(item.label)} key={item.value} placement="bottom">
<span className="univer-flex univer-w-full univer-items-center univer-justify-center">
<Button
type="button"
@@ -172,32 +176,32 @@ export function ParagraphSetting() {
</div>
</ParagraphSettingSection>
- <ParagraphSettingSection title={localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.indentation')}>
+ <ParagraphSettingSection titleKey="docs-ui.doc.paragraphSetting.indentation">
<div className="univer-grid univer-gap-3">
- <ParagraphSettingRow label={`${localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.left')}(px)`}>
+ <ParagraphSettingRow labelKey="docs-ui.doc.paragraphSetting.left" unit="(px)">
<AutoFocusInputNumber value={indentStart} onChange={(v) => setIndentStart(v ?? 0)} />
</ParagraphSettingRow>
- <ParagraphSettingRow label={`${localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.right')}(px)`}>
+ <ParagraphSettingRow labelKey="docs-ui.doc.paragraphSetting.right" unit="(px)">
<AutoFocusInputNumber value={indentEnd} onChange={(v) => setIndentEnd(v ?? 0)} />
</ParagraphSettingRow>
- <ParagraphSettingRow label={`${localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.firstLine')}(px)`}>
+ <ParagraphSettingRow labelKey="docs-ui.doc.paragraphSetting.firstLine" unit="(px)">
<AutoFocusInputNumber value={indentFirstLine} onChange={(v) => setIndentFirstLine(v ?? 0)} />
</ParagraphSettingRow>
- <ParagraphSettingRow label={`${localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.hanging')}(px)`}>
+ <ParagraphSettingRow labelKey="docs-ui.doc.paragraphSetting.hanging" unit="(px)">
<AutoFocusInputNumber value={hanging} onChange={(v) => setHanging(v ?? 0)} />
</ParagraphSettingRow>
</div>
</ParagraphSettingSection>
- <ParagraphSettingSection title={localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.spacing')}>
+ <ParagraphSettingSection titleKey="docs-ui.doc.paragraphSetting.spacing">
<div className="univer-grid univer-gap-3">
- <ParagraphSettingRow label={`${localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.before')}(px)`}>
+ <ParagraphSettingRow labelKey="docs-ui.doc.paragraphSetting.before" unit="(px)">
<AutoFocusInputNumber value={spaceAbove} onChange={(v) => setSpaceAbove(v ?? 0)} />
</ParagraphSettingRow>
- <ParagraphSettingRow label={`${localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.after')}(px)`}>
+ <ParagraphSettingRow labelKey="docs-ui.doc.paragraphSetting.after" unit="(px)">
<AutoFocusInputNumber value={spaceBelow} onChange={(v) => setSpaceBelow(v ?? 0)} />
</ParagraphSettingRow>
- <ParagraphSettingRow label={localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.lineSpace')}>
+ <ParagraphSettingRow labelKey="docs-ui.doc.paragraphSetting.lineSpace">
<div className="univer-flex univer-w-full univer-flex-col univer-gap-2">
<Select
className="univer-w-full"
diff --git a/packages/docs-ui/src/views/paragraph-setting/__tests__/line-spacing.spec.ts b/packages/docs-ui/src/views/paragraph-setting/__tests__/line-spacing.spec.ts
index 044b23d68e..cc5f0f472a 100644
--- a/packages/docs-ui/src/views/paragraph-setting/__tests__/line-spacing.spec.ts
+++ b/packages/docs-ui/src/views/paragraph-setting/__tests__/line-spacing.spec.ts
@@ -21,14 +21,12 @@ import {
convertLineSpacingForRuleChange,
convertStoredLineSpacingToDisplayValue,
getLineSpacingInputConfig,
- getLineSpacingRuleOptions,
+ LINE_SPACING_RULE_OPTIONS,
} from '../line-spacing';
describe('paragraph line spacing helpers', () => {
it('exposes Word-style spacing rule options', () => {
- expect(getLineSpacingRuleOptions({
- t: (key: string) => key,
- } as any)).toEqual([
+ expect(LINE_SPACING_RULE_OPTIONS).toEqual([
{ label: 'docs-ui.doc.paragraphSetting.multiSpace', value: `${SpacingRule.AUTO}` },
{ label: 'docs-ui.doc.paragraphSetting.atLeast', value: `${SpacingRule.AT_LEAST}` },
{ label: 'docs-ui.doc.paragraphSetting.exactly', value: `${SpacingRule.EXACT}` },
diff --git a/packages/docs-ui/src/views/paragraph-setting/line-spacing.ts b/packages/docs-ui/src/views/paragraph-setting/line-spacing.ts
index 1692f963d3..fabae9627a 100644
--- a/packages/docs-ui/src/views/paragraph-setting/line-spacing.ts
+++ b/packages/docs-ui/src/views/paragraph-setting/line-spacing.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import type { LocaleService } from '@univerjs/core';
import type { IDocumentSkeletonLine } from '@univerjs/engine-render';
import type { LocaleKey } from '../../locale/types';
import { DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_STYLES, SpacingRule } from '@univerjs/core';
@@ -36,13 +35,11 @@ function clamp(value: number, min: number, max: number) {
return Math.min(max, Math.max(min, value));
}
-export function getLineSpacingRuleOptions(localeService: LocaleService) {
- return [
- { label: localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.multiSpace'), value: `${SpacingRule.AUTO}` },
- { label: localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.atLeast'), value: `${SpacingRule.AT_LEAST}` },
- { label: localeService.t<LocaleKey>('docs-ui.doc.paragraphSetting.exactly'), value: `${SpacingRule.EXACT}` },
- ];
-}
+export const LINE_SPACING_RULE_OPTIONS: Array<{ label: LocaleKey; value: string }> = [
+ { label: 'docs-ui.doc.paragraphSetting.multiSpace', value: `${SpacingRule.AUTO}` },
+ { label: 'docs-ui.doc.paragraphSetting.atLeast', value: `${SpacingRule.AT_LEAST}` },
+ { label: 'docs-ui.doc.paragraphSetting.exactly', value: `${SpacingRule.EXACT}` },
+];
export function getLineSpacingInputConfig(spacingRule: SpacingRule) {
return spacingRule === SpacingRule.AUTO ? AUTO_LINE_SPACING_CONFIG : FIXED_LINE_SPACING_CONFIG;
diff --git a/packages/drawing-ui/src/index.ts b/packages/drawing-ui/src/index.ts
index 8bcf6af999..a64e13dfa2 100644
--- a/packages/drawing-ui/src/index.ts
+++ b/packages/drawing-ui/src/index.ts
@@ -59,7 +59,6 @@ export {
} from './views/object-list-panel/object-list-panel-layer';
export type { ObjectListPanelSectionId } from './views/object-list-panel/object-list-panel-layer';
export {
- DrawingObjectListPanel,
getObjectListPanelLabels,
getObjectListPanelTypeName,
ObjectListPanelBase,
diff --git a/packages/drawing-ui/src/views/image-popup-menu/ImagePopupMenu.tsx b/packages/drawing-ui/src/views/image-popup-menu/ImagePopupMenu.tsx
index c8aecbc0e9..fd965563de 100644
--- a/packages/drawing-ui/src/views/image-popup-menu/ImagePopupMenu.tsx
+++ b/packages/drawing-ui/src/views/image-popup-menu/ImagePopupMenu.tsx
@@ -191,9 +191,11 @@ function ToolbarGroup(props: { children: ReactNode }) {
);
}
-function ToolbarButton(props: { title: string; active?: boolean; disabled?: boolean; children: ReactNode; onClick: () => void }) {
+function ToolbarButton(props: { titleKey: string; active?: boolean; disabled?: boolean; children: ReactNode; onClick: () => void }) {
+ const localeService = useDependency(LocaleService);
+
return (
- <Tooltip title={props.title} placement="bottom">
+ <Tooltip title={localeService.t(props.titleKey)} placement="bottom">
<button
type="button"
disabled={props.disabled}
@@ -372,7 +374,7 @@ function DocImageFloatingToolbar(props: IDocImageFloatingToolbarProps) {
<Separator orientation="vertical" />
<ToolbarGroup>
<ToolbarButton
- title={editItem ? localeService.t<LocaleKey>(editItem.label) : localeService.t<LocaleKey>('drawing-ui.image-popup.edit')}
+ titleKey={editItem?.label ?? 'drawing-ui.image-popup.edit'}
disabled={!editItem || editItem.disable}
onClick={() => {
setHidden(true);
@@ -382,7 +384,7 @@ function DocImageFloatingToolbar(props: IDocImageFloatingToolbarProps) {
<DocSettingIcon />
</ToolbarButton>
<ToolbarButton
- title={cropItem ? localeService.t<LocaleKey>(cropItem.label) : localeService.t<LocaleKey>('drawing-ui.image-popup.crop')}
+ titleKey={cropItem?.label ?? 'drawing-ui.image-popup.crop'}
disabled={!cropItem || cropItem.disable}
onClick={() => executeMenuItem(cropItem)}
>
@@ -392,7 +394,7 @@ function DocImageFloatingToolbar(props: IDocImageFloatingToolbarProps) {
<Separator orientation="vertical" />
<ToolbarGroup>
<ToolbarButton
- title={deleteItem ? localeService.t<LocaleKey>(deleteItem.label) : localeService.t<LocaleKey>('drawing-ui.image-popup.delete')}
+ titleKey={deleteItem?.label ?? 'drawing-ui.image-popup.delete'}
disabled={!deleteItem || deleteItem.disable}
onClick={() => executeMenuItem(deleteItem)}
>
diff --git a/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsx b/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsx
index a578fc811d..af11687b7e 100644
--- a/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsx
+++ b/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsx
@@ -847,8 +847,6 @@ function ObjectDetailsEditor(props: {
);
}
-export const DrawingObjectListPanel = ObjectListPanelBase;
-
export type IDrawingObjectListItem = IObjectListPanelItem;
export type IDrawingObjectListPanelLabels = IObjectListPanelLabels;
export type IDrawingObjectListPanelProps = IObjectListPanelBaseProps;
diff --git a/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx b/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx
index d42eb605fc..e798abd91d 100644
--- a/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx
+++ b/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx
@@ -20,7 +20,7 @@ import type { LocaleKey } from '../../locale/types';
import { ICommandService, IContextService, LocaleService } from '@univerjs/core';
import { Button, Checkbox, FormDualColumnLayout, FormLayout, Input, MessageType, Select } from '@univerjs/design';
import { ILayoutService, IMessageService, useDebounceFn, useDependency, useObservable } from '@univerjs/ui';
-import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
+import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from 'react';
import { fromEvent } from 'rxjs';
import { ReplaceAllMatchesCommand, ReplaceCurrentMatchCommand } from '../../commands/commands/replace.command';
import { OpenReplaceDialogOperation } from '../../commands/operations/find-replace.operation';
@@ -33,6 +33,21 @@ interface ISubFormRef {
selectHasFocus(): boolean;
}
+const FIND_SCOPE_OPTIONS: Array<{ label: LocaleKey; value: FindScope }> = [
+ { label: 'find-replace.dialog.find-scope.current-sheet', value: FindScope.SUBUNIT },
+ { label: 'find-replace.dialog.find-scope.workbook', value: FindScope.UNIT },
+];
+
+const FIND_DIRECTION_OPTIONS: Array<{ label: LocaleKey; value: FindDirection }> = [
+ { label: 'find-replace.dialog.find-direction.row', value: FindDirection.ROW },
+ { label: 'find-replace.dialog.find-direction.column', value: FindDirection.COLUMN },
+];
+
+const FIND_BY_OPTIONS: Array<{ label: LocaleKey; value: FindBy }> = [
+ { label: 'find-replace.dialog.find-by.value', value: FindBy.VALUE },
+ { label: 'find-replace.dialog.find-by.formula', value: FindBy.FORMULA },
+];
+
function useFindInputFocus(findReplaceService: IFindReplaceService, ref: ForwardedRef<unknown>) {
const focus = useCallback(() => {
(document.querySelector('.univer-find-input input') as Nullable<HTMLInputElement>)?.focus();
@@ -158,9 +173,9 @@ export const ReplaceDialog = forwardRef(function ReplaceDialogImpl(_props, ref)
findReplaceService.changeFindBy(findBy as FindBy);
}, [findReplaceService]);
- const findScopeOptions = useFindScopeOptions(localeService);
- const findDirectionOptions = useFindDirectionOptions(localeService);
- const findByOptions = useFindByOptions(localeService);
+ const findScopeOptions = FIND_SCOPE_OPTIONS.map((option) => ({ ...option, label: localeService.t(option.label) }));
+ const findDirectionOptions = FIND_DIRECTION_OPTIONS.map((option) => ({ ...option, label: localeService.t(option.label) }));
+ const findByOptions = FIND_BY_OPTIONS.map((option) => ({ ...option, label: localeService.t(option.label) }));
useEffect(() => {
const shouldDisplayNoMatchInfo = findCompleted && matchesCount === 0;
@@ -302,39 +317,3 @@ export function FindReplaceDialog() {
</div>
);
}
-
-function useFindScopeOptions(localeService: LocaleService): Array<{ label: string; value: string }> {
- const locale = localeService.getCurrentLocale();
- const options = useMemo(() => {
- return [
- { label: localeService.t<LocaleKey>('find-replace.dialog.find-scope.current-sheet'), value: FindScope.SUBUNIT },
- { label: localeService.t<LocaleKey>('find-replace.dialog.find-scope.workbook'), value: FindScope.UNIT },
- ];
- }, [locale]);
-
- return options;
-}
-
-function useFindDirectionOptions(localeService: LocaleService): Array<{ label: string; value: string }> {
- const locale = localeService.getCurrentLocale();
- const options = useMemo(() => {
- return [
- { label: localeService.t<LocaleKey>('find-replace.dialog.find-direction.row'), value: FindDirection.ROW },
- { label: localeService.t<LocaleKey>('find-replace.dialog.find-direction.column'), value: FindDirection.COLUMN },
- ];
- }, [locale]);
-
- return options;
-}
-
-function useFindByOptions(localeService: LocaleService): Array<{ label: string; value: string }> {
- const locale = localeService.getCurrentLocale();
- const options = useMemo(() => {
- return [
- { label: localeService.t<LocaleKey>('find-replace.dialog.find-by.value'), value: FindBy.VALUE },
- { label: localeService.t<LocaleKey>('find-replace.dialog.find-by.formula'), value: FindBy.FORMULA },
- ];
- }, [locale]);
-
- return options;
-}
diff --git a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/ColorScale.tsx b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/ColorScale.tsx
index c8961c525a..989a50f1f1 100644
--- a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/ColorScale.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/ColorScale.tsx
@@ -29,8 +29,8 @@ import { ColorPicker } from '../../ColorPicker';
import { Preview } from '../../Preview';
import { previewClassName } from './styles';
-const createOptionItem = (text: string, localeService: LocaleService) => ({
- label: localeService.t(`sheets-conditional-formatting-ui.valueType.${text}`),
+const createOptionItem = (text: CFValueType | 'none'): { label: LocaleKey; value: CFValueType | 'none' } => ({
+ label: `sheets-conditional-formatting-ui.valueType.${text}`,
value: text,
});
@@ -101,10 +101,10 @@ export const ColorScaleStyleEditor = (props: IStyleEditorProps) => {
const localeService = useDependency(LocaleService);
const rule = props.rule?.type === CFRuleType.colorScale ? props.rule : undefined as IColorScale | undefined;
- const commonOptions = [createOptionItem(CFValueType.num, localeService), createOptionItem(CFValueType.percent, localeService), createOptionItem(CFValueType.percentile, localeService), createOptionItem(CFValueType.formula, localeService)];
- const minOptions = [createOptionItem(CFValueType.min, localeService), ...commonOptions];
- const medianOptions = [createOptionItem('none', localeService), ...commonOptions];
- const maxOptions = [createOptionItem(CFValueType.max, localeService), ...commonOptions];
+ const commonOptionDefinitions = [createOptionItem(CFValueType.num), createOptionItem(CFValueType.percent), createOptionItem(CFValueType.percentile), createOptionItem(CFValueType.formula)];
+ const minOptions = [createOptionItem(CFValueType.min), ...commonOptionDefinitions].map((option) => ({ ...option, label: localeService.t(option.label) }));
+ const medianOptions = [createOptionItem('none'), ...commonOptionDefinitions].map((option) => ({ ...option, label: localeService.t(option.label) }));
+ const maxOptions = [createOptionItem(CFValueType.max), ...commonOptionDefinitions].map((option) => ({ ...option, label: localeService.t(option.label) }));
const [minType, setMinType] = useState(() => {
const defaultV = CFValueType.min;
diff --git a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/DataBar.tsx b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/DataBar.tsx
index da7cf69e2a..6ca1f47020 100644
--- a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/DataBar.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/DataBar.tsx
@@ -35,7 +35,10 @@ import { ColorPicker } from '../../ColorPicker';
import { Preview } from '../../Preview';
import { previewClassName } from './styles';
-const createOptionItem = (text: CFValueType, localeService: LocaleService) => ({ label: localeService.t<LocaleKey>(`sheets-conditional-formatting-ui.valueType.${text}`), value: text });
+const createOptionItem = (text: CFValueType): { label: LocaleKey; value: CFValueType } => ({
+ label: `sheets-conditional-formatting-ui.valueType.${text}`,
+ value: text,
+});
const InputText = (props: { disabled?: boolean; id: string; className?: string; type: CFValueType; value: string | number; onChange: (v: string | number) => void }) => {
const { onChange, className, value, type, id, disabled = false } = props;
@@ -128,14 +131,14 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => {
}
return rule.config?.nativeColor || defaultDataBarNativeColor;
});
- const commonOptions = [
- createOptionItem(CFValueType.num, localeService),
- createOptionItem(CFValueType.percent, localeService),
- createOptionItem(CFValueType.percentile, localeService),
- createOptionItem(CFValueType.formula, localeService),
+ const commonOptionDefinitions = [
+ createOptionItem(CFValueType.num),
+ createOptionItem(CFValueType.percent),
+ createOptionItem(CFValueType.percentile),
+ createOptionItem(CFValueType.formula),
];
- const minOptions = [createOptionItem(CFValueType.min, localeService), ...commonOptions];
- const maxOptions = [createOptionItem(CFValueType.max, localeService), ...commonOptions];
+ const minOptions = [createOptionItem(CFValueType.min), ...commonOptionDefinitions].map((option) => ({ ...option, label: localeService.t(option.label) }));
+ const maxOptions = [createOptionItem(CFValueType.max), ...commonOptionDefinitions].map((option) => ({ ...option, label: localeService.t(option.label) }));
const [minValueType, setMinValueType] = useState<CFValueType>(() => {
const defaultV = minOptions[0].value as CFValueType;
if (!rule) {
@@ -257,7 +260,7 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => {
};
const isShowInput = (type: string) => {
- return commonOptions.map((item) => item.value).includes(type as CFValueType);
+ return commonOptionDefinitions.map((item) => item.value).includes(type as CFValueType);
};
return (
diff --git a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/HighlightCell.tsx b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/HighlightCell.tsx
index 2f1a3ff7f7..fbb69dbe64 100644
--- a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/HighlightCell.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/HighlightCell.tsx
@@ -40,8 +40,8 @@ import { Preview } from '../../Preview';
import { WrapperError } from '../../wrapper-error/WrapperError';
import { previewClassName } from './styles';
-const createOptionItem = (text: string, localeService: LocaleService) => ({
- label: localeService.t(`sheets-conditional-formatting-ui.operator.${text}`),
+const createOptionItem = (text: CFTextOperator | CFNumberOperator | CFTimePeriodOperator): { label: LocaleKey; value: string } => ({
+ label: `sheets-conditional-formatting-ui.operator.${text}`,
value: text,
});
type IValue = number | string | [number, number];
@@ -190,48 +190,50 @@ function HighlightCellInput(props: {
}
return null;
};
-const getOperatorOptions = (type: CFSubRuleType.duplicateValues | CFSubRuleType.uniqueValues | CFSubRuleType.number | CFSubRuleType.text | CFSubRuleType.timePeriod | CFSubRuleType.formula, localeService: LocaleService) => {
+const getOperatorOptions = (type: CFSubRuleType.duplicateValues | CFSubRuleType.uniqueValues | CFSubRuleType.number | CFSubRuleType.text | CFSubRuleType.timePeriod | CFSubRuleType.formula) => {
switch (type) {
case CFSubRuleType.text: {
return [
- createOptionItem(CFTextOperator.containsText, localeService),
- createOptionItem(CFTextOperator.notContainsText, localeService),
- createOptionItem(CFTextOperator.beginsWith, localeService),
- createOptionItem(CFTextOperator.endsWith, localeService),
- createOptionItem(CFTextOperator.equal, localeService),
- createOptionItem(CFTextOperator.notEqual, localeService),
- createOptionItem(CFTextOperator.containsBlanks, localeService),
- createOptionItem(CFTextOperator.notContainsBlanks, localeService),
- createOptionItem(CFTextOperator.containsErrors, localeService),
- createOptionItem(CFTextOperator.notContainsErrors, localeService),
+ createOptionItem(CFTextOperator.containsText),
+ createOptionItem(CFTextOperator.notContainsText),
+ createOptionItem(CFTextOperator.beginsWith),
+ createOptionItem(CFTextOperator.endsWith),
+ createOptionItem(CFTextOperator.equal),
+ createOptionItem(CFTextOperator.notEqual),
+ createOptionItem(CFTextOperator.containsBlanks),
+ createOptionItem(CFTextOperator.notContainsBlanks),
+ createOptionItem(CFTextOperator.containsErrors),
+ createOptionItem(CFTextOperator.notContainsErrors),
];
}
case CFSubRuleType.number: {
return [
- createOptionItem(CFNumberOperator.between, localeService),
- createOptionItem(CFNumberOperator.notBetween, localeService),
- createOptionItem(CFNumberOperator.equal, localeService),
- createOptionItem(CFNumberOperator.notEqual, localeService),
- createOptionItem(CFNumberOperator.greaterThan, localeService),
- createOptionItem(CFNumberOperator.greaterThanOrEqual, localeService),
- createOptionItem(CFNumberOperator.lessThan, localeService),
- createOptionItem(CFNumberOperator.lessThanOrEqual, localeService),
+ createOptionItem(CFNumberOperator.between),
+ createOptionItem(CFNumberOperator.notBetween),
+ createOptionItem(CFNumberOperator.equal),
+ createOptionItem(CFNumberOperator.notEqual),
+ createOptionItem(CFNumberOperator.greaterThan),
+ createOptionItem(CFNumberOperator.greaterThanOrEqual),
+ createOptionItem(CFNumberOperator.lessThan),
+ createOptionItem(CFNumberOperator.lessThanOrEqual),
];
}
case CFSubRuleType.timePeriod: {
return [
- createOptionItem(CFTimePeriodOperator.yesterday, localeService),
- createOptionItem(CFTimePeriodOperator.today, localeService),
- createOptionItem(CFTimePeriodOperator.tomorrow, localeService),
- createOptionItem(CFTimePeriodOperator.last7Days, localeService),
- createOptionItem(CFTimePeriodOperator.lastWeek, localeService),
- createOptionItem(CFTimePeriodOperator.thisWeek, localeService),
- createOptionItem(CFTimePeriodOperator.nextWeek, localeService),
- createOptionItem(CFTimePeriodOperator.lastMonth, localeService),
- createOptionItem(CFTimePeriodOperator.thisMonth, localeService),
- createOptionItem(CFTimePeriodOperator.nextMonth, localeService),
+ createOptionItem(CFTimePeriodOperator.yesterday),
+ createOptionItem(CFTimePeriodOperator.today),
+ createOptionItem(CFTimePeriodOperator.tomorrow),
+ createOptionItem(CFTimePeriodOperator.last7Days),
+ createOptionItem(CFTimePeriodOperator.lastWeek),
+ createOptionItem(CFTimePeriodOperator.thisWeek),
+ createOptionItem(CFTimePeriodOperator.nextWeek),
+ createOptionItem(CFTimePeriodOperator.lastMonth),
+ createOptionItem(CFTimePeriodOperator.thisMonth),
+ createOptionItem(CFTimePeriodOperator.nextMonth),
];
}
+ default:
+ return [];
}
};
export const HighlightCellStyleEditor = (props: IStyleEditorProps<any, ITextHighlightCell | INumberHighlightCell | ITimePeriodHighlightCell>) => {
@@ -264,10 +266,10 @@ export const HighlightCellStyleEditor = (props: IStyleEditorProps<any, ITextHigh
label: localeService.t<LocaleKey>('sheets-conditional-formatting-ui.subRuleType.uniqueValues'),
}];
- const operatorOptions = useMemo(() => getOperatorOptions(subType, localeService), [subType]);
+ const operatorOptions = useMemo(() => getOperatorOptions(subType).map((option) => ({ ...option, label: localeService.t(option.label) })), [localeService, subType]);
const [operator, setOperator] = useState<IResult['operator'] | undefined>(() => {
- const defaultV = operatorOptions ? operatorOptions[0].value as IResult['operator'] : undefined;
+ const defaultV = operatorOptions[0]?.value as IResult['operator'] | undefined;
if (!rule) {
return defaultV;
}
@@ -287,6 +289,14 @@ export const HighlightCellStyleEditor = (props: IStyleEditorProps<any, ITextHigh
const getResult = useMemo(() => (option: { subType?: string; operator?: string; value?: IValue; style?: IHighlightCell['style'] }) => {
switch (option.subType || subType) {
+ case CFSubRuleType.duplicateValues:
+ case CFSubRuleType.uniqueValues: {
+ return {
+ type: CFRuleType.highlightCell,
+ subType: option.subType ?? subType,
+ style: option.style ?? style,
+ };
+ }
case CFSubRuleType.text: {
if ([CFTextOperator.beginsWith, CFTextOperator.endsWith, CFTextOperator.containsText, CFTextOperator.notContainsText, CFTextOperator.equal, CFTextOperator.notEqual].includes(operator as CFTextOperator)) {
return {
@@ -346,8 +356,8 @@ export const HighlightCellStyleEditor = (props: IStyleEditorProps<any, ITextHigh
const onTypeChange = (v: string) => {
const _subType = v as typeof subType;
- const operatorList = getOperatorOptions(_subType, localeService);
- const _operator = operatorList && operatorList[0].value as typeof operator;
+ const operatorList = getOperatorOptions(_subType).map((option) => ({ ...option, label: localeService.t(option.label) }));
+ const _operator = operatorList[0]?.value as typeof operator;
setSubType(_subType);
setOperator(_operator);
_operator && setValue(createDefaultValue(_subType, _operator));
diff --git a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/__tests__/RuleEditors.spec.tsx b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/__tests__/RuleEditors.spec.tsx
index 35c90f7b00..9abad4d853 100644
--- a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/__tests__/RuleEditors.spec.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/__tests__/RuleEditors.spec.tsx
@@ -677,14 +677,17 @@ describe('conditional formatting rule editors', () => {
});
expect(interceptorManager.fetchThroughInterceptors(beforeSubmit)(true, null)).toBe(true);
- expect(submitRule(interceptorManager)).toMatchObject({
+ const submittedRule = submitRule(interceptorManager);
+ expect(submittedRule).toMatchObject({
type: CFRuleType.highlightCell,
subType: CFSubRuleType.duplicateValues,
});
+ expect(submittedRule).not.toHaveProperty('operator');
expect(lastRule).toMatchObject({
type: CFRuleType.highlightCell,
subType: CFSubRuleType.duplicateValues,
});
+ expect(lastRule).not.toHaveProperty('operator');
});
it('preserves an existing formula highlight rule and validates it through beforeSubmit', async () => {
diff --git a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
index b06a854443..0f258ab74e 100644
--- a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
+++ b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
@@ -44,7 +44,7 @@ import {
} from '@univerjs/sheets';
import { FilterBy, SetSheetsFilterRangeMutation, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { SheetsFilterPanelService } from '../../../services/sheets-filter-panel.service';
+import { ISheetsFilterPanelService, SheetsFilterPanelService } from '../../../services/sheets-filter-panel.service';
import {
ChangeFilterByOperation,
CloseFilterPanelOperation,
@@ -103,7 +103,7 @@ function createFilterOperationTestBed() {
override onStarting(): void {
([
[SheetInterceptorService],
- [SheetsFilterPanelService],
+ [ISheetsFilterPanelService, { useClass: SheetsFilterPanelService }],
[RefRangeService],
[SheetsSelectionsService],
[SheetRangeThemeModel],
@@ -138,7 +138,7 @@ describe('test sheets filter ui operations', () => {
let get: Injector['get'];
let contextService: IContextService;
let commandService: ICommandService;
- let sheetsFilterPanelService: SheetsFilterPanelService;
+ let sheetsFilterPanelService: ISheetsFilterPanelService;
beforeEach(() => {
const testBed = createFilterOperationTestBed();
@@ -147,7 +147,7 @@ describe('test sheets filter ui operations', () => {
contextService = get(IContextService);
commandService = get(ICommandService);
- sheetsFilterPanelService = get(SheetsFilterPanelService);
+ sheetsFilterPanelService = get(ISheetsFilterPanelService);
});
afterEach(() => {
diff --git a/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts b/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts
index 1d2088d5ce..ebdf5c812b 100644
--- a/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts
+++ b/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts
@@ -20,7 +20,7 @@ import { CommandType, ICommandService, IContextService, Quantity } from '@univer
import { SheetsFilterService } from '@univerjs/sheets-filter';
import { IEditorBridgeService, SetCellEditVisibleOperation } from '@univerjs/sheets-ui';
import { ILayoutService } from '@univerjs/ui';
-import { SheetsFilterPanelService } from '../../services/sheets-filter-panel.service';
+import { ISheetsFilterPanelService } from '../../services/sheets-filter-panel.service';
export const FILTER_PANEL_OPENED_KEY = 'FILTER_PANEL_OPENED';
@@ -40,7 +40,7 @@ export const OpenFilterPanelOperation: IOperation<IOpenFilterPanelOperationParam
handler: (accessor, params: IOpenFilterPanelOperationParams) => {
const contextService = accessor.get(IContextService);
const sheetsFilterService = accessor.get(SheetsFilterService);
- const sheetsFilterPanelService = accessor.get(SheetsFilterPanelService);
+ const sheetsFilterPanelService = accessor.get(ISheetsFilterPanelService);
const commandService = accessor.get(ICommandService);
// Close the cell edit if it is opened.
@@ -68,7 +68,7 @@ export const CloseFilterPanelOperation: IOperation = {
type: CommandType.OPERATION,
handler: (accessor) => {
const contextService = accessor.get(IContextService);
- const sheetsFilterPanelService = accessor.get(SheetsFilterPanelService);
+ const sheetsFilterPanelService = accessor.get(ISheetsFilterPanelService);
const layoutService = accessor.get(ILayoutService, Quantity.OPTIONAL);
if (contextService.getContextValue(FILTER_PANEL_OPENED_KEY)) {
@@ -90,7 +90,7 @@ export const ChangeFilterByOperation: IOperation<IChangeFilterByOperationParams>
type: CommandType.OPERATION,
handler: (accessor, params) => {
const { filterBy } = params!;
- const sheetsFilterPanelService = accessor.get(SheetsFilterPanelService);
+ const sheetsFilterPanelService = accessor.get(ISheetsFilterPanelService);
return sheetsFilterPanelService.changeFilterBy(filterBy);
},
};
diff --git a/packages/sheets-filter-ui/src/controllers/ui.controller.ts b/packages/sheets-filter-ui/src/controllers/ui.controller.ts
index b84f75806c..74a8e3c1be 100644
--- a/packages/sheets-filter-ui/src/controllers/ui.controller.ts
+++ b/packages/sheets-filter-ui/src/controllers/ui.controller.ts
@@ -29,7 +29,7 @@ import {
OpenFilterPanelOperation,
} from '../commands/operations/sheets-filter.operation';
import { menuSchema } from '../menu/schema';
-import { SheetsFilterPanelService } from '../services/sheets-filter-panel.service';
+import { ISheetsFilterPanelService } from '../services/sheets-filter-panel.service';
import { FILTER_PANEL_POPUP_KEY } from '../views/components/SheetsFilterPanel';
import { SmartToggleFilterShortcut } from './sheets-filter.shortcut';
import { SheetsFilterUIMobileController } from './ui-mobile.controller';
@@ -40,7 +40,7 @@ import { SheetsFilterUIMobileController } from './ui-mobile.controller';
export class SheetsFilterUIDesktopController extends SheetsFilterUIMobileController {
constructor(
@Inject(Injector) private readonly _injector: Injector,
- @Inject(SheetsFilterPanelService) private readonly _sheetsFilterPanelService: SheetsFilterPanelService,
+ @ISheetsFilterPanelService private readonly _sheetsFilterPanelService: ISheetsFilterPanelService,
@Inject(SheetCanvasPopManagerService) private _sheetCanvasPopupService: SheetCanvasPopManagerService,
@Inject(SheetsFilterService) private _sheetsFilterService: SheetsFilterService,
@Inject(LocaleService) private _localeService: LocaleService,
diff --git a/packages/sheets-filter-ui/src/plugin.ts b/packages/sheets-filter-ui/src/plugin.ts
index 1419333dff..533c8971dd 100644
--- a/packages/sheets-filter-ui/src/plugin.ts
+++ b/packages/sheets-filter-ui/src/plugin.ts
@@ -34,7 +34,7 @@ import { defaultPluginConfig, SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY } from './confi
import { ComponentsController } from './controllers/components.controller';
import { SheetsFilterPermissionController } from './controllers/sheets-filter-permission.controller';
import { SheetsFilterUIDesktopController } from './controllers/ui.controller';
-import { SheetsFilterPanelService } from './services/sheets-filter-panel.service';
+import { ISheetsFilterPanelService, SheetsFilterPanelService } from './services/sheets-filter-panel.service';
import {
ISheetsGenerateFilterValuesService,
SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME,
@@ -74,7 +74,7 @@ export class UniverSheetsFilterUIPlugin extends Plugin {
this._injector.add([ComponentsController]);
this._injector.get(ComponentsController);
registerDependencies(this._injector, [
- [SheetsFilterPanelService],
+ [ISheetsFilterPanelService, { useClass: SheetsFilterPanelService }],
[SheetsFilterPermissionController],
[SheetsFilterUIDesktopController],
]);
diff --git a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
index b67adb896b..861e7fa6bf 100644
--- a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
+++ b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
@@ -63,7 +63,13 @@ import {
import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
import { FilterConditionItems } from '../../models/conditions';
import { ExtendCustomFilterOperator } from '../../models/extended-operators';
-import { ByColorsModel, ByConditionsModel, ByValuesModel, SheetsFilterPanelService } from '../sheets-filter-panel.service';
+import {
+ ByColorsModel,
+ ByConditionsModel,
+ ByValuesModel,
+ ISheetsFilterPanelService,
+ SheetsFilterPanelService,
+} from '../sheets-filter-panel.service';
const SetCellEditVisibleOperation: IOperation<IEditorBridgeServiceVisibleParam> = {
id: 'sheet.operation.set-cell-edit-visible',
@@ -128,7 +134,7 @@ function createSheetsFilterPanelServiceTestBed(workbookData: IWorkbookData) {
[RefRangeService],
[SheetsSelectionsService],
[SheetInterceptorService],
- [SheetsFilterPanelService],
+ [ISheetsFilterPanelService, { useClass: SheetsFilterPanelService }],
[SheetRangeThemeModel],
[ZebraCrossingCacheController],
[IActiveDirtyManagerService, { useClass: ActiveDirtyManagerService }],
@@ -162,7 +168,7 @@ describe('test "SheetsFilterPanelService"', () => {
let get: Injector['get'];
let commandService: ICommandService;
let sheetsFilterService: SheetsFilterService;
- let sheetsFilterPanelService: SheetsFilterPanelService;
+ let sheetsFilterPanelService: ISheetsFilterPanelService;
function prepare(workbookData: IWorkbookData) {
const testBed = createSheetsFilterPanelServiceTestBed(workbookData);
@@ -172,7 +178,7 @@ describe('test "SheetsFilterPanelService"', () => {
commandService = get(ICommandService);
sheetsFilterService = get(SheetsFilterService);
- sheetsFilterPanelService = get(SheetsFilterPanelService);
+ sheetsFilterPanelService = get(ISheetsFilterPanelService);
}
afterEach(() => {
diff --git a/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts b/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts
index d7b70a1c59..a77031475d 100644
--- a/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts
+++ b/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts
@@ -56,17 +56,17 @@ export interface IFilterByColorItem {
}
export interface ISheetsFilterPanelService {
- /**
- * Set up the panel to change the filter condition on a specific column.
- * @param filterModel the filter model we will be working on
- * @param col
- * @returns if the filter condition is set up successfully
- */
- setUpFilterConditionOfCol(filterModel: FilterModel, col: number): boolean;
-
- /**
- * Terminate the filter panel without applying changes.
- */
+ readonly col: number;
+ readonly col$: Observable<number>;
+ readonly filterBy: FilterBy;
+ readonly filterBy$: Observable<FilterBy>;
+ readonly filterByModel: Nullable<IFilterByModel>;
+ readonly filterByModel$: Observable<Nullable<IFilterByModel>>;
+ readonly filterModel: Nullable<FilterModel>;
+ readonly hasCriteria$: Observable<boolean>;
+
+ setupCol(filterModel: FilterModel, col: number): void;
+ changeFilterBy(filterBy: FilterBy): boolean;
terminate(): boolean;
}
export const ISheetsFilterPanelService = createIdentifier<ISheetsFilterPanelService>('sheets-filter-ui.sheets-filter-panel.service');
@@ -84,7 +84,7 @@ export interface IFilterByModel extends IDisposable {
* This service controls the state of the filter panel. There should be only one instance of the filter panel
* at one time.
*/
-export class SheetsFilterPanelService extends Disposable {
+export class SheetsFilterPanelService extends Disposable implements ISheetsFilterPanelService {
private readonly _filterBy$ = new BehaviorSubject<FilterBy>(FilterBy.VALUES);
readonly filterBy$ = this._filterBy$.asObservable();
get filterBy(): FilterBy { return this._filterBy$.getValue(); }
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx
index 41f27db046..abf16403a6 100644
--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx
+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx
@@ -14,16 +14,38 @@
* limitations under the License.
*/
-import type { ISelectProps } from '@univerjs/design';
import type { LocaleKey } from '../../locale/types';
import type { FilterOperator, IFilterConditionFormParams } from '../../models/conditions';
import type { ByConditionsModel } from '../../services/sheets-filter-panel.service';
import { LocaleService } from '@univerjs/core';
import { borderClassName, clsx, Input, Radio, RadioGroup, Select } from '@univerjs/design';
import { useDependency, useObservable } from '@univerjs/ui';
-import { useCallback, useMemo } from 'react';
+import { useCallback } from 'react';
import { FilterConditionItems } from '../../models/conditions';
+const PRIMARY_CONDITION_GROUPS = [
+ [FilterConditionItems.NONE],
+ [FilterConditionItems.EMPTY, FilterConditionItems.NOT_EMPTY],
+ [
+ FilterConditionItems.TEXT_CONTAINS,
+ FilterConditionItems.DOES_NOT_CONTAIN,
+ FilterConditionItems.STARTS_WITH,
+ FilterConditionItems.ENDS_WITH,
+ FilterConditionItems.EQUALS,
+ ],
+ [
+ FilterConditionItems.GREATER_THAN,
+ FilterConditionItems.GREATER_THAN_OR_EQUAL,
+ FilterConditionItems.LESS_THAN,
+ FilterConditionItems.LESS_THAN_OR_EQUAL,
+ FilterConditionItems.EQUAL,
+ FilterConditionItems.NOT_EQUAL,
+ FilterConditionItems.BETWEEN,
+ FilterConditionItems.NOT_BETWEEN,
+ ],
+ [FilterConditionItems.CUSTOM],
+];
+
/**
* Filter by conditions.
*/
@@ -41,12 +63,22 @@ export function FilterByCondition(props: { model: ByConditionsModel }) {
model.onConditionFormChange({ and: key === 'AND' });
}, [model]);
- const primaryOptions = usePrimaryOptions(localeService);
+ const primaryOptions = PRIMARY_CONDITION_GROUPS.map((group) => ({
+ options: group.map((conditionItem) => ({
+ label: localeService.t(conditionItem.label),
+ value: conditionItem.operator,
+ })),
+ }));
const onPrimaryConditionChange = useCallback((value: string) => {
model.onPrimaryConditionChange(value as FilterOperator);
}, [model]);
- const secondaryOptions = useSecondaryOptions(localeService);
+ const secondaryOptions = FilterConditionItems.ALL_CONDITIONS
+ .filter((conditionItem) => conditionItem.numOfParameters !== 2)
+ .map((conditionItem) => ({
+ label: localeService.t(conditionItem.label),
+ value: conditionItem.operator,
+ }));
const onFormParamsChange = useCallback((diffParams: Partial<IFilterConditionFormParams>) => {
model.onConditionFormChange(diffParams);
}, [model]);
@@ -116,109 +148,3 @@ export function FilterByCondition(props: { model: ByConditionsModel }) {
</div>
);
}
-
-function usePrimaryOptions(localeService: LocaleService): ISelectProps['options'] {
- const locale = localeService.getCurrentLocale();
-
- return useMemo(() => [
- {
- options: [
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.NONE.label),
- value: FilterConditionItems.NONE.operator,
- },
- ],
- },
- {
- options: [
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.EMPTY.label),
- value: FilterConditionItems.EMPTY.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.NOT_EMPTY.label),
- value: FilterConditionItems.NOT_EMPTY.operator,
- },
- ],
- },
- {
- options: [
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.TEXT_CONTAINS.label),
- value: FilterConditionItems.TEXT_CONTAINS.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.DOES_NOT_CONTAIN.label),
- value: FilterConditionItems.DOES_NOT_CONTAIN.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.STARTS_WITH.label),
- value: FilterConditionItems.STARTS_WITH.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.ENDS_WITH.label),
- value: FilterConditionItems.ENDS_WITH.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.EQUALS.label),
- value: FilterConditionItems.EQUALS.operator,
- },
- ],
- },
- {
- options: [
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.GREATER_THAN.label),
- value: FilterConditionItems.GREATER_THAN.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.GREATER_THAN_OR_EQUAL.label),
- value: FilterConditionItems.GREATER_THAN_OR_EQUAL.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.LESS_THAN.label),
- value: FilterConditionItems.LESS_THAN.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.LESS_THAN_OR_EQUAL.label),
- value: FilterConditionItems.LESS_THAN_OR_EQUAL.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.EQUAL.label),
- value: FilterConditionItems.EQUAL.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.NOT_EQUAL.label),
- value: FilterConditionItems.NOT_EQUAL.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.BETWEEN.label),
- value: FilterConditionItems.BETWEEN.operator,
- },
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.NOT_BETWEEN.label),
- value: FilterConditionItems.NOT_BETWEEN.operator,
- },
- ],
- },
- {
- options: [
- {
- label: localeService.t<LocaleKey>(FilterConditionItems.CUSTOM.label),
- value: FilterConditionItems.CUSTOM.operator,
- },
- ],
- },
- ] as ISelectProps['options'], [locale, localeService]);
-}
-
-function useSecondaryOptions(localeService: LocaleService): ISelectProps['options'] {
- const locale = localeService.getCurrentLocale();
-
- return useMemo(() => FilterConditionItems.ALL_CONDITIONS
- .filter((c) => c.numOfParameters !== 2)
- .map((c) => ({
- label: localeService.t<LocaleKey>(c.label),
- value: c.operator,
- })) as ISelectProps['options'], [locale, localeService]);
-}
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx
index 296a255837..28caf60a04 100644
--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx
+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx
@@ -28,7 +28,7 @@ import { ChangeFilterByOperation, CloseFilterPanelOperation, OpenFilterPanelOper
import enUS from '../../locale/en-US';
import ruRU from '../../locale/ru-RU';
import zhCN from '../../locale/zh-CN';
-import { SheetsFilterPanelService } from '../../services/sheets-filter-panel.service';
+import { ISheetsFilterPanelService, SheetsFilterPanelService } from '../../services/sheets-filter-panel.service';
import { FilterPanel } from './SheetsFilterPanel';
const meta: Meta<typeof FilterPanel> = {
@@ -69,7 +69,7 @@ function createFilterStorybookBed(workbookData: IWorkbookData, locale: LocaleTyp
[IUIPartsService, { useClass: UIPartsService }],
[WorksheetProtectionPointModel],
[SheetInterceptorService],
- [SheetsFilterPanelService],
+ [ISheetsFilterPanelService, { useClass: SheetsFilterPanelService }],
[RefRangeService],
]);
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx
index 88ebe14575..8f5f7b2dbf 100644
--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx
+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx
@@ -21,29 +21,35 @@ import { Button, Segmented } from '@univerjs/design';
import { FilterBy, SheetsFilterService } from '@univerjs/sheets-filter';
import { SheetsUIPart } from '@univerjs/sheets-ui';
import { ComponentContainer, useComponentsOfPart, useDependency, useObservable } from '@univerjs/ui';
-import { useCallback, useMemo } from 'react';
+import { useCallback } from 'react';
import { of } from 'rxjs';
import { ChangeFilterByOperation, CloseFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
-import { SheetsFilterPanelService } from '../../services/sheets-filter-panel.service';
+import { ISheetsFilterPanelService } from '../../services/sheets-filter-panel.service';
import { FilterByColor } from './SheetsFilterByColorsPanel';
import { FilterByCondition } from './SheetsFilterByConditionsPanel';
import { FilterByValue } from './SheetsFilterByValuesPanel';
import { FilterSyncSwitch } from './SheetsFilterSyncSwitch';
+const FILTER_BY_OPTIONS: Array<{ label: LocaleKey; value: FilterBy }> = [
+ { label: 'sheets-filter-ui.panel.by-values', value: FilterBy.VALUES },
+ { label: 'sheets-filter-ui.panel.by-colors', value: FilterBy.COLORS },
+ { label: 'sheets-filter-ui.panel.by-conditions', value: FilterBy.CONDITIONS },
+];
+
/**
* This Filter Panel component is used to filter the data in the sheet.
*
* @returns React element
*/
export function FilterPanel() {
- const sheetsFilterPanelService = useDependency(SheetsFilterPanelService);
+ const sheetsFilterPanelService = useDependency(ISheetsFilterPanelService);
const localeService = useDependency(LocaleService);
const commandService = useDependency(ICommandService);
const filterBy = useObservable(sheetsFilterPanelService.filterBy$, undefined, true);
const filterByModel = useObservable(sheetsFilterPanelService.filterByModel$, undefined, false);
const canApply = useObservable(() => filterByModel?.canApply$ || of(false), undefined, false, [filterByModel]);
- const items = useFilterByOptions(localeService);
+ const items = FILTER_BY_OPTIONS.map((option) => ({ ...option, label: localeService.t(option.label) }));
// only can disable clear when there is no criteria
const clearFilterDisabled = !useObservable(sheetsFilterPanelService.hasCriteria$);
@@ -131,12 +137,3 @@ export function FilterPanel() {
);
}
export const FILTER_PANEL_POPUP_KEY = 'FILTER_PANEL_POPUP';
-
-function useFilterByOptions(localeService: LocaleService) {
- const locale = localeService.getCurrentLocale();
- return useMemo(() => [
- { label: localeService.t<LocaleKey>('sheets-filter-ui.panel.by-values'), value: FilterBy.VALUES },
- { label: localeService.t<LocaleKey>('sheets-filter-ui.panel.by-colors'), value: FilterBy.COLORS },
- { label: localeService.t<LocaleKey>('sheets-filter-ui.panel.by-conditions'), value: FilterBy.CONDITIONS },
- ], [locale, localeService]);
-}
diff --git a/packages/sheets-filter-ui/src/views/components/__tests__/SheetsFilterPanel.spec.tsx b/packages/sheets-filter-ui/src/views/components/__tests__/SheetsFilterPanel.spec.tsx
index f3cee81b37..30ba8c35d6 100644
--- a/packages/sheets-filter-ui/src/views/components/__tests__/SheetsFilterPanel.spec.tsx
+++ b/packages/sheets-filter-ui/src/views/components/__tests__/SheetsFilterPanel.spec.tsx
@@ -61,7 +61,7 @@ import {
OpenFilterPanelOperation,
} from '../../../commands/operations/sheets-filter.operation';
import enUS from '../../../locale/en-US';
-import { SheetsFilterPanelService } from '../../../services/sheets-filter-panel.service';
+import { ISheetsFilterPanelService, SheetsFilterPanelService } from '../../../services/sheets-filter-panel.service';
import { FilterPanel } from '../SheetsFilterPanel';
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
@@ -151,7 +151,7 @@ function createFilterPanelViewTestBed(workbookData: IWorkbookData, filterConfig?
override onStarting(): void {
([
[SheetInterceptorService],
- [SheetsFilterPanelService],
+ [ISheetsFilterPanelService, { useClass: SheetsFilterPanelService }],
[RefRangeService],
[SheetsSelectionsService],
[SheetRangeThemeModel],
@@ -194,7 +194,7 @@ function createFilterPanelViewTestBed(workbookData: IWorkbookData, filterConfig?
commandService,
contextService: injector.get(IContextService),
filterService: injector.get(SheetsFilterService),
- panelService: injector.get(SheetsFilterPanelService),
+ panelService: injector.get(ISheetsFilterPanelService),
messageService: injector.get(IMessageService) as TestMessageService,
};
}
diff --git a/packages/sheets-formula-ui/src/views/formula-editor/help-function/HelpFunction.tsx b/packages/sheets-formula-ui/src/views/formula-editor/help-function/HelpFunction.tsx
index 01dd5224e3..7a9bf8421a 100644
--- a/packages/sheets-formula-ui/src/views/formula-editor/help-function/HelpFunction.tsx
+++ b/packages/sheets-formula-ui/src/views/formula-editor/help-function/HelpFunction.tsx
@@ -31,26 +31,31 @@ import { HelpHiddenTip } from './HelpHiddenTip';
interface IParamsProps {
className?: string;
title?: string;
+ titleKey?: LocaleKey;
value?: string;
}
-const Params = ({ className, title, value }: IParamsProps) => (
- <div className="univer-my-2">
- <div
- className={clsx(`
- univer-mb-2 univer-text-sm univer-font-medium univer-text-gray-900
- dark:!univer-text-white
- `, className)}
- >
- {title}
- </div>
- <div
- className="univer-whitespace-pre-wrap univer-break-words univer-text-xs univer-text-gray-500"
- >
- {value}
+const Params = ({ className, title, titleKey, value }: IParamsProps) => {
+ const localeService = useDependency(LocaleService);
+
+ return (
+ <div className="univer-my-2">
+ <div
+ className={clsx(`
+ univer-mb-2 univer-text-sm univer-font-medium univer-text-gray-900
+ dark:!univer-text-white
+ `, className)}
+ >
+ {titleKey ? localeService.t(titleKey) : title}
+ </div>
+ <div
+ className="univer-whitespace-pre-wrap univer-break-words univer-text-xs univer-text-gray-500"
+ >
+ {value}
+ </div>
</div>
- </div>
-);
+ );
+};
interface IHelpProps {
prefix?: string;
@@ -189,13 +194,13 @@ export function HelpFunction(props: IHelpFunctionProps) {
>
<div className="univer-mt-3">
<Params
- title={localeService.t<LocaleKey>('sheets-formula-ui.prompt.helpExample')}
+ titleKey="sheets-formula-ui.prompt.helpExample"
value={`${functionInfo.functionName}(${functionInfo.functionParameter
.map((item) => item.example)
.join(',')})`}
/>
<Params
- title={localeService.t<LocaleKey>('sheets-formula-ui.prompt.helpAbstract')}
+ titleKey="sheets-formula-ui.prompt.helpAbstract"
value={functionInfo.description}
/>
{functionInfo &&
diff --git a/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-left-and-right-arrow.ts b/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-left-and-right-arrow.ts
index 08853cf8b6..d786c33168 100644
--- a/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-left-and-right-arrow.ts
+++ b/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-left-and-right-arrow.ts
@@ -54,8 +54,6 @@ export function isFormulaEditorInteractionOwner(
focusEditorId === (options.normalEditorId ?? DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
}
-export const isFormulaEditorKeyboardOwner = isFormulaEditorInteractionOwner;
-
export const useLeftAndRightArrow = (
isNeed: boolean,
shouldMoveSelection: FormulaSelectingType,
diff --git a/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsx b/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsx
index 53d24fb674..d7a855e62d 100644
--- a/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsx
+++ b/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsx
@@ -39,7 +39,7 @@ import {
TableManager,
} from '@univerjs/sheets-table';
import { useDependency } from '@univerjs/ui';
-import { useMemo, useState } from 'react';
+import { useState } from 'react';
import { SheetsTableComponentController } from '../../controllers/sheet-table-component.controller';
import { SheetsTableUiService } from '../../services/sheets-table-ui.service';
import { FilterByEnum } from '../../types';
@@ -47,9 +47,14 @@ import { SheetTableConditionPanel } from './SheetTableConditionPanel';
import { SheetTableItemsFilterPanel } from './SheetTableItemsFilterPanel';
import { getInitConditionInfo } from './util';
+const FILTER_BY_OPTIONS: Array<{ label: LocaleKey; value: FilterByEnum }> = [
+ { label: 'sheets-table-ui.filter.by-values', value: FilterByEnum.Items },
+ { label: 'sheets-table-ui.filter.by-conditions', value: FilterByEnum.Condition },
+];
+
export function SheetTableFilterPanel() {
const localeService = useDependency(LocaleService);
- const filterByItems = useFilterByOptions(localeService);
+ const filterByItems = FILTER_BY_OPTIONS.map((option) => ({ ...option, label: localeService.t(option.label) }));
const tableUiService = useDependency(SheetsTableUiService);
const tableManager = useDependency(TableManager);
const commandService = useDependency(ICommandService);
@@ -327,11 +332,3 @@ export function SheetTableFilterPanel() {
</div>
);
}
-
-function useFilterByOptions(localeService: LocaleService) {
- const locale = localeService.getCurrentLocale();
- return useMemo(() => [
- { label: localeService.t<LocaleKey>('sheets-table-ui.filter.by-values'), value: FilterByEnum.Items },
- { label: localeService.t<LocaleKey>('sheets-table-ui.filter.by-conditions'), value: FilterByEnum.Condition },
- ], [locale, localeService]);
-}
diff --git a/packages/sheets-ui/src/locale/ar-SA.ts b/packages/sheets-ui/src/locale/ar-SA.ts
index e75d3a9291..cdad7ab72d 100644
--- a/packages/sheets-ui/src/locale/ar-SA.ts
+++ b/packages/sheets-ui/src/locale/ar-SA.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'الحدود الداخلية',
borderHorizontal: 'الحدود الأفقية',
borderVertical: 'الحدود العمودية',
+ borderTlbr: 'حد قطري لأسفل',
+ borderTlbcTlmr: 'حد قطري مزدوج لأسفل',
+ borderTlbrTlbcTlmr: 'حد قطري ثلاثي لأسفل',
+ borderBlTr: 'حد قطري لأعلى',
+ borderMltrBctr: 'حد قطري مزدوج لأعلى',
borderColor: 'لون الحدود',
borderSize: 'حجم الحدود',
borderType: 'نوع الحدود',
diff --git a/packages/sheets-ui/src/locale/ca-ES.ts b/packages/sheets-ui/src/locale/ca-ES.ts
index 99041bb971..932390aab3 100644
--- a/packages/sheets-ui/src/locale/ca-ES.ts
+++ b/packages/sheets-ui/src/locale/ca-ES.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'voraInterior',
borderHorizontal: 'voraHoritzontal',
borderVertical: 'voraVertical',
+ borderTlbr: 'Vora diagonal descendent',
+ borderTlbcTlmr: 'Vora diagonal descendent doble',
+ borderTlbrTlbcTlmr: 'Vora diagonal descendent triple',
+ borderBlTr: 'Vora diagonal ascendent',
+ borderMltrBctr: 'Vora diagonal ascendent doble',
borderColor: 'colorVora',
borderSize: 'gruixVora',
borderType: 'tipusVora',
diff --git a/packages/sheets-ui/src/locale/de-DE.ts b/packages/sheets-ui/src/locale/de-DE.ts
index 3846751ce4..8d261bf94f 100644
--- a/packages/sheets-ui/src/locale/de-DE.ts
+++ b/packages/sheets-ui/src/locale/de-DE.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'Rahmen innen',
borderHorizontal: 'Horizontale Rahmenlinie',
borderVertical: 'Vertikale Rahmenlinie',
+ borderTlbr: 'Diagonale Linie abwärts',
+ borderTlbcTlmr: 'Doppelte diagonale Linie abwärts',
+ borderTlbrTlbcTlmr: 'Dreifache diagonale Linie abwärts',
+ borderBlTr: 'Diagonale Linie aufwärts',
+ borderMltrBctr: 'Doppelte diagonale Linie aufwärts',
borderColor: 'Rahmenfarbe',
borderSize: 'Rahmenstärke',
borderType: 'Rahmentyp',
diff --git a/packages/sheets-ui/src/locale/en-US.ts b/packages/sheets-ui/src/locale/en-US.ts
index 2e109d3bf4..8744a2689f 100644
--- a/packages/sheets-ui/src/locale/en-US.ts
+++ b/packages/sheets-ui/src/locale/en-US.ts
@@ -95,6 +95,11 @@ const locale = {
borderInside: 'borderInside',
borderHorizontal: 'borderHorizontal',
borderVertical: 'borderVertical',
+ borderTlbr: 'Diagonal down border',
+ borderTlbcTlmr: 'Double diagonal down border',
+ borderTlbrTlbcTlmr: 'Triple diagonal down border',
+ borderBlTr: 'Diagonal up border',
+ borderMltrBctr: 'Double diagonal up border',
borderColor: 'borderColor',
borderSize: 'borderSize',
borderType: 'borderType',
diff --git a/packages/sheets-ui/src/locale/es-ES.ts b/packages/sheets-ui/src/locale/es-ES.ts
index 610e5de3c8..5289d8ec38 100644
--- a/packages/sheets-ui/src/locale/es-ES.ts
+++ b/packages/sheets-ui/src/locale/es-ES.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'bordeInterior',
borderHorizontal: 'bordeHorizontal',
borderVertical: 'bordeVertical',
+ borderTlbr: 'Borde diagonal descendente',
+ borderTlbcTlmr: 'Borde diagonal descendente doble',
+ borderTlbrTlbcTlmr: 'Borde diagonal descendente triple',
+ borderBlTr: 'Borde diagonal ascendente',
+ borderMltrBctr: 'Borde diagonal ascendente doble',
borderColor: 'colorBorde',
borderSize: 'grosorBorde',
borderType: 'tipoBorde',
diff --git a/packages/sheets-ui/src/locale/fa-IR.ts b/packages/sheets-ui/src/locale/fa-IR.ts
index f4c3d35347..66a4ff4a97 100644
--- a/packages/sheets-ui/src/locale/fa-IR.ts
+++ b/packages/sheets-ui/src/locale/fa-IR.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'حاشیه داخلی',
borderHorizontal: 'حاشیه افقی',
borderVertical: 'حاشیه عمودی',
+ borderTlbr: 'حاشیه قطری رو به پایین',
+ borderTlbcTlmr: 'حاشیه قطری دوتایی رو به پایین',
+ borderTlbrTlbcTlmr: 'حاشیه قطری سه‌تایی رو به پایین',
+ borderBlTr: 'حاشیه قطری رو به بالا',
+ borderMltrBctr: 'حاشیه قطری دوتایی رو به بالا',
borderColor: 'رنگ حاشیه',
borderSize: 'اندازه حاشیه',
borderType: 'نوع حاشیه',
diff --git a/packages/sheets-ui/src/locale/fr-FR.ts b/packages/sheets-ui/src/locale/fr-FR.ts
index 6ab007dd08..a67c70c764 100644
--- a/packages/sheets-ui/src/locale/fr-FR.ts
+++ b/packages/sheets-ui/src/locale/fr-FR.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'bordureIntérieure',
borderHorizontal: 'bordureHorizontale',
borderVertical: 'bordureVerticale',
+ borderTlbr: 'Bordure diagonale descendante',
+ borderTlbcTlmr: 'Double bordure diagonale descendante',
+ borderTlbrTlbcTlmr: 'Triple bordure diagonale descendante',
+ borderBlTr: 'Bordure diagonale montante',
+ borderMltrBctr: 'Double bordure diagonale montante',
borderColor: 'couleurDeBordure',
borderSize: 'tailleDeBordure',
borderType: 'typeDeBordure',
diff --git a/packages/sheets-ui/src/locale/id-ID.ts b/packages/sheets-ui/src/locale/id-ID.ts
index b552ab1b2c..a7dd20c3f0 100644
--- a/packages/sheets-ui/src/locale/id-ID.ts
+++ b/packages/sheets-ui/src/locale/id-ID.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'Batas dalam',
borderHorizontal: 'Batas horizontal',
borderVertical: 'Batas vertikal',
+ borderTlbr: 'Batas diagonal turun',
+ borderTlbcTlmr: 'Batas diagonal turun ganda',
+ borderTlbrTlbcTlmr: 'Batas diagonal turun rangkap tiga',
+ borderBlTr: 'Batas diagonal naik',
+ borderMltrBctr: 'Batas diagonal naik ganda',
borderColor: 'Warna batas',
borderSize: 'Ukuran batas',
borderType: 'Jenis batas',
diff --git a/packages/sheets-ui/src/locale/it-IT.ts b/packages/sheets-ui/src/locale/it-IT.ts
index 75aed17076..6ea790abbf 100644
--- a/packages/sheets-ui/src/locale/it-IT.ts
+++ b/packages/sheets-ui/src/locale/it-IT.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'bordoInterno',
borderHorizontal: 'bordoOrizzontale',
borderVertical: 'bordoVerticale',
+ borderTlbr: 'Bordo diagonale discendente',
+ borderTlbcTlmr: 'Bordo diagonale discendente doppio',
+ borderTlbrTlbcTlmr: 'Bordo diagonale discendente triplo',
+ borderBlTr: 'Bordo diagonale ascendente',
+ borderMltrBctr: 'Bordo diagonale ascendente doppio',
borderColor: 'coloreBordo',
borderSize: 'spessoreBordo',
borderType: 'tipoBordo',
diff --git a/packages/sheets-ui/src/locale/ja-JP.ts b/packages/sheets-ui/src/locale/ja-JP.ts
index 4e8ccc328e..bee2bdc632 100644
--- a/packages/sheets-ui/src/locale/ja-JP.ts
+++ b/packages/sheets-ui/src/locale/ja-JP.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: '内側',
borderHorizontal: '横罫線',
borderVertical: '縦罫線',
+ borderTlbr: '右下がり罫線',
+ borderTlbcTlmr: '右下がり二重斜線',
+ borderTlbrTlbcTlmr: '右下がり三重斜線',
+ borderBlTr: '右上がり罫線',
+ borderMltrBctr: '右上がり二重斜線',
borderColor: '罫線の色',
borderSize: '罫線の太さ',
borderType: '罫線の種類',
diff --git a/packages/sheets-ui/src/locale/ko-KR.ts b/packages/sheets-ui/src/locale/ko-KR.ts
index 1de0bb1a92..2abdc54555 100644
--- a/packages/sheets-ui/src/locale/ko-KR.ts
+++ b/packages/sheets-ui/src/locale/ko-KR.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: '내부',
borderHorizontal: '가로',
borderVertical: '세로',
+ borderTlbr: '오른쪽 아래 대각선 테두리',
+ borderTlbcTlmr: '오른쪽 아래 이중 대각선 테두리',
+ borderTlbrTlbcTlmr: '오른쪽 아래 삼중 대각선 테두리',
+ borderBlTr: '오른쪽 위 대각선 테두리',
+ borderMltrBctr: '오른쪽 위 이중 대각선 테두리',
borderColor: '테두리 색상',
borderSize: '테두리 크기',
borderType: '테두리 유형',
diff --git a/packages/sheets-ui/src/locale/pl-PL.ts b/packages/sheets-ui/src/locale/pl-PL.ts
index 4b811d78b2..f734250aee 100644
--- a/packages/sheets-ui/src/locale/pl-PL.ts
+++ b/packages/sheets-ui/src/locale/pl-PL.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'Wewnątrz',
borderHorizontal: 'Poziome',
borderVertical: 'Pionowe',
+ borderTlbr: 'Ukośne obramowanie w dół',
+ borderTlbcTlmr: 'Podwójne ukośne obramowanie w dół',
+ borderTlbrTlbcTlmr: 'Potrójne ukośne obramowanie w dół',
+ borderBlTr: 'Ukośne obramowanie w górę',
+ borderMltrBctr: 'Podwójne ukośne obramowanie w górę',
borderColor: 'Kolor obramowania',
borderSize: 'Rozmiar obramowania',
borderType: 'Typ obramowania',
diff --git a/packages/sheets-ui/src/locale/pt-BR.ts b/packages/sheets-ui/src/locale/pt-BR.ts
index 55cb035254..dcd28c605d 100644
--- a/packages/sheets-ui/src/locale/pt-BR.ts
+++ b/packages/sheets-ui/src/locale/pt-BR.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'borda interna',
borderHorizontal: 'borda horizontal',
borderVertical: 'borda vertical',
+ borderTlbr: 'Borda diagonal descendente',
+ borderTlbcTlmr: 'Borda diagonal descendente dupla',
+ borderTlbrTlbcTlmr: 'Borda diagonal descendente tripla',
+ borderBlTr: 'Borda diagonal ascendente',
+ borderMltrBctr: 'Borda diagonal ascendente dupla',
borderColor: 'cor da borda',
borderSize: 'tamanho da borda',
borderType: 'tipo de borda',
diff --git a/packages/sheets-ui/src/locale/ru-RU.ts b/packages/sheets-ui/src/locale/ru-RU.ts
index 60a198335a..aa6540d800 100644
--- a/packages/sheets-ui/src/locale/ru-RU.ts
+++ b/packages/sheets-ui/src/locale/ru-RU.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'внутренняя граница',
borderHorizontal: 'горизонтальная граница',
borderVertical: 'вертикальная граница',
+ borderTlbr: 'Диагональная граница вниз',
+ borderTlbcTlmr: 'Двойная диагональная граница вниз',
+ borderTlbrTlbcTlmr: 'Тройная диагональная граница вниз',
+ borderBlTr: 'Диагональная граница вверх',
+ borderMltrBctr: 'Двойная диагональная граница вверх',
borderColor: 'цвет границы',
borderSize: 'размер границы',
borderType: 'тип границы',
diff --git a/packages/sheets-ui/src/locale/sk-SK.ts b/packages/sheets-ui/src/locale/sk-SK.ts
index 9936412ced..ba66ef882b 100644
--- a/packages/sheets-ui/src/locale/sk-SK.ts
+++ b/packages/sheets-ui/src/locale/sk-SK.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'vnútornéOhraničenie',
borderHorizontal: 'vodorovnéOhraničenie',
borderVertical: 'zvisléOhraničenie',
+ borderTlbr: 'Diagonálne orámovanie nadol',
+ borderTlbcTlmr: 'Dvojité diagonálne orámovanie nadol',
+ borderTlbrTlbcTlmr: 'Trojité diagonálne orámovanie nadol',
+ borderBlTr: 'Diagonálne orámovanie nahor',
+ borderMltrBctr: 'Dvojité diagonálne orámovanie nahor',
borderColor: 'farbaOhraničenia',
borderSize: 'hrúbkaOhraničenia',
borderType: 'typOhraničenia',
diff --git a/packages/sheets-ui/src/locale/vi-VN.ts b/packages/sheets-ui/src/locale/vi-VN.ts
index d1baf5a8ab..9419103472 100644
--- a/packages/sheets-ui/src/locale/vi-VN.ts
+++ b/packages/sheets-ui/src/locale/vi-VN.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: 'Bên trong',
borderHorizontal: 'Đường ngang bên trong',
borderVertical: 'Đường dọc bên trong',
+ borderTlbr: 'Đường viền chéo xuống',
+ borderTlbcTlmr: 'Đường viền chéo xuống kép',
+ borderTlbrTlbcTlmr: 'Đường viền chéo xuống ba',
+ borderBlTr: 'Đường viền chéo lên',
+ borderMltrBctr: 'Đường viền chéo lên kép',
borderColor: 'Màu viền',
borderSize: 'Độ dày viền',
borderType: 'Loại đường viền',
diff --git a/packages/sheets-ui/src/locale/zh-CN.ts b/packages/sheets-ui/src/locale/zh-CN.ts
index 6ff5bf5af3..5ae45a7cbc 100644
--- a/packages/sheets-ui/src/locale/zh-CN.ts
+++ b/packages/sheets-ui/src/locale/zh-CN.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: '内侧',
borderHorizontal: '内侧横线',
borderVertical: '内侧竖线',
+ borderTlbr: '右下斜线',
+ borderTlbcTlmr: '右下双斜线',
+ borderTlbrTlbcTlmr: '右下三斜线',
+ borderBlTr: '右上斜线',
+ borderMltrBctr: '右上双斜线',
borderColor: '边框颜色',
borderSize: '边框粗细',
borderType: '边框线类型',
diff --git a/packages/sheets-ui/src/locale/zh-HK.ts b/packages/sheets-ui/src/locale/zh-HK.ts
index 3ea839836a..db506f6e36 100644
--- a/packages/sheets-ui/src/locale/zh-HK.ts
+++ b/packages/sheets-ui/src/locale/zh-HK.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: '內側',
borderHorizontal: '內側水平框線',
borderVertical: '內側垂直框線',
+ borderTlbr: '右下斜線',
+ borderTlbcTlmr: '右下雙斜線',
+ borderTlbrTlbcTlmr: '右下三斜線',
+ borderBlTr: '右上斜線',
+ borderMltrBctr: '右上雙斜線',
borderColor: '邊框顏色',
borderSize: '邊框粗細',
borderType: '邊框線類型',
diff --git a/packages/sheets-ui/src/locale/zh-TW.ts b/packages/sheets-ui/src/locale/zh-TW.ts
index 3ea839836a..db506f6e36 100644
--- a/packages/sheets-ui/src/locale/zh-TW.ts
+++ b/packages/sheets-ui/src/locale/zh-TW.ts
@@ -97,6 +97,11 @@ const locale: typeof enUS = {
borderInside: '內側',
borderHorizontal: '內側水平框線',
borderVertical: '內側垂直框線',
+ borderTlbr: '右下斜線',
+ borderTlbcTlmr: '右下雙斜線',
+ borderTlbrTlbcTlmr: '右下三斜線',
+ borderBlTr: '右上斜線',
+ borderMltrBctr: '右上雙斜線',
borderColor: '邊框顏色',
borderSize: '邊框粗細',
borderType: '邊框線類型',
diff --git a/packages/sheets-ui/src/views/border-panel/interface.ts b/packages/sheets-ui/src/views/border-panel/interface.ts
index e364d707d1..6709e25d13 100644
--- a/packages/sheets-ui/src/views/border-panel/interface.ts
+++ b/packages/sheets-ui/src/views/border-panel/interface.ts
@@ -16,6 +16,7 @@
import type { IBorderInfo } from '@univerjs/sheets';
import type { ICustomComponentProps } from '@univerjs/ui';
+import type { LocaleKey } from '../../locale/types';
import { BorderStyleTypes } from '@univerjs/core';
import { COMPONENT_PREFIX } from '../const';
@@ -100,7 +101,7 @@ export const BORDER_LINE_CHILDREN = [
icon: 'RightDoubleDiagonalDoubleIcon',
value: 'mltr_bctr',
},
-];
+] satisfies Array<{ label: LocaleKey; icon: string; value: string }>;
export const BORDER_SIZE_CHILDREN = [
{
diff --git a/packages/sheets-ui/src/views/dropdown/ListDropDown.tsx b/packages/sheets-ui/src/views/dropdown/ListDropDown.tsx
index 870a30f6c3..adc7698641 100644
--- a/packages/sheets-ui/src/views/dropdown/ListDropDown.tsx
+++ b/packages/sheets-ui/src/views/dropdown/ListDropDown.tsx
@@ -38,7 +38,6 @@ interface ISelectListProps {
onChange: (val: string[]) => void;
multiple?: boolean;
options: { label: string; value: string; color?: string }[];
- title?: string;
onEdit?: () => void;
style?: CSSProperties;
location: ISheetLocation;
@@ -52,7 +51,6 @@ function SelectList(props: ISelectListProps) {
onChange,
multiple,
options,
- title,
onEdit,
style,
location,
@@ -125,7 +123,11 @@ function SelectList(props: ISelectListProps) {
/>
</div>
)}
- <div className="univer-px-3.5 univer-py-1 univer-pt-2 univer-text-xs">{title}</div>
+ <div className="univer-px-3.5 univer-py-1 univer-pt-2 univer-text-xs">
+ {localeService.t<LocaleKey>(multiple
+ ? 'sheets-ui.data-validation.listMultiple.dropdown'
+ : 'sheets-ui.data-validation.list.dropdown')}
+ </div>
<div
key={lowerFilter}
className={clsx(`
@@ -236,14 +238,12 @@ export function ListDropDown(props: { popup: IPopup<IListDropdownProps & IBaseDr
const { worksheet } = location;
if (!worksheet) return null;
- const localeService = useDependency(LocaleService);
const [localValue, setLocalValue] = useState(defaultValue);
const cellWidth = (anchorRect?.right ?? 0) - (anchorRect?.left ?? 0);
return (
<SelectList
style={{ minWidth: cellWidth, maxWidth: Math.max(cellWidth, 200) }}
- title={multiple ? localeService.t<LocaleKey>('sheets-ui.data-validation.listMultiple.dropdown') : localeService.t<LocaleKey>('sheets-ui.data-validation.list.dropdown')}
value={getListDropdownValue(localValue, multiple)}
multiple={multiple}
onChange={async (newValue) => {
diff --git a/packages/ui/src/views/emoji-picker/EmojiPicker.tsx b/packages/ui/src/views/emoji-picker/EmojiPicker.tsx
index 24ed315e89..5b2abf0fba 100644
--- a/packages/ui/src/views/emoji-picker/EmojiPicker.tsx
+++ b/packages/ui/src/views/emoji-picker/EmojiPicker.tsx
@@ -226,7 +226,7 @@ export function EmojiPicker(props: { popup?: IPopup<IEmojiPickerPopupProps> }) {
>
<CategoryButton
selected={!isSearching && activeTab === 'recent'}
- title={localeService.t<LocaleKey>('ui.emojiPicker.recents')}
+ titleKey="ui.emojiPicker.recents"
onClick={() => scrollToSection('recent')}
>
<RecentIcon />
@@ -235,7 +235,7 @@ export function EmojiPicker(props: { popup?: IPopup<IEmojiPickerPopupProps> }) {
<CategoryButton
key={category.key}
selected={!isSearching && activeTab === category.key}
- title={localeService.t(category.titleKey)}
+ titleKey={category.titleKey}
onClick={() => scrollToSection(category.key)}
>
<CategoryIcon category={category.key} />
@@ -319,13 +319,15 @@ function EmojiGrid(props: {
);
}
-function CategoryButton(props: { children: ReactElement; onClick: () => void; selected: boolean; title: string }) {
+function CategoryButton(props: { children: ReactElement; onClick: () => void; selected: boolean; titleKey: LocaleKey }) {
+ const localeService = useDependency(LocaleService);
+
return (
<button
type="button"
- aria-label={props.title}
+ aria-label={localeService.t(props.titleKey)}
aria-selected={props.selected}
- title={props.title}
+ title={localeService.t(props.titleKey)}
className={clsx(
`
univer-flex univer-h-[30px] univer-flex-1 univer-cursor-pointer univer-items-center
diff --git a/packages/ui/src/views/emoji-picker/emoji-picker-utils.ts b/packages/ui/src/views/emoji-picker/emoji-picker-utils.ts
index b023ee39ca..ce5fffd959 100644
--- a/packages/ui/src/views/emoji-picker/emoji-picker-utils.ts
+++ b/packages/ui/src/views/emoji-picker/emoji-picker-utils.ts
@@ -15,6 +15,7 @@
*/
import type { LocaleService } from '@univerjs/core';
+import type { LocaleKey } from '../../locale/types';
import { emojis } from './emojis.generated';
export interface IEmojiItem {
@@ -31,7 +32,7 @@ export type EmojiCategory = Exclude<keyof typeof emojis, 'frequent'>;
export const EMOJI_RECENT_LIMIT = 11;
-const EMOJI_CATEGORY_LABEL_KEYS: Record<EmojiCategory, string> = {
+const EMOJI_CATEGORY_LABEL_KEYS: Record<EmojiCategory, LocaleKey> = {
activity: 'ui.emojiPicker.activities',
foods: 'ui.emojiPicker.food',
nature: 'ui.emojiPicker.animals',