-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Update table selection example to support switching between co…
…ntrolled & uncontrolled logic - requires creating a new prop and semi custom section - + clean up and remove unnecessary table data not relevant to the demo(s)
- Loading branch information
Showing
6 changed files
with
652 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 42 additions & 61 deletions
103
src-docs/src/views/tables/in_memory/in_memory_selection_section.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,51 @@ | ||
import React from 'react'; | ||
import { EuiCode } from '../../../../../src/components'; | ||
import { GuideSectionTypes } from '../../../components'; | ||
import { EuiCode, EuiSpacer } from '../../../../../src/components'; | ||
|
||
import Table from './in_memory_selection'; | ||
import { EuiInMemoryTable } from '../../../../../src/components/basic_table/in_memory_table'; | ||
import { | ||
Criteria, | ||
CriteriaWithPagination, | ||
} from '!!prop-loader!../../../../../src/components/basic_table/basic_table'; | ||
import { Pagination } from '../paginated/_props'; | ||
import { | ||
EuiTableFieldDataColumnType, | ||
EuiTableComputedColumnType, | ||
EuiTableActionsColumnType, | ||
EuiTableSelectionType, | ||
EuiTableSortingType, | ||
} from '!!prop-loader!../../../../../src/components/basic_table/table_types'; | ||
import { CustomItemAction } from '!!prop-loader!../../../../../src/components/basic_table/action_types'; | ||
import { | ||
DefaultItemActionProps as DefaultItemAction, | ||
SearchProps as Search, | ||
SearchFilterConfigProps as SearchFilterConfig, | ||
} from '../props/props'; | ||
import { FieldValueOptionType } from '!!prop-loader!../../../../../src/components/search_bar/filters/field_value_selection_filter'; | ||
import { FieldValueToggleGroupFilterItemType } from '!prop-loader!../../../../../src/components/search_bar/filters/field_value_toggle_group_filter.tsx'; | ||
import { ConditionallyControlledDemo } from '../../tables/selection/selection_section'; | ||
|
||
const source = require('!!raw-loader!./in_memory_selection'); | ||
import Controlled from './in_memory_selection_controlled'; | ||
const controlledSource = require('!!raw-loader!./in_memory_selection_controlled'); | ||
|
||
import Uncontrolled from './in_memory_selection_uncontrolled'; | ||
const uncontrolledSource = require('!!raw-loader!./in_memory_selection_uncontrolled'); | ||
|
||
export const selectionSection = { | ||
title: 'In-memory table selection', | ||
source: [ | ||
{ | ||
type: GuideSectionTypes.TSX, | ||
code: source, | ||
}, | ||
], | ||
text: ( | ||
<p> | ||
The following example shows how to use <strong>EuiInMemoryTable</strong>{' '} | ||
along with item selection. It also shows how you can display messages, | ||
errors and show loading indication. You can set items to be selected | ||
initially by passing an array of items as the{' '} | ||
<EuiCode>initialSelected</EuiCode> value inside{' '} | ||
<EuiCode>selection</EuiCode> property and passing{' '} | ||
<EuiCode>itemId</EuiCode> property to enable selection. You can also use | ||
the <EuiCode>setSelection</EuiCode> method to take complete control over | ||
table selection. This can be useful if you want to handle selection in | ||
table based on user interaction with another part of the UI. | ||
</p> | ||
<> | ||
<p> | ||
To enable selection, both the <EuiCode>itemId</EuiCode> and{' '} | ||
<EuiCode>selection</EuiCode> props must be passed. The following example | ||
shows how to use <strong>EuiInMemoryTable</strong> with both controlled | ||
and uncontrolled item selection. It also shows how you can display | ||
messages, errors and show loading indication. | ||
</p> | ||
<p> | ||
For uncontrolled usage, where selection changes are determined entirely | ||
by the user, you can set items to be selected initially by passing an | ||
array of items to an array of items to{' '} | ||
<EuiCode>selection.initialSelected</EuiCode>. You can also use{' '} | ||
<EuiCode>selected.onSelectionChange</EuiCode> to track or respond to the | ||
items that users select. | ||
</p> | ||
<p> | ||
To completely control table selection, use{' '} | ||
<EuiCode>selection.selected</EuiCode> instead (which requires passing{' '} | ||
<EuiCode>selected.onSelectionChange</EuiCode>). This can be useful if | ||
you want to handle selection in table based on user interaction with | ||
another part of the UI. | ||
</p> | ||
</> | ||
), | ||
children: ( | ||
<> | ||
<EuiSpacer /> | ||
<ConditionallyControlledDemo | ||
controlledDemo={<Controlled />} | ||
uncontrolledDemo={<Uncontrolled />} | ||
controlledSource={controlledSource} | ||
uncontrolledSource={uncontrolledSource} | ||
/> | ||
</> | ||
), | ||
props: { | ||
EuiInMemoryTable, | ||
Criteria, | ||
CriteriaWithPagination, | ||
Pagination, | ||
EuiTableSortingType, | ||
EuiTableSelectionType, | ||
EuiTableFieldDataColumnType, | ||
EuiTableComputedColumnType, | ||
EuiTableActionsColumnType, | ||
DefaultItemAction, | ||
CustomItemAction, | ||
Search, | ||
SearchFilterConfig, | ||
FieldValueOptionType, | ||
FieldValueToggleGroupFilterItemType, | ||
}, | ||
demo: <Table />, | ||
}; |
Oops, something went wrong.