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

Commit

Permalink
refactor: move superset-ui/dimension to core (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud committed Aug 26, 2020
1 parent 9078a87 commit d9cce6c
Show file tree
Hide file tree
Showing 53 changed files with 38 additions and 147 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Current master: https://superset-ui.now.sh/
| [@superset-ui/chart-composition](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-chart-composition) | [![Version](https://img.shields.io/npm/v/@superset-ui/chart-composition.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/chart-composition.svg?style=flat-square) |
| [@superset-ui/color](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-color) | [![Version](https://img.shields.io/npm/v/@superset-ui/color.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/color.svg?style=flat-square) |
| [@superset-ui/core](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-core) | [![Version](https://img.shields.io/npm/v/@superset-ui/core.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/core.svg?style=flat-square) |
| [@superset-ui/dimension](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-dimension) | [![Version](https://img.shields.io/npm/v/@superset-ui/dimension.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/dimension.svg?style=flat-square) |
| [@superset-ui/generator-superset](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-generator-superset) | [![Version](https://img.shields.io/npm/v/@superset-ui/generator-superset.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/generator-superset.svg?style=flat-square) |
| [@superset-ui/number-format](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-number-format) | [![Version](https://img.shields.io/npm/v/@superset-ui/number-format.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/number-format.svg?style=flat-square) |
| [@superset-ui/style](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-style) | [![Version](https://img.shields.io/npm/v/@superset-ui/style.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/style.svg?style=flat-square) |
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"test": "yarn jest",
"test:watch": "yarn lint:fix && yarn jest --watch",
"type": "yarn build --no-babel",
"type:nimbus": "nimbus typescript --build --reference-workspaces",
"prepare-release": "git checkout master && git pull --rebase origin master && yarn install && yarn test",
"prerelease": "yarn build",
"release": "yarn prepare-release && lerna publish && yarn postrelease",
Expand Down
1 change: 0 additions & 1 deletion packages/superset-ui-chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@types/react-loadable": "^5.4.2",
"@vx/responsive": "^0.0.197",
"@superset-ui/core": "^0.15.0",
"@superset-ui/dimension": "^0.14.0",
"prop-types": "^15.6.2",
"react-error-boundary": "^1.2.5",
"react-loadable": "^5.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/superset-ui-chart/src/components/SuperChart.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactNode } from 'react';
import ErrorBoundary, { ErrorBoundaryProps, FallbackProps } from 'react-error-boundary';
import { parseLength, Dimension } from '@superset-ui/dimension';
import { parseLength, Dimension } from '@superset-ui/core';
import { ParentSize } from '@vx/responsive';
import { createSelector } from 'reselect';
import SuperChartCore, { Props as SuperChartCoreProps } from './SuperChartCore';
Expand Down
3 changes: 0 additions & 3 deletions packages/superset-ui-chart/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
"references": [
{
"path": "../superset-ui-core"
},
{
"path": "../superset-ui-dimension"
}
]
}
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 @@ -24,3 +24,4 @@ export * from './connection';
export * from './query';
export * from './number-format';
export * from './time-format';
export * from './dimension';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computeMaxFontSize } from '../src';
import { computeMaxFontSize } from '@superset-ui/core/src';
import { addDummyFill, removeDummyFill, SAMPLE_TEXT } from './getBBoxDummyFill';

describe('computeMaxFontSize(input)', () => {
Expand All @@ -7,11 +7,11 @@ describe('computeMaxFontSize(input)', () => {
afterEach(removeDummyFill);

it('requires either idealFontSize or maxHeight', () => {
expect(() =>
expect(() => {
computeMaxFontSize({
text: SAMPLE_TEXT[0],
}),
).toThrow();
});
}).toThrow();
});
it('computes maximum font size for given maxWidth and maxHeight', () => {
expect(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { promiseTimeout } from '@superset-ui/core';
import { getMultipleTextDimensions } from '../src';
import { getMultipleTextDimensions, promiseTimeout } from '@superset-ui/core/src';
import { addDummyFill, removeDummyFill, SAMPLE_TEXT } from './getBBoxDummyFill';

describe('getMultipleTextDimension(input)', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { promiseTimeout } from '@superset-ui/core';
import { getTextDimension } from '../src';
import { promiseTimeout, getTextDimension } from '@superset-ui/core/src';
import { addDummyFill, removeDummyFill, SAMPLE_TEXT } from './getBBoxDummyFill';

describe('getTextDimension(input)', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mergeMargin } from '../src';
import { mergeMargin } from '@superset-ui/core/src';

describe('mergeMargin(margin1, margin2, mode?)', () => {
it('combines two given margin', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import parseLength from '../src/parseLength';
import { parseLength } from '@superset-ui/core/src';

describe('parseLength(input)', () => {
it('handles string "auto"', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LazyFactory from '../../src/svg/LazyFactory';
import LazyFactory from '@superset-ui/core/src/dimension/svg/LazyFactory';

describe('LazyFactory', () => {
describe('createInContainer()', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import getBBoxCeil from '../../src/svg/getBBoxCeil';
import createTextNode from '../../src/svg/createTextNode';
import getBBoxCeil from '@superset-ui/core/src/dimension/svg/getBBoxCeil';
import createTextNode from '@superset-ui/core/src/dimension/svg/createTextNode';

describe('getBBoxCeil(node, defaultDimension)', () => {
describe('returns default dimension if getBBox() is not available', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import updateTextNode from '../../src/svg/updateTextNode';
import createTextNode from '../../src/svg/createTextNode';
import updateTextNode from '@superset-ui/core/src/dimension/svg/updateTextNode';
import createTextNode from '@superset-ui/core/src/dimension/svg/createTextNode';

describe('updateTextNode(node, options)', () => {
it('handles empty options', () => {
Expand Down
23 changes: 0 additions & 23 deletions packages/superset-ui-dimension/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions packages/superset-ui-dimension/package.json

This file was deleted.

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

This file was deleted.

18 changes: 0 additions & 18 deletions packages/superset-ui-dimension/tsconfig.json

This file was deleted.

1 change: 0 additions & 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,6 @@
"@superset-ui/chart-controls": "^0.14.3",
"@superset-ui/color": "^0.14.0",
"@superset-ui/core": "^0.15.0",
"@superset-ui/dimension": "^0.14.0",
"@superset-ui/style": "^0.14.0",
"@superset-ui/validator": "^0.14.0",
"@types/d3-scale": "^2.0.2",
Expand Down
4 changes: 1 addition & 3 deletions plugins/legacy-plugin-chart-time-table/src/SparklineCell.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/forbid-prop-types */
/* eslint-disable class-methods-use-this */
/**
* Licensed to the Apache Software Foundation (ASF) under one
Expand Down Expand Up @@ -27,8 +26,7 @@ import {
VerticalReferenceLine,
WithTooltip,
} from '@data-ui/sparkline';
import { formatNumber } from '@superset-ui/core';
import { getTextDimension } from '@superset-ui/dimension';
import { getTextDimension, formatNumber } from '@superset-ui/core';

interface Props {
ariaLabel: string;
Expand Down
3 changes: 0 additions & 3 deletions plugins/legacy-plugin-chart-time-table/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
{
"path": "../../packages/superset-ui-core"
},
{
"path": "../../packages/superset-ui-dimension"
},
{
"path": "../../packages/superset-ui-style"
},
Expand Down
1 change: 0 additions & 1 deletion plugins/legacy-preset-chart-big-number/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@superset-ui/chart-controls": "^0.14.0",
"@superset-ui/color": "^0.14.0",
"@superset-ui/core": "^0.15.0",
"@superset-ui/dimension": "^0.14.0",
"@superset-ui/style": "^0.14.0",
"@types/d3-color": "^1.2.2",
"@types/shortid": "^0.0.29",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import {
NumberFormatter,
smartDateVerboseFormatter,
TimeFormatter,
computeMaxFontSize,
} from '@superset-ui/core';
import { XYChart, AreaSeries, CrossHair, LinearGradient } from '@data-ui/xy-chart';
import { BRAND_COLOR } from '@superset-ui/color';
import { computeMaxFontSize } from '@superset-ui/dimension';

import styled from '@superset-ui/style';

Expand Down
3 changes: 0 additions & 3 deletions plugins/legacy-preset-chart-big-number/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
{
"path": "../../packages/superset-ui-core"
},
{
"path": "../../packages/superset-ui-dimension"
},
{
"path": "../../packages/superset-ui-style"
}
Expand Down
1 change: 0 additions & 1 deletion plugins/legacy-preset-chart-nvd3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@superset-ui/chart-controls": "^0.14.0",
"@superset-ui/color": "^0.14.0",
"@superset-ui/core": "^0.15.0",
"@superset-ui/dimension": "^0.14.0",
"@superset-ui/style": "^0.14.20",
"@superset-ui/validator": "^0.14.0",
"d3": "^3.5.17",
Expand Down
3 changes: 0 additions & 3 deletions plugins/legacy-preset-chart-nvd3/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
{
"path": "../../packages/superset-ui-core"
},
{
"path": "../../packages/superset-ui-dimension"
},
{
"path": "../../packages/superset-ui-style"
},
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 @@ -34,7 +34,6 @@
"@superset-ui/chart-controls": "^0.14.0",
"@superset-ui/color": "^0.14.0",
"@superset-ui/core": "^0.15.0",
"@superset-ui/dimension": "^0.14.0",
"@data-ui/theme": "^0.0.84",
"@data-ui/xy-chart": "^0.0.84",
"@vx/axis": "^0.0.198",
Expand Down
6 changes: 3 additions & 3 deletions plugins/preset-chart-xy/src/components/BoxPlot/BoxPlot.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +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/dimension';
import { Margin, Dimension } from '@superset-ui/core';
import { WithLegend } from '@superset-ui/chart-composition';
import { Dataset, PlainObject, isFieldDef } from 'encodable';
import DefaultTooltipRenderer from './DefaultTooltipRenderer';
Expand Down Expand Up @@ -85,9 +85,9 @@ export default class BoxPlot extends React.PureComponent<Props> {
<TooltipRenderer datum={datum} color={color} encoder={encoder} />
)}
theme={theme}
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
xScale={convertScaleToDataUIScale(channels.x.definition.scale as any)}
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
yScale={convertScaleToDataUIScale(channels.y.definition.scale as any)}
>
{layout.renderXAxis()}
Expand Down
6 changes: 3 additions & 3 deletions plugins/preset-chart-xy/src/components/Line/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
WithTooltip,
} from '@data-ui/xy-chart';
import { chartTheme } from '@data-ui/theme';
import { Margin, Dimension } from '@superset-ui/dimension';
import { Margin, Dimension } from '@superset-ui/core';
import { WithLegend } from '@superset-ui/chart-composition';
import { createSelector } from 'reselect';
import { Dataset, PlainObject } from 'encodable';
Expand Down Expand Up @@ -240,9 +240,9 @@ export default class LineChart extends PureComponent<Props> {
renderTooltip={null}
theme={theme}
tooltipData={tooltipData}
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
xScale={convertScaleToDataUIScale(channels.x.definition.scale as any)}
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
yScale={convertScaleToDataUIScale(channels.y.definition.scale as any)}
onMouseMove={onMouseMove}
onMouseLeave={onMouseLeave}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import { XYChart, PointSeries } from '@data-ui/xy-chart';
import { chartTheme, ChartTheme } from '@data-ui/theme';
import { Margin, Dimension } from '@superset-ui/dimension';
import { Margin, Dimension } from '@superset-ui/core';
import { WithLegend } from '@superset-ui/chart-composition';
import { isFieldDef, Dataset, PlainObject } from 'encodable';

Expand Down
2 changes: 1 addition & 1 deletion plugins/preset-chart-xy/src/utils/XYChartLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactNode, CSSProperties } from 'react';
import { XAxis, YAxis } from '@data-ui/xy-chart';
import { Margin, mergeMargin, Dimension } from '@superset-ui/dimension';
import { Margin, mergeMargin, Dimension } from '@superset-ui/core';
import { ChartFrame } from '@superset-ui/chart-composition';
import { ChannelEncoder, PlainObject, Value, XFieldDef, YFieldDef } from 'encodable';
import createTickComponent from './createTickComponent';
Expand Down
2 changes: 1 addition & 1 deletion plugins/preset-chart-xy/src/utils/computeAxisLayout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CSSProperties } from 'react';
import { getTextDimension, Margin, Dimension } from '@superset-ui/dimension';
import { getTextDimension, Margin, Dimension } from '@superset-ui/core';
import { AxisOrient, ChannelDef, Value } from 'encodable';

import ChannelEncoderAxis from 'encodable/lib/encoders/ChannelEncoderAxis';
Expand Down
2 changes: 1 addition & 1 deletion plugins/preset-chart-xy/src/utils/createMarginSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSelector } from 'reselect';
import { Margin } from '@superset-ui/dimension';
import { Margin } from '@superset-ui/core';

export const DEFAULT_MARGIN = { bottom: 16, left: 16, right: 16, top: 16 };

Expand Down
2 changes: 1 addition & 1 deletion plugins/preset-chart-xy/src/utils/createTickComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { CSSProperties } from 'react';
import { Dimension } from '@superset-ui/dimension';
import { Dimension } from '@superset-ui/core';
import { AxisLayout } from './computeAxisLayout';

export default function createTickComponent({
Expand Down
3 changes: 0 additions & 3 deletions plugins/preset-chart-xy/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
},
{
"path": "../../packages/superset-ui-core"
},
{
"path": "../../packages/superset-ui-dimension"
}
]
}
2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ if (shouldRunTyping) {
// only run tsc for packages with ts files
scope = getPackages(glob, true);
run(`lerna exec --stream --concurrency 3 --scope ${scope} \
-- tsc --build`);
-- ../../scripts/tsc.sh --build`);
}
Loading

0 comments on commit d9cce6c

Please sign in to comment.