From 6fbfd8d48b5f1c5f4604c0d3bfb37ed9410e4f04 Mon Sep 17 00:00:00 2001 From: cchaos Date: Thu, 23 Aug 2018 18:00:43 -0400 Subject: [PATCH 1/6] Allowing `onClick` to be passed to whole pill --- src/components/combo_box/combo_box_input/combo_box_input.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/combo_box/combo_box_input/combo_box_input.js b/src/components/combo_box/combo_box_input/combo_box_input.js index 237af9456c0..86092a1f293 100644 --- a/src/components/combo_box/combo_box_input/combo_box_input.js +++ b/src/components/combo_box/combo_box_input/combo_box_input.js @@ -100,15 +100,18 @@ export class EuiComboBoxInput extends Component { const { label, color, + onClick, ...rest } = option; return ( {label} From a12c9a37b9770050c47557f05057fdac3255f8de Mon Sep 17 00:00:00 2001 From: cchaos Date: Thu, 23 Aug 2018 18:04:35 -0400 Subject: [PATCH 2/6] Allowing single selection types to show plain text with `asPlainText` as a property of `singleSelection` --- .../src/views/combo_box/combo_box_example.js | 6 ++-- .../src/views/combo_box/single_selection.js | 2 +- src/components/combo_box/_combo_box.scss | 17 +++++----- src/components/combo_box/combo_box.js | 5 ++- .../combo_box_input/_combo_box_pill.scss | 10 ++++++ .../combo_box_input/combo_box_input.js | 9 +++++- .../combo_box_input/combo_box_pill.js | 31 ++++++++++--------- 7 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src-docs/src/views/combo_box/combo_box_example.js b/src-docs/src/views/combo_box/combo_box_example.js index 055b577d8b2..1a287549817 100644 --- a/src-docs/src/views/combo_box/combo_box_example.js +++ b/src-docs/src/views/combo_box/combo_box_example.js @@ -224,8 +224,10 @@ export const ComboBoxExample = { }], text: (

- To only allow the user to select a single option, provide - the singleSelection prop. + To only allow the user to select a single option, provide the{' '} + singleSelection prop. You may want to render the selected option as + plain text instead of pill form. To do this, pass{' '} + {'singleSelection={{ asPlainText: true }}'}

), props: { EuiComboBox }, diff --git a/src-docs/src/views/combo_box/single_selection.js b/src-docs/src/views/combo_box/single_selection.js index 18275954aec..43535d036c8 100644 --- a/src-docs/src/views/combo_box/single_selection.js +++ b/src-docs/src/views/combo_box/single_selection.js @@ -48,7 +48,7 @@ export default class extends Component { return ( {label} @@ -174,6 +180,7 @@ export class EuiComboBoxInput extends Component { const wrapClasses = classNames('euiComboBox__inputWrap', { 'euiComboBox__inputWrap--fullWidth': fullWidth, + 'euiComboBox__inputWrap--noWrap': singleSelection, }); return ( diff --git a/src/components/combo_box/combo_box_input/combo_box_pill.js b/src/components/combo_box/combo_box_input/combo_box_pill.js index 9ce28d5dca8..e5353275512 100644 --- a/src/components/combo_box/combo_box_input/combo_box_pill.js +++ b/src/components/combo_box/combo_box_input/combo_box_pill.js @@ -1,12 +1,8 @@ -import React, { - Component, -} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; -import { - EuiBadge, -} from '../../badge'; +import { EuiBadge } from '../../badge'; export class EuiComboBoxPill extends Component { static propTypes = { @@ -15,6 +11,7 @@ export class EuiComboBoxPill extends Component { className: PropTypes.string, color: PropTypes.string, onClose: PropTypes.func, + asPlainText: PropTypes.bool, }; static defaultProps = { @@ -33,9 +30,16 @@ export class EuiComboBoxPill extends Component { option, // eslint-disable-line no-unused-vars onClose, // eslint-disable-line no-unused-vars color, + asPlainText, ...rest } = this.props; - const classes = classNames('euiComboBoxPill', className); + const classes = classNames( + 'euiComboBoxPill', + { + 'euiComboBoxPill--plainText': asPlainText, + }, + className + ); if (onClose) { return ( @@ -48,7 +52,7 @@ export class EuiComboBoxPill extends Component { iconSide="right" color={color} closeButtonProps={{ - tabIndex: '-1' + tabIndex: '-1', }} {...rest} > @@ -57,13 +61,12 @@ export class EuiComboBoxPill extends Component { ); } + if (asPlainText) { + return {children}; + } + return ( - + {children} ); From 0d8f3691f2fe957cb79f1dd8984a0533302fc14f Mon Sep 17 00:00:00 2001 From: cchaos Date: Thu, 23 Aug 2018 18:38:36 -0400 Subject: [PATCH 3/6] Altering the padding based on props --- src-docs/src/views/combo_box/combo_box_example.js | 2 +- .../combo_box/__snapshots__/combo_box.test.js.snap | 4 ++-- src/components/combo_box/_combo_box.scss | 6 +++++- .../combo_box/combo_box_input/_combo_box_input.scss | 1 + src/components/combo_box/combo_box_input/combo_box_input.js | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src-docs/src/views/combo_box/combo_box_example.js b/src-docs/src/views/combo_box/combo_box_example.js index 1a287549817..9ae64d90d9d 100644 --- a/src-docs/src/views/combo_box/combo_box_example.js +++ b/src-docs/src/views/combo_box/combo_box_example.js @@ -259,7 +259,7 @@ export const ComboBoxExample = { }], text: (

- Alternatively, provide thhe noSuggestions prop to hide the suggestions list + Alternatively, provide the noSuggestions prop to hide the suggestions list and only allow the creation of custom options.

), diff --git a/src/components/combo_box/__snapshots__/combo_box.test.js.snap b/src/components/combo_box/__snapshots__/combo_box.test.js.snap index 4c4575cb8f1..ef0c350452e 100644 --- a/src/components/combo_box/__snapshots__/combo_box.test.js.snap +++ b/src/components/combo_box/__snapshots__/combo_box.test.js.snap @@ -13,7 +13,7 @@ exports[`EuiComboBox is rendered 1`] = ` class="euiFormControlLayout__childrenWrapper" >