All files / addon/components/bootstrap-inputs -checkbox.js

100% Statements 3/3
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                      1x                                                                               8x       8x      
import { guidFor } from '@ember/object/internals';
import { computed } from '@ember/object';
import { or } from '@ember/object/computed';
import Component from '@ember/component';
import layout from '../../templates/components/bootstrap-inputs/-checkbox';
import { PropTypes } from 'ember-prop-types';
import {
  BuilderForPropTypes,
  BuilderForPropDefaults
} from 'ember-bootstrap-controls/utils/prop-definition-tools';
 
export const propDefinitions = {
  disabled: {
    description: 'Indicates whether the control is disabled',
    type: PropTypes.bool,
  },
  label: {
    description: 'The label for the input.',
    type: PropTypes.string.isRequired,
  },
  required: {
    default: false,
    description: 'Indicates that the user must fill in a value before submitting a form.',
    type: PropTypes.bool,
  },
  srOnly: {
    default: false,
    description: 'Indicated that the label should be hidden to all devices except screen readers',
    type: PropTypes.bool,
  },
  tabindex: {
    description: 'The position of the element in the tabbing navigation order for the current document.',
    type: PropTypes.number,
  },
  value: {
    description: 'A boolean that is the value for the control.',
    type: PropTypes.bool.isRequired,
  },
  onChange: {
    description: 'A function that is called when the checkbox is changed.',
    type: PropTypes.func,
  },
};
 
export default Component.extend({
  classNames: ['form-check'],
  layout,
  propTypes: BuilderForPropTypes(propDefinitions),
  _disabled: or('formDisabled', 'disabled'),
 
  getDefaultProps() {
    return BuilderForPropDefaults(propDefinitions)
  },
 
  inputId: computed(function() {
    return `bootstrap-control-input-${guidFor(this)}`;
  }),
});