zartui 2.0.79 → 2.0.80-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/es/action-sheet/index.js +15 -26
  2. package/es/area/index.js +5 -41
  3. package/es/avatar/index.js +3 -16
  4. package/es/back-top/index.js +4 -19
  5. package/es/badge/index.js +4 -12
  6. package/es/button/index.js +20 -40
  7. package/es/calendar/components/Header.js +3 -12
  8. package/es/calendar/components/Month.js +12 -65
  9. package/es/calendar/index.js +23 -94
  10. package/es/calendar/types.js +0 -6
  11. package/es/calendar/utils.js +5 -16
  12. package/es/cascader/index.js +4 -37
  13. package/es/cell/index.js +19 -37
  14. package/es/cell-group/index.js +5 -8
  15. package/es/checkbox/index.js +4 -11
  16. package/es/checkbox-group/index.js +4 -9
  17. package/es/col/index.js +6 -11
  18. package/es/collapse/index.js +2 -5
  19. package/es/collapse-item/index.js +19 -35
  20. package/es/count-down/index.js +2 -15
  21. package/es/count-down/utils.js +3 -10
  22. package/es/datetime-picker/DatePicker.js +12 -70
  23. package/es/datetime-picker/TimePicker.js +10 -23
  24. package/es/datetime-picker/index.js +2 -4
  25. package/es/datetime-picker/shared.js +5 -19
  26. package/es/datetime-picker/utils.js +0 -5
  27. package/es/dialog/Dialog.js +6 -21
  28. package/es/dialog/index.js +0 -16
  29. package/es/divider/index.js +5 -6
  30. package/es/dropdown-item/index.js +22 -35
  31. package/es/dropdown-menu/index.js +4 -9
  32. package/es/empty/index.js +3 -11
  33. package/es/field/index.js +20 -83
  34. package/es/fold-dialog/index.js +5 -20
  35. package/es/form/index.js +2 -18
  36. package/es/grid/index.js +2 -6
  37. package/es/grid-item/index.js +17 -30
  38. package/es/hierarchy-select/breadcrumb.js +2 -6
  39. package/es/hierarchy-select/index.js +3 -12
  40. package/es/hierarchy-select/markList.js +2 -25
  41. package/es/hierarchy-select/svg/SubIcon.js +0 -1
  42. package/es/icon/index.js +9 -13
  43. package/es/image/index.js +2 -17
  44. package/es/image-preview/ImagePreview.js +4 -8
  45. package/es/image-preview/ImagePreviewItem.js +14 -30
  46. package/es/image-preview/index.js +0 -12
  47. package/es/image-preview/shared.js +2 -4
  48. package/es/index-anchor/index.js +2 -6
  49. package/es/index-bar/IndexIndicate.js +0 -1
  50. package/es/index-bar/index.js +7 -28
  51. package/es/index.js +1 -4
  52. package/es/info/index.js +6 -8
  53. package/es/list/index.js +11 -27
  54. package/es/loading/index.js +7 -15
  55. package/es/locale/index.js +0 -2
  56. package/es/media-picker/index.js +33 -117
  57. package/es/media-picker/media-util.js +2 -5
  58. package/es/media-picker/type.js +0 -5
  59. package/es/media-player/index.js +7 -17
  60. package/es/mixins/bind-event.js +0 -3
  61. package/es/mixins/checkbox.js +5 -11
  62. package/es/mixins/click-outside.js +0 -2
  63. package/es/mixins/close-on-popstate.js +0 -1
  64. package/es/mixins/field.js +0 -2
  65. package/es/mixins/popup/index.js +12 -28
  66. package/es/mixins/popup/overlay.js +1 -11
  67. package/es/mixins/portal.js +2 -8
  68. package/es/mixins/relation.js +0 -8
  69. package/es/mixins/slots.js +1 -4
  70. package/es/mixins/touch.js +4 -9
  71. package/es/multiple-picker/MultiplePickerOptions.js +2 -18
  72. package/es/multiple-picker/index.js +5 -17
  73. package/es/nav-bar/index.js +4 -12
  74. package/es/notice-bar/index.js +10 -28
  75. package/es/number-keyboard/Key.js +2 -10
  76. package/es/number-keyboard/index.js +4 -19
  77. package/es/overlay/index.js +5 -8
  78. package/es/password-input/index.js +10 -16
  79. package/es/picker/PickerColumn.js +20 -54
  80. package/es/picker/index.js +13 -42
  81. package/es/popover/index.js +11 -20
  82. package/es/popup/index.js +5 -21
  83. package/es/pull-refresh/index.js +15 -32
  84. package/es/radio/index.js +2 -4
  85. package/es/radio-group/index.js +2 -4
  86. package/es/rate/index.js +12 -26
  87. package/es/row/index.js +3 -9
  88. package/es/search/index.js +8 -13
  89. package/es/signature/bezier.js +5 -12
  90. package/es/signature/force-landscape.js +0 -5
  91. package/es/signature/index.js +5 -24
  92. package/es/signature/point.js +1 -6
  93. package/es/signature/throttle.js +1 -10
  94. package/es/skeleton/index.js +5 -15
  95. package/es/slider/index.js +19 -55
  96. package/es/step/index.js +5 -12
  97. package/es/stepper/index.js +10 -37
  98. package/es/steps/index.js +2 -4
  99. package/es/sticky/index.js +8 -50
  100. package/es/swipe/index.js +19 -62
  101. package/es/swipe-cell/index.js +7 -23
  102. package/es/swipe-item/index.js +9 -19
  103. package/es/switch/index.js +8 -10
  104. package/es/switch/shared.js +1 -0
  105. package/es/switch-cell/index.js +7 -7
  106. package/es/tab/index.js +4 -15
  107. package/es/tabbar/index.js +4 -14
  108. package/es/tabbar-item/index.js +7 -15
  109. package/es/table/index.js +10 -35
  110. package/es/tabs/Content.js +5 -9
  111. package/es/tabs/Title.js +11 -19
  112. package/es/tabs/index.js +16 -51
  113. package/es/tabs/utils.js +0 -8
  114. package/es/tag/index.js +13 -17
  115. package/es/timeline/index.js +2 -25
  116. package/es/toast/Toast.js +11 -23
  117. package/es/toast/index.js +6 -33
  118. package/es/toast/lock-click.js +0 -2
  119. package/es/uploader/index.js +11 -62
  120. package/es/uploader/utils.js +0 -10
  121. package/es/utils/constant.js +2 -1
  122. package/es/utils/create/bem.js +1 -5
  123. package/es/utils/create/component.js +4 -7
  124. package/es/utils/create/i18n.js +0 -2
  125. package/es/utils/deep-assign.js +0 -4
  126. package/es/utils/deep-clone.js +0 -3
  127. package/es/utils/dom/event.js +2 -5
  128. package/es/utils/dom/node.js +0 -1
  129. package/es/utils/dom/raf.js +7 -6
  130. package/es/utils/dom/reset-scroll.js +2 -1
  131. package/es/utils/dom/scroll.js +8 -17
  132. package/es/utils/dom/style.js +3 -2
  133. package/es/utils/easings.js +2 -4
  134. package/es/utils/format/date-util.js +54 -122
  135. package/es/utils/format/number.js +2 -11
  136. package/es/utils/format/string.js +0 -3
  137. package/es/utils/format/unit.js +2 -12
  138. package/es/utils/functional.js +6 -9
  139. package/es/utils/getScroll.js +0 -5
  140. package/es/utils/index.js +3 -5
  141. package/es/utils/interceptor.js +2 -4
  142. package/es/utils/media/image-util.js +7 -19
  143. package/es/utils/raf.js +4 -12
  144. package/es/utils/router.js +7 -6
  145. package/es/utils/scrollTo.js +7 -12
  146. package/es/utils/validate/number.js +2 -2
  147. package/es/utils/vnodes.js +2 -8
  148. package/lib/action-sheet/index.js +11 -35
  149. package/lib/area/index.js +5 -45
  150. package/lib/avatar/index.js +3 -18
  151. package/lib/back-top/index.js +4 -25
  152. package/lib/badge/index.js +4 -15
  153. package/lib/button/index.js +19 -50
  154. package/lib/calendar/components/Header.js +3 -18
  155. package/lib/calendar/components/Month.js +12 -71
  156. package/lib/calendar/index.js +21 -106
  157. package/lib/calendar/types.js +0 -7
  158. package/lib/calendar/utils.js +5 -32
  159. package/lib/cascader/index.js +4 -46
  160. package/lib/cell/index.js +18 -48
  161. package/lib/cell-group/index.js +5 -15
  162. package/lib/checkbox/index.js +4 -14
  163. package/lib/checkbox-group/index.js +4 -13
  164. package/lib/col/index.js +6 -14
  165. package/lib/collapse/index.js +2 -8
  166. package/lib/collapse-item/index.js +18 -43
  167. package/lib/count-down/index.js +2 -19
  168. package/lib/count-down/utils.js +3 -15
  169. package/lib/datetime-picker/DatePicker.js +12 -81
  170. package/lib/datetime-picker/TimePicker.js +10 -30
  171. package/lib/datetime-picker/index.js +2 -10
  172. package/lib/datetime-picker/shared.js +5 -27
  173. package/lib/datetime-picker/utils.js +0 -9
  174. package/lib/dialog/Dialog.js +6 -28
  175. package/lib/dialog/index.js +0 -22
  176. package/lib/divider/index.js +5 -12
  177. package/lib/dropdown-item/index.js +21 -44
  178. package/lib/dropdown-menu/index.js +4 -15
  179. package/lib/empty/index.js +3 -23
  180. package/lib/field/index.js +20 -96
  181. package/lib/fold-dialog/index.js +5 -22
  182. package/lib/form/index.js +2 -21
  183. package/lib/grid/index.js +2 -10
  184. package/lib/grid-item/index.js +16 -37
  185. package/lib/hierarchy-select/breadcrumb.js +3 -10
  186. package/lib/hierarchy-select/index.js +4 -20
  187. package/lib/hierarchy-select/markList.js +3 -31
  188. package/lib/hierarchy-select/svg/SubIcon.js +0 -1
  189. package/lib/icon/index.js +8 -19
  190. package/lib/image/index.js +2 -22
  191. package/lib/image-preview/ImagePreview.js +0 -16
  192. package/lib/image-preview/ImagePreviewItem.js +13 -36
  193. package/lib/image-preview/index.js +0 -16
  194. package/lib/image-preview/shared.js +2 -5
  195. package/lib/index-anchor/index.js +2 -11
  196. package/lib/index-bar/IndexIndicate.js +0 -1
  197. package/lib/index-bar/index.js +7 -37
  198. package/lib/index.js +1 -157
  199. package/lib/info/index.js +6 -14
  200. package/lib/lazyload/index.js +0 -3
  201. package/lib/list/index.js +10 -33
  202. package/lib/loading/index.js +7 -21
  203. package/lib/locale/index.js +0 -7
  204. package/lib/media-picker/index.js +27 -153
  205. package/lib/media-picker/media-util.js +2 -15
  206. package/lib/media-picker/type.js +0 -5
  207. package/lib/media-player/index.js +6 -22
  208. package/lib/mixins/bind-event.js +1 -6
  209. package/lib/mixins/checkbox.js +6 -18
  210. package/lib/mixins/click-outside.js +1 -5
  211. package/lib/mixins/close-on-popstate.js +0 -4
  212. package/lib/mixins/field.js +0 -2
  213. package/lib/mixins/popup/index.js +11 -36
  214. package/lib/mixins/popup/overlay.js +1 -23
  215. package/lib/mixins/portal.js +2 -9
  216. package/lib/mixins/relation.js +0 -11
  217. package/lib/mixins/slots.js +1 -5
  218. package/lib/mixins/touch.js +4 -11
  219. package/lib/multiple-picker/MultiplePickerOptions.js +2 -23
  220. package/lib/multiple-picker/index.js +5 -26
  221. package/lib/nav-bar/index.js +4 -16
  222. package/lib/notice-bar/index.js +10 -40
  223. package/lib/number-keyboard/Key.js +2 -17
  224. package/lib/number-keyboard/index.js +4 -26
  225. package/lib/overlay/index.js +5 -16
  226. package/lib/password-input/index.js +10 -23
  227. package/lib/picker/PickerColumn.js +19 -63
  228. package/lib/picker/index.js +13 -53
  229. package/lib/popover/index.js +9 -27
  230. package/lib/popup/index.js +5 -27
  231. package/lib/pull-refresh/index.js +14 -38
  232. package/lib/radio/index.js +2 -7
  233. package/lib/radio-group/index.js +2 -8
  234. package/lib/rate/index.js +11 -31
  235. package/lib/row/index.js +3 -12
  236. package/lib/search/index.js +7 -21
  237. package/lib/signature/bezier.js +5 -15
  238. package/lib/signature/force-landscape.js +0 -11
  239. package/lib/signature/index.js +6 -31
  240. package/lib/signature/point.js +0 -8
  241. package/lib/signature/throttle.js +1 -11
  242. package/lib/skeleton/index.js +5 -21
  243. package/lib/slider/index.js +19 -63
  244. package/lib/step/index.js +5 -18
  245. package/lib/stepper/index.js +10 -46
  246. package/lib/steps/index.js +2 -7
  247. package/lib/sticky/index.js +8 -59
  248. package/lib/swipe/index.js +19 -70
  249. package/lib/swipe-cell/index.js +7 -29
  250. package/lib/swipe-item/index.js +9 -24
  251. package/lib/switch/index.js +7 -14
  252. package/lib/switch/shared.js +1 -1
  253. package/lib/switch-cell/index.js +6 -16
  254. package/lib/tab/index.js +4 -21
  255. package/lib/tabbar/index.js +4 -19
  256. package/lib/tabbar-item/index.js +5 -21
  257. package/lib/table/index.js +10 -38
  258. package/lib/tabs/Content.js +5 -15
  259. package/lib/tabs/Title.js +11 -23
  260. package/lib/tabs/index.js +15 -65
  261. package/lib/tabs/utils.js +0 -13
  262. package/lib/tag/index.js +12 -23
  263. package/lib/timeline/index.js +2 -32
  264. package/lib/toast/Toast.js +10 -30
  265. package/lib/toast/index.js +6 -38
  266. package/lib/toast/lock-click.js +0 -3
  267. package/lib/uploader/index.js +10 -72
  268. package/lib/uploader/utils.js +0 -17
  269. package/lib/utils/constant.js +2 -1
  270. package/lib/utils/create/bem.js +1 -6
  271. package/lib/utils/create/component.js +5 -14
  272. package/lib/utils/create/i18n.js +0 -8
  273. package/lib/utils/create/index.js +0 -4
  274. package/lib/utils/deep-assign.js +0 -6
  275. package/lib/utils/deep-clone.js +0 -5
  276. package/lib/utils/device.js +0 -2
  277. package/lib/utils/dom/event.js +2 -10
  278. package/lib/utils/dom/node.js +0 -2
  279. package/lib/utils/dom/raf.js +7 -11
  280. package/lib/utils/dom/reset-scroll.js +2 -4
  281. package/lib/utils/dom/scroll.js +8 -28
  282. package/lib/utils/dom/style.js +3 -3
  283. package/lib/utils/easings.js +2 -5
  284. package/lib/utils/format/date-util.js +54 -168
  285. package/lib/utils/format/number.js +2 -13
  286. package/lib/utils/format/string.js +0 -5
  287. package/lib/utils/format/unit.js +2 -16
  288. package/lib/utils/functional.js +6 -14
  289. package/lib/utils/getScroll.js +0 -7
  290. package/lib/utils/index.js +3 -19
  291. package/lib/utils/interceptor.js +2 -6
  292. package/lib/utils/media/image-util.js +7 -25
  293. package/lib/utils/raf.js +4 -13
  294. package/lib/utils/router.js +7 -9
  295. package/lib/utils/scrollTo.js +9 -21
  296. package/lib/utils/validate/date.js +0 -2
  297. package/lib/utils/validate/email.js +0 -1
  298. package/lib/utils/validate/mobile.js +0 -1
  299. package/lib/utils/validate/number.js +2 -4
  300. package/lib/utils/validate/system.js +0 -3
  301. package/lib/utils/vnodes.js +2 -9
  302. package/lib/zart.js +57 -18
  303. package/lib/zart.min.js +1 -1
  304. package/package.json +17 -18
