Skip to content

Commit

Permalink
chore: menu item target default value is _self
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Nov 27, 2023
1 parent 608ab14 commit 989a471
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 109 deletions.
Binary file modified db/TDesign.db
Binary file not shown.
4 changes: 3 additions & 1 deletion packages/products/tdesign-react/src/menu/defaultProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdMenuProps, TdHeadMenuProps } from './type';
import { TdMenuProps, TdHeadMenuProps, TdMenuItemProps } from './type';

export const menuDefaultProps: TdMenuProps = {
collapsed: false,
Expand All @@ -14,3 +14,5 @@ export const menuDefaultProps: TdMenuProps = {
};

export const headMenuDefaultProps: TdHeadMenuProps = { expandType: 'normal', expanded: [], theme: 'light' };

export const menuItemDefaultProps: TdMenuItemProps = { target: '_self' };
35 changes: 17 additions & 18 deletions packages/products/tdesign-react/src/menu/menu.en-US.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
:: BASE_DOC ::

## API

### Menu Props

name | type | default | description | required
Expand All @@ -10,15 +9,15 @@ className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
collapsed | Boolean | false | \- | N
expandMutex | Boolean | false | \- | N
expandType | String | normal | optionsnormal/popup | N
expandType | String | normal | options: normal/popup | N
expanded | Array | [] | Typescript:`Array<MenuValue>` | N
defaultExpanded | Array | [] | uncontrolled property。Typescript:`Array<MenuValue>` | N
logo | TElement | - | Typescript:`TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
operations | TElement | - | Typescript:`TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
theme | String | light | Menu can be light mode or dark mode.。optionslight/dark/global/system | N
value | String / Number | - | Typescript:`MenuValue` `type MenuValue = string | number`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
defaultValue | String / Number | - | uncontrolled property。Typescript:`MenuValue` `type MenuValue = string | number`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
width | String / Number / Array | '232px' | Typescript:`string | number | Array<string | number>` | N
theme | String | light | Menu can be light mode or dark mode.。options: light/dark/global/system | N
value | String / Number | - | Typescript:`MenuValue` `type MenuValue = string \| number`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
defaultValue | String / Number | - | uncontrolled property。Typescript:`MenuValue` `type MenuValue = string \| number`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
width | String / Number / Array | '232px' | Typescript:`string \| number \| Array<string \| number>` | N
onChange | Function | | Typescript:`(value: MenuValue) => void`<br/> | N
onExpand | Function | | Typescript:`(value: Array<MenuValue>) => void`<br/> | N

Expand All @@ -28,14 +27,13 @@ name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
expandType | String | normal | optionsnormal/popup | N
expandType | String | normal | options: normal/popup | N
expanded | Array | [] | Typescript:`Array<MenuValue>` | N
defaultExpanded | Array | [] | uncontrolled property。Typescript:`Array<MenuValue>` | N
logo | TElement | - | Typescript:`TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
operations | TElement | - | Typescript:`TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
theme | String | light | optionslight/dark | N
value | String / Number | - | Typescript:`MenuValue` `type MenuValue = string | number`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
defaultValue | String / Number | - | uncontrolled property。Typescript:`MenuValue` `type MenuValue = string | number`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
theme | String | light | options: light/dark | N
value | String / Number | - | Typescript:`MenuValue` `type MenuValue = string \| number`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
defaultValue | String / Number | - | uncontrolled property。Typescript:`MenuValue` `type MenuValue = string \| number`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
onChange | Function | | Typescript:`(value: MenuValue) => void`<br/> | N
onExpand | Function | | Typescript:`(value: Array<MenuValue>) => void`<br/> | N

Expand All @@ -45,11 +43,12 @@ name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
children | TNode | - | Typescript:`string | TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
content | TNode | - | Typescript:`string | TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
children | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
content | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
disabled | Boolean | - | \- | N
icon | TElement | - | Typescript:`TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
title | TNode | - | Typescript:`string | TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
popupProps | Object | - | Transparent all feature props of the Popup。Typescript:`PopupProps`[Popup API Documents](./popup?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
title | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
value | String / Number | - | Typescript:`MenuValue` | N

### MenuItem Props
Expand All @@ -58,12 +57,12 @@ name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
children | TNode | - | Typescript:`string | TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
content | TNode | - | Typescript:`string | TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
children | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
content | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
disabled | Boolean | - | \- | N
href | String | - | \- | N
icon | TElement | - | Typescript:`TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
target | String | - | options_blank/_self/_parent/_top | N
target | String | _self | options: _blank/_self/_parent/_top | N
value | String / Number | - | Typescript:`MenuValue` | N
onClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/>trigger on click | N

Expand All @@ -73,4 +72,4 @@ name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
title | TNode | - | Typescript:`string | TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
title | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
27 changes: 13 additions & 14 deletions packages/products/tdesign-react/src/menu/menu.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
:: BASE_DOC ::

## API

### Menu Props

名称 | 类型 | 默认值 | 说明 | 必传
Expand All @@ -16,9 +15,9 @@ defaultExpanded | Array | [] | 子菜单展开的导航集合。非受控属性
logo | TElement | - | 站点 LOGO。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
operations | TElement | - | 导航操作区域。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
theme | String | light | 菜单风格,有亮色模式和暗色模式两种。当 `theme = global` 时,模式随整个组件库;当 `theme = system` 时,模式跟随系统。⚠️ `global/system` 正在开发中,暂勿使用。可选项:light/dark/global/system | N
value | String / Number | - | 激活菜单项。TS 类型:`MenuValue` `type MenuValue = string | number`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
defaultValue | String / Number | - | 激活菜单项。非受控属性。TS 类型:`MenuValue` `type MenuValue = string | number`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
width | String / Number / Array | '232px' | 菜单宽度。值类型为数组时,分别表示菜单展开和折叠的宽度。[ 展开时的宽度, 折叠时的宽度 ],示例:['200px', '80px']。TS 类型:`string | number | Array<string | number>` | N
value | String / Number | - | 激活菜单项。TS 类型:`MenuValue` `type MenuValue = string \| number`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
defaultValue | String / Number | - | 激活菜单项。非受控属性。TS 类型:`MenuValue` `type MenuValue = string \| number`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
width | String / Number / Array | '232px' | 菜单宽度。值类型为数组时,分别表示菜单展开和折叠的宽度。[ 展开时的宽度, 折叠时的宽度 ],示例:['200px', '80px']。TS 类型:`string \| number \| Array<string \| number>` | N
onChange | Function | | TS 类型:`(value: MenuValue) => void`<br/>激活菜单项发生变化时触发 | N
onExpand | Function | | TS 类型:`(value: Array<MenuValue>) => void`<br/>展开的菜单项发生变化时触发 | N

Expand All @@ -30,12 +29,11 @@ className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
expandType | String | normal | 二级菜单展开方式,平铺展开和浮层展开。可选项:normal/popup | N
expanded | Array | [] | 展开的子菜单集合。TS 类型:`Array<MenuValue>` | N
defaultExpanded | Array | [] | 展开的子菜单集合。非受控属性。TS 类型:`Array<MenuValue>` | N
logo | TElement | - | 站点 LOGO。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
operations | TElement | - | 导航操作区域。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
theme | String | light | 可选项:light/dark | N
value | String / Number | - | 激活菜单项。TS 类型:`MenuValue` `type MenuValue = string | number`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
defaultValue | String / Number | - | 激活菜单项。非受控属性。TS 类型:`MenuValue` `type MenuValue = string | number`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
value | String / Number | - | 激活菜单项。TS 类型:`MenuValue` `type MenuValue = string \| number`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
defaultValue | String / Number | - | 激活菜单项。非受控属性。TS 类型:`MenuValue` `type MenuValue = string \| number`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
onChange | Function | | TS 类型:`(value: MenuValue) => void`<br/>激活菜单项发生变化时触发 | N
onExpand | Function | | TS 类型:`(value: Array<MenuValue>) => void`<br/>展开的菜单项发生变化时触发 | N

Expand All @@ -45,11 +43,12 @@ onExpand | Function | | TS 类型:`(value: Array<MenuValue>) => void`<br/>展
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
children | TNode | - | 菜单项内容,同 content。TS 类型:`string | TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
content | TNode | - | 菜单项内容。TS 类型:`string | TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
children | TNode | - | 菜单项内容,同 content。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
content | TNode | - | 菜单项内容。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
disabled | Boolean | - | 是否禁用菜单项展开/收起/跳转等功能 | N
icon | TElement | - | 菜单项图标。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
title | TNode | - | 二级菜单内容。TS 类型:`string | TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
popupProps | Object | - | 透传 Popup 组件全部特性。TS 类型:`PopupProps`[Popup API Documents](./popup?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/menu/type.ts) | N
title | TNode | - | 二级菜单内容。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
value | String / Number | - | 菜单项唯一标识。TS 类型:`MenuValue` | N

### MenuItem Props
Expand All @@ -58,12 +57,12 @@ value | String / Number | - | 菜单项唯一标识。TS 类型:`MenuValue` |
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
children | TNode | - | 菜单项内容,同 content。TS 类型:`string | TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
content | TNode | - | 菜单项内容。TS 类型:`string | TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
children | TNode | - | 菜单项内容,同 content。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
content | TNode | - | 菜单项内容。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
disabled | Boolean | - | 是否禁用菜单项展开/收起/跳转等功能 | N
href | String | - | 跳转链接 | N
icon | TElement | - | 图标。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
target | String | - | 链接或路由跳转方式。可选项:_blank/_self/_parent/_top | N
target | String | _self | 链接或路由跳转方式。可选项:_blank/_self/_parent/_top | N
value | String / Number | - | 菜单项唯一标识。TS 类型:`MenuValue` | N
onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>点击时触发 | N

Expand All @@ -73,4 +72,4 @@ onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
title | TNode | - | 菜单组标题。TS 类型:`string | TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
title | TNode | - | 菜单组标题。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
6 changes: 6 additions & 0 deletions packages/products/tdesign-react/src/menu/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { PopupProps } from '../popup';
import { TNode, TElement } from '../common';
import { MouseEvent } from 'react';

Expand Down Expand Up @@ -133,6 +134,10 @@ export interface TdSubmenuProps {
* 菜单项图标
*/
icon?: TElement;
/**
* 透传 Popup 组件全部特性
*/
popupProps?: PopupProps;
/**
* 二级菜单内容
*/
Expand Down Expand Up @@ -167,6 +172,7 @@ export interface TdMenuItemProps {
icon?: TElement;
/**
* 链接或路由跳转方式
* @default _self
*/
target?: '_blank' | '_self' | '_parent' | '_top';
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
/** 展开的子菜单集合 */
expanded: {
type: Array as PropType<TdHeadMenuProps['expanded']>,
default: undefined,
default: undefined as TdHeadMenuProps['expanded'],
},
/** 展开的子菜单集合,非受控属性 */
defaultExpanded: {
Expand All @@ -47,11 +47,11 @@ export default {
/** 激活菜单项 */
value: {
type: [String, Number] as PropType<TdHeadMenuProps['value']>,
default: undefined,
default: undefined as TdHeadMenuProps['value'],
},
modelValue: {
type: [String, Number] as PropType<TdHeadMenuProps['value']>,
default: undefined,
default: undefined as TdHeadMenuProps['value'],
},
/** 激活菜单项,非受控属性 */
defaultValue: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
/** 链接或路由跳转方式 */
target: {
type: String as PropType<TdMenuItemProps['target']>,
default: '_self' as TdMenuItemProps['target'],
validator(val: TdMenuItemProps['target']): boolean {
if (!val) return true;
return ['_blank', '_self', '_parent', '_top'].includes(val);
Expand Down
Loading

0 comments on commit 989a471

Please sign in to comment.