@nutui/nutui 3.1.22-beta.5 → 3.1.23-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.
Files changed (168) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +3 -4
  3. package/dist/nutui.es.js +20412 -4214
  4. package/dist/nutui.umd.js +20518 -4216
  5. package/dist/packages/_es/ActionSheet.js +149 -17
  6. package/dist/packages/_es/Address.js +535 -110
  7. package/dist/packages/_es/AddressList.js +615 -113
  8. package/dist/packages/_es/Animate.js +59 -17
  9. package/dist/packages/_es/Audio.js +257 -53
  10. package/dist/packages/_es/AudioOperate.js +100 -13
  11. package/dist/packages/_es/Avatar.js +162 -38
  12. package/dist/packages/_es/AvatarGroup.js +73 -14
  13. package/dist/packages/_es/BackTop.js +156 -43
  14. package/dist/packages/_es/Badge.js +86 -14
  15. package/dist/packages/_es/Barrage.js +120 -41
  16. package/dist/packages/_es/Button.js +128 -23
  17. package/dist/packages/_es/Calendar.js +246 -30
  18. package/dist/packages/_es/CalendarItem.js +1 -1
  19. package/dist/packages/_es/Card.js +107 -10
  20. package/dist/packages/_es/Cascader.js +496 -147
  21. package/dist/packages/_es/Category.js +58 -15
  22. package/dist/packages/_es/CategoryPane.js +111 -11
  23. package/dist/packages/_es/Cell.js +108 -21
  24. package/dist/packages/_es/CellGroup.js +44 -9
  25. package/dist/packages/_es/Checkbox.js +134 -29
  26. package/dist/packages/_es/CheckboxGroup.js +79 -29
  27. package/dist/packages/_es/CircleProgress.js +150 -28
  28. package/dist/packages/_es/Col.js +56 -14
  29. package/dist/packages/_es/Collapse.js +109 -32
  30. package/dist/packages/_es/CollapseItem.js +253 -59
  31. package/dist/packages/_es/Comment.js +434 -64
  32. package/dist/packages/_es/ConfigProvider.js +20 -8
  33. package/dist/packages/_es/CountDown.js +238 -56
  34. package/dist/packages/_es/CountUp.js +539 -140
  35. package/dist/packages/_es/DatePicker.js +315 -98
  36. package/dist/packages/_es/Dialog.js +289 -60
  37. package/dist/packages/_es/Divider.js +65 -13
  38. package/dist/packages/_es/Drag.js +197 -56
  39. package/dist/packages/_es/Ecard.js +159 -24
  40. package/dist/packages/_es/Elevator.js +255 -58
  41. package/dist/packages/_es/Ellipsis.js +200 -58
  42. package/dist/packages/_es/Empty.js +71 -12
  43. package/dist/packages/_es/FixedNav.js +122 -15
  44. package/dist/packages/_es/Form.js +151 -64
  45. package/dist/packages/_es/FormItem.js +114 -15
  46. package/dist/packages/_es/Grid.js +6 -5
  47. package/dist/packages/_es/GridItem.js +144 -33
  48. package/dist/packages/_es/Icon.js +40 -15
  49. package/dist/packages/_es/Image.js +137 -26
  50. package/dist/packages/_es/ImagePreview.js +547 -76
  51. package/dist/packages/_es/Indicator.js +62 -15
  52. package/dist/packages/_es/InfiniteLoading.js +249 -57
  53. package/dist/packages/_es/Input.js +433 -51
  54. package/dist/packages/_es/InputNumber.js +160 -41
  55. package/dist/packages/_es/Layout.js +5 -4
  56. package/dist/packages/_es/List.js +106 -18
  57. package/dist/packages/_es/Menu.js +168 -44
  58. package/dist/packages/_es/MenuItem.js +173 -37
  59. package/dist/packages/_es/Navbar.js +192 -30
  60. package/dist/packages/_es/NoticeBar.js +380 -74
  61. package/dist/packages/_es/Notify.js +227 -72
  62. package/dist/packages/_es/NumberKeyboard.js +272 -41
  63. package/dist/packages/_es/OldPicker.js +457 -130
  64. package/dist/packages/_es/OverLay.js +98 -24
  65. package/dist/packages/_es/Pagination.js +157 -39
  66. package/dist/packages/_es/Picker.js +454 -129
  67. package/dist/packages/_es/Popover.js +957 -318
  68. package/dist/packages/_es/Popup.js +299 -55
  69. package/dist/packages/_es/Price.js +118 -16
  70. package/dist/packages/_es/Progress.js +146 -14
  71. package/dist/packages/_es/PullRefresh.js +339 -84
  72. package/dist/packages/_es/Radio.js +90 -22
  73. package/dist/packages/_es/RadioGroup.js +37 -8
  74. package/dist/packages/_es/Range.js +408 -83
  75. package/dist/packages/_es/Rate.js +192 -36
  76. package/dist/packages/_es/Row.js +64 -22
  77. package/dist/packages/_es/SearchBar.js +238 -37
  78. package/dist/packages/_es/ShortPassword.js +225 -35
  79. package/dist/packages/_es/SideNavBar.js +81 -24
  80. package/dist/packages/_es/SideNavBarItem.js +46 -11
  81. package/dist/packages/_es/Signature.js +160 -41
  82. package/dist/packages/_es/Skeleton.js +136 -20
  83. package/dist/packages/_es/Sku.js +491 -84
  84. package/dist/packages/_es/Step.js +115 -20
  85. package/dist/packages/_es/Steps.js +53 -18
  86. package/dist/packages/_es/Sticky.js +138 -53
  87. package/dist/packages/_es/SubSideNavBar.js +82 -17
  88. package/dist/packages/_es/Swipe.js +178 -41
  89. package/dist/packages/_es/Swiper.js +433 -121
  90. package/dist/packages/_es/SwiperItem.js +53 -22
  91. package/dist/packages/_es/Switch.js +116 -21
  92. package/dist/packages/_es/TabPane.js +39 -12
  93. package/dist/packages/_es/Tabbar.js +72 -17
  94. package/dist/packages/_es/TabbarItem.js +151 -29
  95. package/dist/packages/_es/Table.js +178 -18
  96. package/dist/packages/_es/Tabs.js +202 -43
  97. package/dist/packages/_es/Tag.js +97 -20
  98. package/dist/packages/_es/TextArea.js +160 -42
  99. package/dist/packages/_es/TimeDetail.js +79 -18
  100. package/dist/packages/_es/TimePannel.js +48 -14
  101. package/dist/packages/_es/TimeSelect.js +112 -15
  102. package/dist/packages/_es/Toast.js +310 -71
  103. package/dist/packages/_es/Uploader.js +455 -104
  104. package/dist/packages/_es/Video.js +332 -74
  105. package/dist/packages/_es/common.js +128 -38
  106. package/dist/packages/_es/component.js +76 -35
  107. package/dist/packages/_es/index.js +6 -5
  108. package/dist/packages/_es/index2.js +30 -9
  109. package/dist/packages/_es/index3.js +8 -6
  110. package/dist/packages/_es/index4.js +64 -13
  111. package/dist/packages/_es/index5.js +780 -164
  112. package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
  113. package/dist/packages/_es/pxCheck.js +5 -3
  114. package/dist/packages/_es/raf.js +15 -8
  115. package/dist/packages/imagepreview/index.scss +6 -1
  116. package/dist/packages/locale/lang/baseLang.js +3 -3
  117. package/dist/packages/locale/lang/en-US.js +105 -5
  118. package/dist/packages/locale/lang/id-ID.js +105 -5
  119. package/dist/packages/locale/lang/index.js +38 -16
  120. package/dist/packages/locale/lang/zh-CN.js +105 -5
  121. package/dist/packages/locale/lang/zh-TW.js +105 -5
  122. package/dist/packages/picker/index.scss +13 -0
  123. package/dist/smartips/attributes.json +8 -0
  124. package/dist/smartips/tags.json +3 -1
  125. package/dist/smartips/web-types.json +19 -1
  126. package/dist/style.css +1 -1
  127. package/dist/style.es.js +1 -1
  128. package/dist/styles/themes/default.scss +49 -49
  129. package/dist/styles/themes/jdb.scss +49 -49
  130. package/dist/styles/themes/jdt.scss +49 -49
  131. package/dist/styles/variables-jdb.scss +4 -1
  132. package/dist/styles/variables-jdt.scss +4 -1
  133. package/dist/styles/variables.scss +1 -1
  134. package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
  135. package/dist/types/__VUE/address/index.vue.d.ts +4 -4
  136. package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
  137. package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
  138. package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
  139. package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
  140. package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
  141. package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
  142. package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
  143. package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
  144. package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
  145. package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
  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/infiniteloading/index.vue.d.ts +6 -6
  149. package/dist/types/__VUE/input/index.vue.d.ts +2 -2
  150. package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
  151. package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
  152. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
  153. package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
  154. package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
  155. package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
  156. package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
  157. package/dist/types/__VUE/range/index.vue.d.ts +1 -1
  158. package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
  159. package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
  160. package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
  161. package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
  162. package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
  163. package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
  164. package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
  165. package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
  166. package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
  167. package/dist/types/index.d.ts +1 -1
  168. package/package.json +1 -2
