How to use the react-select.Creatable function in react-select

To help you get started, we’ve selected a few react-select examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scanner-research / esper-tv / app / assets / js / views / Select.jsx View on Github external
render() {
    let SelectComponent = this.props.creatable ? ReactSelect.Creatable : ReactSelect;
    return  ({value: k, label: v}))}
             multi={this.props.multi}
             placeholder={'Search...'}
             style={{width: this.props.width}}
             openOnFocus={true}
             autoFocus={true}
             value={this.state.value}
             escapeClearsValue={false}
             onInputKeyDown={(e) => {
                 if (e.which == 27) { // ESC
                   if (this.props.multi) {
                     let v = this.state.value;
                     if (v === null || v === []) {
                       this.props.onClose();
                     } else {
github Clever / components / src / Select / Select.jsx View on Github external
let inputNote;
  if (required) {
    inputNote = <span>required</span>;
  }

  let reactSelectClasses = cssClass.REACT_SELECT;
  if (readOnly) {
    reactSelectClasses += ` ${cssClass.READ_ONLY}`;
  }

  let SelectComponent = ReactSelect;
  if (creatable &amp;&amp; lazy) {
    SelectComponent = ReactSelect.AsyncCreatable;
  } else if (creatable) {
    SelectComponent = ReactSelect.Creatable;
  } else if (lazy) {
    SelectComponent = ReactSelect.Async;
  }

  // The label container must be returned after the ReactSelect otherwise it does not get displayed
  // in the browser.
  return (
    <div>
      <div id="{id}">
        </div></div>
github bowtie-co / houndstooth-ui / src / components / molecules / Field / MultiSelect / MultiSelect.jsx View on Github external
const MultiSelect = ({ id, name, async, onChange, creatable, className = '', edited, value = [], ...rest }) =&gt; {
  const SelectComponent = async ? Select.Async : (creatable ? Select.Creatable : Select)
  return (
    
       onChange({ target: { name, value: v.map(i =&gt; i.value) } })}
        {...rest}
      /&gt;
    
  )
}
github cloudflare / cf-ui / packages / cf-component-select / src / Select.js View on Github external
render() {
    const {
      async,
      creatable,
      searchable,
      label,
      className,
      ...props
    } = this.props;

    let SelectClass;
    if (async) {
      SelectClass = creatable ? ReactSelect.AsyncCreatable : ReactSelect.Async;
    } else {
      SelectClass = creatable ? ReactSelect.Creatable : ReactSelect;
    }

    return (
      <div>
        {label &amp;&amp;
          <label>
            {label}
          </label>}
         this.select = ref}
        /&gt;</div>
github esnet / react-dynamic-forms / lib / components / TagsEdit.js View on Github external
value.push({ value: i, label: tag });
            } else {
              options.push({ value: i, label: tag });
            }
          });

          var className = void 0;
          if (isMissing) {
            className = "missing";
          }

          return {
            v: _react2.default.createElement(
              "div",
              null,
              _react2.default.createElement(_reactSelect.Creatable, {
                key: "bob",
                className: className,
                multi: true,
                disabled: _this3.props.disabled,
                placeholder: "Select tags...",
                allowCreate: true,
                value: value,
                options: options,
                onChange: function onChange(value) {
                  return _this3.handleChange(value);
                }
              }),
              _react2.default.createElement("div", { className: "help-block" })
            )
          };
        }();
github esnet / react-dynamic-forms / packages / react-dynamic-forms / lib / components / TagsEdit.js View on Github external
if (_this3.props.value.contains(tag)) {
                        value.push({ value: i, label: tag });
                    } else {
                        options.push({ value: i, label: tag });
                    }
                });

                var className = void 0;
                if (isMissing) {
                    className = "missing";
                }

                return _react2.default.createElement(
                    "div",
                    null,
                    _react2.default.createElement(_reactSelect.Creatable, {
                        key: "bob",
                        className: className,
                        multi: true,
                        disabled: this.props.disabled,
                        placeholder: "Select tags...",
                        allowCreate: true,
                        value: value,
                        options: options,
                        onChange: function onChange(value) {
                            return _this3.handleChange(value);
                        }
                    }),
                    _react2.default.createElement("div", { className: "help-block" })
                );
            } else {
                var tagStyle = {
github zooniverse / Panoptes-Front-End / app / classifier / tasks / dropdown / index.jsx View on Github external
{selects.map((select, i) =&gt; {
            const disabled = this.getDisabledAttribute(i);
            const options = Array.from(this.getOptions(i));
            const selectedOptions = this.selectedOptions();

            let selectedOption = null;
            if (selectedOptions &amp;&amp; selectedOptions[i] &amp;&amp; (selectedOptions[i].value || selectedOptions[i].value === 0)) {
              selectedOption = selectedOptions[i];
            }

            let SelectComponent = Select;
            if (select.allowCreate) {
              SelectComponent = Select.Creatable;
            }

            return (
              <div id="{select.id}">
                {(select.title !== this.props.translation.instruction) &amp;&amp;
                  <div>{select.title}</div>}
                 `Press enter or tab for ${label}…`}
                  shouldKeyDownEventCreateNewOption={({ keyCode }) =&gt; keyCode === 9 || keyCode === 13}
                  matchPos="start"</div>