From 9dd6301979187fe9b422eda57d82c2c0b3a8d1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Fri, 21 Apr 2023 16:42:00 +0300 Subject: [PATCH] Refactor #3879 - For ScrollTop --- api-generator/components/scrolltop.js | 6 ++++ components/lib/scrolltop/ScrollTop.d.ts | 48 +++++++++++++++++++++++++ components/lib/scrolltop/ScrollTop.vue | 7 ++-- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/api-generator/components/scrolltop.js b/api-generator/components/scrolltop.js index 4f59e0804..4dfc7beb1 100644 --- a/api-generator/components/scrolltop.js +++ b/api-generator/components/scrolltop.js @@ -22,6 +22,12 @@ const ScrollTopProps = [ type: 'string', default: 'smooth', description: 'Defines the scrolling behavi, "smooth" adds an animation and "auto" scrolls with a jump.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/scrolltop/ScrollTop.d.ts b/components/lib/scrolltop/ScrollTop.d.ts index dcb696f5d..bc65e65d2 100644 --- a/components/lib/scrolltop/ScrollTop.d.ts +++ b/components/lib/scrolltop/ScrollTop.d.ts @@ -10,6 +10,49 @@ import { VNode } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type ScrollTopPassThroughOptionType = ScrollTopPassThroughAttributes | ((options: ScrollTopPassThroughMethodOptions) => ScrollTopPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface ScrollTopPassThroughMethodOptions { + props: ScrollTopProps; + state: ScrollTopState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link ScrollTopProps.pt} + */ +export interface ScrollTopPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: ScrollTopPassThroughOptionType; + /** + * Uses to pass attributes to the icon's DOM element. + */ + icon?: ScrollTopPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface ScrollTopPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in ScrollTop component. + */ +export interface ScrollTopState { + /** + * Current visible state as a boolean. + * @defaultValue false + */ + visible: boolean; +} + /** * Defines valid properties in ScrollTop component. */ @@ -34,6 +77,11 @@ export interface ScrollTopProps { * @defaultValue smooth */ behavior?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {ScrollTopPassThroughOptions} + */ + pt?: ScrollTopPassThroughOptions; } /** diff --git a/components/lib/scrolltop/ScrollTop.vue b/components/lib/scrolltop/ScrollTop.vue index b4aae9c96..3e12a1e7d 100644 --- a/components/lib/scrolltop/ScrollTop.vue +++ b/components/lib/scrolltop/ScrollTop.vue @@ -1,18 +1,21 @@