From e2c4585fc4d35dd6add64bd1644705321ebc8411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rard=20Collin?= Date: Sun, 3 Mar 2024 23:13:17 +0100 Subject: [PATCH] Export the plugin as default (#28) --- src/index.js | 4 +++- types/index.esm.d.ts | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index a8df276..9937a5a 100644 --- a/src/index.js +++ b/src/index.js @@ -42,7 +42,7 @@ function getNext(color, customize, context) { return c; } -export default { +var autocolorPlugin = { id: 'autocolors', beforeUpdate(chart, args, options) { const {mode = 'dataset', enabled = true, customize, repeat} = options; @@ -97,3 +97,5 @@ function labelMode(chart, gen, customize) { setColors(dataset, c.background, c.border); } } + +export {autocolorPlugin as default}; diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index 230b509..3085fde 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -7,12 +7,12 @@ declare module 'chart.js' { } } -interface ColorsDescriptor { +export interface ColorsDescriptor { background: string border: string } -interface AutocolorsOptions { +export interface AutocolorsOptions { enabled?: boolean, mode?: 'dataset' | 'data' | 'label', offset?: number, @@ -20,9 +20,15 @@ interface AutocolorsOptions { customize?: (ctx: AutocolorsContext, options: AutocolorsOptions) => ColorsDescriptor } -interface AutocolorsContext { +export interface AutocolorsContext { chart: Chart colors: ColorsDescriptor dataIndex?: number datasetIndex: number } + +/** + * Exports the plugin class as default + */ +// eslint-disable-next-line @typescript-eslint/no-use-before-define +export { autocolorPlugin as default };