@opentiny/vue-renderless 3.13.1 → 3.14.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 (321) hide show
  1. package/action-sheet/index.js +20 -13
  2. package/action-sheet/vue.js +8 -7
  3. package/amount/index.js +100 -25
  4. package/amount/vue.js +102 -26
  5. package/anchor/index.js +1 -0
  6. package/area/index.js +8 -8
  7. package/area/vue.js +5 -5
  8. package/async-flowchart/index.js +16 -3
  9. package/autocomplete/index.js +58 -14
  10. package/autocomplete/vue.js +40 -12
  11. package/badge/index.js +12 -0
  12. package/badge/vue.js +6 -4
  13. package/breadcrumb/vue.js +3 -1
  14. package/breadcrumb-item/vue.js +6 -2
  15. package/button/index.js +5 -1
  16. package/calendar/index.js +2 -86
  17. package/calendar-bar/index.js +18 -4
  18. package/calendar-view/index.js +5 -1
  19. package/calendar-view/vue.js +16 -3
  20. package/card-group/vue.js +4 -2
  21. package/cascader/index.js +86 -34
  22. package/cascader/vue.js +61 -20
  23. package/cascader-menu/index.js +7 -7
  24. package/cascader-menu/vue.js +2 -3
  25. package/cascader-mobile/index.js +36 -23
  26. package/cascader-mobile/vue.js +6 -0
  27. package/cascader-node/index.js +13 -1
  28. package/cascader-node/vue.js +15 -4
  29. package/cascader-panel/index.js +1 -1
  30. package/cascader-select/column-index.js +150 -0
  31. package/cascader-select/column.js +120 -0
  32. package/cascader-select/index.js +29 -165
  33. package/cascader-select/usePicker.js +251 -0
  34. package/cascader-select/useTouch.js +65 -0
  35. package/cascader-select/vue.js +35 -47
  36. package/cell/vue.js +2 -1
  37. package/chart-bar/index.js +2 -3
  38. package/chart-core/deps/constants.js +43 -43
  39. package/chart-core/index.js +1 -1
  40. package/chart-gauge/index.js +2 -2
  41. package/chart-heatmap/index.js +17 -10
  42. package/chart-line/index.js +8 -9
  43. package/chart-tree/index.js +2 -2
  44. package/chart-waterfall/index.js +4 -6
  45. package/checkbox/index.js +18 -1
  46. package/checkbox/vue.js +15 -7
  47. package/checkbox-group/vue.js +1 -0
  48. package/col/vue.js +1 -1
  49. package/collapse/index.js +3 -3
  50. package/color-select-panel/vue.js +0 -7
  51. package/column-list-item/index.js +17 -1
  52. package/column-list-item/vue.js +8 -3
  53. package/common/date.js +7 -5
  54. package/common/deps/clickoutside.js +6 -2
  55. package/common/deps/dom.js +19 -4
  56. package/common/deps/popper.js +44 -11
  57. package/common/deps/resize-event.js +1 -0
  58. package/common/deps/touch-emulator.js +4 -1
  59. package/common/deps/tree-model/node.js +2 -2
  60. package/common/deps/tree-model/tree-store.js +2 -13
  61. package/common/deps/useRect.js +25 -0
  62. package/common/deps/vue-popper.js +38 -20
  63. package/common/index.js +2 -2
  64. package/common/runtime.js +1 -1
  65. package/common/string.js +2 -2
  66. package/common/type.js +2 -1
  67. package/common/validate/rules/enum.js +1 -1
  68. package/common/validate/rules/pattern.js +2 -2
  69. package/common/validate/rules/range.js +8 -5
  70. package/common/validate/rules/required.js +1 -1
  71. package/common/validate/rules/type.js +5 -5
  72. package/common/validate/rules/whitespace.js +1 -1
  73. package/common/validate/util.js +15 -16
  74. package/common/validate/validations/integer.js +1 -1
  75. package/common/validate/validations/method.js +1 -1
  76. package/currency/index.js +74 -7
  77. package/currency/vue.js +21 -5
  78. package/date-panel/index.js +16 -0
  79. package/date-panel/vue.js +8 -2
  80. package/date-picker-mobile/index.js +12 -0
  81. package/date-picker-mobile/vue.js +7 -1
  82. package/date-range/vue.js +14 -6
  83. package/date-table/index.js +5 -0
  84. package/date-table/vue.js +3 -1
  85. package/dialog-box/index.js +46 -14
  86. package/dialog-box/vue.js +30 -7
  87. package/dialog-select/index.js +6 -3
  88. package/dialog-select/vue.js +8 -4
  89. package/drawer/index.js +27 -5
  90. package/drawer/vue.js +14 -7
  91. package/dropdown/index.js +7 -7
  92. package/dropdown/vue.js +6 -2
  93. package/dropdown-item/index.js +9 -1
  94. package/dropdown-item/mf.js +6 -10
  95. package/dropdown-item/vue.js +20 -7
  96. package/dropdown-menu/index.js +20 -7
  97. package/dropdown-menu/vue.js +4 -3
  98. package/exception/index.js +2 -7
  99. package/exception/vue.js +7 -10
  100. package/fall-menu/index.js +5 -1
  101. package/fall-menu/vue.js +13 -2
  102. package/file-upload/index.js +68 -18
  103. package/file-upload/vue.js +38 -8
  104. package/filter-box/index.js +1 -0
  105. package/float-button/index.js +42 -0
  106. package/float-button/vue.js +101 -0
  107. package/floating-button/index.js +62 -16
  108. package/floating-button/vue.js +27 -9
  109. package/flowchart/index.js +134 -25
  110. package/flowchart/node.js +13 -4
  111. package/flowchart/vue.js +16 -4
  112. package/form/vue.js +8 -0
  113. package/form-item/index.js +5 -5
  114. package/form-item/vue.js +3 -1
  115. package/fullscreen/index.js +5 -5
  116. package/fullscreen/vue.js +3 -3
  117. package/grid/plugins/export.js +5 -2
  118. package/grid/utils/column.js +1 -0
  119. package/grid/utils/dom.js +7 -1
  120. package/image/index.js +6 -1
  121. package/image/vue.js +6 -3
  122. package/image-viewer/index.js +62 -51
  123. package/image-viewer/vue.js +17 -5
  124. package/input/index.js +81 -20
  125. package/input/vue.js +44 -18
  126. package/ip-address/index.js +61 -19
  127. package/ip-address/vue.js +22 -4
  128. package/link/vue.js +3 -1
  129. package/loading/index.js +2 -2
  130. package/loading/vue.js +8 -2
  131. package/logout/index.js +1 -1
  132. package/menu/index.js +15 -2
  133. package/menu/vue.js +22 -17
  134. package/mind-map/index.js +47 -0
  135. package/mind-map/vue.js +53 -0
  136. package/modal/index.js +44 -4
  137. package/modal/vue.js +18 -4
  138. package/multi-select/index.js +186 -11
  139. package/multi-select/vue.js +60 -15
  140. package/multi-select-item/index.js +23 -0
  141. package/multi-select-item/vue.js +31 -0
  142. package/numeric/index.js +46 -12
  143. package/numeric/vue.js +44 -19
  144. package/option/index.js +27 -9
  145. package/option/vue.js +37 -21
  146. package/option-group/index.js +3 -3
  147. package/package.json +1 -1
  148. package/pager/index.js +18 -4
  149. package/pager/vue.js +16 -5
  150. package/picker/index.js +258 -49
  151. package/picker/mb.js +42 -0
  152. package/picker/vue.js +70 -17
  153. package/picker-column/index.js +1 -1
  154. package/pop-upload/vue.js +3 -0
  155. package/popconfirm/index.js +3 -6
  156. package/popconfirm/vue.js +1 -1
  157. package/popeditor/index.js +71 -32
  158. package/popeditor/vue.js +15 -11
  159. package/popover/index.js +4 -4
  160. package/popover/vue.js +6 -6
  161. package/popup/index.js +3 -3
  162. package/popup/vue.js +5 -5
  163. package/pull-refresh/index.js +13 -13
  164. package/pull-refresh/vue.js +5 -4
  165. package/radio/index.js +0 -17
  166. package/radio/vue.js +4 -10
  167. package/rate/index.js +1 -1
  168. package/rate/vue.js +0 -2
  169. package/record/index.js +4 -1
  170. package/rich-text/clipboard.js +54 -0
  171. package/rich-text/index.js +192 -0
  172. package/rich-text/module/file-upload.js +107 -0
  173. package/rich-text/module/image-drop.js +63 -0
  174. package/rich-text/module/image-upload.js +89 -0
  175. package/rich-text/options.js +141 -0
  176. package/rich-text/table-module.js +382 -0
  177. package/rich-text/vue.js +102 -0
  178. package/{rich-text-edtior → rich-text-editor}/index.js +2 -2
  179. package/{rich-text-edtior → rich-text-editor}/vue.js +2 -5
  180. package/scrollbar/index.js +11 -11
  181. package/scrollbar/vue-bar.js +3 -3
  182. package/scrollbar/vue.js +5 -5
  183. package/search/index.js +9 -9
  184. package/search/vue.js +8 -6
  185. package/select/index.js +457 -389
  186. package/select/vue.js +257 -161
  187. package/select-dropdown/index.js +61 -3
  188. package/select-dropdown/vue.js +85 -8
  189. package/select-view/index.js +3 -1
  190. package/selected-box/index.js +2 -0
  191. package/selected-box/vue.js +6 -3
  192. package/signature/index.js +241 -0
  193. package/signature/vue.js +88 -0
  194. package/skeleton/index.js +14 -0
  195. package/skeleton/vue.js +15 -0
  196. package/skeleton-item/vue.js +15 -0
  197. package/slider/index.js +70 -17
  198. package/slider/vue.js +16 -7
  199. package/split/index.js +5 -3
  200. package/split/vue.js +4 -6
  201. package/standard-list-item/index.js +15 -1
  202. package/standard-list-item/vue.js +6 -5
  203. package/steps/index.js +25 -2
  204. package/steps/slide-bar.js +8 -1
  205. package/steps/vue.js +15 -3
  206. package/tab-item-mf/vue.js +14 -8
  207. package/tab-nav/index.js +30 -5
  208. package/tab-nav/vue.js +16 -4
  209. package/tabbar/vue.js +9 -3
  210. package/tabbar-item/vue.js +3 -2
  211. package/tabs/index.js +16 -4
  212. package/tabs/vue.js +2 -1
  213. package/tabs-mf/index.js +20 -6
  214. package/tabs-mf/vue-nav.js +26 -11
  215. package/tabs-mf/vue.js +7 -7
  216. package/tabs-mf/wheel.js +1 -0
  217. package/tag/index.js +1 -1
  218. package/tag-group/index.js +2 -1
  219. package/time/index.js +5 -2
  220. package/time/vue.js +1 -1
  221. package/time-line/index.js +3 -3
  222. package/time-line/vue.js +2 -2
  223. package/time-picker-mobile/index.js +24 -5
  224. package/time-picker-mobile/vue.js +17 -7
  225. package/time-range/index.js +2 -0
  226. package/timeline-item/vue.js +1 -1
  227. package/tooltip/index.js +6 -3
  228. package/tooltip/vue.js +4 -4
  229. package/transfer/index.js +20 -22
  230. package/transfer/vue.js +1 -6
  231. package/transfer-panel/vue.js +3 -5
  232. package/tree/index.js +21 -4
  233. package/tree/vue.js +10 -8
  234. package/tree-menu/index.js +31 -5
  235. package/tree-menu/vue.js +28 -15
  236. package/tree-node/index.js +18 -18
  237. package/tree-node/vue.js +6 -5
  238. package/types/action-sheet.type.d.ts +118 -1
  239. package/types/alert.type.d.ts +1 -1
  240. package/types/amount.type.d.ts +168 -1
  241. package/types/area.type.d.ts +134 -1
  242. package/types/async-flowchart.type.d.ts +72 -0
  243. package/types/autocomplete.type.d.ts +199 -1
  244. package/types/badge.type.d.ts +3 -1
  245. package/types/breadcrumb-item.type.d.ts +2 -0
  246. package/types/breadcrumb.type.d.ts +2 -0
  247. package/types/button-group.type.d.ts +3 -3
  248. package/types/button.type.d.ts +4 -0
  249. package/types/cascader-menu.type.d.ts +3 -4
  250. package/types/cascader-node.type.d.ts +5 -2
  251. package/types/cascader-panel.type-2bd03be3.d.ts +241 -0
  252. package/types/cascader-panel.type.d.ts +3 -241
  253. package/types/cascader.type.d.ts +329 -1
  254. package/types/checkbox.type.d.ts +9 -3
  255. package/types/collapse.type.d.ts +20 -3
  256. package/types/date-picker.type.d.ts +37 -0
  257. package/types/dialog-box.type.d.ts +13 -3
  258. package/types/drawer.type.d.ts +133 -1
  259. package/types/{dropdown-item.type-8ea6c633.d.ts → dropdown-item.type-8475a549.d.ts} +7 -13
  260. package/types/dropdown-item.type.d.ts +1 -1
  261. package/types/dropdown-menu.type.d.ts +1 -1
  262. package/types/dropdown.type.d.ts +1 -5
  263. package/types/fall-menu.type.d.ts +94 -1
  264. package/types/file-upload.type.d.ts +1 -1
  265. package/types/float-button.type.d.ts +123 -0
  266. package/types/form-item.type.d.ts +1 -1
  267. package/types/{form.type-d0fd42f3.d.ts → form.type-222799ae.d.ts} +5 -2
  268. package/types/form.type.d.ts +1 -1
  269. package/types/{index-e0250f63.d.ts → index-b012f687.d.ts} +9 -0
  270. package/types/input.type.d.ts +1 -5
  271. package/types/ip-address.type.d.ts +160 -1
  272. package/types/link.type.d.ts +6 -3
  273. package/types/loading.type.d.ts +7 -0
  274. package/types/milestone.type.d.ts +1 -1
  275. package/types/mind-map.type.d.ts +20 -0
  276. package/types/modal.type.d.ts +29 -2
  277. package/types/numeric.type.d.ts +41 -10
  278. package/types/pager.type.d.ts +13 -1
  279. package/types/picker.type.d.ts +18 -0
  280. package/types/popconfirm.type.d.ts +86 -1
  281. package/types/popeditor.type.d.ts +5 -1
  282. package/types/popover.type.d.ts +3 -3
  283. package/types/progress.type.d.ts +3 -1
  284. package/types/radio.type.d.ts +0 -4
  285. package/types/rate.type.d.ts +236 -1
  286. package/types/search.type.d.ts +88 -1
  287. package/types/shared.type.d.ts +1 -1
  288. package/types/skeleton-item.type.d.ts +38 -0
  289. package/types/skeleton.type.d.ts +45 -0
  290. package/types/slider.type.d.ts +49 -10
  291. package/types/steps.type.d.ts +15 -4
  292. package/types/switch.type.d.ts +3 -3
  293. package/types/tab-bar.type.d.ts +1 -1
  294. package/types/tab-nav.type.d.ts +7 -2
  295. package/types/tabs.type.d.ts +9 -1
  296. package/types/tag-group.type.d.ts +64 -1
  297. package/types/{time-line.type-d7daa669.d.ts → time-line.type-b155cb4f.d.ts} +12 -0
  298. package/types/time-line.type.d.ts +1 -1
  299. package/types/timeline-item.type.d.ts +1 -1
  300. package/types/tooltip.type.d.ts +2 -2
  301. package/types/transfer.type.d.ts +185 -1
  302. package/types/tree-menu.type.d.ts +210 -1
  303. package/types/upload-dragger.type.d.ts +2 -2
  304. package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-a29aea50.d.ts} +31 -8
  305. package/types/upload-list.type.d.ts +1 -1
  306. package/types/upload.type.d.ts +1 -1
  307. package/types/user-head.type.d.ts +146 -1
  308. package/types/wizard.type.d.ts +1 -0
  309. package/upload/index.js +64 -34
  310. package/upload/vue.js +9 -5
  311. package/upload-dragger/index.js +22 -20
  312. package/upload-list/index.js +24 -18
  313. package/upload-list/vue.js +9 -4
  314. package/user/index.js +34 -25
  315. package/user/vue.js +1 -1
  316. package/user-head/index.js +3 -3
  317. package/watermark/index.js +11 -0
  318. package/wheel/index.js +3 -0
  319. package/wizard/vue.js +4 -2
  320. package/common/deps/modal-queue.js +0 -6
  321. package/common/deps/requestAnimationFrame.js +0 -25
