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.

fix(design): fix dropdown menu props name (#5072)

Wenzhao Hu7be328ebcdea
diff --git a/packages/design/src/components/dropdown-menu/DropdownMenu.tsx b/packages/design/src/components/dropdown-menu/DropdownMenu.tsx
index 1481ea86e0..4f6deb1851 100644
--- a/packages/design/src/components/dropdown-menu/DropdownMenu.tsx
+++ b/packages/design/src/components/dropdown-menu/DropdownMenu.tsx
@@ -25,7 +25,6 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from './DropdownMenuPrimitive';
-// import { DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuPrimitive, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from './DropdownMenuPrimitive';
type DropdownMenu = {
type: 'item';
@@ -44,7 +43,7 @@ type DropdownMenu = {
onSelect?: (item: string) => void;
};
-export interface IDropdownProps {
+export interface IDropdownMenuProps extends ComponentProps<typeof DropdownMenuContent> {
children: ReactNode;
items: DropdownMenu[];
disabled?: boolean;
@@ -52,7 +51,7 @@ export interface IDropdownProps {
onOpenChange?: (open: boolean) => void;
}
-export function DropdownMenu(props: IDropdownProps & ComponentProps<typeof DropdownMenuContent>) {
+export function DropdownMenu(props: IDropdownMenuProps) {
const {
children,
items,
diff --git a/packages/design/src/components/dropdown-menu/index.ts b/packages/design/src/components/dropdown-menu/index.ts
index 4f146f1a10..0c0ea020f5 100644
--- a/packages/design/src/components/dropdown-menu/index.ts
+++ b/packages/design/src/components/dropdown-menu/index.ts
@@ -14,4 +14,4 @@
* limitations under the License.
*/
-export { DropdownMenu, type IDropdownProps } from './DropdownMenu';
+export { DropdownMenu, type IDropdownMenuProps } from './DropdownMenu';
diff --git a/packages/design/src/components/dropdown/Dropdown.tsx b/packages/design/src/components/dropdown/Dropdown.tsx
index 52719e5df8..3d006cc78c 100644
--- a/packages/design/src/components/dropdown/Dropdown.tsx
+++ b/packages/design/src/components/dropdown/Dropdown.tsx
@@ -19,7 +19,7 @@ import type { ComponentProps, ReactNode } from 'react';
import { useState } from 'react';
import { PopoverContent, PopoverPrimitive, PopoverTrigger } from './PopoverPrimitive';
-interface IDropdownProps {
+export interface IDropdownProps extends ComponentProps<typeof Content> {
children: ReactNode;
overlay: ReactNode;
disabled?: boolean;
@@ -27,7 +27,7 @@ interface IDropdownProps {
onOpenChange?: (open: boolean) => void;
}
-export function Dropdown(props: IDropdownProps & ComponentProps<typeof Content>) {
+export function Dropdown(props: IDropdownProps) {
const {
children,
overlay,
diff --git a/packages/design/src/components/dropdown/index.ts b/packages/design/src/components/dropdown/index.ts
index 8fc98b2be4..4889b85bb6 100644
--- a/packages/design/src/components/dropdown/index.ts
+++ b/packages/design/src/components/dropdown/index.ts
@@ -14,4 +14,4 @@
* limitations under the License.
*/
-export { Dropdown } from './Dropdown';
+export { Dropdown, type IDropdownProps } from './Dropdown';
diff --git a/packages/design/src/index.ts b/packages/design/src/index.ts
index 2650c2761d..6c5fe680ed 100644
--- a/packages/design/src/index.ts
+++ b/packages/design/src/index.ts
@@ -27,7 +27,7 @@ export { Confirm, type IConfirmProps } from './components/confirm';
export { DatePanel, DatePicker, type IDatePanelProps, type IDatePickerProps } from './components/date-picker';
export { Dialog, type IDialogProps } from './components/dialog';
export { DropdownLegacy, type IDropdownLegacyProps } from './components/dropdown-legacy';
-export { Dropdown } from './components/dropdown';
+export { Dropdown, type IDropdownProps } from './components/dropdown';
export { FormDualColumnLayout, FormLayout, type IFormDualColumnLayoutProps, type IFormLayoutProps } from './components/form-layout';
export { type IInputProps, Input } from './components/input';
export { type IInputNumberProps, InputNumber } from './components/input-number';
@@ -51,7 +51,7 @@ export { clsx } from './helper/clsx';
export { resizeObserverCtor } from './helper/resize-observer';
export { render, unmount } from './helper/react-dom';
export { isBrowser } from './helper/is-browser';
-export { DropdownMenu, type IDropdownProps } from './components/dropdown-menu';
+export { DropdownMenu, type IDropdownMenuProps } from './components/dropdown-menu';
export { Separator } from './components/separator';
export { DateRangePicker } from './components/date-range-picker';
export { type IKBDProps, KBD } from './components/kbd';
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx
index 82c036250c..3ab97b9cef 100644
--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx
+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx
@@ -15,7 +15,7 @@
*/
import type { ICommandInfo, Workbook } from '@univerjs/core';
-import type { IDropdownProps } from '@univerjs/design';
+import type { IDropdownMenuProps } from '@univerjs/design';
import { BooleanNumber, DisposableCollection, ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { clsx, DropdownMenu } from '@univerjs/design';
import { CheckMarkSingle, ConvertSingle, EyelashSingle } from '@univerjs/icons';
@@ -126,7 +126,7 @@ export function SheetBarMenu() {
return () => disposables.dispose();
}, [setupStatusUpdate, sheetBarService, statusInit, workbook]);
- const items: IDropdownProps['items'] = useMemo(() => menu.map((item) => ({
+ const items: IDropdownMenuProps['items'] = useMemo(() => menu.map((item) => ({
type: 'item',
children: (
<div className="univer-relative univer-box-border univer-pl-6">
diff --git a/packages/ui/src/components/slider/Slider.tsx b/packages/ui/src/components/slider/Slider.tsx
index 600f44f8e7..3306e58072 100644
--- a/packages/ui/src/components/slider/Slider.tsx
+++ b/packages/ui/src/components/slider/Slider.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IDropdownProps } from '@univerjs/design';
+import type { IDropdownMenuProps } from '@univerjs/design';
import { LocaleService } from '@univerjs/core';
import { Button, clsx, DropdownMenu, Tooltip } from '@univerjs/design';
import { IncreaseSingle, ReduceSingle } from '@univerjs/icons';
@@ -151,7 +151,7 @@ export function Slider(props: ISliderProps) {
onChange && onChange(value);
}
- const items: IDropdownProps['items'] = [{
+ const items: IDropdownMenuProps['items'] = [{
type: 'radio',
value: value.toString(),
options: shortcuts.map((item) => ({ value: item.toString(), label: `${item}%` })),
diff --git a/packages/ui/src/views/components/ribbon/TooltipButtonWrapper.tsx b/packages/ui/src/views/components/ribbon/TooltipButtonWrapper.tsx
index 163c348336..24da206714 100644
--- a/packages/ui/src/views/components/ribbon/TooltipButtonWrapper.tsx
+++ b/packages/ui/src/views/components/ribbon/TooltipButtonWrapper.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IDropdownProps, ITooltipProps } from '@univerjs/design';
+import type { IDropdownMenuProps, IDropdownProps, ITooltipProps } from '@univerjs/design';
import type { ReactNode } from 'react';
import type { IMenuItem, IValueOption } from '../../../services/menu/menu';
import { clsx, Dropdown, DropdownMenu, Tooltip } from '@univerjs/design';
@@ -219,7 +219,7 @@ export function DropdownMenuWrapper({
// options menu
if (options?.length) {
- const items: IDropdownProps['items'] = options.map((option) => ({
+ const items: IDropdownMenuProps['items'] = options.map((option) => ({
type: 'item',
className: clsx({
'focus:univer-bg-white': typeof option.label !== 'string' && option.label?.hoverable === false,
@@ -285,7 +285,7 @@ export function DropdownMenuWrapper({
</DropdownMenu>
);
} else {
- const items: IDropdownProps['items'] = [];
+ const items: IDropdownMenuProps['items'] = [];
for (const menuItem of filteredMenuItems) {
if (menuItem.item) {
diff --git a/packages/ui/src/views/workbench/Workbench.tsx b/packages/ui/src/views/workbench/Workbench.tsx
index 26515fbeb1..c6204e70e5 100644
--- a/packages/ui/src/views/workbench/Workbench.tsx
+++ b/packages/ui/src/views/workbench/Workbench.tsx
@@ -69,6 +69,8 @@ export function DesktopWorkbenchContent(props: IUniverWorkbenchProps) {
const leftSidebarComponents = useComponentsOfPart(BuiltInUIPart.LEFT_SIDEBAR);
const globalComponents = useComponentsOfPart(BuiltInUIPart.GLOBAL);
const toolbarComponents = useComponentsOfPart(BuiltInUIPart.TOOLBAR);
+
+ // FIXME@weird94: do not write type-specific code in the type-independent modules
const [docSnapShot, setDocSnapShot] = useState<Nullable<IDocumentData>>(null);
const popupRootId = uiConfig?.popupRootId ?? 'univer-popup-portal';