@nutui/nutui 3.1.22 → 3.1.23-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.
Files changed (176) hide show
  1. package/dist/nutui.es.js +20418 -4214
  2. package/dist/nutui.umd.js +20524 -4216
  3. package/dist/packages/_es/ActionSheet.js +149 -17
  4. package/dist/packages/_es/Address.js +535 -110
  5. package/dist/packages/_es/AddressList.js +615 -113
  6. package/dist/packages/_es/Animate.js +59 -17
  7. package/dist/packages/_es/Audio.js +257 -53
  8. package/dist/packages/_es/AudioOperate.js +100 -13
  9. package/dist/packages/_es/Avatar.js +162 -38
  10. package/dist/packages/_es/AvatarGroup.js +73 -14
  11. package/dist/packages/_es/BackTop.js +156 -43
  12. package/dist/packages/_es/Badge.js +86 -14
  13. package/dist/packages/_es/Barrage.js +120 -41
  14. package/dist/packages/_es/Button.js +128 -23
  15. package/dist/packages/_es/Calendar.js +246 -30
  16. package/dist/packages/_es/CalendarItem.js +1 -1
  17. package/dist/packages/_es/Card.js +107 -10
  18. package/dist/packages/_es/Cascader.js +496 -147
  19. package/dist/packages/_es/Category.js +58 -15
  20. package/dist/packages/_es/CategoryPane.js +111 -11
  21. package/dist/packages/_es/Cell.js +108 -21
  22. package/dist/packages/_es/CellGroup.js +44 -9
  23. package/dist/packages/_es/Checkbox.js +134 -29
  24. package/dist/packages/_es/CheckboxGroup.js +79 -29
  25. package/dist/packages/_es/CircleProgress.js +150 -28
  26. package/dist/packages/_es/Col.js +56 -14
  27. package/dist/packages/_es/Collapse.js +109 -32
  28. package/dist/packages/_es/CollapseItem.js +253 -59
  29. package/dist/packages/_es/Comment.js +434 -64
  30. package/dist/packages/_es/ConfigProvider.js +20 -8
  31. package/dist/packages/_es/CountDown.js +238 -56
  32. package/dist/packages/_es/CountUp.js +539 -140
  33. package/dist/packages/_es/DatePicker.js +315 -98
  34. package/dist/packages/_es/Dialog.js +289 -60
  35. package/dist/packages/_es/Divider.js +65 -13
  36. package/dist/packages/_es/Drag.js +197 -56
  37. package/dist/packages/_es/Ecard.js +159 -24
  38. package/dist/packages/_es/Elevator.js +255 -58
  39. package/dist/packages/_es/Ellipsis.js +200 -58
  40. package/dist/packages/_es/Empty.js +71 -12
  41. package/dist/packages/_es/FixedNav.js +122 -15
  42. package/dist/packages/_es/Form.js +151 -64
  43. package/dist/packages/_es/FormItem.js +114 -15
  44. package/dist/packages/_es/Grid.js +6 -5
  45. package/dist/packages/_es/GridItem.js +144 -33
  46. package/dist/packages/_es/Icon.js +40 -15
  47. package/dist/packages/_es/Image.js +137 -26
  48. package/dist/packages/_es/ImagePreview.js +547 -76
  49. package/dist/packages/_es/Indicator.js +62 -15
  50. package/dist/packages/_es/InfiniteLoading.js +249 -57
  51. package/dist/packages/_es/Input.js +433 -51
  52. package/dist/packages/_es/InputNumber.js +160 -41
  53. package/dist/packages/_es/Layout.js +5 -4
  54. package/dist/packages/_es/List.js +106 -18
  55. package/dist/packages/_es/Menu.js +168 -44
  56. package/dist/packages/_es/MenuItem.js +173 -37
  57. package/dist/packages/_es/Navbar.js +192 -30
  58. package/dist/packages/_es/NoticeBar.js +380 -74
  59. package/dist/packages/_es/Notify.js +227 -72
  60. package/dist/packages/_es/NumberKeyboard.js +272 -41
  61. package/dist/packages/_es/OldPicker.js +457 -130
  62. package/dist/packages/_es/OverLay.js +98 -24
  63. package/dist/packages/_es/Pagination.js +157 -39
  64. package/dist/packages/_es/Picker.js +460 -129
  65. package/dist/packages/_es/Popover.js +957 -318
  66. package/dist/packages/_es/Popup.js +299 -55
  67. package/dist/packages/_es/Price.js +118 -16
  68. package/dist/packages/_es/Progress.js +146 -14
  69. package/dist/packages/_es/PullRefresh.js +339 -84
  70. package/dist/packages/_es/Radio.js +90 -22
  71. package/dist/packages/_es/RadioGroup.js +37 -8
  72. package/dist/packages/_es/Range.js +408 -83
  73. package/dist/packages/_es/Rate.js +192 -36
  74. package/dist/packages/_es/Row.js +64 -22
  75. package/dist/packages/_es/SearchBar.js +238 -37
  76. package/dist/packages/_es/ShortPassword.js +225 -35
  77. package/dist/packages/_es/SideNavBar.js +81 -24
  78. package/dist/packages/_es/SideNavBarItem.js +46 -11
  79. package/dist/packages/_es/Signature.js +160 -41
  80. package/dist/packages/_es/Skeleton.js +136 -20
  81. package/dist/packages/_es/Sku.js +491 -84
  82. package/dist/packages/_es/Step.js +115 -20
  83. package/dist/packages/_es/Steps.js +53 -18
  84. package/dist/packages/_es/Sticky.js +138 -53
  85. package/dist/packages/_es/SubSideNavBar.js +82 -17
  86. package/dist/packages/_es/Swipe.js +178 -41
  87. package/dist/packages/_es/Swiper.js +433 -121
  88. package/dist/packages/_es/SwiperItem.js +53 -22
  89. package/dist/packages/_es/Switch.js +116 -21
  90. package/dist/packages/_es/TabPane.js +39 -12
  91. package/dist/packages/_es/Tabbar.js +72 -17
  92. package/dist/packages/_es/TabbarItem.js +151 -29
  93. package/dist/packages/_es/Table.js +178 -18
  94. package/dist/packages/_es/Tabs.js +202 -43
  95. package/dist/packages/_es/Tag.js +97 -20
  96. package/dist/packages/_es/TextArea.js +160 -42
  97. package/dist/packages/_es/TimeDetail.js +79 -18
  98. package/dist/packages/_es/TimePannel.js +48 -14
  99. package/dist/packages/_es/TimeSelect.js +112 -15
  100. package/dist/packages/_es/Toast.js +310 -71
  101. package/dist/packages/_es/Uploader.js +455 -104
  102. package/dist/packages/_es/Video.js +332 -74
  103. package/dist/packages/_es/common.js +128 -38
  104. package/dist/packages/_es/component.js +76 -35
  105. package/dist/packages/_es/index.js +6 -5
  106. package/dist/packages/_es/index2.js +30 -9
  107. package/dist/packages/_es/index3.js +8 -6
  108. package/dist/packages/_es/index4.js +64 -13
  109. package/dist/packages/_es/index5.js +780 -164
  110. package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
  111. package/dist/packages/_es/pxCheck.js +5 -3
  112. package/dist/packages/_es/raf.js +15 -8
  113. package/dist/packages/imagepreview/index.scss +6 -1
  114. package/dist/packages/locale/lang/baseLang.js +3 -3
  115. package/dist/packages/locale/lang/en-US.js +105 -5
  116. package/dist/packages/locale/lang/id-ID.js +105 -5
  117. package/dist/packages/locale/lang/index.js +38 -16
  118. package/dist/packages/locale/lang/zh-CN.js +105 -5
  119. package/dist/packages/locale/lang/zh-TW.js +105 -5
  120. package/dist/smartips/attributes.json +8 -0
  121. package/dist/smartips/tags.json +3 -1
  122. package/dist/smartips/web-types.json +19 -1
  123. package/dist/style.css +1 -1
  124. package/dist/style.es.js +1 -1
  125. package/dist/styles/themes/default.scss +41 -41
  126. package/dist/styles/themes/jdb.scss +41 -41
  127. package/dist/styles/themes/jdt.scss +41 -41
  128. package/dist/types/__VUE/actionsheet/index.vue.d.ts +5 -5
  129. package/dist/types/__VUE/address/index.vue.d.ts +7 -7
  130. package/dist/types/__VUE/avatar/index.vue.d.ts +4 -4
  131. package/dist/types/__VUE/avatargroup/index.vue.d.ts +2 -2
  132. package/dist/types/__VUE/backtop/index.vue.d.ts +2 -2
  133. package/dist/types/__VUE/badge/index.vue.d.ts +2 -2
  134. package/dist/types/__VUE/button/index.vue.d.ts +8 -8
  135. package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
  136. package/dist/types/__VUE/cascader/index.vue.d.ts +4 -4
  137. package/dist/types/__VUE/cell/index.vue.d.ts +6 -6
  138. package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
  139. package/dist/types/__VUE/collapseitem/index.vue.d.ts +2 -2
  140. package/dist/types/__VUE/comment/index.vue.d.ts +2 -2
  141. package/dist/types/__VUE/datepicker/index.vue.d.ts +4 -4
  142. package/dist/types/__VUE/dialog/index.vue.d.ts +4 -4
  143. package/dist/types/__VUE/fixednav/index.vue.d.ts +4 -4
  144. package/dist/types/__VUE/grid/index.vue.d.ts +4 -4
  145. package/dist/types/__VUE/image/index.vue.d.ts +4 -4
  146. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
  147. package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
  148. package/dist/types/__VUE/input/index.vue.d.ts +4 -4
  149. package/dist/types/__VUE/inputnumber/index.vue.d.ts +2 -2
  150. package/dist/types/__VUE/menu/index.vue.d.ts +2 -2
  151. package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
  152. package/dist/types/__VUE/noticebar/index.vue.d.ts +3 -3
  153. package/dist/types/__VUE/notify/index.vue.d.ts +2 -2
  154. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
  155. package/dist/types/__VUE/oldpicker/index.vue.d.ts +5 -5
  156. package/dist/types/__VUE/picker/Column.vue.d.ts +1 -1
  157. package/dist/types/__VUE/picker/index.vue.d.ts +6 -6
  158. package/dist/types/__VUE/popover/index.vue.d.ts +8 -8
  159. package/dist/types/__VUE/popup/index.vue.d.ts +6 -6
  160. package/dist/types/__VUE/radio/index.vue.d.ts +4 -4
  161. package/dist/types/__VUE/range/index.vue.d.ts +4 -4
  162. package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
  163. package/dist/types/__VUE/skeleton/index.vue.d.ts +4 -4
  164. package/dist/types/__VUE/sku/index.vue.d.ts +5 -5
  165. package/dist/types/__VUE/step/index.vue.d.ts +2 -2
  166. package/dist/types/__VUE/sticky/index.vue.d.ts +4 -4
  167. package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
  168. package/dist/types/__VUE/swiper/index.vue.d.ts +2 -2
  169. package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
  170. package/dist/types/__VUE/tabbaritem/index.vue.d.ts +2 -2
  171. package/dist/types/__VUE/tag/index.vue.d.ts +2 -2
  172. package/dist/types/__VUE/timeselect/index.vue.d.ts +2 -2
  173. package/dist/types/__VUE/toast/index.vue.d.ts +4 -4
  174. package/dist/types/__VUE/uploader/index.vue.d.ts +4 -4
  175. package/dist/types/index.d.ts +1 -1
  176. package/package.json +1 -2
