Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
130c722
[Setup] Move toolbar CSS to own file
cee-chen Oct 27, 2021
52398d9
[Cleanup] DRY out repeated specific CSS class
cee-chen Oct 27, 2021
fc2203f
Reorder toolbar per Caroline's mocks
cee-chen Oct 27, 2021
8ddb5e2
Convert display buttons to icons only
cee-chen Oct 27, 2021
e5871eb
Convert density UI to a compressed EuiFormRow w/ new text/order per m…
cee-chen Oct 27, 2021
2782596
Update test snapshots
cee-chen Oct 27, 2021
84009b0
Add changelog entry
cee-chen Oct 27, 2021
6d71251
Merge branch 'master' into datagrid-toolbar
cee-chen Oct 29, 2021
7b1158a
[PR feedback] Revert location of additionalControls + fix props descr…
cee-chen Oct 29, 2021
05a696d
[PR feedback] CSS feedback
cee-chen Oct 29, 2021
6e3ecce
[PR feature request] Change toolbar icon based on grid density
cee-chen Oct 29, 2021
07ea746
[PR feedback][extra] Fix missing sort control on styling example
cee-chen Oct 29, 2021
e4e5d95
updoot snaps
cee-chen Oct 29, 2021
6611bf5
Merge branch 'master' into datagrid-toolbar
constancecchen Nov 1, 2021
2f38124
Merge branch 'master' into datagrid-toolbar
cee-chen Nov 2, 2021
87dfa97
Merge branch 'main' into datagrid-toolbar
cee-chen Nov 4, 2021
a9286d2
Fix changelog
cee-chen Nov 4, 2021
ba33c75
[misc] Reorganize EuiDataGridToolbar utils to bottom of file
cee-chen Nov 4, 2021
d740d08
Rename CSS toolbar class to left/right to match API
cee-chen Nov 4, 2021
5ee90d7
Add API support for left/right positioning of `additionalControls`
cee-chen Nov 4, 2021
440e5ef
Update additionalControls documentation + example
cee-chen Nov 4, 2021
5ba6a95
PR feedback & cleanup from Caroline (#4)
cchaos Nov 8, 2021
4747d09
Update CSS class to be more specific
cee-chen Nov 8, 2021
99de8bc
closes #5092 - add changelog for fullscreen bugfix in Caroline's work
cee-chen Nov 8, 2021
8ec3bd1
Merge branch 'feat/datagrid/toolbar-reorg-and-row-height-switcher' in…
constancecchen Nov 8, 2021
a8c12ed
Merge branch 'main' into datagrid-toolbar
cee-chen Nov 9, 2021
9a4a5c7
[PR feedback] Changelog
cee-chen Nov 9, 2021
2c18e4d
Update snapshots
cee-chen Nov 9, 2021
7abae68
PR feedback
cee-chen Nov 9, 2021
921d9c2
Remove unused CSS class
cee-chen Nov 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## [`main`](https://github.com/elastic/eui/tree/main)

- Updated the organization of `EuiDataGrid`'s toolbar/grid controls ([#5334](https://github.com/elastic/eui/pull/5334))

**Bug fixes**

- Fixed an `EuiDataGrid` race condition where grid rows had incorrect heights if loaded in before CSS ([#5284](https://github.com/elastic/eui/pull/5284))
- Fixed an accessibility issue where `EuiDataGrid` cells weren't owned by `role=row` elements ([#5285](https://github.com/elastic/eui/pull/5285))
- Fixed persistent `EuiDataGrid` full screen `<body>` class ([#5354](https://github.com/elastic/eui/pull/5354))

## [`41.0.0`](https://github.com/elastic/eui/tree/v41.0.0)

Expand Down
104 changes: 0 additions & 104 deletions src-docs/src/views/datagrid/additional_controls.js

This file was deleted.

197 changes: 197 additions & 0 deletions src-docs/src/views/datagrid/additional_controls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
import React, { useState, useCallback, Fragment } from 'react';

// @ts-ignore Importing from JS
import { fake } from 'faker';

import {
EuiDataGrid,
EuiButtonEmpty,
EuiButtonIcon,
EuiLink,
EuiToolTip,
useGeneratedHtmlId,
EuiFlyout,
EuiFlyoutBody,
EuiFlyoutHeader,
EuiText,
EuiTitle,
EuiContextMenuItem,
EuiContextMenuPanel,
EuiPopover,
} from '../../../../src';

const columns = [
{
id: 'name',
},
{
id: 'email',
},
{
id: 'city',
},
{
id: 'country',
},
{
id: 'account',
},
];

const data: any[] = [];

for (let i = 1; i < 20; i++) {
data.push({
name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
email: fake('{{internet.email}}'),
city: (
<EuiLink href="http://google.com">{fake('{{address.city}}')}</EuiLink>
),
country: fake('{{address.country}}'),
account: fake('{{finance.account}}'),
});
}

export default () => {
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
const flyoutTitleId = useGeneratedHtmlId({
prefix: 'dataGridAdditionalControlsFlyout',
});

let flyout;
if (isFlyoutVisible) {
flyout = (
<EuiFlyout
onClose={() => setIsFlyoutVisible(false)}
aria-labelledby={flyoutTitleId}
>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="m">
<h2 id={flyoutTitleId}>Inspect</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiText>
<p>
This is not a real control, just an example of how to trigger a
flyout from a custom data grid control.
</p>
</EuiText>
</EuiFlyoutBody>
</EuiFlyout>
);
}

const [isPopoverOpen, setPopover] = useState(false);
const popoverId = useGeneratedHtmlId({
prefix: 'dataGridAdditionalControlsPopover',
});
const alertAndClosePopover = () => {
setPopover(false);
window.alert('This is not a real control.');
};

const [visibleColumns, setVisibleColumns] = useState(() =>
columns.map(({ id }) => id)
);

const setPageIndex = useCallback(
(pageIndex) => setPagination({ ...pagination, pageIndex }),
[pagination, setPagination]
);
const setPageSize = useCallback(
(pageSize) => setPagination({ ...pagination, pageSize, pageIndex: 0 }),
[pagination, setPagination]
);

return (
<>
<EuiDataGrid
aria-label="Data grid demo with additional controls"
columns={columns}
columnVisibility={{
visibleColumns: visibleColumns,
setVisibleColumns: setVisibleColumns,
}}
rowCount={data.length}
gridStyle={{
border: 'horizontal',
header: 'underline',
}}
renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]}
pagination={{
...pagination,
pageSizeOptions: [5, 10, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
toolbarVisibility={{
additionalControls: {
left: (
<EuiPopover
id={popoverId}
button={
<EuiButtonEmpty
size="xs"
iconType="download"
onClick={() => setPopover((open) => !open)}
>
Download
</EuiButtonEmpty>
}
isOpen={isPopoverOpen}
closePopover={() => setPopover(false)}
panelPaddingSize="none"
>
<EuiContextMenuPanel
size="s"
items={[
<EuiContextMenuItem
key="csv"
onClick={alertAndClosePopover}
>
CSV
</EuiContextMenuItem>,
<EuiContextMenuItem
key="jsonedit"
onClick={alertAndClosePopover}
>
JSON
</EuiContextMenuItem>,
]}
/>
</EuiPopover>
),
right: (
<Fragment>
<EuiToolTip
title="Updated 3 min ago"
content="Click to refresh"
>
<EuiButtonIcon
aria-label="Refresh grid data"
size="xs"
iconType="refresh"
onClick={() => {
window.alert('This is not a real control.');
}}
/>
</EuiToolTip>
<EuiToolTip content="Inspect grid data">
<EuiButtonIcon
aria-label="Inspect grid data"
size="xs"
iconType="inspect"
onClick={() => setIsFlyoutVisible(true)}
/>
</EuiToolTip>
</Fragment>
),
},
}}
/>
{flyout}
</>
);
};
Loading