index.js 491 B

1234567891011121314151617
  1. import { Component, triggerEvent } from '../_util/simply';
  2. import { SwitchDefaultProps } from './props';
  3. import mixinValue from '../mixins/value';
  4. Component(SwitchDefaultProps, {
  5. onChange: function (e) {
  6. var value = !this.getValue();
  7. if (!this.isControlled()) {
  8. this.update(value);
  9. }
  10. triggerEvent(this, 'change', value, e);
  11. },
  12. }, null, [
  13. mixinValue({
  14. valueKey: 'checked',
  15. defaultValueKey: 'defaultChecked',
  16. }),
  17. ]);