From 2a4c254c6a176f6bb1d2ff034be72516d22cc14b Mon Sep 17 00:00:00 2001 From: cchaos Date: Tue, 12 Jun 2018 14:55:40 -0400 Subject: [PATCH] Moved mapping option to inside super select --- .../src/views/super_select/super_select.js | 74 +---- .../__snapshots__/super_select.test.js.snap | 247 +++++++++++--- .../super_select_control.test.js.snap | 309 ++++++++++++++++++ .../form/super_select/_super_select.scss | 15 +- .../form/super_select/super_select.js | 97 ++++-- .../form/super_select/super_select.test.js | 50 ++- .../form/super_select/super_select_control.js | 4 +- .../super_select/super_select_control.test.js | 73 +++++ 8 files changed, 739 insertions(+), 130 deletions(-) diff --git a/src-docs/src/views/super_select/super_select.js b/src-docs/src/views/super_select/super_select.js index c7a52bd15ff..735aa2bb837 100644 --- a/src-docs/src/views/super_select/super_select.js +++ b/src-docs/src/views/super_select/super_select.js @@ -8,8 +8,6 @@ import { EuiSpacer, EuiText, EuiIcon, - EuiContextMenuItem, - EuiHorizontalRule, } from '../../../../src/components'; export default class extends Component { @@ -19,8 +17,8 @@ export default class extends Component { this.options = [ { value: 'option_one', - text: 'Option one', - display: ( + inputDisplay: 'Option one', + dropdownDisplay: ( Option one @@ -32,12 +30,12 @@ export default class extends Component { }, { value: 'option_two', - text: ( + inputDisplay: ( Option two ), - display: ( + dropdownDisplay: ( Option two @@ -49,8 +47,8 @@ export default class extends Component { }, { value: 'option_three', - text: 'Option three has a super long text to see if it will truncate or what', - display: ( + inputDisplay: 'Option three has a super long text to see if it will truncate or what', + dropdownDisplay: ( Option three @@ -64,101 +62,65 @@ export default class extends Component { this.state = { value: this.options[1].value, - isPopoverOpen: false, }; } - onChange = e => { - this.setState({ - value: e.target.value, - }); - }; - - itemClicked = (value) => { + onChange = (value) => { this.setState({ value: value, - isPopoverOpen: false, }); }; render() { - const items = this.options.map((option, index) => { - return ( - - this.itemClicked(option.value)} - layoutAlign="top" - > - {option.display} - - {index < this.options.length - 1 && - - } - - ); - }); - return ( - {items} - + /> - {items} - + /> - {items} - + /> - {items} - + /> - {items} - + /> ); } diff --git a/src/components/form/super_select/__snapshots__/super_select.test.js.snap b/src/components/form/super_select/__snapshots__/super_select.test.js.snap index f404f4d6e1c..780c401467b 100644 --- a/src/components/form/super_select/__snapshots__/super_select.test.js.snap +++ b/src/components/form/super_select/__snapshots__/super_select.test.js.snap @@ -2,58 +2,223 @@ exports[`EuiSuperSelect is rendered 1`] = `
+
-
+
+ +`; + +exports[`EuiSuperSelect props custom display is propagated to dropdown 1`] = ` +
+ +
+
+
+`; + +exports[`EuiSuperSelect props options are rendered 1`] = ` +
+ +
+
+
+`; + +exports[`EuiSuperSelect props valueSelected is rendered 1`] = ` +
+ +
+ +
+ + +
diff --git a/src/components/form/super_select/__snapshots__/super_select_control.test.js.snap b/src/components/form/super_select/__snapshots__/super_select_control.test.js.snap index d6ea56fdba3..94318ced541 100644 --- a/src/components/form/super_select/__snapshots__/super_select_control.test.js.snap +++ b/src/components/form/super_select/__snapshots__/super_select_control.test.js.snap @@ -50,3 +50,312 @@ Array [ , ] `; + +exports[`EuiSuperSelectControl props compressed is rendered 1`] = ` +Array [ + +