umy-ui-table 1.2.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 (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/lib/button.js +1 -0
  4. package/lib/icon.js +1 -0
  5. package/lib/index.js +1 -0
  6. package/lib/locale/format.js +56 -0
  7. package/lib/locale/index.js +72 -0
  8. package/lib/locale/lang/en.js +123 -0
  9. package/lib/locale/lang/zh-CN.js +119 -0
  10. package/lib/mixins/locale.js +17 -0
  11. package/lib/theme-chalk/base.css +0 -0
  12. package/lib/theme-chalk/button.css +1 -0
  13. package/lib/theme-chalk/fonts/element-icons.ttf +0 -0
  14. package/lib/theme-chalk/fonts/element-icons.woff +0 -0
  15. package/lib/theme-chalk/fonts/iconfont.1785562768224.ttf +0 -0
  16. package/lib/theme-chalk/fonts/iconfont.1785562768224.woff +0 -0
  17. package/lib/theme-chalk/fonts/iconfont.1785562768224.woff2 +0 -0
  18. package/lib/theme-chalk/icon.css +1 -0
  19. package/lib/theme-chalk/index.css +1 -0
  20. package/lib/theme-chalk/u-table-column.css +0 -0
  21. package/lib/theme-chalk/u-table.css +1 -0
  22. package/lib/theme-chalk/ux-grid.css +1 -0
  23. package/lib/theme-chalk/ux-table-column.css +0 -0
  24. package/lib/u-table-column.js +1 -0
  25. package/lib/u-table.js +1 -0
  26. package/lib/umd/locale/en.js +139 -0
  27. package/lib/umd/locale/zh-CN.js +135 -0
  28. package/lib/umy-ui.common.js +1 -0
  29. package/lib/utils/svg.js +33 -0
  30. package/lib/utils/types.js +35 -0
  31. package/lib/utils/util.js +268 -0
  32. package/lib/ux-grid.js +1 -0
  33. package/lib/ux-table-column.js +1 -0
  34. package/package.json +117 -0
  35. package/packages/button/index.js +7 -0
  36. package/packages/button/src/button-group.vue +10 -0
  37. package/packages/button/src/button.vue +166 -0
  38. package/packages/checkbox/index.js +8 -0
  39. package/packages/checkbox/src/checkbox-button.vue +199 -0
  40. package/packages/checkbox/src/checkbox-group.vue +48 -0
  41. package/packages/checkbox/src/checkbox.vue +222 -0
  42. package/packages/checkbox-button/index.js +8 -0
  43. package/packages/checkbox-group/index.js +8 -0
  44. package/packages/icon/index.js +7 -0
  45. package/packages/icon/src/icon.vue +40 -0
  46. package/packages/input/index.js +2 -0
  47. package/packages/input/src/calcTextareaHeight.js +104 -0
  48. package/packages/input/src/input.vue +424 -0
  49. package/packages/option/index.js +2 -0
  50. package/packages/pagination/index.js +2 -0
  51. package/packages/pagination/src/pager.vue +163 -0
  52. package/packages/pagination/src/pagination.js +386 -0
  53. package/packages/scrollbar/index.js +8 -0
  54. package/packages/scrollbar/src/bar.js +92 -0
  55. package/packages/scrollbar/src/main.js +130 -0
  56. package/packages/scrollbar/src/util.js +34 -0
  57. package/packages/select/index.js +2 -0
  58. package/packages/select/src/navigation-mixin.js +54 -0
  59. package/packages/select/src/option-group.vue +60 -0
  60. package/packages/select/src/option.vue +163 -0
  61. package/packages/select/src/select-dropdown.vue +74 -0
  62. package/packages/select/src/select.vue +889 -0
  63. package/packages/table/index.js +8 -0
  64. package/packages/table/src/config.js +123 -0
  65. package/packages/table/src/dropdown.js +28 -0
  66. package/packages/table/src/filter-panel.vue +194 -0
  67. package/packages/table/src/layout-observer.js +68 -0
  68. package/packages/table/src/store/current.js +71 -0
  69. package/packages/table/src/store/expand.js +65 -0
  70. package/packages/table/src/store/helper.js +37 -0
  71. package/packages/table/src/store/index.js +145 -0
  72. package/packages/table/src/store/tree.js +208 -0
  73. package/packages/table/src/store/watcher.js +448 -0
  74. package/packages/table/src/table-body.js +493 -0
  75. package/packages/table/src/table-column.js +381 -0
  76. package/packages/table/src/table-footer.js +174 -0
  77. package/packages/table/src/table-header.js +537 -0
  78. package/packages/table/src/table-layout.js +231 -0
  79. package/packages/table/src/table.vue +741 -0
  80. package/packages/table/src/util.js +256 -0
  81. package/packages/tag/index.js +8 -0
  82. package/packages/tag/src/tag.vue +58 -0
  83. package/packages/tools/directives/mousewheel.js +18 -0
  84. package/packages/tools/directives/repeat-click.js +24 -0
  85. package/packages/tools/locale/format.js +46 -0
  86. package/packages/tools/locale/index.js +48 -0
  87. package/packages/tools/locale/lang/en.js +120 -0
  88. package/packages/tools/locale/lang/zh-CN.js +116 -0
  89. package/packages/tools/mixins/emitter.js +33 -0
  90. package/packages/tools/mixins/focus.js +9 -0
  91. package/packages/tools/mixins/locale.js +9 -0
  92. package/packages/tools/mixins/migrating.js +54 -0
  93. package/packages/tools/transitions/collapse-transition.js +77 -0
  94. package/packages/tools/utils/after-leave.js +27 -0
  95. package/packages/tools/utils/aria-dialog.js +90 -0
  96. package/packages/tools/utils/aria-utils.js +122 -0
  97. package/packages/tools/utils/clickoutside.js +76 -0
  98. package/packages/tools/utils/date-util.js +292 -0
  99. package/packages/tools/utils/date.js +368 -0
  100. package/packages/tools/utils/dom.js +227 -0
  101. package/packages/tools/utils/menu/aria-menubar.js +14 -0
  102. package/packages/tools/utils/menu/aria-menuitem.js +49 -0
  103. package/packages/tools/utils/menu/aria-submenu.js +59 -0
  104. package/packages/tools/utils/merge.js +15 -0
  105. package/packages/tools/utils/popper.js +1276 -0
  106. package/packages/tools/utils/popup/index.js +218 -0
  107. package/packages/tools/utils/popup/popup-manager.js +194 -0
  108. package/packages/tools/utils/resize-event.js +35 -0
  109. package/packages/tools/utils/scroll-into-view.js +27 -0
  110. package/packages/tools/utils/scrollbar-width.js +29 -0
  111. package/packages/tools/utils/shared.js +7 -0
  112. package/packages/tools/utils/svg.js +1 -0
  113. package/packages/tools/utils/types.js +28 -0
  114. package/packages/tools/utils/util.js +241 -0
  115. package/packages/tools/utils/vdom.js +5 -0
  116. package/packages/tools/utils/vue-popper.js +198 -0
  117. package/packages/tooltip/index.js +8 -0
  118. package/packages/tooltip/src/main.js +241 -0
  119. package/packages/u-table/index.js +4 -0
  120. package/packages/u-table/revise-el-table-mixins/index.js +10 -0
  121. package/packages/u-table/revise-el-table-mixins/table-extend.js +60 -0
  122. package/packages/u-table/revise-el-table-mixins/table.mixins.js +261 -0
  123. package/packages/u-table/revise-el-table-mixins/virtual-table-body-render.js +132 -0
  124. package/packages/u-table/src/u-table.vue +248 -0
  125. package/packages/u-table/u-table-mixins/index.js +483 -0
  126. package/packages/u-table/u-table-tree-mixins/methods.js +120 -0
  127. package/packages/u-table/u-table-tree-mixins/u-table-tree-mixins.js +161 -0
  128. package/packages/u-table-column/index.js +8 -0
  129. package/packages/utils/common.js +27 -0
  130. package/packages/ux-grid/index.js +6 -0
  131. package/packages/ux-grid/mixins/index.js +707 -0
  132. package/packages/ux-grid/src/interceptor.js +6 -0
  133. package/packages/ux-grid/src/ux-grid.vue +301 -0
  134. package/packages/ux-table-column/index.js +10 -0
  135. package/tools/locale/format.js +46 -0
  136. package/tools/locale/index.js +54 -0
  137. package/tools/locale/lang/en.js +120 -0
  138. package/tools/locale/lang/zh-CN.js +116 -0
  139. package/tools/mixins/locale.js +9 -0
  140. package/tools/utils/svg.js +1 -0
  141. package/tools/utils/types.js +28 -0
  142. package/tools/utils/util.js +241 -0
@@ -0,0 +1,386 @@
1
+ import Pager from './pager.vue';
2
+ import ElSelect from '../../select';
3
+ import ElOption from '../../option';
4
+ import ElInput from '../../input';
5
+ import Locale from '../../tools/mixins/locale';
6
+ import { valueEquals } from '../../tools/utils/util';
7
+
8
+ export default {
9
+ name: 'ElPagination',
10
+
11
+ props: {
12
+ pageSize: {
13
+ type: Number,
14
+ default: 10
15
+ },
16
+
17
+ small: Boolean,
18
+
19
+ total: Number,
20
+
21
+ pageCount: Number,
22
+
23
+ pagerCount: {
24
+ type: Number,
25
+ validator(value) {
26
+ return (value | 0) === value && value > 4 && value < 22 && (value % 2) === 1;
27
+ },
28
+ default: 7
29
+ },
30
+
31
+ currentPage: {
32
+ type: Number,
33
+ default: 1
34
+ },
35
+
36
+ layout: {
37
+ default: 'prev, pager, next, jumper, ->, total'
38
+ },
39
+
40
+ pageSizes: {
41
+ type: Array,
42
+ default() {
43
+ return [10, 20, 30, 40, 50, 100];
44
+ }
45
+ },
46
+
47
+ popperClass: String,
48
+
49
+ prevText: String,
50
+
51
+ nextText: String,
52
+
53
+ background: Boolean,
54
+
55
+ disabled: Boolean,
56
+
57
+ hideOnSinglePage: Boolean
58
+ },
59
+
60
+ data() {
61
+ return {
62
+ internalCurrentPage: 1,
63
+ internalPageSize: 0,
64
+ lastEmittedPage: -1,
65
+ userChangePageSize: false
66
+ };
67
+ },
68
+
69
+ render(h) {
70
+ const layout = this.layout;
71
+ if (!layout) return null;
72
+ if (this.hideOnSinglePage && (!this.internalPageCount || this.internalPageCount === 1)) return null;
73
+
74
+ let template = <div class={['el-pagination', {
75
+ 'is-background': this.background,
76
+ 'el-pagination--small': this.small
77
+ }] }></div>;
78
+ const TEMPLATE_MAP = {
79
+ prev: <prev></prev>,
80
+ jumper: <jumper></jumper>,
81
+ pager: <pager currentPage={ this.internalCurrentPage } pageCount={ this.internalPageCount } pagerCount={ this.pagerCount } on-change={ this.handleCurrentChange } disabled={ this.disabled }></pager>,
82
+ next: <next></next>,
83
+ sizes: <sizes pageSizes={ this.pageSizes }></sizes>,
84
+ slot: <slot>{ this.$slots.default ? this.$slots.default : '' }</slot>,
85
+ total: <total></total>
86
+ };
87
+ const components = layout.split(',').map((item) => item.trim());
88
+ const rightWrapper = <div class="el-pagination__rightwrapper"></div>;
89
+ let haveRightWrapper = false;
90
+
91
+ template.children = template.children || [];
92
+ rightWrapper.children = rightWrapper.children || [];
93
+ components.forEach(compo => {
94
+ if (compo === '->') {
95
+ haveRightWrapper = true;
96
+ return;
97
+ }
98
+
99
+ if (!haveRightWrapper) {
100
+ template.children.push(TEMPLATE_MAP[compo]);
101
+ } else {
102
+ rightWrapper.children.push(TEMPLATE_MAP[compo]);
103
+ }
104
+ });
105
+
106
+ if (haveRightWrapper) {
107
+ template.children.unshift(rightWrapper);
108
+ }
109
+
110
+ return template;
111
+ },
112
+
113
+ components: {
114
+ Prev: {
115
+ render(h) {
116
+ return (
117
+ <button
118
+ type="button"
119
+ class="btn-prev"
120
+ disabled={ this.$parent.disabled || this.$parent.internalCurrentPage <= 1 }
121
+ on-click={ this.$parent.prev }>
122
+ {
123
+ this.$parent.prevText
124
+ ? <span>{ this.$parent.prevText }</span>
125
+ : <i class="el-icon el-icon-arrow-left"></i>
126
+ }
127
+ </button>
128
+ );
129
+ }
130
+ },
131
+
132
+ Next: {
133
+ render(h) {
134
+ return (
135
+ <button
136
+ type="button"
137
+ class="btn-next"
138
+ disabled={ this.$parent.disabled || this.$parent.internalCurrentPage === this.$parent.internalPageCount || this.$parent.internalPageCount === 0 }
139
+ on-click={ this.$parent.next }>
140
+ {
141
+ this.$parent.nextText
142
+ ? <span>{ this.$parent.nextText }</span>
143
+ : <i class="el-icon el-icon-arrow-right"></i>
144
+ }
145
+ </button>
146
+ );
147
+ }
148
+ },
149
+
150
+ Sizes: {
151
+ mixins: [Locale],
152
+
153
+ props: {
154
+ pageSizes: Array
155
+ },
156
+
157
+ watch: {
158
+ pageSizes: {
159
+ immediate: true,
160
+ handler(newVal, oldVal) {
161
+ if (valueEquals(newVal, oldVal)) return;
162
+ if (Array.isArray(newVal)) {
163
+ this.$parent.internalPageSize = newVal.indexOf(this.$parent.pageSize) > -1
164
+ ? this.$parent.pageSize
165
+ : this.pageSizes[0];
166
+ }
167
+ }
168
+ }
169
+ },
170
+
171
+ render(h) {
172
+ return (
173
+ <span class="el-pagination__sizes">
174
+ <el-select
175
+ value={ this.$parent.internalPageSize }
176
+ popperClass={ this.$parent.popperClass || '' }
177
+ size="mini"
178
+ on-input={ this.handleChange }
179
+ disabled={ this.$parent.disabled }>
180
+ {
181
+ this.pageSizes.map(item =>
182
+ <el-option
183
+ value={ item }
184
+ label={ item + this.t('el.pagination.pagesize') }>
185
+ </el-option>
186
+ )
187
+ }
188
+ </el-select>
189
+ </span>
190
+ );
191
+ },
192
+
193
+ components: {
194
+ ElSelect,
195
+ ElOption
196
+ },
197
+
198
+ methods: {
199
+ handleChange(val) {
200
+ if (val !== this.$parent.internalPageSize) {
201
+ this.$parent.internalPageSize = val = parseInt(val, 10);
202
+ this.$parent.userChangePageSize = true;
203
+ this.$parent.$emit('update:pageSize', val);
204
+ this.$parent.$emit('size-change', val);
205
+ }
206
+ }
207
+ }
208
+ },
209
+
210
+ Jumper: {
211
+ mixins: [Locale],
212
+
213
+ components: { ElInput },
214
+
215
+ data() {
216
+ return {
217
+ userInput: null
218
+ };
219
+ },
220
+
221
+ watch: {
222
+ '$parent.internalCurrentPage'() {
223
+ this.userInput = null;
224
+ }
225
+ },
226
+
227
+ methods: {
228
+ handleKeyup({ keyCode, target }) {
229
+ // Chrome, Safari, Firefox triggers change event on Enter
230
+ // Hack for IE: https://github.com/ElemeFE/element/issues/11710
231
+ // Drop this method when we no longer supports IE
232
+ if (keyCode === 13) {
233
+ this.handleChange(target.value);
234
+ }
235
+ },
236
+ handleInput(value) {
237
+ this.userInput = value;
238
+ },
239
+ handleChange(value) {
240
+ this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(value);
241
+ this.$parent.emitChange();
242
+ this.userInput = null;
243
+ }
244
+ },
245
+
246
+ render(h) {
247
+ return (
248
+ <span class="el-pagination__jump">
249
+ { this.t('el.pagination.goto') }
250
+ <el-input
251
+ class="el-pagination__editor is-in-pagination"
252
+ min={ 1 }
253
+ max={ this.$parent.internalPageCount }
254
+ value={ this.userInput !== null ? this.userInput : this.$parent.internalCurrentPage }
255
+ type="number"
256
+ disabled={ this.$parent.disabled }
257
+ nativeOnKeyup={ this.handleKeyup }
258
+ onInput={ this.handleInput }
259
+ onChange={ this.handleChange }/>
260
+ { this.t('el.pagination.pageClassifier') }
261
+ </span>
262
+ );
263
+ }
264
+ },
265
+
266
+ Total: {
267
+ mixins: [Locale],
268
+
269
+ render(h) {
270
+ return (
271
+ typeof this.$parent.total === 'number'
272
+ ? <span class="el-pagination__total">{ this.t('el.pagination.total', { total: this.$parent.total }) }</span>
273
+ : ''
274
+ );
275
+ }
276
+ },
277
+
278
+ Pager
279
+ },
280
+
281
+ methods: {
282
+ handleCurrentChange(val) {
283
+ this.internalCurrentPage = this.getValidCurrentPage(val);
284
+ this.userChangePageSize = true;
285
+ this.emitChange();
286
+ },
287
+
288
+ prev() {
289
+ if (this.disabled) return;
290
+ const newVal = this.internalCurrentPage - 1;
291
+ this.internalCurrentPage = this.getValidCurrentPage(newVal);
292
+ this.$emit('prev-click', this.internalCurrentPage);
293
+ this.emitChange();
294
+ },
295
+
296
+ next() {
297
+ if (this.disabled) return;
298
+ const newVal = this.internalCurrentPage + 1;
299
+ this.internalCurrentPage = this.getValidCurrentPage(newVal);
300
+ this.$emit('next-click', this.internalCurrentPage);
301
+ this.emitChange();
302
+ },
303
+
304
+ getValidCurrentPage(value) {
305
+ value = parseInt(value, 10);
306
+
307
+ const havePageCount = typeof this.internalPageCount === 'number';
308
+
309
+ let resetValue;
310
+ if (!havePageCount) {
311
+ if (isNaN(value) || value < 1) resetValue = 1;
312
+ } else {
313
+ if (value < 1) {
314
+ resetValue = 1;
315
+ } else if (value > this.internalPageCount) {
316
+ resetValue = this.internalPageCount;
317
+ }
318
+ }
319
+
320
+ if (resetValue === undefined && isNaN(value)) {
321
+ resetValue = 1;
322
+ } else if (resetValue === 0) {
323
+ resetValue = 1;
324
+ }
325
+
326
+ return resetValue === undefined ? value : resetValue;
327
+ },
328
+
329
+ emitChange() {
330
+ this.$nextTick(() => {
331
+ if (this.internalCurrentPage !== this.lastEmittedPage || this.userChangePageSize) {
332
+ this.$emit('current-change', this.internalCurrentPage);
333
+ this.lastEmittedPage = this.internalCurrentPage;
334
+ this.userChangePageSize = false;
335
+ }
336
+ });
337
+ }
338
+ },
339
+
340
+ computed: {
341
+ internalPageCount() {
342
+ if (typeof this.total === 'number') {
343
+ return Math.max(1, Math.ceil(this.total / this.internalPageSize));
344
+ } else if (typeof this.pageCount === 'number') {
345
+ return Math.max(1, this.pageCount);
346
+ }
347
+ return null;
348
+ }
349
+ },
350
+
351
+ watch: {
352
+ currentPage: {
353
+ immediate: true,
354
+ handler(val) {
355
+ this.internalCurrentPage = this.getValidCurrentPage(val);
356
+ }
357
+ },
358
+
359
+ pageSize: {
360
+ immediate: true,
361
+ handler(val) {
362
+ this.internalPageSize = isNaN(val) ? 10 : val;
363
+ }
364
+ },
365
+
366
+ internalCurrentPage: {
367
+ immediate: true,
368
+ handler(newVal) {
369
+ this.$emit('update:currentPage', newVal);
370
+ this.lastEmittedPage = -1;
371
+ }
372
+ },
373
+
374
+ internalPageCount(newVal) {
375
+ /* istanbul ignore if */
376
+ const oldPage = this.internalCurrentPage;
377
+ if (newVal > 0 && oldPage === 0) {
378
+ this.internalCurrentPage = 1;
379
+ } else if (oldPage > newVal) {
380
+ this.internalCurrentPage = newVal === 0 ? 1 : newVal;
381
+ this.userChangePageSize && this.emitChange();
382
+ }
383
+ this.userChangePageSize = false;
384
+ }
385
+ }
386
+ };
@@ -0,0 +1,8 @@
1
+ import Scrollbar from './src/main';
2
+
3
+ /* istanbul ignore next */
4
+ Scrollbar.install = function(Vue) {
5
+ Vue.component(Scrollbar.name, Scrollbar);
6
+ };
7
+
8
+ export default Scrollbar;
@@ -0,0 +1,92 @@
1
+ import { on, off } from '../../tools/utils/dom';
2
+ import { renderThumbStyle, BAR_MAP } from './util';
3
+
4
+ /* istanbul ignore next */
5
+ export default {
6
+ name: 'Bar',
7
+
8
+ props: {
9
+ vertical: Boolean,
10
+ size: String,
11
+ move: Number
12
+ },
13
+
14
+ computed: {
15
+ bar() {
16
+ return BAR_MAP[this.vertical ? 'vertical' : 'horizontal'];
17
+ },
18
+
19
+ wrap() {
20
+ return this.$parent.wrap;
21
+ }
22
+ },
23
+
24
+ render(h) {
25
+ const { size, move, bar } = this;
26
+
27
+ return (
28
+ <div
29
+ class={ ['el-scrollbar__bar', 'is-' + bar.key] }
30
+ onMousedown={ this.clickTrackHandler } >
31
+ <div
32
+ ref="thumb"
33
+ class="el-scrollbar__thumb"
34
+ onMousedown={ this.clickThumbHandler }
35
+ style={ renderThumbStyle({ size, move, bar }) }>
36
+ </div>
37
+ </div>
38
+ );
39
+ },
40
+
41
+ methods: {
42
+ clickThumbHandler(e) {
43
+ // prevent click event of right button
44
+ if (e.ctrlKey || e.button === 2) {
45
+ return;
46
+ }
47
+ this.startDrag(e);
48
+ this[this.bar.axis] = (e.currentTarget[this.bar.offset] - (e[this.bar.client] - e.currentTarget.getBoundingClientRect()[this.bar.direction]));
49
+ },
50
+
51
+ clickTrackHandler(e) {
52
+ const offset = Math.abs(e.target.getBoundingClientRect()[this.bar.direction] - e[this.bar.client]);
53
+ const thumbHalf = (this.$refs.thumb[this.bar.offset] / 2);
54
+ const thumbPositionPercentage = ((offset - thumbHalf) * 100 / this.$el[this.bar.offset]);
55
+
56
+ this.wrap[this.bar.scroll] = (thumbPositionPercentage * this.wrap[this.bar.scrollSize] / 100);
57
+ },
58
+
59
+ startDrag(e) {
60
+ e.stopImmediatePropagation();
61
+ this.cursorDown = true;
62
+
63
+ on(document, 'mousemove', this.mouseMoveDocumentHandler);
64
+ on(document, 'mouseup', this.mouseUpDocumentHandler);
65
+ document.onselectstart = () => false;
66
+ },
67
+
68
+ mouseMoveDocumentHandler(e) {
69
+ if (this.cursorDown === false) return;
70
+ const prevPage = this[this.bar.axis];
71
+
72
+ if (!prevPage) return;
73
+
74
+ const offset = ((this.$el.getBoundingClientRect()[this.bar.direction] - e[this.bar.client]) * -1);
75
+ const thumbClickPosition = (this.$refs.thumb[this.bar.offset] - prevPage);
76
+ const thumbPositionPercentage = ((offset - thumbClickPosition) * 100 / this.$el[this.bar.offset]);
77
+
78
+ this.wrap[this.bar.scroll] = (thumbPositionPercentage * this.wrap[this.bar.scrollSize] / 100);
79
+ },
80
+
81
+ mouseUpDocumentHandler(e) {
82
+ this.cursorDown = false;
83
+ this[this.bar.axis] = 0;
84
+ off(document, 'mousemove', this.mouseMoveDocumentHandler);
85
+ document.onselectstart = null;
86
+ }
87
+ },
88
+
89
+ destroyed() {
90
+ off(document, 'mouseup', this.mouseUpDocumentHandler);
91
+ }
92
+ };
@@ -0,0 +1,130 @@
1
+ // reference https://github.com/noeldelgado/gemini-scrollbar/blob/master/index.js
2
+
3
+ import { addResizeListener, removeResizeListener } from '../../tools/utils/resize-event';
4
+ import scrollbarWidth from '../../tools/utils/scrollbar-width';
5
+ import { toObject } from '../../tools/utils/util';
6
+ import Bar from './bar';
7
+
8
+ /* istanbul ignore next */
9
+ export default {
10
+ name: 'ElScrollbar',
11
+
12
+ components: { Bar },
13
+
14
+ props: {
15
+ native: Boolean,
16
+ wrapStyle: {},
17
+ wrapClass: {},
18
+ viewClass: {},
19
+ viewStyle: {},
20
+ noresize: Boolean, // 如果 container 尺寸不会发生变化,最好设置它可以优化性能
21
+ tag: {
22
+ type: String,
23
+ default: 'div'
24
+ }
25
+ },
26
+
27
+ data() {
28
+ return {
29
+ sizeWidth: '0',
30
+ sizeHeight: '0',
31
+ moveX: 0,
32
+ moveY: 0
33
+ };
34
+ },
35
+
36
+ computed: {
37
+ wrap() {
38
+ return this.$refs.wrap;
39
+ }
40
+ },
41
+
42
+ render(h) {
43
+ let gutter = scrollbarWidth();
44
+ let style = this.wrapStyle;
45
+
46
+ if (gutter) {
47
+ const gutterWith = `-${gutter}px`;
48
+ const gutterStyle = `margin-bottom: ${gutterWith}; margin-right: ${gutterWith};`;
49
+
50
+ if (Array.isArray(this.wrapStyle)) {
51
+ style = toObject(this.wrapStyle);
52
+ style.marginRight = style.marginBottom = gutterWith;
53
+ } else if (typeof this.wrapStyle === 'string') {
54
+ style += gutterStyle;
55
+ } else {
56
+ style = gutterStyle;
57
+ }
58
+ }
59
+ const view = h(this.tag, {
60
+ class: ['el-scrollbar__view', this.viewClass],
61
+ style: this.viewStyle,
62
+ ref: 'resize'
63
+ }, this.$slots.default);
64
+ const wrap = (
65
+ <div
66
+ ref="wrap"
67
+ style={ style }
68
+ onScroll={ this.handleScroll }
69
+ class={ [this.wrapClass, 'el-scrollbar__wrap', gutter ? '' : 'el-scrollbar__wrap--hidden-default'] }>
70
+ { [view] }
71
+ </div>
72
+ );
73
+ let nodes;
74
+
75
+ if (!this.native) {
76
+ nodes = ([
77
+ wrap,
78
+ <Bar
79
+ move={ this.moveX }
80
+ size={ this.sizeWidth }></Bar>,
81
+ <Bar
82
+ vertical
83
+ move={ this.moveY }
84
+ size={ this.sizeHeight }></Bar>
85
+ ]);
86
+ } else {
87
+ nodes = ([
88
+ <div
89
+ ref="wrap"
90
+ class={ [this.wrapClass, 'el-scrollbar__wrap'] }
91
+ style={ style }>
92
+ { [view] }
93
+ </div>
94
+ ]);
95
+ }
96
+ return h('div', { class: 'el-scrollbar' }, nodes);
97
+ },
98
+
99
+ methods: {
100
+ handleScroll() {
101
+ const wrap = this.wrap;
102
+
103
+ this.moveY = ((wrap.scrollTop * 100) / wrap.clientHeight);
104
+ this.moveX = ((wrap.scrollLeft * 100) / wrap.clientWidth);
105
+ },
106
+
107
+ update() {
108
+ let heightPercentage, widthPercentage;
109
+ const wrap = this.wrap;
110
+ if (!wrap) return;
111
+
112
+ heightPercentage = (wrap.clientHeight * 100 / wrap.scrollHeight);
113
+ widthPercentage = (wrap.clientWidth * 100 / wrap.scrollWidth);
114
+
115
+ this.sizeHeight = (heightPercentage < 100) ? (heightPercentage + '%') : '';
116
+ this.sizeWidth = (widthPercentage < 100) ? (widthPercentage + '%') : '';
117
+ }
118
+ },
119
+
120
+ mounted() {
121
+ if (this.native) return;
122
+ this.$nextTick(this.update);
123
+ !this.noresize && addResizeListener(this.$refs.resize, this.update);
124
+ },
125
+
126
+ beforeDestroy() {
127
+ if (this.native) return;
128
+ !this.noresize && removeResizeListener(this.$refs.resize, this.update);
129
+ }
130
+ };
@@ -0,0 +1,34 @@
1
+ export const BAR_MAP = {
2
+ vertical: {
3
+ offset: 'offsetHeight',
4
+ scroll: 'scrollTop',
5
+ scrollSize: 'scrollHeight',
6
+ size: 'height',
7
+ key: 'vertical',
8
+ axis: 'Y',
9
+ client: 'clientY',
10
+ direction: 'top'
11
+ },
12
+ horizontal: {
13
+ offset: 'offsetWidth',
14
+ scroll: 'scrollLeft',
15
+ scrollSize: 'scrollWidth',
16
+ size: 'width',
17
+ key: 'horizontal',
18
+ axis: 'X',
19
+ client: 'clientX',
20
+ direction: 'left'
21
+ }
22
+ };
23
+
24
+ export function renderThumbStyle({ move, size, bar }) {
25
+ const style = {};
26
+ const translate = `translate${bar.axis}(${ move }%)`;
27
+
28
+ style[bar.size] = size;
29
+ style.transform = translate;
30
+ style.msTransform = translate;
31
+ style.webkitTransform = translate;
32
+
33
+ return style;
34
+ };
@@ -0,0 +1,2 @@
1
+ import Select from './src/select';
2
+ export default Select;
@@ -0,0 +1,54 @@
1
+ export default {
2
+ data() {
3
+ return {
4
+ hoverOption: -1
5
+ };
6
+ },
7
+
8
+ computed: {
9
+ optionsAllDisabled() {
10
+ return this.options.filter(option => option.visible).every(option => option.disabled);
11
+ }
12
+ },
13
+
14
+ watch: {
15
+ hoverIndex(val) {
16
+ if (typeof val === 'number' && val > -1) {
17
+ this.hoverOption = this.options[val] || {};
18
+ }
19
+ this.options.forEach(option => {
20
+ option.hover = this.hoverOption === option;
21
+ });
22
+ }
23
+ },
24
+
25
+ methods: {
26
+ navigateOptions(direction) {
27
+ if (!this.visible) {
28
+ this.visible = true;
29
+ return;
30
+ }
31
+ if (this.options.length === 0 || this.filteredOptionsCount === 0) return;
32
+ if (!this.optionsAllDisabled) {
33
+ if (direction === 'next') {
34
+ this.hoverIndex++;
35
+ if (this.hoverIndex === this.options.length) {
36
+ this.hoverIndex = 0;
37
+ }
38
+ } else if (direction === 'prev') {
39
+ this.hoverIndex--;
40
+ if (this.hoverIndex < 0) {
41
+ this.hoverIndex = this.options.length - 1;
42
+ }
43
+ }
44
+ const option = this.options[this.hoverIndex];
45
+ if (option.disabled === true ||
46
+ option.groupDisabled === true ||
47
+ !option.visible) {
48
+ this.navigateOptions(direction);
49
+ }
50
+ this.$nextTick(() => this.scrollToOption(this.hoverOption));
51
+ }
52
+ }
53
+ }
54
+ };