@trionesdev/antd-taro-react 0.0.2-beta.11 → 0.0.2-beta.13

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.
Files changed (70) hide show
  1. package/dist/Calendar/calendar.js +0 -3
  2. package/dist/Calendar/touchable-calendar-grid.js +16 -16
  3. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts +4 -4
  4. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.js +144 -48
  5. package/dist/CalendarDatetimePicker/style.scss +52 -14
  6. package/dist/CalendarDatetimePicker/types.d.ts +4 -0
  7. package/dist/CalendarDatetimePicker/types.js +6 -1
  8. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.d.ts +9 -0
  9. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.js +60 -0
  10. package/dist/CalendarDatetimePickerCell/index.d.ts +3 -0
  11. package/dist/CalendarDatetimePickerCell/index.js +2 -0
  12. package/dist/CalendarPicker/CalendarPicker.d.ts +4 -0
  13. package/dist/{CalendarPopup/CalendarPopup.js → CalendarPicker/CalendarPicker.js} +3 -2
  14. package/dist/CalendarPicker/CalendarRangePicker.d.ts +4 -0
  15. package/dist/{CalendarPopup/CalendarRangePopup.js → CalendarPicker/CalendarRangePicker.js} +3 -2
  16. package/dist/CalendarPicker/index.d.ts +8 -0
  17. package/dist/CalendarPicker/index.js +5 -0
  18. package/dist/{CalendarPopup → CalendarPicker}/style.scss +2 -2
  19. package/dist/{CalendarPopup → CalendarPicker}/types.d.ts +3 -3
  20. package/dist/CalendarPicker/types.js +1 -0
  21. package/dist/CalendarPickerCell/CalendarPickerCell.d.ts +11 -0
  22. package/dist/CalendarPickerCell/CalendarPickerCell.js +54 -0
  23. package/dist/CalendarPickerCell/CalendarRangePickerCell.d.ts +11 -0
  24. package/dist/CalendarPickerCell/CalendarRangePickerCell.js +56 -0
  25. package/dist/CalendarPickerCell/index.d.ts +8 -0
  26. package/dist/CalendarPickerCell/index.js +5 -0
  27. package/dist/{CascaderPopup/cascader-popup.d.ts → CascaderPicker/cascader-picker.d.ts} +2 -2
  28. package/dist/{CascaderPopup/cascader-popup.js → CascaderPicker/cascader-picker.js} +8 -8
  29. package/dist/CascaderPicker/index.d.ts +1 -1
  30. package/dist/CascaderPicker/index.js +1 -1
  31. package/dist/CascaderPicker/style.scss +33 -12
  32. package/dist/{CascaderPicker/CascaderPicker.d.ts → CascaderPickerCell/CascaderPickerCell.d.ts} +4 -9
  33. package/dist/{CascaderPicker/CascaderPicker.js → CascaderPickerCell/CascaderPickerCell.js} +6 -14
  34. package/dist/CascaderPickerCell/index.d.ts +3 -0
  35. package/dist/CascaderPickerCell/index.js +2 -0
  36. package/dist/DatePicker/DatePicker.d.ts +8 -6
  37. package/dist/DatePicker/DatePicker.js +293 -50
  38. package/dist/DatePicker/index.d.ts +2 -1
  39. package/dist/DatePicker/style.scss +1 -24
  40. package/dist/DatePickerCell/DatePickerCell.d.ts +14 -0
  41. package/dist/DatePickerCell/DatePickerCell.js +79 -0
  42. package/dist/DatePickerCell/index.d.ts +3 -0
  43. package/dist/DatePickerCell/index.js +2 -0
  44. package/dist/Input/taro-input.js +5 -2
  45. package/dist/Input/types.d.ts +1 -0
  46. package/dist/Picker/Picker.js +30 -4
  47. package/dist/index.d.ts +11 -6
  48. package/dist/index.js +5 -3
  49. package/dist/utils/dayjs.d.ts +2 -1
  50. package/dist/utils/dayjs.js +13 -0
  51. package/package.json +4 -4
  52. package/dist/CalendarDatetimePopup/CalendarDatetimePopup.d.ts +0 -11
  53. package/dist/CalendarDatetimePopup/CalendarDatetimePopup.js +0 -164
  54. package/dist/CalendarDatetimePopup/index.d.ts +0 -3
  55. package/dist/CalendarDatetimePopup/index.js +0 -2
  56. package/dist/CalendarDatetimePopup/style.scss +0 -62
  57. package/dist/CalendarDatetimePopup/types.d.ts +0 -5
  58. package/dist/CalendarDatetimePopup/types.js +0 -6
  59. package/dist/CalendarPopup/CalendarPopup.d.ts +0 -4
  60. package/dist/CalendarPopup/CalendarRangePopup.d.ts +0 -4
  61. package/dist/CalendarPopup/index.d.ts +0 -8
  62. package/dist/CalendarPopup/index.js +0 -5
  63. package/dist/CalendarPopup/types.js +0 -1
  64. package/dist/CascaderPopup/index.d.ts +0 -3
  65. package/dist/CascaderPopup/index.js +0 -2
  66. package/dist/CascaderPopup/style.scss +0 -45
  67. package/dist/DatePicker/DatePickerPopup.d.ts +0 -18
  68. package/dist/DatePicker/DatePickerPopup.js +0 -329
  69. /package/dist/{CalendarDatetimePopup → CalendarDatetimePicker}/DateTimeSwitch.d.ts +0 -0
  70. /package/dist/{CalendarDatetimePopup → CalendarDatetimePicker}/DateTimeSwitch.js +0 -0
