index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. import { Component, triggerEvent, triggerEventValues, triggerEventOnly, getValueFromProps, } from '../../_util/simply';
  2. import { resolveEventValue, resolveEventValues } from '../../_util/platform';
  3. import { FormDatePickerDefaultProps } from './props';
  4. import { createForm } from '../form';
  5. Component(FormDatePickerDefaultProps, {
  6. onOk: function (date, dateStr, e) {
  7. var v = resolveEventValues(date, dateStr);
  8. this.emit('onChange', v[0]);
  9. triggerEventValues(this, 'ok', v, e);
  10. },
  11. onPickerChange: function (date, dateStr, e) {
  12. triggerEventValues(this, 'pickerChange', resolveEventValues(date, dateStr), e);
  13. },
  14. onVisibleChange: function (visible, e) {
  15. triggerEvent(this, 'visibleChange', resolveEventValue(visible), e);
  16. },
  17. onDismissPicker: function (e) {
  18. triggerEventOnly(this, 'dismissPicker', e);
  19. },
  20. handleFormat: function (date, dateStr) {
  21. var onFormat = getValueFromProps(this, 'onFormat');
  22. if (onFormat) {
  23. return onFormat(date, dateStr);
  24. }
  25. },
  26. handleFormatLabel: function (type, value) {
  27. var onFormatLabel = getValueFromProps(this, 'onFormatLabel');
  28. if (onFormatLabel) {
  29. return onFormatLabel(type, value);
  30. }
  31. },
  32. }, {}, [createForm()], {});