@@ -1,19 +1,151 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.22 Fri Jun 24 2022 18:11:16 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { useSlots as e, ref as t, computed as r, onMounted as s, resolveComponent as o, openBlock as n, createElementBlock as a, createElementVNode as i, normalizeClass as l, normalizeStyle as u, toDisplayString as p, createCommentVNode as g, renderSlot as c, createBlock as d } from "vue";
7
- import { c as f } from "./component.js";
8
- import { _ as y } from "./plugin-vue_export-helper.js";
6
+ import { useSlots, ref, computed, onMounted, resolveComponent, openBlock, createElementBlock, createElementVNode, normalizeClass, normalizeStyle, toDisplayString, createCommentVNode, renderSlot, createBlock } from "vue";
7
+ import { c as createComponent } from "./component.js";
8
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
9
9
  import "../locale/lang";
10
- const { create: x } = f("progress"), h = x({ props: { percentage: { type: [Number, String], default: 0, required: true }, size: { type: String, default: "base" }, status: { type: String, default: "" }, strokeWidth: { type: [Number, String], default: "" }, textInside: { type: Boolean, default: false }, showText: { type: Boolean, default: true }, strokeColor: { type: String, default: "" }, textColor: { type: String, default: "" }, textBackground: { type: String, default: "" }, iconName: { type: String, default: "checked" }, iconColor: { type: String, default: "#439422" }, isShowPercentage: { type: Boolean, default: true } }, setup(o2, { emit: n2 }) {
11
- const a2 = !!e().default, i2 = t(o2.strokeWidth + "px"), l2 = t(), u2 = t(), p2 = r(() => ({ width: o2.percentage + "%", background: o2.strokeColor || "" })), g2 = r(() => ({ color: o2.textColor || "" }));
12
- return s(() => {
13
- }), { height: i2, bgStyle: p2, textStyle: g2, progressOuter: l2, insideText: u2, slotDefault: a2 };
14
- } }), m = { class: "nut-progress" };
15
- var S = y(h, [["render", function(e2, t2, r2, s2, f2, y2) {
16
- const x2 = o("nut-icon");
17
- return n(), a("div", m, [i("div", { class: l(["nut-progress-outer", [e2.showText && !e2.textInside ? "nut-progress-outer-part" : "", e2.size ? "nut-progress-" + e2.size : ""]]), ref: "progressOuter", style: u({ height: e2.height }) }, [i("div", { class: l(["nut-progress-inner", e2.status == "active" ? "nut-active" : ""]), style: u(e2.bgStyle) }, [e2.showText && e2.textInside && !e2.slotDefault ? (n(), a("div", { key: 0, class: "nut-progress-text nut-progress-insidetext", ref: "insideText", style: u({ lineHeight: e2.height, left: `${e2.percentage}%`, transform: `translate(-${+e2.percentage}%,-50%)`, background: e2.textBackground || e2.strokeColor }) }, [i("span", { style: u(e2.textStyle) }, p(e2.percentage) + p(e2.isShowPercentage ? "%" : ""), 5)], 4)) : g("", true), e2.showText && e2.textInside && e2.slotDefault ? (n(), a("div", { key: 1, ref: "insideText", style: u({ position: "absolute", top: "50%", left: `${e2.percentage}%`, transform: `translate(-${+e2.percentage}%,-50%)` }) }, [c(e2.$slots, "default")], 4)) : g("", true)], 6)], 6), e2.showText && !e2.textInside ? (n(), a("div", { key: 0, class: "nut-progress-text", style: u({ lineHeight: e2.height }) }, [e2.status == "active" || e2.status == "" ? (n(), a("span", { key: 0, style: u(e2.textStyle) }, p(e2.percentage) + p(e2.isShowPercentage ? "%" : ""), 5)) : e2.status == "icon" ? (n(), d(x2, { key: 1, size: "16px", name: e2.iconName, color: e2.iconColor }, null, 8, ["name", "color"])) : g("", true)], 4)) : g("", true)]);
18
- }]]);
19
- export { S as default };
10
+ const { create } = createComponent("progress");
11
+ const _sfc_main = create({
12
+ props: {
13
+ percentage: {
14
+ type: [Number, String],
15
+ default: 0,
16
+ required: true
17
+ },
18
+ size: {
19
+ type: String,
20
+ default: "base"
21
+ },
22
+ status: {
23
+ type: String,
24
+ default: ""
25
+ },
26
+ strokeWidth: {
27
+ type: [Number, String],
28
+ default: ""
29
+ },
30
+ textInside: {
31
+ type: Boolean,
32
+ default: false
33
+ },
34
+ showText: {
35
+ type: Boolean,
36
+ default: true
37
+ },
38
+ strokeColor: {
39
+ type: String,
40
+ default: ""
41
+ },
42
+ textColor: {
43
+ type: String,
44
+ default: ""
45
+ },
46
+ textBackground: {
47
+ type: String,
48
+ default: ""
49
+ },
50
+ iconName: {
51
+ type: String,
52
+ default: "checked"
53
+ },
54
+ iconColor: {
55
+ type: String,
56
+ default: "#439422"
57
+ },
58
+ isShowPercentage: {
59
+ type: Boolean,
60
+ default: true
61
+ }
62
+ },
63
+ setup(props, { emit }) {
64
+ const slotDefault = !!useSlots().default;
65
+ const height = ref(props.strokeWidth + "px");
66
+ const progressOuter = ref();
67
+ const insideText = ref();
68
+ const bgStyle = computed(() => {
69
+ return {
70
+ width: props.percentage + "%",
71
+ background: props.strokeColor || ""
72
+ };
73
+ });
74
+ const textStyle = computed(() => {
75
+ return {
76
+ color: props.textColor || ""
77
+ };
78
+ });
79
+ onMounted(() => {
80
+ });
81
+ return {
82
+ height,
83
+ bgStyle,
84
+ textStyle,
85
+ progressOuter,
86
+ insideText,
87
+ slotDefault
88
+ };
89
+ }
90
+ });
91
+ const _hoisted_1 = { class: "nut-progress" };
92
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
93
+ const _component_nut_icon = resolveComponent("nut-icon");
94
+ return openBlock(), createElementBlock("div", _hoisted_1, [
95
+ createElementVNode("div", {
96
+ class: normalizeClass(["nut-progress-outer", [_ctx.showText && !_ctx.textInside ? "nut-progress-outer-part" : "", _ctx.size ? "nut-progress-" + _ctx.size : ""]]),
97
+ ref: "progressOuter",
98
+ style: normalizeStyle({ height: _ctx.height })
99
+ }, [
100
+ createElementVNode("div", {
101
+ class: normalizeClass(["nut-progress-inner", _ctx.status == "active" ? "nut-active" : ""]),
102
+ style: normalizeStyle(_ctx.bgStyle)
103
+ }, [
104
+ _ctx.showText && _ctx.textInside && !_ctx.slotDefault ? (openBlock(), createElementBlock("div", {
105
+ key: 0,
106
+ class: "nut-progress-text nut-progress-insidetext",
107
+ ref: "insideText",
108
+ style: normalizeStyle({
109
+ lineHeight: _ctx.height,
110
+ left: `${_ctx.percentage}%`,
111
+ transform: `translate(-${+_ctx.percentage}%,-50%)`,
112
+ background: _ctx.textBackground || _ctx.strokeColor
113
+ })
114
+ }, [
115
+ createElementVNode("span", {
116
+ style: normalizeStyle(_ctx.textStyle)
117
+ }, toDisplayString(_ctx.percentage) + toDisplayString(_ctx.isShowPercentage ? "%" : ""), 5)
118
+ ], 4)) : createCommentVNode("", true),
119
+ _ctx.showText && _ctx.textInside && _ctx.slotDefault ? (openBlock(), createElementBlock("div", {
120
+ key: 1,
121
+ ref: "insideText",
122
+ style: normalizeStyle({
123
+ position: `absolute`,
124
+ top: `50%`,
125
+ left: `${_ctx.percentage}%`,
126
+ transform: `translate(-${+_ctx.percentage}%,-50%)`
127
+ })
128
+ }, [
129
+ renderSlot(_ctx.$slots, "default")
130
+ ], 4)) : createCommentVNode("", true)
131
+ ], 6)
132
+ ], 6),
133
+ _ctx.showText && !_ctx.textInside ? (openBlock(), createElementBlock("div", {
134
+ key: 0,
135
+ class: "nut-progress-text",
136
+ style: normalizeStyle({ lineHeight: _ctx.height })
137
+ }, [
138
+ _ctx.status == "active" || _ctx.status == "" ? (openBlock(), createElementBlock("span", {
139
+ key: 0,
140
+ style: normalizeStyle(_ctx.textStyle)
141
+ }, toDisplayString(_ctx.percentage) + toDisplayString(_ctx.isShowPercentage ? "%" : ""), 5)) : _ctx.status == "icon" ? (openBlock(), createBlock(_component_nut_icon, {
142
+ key: 1,
143
+ size: "16px",
144
+ name: _ctx.iconName,
145
+ color: _ctx.iconColor
146
+ }, null, 8, ["name", "color"])) : createCommentVNode("", true)
147
+ ], 4)) : createCommentVNode("", true)
148
+ ]);
149
+ }
150
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
151
+ export { index as default };
@@ -1,94 +1,349 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.22 Fri Jun 24 2022 18:11:16 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { ref as e, toRefs as t, reactive as l, computed as a, onMounted as o, openBlock as u, createElementBlock as r, normalizeStyle as n, createElementVNode as s, normalizeClass as i, toDisplayString as v, renderSlot as c } from "vue";
7
- import { c as d } from "./component.js";
8
- import { _ as h } from "./plugin-vue_export-helper.js";
6
+ import { ref, toRefs, reactive, computed, onMounted, openBlock, createElementBlock, normalizeStyle, createElementVNode, normalizeClass, toDisplayString, renderSlot } from "vue";
7
+ import { c as createComponent } from "./component.js";
8
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
9
9
  import "../locale/lang";
