From fba71b18649d96a8e6ae236fc580d4f96b029fef 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: Tue, 2 May 2023 10:18:02 +0300 Subject: [PATCH] Refactor #3911 - For Chart --- api-generator/components/chart.js | 6 ++++++ components/lib/chart/Chart.d.ts | 36 +++++++++++++++++++++++++++++++ components/lib/chart/Chart.vue | 7 ++++-- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/api-generator/components/chart.js b/api-generator/components/chart.js index c60869bca..2cd31d4e2 100644 --- a/api-generator/components/chart.js +++ b/api-generator/components/chart.js @@ -34,6 +34,12 @@ const ChartProps = [ type: 'number', default: '150', description: 'Height of the chart in non-responsive mode.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/chart/Chart.d.ts b/components/lib/chart/Chart.d.ts index 25227eaee..2ea6c838c 100755 --- a/components/lib/chart/Chart.d.ts +++ b/components/lib/chart/Chart.d.ts @@ -10,6 +10,37 @@ import { CanvasHTMLAttributes } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type ChartPassThroughOptionType = ChartPassThroughAttributes | ((options: ChartPassThroughMethodOptions) => ChartPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface ChartPassThroughMethodOptions { + props: ChartProps; +} + +/** + * Custom passthrough(pt) options. + * @see {@link ChartProps.pt} + */ +export interface ChartPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: ChartPassThroughOptionType; + /** + * Uses to pass attributes to the canvas's DOM element. + */ + canvas?: ChartPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface ChartPassThroughAttributes { + [key: string]: any; +} + /** * Custom select event. * @see {@link ChartEmits.select} @@ -63,6 +94,11 @@ export interface ChartProps { * Uses to pass all properties of the CanvasHTMLAttributes to canvas element inside the component. */ canvasProps?: CanvasHTMLAttributes | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {ChartPassThroughOptions} + */ + pt?: ChartPassThroughOptions; } export interface ChartSlots {} diff --git a/components/lib/chart/Chart.vue b/components/lib/chart/Chart.vue index a3b6fa893..1de5f969d 100755 --- a/components/lib/chart/Chart.vue +++ b/components/lib/chart/Chart.vue @@ -1,12 +1,15 @@