From 0df29e31fe910d30f545c3861d50690604a59fb7 Mon Sep 17 00:00:00 2001 From: boogie-ben Date: Tue, 9 Jul 2024 15:48:09 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat(anchor-item):=20=E6=96=B0=E5=A2=9EAPI(?= =?UTF-8?q?disableScroll)=EF=BC=8C=E6=94=AF=E6=8C=81=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/anchor/anchor-item-props.ts | 5 +++++ src/anchor/anchor-item.tsx | 2 +- src/anchor/anchor.md | 1 + src/anchor/type.ts | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/anchor/anchor-item-props.ts b/src/anchor/anchor-item-props.ts index 12f20eb310..66ddb2edfb 100644 --- a/src/anchor/anchor-item-props.ts +++ b/src/anchor/anchor-item-props.ts @@ -28,4 +28,9 @@ export default { type: [String, Function] as PropType, default: '', }, + /** 禁用点击锚点链接后自动滚动到目标元素,滚动行为由用户或浏览器处理(如scroll-behavior: smooth) */ + disableScroll: { + type: Boolean, + default: false, + }, }; diff --git a/src/anchor/anchor-item.tsx b/src/anchor/anchor-item.tsx index f04d676231..9be174e11b 100644 --- a/src/anchor/anchor-item.tsx +++ b/src/anchor/anchor-item.tsx @@ -37,7 +37,7 @@ export default defineComponent({ }; const handleClick = (e: MouseEvent) => { const { href, title } = props; - anchor.handleScrollTo(href); + if (!props.disableScroll) anchor.handleScrollTo(href); anchor.handleLinkClick({ href, title: isString(title) ? title : undefined, e }); }; const renderTitle = () => { diff --git a/src/anchor/anchor.md b/src/anchor/anchor.md index 52f3c4258e..a10815bef9 100644 --- a/src/anchor/anchor.md +++ b/src/anchor/anchor.md @@ -28,6 +28,7 @@ click | `(link: { href: string; title: string; e: MouseEvent })` | 锚点被点 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 +disableScroll | Boolean | false | 禁用点击锚点链接后自动滚动到目标元素,滚动行为由用户或浏览器处理(如scroll-behavior: smooth) ### AnchorTarget Props diff --git a/src/anchor/type.ts b/src/anchor/type.ts index 2c9b066a93..4019758658 100644 --- a/src/anchor/type.ts +++ b/src/anchor/type.ts @@ -76,4 +76,9 @@ export interface TdAnchorItemProps { * @default '' */ title?: string | TNode; + /** + * 禁用点击锚点链接后自动滚动到目标元素,滚动行为由用户或浏览器处理(如scroll-behavior: smooth) + * @default false + */ + disableScroll?: boolean; } From 7bf8c4ca580ac2d7a59c216810b82999a493d58a Mon Sep 17 00:00:00 2001 From: boogie-ben Date: Sun, 17 Nov 2024 22:51:50 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat(anchor-item):=20=E6=96=B0=E5=A2=9Eapi?= =?UTF-8?q?=20customScroll=20=E6=94=AF=E6=8C=81=E7=94=A8=E6=88=B7=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9A=84=E9=94=9A=E7=82=B9?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/anchor/anchor-item-props.ts | 4 ++-- src/anchor/anchor-item.tsx | 2 +- src/anchor/anchor.en-US.md | 1 + src/anchor/anchor.md | 2 +- src/anchor/type.ts | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/anchor/anchor-item-props.ts b/src/anchor/anchor-item-props.ts index 66ddb2edfb..b5d213722a 100644 --- a/src/anchor/anchor-item-props.ts +++ b/src/anchor/anchor-item-props.ts @@ -28,8 +28,8 @@ export default { type: [String, Function] as PropType, default: '', }, - /** 禁用点击锚点链接后自动滚动到目标元素,滚动行为由用户或浏览器处理(如scroll-behavior: smooth) */ - disableScroll: { + /** 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 */ + customScroll: { type: Boolean, default: false, }, diff --git a/src/anchor/anchor-item.tsx b/src/anchor/anchor-item.tsx index 9be174e11b..ce6b3261bc 100644 --- a/src/anchor/anchor-item.tsx +++ b/src/anchor/anchor-item.tsx @@ -37,7 +37,7 @@ export default defineComponent({ }; const handleClick = (e: MouseEvent) => { const { href, title } = props; - if (!props.disableScroll) anchor.handleScrollTo(href); + if (!props.customScroll) anchor.handleScrollTo(href); anchor.handleLinkClick({ href, title: isString(title) ? title : undefined, e }); }; const renderTitle = () => { diff --git a/src/anchor/anchor.en-US.md b/src/anchor/anchor.en-US.md index 44ea48592d..f17aff4d41 100644 --- a/src/anchor/anchor.en-US.md +++ b/src/anchor/anchor.en-US.md @@ -29,6 +29,7 @@ name | type | default | description | required 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 +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. ### AnchorTarget Props diff --git a/src/anchor/anchor.md b/src/anchor/anchor.md index a10815bef9..8bf8a8f1e7 100644 --- a/src/anchor/anchor.md +++ b/src/anchor/anchor.md @@ -28,7 +28,7 @@ click | `(link: { href: string; title: string; e: MouseEvent })` | 锚点被点 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 -disableScroll | Boolean | false | 禁用点击锚点链接后自动滚动到目标元素,滚动行为由用户或浏览器处理(如scroll-behavior: smooth) +customScroll | Boolean | false | 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 ### AnchorTarget Props diff --git a/src/anchor/type.ts b/src/anchor/type.ts index 4019758658..75a5cf5b44 100644 --- a/src/anchor/type.ts +++ b/src/anchor/type.ts @@ -77,8 +77,8 @@ export interface TdAnchorItemProps { */ title?: string | TNode; /** - * 禁用点击锚点链接后自动滚动到目标元素,滚动行为由用户或浏览器处理(如scroll-behavior: smooth) + * 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 * @default false */ - disableScroll?: boolean; + customScroll?: boolean; } From e9ab01ce7ff0dc7b7f49abbffce0b8ca682a9afd Mon Sep 17 00:00:00 2001 From: boogie-ben Date: Sun, 17 Nov 2024 23:55:45 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat(anchor):=20=E6=96=B0=E5=A2=9Edemo?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=BB=9A=E5=8A=A8=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/anchor/_example-ts/custom-scroll.vue | 19 +++++++++++++++++++ src/anchor/_example/custom-scroll.vue | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/anchor/_example-ts/custom-scroll.vue create mode 100644 src/anchor/_example/custom-scroll.vue diff --git a/src/anchor/_example-ts/custom-scroll.vue b/src/anchor/_example-ts/custom-scroll.vue new file mode 100644 index 0000000000..b74c09cc18 --- /dev/null +++ b/src/anchor/_example-ts/custom-scroll.vue @@ -0,0 +1,19 @@ + + diff --git a/src/anchor/_example/custom-scroll.vue b/src/anchor/_example/custom-scroll.vue new file mode 100644 index 0000000000..60a52e541f --- /dev/null +++ b/src/anchor/_example/custom-scroll.vue @@ -0,0 +1,19 @@ + + From ba5dea1457e436a65a3ec5a11dc57a3b95707157 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Nov 2024 07:56:20 +0000 Subject: [PATCH 4/6] chore: update common --- src/_common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_common b/src/_common index 4bdf9ced2d..c2be429ce8 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 4bdf9ced2d0b1c3aaf88c035424ef2230d71f396 +Subproject commit c2be429ce8b4f75c8d166a9ce4d6a3c69e01e2d3 From 75dbba5eee4e8b7f38798c27c0e42c143eefc948 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Nov 2024 08:14:53 +0000 Subject: [PATCH 5/6] chore: update snapshot --- test/unit/snap/__snapshots__/csr.test.js.snap | 102 ++++++++++++++++++ test/unit/snap/__snapshots__/ssr.test.js.snap | 2 + 2 files changed, 104 insertions(+) diff --git a/test/unit/snap/__snapshots__/csr.test.js.snap b/test/unit/snap/__snapshots__/csr.test.js.snap index d7f4b9ce80..563ebbd294 100644 --- a/test/unit/snap/__snapshots__/csr.test.js.snap +++ b/test/unit/snap/__snapshots__/csr.test.js.snap @@ -1399,6 +1399,108 @@ exports[`csr snapshot test > csr test ./src/anchor/_example/cursor.vue 1`] = ` `; +exports[`csr snapshot test > csr test ./src/anchor/_example/custom-scroll.vue 1`] = ` +
+ +`; + exports[`csr snapshot test > csr test ./src/anchor/_example/large.vue 1`] = `
ssr test ./src/anchor/_example/container.vue 1`] = exports[`ssr snapshot test > ssr test ./src/anchor/_example/cursor.vue 1`] = `""`; +exports[`ssr snapshot test > ssr test ./src/anchor/_example/custom-scroll.vue 1`] = `""`; + exports[`ssr snapshot test > ssr test ./src/anchor/_example/large.vue 1`] = `""`; exports[`ssr snapshot test > ssr test ./src/anchor/_example/multiple.vue 1`] = `""`; From 37480e9267f2448abc37115b065c1f30deaca3eb Mon Sep 17 00:00:00 2001 From: Uyarn Date: Tue, 19 Nov 2024 18:36:21 +0800 Subject: [PATCH 6/6] chore: fix lint --- src/date-picker/hooks/useTableData.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/date-picker/hooks/useTableData.tsx b/src/date-picker/hooks/useTableData.tsx index b1ba9958a3..ca3245d01f 100644 --- a/src/date-picker/hooks/useTableData.tsx +++ b/src/date-picker/hooks/useTableData.tsx @@ -38,5 +38,7 @@ export default function useTableData(props: any) { hoverEnd: props.hoverEnd, type: props.mode, isRange: props.isRange, + value: props.value, + multiple: props.multiple, }); }