diff --git a/UNRELEASED.md b/UNRELEASED.md index 023cfe018af..b4ee38c35bb 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -15,5 +15,6 @@ ### Code quality - Converted `/tests/build.test.js` to TypeScript ([#2617](https://github.com/Shopify/polaris-react/pull/2617)) +- Use `export *` to rexport component content in component indexs and subcomponent listings ([#2625](https://github.com/Shopify/polaris-react/pull/2625)) ### Deprecations diff --git a/src/components/AccountConnection/index.ts b/src/components/AccountConnection/index.ts index 864745032b4..1e2b0e3adfa 100644 --- a/src/components/AccountConnection/index.ts +++ b/src/components/AccountConnection/index.ts @@ -1 +1 @@ -export {AccountConnection, AccountConnectionProps} from './AccountConnection'; +export * from './AccountConnection'; diff --git a/src/components/ActionList/components/Item/index.ts b/src/components/ActionList/components/Item/index.ts index e158f53cc0d..c924835a042 100644 --- a/src/components/ActionList/components/Item/index.ts +++ b/src/components/ActionList/components/Item/index.ts @@ -1 +1 @@ -export {Item, ItemProps} from './Item'; +export * from './Item'; diff --git a/src/components/ActionList/components/Section/index.ts b/src/components/ActionList/components/Section/index.ts index 344c319971d..b524e0f3c49 100644 --- a/src/components/ActionList/components/Section/index.ts +++ b/src/components/ActionList/components/Section/index.ts @@ -1 +1 @@ -export {Section, SectionProps} from './Section'; +export * from './Section'; diff --git a/src/components/ActionList/components/index.ts b/src/components/ActionList/components/index.ts index 029ec98e8df..1f6e50145f3 100644 --- a/src/components/ActionList/components/index.ts +++ b/src/components/ActionList/components/index.ts @@ -1,3 +1,3 @@ -export {Item, ItemProps} from './Item'; +export * from './Item'; -export {Section, SectionProps} from './Section'; +export * from './Section'; diff --git a/src/components/ActionList/index.ts b/src/components/ActionList/index.ts index 28da31ede9b..cb756037c18 100644 --- a/src/components/ActionList/index.ts +++ b/src/components/ActionList/index.ts @@ -1 +1 @@ -export {ActionList, ActionListProps} from './ActionList'; +export * from './ActionList'; 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/components/MenuAction/index.ts b/src/components/ActionMenu/components/MenuAction/index.ts index e59101fa10c..9f93c3233c3 100644 --- a/src/components/ActionMenu/components/MenuAction/index.ts +++ b/src/components/ActionMenu/components/MenuAction/index.ts @@ -1 +1 @@ -export {MenuAction, MenuActionProps} from './MenuAction'; +export * from './MenuAction'; diff --git a/src/components/ActionMenu/components/MenuGroup/index.ts b/src/components/ActionMenu/components/MenuGroup/index.ts index abe8f075c8d..b15a373f461 100644 --- a/src/components/ActionMenu/components/MenuGroup/index.ts +++ b/src/components/ActionMenu/components/MenuGroup/index.ts @@ -1 +1 @@ -export {MenuGroup, MenuGroupProps} from './MenuGroup'; +export * from './MenuGroup'; diff --git a/src/components/ActionMenu/components/RollupActions/index.ts b/src/components/ActionMenu/components/RollupActions/index.ts index 483ffad2aa4..3f3a3a489a7 100644 --- a/src/components/ActionMenu/components/RollupActions/index.ts +++ b/src/components/ActionMenu/components/RollupActions/index.ts @@ -1 +1 @@ -export {RollupActions, RollupActionsProps} from './RollupActions'; +export * from './RollupActions'; diff --git a/src/components/ActionMenu/components/index.ts b/src/components/ActionMenu/components/index.ts index f55c125f03d..e9eefe7dc26 100644 --- a/src/components/ActionMenu/components/index.ts +++ b/src/components/ActionMenu/components/index.ts @@ -1,5 +1,5 @@ -export {MenuAction, MenuActionProps} from './MenuAction'; +export * from './MenuAction'; -export {MenuGroup, MenuGroupProps} from './MenuGroup'; +export * from './MenuGroup'; -export {RollupActions, RollupActionsProps} from './RollupActions'; +export * from './RollupActions'; diff --git a/src/components/ActionMenu/index.ts b/src/components/ActionMenu/index.ts index 127524de4c7..ef0c9807a59 100644 --- a/src/components/ActionMenu/index.ts +++ b/src/components/ActionMenu/index.ts @@ -1 +1 @@ -export {ActionMenu, ActionMenuProps, hasGroupsWithActions} from './ActionMenu'; +export * from './ActionMenu'; 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/AfterInitialMount/index.ts b/src/components/AfterInitialMount/index.ts index 561c9c775d0..3f90305fb1c 100644 --- a/src/components/AfterInitialMount/index.ts +++ b/src/components/AfterInitialMount/index.ts @@ -1 +1 @@ -export {AfterInitialMount} from './AfterInitialMount'; +export * from './AfterInitialMount'; diff --git a/src/components/AppProvider/index.ts b/src/components/AppProvider/index.ts index 020b20af464..bd2c0cdccb2 100644 --- a/src/components/AppProvider/index.ts +++ b/src/components/AppProvider/index.ts @@ -1 +1 @@ -export {AppProvider, AppProviderProps} from './AppProvider'; +export * from './AppProvider'; diff --git a/src/components/Autocomplete/components/ComboBox/ComboBox.tsx b/src/components/Autocomplete/components/ComboBox/ComboBox.tsx index d38a79f0646..ccead1d7738 100644 --- a/src/components/Autocomplete/components/ComboBox/ComboBox.tsx +++ b/src/components/Autocomplete/components/ComboBox/ComboBox.tsx @@ -23,7 +23,7 @@ interface State { popoverWasActive: boolean; } -export interface ComboBoxProps { +interface ComboBoxProps { /** A unique identifier for the ComboBox */ id?: string; /** Collection of options to be listed */ diff --git a/src/components/Autocomplete/components/ComboBox/index.ts b/src/components/Autocomplete/components/ComboBox/index.ts index 94540f37e9e..d122f03ba63 100644 --- a/src/components/Autocomplete/components/ComboBox/index.ts +++ b/src/components/Autocomplete/components/ComboBox/index.ts @@ -1 +1 @@ -export {ComboBox} from './ComboBox'; +export * from './ComboBox'; diff --git a/src/components/Autocomplete/components/TextField/index.ts b/src/components/Autocomplete/components/TextField/index.ts index 35e9e6ed312..665fa3cb54f 100644 --- a/src/components/Autocomplete/components/TextField/index.ts +++ b/src/components/Autocomplete/components/TextField/index.ts @@ -1 +1 @@ -export {TextField} from './TextField'; +export * from './TextField'; diff --git a/src/components/Autocomplete/components/index.ts b/src/components/Autocomplete/components/index.ts index 8a65d0fe030..c8e78f10ae4 100644 --- a/src/components/Autocomplete/components/index.ts +++ b/src/components/Autocomplete/components/index.ts @@ -1,3 +1,3 @@ -export {ComboBox} from './ComboBox'; +export * from './ComboBox'; -export {TextField} from './TextField'; +export * from './TextField'; diff --git a/src/components/Autocomplete/index.ts b/src/components/Autocomplete/index.ts index e9a10de0eb3..a796c54c60e 100644 --- a/src/components/Autocomplete/index.ts +++ b/src/components/Autocomplete/index.ts @@ -1 +1 @@ -export {Autocomplete, AutocompleteProps} from './Autocomplete'; +export * from './Autocomplete'; 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/index.ts b/src/components/Avatar/index.ts index 2822843f0cf..27700fe3f37 100644 --- a/src/components/Avatar/index.ts +++ b/src/components/Avatar/index.ts @@ -1 +1 @@ -export {Avatar, AvatarProps} from './Avatar'; +export * from './Avatar'; 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/Backdrop/index.ts b/src/components/Backdrop/index.ts index 4161d9da33f..b4c58db120a 100644 --- a/src/components/Backdrop/index.ts +++ b/src/components/Backdrop/index.ts @@ -1 +1 @@ -export {Backdrop, BackdropProps} from './Backdrop'; +export * from './Backdrop'; 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..9c8edca28a4 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 * 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/Banner/index.ts b/src/components/Banner/index.ts index f5404b5b4d7..bc95f09d62a 100644 --- a/src/components/Banner/index.ts +++ b/src/components/Banner/index.ts @@ -1 +1 @@ -export {Banner, BannerProps, BannerStatus} from './Banner'; +export * from './Banner'; diff --git a/src/components/Breadcrumbs/index.ts b/src/components/Breadcrumbs/index.ts index 7a663c9d3d9..ce977548b14 100644 --- a/src/components/Breadcrumbs/index.ts +++ b/src/components/Breadcrumbs/index.ts @@ -1 +1 @@ -export {Breadcrumbs, BreadcrumbsProps} from './Breadcrumbs'; +export * from './Breadcrumbs'; 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('