@@ -1,6 +1,13 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
- import { comptCheckPath, handleExpand, isInPath, handleCheckChange, handleMultiCheckChange } from "./index";
3
- const api = ["state", "handleMultiCheckChange", "handleCheckChange", "handleExpand"];
2
+ import {
3
+ comptCheckPath,
4
+ handleExpand,
5
+ isInPath,
6
+ handleCheckChange,
7
+ handleMultiCheckChange,
8
+ handleNodeClick
9
+ } from "./index";
10
+ const api = ["state", "handleMultiCheckChange", "handleCheckChange", "handleExpand", "handleNodeClick"];
4
11
  const renderless = (props, { computed, reactive, inject }, { dispatch }) => {
5
12
  const parent = inject("panel");
6
13
  const api2 = {};
@@ -12,7 +19,10 @@ const renderless = (props, { computed, reactive, inject }, { dispatch }) => {
12
19
  isChecked: computed(() => props.node.isSameNode(state.checkedValue)),
13
20
  inActivePath: computed(() => api2.isInPath(parent.state.activePath)),
14
21
  inCheckedPath: computed(() => api2.comptCheckPath()),
15
- value: computed(() => props.node.getValueByOption())
22
+ value: computed(() => props.node.getValueByOption()),
23
+ nodeLabel: computed(() => {
24
+ return parent.state.renderLabelFn ? parent.state.renderLabelFn({ node: props.node, data: props.node.data }) : props.node.label;
25
+ })
16
26
  });
