@cloudscape-design/chart-components 1.0.54 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -40,11 +40,18 @@ export const InternalCartesianChart = forwardRef(({ tooltip, ...props }, ref) =>
|
|
|
40
40
|
// to the ones we get from the consumer due to the internal validation/transformation we run on them.
|
|
41
41
|
// See: https://api.highcharts.com/class-reference/Highcharts.Chart#userOptions.
|
|
42
42
|
const transformItem = (item) => {
|
|
43
|
-
var _a;
|
|
44
|
-
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
const userOptions = item.point.series.userOptions;
|
|
45
|
+
// Restore original threshold type from custom metadata, since transformCartesianSeries
|
|
46
|
+
// replaces "x-threshold" and "y-threshold" with "line" for Highcharts compatibility.
|
|
47
|
+
const originalType = (_b = (_a = item.point.series.userOptions.custom) === null || _a === void 0 ? void 0 : _a.awsui) === null || _b === void 0 ? void 0 : _b.type;
|
|
48
|
+
const series = originalType
|
|
49
|
+
? { ...userOptions, type: originalType }
|
|
50
|
+
: userOptions;
|
|
51
|
+
return {
|
|
45
52
|
x: item.point.x,
|
|
46
|
-
y: isXThreshold(item.point.series) ? null : ((
|
|
47
|
-
series
|
|
53
|
+
y: isXThreshold(item.point.series) ? null : ((_c = item.point.y) !== null && _c !== void 0 ? _c : null),
|
|
54
|
+
series,
|
|
48
55
|
errorRanges: item.errorRanges.map((point) => {
|
|
49
56
|
var _a, _b;
|
|
50
57
|
return ({
|
|
@@ -53,7 +60,7 @@ export const InternalCartesianChart = forwardRef(({ tooltip, ...props }, ref) =>
|
|
|
53
60
|
series: point.series.userOptions,
|
|
54
61
|
});
|
|
55
62
|
}),
|
|
56
|
-
}
|
|
63
|
+
};
|
|
57
64
|
};
|
|
58
65
|
const transformSeriesProps = (props) => ({
|
|
59
66
|
item: transformItem(props.item),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-cartesian-internal.js","sourceRoot":"","sources":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C,aAAa,EACjC,oBAAoB,EAAE,qBAAqB,EAC3C,SAAS,EAAE,WAAW,CAAC,IAAI,GAC3B,CACH,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { forwardRef, useImperativeHandle, useRef, useState } from \"react\";\n\nimport { useControllableState } from \"@cloudscape-design/component-toolkit\";\n\nimport { InternalCoreChart } from \"../core/chart-core\";\nimport { CoreChartProps, ErrorBarSeriesOptions } from \"../core/interfaces\";\nimport { getOptionsId, isXThreshold } from \"../core/utils\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { fireNonCancelableEvent } from \"../internal/events\";\nimport { castArray, SomeRequired } from \"../internal/utils/utils\";\nimport { transformCartesianSeries } from \"./chart-series-cartesian\";\nimport { CartesianChartProps, NonErrorBarSeriesOptions } from \"./interfaces\";\n\nimport testClasses from \"./test-classes/styles.css.js\";\n\ninterface InternalCartesianChartProps extends InternalBaseComponentProps, CartesianChartProps {\n tooltip: SomeRequired<CartesianChartProps.TooltipOptions, \"enabled\" | \"placement\" | \"size\">;\n legend: SomeRequired<CartesianChartProps.LegendOptions, \"enabled\">;\n}\n\nexport const InternalCartesianChart = forwardRef(\n ({ tooltip, ...props }: InternalCartesianChartProps, ref: React.Ref<CartesianChartProps.Ref>) => {\n const apiRef = useRef<null | CoreChartProps.ChartAPI>(null);\n\n // When visibleSeries and onVisibleSeriesChange are provided - the series visibility can be controlled from the outside.\n // Otherwise - the component handles series visibility using its internal state.\n useControllableState(props.visibleSeries, props.onVisibleSeriesChange, undefined, {\n componentName: \"CartesianChart\",\n propertyName: \"visibleSeries\",\n changeHandlerName: \"onVisibleSeriesChange\",\n });\n const allSeriesIds = props.series.map((s) => getOptionsId(s));\n // We keep local visible series state to compute threshold series data, that depends on series visibility.\n const [visibleSeriesLocal, setVisibleSeriesLocal] = useState(props.visibleSeries ?? allSeriesIds);\n const visibleSeriesState = props.visibleSeries ?? visibleSeriesLocal;\n const onVisibleSeriesChange: CoreChartProps[\"onVisibleItemsChange\"] = ({ detail: { items } }) => {\n const visibleSeries = items.filter((i) => i.visible).map((i) => i.id);\n if (props.visibleSeries) {\n fireNonCancelableEvent(props.onVisibleSeriesChange, { visibleSeries });\n } else {\n setVisibleSeriesLocal(visibleSeries);\n }\n };\n\n // We convert cartesian tooltip options to the core chart's getTooltipContent callback,\n // ensuring no internal types are exposed to the consumer-defined render functions.\n const getTooltipContent: CoreChartProps[\"getTooltipContent\"] = () => {\n // We use point.series.userOptions to get the series options that were passed down to Highcharts,\n // assuming Highcharts makes no modifications for those. These options are not referentially equal\n // to the ones we get from the consumer due to the internal validation/transformation we run on them.\n // See: https://api.highcharts.com/class-reference/Highcharts.Chart#userOptions.\n const transformItem = (item: CoreChartProps.TooltipContentItem): CartesianChartProps.TooltipPointItem => ({\n x: item.point.x,\n y: isXThreshold(item.point.series) ? null : (item.point.y ?? null),\n series: item.point.series.userOptions as NonErrorBarSeriesOptions,\n errorRanges: item.errorRanges.map((point) => ({\n low: point.options.low ?? 0,\n high: point.options.high ?? 0,\n series: point.series.userOptions as ErrorBarSeriesOptions,\n })),\n });\n const transformSeriesProps = (\n props: CoreChartProps.TooltipPointProps,\n ): CartesianChartProps.TooltipPointRenderProps => ({\n item: transformItem(props.item),\n });\n const transformSlotProps = (\n props: CoreChartProps.TooltipSlotProps,\n ): CartesianChartProps.TooltipSlotRenderProps => ({\n x: props.x,\n items: props.items.map(transformItem),\n });\n return {\n point: tooltip.point ? (props) => tooltip.point!(transformSeriesProps(props)) : undefined,\n header: tooltip.header ? (props) => tooltip.header!(transformSlotProps(props)) : undefined,\n body: tooltip.body ? (props) => tooltip.body!(transformSlotProps(props)) : undefined,\n footer: tooltip.footer ? (props) => tooltip.footer!(transformSlotProps(props)) : undefined,\n };\n };\n\n // Converting x-, and y-threshold series to Highcharts series and plot lines.\n const { series, xPlotLines, yPlotLines } = transformCartesianSeries(props.series, visibleSeriesState);\n\n // Cartesian chart imperative API.\n useImperativeHandle(ref, () => ({\n setVisibleSeries: (visibleSeriesIds) => apiRef.current?.setItemsVisible(visibleSeriesIds),\n showAllSeries: () => apiRef.current?.setItemsVisible(allSeriesIds),\n }));\n\n return (\n <InternalCoreChart\n {...props}\n callback={(api) => (apiRef.current = api)}\n options={{\n chart: {\n inverted: props.inverted,\n },\n plotOptions: {\n series: { stacking: props.stacking },\n },\n series,\n xAxis: castArray(props.xAxis)?.map((xAxisProps) => ({\n ...xAxisProps,\n title: { text: xAxisProps.title },\n plotLines: xPlotLines,\n })),\n yAxis: castArray(props.yAxis)?.map((yAxisProps) => ({\n ...yAxisProps,\n title: { text: yAxisProps.title },\n plotLines: yPlotLines,\n })),\n }}\n tooltip={tooltip}\n getTooltipContent={getTooltipContent}\n visibleItems={props.visibleSeries}\n onVisibleItemsChange={onVisibleSeriesChange}\n className={testClasses.root}\n />\n );\n },\n);\n"]}
|
|
1
|
+
{"version":3,"file":"chart-cartesian-internal.js","sourceRoot":"","sources":["../../../src/cartesian-chart/chart-cartesian-internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAgB,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,OAAO,WAAW,MAAM,8BAA8B,CAAC;AAOvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAA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,CAAC,OAAO,0CAAE,eAAe,CAAC,YAAY,CAAC,CAAA,EAAA;KACnE,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,KAAC,iBAAiB,OACZ,KAAK,EACT,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC,EACzC,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,QAAQ,EAAE,KAAK,CAAC,QAAQ;aACzB;YACD,WAAW,EAAE;gBACX,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;aACrC;YACD,MAAM;YACN,KAAK,EAAE,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAClD,GAAG,UAAU;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE;gBACjC,SAAS,EAAE,UAAU;aACtB,CAAC,CAAC;YACH,KAAK,EAAE,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAClD,GAAG,UAAU;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE;gBACjC,SAAS,EAAE,UAAU;aACtB,CAAC,CAAC;SACJ,EACD,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,KAAK,CAAC,aAAa,EACjC,oBAAoB,EAAE,qBAAqB,EAC3C,SAAS,EAAE,WAAW,CAAC,IAAI,GAC3B,CACH,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { forwardRef, useImperativeHandle, useRef, useState } from \"react\";\n\nimport { useControllableState } from \"@cloudscape-design/component-toolkit\";\n\nimport { InternalCoreChart } from \"../core/chart-core\";\nimport { CoreChartProps, ErrorBarSeriesOptions } from \"../core/interfaces\";\nimport { getOptionsId, isXThreshold } from \"../core/utils\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { fireNonCancelableEvent } from \"../internal/events\";\nimport { castArray, SomeRequired } from \"../internal/utils/utils\";\nimport { transformCartesianSeries } from \"./chart-series-cartesian\";\nimport { CartesianChartProps, NonErrorBarSeriesOptions } from \"./interfaces\";\n\nimport testClasses from \"./test-classes/styles.css.js\";\n\ninterface InternalCartesianChartProps extends InternalBaseComponentProps, CartesianChartProps {\n tooltip: SomeRequired<CartesianChartProps.TooltipOptions, \"enabled\" | \"placement\" | \"size\">;\n legend: SomeRequired<CartesianChartProps.LegendOptions, \"enabled\">;\n}\n\nexport const InternalCartesianChart = forwardRef(\n ({ tooltip, ...props }: InternalCartesianChartProps, ref: React.Ref<CartesianChartProps.Ref>) => {\n const apiRef = useRef<null | CoreChartProps.ChartAPI>(null);\n\n // When visibleSeries and onVisibleSeriesChange are provided - the series visibility can be controlled from the outside.\n // Otherwise - the component handles series visibility using its internal state.\n useControllableState(props.visibleSeries, props.onVisibleSeriesChange, undefined, {\n componentName: \"CartesianChart\",\n propertyName: \"visibleSeries\",\n changeHandlerName: \"onVisibleSeriesChange\",\n });\n const allSeriesIds = props.series.map((s) => getOptionsId(s));\n // We keep local visible series state to compute threshold series data, that depends on series visibility.\n const [visibleSeriesLocal, setVisibleSeriesLocal] = useState(props.visibleSeries ?? allSeriesIds);\n const visibleSeriesState = props.visibleSeries ?? visibleSeriesLocal;\n const onVisibleSeriesChange: CoreChartProps[\"onVisibleItemsChange\"] = ({ detail: { items } }) => {\n const visibleSeries = items.filter((i) => i.visible).map((i) => i.id);\n if (props.visibleSeries) {\n fireNonCancelableEvent(props.onVisibleSeriesChange, { visibleSeries });\n } else {\n setVisibleSeriesLocal(visibleSeries);\n }\n };\n\n // We convert cartesian tooltip options to the core chart's getTooltipContent callback,\n // ensuring no internal types are exposed to the consumer-defined render functions.\n const getTooltipContent: CoreChartProps[\"getTooltipContent\"] = () => {\n // We use point.series.userOptions to get the series options that were passed down to Highcharts,\n // assuming Highcharts makes no modifications for those. These options are not referentially equal\n // to the ones we get from the consumer due to the internal validation/transformation we run on them.\n // See: https://api.highcharts.com/class-reference/Highcharts.Chart#userOptions.\n const transformItem = (item: CoreChartProps.TooltipContentItem): CartesianChartProps.TooltipPointItem => {\n const userOptions = item.point.series.userOptions as NonErrorBarSeriesOptions;\n // Restore original threshold type from custom metadata, since transformCartesianSeries\n // replaces \"x-threshold\" and \"y-threshold\" with \"line\" for Highcharts compatibility.\n const originalType = item.point.series.userOptions.custom?.awsui?.type;\n const series = originalType\n ? ({ ...userOptions, type: originalType } as NonErrorBarSeriesOptions)\n : userOptions;\n return {\n x: item.point.x,\n y: isXThreshold(item.point.series) ? null : (item.point.y ?? null),\n series,\n errorRanges: item.errorRanges.map((point) => ({\n low: point.options.low ?? 0,\n high: point.options.high ?? 0,\n series: point.series.userOptions as ErrorBarSeriesOptions,\n })),\n };\n };\n const transformSeriesProps = (\n props: CoreChartProps.TooltipPointProps,\n ): CartesianChartProps.TooltipPointRenderProps => ({\n item: transformItem(props.item),\n });\n const transformSlotProps = (\n props: CoreChartProps.TooltipSlotProps,\n ): CartesianChartProps.TooltipSlotRenderProps => ({\n x: props.x,\n items: props.items.map(transformItem),\n });\n return {\n point: tooltip.point ? (props) => tooltip.point!(transformSeriesProps(props)) : undefined,\n header: tooltip.header ? (props) => tooltip.header!(transformSlotProps(props)) : undefined,\n body: tooltip.body ? (props) => tooltip.body!(transformSlotProps(props)) : undefined,\n footer: tooltip.footer ? (props) => tooltip.footer!(transformSlotProps(props)) : undefined,\n };\n };\n\n // Converting x-, and y-threshold series to Highcharts series and plot lines.\n const { series, xPlotLines, yPlotLines } = transformCartesianSeries(props.series, visibleSeriesState);\n\n // Cartesian chart imperative API.\n useImperativeHandle(ref, () => ({\n setVisibleSeries: (visibleSeriesIds) => apiRef.current?.setItemsVisible(visibleSeriesIds),\n showAllSeries: () => apiRef.current?.setItemsVisible(allSeriesIds),\n }));\n\n return (\n <InternalCoreChart\n {...props}\n callback={(api) => (apiRef.current = api)}\n options={{\n chart: {\n inverted: props.inverted,\n },\n plotOptions: {\n series: { stacking: props.stacking },\n },\n series,\n xAxis: castArray(props.xAxis)?.map((xAxisProps) => ({\n ...xAxisProps,\n title: { text: xAxisProps.title },\n plotLines: xPlotLines,\n })),\n yAxis: castArray(props.yAxis)?.map((yAxisProps) => ({\n ...yAxisProps,\n title: { text: yAxisProps.title },\n plotLines: yPlotLines,\n })),\n }}\n tooltip={tooltip}\n getTooltipContent={getTooltipContent}\n visibleItems={props.visibleSeries}\n onVisibleItemsChange={onVisibleSeriesChange}\n className={testClasses.root}\n />\n );\n },\n);\n"]}
|
package/internal/environment.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export var PACKAGE_SOURCE = "chart-components";
|
|
2
|
-
export var PACKAGE_VERSION = "1.0.0 (
|
|
2
|
+
export var PACKAGE_VERSION = "1.0.0 (c4d57e45)";
|
|
3
3
|
export var THEME = "open-source-visual-refresh";
|
|
4
4
|
export var ALWAYS_VISUAL_REFRESH = true;
|
|
5
5
|
export var SYSTEM = "core";
|
package/internal/manifest.json
CHANGED