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(anchor): anchor item add custom scroll #476

Merged
merged 1 commit into from
Nov 19, 2024
Merged
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.
20 changes: 12 additions & 8 deletions packages/products/tdesign-react/src/anchor/anchor.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,36 @@

name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
className | String | - | className of component | N
style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N
affixProps | Object | - | Typescript:`Omit<AffixProps, 'children'>`,[Affix API Documents](./affix?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/anchor/type.ts) | N
bounds | Number | 5 | \- | N
container | String / Function | () => (() => window) | Typescript:`ScrollContainer`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
cursor | TElement | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
size | String | medium | options:small/medium/large。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
getCurrentAnchor | Function | - | Custom Highlighted Anchor Points。Typescript:`(activeLink: string) => string` | N
size | String | medium | options: small/medium/large。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
targetOffset | Number | 0 | \- | N
onChange | Function | | Typescript:`(currentLink: string, prevLink: string) => void`<br/> | N
onClick | Function | | Typescript:`(link: { href: string; title: string; e: MouseEvent }) => void`<br/> | N


### AnchorItem Props

name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
className | String | - | className of component | N
style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N
customScroll | Boolean | false | custom scroll effect, when set to true, clicking on an anchor link will not use JavaScript animation to smoothly scroll to the anchor target element. | N
href | String | - | required | Y
target | String | _self | options_self/_blank/_parent/_top | N
target | String | _self | options: _self/_blank/_parent/_top | N
title | TNode | '' | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N


### AnchorTarget Props

name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
className | String | - | className of component | N
style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N
id | String | - | required | Y
tag | String | div | \- | N
10 changes: 7 additions & 3 deletions packages/products/tdesign-react/src/anchor/anchor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,36 @@

### Anchor Props

名称 | 类型 | 默认值 | 说明 | 必传
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
affixProps | Object | - | 透传 Affix 组件属性,即让 Anchor 组件支持所有 Affix 组件特性。TS 类型:`Omit<AffixProps, 'children'>`,[Affix API Documents](./affix?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/anchor/type.ts) | N
bounds | Number | 5 | 锚点区域边界 | N
container | String / Function | () => (() => window) | 指定滚动的容器。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`ScrollContainer`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
cursor | TElement | - | 用于自定义选中项左侧游标。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
getCurrentAnchor | Function | - | 自定义高亮的锚点 。TS 类型:`(activeLink: string) => string` | N
size | String | medium | 组件尺寸,small(120px),medium(200px),large(320px)。可选项:small/medium/large。TS 类型:`SizeEnum`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
targetOffset | Number | 0 | 锚点滚动偏移量 | N
onChange | Function | | TS 类型:`(currentLink: string, prevLink: string) => void`<br/>锚点改变时触发 | N
onClick | Function | | TS 类型:`(link: { href: string; title: string; e: MouseEvent }) => void`<br/>锚点被点击时触发 | N


### AnchorItem Props

名称 | 类型 | 默认值 | 说明 | 必传
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
customScroll | Boolean | false | 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 | N
href | String | - | 必需。锚点链接, 如果是 hash 模式需要加上当前 path | Y
target | String | _self | 锚点文本。可选项:_self/_blank/_parent/_top | N
title | TNode | '' | 锚点文本。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N


### AnchorTarget Props

名称 | 类型 | 默认值 | 说明 | 必传
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
Expand Down
16 changes: 16 additions & 0 deletions packages/products/tdesign-react/src/anchor/defaultProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdAnchorProps, TdAnchorItemProps, TdAnchorTargetProps } from './type';

export const anchorDefaultProps: TdAnchorProps = {
bounds: 5,
container: '() => (() => window)',
size: 'medium',
targetOffset: 0,
};

export const anchorItemDefaultProps: TdAnchorItemProps = { customScroll: false, target: '_self', title: '' };

export const anchorTargetDefaultProps: TdAnchorTargetProps = { tag: 'div' };
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdAnchorItemProps } from '../anchor/type';
import { PropType } from 'vue';

