Skip to content

Commit

Permalink
Add props tables for container constraints page
Browse files Browse the repository at this point in the history
- switch to `Pick<>` over `Omit<>`, clearer typing

- have to whitelist the component directly - we can't use `allowedParents` unfortunately because react-window's type name "CommonProps" is too generic :(
  • Loading branch information
cee-chen committed Dec 6, 2024
1 parent 61fc54d commit 7e1de33
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
6 changes: 5 additions & 1 deletion packages/eui-docgen/src/filter_prop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ const allowedParents = [
'RefAttributes',
];

// components/types that should allow all props, even from external modules
const allowedComponents = ['EuiDataGridVirtualizationOptions'];

/**
* Filter props to remove props from node modules while keeping those whitelisted
*/
Expand Down Expand Up @@ -88,9 +91,10 @@ export const filterProp = (
return true;
}

if (allowedComponents.includes(component.name)) return true;
if (prop.parent.fileName.includes('@elastic/charts')) return true;
return !prop.parent.fileName.includes('node_modules');
}

return true;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ export const EuiDataGridRowHeightsOptions: FunctionComponent<
DataGridTypes.EuiDataGridRowHeightsOptions
> = () => <></>;

export const EuiDataGridHeightWidthProps: FunctionComponent<
Pick<DataGridTypes.EuiDataGridProps, 'height' | 'width'>
> = () => <></>;

export const EuiDataGridVirtualizationOptions: FunctionComponent<
DataGridTypes.EuiDataGridProps['virtualizationOptions']
> = () => <></>;

export const EuiDataGridRefProps: FunctionComponent<
DataGridTypes.EuiDataGridRefProps
> = () => <></>;
Expand Down
32 changes: 15 additions & 17 deletions packages/eui/src/components/datagrid/data_grid_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,23 +366,21 @@ export type CommonGridProps = CommonProps &
/**
* Allows customizing the underlying [react-window grid](https://react-window.vercel.app/#/api/VariableSizeGrid) props.
*/
virtualizationOptions?: Partial<
Omit<
VariableSizeGridProps,
| 'children'
| 'itemData'
| 'height'
| 'width'
| 'rowCount'
| 'rowHeight'
| 'columnCount'
| 'columnWidth'
| 'ref'
| 'innerRef'
| 'outerRef'
| 'innerElementType'
| 'useIsScrolling'
>
virtualizationOptions?: Pick<
VariableSizeGridProps,
| 'className'
| 'style'
| 'direction'
| 'estimatedRowHeight'
| 'estimatedColumnWidth'
| 'overscanRowCount'
| 'overscanColumnCount'
| 'initialScrollTop'
| 'initialScrollLeft'
| 'onScroll'
| 'onItemsRendered'
| 'itemKey'
| 'outerElementType'
>;
/**
* A #EuiDataGridRowHeightsOptions object that provides row heights options.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,9 @@ export default () => {
};
```

<!--
TODO: EuiDataGrid lower level types aren't currently exported.
## Props

import docgen from '@elastic/eui-docgen/dist/components/datagrid/data_grid.json';
import docgen from '@elastic/eui-docgen/dist/components/datagrid/data_grid_types.docgen.json';

virtualizationProps
height
width
-->
<PropTable definition={{ ...docgen.EuiDataGridHeightWidthProps, displayName: 'EuiDataGridProps' }} />
<PropTable definition={docgen.EuiDataGridVirtualizationOptions} />

0 comments on commit 7e1de33

Please sign in to comment.