Skip to content

Commit

Permalink
fix: remove cycles from the codebase (#2508)
Browse files Browse the repository at this point in the history
  • Loading branch information
maltoze authored Jan 15, 2021
1 parent b92706e commit 3a70cc5
Show file tree
Hide file tree
Showing 31 changed files with 126 additions and 98 deletions.
4 changes: 2 additions & 2 deletions src/babel/__fixtures__/rewrite-imports/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Text } from 'react-native';
import PaperProvider from "react-native-paper/lib/module/core/Provider";
import BottomNavigation from "react-native-paper/lib/module/components/BottomNavigation";
import Button from "react-native-paper/lib/module/components/Button";
import FAB from "react-native-paper/lib/module/components/FAB/FAB";
import Appbar from "react-native-paper/lib/module/components/Appbar/Appbar";
import FAB from "react-native-paper/lib/module/components/FAB";
import Appbar from "react-native-paper/lib/module/components/Appbar";
import * as Colors from "react-native-paper/lib/module/styles/colors";
import { NonExistent, NonExistentSecond as Stuff, Theme } from "react-native-paper/lib/module/index.js";
import { ThemeProvider } from "react-native-paper/lib/module/core/theming";
Expand Down
18 changes: 3 additions & 15 deletions src/components/Appbar/Appbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import * as React from 'react';
import { View, ViewStyle, Platform, StyleSheet, StyleProp } from 'react-native';
import color from 'color';

import {
AppbarContent,
AppbarAction,
AppbarBackAction,
AppbarHeader,
} from './AppbarElements';
import AppbarContent from './AppbarContent';
import AppbarAction from './AppbarAction';
import AppbarBackAction from './AppbarBackAction';
import Surface from '../Surface';
import { withTheme } from '../../core/theming';
import { black, white } from '../../styles/colors';
Expand Down Expand Up @@ -171,15 +168,6 @@ const Appbar = ({ children, dark, style, theme, ...rest }: Props) => {
);
};

// @component ./AppbarContent.tsx
Appbar.Content = AppbarContent;
// @component ./AppbarAction.tsx
Appbar.Action = AppbarAction;
// @component ./AppbarBackAction.tsx
Appbar.BackAction = AppbarBackAction;
// @component ./AppbarHeader.tsx
Appbar.Header = AppbarHeader;

