@zkwq/business 0.0.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 (231) hide show
  1. package/dist/index.css +1 -0
  2. package/dist/index.js +21861 -0
  3. package/dist/index.umd.cjs +46 -0
  4. package/package.json +27 -0
  5. package/src/components/base/ui/alert/Alert.vue +94 -0
  6. package/src/components/base/ui/autocomplete/autocomplete-suggestions.vue +77 -0
  7. package/src/components/base/ui/autocomplete/autocomplete.vue +305 -0
  8. package/src/components/base/ui/backtop/main.vue +112 -0
  9. package/src/components/base/ui/button/Button.vue +84 -0
  10. package/src/components/base/ui/button/ButtonGroup.vue +10 -0
  11. package/src/components/base/ui/carousel/Carousel.vue +304 -0
  12. package/src/components/base/ui/carousel/CarouselItem.vue +137 -0
  13. package/src/components/base/ui/cascader/cascader.vue +650 -0
  14. package/src/components/base/ui/cascader-panel/cascader-menu.vue +138 -0
  15. package/src/components/base/ui/cascader-panel/cascader-node.vue +246 -0
  16. package/src/components/base/ui/cascader-panel/cascader-panel.vue +382 -0
  17. package/src/components/base/ui/cascader-panel/node.js +166 -0
  18. package/src/components/base/ui/cascader-panel/store.js +62 -0
  19. package/src/components/base/ui/checkbox/checkbox-button.vue +199 -0
  20. package/src/components/base/ui/checkbox/checkbox-group.vue +48 -0
  21. package/src/components/base/ui/checkbox/checkbox.vue +222 -0
  22. package/src/components/base/ui/col/col.js +71 -0
  23. package/src/components/base/ui/collapse/collapse-item.vue +180 -0
  24. package/src/components/base/ui/collapse/collapse.vue +73 -0
  25. package/src/components/base/ui/color-picker/color.js +317 -0
  26. package/src/components/base/ui/color-picker/components/alpha-slider.vue +132 -0
  27. package/src/components/base/ui/color-picker/components/hue-slider.vue +123 -0
  28. package/src/components/base/ui/color-picker/components/picker-dropdown.vue +119 -0
  29. package/src/components/base/ui/color-picker/components/predefine.vue +61 -0
  30. package/src/components/base/ui/color-picker/components/sv-panel.vue +100 -0
  31. package/src/components/base/ui/color-picker/draggable.js +36 -0
  32. package/src/components/base/ui/color-picker/index.js +2 -0
  33. package/src/components/base/ui/color-picker/main.vue +188 -0
  34. package/src/components/base/ui/date-picker/basic/date-table.vue +441 -0
  35. package/src/components/base/ui/date-picker/basic/month-table.vue +254 -0
  36. package/src/components/base/ui/date-picker/basic/time-spinner.vue +304 -0
  37. package/src/components/base/ui/date-picker/basic/year-table.vue +101 -0
  38. package/src/components/base/ui/date-picker/panel/date-range.vue +680 -0
  39. package/src/components/base/ui/date-picker/panel/date.vue +597 -0
  40. package/src/components/base/ui/date-picker/panel/month-range.vue +289 -0
  41. package/src/components/base/ui/date-picker/panel/time-range.vue +248 -0
  42. package/src/components/base/ui/date-picker/panel/time-select.vue +178 -0
  43. package/src/components/base/ui/date-picker/panel/time.vue +186 -0
  44. package/src/components/base/ui/date-picker/picker/date-picker.js +43 -0
  45. package/src/components/base/ui/date-picker/picker/time-picker.js +39 -0
  46. package/src/components/base/ui/date-picker/picker/time-select.js +21 -0
  47. package/src/components/base/ui/date-picker/picker.vue +942 -0
  48. package/src/components/base/ui/dialog/Index.vue +212 -0
  49. package/src/components/base/ui/directive/repeat-click.js +24 -0
  50. package/src/components/base/ui/directive/ripple.js +303 -0
  51. package/src/components/base/ui/divider/Divider.vue +37 -0
  52. package/src/components/base/ui/drawer/Drawer.vue +202 -0
  53. package/src/components/base/ui/dropdown/dropdown-item.vue +39 -0
  54. package/src/components/base/ui/dropdown/dropdown-menu.vue +63 -0
  55. package/src/components/base/ui/dropdown/dropdown.vue +308 -0
  56. package/src/components/base/ui/form/Form.vue +167 -0
  57. package/src/components/base/ui/form/FormItem.vue +334 -0
  58. package/src/components/base/ui/form/LabelWrap.vue +69 -0
  59. package/src/components/base/ui/icon/icon.vue +13 -0
  60. package/src/components/base/ui/image/image-viewer.vue +302 -0
  61. package/src/components/base/ui/image/main.vue +248 -0
  62. package/src/components/base/ui/index.js +189 -0
  63. package/src/components/base/ui/input/Input.vue +438 -0
  64. package/src/components/base/ui/input/calcTextareaHeight.js +104 -0
  65. package/src/components/base/ui/input-number/input-number.vue +285 -0
  66. package/src/components/base/ui/locale/format.js +32 -0
  67. package/src/components/base/ui/locale/index.js +48 -0
  68. package/src/components/base/ui/locale/lang/zh-CN.js +120 -0
  69. package/src/components/base/ui/menu/menu-item-group.vue +45 -0
  70. package/src/components/base/ui/menu/menu-item.vue +112 -0
  71. package/src/components/base/ui/menu/menu-mixin.js +44 -0
  72. package/src/components/base/ui/menu/menu.vue +312 -0
  73. package/src/components/base/ui/menu/submenu.vue +408 -0
  74. package/src/components/base/ui/message/index.js +2 -0
  75. package/src/components/base/ui/message/main.js +87 -0
  76. package/src/components/base/ui/message/main.vue +110 -0
  77. package/src/components/base/ui/message-box/main.js +216 -0
  78. package/src/components/base/ui/message-box/main.vue +323 -0
  79. package/src/components/base/ui/mixin/emitter.js +31 -0
  80. package/src/components/base/ui/mixin/focus.js +9 -0
  81. package/src/components/base/ui/mixin/locale.js +9 -0
  82. package/src/components/base/ui/mixin/migrating.js +33 -0
  83. package/src/components/base/ui/pagination/pager.vue +163 -0
  84. package/src/components/base/ui/pagination/pagination.jsx +391 -0
  85. package/src/components/base/ui/popover/directive.js +20 -0
  86. package/src/components/base/ui/popover/index.js +14 -0
  87. package/src/components/base/ui/popover/main.vue +236 -0
  88. package/src/components/base/ui/progress/Progress.vue +227 -0
  89. package/src/components/base/ui/radio/radio-button.vue +114 -0
  90. package/src/components/base/ui/radio/radio-group.vue +111 -0
  91. package/src/components/base/ui/radio/radio.vue +134 -0
  92. package/src/components/base/ui/row/row.js +47 -0
  93. package/src/components/base/ui/scrollbar/bar.jsx +91 -0
  94. package/src/components/base/ui/scrollbar/index.jsx +203 -0
  95. package/src/components/base/ui/scrollbar/util.js +32 -0
  96. package/src/components/base/ui/select/Option.vue +168 -0
  97. package/src/components/base/ui/select/OptionGroup.vue +60 -0
  98. package/src/components/base/ui/select/Select.vue +920 -0
  99. package/src/components/base/ui/select/SelectDropdown.vue +74 -0
  100. package/src/components/base/ui/select/navigation-mixin.js +54 -0
  101. package/src/components/base/ui/skeleton/index.js +8 -0
  102. package/src/components/base/ui/skeleton/src/img-placeholder.vue +16 -0
  103. package/src/components/base/ui/skeleton/src/index.vue +80 -0
  104. package/src/components/base/ui/skeleton/src/item.vue +22 -0
  105. package/src/components/base/ui/skeleton-item/index.js +8 -0
  106. package/src/components/base/ui/slider/button.vue +238 -0
  107. package/src/components/base/ui/slider/main.vue +427 -0
  108. package/src/components/base/ui/slider/marker.js +18 -0
  109. package/src/components/base/ui/style/alert.scss +147 -0
  110. package/src/components/base/ui/style/animations.scss +65 -0
  111. package/src/components/base/ui/style/autocomplete.scss +81 -0
  112. package/src/components/base/ui/style/backtop.scss +20 -0
  113. package/src/components/base/ui/style/button-group.scss +0 -0
  114. package/src/components/base/ui/style/button.scss +380 -0
  115. package/src/components/base/ui/style/carousel-item.scss +50 -0
  116. package/src/components/base/ui/style/carousel.scss +161 -0
  117. package/src/components/base/ui/style/cascader-panel.scss +120 -0
  118. package/src/components/base/ui/style/cascader.scss +185 -0
  119. package/src/components/base/ui/style/checkbox-button.scss +0 -0
  120. package/src/components/base/ui/style/checkbox-group.scss +0 -0
  121. package/src/components/base/ui/style/checkbox.scss +360 -0
  122. package/src/components/base/ui/style/col.scss +156 -0
  123. package/src/components/base/ui/style/collapse-item.scss +0 -0
  124. package/src/components/base/ui/style/collapse.scss +114 -0
  125. package/src/components/base/ui/style/color-picker.scss +387 -0
  126. package/src/components/base/ui/style/config.scss +4 -0
  127. package/src/components/base/ui/style/date-picker/date-picker.scss +97 -0
  128. package/src/components/base/ui/style/date-picker/date-range-picker.scss +101 -0
  129. package/src/components/base/ui/style/date-picker/date-table.scss +151 -0
  130. package/src/components/base/ui/style/date-picker/month-table.scss +82 -0
  131. package/src/components/base/ui/style/date-picker/picker-panel.scss +117 -0
  132. package/src/components/base/ui/style/date-picker/picker.scss +197 -0
  133. package/src/components/base/ui/style/date-picker/time-picker.scss +85 -0
  134. package/src/components/base/ui/style/date-picker/time-range-picker.scss +31 -0
  135. package/src/components/base/ui/style/date-picker/time-spinner.scss +110 -0
  136. package/src/components/base/ui/style/date-picker/year-table.scss +51 -0
  137. package/src/components/base/ui/style/date-picker.scss +12 -0
  138. package/src/components/base/ui/style/dialog.scss +123 -0
  139. package/src/components/base/ui/style/divider.scss +47 -0
  140. package/src/components/base/ui/style/drawer.scss +218 -0
  141. package/src/components/base/ui/style/dropdown-item.scss +0 -0
  142. package/src/components/base/ui/style/dropdown-menu.scss +0 -0
  143. package/src/components/base/ui/style/dropdown.scss +185 -0
  144. package/src/components/base/ui/style/form-item.scss +0 -0
  145. package/src/components/base/ui/style/form.scss +203 -0
  146. package/src/components/base/ui/style/function.scss +43 -0
  147. package/src/components/base/ui/style/icon.scss +1167 -0
  148. package/src/components/base/ui/style/image.scss +184 -0
  149. package/src/components/base/ui/style/index.scss +57 -0
  150. package/src/components/base/ui/style/input-number.scss +187 -0
  151. package/src/components/base/ui/style/input.scss +477 -0
  152. package/src/components/base/ui/style/menu-item-group.scss +0 -0
  153. package/src/components/base/ui/style/menu-item.scss +0 -0
  154. package/src/components/base/ui/style/menu.scss +294 -0
  155. package/src/components/base/ui/style/message-box.scss +231 -0
  156. package/src/components/base/ui/style/message.scss +120 -0
  157. package/src/components/base/ui/style/mixins.scss +196 -0
  158. package/src/components/base/ui/style/option-group.scss +42 -0
  159. package/src/components/base/ui/style/option.scss +36 -0
  160. package/src/components/base/ui/style/pagination.scss +295 -0
  161. package/src/components/base/ui/style/popover.scss +40 -0
  162. package/src/components/base/ui/style/popper.scss +102 -0
  163. package/src/components/base/ui/style/popup.scss +42 -0
  164. package/src/components/base/ui/style/progress.scss +141 -0
  165. package/src/components/base/ui/style/radio-button.scss +113 -0
  166. package/src/components/base/ui/style/radio-group.scss +9 -0
  167. package/src/components/base/ui/style/radio.scss +203 -0
  168. package/src/components/base/ui/style/ripple.scss +35 -0
  169. package/src/components/base/ui/style/row.scss +39 -0
  170. package/src/components/base/ui/style/scrollbar.scss +75 -0
  171. package/src/components/base/ui/style/select-dropdown.scss +59 -0
  172. package/src/components/base/ui/style/select.scss +154 -0
  173. package/src/components/base/ui/style/skeleton-item.scss +84 -0
  174. package/src/components/base/ui/style/skeleton.scss +40 -0
  175. package/src/components/base/ui/style/slider.scss +250 -0
  176. package/src/components/base/ui/style/switch.scss +116 -0
  177. package/src/components/base/ui/style/tabs.scss +602 -0
  178. package/src/components/base/ui/style/tag.scss +174 -0
  179. package/src/components/base/ui/style/tooltip.scss +146 -0
  180. package/src/components/base/ui/style/transition.scss +138 -0
  181. package/src/components/base/ui/style/upload.scss +603 -0
  182. package/src/components/base/ui/style/utils.scss +39 -0
  183. package/src/components/base/ui/style/var.scss +1007 -0
  184. package/src/components/base/ui/switch/index.vue +174 -0
  185. package/src/components/base/ui/tabs/tab-bar.vue +57 -0
  186. package/src/components/base/ui/tabs/tab-nav.vue +294 -0
  187. package/src/components/base/ui/tabs/tab-pane.vue +56 -0
  188. package/src/components/base/ui/tabs/tabs.vue +191 -0
  189. package/src/components/base/ui/tag/Tag.vue +60 -0
  190. package/src/components/base/ui/tooltip/tooltip.jsx +234 -0
  191. package/src/components/base/ui/upload/Index.vue +340 -0
  192. package/src/components/base/ui/upload/Upload.vue +216 -0
  193. package/src/components/base/ui/upload/UploadDragger.vue +70 -0
  194. package/src/components/base/ui/upload/UploadList.vue +100 -0
  195. package/src/components/base/ui/upload/ajax.js +85 -0
  196. package/src/components/base/ui/util/aria-dialog.js +90 -0
  197. package/src/components/base/ui/util/aria-utils.js +122 -0
  198. package/src/components/base/ui/util/clickoutside.js +76 -0
  199. package/src/components/base/ui/util/date-util.js +292 -0
  200. package/src/components/base/ui/util/date.js +370 -0
  201. package/src/components/base/ui/util/debounce.js +21 -0
  202. package/src/components/base/ui/util/deepmerge.js +100 -0
  203. package/src/components/base/ui/util/dom.js +215 -0
  204. package/src/components/base/ui/util/index.js +262 -0
  205. package/src/components/base/ui/util/menu/aria-menubar.js +14 -0
  206. package/src/components/base/ui/util/menu/aria-menuitem.js +49 -0
  207. package/src/components/base/ui/util/menu/aria-submenu.js +59 -0
  208. package/src/components/base/ui/util/merge.js +14 -0
  209. package/src/components/base/ui/util/popper.js +1235 -0
  210. package/src/components/base/ui/util/popup/index.js +218 -0
  211. package/src/components/base/ui/util/popup/popup-manager.js +194 -0
  212. package/src/components/base/ui/util/resize-events.js +32 -0
  213. package/src/components/base/ui/util/scroll-into-view.js +27 -0
  214. package/src/components/base/ui/util/scrollbar-width.js +29 -0
  215. package/src/components/base/ui/util/shared.js +7 -0
  216. package/src/components/base/ui/util/throttle.js +91 -0
  217. package/src/components/base/ui/util/types.js +24 -0
  218. package/src/components/base/ui/util/vdom.js +5 -0
  219. package/src/components/base/ui/util/vue-popper.js +188 -0
  220. package/src/components/normal/AggsItemH.vue +139 -0
  221. package/src/index.js +10 -0
  222. package/src/static/base-icons.ttf +0 -0
  223. package/src/static/base-icons.woff +0 -0
  224. package/src/static/label_bg.png +0 -0
  225. package/src/static/term-label-bg.png +0 -0
  226. package/src/style/app-article.scss +698 -0
  227. package/src/style/app-comment.scss +259 -0
  228. package/src/style/app-recommend.scss +48 -0
  229. package/src/style/app-richtext.scss +176 -0
  230. package/src/style/index.scss +523 -0
  231. package/vite.config.js +38 -0
