Skip to content

Commit db47ea9

Browse files
committed
Align vis owned file to use PropsWithChildren and not pollute props
1 parent 604f507 commit db47ea9

8 files changed

Lines changed: 22 additions & 34 deletions

File tree

packages/kbn-dom-drag-drop/src/drop_overlay_wrapper.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Side Public License, v 1.
77
*/
88

9-
import React from 'react';
9+
import React, { PropsWithChildren } from 'react';
1010
import classnames from 'classnames';
1111

1212
/**
@@ -16,7 +16,6 @@ export interface DropOverlayWrapperProps {
1616
isVisible: boolean;
1717
className?: string;
1818
overlayProps?: object;
19-
children: React.ReactNode;
2019
}
2120

2221
/**
@@ -28,7 +27,7 @@ export interface DropOverlayWrapperProps {
2827
* @param otherProps
2928
* @constructor
3029
*/
31-
export const DropOverlayWrapper: React.FC<DropOverlayWrapperProps> = ({
30+
export const DropOverlayWrapper: React.FC<PropsWithChildren<DropOverlayWrapperProps>> = ({
3231
isVisible,
3332
children,
3433
overlayProps,

src/plugins/chart_expressions/expression_partition_vis/public/__stories__/mosaic_vis_renderer.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Side Public License, v 1.
77
*/
88

9-
import React, { FC } from 'react';
9+
import React, { FC, PropsWithChildren } from 'react';
1010
import { ComponentStory } from '@storybook/react';
1111
import { Render } from '@kbn/presentation-util-plugin/public/__stories__';
1212
import { getPartitionVisRenderer } from '../expression_renderers';
@@ -22,12 +22,11 @@ const containerSize = {
2222
const PartitionVisRenderer = () => getPartitionVisRenderer({ getStartDeps });
2323

2424
type Props = {
25-
children: React.ReactNode;
2625
visType: PartitionChartProps['visType'];
2726
syncColors: PartitionChartProps['syncColors'];
2827
} & PartitionChartProps['visConfig'];
2928

30-
const PartitionVis: ComponentStory<FC<Props>> = ({
29+
const PartitionVis: ComponentStory<FC<PropsWithChildren<Props>>> = ({
3130
visType,
3231
syncColors,
3332
children,

src/plugins/chart_expressions/expression_partition_vis/public/__stories__/pie_vis_renderer.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Side Public License, v 1.
77
*/
88

9-
import React, { FC } from 'react';
9+
import React, { FC, PropsWithChildren } from 'react';
1010
import { ComponentStory } from '@storybook/react';
1111
import { Render } from '@kbn/presentation-util-plugin/public/__stories__';
1212
import { getPartitionVisRenderer } from '../expression_renderers';
@@ -22,12 +22,11 @@ const containerSize = {
2222
const PartitionVisRenderer = () => getPartitionVisRenderer({ getStartDeps });
2323

2424
type Props = {
25-
children: React.ReactNode;
2625
visType: PartitionChartProps['visType'];
2726
syncColors: PartitionChartProps['syncColors'];
2827
} & PartitionChartProps['visConfig'];
2928

30-
const PartitionVis: ComponentStory<FC<Props>> = ({
29+
const PartitionVis: ComponentStory<FC<PropsWithChildren<Props>>> = ({
3130
visType,
3231
syncColors,
3332
children,

src/plugins/chart_expressions/expression_partition_vis/public/__stories__/treemap_vis_renderer.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Side Public License, v 1.
77
*/
88

9-
import React, { FC } from 'react';
9+
import React, { FC, PropsWithChildren } from 'react';
1010
import { ComponentStory } from '@storybook/react';
1111
import { Render } from '@kbn/presentation-util-plugin/public/__stories__';
1212
import { getPartitionVisRenderer } from '../expression_renderers';
@@ -22,12 +22,11 @@ const containerSize = {
2222
const PartitionVisRenderer = () => getPartitionVisRenderer({ getStartDeps });
2323

2424
type Props = {
25-
children: React.ReactNode;
2625
visType: PartitionChartProps['visType'];
2726
syncColors: PartitionChartProps['syncColors'];
2827
} & PartitionChartProps['visConfig'];
2928

30-
const PartitionVis: ComponentStory<FC<Props>> = ({
29+
const PartitionVis: ComponentStory<FC<PropsWithChildren<Props>>> = ({
3130
visType,
3231
syncColors,
3332
children,

src/plugins/chart_expressions/expression_partition_vis/public/__stories__/waffle_vis_renderer.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Side Public License, v 1.
77
*/
88

9-
import React, { FC } from 'react';
9+
import React, { FC, PropsWithChildren } from 'react';
1010
import { ComponentStory } from '@storybook/react';
1111
import { Render } from '@kbn/presentation-util-plugin/public/__stories__';
1212
import { getPartitionVisRenderer } from '../expression_renderers';
@@ -22,12 +22,11 @@ const containerSize = {
2222
const PartitionVisRenderer = () => getPartitionVisRenderer({ getStartDeps });
2323

2424
type Props = {
25-
children: React.ReactNode;
2625
visType: PartitionChartProps['visType'];
2726
syncColors: PartitionChartProps['syncColors'];
2827
} & PartitionChartProps['visConfig'];
2928

30-
const PartitionVis: ComponentStory<FC<Props>> = ({
29+
const PartitionVis: ComponentStory<FC<PropsWithChildren<Props>>> = ({
3130
visType,
3231
syncColors,
3332
children,

x-pack/plugins/lens/public/app_plugin/mounter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
import React, { FC, useCallback, useEffect, useState, useMemo } from 'react';
8+
import React, { FC, PropsWithChildren, useCallback, useEffect, useState, useMemo } from 'react';
99
import { AppMountParameters, CoreSetup, CoreStart } from '@kbn/core/public';
1010
import { FormattedMessage, I18nProvider } from '@kbn/i18n-react';
1111
import { RouteComponentProps } from 'react-router-dom';
@@ -154,7 +154,7 @@ export async function mountApp(
154154
mountProps: {
155155
createEditorFrame: EditorFrameStart['createInstance'];
156156
attributeService: LensAttributeService;
157-
getPresentationUtilContext: () => FC<{ children: React.ReactNode }>;
157+
getPresentationUtilContext: () => FC<PropsWithChildren<{}>>;
158158
topNavMenuEntryGenerators: LensTopNavMenuEntryGenerator[];
159159
locator?: LensAppLocator;
160160
}

x-pack/plugins/lens/public/mocks/store_mocks.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
import React, { ReactElement } from 'react';
8+
import React, { PropsWithChildren, ReactElement } from 'react';
99
import { ReactWrapper } from 'enzyme';
1010
import { mountWithIntl as mount } from '@kbn/test-jest-helpers';
1111
import { Provider } from 'react-redux';
@@ -80,9 +80,7 @@ export const renderWithReduxStore = (
8080

8181
const CustomWrapper = wrapper as React.ComponentType;
8282

83-
const Wrapper: React.FC<{
84-
children: React.ReactNode;
85-
}> = ({ children }) => {
83+
const Wrapper: React.FC<PropsWithChildren<{}>> = ({ children }) => {
8684
return (
8785
<Provider store={store}>
8886
<I18nProvider>
@@ -135,9 +133,7 @@ export const mountWithProvider = async (
135133
component: React.ReactElement,
136134
store?: MountStoreProps,
137135
options?: {
138-
wrappingComponent?: React.FC<{
139-
children: React.ReactNode;
140-
}>;
136+
wrappingComponent?: React.FC<PropsWithChildren<{}>>;
141137
wrappingComponentProps?: Record<string, unknown>;
142138
attachTo?: HTMLElement;
143139
}
@@ -156,18 +152,16 @@ const getMountWithProviderParams = (
156152
component: React.ReactElement,
157153
store?: MountStoreProps,
158154
options?: {
159-
wrappingComponent?: React.FC<{
160-
children: React.ReactNode;
161-
}>;
155+
wrappingComponent?: React.FC<PropsWithChildren<{}>>;
162156
wrappingComponentProps?: Record<string, unknown>;
163157
attachTo?: HTMLElement;
164158
}
165159
) => {
166160
const { store: lensStore, deps } = makeLensStore(store || {});
167161

168-
let wrappingComponent: React.FC<{
169-
children: React.ReactNode;
170-
}> = ({ children }) => <Provider store={lensStore}>{children}</Provider>;
162+
let wrappingComponent: React.FC<PropsWithChildren<{}>> = ({ children }) => (
163+
<Provider store={lensStore}>{children}</Provider>
164+
);
171165

172166
let restOptions: {
173167
attachTo?: HTMLElement | undefined;
@@ -177,7 +171,7 @@ const getMountWithProviderParams = (
177171
restOptions = rest;
178172

179173
if (_wrappingComponent) {
180-
wrappingComponent = ({ children }: { children?: React.ReactNode }) => {
174+
wrappingComponent = ({ children }) => {
181175
return _wrappingComponent({
182176
...wrappingComponentProps,
183177
children: <Provider store={lensStore}>{children}</Provider>,

x-pack/plugins/lens/public/shared_components/toolbar_popover.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import './toolbar_popover.scss';
9-
import React, { useState } from 'react';
9+
import React, { PropsWithChildren, useState } from 'react';
1010
import { EuiFlexItem, EuiPopover, EuiPopoverProps, EuiPopoverTitle, IconType } from '@elastic/eui';
1111
import { ToolbarButton, ToolbarButtonProps } from '@kbn/shared-ux-button-toolbar';
1212
import { EuiIconLegend } from '@kbn/chart-icons';
@@ -39,10 +39,9 @@ export type ToolbarPopoverProps = Partial<EuiPopoverProps> & {
3939
buttonDataTestSubj?: string;
4040
panelClassName?: string;
4141
handleClose?: () => void;
42-
children: React.ReactNode;
4342
};
4443

45-
export const ToolbarPopover: React.FunctionComponent<ToolbarPopoverProps> = ({
44+
export const ToolbarPopover: React.FC<PropsWithChildren<ToolbarPopoverProps>> = ({
4645
children,
4746
title,
4847
type,

0 commit comments

Comments
 (0)