shineout 1.12.4 → 1.12.6-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -121,11 +121,11 @@ function (_PureComponent) {
121
121
  if (type === 'week') {
122
122
  onChange.apply(void 0, _paramUtils.default.weekHandleChangeParams(date, true, true));
123
123
  } else {
124
- var newDate = _utils.default.setTime(_utils.default.toDate(date), current); // only can select day with the same day of min/max
124
+ var newDate = _utils.default.setTime(_utils.default.toDate(date), current, this.getOptions()); // only can select day with the same day of min/max
125
125
 
126
126
 
127
- if (min && _utils.default.compareAsc(newDate, min) < 0) _utils.default.setTime(newDate, min);
128
- if (max && _utils.default.compareAsc(newDate, max) > 0) _utils.default.setTime(newDate, max);
127
+ if (min && _utils.default.compareAsc(newDate, min) < 0) newDate = _utils.default.setTime(newDate, min, this.getOptions());
128
+ if (max && _utils.default.compareAsc(newDate, max) > 0) newDate = _utils.default.setTime(newDate, max, this.getOptions());
129
129
  if (allowSingle && rangeDate[index] && _utils.default.clearHMS(newDate, this.getOptions()).getTime() === _utils.default.clearHMS(rangeDate[index], this.getOptions()).getTime()) newDate = '';
130
130
  onChange.apply(void 0, _paramUtils.default.dayHandleChangeParams(newDate, true, type !== 'datetime'));
131
131
  }
@@ -94,6 +94,7 @@ function (_PureComponent) {
94
94
  };
95
95
 
96
96
  _proto.handleDayHover = function handleDayHover(date) {
97
+ // will never in
97
98
  if (this.state.rangeDate.length === 1) {
98
99
  _utils.default.cloneTime(date, this.props.value[1], this.props.format, this.getOptions()); // this.setState({ hover: date })
99
100
 
@@ -113,7 +114,7 @@ function (_PureComponent) {
113
114
  if (_utils.default.compareAsc(s, e) > 0) {
114
115
  var sWitheTime = _utils.default.toDate(s, this.getOptions());
115
116
 
116
- _utils.default.setTime(sWitheTime, e);
117
+ _utils.default.setTime(sWitheTime, e, this.getOptions());
117
118
 
118
119
  rangeDate[1] = _utils.default.compareAsc(s, sWitheTime) > 0 ? s : sWitheTime;
119
120
  }
@@ -123,6 +124,8 @@ function (_PureComponent) {
123
124
  _proto.handleChange = function handleChange(index, date, change, end, mode, isQuickSelect, areaType) {
124
125
  var _this2 = this;
125
126
 
127
+ var newDate = _utils.default.toDate(date);
128
+
126
129
  var _this$props = this.props,
127
130
  type = _this$props.type,
128
131
  range = _this$props.range,
@@ -135,7 +138,7 @@ function (_PureComponent) {
135
138
  var _this$props2;
136
139
 
137
140
  var current = (0, _immer.default)(this.props.current, function (draft) {
138
- draft[index] = date;
141
+ draft[index] = newDate;
139
142
  });
140
143
 
141
144
  (_this$props2 = this.props).onChange.apply(_this$props2, handleOnChangeParams(current));
@@ -146,7 +149,7 @@ function (_PureComponent) {
146
149
  if (mode === 'time') {
147
150
  var endChangedDate;
148
151
  this.setState((0, _immer.default)(function (draft) {
149
- draft.rangeDate[index] = date;
152
+ draft.rangeDate[index] = newDate;
150
153
  var _draft$rangeDate = draft.rangeDate,
151
154
  s = _draft$rangeDate[0],
152
155
  e = _draft$rangeDate[1];
@@ -162,7 +165,7 @@ function (_PureComponent) {
162
165
  }
163
166
 
164
167
  if (range && _utils.default.compareAsc(s, e) === 1) {
165
- endChangedDate = date;
168
+ endChangedDate = newDate;
166
169
  draft.rangeDate[1] = endChangedDate;
167
170
  }
168
171
 
@@ -174,7 +177,7 @@ function (_PureComponent) {
174
177
  var _this2$props;
175
178
 
176
179
  var current = (0, _immer.default)(_this2.props.value, function (draft) {
177
- draft[index] = date;
180
+ draft[index] = newDate;
178
181
  if (endChangedDate) draft[1] = endChangedDate;
179
182
  draft[1 - index] = draft[1 - index] || '';
180
183
  });
@@ -189,7 +192,7 @@ function (_PureComponent) {
189
192
 
190
193
  // eslint-disable-next-line
191
194
  var rangeDate = [].concat(this.state.rangeDate);
192
- rangeDate[index] = date;
195
+ rangeDate[index] = newDate;
193
196
  rangeDate[1 - index] = rangeDate[1 - index] || '';
194
197
  this.changeDateSmart(rangeDate);
195
198
  this.setState({
@@ -201,14 +204,14 @@ function (_PureComponent) {
201
204
  return;
202
205
  }
203
206
 
204
- _utils.default.cloneTime(date, this.props.value[index], undefined, this.getOptions());
207
+ newDate = _utils.default.cloneTime(newDate, this.props.value[index], undefined, this.getOptions());
205
208
 
206
- if (min && _utils.default.compareAsc(date, min) <= 0) {
207
- _utils.default.setTime(date, min);
209
+ if (min && _utils.default.compareAsc(newDate, min) <= 0) {
210
+ newDate = _utils.default.setTime(newDate, min, this.getOptions());
208
211
  }
209
212
 
210
- if (max && _utils.default.compareAsc(date, max) >= 0) {
211
- _utils.default.setTime(date, max);
213
+ if (max && _utils.default.compareAsc(newDate, max) >= 0) {
214
+ newDate = _utils.default.setTime(newDate, max, this.getOptions());
212
215
  } // if (this.state.rangeDate.filter(a => a).length !== 1) {
213
216
  // this.setState({ rangeDate: index === 1 ? [undefined, date] : [date], hover: undefined })
214
217
  // return
@@ -217,7 +220,7 @@ function (_PureComponent) {
217
220
 
218
221
  this.setState((0, _immer.default)(function (draft) {
219
222
  // const method = utils.compareAsc(draft.rangeDate[0], date) > 0 ? 'unshift' : 'push'
220
- draft.rangeDate[index] = date;
223
+ draft.rangeDate[index] = newDate;
221
224
  draft.rangeDate[1 - index] = draft.rangeDate[1 - index] || ''; // draft.rangeDate.map(this.fillTime)
222
225
  // range change start&end
223
226
 
@@ -17,7 +17,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
 
18
18
  var _classnames = _interopRequireDefault(require("classnames"));
19
19
 
20
- var _styles = require("shineout/Input/styles");
20
+ var _styles = require("../Input/styles");
21
21
 
22
22
  var _element = require("../utils/dom/element");
23
23
 
@@ -59,7 +59,7 @@ function (_PureComponent) {
59
59
  _proto.getDefaultTime = function getDefaultTime() {
60
60
  var idx = 0;
61
61
 
62
- var current = _utils.default.newDate();
62
+ var current = _utils.default.newDate(undefined, this.getOptions());
63
63
 
64
64
  var _this$props = this.props,
65
65
  index = _this$props.index,
@@ -88,7 +88,7 @@ export interface DatePickerProps<T = DatePickerValue> extends StandardProps,
88
88
  *
89
89
  * default: props.format
90
90
  */
91
- formatResult?: string | ((date: Date) => string);
91
+ formatResult?: string | ((date: Date, offsetDate: Date) => string);
92
92
 
93
93
  /**
94
94
  * a callback when the value is changing
@@ -102,7 +102,7 @@ function transDateWithZone(dd, options, back) {
102
102
  console.error(new Error("timeZone is not supported: " + options.timeZone));
103
103
  }
104
104
 
105
- return dd;
105
+ return new Date(dd);
106
106
  }
107
107
 
108
108
  function addDays(date, offset, options) {
@@ -274,7 +274,7 @@ function isInvalid(date) {
274
274
  function toDateWithFormat(dirtyDate, fmt, def, options) {
275
275
  var date;
276
276
 
277
- if (typeof dirtyDate === 'string') {
277
+ if (typeof dirtyDate === 'string' && fmt) {
278
278
  date = parse(dirtyDate, fmt, options);
279
279
  var str = format(date, fmt, options);
280
280
 
@@ -339,24 +339,27 @@ function newDate(defaultDate, options) {
339
339
  return ud;
340
340
  }
341
341
 
342
- function setTime(date, old) {
343
- date.setHours(old.getHours());
344
- date.setMinutes(old.getMinutes());
345
- date.setSeconds(old.getSeconds());
346
- date.setMilliseconds(old.getMilliseconds());
347
- return date;
342
+ function setTime(date, old, options) {
343
+ var zd = transDateWithZone(date, options);
344
+ var oldZd = transDateWithZone(old, options);
345
+ zd.setHours(oldZd.getHours());
346
+ zd.setMinutes(oldZd.getMinutes());
347
+ zd.setSeconds(oldZd.getSeconds());
348
+ zd.setMilliseconds(oldZd.getMilliseconds());
349
+ var ud = transDateWithZone(zd, options, true);
350
+ return ud;
348
351
  }
349
352
 
350
353
  function cloneTime(date, old, fmt, options) {
351
354
  if (!date) return date;
352
355
  var oldDate = toDateWithFormat(old, fmt, undefined, options);
353
356
  if (isInvalid(oldDate)) return date;
354
- return setTime(date, oldDate);
357
+ return setTime(date, oldDate, options);
355
358
  }
356
359
 
357
360
  function formatDateWithDefaultTime(date, value, defaultTime, fmt, options) {
358
361
  if (!date) return date;
359
- if (value) return setTime(date, value);
362
+ if (value) return setTime(date, value, options);
360
363
  if (!defaultTime) return date;
361
364
  var dateHMS = toDateWithFormat(defaultTime, TIME_FORMAT, undefined, options);
362
365
  if (isInvalid(dateHMS)) return date;
@@ -405,7 +408,8 @@ function resetTimeByFormat(value, fo, options) {
405
408
  }
406
409
 
407
410
  function formatted(date, fmt, options) {
408
- if (typeof fmt === 'function') return fmt(date);
411
+ var offsetDate = transDateWithZone(date, options);
412
+ if (typeof fmt === 'function') return fmt(date, offsetDate);
409
413
  return format(date, fmt, options);
410
414
  }
411
415
 
@@ -439,6 +443,7 @@ var _default = {
439
443
  TIME_FORMAT: TIME_FORMAT,
440
444
  resetTimeByFormat: resetTimeByFormat,
441
445
  changeDate: changeDate,
442
- getDateInfo: getDateInfo
446
+ getDateInfo: getDateInfo,
447
+ transDateWithZone: transDateWithZone
443
448
  };
444
449
  exports.default = _default;
package/css/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as utils from './utils'
3
3
 
4
4
  declare const __default: {
5
5
  utils: typeof utils,
6
- version: '1.12.4'
6
+ version: '1.12.6-beta.1'
7
7
  }
8
8
 
9
9
  export default __default
package/css/index.js CHANGED
@@ -224,6 +224,6 @@ exports.Upload = _Upload.default;
224
224
  // Created by scripts/src-index.js.
225
225
  var _default = {
226
226
  utils: utils,
227
- version: '1.12.4'
227
+ version: '1.12.6-beta.1'
228
228
  };
229
229
  exports.default = _default;