@@ -1,139 +1,464 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.22-beta.5 Fri Jun 24 2022 15:10:09 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 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 { _ as _export_sfc } from "./plugin-vue_export-helper.js";
10
10
  import "../locale/lang";
11
11
  import "./OverLay.js";
12
12
  import "./Icon.js";
13
13
  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;
14
+ const { create: create$1 } = createComponent("picker-column");
15
+ const _sfc_main$1 = create$1({
16
+ props: {
17
+ value: [String, Number],
18
+ columnsType: String,
19
+ itemShow: {
20
+ type: Boolean,
21
+ default: false
22
+ },
23
+ column: {
24
+ type: Array,
25
+ default: () => []
26
+ },
27
+ readonly: {
28
+ type: Boolean,
29
+ default: false
30
30
  }
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";
31
+ },
32
+ emits: ["click", "change"],
33
+ setup(props, { emit }) {
34
+ const wrapper = ref();
35
+ const state = reactive({
36
+ touchParams: {
37
+ startY: 0,
38
+ endY: 0,
39
+ startTime: 0,
40
+ endTime: 0,
41
+ lastY: 0,
42
+ lastTime: 0
43
+ },
44
+ currIndex: 1,
45
+ transformY: 0,
46
+ scrollDistance: 0,
47
+ lineSpacing: 36,
48
+ rotation: 20,
49
+ timer: null
50
+ });
51
+ const roller = ref(null);
52
+ const list = ref(null);
53
+ const listItem = ref(null);
54
+ const touchDeg = ref(0);
55
+ const touchTime = ref(0);
56
+ const touchTranslateY = ref(0);
57
+ const touchListStyle = computed(() => {
58
+ return {
59
+ transition: `transform ${touchTime.value}ms cubic-bezier(0.19, 1, 0.22, 1)`,
60
+ transform: `translate3d(0, ${state.scrollDistance}px, 0)`
61
+ };
62
+ });
63
+ const touchRollerStyle = computed(() => {
64
+ return {
65
+ transition: `transform ${touchTime.value}ms cubic-bezier(0.19, 1, 0.22, 1)`,
66
+ transform: `rotate3d(1, 0, 0, ${touchDeg.value})`
67
+ };
68
+ });
69
+ const onTouchStart = (event) => {
70
+ event.preventDefault();
71
+ let changedTouches = event.changedTouches[0];
72
+ state.touchParams.startY = changedTouches.pageY;
73
+ state.touchParams.startTime = event.timeStamp || Date.now();
74
+ state.transformY = state.scrollDistance;
75
+ };
76
+ const onTouchMove = (event) => {
77
+ event.preventDefault();
78
+ let changedTouches = event.changedTouches[0];
79
+ state.touchParams.lastY = changedTouches.pageY;
80
+ state.touchParams.lastTime = event.timeStamp || Date.now();
81
+ let move = state.touchParams.lastY - state.touchParams.startY;
82
+ setMove(move);
83
+ };
84
+ const onTouchEnd = (event) => {
85
+ event.preventDefault();
86
+ let changedTouches = event.changedTouches[0];
87
+ state.touchParams.lastY = changedTouches.pageY;
88
+ state.touchParams.lastTime = event.timeStamp || Date.now();
89
+ let move = state.touchParams.lastY - state.touchParams.startY;
90
+ let moveTime = state.touchParams.lastTime - state.touchParams.startTime;
91
+ console.log("touchEnd", move, moveTime);
92
+ if (moveTime <= 300) {
93
+ move = move * 2;
94
+ moveTime = moveTime + 1e3;
95
+ setMove(move, "end", moveTime);
96
+ } else {
97
+ setMove(move, "end");
98
+ }
99
+ };
100
+ const setRollerStyle = (index) => {
101
+ return `transform: rotate3d(1, 0, 0, ${-state.rotation * index}deg) translate3d(0px, 0px, 104px)`;
102
+ };
103
+ const isHidden = (index) => {
104
+ if (index >= state.currIndex + 8 || index <= state.currIndex - 8) {
105
+ return true;
106
+ } else {
107
+ return false;
108
+ }
109
+ };
110
+ const setTransform = (translateY = 0, type, time = 1e3, deg) => {
111
+ if (type === "end") {
112
+ touchTime.value = time;
113
+ } else {
114
+ touchTime.value = 0;
115
+ }
116
+ touchDeg.value = deg;
117
+ touchTranslateY.value = translateY;
118
+ state.scrollDistance = translateY;
119
+ };
120
+ const setMove = (move, type, time) => {
121
+ console.log("setMove");
122
+ let updateMove = move + state.transformY;
123
+ if (type === "end") {
124
+ if (updateMove > 0) {
125
+ updateMove = 0;
126
+ }
127
+ if (updateMove < -(props.column.length - 1) * state.lineSpacing) {
128
+ updateMove = -(props.column.length - 1) * state.lineSpacing;
129
+ }
130
+ let endMove = Math.round(updateMove / state.lineSpacing) * state.lineSpacing;
131
+ let deg = `${(Math.abs(Math.round(endMove / state.lineSpacing)) + 1) * state.rotation}deg`;
132
+ setTransform(endMove, type, time, deg);
133
+ let t = time ? time / 2 : 0;
134
+ state.timer = setTimeout(() => {
135
+ setChooseValue();
136
+ }, t);
137
+ state.currIndex = Math.abs(Math.round(endMove / state.lineSpacing)) + 1;
138
+ } else {
139
+ let deg = "0deg";
140
+ let degNum = 0;
141
+ if (updateMove < 0) {
142
+ degNum = (Math.abs(updateMove / state.lineSpacing) + 1) * state.rotation;
143
+ } else {
144
+ degNum = (-updateMove / state.lineSpacing + 1) * state.rotation;
145
+ }
146
+ const maxDeg = (props.column.length + 1) * state.rotation;
147
+ const minDeg = 0;
148
+ if (degNum > maxDeg) {
149
+ deg = `${maxDeg}deg`;
150
+ } else if (degNum < minDeg) {
151
+ deg = `${minDeg}deg`;
152
+ } else {
153
+ deg = `${degNum}deg`;
154
+ setTransform(updateMove, null, void 0, deg);
155
+ state.currIndex = Math.abs(Math.round(updateMove / state.lineSpacing)) + 1;
156
+ }
157
+ }
158
+ };
159
+ const setChooseValue = () => {
160
+ emit("change", props.column[state.currIndex - 1]);
161
+ };
162
+ const modifyStatus = (type) => {
163
+ const { column: column2 } = props;
164
+ let index = column2.findIndex((columnItem) => columnItem.value == props.value);
165
+ state.currIndex = index === -1 ? 1 : index + 1;
166
+ let move = index === -1 ? 0 : index * state.lineSpacing;
167
+ type && setChooseValue();
168
+ setMove(-move);
169
+ };
170
+ watch(() => props.column, (val) => {
171
+ console.log("props.column\u53D8\u5316", props.column);
172
+ state.transformY = 0;
173
+ modifyStatus(false);
174
+ }, {
175
+ deep: true
176
+ });
177
+ onMounted(() => {
178
+ modifyStatus(true);
179
+ });
180
+ return {
181
+ ...toRefs(state),
182
+ ...toRefs(props),
183
+ wrapper,
184
+ setRollerStyle,
185
+ isHidden,
186
+ roller,
187
+ list,
188
+ listItem,
189
+ onTouchStart,
190
+ onTouchMove,
191
+ onTouchEnd,
192
+ touchRollerStyle,
193
+ touchListStyle,
194
+ setMove
195
+ };
196
+ }
197
+ });
198
+ const _hoisted_1$1 = /* @__PURE__ */ createElementVNode("view", { class: "nut-picker-roller-mask" }, null, -1);
199
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
200
+ return openBlock(), createElementBlock("view", {
201
+ class: "nut-picker__list",
202
+ onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
203
+ onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
204
+ onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
205
+ }, [
206
+ createElementVNode("view", {
207
+ class: "nut-picker-roller",
208
+ ref: "roller",
209
+ style: normalizeStyle(_ctx.touchRollerStyle)
210
+ }, [
211
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.column, (item, index) => {
212
+ return openBlock(), createElementBlock(Fragment, {
213
+ key: item.value ? item.value : index
214
+ }, [
215
+ item && item.text ? (openBlock(), createElementBlock("view", {
216
+ key: 0,
217
+ class: normalizeClass(["nut-picker-roller-item", { "nut-picker-roller-item-hidden": _ctx.isHidden(index + 1) }]),
218
+ style: normalizeStyle(_ctx.setRollerStyle(index + 1))
219
+ }, toDisplayString(item.text), 7)) : createCommentVNode("", true)
220
+ ], 64);
221
+ }), 128))
222
+ ], 4),
223
+ _hoisted_1$1
224
+ ], 32);
225
+ }
226
+ var column = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
227
+ const { componentName, create, translate } = createComponent("picker");
228
+ const _sfc_main = create({
229
+ components: {
230
+ [column.name]: column,
231
+ [Popup.name]: Popup
232
+ },
233
+ props: {
234
+ ...popupProps,
235
+ modelValue: {
236
+ type: Array,
237
+ default: () => []
238
+ },
239
+ title: {
240
+ type: String,
241
+ default: ""
242
+ },
243
+ cancelText: {
244
+ type: String,
245
+ default: ""
246
+ },
247
+ okText: {
248
+ type: String,
249
+ default: ""
250
+ },
251
+ columns: {
252
+ type: Array,
253
+ default: () => {
254
+ return [];
255
+ }
256
+ },
257
+ readonly: {
258
+ type: Boolean,
259
+ default: false
83
260
  }
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 };
261
+ },
262
+ emits: ["close", "change", "confirm", "update:visible", "update:modelValue"],
263
+ setup(props, { emit }) {
264
+ const state = reactive({
265
+ show: false,
266
+ formattedColumns: props.columns
267
+ });
268
+ let defaultValues = ref(props.modelValue);
269
+ ref();
270
+ const classes = computed(() => {
271
+ const prefixCls = componentName;
272
+ return {
273
+ [prefixCls]: true
274
+ };
275
+ });
276
+ const selectedOptions = computed(() => {
277
+ let optins = [];
278
+ columnsList.value.map((column2, index) => {
279
+ let currOptions = [];
280
+ currOptions = column2.filter((item) => item.value == defaultValues.value[index]);
281
+ optins.push(currOptions[0]);
282
+ });
283
+ return optins;
284
+ });
285
+ const columnsType = computed(() => {
286
+ const firstColumn = state.formattedColumns[0];
287
+ if (firstColumn) {
288
+ if (Array.isArray(firstColumn)) {
289
+ return "multiple";
290
+ }
291
+ if ("children" in firstColumn) {
292
+ return "cascade";
293
+ }
294
+ }
295
+ return "single";
296
+ });
297
+ const columnsList = computed(() => {
298
+ switch (columnsType.value) {
299
+ case "multiple":
300
+ return state.formattedColumns;
301
+ case "cascade":
302
+ return formatCascade(state.formattedColumns, defaultValues.value);
303
+ default:
304
+ return [state.formattedColumns];
305
+ }
306
+ });
307
+ const formatCascade = (columns, defaultValues2) => {
308
+ const formatted = [];
309
+ let cursor = {
310
+ text: "",
311
+ value: "",
312
+ children: columns
313
+ };
314
+ let columnIndex = 0;
315
+ while (cursor && cursor.children) {
316
+ const options = cursor.children;
317
+ const value = defaultValues2[columnIndex];
318
+ let index = options.findIndex((columnItem) => columnItem.value == value);
319
+ if (index == -1)
320
+ index = 0;
321
+ cursor = cursor.children[index];
322
+ columnIndex++;
323
+ formatted.push(options);
324
+ }
325
+ return formatted;
326
+ };
327
+ const close = () => {
328
+ emit("close");
329
+ emit("update:visible", false);
330
+ };
331
+ const changeHandler = (columnIndex, option) => {
332
+ if (option && Object.keys(option).length) {
333
+ if (columnsType.value === "cascade") {
334
+ defaultValues.value[columnIndex] = option.value ? option.value : "";
335
+ let index = columnIndex;
336
+ let cursor = option;
337
+ while (cursor && cursor.children) {
338
+ defaultValues.value[index + 1] = cursor.children[0].value;
339
+ index++;
340
+ cursor = cursor.children[0];
341
+ }
342
+ } else {
343
+ defaultValues.value[columnIndex] = option.hasOwnProperty("value") ? option.value : "";
344
+ }
345
+ emit("change", {
346
+ columnIndex,
347
+ selectedValue: defaultValues.value,
348
+ selectedOptions: selectedOptions.value
349
+ });
350
+ }
351
+ };
352
+ const confirmHandler = () => {
353
+ emit("confirm", {
354
+ selectedValue: defaultValues.value,
355
+ selectedOptions: selectedOptions.value
356
+ });
357
+ emit("update:visible", false);
358
+ };
359
+ onMounted(() => {
360
+ if (props.visible)
361
+ state.show = props.visible;
362
+ });
363
+ onBeforeUnmount(() => {
364
+ if (props.visible)
365
+ state.show = false;
366
+ });
367
+ watch(() => props.modelValue, (newValues) => {
368
+ const isSameValue = JSON.stringify(newValues) === JSON.stringify(defaultValues.value);
369
+ if (!isSameValue) {
370
+ defaultValues.value = newValues;
371
+ }
372
+ }, { deep: true });
373
+ watch(defaultValues, (newValues) => {
374
+ const isSameValue = JSON.stringify(newValues) === JSON.stringify(props.modelValue);
375
+ if (!isSameValue) {
376
+ emit("update:modelValue", newValues);
377
+ }
378
+ }, { immediate: true });
379
+ watch(() => props.visible, (val) => {
380
+ state.show = val;
381
+ });
382
+ watch(() => props.columns, (val) => {
383
+ if (val.length)
384
+ state.formattedColumns = val;
385
+ });
386
+ return {
387
+ classes,
388
+ ...toRefs(state),
389
+ column,
390
+ columnsType,
391
+ columnsList,
392
+ close,
393
+ changeHandler,
394
+ confirmHandler,
395
+ defaultValues,
396
+ translate
397
+ };
398
+ }
399
+ });
400
+ const _hoisted_1 = { class: "nut-picker__bar" };
401
+ const _hoisted_2 = { class: "nut-picker__title" };
402
+ const _hoisted_3 = {
403
+ class: "nut-picker__column",
404
+ ref: "wrapHeight"
405
+ };
406
+ const _hoisted_4 = /* @__PURE__ */ createElementVNode("view", { class: "nut-picker__hairline" }, null, -1);
407
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
408
+ const _component_nut_picker_column = resolveComponent("nut-picker-column");
409
+ const _component_nut_popup = resolveComponent("nut-popup");
410
+ return openBlock(), createElementBlock("view", {
411
+ class: normalizeClass(_ctx.classes)
412
+ }, [
413
+ createVNode(_component_nut_popup, {
414
+ position: "bottom",
415
+ visible: _ctx.show,
416
+ "onUpdate:visible": _cache[2] || (_cache[2] = ($event) => _ctx.show = $event),
417
+ teleport: _ctx.teleport,
418
+ "lock-scroll": _ctx.lockScroll,
419
+ "close-on-click-overlay": _ctx.closeOnClickOverlay,
420
+ onClose: _ctx.close,
421
+ round: true,
422
+ isWrapTeleport: _ctx.isWrapTeleport
423
+ }, {
424
+ default: withCtx(() => [
425
+ createElementVNode("view", _hoisted_1, [
426
+ createElementVNode("view", {
427
+ class: "nut-picker__cancel nut-picker__left nut-picker__button",
428
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.close && _ctx.close(...args))
429
+ }, toDisplayString(_ctx.cancelText || _ctx.translate("cancel")), 1),
430
+ createElementVNode("view", _hoisted_2, toDisplayString(_ctx.title), 1),
431
+ createElementVNode("view", {
432
+ class: "nut-picker__confirm nut-picker__right nut-picker__button",
433
+ onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirmHandler())
434
+ }, toDisplayString(_ctx.okText || _ctx.translate("confirm")), 1)
435
+ ]),
436
+ renderSlot(_ctx.$slots, "top"),
437
+ createElementVNode("view", _hoisted_3, [
438
+ _hoisted_4,
439
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columnsList, (column2, columnIndex) => {
440
+ return openBlock(), createElementBlock("view", {
441
+ class: "nut-picker__columnitem",
442
+ key: columnIndex
443
+ }, [
444
+ createVNode(_component_nut_picker_column, {
445
+ itemShow: _ctx.show,
446
+ column: column2,
447
+ readonly: _ctx.readonly,
448
+ columnsType: _ctx.columnsType,
449
+ value: _ctx.defaultValues[columnIndex],
450
+ onChange: (option) => {
451
+ _ctx.changeHandler(columnIndex, option);
452
+ }
453
+ }, null, 8, ["itemShow", "column", "readonly", "columnsType", "value", "onChange"])
454
+ ]);
455
+ }), 128))
456
+ ], 512),
457
+ renderSlot(_ctx.$slots, "default")
458
+ ]),
459
+ _: 3
460
+ }, 8, ["visible", "teleport", "lock-scroll", "close-on-click-overlay", "onClose", "isWrapTeleport"])
461
+ ], 2);
462
+ }
463
+ var Picker = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
464
+ export { Picker as default };