export default {
/** 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 */
customScroll: Boolean,
/** 锚点链接, 如果是 hash 模式需要加上当前 path */
href: {
type: String,
default: '',
required: true,
},
/** 锚点文本 */
target: {
type: String as PropType<TdAnchorItemProps['target']>,
default: '_self' as TdAnchorItemProps['target'],
validator(val: TdAnchorItemProps['target']): boolean {
if (!val) return true;
return ['_self', '_blank', '_parent', '_top'].includes(val);
},
},
/** 锚点文本 */
title: {
type: [String, Function] as PropType<TdAnchorItemProps['title']>,
default: '' as TdAnchorItemProps['title'],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

export default {
/** 目标内容 id */
id: {
type: String,
default: '',
required: true,
},
/** 渲染的标签 */
tag: {
type: String,
default: 'div',
},
};
43 changes: 43 additions & 0 deletions packages/products/tdesign-vue-next/src/anchor/anchor.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
:: BASE_DOC ::

## API


### Anchor Props

name | type | default | description | required
-- | -- | -- | -- | --
affixProps | Object | - | Typescript:`AffixProps`,[Affix API Documents](./affix?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/anchor/type.ts) | N
bounds | Number | 5 | \- | N
container | String / Function | () => (() => window) | Typescript:`ScrollContainer`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
cursor | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
getCurrentAnchor | Function | - | Custom Highlighted Anchor Points。Typescript:`(activeLink: string) => string` | N
size | String | medium | options: small/medium/large。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
targetOffset | Number | 0 | \- | N
onChange | Function | | Typescript:`(currentLink: string, prevLink: string) => void`<br/> | N
onClick | Function | | Typescript:`(link: { href: string; title: string; e: MouseEvent }) => void`<br/> | N

### Anchor Events

name | params | description
-- | -- | --
change | `(currentLink: string, prevLink: string)` | \-
click | `(link: { href: string; title: string; e: MouseEvent })` | \-


### AnchorItem Props

name | type | default | description | required
-- | -- | -- | -- | --
customScroll | Boolean | false | custom scroll effect, when set to true, clicking on an anchor link will not use JavaScript animation to smoothly scroll to the anchor target element. | N
href | String | - | required | Y
target | String | _self | options: _self/_blank/_parent/_top | N
title | String / Slot / Function | '' | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N


### AnchorTarget Props

name | type | default | description | required
-- | -- | -- | -- | --
id | String | - | required | Y
tag | String | div | \- | N
43 changes: 43 additions & 0 deletions packages/products/tdesign-vue-next/src/anchor/anchor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
:: BASE_DOC ::

## API


### Anchor Props

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
affixProps | Object | - | 透传 Affix 组件属性,即让 Anchor 组件支持所有 Affix 组件特性。TS 类型:`AffixProps`,[Affix API Documents](./affix?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/anchor/type.ts) | N
bounds | Number | 5 | 锚点区域边界 | N
container | String / Function | () => (() => window) | 指定滚动的容器。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`ScrollContainer`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
cursor | Slot / Function | - | 用于自定义选中项左侧游标。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
getCurrentAnchor | Function | - | 自定义高亮的锚点 。TS 类型:`(activeLink: string) => string` | N
size | String | medium | 组件尺寸,small(120px),medium(200px),large(320px)。可选项:small/medium/large。TS 类型:`SizeEnum`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
targetOffset | Number | 0 | 锚点滚动偏移量 | N
onChange | Function | | TS 类型:`(currentLink: string, prevLink: string) => void`<br/>锚点改变时触发 | N
onClick | Function | | TS 类型:`(link: { href: string; title: string; e: MouseEvent }) => void`<br/>锚点被点击时触发 | N

### Anchor Events

名称 | 参数 | 描述
-- | -- | --
change | `(currentLink: string, prevLink: string)` | 锚点改变时触发
click | `(link: { href: string; title: string; e: MouseEvent })` | 锚点被点击时触发


### AnchorItem Props

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
customScroll | Boolean | false | 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 | N
href | String | - | 必需。锚点链接, 如果是 hash 模式需要加上当前 path | Y
target | String | _self | 锚点文本。可选项:_self/_blank/_parent/_top | N
title | String / Slot / Function | '' | 锚点文本。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N


### AnchorTarget Props

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
id | String | - | 必需。目标内容 id | Y
tag | String | div | 渲染的标签 | N
51 changes: 51 additions & 0 deletions packages/products/tdesign-vue-next/src/anchor/props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdAnchorProps } from './type';
import { PropType } from 'vue';

export default {
/** 透传 Affix 组件属性,即让 Anchor 组件支持所有 Affix 组件特性 */
affixProps: {
type: Object as PropType<TdAnchorProps['affixProps']>,
},
/** 锚点区域边界 */
bounds: {
type: Number,
default: 5,
},
/** 指定滚动的容器。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body */
container: {
type: [String, Function] as PropType<TdAnchorProps['container']>,
default: () => (() => window) as TdAnchorProps['container'],
},
/** 用于自定义选中项左侧游标 */
cursor: {
type: Function as PropType<TdAnchorProps['cursor']>,
},
/** 自定义高亮的锚点 */
getCurrentAnchor: {
type: Function as PropType<TdAnchorProps['getCurrentAnchor']>,
},
/** 组件尺寸,small(120px),medium(200px),large(320px) */
size: {
type: String as PropType<TdAnchorProps['size']>,
default: 'medium' as TdAnchorProps['size'],
validator(val: TdAnchorProps['size']): boolean {
if (!val) return true;
return ['small', 'medium', 'large'].includes(val);
},
},
/** 锚点滚动偏移量 */
targetOffset: {
type: Number,
default: 0,
},
/** 锚点改变时触发 */
onChange: Function as PropType<TdAnchorProps['onChange']>,
/** 锚点被点击时触发 */
onClick: Function as PropType<TdAnchorProps['onClick']>,
};
33 changes: 33 additions & 0 deletions packages/products/tdesign-vue/src/anchor/anchor-item-props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdAnchorItemProps } from '../anchor/type';
import { PropType } from 'vue';