const styles = StyleSheet.create({
appbar: {
height: DEFAULT_APPBAR_HEIGHT,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Appbar/AppbarBackAction.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import type { $Omit } from './../../types';
import { AppbarAction, AppbarBackIcon } from './AppbarElements';
import AppbarAction from './AppbarAction';
import AppbarBackIcon from './AppbarBackIcon';
import type { StyleProp, ViewStyle } from 'react-native';

type Props = $Omit<
Expand Down
6 changes: 0 additions & 6 deletions src/components/Appbar/AppbarElements.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions src/components/Appbar/AppbarHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
ViewStyle,
} from 'react-native';
import overlay from '../../styles/overlay';
import { Appbar } from './AppbarElements';
import { DEFAULT_APPBAR_HEIGHT } from './Appbar';
import { DEFAULT_APPBAR_HEIGHT, Appbar } from './Appbar';
import shadow from '../../styles/shadow';
import { withTheme } from '../../core/theming';
import { APPROX_STATUSBAR_HEIGHT } from '../../constants';
Expand Down
22 changes: 22 additions & 0 deletions src/components/Appbar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import AppbarComponent from './Appbar';
import AppbarContent from './AppbarContent';
import AppbarAction from './AppbarAction';
import AppbarBackAction from './AppbarBackAction';
import AppbarHeader from './AppbarHeader';

const Appbar = Object.assign(
// @component ./Appbar.tsx
AppbarComponent,
{
// @component ./AppbarContent.tsx
Content: AppbarContent,
// @component ./AppbarAction.tsx
Action: AppbarAction,
// @component ./AppbarBackAction.tsx
BackAction: AppbarBackAction,
// @component ./AppbarHeader.tsx
Header: AppbarHeader,
}
);

export default Appbar;
12 changes: 2 additions & 10 deletions src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { Platform } from 'react-native';
import { CheckboxIOS, CheckboxItem, CheckboxAndroid } from './CheckboxElements';
import CheckboxIOS from './CheckboxIOS';
import CheckboxAndroid from './CheckboxAndroid';
import { withTheme } from '../../core/theming';

type Props = {
Expand Down Expand Up @@ -84,15 +85,6 @@ const Checkbox = (props: Props) =>
<CheckboxAndroid {...props} />
);

// @component ./CheckboxItem.tsx
Checkbox.Item = CheckboxItem;

// @component ./CheckboxAndroid.tsx
Checkbox.Android = CheckboxAndroid;

// @component ./CheckboxIOS.tsx
Checkbox.IOS = CheckboxIOS;

export default withTheme(Checkbox);

// @component-docs ignore-next-line
Expand Down
4 changes: 0 additions & 4 deletions src/components/Checkbox/CheckboxElements.tsx

This file was deleted.

4 changes: 3 additions & 1 deletion src/components/Checkbox/CheckboxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
ViewStyle,
} from 'react-native';

import { Checkbox, CheckboxAndroid, CheckboxIOS } from './CheckboxElements';
import Checkbox from './Checkbox';
import CheckboxAndroid from './CheckboxAndroid';
import CheckboxIOS from './CheckboxIOS';
import Text from '../Typography/Text';
import TouchableRipple from '../TouchableRipple/TouchableRipple';
import { withTheme } from '../../core/theming';
Expand Down
19 changes: 19 additions & 0 deletions src/components/Checkbox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import CheckboxComponent from './Checkbox';
import CheckboxItem from './CheckboxItem';
import CheckboxAndroid from './CheckboxAndroid';
import CheckboxIOS from './CheckboxIOS';

const Checkbox = Object.assign(
// @component ./Checkbox.tsx
CheckboxComponent,
{
// @component ./CheckboxItem.tsx
Item: CheckboxItem,
// @component ./CheckboxAndroid.tsx
Android: CheckboxAndroid,
// @component ./CheckboxIOS.tsx
IOS: CheckboxIOS,
}
);

export default Checkbox;
4 changes: 0 additions & 4 deletions src/components/FAB/FAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { withTheme } from '../../core/theming';
import type { $RemoveChildren } from '../../types';
import type { IconSource } from './../Icon';
import type { AccessibilityState } from 'react-native';
import { FABGroup } from './FABElements';

type Props = $RemoveChildren<typeof Surface> & {
/**
Expand Down Expand Up @@ -244,9 +243,6 @@ const FAB = ({
);
};

// @component ./FABGroup.tsx
FAB.Group = FABGroup;

const styles = StyleSheet.create({
container: {
borderRadius: 28,
Expand Down
2 changes: 0 additions & 2 deletions src/components/FAB/FABElements.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/FAB/FABGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ViewStyle,
} from 'react-native';
import color from 'color';
import { FAB } from './FABElements';
import FAB from './FAB';
import Text from '../Typography/Text';
import Card from '../Card/Card';
import { withTheme } from '../../core/theming';
Expand Down
13 changes: 13 additions & 0 deletions src/components/FAB/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import FABComponent from './FAB';
import FABGroup from './FABGroup';

const FAB = Object.assign(
// @component ./FAB.tsx
FABComponent,
{
// @component ./FABGroup.tsx
Group: FABGroup,
}
);

export default FAB;
20 changes: 2 additions & 18 deletions src/components/RadioButton/RadioButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import * as React from 'react';
import { Platform } from 'react-native';
import {
RadioButtonAndroid,
RadioButtonGroup,
RadioButtonIOS,
RadioButtonItem,
} from './RadioButtonElements';
import RadioButtonAndroid from './RadioButtonAndroid';
import RadioButtonIOS from './RadioButtonIOS';
import { withTheme } from '../../core/theming';

export type Props = {
Expand Down Expand Up @@ -102,18 +98,6 @@ const RadioButton = (props: Props) => {
return <Button {...props} />;
};

// @component ./RadioButtonGroup.tsx
RadioButton.Group = RadioButtonGroup;

// @component ./RadioButtonAndroid.tsx
RadioButton.Android = RadioButtonAndroid;

// @component ./RadioButtonIOS.tsx
RadioButton.IOS = RadioButtonIOS;

// @component ./RadioButtonItem.tsx
RadioButton.Item = RadioButtonItem;

export default withTheme(RadioButton);

// @component-docs ignore-next-line
Expand Down
5 changes: 0 additions & 5 deletions src/components/RadioButton/RadioButtonElements.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/RadioButton/RadioButtonItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { withTheme } from '../../core/theming';
import { RadioButtonContext, RadioButtonContextType } from './RadioButtonGroup';
import { handlePress } from './utils';
import TouchableRipple from '../TouchableRipple/TouchableRipple';
import { RadioButton } from './RadioButtonElements';
import RadioButton from './RadioButton';
import Text from '../Typography/Text';
import RadioButtonAndroid from './RadioButtonAndroid';
import RadioButtonIOS from './RadioButtonIOS';
Expand Down
22 changes: 22 additions & 0 deletions src/components/RadioButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import RadioButtonComponent from './RadioButton';
import RadioButtonGroup from './RadioButtonGroup';
import RadioButtonAndroid from './RadioButtonAndroid';
import RadioButtonIOS from './RadioButtonIOS';
import RadioButtonItem from './RadioButtonItem';

const RadioButton = Object.assign(
// @component ./RadioButton.tsx
RadioButtonComponent,
{
// @component ./RadioButtonGroup.tsx
Group: RadioButtonGroup,
// @component ./RadioButtonAndroid.tsx
Android: RadioButtonAndroid,
// @component ./RadioButtonIOS.tsx
IOS: RadioButtonIOS,
// @component ./RadioButtonItem.tsx
Item: RadioButtonItem,
}
);

export default RadioButton;
7 changes: 0 additions & 7 deletions src/components/ToggleButton/ToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import IconButton from '../IconButton';
import { ToggleButtonGroupContext } from './ToggleButtonGroup';
import { black, white } from '../../styles/colors';
import type { IconSource } from '../Icon';
import { ToggleButtonRow, ToggleButtonGroup } from './ToggleButtonElements';

type Props = {
/**
Expand Down Expand Up @@ -154,12 +153,6 @@ const ToggleButton = ({
);
};

// @component ./ToggleButtonGroup.tsx
ToggleButton.Group = ToggleButtonGroup;

// @component ./ToggleButtonRow.tsx
ToggleButton.Row = ToggleButtonRow;

const styles = StyleSheet.create({
content: {
width: 42,
Expand Down
3 changes: 0 additions & 3 deletions src/components/ToggleButton/ToggleButtonElements.tsx

This file was deleted.

7 changes: 4 additions & 3 deletions src/components/ToggleButton/ToggleButtonRow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { StyleSheet, View, StyleProp, ViewStyle } from 'react-native';
import { ToggleButton } from './ToggleButtonElements';
import ToggleButtonGroup from './ToggleButtonGroup';
import ToggleButton from './ToggleButton';

type Props = {
/**
Expand Down Expand Up @@ -51,7 +52,7 @@ const ToggleButtonRow = ({ value, onValueChange, children, style }: Props) => {
const count = React.Children.count(children);

return (
<ToggleButton.Group value={value} onValueChange={onValueChange}>
<ToggleButtonGroup value={value} onValueChange={onValueChange}>
<View style={[styles.row, style]}>
{React.Children.map(children, (child, i) => {
// @ts-ignore
Expand All @@ -74,7 +75,7 @@ const ToggleButtonRow = ({ value, onValueChange, children, style }: Props) => {
return child;
})}
</View>
</ToggleButton.Group>
</ToggleButtonGroup>
);
};

Expand Down
16 changes: 16 additions & 0 deletions src/components/ToggleButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import ToggleButtonComponent from './ToggleButton';
import ToggleButtonGroup from './ToggleButtonGroup';
import ToggleButtonRow from './ToggleButtonRow';

const ToggleButton = Object.assign(
// @component ./ToggleButton.tsx
ToggleButtonComponent,
{
// @component ./ToggleButtonGroup.tsx
Group: ToggleButtonGroup,
// @component ./ToggleButtonRow.tsx
Row: ToggleButtonRow,
}
);

export default ToggleButton;
2 changes: 1 addition & 1 deletion src/components/__tests__/Appbar/Appbar.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Appbar from '../../Appbar/Appbar';
import Appbar from '../../Appbar';
import Searchbar from '../../Searchbar';

describe('Appbar', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/Checkbox/Checkbox.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import renderer from 'react-test-renderer';
import Checkbox from '../../Checkbox/Checkbox';
import Checkbox from '../../Checkbox';

it('renders checked Checkbox with onPress', () => {
const tree = renderer
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/Checkbox/CheckboxItem.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Platform } from 'react-native';
import renderer from 'react-test-renderer';
import Checkbox from '../../Checkbox/Checkbox';
import Checkbox from '../../Checkbox';

it('renders unchecked', () => {
const tree = renderer
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/FAB.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import renderer from 'react-test-renderer';
import FAB from '../FAB/FAB';
import FAB from '../FAB';

it('renders normal FAB', () => {
const tree = renderer.create(<FAB onPress={() => {}} icon="plus" />).toJSON();
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/RadioButton/RadioButton.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { RadioButtonContext } from '../../RadioButton/RadioButtonGroup';
import RadioButton from '../../RadioButton/RadioButton';
import RadioButton from '../../RadioButton';

describe('RadioButton', () => {
afterEach(() => jest.resetModules());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import renderer from 'react-test-renderer';
import RadioButton from '../../RadioButton/RadioButton';
import RadioButton from '../../RadioButton';

describe('RadioButtonGroup', () => {
it('renders properly', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Platform } from 'react-native';
import renderer from 'react-test-renderer';
import RadioButton from '../../RadioButton/RadioButton';
import RadioButton from '../../RadioButton';

it('renders unchecked', () => {
const tree = renderer
Expand Down
Loading

0 comments on commit 3a70cc5

Please sign in to comment.