Back to Consul

OptionInput

ui/packages/consul-ui/app/components/option-input/README.mdx

1.22.71.8 KB
Original Source

OptionInput

Form component to be used for choosing options, both compacted form (coming soon) and expanded form. Certain API decision are based on the usage of ember-power-select which is currently used internally. This is likely to change slightly at some point in the future.

hbs
  <OptionInput
    @name="Choice"
    @label="Choice of different options"
    @item={{hash
      Choice="selection"
    }}
    @selected={{or this.selected 'option 2'}}
    @items={{array
      'option 1'
      'option 2'
      'option 3'
      'option 4'
    }}
    @onchange={{action (mut this.selected)}}
  >
    <:option as |option|>
      <span>{{option.item}}</span>
    </:option>
  </OptionInput>

Arguments

ArgumentTypeDefaultDescription
itemObjectAn object whose properties are to be edited
nameString''An identifier for the property to be edited on the item
labelString@nameA label to use to label the text input element
placeholderStringEquivalent to the HTML placeholder="" attribute
helpStringProvide some help text for the input (consider using @validations instead)
multipleBooleanfalseSet the OptionInput to be multiple choice (coming soon)
expandedBooleanfalseWhether to use expanded radiobuttons/checkboxes or just a non-expanded select-like input
validationsObjectA validations object to be passed to the underlying validate modifier
chartObjectA StateChart object (implementing state and dispatch to be passed to the underlying validate modifier
onchangeFunctionAn event listener fired onchange of the input

See