@@ -2,19 +2,14 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
-
6
5
  var _utils = require("../utils");
7
-
8
6
  var _constant = require("../utils/constant");
9
-
10
7
  var _createNamespace = (0, _utils.createNamespace)('table'),
11
- createComponent = _createNamespace[0],
12
- bem = _createNamespace[1];
13
-
8
+ createComponent = _createNamespace[0],
9
+ bem = _createNamespace[1];
14
10
  var defaultData = function defaultData() {
15
11
  return {};
16
12
  };
17
-
18
13
  var _default = createComponent({
19
14
  props: {
20
15
  headList: {
@@ -80,30 +75,24 @@ var _default = createComponent({
80
75
  var columnTotalWidth = 0;
81
76
  this.headList.forEach(function (v, i) {
82
77
  var dom = document.getElementById("tableHead" + i);
83
-
84
78
  if (dom) {
85
79
  columnTotalWidth += dom.clientWidth || 0;
86
80
  }
87
81
  });
88
82
  var box = document.getElementById("normalBoxID");
89
83
  var boxWidth = 0;
90
-
91
84
  if (box) {
92
85
  boxWidth = box.clientWidth;
93
86
  }
94
-
95
87
  if (this.fixedColumnLeft && this.fixedColumnLeft.length || this.fixedColumnRight && this.fixedColumnRight.length) {
96
88
  // 当表格横向出现滚动时,给固定列加一个box-shadow
97
89
  var fixedBoxRight = document.getElementById("fixedRightBoxID");
98
-
99
90
  if (fixedBoxRight && columnTotalWidth > boxWidth) {
100
91
  fixedBoxRight.classList.add("shadow");
101
92
  }
102
-
103
93
  if (box) {
104
94
  box.addEventListener("scroll", function (e) {
105
95
  var fixedBoxLeft = document.getElementById("fixedLeftBoxID");
106
-
107
96
  if (fixedBoxLeft) {
108
97
  if (e && e.target && e.target.scrollLeft > 0) {
109
98
  fixedBoxLeft.classList.add("shadow");
@@ -111,7 +100,6 @@ var _default = createComponent({
111
100
  fixedBoxLeft.classList.remove("shadow");
112
101
  }
113
102
  }
114
-
115
103
  if (fixedBoxRight) {
116
104
  if (e && e.target && e.target.scrollLeft + e.target.clientWidth >= columnTotalWidth - 1) {
117
105
  fixedBoxRight.classList.remove("shadow");
@@ -121,9 +109,8 @@ var _default = createComponent({
121
109
  }
122
110
  });
123
111
  }
124
- } // 获取需固定列的实际宽度,用于设置绝对定位元素的宽度
125
-
126
-
112
+ }
113
+ // 获取需固定列的实际宽度,用于设置绝对定位元素的宽度
127
114
  var fixedLeftIndexList = this.headList.map(function (v, i) {
128
115
  if (v.fixedLeft) {
129
116
  return "tableHead" + i;
@@ -133,19 +120,16 @@ var _default = createComponent({
133
120
  }).filter(function (v) {
134
121
  return v !== "";
135
122
  });
136
-
137
123
  if (fixedLeftIndexList.length > 0) {
138
124
  fixedLeftIndexList.forEach(function (current, index) {
139
125
  var fixedDom = document.getElementById("fixedHeadLeft" + index);
140
126
  var normalDom = document.getElementById(current);
141
-
142
127
  if (fixedDom && normalDom) {
143
128
  fixedDom.style.width = normalDom.offsetWidth + "px";
144
129
  }
145
130
  }, 0);
146
- } // 获取需固定列的实际宽度,用于设置绝对定位元素的宽度
147
-
148
-
131
+ }
132
+ // 获取需固定列的实际宽度,用于设置绝对定位元素的宽度
149
133
  var fixedRightIndexList = this.headList.map(function (v, i) {
150
134
  if (v.fixedRight) {
151
135
  return "tableHead" + i;
@@ -155,20 +139,18 @@ var _default = createComponent({
155
139
  }).filter(function (v) {
156
140
  return v !== "";
157
141
  });
158
-
159
142
  if (fixedRightIndexList.length > 0) {
160
143
  fixedRightIndexList.forEach(function (current, index) {
161
144
  var fixedDom = document.getElementById("fixedHeadRight" + index);
162
145
  var normalDom = document.getElementById(current);
163
-
164
146
  if (fixedDom && normalDom) {
165
147
  fixedDom.style.width = normalDom.offsetWidth + "px";
166
148
  }
167
- }, 0); // 当存在右侧固定列,且列宽度不足以撑满容器时,将最后一列宽度拉长到填满
149
+ }, 0);
150
+ // 当存在右侧固定列,且列宽度不足以撑满容器时,将最后一列宽度拉长到填满
168
151
 
169
152
  if (columnTotalWidth < boxWidth) {
170
153
  var lastColumn = document.getElementById("tableHead" + (this.headList.length - 1));
171
-
172
154
  if (lastColumn) {
173
155
  lastColumn.classList.add("widen");
174
156
  lastColumn.style.width = "unset";
@@ -181,11 +163,9 @@ var _default = createComponent({
181
163
  methods: {
182
164
  genColumn: function genColumn(headObj, index, isFixed) {
183
165
  var h = this.$createElement;
184
-
185
166
  var _ref = this,
186
- slots = _ref.slots,
187
- hideTableHead = _ref.hideTableHead;
188
-
167
+ slots = _ref.slots,
168
+ hideTableHead = _ref.hideTableHead;
189
169
  var headItemStyle = {
190
170
  color: this.headColor,
191
171
  background: this.headBackground
@@ -195,22 +175,17 @@ var _default = createComponent({
195
175
  background: this.dataBackground
196
176
  };
197
177
  var idName = "tableHead" + index;
198
-
199
178
  if (isFixed === "left") {
200
179
  idName = "fixedHeadLeft" + index;
201
180
  }
202
-
203
181
  if (isFixed === "right") {
204
182
  idName = "fixedHeadRight" + index;
205
183
  }
206
-
207
184
  var headRender = slots("head" + headObj.id) || headObj.label;
208
-
209
185
  if ((headObj.fixedLeft || headObj.fixedRight) && !isFixed) {
210
186
  // 被固定列遮住的列不显示内容
211
187
  headRender = "";
212
188
  }
213
-
214
189
  return h("div", {
215
190
  "class": [bem(isFixed ? "fixed-head" : "head"), isFixed ? _constant.BORDER_SURROUND : _constant.BORDER_RIGHT],
216
191
  "attrs": {
@@ -226,7 +201,6 @@ var _default = createComponent({
226
201
  "style": headItemStyle
227
202
  }, [headRender]), this.dataList.map(function (data) {
228
203
  var hide = (headObj.fixedLeft || headObj.fixedRight) && !isFixed;
229
-
230
204
  if (hide) {
231
205
  // 被固定列遮住的列不显示内容
232
206
  return h("div", {
@@ -254,7 +228,6 @@ var _default = createComponent({
254
228
  },
255
229
  render: function render(h) {
256
230
  var _this = this;
257
-
258
231
  var showFixed = this.dataList && this.dataList.length;
259
232
  return h("div", {
260
233
  "class": bem(["", this.outline ? "" : "no-border"])
@@ -290,5 +263,4 @@ var _default = createComponent({
290
263
  })])]);
291
264
  }
292
265
  });
293
-
294
266
  exports.default = _default;
@@ -1,22 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  exports.__esModule = true;
6
5
  exports.default = void 0;
7
-
8
6
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
-
10
7
  var _utils = require("../utils");
11
-
12
8
  var _touch = require("../mixins/touch");
13
-
14
9
  var _createNamespace = (0, _utils.createNamespace)('tabs'),
15
- createComponent = _createNamespace[0],
16
- bem = _createNamespace[1];
17
-
10
+ createComponent = _createNamespace[0],
11
+ bem = _createNamespace[1];
18
12
  var MIN_SWIPE_DISTANCE = 50;
19
-
20
13
  var _default = createComponent({
21
14
  mixins: [_touch.TouchMixin],
22
15
  props: {
@@ -50,10 +43,10 @@ var _default = createComponent({
50
43
  // watch swipe touch end
51
44
  onTouchEnd: function onTouchEnd() {
52
45
  var direction = this.direction,
53
- deltaX = this.deltaX,
54
- currentIndex = this.currentIndex;
55
- /* istanbul ignore else */
46
+ deltaX = this.deltaX,
47
+ currentIndex = this.currentIndex;
56
48
 
49
+ /* istanbul ignore else */
57
50
  if (direction === 'horizontal' && this.offsetX >= MIN_SWIPE_DISTANCE) {
58
51
  /* istanbul ignore else */
59
52
  if (deltaX > 0 && currentIndex !== 0) {
@@ -65,14 +58,12 @@ var _default = createComponent({
65
58
  },
66
59
  genChildren: function genChildren() {
67
60
  var h = this.$createElement;
68
-
69
61
  if (this.animated) {
70
62
  return h("div", {
71
63
  "class": bem('track'),
72
64
  "style": this.style
73
65
  }, [this.slots()]);
74
66
  }
75
-
76
67
  return this.slots();
77
68
  }
78
69
  },
@@ -86,5 +77,4 @@ var _default = createComponent({
86
77
  }, [this.genChildren()]);
87
78
  }
88
79
  });
89
-
90
80
  exports.default = _default;
package/lib/tabs/Title.js CHANGED
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  exports.__esModule = true;
6
5
  exports.default = void 0;
7
-
8
6
  var _utils = require("../utils");
9
-
10
7
  var _info = _interopRequireDefault(require("../info"));
11
-
12
8
  var _createNamespace = (0, _utils.createNamespace)('tab'),
13
- createComponent = _createNamespace[0],
14
- bem = _createNamespace[1];
15
-
9
+ createComponent = _createNamespace[0],
10
+ bem = _createNamespace[1];
16
11
  var _default = createComponent({
17
12
  props: {
18
13
  dot: Boolean,
@@ -34,12 +29,12 @@ var _default = createComponent({
34
29
  style: function style() {
35
30
  var style = {};
36
31
  var color = this.color,
37
- isActive = this.isActive;
38
- var isCard = this.type === 'card'; // card theme color
32
+ isActive = this.isActive;
33
+ var isCard = this.type === 'card';
39
34
 
35
+ // card theme color
40
36
  if (color && isCard) {
41
37
  style.borderColor = color;
42
-
43
38
  if (!this.disabled) {
44
39
  if (isActive) {
45
40
  style.backgroundColor = color;
@@ -48,27 +43,23 @@ var _default = createComponent({
48
43
  }
49
44
  }
50
45
  }
51
-
52
46
  var titleColor = isActive ? this.activeColor : this.inactiveColor;
53
-
54
47
  if (titleColor) {
55
48
  style.color = titleColor;
56
- } // 可滚动的tabs,不对元素宽度进行限制
57
-
58
-
49
+ }
50
+ // 可滚动的tabs,不对元素宽度进行限制
59
51
  if (!this.scrollable) {
60
52
  style.maxWidth = this.maxWidth;
61
53
  } else {
62
54
  // tab之间的padding距离
63
- var OPTIONS_LABEL_PADDING = 24; // 限制最大展示7个字
64
-
65
- var LIMIT_WORDS_LEN = 7; // 根据实际是否激活状态,设置其字体宽度
66
-
55
+ var OPTIONS_LABEL_PADDING = 24;
56
+ // 限制最大展示7个字
57
+ var LIMIT_WORDS_LEN = 7;
58
+ // 根据实际是否激活状态,设置其字体宽度
67
59
  var FONT_SIZE = isActive ? 16 : 14;
68
60
  var scrollAbleWidth = OPTIONS_LABEL_PADDING + LIMIT_WORDS_LEN * FONT_SIZE + 'px';
69
61
  style.maxWidth = scrollAbleWidth;
70
62
  }
71
-
72
63
  return style;
73
64
  }
74
65
  },
@@ -83,7 +74,6 @@ var _default = createComponent({
83
74
  ellipsis: true
84
75
  })
85
76
  }, [this.slots() || this.title]);
86
-
87
77
  if (this.dot || (0, _utils.isDef)(this.info) && this.info !== '') {
88
78
  return h("span", {
89
79
  "class": bem('text-wrapper')
@@ -94,7 +84,6 @@ var _default = createComponent({
94
84
  }
95
85
  })]);
96
86
  }
97
-
98
87
  return Text;
99
88
  }
100
89
  },
@@ -117,5 +106,4 @@ var _default = createComponent({
117
106
  }, [this.genText()]), this.slots('suffix')]);
118
107
  }
119
108
  });
120
-
121
109
  exports.default = _default;
package/lib/tabs/index.js CHANGED
@@ -1,53 +1,37 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  exports.__esModule = true;
6
5
  exports.default = void 0;
7
-
8
6
  var _utils = require("../utils");
9
-
10
7
  var _utils2 = require("./utils");
11
-
12
8
  var _router = require("../utils/router");
13
-
14
9
  var _style = require("../utils/dom/style");
15
-
16
10
  var _event = require("../utils/dom/event");
17
-
18
11
  var _unit = require("../utils/format/unit");
19
-
20
12
  var _constant = require("../utils/constant");
21
-
22
13
  var _interceptor = require("../utils/interceptor");
23
-
24
14
  var _scroll = require("../utils/dom/scroll");
25
-
26
15
  var _relation = require("../mixins/relation");
27
-
28
16
  var _bindEvent = require("../mixins/bind-event");
29
-
30
17
  var _Title = _interopRequireDefault(require("./Title"));
31
-
32
18
  var _sticky = _interopRequireDefault(require("../sticky"));
33
-
34
19
  var _Content = _interopRequireDefault(require("./Content"));
35
-
36
20
  // Utils
21
+
37
22
  // Mixins
23
+
38
24
  // Components
39
- var _createNamespace = (0, _utils.createNamespace)('tabs'),
40
- createComponent = _createNamespace[0],
41
- bem = _createNamespace[1];
42
25
 
26
+ var _createNamespace = (0, _utils.createNamespace)('tabs'),
27
+ createComponent = _createNamespace[0],
28
+ bem = _createNamespace[1];
43
29
  var _default2 = createComponent({
44
30
  mixins: [(0, _relation.ParentMixin)('ztTabs'), (0, _bindEvent.BindEventMixin)(function (bind) {
45
31
  if (!this.scroller) {
46
32
  this.scroller = (0, _scroll.getScroller)(this.$el);
47
33
  }
48
-
49
34
  bind(window, 'resize', this.resize, true);
50
-
51
35
  if (this.scrollspy) {
52
36
  bind(this.scroller, 'scroll', this.onScroll, true);
53
37
  }
@@ -128,7 +112,6 @@ var _default2 = createComponent({
128
112
  },
129
113
  currentName: function currentName() {
130
114
  var activeTab = this.children[this.currentIndex];
131
-
132
115
  if (activeTab) {
133
116
  return activeTab.computedName;
134
117
  }
@@ -140,7 +123,6 @@ var _default2 = createComponent({
140
123
  if (this.sticky) {
141
124
  return this.offsetTopPx + this.tabHeight;
142
125
  }
143
-
144
126
  return 0;
145
127
  }
146
128
  },
@@ -153,7 +135,6 @@ var _default2 = createComponent({
153
135
  },
154
136
  children: function children() {
155
137
  var _this = this;
156
-
157
138
  this.setCurrentIndexByName(this.active);
158
139
  this.setLine();
159
140
  this.$nextTick(function () {
@@ -162,8 +143,9 @@ var _default2 = createComponent({
162
143
  },
163
144
  currentIndex: function currentIndex() {
164
145
  this.scrollIntoView();
165
- this.setLine(); // scroll to correct position
146
+ this.setLine();
166
147
 
148
+ // scroll to correct position
167
149
  if (this.stickyFixed && !this.scrollspy) {
168
150
  (0, _scroll.setRootScrollTop)(Math.ceil((0, _scroll.getElementTop)(this.$el) - this.offsetTopPx));
169
151
  }
@@ -178,9 +160,9 @@ var _default2 = createComponent({
178
160
  },
179
161
  mounted: function mounted() {
180
162
  var _this2 = this;
163
+ this.init();
181
164
 
182
- this.init(); // https://github.com/youzan/vant/issues/7959
183
-
165
+ // https://github.com/youzan/vant/issues/7959
184
166
  if (this.vanPopup) {
185
167
  this.vanPopup.onReopen(function () {
186
168
  _this2.setLine();
@@ -198,26 +180,21 @@ var _default2 = createComponent({
198
180
  },
199
181
  init: function init() {
200
182
  var _this3 = this;
201
-
202
183
  this.$nextTick(function () {
203
184
  _this3.inited = true;
204
185
  _this3.tabHeight = (0, _scroll.getVisibleHeight)(_this3.$refs.wrap);
205
-
206
186
  _this3.scrollIntoView(true);
207
187
  });
208
188
  },
209
189
  // update nav bar style
210
190
  setLine: function setLine() {
211
191
  var _this4 = this;
212
-
213
192
  var shouldAnimate = this.inited;
214
193
  this.$nextTick(function () {
215
194
  var titles = _this4.$refs.titles;
216
-
217
195
  if (!titles || !titles[_this4.currentIndex] || _this4.type !== 'line' || (0, _style.isHidden)(_this4.$el)) {
218
196
  return;
219
197
  }
220
-
221
198
  var title = titles[_this4.currentIndex].$el;
222
199
  var lineHeight = _this4.lineHeight;
223
200
  var left = title.offsetLeft + title.offsetWidth / 2;
@@ -226,17 +203,14 @@ var _default2 = createComponent({
226
203
  backgroundColor: _this4.color,
227
204
  transform: "translateX(" + left + "px) translateX(-50%)"
228
205
  };
229
-
230
206
  if (shouldAnimate) {
231
207
  lineStyle.transitionDuration = _this4.duration + "s";
232
208
  }
233
-
234
209
  if ((0, _utils.isDef)(lineHeight)) {
235
210
  var height = (0, _utils.addUnit)(lineHeight);
236
211
  lineStyle.height = height;
237
212
  lineStyle.borderRadius = height;
238
213
  }
239
-
240
214
  _this4.lineStyle = lineStyle;
241
215
  });
242
216
  },
@@ -250,19 +224,15 @@ var _default2 = createComponent({
250
224
  },
251
225
  setCurrentIndex: function setCurrentIndex(currentIndex) {
252
226
  var newIndex = this.findAvailableTab(currentIndex);
253
-
254
227
  if (!(0, _utils.isDef)(newIndex)) {
255
228
  return;
256
229
  }
257
-
258
230
  var newTab = this.children[newIndex];
259
231
  var newName = newTab.computedName;
260
232
  var shouldEmitChange = this.currentIndex !== null;
261
233
  this.currentIndex = newIndex;
262
-
263
234
  if (newName !== this.active) {
264
235
  this.$emit('input', newName);
265
-
266
236
  if (shouldEmitChange) {
267
237
  this.$emit('change', newName, newTab.title);
268
238
  }
@@ -270,24 +240,20 @@ var _default2 = createComponent({
270
240
  },
271
241
  findAvailableTab: function findAvailableTab(index) {
272
242
  var diff = index < this.currentIndex ? -1 : 1;
273
-
274
243
  while (index >= 0 && index < this.children.length) {
275
244
  if (!this.children[index].disabled) {
276
245
  return index;
277
246
  }
278
-
279
247
  index += diff;
280
248
  }
281
249
  },
282
250
  // emit event when clicked
283
251
  onClick: function onClick(item, index) {
284
252
  var _this5 = this;
285
-
286
253
  var _this$children$index = this.children[index],
287
- title = _this$children$index.title,
288
- disabled = _this$children$index.disabled,
289
- computedName = _this$children$index.computedName;
290
-
254
+ title = _this$children$index.title,
255
+ disabled = _this$children$index.disabled,
256
+ computedName = _this$children$index.computedName;
291
257
  if (disabled) {
292
258
  this.$emit('disabled', computedName, title);
293
259
  } else {
@@ -296,7 +262,6 @@ var _default2 = createComponent({
296
262
  args: [computedName],
297
263
  done: function done() {
298
264
  _this5.setCurrentIndex(index);
299
-
300
265
  _this5.scrollToCurrentContent();
301
266
  }
302
267
  });
@@ -307,11 +272,9 @@ var _default2 = createComponent({
307
272
  // scroll active tab into view
308
273
  scrollIntoView: function scrollIntoView(immediate) {
309
274
  var titles = this.$refs.titles;
310
-
311
275
  if (!this.scrollable || !titles || !titles[this.currentIndex]) {
312
276
  return;
313
277
  }
314
-
315
278
  var nav = this.$refs.nav;
316
279
  var title = titles[this.currentIndex].$el;
317
280
  var to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
@@ -324,24 +287,19 @@ var _default2 = createComponent({
324
287
  // @exposed-api
325
288
  scrollTo: function scrollTo(name) {
326
289
  var _this6 = this;
327
-
328
290
  this.$nextTick(function () {
329
291
  _this6.setCurrentIndexByName(name);
330
-
331
292
  _this6.scrollToCurrentContent(true);
332
293
  });
333
294
  },
334
295
  scrollToCurrentContent: function scrollToCurrentContent(immediate) {
335
296
  var _this7 = this;
336
-
337
297
  if (immediate === void 0) {
338
298
  immediate = false;
339
299
  }
340
-
341
300
  if (this.scrollspy) {
342
301
  var target = this.children[this.currentIndex];
343
302
  var el = target == null ? void 0 : target.$el;
344
-
345
303
  if (el) {
346
304
  var to = (0, _scroll.getElementTop)(el, this.scroller) - this.scrollOffset;
347
305
  this.lockScroll = true;
@@ -359,29 +317,24 @@ var _default2 = createComponent({
359
317
  },
360
318
  getCurrentIndexOnScroll: function getCurrentIndexOnScroll() {
361
319
  var children = this.children;
362
-
363
320
  for (var index = 0; index < children.length; index++) {
364
321
  var top = (0, _scroll.getVisibleTop)(children[index].$el);
365
-
366
322
  if (top > this.scrollOffset) {
367
323
  return index === 0 ? 0 : index - 1;
368
324
  }
369
325
  }
370
-
371
326
  return children.length - 1;
372
327
  }
373
328
  },
374
329
  render: function render() {
375
330
  var _this8 = this,
376
- _ref;
377
-
331
+ _ref;
378
332
  var h = arguments[0];
379
333
  var type = this.type,
380
- animated = this.animated,
381
- scrollable = this.scrollable;
334
+ animated = this.animated,
335
+ scrollable = this.scrollable;
382
336
  var Nav = this.children.map(function (item, index) {
383
337
  var _item$badge;
384
-
385
338
  return h(_Title.default, {
386
339
  "ref": "titles",
387
340
  "refInFor": true,
@@ -420,11 +373,9 @@ var _default2 = createComponent({
420
373
  var wrapStyle = {
421
374
  borderBottom: "none"
422
375
  };
423
-
424
376
  if (type !== 'card' && this.divider) {
425
377
  wrapStyle.borderBottom = "1px solid #eee";
426
378
  }
427
-
428
379
  var Wrap = h("div", {
429
380
  "ref": "wrap",
430
381
  "class": [bem('wrap', {
@@ -467,5 +418,4 @@ var _default2 = createComponent({
467
418
  }, [this.slots()])]);
468
419
  }
469
420
  });
470
-
471
421
  exports.default = _default2;
package/lib/tabs/utils.js CHANGED
@@ -3,51 +3,38 @@
3
3
  exports.__esModule = true;
4
4
  exports.scrollLeftTo = scrollLeftTo;
5
5
  exports.scrollTopTo = scrollTopTo;
6
-
7
6
  var _raf = require("../utils/dom/raf");
8
-
9
7
  var _scroll = require("../utils/dom/scroll");
10
-
11
8
  var scrollLeftRafId;
12
-
13
9
  function scrollLeftTo(scroller, to, duration) {
14
10
  (0, _raf.cancelRaf)(scrollLeftRafId);
15
11
  var count = 0;
16
12
  var from = scroller.scrollLeft;
17
13
  var frames = duration === 0 ? 1 : Math.round(duration * 1000 / 16);
18
-
19
14
  function animate() {
20
15
  scroller.scrollLeft += (to - from) / frames;
21
-
22
16
  if (++count < frames) {
23
17
  scrollLeftRafId = (0, _raf.raf)(animate);
24
18
  }
25
19
  }
26
-
27
20
  animate();
28
21
  }
29
-
30
22
  function scrollTopTo(scroller, to, duration, callback) {
31
23
  var current = (0, _scroll.getScrollTop)(scroller);
32
24
  var isDown = current < to;
33
25
  var frames = duration === 0 ? 1 : Math.round(duration * 1000 / 16);
34
26
  var step = (to - current) / frames;
35
-
36
27
  function animate() {
37
28
  current += step;
38
-
39
29
  if (isDown && current > to || !isDown && current < to) {
40
30
  current = to;
41
31
  }
42
-
43
32
  (0, _scroll.setScrollTop)(scroller, current);
44
-
45
33
  if (isDown && current < to || !isDown && current > to) {
46
34
  (0, _raf.raf)(animate);
47
35
  } else if (callback) {
48
36
  (0, _raf.raf)(callback);
49
37
  }
50
38
  }
51
-
52
39
  animate();
53
40
  }