@nutui/nutui 3.1.22 → 3.1.23-beta.2

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 (186) hide show
  1. package/dist/nutui.es.js +20643 -4214
  2. package/dist/nutui.umd.js +20750 -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 +113 -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 +143 -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 +316 -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 +482 -129
  65. package/dist/packages/_es/Popover.js +957 -318
  66. package/dist/packages/_es/Popup.js +295 -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 +444 -121
  88. package/dist/packages/_es/SwiperItem.js +53 -22
  89. package/dist/packages/_es/Switch.js +124 -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/WaterMark.js +187 -0
  104. package/dist/packages/_es/common.js +128 -38
  105. package/dist/packages/_es/component.js +76 -35
  106. package/dist/packages/_es/index.js +6 -5
  107. package/dist/packages/_es/index2.js +30 -9
  108. package/dist/packages/_es/index3.js +8 -6
  109. package/dist/packages/_es/index4.js +64 -13
  110. package/dist/packages/_es/index5.js +781 -164
  111. package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
  112. package/dist/packages/_es/pxCheck.js +5 -3
  113. package/dist/packages/_es/raf.js +15 -8
  114. package/dist/packages/imagepreview/index.scss +5 -1
  115. package/dist/packages/locale/lang/baseLang.js +3 -3
  116. package/dist/packages/locale/lang/en-US.js +105 -5
  117. package/dist/packages/locale/lang/id-ID.js +105 -5
  118. package/dist/packages/locale/lang/index.js +38 -16
  119. package/dist/packages/locale/lang/zh-CN.js +105 -5
  120. package/dist/packages/locale/lang/zh-TW.js +105 -5
  121. package/dist/packages/picker/index.scss +14 -0
  122. package/dist/packages/watermark/index.scss +13 -0
  123. package/dist/smartips/attributes.json +68 -0
  124. package/dist/smartips/tags.json +23 -2
  125. package/dist/smartips/web-types.json +161 -1
  126. package/dist/style.css +1 -1
  127. package/dist/style.es.js +1 -1
  128. package/dist/styles/themes/default.scss +51 -50
  129. package/dist/styles/themes/jdb.scss +51 -50
  130. package/dist/styles/themes/jdt.scss +51 -50
  131. package/dist/styles/variables-jdb.scss +3 -1
  132. package/dist/styles/variables-jdt.scss +3 -1
  133. package/dist/styles/variables.scss +4 -1
  134. package/dist/types/__VUE/actionsheet/index.vue.d.ts +5 -5
  135. package/dist/types/__VUE/address/index.vue.d.ts +7 -7
  136. package/dist/types/__VUE/avatar/index.vue.d.ts +4 -4
  137. package/dist/types/__VUE/avatargroup/index.vue.d.ts +2 -2
  138. package/dist/types/__VUE/backtop/index.vue.d.ts +2 -2
  139. package/dist/types/__VUE/badge/index.vue.d.ts +2 -2
  140. package/dist/types/__VUE/button/index.vue.d.ts +8 -8
  141. package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
  142. package/dist/types/__VUE/cascader/index.vue.d.ts +4 -4
  143. package/dist/types/__VUE/categorypane/index.vue.d.ts +1 -1
  144. package/dist/types/__VUE/cell/index.vue.d.ts +6 -6
  145. package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
  146. package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
  147. package/dist/types/__VUE/collapseitem/index.vue.d.ts +2 -2
  148. package/dist/types/__VUE/comment/index.vue.d.ts +2 -2
  149. package/dist/types/__VUE/datepicker/index.vue.d.ts +4 -4
  150. package/dist/types/__VUE/dialog/index.vue.d.ts +4 -4
  151. package/dist/types/__VUE/fixednav/index.vue.d.ts +4 -4
  152. package/dist/types/__VUE/grid/index.vue.d.ts +4 -4
  153. package/dist/types/__VUE/image/index.vue.d.ts +4 -4
  154. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
  155. package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
  156. package/dist/types/__VUE/input/index.vue.d.ts +4 -4
  157. package/dist/types/__VUE/inputnumber/index.vue.d.ts +2 -2
  158. package/dist/types/__VUE/menu/index.vue.d.ts +2 -2
  159. package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
  160. package/dist/types/__VUE/noticebar/index.vue.d.ts +3 -3
  161. package/dist/types/__VUE/notify/index.vue.d.ts +2 -2
  162. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
  163. package/dist/types/__VUE/oldpicker/index.vue.d.ts +5 -5
  164. package/dist/types/__VUE/picker/Column.vue.d.ts +2 -1
  165. package/dist/types/__VUE/picker/index.vue.d.ts +7 -6
  166. package/dist/types/__VUE/popover/index.vue.d.ts +8 -8
  167. package/dist/types/__VUE/popup/index.vue.d.ts +8 -8
  168. package/dist/types/__VUE/radio/index.vue.d.ts +4 -4
  169. package/dist/types/__VUE/range/index.vue.d.ts +4 -4
  170. package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
  171. package/dist/types/__VUE/skeleton/index.vue.d.ts +4 -4
  172. package/dist/types/__VUE/sku/index.vue.d.ts +5 -5
  173. package/dist/types/__VUE/step/index.vue.d.ts +2 -2
  174. package/dist/types/__VUE/sticky/index.vue.d.ts +4 -4
  175. package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
  176. package/dist/types/__VUE/swiper/index.vue.d.ts +9 -2
  177. package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
  178. package/dist/types/__VUE/tabbaritem/index.vue.d.ts +2 -2
  179. package/dist/types/__VUE/tag/index.vue.d.ts +2 -2
  180. package/dist/types/__VUE/timeselect/index.vue.d.ts +2 -2
  181. package/dist/types/__VUE/toast/index.vue.d.ts +4 -4
  182. package/dist/types/__VUE/uploader/index.vue.d.ts +4 -4
  183. package/dist/types/__VUE/watermark/index.vue.d.ts +143 -0
  184. package/dist/types/index.d.ts +1 -1
  185. package/dist/types/nutui.d.ts +2 -1
  186. package/package.json +8 -3
