Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/__tests__/__snapshots__/documenter.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ exports[`internal core API matches snapshot > internal-core-chart 1`] = `
"properties": [
{
"inlineType": {
"name": "LegendItem",
"name": "CoreChartProps.LegendItem",
"properties": [
{
"name": "highlighted",
Expand Down Expand Up @@ -1204,7 +1204,7 @@ exports[`internal core API matches snapshot > internal-core-chart 1`] = `
},
"name": "item",
"optional": false,
"type": "LegendItem",
"type": "CoreChartProps.LegendItem",
},
],
"type": "object",
Expand All @@ -1222,10 +1222,10 @@ exports[`internal core API matches snapshot > internal-core-chart 1`] = `
"type": "union",
"valueDescriptions": undefined,
"values": [
"{ items: ReadonlyArray<LegendItem>; } & CoreChartProps.ApiInteraction",
"{ items: ReadonlyArray<LegendItem>; } & CoreChartProps.FilterInteraction",
"{ items: ReadonlyArray<LegendItem>; } & CoreChartProps.ToggleInteraction",
"{ items: ReadonlyArray<LegendItem>; } & CoreChartProps.SelectInteraction",
"{ items: ReadonlyArray<CoreChartProps.LegendItem>; } & CoreChartProps.ApiInteraction",
"{ items: ReadonlyArray<CoreChartProps.LegendItem>; } & CoreChartProps.FilterInteraction",
"{ items: ReadonlyArray<CoreChartProps.LegendItem>; } & CoreChartProps.ToggleInteraction",
"{ items: ReadonlyArray<CoreChartProps.LegendItem>; } & CoreChartProps.SelectInteraction",
],
},
"detailType": "CoreChartProps.VisibleItemsChangeDetail",
Expand Down Expand Up @@ -1455,20 +1455,20 @@ minimum width, the horizontal scrollbar is automatically added.",
If not provided, no tooltip will be displayed.",
"i18nTag": undefined,
"inlineType": {
"name": "GetLegendTooltipContent",
"name": "CoreChartProps.GetLegendTooltipContent",
"parameters": [
{
"name": "props",
"type": "GetLegendTooltipContentProps",
"type": "CoreChartProps.GetLegendTooltipContentProps",
},
],
"returnType": "LegendTooltipContent",
"returnType": "CoreChartProps.LegendTooltipContent",
"type": "function",
},
"name": "getLegendTooltipContent",
"optional": true,
"systemTags": undefined,
"type": "GetLegendTooltipContent",
"type": "CoreChartProps.GetLegendTooltipContent",
"visualRefreshTag": undefined,
},
{
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function getAllComponents(): string[] {
name !== "internal" &&
name !== "internal-do-not-use" &&
name !== "test-utils" &&
name !== "types" &&
!name.includes(".") &&
!name.includes("LICENSE") &&
!name.includes("NOTICE"),
Expand Down
2 changes: 1 addition & 1 deletion src/cartesian-chart/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import * as CoreTypes from "../core/interfaces";
import { NonCancelableEventHandler } from "../internal/events";
import { NonCancelableEventHandler } from "../types/events";

// CartesianChartProps is the type for CartesianChart React component properties. Unlike in Highcharts API,
// we pass options directly to the component, instead of grouping them all into a single "options" property.
Expand Down
31 changes: 22 additions & 9 deletions src/core/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import type Highcharts from "highcharts";

import type * as InternalComponentTypes from "../internal/components/interfaces";
import { ChartSeriesMarkerStatus } from "../internal/components/series-marker/interfaces";
import { type NonCancelableEventHandler } from "../internal/events";
import { type NonCancelableEventHandler } from "../types/events";

export type ChartSeriesMarkerStatus = "warning" | "default";

// All charts take `highcharts` instance, that can be served statically or dynamically.
// Although it has to be of type Highcharts, the TS type we use is `null | object`, so
Expand Down Expand Up @@ -527,10 +527,23 @@ export namespace CoreChartProps {

export type LegendOptionsHorizontalAlignment = "start" | "center";

export type LegendItem = InternalComponentTypes.LegendItem;
export type LegendTooltipContent = InternalComponentTypes.LegendTooltipContent;
export type GetLegendTooltipContent = InternalComponentTypes.GetLegendTooltipContent;
export type GetLegendTooltipContentProps = InternalComponentTypes.GetLegendTooltipContentProps;
export interface LegendItem {
id: string;
name: string;
marker: React.ReactNode;
visible: boolean;
highlighted: boolean;
isSecondary?: boolean;
}
export interface LegendTooltipContent {
header: React.ReactNode;
body: React.ReactNode;
footer?: React.ReactNode;
}
export type GetLegendTooltipContent = (props: GetLegendTooltipContentProps) => LegendTooltipContent;
export interface GetLegendTooltipContentProps {
legendItem: LegendItem;
}

export interface TooltipOptions {
enabled?: boolean;
Expand Down Expand Up @@ -624,8 +637,8 @@ export interface CoreLegendProps {
}

export namespace CoreLegendProps {
export type Item = InternalComponentTypes.LegendItem;
export type GetTooltipContent = InternalComponentTypes.GetLegendTooltipContent;
export type Item = CoreChartProps.LegendItem;
export type GetTooltipContent = CoreChartProps.GetLegendTooltipContent;
export interface ItemHighlightDetail {
item: Item;
}
Expand Down
7 changes: 3 additions & 4 deletions src/internal/events/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

export type CancelableEventHandler<Detail = object> = (event: CustomEvent<Detail>) => void;
import { NonCancelableEventHandler } from "../../types/events";

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export type NonCancelableEventHandler<Detail = {}> = (event: NonCancelableCustomEvent<Detail>) => void;
export type { NonCancelableCustomEvent, NonCancelableEventHandler } from "../../types/events";

export type NonCancelableCustomEvent<DetailType> = Omit<CustomEvent<DetailType>, "preventDefault">;
export type CancelableEventHandler<Detail = object> = (event: CustomEvent<Detail>) => void;

export interface ClickDetail {
button: number;
Expand Down
2 changes: 1 addition & 1 deletion src/pie-chart/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import * as CoreTypes from "../core/interfaces";
import { NonCancelableEventHandler } from "../internal/events";
import { NonCancelableEventHandler } from "../types/events";

// PieChartProps is the type for PieChart React component properties. Unlike in Highcharts API,
// we pass options directly to the component, instead of grouping them all into a single "options" property.
Expand Down
7 changes: 7 additions & 0 deletions src/types/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

export type NonCancelableCustomEvent<DetailType> = Omit<CustomEvent<DetailType>, "preventDefault">;

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export type NonCancelableEventHandler<Detail = {}> = (event: NonCancelableCustomEvent<Detail>) => void;
Loading