10
- function f(e2, t2) {
11
- (typeof e2.cancelable != "boolean" || e2.cancelable) && e2.preventDefault(), t2 && e2.stopPropagation();
10
+ const MIN_DISTANCE = 10;
11
+ function getDirection(x, y) {
12
+ if (x > y && x > MIN_DISTANCE) {
13
+ return "horizontal";
14
+ }
15
+ if (y > x && y > MIN_DISTANCE) {
16
+ return "vertical";
17
+ }
18
+ return "";
12
19
  }
13
- const { componentName: p, create: m } = d("pullrefresh"), g = m({ props: { useWindow: { type: Boolean, default: true }, containerId: { type: String, default: "" }, disabled: { type: Boolean, default: false }, direction: { type: String, default: "vertical" }, pullingText: { type: Object, default: { top: "\u4E0B\u62C9\u5237\u65B0", bottom: "\u4E0A\u62C9\u52A0\u8F7D", left: "\u5DE6\u6ED1\u5237\u65B0", right: "\u53F3\u6ED1\u52A0\u8F7D" } }, loosingText: { type: Object, default: { top: "\u677E\u624B\u91CA\u653E\u5237\u65B0", bottom: "\u677E\u624B\u91CA\u653E\u5237\u65B0", left: "\u91CA\u653E\u5237\u65B0", right: "\u52A0\u8F7D\u66F4\u591A" } }, loadingText: { type: Object, default: { top: "\u52A0\u8F7D\u4E2D...", bottom: "\u52A0\u8F7D\u4E2D...", left: "\u52A0\u8F7D\u4E2D...", right: "\u52A0\u8F7D\u4E2D..." } } }, emits: ["refresh", "downRefresh"], setup(u2, { emit: r2 }) {
14
- const { containerId: n2, useWindow: s2, direction: i2, disabled: v2 } = t(u2), c2 = e(false), d2 = e(false), h2 = e(false), p2 = e(false), m2 = l({ status: "normal", distance: 0, duration: 0 });
15
- let g2 = document.documentElement || document.body;
16
- const b2 = e(null), T2 = function() {
17
- const t2 = e(0), l2 = e(0), a2 = e(0), o2 = e(0), u3 = e(0), r3 = e(0), n3 = e(""), s3 = () => {
18
- a2.value = 0, o2.value = 0, u3.value = 0, r3.value = 0, n3.value = "";
19
- };
20
- return { move: (e2) => {
21
- const s4 = e2.touches[0];
22
- var i3, v3;
23
- a2.value = s4.clientX - t2.value, o2.value = s4.clientY - l2.value, u3.value = Math.abs(a2.value), r3.value = Math.abs(o2.value), n3.value || (n3.value = (i3 = u3.value) > (v3 = r3.value) && i3 > 10 ? "horizontal" : v3 > i3 && v3 > 10 ? "vertical" : "");
24
- }, start: (e2) => {
25
- s3(), t2.value = e2.touches[0].clientX, l2.value = e2.touches[0].clientY;
26
- }, reset: s3, startX: t2, startY: l2, deltaX: a2, deltaY: o2, offsetX: u3, offsetY: r3, direction: n3, isVertical: () => n3.value === "vertical", isHorizontal: () => n3.value === "horizontal" };
27
- }(), x = a(() => {
28
- let e2 = {};
29
- const { deltaY: t2, deltaX: l2 } = T2;
30
- return i2.value == "vertical" && (c2.value && t2.value > 0 || d2.value && t2.value < 0) && T2.isVertical() && (e2 = { transitionDuration: `${m2.duration}ms`, transform: m2.distance ? `translate3d(0,${m2.distance}px, 0)` : "translate3d(0,0,0)" }), i2.value == "horizontal" && (h2.value && l2.value > 0 || p2.value && l2.value < 0) && T2.isHorizontal() && (e2 = { transitionDuration: `${m2.duration}ms`, transform: m2.distance ? `translate3d(${m2.distance}px, 0,0)` : "translate3d(0,0,0)" }), e2;
31
- }), y = a(() => {
32
- let e2 = {};
33
- if (i2.value == "vertical" && d2.value && T2.deltaY.value < 0 && T2.isVertical()) {
34
- e2 = { height: (Math.abs(m2.distance) < 50 ? -m2.distance : 50) + "px" };
35
- }
36
- if (i2.value == "horizontal" && p2.value && T2.deltaX.value < 0 && T2.isVertical()) {
37
- e2 = { width: (Math.abs(m2.distance) < 50 ? -m2.distance : 50) + "px" };
20
+ function useTouch() {
21
+ const startX = ref(0);
22
+ const startY = ref(0);
23
+ const deltaX = ref(0);
24
+ const deltaY = ref(0);
25
+ const offsetX = ref(0);
26
+ const offsetY = ref(0);
27
+ const direction = ref("");
28
+ const isVertical = () => direction.value === "vertical";
29
+ const isHorizontal = () => direction.value === "horizontal";
30
+ const reset = () => {
31
+ deltaX.value = 0;
32
+ deltaY.value = 0;
33
+ offsetX.value = 0;
34
+ offsetY.value = 0;
35
+ direction.value = "";
36
+ };
37
+ const start = (event) => {
38
+ reset();
39
+ startX.value = event.touches[0].clientX;
40
+ startY.value = event.touches[0].clientY;
41
+ };
42
+ const move = (event) => {
43
+ const touch = event.touches[0];
44
+ deltaX.value = touch.clientX - startX.value;
45
+ deltaY.value = touch.clientY - startY.value;
46
+ offsetX.value = Math.abs(deltaX.value);
47
+ offsetY.value = Math.abs(deltaY.value);
48
+ if (!direction.value) {
49
+ direction.value = getDirection(offsetX.value, offsetY.value);
38
50
  }
39
- return e2;
40
- }), z = a(() => {
41
- const { status: e2, distance: t2 } = m2, l2 = i2.value == "vertical" ? "top" : "left";
42
- return e2 == "loading" && (c2.value || h2.value) && t2 > 0 ? u2.loadingText[l2] : e2 == "pulling" && (c2.value || h2.value) && t2 > 0 ? u2.pullingText[l2] : e2 == "loosing" && (c2.value || h2.value) && t2 > 0 ? u2.loosingText[l2] : "";
43
- }), M = a(() => {
44
- const { status: e2, distance: t2 } = m2, l2 = i2.value == "vertical" ? "bottom" : "right";
45
- return e2 == "loading" && (d2.value || p2.value) && t2 < 0 ? u2.loadingText[l2] : e2 == "pulling" && (d2.value || p2.value) && t2 < 0 ? u2.pullingText[l2] : e2 == "loosing" && (d2.value || p2.value) && t2 < 0 ? u2.loosingText[l2] : "";
46
- }), w = () => m2.status !== "loading" && !v2.value, S = (e2, t2) => {
47
- m2.distance = e2, t2 ? m2.status = "loading" : e2 === 0 ? m2.status = "normal" : Math.abs(e2) < 50 ? m2.status = "pulling" : m2.status = "loosing";
48
51
  };
49
- o(() => {
50
- const e2 = (t2 = b2, n2.value != "" ? document.querySelector(`#${n2.value}`) : t2 && t2.parentNode);
51
- var t2;
52
- let l2 = document.documentElement || document.body;
53
- s2.value === false && (l2 = e2), g2 = l2;
54
- });
55
- const X = (e2) => {
56
- const t2 = 50;
57
- return e2 > t2 && (e2 = e2 < 100 ? t2 + (e2 - t2) / 2 : 75 + (e2 - 100) / 4), Math.round(e2);
58
- }, Y = () => {
59
- S(0);
52
+ return {
53
+ move,
54
+ start,
55
+ reset,
56
+ startX,
57
+ startY,
58
+ deltaX,
59
+ deltaY,
60
+ offsetX,
61
+ offsetY,
62
+ direction,
63
+ isVertical,
64
+ isHorizontal
60
65
  };
61
- return { scroller: b2, touchStart: (e2) => {
62
- if (w())
63
- if (i2.value == "vertical") {
64
- const t2 = "scrollTop" in g2 ? g2.scrollTop : 0;
65
- c2.value = Math.max(t2, 0) == 0;
66
- const { scrollHeight: l2, clientHeight: a2, scrollTop: o2 } = g2;
67
- d2.value = a2 + o2 == l2, (c2.value || d2.value) && (m2.duration = 0, T2.start(e2));
68
- } else {
69
- const { scrollWidth: t2, clientWidth: l2, scrollLeft: a2 } = g2, o2 = "scrollLeft" in g2 ? g2.scrollLeft : 0;
70
- h2.value = Math.max(o2, 0) == 0, p2.value = l2 + a2 == t2, (h2.value || p2.value) && (m2.duration = 0, T2.start(e2));
71
- }
72
- else
73
- f(e2);
74
- }, touchMove: (e2) => {
75
- if (w()) {
76
- const { deltaY: t2, deltaX: l2 } = T2;
77
- T2.move(e2), i2.value == "vertical" && (d2.value && t2.value < 0 || c2.value && t2.value >= 0) && T2.isVertical() && (f(e2), S(X(t2.value))), i2.value == "horizontal" && (h2.value && l2.value >= 0 || p2.value && l2.value < 0) && T2.isHorizontal() && (f(e2), S(X(l2.value)));
78
- } else
79
- f(e2);
80
- }, touchEnd: () => {
81
- if (w()) {
82
- const { deltaY: e2, deltaX: t2 } = T2;
83
- if (m2.status === "loosing") {
84
- let l2 = 0;
85
- i2.value == "vertical" && c2.value && e2.value > 0 && (l2 = 50, r2("downRefresh", Y)), i2.value == "vertical" && d2.value && e2.value < 0 && (l2 = -50, r2("refresh", Y)), i2.value == "horizontal" && h2.value && t2.value > 0 && (l2 = 50, r2("downRefresh", Y)), i2.value == "horizontal" && p2.value && t2.value < 0 && (l2 = -50, r2("refresh", Y)), S(l2, true);
86
- } else
87
- S(0);
66
+ }
67
+ function preventDefault(event, isStopPropagation) {
68
+ if (typeof event.cancelable !== "boolean" || event.cancelable) {
69
+ event.preventDefault();
70
+ }
71
+ if (isStopPropagation)
72
+ event.stopPropagation();
73
+ }
74
+ const { componentName, create } = createComponent("pullrefresh");
75
+ const _sfc_main = create({
76
+ props: {
77
+ useWindow: {
78
+ type: Boolean,
79
+ default: true
80
+ },
81
+ containerId: {
82
+ type: String,
83
+ default: ""
84
+ },
85
+ disabled: {
86
+ type: Boolean,
87
+ default: false
88
+ },
89
+ direction: {
90
+ type: String,
91
+ default: "vertical"
92
+ },
93
+ pullingText: {
94
+ type: Object,
95
+ default: {
96
+ top: "\u4E0B\u62C9\u5237\u65B0",
97
+ bottom: "\u4E0A\u62C9\u52A0\u8F7D",
98
+ left: "\u5DE6\u6ED1\u5237\u65B0",
99
+ right: "\u53F3\u6ED1\u52A0\u8F7D"
100
+ }
101
+ },
102
+ loosingText: {
103
+ type: Object,
104
+ default: {
105
+ top: "\u677E\u624B\u91CA\u653E\u5237\u65B0",
106
+ bottom: "\u677E\u624B\u91CA\u653E\u5237\u65B0",
107
+ left: "\u91CA\u653E\u5237\u65B0",
108
+ right: "\u52A0\u8F7D\u66F4\u591A"
109
+ }
110
+ },
111
+ loadingText: {
112
+ type: Object,
113
+ default: {
114
+ top: "\u52A0\u8F7D\u4E2D...",
115
+ bottom: "\u52A0\u8F7D\u4E2D...",
116
+ left: "\u52A0\u8F7D\u4E2D...",
117
+ right: "\u52A0\u8F7D\u4E2D..."
118
+ }
88
119
  }
89
- }, getStyle: x, reachBottom: d2, reachTop: c2, reachRight: p2, reachLeft: h2, getBottomStyle: y, refreshTopTem: z, refreshBottomTem: M, ...t(m2) };
90
- } }), b = { class: "pullrefresh-content", ref: "pull" };
91
- var T = h(g, [["render", function(e2, t2, l2, a2, o2, d2) {
92
- return u(), r("view", { class: "nut-pullrefresh", ref: "scroller", style: n(e2.getStyle), onTouchstart: t2[0] || (t2[0] = (...t3) => e2.touchStart && e2.touchStart(...t3)), onTouchmove: t2[1] || (t2[1] = (...t3) => e2.touchMove && e2.touchMove(...t3)), onTouchend: t2[2] || (t2[2] = (...t3) => e2.touchEnd && e2.touchEnd(...t3)) }, [s("view", { class: i(["pullrefresh-top", e2.direction == "horizontal" ? "pullrefresh-top-h" : "pullrefresh-top-v"]) }, v(e2.refreshTopTem), 3), s("view", b, [c(e2.$slots, "default")], 512), s("view", { class: i(["pullrefresh-bottom", e2.direction == "horizontal" ? "pullrefresh-bottom-h" : "pullrefresh-bottom-v"]), style: n(e2.getBottomStyle) }, v(e2.refreshBottomTem), 7)], 36);
93
- }]]);
94
- export { T as default };
120
+ },
121
+ emits: ["refresh", "downRefresh"],
122
+ setup(props, { emit }) {
123
+ const { containerId, useWindow, direction, disabled } = toRefs(props);
124
+ const reachTop = ref(false);
125
+ const reachBottom = ref(false);
126
+ const reachLeft = ref(false);
127
+ const reachRight = ref(false);
128
+ const state = reactive({
129
+ status: "normal",
130
+ distance: 0,
131
+ duration: 0
132
+ });
133
+ let scrollEl = document.documentElement || document.body;
134
+ const scroller = ref(null);
135
+ const touch = useTouch();
136
+ const getStyle = computed(() => {
137
+ let style = {};
138
+ const { deltaY, deltaX } = touch;
139
+ if (direction.value == "vertical" && (reachTop.value && deltaY.value > 0 || reachBottom.value && deltaY.value < 0) && touch.isVertical()) {
140
+ style = {
141
+ transitionDuration: `${state.duration}ms`,
142
+ transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : `translate3d(0,0,0)`
143
+ };
144
+ }
145
+ if (direction.value == "horizontal" && (reachLeft.value && deltaX.value > 0 || reachRight.value && deltaX.value < 0) && touch.isHorizontal()) {
146
+ style = {
147
+ transitionDuration: `${state.duration}ms`,
148
+ transform: state.distance ? `translate3d(${state.distance}px, 0,0)` : `translate3d(0,0,0)`
149
+ };
150
+ }
151
+ return style;
152
+ });
153
+ const getBottomStyle = computed(() => {
154
+ let style = {};
155
+ if (direction.value == "vertical" && reachBottom.value && touch.deltaY.value < 0 && touch.isVertical()) {
156
+ const dis = Math.abs(state.distance) < 50 ? -state.distance : 50;
157
+ style = {
158
+ height: dis + "px"
159
+ };
160
+ }
161
+ if (direction.value == "horizontal" && reachRight.value && touch.deltaX.value < 0 && touch.isVertical()) {
162
+ const dis = Math.abs(state.distance) < 50 ? -state.distance : 50;
163
+ style = {
164
+ width: dis + "px"
165
+ };
166
+ }
167
+ return style;
168
+ });
169
+ const refreshTopTem = computed(() => {
170
+ const { status, distance } = state;
171
+ const tag = direction.value == "vertical" ? "top" : "left";
172
+ if (status == "loading" && (reachTop.value || reachLeft.value) && distance > 0) {
173
+ return props.loadingText[tag];
174
+ }
175
+ if (status == "pulling" && (reachTop.value || reachLeft.value) && distance > 0) {
176
+ return props.pullingText[tag];
177
+ }
178
+ if (status == "loosing" && (reachTop.value || reachLeft.value) && distance > 0) {
179
+ return props.loosingText[tag];
180
+ }
181
+ return "";
182
+ });
183
+ const refreshBottomTem = computed(() => {
184
+ const { status, distance } = state;
185
+ const tag = direction.value == "vertical" ? "bottom" : "right";
186
+ if (status == "loading" && (reachBottom.value || reachRight.value) && distance < 0) {
187
+ return props.loadingText[tag];
188
+ }
189
+ if (status == "pulling" && (reachBottom.value || reachRight.value) && distance < 0) {
190
+ return props.pullingText[tag];
191
+ }
192
+ if (status == "loosing" && (reachBottom.value || reachRight.value) && distance < 0) {
193
+ return props.loosingText[tag];
194
+ }
195
+ return "";
196
+ });
197
+ const isTouchable = () => state.status !== "loading" && !disabled.value;
198
+ const setStatus = (distance, isLoading) => {
199
+ state.distance = distance;
200
+ if (isLoading) {
201
+ state.status = "loading";
202
+ } else if (distance === 0) {
203
+ state.status = "normal";
204
+ } else if (Math.abs(distance) < 50) {
205
+ state.status = "pulling";
206
+ } else {
207
+ state.status = "loosing";
208
+ }
209
+ };
210
+ const getParentElement = (el) => {
211
+ if (containerId.value != "") {
212
+ return document.querySelector(`#${containerId.value}`);
213
+ }
214
+ return el && el.parentNode;
215
+ };
216
+ onMounted(() => {
217
+ const parentElement = getParentElement(scroller);
218
+ let scrollElCopy = document.documentElement || document.body;
219
+ if (useWindow.value === false) {
220
+ scrollElCopy = parentElement;
221
+ }
222
+ scrollEl = scrollElCopy;
223
+ });
224
+ const ease = (distance) => {
225
+ const headHeight = 50;
226
+ if (distance > headHeight) {
227
+ if (distance < headHeight * 2) {
228
+ distance = headHeight + (distance - headHeight) / 2;
229
+ } else {
230
+ distance = headHeight * 1.5 + (distance - headHeight * 2) / 4;
231
+ }
232
+ }
233
+ return Math.round(distance);
234
+ };
235
+ const refreshDone = () => {
236
+ setStatus(0);
237
+ };
238
+ const touchStart = (event) => {
239
+ if (isTouchable()) {
240
+ if (direction.value == "vertical") {
241
+ const top = "scrollTop" in scrollEl ? scrollEl.scrollTop : 0;
242
+ reachTop.value = Math.max(top, 0) == 0 ? true : false;
243
+ const { scrollHeight, clientHeight, scrollTop } = scrollEl;
244
+ reachBottom.value = clientHeight + scrollTop == scrollHeight ? true : false;
245
+ if (reachTop.value || reachBottom.value) {
246
+ state.duration = 0;
247
+ touch.start(event);
248
+ }
249
+ } else {
250
+ const { scrollWidth, clientWidth, scrollLeft } = scrollEl;
251
+ const left = "scrollLeft" in scrollEl ? scrollEl.scrollLeft : 0;
252
+ reachLeft.value = Math.max(left, 0) == 0 ? true : false;
253
+ reachRight.value = clientWidth + scrollLeft == scrollWidth ? true : false;
254
+ if (reachLeft.value || reachRight.value) {
255
+ state.duration = 0;
256
+ touch.start(event);
257
+ }
258
+ }
259
+ } else {
260
+ preventDefault(event);
261
+ }
262
+ };
263
+ const touchMove = (event) => {
264
+ if (isTouchable()) {
265
+ const { deltaY, deltaX } = touch;
266
+ touch.move(event);
267
+ if (direction.value == "vertical" && (reachBottom.value && deltaY.value < 0 || reachTop.value && deltaY.value >= 0) && touch.isVertical()) {
268
+ preventDefault(event);
269
+ setStatus(ease(deltaY.value));
270
+ }
271
+ if (direction.value == "horizontal" && (reachLeft.value && deltaX.value >= 0 || reachRight.value && deltaX.value < 0) && touch.isHorizontal()) {
272
+ preventDefault(event);
273
+ setStatus(ease(deltaX.value));
274
+ }
275
+ } else {
276
+ preventDefault(event);
277
+ }
278
+ };
279
+ const touchEnd = () => {
280
+ if (isTouchable()) {
281
+ const { deltaY, deltaX } = touch;
282
+ if (state.status === "loosing") {
283
+ let dis = 0;
284
+ if (direction.value == "vertical" && reachTop.value && deltaY.value > 0) {
285
+ dis = 50;
286
+ emit("downRefresh", refreshDone);
287
+ }
288
+ if (direction.value == "vertical" && reachBottom.value && deltaY.value < 0) {
289
+ dis = -50;
290
+ emit("refresh", refreshDone);
291
+ }
292
+ if (direction.value == "horizontal" && reachLeft.value && deltaX.value > 0) {
293
+ dis = 50;
294
+ emit("downRefresh", refreshDone);
295
+ }
296
+ if (direction.value == "horizontal" && reachRight.value && deltaX.value < 0) {
297
+ dis = -50;
298
+ emit("refresh", refreshDone);
299
+ }
300
+ setStatus(dis, true);
301
+ } else {
302
+ setStatus(0);
303
+ }
304
+ }
305
+ };
306
+ return {
307
+ scroller,
308
+ touchStart,
309
+ touchMove,
310
+ touchEnd,
311
+ getStyle,
312
+ reachBottom,
313
+ reachTop,
314
+ reachRight,
315
+ reachLeft,
316
+ getBottomStyle,
317
+ refreshTopTem,
318
+ refreshBottomTem,
319
+ ...toRefs(state)
320
+ };
321
+ }
322
+ });
323
+ const _hoisted_1 = {
324
+ class: "pullrefresh-content",
325
+ ref: "pull"
326
+ };
327
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
328
+ return openBlock(), createElementBlock("view", {
329
+ class: "nut-pullrefresh",
330
+ ref: "scroller",
331
+ style: normalizeStyle(_ctx.getStyle),
332
+ onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.touchStart && _ctx.touchStart(...args)),
333
+ onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.touchMove && _ctx.touchMove(...args)),
334
+ onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.touchEnd && _ctx.touchEnd(...args))
335
+ }, [
336
+ createElementVNode("view", {
337
+ class: normalizeClass(["pullrefresh-top", _ctx.direction == "horizontal" ? "pullrefresh-top-h" : "pullrefresh-top-v"])
338
+ }, toDisplayString(_ctx.refreshTopTem), 3),
339
+ createElementVNode("view", _hoisted_1, [
340
+ renderSlot(_ctx.$slots, "default")
341
+ ], 512),
342
+ createElementVNode("view", {
343
+ class: normalizeClass(["pullrefresh-bottom", _ctx.direction == "horizontal" ? "pullrefresh-bottom-h" : "pullrefresh-bottom-v"]),
344
+ style: normalizeStyle(_ctx.getBottomStyle)
345
+ }, toDisplayString(_ctx.refreshBottomTem), 7)
346
+ ], 36);
347
+ }
348
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
349
+ export { index as default };