@trionesdev/antd-mobile-react 0.0.2-beta.0
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 -0
- package/dist/ActionSheet/demo/base.d.ts +3 -0
- package/dist/ActionSheet/demo/base.js +39 -0
- package/dist/ActionSheet/index.d.ts +3 -0
- package/dist/ActionSheet/index.js +2 -0
- package/dist/Alert/demo/base.d.ts +3 -0
- package/dist/Alert/demo/base.js +56 -0
- package/dist/Alert/index.d.ts +3 -0
- package/dist/Alert/index.js +2 -0
- package/dist/Avatar/demo/base.d.ts +7 -0
- package/dist/Avatar/demo/base.js +109 -0
- package/dist/Avatar/demo/style.scss +6 -0
- package/dist/Avatar/index.d.ts +3 -0
- package/dist/Avatar/index.js +2 -0
- package/dist/Badge/demo/base.d.ts +7 -0
- package/dist/Badge/demo/base.js +167 -0
- package/dist/Badge/demo/base.scss +6 -0
- package/dist/Badge/index.d.ts +3 -0
- package/dist/Badge/index.js +2 -0
- package/dist/Button/button.d.ts +53 -0
- package/dist/Button/button.js +66 -0
- package/dist/Button/demo/base.d.ts +3 -0
- package/dist/Button/demo/base.js +163 -0
- package/dist/Button/index.d.ts +3 -0
- package/dist/Button/index.js +2 -0
- package/dist/Button/style.scss +231 -0
- package/dist/Calendar/calendar-grid.d.ts +27 -0
- package/dist/Calendar/calendar-grid.js +164 -0
- package/dist/Calendar/calendar-header.d.ts +7 -0
- package/dist/Calendar/calendar-header.js +42 -0
- package/dist/Calendar/calendar-range.d.ts +10 -0
- package/dist/Calendar/calendar-range.js +57 -0
- package/dist/Calendar/calendar.d.ts +10 -0
- package/dist/Calendar/calendar.js +49 -0
- package/dist/Calendar/demo/calendar.d.ts +3 -0
- package/dist/Calendar/demo/calendar.js +10 -0
- package/dist/Calendar/demo/grid.d.ts +3 -0
- package/dist/Calendar/demo/grid.js +12 -0
- package/dist/Calendar/demo/touch-grid.d.ts +3 -0
- package/dist/Calendar/demo/touch-grid.js +8 -0
- package/dist/Calendar/index.d.ts +11 -0
- package/dist/Calendar/index.js +8 -0
- package/dist/Calendar/style.scss +85 -0
- package/dist/Calendar/touchable-calendar-grid.d.ts +14 -0
- package/dist/Calendar/touchable-calendar-grid.js +395 -0
- package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts +10 -0
- package/dist/CalendarDatetimePicker/CalendarDatetimePicker.js +156 -0
- package/dist/CalendarDatetimePicker/DateTimeSwitch.d.ts +14 -0
- package/dist/CalendarDatetimePicker/DateTimeSwitch.js +39 -0
- package/dist/CalendarDatetimePicker/demo/base.d.ts +3 -0
- package/dist/CalendarDatetimePicker/demo/base.js +41 -0
- package/dist/CalendarDatetimePicker/index.d.ts +3 -0
- package/dist/CalendarDatetimePicker/index.js +2 -0
- package/dist/CalendarDatetimePicker/style.scss +54 -0
- package/dist/CalendarDatetimePicker/types.d.ts +5 -0
- package/dist/CalendarDatetimePicker/types.js +6 -0
- package/dist/CalendarPicker/calendar-picker.d.ts +4 -0
- package/dist/CalendarPicker/calendar-picker.js +87 -0
- package/dist/CalendarPicker/calendar-range-picker.d.ts +4 -0
- package/dist/CalendarPicker/calendar-range-picker.js +87 -0
- package/dist/CalendarPicker/demo/base.d.ts +3 -0
- package/dist/CalendarPicker/demo/base.js +66 -0
- package/dist/CalendarPicker/index.d.ts +9 -0
- package/dist/CalendarPicker/index.js +5 -0
- package/dist/CalendarPicker/style.scss +31 -0
- package/dist/CalendarPicker/types.d.ts +21 -0
- package/dist/CalendarPicker/types.js +1 -0
- package/dist/Card/demo/base.d.ts +4 -0
- package/dist/Card/demo/base.js +65 -0
- package/dist/Card/demo/base.scss +18 -0
- package/dist/Card/index.d.ts +3 -0
- package/dist/Card/index.js +2 -0
- package/dist/CascaderPicker/demo/base.d.ts +3 -0
- package/dist/CascaderPicker/demo/base.js +85 -0
- package/dist/CascaderPicker/index.d.ts +3 -0
- package/dist/CascaderPicker/index.js +2 -0
- package/dist/CascaderView/demo/async.d.ts +3 -0
- package/dist/CascaderView/demo/async.js +41 -0
- package/dist/CascaderView/demo/base.d.ts +3 -0
- package/dist/CascaderView/demo/base.js +62 -0
- package/dist/CascaderView/demo/value.d.ts +3 -0
- package/dist/CascaderView/demo/value.js +63 -0
- package/dist/CascaderView/index.d.ts +3 -0
- package/dist/CascaderView/index.js +2 -0
- package/dist/Cell/demo/base.d.ts +3 -0
- package/dist/Cell/demo/base.js +13 -0
- package/dist/Cell/index.d.ts +3 -0
- package/dist/Cell/index.js +2 -0
- package/dist/Checkbox/demo/base.d.ts +6 -0
- package/dist/Checkbox/demo/base.js +43 -0
- package/dist/Checkbox/demo/disabled.d.ts +3 -0
- package/dist/Checkbox/demo/disabled.js +19 -0
- package/dist/Checkbox/index.d.ts +3 -0
- package/dist/Checkbox/index.js +2 -0
- package/dist/ConfigProvider/demo/base.d.ts +6 -0
- package/dist/ConfigProvider/demo/base.js +24 -0
- package/dist/ConfigProvider/index.d.ts +3 -0
- package/dist/ConfigProvider/index.js +2 -0
- package/dist/DemoBlock/index.d.ts +10 -0
- package/dist/DemoBlock/index.js +15 -0
- package/dist/DemoBlock/index.scss +20 -0
- package/dist/DemoDescription/index.d.ts +6 -0
- package/dist/DemoDescription/index.js +7 -0
- package/dist/DemoDescription/index.scss +3 -0
- package/dist/Descriptions/demo/base.d.ts +3 -0
- package/dist/Descriptions/demo/base.js +102 -0
- package/dist/Descriptions/demo/vertical.d.ts +3 -0
- package/dist/Descriptions/demo/vertical.js +70 -0
- package/dist/Descriptions/index.d.ts +3 -0
- package/dist/Descriptions/index.js +2 -0
- package/dist/Divider/demo/base.d.ts +3 -0
- package/dist/Divider/demo/base.js +35 -0
- package/dist/Divider/index.d.ts +3 -0
- package/dist/Divider/index.js +2 -0
- package/dist/Ellipsis/demo/base.d.ts +3 -0
- package/dist/Ellipsis/demo/base.js +81 -0
- package/dist/Ellipsis/index.d.ts +3 -0
- package/dist/Ellipsis/index.js +2 -0
- package/dist/Empty/demo/base.d.ts +3 -0
- package/dist/Empty/demo/base.js +38 -0
- package/dist/Empty/index.d.ts +3 -0
- package/dist/Empty/index.js +2 -0
- package/dist/ErrorBlock/demo/base.d.ts +3 -0
- package/dist/ErrorBlock/demo/base.js +23 -0
- package/dist/ErrorBlock/index.d.ts +4 -0
- package/dist/ErrorBlock/index.js +3 -0
- package/dist/Footer/demo/base.d.ts +6 -0
- package/dist/Footer/demo/base.js +81 -0
- package/dist/Footer/index.d.ts +3 -0
- package/dist/Footer/index.js +2 -0
- package/dist/Form/demo/base.d.ts +3 -0
- package/dist/Form/demo/base.js +99 -0
- package/dist/Form/demo/input.d.ts +3 -0
- package/dist/Form/demo/input.js +39 -0
- package/dist/Form/index.d.ts +3 -0
- package/dist/Form/index.js +2 -0
- package/dist/Grid/demo/base.d.ts +7 -0
- package/dist/Grid/demo/base.js +46 -0
- package/dist/Grid/demo/base.scss +7 -0
- package/dist/Grid/index.d.ts +3 -0
- package/dist/Grid/index.js +2 -0
- package/dist/Icon/check-icon.d.ts +3 -0
- package/dist/Icon/check-icon.js +10 -0
- package/dist/Icon/demo/base.d.ts +6 -0
- package/dist/Icon/demo/base.js +41 -0
- package/dist/Image/broken-image-icon.d.ts +2 -0
- package/dist/Image/broken-image-icon.js +11 -0
- package/dist/Image/demo/base.d.ts +4 -0
- package/dist/Image/demo/base.js +101 -0
- package/dist/Image/demo/base.scss +4 -0
- package/dist/Image/image-icon.d.ts +2 -0
- package/dist/Image/image-icon.js +11 -0
- package/dist/Image/image.d.ts +19 -0
- package/dist/Image/image.js +113 -0
- package/dist/Image/index.d.ts +4 -0
- package/dist/Image/index.js +3 -0
- package/dist/Image/lazy-detector.d.ts +6 -0
- package/dist/Image/lazy-detector.js +22 -0
- package/dist/Image/style.scss +30 -0
- package/dist/ImagesPreview/ImagesPreview.d.ts +12 -0
- package/dist/ImagesPreview/ImagesPreview.js +83 -0
- package/dist/ImagesPreview/demo/base.d.ts +3 -0
- package/dist/ImagesPreview/demo/base.js +30 -0
- package/dist/ImagesPreview/index.d.ts +3 -0
- package/dist/ImagesPreview/index.js +2 -0
- package/dist/ImagesPreview/style.scss +34 -0
- package/dist/ImagesWall/CameraModal.d.ts +6 -0
- package/dist/ImagesWall/CameraModal.js +23 -0
- package/dist/ImagesWall/ImagesWall.d.ts +29 -0
- package/dist/ImagesWall/ImagesWall.js +225 -0
- package/dist/ImagesWall/demo/base.d.ts +3 -0
- package/dist/ImagesWall/demo/base.js +29 -0
- package/dist/ImagesWall/index.d.ts +3 -0
- package/dist/ImagesWall/index.js +2 -0
- package/dist/ImagesWall/style.scss +70 -0
- package/dist/Input/demo/base.d.ts +3 -0
- package/dist/Input/demo/base.js +29 -0
- package/dist/Input/index.d.ts +3 -0
- package/dist/Input/index.js +2 -0
- package/dist/InputNumber/demo/base.d.ts +3 -0
- package/dist/InputNumber/demo/base.js +13 -0
- package/dist/InputNumber/index.d.ts +3 -0
- package/dist/InputNumber/index.js +2 -0
- package/dist/Mask/demo/base.d.ts +3 -0
- package/dist/Mask/demo/base.js +29 -0
- package/dist/Mask/index.d.ts +3 -0
- package/dist/Mask/index.js +2 -0
- package/dist/NavBar/demo/base.d.ts +4 -0
- package/dist/NavBar/demo/base.js +70 -0
- package/dist/NavBar/demo/base.scss +5 -0
- package/dist/NavBar/index.d.ts +3 -0
- package/dist/NavBar/index.js +2 -0
- package/dist/NoticeBar/demo/base.d.ts +3 -0
- package/dist/NoticeBar/demo/base.js +90 -0
- package/dist/NoticeBar/index.d.ts +3 -0
- package/dist/NoticeBar/index.js +2 -0
- package/dist/PageIndicator/demo/base.d.ts +3 -0
- package/dist/PageIndicator/demo/base.js +41 -0
- package/dist/PageIndicator/index.d.ts +3 -0
- package/dist/PageIndicator/index.js +2 -0
- package/dist/Picker/demo/base.d.ts +3 -0
- package/dist/Picker/demo/base.js +56 -0
- package/dist/Picker/index.d.ts +3 -0
- package/dist/Picker/index.js +2 -0
- package/dist/PickerView/demo/base.d.ts +3 -0
- package/dist/PickerView/demo/base.js +36 -0
- package/dist/PickerView/index.d.ts +3 -0
- package/dist/PickerView/index.js +2 -0
- package/dist/Popup/demo/base.d.ts +3 -0
- package/dist/Popup/demo/base.js +99 -0
- package/dist/Popup/index.d.ts +3 -0
- package/dist/Popup/index.js +2 -0
- package/dist/Progress/Progress.d.ts +37 -0
- package/dist/Progress/Progress.js +52 -0
- package/dist/Progress/ProgressCircle.d.ts +17 -0
- package/dist/Progress/ProgressCircle.js +148 -0
- package/dist/Progress/ProgressLine.d.ts +15 -0
- package/dist/Progress/ProgressLine.js +87 -0
- package/dist/Progress/demo/base.d.ts +3 -0
- package/dist/Progress/demo/base.js +73 -0
- package/dist/Progress/index.d.ts +3 -0
- package/dist/Progress/index.js +2 -0
- package/dist/Progress/style.scss +33 -0
- package/dist/Progress/types.d.ts +4 -0
- package/dist/Progress/types.js +2 -0
- package/dist/Radio/demo/base.d.ts +4 -0
- package/dist/Radio/demo/base.js +85 -0
- package/dist/Radio/demo/base.scss +4 -0
- package/dist/Radio/index.d.ts +3 -0
- package/dist/Radio/index.js +2 -0
- package/dist/Rate/demo/base.d.ts +3 -0
- package/dist/Rate/demo/base.js +59 -0
- package/dist/Rate/index.d.ts +3 -0
- package/dist/Rate/index.js +2 -0
- package/dist/Result/demo/base.d.ts +3 -0
- package/dist/Result/demo/base.js +57 -0
- package/dist/Result/index.d.ts +3 -0
- package/dist/Result/index.js +2 -0
- package/dist/SafeArea/demo/base.d.ts +3 -0
- package/dist/SafeArea/demo/base.js +17 -0
- package/dist/SafeArea/demo/base.scss +18 -0
- package/dist/SafeArea/index.d.ts +3 -0
- package/dist/SafeArea/index.js +2 -0
- package/dist/Scaffold/demo/base.d.ts +3 -0
- package/dist/Scaffold/demo/base.js +30 -0
- package/dist/Scaffold/index.d.ts +3 -0
- package/dist/Scaffold/index.js +2 -0
- package/dist/ScrollView/demo/base.d.ts +3 -0
- package/dist/ScrollView/demo/base.js +43 -0
- package/dist/ScrollView/index.d.ts +3 -0
- package/dist/ScrollView/index.js +2 -0
- package/dist/SideBar/SideBarContext.d.ts +18 -0
- package/dist/SideBar/SideBarContext.js +2 -0
- package/dist/SideBar/demo/base.d.ts +3 -0
- package/dist/SideBar/demo/base.js +54 -0
- package/dist/SideBar/demo/default-active.d.ts +3 -0
- package/dist/SideBar/demo/default-active.js +34 -0
- package/dist/SideBar/demo/scroll-mode.d.ts +3 -0
- package/dist/SideBar/demo/scroll-mode.js +55 -0
- package/dist/SideBar/index.d.ts +3 -0
- package/dist/SideBar/index.js +2 -0
- package/dist/SideBar/side-bar.d.ts +25 -0
- package/dist/SideBar/side-bar.js +351 -0
- package/dist/SideBar/style.scss +85 -0
- package/dist/SideBar/types.d.ts +7 -0
- package/dist/SideBar/types.js +1 -0
- package/dist/Space/demo/base.d.ts +3 -0
- package/dist/Space/demo/base.js +120 -0
- package/dist/Space/index.d.ts +3 -0
- package/dist/Space/index.js +2 -0
- package/dist/SpinLoading/demo/base.d.ts +3 -0
- package/dist/SpinLoading/demo/base.js +21 -0
- package/dist/SpinLoading/index.d.ts +3 -0
- package/dist/SpinLoading/index.js +2 -0
- package/dist/Steps/demo/base.d.ts +3 -0
- package/dist/Steps/demo/base.js +71 -0
- package/dist/Steps/index.d.ts +3 -0
- package/dist/Steps/index.js +2 -0
- package/dist/Swiper/Swiper.d.ts +10 -0
- package/dist/Swiper/Swiper.js +22 -0
- package/dist/Swiper/SwiperCore.d.ts +23 -0
- package/dist/Swiper/SwiperCore.js +272 -0
- package/dist/Swiper/demo/base.d.ts +3 -0
- package/dist/Swiper/demo/base.js +122 -0
- package/dist/Swiper/index.d.ts +8 -0
- package/dist/Swiper/index.js +5 -0
- package/dist/Swiper/style.scss +54 -0
- package/dist/Switch/demo/base.d.ts +3 -0
- package/dist/Switch/demo/base.js +108 -0
- package/dist/Switch/index.d.ts +3 -0
- package/dist/Switch/index.js +2 -0
- package/dist/TabBar/demo/base.d.ts +6 -0
- package/dist/TabBar/demo/base.js +26 -0
- package/dist/TabBar/index.d.ts +3 -0
- package/dist/TabBar/index.js +2 -0
- package/dist/Tabs/demo/base.d.ts +3 -0
- package/dist/Tabs/demo/base.js +59 -0
- package/dist/Tabs/index.d.ts +3 -0
- package/dist/Tabs/index.js +2 -0
- package/dist/Tag/demo/base.d.ts +7 -0
- package/dist/Tag/demo/base.js +67 -0
- package/dist/Tag/demo/style.scss +8 -0
- package/dist/Tag/index.d.ts +3 -0
- package/dist/Tag/index.js +2 -0
- package/dist/Toast/demo/base.d.ts +3 -0
- package/dist/Toast/demo/base.js +121 -0
- package/dist/Toast/demo/component-mode.d.ts +3 -0
- package/dist/Toast/demo/component-mode.js +32 -0
- package/dist/Toast/index.d.ts +8 -0
- package/dist/Toast/index.js +4 -0
- package/dist/Toast/style.scss +63 -0
- package/dist/Toast/toast-modal.d.ts +18 -0
- package/dist/Toast/toast-modal.js +112 -0
- package/dist/Toast/toast.d.ts +20 -0
- package/dist/Toast/toast.js +112 -0
- package/dist/VerificationCodeInput/demo/base.d.ts +3 -0
- package/dist/VerificationCodeInput/demo/base.js +11 -0
- package/dist/VerificationCodeInput/index.d.ts +3 -0
- package/dist/VerificationCodeInput/index.js +2 -0
- package/dist/WaterMark/demo/demo1.d.ts +7 -0
- package/dist/WaterMark/demo/demo1.js +47 -0
- package/dist/WaterMark/demo/demo1.scss +6 -0
- package/dist/WaterMark/demo/demo2.d.ts +3 -0
- package/dist/WaterMark/demo/demo2.js +31 -0
- package/dist/WaterMark/index.d.ts +3 -0
- package/dist/WaterMark/index.js +2 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +53 -0
- package/dist/locales/base.d.ts +139 -0
- package/dist/locales/base.js +139 -0
- package/dist/locales/en-US.d.ts +139 -0
- package/dist/locales/en-US.js +4 -0
- package/dist/locales/zh-CN.d.ts +3 -0
- package/dist/locales/zh-CN.js +140 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.js +1 -0
- package/dist/utils/attach-properties-to-component.d.ts +1 -0
- package/dist/utils/attach-properties-to-component.js +9 -0
- package/dist/utils/bound.d.ts +1 -0
- package/dist/utils/bound.js +10 -0
- package/dist/utils/can-use-dom.d.ts +1 -0
- package/dist/utils/can-use-dom.js +1 -0
- package/dist/utils/convert-px.d.ts +1 -0
- package/dist/utils/convert-px.js +27 -0
- package/dist/utils/datetime-utils.d.ts +3 -0
- package/dist/utils/datetime-utils.js +18 -0
- package/dist/utils/dev-log.d.ts +3 -0
- package/dist/utils/dev-log.js +36 -0
- package/dist/utils/get-container.d.ts +2 -0
- package/dist/utils/get-container.js +4 -0
- package/dist/utils/get-scroll-parent.d.ts +3 -0
- package/dist/utils/get-scroll-parent.js +23 -0
- package/dist/utils/is-dev.d.ts +1 -0
- package/dist/utils/is-dev.js +1 -0
- package/dist/utils/lang.d.ts +1 -0
- package/dist/utils/lang.js +1 -0
- package/dist/utils/matrix.d.ts +10 -0
- package/dist/utils/matrix.js +37 -0
- package/dist/utils/merge-locale.d.ts +1 -0
- package/dist/utils/merge-locale.js +16 -0
- package/dist/utils/native-props.d.ts +10 -0
- package/dist/utils/native-props.js +39 -0
- package/dist/utils/random-utils.d.ts +3 -0
- package/dist/utils/random-utils.js +13 -0
- package/dist/utils/reactNode.d.ts +7 -0
- package/dist/utils/reactNode.js +13 -0
- package/dist/utils/render-imperatively.d.ts +14 -0
- package/dist/utils/render-imperatively.js +105 -0
- package/dist/utils/render-to-body.d.ts +2 -0
- package/dist/utils/render-to-body.js +13 -0
- package/dist/utils/render-to-container.d.ts +3 -0
- package/dist/utils/render-to-container.js +10 -0
- package/dist/utils/render.d.ts +9 -0
- package/dist/utils/render.js +87 -0
- package/dist/utils/rubberband.d.ts +2 -0
- package/dist/utils/rubberband.js +11 -0
- package/dist/utils/should-render.d.ts +10 -0
- package/dist/utils/should-render.js +12 -0
- package/dist/utils/supports-passive.d.ts +1 -0
- package/dist/utils/supports-passive.js +13 -0
- package/dist/utils/to-css-length.d.ts +1 -0
- package/dist/utils/to-css-length.js +3 -0
- package/dist/utils/type.d.ts +65 -0
- package/dist/utils/type.js +48 -0
- package/dist/utils/use-initialized.d.ts +1 -0
- package/dist/utils/use-initialized.js +8 -0
- package/dist/utils/use-isomorphic-update-layout-effect.d.ts +2 -0
- package/dist/utils/use-isomorphic-update-layout-effect.js +2 -0
- package/dist/utils/use-lock-scroll.d.ts +2 -0
- package/dist/utils/use-lock-scroll.js +81 -0
- package/dist/utils/use-mutation-effect.d.ts +3 -0
- package/dist/utils/use-mutation-effect.js +26 -0
- package/dist/utils/use-props-value.d.ts +8 -0
- package/dist/utils/use-props-value.js +22 -0
- package/dist/utils/use-resize-effect.d.ts +2 -0
- package/dist/utils/use-resize-effect.js +23 -0
- package/dist/utils/use-touch.d.ts +17 -0
- package/dist/utils/use-touch.js +63 -0
- package/dist/utils/validate.d.ts +1 -0
- package/dist/utils/validate.js +4 -0
- package/dist/utils/with-default-props.d.ts +9 -0
- package/dist/utils/with-default-props.js +33 -0
- package/dist/utils/with-stop-propagation.d.ts +4 -0
- package/dist/utils/with-stop-propagation.js +38 -0
- package/dist/utils/zIndex.d.ts +1 -0
- package/dist/utils/zIndex.js +4 -0
- package/dist/utils/zindexContext.d.ts +3 -0
- package/dist/utils/zindexContext.js +6 -0
- package/package.json +104 -0
- package/readme.md +43 -0
|
@@ -0,0 +1,395 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
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; }
|
|
7
|
+
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); } }
|
|
8
|
+
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); }); }; }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
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."); }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
import React, { memo, useEffect, useRef, useState } from 'react';
|
|
16
|
+
import { CalendarGrid } from "../Calendar";
|
|
17
|
+
import { RandomUtils } from "../utils/random-utils";
|
|
18
|
+
import classNames from "classnames";
|
|
19
|
+
/**
|
|
20
|
+
* 可以手势滑动的日历组件
|
|
21
|
+
*/
|
|
22
|
+
export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
|
|
23
|
+
var _wrapperRef$current3;
|
|
24
|
+
var _ref$mouth = _ref.mouth,
|
|
25
|
+
mouth = _ref$mouth === void 0 ? new Date() : _ref$mouth,
|
|
26
|
+
value = _ref.value,
|
|
27
|
+
defaultValue = _ref.defaultValue,
|
|
28
|
+
onChange = _ref.onChange,
|
|
29
|
+
onMouthChange = _ref.onMouthChange,
|
|
30
|
+
range = _ref.range;
|
|
31
|
+
var wrapperRef = useRef();
|
|
32
|
+
var wrapperUniqueRef = React.useRef(RandomUtils.random());
|
|
33
|
+
var _useState = useState(mouth),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
currentMouth = _useState2[0],
|
|
36
|
+
setCurrentMouth = _useState2[1];
|
|
37
|
+
var waiting = false;
|
|
38
|
+
var _useState3 = useState(200),
|
|
39
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
+
mouthHeight = _useState4[0],
|
|
41
|
+
setMouthHeight = _useState4[1]; //当前选中的月份的展示高度
|
|
42
|
+
var _useState5 = useState(false),
|
|
43
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
44
|
+
touching = _useState6[0],
|
|
45
|
+
setTouching = _useState6[1]; //是否正在滑动
|
|
46
|
+
var _React$useState = React.useState(),
|
|
47
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
48
|
+
touchStartPoint = _React$useState2[0],
|
|
49
|
+
setTouchStartPoint = _React$useState2[1]; //触摸点
|
|
50
|
+
var _React$useState3 = React.useState(),
|
|
51
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
52
|
+
touchPoint = _React$useState4[0],
|
|
53
|
+
setTouchPoint = _React$useState4[1]; //触摸点
|
|
54
|
+
var _useState7 = useState(0),
|
|
55
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
56
|
+
translateY = _useState8[0],
|
|
57
|
+
setTranslateY = _useState8[1];
|
|
58
|
+
var _useState9 = useState([]),
|
|
59
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
60
|
+
mouths = _useState10[0],
|
|
61
|
+
setMouths = _useState10[1];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 计算出每个格子的大小
|
|
65
|
+
*/
|
|
66
|
+
var cellSize = /*#__PURE__*/function () {
|
|
67
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
68
|
+
var _wrapperRef$current;
|
|
69
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
70
|
+
while (1) switch (_context.prev = _context.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
return _context.abrupt("return", Promise.resolve(((_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.clientWidth) / 7));
|
|
73
|
+
case 1:
|
|
74
|
+
case "end":
|
|
75
|
+
return _context.stop();
|
|
76
|
+
}
|
|
77
|
+
}, _callee);
|
|
78
|
+
}));
|
|
79
|
+
return function cellSize() {
|
|
80
|
+
return _ref2.apply(this, arguments);
|
|
81
|
+
};
|
|
82
|
+
}();
|
|
83
|
+
/**
|
|
84
|
+
* 计算出最大的translateY,默认为wrapperRef.current?.clientHeight
|
|
85
|
+
*/
|
|
86
|
+
var minTranslateY = /*#__PURE__*/function () {
|
|
87
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
88
|
+
var _wrapperRef$current2;
|
|
89
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
90
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
return _context2.abrupt("return", Promise.resolve((_wrapperRef$current2 = wrapperRef.current) === null || _wrapperRef$current2 === void 0 ? void 0 : _wrapperRef$current2.clientHeight));
|
|
93
|
+
case 1:
|
|
94
|
+
case "end":
|
|
95
|
+
return _context2.stop();
|
|
96
|
+
}
|
|
97
|
+
}, _callee2);
|
|
98
|
+
}));
|
|
99
|
+
return function minTranslateY() {
|
|
100
|
+
return _ref3.apply(this, arguments);
|
|
101
|
+
};
|
|
102
|
+
}();
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 计算出该月的行数
|
|
106
|
+
* @param mouth
|
|
107
|
+
*/
|
|
108
|
+
var mouthLines = function mouthLines(mouth) {
|
|
109
|
+
var firstDate = new Date(mouth.getFullYear(), mouth.getMonth(), 1);
|
|
110
|
+
var lastDate = new Date(mouth.getFullYear(), mouth.getMonth() + 1, 0);
|
|
111
|
+
var beforeDays = firstDate.getDay();
|
|
112
|
+
var afterDays = 6 - lastDate.getDay();
|
|
113
|
+
var countDays = beforeDays + lastDate.getDate() + afterDays;
|
|
114
|
+
return Math.ceil(countDays / 7);
|
|
115
|
+
};
|
|
116
|
+
var handleInsertMouth = /*#__PURE__*/function () {
|
|
117
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
118
|
+
var firstMouth, insertMouth, newMouths, insertMouthLines, insertMouthHeight;
|
|
119
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
120
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
121
|
+
case 0:
|
|
122
|
+
firstMouth = mouths[0];
|
|
123
|
+
insertMouth = new Date(firstMouth.getFullYear(), firstMouth.getMonth() - 1, 1);
|
|
124
|
+
newMouths = [insertMouth].concat(_toConsumableArray(mouths));
|
|
125
|
+
setMouths(newMouths);
|
|
126
|
+
insertMouthLines = mouthLines(insertMouth);
|
|
127
|
+
_context3.t0 = insertMouthLines;
|
|
128
|
+
_context3.next = 8;
|
|
129
|
+
return cellSize();
|
|
130
|
+
case 8:
|
|
131
|
+
_context3.t1 = _context3.sent;
|
|
132
|
+
insertMouthHeight = _context3.t0 * _context3.t1;
|
|
133
|
+
setTranslateY(translateY - insertMouthHeight);
|
|
134
|
+
// waiting = false
|
|
135
|
+
case 11:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context3.stop();
|
|
138
|
+
}
|
|
139
|
+
}, _callee3);
|
|
140
|
+
}));
|
|
141
|
+
return function handleInsertMouth() {
|
|
142
|
+
return _ref4.apply(this, arguments);
|
|
143
|
+
};
|
|
144
|
+
}();
|
|
145
|
+
var handleAppendMouth = function handleAppendMouth() {
|
|
146
|
+
// if (waiting){
|
|
147
|
+
// return
|
|
148
|
+
// }
|
|
149
|
+
// waiting = true
|
|
150
|
+
var lastMouth = mouths[mouths.length - 1];
|
|
151
|
+
var appendMouth = new Date(lastMouth.getFullYear(), lastMouth.getMonth() + 1, 1);
|
|
152
|
+
var newMouths = [].concat(_toConsumableArray(mouths), [appendMouth]);
|
|
153
|
+
setMouths(newMouths);
|
|
154
|
+
// waiting = false
|
|
155
|
+
};
|
|
156
|
+
useEffect(function () {
|
|
157
|
+
var initMouths = [new Date(currentMouth.getFullYear(), currentMouth.getMonth() - 1, 1), new Date(currentMouth.getFullYear(), currentMouth.getMonth(), 1), new Date(currentMouth.getFullYear(), currentMouth.getMonth() + 1, 1)];
|
|
158
|
+
Promise.all([]).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
159
|
+
var firstMouthHeight;
|
|
160
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
161
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
162
|
+
case 0:
|
|
163
|
+
setMouths(initMouths);
|
|
164
|
+
_context4.t0 = setMouthHeight;
|
|
165
|
+
_context4.t1 = mouthLines(currentMouth);
|
|
166
|
+
_context4.next = 5;
|
|
167
|
+
return cellSize();
|
|
168
|
+
case 5:
|
|
169
|
+
_context4.t2 = _context4.sent;
|
|
170
|
+
_context4.t3 = _context4.t1 * _context4.t2;
|
|
171
|
+
(0, _context4.t0)(_context4.t3);
|
|
172
|
+
_context4.t4 = mouthLines(initMouths[0]);
|
|
173
|
+
_context4.next = 11;
|
|
174
|
+
return cellSize();
|
|
175
|
+
case 11:
|
|
176
|
+
_context4.t5 = _context4.sent;
|
|
177
|
+
firstMouthHeight = _context4.t4 * _context4.t5;
|
|
178
|
+
setTranslateY(0 - firstMouthHeight);
|
|
179
|
+
case 14:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context4.stop();
|
|
182
|
+
}
|
|
183
|
+
}, _callee4);
|
|
184
|
+
})));
|
|
185
|
+
}, [currentMouth]);
|
|
186
|
+
useEffect(function () {
|
|
187
|
+
if (mouth !== undefined) {
|
|
188
|
+
var newMouth = new Date(mouth.getFullYear(), mouth.getMonth(), 1);
|
|
189
|
+
if (currentMouth === null || !(currentMouth.getFullYear() === newMouth.getFullYear() && currentMouth.getMonth() === newMouth.getMonth())) {
|
|
190
|
+
setCurrentMouth(newMouth);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, [mouth]);
|
|
194
|
+
useEffect(function () {
|
|
195
|
+
if (value !== undefined) {}
|
|
196
|
+
}, [value]);
|
|
197
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
198
|
+
style: {
|
|
199
|
+
boxSizing: 'border-box',
|
|
200
|
+
overflow: 'hidden',
|
|
201
|
+
height: mouthHeight
|
|
202
|
+
}
|
|
203
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
204
|
+
ref: wrapperRef,
|
|
205
|
+
id: (_wrapperRef$current3 = wrapperRef.current) === null || _wrapperRef$current3 === void 0 ? void 0 : _wrapperRef$current3.uid,
|
|
206
|
+
className: classNames("".concat(wrapperUniqueRef.current)),
|
|
207
|
+
style: {
|
|
208
|
+
transform: "translate3d(0, ".concat(translateY, "px, 0)")
|
|
209
|
+
},
|
|
210
|
+
onTouchStart: function onTouchStart(event) {
|
|
211
|
+
event.preventDefault();
|
|
212
|
+
event.stopPropagation();
|
|
213
|
+
setTouching(true);
|
|
214
|
+
var startPoint = {
|
|
215
|
+
clientX: event.touches[0].clientX,
|
|
216
|
+
clientY: event.touches[0].clientY
|
|
217
|
+
};
|
|
218
|
+
setTouchStartPoint(startPoint);
|
|
219
|
+
setTouchPoint(startPoint);
|
|
220
|
+
},
|
|
221
|
+
onTouchMove: ( /*#__PURE__*/function () {
|
|
222
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(event) {
|
|
223
|
+
var movePoint, newTranslateY;
|
|
224
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
225
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
226
|
+
case 0:
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
event.stopPropagation();
|
|
229
|
+
if (!touching) {
|
|
230
|
+
_context5.next = 33;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
movePoint = {
|
|
234
|
+
clientX: event.touches[0].clientX,
|
|
235
|
+
clientY: event.touches[0].clientY
|
|
236
|
+
};
|
|
237
|
+
_context5.t0 = translateY > 0;
|
|
238
|
+
if (_context5.t0) {
|
|
239
|
+
_context5.next = 12;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
_context5.t1 = translateY;
|
|
243
|
+
_context5.next = 9;
|
|
244
|
+
return minTranslateY();
|
|
245
|
+
case 9:
|
|
246
|
+
_context5.t2 = _context5.sent;
|
|
247
|
+
_context5.t3 = 0 - _context5.t2;
|
|
248
|
+
_context5.t0 = _context5.t1 < _context5.t3;
|
|
249
|
+
case 12:
|
|
250
|
+
if (!_context5.t0) {
|
|
251
|
+
_context5.next = 14;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
return _context5.abrupt("return");
|
|
255
|
+
case 14:
|
|
256
|
+
console.log('move', movePoint.clientY - touchPoint.clientY);
|
|
257
|
+
newTranslateY = translateY + (movePoint.clientY - touchPoint.clientY);
|
|
258
|
+
setTranslateY(newTranslateY);
|
|
259
|
+
setTouchPoint(movePoint);
|
|
260
|
+
// console.log(newTranslateY,minTranslateY())
|
|
261
|
+
if (!(newTranslateY > -10)) {
|
|
262
|
+
_context5.next = 24;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
//当向下滑动,顶部距离视窗顶部距离小于10,则插入上一个月份
|
|
266
|
+
console.log('insert');
|
|
267
|
+
_context5.next = 22;
|
|
268
|
+
return handleInsertMouth();
|
|
269
|
+
case 22:
|
|
270
|
+
_context5.next = 33;
|
|
271
|
+
break;
|
|
272
|
+
case 24:
|
|
273
|
+
_context5.t4 = newTranslateY;
|
|
274
|
+
_context5.next = 27;
|
|
275
|
+
return minTranslateY();
|
|
276
|
+
case 27:
|
|
277
|
+
_context5.t5 = _context5.sent;
|
|
278
|
+
_context5.t6 = 0 - _context5.t5;
|
|
279
|
+
_context5.t7 = _context5.t6 + 10;
|
|
280
|
+
if (!(_context5.t4 < _context5.t7)) {
|
|
281
|
+
_context5.next = 33;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
//当向下滑动,底部距离视窗底部距离小于10,则追加下一个月份
|
|
285
|
+
console.log('append');
|
|
286
|
+
handleAppendMouth();
|
|
287
|
+
case 33:
|
|
288
|
+
case "end":
|
|
289
|
+
return _context5.stop();
|
|
290
|
+
}
|
|
291
|
+
}, _callee5);
|
|
292
|
+
}));
|
|
293
|
+
return function (_x) {
|
|
294
|
+
return _ref6.apply(this, arguments);
|
|
295
|
+
};
|
|
296
|
+
}()),
|
|
297
|
+
onTouchEnd: ( /*#__PURE__*/function () {
|
|
298
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(event) {
|
|
299
|
+
var displayMouth, _mouthHeightSum, i, _mouthHeight, _topLineY, _windowDisplayHeight, _bottomLineY, _windowDisplayHeight2;
|
|
300
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
301
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
302
|
+
case 0:
|
|
303
|
+
setTouching(false);
|
|
304
|
+
if (!(Math.abs(Math.abs(touchStartPoint.clientY) - Math.abs(touchPoint.clientY)) < 5)) {
|
|
305
|
+
_context6.next = 3;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
return _context6.abrupt("return");
|
|
309
|
+
case 3:
|
|
310
|
+
console.log(mouths);
|
|
311
|
+
//region 判断当前月份是否在视窗内
|
|
312
|
+
_mouthHeightSum = 0;
|
|
313
|
+
i = 0;
|
|
314
|
+
case 6:
|
|
315
|
+
if (!(i < mouths.length)) {
|
|
316
|
+
_context6.next = 40;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
console.log('mouthHeight', mouthHeight);
|
|
320
|
+
console.log('mouths[i]', mouths[i], i);
|
|
321
|
+
_context6.t0 = mouthLines(mouths[i]);
|
|
322
|
+
_context6.next = 12;
|
|
323
|
+
return cellSize();
|
|
324
|
+
case 12:
|
|
325
|
+
_context6.t1 = _context6.sent;
|
|
326
|
+
_mouthHeight = _context6.t0 * _context6.t1;
|
|
327
|
+
_mouthHeightSum += _mouthHeight;
|
|
328
|
+
console.log('_mouthHeightSum', _mouthHeightSum);
|
|
329
|
+
console.log('translateY', translateY);
|
|
330
|
+
_topLineY = 0 - (_mouthHeightSum - _mouthHeight); //该月份区域顶部,对于顶点的偏移量
|
|
331
|
+
console.log('_topLineY', _topLineY);
|
|
332
|
+
if (!(_topLineY <= translateY && _topLineY >= translateY - mouthHeight)) {
|
|
333
|
+
_context6.next = 27;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
//该月份区域的顶部在视窗内
|
|
337
|
+
console.log('top_in');
|
|
338
|
+
_windowDisplayHeight = _mouthHeightSum - (0 - translateY); //该月份区域底部距离视窗顶部的距离
|
|
339
|
+
console.log('_windowDisplayHeight——top', _windowDisplayHeight);
|
|
340
|
+
if (!(_windowDisplayHeight >= mouthHeight / 2)) {
|
|
341
|
+
_context6.next = 27;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
console.log('displayMouth', mouths[i]);
|
|
345
|
+
displayMouth = mouths[i];
|
|
346
|
+
return _context6.abrupt("break", 40);
|
|
347
|
+
case 27:
|
|
348
|
+
_bottomLineY = 0 - _mouthHeightSum; //该月份区域底部,对于顶点的偏移量
|
|
349
|
+
console.log('_bottomLineY', _bottomLineY);
|
|
350
|
+
if (!(_bottomLineY <= translateY && _bottomLineY >= translateY - mouthHeight)) {
|
|
351
|
+
_context6.next = 37;
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
//该月份区域的底部在视窗内
|
|
355
|
+
console.log('bottom_in');
|
|
356
|
+
_windowDisplayHeight2 = _mouthHeightSum - (0 - translateY); //该月份区域底部距离视窗顶部的距离
|
|
357
|
+
console.log('_windowDisplayHeight-bottom', _windowDisplayHeight2);
|
|
358
|
+
if (!(_windowDisplayHeight2 >= mouthHeight / 2)) {
|
|
359
|
+
_context6.next = 37;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
console.log('displayMouth', mouths[i]);
|
|
363
|
+
displayMouth = mouths[i];
|
|
364
|
+
return _context6.abrupt("break", 40);
|
|
365
|
+
case 37:
|
|
366
|
+
i++;
|
|
367
|
+
_context6.next = 6;
|
|
368
|
+
break;
|
|
369
|
+
case 40:
|
|
370
|
+
//endregion
|
|
371
|
+
if (displayMouth) {
|
|
372
|
+
setCurrentMouth(displayMouth);
|
|
373
|
+
onMouthChange === null || onMouthChange === void 0 || onMouthChange(displayMouth);
|
|
374
|
+
}
|
|
375
|
+
case 41:
|
|
376
|
+
case "end":
|
|
377
|
+
return _context6.stop();
|
|
378
|
+
}
|
|
379
|
+
}, _callee6);
|
|
380
|
+
}));
|
|
381
|
+
return function (_x2) {
|
|
382
|
+
return _ref7.apply(this, arguments);
|
|
383
|
+
};
|
|
384
|
+
}())
|
|
385
|
+
}, mouths.map(function (mouth, index) {
|
|
386
|
+
return /*#__PURE__*/React.createElement(CalendarGrid, {
|
|
387
|
+
key: index,
|
|
388
|
+
mouth: mouth,
|
|
389
|
+
value: value,
|
|
390
|
+
defaultValue: defaultValue,
|
|
391
|
+
onChange: onChange,
|
|
392
|
+
range: range
|
|
393
|
+
});
|
|
394
|
+
})));
|
|
395
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import './style.scss';
|
|
3
|
+
export type CalendarDatetimePickerProps = {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
afterOpenChange?: (open: boolean) => void;
|
|
6
|
+
value?: Date;
|
|
7
|
+
onOk?: (value?: Date) => void;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const CalendarDatetimePicker: FC<CalendarDatetimePickerProps>;
|
|
@@ -0,0 +1,156 @@
|
|
|
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 CalendarDatetimePicker = function CalendarDatetimePicker(_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 _React$useState = React.useState(open || false),
|
|
32
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
33
|
+
innerOpen = _React$useState2[0],
|
|
34
|
+
setInnerOpen = _React$useState2[1];
|
|
35
|
+
var _useState = useState(Mode.date),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
mode = _useState2[0],
|
|
38
|
+
setMode = _useState2[1];
|
|
39
|
+
var valueRef = useRef(value || new Date());
|
|
40
|
+
var bodyRef = useRef(null);
|
|
41
|
+
var datetimeSwitchRef = useRef();
|
|
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();
|
|
74
|
+
}
|
|
75
|
+
}, [innerOpen]);
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
if (open === undefined) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (open === innerOpen) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setInnerOpen(open);
|
|
84
|
+
}, [open]);
|
|
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, {
|
|
127
|
+
open: innerOpen,
|
|
128
|
+
onClose: function onClose() {
|
|
129
|
+
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
|
+
},
|
|
142
|
+
onTimeTabTap: function onTimeTabTap() {
|
|
143
|
+
handleComputeBodyHeight().then(function (height) {
|
|
144
|
+
setBodyHeight(height);
|
|
145
|
+
setMode(Mode.time);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}), /*#__PURE__*/React.createElement("a", {
|
|
149
|
+
className: classNames("".concat(cls, "-header-button"), "".concat(cls, "-header-button-ok")),
|
|
150
|
+
onClick: handleOk
|
|
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())));
|
|
156
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './style.scss';
|
|
3
|
+
import { Mode } from './types';
|
|
4
|
+
export interface DateTimeSwitchHandle {
|
|
5
|
+
setDatetime: (datetime: Date) => void;
|
|
6
|
+
}
|
|
7
|
+
type DateTimeSwitchProps = {
|
|
8
|
+
onDateTabTap?: () => void;
|
|
9
|
+
onTimeTabTap?: () => void;
|
|
10
|
+
mode?: Mode;
|
|
11
|
+
value?: Date;
|
|
12
|
+
};
|
|
13
|
+
export declare const DateTimeSwitch: React.ForwardRefExoticComponent<DateTimeSwitchProps & React.RefAttributes<DateTimeSwitchHandle>>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
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); }
|
|
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, { forwardRef, useImperativeHandle, useState } from 'react';
|
|
13
|
+
import { DatetimeUtils } from "../utils/datetime-utils";
|
|
14
|
+
import "./style.scss";
|
|
15
|
+
import { cls, Mode } from "./types";
|
|
16
|
+
export var DateTimeSwitch = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
17
|
+
var onDateTabTap = _ref.onDateTabTap,
|
|
18
|
+
onTimeTabTap = _ref.onTimeTabTap,
|
|
19
|
+
mode = _ref.mode,
|
|
20
|
+
value = _ref.value;
|
|
21
|
+
var _useState = useState(value),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
datetime = _useState2[0],
|
|
24
|
+
setDatetime = _useState2[1];
|
|
25
|
+
useImperativeHandle(ref, function () {
|
|
26
|
+
return {
|
|
27
|
+
setDatetime: setDatetime
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: classNames("".concat(cls, "-header-display"))
|
|
32
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: classNames("".concat(cls, "-header-display-date"), _defineProperty({}, "".concat(cls, "-header-display-active"), mode === Mode.date)),
|
|
34
|
+
onClick: onDateTabTap
|
|
35
|
+
}, datetime ? "".concat(datetime.getFullYear(), "-").concat(DatetimeUtils.twoDigits(datetime.getMonth() + 1), "-").concat(DatetimeUtils.twoDigits(datetime.getDate())) : ''), /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: classNames("".concat(cls, "-header-display-time"), _defineProperty({}, "".concat(cls, "-header-display-active"), mode === Mode.time)),
|
|
37
|
+
onClick: onTimeTabTap
|
|
38
|
+
}, datetime ? "".concat(datetime.getHours(), ":").concat(datetime.getMinutes()) : ''));
|
|
39
|
+
});
|