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

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

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 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 91 92 93 94 95 96                  1x                                                                                                                                                                     6x      
import Component from '@ember/component';
import layout from '../../templates/components/bootstrap-inputs/-date';
import { or } from '@ember/object/computed';
import { PropTypes } from 'ember-prop-types';
import {
  BuilderForPropTypes,
  BuilderForPropDefaults
} from 'ember-bootstrap-controls/utils/prop-definition-tools';
 
export const propDefinitions = {
  autocomplete: {
    default: 'off',
    description: 'Indicates whether the value can be automatically completed by the browser.',
    type: PropTypes.oneOf(['off','on', 'cc-exp', 'bday']),
  },
  disabled: {
    description: 'Indicates whether the control is disabled',
    type: PropTypes.bool,
  },
  errors: {
    description: 'An array of EmberData errors to display.',
    type: PropTypes.arrayOf(PropTypes.string),
  },
  help: {
    description: 'Additonal text to provide additional context to the user that is displayed below the input.',
    type: PropTypes.string,
  },
  label: {
    default: 'Date Picker',
    description: 'The label for the input.',
    type: PropTypes.string,
  },
  max: {
    description: 'The maximum future date that can be selected from the calandar.',
    type: PropTypes.date,
  },
  min: {
    description: 'The minimum future date that can be selected from the calandar.',
    type: PropTypes.date,
  },
  multiple: {
    default: false,
    description: 'Indicates whether the user can enter more than one value.',
    type: PropTypes.bool,
  },
  pattern: {
    description: "A regular expression that the control's value is checked against (used for fallback browser input formatting).",
    type: PropTypes.instanceOf(RegExp),
  },
  placeholder: {
    description: 'A hint to the user of what can be entered in the control. This is displayed in the empty input.',
    type: PropTypes.date,
  },
  readonly: {
    default: false,
    description: 'Indicates that the user cannot modify the value of the control.',
    type: PropTypes.bool,
  },
  required: {
    default: false,
    description: 'Indicates that the user must fill in a value before submitting a form.',
    type: PropTypes.bool,
  },
  srOnly: {
    default: false,
    description: 'Indicates that the label should be hidden to all devices except screen readers',
    type: PropTypes.bool,
  },
  step: {
    description: 'Works with the min and max attributes to limit the increments at which a value can be set. If this attribute is not set to any, the control accepts only values at multiples of the step value greater than the minimum.',
    type: PropTypes.number,
  },
  tabindex: {
    description: 'The position of the element in the tabbing navigation order for the current document.',
    type: PropTypes.number,
  },
  value: {
    default: new Date(),
    description: 'A formatted string that is the value for the control.',
    type: PropTypes.date.isRequired,
  },
};
 
export default Component.extend({
  layout,
  propTypes: BuilderForPropTypes(propDefinitions),
  _disabled: or('formDisabled', 'disabled'),
 
  todayHighlight: true,
  format: 'mm/dd/yyyy',
 
  getDefaultProps() {
    return BuilderForPropDefaults(propDefinitions);
  },
});