index.js 600 B

12345678910111213141516
  1. import { Component, triggerEvent, getValueFromProps } from '../../_util/simply';
  2. import { RadioGroupDefaultProps } from './props';
  3. import mixinValue from '../../mixins/value';
  4. Component(RadioGroupDefaultProps, {
  5. onChange: function (_, e) {
  6. var event;
  7. event = e;
  8. var index = event.currentTarget.dataset.index;
  9. var options = getValueFromProps(this, 'options');
  10. var value = options[index].value;
  11. if (!this.isControlled()) {
  12. this.update(value);
  13. }
  14. triggerEvent(this, 'change', value, event);
  15. },
  16. }, null, [mixinValue()]);