@opentiny/vue-renderless 3.12.0 → 3.13.0-alpha.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 (298) hide show
  1. package/action-sheet/index.js +20 -13
  2. package/action-sheet/vue.js +8 -7
  3. package/alert/index.js +50 -1
  4. package/alert/vue.js +36 -9
  5. package/amount/index.js +100 -25
  6. package/amount/vue.js +102 -26
  7. package/anchor/index.js +1 -0
  8. package/area/index.js +8 -8
  9. package/area/vue.js +5 -5
  10. package/async-flowchart/index.js +16 -3
  11. package/autocomplete/index.js +58 -14
  12. package/autocomplete/vue.js +40 -12
  13. package/badge/index.js +12 -0
  14. package/badge/vue.js +6 -4
  15. package/breadcrumb/vue.js +3 -1
  16. package/breadcrumb-item/vue.js +6 -2
  17. package/button/index.js +5 -1
  18. package/calendar/index.js +2 -86
  19. package/calendar-bar/index.js +20 -6
  20. package/calendar-view/index.js +10 -12
  21. package/calendar-view/vue.js +17 -4
  22. package/cascader/index.js +80 -34
  23. package/cascader/vue.js +49 -19
  24. package/cascader-menu/index.js +7 -7
  25. package/cascader-menu/vue.js +2 -3
  26. package/cascader-mobile/index.js +37 -24
  27. package/cascader-mobile/vue.js +7 -1
  28. package/cascader-node/index.js +13 -1
  29. package/cascader-node/vue.js +15 -4
  30. package/cascader-panel/index.js +1 -1
  31. package/cascader-select/column-index.js +150 -0
  32. package/cascader-select/column.js +120 -0
  33. package/cascader-select/index.js +29 -165
  34. package/cascader-select/usePicker.js +251 -0
  35. package/cascader-select/useTouch.js +65 -0
  36. package/cascader-select/vue.js +35 -47
  37. package/cascader-view/index.js +1 -1
  38. package/cell/vue.js +2 -1
  39. package/chart-bar/index.js +2 -3
  40. package/chart-core/deps/constants.js +43 -43
  41. package/chart-core/index.js +1 -1
  42. package/chart-gauge/index.js +2 -2
  43. package/chart-heatmap/index.js +17 -10
  44. package/chart-line/index.js +8 -9
  45. package/chart-tree/index.js +2 -2
  46. package/chart-waterfall/index.js +4 -6
  47. package/checkbox/index.js +17 -0
  48. package/checkbox/vue.js +16 -7
  49. package/checkbox-group/vue.js +2 -0
  50. package/col/index.js +7 -2
  51. package/col/vue.js +1 -1
  52. package/collapse/index.js +3 -3
  53. package/color-select-panel/vue.js +0 -7
  54. package/column-list-item/index.js +17 -1
  55. package/column-list-item/vue.js +8 -3
  56. package/common/date.js +2 -0
  57. package/common/deps/dom.js +19 -4
  58. package/common/deps/popper.js +48 -5
  59. package/common/deps/touch-emulator.js +4 -1
  60. package/common/deps/tree-model/node.js +1 -1
  61. package/common/deps/tree-model/tree-store.js +2 -13
  62. package/common/deps/useRect.js +25 -0
  63. package/common/deps/vue-popper.js +22 -10
  64. package/common/index.js +1 -1
  65. package/common/runtime.js +1 -1
  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/container/index.js +17 -1
  77. package/container/vue.js +12 -3
  78. package/currency/index.js +74 -7
  79. package/currency/vue.js +21 -5
  80. package/date-panel/index.js +16 -0
  81. package/date-panel/vue.js +8 -2
  82. package/date-picker-mobile/index.js +12 -0
  83. package/date-picker-mobile/vue.js +7 -1
  84. package/date-range/vue.js +12 -5
  85. package/date-table/index.js +5 -0
  86. package/date-table/vue.js +3 -1
  87. package/dialog-box/index.js +17 -6
  88. package/dialog-select/index.js +6 -3
  89. package/dialog-select/vue.js +8 -4
  90. package/drawer/index.js +26 -5
  91. package/drawer/vue.js +13 -7
  92. package/dropdown/index.js +7 -7
  93. package/dropdown/vue.js +6 -2
  94. package/dropdown-item/index.js +9 -1
  95. package/dropdown-item/mf.js +6 -10
  96. package/dropdown-item/vue.js +21 -8
  97. package/dropdown-menu/index.js +20 -7
  98. package/dropdown-menu/vue.js +4 -3
  99. package/exception/index.js +2 -7
  100. package/exception/vue.js +7 -10
  101. package/fall-menu/index.js +5 -1
  102. package/fall-menu/vue.js +13 -2
  103. package/file-upload/index.js +47 -12
  104. package/file-upload/vue.js +38 -8
  105. package/filter-box/index.js +1 -0
  106. package/floating-button/index.js +62 -16
  107. package/floating-button/vue.js +27 -9
  108. package/flowchart/index.js +134 -25
  109. package/flowchart/node.js +13 -4
  110. package/flowchart/vue.js +16 -4
  111. package/form/vue.js +3 -1
  112. package/form-item/index.js +4 -4
  113. package/form-item/vue.js +3 -1
  114. package/fullscreen/index.js +5 -5
  115. package/fullscreen/vue.js +3 -3
  116. package/grid/utils/common.js +10 -5
  117. package/grid/utils/dom.js +7 -1
  118. package/image/index.js +6 -0
  119. package/image/vue.js +6 -3
  120. package/image-viewer/index.js +62 -51
  121. package/image-viewer/vue.js +17 -5
  122. package/input/index.js +89 -22
  123. package/input/vue.js +52 -21
  124. package/ip-address/index.js +61 -19
  125. package/ip-address/vue.js +22 -4
  126. package/label/index.js +56 -0
  127. package/label/vue.js +26 -0
  128. package/link/vue.js +3 -1
  129. package/loading/vue.js +8 -2
  130. package/logout/index.js +1 -1
  131. package/mask/index.js +13 -0
  132. package/mask/vue.js +18 -0
  133. package/mind-map/index.js +47 -0
  134. package/mind-map/vue.js +53 -0
  135. package/multi-select/index.js +150 -10
  136. package/multi-select/vue.js +46 -11
  137. package/multi-select-item/index.js +17 -0
  138. package/multi-select-item/vue.js +31 -0
  139. package/numeric/index.js +51 -9
  140. package/numeric/vue.js +44 -14
  141. package/option/index.js +12 -5
  142. package/option/vue.js +15 -7
  143. package/option-group/index.js +3 -3
  144. package/package.json +1 -1
  145. package/pager/index.js +372 -0
  146. package/pager/vue.js +125 -2
  147. package/picker/index.js +253 -48
  148. package/picker/mb.js +42 -0
  149. package/picker/vue.js +70 -17
  150. package/picker-column/index.js +1 -1
  151. package/pop-upload/index.js +0 -2
  152. package/pop-upload/vue.js +3 -4
  153. package/popconfirm/index.js +3 -6
  154. package/popconfirm/vue.js +1 -1
  155. package/popeditor/index.js +55 -24
  156. package/popeditor/vue.js +15 -11
  157. package/popover/index.js +4 -4
  158. package/popover/vue.js +6 -6
  159. package/popup/index.js +3 -3
  160. package/popup/vue.js +5 -5
  161. package/pull-refresh/index.js +57 -65
  162. package/pull-refresh/vue.js +23 -7
  163. package/radio/index.js +0 -17
  164. package/radio/vue.js +4 -10
  165. package/rate/index.js +1 -1
  166. package/rate/vue.js +0 -2
  167. package/record/index.js +4 -1
  168. package/{rich-text-edtior → rich-text-editor}/index.js +2 -2
  169. package/{rich-text-edtior → rich-text-editor}/vue.js +2 -5
  170. package/scrollbar/index.js +11 -11
  171. package/scrollbar/vue-bar.js +3 -3
  172. package/scrollbar/vue.js +5 -5
  173. package/search/index.js +1 -1
  174. package/search/vue.js +3 -1
  175. package/select/index.js +185 -113
  176. package/select/vue.js +105 -20
  177. package/select-dropdown/index.js +62 -4
  178. package/select-dropdown/vue.js +85 -8
  179. package/select-view/index.js +3 -1
  180. package/signature/index.js +241 -0
  181. package/signature/vue.js +88 -0
  182. package/skeleton/index.js +14 -0
  183. package/skeleton/vue.js +15 -0
  184. package/skeleton-item/vue.js +15 -0
  185. package/slider/index.js +27 -7
  186. package/slider/vue.js +26 -7
  187. package/split/index.js +1 -1
  188. package/split/vue.js +4 -6
  189. package/standard-list-item/index.js +15 -1
  190. package/standard-list-item/vue.js +6 -5
  191. package/steps/index.js +25 -2
  192. package/steps/slide-bar.js +8 -1
  193. package/steps/vue.js +15 -3
  194. package/tab-item-mf/vue.js +14 -8
  195. package/tab-nav/index.js +9 -4
  196. package/tab-nav/vue.js +6 -2
  197. package/tabbar/vue.js +9 -3
  198. package/tabbar-item/vue.js +3 -2
  199. package/tabs/index.js +1 -1
  200. package/tabs/vue.js +1 -0
  201. package/tabs-mf/index.js +20 -6
  202. package/tabs-mf/vue-nav.js +26 -11
  203. package/tabs-mf/vue.js +7 -7
  204. package/tag/index.js +1 -1
  205. package/tag/vue.js +5 -1
  206. package/tag-group/index.js +2 -1
  207. package/tall-storage/index.js +4 -5
  208. package/time/index.js +4 -1
  209. package/time/vue.js +1 -1
  210. package/time-line/vue.js +1 -1
  211. package/time-picker-mobile/index.js +24 -5
  212. package/time-picker-mobile/vue.js +17 -7
  213. package/time-range/index.js +2 -0
  214. package/time-spinner/index.js +0 -3
  215. package/time-spinner/vue.js +2 -3
  216. package/timeline-item/vue.js +1 -1
  217. package/tooltip/index.js +1 -2
  218. package/tooltip/vue.js +3 -3
  219. package/transfer/index.js +20 -22
  220. package/transfer/vue.js +1 -6
  221. package/transfer-panel/vue.js +3 -5
  222. package/tree/index.js +21 -4
  223. package/tree/vue.js +10 -8
  224. package/tree-menu/index.js +27 -3
  225. package/tree-menu/vue.js +27 -14
  226. package/tree-node/index.js +12 -10
  227. package/tree-node/vue.js +6 -5
  228. package/types/action-menu.type.d.ts +5 -0
  229. package/types/action-sheet.type.d.ts +118 -1
  230. package/types/alert.type.d.ts +16 -1
  231. package/types/amount.type.d.ts +168 -1
  232. package/types/area.type.d.ts +134 -1
  233. package/types/async-flowchart.type.d.ts +72 -0
  234. package/types/autocomplete.type.d.ts +199 -1
  235. package/types/badge.type.d.ts +3 -1
  236. package/types/breadcrumb-item.type.d.ts +2 -0
  237. package/types/breadcrumb.type.d.ts +2 -0
  238. package/types/button.type.d.ts +5 -0
  239. package/types/cascader-menu.type.d.ts +3 -4
  240. package/types/cascader-node.type.d.ts +5 -2
  241. package/types/cascader-panel.type-2bd03be3.d.ts +241 -0
  242. package/types/cascader-panel.type.d.ts +3 -241
  243. package/types/cascader.type.d.ts +327 -1
  244. package/types/checkbox.type.d.ts +9 -0
  245. package/types/collapse.type.d.ts +19 -2
  246. package/types/date-picker.type.d.ts +33 -0
  247. package/types/dialog-box.type.d.ts +5 -1
  248. package/types/drawer.type.d.ts +132 -1
  249. package/types/{dropdown-item.type-bf83e929.d.ts → dropdown-item.type-8475a549.d.ts} +8 -14
  250. package/types/dropdown-item.type.d.ts +1 -1
  251. package/types/dropdown-menu.type.d.ts +1 -1
  252. package/types/dropdown.type.d.ts +2 -5
  253. package/types/fall-menu.type.d.ts +94 -1
  254. package/types/file-upload.type.d.ts +1 -1
  255. package/types/form-item.type.d.ts +1 -1
  256. package/types/{form.type-d0fd42f3.d.ts → form.type-d88482e4.d.ts} +3 -0
  257. package/types/form.type.d.ts +1 -1
  258. package/types/input.type.d.ts +23 -9
  259. package/types/ip-address.type.d.ts +160 -1
  260. package/types/label.type.d.ts +81 -0
  261. package/types/link.type.d.ts +6 -3
  262. package/types/mind-map.type.d.ts +20 -0
  263. package/types/modal.type.d.ts +4 -2
  264. package/types/numeric.type.d.ts +36 -9
  265. package/types/pager.type.d.ts +171 -1
  266. package/types/picker.type.d.ts +14 -0
  267. package/types/popconfirm.type.d.ts +85 -1
  268. package/types/popeditor.type.d.ts +4 -0
  269. package/types/popover.type.d.ts +3 -3
  270. package/types/radio.type.d.ts +0 -4
  271. package/types/rate.type.d.ts +236 -1
  272. package/types/search.type.d.ts +88 -1
  273. package/types/shared.type.d.ts +1 -1
  274. package/types/skeleton-item.type.d.ts +38 -0
  275. package/types/skeleton.type.d.ts +45 -0
  276. package/types/slider.type.d.ts +8 -1
  277. package/types/steps.type.d.ts +14 -3
  278. package/types/tab-item.type.d.ts +0 -1
  279. package/types/tab-nav.type.d.ts +6 -1
  280. package/types/tabs.type.d.ts +5 -0
  281. package/types/tag-group.type.d.ts +64 -1
  282. package/types/tag.type.d.ts +12 -0
  283. package/types/tooltip.type.d.ts +1 -1
  284. package/types/transfer.type.d.ts +183 -1
  285. package/types/tree-menu.type.d.ts +210 -1
  286. package/types/upload-dragger.type.d.ts +1 -1
  287. package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-1078fba2.d.ts} +27 -6
  288. package/types/upload-list.type.d.ts +1 -1
  289. package/types/upload.type.d.ts +1 -1
  290. package/types/wizard.type.d.ts +1 -0
  291. package/upload/index.js +59 -29
  292. package/upload/vue.js +6 -4
  293. package/upload-list/index.js +14 -14
  294. package/upload-list/vue.js +5 -2
  295. package/user/index.js +5 -4
  296. package/user-head/index.js +1 -1
  297. package/wheel/index.js +3 -0
  298. package/wizard/vue.js +4 -2
