From 90864de25d875953f7279542797d6a35d4d3b55e Mon Sep 17 00:00:00 2001 From: Gaby Zifferman Date: Fri, 20 Sep 2024 22:40:12 +0200 Subject: [PATCH] fix: fix ts erros --- .../data-entry/Checkbox/Checkbox.stories.tsx | 3 ++- .../feedback/Watermark/Watermark.stories.tsx | 20 +++++++++++++------ .../GlobalNavigation/NavigationCreate.tsx | 7 +++++-- .../GlobalNavigation/NavigationList.tsx | 6 ++++-- .../WorkspaceSelectorItems.d.ts | 1 + src/components/navigation/Menu/Menu.tsx | 13 ++++++------ 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/components/data-entry/Checkbox/Checkbox.stories.tsx b/src/components/data-entry/Checkbox/Checkbox.stories.tsx index 4865c19f1..8ca8df0c9 100644 --- a/src/components/data-entry/Checkbox/Checkbox.stories.tsx +++ b/src/components/data-entry/Checkbox/Checkbox.stories.tsx @@ -3,11 +3,12 @@ import { type StoryObj } from '@storybook/react' import { Checkbox, Divider } from 'src/components' import { useState } from 'react' import { ExampleStory } from 'src/utils/ExampleStory' -import { type CheckboxValueType } from 'antd/es/checkbox/Group' import { type ICheckboxProps } from 'src/components/data-entry/Checkbox/Checkbox' import { userEvent } from '@storybook/test' import { expect } from '@storybook/test' +export type CheckboxValueType = string | number | boolean + const meta: Meta = { title: 'Aquarium/Data Entry/Checkbox', component: props => { diff --git a/src/components/feedback/Watermark/Watermark.stories.tsx b/src/components/feedback/Watermark/Watermark.stories.tsx index 17f415125..e427e9470 100644 --- a/src/components/feedback/Watermark/Watermark.stories.tsx +++ b/src/components/feedback/Watermark/Watermark.stories.tsx @@ -114,7 +114,7 @@ export const ExampleMultiline: Story = { export const ExampleConfig: Story = { render: () => { - type Color = GetProp + type Color = GetProp interface WatermarkConfig { content: string @@ -144,7 +144,15 @@ export const ExampleConfig: Story = { rotate, gap, offset, - font: { color: typeof color === 'string' ? color : color.toRgbString(), fontSize }, + font: { + color: + typeof color === 'string' + ? color + : typeof color === 'object' && 'toRgbString' in color + ? color.toRgbString() + : String(color), + fontSize, + }, } return ( @@ -153,8 +161,8 @@ export const ExampleConfig: Story = { The light-speed iteration of the digital world makes products more complex. However, human consciousness - and attention resources are limited. Facing this design contradiction, the pursuit of natural - interaction will be the consistent direction of Ant Design. + and attention resources are limited. Facing this design contradiction, the pursuit of natural interaction + will be the consistent direction of Ant Design. Natural user cognition: According to cognitive psychology, about 80% of external information is obtained @@ -169,8 +177,8 @@ export const ExampleConfig: Story = { relationship between users, system roles, and task objectives, and also contextually organize system functions and services. At the same time, a series of methods such as behavior analysis, artificial intelligence and sensors could be applied to assist users to make effective decisions and reduce extra - operations of users, to save users' mental and physical resources and make human-computer - interaction more natural. + operations of users, to save users' mental and physical resources and make human-computer interaction + more natural. ['items'][number] +export type MenuItemGroupType = Required['items'][number] // Same as menu item type export interface INavigationCreateProps { createItems: Array } @@ -20,6 +22,7 @@ export interface INavigationCreateGroup extends Omit { } export interface INavigationCreateItem extends Omit { + disabled?: boolean title: string description: string type?: undefined diff --git a/src/components/navigation/GlobalNavigation/NavigationList.tsx b/src/components/navigation/GlobalNavigation/NavigationList.tsx index 989a62938..566a33f77 100644 --- a/src/components/navigation/GlobalNavigation/NavigationList.tsx +++ b/src/components/navigation/GlobalNavigation/NavigationList.tsx @@ -1,5 +1,5 @@ import { Menu } from 'src/components' -import type { MenuItemGroupType } from 'antd/es/menu/hooks/useItems' +import { type MenuProps } from 'antd' import { NavigationIcon } from 'src/components/navigation/GlobalNavigation/NavigationIcon' import { NavigationItem } from 'src/components/navigation/GlobalNavigation/NavigationItem' import { Center } from 'src/components' @@ -9,6 +9,8 @@ import { Fragment } from 'react' import { buildLinkFromHrefOptions } from 'src/utils/utils' import { NavigationButtonItem } from 'src/components/navigation/GlobalNavigation/NavigationButtonItem' +export type MenuItemGroupType = Required['items'][number] // This works for both groups and items + export interface INavigationListProps { items: IGlobalNavigationItem[] } @@ -44,7 +46,7 @@ function generateMenuItem(item: IGlobalNavigationItem, i: number) { if (child.type !== 'button') { children.push(child) } else { - const buttonKey = `submenu-button-${children.filter(c => c.type === 'button').length}-${index}` + const buttonKey = `submenu-button-${children.filter(c => c !== null && c.type === 'button').length}-${index}` children.push({ className: 'globalNavigation__buttonItem', diff --git a/src/components/navigation/GlobalNavigation/WorkspaceSelector/WorkspaceSelectorItems.d.ts b/src/components/navigation/GlobalNavigation/WorkspaceSelector/WorkspaceSelectorItems.d.ts index 34a093080..47d9ad94e 100644 --- a/src/components/navigation/GlobalNavigation/WorkspaceSelector/WorkspaceSelectorItems.d.ts +++ b/src/components/navigation/GlobalNavigation/WorkspaceSelector/WorkspaceSelectorItems.d.ts @@ -22,6 +22,7 @@ export interface INavigationWorkspace extends IWorkspaceSelectorItem { } export interface IWorkspaceSelectorDisplayItem extends MenuItemType { + key: string | null | undefined type: 'org' | 'account' | 'workspace' className: string label: ReactNode diff --git a/src/components/navigation/Menu/Menu.tsx b/src/components/navigation/Menu/Menu.tsx index 8469bdb0e..d15e2e9ad 100644 --- a/src/components/navigation/Menu/Menu.tsx +++ b/src/components/navigation/Menu/Menu.tsx @@ -1,14 +1,13 @@ -import { Menu as AntMenu } from 'antd' +import { Menu as AntMenu, type MenuProps } from 'antd' import { type MenuProps as AntMenuProps } from 'antd' -import { - type MenuItemType as AndMenuItemType, - type MenuItemGroupType as AndMenuItemGroupType, - type MenuDividerType as AndMenuDividerType, - type SubMenuType as AndSubMenuType, -} from 'antd/es/menu/hooks/useItems' import { type MenuInfo as RCMenuInfo } from 'rc-menu/lib/interface' import { ConfigProvider } from 'src/components' +export type AndMenuItemType = Required['items'][number] +export type AndMenuItemGroupType = Required['items'][number] // Same type used for menu groups +export type AndMenuDividerType = Required['items'][number] // Menu divider uses the same type +export type AndSubMenuType = Required['items'][number] // Submenu is also part of 'items' + export interface IMenuProps extends AntMenuProps {} export interface IMenuInfo extends RCMenuInfo {}