@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
@@ -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
  };
@@ -0,0 +1,251 @@
1
+ import {
2
+ __spreadProps,
3
+ __spreadValues
4
+ } from "../chunk-G2ADBYYC.js";
5
+ const DEFAULT_FILED_NAMES = {
6
+ text: "label",
7
+ value: "id",
8
+ children: "children"
9
+ };
10
+ const createSourceData = ({ props, state, api }) => () => {
11
+ if (!api.validProps())
12
+ return;
13
+ const { options, valueField, textField, type } = props;
14
+ if (type === "cascade")
15
+ return options;
16
+ const values = api.parseType(state.defaultValues.slice());
17
+ const types = Array.from({ length: values.length });
18
+ const ranges = Array.from({ length: values.length });
19
+ const indices = Array.from({ length: values.length });
20
+ const visibleOptions = options.map((opt, i) => {
21
+ let slicedValues, existOption;
22
+ if (Array.isArray(opt)) {
23
+ if (opt.length === 0)
24
+ return [];
25
+ let index = opt.findIndex((item) => item[valueField] === values[i]);
26
+ index = index === -1 ? 0 : index;
27
+ types[i] = "a";
28
+ ranges[i] = [0, opt.length - 1];
29
+ indices[i] = index;
30
+ slicedValues = api.sliceValue(0, opt.length - 1);
31
+ existOption = (i2) => opt[i2];
32
+ } else if (opt && typeof opt === "object") {
33
+ let range;
34
+ if (Array.isArray(opt.range)) {
35
+ range = opt.range.slice(0, 2);
36
+ } else if (typeof opt.rangeMethod === "function") {
37
+ range = opt.rangeMethod(...values);
38
+ state.isOldCascadeType = true;
39
+ }
40
+ types[i] = "o";
41
+ ranges[i] = api.parseType(range);
42
+ slicedValues = api.sliceValue(ranges[i][0], ranges[i][1]);
43
+ existOption = (i2) => opt.optionMethod(i2, ...values);
44
+ }
45
+ if (!slicedValues || !existOption)
46
+ return [];
47
+ return slicedValues.map((slicedValue) => {
48
+ const option = slicedValue === null ? { [valueField]: null, [textField]: "" } : existOption(slicedValue);
49
+ return option;
50
+ });
51
+ });
52
+ return visibleOptions;
53
+ };
54
+ const changeHandler = ({ state, columnFieldNames, columnsType, api }) => (columnIndex, option) => {
55
+ const fields = columnFieldNames.value;
56
+ if (option && Object.keys(option).length) {
57
+ state.defaultValues = state.defaultValues ? state.defaultValues : [];
58
+ if (columnsType.value === "cascade") {
59
+ state.defaultValues[columnIndex] = option[fields.value] || "";
60
+ let index = columnIndex;
61
+ let cursor = option;
62
+ while (cursor && cursor[fields.children] && cursor[fields.children][0]) {
63
+ state.defaultValues[index + 1] = cursor[fields.children][0][fields.value];
64
+ index++;
65
+ cursor = cursor[fields.children][0];
66
+ }
67
+ if (cursor && cursor[fields.children] && cursor[fields.children].length === 0) {
68
+ state.defaultValues = state.defaultValues.slice(0, index + 1);
69
+ }
70
+ } else {
71
+ state.defaultValues[columnIndex] = Object.prototype.hasOwnProperty.call(option, fields.value) ? option[fields.value] : "";
72
+ }
73
+ api.change(columnIndex);
74
+ }
75
+ };
76
+ const formatCascade = ({ columnFieldNames }) => (columns, defaultValues) => {
77
+ const formatted = [];
78
+ const fields = columnFieldNames.value;
79
+ let cursor = {
80
+ text: "",
81
+ value: "",
82
+ [fields.children]: columns
83
+ };
84
+ let columnIndex = 0;
85
+ while (cursor && cursor[fields.children]) {
86
+ const options = cursor[fields.children];
87
+ const value = defaultValues[columnIndex];
88
+ let index = options.findIndex((columnItem) => columnItem[fields.value] === value);
89
+ if (index === -1)
90
+ index = 0;
91
+ cursor = cursor[fields.children][index];
92
+ columnIndex++;
93
+ formatted.push(options);
94
+ }
95
+ return formatted.slice();
96
+ };
97
+ const columnFieldNamesComputed = ({ props, computed }) => computed(() => {
98
+ return __spreadProps(__spreadValues({}, DEFAULT_FILED_NAMES), {
99
+ text: props.textField,
100
+ value: props.valueField,
101
+ children: props.childrenField
102
+ });
103
+ });
104
+ const defaultIndexes = ({ state, computed, columnFieldNames, columnsList }) => computed(() => {
105
+ const fields = columnFieldNames.value;
106
+ return columnsList.value.map((column, index) => {
107
+ const targetIndex = column.findIndex((item) => item[fields.value] === state.defaultValues[index]);
108
+ return targetIndex === -1 ? 0 : targetIndex;
109
+ });
110
+ });
111
+ const confirmDisabled = ({ props, state, columnsList }) => () => {
112
+ if (typeof props.disabled !== "function") {
113
+ return false;
114
+ }
115
+ state.isDisabled = columnsList.value.some((column, columnIndex) => {
116
+ return props.disabled(state.defaultValues[columnIndex], ...state.defaultValues);
117
+ });
118
+ };
119
+ const change = ({ api, state, columnFieldNames, columnsList }) => () => {
120
+ if (api.isSameValue(state.oldValues, state.defaultValues))
121
+ return;
122
+ state.oldValues = state.defaultValues.slice();
123
+ if (state.isOldCascadeType) {
124
+ state.formattedColumns = api.createSourceData();
125
+ }
126
+ api.getColumnsList();
127
+ api.confirmDisabled();
128
+ const fields = columnFieldNames.value;
129
+ state.selectedOptions = columnsList.value.map((column, index) => {
130
+ return column.find((item) => item[fields.value] === state.defaultValues[index]) || column[0];
131
+ });
132
+ };
133
+ const columnsTypeComputed = ({ state, computed, columnFieldNames }) => computed(() => {
134
+ const firstColumn = state.formattedColumns[0];
135
+ const fields = columnFieldNames.value;
136
+ if (firstColumn) {
137
+ if (Array.isArray(firstColumn)) {
138
+ return "multiple";
139
+ }
140
+ if (fields.children in firstColumn) {
141
+ return "cascade";
142
+ }
143
+ }
144
+ return "single";
145
+ });
146
+ const getColumnsList = ({ state, api, columnsType, columnsList }) => () => {
147
+ let result = [];
148
+ switch (columnsType.value) {
149
+ case "multiple":
150
+ result = state.formattedColumns;
151
+ break;
152
+ case "cascade":
153
+ result = api.formatCascade(state.formattedColumns, state.defaultValues ? state.defaultValues : []);
154
+ break;
155
+ default:
156
+ result = [state.formattedColumns];
157
+ break;
158
+ }
159
+ columnsList.value = result;
160
+ };
161
+ const setValue = ({ api, state }) => (value) => {
162
+ if (!api.isSameValue(value, state.defaultValues)) {
163
+ state.defaultValues = (value || []).slice();
164
+ api.change();
165
+ }
166
+ };
167
+ const isSameValue = (valA, valB) => JSON.stringify(valA) === JSON.stringify(valB);
168
+ const sliceValue = (min, max) => {
169
+ const values = [min];
170
+ Array.from({ length: max - min }).map((v, i) => values.push(min + i + 1));
171
+ return values;
172
+ };
173
+ const validArr = (arr) => Array.isArray(arr) && arr.length;
174
+ const validProps = ({ props }) => () => {
175
+ const { modelValue, options } = props;
176
+ return validArr(modelValue) && validArr(options) && modelValue.length === options.length;
177
+ };
178
+ const parseType = ({ props }) => (values) => {
179
+ const { valueType } = props;
180
+ return values.map(valueType === "number" ? Number : valueType === "string" ? String : (i) => i);
181
+ };
182
+ const init = ({ api, state }) => () => {
183
+ state.isInit = true;
184
+ state.formattedColumns = api.createSourceData();
185
+ api.getColumnsList();
186
+ };
187
+ const usePicker = (args) => {
188
+ const { ref, reactive, watch, computed, toRefs, props } = args;
189
+ const state = reactive({
190
+ formattedColumns: [],
191
+ defaultValues: [],
192
+ selectedOptions: [],
193
+ oldValues: [],
194
+ isOldCascadeType: false,
195
+ isDisabled: false,
196
+ isInit: false
197
+ });
198
+ const api = {};
199
+ const columnsList = ref([]);
200
+ const pickerColumn = ref([]);
201
+ const columnFieldNames = columnFieldNamesComputed({ props, computed });
202
+ const columnsType = columnsTypeComputed({ state, computed, columnFieldNames });
203
+ Object.assign(api, {
204
+ change: change({ api, state, columnFieldNames, columnsList }),
205
+ changeHandler: changeHandler({ state, columnFieldNames, columnsType, api }),
206
+ formatCascade: formatCascade({ columnFieldNames }),
207
+ setValue: setValue({ api, state }),
208
+ validProps: validProps({ props }),
209
+ parseType: parseType({ props }),
210
+ init: init({ api, state }),
211
+ isSameValue,
212
+ sliceValue,
213
+ getColumnsList: getColumnsList({ state, api, columnsType, columnsList }),
214
+ confirmDisabled: confirmDisabled({ props, state, columnsList }),
215
+ defaultIndexes: defaultIndexes({ state, computed, columnFieldNames, columnsList }),
216
+ createSourceData: createSourceData({ props, state, api })
217
+ });
218
+ initWatch({ props, api, state, watch });
219
+ return __spreadProps(__spreadValues({}, toRefs(state)), {
220
+ columnsType,
221
+ columnsList,
222
+ columnFieldNames,
223
+ changeHandler: api.changeHandler,
224
+ defaultIndexes: api.defaultIndexes,
225
+ pickerColumn,
226
+ isSameValue: api.isSameValue,
227
+ setValue: api.setValue
228
+ });
229
+ };
230
+ const initWatch = ({ props, api, state, watch }) => {
231
+ watch(
232
+ () => props.modelValue,
233
+ (newValues) => {
234
+ api.setValue(newValues);
235
+ },
236
+ { deep: true, immediate: true }
237
+ );
238
+ watch(
239
+ () => props.options,
240
+ () => props.visible && api.init(),
241
+ { deep: true, immediate: true }
242
+ );
243
+ watch(
244
+ () => props.visible,
245
+ () => props.visible && !state.isInit && api.init(),
246
+ { deep: true, immediate: true }
247
+ );
248
+ };
249
+ export {
250
+ usePicker
251
+ };
@@ -0,0 +1,65 @@
1
+ import "../chunk-G2ADBYYC.js";
2
+ const MIN_DISTANCE = 10;
3
+ const getDirection = (x, y) => {
4
+ if (x > y && x > MIN_DISTANCE)
5
+ return "horizontal";
6
+ if (y > x && y > MIN_DISTANCE)
7
+ return "vertical";
8
+ return "";
9
+ };
10
+ function useTouch({ ref }) {
11
+ const startX = ref(0);
12
+ const startY = ref(0);
13
+ const moveX = ref(0);
14
+ const moveY = ref(0);
15
+ const deltaX = ref(0);
16
+ const deltaY = ref(0);
17
+ const offsetX = ref(0);
18
+ const offsetY = ref(0);
19
+ const direction = ref("");
20
+ const isVertical = () => direction.value === "vertical";
21
+ const isHorizontal = () => direction.value === "horizontal";
22
+ const move = (event) => {
23
+ const touchEvent = event.touches[0];
24
+ deltaX.value = touchEvent.clientX - startX.value;
25
+ deltaY.value = touchEvent.clientY - startY.value;
26
+ moveY.value = touchEvent.clientY;
27
+ moveX.value = touchEvent.clientX;
28
+ offsetY.value = Math.abs(deltaY.value);
29
+ offsetX.value = Math.abs(deltaX.value);
30
+ if (!direction.value) {
31
+ direction.value = getDirection(offsetX.value, offsetY.value);
32
+ }
33
+ };
34
+ const reset = () => {
35
+ deltaX.value = 0;
36
+ offsetX.value = 0;
37
+ offsetY.value = 0;
38
+ deltaY.value = 0;
39
+ direction.value = "";
40
+ };
41
+ const start = (event) => {
42
+ reset();
43
+ startY.value = event.touches[0].clientY;
44
+ startX.value = event.touches[0].clientX;
45
+ };
46
+ return {
47
+ start,
48
+ move,
49
+ reset,
50
+ startY,
51
+ startX,
52
+ moveY,
53
+ moveX,
54
+ deltaY,
55
+ deltaX,
56
+ offsetY,
57
+ offsetX,
58
+ isVertical,
59
+ direction,
60
+ isHorizontal
61
+ };
62
+ }
63
+ export {
64
+ useTouch
65
+ };
@@ -1,67 +1,55 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
- import {
3
- init,
4
- handleTouchstart,
5
- handleTouchend,
6
- handleTouchmove,
7
- watchActionSheetVisible,
8
- calcSelector,
9
- close,
10
- confirm,
11
- styleOpt,
12
- statusOpt,
13
- computedConfirmDisabled,
14
- parseType
15
- } from "./index";
16
- import throttle from "../common/deps/throttle";
2
+ import { watchActionSheetVisible, close, confirm, columnStyle } from "./index";
3
+ import { usePicker } from "./usePicker";
17
4
  const api = [
18
5
  "state",
19
- "handleTouchstart",
20
- "handleTouchend",
21
- "throttledHandleTouchmove",
22
6
  "close",
23
7
  "confirm",
24
- "styleOpt",
25
- "statusOpt"
8
+ "columnsType",
9
+ "columnsList",
10
+ "columnFieldNames",
11
+ "changeHandler",
12
+ "defaultValues",
13
+ "isDisabled",
14
+ "selectedOptions",
15
+ "columnStyle"
26
16
  ];
