Skip to content

Commit

Permalink
Export props for components (#4517)
Browse files Browse the repository at this point in the history
Props are now exported for all components down to the dist. This I believe means we can now use `import { EuiComponentNameProps } from @elastic/eui/` without reaching into source.
  • Loading branch information
snide authored Feb 17, 2021
1 parent f0be026 commit 015b7cd
Show file tree
Hide file tree
Showing 84 changed files with 555 additions and 217 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added exports for all EUI component props matching `EuiComponentProps` name pattern. ([#4517](https://github.com/elastic/eui/pull/4517))
- Added `truncate`, `disabled`, and `emphasize` props to `EuiSideNavItem` ([#4488](https://github.com/elastic/eui/pull/4488))
- Added `truncate` prop to `EuiSideNav` ([#4488](https://github.com/elastic/eui/pull/4488))

Expand Down
2 changes: 1 addition & 1 deletion src/components/badge/beta_badge/beta_badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type BadgeProps = {
title?: string;
} & ExclusiveUnion<LabelAsNode, LabelAsString>;

type EuiBetaBadgeProps = CommonProps &
export type EuiBetaBadgeProps = CommonProps &
Omit<HTMLAttributes<HTMLSpanElement>, 'title'> &
BadgeProps;

Expand Down
2 changes: 1 addition & 1 deletion src/components/badge/beta_badge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiBetaBadge } from './beta_badge';
export { EuiBetaBadge, EuiBetaBadgeProps } from './beta_badge';
2 changes: 1 addition & 1 deletion src/components/badge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

export { EuiBadge, EuiBadgeProps } from './badge';

export { EuiBetaBadge } from './beta_badge';
export { EuiBetaBadge, EuiBetaBadgeProps } from './beta_badge';

export { EuiNotificationBadge } from './notification_badge';

Expand Down
5 changes: 4 additions & 1 deletion src/components/badge/notification_badge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
* under the License.
*/

export { EuiNotificationBadge } from './badge_notification';
export {
EuiNotificationBadge,
EuiNotificationBadgeProps,
} from './badge_notification';
6 changes: 3 additions & 3 deletions src/components/bottom_bar/bottom_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const paddingSizeToClassNameMap: {
l: 'euiBottomBar--paddingLarge',
};

interface Props extends CommonProps {
export interface EuiBottomBarProps extends CommonProps {
/**
* Padding applied to the bar. Default is 'm'.
*/
Expand All @@ -59,7 +59,7 @@ interface Props extends CommonProps {
landmarkHeading?: string;
}

export class EuiBottomBar extends Component<Props> {
export class EuiBottomBar extends Component<EuiBottomBarProps> {
static defaultProps = {
paddingSize: 'm',
affordForDisplacement: true,
Expand All @@ -78,7 +78,7 @@ export class EuiBottomBar extends Component<Props> {
}
}

componentDidUpdate(prevProps: Props) {
componentDidUpdate(prevProps: EuiBottomBarProps) {
if (prevProps.affordForDisplacement !== this.props.affordForDisplacement) {
if (this.props.affordForDisplacement) {
// start affording for displacement
Expand Down
2 changes: 1 addition & 1 deletion src/components/bottom_bar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiBottomBar } from './bottom_bar';
export { EuiBottomBar, EuiBottomBarProps } from './bottom_bar';
16 changes: 11 additions & 5 deletions src/components/color_picker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@
*/

export { EuiColorPicker, EuiColorPickerProps } from './color_picker';
export { EuiColorPickerSwatch } from './color_picker_swatch';
export { EuiHue } from './hue';
export { EuiSaturation } from './saturation';
export { EuiColorStops } from './color_stops';
export {
EuiColorPickerSwatch,
EuiColorPickerSwatchProps,
} from './color_picker_swatch';
export { EuiHue, EuiHueProps } from './hue';
export { EuiSaturation, EuiSaturationProps } from './saturation';
export { EuiColorStops, EuiColorStopsProps } from './color_stops';
export {
EuiColorPalettePicker,
EuiColorPalettePickerProps,
EuiColorPalettePickerPaletteProps,
} from './color_palette_picker';

export { EuiColorPaletteDisplay } from './color_palette_display';
export {
EuiColorPaletteDisplay,
EuiColorPaletteDisplayProps,
} from './color_palette_display';
2 changes: 1 addition & 1 deletion src/components/context/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface I18nShape {
const I18nContext: React.Context<I18nShape> = createContext({});
const { Provider: EuiI18nProvider, Consumer: EuiI18nConsumer } = I18nContext;

interface EuiContextProps {
export interface EuiContextProps {
i18n: I18nShape;
/**
* ReactNode to render as this component's content
Expand Down
2 changes: 1 addition & 1 deletion src/components/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiContext, EuiI18nConsumer } from './context';
export { EuiContext, EuiI18nConsumer, EuiContextProps } from './context';
2 changes: 2 additions & 0 deletions src/components/context_menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

export {
EuiContextMenu,
EuiContextMenuProps,
EuiContextMenuPanelDescriptor,
EuiContextMenuPanelItemDescriptor,
} from './context_menu';
Expand All @@ -30,6 +31,7 @@ export {

export {
EuiContextMenuItem,
EuiContextMenuItemProps,
EuiContextMenuItemIcon,
EuiContextMenuItemLayoutAlignment,
} from './context_menu_item';
2 changes: 1 addition & 1 deletion src/components/control_bar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiControlBar } from './control_bar';
export { EuiControlBar, EuiControlBarProps } from './control_bar';
2 changes: 1 addition & 1 deletion src/components/copy/copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { CommonProps } from '../common';
import { copyToClipboard } from '../../services';
import { EuiToolTip, EuiToolTipProps } from '../tool_tip';

interface EuiCopyProps
export interface EuiCopyProps
extends CommonProps,
Partial<Omit<EuiToolTipProps, 'children'>> {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/copy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiCopy } from './copy';
export { EuiCopy, EuiCopyProps } from './copy';
2 changes: 1 addition & 1 deletion src/components/delay_hide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiDelayHide } from './delay_hide';
export { EuiDelayHide, EuiDelayHideProps } from './delay_hide';
2 changes: 1 addition & 1 deletion src/components/delay_render/delay_render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { Component } from 'react';

interface EuiDelayRenderProps {
export interface EuiDelayRenderProps {
delay: number;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/delay_render/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiDelayRender } from './delay_render';
export { EuiDelayRender, EuiDelayRenderProps } from './delay_render';
5 changes: 4 additions & 1 deletion src/components/description_list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
* under the License.
*/

export { EuiDescriptionList } from './description_list';
export {
EuiDescriptionList,
EuiDescriptionListProps,
} from './description_list';

export { EuiDescriptionListTitle } from './description_list_title';

Expand Down
10 changes: 6 additions & 4 deletions src/components/drag_and_drop/drag_drop_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ import {

type EuiDraggingType = string | null;

interface EuiDraggingContext {
export interface EuiDragDropContextProps {
isDraggingType: EuiDraggingType;
}

export const EuiDragDropContextContext = createContext<EuiDraggingContext>({
isDraggingType: null,
});
export const EuiDragDropContextContext = createContext<EuiDragDropContextProps>(
{
isDraggingType: null,
}
);

export const EuiDragDropContext: FunctionComponent<DragDropContextProps> = ({
onBeforeDragStart,
Expand Down
9 changes: 6 additions & 3 deletions src/components/drag_and_drop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
* under the License.
*/

export { EuiDragDropContext } from './drag_drop_context';
export { EuiDraggable } from './draggable';
export { EuiDroppable } from './droppable';
export {
EuiDragDropContext,
EuiDragDropContextProps,
} from './drag_drop_context';
export { EuiDraggable, EuiDraggableProps } from './draggable';
export { EuiDroppable, EuiDroppableProps } from './droppable';
export {
euiDragDropCopy,
euiDragDropMove,
Expand Down
2 changes: 1 addition & 1 deletion src/components/expression/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiExpression } from './expression';
export { EuiExpression, EuiExpressionProps } from './expression';
4 changes: 2 additions & 2 deletions src/components/flex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export {
EuiFlexGroupGutterSize,
} from './flex_group';

export { EuiFlexGrid } from './flex_grid';
export { EuiFlexGrid, EuiFlexGridProps } from './flex_grid';

export { EuiFlexItem } from './flex_item';
export { EuiFlexItem, EuiFlexItemProps } from './flex_item';
2 changes: 1 addition & 1 deletion src/components/focus_trap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiFocusTrap, FocusTarget } from './focus_trap';
export { EuiFocusTrap, EuiFocusTrapProps, FocusTarget } from './focus_trap';
4 changes: 2 additions & 2 deletions src/components/header/header_links/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* under the License.
*/

export { EuiHeaderLink } from './header_link';
export { EuiHeaderLink, EuiHeaderLinkProps } from './header_link';

export { EuiHeaderLinks } from './header_links';
export { EuiHeaderLinks, EuiHeaderLinksProps } from './header_links';
4 changes: 2 additions & 2 deletions src/components/header/header_section/header_section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const sideToClassNameMap: { [side in HeaderSectionSide]: string } = {
right: 'euiHeaderSection--right',
};

type Props = CommonProps &
export type EuiHeaderSectionProps = CommonProps &
HTMLAttributes<HTMLDivElement> & {
side?: HeaderSectionSide;
grow?: boolean;
};

export const EuiHeaderSection: FunctionComponent<Props> = ({
export const EuiHeaderSection: FunctionComponent<EuiHeaderSectionProps> = ({
side = 'left',
children,
className,
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/header_section/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

export { EuiHeaderSection } from './header_section';
export { EuiHeaderSection, EuiHeaderSectionProps } from './header_section';

export {
EuiHeaderSectionItem,
Expand Down
7 changes: 6 additions & 1 deletion src/components/header/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export { EuiHeaderAlert, EuiHeaderAlertProps } from './header_alert';

export { EuiHeaderBreadcrumbs } from './header_breadcrumbs';

export { EuiHeaderLink, EuiHeaderLinks } from './header_links';
export {
EuiHeaderLink,
EuiHeaderLinkProps,
EuiHeaderLinks,
EuiHeaderLinksProps,
} from './header_links';

export { EuiHeaderLogo, EuiHeaderLogoProps } from './header_logo';

Expand Down
2 changes: 1 addition & 1 deletion src/components/highlight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiHighlight } from './highlight';
export { EuiHighlight, EuiHighlightProps } from './highlight';
2 changes: 1 addition & 1 deletion src/components/i18n/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ interface I18nTokensShape<T extends any[]> {
children: (x: Array<T[number]>) => ReactChild;
}

type EuiI18nProps<
export type EuiI18nProps<
T,
DEFAULT extends Renderable<T>,
DEFAULTS extends any[]
Expand Down
2 changes: 1 addition & 1 deletion src/components/i18n/i18n_number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface EuiI18nNumberValuesShape {
children: (x: ReactChild[]) => ReactElement<any>;
}

type EuiI18nNumberProps = ExclusiveUnion<
export type EuiI18nNumberProps = ExclusiveUnion<
EuiI18nNumberValueShape,
EuiI18nNumberValuesShape
>;
Expand Down
4 changes: 2 additions & 2 deletions src/components/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

export { EuiI18n, useEuiI18n } from './i18n';
export { EuiI18nNumber } from './i18n_number';
export { EuiI18n, EuiI18nProps, useEuiI18n } from './i18n';
export { EuiI18nNumber, EuiI18nNumberProps } from './i18n_number';
4 changes: 3 additions & 1 deletion src/components/image/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ const fullScreenIconColorMap: { [color in FullScreenIconColor]: string } = {
dark: 'default',
};

interface EuiImageProps extends CommonProps, HTMLAttributes<HTMLImageElement> {
export interface EuiImageProps
extends CommonProps,
HTMLAttributes<HTMLImageElement> {
/**
* Separate from the caption is a title on the alt tag itself.
* This one is required for accessibility.
Expand Down
2 changes: 1 addition & 1 deletion src/components/image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { EuiImage } from './image';
export { EuiImage, EuiImageProps } from './image';
Loading

0 comments on commit 015b7cd

Please sign in to comment.