@@ -39,9 +39,6 @@ export var Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref,
39
39
  setCurrentMonth(dayjs(month));
40
40
  }
41
41
  }, [month]);
42
- useEffect(function () {
43
- console.log('calendar value', value);
44
- }, [value]);
45
42
  return /*#__PURE__*/React.createElement("div", {
46
43
  ref: ref,
47
44
  className: classNames("".concat(calendarCls))
@@ -37,7 +37,7 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
37
37
  isTaroWeApp = _useTaro.isTaroWeApp;
38
38
  var wrapperRef = useRef();
39
39
  var wrapperUniqueRef = React.useRef(RandomUtils.random());
40
- var _useState = useState(month || dayjs()),
40
+ var _useState = useState(dayjs(month)),
41
41
  _useState2 = _slicedToArray(_useState, 2),
42
42
  currentMonth = _useState2[0],
43
43
  setCurrentMonth = _useState2[1];
@@ -64,8 +64,8 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
64
64
  setTranslateY = _useState8[1];
65
65
  var _useState9 = useState([]),
66
66
  _useState10 = _slicedToArray(_useState9, 2),
67
- mouths = _useState10[0],
68
- setMouths = _useState10[1];
67
+ months = _useState10[0],
68
+ setMonths = _useState10[1];
69
69
 
70
70
  /**
71
71
  * 计算出每个格子的大小
@@ -159,10 +159,10 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
159
159
  // }
160
160
  // debugger
161
161
  // waiting = true
162
- firstMouth = mouths[0];
162
+ firstMouth = months[0];
163
163
  insertMouth = dayjs(new Date(firstMouth.year(), firstMouth.month() - 1, 1));
164
- newMouths = [insertMouth].concat(_toConsumableArray(mouths));
165
- setMouths(newMouths);
164
+ newMouths = [insertMouth].concat(_toConsumableArray(months));
165
+ setMonths(newMouths);
166
166
  // const insertMouthLines = mouthLines(insertMouth);
167
167
  _context3.t0 = monthLines;
168
168
  _context3.next = 7;
@@ -187,20 +187,20 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
187
187
  // return
188
188
  // }
189
189
  // waiting = true
190
- var lastMouth = mouths[mouths.length - 1];
190
+ var lastMouth = months[months.length - 1];
191
191
  var appendMouth = lastMouth.add(1, 'month');
192
- var newMouths = [].concat(_toConsumableArray(mouths), [appendMouth]);
193
- setMouths(newMouths);
192
+ var newMouths = [].concat(_toConsumableArray(months), [appendMouth]);
193
+ setMonths(newMouths);
194
194
  // waiting = false
195
195
  };
196
196
  useEffect(function () {
197
- var initMouths = [currentMonth.clone().subtract(1, 'month'), currentMonth.clone(), currentMonth.clone().add(1, 'month')];
197
+ var initMonths = [currentMonth.clone().subtract(1, 'month'), currentMonth.clone(), currentMonth.clone().add(1, 'month')];
198
198
  Promise.all([]).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
199
199
  var firstMouthHeight;
200
200
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
201
201
  while (1) switch (_context4.prev = _context4.next) {
202
202
  case 0:
203
- setMouths(initMouths);
203
+ setMonths(initMonths);
204
204
  _context4.t0 = setMouthHeight;
205
205
  _context4.t1 = monthLines;
206
206
  _context4.next = 5;
@@ -345,12 +345,12 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
345
345
  }
346
346
  return _context6.abrupt("return");
347
347
  case 3:
348
- console.log(mouths);
348
+ console.log(months);
349
349
  //region 判断当前月份是否在视窗内
350
350
  _mouthHeightSum = 0;
351
351
  i = 0;
352
352
  case 6:
353
- if (!(i < mouths.length)) {
353
+ if (!(i < months.length)) {
354
354
  _context6.next = 28;
355
355
  break;
356
356
  }
@@ -378,7 +378,7 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
378
378
  break;
379
379
  }
380
380
  // console.log('displayMouth', mouths[i]);
381
- displayMouth = mouths[i];
381
+ displayMouth = months[i];
382
382
  return _context6.abrupt("break", 28);
383
383
  case 19:
384
384
  _bottomLineY = 0 - _mouthHeightSum; //该月份区域底部,对于顶点的偏移量
@@ -399,7 +399,7 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
399
399
  break;
400
400
  }
401
401
  // console.log('displayMouth', mouths[i]);
402
- displayMouth = mouths[i];
402
+ displayMouth = months[i];
403
403
  return _context6.abrupt("break", 28);
404
404
  case 25:
405
405
  i++;
@@ -421,7 +421,7 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
421
421
  return _ref7.apply(this, arguments);
422
422
  };
423
423
  }())
424
- }, mouths.map(function (mouth, index) {
424
+ }, months.map(function (mouth, index) {
425
425
  return /*#__PURE__*/React.createElement(CalendarGrid, {
426
426
  key: index,
427
427
  month: mouth,
@@ -2,10 +2,10 @@ import { FC } from 'react';
2
2
  import './style.scss';
3
3
  import dayjs from "dayjs";
4
4
  export type CalendarDatetimePickerProps = {
5
- placeholder?: string;
5
+ open?: boolean;
6
+ afterOpenChange?: (open: boolean) => void;
6
7
  value?: dayjs.Dayjs | Date;
7
- format?: string;
8
- onChange?: (value?: dayjs.Dayjs) => void;
9
- align?: 'left' | 'right' | 'center';
8
+ onOk?: (value?: dayjs.Dayjs) => void;
9
+ onClose?: () => void;
10
10
  };
11
11
  export declare const CalendarDatetimePicker: FC<CalendarDatetimePickerProps>;
@@ -1,68 +1,164 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
6
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
7
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import { CustomWrapper, PickerView, PickerViewColumn, View } from '@tarojs/components';
12
+ import Taro from '@tarojs/taro';
11
13
  import classNames from 'classnames';
12
- import React, { useEffect, useState } from 'react';
14
+ import React, { useEffect, useRef, useState } from 'react';
15
+ import Calendar from "../Calendar";
16
+ import ConfigProvider from "../ConfigProvider";
17
+ import { useTaro } from "../hooks";
18
+ import Popup from "../Popup";
19
+ import { DateTimeSwitch } from "./DateTimeSwitch";
13
20
  import "./style.scss";
14
- import { cls } from "./types";
15
- import CalendarDatetimePopup from "../CalendarDatetimePopup";
21
+ import { cls, Mode } from "./types";
22
+ import { DatetimeUtils } from "../utils/datetime-utils";
16
23
  import dayjs from "dayjs";
17
- import { isSame } from "../utils/dayjs";
18
24
  export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
19
- var _ref$placeholder = _ref.placeholder,
20
- placeholder = _ref$placeholder === void 0 ? '请选择' : _ref$placeholder,
25
+ var open = _ref.open,
26
+ _afterOpenChange = _ref.afterOpenChange,
21
27
  value = _ref.value,
22
- _ref$format = _ref.format,
23
- format = _ref$format === void 0 ? 'YYYY-MM-DD HH:mm' : _ref$format,
24
- onChange = _ref.onChange,
25
- _ref$align = _ref.align,
26
- align = _ref$align === void 0 ? 'left' : _ref$align;
27
- var _React$useState = React.useState(false),
28
- _React$useState2 = _slicedToArray(_React$useState, 2),
29
- innerOpen = _React$useState2[0],
30
- setInnerOpen = _React$useState2[1];
31
- var _useState = useState(value ? dayjs(value) : undefined),
28
+ onOk = _ref.onOk,
29
+ _onClose = _ref.onClose;
30
+ var _ConfigProvider$useCo = ConfigProvider.useConfig(),
31
+ locale = _ConfigProvider$useCo.locale;
32
+ var _useTaro = useTaro(),
33
+ isTaroWeApp = _useTaro.isTaroWeApp;
34
+ var _useState = useState(Mode.date),
32
35
  _useState2 = _slicedToArray(_useState, 2),
33
- internalValue = _useState2[0],
34
- setInternalValue = _useState2[1];
35
- var handleValueRender = function handleValueRender() {
36
- if (internalValue) {
37
- return internalValue.format(format);
38
- }
39
- return null;
36
+ mode = _useState2[0],
37
+ setMode = _useState2[1];
38
+ var valueRef = useRef(dayjs(value));
39
+ var bodyRef = useRef(null);
40
+ var datetimeSwitchRef = useRef();
41
+ var _useState3 = useState(300),
42
+ _useState4 = _slicedToArray(_useState3, 2),
43
+ bodyHeight = _useState4[0],
44
+ setBodyHeight = _useState4[1];
45
+ var handleClose = function handleClose() {
46
+ _onClose === null || _onClose === void 0 || _onClose();
47
+ };
48
+ var handleOk = function handleOk() {
49
+ onOk === null || onOk === void 0 || onOk(valueRef.current);
50
+ handleClose();
40
51
  };
52
+ var handleComputeBodyHeight = /*#__PURE__*/function () {
53
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
54
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
55
+ while (1) switch (_context.prev = _context.next) {
56
+ case 0:
57
+ if (!isTaroWeApp) {
58
+ _context.next = 2;
59
+ break;
60
+ }
61
+ return _context.abrupt("return", new Promise(function (resolve) {
62
+ Taro.createSelectorQuery().in(bodyRef.current.ctx).select(".".concat(cls, "-body")).boundingClientRect()
63
+ // .fields({ node: true, size: true })
64
+ .exec(function (res) {
65
+ var _res$;
66
+ console.log(res);
67
+ resolve(res === null || res === void 0 || (_res$ = res[0]) === null || _res$ === void 0 ? void 0 : _res$.height);
68
+ });
69
+ }));
70
+ case 2:
71
+ return _context.abrupt("return", Promise.resolve(bodyRef.current.offsetHeight));
72
+ case 3:
73
+ case "end":
74
+ return _context.stop();
75
+ }
76
+ }, _callee);
77
+ }));
78
+ return function handleComputeBodyHeight() {
79
+ return _ref2.apply(this, arguments);
80
+ };
81
+ }();
41
82
  useEffect(function () {
42
- if (value === undefined) {
43
- return;
83
+ if (datetimeSwitchRef.current) {
84
+ datetimeSwitchRef.current.setDatetime(valueRef.current);
44
85
  }
45
- if (!isSame(value, internalValue)) {
46
- setInternalValue(dayjs(value));
47
- }
48
- }, [value]);
49
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CalendarDatetimePopup, {
50
- open: innerOpen,
51
- value: internalValue || dayjs(),
52
- onClose: function onClose() {
53
- setInnerOpen(false);
86
+ }, []);
87
+ var bodyRender = function bodyRender() {
88
+ return /*#__PURE__*/React.createElement(React.Fragment, null, mode === Mode.date && /*#__PURE__*/React.createElement("div", {
89
+ style: {}
90
+ }, /*#__PURE__*/React.createElement(Calendar, {
91
+ month: value,
92
+ value: value,
93
+ onChange: function onChange(date) {
94
+ var _datetimeSwitchRef$cu;
95
+ valueRef.current = dayjs(new Date(date.year(), date.month(), date.date(), valueRef.current.hour(), valueRef.current.minute()));
96
+ (_datetimeSwitchRef$cu = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu === void 0 || _datetimeSwitchRef$cu.setDatetime(valueRef.current);
97
+ }
98
+ })), mode === Mode.time && /*#__PURE__*/React.createElement("div", {
99
+ style: {
100
+ height: bodyHeight
101
+ }
102
+ }, /*#__PURE__*/React.createElement(PickerView, {
103
+ className: "time-picker",
104
+ indicatorStyle: "height: 32Px;",
105
+ style: {
106
+ height: bodyHeight
107
+ },
108
+ value: [valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.hour(), valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.minute()],
109
+ onChange: function onChange(e) {
110
+ var _datetimeSwitchRef$cu2;
111
+ var v = e.detail.value;
112
+ valueRef.current = dayjs(new Date(valueRef.current.year(), valueRef.current.month(), valueRef.current.date(), v[0], v[1]));
113
+ (_datetimeSwitchRef$cu2 = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu2 === void 0 || _datetimeSwitchRef$cu2.setDatetime(valueRef.current);
114
+ }
115
+ }, /*#__PURE__*/React.createElement(PickerViewColumn, null, Array(24).fill(0).map(function (_, i) {
116
+ return /*#__PURE__*/React.createElement(View, {
117
+ key: "hour-".concat(i),
118
+ className: "time-item"
119
+ }, DatetimeUtils.twoDigits(i));
120
+ })), /*#__PURE__*/React.createElement(PickerViewColumn, null, Array(60).fill(0).map(function (_, i) {
121
+ return /*#__PURE__*/React.createElement(View, {
122
+ key: "minute-".concat(i),
123
+ className: "time-item"
124
+ }, DatetimeUtils.twoDigits(i));
125
+ })))));
126
+ };
127
+ return /*#__PURE__*/React.createElement(Popup, {
128
+ open: open,
129
+ round: true,
130
+ afterOpenChange: function afterOpenChange(o) {
131
+ if (!o) {
132
+ setMode(Mode.date);
133
+ }
134
+ _afterOpenChange === null || _afterOpenChange === void 0 || _afterOpenChange(o);
54
135
  },
55
- onOk: function onOk(date) {
56
- setInternalValue(date);
57
- setInnerOpen(false);
58
- onChange === null || onChange === void 0 || onChange(date);
136
+ onClose: function onClose() {
137
+ _onClose === null || _onClose === void 0 || _onClose();
59
138
  }
60
- }), /*#__PURE__*/React.createElement("div", {
61
- className: classNames(cls, _defineProperty({}, "".concat(cls, "-").concat(align), true)),
62
- onClick: function onClick() {
63
- setInnerOpen(true);
139
+ }, /*#__PURE__*/React.createElement("div", {
140
+ className: classNames(cls)
141
+ }, /*#__PURE__*/React.createElement("div", {
142
+ className: "".concat(cls, "-header")
143
+ }, /*#__PURE__*/React.createElement(DateTimeSwitch, {
144
+ ref: datetimeSwitchRef,
145
+ mode: mode,
146
+ value: valueRef.current,
147
+ onDateTabTap: function onDateTabTap() {
148
+ return setMode(Mode.date);
149
+ },
150
+ onTimeTabTap: function onTimeTabTap() {
151
+ handleComputeBodyHeight().then(function (height) {
152
+ setBodyHeight(height);
153
+ setMode(Mode.time);
154
+ });
64
155
  }
65
- }, !internalValue ? /*#__PURE__*/React.createElement("div", {
66
- className: "".concat(cls, "-placeholder")
67
- }, placeholder) : /*#__PURE__*/React.createElement("div", null, handleValueRender())));
156
+ }), /*#__PURE__*/React.createElement("a", {
157
+ className: classNames("".concat(cls, "-header-button"), "".concat(cls, "-header-button-ok")),
158
+ onClick: handleOk
159
+ }, locale.common.confirm)), /*#__PURE__*/React.createElement(CustomWrapper, {
160
+ ref: bodyRef
161
+ }, /*#__PURE__*/React.createElement("div", {
162
+ className: "".concat(cls, "-body")
163
+ }, bodyRender()))));
68
164
  };
@@ -1,24 +1,62 @@
1
1
  @use "../style/variable" as variable;
2
+
2
3
  $calendarDatetimePickerCls: 'triones-antm-calendar-datetime-picker';
3
4
 
4
5
  .#{$calendarDatetimePickerCls} {
5
- width: 100%;
6
- line-height: 1.4;
7
- display: flex;
6
+ border-top-left-radius: variable.$trionesBorderRadius;
7
+ border-top-right-radius: variable.$trionesBorderRadius;
8
8
 
9
- &-left {
10
- justify-content: flex-start;
11
- }
9
+ &-header {
10
+ display: flex;
11
+ justify-content: space-between;
12
+ border-bottom: 1Px solid variable.$trionesBorderColor;
12
13
 
13
- &-center {
14
- justify-content: center;
15
- }
16
14
 
17
- &-right {
18
- justify-content: flex-end;
15
+ &-display {
16
+ display: flex;
17
+ padding-left: 8Px;
18
+
19
+ &-date {
20
+ padding-inline: 8Px;
21
+ cursor: default;
22
+ display: flex;
23
+ align-items: center;
24
+ }
25
+
26
+ &-time {
27
+ padding-inline: 12Px;
28
+ display: flex;
29
+ align-items: center;
30
+ cursor: default;
31
+ }
32
+
33
+ &-active {
34
+ color: variable.$trionesColorText;
35
+ font-weight: bold;
36
+ background-color: variable.$trionesColorBgTextActive;
37
+ }
38
+ }
39
+
40
+ &-button {
41
+ padding: 12Px 16Px;
42
+
43
+ &-cancel {}
44
+
45
+ &-ok {
46
+ color: variable.$trionesColorPrimary;
47
+ }
48
+ }
19
49
  }
20
50
 
21
- &-placeholder {
22
- color: variable.$trionesColorTextPlaceholder;
51
+ &-body {
52
+ .time-picker {
53
+ .time-item {
54
+ flex-shrink: 0;
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: center;
58
+ height: 32Px;
59
+ }
60
+ }
23
61
  }
24
- }
62
+ }
@@ -1 +1,5 @@
1
1
  export declare const cls = "triones-antm-calendar-datetime-picker";
2
+ export declare enum Mode {
3
+ date = 0,
4
+ time = 1
5
+ }
@@ -1 +1,6 @@
1
- export var cls = 'triones-antm-calendar-datetime-picker';
1
+ export var cls = 'triones-antm-calendar-datetime-picker';
2
+ export var Mode = /*#__PURE__*/function (Mode) {
3
+ Mode[Mode["date"] = 0] = "date";
4
+ Mode[Mode["time"] = 1] = "time";
5
+ return Mode;
6
+ }({});
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import dayjs from "dayjs";
3
+ import { CellProps } from "../Cell";
4
+ export type CalendarDatetimePickerCellProps = Omit<CellProps, 'value'> & {
5
+ value?: dayjs.Dayjs | Date;
6
+ format?: string;
7
+ onChange?: (value?: dayjs.Dayjs) => void;
8
+ };
9
+ export declare const CalendarDatetimePickerCell: FC<CalendarDatetimePickerCellProps>;
@@ -0,0 +1,60 @@
1
+ var _excluded = ["value", "format", "onChange"];
2
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
+ import React, { useEffect, useState } from 'react';
12
+ import CalendarDatetimePicker from "../CalendarDatetimePicker";
13
+ import dayjs from "dayjs";
14
+ import { isSame } from "../utils/dayjs";
15
+ import Cell from "../Cell";
16
+ export var CalendarDatetimePickerCell = function CalendarDatetimePickerCell(_ref) {
17
+ var value = _ref.value,
18
+ _ref$format = _ref.format,
19
+ format = _ref$format === void 0 ? 'YYYY-MM-DD HH:mm' : _ref$format,
20
+ onChange = _ref.onChange,
21
+ rest = _objectWithoutProperties(_ref, _excluded);
22
+ var _React$useState = React.useState(false),
23
+ _React$useState2 = _slicedToArray(_React$useState, 2),
24
+ innerOpen = _React$useState2[0],
25
+ setInnerOpen = _React$useState2[1];
26
+ var _useState = useState(value ? dayjs(value) : undefined),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ internalValue = _useState2[0],
29
+ setInternalValue = _useState2[1];
30
+ var handleValueRender = function handleValueRender() {
31
+ if (internalValue) {
32
+ return internalValue.format(format);
33
+ }
34
+ return null;
35
+ };
36
+ useEffect(function () {
37
+ if (value === undefined) {
38
+ return;
39
+ }
40
+ if (!isSame(value, internalValue)) {
41
+ setInternalValue(dayjs(value));
42
+ }
43
+ }, [value]);
44
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CalendarDatetimePicker, {
45
+ open: innerOpen,
46
+ value: internalValue || dayjs(),
47
+ onClose: function onClose() {
48
+ setInnerOpen(false);
49
+ },
50
+ onOk: function onOk(date) {
51
+ setInternalValue(date);
52
+ setInnerOpen(false);
53
+ onChange === null || onChange === void 0 || onChange(date);
54
+ }
55
+ }), /*#__PURE__*/React.createElement(Cell, _extends({
56
+ onClick: function onClick() {
57
+ setInnerOpen(true);
58
+ }
59
+ }, rest), handleValueRender()));
60
+ };
@@ -0,0 +1,3 @@
1
+ import { CalendarDatetimePickerCell, CalendarDatetimePickerCellProps } from "./CalendarDatetimePickerCell";
2
+ export type { CalendarDatetimePickerCellProps };
3
+ export default CalendarDatetimePickerCell;
@@ -0,0 +1,2 @@
1
+ import { CalendarDatetimePickerCell } from "./CalendarDatetimePickerCell";
2
+ export default CalendarDatetimePickerCell;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import './style.scss';
3
+ import { CalendarPickerProps } from './types';
4
+ export declare const CalendarPicker: FC<CalendarPickerProps>;
@@ -12,7 +12,8 @@ import Popup from "../Popup";
12
12
  import "./style.scss";