27
- const renderless = (props, { reactive, computed, onBeforeMount, watch }, { emit, vm }) => {
17
+ const renderless = (props, { reactive, computed, watch, ref, toRefs }, { emit, vm }) => {
28
18
  const state = reactive({
29
19
  actionSheetVisible: false,
30
- visibleOptionCount: 5,
31
- selectorCount: 1,
32
- selector0: {},
33
- selector1: {},
34
- selector2: {},
35
- confirmDisabled: computed(() => api2.computedConfirmDisabled())
20
+ visibleOptionNum: 5
36
21
  });
22
+ const {
23
+ changeHandler,
24
+ defaultValues,
25
+ columnsList,
26
+ columnsType,
27
+ columnFieldNames,
28
+ selectedOptions,
29
+ setValue,
30
+ isDisabled
31
+ } = usePicker({ ref, reactive, watch, computed, toRefs, props, emit });
37
32
  const api2 = {
38
- state,
39
- styleOpt,
40
- statusOpt,
41
- handleTouchstart: handleTouchstart(state),
42
- handleTouchend: handleTouchend(state),
43
- watchActionSheetVisible: watchActionSheetVisible({ emit, state, vm }),
44
- close: close(state),
45
- computedConfirmDisabled: computedConfirmDisabled(state),
46
- parseType: parseType(props)
33
+ state
47
34
  };
48
35
  Object.assign(api2, {
49
- init: init({ api: api2, props, state }),
50
- throttledHandleTouchmove: throttle(20, handleTouchmove({ api: api2, props, state })),
51
- calcSelector: calcSelector(api2),
52
- confirm: confirm({ api: api2, emit, props, state, vm })
53
- });
54
- onBeforeMount(() => {
55
- api2.init();
36
+ close: close(state),
37
+ confirm: confirm({ api: api2, emit, props, state, defaultValues, selectedOptions, isDisabled, vm }),
38
+ watchActionSheetVisible: watchActionSheetVisible({ emit, api: api2, props }),
39
+ columnsType,
40
+ columnsList,
41
+ columnFieldNames,
42
+ changeHandler,
43
+ defaultValues,
44
+ selectedOptions,
45
+ setValue,
46
+ isDisabled,
47
+ columnStyle: columnStyle({ props, computed })
56
48
  });
57
49
  watch(
58
50
  () => props.visible,
59
51
  (value) => state.actionSheetVisible = value
60
52
  );
61
- watch(
62
- () => props.modelValue,
63
- (value) => api2.init(value)
64
- );
65
53
  watch(
66
54
  () => state.actionSheetVisible,
67
55
  (value) => api2.watchActionSheetVisible(value)
@@ -62,7 +62,7 @@ const nodeExpand = ({ emit, state, props, api }) => (option) => {
62
62
  state.loading = false;
63
63
  option.loading = false;
64
64
  option.loaded = true;
65
- nodes.map((data) => {
65
+ nodes.forEach((data) => {
66
66
  index = -1;
67
67
  state.store.append(data, option.data);
68
68
  waitLoadCheckList.some((item, i) => {
package/cell/vue.js CHANGED
@@ -3,7 +3,8 @@ const api = ["state"];
3
3
  const renderless = (props, { reactive, computed, inject }, { parent }) => {
4
4
  parent.tinyForm = parent.tinyForm || inject("form", null);
5
5
  const state = reactive({
6
- isDisplayOnly: computed(() => (parent.tinyForm || {}).displayOnly)
6
+ isDisplayOnly: computed(() => (parent.tinyForm || {}).displayOnly),
7
+ isDisabled: computed(() => props.disabled || (parent.tinyForm || {}).disabled)
7
8
  });
8
9
  const api2 = {
9
10
  state
@@ -30,8 +30,7 @@ const getBarDimAxis = (args) => {
30
30
  },
31
31
  show: axisVisible,
32
32
  axisTick: { show: true, alignWithLabel: true, lineStyle: { color: "#191919", opacity: 0.1, width: 2 } },
33
- axisLine: { show: true, lineStyle: { color: "#191919", opacity: 0.1, width: 2 } },
34
- axisPointer: { type: "shadow", z: 1, shadowStyle: { color: "#f5f5f5" } }
33
+ axisLine: { show: true, lineStyle: { color: "#191919", opacity: 0.1, width: 2 } }
35
34
  }));
36
35
  };
37
36
  const factoryFmt = ({ meaAxisType, i, digit }) => (val) => getFormated(val, meaAxisType[i], digit);
@@ -74,7 +73,7 @@ const getBarTooltip = (args) => {
74
73
  });
75
74
  return tplt.join("");
76
75
  };
77
- return { trigger: "axis", formatter };
76
+ return { trigger: "axis", formatter, axisPointer: { type: "shadow", z: 1, shadowStyle: { color: "#f5f5f5" } } };
78
77
  };
79
78
  const getValueData = (seriesTemp, dims) => {
80
79
  const max = Math.max(...dims);