17
27
  Object.assign(api2, {
18
28
  state,
@@ -20,7 +30,8 @@ const renderless = (props, { computed, reactive, inject }, { dispatch }) => {
20
30
  handleExpand: handleExpand({ api: api2, props, parent, state }),
21
31
  comptCheckPath: comptCheckPath({ api: api2, parent, state }),
22
32
  handleCheckChange: handleCheckChange({ api: api2, parent, dispatch, state }),
23
- handleMultiCheckChange: handleMultiCheckChange({ parent, props })
33
+ handleMultiCheckChange: handleMultiCheckChange({ parent, props }),
34
+ handleNodeClick: handleNodeClick({ state, api: api2 })
24
35
  });
25
36
  return api2;
26
37
  };
@@ -223,7 +223,7 @@ const getCheckedNodes = ({ api, state }) => (leafOnly, cascaderCheckedValue) =>
223
223
  const nodes = api.getFlattedNodes(leafOnly);
224
224
  return nodes.filter((node2) => node2.checked && isCascaderChecked(node2.value, cascaderCheckedValue));
225
225
  }
226
- const node = api.getNodeByValue(state.checkedValue);
226
+ const node = api.getNodeByValue(cascaderCheckedValue || state.checkedValue);
227
227
  return isEmpty(state.checkedValue) || !node ? [] : [node];
