all files / addon/components/ polaris-choice.js

0% Statements 0/2
100% Branches 0/0
0% Functions 0/2
0% Lines 0/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90                                                                                                                                                                                   
import Component from '@ember/component';
import { computed } from '@ember/object';
import { or } from '@ember/object/computed';
import layout from '../templates/components/polaris-choice';
 
/**
 * Polaris choice component.
 * Wrapper for checkbox and radiobutton components.
 */
export default Component.extend({
  // Tagless component since sometimes we need to wrap the label in a div.
  tagName: '',
 
  layout,
 
  /**
   * ID of the choice's input
   *
   * @property inputId
   * @type {String}
   * @default: null
   * @public
   */
  inputId: null,
 
  /**
   * Label content for the choice
   *
   * @property label
   * @type {String}
   * @default: null
   * @public
   */
  label: null,
 
  /**
   * Component to render for the choice's label
   *
   * @property labelComponent
   * @type {String | Component}
   * @default null
   * @public
   */
  labelComponent: null,
 
  /**
   * Error content for this choice
   *
   * @property error
   * @type {String}
   * @default: null
   * @public
   */
  error: null,
 
  /**
   * Flag to hide the label for this choice
   *
   * @property labelHidden
   * @type {boolean}
   * @default: false
   * @public
   */
  labelHidden: false,
 
  /**
   * Help text for this choice
   *
   * @property helpText
   * @type {String}
   * @default: null
   * @public
   */
  helpText: null,
 
  /*
   * Internal properties.
   */
  hasDescription: or('error', 'helpText'),
 
  errorId: computed('inputId', function() {
    return `${ this.get('inputId') }Error`;
  }).readOnly(),
 
  helpTextId: computed('inputId', function() {
    return `${ this.get('inputId') }HelpText`;
  }).readOnly(),
});