13
13
  import { cls } from "./types";
14
14
  import dayjs from "dayjs";
15
- export var CalendarPopup = /*#__PURE__*/memo(function (_ref) {
15
+ import { isSame } from "../utils/dayjs";
16
+ export var CalendarPicker = /*#__PURE__*/memo(function (_ref) {
16
17
  var month = _ref.month,
17
18
  open = _ref.open,
18
19
  title = _ref.title,
@@ -46,7 +47,7 @@ export var CalendarPopup = /*#__PURE__*/memo(function (_ref) {
46
47
  }, [innerOpen]);
47
48
  useEffect(function () {
48
49
  if (value !== undefined) {
49
- if (value !== valueRef.current) {
50
+ if (!isSame(value, valueRef.current, 'day')) {
50
51
  valueRef.current = value;
51
52
  }
52
53
  }
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import "./style.scss";
3
+ import { CalendarPickerRangeProps } from "./types";
4
+ export declare const CalendarRangePicker: FC<CalendarPickerRangeProps>;
@@ -11,7 +11,8 @@ import Calendar from "../Calendar";
11
11
  import "./style.scss";
12
12
  import { cls } from "./types";
13
13
  import ConfigProvider from "../ConfigProvider";
14
- export var CalendarRangePopup = /*#__PURE__*/memo(function (_ref) {
14
+ import { isSameArray } from "../utils/dayjs";
15
+ export var CalendarRangePicker = /*#__PURE__*/memo(function (_ref) {
15
16
  var month = _ref.month,
16
17
  open = _ref.open,
17
18
  title = _ref.title,
@@ -44,7 +45,7 @@ export var CalendarRangePopup = /*#__PURE__*/memo(function (_ref) {
44
45
  }, [innerOpen]);
45
46
  useEffect(function () {
46
47
  if (value !== undefined) {
47
- if (value !== valueRef.current) {
48
+ if (!isSameArray(value, valueRef.current, 'day')) {
48
49
  valueRef.current = value;
49
50
  }
50
51
  }
@@ -0,0 +1,8 @@
1
+ import { CalendarPicker as InternalCalendarPicker } from "./CalendarPicker";
2
+ import { CalendarRangePicker } from "./CalendarRangePicker";
3
+ type CompoundedComponent = typeof InternalCalendarPicker & {
4
+ Range: typeof CalendarRangePicker;
5
+ };
6
+ declare const CalendarPicker: CompoundedComponent;
7
+ export type { CalendarPickerProps, CalendarPickerRangeProps } from "./types";
8
+ export default CalendarPicker;
@@ -0,0 +1,5 @@
1
+ import { CalendarPicker as InternalCalendarPicker } from "./CalendarPicker";
2
+ import { CalendarRangePicker } from "./CalendarRangePicker";
3
+ var CalendarPicker = InternalCalendarPicker;
4
+ CalendarPicker.Range = CalendarRangePicker;
5
+ export default CalendarPicker;
@@ -1,8 +1,8 @@
1
1
  @use "../style/variable" as variable;
2
2
 
3
- $calendarPopupCls: 'triones-antm-calendar-popup';
3
+ $calendarPickerCls: 'triones-antm-calendar-picker';
4
4
 
5
- .#{$calendarPopupCls} {
5
+ .#{$calendarPickerCls} {
6
6
  border-top-left-radius: variable.$trionesBorderRadius;
7
7
  border-top-right-radius: variable.$trionesBorderRadius;
8
8
 
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import dayjs from "dayjs";
3
- export declare const cls = "triones-antm-calendar-popup";
4
- export type CalendarPopupProps = {
3
+ export declare const cls = "triones-antm-calendar-picker";
4
+ export type CalendarPickerProps = {
5
5
  month?: dayjs.Dayjs;
6
6
  open?: boolean;
7
7
  title?: React.ReactNode;
@@ -11,7 +11,7 @@ export type CalendarPopupProps = {
11
11
  onCancel?: () => void;
12
12
  onClose?: () => void;
13
13
  };
14
- export type CalendarPopupRangeProps = {
14
+ export type CalendarPickerRangeProps = {
15
15
  month?: dayjs.Dayjs;
16
16
  open?: boolean;
17
17
  title?: React.ReactNode;
@@ -0,0 +1 @@
1
+ export var cls = 'triones-antm-calendar-picker';