@@ -0,0 +1,163 @@
1
+ <template>
2
+ <ul @click="onPagerClick" class="base-pager">
3
+ <li
4
+ :class="{ active: currentPage === 1, disabled }"
5
+ v-if="pageCount > 0"
6
+ class="number">1</li>
7
+ <li
8
+ class="base-icon more btn-quickprev"
9
+ :class="[quickprevIconClass, { disabled }]"
10
+ v-if="showPrevMore"
11
+ @mouseenter="onMouseenter('left')"
12
+ @mouseleave="quickprevIconClass = 'base-icon-more'">
13
+ </li>
14
+ <li
15
+ v-for="pager in pagers"
16
+ :key="pager"
17
+ :class="{ active: currentPage === pager, disabled }"
18
+ class="number">{{ pager }}</li>
19
+ <li
20
+ class="base-icon more btn-quicknext"
21
+ :class="[quicknextIconClass, { disabled }]"
22
+ v-if="showNextMore"
23
+ @mouseenter="onMouseenter('right')"
24
+ @mouseleave="quicknextIconClass = 'base-icon-more'">
25
+ </li>
26
+ <li
27
+ :class="{ active: currentPage === pageCount, disabled }"
28
+ class="number"
29
+ v-if="pageCount > 1">{{ pageCount }}</li>
30
+ </ul>
31
+ </template>
32
+
33
+ <script type="text/babel">
34
+ export default {
35
+ name: 'BasePager',
36
+
37
+ props: {
38
+ currentPage: Number,
39
+
40
+ pageCount: Number,
41
+
42
+ pagerCount: Number,
43
+
44
+ disabled: Boolean
45
+ },
46
+
47
+ watch: {
48
+ showPrevMore(val) {
49
+ if (!val) this.quickprevIconClass = 'base-icon-more';
50
+ },
51
+
52
+ showNextMore(val) {
53
+ if (!val) this.quicknextIconClass = 'base-icon-more';
54
+ }
55
+ },
56
+
57
+ methods: {
58
+ onPagerClick(event) {
59
+ const target = event.target;
60
+ if (target.tagName === 'UL' || this.disabled) {
61
+ return;
62
+ }
63
+
64
+ let newPage = Number(event.target.textContent);
65
+ const pageCount = this.pageCount;
66
+ const currentPage = this.currentPage;
67
+ const pagerCountOffset = this.pagerCount - 2;
68
+
69
+ if (target.className.indexOf('more') !== -1) {
70
+ if (target.className.indexOf('quickprev') !== -1) {
71
+ newPage = currentPage - pagerCountOffset;
72
+ } else if (target.className.indexOf('quicknext') !== -1) {
73
+ newPage = currentPage + pagerCountOffset;
74
+ }
75
+ }
76
+
77
+ /* istanbul ignore if */
78
+ if (!isNaN(newPage)) {
79
+ if (newPage < 1) {
80
+ newPage = 1;
81
+ }
82
+
83
+ if (newPage > pageCount) {
84
+ newPage = pageCount;
85
+ }
86
+ }
87
+
88
+ if (newPage !== currentPage) {
89
+ this.$emit('change', newPage);
90
+ }
91
+ },
92
+
93
+ onMouseenter(direction) {
94
+ if (this.disabled) return;
95
+ if (direction === 'left') {
96
+ this.quickprevIconClass = 'base-icon-d-arrow-left';
97
+ } else {
98
+ this.quicknextIconClass = 'base-icon-d-arrow-right';
99
+ }
100
+ }
101
+ },
102
+
103
+ computed: {
104
+ pagers() {
105
+ const pagerCount = this.pagerCount;
106
+ const halfPagerCount = (pagerCount - 1) / 2;
107
+
108
+ const currentPage = Number(this.currentPage);
109
+ const pageCount = Number(this.pageCount);
110
+
111
+ let showPrevMore = false;
112
+ let showNextMore = false;
113
+
114
+ if (pageCount > pagerCount) {
115
+ if (currentPage > pagerCount - halfPagerCount) {
116
+ showPrevMore = true;
117
+ }
118
+
119
+ if (currentPage < pageCount - halfPagerCount) {
120
+ showNextMore = true;
121
+ }
122
+ }
123
+
124
+ const array = [];
125
+
126
+ if (showPrevMore && !showNextMore) {
127
+ const startPage = pageCount - (pagerCount - 2);
128
+ for (let i = startPage; i < pageCount; i++) {
129
+ array.push(i);
130
+ }
131
+ } else if (!showPrevMore && showNextMore) {
132
+ for (let i = 2; i < pagerCount; i++) {
133
+ array.push(i);
134
+ }
135
+ } else if (showPrevMore && showNextMore) {
136
+ const offset = Math.floor(pagerCount / 2) - 1;
137
+ for (let i = currentPage - offset ; i <= currentPage + offset; i++) {
138
+ array.push(i);
139
+ }
140
+ } else {
141
+ for (let i = 2; i < pageCount; i++) {
142
+ array.push(i);
143
+ }
144
+ }
145
+
146
+ this.showPrevMore = showPrevMore;
147
+ this.showNextMore = showNextMore;
148
+
149
+ return array;
150
+ }
151
+ },
152
+
153
+ data() {
154
+ return {
155
+ current: null,
156
+ showPrevMore: false,
157
+ showNextMore: false,
158
+ quicknextIconClass: 'base-icon-more',
159
+ quickprevIconClass: 'base-icon-more'
160
+ };
161
+ }
162
+ };
163
+ </script>
@@ -0,0 +1,391 @@
1
+ import Pager from './pager.vue';
2
+ import BaseSelect from '../select/Select';
3
+ import BaseOption from '../select/Option';
4
+ import BaseInput from '../input/Input';
5
+ import Locale from '../mixin/locale';
6
+ import { valueEquals } from '../util/index';
7
+
8
+ export default {
9
+ name: 'BasePagination',
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
+ unitText: {
60
+ type: String,
61
+ default: '条'
62
+ }
63
+ },
64
+
65
+ data() {
66
+ return {
67
+ internalCurrentPage: 1,
68
+ internalPageSize: 0,
69
+ lastEmittedPage: -1,
70
+ userChangePageSize: false
71
+ };
72
+ },
73
+
74
+ render(h) {
75
+ const layout = this.layout;
76
+ if (!layout) return null;
77
+ if (this.hideOnSinglePage && (!this.internalPageCount || this.internalPageCount === 1)) return null;
78
+
79
+ let template = <div class={['base-pagination', {
80
+ 'is-background': this.background,
81
+ 'base-pagination--small': this.small
82
+ }] }></div>;
83
+ const TEMPLATE_MAP = {
84
+ prev: <prev></prev>,
85
+ jumper: <jumper></jumper>,
86
+ pager: <pager currentPage={ this.internalCurrentPage } pageCount={ this.internalPageCount } pagerCount={ this.pagerCount } on-change={ this.handleCurrentChange } disabled={ this.disabled }></pager>,
87
+ next: <next></next>,
88
+ sizes: <sizes pageSizes={ this.pageSizes }></sizes>,
89
+ slot: <slot>{ this.$slots.default ? this.$slots.default : '' }</slot>,
90
+ total: <total></total>
91
+ };
92
+ const components = layout.split(',').map((item) => item.trim());
93
+ const rightWrapper = <div class="base-pagination__rightwrapper"></div>;
94
+ let haveRightWrapper = false;
95
+
96
+ template.children = template.children || [];
97
+ rightWrapper.children = rightWrapper.children || [];
98
+ components.forEach(compo => {
99
+ if (compo === '->') {
100
+ haveRightWrapper = true;
101
+ return;
102
+ }
103
+
104
+ if (!haveRightWrapper) {
105
+ template.children.push(TEMPLATE_MAP[compo]);
106
+ } else {
107
+ rightWrapper.children.push(TEMPLATE_MAP[compo]);
108
+ }
109
+ });
110
+
111
+ if (haveRightWrapper) {
112
+ template.children.unshift(rightWrapper);
113
+ }
114
+
115
+ return template;
116
+ },
117
+
118
+ components: {
119
+ Prev: {
120
+ render(h) {
121
+ return (
122
+ <button
123
+ type="button"
124
+ class="btn-prev"
125
+ disabled={ this.$parent.disabled || this.$parent.internalCurrentPage <= 1 }
126
+ on-click={ this.$parent.prev }>
127
+ {
128
+ this.$parent.prevText
129
+ ? <span>{ this.$parent.prevText }</span>
130
+ : <i class="base-icon base-icon-arrow-left"></i>
131
+ }
132
+ </button>
133
+ );
134
+ }
135
+ },
136
+
137
+ Next: {
138
+ render(h) {
139
+ return (
140
+ <button
141
+ type="button"
142
+ class="btn-next"
143
+ disabled={ this.$parent.disabled || this.$parent.internalCurrentPage === this.$parent.internalPageCount || this.$parent.internalPageCount === 0 }
144
+ on-click={ this.$parent.next }>
145
+ {
146
+ this.$parent.nextText
147
+ ? <span>{ this.$parent.nextText }</span>
148
+ : <i class="base-icon base-icon-arrow-right"></i>
149
+ }
150
+ </button>
151
+ );
152
+ }
153
+ },
154
+
155
+ Sizes: {
156
+ mixins: [Locale],
157
+
158
+ props: {
159
+ pageSizes: Array
160
+ },
161
+
162
+ watch: {
163
+ pageSizes: {
164
+ immediate: true,
165
+ handler(newVal, oldVal) {
166
+ if (valueEquals(newVal, oldVal)) return;
167
+ if (Array.isArray(newVal)) {
168
+ this.$parent.internalPageSize = newVal.indexOf(this.$parent.pageSize) > -1
169
+ ? this.$parent.pageSize
170
+ : this.pageSizes[0];
171
+ }
172
+ }
173
+ }
174
+ },
175
+
176
+ render(h) {
177
+ return (
178
+ <span class="base-pagination__sizes">
179
+ <base-select
180
+ value={ this.$parent.internalPageSize }
181
+ popperClass={ this.$parent.popperClass || '' }
182
+ size="mini"
183
+ on-input={ this.handleChange }
184
+ disabled={ this.$parent.disabled }>
185
+ {
186
+ this.pageSizes.map(item =>
187
+ <base-option
188
+ value={ item }
189
+ label={ item + this.t('base.pagination.pagesize') }>
190
+ </base-option>
191
+ )
192
+ }
193
+ </base-select>
194
+ </span>
195
+ );
196
+ },
197
+
198
+ components: {
199
+ BaseSelect,
200
+ BaseOption
201
+ },
202
+
203
+ methods: {
204
+ handleChange(val) {
205
+ if (val !== this.$parent.internalPageSize) {
206
+ this.$parent.internalPageSize = val = parseInt(val, 10);
207
+ this.$parent.userChangePageSize = true;
208
+ this.$parent.$emit('update:pageSize', val);
209
+ this.$parent.$emit('size-change', val);
210
+ }
211
+ }
212
+ }
213
+ },
214
+
215
+ Jumper: {
216
+ mixins: [Locale],
217
+
218
+ components: { BaseInput },
219
+
220
+ data() {
221
+ return {
222
+ userInput: null
223
+ };
224
+ },
225
+
226
+ watch: {
227
+ '$parent.internalCurrentPage'() {
228
+ this.userInput = null;
229
+ }
230
+ },
231
+
232
+ methods: {
233
+ handleKeyup({ keyCode, target }) {
234
+ // Chrome, Safari, Firefox triggers change event on Enter
235
+ // Hack for IE: https://github.com/ElemeFE/element/issues/11710
236
+ // Drop this method when we no longer supports IE
237
+ if (keyCode === 13) {
238
+ this.handleChange(target.value);
239
+ }
240
+ },
241
+ handleInput(value) {
242
+ this.userInput = value;
243
+ },
244
+ handleChange(value) {
245
+ this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(value);
246
+ this.$parent.emitChange();
247
+ this.userInput = null;
248
+ }
249
+ },
250
+
251
+ render(h) {
252
+ return (
253
+ <span class="base-pagination__jump">
254
+ { this.t('base.pagination.goto') }
255
+ <base-input
256
+ class="base-pagination__editor is-in-pagination"
257
+ min={ 1 }
258
+ max={ this.$parent.internalPageCount }
259
+ value={ this.userInput !== null ? this.userInput : this.$parent.internalCurrentPage }
260
+ type="number"
261
+ disabled={ this.$parent.disabled }
262
+ nativeOnKeyup={ this.handleKeyup }
263
+ onInput={ this.handleInput }
264
+ onChange={ this.handleChange }/>
265
+ { this.t('base.pagination.pageClassifier') }
266
+ </span>
267
+ );
268
+ }
269
+ },
270
+
271
+ Total: {
272
+ mixins: [Locale],
273
+
274
+ render(h) {
275
+ return (
276
+ typeof this.$parent.total === 'number'
277
+ ? <span class="base-pagination__total">{ this.t('base.pagination.total', { total: this.$parent.total,unitText: this.$parent.unitText }) }</span>
278
+ : ''
279
+ );
280
+ }
281
+ },
282
+
283
+ Pager
284
+ },
285
+
286
+ methods: {
287
+ handleCurrentChange(val) {
288
+ this.internalCurrentPage = this.getValidCurrentPage(val);
289
+ this.userChangePageSize = true;
290
+ this.emitChange();
291
+ },
292
+
293
+ prev() {
294
+ if (this.disabled) return;
295
+ const newVal = this.internalCurrentPage - 1;
296
+ this.internalCurrentPage = this.getValidCurrentPage(newVal);
297
+ this.$emit('prev-click', this.internalCurrentPage);
298
+ this.emitChange();
299
+ },
300
+
301
+ next() {
302
+ if (this.disabled) return;
303
+ const newVal = this.internalCurrentPage + 1;
304
+ this.internalCurrentPage = this.getValidCurrentPage(newVal);
305
+ this.$emit('next-click', this.internalCurrentPage);
306
+ this.emitChange();
307
+ },
308
+
309
+ getValidCurrentPage(value) {
310
+ value = parseInt(value, 10);
311
+
312
+ const havePageCount = typeof this.internalPageCount === 'number';
313
+
314
+ let resetValue;
315
+ if (!havePageCount) {
316
+ if (isNaN(value) || value < 1) resetValue = 1;
317
+ } else {
318
+ if (value < 1) {
319
+ resetValue = 1;
320
+ } else if (value > this.internalPageCount) {
321
+ resetValue = this.internalPageCount;
322
+ }
323
+ }
324
+
325
+ if (resetValue === undefined && isNaN(value)) {
326
+ resetValue = 1;
327
+ } else if (resetValue === 0) {
328
+ resetValue = 1;
329
+ }
330
+
331
+ return resetValue === undefined ? value : resetValue;
332
+ },
333
+
334
+ emitChange() {
335
+ this.$nextTick(() => {
336
+ if (this.internalCurrentPage !== this.lastEmittedPage || this.userChangePageSize) {
337
+ this.$emit('current-change', this.internalCurrentPage);
338
+ this.lastEmittedPage = this.internalCurrentPage;
339
+ this.userChangePageSize = false;
340
+ }
341
+ });
342
+ }
343
+ },
344
+
345
+ computed: {
346
+ internalPageCount() {
347
+ if (typeof this.total === 'number') {
348
+ return Math.max(1, Math.ceil(this.total / this.internalPageSize));
349
+ } else if (typeof this.pageCount === 'number') {
350
+ return Math.max(1, this.pageCount);
351
+ }
352
+ return null;
353
+ }
354
+ },
355
+
356
+ watch: {
357
+ currentPage: {
358
+ immediate: true,
359
+ handler(val) {
360
+ this.internalCurrentPage = this.getValidCurrentPage(val);
361
+ }
362
+ },
363
+
364
+ pageSize: {
365
+ immediate: true,
366
+ handler(val) {
367
+ this.internalPageSize = isNaN(val) ? 10 : val;
368
+ }
369
+ },
370
+
371
+ internalCurrentPage: {
372
+ immediate: true,
373
+ handler(newVal) {
374
+ this.$emit('update:currentPage', newVal);
375
+ this.lastEmittedPage = -1;
376
+ }
377
+ },
378
+
379
+ internalPageCount(newVal) {
380
+ /* istanbul ignore if */
381
+ const oldPage = this.internalCurrentPage;
382
+ if (newVal > 0 && oldPage === 0) {
383
+ this.internalCurrentPage = 1;
384
+ } else if (oldPage > newVal) {
385
+ this.internalCurrentPage = newVal === 0 ? 1 : newVal;
386
+ this.userChangePageSize && this.emitChange();
387
+ }
388
+ this.userChangePageSize = false;
389
+ }
390
+ }
391
+ };
@@ -0,0 +1,20 @@
1
+ const getReference = (el, binding, vnode) => {
2
+ const _ref = binding.expression ? binding.value : binding.arg;
3
+ const popper = vnode.context.$refs[_ref];
4
+ if (popper) {
5
+ if (Array.isArray(popper)) {
6
+ popper[0].$refs.reference = el;
7
+ } else {
8
+ popper.$refs.reference = el;
9
+ }
10
+ }
11
+ };
12
+
13
+ export default {
14
+ bind(el, binding, vnode) {
15
+ getReference(el, binding, vnode);
16
+ },
17
+ inserted(el, binding, vnode) {
18
+ getReference(el, binding, vnode);
19
+ }
20
+ };
@@ -0,0 +1,14 @@
1
+ import Popover from './main';
2
+ import directive from './directive';
3
+ import Vue from 'vue';
4
+
5
+ Vue.directive('popover', directive);
6
+
7
+ /* istanbul ignore next */
8
+ Popover.install = function(Vue) {
9
+ Vue.directive('popover', directive);
10
+ Vue.component(Popover.name, Popover);
11
+ };
12
+ Popover.directive = directive;
13
+
14
+ export default Popover;