UNPKG

ukelli-ui

Version:

Base on React's UI lib. Make frontend's dev simpler and faster.

49 lines (48 loc) 2.15 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { Call, DateFormat } from 'basic-helper'; import { ToUTC } from 'basic-helper/datetime-helper'; import { UkePureComponent } from '../utils/uke-component'; var DateBasic = /** @class */ (function (_super) { __extends(DateBasic, _super); function DateBasic() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.dateFormat = 'YYYY-MM-DD'; _this.timeFormat = 'hh:mm:ss'; _this.emitChangeValue = function (val) { /** 统一处理过滤所有的 value 格式 */ var _a = _this.props, needTime = _a.needTime, outputAsString = _a.outputAsString, _b = _a.toUTC, toUTC = _b === void 0 ? true : _b, onChange = _a.onChange; /** 确保只有一个值的时候的时分秒为 23:59:59 */ var emitVal = Array.isArray(val) ? val : [null, val]; var resVal = []; emitVal.forEach(function (_val, idx) { if (!_val) return; var resDate = DateFormat(_val, needTime ? _this.dateFormat + " " + _this.timeFormat : _this.dateFormat); if (!outputAsString) { if (toUTC) { resDate = ToUTC(resDate); } } resVal.push(resDate); }); var emitResVal = resVal.length === 1 ? resVal[0] : resVal; Call(onChange, emitResVal); return emitResVal; }; return _this; } return DateBasic; }(UkePureComponent)); export { DateBasic };