@@ -1,139 +1,492 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.22 Fri Jun 24 2022 18:11:16 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.2 Thu Jul 07 2022 19:06:52 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { ref as e, reactive as t, computed as l, watch as n, onMounted as a, toRefs as o, openBlock as r, createElementBlock as s, createElementVNode as c, normalizeStyle as i, Fragment as u, renderList as m, normalizeClass as p, toDisplayString as d, createCommentVNode as h, onBeforeUnmount as v, resolveComponent as f, createVNode as g, withCtx as y, renderSlot as k } from "vue";
7
- import { c as S } from "./component.js";
8
- import T, { popupProps as w } from "./Popup.js";
9
- import { _ } from "./plugin-vue_export-helper.js";
6
+ import { ref, reactive, computed, watch, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, normalizeStyle, Fragment, renderList, normalizeClass, toDisplayString, createCommentVNode, onBeforeUnmount, resolveComponent, createVNode, withCtx, renderSlot } from "vue";
7
+ import { c as createComponent } from "./component.js";
8
+ import Popup, { popupProps } from "./Popup.js";
9
+ import { u as useTouch } from "./index4.js";
10
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
10
11
  import "../locale/lang";
11
12
  import "./OverLay.js";
12
13
  import "./Icon.js";
13
14
  import "./pxCheck.js";
