-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [EuiSelectable] Better export and display of props - Setting `searchable` to required but adding a default of false * [EuiListGroup] Exporting props at top level
- Loading branch information
Showing
24 changed files
with
265 additions
and
336 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
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { | ||
EuiSelectableOption, | ||
EuiSelectableOptionsListProps, | ||
} from '../../../../src/components/selectable'; | ||
|
||
export const EuiSelectableOptionProps: FunctionComponent< | ||
EuiSelectableOption | ||
> = () => <div />; | ||
|
||
export const EuiSelectableOptionsList: FunctionComponent< | ||
EuiSelectableOptionsListProps | ||
> = () => <div />; |
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,34 +1,17 @@ | ||
import React, { Component } from 'react'; | ||
import React, { useState } from 'react'; | ||
|
||
import { EuiSelectable } from '../../../../src/components/selectable'; | ||
import { Option } from '../../../../src/components/selectable/types'; | ||
import { Options } from './data'; | ||
|
||
export default class extends Component<{}, { options: Option[] }> { | ||
constructor(props: any) { | ||
super(props); | ||
export default () => { | ||
const [options, setOptions] = useState(Options); | ||
|
||
this.state = { | ||
options: Options as Option[], | ||
}; | ||
} | ||
|
||
onChange = (options: Option[]) => { | ||
this.setState({ | ||
options, | ||
}); | ||
}; | ||
|
||
render() { | ||
const { options } = this.state; | ||
|
||
return ( | ||
<EuiSelectable | ||
options={options} | ||
onChange={this.onChange} | ||
listProps={{ bordered: true }}> | ||
{list => list} | ||
</EuiSelectable> | ||
); | ||
} | ||
} | ||
return ( | ||
<EuiSelectable | ||
options={options} | ||
listProps={{ bordered: true }} | ||
onChange={newOptions => setOptions(newOptions)}> | ||
{list => list} | ||
</EuiSelectable> | ||
); | ||
}; |
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
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,31 +1,17 @@ | ||
import React, { Component } from 'react'; | ||
import React, { useState } from 'react'; | ||
|
||
import { EuiSelectable } from '../../../../src/components/selectable'; | ||
import { Option } from '../../../../src/components/selectable/types'; | ||
import { Options } from './data'; | ||
|
||
export default class extends Component<{}, { options: Option[] }> { | ||
constructor(props: any) { | ||
super(props); | ||
export default () => { | ||
const [options, setOptions] = useState(Options); | ||
|
||
this.state = { | ||
options: Options as Option[], | ||
}; | ||
} | ||
|
||
onChange = (options: Option[]) => { | ||
this.setState({ | ||
options, | ||
}); | ||
}; | ||
|
||
render() { | ||
const { options } = this.state; | ||
|
||
return ( | ||
<EuiSelectable allowExclusions options={options} onChange={this.onChange}> | ||
{list => list} | ||
</EuiSelectable> | ||
); | ||
} | ||
} | ||
return ( | ||
<EuiSelectable | ||
allowExclusions | ||
options={options} | ||
onChange={newOptions => setOptions(newOptions)}> | ||
{list => list} | ||
</EuiSelectable> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { useState, Fragment } from 'react'; | ||
|
||
import { | ||
EuiSelectable, | ||
EuiSelectableMessage, | ||
} from '../../../../src/components/selectable'; | ||
import { EuiSwitch } from '../../../../src/components/form/switch'; | ||
import { EuiSpacer } from '../../../../src/components/spacer'; | ||
|
||
export default () => { | ||
const [useCustomMessage, setUseCustomMessage] = useState(false); | ||
const [isLoading, setIsLoading] = useState(false); | ||
|
||
const customMessage = ( | ||
<EuiSelectableMessage>You have no spice</EuiSelectableMessage> | ||
); | ||
|
||
return ( | ||
<Fragment> | ||
<EuiSwitch | ||
label="Custom message" | ||
onChange={e => setUseCustomMessage(e.target.checked)} | ||
checked={!isLoading && useCustomMessage} | ||
disabled={isLoading} | ||
/> | ||
  | ||
<EuiSwitch | ||
label="Show loading" | ||
onChange={e => setIsLoading(e.target.checked)} | ||
checked={isLoading} | ||
/> | ||
<EuiSpacer /> | ||
<EuiSelectable options={[]} style={{ width: 200 }} isLoading={isLoading}> | ||
{list => (useCustomMessage && !isLoading ? customMessage : list)} | ||
</EuiSelectable> | ||
</Fragment> | ||
); | ||
}; |
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,57 +1,27 @@ | ||
import React, { Component, Fragment } from 'react'; | ||
|
||
import { EuiButtonEmpty } from '../../../../src/components/button'; | ||
import React, { useState, Fragment } from 'react'; | ||
|
||
import { EuiSelectable } from '../../../../src/components/selectable'; | ||
import { Option } from '../../../../src/components/selectable/types'; | ||
import { Options } from './data'; | ||
|
||
export default class extends Component<{}, { options: Option[] }> { | ||
constructor(props: any) { | ||
super(props); | ||
|
||
this.state = { | ||
options: Options as Option[], | ||
}; | ||
} | ||
|
||
onChange = (options: Option[]) => { | ||
this.setState({ | ||
options, | ||
}); | ||
}; | ||
|
||
render() { | ||
const { options } = this.state; | ||
export default () => { | ||
const [options, setOptions] = useState(Options); | ||
|
||
return ( | ||
<Fragment> | ||
<EuiButtonEmpty | ||
onClick={() => { | ||
this.setState({ | ||
options: Options.map(option => ({ | ||
...option, | ||
checked: undefined, | ||
})), | ||
}); | ||
}}> | ||
Deselect all | ||
</EuiButtonEmpty> | ||
<EuiSelectable | ||
searchable | ||
searchProps={{ | ||
'data-test-subj': 'selectableSearchHere', | ||
}} | ||
options={options} | ||
onChange={this.onChange}> | ||
{(list, search) => ( | ||
<Fragment> | ||
{search} | ||
{list} | ||
</Fragment> | ||
)} | ||
</EuiSelectable> | ||
</Fragment> | ||
); | ||
} | ||
} | ||
return ( | ||
<Fragment> | ||
<EuiSelectable | ||
searchable | ||
searchProps={{ | ||
'data-test-subj': 'selectableSearchHere', | ||
}} | ||
options={options} | ||
onChange={newOptions => setOptions(newOptions)}> | ||
{(list, search) => ( | ||
<Fragment> | ||
{search} | ||
{list} | ||
</Fragment> | ||
)} | ||
</EuiSelectable> | ||
</Fragment> | ||
); | ||
}; |
Oops, something went wrong.