From c14c2f160ed7ab4bcdbe7a08b6e5c9b558d066e9 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: Mon, 27 Mar 2023 10:13:31 +0300 Subject: [PATCH] Refactor #3797 - Splitter updates --- api-generator/components/splitter.js | 6 +++ api-generator/components/splitterpanel.js | 6 +++ components/lib/splitter/Splitter.d.ts | 51 +++++++++++++++++++ components/lib/splitter/Splitter.vue | 19 +++++-- .../lib/splitterpanel/SplitterPanel.d.ts | 32 ++++++++++++ .../lib/splitterpanel/SplitterPanel.vue | 5 +- 6 files changed, 115 insertions(+), 4 deletions(-) diff --git a/api-generator/components/splitter.js b/api-generator/components/splitter.js index a3a228257..0ba1b0060 100644 --- a/api-generator/components/splitter.js +++ b/api-generator/components/splitter.js @@ -28,6 +28,12 @@ const SplitterProps = [ type: 'number', default: '5', description: 'Step factor to increment/decrement the size of the panels while pressing the arrow keys.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/api-generator/components/splitterpanel.js b/api-generator/components/splitterpanel.js index 302674132..fa98e1225 100644 --- a/api-generator/components/splitterpanel.js +++ b/api-generator/components/splitterpanel.js @@ -10,6 +10,12 @@ const SplitterPanelProps = [ type: 'number', default: 'null', description: 'Minimum size of the element relative to 100%.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/splitter/Splitter.d.ts b/components/lib/splitter/Splitter.d.ts index ae979761b..efdaf4743 100644 --- a/components/lib/splitter/Splitter.d.ts +++ b/components/lib/splitter/Splitter.d.ts @@ -10,6 +10,16 @@ import { VNode } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type SplitterPassThroughOptionType = SplitterPassThroughAttributes | ((options: SplitterPassThroughMethodOptions) => SplitterPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface SplitterPassThroughMethodOptions { + props: SplitterProps; + state: SplitterState; +} + /** * Custom resize start event. * @see {@link SplitterEmits.resizestar} @@ -40,6 +50,42 @@ export interface SplitterResizeEndEvent { sizes: number[]; } +/** + * Custom passthrough(pt) options. + * @see {@link SplitterProps.pt} + */ +export interface SplitterPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: SplitterPassThroughOptionType; + /** + * Uses to pass attributes to the gutter's DOM element. + */ + gutter?: SplitterPassThroughOptionType; + /** + * Uses to pass attributes to the gutter handler's DOM element. + */ + gutterhandler?: SplitterPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface SplitterPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in Panel component. + */ +export interface SplitterState { + /** + * Previous size state as a number. + */ + prevSize: number; +} + /** * Defines valid properties in Splitter component. */ @@ -68,6 +114,11 @@ export interface SplitterProps { * @defaultValue 1 */ step?: number | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {SplitterPassThroughOptions} + */ + pt?: SplitterPassThroughOptions; } /** diff --git a/components/lib/splitter/Splitter.vue b/components/lib/splitter/Splitter.vue index 887f98443..07568d0fd 100644 --- a/components/lib/splitter/Splitter.vue +++ b/components/lib/splitter/Splitter.vue @@ -1,19 +1,32 @@