Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

refactor: move superset-ui/chart-composition to core #759

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 0 additions & 28 deletions packages/superset-ui-chart-composition/README.md

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions packages/superset-ui-chart-composition/package.json

This file was deleted.

19 changes: 0 additions & 19 deletions packages/superset-ui-chart-composition/test/tsconfig.json

This file was deleted.

22 changes: 0 additions & 22 deletions packages/superset-ui-chart-composition/tsconfig.json

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions packages/superset-ui-chart/__mocks__/resize-observer-polyfill.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/superset-ui-chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"access": "public"
},
"dependencies": {
"@types/react": "^16.9.43",
"@types/react": "*",
"@types/react-loadable": "^5.4.2",
"@vx/responsive": "^0.0.197",
"@superset-ui/core": "^0.15.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React from 'react';
import { mount } from 'enzyme';
import mockConsole, { RestoreConsole } from 'jest-mock-console';

jest.mock('resize-observer-polyfill');
// @ts-ignore
import { triggerResizeObserver } from 'resize-observer-polyfill';
import ErrorBoundary from 'react-error-boundary';
Expand Down
6 changes: 6 additions & 0 deletions packages/superset-ui-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"@types/d3-time-format": "^2.1.0",
"@types/d3-interpolate": "^1.3.1",
"@types/d3-scale": "^2.1.1",
"@types/react": "*",
"@vx/responsive": "^0.0.197",
"csstype": "^2.6.4",
"d3-interpolate": "^1.4.0",
"d3-scale": "^3.0.0",
"d3-format": "^1.3.2",
Expand All @@ -51,5 +54,8 @@
"fetch-retry": "^4.0.1",
"pretty-ms": "^7.0.0",
"whatwg-fetch": "^3.0.0"
},
"peerDependencies": {
"react": "^16.13.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
import { isDefined } from '@superset-ui/core';
import { isDefined } from '../utils';

function checkNumber(input: unknown): input is number {
return isDefined(input) && typeof input === 'number';
Expand Down
1 change: 1 addition & 0 deletions packages/superset-ui-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ export * from './dimension';
export * from './color';
export * from './style';
export * from './validator';
export * from './chart-composition';
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
interface ResizeObserverEntry {
contentRect: {
height: number;
width: number;
};
}
type ObserveCallback = (entries: ResizeObserverEntry[]) => void;

const allCallbacks: ObserveCallback[] = [];

export default function ResizeObserver(callback: ObserveCallback) {
return {
disconnect() {
allCallbacks.splice(allCallbacks.indexOf(callback), 1);
},
observe() {
if (callback) {
allCallbacks.push(callback);
}
},
};
}

export const DEFAULT_OUTPUT: ResizeObserverEntry[] = [{ contentRect: { height: 300, width: 300 } }];

export function triggerResizeObserver(entries = DEFAULT_OUTPUT) {
allCallbacks.forEach(fn => {
fn(entries);
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { ChartFrame } from '../src';
import { ChartFrame } from '@superset-ui/core/src';

describe('TooltipFrame', () => {
it('renders content that requires smaller space than frame', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/* eslint-disable import/imports-first, import/first */
import React from 'react';
import { mount, shallow } from 'enzyme';

jest.mock('resize-observer-polyfill');
// @ts-ignore
import { triggerResizeObserver } from 'resize-observer-polyfill';
import { promiseTimeout } from '@superset-ui/core';
import { WithLegend } from '../../src';
import { promiseTimeout } from '@superset-ui/core/src';
import { WithLegend } from '@superset-ui/core/src/chart-composition';

let renderChart = jest.fn();
let renderLegend = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { TooltipFrame } from '../../src';
import { TooltipFrame } from '@superset-ui/core/src';

describe('TooltipFrame', () => {
it('sets className', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { TooltipTable } from '../../src';
import { TooltipTable } from '@superset-ui/core/src';

describe('TooltipTable', () => {
it('sets className', () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/superset-ui-core/types/resize-observer-polyfill.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module 'resize-observer-polyfill' {
// eslint-disable-next-line import/prefer-default-export
export function triggerResizeObserver(entries?: ResizeObserverEntry[]): void;
}
2 changes: 1 addition & 1 deletion plugins/legacy-plugin-chart-time-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@superset-ui/chart-controls": "^0.14.3",
"@superset-ui/core": "^0.15.0",
"@types/d3-scale": "^2.0.2",
"@types/react": "^16.9.43",
"@types/react": "*",
"d3-scale": "^3.2.1",
"emotion-theming": "^10.0.27",
"moment": "^2.26.0",
Expand Down
3 changes: 1 addition & 2 deletions plugins/plugin-chart-choropleth-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
},
"dependencies": {
"@superset-ui/chart": "^0.14.0",
"@superset-ui/chart-composition": "^0.14.0",
"@superset-ui/core": "^0.15.0",
"@types/d3-geo": "^1.11.1",
"@types/geojson": "^7946.0.3",
"@types/react": "^16.9.43",
"@types/react": "*",
"@types/topojson-client": "^3.0.0",
"@types/topojson-specification": "^1.0.0",
"@vx/clip-path": "^0.0.197",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { isCompleteFieldDef } from 'encodable';
import { uniqBy } from 'lodash';
import { Tooltip } from '@vx/tooltip';
import { TooltipFrame, TooltipTable } from '@superset-ui/chart-composition';
import { TooltipFrame, TooltipTable } from '@superset-ui/core';
import { ChoroplethMapChannelOutputs, ChoroplethMapEncoder } from './Encoder';

export type MapDataPoint = Omit<ChoroplethMapChannelOutputs, 'tooltip'> & {
Expand Down
3 changes: 0 additions & 3 deletions plugins/plugin-chart-choropleth-map/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
{
"path": "../../packages/superset-ui-chart"
},
{
"path": "../../packages/superset-ui-chart-composition"
},
{
"path": "../../packages/superset-ui-core"
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-chart-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@superset-ui/core": "^0.15.0",
"@types/d3-array": "^2.0.0",
"@types/match-sorter": "^4.0.0",
"@types/react": "^16.9.43",
"@types/react": "*",
"@types/react-table": "^7.0.19",
"d3-array": "^2.4.0",
"match-sorter": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-chart-word-cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@superset-ui/core": "^0.15.0",
"@types/d3-cloud": "^1.2.1",
"@types/d3-scale": "^2.0.2",
"@types/react": "^16.9.43",
"@types/react": "*",
"d3-cloud": "^1.2.5",
"d3-scale": "^3.0.1",
"emotion-theming": "^10.0.27",
Expand Down
1 change: 0 additions & 1 deletion plugins/preset-chart-xy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
},
"dependencies": {
"@superset-ui/chart": "^0.14.0",
"@superset-ui/chart-composition": "^0.14.0",
"@superset-ui/chart-controls": "^0.14.0",
"@superset-ui/core": "^0.15.0",
"@data-ui/theme": "^0.0.84",
Expand Down
3 changes: 1 addition & 2 deletions plugins/preset-chart-xy/src/components/BoxPlot/BoxPlot.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import { BoxPlotSeries, XYChart } from '@data-ui/xy-chart';
import { chartTheme, ChartTheme } from '@data-ui/theme';
import { Margin, Dimension } from '@superset-ui/core';
import { WithLegend } from '@superset-ui/chart-composition';
import { WithLegend, Margin, Dimension } from '@superset-ui/core';
import { Dataset, PlainObject, isFieldDef } from 'encodable';
import DefaultTooltipRenderer from './DefaultTooltipRenderer';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { isDefined } from '@superset-ui/core';
import { TooltipFrame, TooltipTable } from '@superset-ui/chart-composition';
import { isDefined, TooltipFrame, TooltipTable } from '@superset-ui/core';
import { BoxPlotEncoder } from './Encoder';
import { BoxPlotDataRow } from './types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { TooltipFrame, TooltipTable } from '@superset-ui/chart-composition';
import { TooltipFrame, TooltipTable } from '@superset-ui/core';
import { chartTheme } from '@data-ui/theme';
import { TooltipProps } from './Line';

Expand Down
3 changes: 1 addition & 2 deletions plugins/preset-chart-xy/src/components/Line/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {
WithTooltip,
} from '@data-ui/xy-chart';
import { chartTheme } from '@data-ui/theme';
import { Margin, Dimension } from '@superset-ui/core';
import { WithLegend } from '@superset-ui/chart-composition';
import { WithLegend, Margin, Dimension } from '@superset-ui/core';
import { createSelector } from 'reselect';
import { Dataset, PlainObject } from 'encodable';
import DefaultTooltipRenderer from './DefaultTooltipRenderer';
Expand Down