From bdb8432b1e70695603a0fd5daa2fd02957182c26 Mon Sep 17 00:00:00 2001 From: Ben Scott Date: Wed, 15 Jan 2020 16:28:16 -0800 Subject: [PATCH 1/6] Fixup component files to they don't export more than their index --- src/components/ActionMenu/ActionMenu.tsx | 2 +- .../ActionMenu/tests/ActionMenu.test.tsx | 12 ++---- .../Autocomplete/components/ComboBox/index.ts | 2 +- src/components/Avatar/Avatar.tsx | 4 +- src/components/Avatar/tests/Avatar.test.tsx | 5 --- src/components/Badge/Badge.tsx | 6 +-- src/components/Badge/index.ts | 9 +---- src/components/Badge/tests/Badge.test.tsx | 20 +++++----- src/components/Button/Button.tsx | 8 ++-- src/components/Button/tests/Button.test.tsx | 4 +- src/components/Checkbox/Checkbox.tsx | 4 +- src/components/ChoiceList/ChoiceList.tsx | 4 +- .../ChoiceList/tests/ChoiceList.test.tsx | 4 +- src/components/Collapsible/Collapsible.tsx | 2 +- src/components/ColorPicker/ColorPicker.tsx | 6 +-- src/components/DatePicker/DatePicker.tsx | 4 +- .../DescriptionList/DescriptionList.tsx | 2 +- src/components/DisplayText/DisplayText.tsx | 2 +- src/components/DropZone/DropZone.tsx | 2 +- src/components/DropZone/index.ts | 1 - src/components/DropZone/types.ts | 1 - src/components/DropZone/utils/index.ts | 2 +- .../EventListener/EventListener.tsx | 2 +- .../ExceptionList/ExceptionList.tsx | 4 +- src/components/Filters/Filters.tsx | 4 +- .../ConnectedFilterControl.tsx | 4 +- src/components/Frame/Frame.tsx | 6 +-- .../Frame/components/CSSAnimation/index.ts | 2 +- src/components/Image/Image.tsx | 4 +- src/components/Image/tests/Image.test.tsx | 4 +- src/components/List/List.tsx | 2 +- src/components/Modal/Modal.tsx | 2 +- .../Modal/components/Dialog/Dialog.tsx | 2 +- src/components/Page/Page.tsx | 2 +- .../Page/components/Header/Header.tsx | 22 ++++++++-- .../components/Header/tests/Header.test.tsx | 5 +-- src/components/Page/index.ts | 1 - src/components/Page/tests/Page.test.tsx | 3 +- src/components/Page/types.ts | 15 ------- src/components/Popover/Popover.tsx | 12 +++--- .../PopoverOverlay/PopoverOverlay.tsx | 14 +++---- .../components/PopoverOverlay/index.ts | 2 +- src/components/Popover/components/index.ts | 2 +- src/components/Popover/index.ts | 6 +-- .../PositionedOverlay/PositionedOverlay.tsx | 2 +- src/components/ProgressBar/ProgressBar.tsx | 2 +- src/components/RadioButton/RadioButton.tsx | 4 +- src/components/ResourceItem/ResourceItem.tsx | 14 ++----- src/components/ResourceList/ResourceList.tsx | 2 +- .../components/BulkActions/BulkActions.tsx | 6 +-- .../BulkActions/tests/BulkActions.test.tsx | 40 +++++-------------- .../ResourcePicker/ResourcePicker.tsx | 2 +- src/components/Select/Select.tsx | 4 +- src/components/Sheet/Sheet.tsx | 4 +- src/components/Sheet/index.ts | 2 +- src/components/Sheet/tests/Sheet.test.tsx | 20 ++++++---- .../SkeletonDisplayText.tsx | 2 +- .../SkeletonThumbnail/SkeletonThumbnail.tsx | 2 +- src/components/Spinner/Spinner.tsx | 4 +- src/components/Spinner/tests/Spinner.test.tsx | 8 ++-- .../TextContainer/TextContainer.tsx | 2 +- src/components/TextField/TextField.tsx | 4 +- src/components/TextStyle/TextStyle.tsx | 4 +- src/components/TextStyle/index.ts | 2 +- src/components/Thumbnail/Thumbnail.tsx | 2 +- src/components/index.ts | 2 +- 66 files changed, 149 insertions(+), 211 deletions(-) delete mode 100755 src/components/DropZone/types.ts delete mode 100644 src/components/Page/types.ts diff --git a/src/components/ActionMenu/ActionMenu.tsx b/src/components/ActionMenu/ActionMenu.tsx index 8c78276f0ef..33b2c06d103 100644 --- a/src/components/ActionMenu/ActionMenu.tsx +++ b/src/components/ActionMenu/ActionMenu.tsx @@ -106,7 +106,7 @@ export function hasGroupsWithActions(groups: ActionMenuProps['groups'] = []) { : groups.some((group) => group.actions.length > 0); } -export function convertGroupToSection({ +function convertGroupToSection({ title, actions, }: MenuGroupDescriptor): ActionListSection { diff --git a/src/components/ActionMenu/tests/ActionMenu.test.tsx b/src/components/ActionMenu/tests/ActionMenu.test.tsx index 58406b32fe9..b6bdba8c7cd 100644 --- a/src/components/ActionMenu/tests/ActionMenu.test.tsx +++ b/src/components/ActionMenu/tests/ActionMenu.test.tsx @@ -4,11 +4,7 @@ import {mountWithAppProvider, trigger} from 'test-utilities/legacy'; import {MenuGroupDescriptor, ActionListItemDescriptor} from '../../../types'; import {MenuAction, MenuGroup, RollupActions} from '../components'; -import { - ActionMenu, - ActionMenuProps, - convertGroupToSection, -} from '../ActionMenu'; +import {ActionMenu, ActionMenuProps} from '../ActionMenu'; describe('', () => { const mockProps: ActionMenuProps = { @@ -72,9 +68,9 @@ describe('', () => { }); it('renders as `sections` when `rollup` is `true`', () => { - const convertedSections = mockGroups.map((group) => - convertGroupToSection(group), - ); + const convertedSections = mockGroups.map((group) => { + return {title: group.title, items: group.actions}; + }); const wrapper = mountWithAppProvider( , ); diff --git a/src/components/Autocomplete/components/ComboBox/index.ts b/src/components/Autocomplete/components/ComboBox/index.ts index 94540f37e9e..5c3c85073b4 100644 --- a/src/components/Autocomplete/components/ComboBox/index.ts +++ b/src/components/Autocomplete/components/ComboBox/index.ts @@ -1 +1 @@ -export {ComboBox} from './ComboBox'; +export {ComboBox, ComboBoxProps} from './ComboBox'; diff --git a/src/components/Avatar/Avatar.tsx b/src/components/Avatar/Avatar.tsx index 3ff50ef5ccc..c766903f2dd 100644 --- a/src/components/Avatar/Avatar.tsx +++ b/src/components/Avatar/Avatar.tsx @@ -9,7 +9,7 @@ import {Image} from '../Image'; import styles from './Avatar.scss'; import * as avatars from './images'; -export type Size = 'small' | 'medium' | 'large'; +type Size = 'small' | 'medium' | 'large'; enum Status { Pending = 'PENDING', @@ -17,7 +17,7 @@ enum Status { Errored = 'ERRORED', } -export const STYLE_CLASSES = ['one', 'two', 'three', 'four', 'five']; +const STYLE_CLASSES = ['one', 'two', 'three', 'four', 'five']; const AVATAR_IMAGES = Object.keys(avatars).map( // import/namespace does not allow computed values by default // eslint-disable-next-line import/namespace diff --git a/src/components/Avatar/tests/Avatar.test.tsx b/src/components/Avatar/tests/Avatar.test.tsx index 1c6130a809c..7c52c6e6209 100644 --- a/src/components/Avatar/tests/Avatar.test.tsx +++ b/src/components/Avatar/tests/Avatar.test.tsx @@ -3,7 +3,6 @@ import React from 'react'; import {mountWithAppProvider} from 'test-utilities/legacy'; import {mountWithApp} from 'test-utilities'; import {Avatar, Image} from 'components'; -import {STYLE_CLASSES} from '../Avatar'; describe('', () => { describe('intials', () => { @@ -116,10 +115,6 @@ describe('', () => { }); describe('styleClass', () => { - it('defaults to five styles', () => { - expect(STYLE_CLASSES).toHaveLength(5); - }); - it('renders a sixth style when unstableGlobalTheming is false', () => { const avatar = mountWithApp(, { features: {unstableGlobalTheming: false}, diff --git a/src/components/Badge/Badge.tsx b/src/components/Badge/Badge.tsx index 43c9fa68d94..3bca2e7a7f1 100644 --- a/src/components/Badge/Badge.tsx +++ b/src/components/Badge/Badge.tsx @@ -4,9 +4,9 @@ import {useI18n} from '../../utilities/i18n'; import {VisuallyHidden} from '../VisuallyHidden'; import styles from './Badge.scss'; -export type Status = 'success' | 'info' | 'attention' | 'warning' | 'new'; -export type Progress = 'incomplete' | 'partiallyComplete' | 'complete'; -export type Size = 'small' | 'medium'; +type Status = 'success' | 'info' | 'attention' | 'warning' | 'new'; +type Progress = 'incomplete' | 'partiallyComplete' | 'complete'; +type Size = 'small' | 'medium'; export interface BadgeProps { /** The content to display inside the badge. */ diff --git a/src/components/Badge/index.ts b/src/components/Badge/index.ts index 3ab47e3b088..7c73a53a981 100644 --- a/src/components/Badge/index.ts +++ b/src/components/Badge/index.ts @@ -1,8 +1 @@ -export { - Badge, - Progress, - BadgeProps, - Status, - PROGRESS_LABELS, - STATUS_LABELS, -} from './Badge'; +export {Badge, BadgeProps, PROGRESS_LABELS, STATUS_LABELS} from './Badge'; diff --git a/src/components/Badge/tests/Badge.test.tsx b/src/components/Badge/tests/Badge.test.tsx index fa10065b9d8..07d109f4710 100644 --- a/src/components/Badge/tests/Badge.test.tsx +++ b/src/components/Badge/tests/Badge.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; // eslint-disable-next-line no-restricted-imports import {mountWithAppProvider} from 'test-utilities/legacy'; import {VisuallyHidden} from 'components'; -import {Badge, Status, Progress, PROGRESS_LABELS, STATUS_LABELS} from '..'; +import {Badge, PROGRESS_LABELS, STATUS_LABELS} from '..'; describe('', () => { it('renders its children', () => { @@ -12,7 +12,7 @@ describe('', () => { }); it('accepts a status prop and renders a visually hidden label', () => { - Object.keys(STATUS_LABELS).forEach((key: Status) => { + Object.keys(STATUS_LABELS).forEach((key: keyof typeof STATUS_LABELS) => { const badge = mountWithAppProvider(); expect(badge.find(VisuallyHidden).exists()).toBe(true); badge.unmount(); @@ -20,12 +20,14 @@ describe('', () => { }); it('accepts a progress prop and renders a visually hidden label', () => { - Object.keys(PROGRESS_LABELS).forEach((key: Progress) => { - const badge = mountWithAppProvider( - , - ); - expect(badge.find(VisuallyHidden).exists()).toBe(true); - badge.unmount(); - }); + Object.keys(PROGRESS_LABELS).forEach( + (key: keyof typeof PROGRESS_LABELS) => { + const badge = mountWithAppProvider( + , + ); + expect(badge.find(VisuallyHidden).exists()).toBe(true); + badge.unmount(); + }, + ); }); }); diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index bf99f2f6712..3c303c1d143 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -10,11 +10,11 @@ import {IconProps} from '../../types'; import {Spinner} from '../Spinner'; import styles from './Button.scss'; -export type Size = 'slim' | 'medium' | 'large'; +type Size = 'slim' | 'medium' | 'large'; -export type TextAlign = 'left' | 'right' | 'center'; +type TextAlign = 'left' | 'right' | 'center'; -export type IconSource = IconProps['source']; +type IconSource = IconProps['source']; export interface ButtonProps { /** The content to display inside the button */ @@ -274,7 +274,7 @@ export function Button({ ); } -export function IconWrapper({children}: any) { +function IconWrapper({children}: any) { return {children}; } diff --git a/src/components/Button/tests/Button.test.tsx b/src/components/Button/tests/Button.test.tsx index c72a386d1c1..87de955cbf4 100644 --- a/src/components/Button/tests/Button.test.tsx +++ b/src/components/Button/tests/Button.test.tsx @@ -4,7 +4,7 @@ import {PlusMinor} from '@shopify/polaris-icons'; import {mountWithAppProvider, trigger} from 'test-utilities/legacy'; import {mountWithApp} from 'test-utilities'; import {UnstyledLink, Icon, Spinner} from 'components'; -import {Button, IconWrapper} from '../Button'; +import {Button} from '../Button'; describe('