@@ -6,16 +6,13 @@ const close = ({ state, emit }) => () => {
6
6
  emit("close", false);
7
7
  };
8
8
  const syncCheckStatus = ({ state, props, api }) => (value) => {
9
- const { valueField, textField, modelValue: propsModelValue, visible } = props;
9
+ const { valueField, textField, modelValue: propsModelValue } = props;
10
10
  const { lazy, isLeaf: leafField } = api.getNodeConfig();
11
11
  let currentData;
12
12
  let navList = [];
13
13
  let modelValue = value || propsModelValue || [];
14
14
  let len = modelValue.length;
15
15
  let isLeaf;
16
- if (!visible) {
17
- return;
18
- }
19
16
  for (let i = 0; i < len; i++) {
20
17
  const id = modelValue[i];
21
18
  currentData = state.store.getNode(id);
@@ -42,7 +39,6 @@ const watchVisible = ({ emit, state, props, api }) => (visible) => {
42
39
  const { modelValue } = props;
43
40
  if (visible) {
44
41
  api.watchModelValue(modelValue);
45
- api.initTreeStore();
46
42
  }
47
43
  setTimeout(() => {
48
44
  state.toggle = visible;
@@ -78,7 +74,7 @@ const selectOption = ({ emit, state, props, api }) => (option) => {
78
74
  option.loading = false;
79
75
  state.loading = false;
80
76
  option.loaded = true;
81
- nodes.map((data) => {
77
+ nodes.forEach((data) => {
82
78
  state.store.append(data, option.data);
83
79
  index = waitLoadList.indexOf(data[valueField]);
84
80
  if (index !== -1) {
@@ -115,19 +111,35 @@ const loopSearchOption = ({
115
111
  textField,
116
112
  prefixValue,
117
113
  prefixText,
118
- textSplit = "/"
114
+ textSplit = "/",
115
+ filterMethod,
116
+ level,
117
+ checkStrictly
119
118
  }) => {
120
119
  const list = [];
121
120
  options.forEach((item) => {
121
+ if (item.disabled) {
122
+ return;
123
+ }
122
124
  const text = item[textField];
123
125
  const textNavStr = prefixText ? prefixText + textSplit + text : text;
124
126
  const value = [...prefixValue, item[valueField]];
125
127
  const children = item[childrenField];
126
- if (text.includes(input)) {
127
- list.push({
128
- [valueField]: value,
129
- [textField]: textNavStr
130
- });
128
+ if (checkStrictly === true || !children || children.length === 0) {
129
+ if (typeof filterMethod === "function") {
130
+ const matched = filterMethod({ data: item, label: item.label, value: item.value, level }, input);
131
+ if (matched) {
132
+ list.push({
133
+ [valueField]: value,
134
+ [textField]: textNavStr
135
+ });
136
+ }
137
+ } else if (text.includes(input)) {
138
+ list.push({
139
+ [valueField]: value,
140
+ [textField]: textNavStr
141
+ });
142
+ }
131
143
  }
132
144
  if (children && children.length) {
133
145
  const arr = loopSearchOption({
@@ -138,7 +150,10 @@ const loopSearchOption = ({
138
150
  textField,
139
151
  prefixValue: value,
140
152
  prefixText: textNavStr,
141
- textSplit
153
+ textSplit,
154
+ filterMethod,
155
+ level: level + 1,
156
+ checkStrictly
142
157
  });
143
158
  list.push(...arr);
144
159
  }
@@ -160,7 +175,10 @@ const searchMethod = ({ state, props, api }) => () => {
160
175
  valueField,
161
176
  textField,
162
177
  prefixValue: [],
163
- prefixText: ""
178
+ prefixText: "",
179
+ filterMethod: searchConfig.filterMethod,
180
+ level: 0,
181
+ checkStrictly: props.nodeConfig.checkStrictly
164
182
  });
165
183
  }
166
184
  if (typeof list.then === "function") {
@@ -169,12 +187,12 @@ const searchMethod = ({ state, props, api }) => () => {
169
187
  state.search.filterOptions = list;
170
188
  }
171
189
  };
172
- const searchBoxToggle = ({ state, props, api }) => (bool) => {
190
+ const searchBoxToggle = ({ state, props, api }) => (isShow) => {
173
191
  const { searchConfig = {} } = props;
174
192
  const { lazy } = api.getNodeConfig();
175
- state.search.show = bool;
193
+ state.search.show = isShow;
176
194
  state.search.input = "";
177
- if (bool) {
195
+ if (isShow) {
178
196
  state.search.options = !lazy && searchConfig.options && searchConfig.options.length ? searchConfig.options : state.store.getAllData();
179
197
  api.searchMethod();
180
198
  }
@@ -198,8 +216,7 @@ const created = ({ api }) => () => {
198
216
  api.initTreeStore();
199
217
  };
200
218
  const loadData = ({ props, state }) => (data) => {
201
- const { visible } = props;
202
- if (!visible) {
219
+ if (!props.visible) {
203
220
  return;
204
221
  }
205
222
  state.store.setData(data);
@@ -230,7 +247,7 @@ const getNodeConfig = ({ constants, props }) => () => {
230
247
  return Object.assign({ nodeKey: valueField }, constants.defaultNodeConfig, nodeConfig);
231
248
  };
232
249
  const initTreeStore = ({ props, state, api }) => () => {
233
- const { data, textField, visible } = props;
250
+ const { data, textField } = props;
234
251
  const {
235
252
  nodeKey,
236
253
  lazy,
@@ -247,10 +264,6 @@ const initTreeStore = ({ props, state, api }) => () => {
247
264
  defaultExpandAll,
248
265
  filterNodeMethod
249
266
  } = api.getNodeConfig();
250
- if (!visible || state.store) {
251
- api.syncCheckStatus();
252
- return;
253
- }
254
267
  state.store = new TreeStore({
255
268
  key: nodeKey,
256
269
  data,
@@ -53,7 +53,7 @@ const renderless = (props, { computed, reactive, watch }, { emit, constants }) =
53
53
  options: computed(() => {
54
54
  let arr;
55
55
  let list = [state.rootData];
56
- state.navList.map((option) => {
56
+ state.navList.forEach((option) => {
57
57
  arr = option.childNodes;
58
58
  arr && arr.length && list.push(arr);
59
59
  });
@@ -67,6 +67,11 @@ const renderless = (props, { computed, reactive, watch }, { emit, constants }) =
67
67
  computedNavList: computed(() => api2.computedNavListHandler()),
68
68
  showButton: computed(() => {
69
69
  const len = state.navList.length;
70
+ if (!props.nodeConfig.checkStrictly) {
71
+ if (state.level < len - 1) {
72
+ return false;
73
+ }
74
+ }
70
75
  return len && (props.nodeConfig.checkStrictly || state.navList[len - 1].isLeaf);
71
76
  })
72
77
  });
@@ -92,6 +97,7 @@ const renderless = (props, { computed, reactive, watch }, { emit, constants }) =
92
97
  isSelected: isSelected({ state, api: api2, props })
93
98
  });
94
99
  api2.created();
100
+ api2.syncCheckStatus();
95
101
  watch(() => props.visible, api2.watchVisible);
96
102
  watch(() => props.modelValue, api2.watchModelValue, { immediate: true, deep: true });
97
103
  watch(() => props.data, api2.loadData, { deep: true });
@@ -15,9 +15,11 @@ const handleExpand = ({ api, parent, props, state }) => () => {
15
15
  if (!state.isLeaf) {
16
16
  api.handleExpand();
17
17
  }
18
- if (multiple) {
18
+ if (multiple && state.isLeaf) {
19
19
  const checked = state.isLeaf ? props.node.checked : false;
20
20
  api.handleMultiCheckChange(Boolean(checked));
21
+ } else {
22
+ parent.handleExpand(props.node);
21
23
  }
22
24
  });
23
25
  } else {
@@ -37,10 +39,20 @@ const isInPath = (props) => (pathNodes) => {
37
39
  const selectedPathNode = pathNodes[props.node.level - 1] || {};
38
40
  return selectedPathNode.uid === props.node.uid;
39
41
  };
42
+ const handleNodeClick = ({ state, api }) => () => {
43
+ if (!state.isDisabled) {
44
+ if (state.isLeaf) {
45
+ api.handleCheckChange();
46
+ } else {
47
+ api.handleExpand();
48
+ }
49
+ }
50
+ };
40
51
  export {
41
52
  comptCheckPath,
42
53
  handleCheckChange,
43
54
  handleExpand,
44
55
  handleMultiCheckChange,
56
+ handleNodeClick,
45
57
  isInPath
46
58
  };
@@ -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
+ };