@nutui/nutui 3.1.22-beta.3 → 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 (207) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +3 -4
  3. package/dist/nutui.es.js +20426 -4050
  4. package/dist/nutui.umd.js +20529 -4049
  5. package/dist/packages/_es/ActionSheet.js +149 -36
  6. package/dist/packages/_es/Address.js +535 -129
  7. package/dist/packages/_es/AddressList.js +615 -113
  8. package/dist/packages/_es/Animate.js +64 -0
  9. package/dist/packages/_es/Audio.js +257 -72
  10. package/dist/packages/_es/AudioOperate.js +100 -32
  11. package/dist/packages/_es/Avatar.js +162 -54
  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 -24
  18. package/dist/packages/_es/CalendarItem.js +2 -1
  19. package/dist/packages/_es/Card.js +107 -10
  20. package/dist/packages/_es/Cascader.js +496 -179
  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 +110 -24
  30. package/dist/packages/_es/CollapseItem.js +252 -80
  31. package/dist/packages/_es/Comment.js +434 -64
  32. package/dist/packages/_es/ConfigProvider.js +25 -0
  33. package/dist/packages/_es/CountDown.js +238 -75
  34. package/dist/packages/_es/CountUp.js +539 -159
  35. package/dist/packages/_es/DatePicker.js +315 -117
  36. package/dist/packages/_es/Dialog.js +289 -79
  37. package/dist/packages/_es/Divider.js +65 -32
  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 -77
  41. package/dist/packages/_es/Ellipsis.js +206 -0
  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 +142 -0
  50. package/dist/packages/_es/ImagePreview.js +547 -84
  51. package/dist/packages/_es/Indicator.js +62 -15
  52. package/dist/packages/_es/InfiniteLoading.js +249 -76
  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 -37
  57. package/dist/packages/_es/Menu.js +168 -29
  58. package/dist/packages/_es/MenuItem.js +173 -34
  59. package/dist/packages/_es/Navbar.js +192 -30
  60. package/dist/packages/_es/NoticeBar.js +380 -93
  61. package/dist/packages/_es/Notify.js +227 -91
  62. package/dist/packages/_es/NumberKeyboard.js +272 -41
  63. package/dist/packages/_es/OldPicker.js +457 -149
  64. package/dist/packages/_es/OverLay.js +98 -40
  65. package/dist/packages/_es/Pagination.js +157 -39
  66. package/dist/packages/_es/Picker.js +460 -148
  67. package/dist/packages/_es/Popover.js +957 -337
  68. package/dist/packages/_es/Popup.js +299 -74
  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 -100
  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 -102
  75. package/dist/packages/_es/Rate.js +193 -16
  76. package/dist/packages/_es/Row.js +64 -22
  77. package/dist/packages/_es/SearchBar.js +238 -56
  78. package/dist/packages/_es/ShortPassword.js +225 -35
  79. package/dist/packages/_es/SideNavBar.js +81 -43
  80. package/dist/packages/_es/SideNavBarItem.js +46 -11
  81. package/dist/packages/_es/Signature.js +160 -60
  82. package/dist/packages/_es/Skeleton.js +136 -20
  83. package/dist/packages/_es/Sku.js +491 -103
  84. package/dist/packages/_es/Step.js +115 -39
  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 -36
  88. package/dist/packages/_es/Swipe.js +178 -60
  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 -37
  96. package/dist/packages/_es/Tabs.js +202 -59
  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 -37
  100. package/dist/packages/_es/TimePannel.js +48 -33
  101. package/dist/packages/_es/TimeSelect.js +112 -15
  102. package/dist/packages/_es/Toast.js +310 -90
  103. package/dist/packages/_es/Uploader.js +455 -120
  104. package/dist/packages/_es/Video.js +332 -93
  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 +783 -130
  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/animate/index.scss +299 -0
  116. package/dist/packages/cell/index.scss +7 -1
  117. package/dist/packages/checkbox/index.scss +10 -0
  118. package/dist/packages/configprovider/index.scss +2 -0
  119. package/dist/packages/ellipsis/index.scss +12 -0
  120. package/dist/packages/formitem/index.scss +12 -0
  121. package/dist/packages/griditem/index.scss +11 -0
  122. package/dist/packages/image/index.scss +39 -0
  123. package/dist/packages/imagepreview/index.scss +26 -2
  124. package/dist/packages/input/index.scss +13 -0
  125. package/dist/packages/inputnumber/index.scss +21 -0
  126. package/dist/packages/locale/lang/baseLang.js +3 -3
  127. package/dist/packages/locale/lang/en-US.js +105 -5
  128. package/dist/packages/locale/lang/id-ID.js +105 -5
  129. package/dist/packages/locale/lang/index.js +38 -16
  130. package/dist/packages/locale/lang/zh-CN.js +105 -5
  131. package/dist/packages/locale/lang/zh-TW.js +105 -5
  132. package/dist/packages/menu/index.scss +45 -36
  133. package/dist/packages/menuitem/index.scss +4 -0
  134. package/dist/packages/navbar/index.scss +9 -0
  135. package/dist/packages/pagination/index.scss +19 -0
  136. package/dist/packages/radio/index.scss +18 -0
  137. package/dist/packages/range/index.scss +19 -0
  138. package/dist/packages/rate/index.scss +1 -1
  139. package/dist/packages/searchbar/index.scss +21 -0
  140. package/dist/packages/switch/index.scss +1 -0
  141. package/dist/packages/tabbar/index.scss +5 -0
  142. package/dist/packages/tabbaritem/index.scss +7 -0
  143. package/dist/packages/tabpane/index.scss +5 -0
  144. package/dist/packages/tabs/index.scss +22 -0
  145. package/dist/packages/textarea/index.scss +8 -0
  146. package/dist/smartips/attributes.json +140 -4
  147. package/dist/smartips/tags.json +55 -6
  148. package/dist/smartips/web-types.json +6963 -0
  149. package/dist/style.css +1 -1
  150. package/dist/style.es.js +1 -1
  151. package/dist/styles/font/config.json +3 -1
  152. package/dist/styles/font/demo_index.html +49 -3
  153. package/dist/styles/font/iconfont.css +11 -3
  154. package/dist/styles/font/iconfont.js +15 -15
  155. package/dist/styles/font/iconfont.json +14 -0
  156. package/dist/styles/font/iconfont.ttf +0 -0
  157. package/dist/styles/font/iconfont.woff +0 -0
  158. package/dist/styles/font/iconfont.woff2 +0 -0
  159. package/dist/styles/themes/default.scss +54 -50
  160. package/dist/styles/themes/jdb.scss +54 -50
  161. package/dist/styles/themes/jdt.scss +54 -50
  162. package/dist/styles/variables-jdb.scss +12 -0
  163. package/dist/styles/variables-jdt.scss +12 -0
  164. package/dist/styles/variables.scss +12 -0
  165. package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
  166. package/dist/types/__VUE/address/index.vue.d.ts +7 -7
  167. package/dist/types/__VUE/animate/index.vue.d.ts +48 -0
  168. package/dist/types/__VUE/animate/type.d.ts +6 -0
  169. package/dist/types/__VUE/avatar/index.vue.d.ts +3 -3
  170. package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
  171. package/dist/types/__VUE/calendaritem/index.vue.d.ts +10 -2
  172. package/dist/types/__VUE/cascader/index.vue.d.ts +2 -2
  173. package/dist/types/__VUE/circleprogress/index.vue.d.ts +2 -2
  174. package/dist/types/__VUE/collapse/index.vue.d.ts +3 -1
  175. package/dist/types/__VUE/configprovider/common.d.ts +20 -0
  176. package/dist/types/__VUE/configprovider/index.vue.d.ts +33 -0
  177. package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
  178. package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
  179. package/dist/types/__VUE/ellipsis/index.vue.d.ts +72 -0
  180. package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
  181. package/dist/types/__VUE/grid/index.vue.d.ts +2 -2
  182. package/dist/types/__VUE/image/index.vue.d.ts +105 -0
  183. package/dist/types/__VUE/image/type.d.ts +6 -0
  184. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
  185. package/dist/types/__VUE/imagepreview/index.vue.d.ts +56 -24
  186. package/dist/types/__VUE/menu/index.vue.d.ts +31 -4
  187. package/dist/types/__VUE/menuitem/index.vue.d.ts +12 -3
  188. package/dist/types/__VUE/noticebar/index.vue.d.ts +1 -1
  189. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
  190. package/dist/types/__VUE/oldpicker/index.vue.d.ts +4 -4
  191. package/dist/types/__VUE/picker/index.vue.d.ts +4 -4
  192. package/dist/types/__VUE/popover/index.vue.d.ts +8 -8
  193. package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
  194. package/dist/types/__VUE/range/index.vue.d.ts +1 -1
  195. package/dist/types/__VUE/rate/common.d.ts +149 -0
  196. package/dist/types/__VUE/rate/index.vue.d.ts +17 -7
  197. package/dist/types/__VUE/row/index.vue.d.ts +2 -2
  198. package/dist/types/__VUE/shortpassword/index.vue.d.ts +2 -2
  199. package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
  200. package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
  201. package/dist/types/__VUE/swiper/index.vue.d.ts +2 -2
  202. package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
  203. package/dist/types/__VUE/timeselect/index.vue.d.ts +3 -2
  204. package/dist/types/__VUE/uploader/uploader.d.ts +1 -0
  205. package/dist/types/index.d.ts +1 -1
  206. package/dist/types/nutui.d.ts +5 -1
  207. package/package.json +5 -4
