Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: global config and default value #501

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified db/TDesign.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { TdPopupProps } from './type';

export const popupDefaultProps: TdPopupProps = {
attach: 'body',
destroyOnClose: false,
hideEmptyPopup: false,
placement: 'top',
Expand Down
16 changes: 13 additions & 3 deletions packages/products/tdesign-react/src/popup/popup.en-US.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
:: BASE_DOC ::

## API

### Popup Props

name | type | default | description | required
-- | -- | -- | -- | --
attach | String / Function | 'body' | Typescript:`AttachNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
attach | String / Function | - | Typescript:`AttachNode`。[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
closeBtn | TNode | - | Typescript:`boolean \| 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
delay | Number / Array | - | delay to show or hide popover。Typescript:`number \| Array<number>` | N
destroyOnClose | Boolean | false | \- | N
Expand All @@ -20,10 +20,20 @@ overlayStyle | Boolean / Object / Function | - | Typescript:`Styles \| ((trigg
placement | String | top | Typescript:`PopupPlacement` `type PopupPlacement = 'top'\|'left'\|'right'\|'bottom'\|'top-left'\|'top-right'\|'bottom-left'\|'bottom-right'\|'left-top'\|'left-bottom'\|'right-top'\|'right-bottom'`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/popup/type.ts) | N
popperOptions | Object | - | popper initial options,details refer to https://popper.js.org/docs | N
showArrow | Boolean | false | \- | N
trigger | String | hover | optionshover/click/focus/mousedown/context-menu | N
trigger | String | hover | options: hover/click/focus/mousedown/context-menu | N
triggerElement | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
visible | Boolean | - | Typescript:`boolean` | N
defaultVisible | Boolean | - | uncontrolled property。Typescript:`boolean` | N
zIndex | Number | - | \- | N
onOverlayClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/>trigger on popup content click | N
onScroll | Function | | Typescript:`(context: { e: WheelEvent }) => void`<br/> | N
onScrollToBottom | Function | | Typescript:`(context: { e: WheelEvent }) => void`<br/> | N
onVisibleChange | Function | | Typescript:`(visible: boolean, context: PopupVisibleChangeContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/popup/type.ts)。<br/>`interface PopupVisibleChangeContext { e?: PopupTriggerEvent; trigger?: PopupTriggerSource }`<br/><br/>`type PopupTriggerEvent = MouseEvent \| FocusEvent \| KeyboardEvent`<br/><br/>`type PopupTriggerSource = 'document' \| 'trigger-element-click' \| 'trigger-element-hover' \| 'trigger-element-blur' \| 'trigger-element-focus' \| 'trigger-element-mousedown' \| 'trigger-element-close' \| 'context-menu' \| 'keydown-esc'`<br/> | N

### PopupInstanceFunctions 组件实例方法

name | params | return | description
-- | -- | -- | --
getOverlay | \- | `HTMLElement` | used to get overly html element
getOverlayState | \- | `{ hover: boolean }` | get mouseover state of overlay
update | \- | \- | used to update overlay content
16 changes: 13 additions & 3 deletions packages/products/tdesign-react/src/popup/popup.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
:: BASE_DOC ::

## API

### Popup Props

名称 | 类型 | 默认值 | 说明 | 必传
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
attach | String / Function | 'body' | 制定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`AttachNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
attach | String / Function | - | 指定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`AttachNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文档描述可能还是得体现默认是body

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文档描述可能还是得体现默认是body

这个问题需要统一处理了,跟 closeOnOverlayClick 情况一样,仅文档体现默认值

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要跟Avatar size 一样描述吗
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还有一个方案 新增 doc_default_value 字段,用于配置文档显示的默认值, 文档显示默认值优先级 高于 field_default_value

Copy link
Member Author

@liweijie0812 liweijie0812 Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api 生成md 默认值处理,组件有全局配置同属性 ,组件属性默认值未定义会取全局配置的默认值 ,
例如。attach 在dialog组件 全局配置 DialogConfig 下,默认值body
image

image image

children | TNode | - | 触发元素,同 triggerElement。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
closeBtn | TNode | - | 是否展示关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 则不显示关闭按钮;也可以自定义关闭按钮。TS 类型:`boolean \| 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
delay | Number / Array | - | 延时显示或隐藏浮层,[延迟显示的时间,延迟隐藏的时间],单位:毫秒。如果只有一个时间,则表示显示和隐藏的延迟时间相同。示例 `'300'` 或者 `[200, 200]`。默认为:[250, 150]。TS 类型:`number \| Array<number>` | N
destroyOnClose | Boolean | false | 是否在关闭浮层时销毁浮层 | N
Expand All @@ -23,7 +23,17 @@ showArrow | Boolean | false | 是否显示浮层箭头 | N
trigger | String | hover | 触发浮层出现的方式。可选项:hover/click/focus/mousedown/context-menu | N
triggerElement | TNode | - | 触发元素。值类型为字符串表示元素选择器。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
visible | Boolean | - | 是否显示浮层。TS 类型:`boolean` | N
defaultVisible | Boolean | - | 是否显示浮层。非受控属性。TS 类型:`boolean` | N
zIndex | Number | - | 组件层级,Web 侧样式默认为 5500,移动端和小程序样式默认为 1500 | N
onOverlayClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>内容面板点击时触发 | N
onScroll | Function | | TS 类型:`(context: { e: WheelEvent }) => void`<br/>下拉选项滚动事件 | N
onScrollToBottom | Function | | TS 类型:`(context: { e: WheelEvent }) => void`<br/>下拉滚动触底事件,常用于滚动到底执行具体业务逻辑 | N
onVisibleChange | Function | | TS 类型:`(visible: boolean, context: PopupVisibleChangeContext) => void`<br/>当浮层隐藏或显示时触发,`trigger=document` 表示点击非浮层元素触发;`trigger=context-menu` 表示右击触发。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/popup/type.ts)。<br/>`interface PopupVisibleChangeContext { e?: PopupTriggerEvent; trigger?: PopupTriggerSource }`<br/><br/>`type PopupTriggerEvent = MouseEvent \| FocusEvent \| KeyboardEvent`<br/><br/>`type PopupTriggerSource = 'document' \| 'trigger-element-click' \| 'trigger-element-hover' \| 'trigger-element-blur' \| 'trigger-element-focus' \| 'trigger-element-mousedown' \| 'trigger-element-close' \| 'context-menu' \| 'keydown-esc'`<br/> | N

### PopupInstanceFunctions 组件实例方法

名称 | 参数 | 返回值 | 描述
-- | -- | -- | --
getOverlay | \- | `HTMLElement` | 获取浮层元素
getOverlayState | \- | `{ hover: boolean }` | 获取浮层悬浮状态
update | \- | \- | 更新浮层内容
27 changes: 21 additions & 6 deletions packages/products/tdesign-react/src/popup/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ import { MouseEvent, KeyboardEvent, FocusEvent, WheelEvent } from 'react';

export interface TdPopupProps {
/**
* 制定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body
* @default 'body'
* 指定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body
*/
attach?: AttachNode;
/**
* 触发元素,同 triggerElement
*/
children?: TNode;
/**
* 是否展示关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 则不显示关闭按钮;也可以自定义关闭按钮
*/
closeBtn?: TNode;
/**
* 浮层里面的内容
*/
Expand Down Expand Up @@ -94,6 +89,10 @@ export interface TdPopupProps {
* 组件层级,Web 侧样式默认为 5500,移动端和小程序样式默认为 1500
*/
zIndex?: number;
/**
* 内容面板点击时触发
*/
onOverlayClick?: (context: { e: MouseEvent<HTMLDivElement> }) => void;
/**
* 下拉选项滚动事件
*/
Expand All @@ -108,6 +107,22 @@ export interface TdPopupProps {
onVisibleChange?: (visible: boolean, context: PopupVisibleChangeContext) => void;
}

/** 组件实例方法 */
export interface PopupInstanceFunctions {
/**
* 获取浮层元素
*/
getOverlay?: () => HTMLElement;
/**
* 获取浮层悬浮状态
*/
getOverlayState?: () => { hover: boolean };
/**
* 更新浮层内容
*/
update?: () => void;
}

export type PopupPlacement =
| 'top'
| 'left'
Expand Down
17 changes: 14 additions & 3 deletions packages/products/tdesign-vue-next/src/popup/popup.en-US.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
:: BASE_DOC ::

## API

### Popup Props

name | type | default | description | required
-- | -- | -- | -- | --
attach | String / Function | 'body' | Typescript:`AttachNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
closeBtn | Boolean / Slot / Function | - | Typescript:`boolean \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
attach | String / Function | - | Typescript:`AttachNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
content | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
default | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
delay | Number / Array | - | delay to show or hide popover。Typescript:`number \| Array<number>` | N
Expand All @@ -20,10 +20,12 @@ overlayStyle | Boolean / Object / Function | - | Typescript:`Styles \| ((trigg
placement | String | top | Typescript:`PopupPlacement` `type PopupPlacement = 'top'\|'left'\|'right'\|'bottom'\|'top-left'\|'top-right'\|'bottom-left'\|'bottom-right'\|'left-top'\|'left-bottom'\|'right-top'\|'right-bottom'`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/popup/type.ts) | N
popperOptions | Object | - | popper initial options,details refer to https://popper.js.org/docs | N
showArrow | Boolean | false | \- | N
trigger | String | hover | optionshover/click/focus/mousedown/context-menu | N
trigger | String | hover | options: hover/click/focus/mousedown/context-menu | N
triggerElement | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
visible | Boolean | - | `v-model` and `v-model:visible` is supported。Typescript:`boolean` | N
defaultVisible | Boolean | - | uncontrolled property。Typescript:`boolean` | N
zIndex | Number | - | \- | N
onOverlayClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/>trigger on popup content click | N
onScroll | Function | | Typescript:`(context: { e: WheelEvent }) => void`<br/> | N
onScrollToBottom | Function | | Typescript:`(context: { e: WheelEvent }) => void`<br/> | N
onVisibleChange | Function | | Typescript:`(visible: boolean, context: PopupVisibleChangeContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/popup/type.ts)。<br/>`interface PopupVisibleChangeContext { e?: PopupTriggerEvent; trigger?: PopupTriggerSource }`<br/><br/>`type PopupTriggerEvent = MouseEvent \| FocusEvent \| KeyboardEvent`<br/><br/>`type PopupTriggerSource = 'document' \| 'trigger-element-click' \| 'trigger-element-hover' \| 'trigger-element-blur' \| 'trigger-element-focus' \| 'trigger-element-mousedown' \| 'trigger-element-close' \| 'context-menu' \| 'keydown-esc'`<br/> | N
Expand All @@ -32,6 +34,15 @@ onVisibleChange | Function | | Typescript:`(visible: boolean, context: PopupV

name | params | description
-- | -- | --
overlay-click | `(context: { e: MouseEvent })` | trigger on popup content click
scroll | `(context: { e: WheelEvent })` | \-
scroll-to-bottom | `(context: { e: WheelEvent })` | \-
visible-change | `(visible: boolean, context: PopupVisibleChangeContext)` | [see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/popup/type.ts)。<br/>`interface PopupVisibleChangeContext { e?: PopupTriggerEvent; trigger?: PopupTriggerSource }`<br/><br/>`type PopupTriggerEvent = MouseEvent \| FocusEvent \| KeyboardEvent`<br/><br/>`type PopupTriggerSource = 'document' \| 'trigger-element-click' \| 'trigger-element-hover' \| 'trigger-element-blur' \| 'trigger-element-focus' \| 'trigger-element-mousedown' \| 'trigger-element-close' \| 'context-menu' \| 'keydown-esc'`<br/>

### PopupInstanceFunctions 组件实例方法

name | params | return | description
-- | -- | -- | --
getOverlay | \- | `HTMLElement` | used to get overly html element
getOverlayState | \- | `{ hover: boolean }` | get mouseover state of overlay
update | \- | \- | used to update overlay content
17 changes: 14 additions & 3 deletions packages/products/tdesign-vue-next/src/popup/popup.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
:: BASE_DOC ::

## API

### Popup Props

名称 | 类型 | 默认值 | 说明 | 必传
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
attach | String / Function | 'body' | 制定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`AttachNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
closeBtn | Boolean / Slot / Function | - | 是否展示关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 则不显示关闭按钮;也可以自定义关闭按钮。TS 类型:`boolean \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
attach | String / Function | - | 指定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`AttachNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
content | String / Slot / Function | - | 浮层里面的内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
default | String / Slot / Function | - | 触发元素,同 triggerElement。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
delay | Number / Array | - | 延时显示或隐藏浮层,[延迟显示的时间,延迟隐藏的时间],单位:毫秒。如果只有一个时间,则表示显示和隐藏的延迟时间相同。示例 `'300'` 或者 `[200, 200]`。默认为:[250, 150]。TS 类型:`number \| Array<number>` | N
Expand All @@ -23,7 +23,9 @@ showArrow | Boolean | false | 是否显示浮层箭头 | N
trigger | String | hover | 触发浮层出现的方式。可选项:hover/click/focus/mousedown/context-menu | N
triggerElement | String / Slot / Function | - | 触发元素。值类型为字符串表示元素选择器。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
visible | Boolean | - | 是否显示浮层。支持语法糖 `v-model` 或 `v-model:visible`。TS 类型:`boolean` | N
defaultVisible | Boolean | - | 是否显示浮层。非受控属性。TS 类型:`boolean` | N
zIndex | Number | - | 组件层级,Web 侧样式默认为 5500,移动端和小程序样式默认为 1500 | N
onOverlayClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>内容面板点击时触发 | N
onScroll | Function | | TS 类型:`(context: { e: WheelEvent }) => void`<br/>下拉选项滚动事件 | N
onScrollToBottom | Function | | TS 类型:`(context: { e: WheelEvent }) => void`<br/>下拉滚动触底事件,常用于滚动到底执行具体业务逻辑 | N
onVisibleChange | Function | | TS 类型:`(visible: boolean, context: PopupVisibleChangeContext) => void`<br/>当浮层隐藏或显示时触发,`trigger=document` 表示点击非浮层元素触发;`trigger=context-menu` 表示右击触发。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/popup/type.ts)。<br/>`interface PopupVisibleChangeContext { e?: PopupTriggerEvent; trigger?: PopupTriggerSource }`<br/><br/>`type PopupTriggerEvent = MouseEvent \| FocusEvent \| KeyboardEvent`<br/><br/>`type PopupTriggerSource = 'document' \| 'trigger-element-click' \| 'trigger-element-hover' \| 'trigger-element-blur' \| 'trigger-element-focus' \| 'trigger-element-mousedown' \| 'trigger-element-close' \| 'context-menu' \| 'keydown-esc'`<br/> | N
Expand All @@ -32,6 +34,15 @@ onVisibleChange | Function | | TS 类型:`(visible: boolean, context: PopupVi

名称 | 参数 | 描述
-- | -- | --
overlay-click | `(context: { e: MouseEvent })` | 内容面板点击时触发
scroll | `(context: { e: WheelEvent })` | 下拉选项滚动事件
scroll-to-bottom | `(context: { e: WheelEvent })` | 下拉滚动触底事件,常用于滚动到底执行具体业务逻辑
visible-change | `(visible: boolean, context: PopupVisibleChangeContext)` | 当浮层隐藏或显示时触发,`trigger=document` 表示点击非浮层元素触发;`trigger=context-menu` 表示右击触发。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/popup/type.ts)。<br/>`interface PopupVisibleChangeContext { e?: PopupTriggerEvent; trigger?: PopupTriggerSource }`<br/><br/>`type PopupTriggerEvent = MouseEvent \| FocusEvent \| KeyboardEvent`<br/><br/>`type PopupTriggerSource = 'document' \| 'trigger-element-click' \| 'trigger-element-hover' \| 'trigger-element-blur' \| 'trigger-element-focus' \| 'trigger-element-mousedown' \| 'trigger-element-close' \| 'context-menu' \| 'keydown-esc'`<br/>

### PopupInstanceFunctions 组件实例方法

名称 | 参数 | 返回值 | 描述
-- | -- | -- | --
getOverlay | \- | `HTMLElement` | 获取浮层元素
getOverlayState | \- | `{ hover: boolean }` | 获取浮层悬浮状态
update | \- | \- | 更新浮层内容
9 changes: 3 additions & 6 deletions packages/products/tdesign-vue-next/src/popup/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@ import { TdPopupProps } from './type';
import { PropType } from 'vue';

export default {
/** 制定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body */
/** 指定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body */
attach: {
type: [String, Function] as PropType<TdPopupProps['attach']>,
default: 'body' as TdPopupProps['attach'],
},
/** 是否展示关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 则不显示关闭按钮;也可以自定义关闭按钮 */
closeBtn: {
type: [Boolean, Function] as PropType<TdPopupProps['closeBtn']>,
},
/** 浮层里面的内容 */
content: {
Expand Down Expand Up @@ -90,6 +85,8 @@ export default {
zIndex: {
type: Number,
},
/** 内容面板点击时触发 */
onOverlayClick: Function as PropType<TdPopupProps['onOverlayClick']>,
/** 下拉选项滚动事件 */
onScroll: Function as PropType<TdPopupProps['onScroll']>,
/** 下拉滚动触底事件,常用于滚动到底执行具体业务逻辑 */
Expand Down
Loading
Loading