|
1 | 1 | import React from 'react';
|
2 |
| -import { EuiCode } from '../../../../../src/components'; |
3 |
| -import { GuideSectionTypes } from '../../../components'; |
| 2 | +import { EuiCode, EuiSpacer } from '../../../../../src/components'; |
4 | 3 |
|
5 |
| -import Table from './in_memory_selection'; |
6 |
| -import { EuiInMemoryTable } from '../../../../../src/components/basic_table/in_memory_table'; |
7 |
| -import { |
8 |
| - Criteria, |
9 |
| - CriteriaWithPagination, |
10 |
| -} from '!!prop-loader!../../../../../src/components/basic_table/basic_table'; |
11 |
| -import { Pagination } from '../paginated/_props'; |
12 |
| -import { |
13 |
| - EuiTableFieldDataColumnType, |
14 |
| - EuiTableComputedColumnType, |
15 |
| - EuiTableActionsColumnType, |
16 |
| - EuiTableSelectionType, |
17 |
| - EuiTableSortingType, |
18 |
| -} from '!!prop-loader!../../../../../src/components/basic_table/table_types'; |
19 |
| -import { CustomItemAction } from '!!prop-loader!../../../../../src/components/basic_table/action_types'; |
20 |
| -import { |
21 |
| - DefaultItemActionProps as DefaultItemAction, |
22 |
| - SearchProps as Search, |
23 |
| - SearchFilterConfigProps as SearchFilterConfig, |
24 |
| -} from '../props/props'; |
25 |
| -import { FieldValueOptionType } from '!!prop-loader!../../../../../src/components/search_bar/filters/field_value_selection_filter'; |
26 |
| -import { FieldValueToggleGroupFilterItemType } from '!prop-loader!../../../../../src/components/search_bar/filters/field_value_toggle_group_filter.tsx'; |
| 4 | +import { ConditionallyControlledDemo } from '../../tables/selection/selection_section'; |
27 | 5 |
|
28 |
| -const source = require('!!raw-loader!./in_memory_selection'); |
| 6 | +import Controlled from './in_memory_selection_controlled'; |
| 7 | +const controlledSource = require('!!raw-loader!./in_memory_selection_controlled'); |
| 8 | + |
| 9 | +import Uncontrolled from './in_memory_selection_uncontrolled'; |
| 10 | +const uncontrolledSource = require('!!raw-loader!./in_memory_selection_uncontrolled'); |
29 | 11 |
|
30 | 12 | export const selectionSection = {
|
31 | 13 | title: 'In-memory table selection',
|
32 |
| - source: [ |
33 |
| - { |
34 |
| - type: GuideSectionTypes.TSX, |
35 |
| - code: source, |
36 |
| - }, |
37 |
| - ], |
38 | 14 | text: (
|
39 |
| - <p> |
40 |
| - The following example shows how to use <strong>EuiInMemoryTable</strong>{' '} |
41 |
| - along with item selection. It also shows how you can display messages, |
42 |
| - errors and show loading indication. You can set items to be selected |
43 |
| - initially by passing an array of items as the{' '} |
44 |
| - <EuiCode>initialSelected</EuiCode> value inside{' '} |
45 |
| - <EuiCode>selection</EuiCode> property and passing{' '} |
46 |
| - <EuiCode>itemId</EuiCode> property to enable selection. You can also use |
47 |
| - the <EuiCode>setSelection</EuiCode> method to take complete control over |
48 |
| - table selection. This can be useful if you want to handle selection in |
49 |
| - table based on user interaction with another part of the UI. |
50 |
| - </p> |
| 15 | + <> |
| 16 | + <p> |
| 17 | + To enable selection, both the <EuiCode>itemId</EuiCode> and{' '} |
| 18 | + <EuiCode>selection</EuiCode> props must be passed. The following example |
| 19 | + shows how to use <strong>EuiInMemoryTable</strong> with both controlled |
| 20 | + and uncontrolled item selection. It also shows how you can display |
| 21 | + messages, errors and show loading indication. |
| 22 | + </p> |
| 23 | + <p> |
| 24 | + For uncontrolled usage, where selection changes are determined entirely |
| 25 | + to be selected initially by passing an array of items to{' '} |
| 26 | + <EuiCode>selection.initialSelected</EuiCode>. You can also use{' '} |
| 27 | + <EuiCode>selected.onSelectionChange</EuiCode> to track or respond to the |
| 28 | + items that users select. |
| 29 | + </p> |
| 30 | + <p> |
| 31 | + To completely control table selection, use{' '} |
| 32 | + <EuiCode>selection.selected</EuiCode> instead (which requires passing{' '} |
| 33 | + <EuiCode>selected.onSelectionChange</EuiCode>). This can be useful if |
| 34 | + you want to handle table selections based on user interaction with |
| 35 | + another part of the UI. |
| 36 | + </p> |
| 37 | + </> |
| 38 | + ), |
| 39 | + children: ( |
| 40 | + <> |
| 41 | + <EuiSpacer /> |
| 42 | + <ConditionallyControlledDemo |
| 43 | + controlledDemo={<Controlled />} |
| 44 | + uncontrolledDemo={<Uncontrolled />} |
| 45 | + controlledSource={controlledSource} |
| 46 | + uncontrolledSource={uncontrolledSource} |
| 47 | + /> |
| 48 | + </> |
51 | 49 | ),
|
52 |
| - props: { |
53 |
| - EuiInMemoryTable, |
54 |
| - Criteria, |
55 |
| - CriteriaWithPagination, |
56 |
| - Pagination, |
57 |
| - EuiTableSortingType, |
58 |
| - EuiTableSelectionType, |
59 |
| - EuiTableFieldDataColumnType, |
60 |
| - EuiTableComputedColumnType, |
61 |
| - EuiTableActionsColumnType, |
62 |
| - DefaultItemAction, |
63 |
| - CustomItemAction, |
64 |
| - Search, |
65 |
| - SearchFilterConfig, |
66 |
| - FieldValueOptionType, |
67 |
| - FieldValueToggleGroupFilterItemType, |
68 |
| - }, |
69 |
| - demo: <Table />, |
70 | 50 | };
|
0 commit comments