@@ -1,158 +1,470 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a2, b2) => {
9
- for (var prop in b2 || (b2 = {}))
10
- if (__hasOwnProp.call(b2, prop))
11
- __defNormalProp(a2, prop, b2[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b2)) {
14
- if (__propIsEnum.call(b2, prop))
15
- __defNormalProp(a2, prop, b2[prop]);
16
- }
17
- return a2;
18
- };
19
- var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
20
1
  /*!
21
- * @nutui/nutui v3.1.22-beta.3 Wed Jun 15 2022 20:12:30 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
22
3
  * (c) 2022 @jdf2e.
23
4
  * Released under the MIT License.
24
5
  */
25
- 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";
26
- import { c as S } from "./component.js";
27
- import T, { popupProps as w } from "./Popup.js";
28
- 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";
29
10
  import "../locale/lang";
30
11
  import "./OverLay.js";
31
12
  import "./Icon.js";
32
13
  import "./pxCheck.js";
33
- 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 }) {
34
- 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) => {
35
- h2.value = t2 === "end" ? l2 : 0, d2.value = n2, v2.value = e2, i2.scrollDistance = e2;
36
- }, k2 = (e2, t2, l2) => {
37
- let n2 = e2 + i2.transformY;
38
- if (t2 === "end") {
39
- n2 > 0 && (n2 = 0), n2 < -(r2.column.length - 1) * i2.lineSpacing && (n2 = -(r2.column.length - 1) * i2.lineSpacing);
40
- let e3 = Math.round(n2 / i2.lineSpacing) * i2.lineSpacing, a2 = (Math.abs(Math.round(e3 / i2.lineSpacing)) + 1) * i2.rotation + "deg";
41
- y2(e3, t2, l2, a2);
42
- let o2 = l2 ? l2 / 2 : 0;
43
- i2.timer = setTimeout(() => {
44
- S2();
45
- }, o2), i2.currIndex = Math.abs(Math.round(e3 / i2.lineSpacing)) + 1;
46
- } else {
47
- let e3 = "0deg";
48
- 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;
49
- }
50
- }, S2 = () => {
51
- s2("change", r2.column[i2.currIndex - 1]);
52
- }, T2 = (e2) => {
53
- const { column: t2 } = r2;
54
- let l2 = t2.findIndex((e3) => e3.value == r2.value);
55
- i2.currIndex = l2 === -1 ? 1 : l2 + 1;
56
- let n2 = l2 === -1 ? 0 : l2 * i2.lineSpacing;
57
- e2 && S2(), k2(-n2);
58
- };
59
- return n(() => r2.column, (e2) => {
60
- i2.transformY = 0, T2(false);
61
- }, { deep: true }), n(() => r2.value, (e2) => {
62
- T2(true);
63
- }, { deep: true }), a(() => {
64
- T2(true);
65
- }), __spreadProps(__spreadValues(__spreadValues({}, 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) => {
66
- e2.preventDefault();
67
- let t2 = e2.changedTouches[0];
68
- i2.touchParams.startY = t2.pageY, i2.touchParams.startTime = e2.timeStamp || Date.now(), i2.transformY = i2.scrollDistance;
69
- }, onTouchMove: (e2) => {
70
- e2.preventDefault();
71
- let t2 = e2.changedTouches[0];
72
- i2.touchParams.lastY = t2.pageY, i2.touchParams.lastTime = e2.timeStamp || Date.now();
73
- let l2 = i2.touchParams.lastY - i2.touchParams.startY;
74
- k2(l2);
75
- }, onTouchEnd: (e2) => {
76
- e2.preventDefault();
77
- let t2 = e2.changedTouches[0];
78
- i2.touchParams.lastY = t2.pageY, i2.touchParams.lastTime = e2.timeStamp || Date.now();
79
- let l2 = i2.touchParams.lastY - i2.touchParams.startY, n2 = i2.touchParams.lastTime - i2.touchParams.startTime;
80
- n2 <= 300 ? (l2 *= 2, n2 += 1e3, k2(l2, "end", n2)) : k2(l2, "end");
81
- }, touchRollerStyle: g2, touchListStyle: f2, setMove: k2 });
82
- } }), Y = { class: "nut-picker-content" }, P = { key: 0, class: "nut-picker-placeholder" };
83
- var C = _(x, [["render", function(e2, t2, l2, n2, a2, o2) {
84
- 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);
85
- }]]);
86
- const { componentName: I, create: M, translate: O } = S("picker"), D = M({ components: { [C.name]: C, [T.name]: T }, props: __spreadProps(__spreadValues({}, 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 }) {
87
- const c2 = t({ show: false, formattedColumns: r2.columns });
88
- let i2 = e(r2.modelValue);
89
- const u2 = l(() => ({ [I]: true })), m2 = l(() => {
90
- let e2 = [];
91
- return d2.value.map((t2, l2) => {
92
- let n2 = [];
93
- n2 = t2.filter((e3) => e3.value == i2.value[l2]), e2.push(n2[0]);
94
- }), e2;
95
- }), p2 = l(() => {
96
- const e2 = c2.formattedColumns[0];
97
- if (e2) {
98
- if (Array.isArray(e2))
99
- return "multiple";
100
- if ("children" in e2)
101
- return "cascade";
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
102
30
  }
103
- return "single";
104
- }), d2 = l(() => {
105
- switch (p2.value) {
106
- case "multiple":
107
- return c2.formattedColumns;
108
- case "cascade":
109
- return h2(c2.formattedColumns, i2.value);
110
- default:
111
- return [c2.formattedColumns];
112
- }
113
- }), h2 = (e2, t2) => {
114
- const l2 = [];
115
- let n2 = { text: "", value: "", children: e2 }, a2 = 0;
116
- for (; n2 && n2.children; ) {
117
- const e3 = n2.children, o2 = t2[a2];
118
- let r3 = e3.findIndex((e4) => e4.value == o2);
119
- r3 == -1 && (r3 = 0), n2 = n2.children[r3], a2++, l2.push(e3);
120
- }
121
- return l2;
122
- };
123
- return a(() => {
124
- r2.visible && (c2.show = r2.visible);
125
- }), v(() => {
126
- r2.visible && (c2.show = false);
127
- }), n(() => r2.modelValue, (e2) => {
128
- JSON.stringify(e2) === JSON.stringify(i2.value) || (i2.value = e2);
129
- }, { deep: true }), n(i2, (e2) => {
130
- JSON.stringify(e2) === JSON.stringify(r2.modelValue) || s2("update:modelValue", e2);
131
- }, { immediate: true }), n(() => r2.visible, (e2) => {
132
- c2.show = e2;
133
- }), n(() => r2.columns, (e2) => {
134
- e2.length && (c2.formattedColumns = e2);
135
- }), __spreadProps(__spreadValues({ classes: u2 }, o(c2)), { column: C, columnsType: p2, columnsList: d2, close: () => {
136
- s2("close"), s2("update:visible", false);
137
- }, changeHandler: (e2, t2) => {
138
- if (t2 && Object.keys(t2).length) {
139
- if (p2.value === "cascade") {
140
- i2.value[e2] = t2.value ? t2.value : "";
141
- let l2 = e2, n2 = t2;
142
- for (; n2 && n2.children; )
143
- i2.value[l2 + 1] = n2.children[0].value, l2++, n2 = n2.children[0];
144
- } else
145
- i2.value[e2] = t2.hasOwnProperty("value") ? t2.value : "";
146
- s2("change", { columnIndex: e2, selectedValue: i2.value, selectedOptions: m2.value });
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
+ if (moveTime <= 300) {
92
+ move = move * 2;
93
+ moveTime = moveTime + 1e3;
94
+ setMove(move, "end", moveTime);
95
+ } else {
96
+ setMove(move, "end");
97
+ }
98
+ };
99
+ const setRollerStyle = (index) => {
100
+ return `transform: rotate3d(1, 0, 0, ${-state.rotation * index}deg) translate3d(0px, 0px, 104px)`;
101
+ };
102
+ const isHidden = (index) => {
103
+ if (index >= state.currIndex + 8 || index <= state.currIndex - 8) {
104
+ return true;
105
+ } else {
106
+ return false;
107
+ }
108
+ };
109
+ const setTransform = (translateY = 0, type, time = 1e3, deg) => {
110
+ if (type === "end") {
111
+ touchTime.value = time;
112
+ } else {
113
+ touchTime.value = 0;
114
+ }
115
+ touchDeg.value = deg;
116
+ touchTranslateY.value = translateY;
117
+ state.scrollDistance = translateY;
118
+ };
119
+ const setMove = (move, type, time) => {
120
+ let updateMove = move + state.transformY;
121
+ if (type === "end") {
122
+ if (updateMove > 0) {
123
+ updateMove = 0;
124
+ }
125
+ if (updateMove < -(props.column.length - 1) * state.lineSpacing) {
126
+ updateMove = -(props.column.length - 1) * state.lineSpacing;
127
+ }
128
+ let endMove = Math.round(updateMove / state.lineSpacing) * state.lineSpacing;
129
+ let deg = `${(Math.abs(Math.round(endMove / state.lineSpacing)) + 1) * state.rotation}deg`;
130
+ setTransform(endMove, type, time, deg);
131
+ let t = time ? time / 2 : 0;
132
+ state.timer = setTimeout(() => {
133
+ setChooseValue();
134
+ }, t);
135
+ state.currIndex = Math.abs(Math.round(endMove / state.lineSpacing)) + 1;
136
+ } else {
137
+ let deg = "0deg";
138
+ if (updateMove < 0) {
139
+ deg = `${(Math.abs(updateMove / state.lineSpacing) + 1) * state.rotation}deg`;
140
+ } else {
141
+ deg = `${(-updateMove / state.lineSpacing + 1) * state.rotation}deg`;
142
+ }
143
+ setTransform(updateMove, null, void 0, deg);
144
+ state.currIndex = Math.abs(Math.round(updateMove / state.lineSpacing)) + 1;
145
+ }
146
+ };
147
+ const setChooseValue = () => {
148
+ emit("change", props.column[state.currIndex - 1]);
149
+ };
150
+ const modifyStatus = (type) => {
151
+ const { column: column2 } = props;
152
+ let index = column2.findIndex((columnItem) => columnItem.value == props.value);
153
+ state.currIndex = index === -1 ? 1 : index + 1;
154
+ let move = index === -1 ? 0 : index * state.lineSpacing;
155
+ type && setChooseValue();
156
+ setMove(-move);
157
+ };
158
+ watch(() => props.column, (val) => {
159
+ state.transformY = 0;
160
+ modifyStatus(false);
161
+ }, {
162
+ deep: true
163
+ });
164
+ watch(() => props.value, (val) => {
165
+ console.log("\u5217\u66F4\u65B0", val);
166
+ modifyStatus(true);
167
+ }, {
168
+ deep: true
169
+ });
170
+ onMounted(() => {
171
+ modifyStatus(true);
172
+ });
173
+ return {
174
+ ...toRefs(state),
175
+ ...toRefs(props),
176
+ wrapper,
177
+ setRollerStyle,
178
+ isHidden,
179
+ roller,
180
+ list,
181
+ listItem,
182
+ onTouchStart,
183
+ onTouchMove,
184
+ onTouchEnd,
185
+ touchRollerStyle,
186
+ touchListStyle,
187
+ setMove
188
+ };
189
+ }
190
+ });
191
+ const _hoisted_1$1 = { class: "nut-picker-content" };
192
+ const _hoisted_2$1 = {
193
+ key: 0,
194
+ class: "nut-picker-placeholder"
195
+ };
196
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
197
+ return openBlock(), createElementBlock("view", {
198
+ class: "nut-picker__list",
199
+ onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
200
+ onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
201
+ onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
202
+ }, [
203
+ createElementVNode("view", {
204
+ class: "nut-picker-roller",
205
+ ref: "roller",
206
+ style: normalizeStyle(_ctx.touchRollerStyle)
207
+ }, [
208
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.column, (item, index) => {
209
+ return openBlock(), createElementBlock("view", {
210
+ class: normalizeClass(["nut-picker-roller-item", { "nut-picker-roller-item-hidden": _ctx.isHidden(index + 1) }]),
211
+ style: normalizeStyle(_ctx.setRollerStyle(index + 1)),
212
+ key: item.value ? item.value : index
213
+ }, toDisplayString(item.text), 7);
214
+ }), 128))
215
+ ], 4),
216
+ createElementVNode("view", _hoisted_1$1, [
217
+ createElementVNode("view", {
218
+ class: "nut-picker-list-panel",
219
+ ref: "list",
220
+ style: normalizeStyle(_ctx.touchListStyle)
221
+ }, [
222
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.column, (item, index) => {
223
+ return openBlock(), createElementBlock("view", {
224
+ class: normalizeClass(["nut-picker-item", "nut-picker-item-ref", item.className]),
225
+ key: item.value ? item.value : index
226
+ }, toDisplayString(item.text), 3);
227
+ }), 128)),
228
+ _ctx.column && _ctx.column.length === 1 ? (openBlock(), createElementBlock("view", _hoisted_2$1)) : createCommentVNode("", true)
229
+ ], 4)
230
+ ])
231
+ ], 32);
232
+ }
233
+ var column = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
234
+ const { componentName, create, translate } = createComponent("picker");
235
+ const _sfc_main = create({
236
+ components: {
237
+ [column.name]: column,
238
+ [Popup.name]: Popup
239
+ },
240
+ props: {
241
+ ...popupProps,
242
+ modelValue: {
243
+ type: Array,
244
+ default: () => []
245
+ },
246
+ title: {
247
+ type: String,
248
+ default: ""
249
+ },
250
+ cancelText: {
251
+ type: String,
252
+ default: ""
253
+ },
254
+ okText: {
255
+ type: String,
256
+ default: ""
257
+ },
258
+ columns: {
259
+ type: Array,
260
+ default: () => {
261
+ return [];
262
+ }
263
+ },
264
+ readonly: {
265
+ type: Boolean,
266
+ default: false
147
267
  }
148
- }, confirmHandler: () => {
149
- s2("confirm", { selectedValue: i2.value, selectedOptions: m2.value }), s2("update:visible", false);
150
- }, defaultValues: i2, translate: O });
151
- } }), V = { class: "nut-picker__bar" }, j = { class: "nut-picker__title" }, N = { class: "nut-picker__column" }, $ = c("view", { class: "nut-picker__hairline" }, null, -1);
152
- var H = _(D, [["render", function(e2, t2, l2, n2, a2, o2) {
153
- const i2 = f("nut-picker-column"), h2 = f("nut-popup");
154
- 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) => {
155
- e2.changeHandler(l3, t4);
156
- } }, 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);
157
- }]]);
158
- export { H as default };
268
+ },
269
+ emits: ["close", "change", "confirm", "update:visible", "update:modelValue"],
270
+ setup(props, { emit }) {
271
+ const state = reactive({
272
+ show: false,
273
+ formattedColumns: props.columns
274
+ });
275
+ let defaultValues = ref(props.modelValue);
276
+ const classes = computed(() => {
277
+ const prefixCls = componentName;
278
+ return {
279
+ [prefixCls]: true
280
+ };
281
+ });
282
+ const selectedOptions = computed(() => {
283
+ let optins = [];
284
+ columnsList.value.map((column2, index) => {
285
+ let currOptions = [];
286
+ currOptions = column2.filter((item) => item.value == defaultValues.value[index]);
287
+ optins.push(currOptions[0]);
288
+ });
289
+ return optins;
290
+ });
291
+ const columnsType = computed(() => {
292
+ const firstColumn = state.formattedColumns[0];
293
+ if (firstColumn) {
294
+ if (Array.isArray(firstColumn)) {
295
+ return "multiple";
296
+ }
297
+ if ("children" in firstColumn) {
298
+ return "cascade";
299
+ }
300
+ }
301
+ return "single";
302
+ });
303
+ const columnsList = computed(() => {
304
+ switch (columnsType.value) {
305
+ case "multiple":
306
+ return state.formattedColumns;
307
+ case "cascade":
308
+ return formatCascade(state.formattedColumns, defaultValues.value);
309
+ default:
310
+ return [state.formattedColumns];
311
+ }
312
+ });
313
+ const formatCascade = (columns, defaultValues2) => {
314
+ const formatted = [];
315
+ let cursor = {
316
+ text: "",
317
+ value: "",
318
+ children: columns
319
+ };
320
+ let columnIndex = 0;
321
+ while (cursor && cursor.children) {
322
+ const options = cursor.children;
323
+ const value = defaultValues2[columnIndex];
324
+ let index = options.findIndex((columnItem) => columnItem.value == value);
325
+ if (index == -1)
326
+ index = 0;
327
+ cursor = cursor.children[index];
328
+ columnIndex++;
329
+ formatted.push(options);
330
+ }
331
+ return formatted;
332
+ };
333
+ const close = () => {
334
+ emit("close");
335
+ emit("update:visible", false);
336
+ };
337
+ const changeHandler = (columnIndex, option) => {
338
+ if (option && Object.keys(option).length) {
339
+ if (columnsType.value === "cascade") {
340
+ defaultValues.value[columnIndex] = option.value ? option.value : "";
341
+ let index = columnIndex;
342
+ let cursor = option;
343
+ while (cursor && cursor.children) {
344
+ defaultValues.value[index + 1] = cursor.children[0].value;
345
+ index++;
346
+ cursor = cursor.children[0];
347
+ }
348
+ } else {
349
+ defaultValues.value[columnIndex] = option.hasOwnProperty("value") ? option.value : "";
350
+ }
351
+ emit("change", {
352
+ columnIndex,
353
+ selectedValue: defaultValues.value,
354
+ selectedOptions: selectedOptions.value
355
+ });
356
+ }
357
+ };
358
+ const confirmHandler = () => {
359
+ emit("confirm", {
360
+ selectedValue: defaultValues.value,
361
+ selectedOptions: selectedOptions.value
362
+ });
363
+ emit("update:visible", false);
364
+ };
365
+ onMounted(() => {
366
+ console.log(11, props.modelValue);
367
+ if (props.visible)
368
+ state.show = props.visible;
369
+ });
370
+ onBeforeUnmount(() => {
371
+ if (props.visible)
372
+ state.show = false;
373
+ });
374
+ watch(() => props.modelValue, (newValues) => {
375
+ console.log("change", newValues, defaultValues.value);
376
+ const isSameValue = JSON.stringify(newValues) === JSON.stringify(defaultValues.value);
377
+ if (!isSameValue) {
378
+ defaultValues.value = newValues;
379
+ }
380
+ }, { deep: true });
381
+ watch(defaultValues, (newValues) => {
382
+ const isSameValue = JSON.stringify(newValues) === JSON.stringify(props.modelValue);
383
+ if (!isSameValue) {
384
+ emit("update:modelValue", newValues);
385
+ }
386
+ }, { immediate: true });
387
+ watch(() => props.visible, (val) => {
388
+ console.log("props\u66F4\u65B0", props.columns);
389
+ state.show = val;
390
+ });
391
+ watch(() => props.columns, (val) => {
392
+ if (val.length)
393
+ state.formattedColumns = val;
394
+ });
395
+ return {
396
+ classes,
397
+ ...toRefs(state),
398
+ column,
399
+ columnsType,
400
+ columnsList,
401
+ close,
402
+ changeHandler,
403
+ confirmHandler,
404
+ defaultValues,
405
+ translate
406
+ };
407
+ }
408
+ });
409
+ const _hoisted_1 = { class: "nut-picker__bar" };
410
+ const _hoisted_2 = { class: "nut-picker__title" };
411
+ const _hoisted_3 = { class: "nut-picker__column" };
412
+ const _hoisted_4 = /* @__PURE__ */ createElementVNode("view", { class: "nut-picker__hairline" }, null, -1);
413
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
414
+ const _component_nut_picker_column = resolveComponent("nut-picker-column");
415
+ const _component_nut_popup = resolveComponent("nut-popup");
416
+ return openBlock(), createElementBlock("view", {
417
+ class: normalizeClass(_ctx.classes)
418
+ }, [
419
+ createVNode(_component_nut_popup, {
420
+ position: "bottom",
421
+ visible: _ctx.show,
422
+ "onUpdate:visible": _cache[2] || (_cache[2] = ($event) => _ctx.show = $event),
423
+ teleport: _ctx.teleport,
424
+ "lock-scroll": _ctx.lockScroll,
425
+ "close-on-click-overlay": _ctx.closeOnClickOverlay,
426
+ onClose: _ctx.close,
427
+ round: true,
428
+ isWrapTeleport: _ctx.isWrapTeleport
429
+ }, {
430
+ default: withCtx(() => [
431
+ createElementVNode("view", _hoisted_1, [
432
+ createElementVNode("view", {
433
+ class: "nut-picker__cancel nut-picker__left nut-picker__button",
434
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.close && _ctx.close(...args))
435
+ }, toDisplayString(_ctx.cancelText || _ctx.translate("cancel")), 1),
436
+ createElementVNode("view", _hoisted_2, toDisplayString(_ctx.title), 1),
437
+ createElementVNode("view", {
438
+ class: "nut-picker__confirm nut-picker__right nut-picker__button",
439
+ onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirmHandler())
440
+ }, toDisplayString(_ctx.okText || _ctx.translate("confirm")), 1)
441
+ ]),
442
+ renderSlot(_ctx.$slots, "top"),
443
+ createElementVNode("view", _hoisted_3, [
444
+ _hoisted_4,
445
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columnsList, (column2, columnIndex) => {
446
+ return openBlock(), createElementBlock("view", {
447
+ class: "nut-picker__columnitem",
448
+ key: columnIndex
449
+ }, [
450
+ createVNode(_component_nut_picker_column, {
451
+ itemShow: _ctx.show,
452
+ column: column2,
453
+ readonly: _ctx.readonly,
454
+ columnsType: _ctx.columnsType,
455
+ value: _ctx.defaultValues[columnIndex],
456
+ onChange: (option) => {
457
+ _ctx.changeHandler(columnIndex, option);
458
+ }
459
+ }, null, 8, ["itemShow", "column", "readonly", "columnsType", "value", "onChange"])
460
+ ]);
461
+ }), 128))
462
+ ]),
463
+ renderSlot(_ctx.$slots, "default")
464
+ ]),
465
+ _: 3
466
+ }, 8, ["visible", "teleport", "lock-scroll", "close-on-click-overlay", "onClose", "isWrapTeleport"])
467
+ ], 2);
468
+ }
469
+ var Picker = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
470
+ export { Picker as default };