Skip to content
Merged
2 changes: 1 addition & 1 deletion src/_common
18 changes: 18 additions & 0 deletions src/config-provider/config-provider.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ name | type | default | description | required
alert | Object | - | Alert global configs。Typescript:`AlertConfig` | N
anchor | Object | - | Anchor global configs。Typescript:`AnchorConfig` | N
animation | Object | - | Typescript:`Partial<Record<'include'\|'exclude', Array<AnimationType>>>` `type AnimationType = 'ripple' \| 'expand' \| 'fade'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N
attach | String / Object / Function | - | Typescript:`AttachNode \| { imageViewer?: AttachNode; popup?: AttachNode; dialog?: AttachNode; drawer?: AttachNode; }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
calendar | Object | - | Calendar global configs。Typescript:`CalendarConfig` | N
cascader | Object | - | Cascader global configs。Typescript:`CascaderConfig` | N
classPrefix | String | t | \- | N
Expand All @@ -70,6 +71,7 @@ datePicker | Object | - | DatePicker global configs。Typescript:`DatePickerCo
descriptions | Object | - | Descriptions global configs。Typescript:`DescriptionsConfig` | N
dialog | Object | - | Dialog global configs。Typescript:`DialogConfig` | N
drawer | Object | - | Drawer global configs。Typescript:`DrawerConfig` | N
empty | Object | - | Empty global configs。Typescript:`EmptyConfig` | N
form | Object | - | Form global configs。Typescript:`FormConfig` | N
guide | Object | - | Guide global configs。Typescript:`GuideConfig` | N
icon | Object | - | icon config。Typescript:`IconConfig` `type IconConfig = GlobalIconConfig` `import { GlobalIconConfig } from '@icon'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N
Expand All @@ -89,6 +91,7 @@ timePicker | Object | - | TimePicker global configs。Typescript:`TimePickerCo
transfer | Object | - | Transfer global configs。Typescript:`TransferConfig` | N
tree | Object | - | Tree global configs。Typescript:`TreeConfig` | N
treeSelect | Object | - | TreeSelect global configs。Typescript:`TreeSelectConfig` | N
typography | Object | - | Typography global configs。Typescript:`TypographyConfig` | N
upload | Object | - | Upload global configs。Typescript:`UploadConfig` | N

### InputConfig
Expand Down Expand Up @@ -390,3 +393,18 @@ skipButtonProps | Object | - | skip button. `{ content: 'Skip', theme: 'default'
name | type | default | description | required
-- | -- | -- | -- | --
rateText | Array | - | Typescript:`string[]` | N

### EmptyConfig

name | type | default | description | required
-- | -- | -- | -- | --
image | Object | - | Typescript:`{ maintenance: TNode; success: TNode; fail: TNode; empty: TNode; networkError: TNode; }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
titleText | Object | - | Typescript:`{ maintenance: string; success: string; fail: string; empty: string; networkError: string; }` | N

### TypographyConfig

name | type | default | description | required
-- | -- | -- | -- | --
collapseText | String | - | collapse text | N
copiedText | String | - | copied text | N
expandText | String | - | expand text | N
18 changes: 18 additions & 0 deletions src/config-provider/config-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Vue.use(TDesign);
alert | Object | - | 警告全局配置。TS 类型:`AlertConfig` | N
anchor | Object | - | 锚点全局配置。TS 类型:`AnchorConfig` | N
animation | Object | - | 动画效果控制,`ripple` 指波纹动画, `expand` 指展开动画,`fade` 指渐变动画。默认为 `{ include: ['ripple','expand','fade'], exclude: [] }`。TS 类型:`Partial<Record<'include'\|'exclude', Array<AnimationType>>>` `type AnimationType = 'ripple' \| 'expand' \| 'fade'`。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N
attach | String / Object / Function | - | TS 类型:`AttachNode \| { imageViewer?: AttachNode; popup?: AttachNode; dialog?: AttachNode; drawer?: AttachNode; }`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
calendar | Object | - | 日历组件全局配置。TS 类型:`CalendarConfig` | N
cascader | Object | - | 级联选择器全局配置。TS 类型:`CascaderConfig` | N
classPrefix | String | t | CSS 类名前缀 | N
Expand All @@ -71,6 +72,7 @@ datePicker | Object | - | 日期选择器全局配置。TS 类型:`DatePickerC
descriptions | Object | - | 描述全局配置。TS 类型:`DescriptionsConfig` | N
dialog | Object | - | 对话框全局配置。TS 类型:`DialogConfig` | N
drawer | Object | - | 抽屉全局配置。TS 类型:`DrawerConfig` | N
empty | Object | - | 空状态全局配置。TS 类型:`EmptyConfig` | N
form | Object | - | 表单组件全局配置。TS 类型:`FormConfig` | N
guide | Object | - | 引导全局配置。TS 类型:`GuideConfig` | N
icon | Object | - | 图标全局配置。TS 类型:`IconConfig` `type IconConfig = GlobalIconConfig` `import { GlobalIconConfig } from '@icon'`。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N
Expand All @@ -90,6 +92,7 @@ timePicker | Object | - | 时间选择器全局配置。TS 类型:`TimePickerC
transfer | Object | - | 穿梭框全局配置。TS 类型:`TransferConfig` | N
tree | Object | - | 树组件全局配置。TS 类型:`TreeConfig` | N
treeSelect | Object | - | 树选择器组件全局配置。TS 类型:`TreeSelectConfig` | N
typography | Object | - | 排版组件全局配置。TS 类型:`TypographyConfig` | N
upload | Object | - | 上传组件全局配置。TS 类型:`UploadConfig` | N

### InputConfig
Expand Down Expand Up @@ -391,3 +394,18 @@ skipButtonProps | Object | - | 跳过按钮,示例:`{ content: '跳过', the
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
rateText | Array | - | 评分描述,默认值:['极差', '失望', '一般', '满意', '惊喜']。TS 类型:`string[]` | N

### EmptyConfig

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
image | Object | - | 空状态组件各类型的图片配置。TS 类型:`{ maintenance: TNode; success: TNode; fail: TNode; empty: TNode; networkError: TNode; }`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
titleText | Object | - | 空状态组件各类型的标题文本配置。TS 类型:`{ maintenance: string; success: string; fail: string; empty: string; networkError: string; }` | N

### TypographyConfig

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
collapseText | String | - | 语言配置,“收起”描述文本 | N
copiedText | String | - | 语言配置,“复制成功”描述文本 | N
expandText | String | - | 语言配置,“展开”描述文本 | N
28 changes: 27 additions & 1 deletion src/config-provider/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ButtonProps } from '../button';
import { FormErrorMessage } from '../form';
import { MessageOptions } from '../message';
import { ImageProps } from '../image';
import { TNode, SizeEnum } from '../common';
import { TNode, SizeEnum, AttachNode } from '../common';

export interface GlobalConfigProvider {
/**
Expand All @@ -25,6 +25,10 @@ export interface GlobalConfigProvider {
* 动画效果控制,`ripple` 指波纹动画, `expand` 指展开动画,`fade` 指渐变动画。默认为 `{ include: ['ripple','expand','fade'], exclude: [] }`
*/
animation?: Partial<Record<'include' | 'exclude', Array<AnimationType>>>;
/**
* null
*/
attach?: AttachNode | { imageViewer?: AttachNode; popup?: AttachNode; dialog?: AttachNode; drawer?: AttachNode };
/**
* 日历组件全局配置
*/
Expand Down Expand Up @@ -138,6 +142,10 @@ export interface GlobalConfigProvider {
* 树选择器组件全局配置
*/
treeSelect?: TreeSelectConfig;
/**
* 排版组件全局配置
*/
typography?: TypographyConfig;
/**
* 上传组件全局配置
*/
Expand Down Expand Up @@ -934,6 +942,24 @@ export interface EmptyConfig {
titleText?: { maintenance: string; success: string; fail: string; empty: string; networkError: string };
}

export interface TypographyConfig {
/**
* 语言配置,“收起”描述文本
* @default ''
*/
collapseText?: string;
/**
* 语言配置,“复制成功”描述文本
* @default ''
*/
copiedText?: string;
/**
* 语言配置,“展开”描述文本
* @default ''
*/
expandText?: string;
}

export type AnimationType = 'ripple' | 'expand' | 'fade';

export type IconConfig = GlobalIconConfig;
Expand Down
8 changes: 6 additions & 2 deletions src/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ErrorCircleFilledIcon as TdErrorCircleFilledIcon,
} from 'tdesign-icons-vue';

import useAttach from '../hooks/useAttach';
import TButton from '../button';
import ActionMixin from './actions';
import { DialogCloseContext, TdDialogProps } from './type';
Expand All @@ -17,7 +18,7 @@ import mixins from '../utils/mixins';
import getConfigReceiverMixins, { DialogConfig, getGlobalIconMixins } from '../config-provider/config-receiver';
import TransferDom from '../utils/transfer-dom';
import { emitEvent } from '../utils/event';
import { ClassName, Styles } from '../common';
import { AttachNode, ClassName, Styles } from '../common';
import { updateElement } from '../hooks/useDestroyOnClose';
import stack from './stack';
import { getScrollbarWidth } from '../_common/js/utils/getScrollbarWidth';
Expand Down Expand Up @@ -144,6 +145,9 @@ export default mixins(ActionMixin, getConfigReceiverMixins<Vue, DialogConfig>('d
computedDialogStyle(): Styles {
return !this.isFullScreen ? { width: getCSSValue(this.width), ...this.dialogStyle } : { ...this.dialogStyle }; // width全屏模式不生效;
},
computeAttach(): AttachNode {
return useAttach('dialog', this.attach).value;
},
},

watch: {
Expand Down Expand Up @@ -518,7 +522,7 @@ export default mixins(ActionMixin, getConfigReceiverMixins<Vue, DialogConfig>('d
onBeforeLeave={this.beforeLeave}
onAfterLeave={this.afterLeave}
>
<div v-show={this.visible} class={this.ctxClass} style={ctxStyle} v-transfer-dom={this.attach}>
<div v-show={this.visible} class={this.ctxClass} style={ctxStyle} v-transfer-dom={this.computeAttach}>
{view}
</div>
</transition>
Expand Down
8 changes: 6 additions & 2 deletions src/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import mixins from '../utils/mixins';
import getConfigReceiverMixins, { DrawerConfig, getGlobalIconMixins } from '../config-provider/config-receiver';
import TransferDom from '../utils/transfer-dom';
import { emitEvent } from '../utils/event';
import { ClassName, Styles } from '../common';
import { AttachNode, ClassName, Styles } from '../common';
import ActionMixin from '../dialog/actions';
import { getScrollbarWidth } from '../_common/js/utils/getScrollbarWidth';
import useAttach from '../hooks/useAttach';

type FooterButtonType = 'confirm' | 'cancel';

Expand Down Expand Up @@ -110,6 +111,9 @@ export default mixins(ActionMixin, getConfigReceiverMixins<Vue, DrawerConfig>('d
cursor: this.isHorizontal ? 'col-resize' : 'row-resize',
};
},
computeAttach(): AttachNode {
return useAttach('drawer', this.attach).value;
},
},

watch: {
Expand Down Expand Up @@ -180,7 +184,7 @@ export default mixins(ActionMixin, getConfigReceiverMixins<Vue, DrawerConfig>('d
class={this.drawerClasses}
style={{ zIndex: this.zIndex }}
onkeydown={this.onKeyDown}
v-transfer-dom={this.attach}
v-transfer-dom={this.computeAttach}
ref="drawerContainer"
tabindex={0}
v-show={this.visible}
Expand Down
23 changes: 23 additions & 0 deletions src/hooks/useAttach.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { computed } from '@vue/composition-api';
import { useConfig } from './useConfig';
import { AttachNode } from '../common';

const defaultAttach = 'body';

/**
* useAttach
*
* 挂载节点 优先级:
*
* props attach -> globalConfig.attach.component -> globalConfig.attach -> default = 'body'
*/

export function useAttach(name: string, attach: AttachNode) {
const { globalConfig } = useConfig();
const attachVal = computed<AttachNode>(
() => attach || globalConfig.value.attach?.[name] || globalConfig.value?.attach || defaultAttach,
);
return attachVal;
}

export default useAttach;
19 changes: 9 additions & 10 deletions src/popup/popup.en-US.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:: BASE_DOC ::

## API

### Popup Props

name | type | default | description | required
Expand All @@ -19,29 +20,27 @@ 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/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/blob/develop/src/common.ts) | N
visible | Boolean | - | `v-model` is supported。Typescript:`boolean` | N
defaultVisible | Boolean | - | uncontrolled property。Typescript:`boolean` | N
zIndex | Number | - | \- | 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/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' \| 'context-menu' \| 'keydown-esc'`<br/> | N
onVisibleChange | Function | | Typescript:`(visible: boolean, context: PopupVisibleChangeContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue/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

### Popup Events

name | params | description
-- | -- | --
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/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' \| 'context-menu' \| 'keydown-esc'`<br/>

### PopupPlugin
visible-change | `(visible: boolean, context: PopupVisibleChangeContext)` | [see more ts definition](https://github.com/Tencent/tdesign-vue/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/>

support `this.$popup`
### PopupInstanceFunctions 组件实例方法

name | params | default | description
name | params | return | description
-- | -- | -- | --
content | String / Slot / Function | - | required。Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)
popupProps | Object | - | \-
triggerElement | String | - | required
getOverlay | \- | `HTMLElement` | used to get overly html element
getOverlayState | \- | `{ hover: boolean }` | get mouseover state of overlay
update | \- | \- | used to update overlay content
Loading
Loading