@nutui/nutui 3.2.5-beta.1 → 3.2.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/nutui.es.js +4214 -4444
- package/dist/nutui.umd.js +4213 -4543
- package/dist/packages/_es/ActionSheet.js +18 -19
- package/dist/packages/_es/Address.js +94 -85
- package/dist/packages/_es/AddressList.js +25 -12
- package/dist/packages/_es/Animate.js +3 -3
- package/dist/packages/_es/Audio.js +9 -2
- package/dist/packages/_es/AudioOperate.js +5 -1
- package/dist/packages/_es/Avatar.js +10 -10
- package/dist/packages/_es/AvatarGroup.js +5 -5
- package/dist/packages/_es/BackTop.js +55 -108
- package/dist/packages/_es/Badge.js +6 -4
- package/dist/packages/_es/Barrage.js +79 -103
- package/dist/packages/_es/Button.js +5 -3
- package/dist/packages/_es/Calendar.js +36 -23
- package/dist/packages/_es/CalendarItem.js +4 -3
- package/dist/packages/_es/Card.js +15 -5
- package/dist/packages/_es/Cascader.js +12 -11
- package/dist/packages/_es/Category.js +13 -12
- package/dist/packages/_es/CategoryPane.js +17 -13
- package/dist/packages/_es/Cell.js +9 -12
- package/dist/packages/_es/CellGroup.js +4 -2
- package/dist/packages/_es/Checkbox.js +1 -1
- package/dist/packages/_es/CheckboxGroup.js +2 -2
- package/dist/packages/_es/CircleProgress.js +98 -82
- package/dist/packages/_es/Col.js +1 -1
- package/dist/packages/_es/Collapse.js +65 -34
- package/dist/packages/_es/CollapseItem.js +93 -60
- package/dist/packages/_es/Comment.js +43 -19
- package/dist/packages/_es/ConfigProvider.js +1 -1
- package/dist/packages/_es/CountDown.js +3 -3
- package/dist/packages/_es/CountUp.js +47 -52
- package/dist/packages/_es/DatePicker.js +37 -54
- package/dist/packages/_es/Dialog.js +9 -88
- package/dist/packages/_es/Divider.js +3 -3
- package/dist/packages/_es/Drag.js +75 -49
- package/dist/packages/_es/Ecard.js +20 -18
- package/dist/packages/_es/Elevator.js +101 -76
- package/dist/packages/_es/Ellipsis.js +140 -100
- package/dist/packages/_es/Empty.js +6 -4
- package/dist/packages/_es/FixedNav.js +11 -6
- package/dist/packages/_es/Form.js +4 -4
- package/dist/packages/_es/FormItem.js +3 -1
- package/dist/packages/_es/Grid.js +1 -1
- package/dist/packages/_es/GridItem.js +10 -27
- package/dist/packages/_es/Icon.js +1 -1
- package/dist/packages/_es/Image.js +13 -114
- package/dist/packages/_es/ImagePreview.js +154 -400
- package/dist/packages/_es/Indicator.js +3 -3
- package/dist/packages/_es/InfiniteLoading.js +103 -115
- package/dist/packages/_es/Input.js +54 -26
- package/dist/packages/_es/InputNumber.js +25 -16
- package/dist/packages/_es/Invoice.js +6 -5
- package/dist/packages/_es/Layout.js +1 -1
- package/dist/packages/_es/List.js +47 -34
- package/dist/packages/_es/Menu.js +35 -35
- package/dist/packages/_es/MenuItem.js +56 -29
- package/dist/packages/_es/Navbar.js +49 -39
- package/dist/packages/_es/NoticeBar.js +52 -41
- package/dist/packages/_es/Notify.js +37 -166
- package/dist/packages/_es/NumberKeyboard.js +15 -20
- package/dist/packages/_es/OldPicker.js +130 -116
- package/dist/packages/_es/OverLay.js +5 -28
- package/dist/packages/_es/Pagination.js +8 -5
- package/dist/packages/_es/Picker.js +196 -65
- package/dist/packages/_es/Popover.js +201 -881
- package/dist/packages/_es/Popup.js +28 -84
- package/dist/packages/_es/Price.js +22 -6
- package/dist/packages/_es/Progress.js +18 -11
- package/dist/packages/_es/PullRefresh.js +4 -2
- package/dist/packages/_es/Radio.js +3 -3
- package/dist/packages/_es/RadioGroup.js +1 -1
- package/dist/packages/_es/Range.js +48 -34
- package/dist/packages/_es/Rate.js +15 -14
- package/dist/packages/_es/Row.js +1 -1
- package/dist/packages/_es/SearchBar.js +39 -36
- package/dist/packages/_es/ShortPassword.js +97 -66
- package/dist/packages/_es/SideNavBar.js +7 -18
- package/dist/packages/_es/SideNavBarItem.js +1 -1
- package/dist/packages/_es/Signature.js +113 -80
- package/dist/packages/_es/Skeleton.js +12 -11
- package/dist/packages/_es/Sku.js +63 -38
- package/dist/packages/_es/Step.js +7 -2
- package/dist/packages/_es/Steps.js +1 -1
- package/dist/packages/_es/Sticky.js +33 -23
- package/dist/packages/_es/SubSideNavBar.js +4 -2
- package/dist/packages/_es/Swipe.js +41 -26
- package/dist/packages/_es/Swiper.js +38 -21
- package/dist/packages/_es/SwiperItem.js +2 -2
- package/dist/packages/_es/Switch.js +8 -8
- package/dist/packages/_es/TabPane.js +1 -1
- package/dist/packages/_es/Tabbar.js +40 -9
- package/dist/packages/_es/TabbarItem.js +24 -30
- package/dist/packages/_es/Table.js +22 -17
- package/dist/packages/_es/Tabs.js +49 -16
- package/dist/packages/_es/Tag.js +6 -5
- package/dist/packages/_es/TextArea.js +114 -49
- package/dist/packages/_es/TimeDetail.js +4 -3
- package/dist/packages/_es/TimePannel.js +3 -3
- package/dist/packages/_es/TimeSelect.js +12 -10
- package/dist/packages/_es/Toast.js +53 -164
- package/dist/packages/_es/TrendArrow.js +6 -4
- package/dist/packages/_es/Uploader.js +141 -140
- package/dist/packages/_es/Video.js +72 -5
- package/dist/packages/_es/WaterMark.js +22 -14
- package/dist/packages/_es/common.js +1 -1
- package/dist/packages/_es/component.js +1 -1
- package/dist/packages/_es/index.js +44 -6
- package/dist/packages/_es/{index5.js → index.taro.js} +167 -154
- package/dist/packages/_es/index2.js +8 -31
- package/dist/packages/_es/index3.js +64 -7
- package/dist/packages/_es/index4.js +424 -62
- package/dist/packages/_es/plugin-vue_export-helper.js +1 -1
- package/dist/packages/_es/pxCheck.js +1 -1
- package/dist/packages/_es/raf.js +1 -1
- package/dist/packages/_es/style.css +21 -3
- package/dist/packages/_es/use-lock-scroll.js +23 -0
- package/dist/packages/locale/lang/baseLang.js +1 -1
- package/dist/packages/locale/lang/en-US.js +1 -1
- package/dist/packages/locale/lang/id-ID.js +1 -1
- package/dist/packages/locale/lang/index.js +1 -1
- package/dist/packages/locale/lang/zh-CN.js +1 -1
- package/dist/packages/locale/lang/zh-TW.js +1 -1
- package/dist/packages/signature/index.scss +4 -1
- package/dist/packages/swiperitem/index.scss +1 -1
- package/dist/smartips/attributes.json +4 -0
- package/dist/smartips/tags.json +2 -1
- package/dist/smartips/web-types.json +10 -1
- package/dist/style.css +1 -1
- package/dist/styles/themes/default.scss +44 -44
- package/dist/styles/themes/jdb.scss +44 -44
- package/dist/styles/themes/jddkh.scss +44 -44
- package/dist/styles/themes/jdt.scss +44 -44
- package/dist/types/__VUE/actionsheet/{index.vue.d.ts → index.taro.vue.d.ts} +9 -9
- package/dist/types/__VUE/address/{index.vue.d.ts → index.taro.vue.d.ts} +73 -33
- package/dist/types/__VUE/addresslist/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/animate/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/avatar/{index.vue.d.ts → index.taro.vue.d.ts} +6 -6
- package/dist/types/__VUE/avatargroup/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/backtop/{index.vue.d.ts → index.taro.vue.d.ts} +15 -37
- package/dist/types/__VUE/badge/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/barrage/{index.vue.d.ts → index.taro.vue.d.ts} +2 -2
- package/dist/types/__VUE/button/index.taro.vue.d.ts +116 -0
- package/dist/types/__VUE/button/index.vue.d.ts +1 -1
- package/dist/types/__VUE/calendar/{index.vue.d.ts → index.taro.vue.d.ts} +13 -1
- package/dist/types/__VUE/calendaritem/{index.vue.d.ts → index.taro.vue.d.ts} +17 -17
- package/dist/types/__VUE/card/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/cascader/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/category/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/categorypane/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/cell/{index.vue.d.ts → index.taro.vue.d.ts} +13 -6
- package/dist/types/__VUE/checkbox/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/circleprogress/{index.vue.d.ts → index.taro.vue.d.ts} +14 -15
- package/dist/types/__VUE/collapse/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/collapseitem/{index.vue.d.ts → index.taro.vue.d.ts} +2 -10
- package/dist/types/__VUE/comment/{index.vue.d.ts → index.taro.vue.d.ts} +1 -2
- package/dist/types/__VUE/configprovider/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/countdown/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/countup/{index.vue.d.ts → index.taro.vue.d.ts} +5 -7
- package/dist/types/__VUE/datepicker/{index.vue.d.ts → index.taro.vue.d.ts} +5 -5
- package/dist/types/__VUE/dialog/{index.vue.d.ts → index.taro.vue.d.ts} +9 -12
- package/dist/types/__VUE/divider/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/drag/{index.vue.d.ts → index.taro.vue.d.ts} +2 -1
- package/dist/types/__VUE/ecard/{index.vue.d.ts → index.taro.vue.d.ts} +3 -3
- package/dist/types/__VUE/elevator/{index.vue.d.ts → index.taro.vue.d.ts} +11 -2
- package/dist/types/__VUE/ellipsis/{index.vue.d.ts → index.taro.vue.d.ts} +4 -0
- package/dist/types/__VUE/empty/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/fixednav/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/form/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/grid/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/griditem/{index.vue.d.ts → index.taro.vue.d.ts} +2 -27
- package/dist/types/__VUE/icon/index.taro.vue.d.ts +74 -0
- package/dist/types/__VUE/image/index.taro.vue.d.ts +33 -0
- package/dist/types/__VUE/imagepreview/{index.vue.d.ts → index.taro.vue.d.ts} +40 -42
- package/dist/types/__VUE/indicator/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/infiniteloading/{index.vue.d.ts → index.taro.vue.d.ts} +15 -8
- package/dist/types/__VUE/input/{index.vue.d.ts → index.taro.vue.d.ts} +34 -16
- package/dist/types/__VUE/inputnumber/{index.vue.d.ts → index.taro.vue.d.ts} +2 -2
- package/dist/types/__VUE/invoice/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/layout/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/list/{index.vue.d.ts → index.taro.vue.d.ts} +2 -2
- package/dist/types/__VUE/menu/{index.vue.d.ts → index.taro.vue.d.ts} +1 -0
- package/dist/types/__VUE/menuitem/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/navbar/{index.vue.d.ts → index.taro.vue.d.ts} +1 -2
- package/dist/types/__VUE/noticebar/{index.vue.d.ts → index.taro.vue.d.ts} +4 -3
- package/dist/types/__VUE/notify/{index.vue.d.ts → index.taro.vue.d.ts} +10 -25
- package/dist/types/__VUE/numberkeyboard/{index.vue.d.ts → index.taro.vue.d.ts} +5 -29
- package/dist/types/__VUE/oldpicker/{Column.vue.d.ts → ColumnTaro.vue.d.ts} +28 -17
- package/dist/types/__VUE/oldpicker/{index.vue.d.ts → index.taro.vue.d.ts} +64 -44
- package/dist/types/__VUE/overlay/index.taro.vue.d.ts +85 -0
- package/dist/types/__VUE/pagination/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/picker/{Column.vue.d.ts → ColumnTaro.vue.d.ts} +16 -4
- package/dist/types/__VUE/picker/{index.vue.d.ts → index.taro.vue.d.ts} +53 -28
- package/dist/types/__VUE/popover/{index.vue.d.ts → index.taro.vue.d.ts} +15 -13
- package/dist/types/__VUE/popup/index.taro.vue.d.ts +1728 -0
- package/dist/types/__VUE/popup/index.vue.d.ts +1 -1
- package/dist/types/__VUE/price/{index.vue.d.ts → index.taro.vue.d.ts} +1 -0
- package/dist/types/__VUE/progress/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/radio/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/range/{index.vue.d.ts → index.taro.vue.d.ts} +8 -7
- package/dist/types/__VUE/rate/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/searchbar/{index.vue.d.ts → index.taro.vue.d.ts} +19 -19
- package/dist/types/__VUE/shortpassword/{index.vue.d.ts → index.taro.vue.d.ts} +6 -21
- package/dist/types/__VUE/sidenavbar/{index.vue.d.ts → index.taro.vue.d.ts} +0 -5
- package/dist/types/__VUE/signature/{index.vue.d.ts → index.taro.vue.d.ts} +8 -5
- package/dist/types/__VUE/skeleton/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/sku/{index.vue.d.ts → index.taro.vue.d.ts} +54 -182
- package/dist/types/__VUE/step/index.vue.d.ts +1 -1
- package/dist/types/__VUE/steps/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/sticky/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/swipe/{index.vue.d.ts → index.taro.vue.d.ts} +2 -1
- package/dist/types/__VUE/swiper/{index.vue.d.ts → index.taro.vue.d.ts} +2 -1
- package/dist/types/__VUE/swiperitem/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/switch/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/tabbar/{index.vue.d.ts → index.taro.vue.d.ts} +10 -0
- package/dist/types/__VUE/tabbaritem/{index.vue.d.ts → index.taro.vue.d.ts} +9 -9
- package/dist/types/__VUE/table/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/tabs/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/tag/{index.vue.d.ts → index.taro.vue.d.ts} +4 -4
- package/dist/types/__VUE/textarea/{index.vue.d.ts → index.taro.vue.d.ts} +5 -3
- package/dist/types/__VUE/timedetail/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/timepannel/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/timeselect/{index.vue.d.ts → index.taro.vue.d.ts} +7 -8
- package/dist/types/__VUE/toast/{index.vue.d.ts → index.taro.vue.d.ts} +44 -22
- package/dist/types/__VUE/trendarrow/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/uploader/{index.vue.d.ts → index.taro.vue.d.ts} +22 -13
- package/dist/types/__VUE/video/index.vue.d.ts +3 -1
- package/dist/types/__VUE/watermark/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/nutui.d.ts +89 -89
- package/package.json +1 -1
- package/dist/types/__VUE/dialog/index.d.ts +0 -48
- package/dist/types/__VUE/image/index.vue.d.ts +0 -117
- package/dist/types/__VUE/image/type.d.ts +0 -6
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +0 -108
- package/dist/types/__VUE/imagepreview/index.d.ts +0 -25
- package/dist/types/__VUE/notify/index.d.ts +0 -26
- package/dist/types/__VUE/tag/type.d.ts +0 -5
- package/dist/types/__VUE/toast/index.d.ts +0 -16
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.2.
|
|
2
|
+
* @nutui/nutui v3.2.6-beta.1 Mon Oct 31 2022 19:38:22 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { ref, computed, reactive, watch, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, renderSlot, Fragment, renderList,
|
|
6
|
+
import { ref, computed, reactive, onMounted, watch, toRefs, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, createTextVNode, renderSlot, Fragment, renderList, createVNode, withCtx, normalizeStyle } from "vue";
|
|
7
7
|
import { c as createComponent } from "./component.js";
|
|
8
|
+
import Taro from "@tarojs/taro";
|
|
9
|
+
import { u as useExpose } from "./index2.js";
|
|
8
10
|
import { r as requestAniFrame } from "./raf.js";
|
|
9
|
-
import { u as useExpose } from "./index3.js";
|
|
10
11
|
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
11
12
|
const Utils = {
|
|
12
13
|
isLeapYear: function(y) {
|
|
@@ -90,6 +91,7 @@ const Utils = {
|
|
|
90
91
|
}
|
|
91
92
|
};
|
|
92
93
|
const { create, translate } = createComponent("calendar-item");
|
|
94
|
+
const TARO_ENV = Taro.getEnv();
|
|
93
95
|
const _sfc_main = create({
|
|
94
96
|
props: {
|
|
95
97
|
type: {
|
|
@@ -138,7 +140,7 @@ const _sfc_main = create({
|
|
|
138
140
|
},
|
|
139
141
|
defaultValue: {
|
|
140
142
|
type: [String, Array],
|
|
141
|
-
default:
|
|
143
|
+
default: null
|
|
142
144
|
},
|
|
143
145
|
startDate: {
|
|
144
146
|
type: String,
|
|
@@ -152,14 +154,10 @@ const _sfc_main = create({
|
|
|
152
154
|
emits: ["choose", "update", "close", "select"],
|
|
153
155
|
setup(props, { emit, slots }) {
|
|
154
156
|
const weeks = ref(translate("weekdays"));
|
|
155
|
-
const
|
|
156
|
-
const monthsPanel = ref(null);
|
|
157
|
-
const weeksPanel = ref(null);
|
|
158
|
-
const viewArea = ref(null);
|
|
157
|
+
const scalePx = ref(2);
|
|
159
158
|
const viewHeight = ref(0);
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
});
|
|
159
|
+
const scrollWithAnimation = ref(false);
|
|
160
|
+
const months = ref(null);
|
|
163
161
|
const showTopBtn = computed(() => {
|
|
164
162
|
return slots.btn;
|
|
165
163
|
});
|
|
@@ -171,7 +169,9 @@ const _sfc_main = create({
|
|
|
171
169
|
});
|
|
172
170
|
const state = reactive({
|
|
173
171
|
yearMonthTitle: "",
|
|
174
|
-
defaultRange: [],
|
|
172
|
+
defaultRange: [0, 1],
|
|
173
|
+
compConthsDatas: [],
|
|
174
|
+
containerHeight: "100%",
|
|
175
175
|
currDate: "",
|
|
176
176
|
propStartDate: "",
|
|
177
177
|
propEndDate: "",
|
|
@@ -197,6 +197,7 @@ const _sfc_main = create({
|
|
|
197
197
|
timer: 0,
|
|
198
198
|
currentIndex: 0,
|
|
199
199
|
avgHeight: 0,
|
|
200
|
+
scrollTop: 0,
|
|
200
201
|
monthsNum: 0
|
|
201
202
|
});
|
|
202
203
|
const splitDate = (date) => {
|
|
@@ -256,7 +257,7 @@ const _sfc_main = create({
|
|
|
256
257
|
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
257
258
|
if (type == "multiple") {
|
|
258
259
|
if (state.currDate.length > 0) {
|
|
259
|
-
let hasIndex =
|
|
260
|
+
let hasIndex = "";
|
|
260
261
|
state.currDate.forEach((item, index) => {
|
|
261
262
|
if (item == days[3]) {
|
|
262
263
|
hasIndex = index;
|
|
@@ -265,7 +266,7 @@ const _sfc_main = create({
|
|
|
265
266
|
if (isFirst) {
|
|
266
267
|
state.chooseData.push([...days]);
|
|
267
268
|
} else {
|
|
268
|
-
if (hasIndex !==
|
|
269
|
+
if (hasIndex !== "") {
|
|
269
270
|
state.currDate.splice(hasIndex, 1);
|
|
270
271
|
state.chooseData.splice(hasIndex, 1);
|
|
271
272
|
} else {
|
|
@@ -323,7 +324,7 @@ const _sfc_main = create({
|
|
|
323
324
|
month = month == 12 ? 1 : ++month;
|
|
324
325
|
break;
|
|
325
326
|
}
|
|
326
|
-
return [year
|
|
327
|
+
return [year, Utils.getNumTwoBit(month), Utils.getMonthDays(String(year), String(month))];
|
|
327
328
|
};
|
|
328
329
|
const getDaysStatus = (days, type, dateInfo) => {
|
|
329
330
|
let { year, month } = dateInfo;
|
|
@@ -356,13 +357,13 @@ const _sfc_main = create({
|
|
|
356
357
|
};
|
|
357
358
|
const getMonth = (curData, type) => {
|
|
358
359
|
const preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
|
|
359
|
-
let preMonth =
|
|
360
|
-
let preYear =
|
|
360
|
+
let preMonth = curData[1] - 1;
|
|
361
|
+
let preYear = curData[0];
|
|
361
362
|
if (preMonth <= 0) {
|
|
362
363
|
preMonth = 12;
|
|
363
364
|
preYear += 1;
|
|
364
365
|
}
|
|
365
|
-
const currMonthDays = Utils.getMonthDays(
|
|
366
|
+
const currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
|
|
366
367
|
const preCurrMonthDays = Utils.getMonthDays(preYear + "", preMonth + "");
|
|
367
368
|
const title = {
|
|
368
369
|
year: curData[0],
|
|
@@ -372,18 +373,19 @@ const _sfc_main = create({
|
|
|
372
373
|
curData,
|
|
373
374
|
title: translate("monthTitle", title.year, title.month),
|
|
374
375
|
monthData: [
|
|
375
|
-
...getPreDaysStatus(
|
|
376
|
-
preMonthDays,
|
|
377
|
-
"prev",
|
|
378
|
-
{ month: preMonth + "", year: preYear + "" },
|
|
379
|
-
preCurrMonthDays
|
|
380
|
-
),
|
|
376
|
+
...getPreDaysStatus(preMonthDays, "prev", { month: preMonth, year: preYear }, preCurrMonthDays),
|
|
381
377
|
...getDaysStatus(currMonthDays, "curr", title)
|
|
382
|
-
]
|
|
383
|
-
cssHeight: 0,
|
|
384
|
-
cssScrollHeight: 0
|
|
378
|
+
]
|
|
385
379
|
};
|
|
386
|
-
|
|
380
|
+
let titleHeight, itemHeight;
|
|
381
|
+
if (TARO_ENV === Taro.ENV_TYPE.WEB) {
|
|
382
|
+
titleHeight = 46 * scalePx.value + 16 * scalePx.value * 2;
|
|
383
|
+
itemHeight = 128 * scalePx.value;
|
|
384
|
+
} else {
|
|
385
|
+
titleHeight = Math.floor(46 * scalePx.value) + Math.floor(16 * scalePx.value) * 2;
|
|
386
|
+
itemHeight = Math.floor(128 * scalePx.value);
|
|
387
|
+
}
|
|
388
|
+
monthInfo.cssHeight = titleHeight + (monthInfo.monthData.length > 35 ? itemHeight * 6 : itemHeight * 5);
|
|
387
389
|
let cssScrollHeight = 0;
|
|
388
390
|
if (state.monthsData.length > 0) {
|
|
389
391
|
cssScrollHeight = state.monthsData[state.monthsData.length - 1].cssScrollHeight + state.monthsData[state.monthsData.length - 1].cssHeight;
|
|
@@ -491,7 +493,7 @@ const _sfc_main = create({
|
|
|
491
493
|
state.currentIndex = current;
|
|
492
494
|
state.yearMonthTitle = state.monthsData[state.currentIndex].title;
|
|
493
495
|
if (state.defaultData.length > 0) {
|
|
494
|
-
if (
|
|
496
|
+
if (state.isRange) {
|
|
495
497
|
chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
|
|
496
498
|
chooseDay({ day: state.defaultData[5], type: "curr" }, state.monthsData[lastCurrent], true);
|
|
497
499
|
} else if (props.type == "multiple") {
|
|
@@ -511,14 +513,12 @@ const _sfc_main = create({
|
|
|
511
513
|
}
|
|
512
514
|
let lastItem = state.monthsData[state.monthsData.length - 1];
|
|
513
515
|
let containerHeight = lastItem.cssHeight + lastItem.cssScrollHeight;
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
viewHeight.value = months.value.clientHeight;
|
|
517
|
-
monthsPanel.value.style.height = `${containerHeight}px`;
|
|
518
|
-
months.value.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
|
|
519
|
-
}
|
|
520
|
-
});
|
|
516
|
+
state.containerHeight = `${containerHeight}px`;
|
|
517
|
+
state.scrollTop = Math.ceil(state.monthsData[state.currentIndex].cssScrollHeight);
|
|
521
518
|
state.avgHeight = Math.floor(containerHeight / (monthsNum + 1));
|
|
519
|
+
if (months == null ? void 0 : months.value) {
|
|
520
|
+
viewHeight.value = months.value.clientHeight;
|
|
521
|
+
}
|
|
522
522
|
};
|
|
523
523
|
const scrollToDate = (date) => {
|
|
524
524
|
if (Utils.compareDate(date, state.propStartDate)) {
|
|
@@ -529,27 +529,16 @@ const _sfc_main = create({
|
|
|
529
529
|
let dateArr = splitDate(date);
|
|
530
530
|
state.monthsData.forEach((item, index) => {
|
|
531
531
|
if (item.title == translate("monthTitle", dateArr[0], dateArr[1])) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
if (flag >= 10) {
|
|
543
|
-
clearInterval(interval);
|
|
544
|
-
if (months.value) {
|
|
545
|
-
months.value.scrollTop = state.monthsData[index].cssScrollHeight;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
}, 40);
|
|
549
|
-
} else {
|
|
550
|
-
months.value.scrollTop = state.monthsData[index].cssScrollHeight;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
532
|
+
state.scrollTop += 1;
|
|
533
|
+
scrollWithAnimation.value = props.toDateAnimation;
|
|
534
|
+
requestAniFrame(() => {
|
|
535
|
+
setTimeout(() => {
|
|
536
|
+
state.scrollTop = state.monthsData[index].cssScrollHeight;
|
|
537
|
+
setTimeout(() => {
|
|
538
|
+
scrollWithAnimation.value = false;
|
|
539
|
+
}, 200);
|
|
540
|
+
}, 10);
|
|
541
|
+
});
|
|
553
542
|
}
|
|
554
543
|
});
|
|
555
544
|
};
|
|
@@ -557,16 +546,22 @@ const _sfc_main = create({
|
|
|
557
546
|
scrollToDate
|
|
558
547
|
});
|
|
559
548
|
const setDefaultRange = (monthsNum, current) => {
|
|
549
|
+
let rangeArr = [];
|
|
560
550
|
if (monthsNum >= 3) {
|
|
561
551
|
if (current > 0 && current < monthsNum) {
|
|
562
|
-
|
|
552
|
+
rangeArr = [current - 1, current + 3];
|
|
563
553
|
} else if (current == 0) {
|
|
564
|
-
|
|
554
|
+
rangeArr = [current, current + 4];
|
|
565
555
|
} else if (current == monthsNum) {
|
|
566
|
-
|
|
556
|
+
rangeArr = [current - 2, current + 2];
|
|
567
557
|
}
|
|
568
558
|
} else {
|
|
569
|
-
|
|
559
|
+
rangeArr = [0, monthsNum + 2];
|
|
560
|
+
}
|
|
561
|
+
if (JSON.stringify(state.defaultRange) !== JSON.stringify(rangeArr)) {
|
|
562
|
+
state.defaultRange[0] = rangeArr[0];
|
|
563
|
+
state.defaultRange[1] = rangeArr[1];
|
|
564
|
+
state.compConthsDatas = state.monthsData.slice(rangeArr[0], rangeArr[1]);
|
|
570
565
|
}
|
|
571
566
|
let defaultScrollTop = state.monthsData[state.defaultRange[0]].cssScrollHeight;
|
|
572
567
|
state.translateY = defaultScrollTop;
|
|
@@ -589,7 +584,7 @@ const _sfc_main = create({
|
|
|
589
584
|
}
|
|
590
585
|
};
|
|
591
586
|
const isCurrDay = (dateInfo) => {
|
|
592
|
-
const date = `${dateInfo.year}-${dateInfo.month}-${
|
|
587
|
+
const date = `${dateInfo.year}-${dateInfo.month}-${dateInfo.day < 10 ? "0" + dateInfo.day : dateInfo.day}`;
|
|
593
588
|
return Utils.isEqual(date, Utils.date2Str(new Date()));
|
|
594
589
|
};
|
|
595
590
|
const mothsViewScroll = (e) => {
|
|
@@ -609,17 +604,6 @@ const _sfc_main = create({
|
|
|
609
604
|
if (currentScrollTop < state.monthsData[current].cssScrollHeight) {
|
|
610
605
|
current -= 1;
|
|
611
606
|
}
|
|
612
|
-
} else {
|
|
613
|
-
const viewPosition = Math.round(currentScrollTop + viewHeight.value);
|
|
614
|
-
if (viewPosition < state.monthsData[current].cssScrollHeight + state.monthsData[current].cssHeight && currentScrollTop > state.monthsData[current - 1].cssScrollHeight) {
|
|
615
|
-
current -= 1;
|
|
616
|
-
}
|
|
617
|
-
if (current + 1 <= state.monthsNum && viewPosition >= state.monthsData[current + 1].cssScrollHeight + state.monthsData[current + 1].cssHeight) {
|
|
618
|
-
current += 1;
|
|
619
|
-
}
|
|
620
|
-
if (current >= 1 && currentScrollTop < state.monthsData[current - 1].cssScrollHeight) {
|
|
621
|
-
current -= 1;
|
|
622
|
-
}
|
|
623
607
|
}
|
|
624
608
|
if (state.currentIndex !== current) {
|
|
625
609
|
state.currentIndex = current;
|
|
@@ -632,7 +616,21 @@ const _sfc_main = create({
|
|
|
632
616
|
state.monthsData.splice(0);
|
|
633
617
|
initData();
|
|
634
618
|
};
|
|
635
|
-
|
|
619
|
+
onMounted(() => {
|
|
620
|
+
Taro.getSystemInfo({
|
|
621
|
+
success(res) {
|
|
622
|
+
let scale = 2;
|
|
623
|
+
let screenWidth = res.screenWidth;
|
|
624
|
+
let toFixed = 3;
|
|
625
|
+
if (TARO_ENV === Taro.ENV_TYPE.WEB) {
|
|
626
|
+
toFixed = 5;
|
|
627
|
+
}
|
|
628
|
+
scale = Number((screenWidth / 750).toFixed(toFixed));
|
|
629
|
+
scalePx.value = scale;
|
|
630
|
+
initData();
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
});
|
|
636
634
|
watch(
|
|
637
635
|
() => props.defaultValue,
|
|
638
636
|
(val) => {
|
|
@@ -645,7 +643,6 @@ const _sfc_main = create({
|
|
|
645
643
|
);
|
|
646
644
|
return {
|
|
647
645
|
weeks,
|
|
648
|
-
compConthsData,
|
|
649
646
|
showTopBtn,
|
|
650
647
|
topInfo,
|
|
651
648
|
bottomInfo,
|
|
@@ -657,12 +654,10 @@ const _sfc_main = create({
|
|
|
657
654
|
chooseDay,
|
|
658
655
|
isCurrDay,
|
|
659
656
|
confirm,
|
|
660
|
-
monthsPanel,
|
|
661
657
|
months,
|
|
662
|
-
weeksPanel,
|
|
663
|
-
viewArea,
|
|
664
658
|
...toRefs(state),
|
|
665
659
|
...toRefs(props),
|
|
660
|
+
scrollWithAnimation,
|
|
666
661
|
translate
|
|
667
662
|
};
|
|
668
663
|
}
|
|
@@ -679,39 +674,39 @@ const _hoisted_3 = {
|
|
|
679
674
|
key: 2,
|
|
680
675
|
class: "calendar-curr-month"
|
|
681
676
|
};
|
|
682
|
-
const _hoisted_4 = {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
ref: "monthsPanel"
|
|
689
|
-
};
|
|
690
|
-
const _hoisted_6 = { class: "calendar-month-title" };
|
|
691
|
-
const _hoisted_7 = { class: "calendar-month-con" };
|
|
692
|
-
const _hoisted_8 = ["onClick"];
|
|
693
|
-
const _hoisted_9 = { class: "calendar-day" };
|
|
694
|
-
const _hoisted_10 = {
|
|
677
|
+
const _hoisted_4 = { class: "calendar-weeks" };
|
|
678
|
+
const _hoisted_5 = { class: "calendar-month-title" };
|
|
679
|
+
const _hoisted_6 = { class: "calendar-month-con" };
|
|
680
|
+
const _hoisted_7 = ["onClick"];
|
|
681
|
+
const _hoisted_8 = { class: "calendar-day" };
|
|
682
|
+
const _hoisted_9 = {
|
|
695
683
|
key: 0,
|
|
696
684
|
class: "calendar-curr-tips calendar-curr-tips-top"
|
|
697
685
|
};
|
|
698
|
-
const
|
|
686
|
+
const _hoisted_10 = {
|
|
699
687
|
key: 1,
|
|
700
688
|
class: "calendar-curr-tips calendar-curr-tips-bottom"
|
|
701
689
|
};
|
|
702
|
-
const
|
|
690
|
+
const _hoisted_11 = {
|
|
703
691
|
key: 2,
|
|
704
692
|
class: "calendar-curr-tip-curr"
|
|
705
693
|
};
|
|
706
|
-
const
|
|
707
|
-
key:
|
|
694
|
+
const _hoisted_12 = {
|
|
695
|
+
key: 3,
|
|
708
696
|
class: "calendar-day-tip"
|
|
709
697
|
};
|
|
710
|
-
const
|
|
698
|
+
const _hoisted_13 = {
|
|
711
699
|
key: 0,
|
|
712
700
|
class: "nut-calendar-footer"
|
|
713
701
|
};
|
|
714
702
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
703
|
+
const _component_scroll_view = resolveComponent(function() {
|
|
704
|
+
if (process.env.TARO_ENV === "h5") {
|
|
705
|
+
return "taro-scroll-view";
|
|
706
|
+
} else {
|
|
707
|
+
return "scroll-view";
|
|
708
|
+
}
|
|
709
|
+
}());
|
|
715
710
|
return openBlock(), createElementBlock("view", {
|
|
716
711
|
class: normalizeClass(["nut-calendar nut-calendar-taro", {
|
|
717
712
|
"nut-calendar-tile": !_ctx.poppable,
|
|
@@ -722,10 +717,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
722
717
|
class: normalizeClass(["nut-calendar-header", { "nut-calendar-header-tile": !_ctx.poppable }])
|
|
723
718
|
}, [
|
|
724
719
|
_ctx.showTitle ? (openBlock(), createElementBlock("view", _hoisted_1, toDisplayString(_ctx.title || _ctx.translate("title")), 1)) : createCommentVNode("", true),
|
|
720
|
+
createTextVNode(),
|
|
725
721
|
_ctx.showTopBtn ? (openBlock(), createElementBlock("view", _hoisted_2, [
|
|
726
722
|
renderSlot(_ctx.$slots, "btn")
|
|
727
723
|
])) : createCommentVNode("", true),
|
|
724
|
+
createTextVNode(),
|
|
728
725
|
_ctx.showSubTitle ? (openBlock(), createElementBlock("view", _hoisted_3, toDisplayString(_ctx.yearMonthTitle), 1)) : createCommentVNode("", true),
|
|
726
|
+
createTextVNode(),
|
|
729
727
|
createElementVNode("view", _hoisted_4, [
|
|
730
728
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weeks, (item, index) => {
|
|
731
729
|
return openBlock(), createElementBlock("view", {
|
|
@@ -733,71 +731,86 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
733
731
|
key: index
|
|
734
732
|
}, toDisplayString(item), 1);
|
|
735
733
|
}), 128))
|
|
736
|
-
]
|
|
734
|
+
])
|
|
737
735
|
], 2),
|
|
738
|
-
|
|
736
|
+
createTextVNode(),
|
|
737
|
+
createVNode(_component_scroll_view, {
|
|
738
|
+
"scroll-top": _ctx.scrollTop,
|
|
739
|
+
"scroll-y": true,
|
|
739
740
|
class: "nut-calendar-content",
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
741
|
+
onScroll: _ctx.mothsViewScroll,
|
|
742
|
+
"scroll-with-animation": _ctx.scrollWithAnimation,
|
|
743
|
+
ref: "months"
|
|
744
|
+
}, {
|
|
745
|
+
default: withCtx(() => [
|
|
744
746
|
createElementVNode("view", {
|
|
745
|
-
class: "
|
|
746
|
-
|
|
747
|
-
style: normalizeStyle({ transform: `translateY(${_ctx.translateY}px)` })
|
|
747
|
+
class: "calendar-months-panel",
|
|
748
|
+
style: normalizeStyle({ height: _ctx.containerHeight })
|
|
748
749
|
}, [
|
|
749
|
-
(
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
750
|
+
createElementVNode("view", {
|
|
751
|
+
class: "viewArea",
|
|
752
|
+
style: normalizeStyle({ transform: `translateY(${_ctx.translateY}px)` })
|
|
753
|
+
}, [
|
|
754
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.compConthsDatas, (month, index) => {
|
|
755
|
+
return openBlock(), createElementBlock("view", {
|
|
756
|
+
class: "calendar-month",
|
|
757
|
+
key: index
|
|
758
|
+
}, [
|
|
759
|
+
createElementVNode("view", _hoisted_5, toDisplayString(month.title), 1),
|
|
760
|
+
createTextVNode(),
|
|
761
|
+
createElementVNode("view", _hoisted_6, [
|
|
762
|
+
createElementVNode("view", {
|
|
763
|
+
class: normalizeClass(["calendar-month-item", _ctx.type === "range" ? "month-item-range" : ""])
|
|
764
|
+
}, [
|
|
765
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(month.monthData, (day, i) => {
|
|
766
|
+
return openBlock(), createElementBlock("view", {
|
|
767
|
+
key: i,
|
|
768
|
+
class: normalizeClass(["calendar-month-day", _ctx.getClass(day, month)]),
|
|
769
|
+
onClick: ($event) => _ctx.chooseDay(day, month)
|
|
770
|
+
}, [
|
|
771
|
+
createElementVNode("view", _hoisted_8, [
|
|
772
|
+
renderSlot(_ctx.$slots, "day", {
|
|
773
|
+
date: day.type == "curr" ? day : ""
|
|
774
|
+
}, () => [
|
|
775
|
+
createTextVNode(toDisplayString(day.type == "curr" ? day.day : ""), 1)
|
|
776
|
+
])
|
|
777
|
+
]),
|
|
778
|
+
createTextVNode(),
|
|
779
|
+
_ctx.topInfo ? (openBlock(), createElementBlock("view", _hoisted_9, [
|
|
780
|
+
renderSlot(_ctx.$slots, "topInfo", {
|
|
781
|
+
date: day.type == "curr" ? day : ""
|
|
782
|
+
})
|
|
783
|
+
])) : createCommentVNode("", true),
|
|
784
|
+
createTextVNode(),
|
|
785
|
+
_ctx.bottomInfo ? (openBlock(), createElementBlock("view", _hoisted_10, [
|
|
786
|
+
renderSlot(_ctx.$slots, "bottomInfo", {
|
|
787
|
+
date: day.type == "curr" ? day : ""
|
|
788
|
+
})
|
|
789
|
+
])) : createCommentVNode("", true),
|
|
790
|
+
createTextVNode(),
|
|
791
|
+
!_ctx.bottomInfo && _ctx.showToday && _ctx.isCurrDay(day) ? (openBlock(), createElementBlock("view", _hoisted_11, toDisplayString(_ctx.translate("today")), 1)) : createCommentVNode("", true),
|
|
792
|
+
createTextVNode(),
|
|
793
|
+
createElementVNode("view", {
|
|
794
|
+
class: normalizeClass({ "calendar-curr-tips-top": _ctx.rangeTip(), "calendar-day-tip": true })
|
|
795
|
+
}, toDisplayString(_ctx.isStartTip(day, month) ? _ctx.startText || _ctx.translate("start") : ""), 3),
|
|
796
|
+
createTextVNode(),
|
|
797
|
+
_ctx.isEndTip(day, month) ? (openBlock(), createElementBlock("view", _hoisted_12, toDisplayString(_ctx.endText || _ctx.translate("end")), 1)) : createCommentVNode("", true)
|
|
798
|
+
], 10, _hoisted_7);
|
|
799
|
+
}), 128))
|
|
800
|
+
], 2)
|
|
801
|
+
])
|
|
802
|
+
]);
|
|
803
|
+
}), 128))
|
|
804
|
+
], 4)
|
|
794
805
|
], 4)
|
|
795
|
-
],
|
|
796
|
-
|
|
797
|
-
|
|
806
|
+
]),
|
|
807
|
+
_: 3
|
|
808
|
+
}, 8, ["scroll-top", "onScroll", "scroll-with-animation"]),
|
|
809
|
+
createTextVNode(),
|
|
810
|
+
_ctx.poppable && !_ctx.isAutoBackFill ? (openBlock(), createElementBlock("view", _hoisted_13, [
|
|
798
811
|
createElementVNode("view", {
|
|
799
812
|
class: "calendar-confirm-btn",
|
|
800
|
-
onClick: _cache[
|
|
813
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.confirm && _ctx.confirm(...args))
|
|
801
814
|
}, toDisplayString(_ctx.confirmText || _ctx.translate("confirm")), 1)
|
|
802
815
|
])) : createCommentVNode("", true)
|
|
803
816
|
], 2);
|
|
@@ -1,36 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.2.
|
|
2
|
+
* @nutui/nutui v3.2.6-beta.1 Mon Oct 31 2022 19:38:22 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const element = unref(elementRef);
|
|
12
|
-
if (isWindow(element)) {
|
|
13
|
-
const width = element.innerWidth;
|
|
14
|
-
const height = element.innerHeight;
|
|
15
|
-
return {
|
|
16
|
-
top: 0,
|
|
17
|
-
left: 0,
|
|
18
|
-
right: width,
|
|
19
|
-
bottom: height,
|
|
20
|
-
width,
|
|
21
|
-
height
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if (element && element.getBoundingClientRect) {
|
|
25
|
-
return element.getBoundingClientRect();
|
|
6
|
+
import { getCurrentInstance } from "vue";
|
|
7
|
+
function useExpose(apis) {
|
|
8
|
+
const instance = getCurrentInstance();
|
|
9
|
+
if (instance) {
|
|
10
|
+
Object.assign(instance.proxy, apis);
|
|
26
11
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
left: 0,
|
|
30
|
-
right: 0,
|
|
31
|
-
bottom: 0,
|
|
32
|
-
width: 0,
|
|
33
|
-
height: 0
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export { useRect as u };
|
|
12
|
+
}
|
|
13
|
+
export { useExpose as u };
|
|
@@ -1,13 +1,70 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.2.
|
|
2
|
+
* @nutui/nutui v3.2.6-beta.1 Mon Oct 31 2022 19:38:22 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
|
|
6
|
+
import { ref } from "vue";
|
|
7
|
+
const MIN_DISTANCE = 10;
|
|
8
|
+
function getDirection(x, y) {
|
|
9
|
+
if (x > y && x > MIN_DISTANCE) {
|
|
10
|
+
return "horizontal";
|
|
11
11
|
}
|
|
12
|
+
if (y > x && y > MIN_DISTANCE) {
|
|
13
|
+
return "vertical";
|
|
14
|
+
}
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
function useTouch() {
|
|
18
|
+
const startX = ref(0);
|
|
19
|
+
const startY = ref(0);
|
|
20
|
+
const moveX = ref(0);
|
|
21
|
+
const moveY = ref(0);
|
|
22
|
+
const deltaX = ref(0);
|
|
23
|
+
const deltaY = ref(0);
|
|
24
|
+
const offsetX = ref(0);
|
|
25
|
+
const offsetY = ref(0);
|
|
26
|
+
const direction = ref("");
|
|
27
|
+
const isVertical = () => direction.value === "vertical";
|
|
28
|
+
const isHorizontal = () => direction.value === "horizontal";
|
|
29
|
+
const reset = () => {
|
|
30
|
+
deltaX.value = 0;
|
|
31
|
+
deltaY.value = 0;
|
|
32
|
+
offsetX.value = 0;
|
|
33
|
+
offsetY.value = 0;
|
|
34
|
+
direction.value = "";
|
|
35
|
+
};
|
|
36
|
+
const start = (event) => {
|
|
37
|
+
reset();
|
|
38
|
+
startX.value = event.touches[0].clientX;
|
|
39
|
+
startY.value = event.touches[0].clientY;
|
|
40
|
+
};
|
|
41
|
+
const move = (event) => {
|
|
42
|
+
const touch = event.touches[0];
|
|
43
|
+
deltaX.value = touch.clientX - startX.value;
|
|
44
|
+
deltaY.value = touch.clientY - startY.value;
|
|
45
|
+
moveX.value = touch.clientX;
|
|
46
|
+
moveY.value = touch.clientY;
|
|
47
|
+
offsetX.value = Math.abs(deltaX.value);
|
|
48
|
+
offsetY.value = Math.abs(deltaY.value);
|
|
49
|
+
if (!direction.value) {
|
|
50
|
+
direction.value = getDirection(offsetX.value, offsetY.value);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
move,
|
|
55
|
+
start,
|
|
56
|
+
reset,
|
|
57
|
+
startX,
|
|
58
|
+
startY,
|
|
59
|
+
moveX,
|
|
60
|
+
moveY,
|
|
61
|
+
deltaX,
|
|
62
|
+
deltaY,
|
|
63
|
+
offsetX,
|
|
64
|
+
offsetY,
|
|
65
|
+
direction,
|
|
66
|
+
isVertical,
|
|
67
|
+
isHorizontal
|
|
68
|
+
};
|
|
12
69
|
}
|
|
13
|
-
export {
|
|
70
|
+
export { useTouch as u };
|