Skip to content

Commit

Permalink
Rename ResponsiveChartContainerPro
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Jun 6, 2024
1 parent df2e894 commit 5854927
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 151 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, screen, waitFor } from '@mui/internal-test-utils';
import { LicenseInfo } from '@mui/x-license';
import { ResponsiveChartContainer } from './ResponsiveChartContainer';
import { ResponsiveChartContainerPro } from './ResponsiveChartContainerPro';

describe('<ResponsiveChartContainer /> - License', () => {
describe('<ResponsiveChartContainerPro /> - License', () => {
const { render } = createRenderer();

it('should render watermark when the license is missing', async () => {
LicenseInfo.setLicenseKey('');

expect(() =>
render(<ResponsiveChartContainer series={[]} width={100} height={100} />),
render(<ResponsiveChartContainerPro series={[]} width={100} height={100} />),
).toErrorDev(['MUI X: Missing license key.']);

await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,17 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { styled } from '@mui/material/styles';
import { useLicenseVerifier, Watermark } from '@mui/x-license';
import { ChartContainer, ChartContainerProps } from '@mui/x-charts/ChartContainer';
import { useChartContainerDimensions } from './useChartContainerDimensions';
import { ChartContainer } from '@mui/x-charts/ChartContainer';
import { ResponsiveChartContainerProps } from '@mui/x-charts/ResponsiveChartContainer';
import { ResizableContainer, useChartContainerDimensions } from '@mui/x-charts/internals';
import { getReleaseInfo } from '../internals/utils/releaseInfo';

export interface ResponsiveChartContainerProps
extends Omit<ChartContainerProps, 'width' | 'height'> {
/**
* The width of the chart in px. If not defined, it takes the width of the parent element.
*/
width?: number;
/**
* The height of the chart in px. If not defined, it takes the height of the parent element.
*/
height?: number;
}

const ResizableContainer = styled('div', {
name: 'MuiResponsiveChart',
slot: 'Container',
})<{ ownerState: Pick<ResponsiveChartContainerProps, 'width' | 'height'> }>(({ ownerState }) => ({
width: ownerState.width ?? '100%',
height: ownerState.height ?? '100%',
display: 'flex',
position: 'relative',
flexGrow: 1,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
overflow: 'hidden',
'&>svg': {
width: '100%',
height: '100%',
},
}));
export interface ResponsiveChartContainerProProps extends ResponsiveChartContainerProps {}

const releaseInfo = getReleaseInfo();

const ResponsiveChartContainer = React.forwardRef(function ResponsiveChartContainer(
props: ResponsiveChartContainerProps,
const ResponsiveChartContainerPro = React.forwardRef(function ResponsiveChartContainerPro(
props: ResponsiveChartContainerProProps,
ref,
) {
const { width: inWidth, height: inHeight, ...other } = props;
Expand All @@ -58,7 +29,7 @@ const ResponsiveChartContainer = React.forwardRef(function ResponsiveChartContai
);
});

ResponsiveChartContainer.propTypes = {
ResponsiveChartContainerPro.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
Expand Down Expand Up @@ -281,4 +252,4 @@ ResponsiveChartContainer.propTypes = {
),
} as any;

export { ResponsiveChartContainer };
export { ResponsiveChartContainerPro };
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ResponsiveChartContainerPro';
3 changes: 1 addition & 2 deletions packages/x-charts-pro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ export * from '@mui/x-charts/ScatterChart';
export * from '@mui/x-charts/SparkLineChart';
export * from '@mui/x-charts/Gauge';
export * from '@mui/x-charts/ChartsSurface';
export * from '@mui/x-charts/ChartContainer';

export * from './ResponsiveChartContainer';
export * from './ResponsiveChartContainerPro';
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { styled } from '@mui/material/styles';
import type { ResponsiveChartContainerProps } from './ResponsiveChartContainer';

/**
* Wrapping div that take the shape of its parent.
*
* @ignore - do not document.
*/
export const ResizableContainer = styled('div', {
name: 'MuiResponsiveChart',
slot: 'Container',
})<{ ownerState: Pick<ResponsiveChartContainerProps, 'width' | 'height'> }>(({ ownerState }) => ({
width: ownerState.width ?? '100%',
height: ownerState.height ?? '100%',
display: 'flex',
position: 'relative',
flexGrow: 1,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
overflow: 'hidden',
'&>svg': {
width: '100%',
height: '100%',
},
}));
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { styled } from '@mui/material/styles';
import { ChartContainer, ChartContainerProps } from '../ChartContainer';
import { useChartContainerDimensions } from './useChartContainerDimensions';
import { ResizableContainer } from './ResizableContainer';

export interface ResponsiveChartContainerProps
extends Omit<ChartContainerProps, 'width' | 'height'> {
Expand All @@ -16,25 +16,6 @@ export interface ResponsiveChartContainerProps
height?: number;
}

const ResizableContainer = styled('div', {
name: 'MuiResponsiveChart',
slot: 'Container',
})<{ ownerState: Pick<ResponsiveChartContainerProps, 'width' | 'height'> }>(({ ownerState }) => ({
width: ownerState.width ?? '100%',
height: ownerState.height ?? '100%',
display: 'flex',
position: 'relative',
flexGrow: 1,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
overflow: 'hidden',
'&>svg': {
width: '100%',
height: '100%',
},
}));

const ResponsiveChartContainer = React.forwardRef(function ResponsiveChartContainer(
props: ResponsiveChartContainerProps,
ref,
Expand Down
3 changes: 3 additions & 0 deletions packages/x-charts/src/internals/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export * from './configInit';

export * from '../ResponsiveChartContainer/useChartContainerDimensions';
export * from '../ResponsiveChartContainer/ResizableContainer';

0 comments on commit 5854927

Please sign in to comment.