@trionesdev/antd-mobile-react 0.0.2-beta.1 → 0.0.2-beta.10
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.
- package/LICENSE +21 -21
- package/dist/ActionSheet/ActionSheet.d.ts +25 -0
- package/dist/ActionSheet/ActionSheet.js +77 -0
- package/dist/ActionSheet/index.d.ts +1 -1
- package/dist/ActionSheet/index.js +1 -1
- package/dist/ActionSheet/style.scss +52 -0
- package/dist/Avatar/demo/base.js +2 -2
- package/dist/Avatar/demo/style.scss +6 -6
- package/dist/Badge/demo/base.js +2 -2
- package/dist/Badge/demo/base.scss +6 -6
- package/dist/Button/demo/base.js +2 -2
- package/dist/Button/style.scss +234 -232
- package/dist/Calendar/calendar.js +2 -1
- package/dist/Calendar/style.scss +85 -85
- package/dist/Calendar/touchable-calendar-grid.js +9 -9
- package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts +5 -6
- package/dist/CalendarDatetimePicker/CalendarDatetimePicker.js +37 -132
- package/dist/CalendarDatetimePicker/demo/base.js +5 -21
- package/dist/CalendarDatetimePicker/index.d.ts +2 -2
- package/dist/CalendarDatetimePicker/style.scss +10 -54
- package/dist/CalendarDatetimePicker/types.d.ts +0 -4
- package/dist/CalendarDatetimePicker/types.js +1 -6
- package/dist/CalendarDatetimePopup/CalendarDatetimePopup.d.ts +10 -0
- package/dist/CalendarDatetimePopup/CalendarDatetimePopup.js +136 -0
- package/dist/CalendarDatetimePopup/demo/base.js +41 -0
- package/dist/CalendarDatetimePopup/index.d.ts +3 -0
- package/dist/CalendarDatetimePopup/index.js +2 -0
- package/dist/CalendarDatetimePopup/style.scss +54 -0
- package/dist/CalendarDatetimePopup/types.d.ts +5 -0
- package/dist/CalendarDatetimePopup/types.js +6 -0
- package/dist/CalendarPopup/calendar-popup.d.ts +4 -0
- package/dist/{CalendarPicker/calendar-picker.js → CalendarPopup/calendar-popup.js} +2 -2
- package/dist/CalendarPopup/calendar-range-popup.d.ts +4 -0
- package/dist/{CalendarPicker/calendar-range-picker.js → CalendarPopup/calendar-range-popup.js} +8 -7
- package/dist/{CalendarPicker → CalendarPopup}/demo/base.js +3 -3
- package/dist/CalendarPopup/index.d.ts +9 -0
- package/dist/CalendarPopup/index.js +5 -0
- package/dist/CalendarPopup/style.scss +31 -0
- package/dist/{CalendarPicker → CalendarPopup}/types.d.ts +2 -2
- package/dist/Card/demo/base.js +2 -2
- package/dist/Card/demo/base.scss +18 -18
- package/dist/CascaderPicker/CascaderPicker.d.ts +25 -0
- package/dist/CascaderPicker/CascaderPicker.js +78 -0
- package/dist/CascaderPicker/demo/base.js +6 -18
- package/dist/CascaderPicker/index.d.ts +1 -1
- package/dist/CascaderPicker/index.js +1 -1
- package/dist/CascaderPicker/style.scss +24 -0
- package/dist/CascaderPopup/cascader-popup.d.ts +27 -0
- package/dist/CascaderPopup/cascader-popup.js +90 -0
- package/dist/CascaderPopup/demo/base.d.ts +3 -0
- package/dist/CascaderPopup/demo/base.js +82 -0
- package/dist/CascaderPopup/index.d.ts +3 -0
- package/dist/CascaderPopup/index.js +2 -0
- package/dist/CascaderPopup/style.scss +45 -0
- package/dist/Cell/demo/base.js +41 -2
- package/dist/Checkbox/demo/base.js +11 -6
- package/dist/Checkbox/demo/disabled.js +2 -1
- package/dist/ConfigProvider/demo/base.js +2 -2
- package/dist/DemoBlock/index.d.ts +6 -0
- package/dist/DemoBlock/index.js +9 -2
- package/dist/DemoBlock/index.scss +20 -20
- package/dist/DemoDescription/index.scss +3 -3
- package/dist/Divider/demo/base.js +2 -2
- package/dist/Ellipsis/demo/base.js +2 -2
- package/dist/Empty/demo/base.js +2 -2
- package/dist/ErrorBlock/demo/base.js +2 -2
- package/dist/Footer/demo/base.js +2 -2
- package/dist/Form/FormItem/form-item-input.d.ts +15 -0
- package/dist/Form/FormItem/form-item-input.js +39 -0
- package/dist/Form/FormItem/form-item-label.d.ts +13 -0
- package/dist/Form/FormItem/form-item-label.js +27 -0
- package/dist/Form/FormItem/form-item.d.ts +22 -0
- package/dist/Form/FormItem/form-item.js +73 -0
- package/dist/Form/FormItem/index.d.ts +5 -0
- package/dist/Form/FormItem/index.js +3 -0
- package/dist/Form/demo/input.js +1 -1
- package/dist/Form/index.d.ts +8 -1
- package/dist/Form/index.js +5 -1
- package/dist/Form/style.scss +67 -0
- package/dist/Grid/demo/base.js +2 -2
- package/dist/Grid/demo/base.scss +7 -7
- package/dist/Icon/demo/base.js +2 -2
- package/dist/Image/demo/base.js +2 -2
- package/dist/Image/demo/base.scss +4 -4
- package/dist/Image/style.scss +30 -30
- package/dist/ImagesPreview/ImagesPreview.js +2 -2
- package/dist/ImagesPreview/style.scss +34 -34
- package/dist/ImagesWall/CameraModal.js +2 -2
- package/dist/ImagesWall/style.scss +70 -70
- package/dist/Input/base-input.d.ts +13 -0
- package/dist/Input/base-input.js +41 -0
- package/dist/Input/demo/base.js +89 -13
- package/dist/Input/index.d.ts +14 -2
- package/dist/Input/index.js +11 -1
- package/dist/Input/index.scss +223 -0
- package/dist/Input/input-affix-wrapper.d.ts +11 -0
- package/dist/Input/input-affix-wrapper.js +37 -0
- package/dist/Input/input-opt.d.ts +16 -0
- package/dist/Input/input-opt.js +87 -0
- package/dist/Input/input-password.d.ts +7 -0
- package/dist/Input/input-password.js +48 -0
- package/dist/Input/input.d.ts +18 -0
- package/dist/Input/input.js +63 -0
- package/dist/Input/textarea.d.ts +15 -0
- package/dist/Input/textarea.js +51 -0
- package/dist/Input/types.d.ts +3 -0
- package/dist/Input/types.js +2 -0
- package/dist/NavBar/demo/base.scss +5 -5
- package/dist/NoticeBar/demo/base.js +2 -2
- package/dist/Overlay/Overlay.d.ts +16 -0
- package/dist/Overlay/Overlay.js +117 -0
- package/dist/Overlay/demo/base.d.ts +3 -0
- package/dist/{Mask → Overlay}/demo/base.js +14 -16
- package/dist/Overlay/index.d.ts +4 -0
- package/dist/Overlay/index.js +3 -0
- package/dist/Overlay/style.scss +20 -0
- package/dist/PageIndicator/demo/base.js +2 -2
- package/dist/Picker/index.d.ts +1 -1
- package/dist/Picker/index.js +1 -1
- package/dist/Picker/picker.d.ts +19 -0
- package/dist/Picker/picker.js +97 -0
- package/dist/Picker/style.scss +44 -0
- package/dist/PickerView/index.d.ts +2 -1
- package/dist/PickerView/index.js +1 -1
- package/dist/PickerView/picker-view-column-item.d.ts +7 -0
- package/dist/PickerView/picker-view-column-item.js +11 -0
- package/dist/PickerView/picker-view-column.d.ts +10 -0
- package/dist/PickerView/picker-view-column.js +117 -0
- package/dist/PickerView/picker-view.d.ts +12 -0
- package/dist/PickerView/picker-view.js +60 -0
- package/dist/PickerView/style.scss +72 -0
- package/dist/PickerView/types.d.ts +4 -0
- package/dist/PickerView/types.js +1 -0
- package/dist/Popup/demo/base.js +109 -27
- package/dist/Popup/index.d.ts +2 -1
- package/dist/Popup/index.js +2 -1
- package/dist/Popup/popup.d.ts +31 -0
- package/dist/Popup/popup.js +87 -0
- package/dist/Popup/style.scss +129 -0
- package/dist/Progress/index.d.ts +1 -1
- package/dist/Progress/index.js +1 -1
- package/dist/Radio/demo/base.js +2 -2
- package/dist/Radio/demo/base.scss +4 -4
- package/dist/Result/demo/base.js +2 -2
- package/dist/SafeArea/demo/base.scss +18 -18
- package/dist/ScrollView/index.d.ts +2 -1
- package/dist/ScrollView/index.js +1 -1
- package/dist/ScrollView/scroll-view.d.ts +4 -0
- package/dist/ScrollView/scroll-view.js +55 -0
- package/dist/ScrollView/style.scss +19 -0
- package/dist/ScrollView/types.d.ts +26 -0
- package/dist/ScrollView/types.js +1 -0
- package/dist/SideBar/index.d.ts +1 -1
- package/dist/SideBar/side-bar.js +6 -6
- package/dist/SideBar/style.scss +85 -85
- package/dist/Space/demo/base.js +2 -2
- package/dist/Swiper/style.scss +54 -54
- package/dist/Switch/demo/base.js +2 -2
- package/dist/TabBar/demo/base.js +2 -2
- package/dist/Tag/demo/base.js +2 -2
- package/dist/Tag/demo/style.scss +8 -8
- package/dist/Toast/style.scss +63 -63
- package/dist/Toast/toast-modal.js +4 -4
- package/dist/VerificationCodeInput/demo/base.js +2 -2
- package/dist/VerificationCodeInput/index.d.ts +2 -2
- package/dist/VerificationCodeInput/index.js +1 -1
- package/dist/VerificationCodeInput/style.scss +20 -0
- package/dist/VerificationCodeInput/verification-code-input.d.ts +24 -0
- package/dist/VerificationCodeInput/verification-code-input.js +99 -0
- package/dist/WaterMark/demo/demo1.js +2 -2
- package/dist/WaterMark/demo/demo1.scss +6 -6
- package/dist/WaterMark/demo/demo2.js +2 -2
- package/dist/index.d.ts +9 -7
- package/dist/index.js +4 -3
- package/dist/style/variable.scss +1 -1
- package/dist/types.d.ts +0 -8
- package/dist/types.js +0 -1
- package/dist/utils/type.js +36 -36
- package/dist/utils/use-isomorphic-update-layout-effect.d.ts +1 -1
- package/dist/utils/with-default-props.js +4 -4
- package/package.json +10 -11
- package/readme.md +43 -43
- package/dist/CalendarPicker/calendar-picker.d.ts +0 -4
- package/dist/CalendarPicker/calendar-range-picker.d.ts +0 -4
- package/dist/CalendarPicker/index.d.ts +0 -9
- package/dist/CalendarPicker/index.js +0 -5
- package/dist/CalendarPicker/style.scss +0 -31
- package/dist/Mask/index.d.ts +0 -3
- package/dist/Mask/index.js +0 -2
- package/dist/Progress/Progress.d.ts +0 -37
- package/dist/Progress/Progress.js +0 -52
- package/dist/Progress/ProgressCircle.d.ts +0 -17
- package/dist/Progress/ProgressCircle.js +0 -148
- package/dist/Progress/ProgressLine.d.ts +0 -15
- package/dist/Progress/ProgressLine.js +0 -87
- package/dist/Progress/style.scss +0 -33
- package/dist/Progress/types.d.ts +0 -4
- package/dist/Progress/types.js +0 -2
- /package/dist/{CalendarDatetimePicker → CalendarDatetimePopup}/DateTimeSwitch.d.ts +0 -0
- /package/dist/{CalendarDatetimePicker → CalendarDatetimePopup}/DateTimeSwitch.js +0 -0
- /package/dist/{CalendarPicker → CalendarDatetimePopup}/demo/base.d.ts +0 -0
- /package/dist/{Mask → CalendarPopup}/demo/base.d.ts +0 -0
- /package/dist/{CalendarPicker → CalendarPopup}/types.js +0 -0
|
@@ -16,8 +16,8 @@ import React, { memo, useEffect, useRef, useState } from 'react';
|
|
|
16
16
|
import { CalendarGrid } from "../Calendar";
|
|
17
17
|
import { RandomUtils } from "../utils/random-utils";
|
|
18
18
|
import classNames from "classnames";
|
|
19
|
-
/**
|
|
20
|
-
* 可以手势滑动的日历组件
|
|
19
|
+
/**
|
|
20
|
+
* 可以手势滑动的日历组件
|
|
21
21
|
*/
|
|
22
22
|
export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
|
|
23
23
|
var _wrapperRef$current3;
|
|
@@ -60,8 +60,8 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
|
|
|
60
60
|
mouths = _useState10[0],
|
|
61
61
|
setMouths = _useState10[1];
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
* 计算出每个格子的大小
|
|
63
|
+
/**
|
|
64
|
+
* 计算出每个格子的大小
|
|
65
65
|
*/
|
|
66
66
|
var cellSize = /*#__PURE__*/function () {
|
|
67
67
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -80,8 +80,8 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
|
|
|
80
80
|
return _ref2.apply(this, arguments);
|
|
81
81
|
};
|
|
82
82
|
}();
|
|
83
|
-
/**
|
|
84
|
-
* 计算出最大的translateY,默认为wrapperRef.current?.clientHeight
|
|
83
|
+
/**
|
|
84
|
+
* 计算出最大的translateY,默认为wrapperRef.current?.clientHeight
|
|
85
85
|
*/
|
|
86
86
|
var minTranslateY = /*#__PURE__*/function () {
|
|
87
87
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
@@ -101,9 +101,9 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
|
|
|
101
101
|
};
|
|
102
102
|
}();
|
|
103
103
|
|
|
104
|
-
/**
|
|
105
|
-
* 计算出该月的行数
|
|
106
|
-
* @param mouth
|
|
104
|
+
/**
|
|
105
|
+
* 计算出该月的行数
|
|
106
|
+
* @param mouth
|
|
107
107
|
*/
|
|
108
108
|
var mouthLines = function mouthLines(mouth) {
|
|
109
109
|
var firstDate = new Date(mouth.getFullYear(), mouth.getMonth(), 1);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import './style.scss';
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
afterOpenChange?: (open: boolean) => void;
|
|
3
|
+
export type CalendarDatetimePopupProps = {
|
|
4
|
+
placeholder?: string;
|
|
6
5
|
value?: Date;
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
format?: string;
|
|
7
|
+
onChange?: (value?: Date) => void;
|
|
9
8
|
};
|
|
10
|
-
export declare const CalendarDatetimePicker: FC<
|
|
9
|
+
export declare const CalendarDatetimePicker: FC<CalendarDatetimePopupProps>;
|
|
@@ -1,7 +1,3 @@
|
|
|
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 _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
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
2
|
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
3
|
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); }
|
|
@@ -9,148 +5,57 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
9
5
|
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
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
7
|
import classNames from 'classnames';
|
|
12
|
-
import React, { useEffect,
|
|
13
|
-
import Calendar from "../Calendar";
|
|
14
|
-
import ConfigProvider from "../ConfigProvider";
|
|
15
|
-
import PickerView from "../PickerView";
|
|
16
|
-
import Popup from "../Popup";
|
|
17
|
-
import { DatetimeUtils } from "../utils/datetime-utils";
|
|
18
|
-
import { DateTimeSwitch } from "./DateTimeSwitch";
|
|
8
|
+
import React, { useEffect, useState } from 'react';
|
|
19
9
|
import "./style.scss";
|
|
20
|
-
import { cls
|
|
10
|
+
import { cls } from "./types";
|
|
11
|
+
import CalendarDatetimePopup from "../CalendarDatetimePopup";
|
|
12
|
+
import dayjs from "dayjs";
|
|
21
13
|
export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_ref$
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var _ConfigProvider$useCo = ConfigProvider.useConfig(),
|
|
30
|
-
locale = _ConfigProvider$useCo.locale;
|
|
31
|
-
var _React$useState = React.useState(open || false),
|
|
14
|
+
var _ref$placeholder = _ref.placeholder,
|
|
15
|
+
placeholder = _ref$placeholder === void 0 ? '请选择' : _ref$placeholder,
|
|
16
|
+
value = _ref.value,
|
|
17
|
+
_ref$format = _ref.format,
|
|
18
|
+
format = _ref$format === void 0 ? 'YYYY-MM-DD HH:mm' : _ref$format,
|
|
19
|
+
onChange = _ref.onChange;
|
|
20
|
+
var _React$useState = React.useState(false),
|
|
32
21
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
33
22
|
innerOpen = _React$useState2[0],
|
|
34
23
|
setInnerOpen = _React$useState2[1];
|
|
35
|
-
var _useState = useState(
|
|
24
|
+
var _useState = useState(value),
|
|
36
25
|
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _useState3 = useState(300),
|
|
43
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
44
|
-
bodyHeight = _useState4[0],
|
|
45
|
-
setBodyHeight = _useState4[1];
|
|
46
|
-
var handleClose = function handleClose() {
|
|
47
|
-
setInnerOpen(false);
|
|
48
|
-
onClose === null || onClose === void 0 || onClose();
|
|
49
|
-
};
|
|
50
|
-
var handleOk = function handleOk() {
|
|
51
|
-
onOk === null || onOk === void 0 || onOk(valueRef.current);
|
|
52
|
-
handleClose();
|
|
53
|
-
};
|
|
54
|
-
var handleComputeBodyHeight = /*#__PURE__*/function () {
|
|
55
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
56
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
57
|
-
while (1) switch (_context.prev = _context.next) {
|
|
58
|
-
case 0:
|
|
59
|
-
return _context.abrupt("return", Promise.resolve(bodyRef.current.offsetHeight));
|
|
60
|
-
case 1:
|
|
61
|
-
case "end":
|
|
62
|
-
return _context.stop();
|
|
63
|
-
}
|
|
64
|
-
}, _callee);
|
|
65
|
-
}));
|
|
66
|
-
return function handleComputeBodyHeight() {
|
|
67
|
-
return _ref2.apply(this, arguments);
|
|
68
|
-
};
|
|
69
|
-
}();
|
|
70
|
-
useEffect(function () {
|
|
71
|
-
afterOpenChange === null || afterOpenChange === void 0 || afterOpenChange(innerOpen);
|
|
72
|
-
if (!innerOpen) {
|
|
73
|
-
onClose === null || onClose === void 0 || onClose();
|
|
26
|
+
internalValue = _useState2[0],
|
|
27
|
+
setInternalValue = _useState2[1];
|
|
28
|
+
var handleValueRender = function handleValueRender() {
|
|
29
|
+
if (internalValue) {
|
|
30
|
+
return dayjs(internalValue).format(format);
|
|
74
31
|
}
|
|
75
|
-
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
76
34
|
useEffect(function () {
|
|
77
|
-
if (
|
|
35
|
+
if (value === undefined) {
|
|
78
36
|
return;
|
|
79
37
|
}
|
|
80
|
-
if (
|
|
81
|
-
|
|
38
|
+
if (value !== internalValue) {
|
|
39
|
+
setInternalValue(value);
|
|
82
40
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
useEffect(function () {
|
|
86
|
-
if (datetimeSwitchRef.current) {
|
|
87
|
-
datetimeSwitchRef.current.setDatetime(valueRef.current);
|
|
88
|
-
}
|
|
89
|
-
}, []);
|
|
90
|
-
var bodyRender = function bodyRender() {
|
|
91
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, mode === Mode.date && /*#__PURE__*/React.createElement("div", {
|
|
92
|
-
style: {}
|
|
93
|
-
}, /*#__PURE__*/React.createElement(Calendar, {
|
|
94
|
-
mouth: value,
|
|
95
|
-
value: value,
|
|
96
|
-
onChange: function onChange(date) {
|
|
97
|
-
var _datetimeSwitchRef$cu;
|
|
98
|
-
valueRef.current = new Date(date.getFullYear(), date.getMonth(), date.getDate(), valueRef.current.getHours(), valueRef.current.getMinutes());
|
|
99
|
-
(_datetimeSwitchRef$cu = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu === void 0 || _datetimeSwitchRef$cu.setDatetime(valueRef.current);
|
|
100
|
-
}
|
|
101
|
-
})), mode === Mode.time && /*#__PURE__*/React.createElement("div", {
|
|
102
|
-
style: {
|
|
103
|
-
height: bodyHeight
|
|
104
|
-
}
|
|
105
|
-
}, /*#__PURE__*/React.createElement(PickerView, {
|
|
106
|
-
columns: [Array(24).fill(0).map(function (_, i) {
|
|
107
|
-
return {
|
|
108
|
-
label: "".concat(DatetimeUtils.twoDigits(i)),
|
|
109
|
-
value: "".concat(i)
|
|
110
|
-
};
|
|
111
|
-
}), Array(60).fill(0).map(function (_, i) {
|
|
112
|
-
return {
|
|
113
|
-
label: "".concat(DatetimeUtils.twoDigits(i)),
|
|
114
|
-
value: "".concat(i)
|
|
115
|
-
};
|
|
116
|
-
})],
|
|
117
|
-
labelInValue: false,
|
|
118
|
-
value: ["".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.getHours()), "".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.getMinutes())],
|
|
119
|
-
onChange: function onChange(v) {
|
|
120
|
-
var _datetimeSwitchRef$cu2;
|
|
121
|
-
valueRef.current = new Date(valueRef.current.getFullYear(), valueRef.current.getMonth(), valueRef.current.getDate(), v[0], v[1]);
|
|
122
|
-
(_datetimeSwitchRef$cu2 = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu2 === void 0 || _datetimeSwitchRef$cu2.setDatetime(valueRef.current);
|
|
123
|
-
}
|
|
124
|
-
})));
|
|
125
|
-
};
|
|
126
|
-
return /*#__PURE__*/React.createElement(Popup, {
|
|
41
|
+
}, [value]);
|
|
42
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CalendarDatetimePopup, {
|
|
127
43
|
open: innerOpen,
|
|
44
|
+
value: internalValue,
|
|
128
45
|
onClose: function onClose() {
|
|
129
46
|
setInnerOpen(false);
|
|
130
|
-
}
|
|
131
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
132
|
-
className: classNames(cls)
|
|
133
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
134
|
-
className: "".concat(cls, "-header")
|
|
135
|
-
}, /*#__PURE__*/React.createElement(DateTimeSwitch, {
|
|
136
|
-
ref: datetimeSwitchRef,
|
|
137
|
-
mode: mode,
|
|
138
|
-
value: valueRef.current,
|
|
139
|
-
onDateTabTap: function onDateTabTap() {
|
|
140
|
-
return setMode(Mode.date);
|
|
141
47
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
48
|
+
onOk: function onOk(date) {
|
|
49
|
+
setInternalValue(date);
|
|
50
|
+
setInnerOpen(false);
|
|
51
|
+
onChange === null || onChange === void 0 || onChange(date);
|
|
52
|
+
}
|
|
53
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: classNames(cls),
|
|
55
|
+
onClick: function onClick() {
|
|
56
|
+
setInnerOpen(true);
|
|
147
57
|
}
|
|
148
|
-
}
|
|
149
|
-
className:
|
|
150
|
-
|
|
151
|
-
}, locale.common.confirm)), /*#__PURE__*/React.createElement("div", {
|
|
152
|
-
className: "".concat(cls, "-body"),
|
|
153
|
-
ref: bodyRef,
|
|
154
|
-
id: (_bodyRef$current = bodyRef.current) === null || _bodyRef$current === void 0 ? void 0 : _bodyRef$current.uid
|
|
155
|
-
}, bodyRender())));
|
|
58
|
+
}, !internalValue ? /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: "".concat(cls, "-placeholder")
|
|
60
|
+
}, placeholder) : /*#__PURE__*/React.createElement("div", null, handleValueRender())));
|
|
156
61
|
};
|
|
@@ -7,8 +7,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { DemoBlock } from "../../DemoBlock";
|
|
9
9
|
import { CalendarDatetimePicker } from "../CalendarDatetimePicker";
|
|
10
|
-
import
|
|
11
|
-
import Toast from "../../Toast";
|
|
10
|
+
import { Cell } from "@trionesdev/antd-mobile-base-react";
|
|
12
11
|
export default (function () {
|
|
13
12
|
var toastContainer = React.useRef();
|
|
14
13
|
var _React$useState = React.useState(false),
|
|
@@ -19,23 +18,8 @@ export default (function () {
|
|
|
19
18
|
ref: toastContainer
|
|
20
19
|
}), /*#__PURE__*/React.createElement(DemoBlock, {
|
|
21
20
|
title: "\u65E5\u671F\u65F6\u95F4\u9009\u62E9\u5668"
|
|
22
|
-
}, /*#__PURE__*/React.createElement(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
onOk: function onOk(date) {
|
|
28
|
-
Toast.show({
|
|
29
|
-
getContainer: function getContainer() {
|
|
30
|
-
return toastContainer.current;
|
|
31
|
-
},
|
|
32
|
-
content: "".concat(date.getFullYear(), "-").concat(date.getMonth() + 1, "-").concat(date.getDate(), " ").concat(date.getHours(), ":").concat(date.getMinutes())
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
36
|
-
block: true,
|
|
37
|
-
onClick: function onClick() {
|
|
38
|
-
setOpen(true);
|
|
39
|
-
}
|
|
40
|
-
}, "\u65E5\u671F\u65F6\u95F4\u9009\u62E9\u5668")));
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Cell, {
|
|
22
|
+
label: 'Label',
|
|
23
|
+
wrapperAlign: "right"
|
|
24
|
+
}, /*#__PURE__*/React.createElement(CalendarDatetimePicker, null))));
|
|
41
25
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CalendarDatetimePicker,
|
|
2
|
-
export type {
|
|
1
|
+
import { CalendarDatetimePicker, CalendarDatetimePopupProps } from "./CalendarDatetimePicker";
|
|
2
|
+
export type { CalendarDatetimePopupProps };
|
|
3
3
|
export default CalendarDatetimePicker;
|
|
@@ -1,54 +1,10 @@
|
|
|
1
|
-
@use "../style/variable" as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
justify-content: space-between;
|
|
12
|
-
border-bottom: 1Px solid $trionesBorderColor;
|
|
13
|
-
|
|
14
|
-
|
|
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: $trionesColorText;
|
|
35
|
-
font-weight: bold;
|
|
36
|
-
background-color: $trionesColorBgTextActive;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&-button {
|
|
41
|
-
padding: 12Px 16Px;
|
|
42
|
-
|
|
43
|
-
&-cancel {
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&-ok {
|
|
47
|
-
color: $trionesColorPrimary;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
&-body {
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
@use "../style/variable" as variable;
|
|
2
|
+
$calendarDatetimePickerCls: 'triones-antm-calendar-datetime-picker';
|
|
3
|
+
|
|
4
|
+
.#{$calendarDatetimePickerCls}{
|
|
5
|
+
min-width: 50Px;
|
|
6
|
+
line-height: 1.4;
|
|
7
|
+
&-placeholder{
|
|
8
|
+
color: variable.$trionesColorTextPlaceholder;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import './style.scss';
|
|
3
|
+
export type CalendarDatetimePopupProps = {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
afterOpenChange?: (open: boolean) => void;
|
|
6
|
+
value?: Date;
|
|
7
|
+
onOk?: (value?: Date) => void;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const CalendarDatetimePopup: FC<CalendarDatetimePopupProps>;
|
|
@@ -0,0 +1,136 @@
|
|
|
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 _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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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
|
+
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
|
+
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
|
+
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
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import classNames from 'classnames';
|
|
12
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
13
|
+
import Calendar from "../Calendar";
|
|
14
|
+
import ConfigProvider from "../ConfigProvider";
|
|
15
|
+
import PickerView from "../PickerView";
|
|
16
|
+
import Popup from "../Popup";
|
|
17
|
+
import { DatetimeUtils } from "../utils/datetime-utils";
|
|
18
|
+
import { DateTimeSwitch } from "./DateTimeSwitch";
|
|
19
|
+
import "./style.scss";
|
|
20
|
+
import { cls, Mode } from "./types";
|
|
21
|
+
export var CalendarDatetimePopup = function CalendarDatetimePopup(_ref) {
|
|
22
|
+
var _bodyRef$current;
|
|
23
|
+
var open = _ref.open,
|
|
24
|
+
afterOpenChange = _ref.afterOpenChange,
|
|
25
|
+
_ref$value = _ref.value,
|
|
26
|
+
value = _ref$value === void 0 ? new Date() : _ref$value,
|
|
27
|
+
onOk = _ref.onOk,
|
|
28
|
+
onClose = _ref.onClose;
|
|
29
|
+
var _ConfigProvider$useCo = ConfigProvider.useConfig(),
|
|
30
|
+
locale = _ConfigProvider$useCo.locale;
|
|
31
|
+
var _useState = useState(Mode.date),
|
|
32
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
33
|
+
mode = _useState2[0],
|
|
34
|
+
setMode = _useState2[1];
|
|
35
|
+
var valueRef = useRef(value || new Date());
|
|
36
|
+
var bodyRef = useRef(null);
|
|
37
|
+
var datetimeSwitchRef = useRef();
|
|
38
|
+
var _useState3 = useState(300),
|
|
39
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
+
bodyHeight = _useState4[0],
|
|
41
|
+
setBodyHeight = _useState4[1];
|
|
42
|
+
var handleClose = function handleClose() {
|
|
43
|
+
onClose === null || onClose === void 0 || onClose();
|
|
44
|
+
};
|
|
45
|
+
var handleOk = function handleOk() {
|
|
46
|
+
onOk === null || onOk === void 0 || onOk(valueRef.current);
|
|
47
|
+
handleClose();
|
|
48
|
+
};
|
|
49
|
+
var handleComputeBodyHeight = /*#__PURE__*/function () {
|
|
50
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
51
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
52
|
+
while (1) switch (_context.prev = _context.next) {
|
|
53
|
+
case 0:
|
|
54
|
+
return _context.abrupt("return", Promise.resolve(bodyRef.current.offsetHeight));
|
|
55
|
+
case 1:
|
|
56
|
+
case "end":
|
|
57
|
+
return _context.stop();
|
|
58
|
+
}
|
|
59
|
+
}, _callee);
|
|
60
|
+
}));
|
|
61
|
+
return function handleComputeBodyHeight() {
|
|
62
|
+
return _ref2.apply(this, arguments);
|
|
63
|
+
};
|
|
64
|
+
}();
|
|
65
|
+
useEffect(function () {
|
|
66
|
+
if (datetimeSwitchRef.current) {
|
|
67
|
+
datetimeSwitchRef.current.setDatetime(valueRef.current);
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
var bodyRender = function bodyRender() {
|
|
71
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, mode === Mode.date && /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
style: {}
|
|
73
|
+
}, /*#__PURE__*/React.createElement(Calendar, {
|
|
74
|
+
mouth: value,
|
|
75
|
+
value: value,
|
|
76
|
+
onChange: function onChange(date) {
|
|
77
|
+
var _datetimeSwitchRef$cu;
|
|
78
|
+
console.log('date', date);
|
|
79
|
+
valueRef.current = date ? new Date(date === null || date === void 0 ? void 0 : date.getFullYear(), date === null || date === void 0 ? void 0 : date.getMonth(), date === null || date === void 0 ? void 0 : date.getDate(), valueRef.current.getHours(), valueRef.current.getMinutes()) : new Date();
|
|
80
|
+
(_datetimeSwitchRef$cu = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu === void 0 || _datetimeSwitchRef$cu.setDatetime(valueRef.current);
|
|
81
|
+
}
|
|
82
|
+
})), mode === Mode.time && /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
style: {
|
|
84
|
+
height: bodyHeight
|
|
85
|
+
}
|
|
86
|
+
}, /*#__PURE__*/React.createElement(PickerView, {
|
|
87
|
+
columns: [Array(24).fill(0).map(function (_, i) {
|
|
88
|
+
return {
|
|
89
|
+
label: "".concat(DatetimeUtils.twoDigits(i)),
|
|
90
|
+
value: "".concat(i)
|
|
91
|
+
};
|
|
92
|
+
}), Array(60).fill(0).map(function (_, i) {
|
|
93
|
+
return {
|
|
94
|
+
label: "".concat(DatetimeUtils.twoDigits(i)),
|
|
95
|
+
value: "".concat(i)
|
|
96
|
+
};
|
|
97
|
+
})],
|
|
98
|
+
labelInValue: false,
|
|
99
|
+
value: ["".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.getHours()), "".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.getMinutes())],
|
|
100
|
+
onChange: function onChange(v) {
|
|
101
|
+
var _valueRef$current, _valueRef$current2, _valueRef$current3, _datetimeSwitchRef$cu2;
|
|
102
|
+
valueRef.current = new Date((_valueRef$current = valueRef.current) === null || _valueRef$current === void 0 ? void 0 : _valueRef$current.getFullYear(), (_valueRef$current2 = valueRef.current) === null || _valueRef$current2 === void 0 ? void 0 : _valueRef$current2.getMonth(), (_valueRef$current3 = valueRef.current) === null || _valueRef$current3 === void 0 ? void 0 : _valueRef$current3.getDate(), v[0], v[1]);
|
|
103
|
+
(_datetimeSwitchRef$cu2 = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu2 === void 0 || _datetimeSwitchRef$cu2.setDatetime(valueRef.current);
|
|
104
|
+
}
|
|
105
|
+
})));
|
|
106
|
+
};
|
|
107
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
108
|
+
open: open,
|
|
109
|
+
onClose: onClose,
|
|
110
|
+
round: true
|
|
111
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: classNames(cls)
|
|
113
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
114
|
+
className: "".concat(cls, "-header")
|
|
115
|
+
}, /*#__PURE__*/React.createElement(DateTimeSwitch, {
|
|
116
|
+
ref: datetimeSwitchRef,
|
|
117
|
+
mode: mode,
|
|
118
|
+
value: valueRef.current,
|
|
119
|
+
onDateTabTap: function onDateTabTap() {
|
|
120
|
+
return setMode(Mode.date);
|
|
121
|
+
},
|
|
122
|
+
onTimeTabTap: function onTimeTabTap() {
|
|
123
|
+
handleComputeBodyHeight().then(function (height) {
|
|
124
|
+
setBodyHeight(height);
|
|
125
|
+
setMode(Mode.time);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}), /*#__PURE__*/React.createElement("a", {
|
|
129
|
+
className: classNames("".concat(cls, "-header-button"), "".concat(cls, "-header-button-ok")),
|
|
130
|
+
onClick: handleOk
|
|
131
|
+
}, locale.common.confirm)), /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
className: "".concat(cls, "-body"),
|
|
133
|
+
ref: bodyRef,
|
|
134
|
+
id: (_bodyRef$current = bodyRef.current) === null || _bodyRef$current === void 0 ? void 0 : _bodyRef$current.uid
|
|
135
|
+
}, bodyRender())));
|
|
136
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { DemoBlock } from "../../DemoBlock";
|
|
9
|
+
import { CalendarDatetimePopup } from "../CalendarDatetimePopup";
|
|
10
|
+
import Button from "../../Button";
|
|
11
|
+
import Toast from "../../Toast";
|
|
12
|
+
export default (function () {
|
|
13
|
+
var toastContainer = React.useRef();
|
|
14
|
+
var _React$useState = React.useState(false),
|
|
15
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
16
|
+
open = _React$useState2[0],
|
|
17
|
+
setOpen = _React$useState2[1];
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
ref: toastContainer
|
|
20
|
+
}), /*#__PURE__*/React.createElement(DemoBlock, {
|
|
21
|
+
title: "\u65E5\u671F\u65F6\u95F4\u9009\u62E9\u5668"
|
|
22
|
+
}, /*#__PURE__*/React.createElement(CalendarDatetimePopup, {
|
|
23
|
+
open: open,
|
|
24
|
+
afterOpenChange: function afterOpenChange(o) {
|
|
25
|
+
setOpen(o);
|
|
26
|
+
},
|
|
27
|
+
onOk: function onOk(date) {
|
|
28
|
+
Toast.show({
|
|
29
|
+
getContainer: function getContainer() {
|
|
30
|
+
return toastContainer.current;
|
|
31
|
+
},
|
|
32
|
+
content: "".concat(date.getFullYear(), "-").concat(date.getMonth() + 1, "-").concat(date.getDate(), " ").concat(date.getHours(), ":").concat(date.getMinutes())
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
36
|
+
block: true,
|
|
37
|
+
onClick: function onClick() {
|
|
38
|
+
setOpen(true);
|
|
39
|
+
}
|
|
40
|
+
}, "\u65E5\u671F\u65F6\u95F4\u9009\u62E9\u5668")));
|
|
41
|
+
});
|