Skip to content

Commit 5347d78

Browse files
pan-kotjperals
andauthored
chore: Exposes internal dependencies for chart components (#3333)
Co-authored-by: Joan Perals <[email protected]>
1 parent dddd3f5 commit 5347d78

File tree

40 files changed

+294
-117
lines changed

40 files changed

+294
-117
lines changed

build-tools/tasks/package-json.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ function getComponentsExports() {
2323
'./contexts/form-field': './contexts/form-field.js',
2424
// Public internal components
2525
'./internal/tooltip-do-not-use': './internal/tooltip-do-not-use/index.js',
26+
'./internal/do-not-use/chart-filter': './internal/do-not-use/chart-filter.js',
27+
'./internal/do-not-use/chart-tooltip': './internal/do-not-use/chart-tooltip.js',
28+
'./internal/do-not-use/expandable-section': './internal/do-not-use/expandable-section.js',
29+
'./internal/do-not-use/i18n': './internal/do-not-use/i18n.js',
30+
'./internal/do-not-use/tooltip': './internal/do-not-use/tooltip.js',
2631
'./internal/widget-exports': './internal/widget-exports.js',
2732
'./test-utils/dom/internal/tooltip': './test-utils/dom/internal/tooltip.js',
2833
'./test-utils/selectors/internal/tooltip': './test-utils/selectors/internal/tooltip.js',
34+
'./test-utils/dom/internal/chart-tooltip': './test-utils/dom/internal/chart-tooltip.js',
35+
'./test-utils/selectors/internal/chart-tooltip': './test-utils/selectors/internal/chart-tooltip.js',
2936
};
3037
let components = listPublicItems('src');
3138

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
{
165165
"path": "lib/components/internal/widget-exports.js",
166166
"brotli": false,
167-
"limit": "755 kB",
167+
"limit": "764 kB",
168168
"ignore": "react-dom"
169169
}
170170
],

src/__tests__/snapshot-tests/__snapshots__/test-utils-selectors.test.tsx.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ exports[`test-utils selectors 1`] = `
350350
"awsui_application_1fcus",
351351
"awsui_axis-label--x_f0fot",
352352
"awsui_axis-label--y_f0fot",
353+
"awsui_body_dgs8z",
353354
"awsui_button-trigger_18eso",
354355
"awsui_button_m5h9f",
355356
"awsui_chart-filter_1px7g",
@@ -360,8 +361,10 @@ exports[`test-utils selectors 1`] = `
360361
"awsui_dropdown_qwoo0",
361362
"awsui_filter-container_z5mul",
362363
"awsui_filtering-match-highlight_1p2cx",
364+
"awsui_footer_dgs8z",
363365
"awsui_handle_sdha6",
364366
"awsui_has-background_15o6u",
367+
"awsui_header_dgs8z",
365368
"awsui_highlighted_15o6u",
366369
"awsui_inner-list-item_10ipo",
367370
"awsui_key_10ipo",

src/area-chart/elements/area-chart-filter.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import React, { memo } from 'react';
44

55
import ChartFilter from '../../internal/components/chart-filter';
6+
import ChartSeriesMarker from '../../internal/components/chart-series-marker';
67
import { AreaChartProps } from '../interfaces';
78
import { ChartModel } from '../model';
89