export default {
/** 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 */
customScroll: Boolean,
/** 锚点链接, 如果是 hash 模式需要加上当前 path */
href: {
type: String,
default: '',
required: true,
},
/** 锚点文本 */
target: {
type: String as PropType<TdAnchorItemProps['target']>,
default: '_self' as TdAnchorItemProps['target'],
validator(val: TdAnchorItemProps['target']): boolean {
if (!val) return true;
return ['_self', '_blank', '_parent', '_top'].includes(val);
},
},
/** 锚点文本 */
title: {
type: [String, Function] as PropType<TdAnchorItemProps['title']>,
default: '',
},
};
19 changes: 19 additions & 0 deletions packages/products/tdesign-vue/src/anchor/anchor-target-props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

export default {
/** 目标内容 id */
id: {
type: String,
default: '',
required: true,
},
/** 渲染的标签 */
tag: {
type: String,
default: 'div',
},
};
43 changes: 43 additions & 0 deletions packages/products/tdesign-vue/src/anchor/anchor.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
:: BASE_DOC ::

## API


### Anchor Props

name | type | default | description | required
-- | -- | -- | -- | --
affixProps | Object | - | Typescript:`AffixProps`,[Affix API Documents](./affix?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/anchor/type.ts) | N
bounds | Number | 5 | \- | N
container | String / Function | () => (() => window) | Typescript:`ScrollContainer`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
cursor | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
getCurrentAnchor | Function | - | Custom Highlighted Anchor Points。Typescript:`(activeLink: string) => string` | N
size | String | medium | options: small/medium/large。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
targetOffset | Number | 0 | \- | N
onChange | Function | | Typescript:`(currentLink: string, prevLink: string) => void`<br/> | N
onClick | Function | | Typescript:`(link: { href: string; title: string; e: MouseEvent }) => void`<br/> | N

### Anchor Events

name | params | description
-- | -- | --
change | `(currentLink: string, prevLink: string)` | \-
click | `(link: { href: string; title: string; e: MouseEvent })` | \-


### AnchorItem Props

name | type | default | description | required
-- | -- | -- | -- | --
customScroll | Boolean | false | custom scroll effect, when set to true, clicking on an anchor link will not use JavaScript animation to smoothly scroll to the anchor target element. | N
href | String | - | required | Y
target | String | _self | options: _self/_blank/_parent/_top | N
title | String / Slot / Function | '' | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N


### AnchorTarget Props

name | type | default | description | required
-- | -- | -- | -- | --
id | String | - | required | Y
tag | String | div | \- | N
Loading
Loading