228
228
  };
229
229
  const clearCheckedNodes = ({ api, state }) => () => {
@@ -0,0 +1,150 @@
1
+ import "../chunk-G2ADBYYC.js";
2
+ const DEFAULT_DURATION = 200;
3
+ const INERTIA_TIME = 300;
4
+ const INERTIA_DISTANCE = 15;
5
+ const preventDefault = (event, isStopPropagation) => {
6
+ if (typeof event.cancelable !== "boolean" || event.cancelable) {
7
+ event.preventDefault();
8
+ }
9
+ if (isStopPropagation) {
10
+ event.stopPropagation();
11
+ }
12
+ };
13
+ const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
14
+ const pxCheck = (value) => {
15
+ return isNaN(Number(value)) ? String(value) : `${value}px`;
16
+ };
17
+ const stopMomentum = ({ state, api }) => () => {
18
+ state.moving = false;
19
+ state.touchTime = 0;
20
+ api.setChooseValue();
21
+ };
22
+ const setRollerStyle = ({ state }) => (index) => {
23
+ return `transform: rotate3d(1, 0, 0, ${-state.rotation * index}deg) translate3d(0px, 0px, 104px)`;
24
+ };
25
+ const onTouchStart = ({ state, props, touch, vm }) => (event) => {
26
+ touch.start(event);
27
+ if (state.moving) {
28
+ const dom = vm.$refs.roller;
29
+ const { transform } = window.getComputedStyle(dom);
30
+ if (props.threeDimensional) {
31
+ const circle = Math.floor(parseInt(state.touchDeg) / 360);
32
+ const cos = +transform.split(", ")[5];
33
+ const sin = +transform.split(", ")[6] < 0 ? 180 : 0;
34
+ const endDeg = circle * 360 + Math.acos(cos) / Math.PI * 180 + sin;
35
+ state.scrollDistance = -Math.abs((endDeg / state.rotation - 1) * +props.optionHeight);
36
+ } else {
37
+ state.scrollDistance = +transform.slice(7, transform.length - 1).split(", ")[5];
38
+ }
39
+ }
40
+ preventDefault(event, true);
41
+ state.touchParams.startY = touch.deltaY.value;
42
+ state.touchParams.startTime = Date.now();
43
+ state.transformY = state.scrollDistance;
44
+ };
45
+ const onTouchMove = ({ state, api, touch }) => (event) => {
46
+ touch.move(event);
47
+ if (touch.isVertical()) {
48
+ state.moving = true;
49
+ preventDefault(event, true);
50
+ }
51
+ state.touchParams.lastY = touch.deltaY.value;
52
+ let move = state.touchParams.lastY - state.touchParams.startY;
53
+ api.setMove(move);
54
+ };
55
+ const onTouchEnd = ({ state, props, api, touch }) => () => {
56
+ state.touchParams.lastY = touch.deltaY.value;
57
+ state.touchParams.lastTime = Date.now();
58
+ let move = state.touchParams.lastY - state.touchParams.startY;
59
+ let moveTime = state.touchParams.lastTime - state.touchParams.startTime;
60
+ if (moveTime <= INERTIA_TIME && Math.abs(move) > INERTIA_DISTANCE) {
61
+ const distance = api.momentum(move, moveTime);
62
+ api.setMove(distance, "end", +props.swipeDuration);
63
+ return;
64
+ } else {
65
+ api.setMove(move, "end");
66
+ }
67
+ setTimeout(() => {
68
+ touch.reset();
69
+ state.moving = false;
70
+ }, 0);
71
+ };
72
+ const momentum = (distance, duration) => {
73
+ const speed = Math.abs(distance / duration);
74
+ distance = speed / 3e-3 * (distance < 0 ? -1 : 1);
75
+ return distance;
76
+ };
77
+ const isHidden = ({ state }) => (index) => {
78
+ if (index >= state.currIndex + 8 || index <= state.currIndex - 8) {
79
+ return true;
80
+ } else {
81
+ return false;
82
+ }
83
+ };
84
+ const setTransform = ({ state }) => (type, deg, translateY = 0, time = DEFAULT_DURATION) => {
85
+ if (type === "end") {
86
+ state.touchTime = time;
87
+ } else {
88
+ state.touchTime = 0;
89
+ }
90
+ state.touchDeg = deg;
91
+ state.scrollDistance = translateY;
92
+ };
93
+ const setMove = ({ state, props, api }) => (move, type, time) => {
94
+ const { optionHeight } = props;
95
+ let updateMove = move + state.transformY;
96
+ if (type === "end") {
97
+ if (updateMove > 0) {
98
+ updateMove = 0;
99
+ }
100
+ if (updateMove < -(props.column.length - 1) * +optionHeight) {
101
+ updateMove = -(props.column.length - 1) * +optionHeight;
102
+ }
103
+ let endMove = Math.round(updateMove / +optionHeight) * +optionHeight;
104
+ let deg = `${(Math.abs(Math.round(endMove / +optionHeight)) + 1) * state.rotation}deg`;
105
+ api.setTransform(type, deg, endMove, time);
106
+ state.currIndex = Math.abs(Math.round(endMove / +optionHeight)) + 1;
107
+ } else {
108
+ let deg = 0;
109
+ let currentDeg = (-updateMove / +optionHeight + 1) * state.rotation;
110
+ const maxDeg = (props.column.length + 1) * state.rotation;
111
+ const minDeg = 0;
112
+ deg = clamp(currentDeg, minDeg, maxDeg);
113
+ if (minDeg < deg && deg < maxDeg) {
114
+ api.setTransform(null, deg + "deg", updateMove, void 0);
115
+ state.currIndex = Math.abs(Math.round(updateMove / +optionHeight)) + 1;
116
+ }
117
+ }
118
+ };
119
+ const setChooseValue = ({ props, state, emit }) => () => {
120
+ emit("change", props.column[state.currIndex - 1]);
121
+ };
122
+ const modifyStatus = ({ state, props, api }) => (type) => {
123
+ const { column } = props;
124
+ let index = column.findIndex((columnItem) => columnItem[props.fieldNames.value] === props.value);
125
+ state.currIndex = index === -1 ? 1 : index + 1;
126
+ let move = index === -1 ? 0 : index * +props.optionHeight;
127
+ type && api.setChooseValue();
128
+ api.setMove(-move);
129
+ };
130
+ const OptionStyle = ({ state }) => (option, column, offset) => {
131
+ const currentIndex = state.currIndex - 1;
132
+ return option === column[currentIndex + offset] || option === column[currentIndex - offset];
133
+ };
134
+ export {
135
+ OptionStyle,
136
+ clamp,
137
+ isHidden,
138
+ modifyStatus,
139
+ momentum,
140
+ onTouchEnd,
141
+ onTouchMove,
142
+ onTouchStart,
143
+ preventDefault,
144
+ pxCheck,
145
+ setChooseValue,
146
+ setMove,
147
+ setRollerStyle,
148
+ setTransform,
149
+ stopMomentum
150
+ };
@@ -0,0 +1,120 @@
1
+ import "../chunk-G2ADBYYC.js";
2
+ import {
3
+ pxCheck,
4
+ stopMomentum,
5
+ setRollerStyle,
6
+ onTouchStart,
7
+ onTouchMove,
8
+ onTouchEnd,
9
+ momentum,
10
+ isHidden,
11
+ setTransform,
12
+ setMove,
13
+ setChooseValue,
14
+ modifyStatus,
15
+ OptionStyle
16
+ } from "./column-index";
17
+ import { useTouch } from "./useTouch";
18
+ const api = [
19
+ "state",
20
+ "touch",
21
+ "OptionStyle",
22
+ "setRollerStyle",
23
+ "isHidden",
24
+ "onTouchStart",
25
+ "onTouchMove",
26
+ "onTouchEnd",
27
+ "setMove",
28
+ "stopMomentum",
29
+ "pxCheck"
30
+ ];
31
+ const renderless = (props, { reactive, computed, watch, ref, onMounted }, { emit, vm }) => {
32
+ const touch = useTouch({ ref });
33
+ const state = reactive({
34
+ touchParams: {
35
+ startY: 0,
36
+ endY: 0,
37
+ startTime: 0,
38
+ endTime: 0,
39
+ lastY: 0,
40
+ lastTime: 0
41
+ },
42
+ currIndex: 1,
43
+ transformY: 0,
44
+ scrollDistance: 0,
45
+ rotation: 20,
46
+ moving: false,
47
+ touchDeg: 0,
48
+ touchTime: 0,
49
+ currentValue: computed(() => props.column[state.currIndex - 1][props.fieldNames.value]),
50
+ touchTileStyle: computed(() => {
51
+ const { optionHeight } = props;
52
+ return {
53
+ transition: `transform ${state.touchTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
54
+ transform: `translate3d(0, ${state.scrollDistance}px, 0)`,
55
+ top: `calc(50% - ${+optionHeight / 2}px)`,
56
+ height: `${optionHeight}px`
57
+ };
58
+ }),
59
+ touchRollerStyle: computed(() => {
60
+ return {
61
+ transition: `transform ${state.touchTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
62
+ transform: `rotate3d(1, 0, 0, ${state.touchDeg})`,
63
+ top: `calc(50% - ${+props.optionHeight / 2}px)`
64
+ };
65
+ }),
66
+ maskStyles: computed(() => {
67
+ return {
68
+ backgroundSize: `100% ${(+props.visibleOptionNum - 1) * +props.optionHeight / 2}px`
69
+ };
70
+ })
71
+ });
72
+ const api2 = {};
73
+ Object.assign(api2, {
74
+ state,
75
+ touch,
76
+ OptionStyle: OptionStyle({ state }),
77
+ setRollerStyle: setRollerStyle({ state }),
78
+ isHidden: isHidden({ state }),
79
+ onTouchStart: onTouchStart({ state, props, touch, vm }),
80
+ onTouchMove: onTouchMove({ state, api: api2, touch }),
81
+ onTouchEnd: onTouchEnd({ state, props, api: api2, touch }),
82
+ setMove: setMove({ state, props, api: api2 }),
83
+ stopMomentum: stopMomentum({ state, api: api2 }),
84
+ setTransform: setTransform({ state }),
85
+ setChooseValue: setChooseValue({ props, state, emit }),
86
+ modifyStatus: modifyStatus({ state, props, api: api2 }),
87
+ pxCheck,
88
+ momentum
89
+ });
90
+ watch(
91
+ () => props.column,
92
+ () => {
93
+ if (props.column && props.column.length > 0) {
94
+ state.transformY = 0;
95
+ api2.modifyStatus(false);
96
+ }
97
+ },
98
+ {
99
+ deep: true
100
+ }
101
+ );
102
+ watch(
103
+ () => props.value,
104
+ () => {
105
+ state.transformY = 0;
106
+ api2.modifyStatus(false);
107
+ },
108
+ {
109
+ deep: true
110
+ }
111
+ );
112
+ onMounted(() => {
113
+ api2.modifyStatus(false);
114
+ });
115
+ return api2;
116
+ };
117
+ export {
118
+ api,
119
+ renderless
120
+ };
@@ -1,179 +1,43 @@
1
- import {
2
- __spreadProps,
3
- __spreadValues
4
- } from "../chunk-G2ADBYYC.js";
5
- const normalRange = (value, min, max) => value < min ? min : value > max ? max : value;
6
- const sliceValue = (value, min, max, count, cycleRoll) => {
7
- value = normalRange(value, min, max);
8
- const values = [value];
9
- const tmpArr = Array.from({ length: rightShift(count) });
10
- const prev = () => cycleRoll ? tVal + max - min + 1 : null;
11
- const next = () => cycleRoll ? tVal - max + min - 1 : null;
12
- let tVal;
13
- tmpArr.map((v, i) => values.unshift((tVal = value - i - 1) < min ? prev() : tVal));
14
- tmpArr.map((v, i) => values.push((tVal = value + i + 1) > max ? next() : tVal));
15
- return values;
16
- };
17
- const validArr = (arr) => Array.isArray(arr) && arr.length;
18
- const validProps = (props) => {
19
- const { modelValue, options } = props;
20
- return validArr(modelValue) && validArr(options) && modelValue.length === options.length;
21
- };
22
- const rightShift = (count) => count >>> 1;
23
- const getFont = (pos, count) => Math.abs(rightShift(count) + 1 - pos);
24
- const parseType = (props) => (values) => {
25
- const { valueType } = props;
26
- return values.map(valueType === "number" ? Number : valueType === "string" ? String : (i) => i);
27
- };
28
- const init = ({ api, props, state }) => (valuesCopy) => {
29
- if (!validProps(props))
30
- return;
31
- const { modelValue, options, cycleRoll, valueField, textField } = props;
32
- const { visibleOptionCount } = state;
33
- let { disabled } = props;
34
- disabled = typeof disabled === "function" ? disabled : () => false;
35
- const values = api.parseType(valuesCopy || modelValue.slice(0));
36
- const types = Array.from({ length: values.length });
37
- const ranges = Array.from({ length: values.length });
38
- const indices = Array.from({ length: values.length });
39
- const visibleOptions = options.map((opt, i) => {
40
- let slicedValues, existOption;
41
- if (Array.isArray(opt)) {
42
- if (opt.length === 0)
43
- return [];
44
- let index = opt.findIndex((item) => item[valueField] === values[i]);
45
- index = index === -1 ? 0 : index;
46
- types[i] = "a";
47
- ranges[i] = [0, opt.length - 1];
48
- indices[i] = index;
49
- slicedValues = sliceValue(index, 0, opt.length - 1, visibleOptionCount, cycleRoll);
50
- existOption = (i2) => __spreadProps(__spreadValues({}, opt[i2]), { disabled: disabled(opt[i2][valueField], ...values) });
51
- } else if (opt && typeof opt === "object") {
52
- let range;
53
- if (Array.isArray(opt.range)) {
54
- range = opt.range.slice(0, 2);
55
- } else if (typeof opt.rangeMethod === "function") {
56
- range = opt.rangeMethod(...values);
57
- }
58
- types[i] = "o";
59
- ranges[i] = api.parseType(range);
60
- slicedValues = sliceValue(values[i], ranges[i][0], ranges[i][1], visibleOptionCount, cycleRoll);
61
- existOption = (i2) => opt.optionMethod(i2, ...values);
62
- }
63
- if (!slicedValues || !existOption)
64
- return [];
65
- return slicedValues.map((slicedValue, i2) => {
66
- const option = slicedValue === null ? { [valueField]: null, [textField]: "" } : existOption(slicedValue);
67
- option._$font = getFont(i2 + 1, visibleOptionCount);
68
- option._$status = option.disabled ? "disabled" : option._$font === 0 ? "focus" : "normal";
69
- return option;
70
- });
71
- });
72
- state.selectorCount = values.length;
73
- values.map((value, i) => {
74
- const index = indices[i];
75
- const opts = options[i];
76
- const vOpts = visibleOptions[i];
77
- state[`selector${i}`] = { index, options: opts, ranges, types, value, values, visibleOptions: vOpts };
78
- });
79
- };
80
- const calcSelector = (api) => (cycleRoll, dy, pos, selector, valueField) => {
81
- const { index, options, ranges, types, value, values } = selector;
82
- const valuesCopy = values.slice(0);
83
- const sRange = ranges[pos];
84
- const sType = types[pos];
85
- let sVal = sType === "o" ? value : sType === "a" ? index : null;
86
- const f = (arr) => arr[0];
87
- const l = (arr) => arr[arr.length - 1];
88
- const noop = () => sVal;
89
- const prev = () => cycleRoll && sVal === f(sRange) ? l(sRange) : sVal - 1;
90
- const next = () => cycleRoll && sVal === l(sRange) ? f(sRange) : sVal + 1;
91
- sVal = dy > 0 ? prev() : dy < 0 ? next() : noop();
92
- sVal = normalRange(sVal, ...sRange);
93
- if (sType === "a") {
94
- sVal = options[sVal][valueField];
95
- }
96
- if (sVal !== value) {
97
- valuesCopy.splice(pos, 1, sVal);
98
- api.init(valuesCopy);
99
- }
100
- };
101
- const handleTouchstart = (state) => (e) => {
102
- const { clientY } = e.changedTouches[0];
103
- state.touching = true;
104
- state.touchStartPos = state.touchPos = { clientY };
105
- state.accrueDy = 0;
106
- };
107
- const handleTouchend = (state) => () => {
108
- state.touching = false;
109
- state.touchStartPos = state.touchPos = {};
110
- state.accrueDy = 0;
111
- };
112
- const handleTouchmove = ({ api, props, state }) => (e, pos) => {
113
- if (!state.touching)
114
- return;
115
- const { cycleRoll, valueField } = props;
116
- const { touchPos, optionHeight } = state;
117
- const { clientY } = e.changedTouches[0];
118
- const dy = clientY - touchPos.clientY;
119
- state.touchPos = { clientY };
120
- state.accrueDy += dy;
121
- const absDy = Math.abs(state.accrueDy);
122
- const threshold = optionHeight / 4;
123
- if (absDy > threshold) {
124
- const selector = state[`selector${pos}`];
125
- api.calcSelector(cycleRoll, state.accrueDy, pos, selector, valueField);
126
- state.accrueDy = 0;
127
- }
128
- };
129
- const watchActionSheetVisible = ({ emit, state, vm }) => (visible) => {
1
+ import "../chunk-G2ADBYYC.js";
2
+ const watchActionSheetVisible = ({ emit, api, props }) => (visible) => {
130
3
  emit("update:visible", visible);
131
4
  if (!visible)
132
5
  return;
133
- setTimeout(() => {
134
- const optionRef = vm.$el.querySelector('[data-tag="tiny-mobile-cs-option"]');
135
- optionRef && (state.optionHeight = optionRef.offsetHeight);
136
- });
6
+ api.setValue(props.modelValue);
137
7
  };
138
8
  const close = (state) => () => state.actionSheetVisible && (state.actionSheetVisible = false);
139
- const confirm = ({ api, emit, props, state, vm }) => () => {
140
- const { confirmDisabled } = state;
141
- if (confirmDisabled)
9
+ const confirm = ({ api, emit, defaultValues, selectedOptions, isDisabled, vm }) => () => {
10
+ if (isDisabled.value)
142
11
  return;
143
- const { modelValue } = props;
144
- let focusOpts = vm.$el.querySelectorAll('[date-status="focus"]');
145
- let values;
146
- if (focusOpts && focusOpts.length) {
147
- focusOpts = [...focusOpts];
148
- values = focusOpts.map((focusOpt) => focusOpt.dataset.option);
149
- values = api.parseType(values);
150
- }
151
- if (validArr(values) && validArr(modelValue) && values.length === modelValue.length && values.join() !== modelValue.join()) {
152
- emit("update:modelValue", values);
12
+ let refs = vm.$refs.swipeRef;
13
+ let moving = false;
14
+ if (!Array.isArray(vm.$refs.swipeRef)) {
15
+ refs = [refs];
153
16
  }
154
- api.close();
155
- };
156
- const styleOpt = (option) => option._$font;
157
- const statusOpt = (option) => option._$status;
158
- const computedConfirmDisabled = (state) => () => {
159
- const { selectorCount, visibleOptionCount } = state;
160
- const interOpts = Array.from({ length: selectorCount }).map((v, i) => {
161
- const vOpts = state[`selector${i}`].visibleOptions;
162
- return vOpts[rightShift(visibleOptionCount)];
17
+ defaultValues.value = refs.map((comp) => {
18
+ if (comp.state.moving) {
19
+ moving = true;
20
+ }
21
+ return comp.state.currentValue;
163
22
  });
164
- return interOpts.some((opt) => opt.disabled);
23
+ if (moving)
24
+ return;
25
+ emit("confirm", {
26
+ selectedValue: defaultValues.value.slice(),
27
+ selectedOptions: selectedOptions.value.slice()
28
+ });
29
+ emit("update:modelValue", defaultValues.value.slice());
30
+ api.close();
165
31
  };
32
+ const columnStyle = ({ props, computed }) => computed(() => {
33
+ return {
34
+ height: `${+props.visibleOptionNum * +props.optionHeight}px`,
35
+ "--lineHeight": `${+props.optionHeight}px`
36
+ };
37
+ });
166
38
  export {
167
- calcSelector,
168
39
  close,
169
- computedConfirmDisabled,
40
+ columnStyle,
170
41
  confirm,
171
- handleTouchend,
172
- handleTouchmove,
173
- handleTouchstart,
174
- init,
175
- parseType,
176
- statusOpt,
177
- styleOpt,
178
42
  watchActionSheetVisible
179
43
  };