@@ -21,7 +22,11 @@ function AreaChartFilter<T extends AreaChartProps.DataTypes>({
2122
}) {
2223
const filterItems = model.allSeries.map(s => {
2324
const { title, color, markerType } = model.getInternalSeries(s);
24-
return { label: title, color, type: markerType, datum: s };
25+
return {
26+
label: title,
27+
marker: <ChartSeriesMarker type={markerType} color={color} />,
28+
datum: s,
29+
};
2530
});
2631

2732
return (

src/area-chart/elements/area-chart-legend.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import React, { memo, useMemo } from 'react';
44

55
import ChartLegend from '../../internal/components/chart-legend';
6+
import ChartSeriesMarker from '../../internal/components/chart-series-marker';
67
import { useSelector } from '../async-store';
78
import { AreaChartProps } from '../interfaces';
89
import { ChartModel } from '../model';
@@ -24,7 +25,7 @@ function AreaChartLegend<T extends AreaChartProps.DataTypes>({
2425
() =>
2526
model.series.map(s => {
2627
const { title, color, markerType } = model.getInternalSeries(s);
27-
return { label: title, color, type: markerType, datum: s };
28+
return { label: title, marker: <ChartSeriesMarker color={color} type={markerType} />, datum: s };
2829
}),
2930
[model]
3031
);

src/area-chart/elements/chart-popover.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import React from 'react';
44

55
import ChartPopover from '../../internal/components/chart-popover';
6-
import ChartPopoverFooter from '../../internal/components/chart-popover-footer';
76
import ChartSeriesDetails from '../../internal/components/chart-series-details';
87
import { AreaChartProps } from '../interfaces';
98
import { ChartModel } from '../model';
@@ -47,11 +46,11 @@ export default function AreaChartPopover<T extends AreaChartProps.DataTypes>({
4746
dismissAriaLabel={dismissAriaLabel}
4847
size={size}
4948
onBlur={onBlur}
49+
footer={footer}
5050
>
5151
<ChartSeriesDetails details={highlightDetails.seriesDetails} />
5252
<div className={styles['popover-divider']} />
5353
<ChartSeriesDetails details={highlightDetails.totalDetails} />
54-
{footer && <ChartPopoverFooter>{footer}</ChartPopoverFooter>}
5554
</ChartPopover>
5655
);
5756
}

src/expandable-section/internal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { CSSTransition } from 'react-transition-group';
55
import clsx from 'clsx';
66

77
import { getBaseProps } from '../internal/base-component';
8+
import { screenReaderTextClass } from '../internal/components/chart-series-details/series-details-text';
89
import { fireNonCancelableEvent } from '../internal/events';
910
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
1011
import { useControllable } from '../internal/hooks/use-controllable';
@@ -18,7 +19,7 @@ import { variantSupportsDescription } from './utils';
1819
import analyticsSelectors from './analytics-metadata/styles.css.js';
1920
import styles from './styles.css.js';
2021

21-
type InternalExpandableSectionProps = Omit<ExpandableSectionProps, 'variant'> &
22+
export type InternalExpandableSectionProps = Omit<ExpandableSectionProps, 'variant'> &
2223
InternalBaseComponentProps & {
2324
variant?: InternalVariant;
2425
__injectAnalyticsComponentMetadata?: boolean;
@@ -109,7 +110,7 @@ export default function InternalExpandableSection({
109110
<ExpandableSectionHeader
110111
id={triggerControlId}
111112
descriptionId={descriptionId}
112-
className={clsx(styles.header, styles[`header-${baseVariant}`])}
113+
className={clsx(styles.header, styles[`header-${baseVariant}`], screenReaderTextClass)}
113114
variant={baseVariant}
114115
expanded={!!expanded}
115116
header={header}

src/internal/components/chart-filter/__tests__/chart-filter.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import tokenGroupStyles from '../../../../../lib/components/token-group/styles.s
1111
const datum0 = {};
1212
const datum1 = {};
1313

14-
const series = [
15-
{ label: 'Chocolate', color: 'chocolate', type: 'line', datum: datum0 },
16-
{ label: 'Apples', color: 'red', type: 'rectangle', datum: datum1 },
17-
] as const;
14+
const series: ChartFilterProps<any>['series'] = [
15+
{ label: 'Chocolate', marker: <div />, datum: datum0 },
16+
{ label: 'Apples', marker: <div />, datum: datum1 },
17+
];
1818

1919
const i18nStrings = {
2020
filterLabel: 'Filter displayed data',

src/internal/components/chart-filter/__tests__/i18n.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import React from 'react';
44
import { render } from '@testing-library/react';
55

66
import TestI18nProvider from '../../../../../lib/components/i18n/testing';
7-
import ChartFilter from '../../../../../lib/components/internal/components/chart-filter';
7+
import ChartFilter, { ChartFilterProps } from '../../../../../lib/components/internal/components/chart-filter';
88
import createWrapper from '../../../../../lib/components/test-utils/dom';
99

1010
const datum0 = {};
1111
const datum1 = {};
1212

13-
const series = [
14-
{ label: 'Chocolate', color: 'chocolate', type: 'line', datum: datum0 },
15-
{ label: 'Apples', color: 'red', type: 'rectangle', datum: datum1 },
16-
] as const;
13+
const series: ChartFilterProps<any>['series'] = [
14+
{ label: 'Chocolate', marker: <div />, datum: datum0 },
15+
{ label: 'Apples', marker: <div />, datum: datum1 },
16+
];
1717

1818
const defaultProps = {
1919
series,

src/internal/components/chart-filter/index.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { MultiselectProps } from '../../../multiselect/interfaces';
99
import InternalMultiselect from '../../../multiselect/internal';
1010
import { BaseComponentProps, getBaseProps } from '../../base-component';
1111
import { NonCancelableEventHandler } from '../../events';
12-
import SeriesMarker, { ChartSeriesMarkerType } from '../chart-series-marker';
1312

1413
import styles from './styles.css.js';
1514

@@ -21,8 +20,7 @@ interface I18nStrings {
2120

2221
interface ChartFilterItem<T> {
2322
label: string;
24-
color: string;
25-
type: ChartSeriesMarkerType;
23+
marker: React.ReactNode;
2624
datum: T;
2725
}
2826

@@ -44,11 +42,7 @@ function ChartFilter<T>({ series, i18nStrings, selectedSeries, onChange, ...rest
4442
label: d.label,
4543
value: '' + i,
4644
datum: d.datum,
47-
__customIcon: (
48-
<span className={styles['custom-icon-wrapper']}>
49-
<SeriesMarker color={d.color} type={d.type} />
50-
</span>
51-
),
45+
__customIcon: <span className={styles['custom-icon-wrapper']}>{d.marker}</span>,
5246
}));
5347

5448
const selectedOptions = defaultOptions.filter(option => selectedSeries?.indexOf(option.datum) !== -1);

0 commit comments

Comments
 (0)