14
- const { create: b } = S("picker-column"), x = b({ props: { value: [String, Number], columnsType: String, itemShow: { type: Boolean, default: false }, column: { type: Array, default: () => [] }, readonly: { type: Boolean, default: false } }, emits: ["click", "change"], setup(r2, { emit: s2 }) {
15
- const c2 = e(), i2 = t({ touchParams: { startY: 0, endY: 0, startTime: 0, endTime: 0, lastY: 0, lastTime: 0 }, currIndex: 1, transformY: 0, scrollDistance: 0, lineSpacing: 36, rotation: 20, timer: null }), u2 = e(null), m2 = e(null), p2 = e(null), d2 = e(0), h2 = e(0), v2 = e(0), f2 = l(() => ({ transition: `transform ${h2.value}ms cubic-bezier(0.19, 1, 0.22, 1)`, transform: `translate3d(0, ${i2.scrollDistance}px, 0)` })), g2 = l(() => ({ transition: `transform ${h2.value}ms cubic-bezier(0.19, 1, 0.22, 1)`, transform: `rotate3d(1, 0, 0, ${d2.value})` })), y2 = (e2 = 0, t2, l2 = 1e3, n2) => {
16
- h2.value = t2 === "end" ? l2 : 0, d2.value = n2, v2.value = e2, i2.scrollDistance = e2;
17
- }, k2 = (e2, t2, l2) => {
18
- let n2 = e2 + i2.transformY;
19
- if (t2 === "end") {
20
- n2 > 0 && (n2 = 0), n2 < -(r2.column.length - 1) * i2.lineSpacing && (n2 = -(r2.column.length - 1) * i2.lineSpacing);
21
- let e3 = Math.round(n2 / i2.lineSpacing) * i2.lineSpacing, a2 = (Math.abs(Math.round(e3 / i2.lineSpacing)) + 1) * i2.rotation + "deg";
22
- y2(e3, t2, l2, a2);
23
- let o2 = l2 ? l2 / 2 : 0;
24
- i2.timer = setTimeout(() => {
25
- S2();
26
- }, o2), i2.currIndex = Math.abs(Math.round(e3 / i2.lineSpacing)) + 1;
27
- } else {
28
- let e3 = "0deg";
29
- e3 = n2 < 0 ? (Math.abs(n2 / i2.lineSpacing) + 1) * i2.rotation + "deg" : (-n2 / i2.lineSpacing + 1) * i2.rotation + "deg", y2(n2, null, void 0, e3), i2.currIndex = Math.abs(Math.round(n2 / i2.lineSpacing)) + 1;
15
+ const { create: create$1 } = createComponent("picker-column");
16
+ const _sfc_main$1 = create$1({
17
+ props: {
18
+ value: [String, Number],
19
+ columnsType: String,
20
+ itemShow: {
21
+ type: Boolean,
22
+ default: false
23
+ },
24
+ column: {
25
+ type: Array,
26
+ default: () => []
27
+ },
28
+ readonly: {
29
+ type: Boolean,
30
+ default: false
30
31
  }
31
- }, S2 = () => {
32
- s2("change", r2.column[i2.currIndex - 1]);
33
- }, T2 = (e2) => {
34
- const { column: t2 } = r2;
35
- let l2 = t2.findIndex((e3) => e3.value == r2.value);
36
- i2.currIndex = l2 === -1 ? 1 : l2 + 1;
37
- let n2 = l2 === -1 ? 0 : l2 * i2.lineSpacing;
38
- e2 && S2(), k2(-n2);
39
- };
40
- return n(() => r2.column, (e2) => {
41
- i2.transformY = 0, T2(false);
42
- }, { deep: true }), n(() => r2.value, (e2) => {
43
- T2(true);
44
- }, { deep: true }), a(() => {
45
- T2(true);
46
- }), { ...o(i2), ...o(r2), wrapper: c2, setRollerStyle: (e2) => `transform: rotate3d(1, 0, 0, ${-i2.rotation * e2}deg) translate3d(0px, 0px, 104px)`, isHidden: (e2) => e2 >= i2.currIndex + 8 || e2 <= i2.currIndex - 8, roller: u2, list: m2, listItem: p2, onTouchStart: (e2) => {
47
- e2.preventDefault();
48
- let t2 = e2.changedTouches[0];
49
- i2.touchParams.startY = t2.pageY, i2.touchParams.startTime = e2.timeStamp || Date.now(), i2.transformY = i2.scrollDistance;
50
- }, onTouchMove: (e2) => {
51
- e2.preventDefault();
52
- let t2 = e2.changedTouches[0];
53
- i2.touchParams.lastY = t2.pageY, i2.touchParams.lastTime = e2.timeStamp || Date.now();
54
- let l2 = i2.touchParams.lastY - i2.touchParams.startY;
55
- k2(l2);
56
- }, onTouchEnd: (e2) => {
57
- e2.preventDefault();
58
- let t2 = e2.changedTouches[0];
59
- i2.touchParams.lastY = t2.pageY, i2.touchParams.lastTime = e2.timeStamp || Date.now();
60
- let l2 = i2.touchParams.lastY - i2.touchParams.startY, n2 = i2.touchParams.lastTime - i2.touchParams.startTime;
61
- n2 <= 300 ? (l2 *= 2, n2 += 1e3, k2(l2, "end", n2)) : k2(l2, "end");
62
- }, touchRollerStyle: g2, touchListStyle: f2, setMove: k2 };
63
- } }), Y = { class: "nut-picker-content" }, P = { key: 0, class: "nut-picker-placeholder" };
64
- var C = _(x, [["render", function(e2, t2, l2, n2, a2, o2) {
65
- return r(), s("view", { class: "nut-picker__list", onTouchstart: t2[0] || (t2[0] = (...t3) => e2.onTouchStart && e2.onTouchStart(...t3)), onTouchmove: t2[1] || (t2[1] = (...t3) => e2.onTouchMove && e2.onTouchMove(...t3)), onTouchend: t2[2] || (t2[2] = (...t3) => e2.onTouchEnd && e2.onTouchEnd(...t3)) }, [c("view", { class: "nut-picker-roller", ref: "roller", style: i(e2.touchRollerStyle) }, [(r(true), s(u, null, m(e2.column, (t3, l3) => (r(), s("view", { class: p(["nut-picker-roller-item", { "nut-picker-roller-item-hidden": e2.isHidden(l3 + 1) }]), style: i(e2.setRollerStyle(l3 + 1)), key: t3.value ? t3.value : l3 }, d(t3.text), 7))), 128))], 4), c("view", Y, [c("view", { class: "nut-picker-list-panel", ref: "list", style: i(e2.touchListStyle) }, [(r(true), s(u, null, m(e2.column, (e3, t3) => (r(), s("view", { class: p(["nut-picker-item", "nut-picker-item-ref", e3.className]), key: e3.value ? e3.value : t3 }, d(e3.text), 3))), 128)), e2.column && e2.column.length === 1 ? (r(), s("view", P)) : h("", true)], 4)])], 32);
66
- }]]);
67
- const { componentName: I, create: M, translate: O } = S("picker"), D = M({ components: { [C.name]: C, [T.name]: T }, props: { ...w, modelValue: { type: Array, default: () => [] }, title: { type: String, default: "" }, cancelText: { type: String, default: "" }, okText: { type: String, default: "" }, columns: { type: Array, default: () => [] }, readonly: { type: Boolean, default: false } }, emits: ["close", "change", "confirm", "update:visible", "update:modelValue"], setup(r2, { emit: s2 }) {
68
- const c2 = t({ show: false, formattedColumns: r2.columns });
69
- let i2 = e(r2.modelValue);
70
- const u2 = l(() => ({ [I]: true })), m2 = l(() => {
71
- let e2 = [];
72
- return d2.value.map((t2, l2) => {
73
- let n2 = [];
74
- n2 = t2.filter((e3) => e3.value == i2.value[l2]), e2.push(n2[0]);
75
- }), e2;
76
- }), p2 = l(() => {
77
- const e2 = c2.formattedColumns[0];
78
- if (e2) {
79
- if (Array.isArray(e2))
80
- return "multiple";
81
- if ("children" in e2)
82
- return "cascade";
32
+ },
33
+ emits: ["click", "change"],
34
+ setup(props, { emit }) {
35
+ const touch = useTouch();
36
+ const wrapper = ref();
37
+ const state = reactive({
38
+ touchParams: {
39
+ startY: 0,
40
+ endY: 0,
41
+ startTime: 0,
42
+ endTime: 0,
43
+ lastY: 0,
44
+ lastTime: 0
45
+ },
46
+ currIndex: 1,
47
+ transformY: 0,
48
+ scrollDistance: 0,
49
+ lineSpacing: 36,
50
+ rotation: 20,
51
+ timer: null
52
+ });
53
+ const roller = ref(null);
54
+ const list = ref(null);
55
+ const listItem = ref(null);
56
+ const moving = ref(false);
57
+ const touchDeg = ref(0);
58
+ const touchTime = ref(0);
59
+ const INERTIA_TIME = 300;
60
+ const INERTIA_DISTANCE = 15;
61
+ const touchRollerStyle = computed(() => {
62
+ return {
63
+ transition: `transform ${touchTime.value}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
64
+ transform: `rotate3d(1, 0, 0, ${touchDeg.value})`
65
+ };
66
+ });
67
+ const touchListStyle = computed(() => {
68
+ return {
69
+ transition: `transform ${touchTime.value}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
70
+ transform: `translate3d(0, ${state.scrollDistance}px, 0)`
71
+ };
72
+ });
73
+ const setRollerStyle = (index) => {
74
+ return `transform: rotate3d(1, 0, 0, ${-state.rotation * index}deg) translate3d(0px, 0px, 104px)`;
75
+ };
76
+ const onTouchStart = (event) => {
77
+ touch.start(event);
78
+ if (moving.value) {
79
+ const { transform } = window.getComputedStyle(list.value);
80
+ state.scrollDistance = +transform.slice(7, transform.length - 1).split(", ")[5];
81
+ }
82
+ state.touchParams.startY = touch.deltaY.value;
83
+ state.touchParams.startTime = Date.now();
84
+ state.transformY = state.scrollDistance;
85
+ };
86
+ const onTouchMove = (event) => {
87
+ touch.move(event);
88
+ if (touch.isVertical) {
89
+ moving.value = true;
90
+ preventDefault(event, true);
91
+ }
92
+ state.touchParams.lastY = touch.deltaY.value;
93
+ const now = Date.now();
94
+ let move = state.touchParams.lastY - state.touchParams.startY;
95
+ setMove(move);
96
+ if (now - state.touchParams.startTime > INERTIA_TIME) {
97
+ state.touchParams.startTime = now;
98
+ state.touchParams.startY = state.touchParams.lastY;
99
+ }
100
+ };
101
+ const onTouchEnd = (event) => {
102
+ state.touchParams.lastY = touch.deltaY.value;
103
+ state.touchParams.lastTime = Date.now();
104
+ let move = state.touchParams.lastY - state.touchParams.startY;
105
+ let moveTime = state.touchParams.lastTime - state.touchParams.startTime;
106
+ if (moveTime <= INERTIA_TIME && Math.abs(move) > INERTIA_DISTANCE) {
107
+ const distance = momentum(move, moveTime);
108
+ setMove(distance, "end", moveTime + 1e3);
109
+ return;
110
+ } else {
111
+ setMove(move, "end");
112
+ }
113
+ setTimeout(() => {
114
+ touch.reset();
115
+ moving.value = false;
116
+ }, 0);
117
+ };
118
+ const momentum = (distance, duration) => {
119
+ const speed = Math.abs(distance / duration);
120
+ distance = speed / 3e-3 * (distance < 0 ? -1 : 1);
121
+ return distance;
122
+ };
123
+ const isHidden = (index) => {
124
+ if (index >= state.currIndex + 8 || index <= state.currIndex - 8) {
125
+ return true;
126
+ } else {
127
+ return false;
128
+ }
129
+ };
130
+ const setTransform = (translateY = 0, type, time = 1e3, deg) => {
131
+ if (type === "end") {
132
+ touchTime.value = time;
133
+ } else {
134
+ touchTime.value = 0;
135
+ }
136
+ touchDeg.value = deg;
137
+ state.scrollDistance = translateY;
138
+ };
139
+ const setMove = (move, type, time) => {
140
+ let updateMove = move + state.transformY;
141
+ if (type === "end") {
142
+ if (updateMove > 0) {
143
+ updateMove = 0;
144
+ }
145
+ if (updateMove < -(props.column.length - 1) * state.lineSpacing) {
146
+ updateMove = -(props.column.length - 1) * state.lineSpacing;
147
+ }
148
+ let endMove = Math.round(updateMove / state.lineSpacing) * state.lineSpacing;
149
+ let deg = `${(Math.abs(Math.round(endMove / state.lineSpacing)) + 1) * state.rotation}deg`;
150
+ setTransform(endMove, type, time, deg);
151
+ state.currIndex = Math.abs(Math.round(endMove / state.lineSpacing)) + 1;
152
+ } else {
153
+ let deg = "0deg";
154
+ let currentDeg = (-updateMove / state.lineSpacing + 1) * state.rotation;
155
+ const maxDeg = (props.column.length + 1) * state.rotation;
156
+ const minDeg = 0;
157
+ deg = Math.min(Math.max(currentDeg, minDeg), maxDeg) + "deg";
158
+ setTransform(updateMove, null, void 0, deg);
159
+ state.currIndex = Math.abs(Math.round(updateMove / state.lineSpacing)) + 1;
160
+ }
161
+ };
162
+ const setChooseValue = () => {
163
+ emit("change", props.column[state.currIndex - 1]);
164
+ };
165
+ const modifyStatus = (type) => {
166
+ const { column: column2 } = props;
167
+ let index = column2.findIndex((columnItem) => columnItem.value == props.value);
168
+ state.currIndex = index === -1 ? 1 : index + 1;
169
+ let move = index === -1 ? 0 : index * state.lineSpacing;
170
+ type && setChooseValue();
171
+ setMove(-move);
172
+ };
173
+ const preventDefault = (event, isStopPropagation) => {
174
+ if (typeof event.cancelable !== "boolean" || event.cancelable) {
175
+ event.preventDefault();
176
+ }
177
+ if (isStopPropagation) {
178
+ event.stopPropagation();
179
+ }
180
+ };
181
+ const stopMomentum = () => {
182
+ moving.value = false;
183
+ setChooseValue();
184
+ };
185
+ watch(() => props.column, (val) => {
186
+ console.log("props.column\u53D8\u5316", props.column);
187
+ state.transformY = 0;
188
+ modifyStatus(false);
189
+ }, {
190
+ deep: true
191
+ });
192
+ onMounted(() => {
193
+ modifyStatus(true);
194
+ });
195
+ return {
196
+ ...toRefs(state),
197
+ ...toRefs(props),
198
+ wrapper,
199
+ setRollerStyle,
200
+ isHidden,
201
+ roller,
202
+ list,
203
+ listItem,
204
+ onTouchStart,
205
+ onTouchMove,
206
+ onTouchEnd,
207
+ touchRollerStyle,
208
+ touchListStyle,
209
+ setMove,
210
+ stopMomentum
211
+ };
212
+ }
213
+ });
214
+ const _hoisted_1$1 = /* @__PURE__ */ createElementVNode("view", { class: "nut-picker-roller-mask" }, null, -1);
215
+ const _hoisted_2$1 = { class: "nut-picker-content" };
216
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
217
+ return openBlock(), createElementBlock("view", {
218
+ class: "nut-picker__list",
219
+ onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
220
+ onTouchmove: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
221
+ onTouchend: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
222
+ }, [
223
+ createElementVNode("view", {
224
+ class: "nut-picker-roller",
225
+ ref: "roller",
226
+ style: normalizeStyle(_ctx.touchRollerStyle),
227
+ onTransitionend: _cache[0] || (_cache[0] = (...args) => _ctx.stopMomentum && _ctx.stopMomentum(...args))
228
+ }, [
229
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.column, (item, index) => {
230
+ return openBlock(), createElementBlock(Fragment, {
231
+ key: item.value ? item.value : index
232
+ }, [
233
+ item && item.text ? (openBlock(), createElementBlock("view", {
234
+ key: 0,
235
+ class: normalizeClass(["nut-picker-roller-item", { "nut-picker-roller-item-hidden": _ctx.isHidden(index + 1) }]),
236
+ style: normalizeStyle(_ctx.setRollerStyle(index + 1))
237
+ }, toDisplayString(item.text), 7)) : createCommentVNode("", true)
238
+ ], 64);
239
+ }), 128))
240
+ ], 36),
241
+ _hoisted_1$1,
242
+ createElementVNode("view", _hoisted_2$1, [
243
+ createElementVNode("view", {
244
+ class: "nut-picker-list-panel",
245
+ ref: "list",
246
+ style: normalizeStyle(_ctx.touchListStyle)
247
+ }, null, 4)
248
+ ])
249
+ ], 32);
250
+ }
251
+ var column = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
252
+ const { componentName, create, translate } = createComponent("picker");
253
+ const _sfc_main = create({
254
+ components: {
255
+ [column.name]: column,
256
+ [Popup.name]: Popup
257
+ },
258
+ props: {
259
+ ...popupProps,
260
+ modelValue: {
261
+ type: Array,
262
+ default: () => []
263
+ },
264
+ title: {
265
+ type: String,
266
+ default: ""
267
+ },
268
+ cancelText: {
269
+ type: String,
270
+ default: ""
271
+ },
272
+ okText: {
273
+ type: String,
274
+ default: ""
275
+ },
276
+ columns: {
277
+ type: Array,
278
+ default: () => {
279
+ return [];
280
+ }
281
+ },
282
+ readonly: {
283
+ type: Boolean,
284
+ default: false
83
285
  }
84
- return "single";
85
- }), d2 = l(() => {
86
- switch (p2.value) {
87
- case "multiple":
88
- return c2.formattedColumns;
89
- case "cascade":
90
- return h2(c2.formattedColumns, i2.value);
91
- default:
92
- return [c2.formattedColumns];
93
- }
94
- }), h2 = (e2, t2) => {
95
- const l2 = [];
96
- let n2 = { text: "", value: "", children: e2 }, a2 = 0;
97
- for (; n2 && n2.children; ) {
98
- const e3 = n2.children, o2 = t2[a2];
99
- let r3 = e3.findIndex((e4) => e4.value == o2);
100
- r3 == -1 && (r3 = 0), n2 = n2.children[r3], a2++, l2.push(e3);
101
- }
102
- return l2;
103
- };
104
- return a(() => {
105
- r2.visible && (c2.show = r2.visible);
106
- }), v(() => {
107
- r2.visible && (c2.show = false);
108
- }), n(() => r2.modelValue, (e2) => {
109
- JSON.stringify(e2) === JSON.stringify(i2.value) || (i2.value = e2);
110
- }, { deep: true }), n(i2, (e2) => {
111
- JSON.stringify(e2) === JSON.stringify(r2.modelValue) || s2("update:modelValue", e2);
112
- }, { immediate: true }), n(() => r2.visible, (e2) => {
113
- c2.show = e2;
114
- }), n(() => r2.columns, (e2) => {
115
- e2.length && (c2.formattedColumns = e2);
116
- }), { classes: u2, ...o(c2), column: C, columnsType: p2, columnsList: d2, close: () => {
117
- s2("close"), s2("update:visible", false);
118
- }, changeHandler: (e2, t2) => {
119
- if (t2 && Object.keys(t2).length) {
120
- if (p2.value === "cascade") {
121
- i2.value[e2] = t2.value ? t2.value : "";
122
- let l2 = e2, n2 = t2;
123
- for (; n2 && n2.children; )
124
- i2.value[l2 + 1] = n2.children[0].value, l2++, n2 = n2.children[0];
125
- } else
126
- i2.value[e2] = t2.hasOwnProperty("value") ? t2.value : "";
127
- s2("change", { columnIndex: e2, selectedValue: i2.value, selectedOptions: m2.value });
128
- }
129
- }, confirmHandler: () => {
130
- s2("confirm", { selectedValue: i2.value, selectedOptions: m2.value }), s2("update:visible", false);
131
- }, defaultValues: i2, translate: O };
132
- } }), V = { class: "nut-picker__bar" }, j = { class: "nut-picker__title" }, N = { class: "nut-picker__column" }, $ = c("view", { class: "nut-picker__hairline" }, null, -1);
133
- var H = _(D, [["render", function(e2, t2, l2, n2, a2, o2) {
134
- const i2 = f("nut-picker-column"), h2 = f("nut-popup");
135
- return r(), s("view", { class: p(e2.classes) }, [g(h2, { position: "bottom", visible: e2.show, "onUpdate:visible": t2[2] || (t2[2] = (t3) => e2.show = t3), teleport: e2.teleport, "lock-scroll": e2.lockScroll, "close-on-click-overlay": e2.closeOnClickOverlay, onClose: e2.close, round: true, isWrapTeleport: e2.isWrapTeleport }, { default: y(() => [c("view", V, [c("view", { class: "nut-picker__cancel nut-picker__left nut-picker__button", onClick: t2[0] || (t2[0] = (...t3) => e2.close && e2.close(...t3)) }, d(e2.cancelText || e2.translate("cancel")), 1), c("view", j, d(e2.title), 1), c("view", { class: "nut-picker__confirm nut-picker__right nut-picker__button", onClick: t2[1] || (t2[1] = (t3) => e2.confirmHandler()) }, d(e2.okText || e2.translate("confirm")), 1)]), k(e2.$slots, "top"), c("view", N, [$, (r(true), s(u, null, m(e2.columnsList, (t3, l3) => (r(), s("view", { class: "nut-picker__columnitem", key: l3 }, [g(i2, { itemShow: e2.show, column: t3, readonly: e2.readonly, columnsType: e2.columnsType, value: e2.defaultValues[l3], onChange: (t4) => {
136
- e2.changeHandler(l3, t4);
137
- } }, null, 8, ["itemShow", "column", "readonly", "columnsType", "value", "onChange"])]))), 128))]), k(e2.$slots, "default")]), _: 3 }, 8, ["visible", "teleport", "lock-scroll", "close-on-click-overlay", "onClose", "isWrapTeleport"])], 2);
138
- }]]);
139
- export { H as default };
286
+ },
287
+ emits: ["close", "change", "confirm", "update:visible", "update:modelValue"],
288
+ setup(props, { emit }) {
289
+ const state = reactive({
290
+ show: false,
291
+ formattedColumns: props.columns
292
+ });
293
+ let defaultValues = ref(props.modelValue);
294
+ ref();
295
+ const classes = computed(() => {
296
+ const prefixCls = componentName;
297
+ return {
298
+ [prefixCls]: true
299
+ };
300
+ });
301
+ const selectedOptions = computed(() => {
302
+ let optins = [];
303
+ columnsList.value.map((column2, index) => {
304
+ let currOptions = [];
305
+ currOptions = column2.filter((item) => item.value == defaultValues.value[index]);
306
+ optins.push(currOptions[0]);
307
+ });
308
+ return optins;
309
+ });
310
+ const columnsType = computed(() => {
311
+ const firstColumn = state.formattedColumns[0];
312
+ if (firstColumn) {
313
+ if (Array.isArray(firstColumn)) {
314
+ return "multiple";
315
+ }
316
+ if ("children" in firstColumn) {
317
+ return "cascade";
318
+ }
319
+ }
320
+ return "single";
321
+ });
322
+ const columnsList = computed(() => {
323
+ switch (columnsType.value) {
324
+ case "multiple":
325
+ return state.formattedColumns;
326
+ case "cascade":
327
+ return formatCascade(state.formattedColumns, defaultValues.value);
328
+ default:
329
+ return [state.formattedColumns];
330
+ }
331
+ });
332
+ const formatCascade = (columns, defaultValues2) => {
333
+ const formatted = [];
334
+ let cursor = {
335
+ text: "",
336
+ value: "",
337
+ children: columns
338
+ };
339
+ let columnIndex = 0;
340
+ while (cursor && cursor.children) {
341
+ const options = cursor.children;
342
+ const value = defaultValues2[columnIndex];
343
+ let index = options.findIndex((columnItem) => columnItem.value == value);
344
+ if (index == -1)
345
+ index = 0;
346
+ cursor = cursor.children[index];
347
+ columnIndex++;
348
+ formatted.push(options);
349
+ }
350
+ return formatted;
351
+ };
352
+ const close = () => {
353
+ emit("close", {
354
+ selectedValue: defaultValues.value,
355
+ selectedOptions: selectedOptions.value
356
+ });
357
+ emit("update:visible", false);
358
+ };
359
+ const changeHandler = (columnIndex, option) => {
360
+ if (option && Object.keys(option).length) {
361
+ if (columnsType.value === "cascade") {
362
+ defaultValues.value[columnIndex] = option.value ? option.value : "";
363
+ let index = columnIndex;
364
+ let cursor = option;
365
+ while (cursor && cursor.children) {
366
+ defaultValues.value[index + 1] = cursor.children[0].value;
367
+ index++;
368
+ cursor = cursor.children[0];
369
+ }
370
+ } else {
371
+ defaultValues.value[columnIndex] = option.hasOwnProperty("value") ? option.value : "";
372
+ }
373
+ emit("change", {
374
+ columnIndex,
375
+ selectedValue: defaultValues.value,
376
+ selectedOptions: selectedOptions.value
377
+ });
378
+ }
379
+ };
380
+ const confirmHandler = () => {
381
+ emit("confirm", {
382
+ selectedValue: defaultValues.value,
383
+ selectedOptions: selectedOptions.value
384
+ });
385
+ emit("update:visible", false);
386
+ };
387
+ onMounted(() => {
388
+ if (props.visible)
389
+ state.show = props.visible;
390
+ });
391
+ onBeforeUnmount(() => {
392
+ if (props.visible)
393
+ state.show = false;
394
+ });
395
+ watch(() => props.modelValue, (newValues) => {
396
+ const isSameValue = JSON.stringify(newValues) === JSON.stringify(defaultValues.value);
397
+ if (!isSameValue) {
398
+ defaultValues.value = newValues;
399
+ }
400
+ }, { deep: true });
401
+ watch(defaultValues, (newValues) => {
402
+ const isSameValue = JSON.stringify(newValues) === JSON.stringify(props.modelValue);
403
+ if (!isSameValue) {
404
+ emit("update:modelValue", newValues);
405
+ }
406
+ }, { immediate: true });
407
+ watch(() => props.visible, (val) => {
408
+ state.show = val;
409
+ });
410
+ watch(() => props.columns, (val) => {
411
+ if (val.length)
412
+ state.formattedColumns = val;
413
+ });
414
+ return {
415
+ classes,
416
+ ...toRefs(state),
417
+ column,
418
+ columnsType,
419
+ columnsList,
420
+ close,
421
+ changeHandler,
422
+ confirmHandler,
423
+ defaultValues,
424
+ translate
425
+ };
426
+ }
427
+ });
428
+ const _hoisted_1 = { class: "nut-picker__bar" };
429
+ const _hoisted_2 = { class: "nut-picker__title" };
430
+ const _hoisted_3 = {
431
+ class: "nut-picker__column",
432
+ ref: "wrapHeight"
433
+ };
434
+ const _hoisted_4 = /* @__PURE__ */ createElementVNode("view", { class: "nut-picker__hairline" }, null, -1);
435
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
436
+ const _component_nut_picker_column = resolveComponent("nut-picker-column");
437
+ const _component_nut_popup = resolveComponent("nut-popup");
438
+ return openBlock(), createElementBlock("view", {
439
+ class: normalizeClass(_ctx.classes)
440
+ }, [
441
+ createVNode(_component_nut_popup, {
442
+ position: "bottom",
443
+ visible: _ctx.show,
444
+ "onUpdate:visible": _cache[2] || (_cache[2] = ($event) => _ctx.show = $event),
445
+ teleport: _ctx.teleport,
446
+ "lock-scroll": _ctx.lockScroll,
447
+ "close-on-click-overlay": _ctx.closeOnClickOverlay,
448
+ onClose: _ctx.close,
449
+ round: true,
450
+ isWrapTeleport: _ctx.isWrapTeleport
451
+ }, {
452
+ default: withCtx(() => [
453
+ createElementVNode("view", _hoisted_1, [
454
+ createElementVNode("view", {
455
+ class: "nut-picker__cancel nut-picker__left nut-picker__button",
456
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.close && _ctx.close(...args))
457
+ }, toDisplayString(_ctx.cancelText || _ctx.translate("cancel")), 1),
458
+ createElementVNode("view", _hoisted_2, toDisplayString(_ctx.title), 1),
459
+ createElementVNode("view", {
460
+ class: "nut-picker__confirm nut-picker__right nut-picker__button",
461
+ onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirmHandler())
462
+ }, toDisplayString(_ctx.okText || _ctx.translate("confirm")), 1)
463
+ ]),
464
+ renderSlot(_ctx.$slots, "top"),
465
+ createElementVNode("view", _hoisted_3, [
466
+ _hoisted_4,
467
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columnsList, (column2, columnIndex) => {
468
+ return openBlock(), createElementBlock("view", {
469
+ class: "nut-picker__columnitem",
470
+ key: columnIndex
471
+ }, [
472
+ createVNode(_component_nut_picker_column, {
473
+ itemShow: _ctx.show,
474
+ column: column2,
475
+ readonly: _ctx.readonly,
476
+ columnsType: _ctx.columnsType,
477
+ value: _ctx.defaultValues[columnIndex],
478
+ onChange: (option) => {
479
+ _ctx.changeHandler(columnIndex, option);
480
+ }
481
+ }, null, 8, ["itemShow", "column", "readonly", "columnsType", "value", "onChange"])
482
+ ]);
483
+ }), 128))
484
+ ], 512),
485
+ renderSlot(_ctx.$slots, "default")
486
+ ]),
487
+ _: 3
488
+ }, 8, ["visible", "teleport", "lock-scroll", "close-on-click-overlay", "onClose", "isWrapTeleport"])
489
+ ], 2);
490
+ }
491
+ var Picker = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
492
+ export { Picker as default };