xt-element-ui 2.2.2 → 2.2.4

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 (153) hide show
  1. package/README.md +140 -192
  2. package/docs/README.md +162 -81
  3. package/docs/components/base/theme.md +248 -0
  4. package/docs/components/base/xt-button.md +11 -4
  5. package/docs/components/base/xt-card.md +5 -11
  6. package/docs/components/base/xt-config-provider.md +2 -0
  7. package/docs/components/base/xt-flow.md +404 -0
  8. package/docs/components/base/xt-list.md +1 -1
  9. package/docs/components/base/xt-multi.md +5 -5
  10. package/docs/components/base/xt-scroll-arrow.md +87 -1
  11. package/docs/components/base/xt-scroll.md +237 -0
  12. package/docs/components/business/xt-chart.md +1 -0
  13. package/docs/components/utils/config.md +18 -4
  14. package/docs/components/utils/theme.md +280 -183
  15. package/lib/index.common.1.js +4 -26
  16. package/lib/index.common.2.js +1 -1
  17. package/lib/index.common.js +4577 -109925
  18. package/lib/index.css +1 -1
  19. package/lib/index.umd.1.js +4 -26
  20. package/lib/index.umd.2.js +1 -1
  21. package/lib/index.umd.js +4583 -109930
  22. package/lib/index.umd.min.1.js +1 -1
  23. package/lib/index.umd.min.js +1 -1
  24. package/lib/theme/element-overrides.css +607 -0
  25. package/lib/theme/element-vars.css +280 -0
  26. package/lib/xt-badge/xt-badge.common.js +1 -1
  27. package/lib/xt-badge/xt-badge.css +1 -1
  28. package/lib/xt-badge/xt-badge.umd.js +1 -1
  29. package/lib/xt-button/xt-button.common.js +13 -8
  30. package/lib/xt-button/xt-button.css +1 -1
  31. package/lib/xt-button/xt-button.umd.js +13 -8
  32. package/lib/xt-button/xt-button.umd.min.js +1 -1
  33. package/lib/xt-card/xt-card.common.js +5 -5
  34. package/lib/xt-card/xt-card.umd.js +5 -5
  35. package/lib/xt-card/xt-card.umd.min.js +1 -1
  36. package/lib/xt-card-item/xt-card-item.common.js +4 -4
  37. package/lib/xt-card-item/xt-card-item.umd.js +4 -4
  38. package/lib/xt-card-item/xt-card-item.umd.min.js +1 -1
  39. package/lib/xt-chart/xt-chart.common.js +1969 -108924
  40. package/lib/xt-chart/xt-chart.css +1 -1
  41. package/lib/xt-chart/xt-chart.umd.js +1975 -108929
  42. package/lib/xt-chart/xt-chart.umd.min.js +1 -1
  43. package/lib/xt-config-provider/xt-config-provider.common.js +561 -107504
  44. package/lib/xt-config-provider/xt-config-provider.css +1 -1
  45. package/lib/xt-config-provider/xt-config-provider.umd.js +567 -107509
  46. package/lib/xt-config-provider/xt-config-provider.umd.min.js +1 -1
  47. package/lib/xt-date-picker/xt-date-picker.common.1.js +4 -26
  48. package/lib/xt-date-picker/xt-date-picker.common.2.js +1 -1
  49. package/lib/xt-date-picker/xt-date-picker.common.js +1 -47
  50. package/lib/xt-date-picker/xt-date-picker.css +1 -1
  51. package/lib/xt-date-picker/xt-date-picker.umd.1.js +4 -26
  52. package/lib/xt-date-picker/xt-date-picker.umd.2.js +1 -1
  53. package/lib/xt-date-picker/xt-date-picker.umd.js +1 -47
  54. package/lib/xt-date-picker/xt-date-picker.umd.min.1.js +1 -1
  55. package/lib/xt-date-picker/xt-date-picker.umd.min.js +1 -1
  56. package/lib/xt-flex-box/xt-flex-box.common.js +1 -1
  57. package/lib/xt-flex-box/xt-flex-box.umd.js +1 -1
  58. package/lib/xt-flow/demo.html +10 -0
  59. package/lib/xt-flow/index.js +1 -0
  60. package/lib/xt-flow/xt-flow.common.js +638 -0
  61. package/lib/xt-flow/xt-flow.css +1 -0
  62. package/lib/xt-flow/xt-flow.umd.js +648 -0
  63. package/lib/xt-flow/xt-flow.umd.min.js +1 -0
  64. package/lib/xt-form-schema/xt-form-schema.common.js +1 -1
  65. package/lib/xt-form-schema/xt-form-schema.umd.js +1 -1
  66. package/lib/xt-grid-box/xt-grid-box.common.js +1 -1
  67. package/lib/xt-grid-box/xt-grid-box.umd.js +1 -1
  68. package/lib/xt-grid-item/xt-grid-item.common.js +1 -1
  69. package/lib/xt-grid-item/xt-grid-item.umd.js +1 -1
  70. package/lib/xt-icon/xt-icon.common.js +1 -1
  71. package/lib/xt-icon/xt-icon.umd.js +1 -1
  72. package/lib/xt-input/xt-input.common.js +1 -1
  73. package/lib/xt-input/xt-input.umd.js +1 -1
  74. package/lib/xt-list/xt-list.common.js +457 -118
  75. package/lib/xt-list/xt-list.css +1 -1
  76. package/lib/xt-list/xt-list.umd.js +457 -118
  77. package/lib/xt-list/xt-list.umd.min.js +1 -1
  78. package/lib/xt-map/xt-map.common.js +1 -1
  79. package/lib/xt-map/xt-map.umd.js +1 -1
  80. package/lib/xt-map-provider/xt-map-provider.common.js +1 -1
  81. package/lib/xt-map-provider/xt-map-provider.umd.js +1 -1
  82. package/lib/xt-page/xt-page.common.js +1 -1
  83. package/lib/xt-page/xt-page.umd.js +1 -1
  84. package/lib/xt-progress/xt-progress.common.js +1 -1
  85. package/lib/xt-progress/xt-progress.umd.js +1 -1
  86. package/lib/xt-scroll/demo.html +10 -0
  87. package/lib/xt-scroll/index.js +1 -0
  88. package/lib/xt-scroll/xt-scroll.common.js +551 -0
  89. package/lib/xt-scroll/xt-scroll.css +1 -0
  90. package/lib/xt-scroll/xt-scroll.umd.js +561 -0
  91. package/lib/xt-scroll/xt-scroll.umd.min.js +1 -0
  92. package/lib/xt-scroll-arrow/xt-scroll-arrow.common.js +591 -170
  93. package/lib/xt-scroll-arrow/xt-scroll-arrow.css +1 -1
  94. package/lib/xt-scroll-arrow/xt-scroll-arrow.umd.js +591 -170
  95. package/lib/xt-scroll-arrow/xt-scroll-arrow.umd.min.js +1 -1
  96. package/lib/xt-select-tree/xt-select-tree.common.js +1 -1
  97. package/lib/xt-select-tree/xt-select-tree.umd.js +1 -1
  98. package/lib/xt-step-price/xt-step-price.common.js +2 -2
  99. package/lib/xt-step-price/xt-step-price.umd.js +2 -2
  100. package/lib/xt-step-price-item/xt-step-price-item.common.js +1 -1
  101. package/lib/xt-step-price-item/xt-step-price-item.umd.js +1 -1
  102. package/lib/xt-tab-pane/xt-tab-pane.common.js +1 -1
  103. package/lib/xt-tab-pane/xt-tab-pane.umd.js +1 -1
  104. package/lib/xt-table/xt-table.common.js +2 -2
  105. package/lib/xt-table/xt-table.umd.js +2 -2
  106. package/lib/xt-tabs/xt-tabs.common.js +1 -1
  107. package/lib/xt-tabs/xt-tabs.umd.js +1 -1
  108. package/lib/xt-text/xt-text.common.js +1 -1
  109. package/lib/xt-text/xt-text.css +1 -1
  110. package/lib/xt-text/xt-text.umd.js +1 -1
  111. package/lib/xt-time/xt-time.common.js +1 -1
  112. package/lib/xt-time/xt-time.umd.js +1 -1
  113. package/lib/xt-transfer-tree/xt-transfer-tree.common.js +1 -1
  114. package/lib/xt-transfer-tree/xt-transfer-tree.umd.js +1 -1
  115. package/lib/xt-upload/xt-upload.common.js +11 -11
  116. package/lib/xt-upload/xt-upload.umd.js +12 -12
  117. package/lib/xt-upload/xt-upload.umd.min.js +1 -1
  118. package/package.json +6 -5
  119. package/src/components/index.scss +7 -1
  120. package/src/components/theme/element-overrides.css +607 -0
  121. package/src/components/theme/element-vars.css +280 -0
  122. package/src/components/theme/iframe-injector.js +502 -0
  123. package/src/components/theme/index.js +64 -0
  124. package/src/components/xt-badge/style/index.scss +6 -6
  125. package/src/components/xt-button/index.vue +11 -6
  126. package/src/components/xt-button/style/index.scss +7 -5
  127. package/src/components/xt-card/index.vue +3 -3
  128. package/src/components/xt-card-item/index.vue +2 -2
  129. package/src/components/xt-chart/XtMulti.vue +8 -18
  130. package/src/components/xt-chart/XtPie.vue +1 -0
  131. package/src/components/xt-chart/utils.js +84 -50
  132. package/src/components/xt-config-provider/index.vue +56 -54
  133. package/src/components/xt-config-provider/style/index.scss +0 -11
  134. package/src/components/xt-date-picker/component/RangeDate.vue +1 -29
  135. package/src/components/xt-date-picker/style/index.scss +79 -54
  136. package/src/components/xt-flow/flowable-parser.js +244 -0
  137. package/src/components/xt-flow/index.js +8 -0
  138. package/src/components/xt-flow/index.vue +226 -0
  139. package/src/components/xt-flow/style/index.scss +359 -0
  140. package/src/components/xt-list/index.vue +23 -12
  141. package/src/components/xt-scroll/index.js +9 -0
  142. package/src/components/xt-scroll/index.vue +363 -0
  143. package/src/components/xt-scroll/style/index.scss +107 -0
  144. package/src/components/xt-scroll-arrow/index.vue +200 -83
  145. package/src/components/xt-scroll-arrow/style/index.scss +16 -5
  146. package/src/components/xt-text/style/index.scss +6 -6
  147. package/src/index.js +15 -13
  148. package/src/styles/css-variables.scss +73 -1
  149. package/src/utils/color.js +105 -0
  150. package/src/utils/index.js +456 -468
  151. package/src/utils/theme-vars.js +134 -0
  152. package/lib/css/1.87a493be.css +0 -1
  153. package/lib/xt-date-picker/css/1.87a493be.css +0 -1
@@ -0,0 +1,561 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["xt-scroll"] = factory();
8
+ else
9
+ root["xt-scroll"] = factory();
10
+ })((typeof self !== 'undefined' ? self : this), function() {
11
+ return /******/ (function(modules) { // webpackBootstrap
12
+ /******/ // The module cache
13
+ /******/ var installedModules = {};
14
+ /******/
15
+ /******/ // The require function
16
+ /******/ function __webpack_require__(moduleId) {
17
+ /******/
18
+ /******/ // Check if module is in cache
19
+ /******/ if(installedModules[moduleId]) {
20
+ /******/ return installedModules[moduleId].exports;
21
+ /******/ }
22
+ /******/ // Create a new module (and put it into the cache)
23
+ /******/ var module = installedModules[moduleId] = {
24
+ /******/ i: moduleId,
25
+ /******/ l: false,
26
+ /******/ exports: {}
27
+ /******/ };
28
+ /******/
29
+ /******/ // Execute the module function
30
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
+ /******/
32
+ /******/ // Flag the module as loaded
33
+ /******/ module.l = true;
34
+ /******/
35
+ /******/ // Return the exports of the module
36
+ /******/ return module.exports;
37
+ /******/ }
38
+ /******/
39
+ /******/
40
+ /******/ // expose the modules object (__webpack_modules__)
41
+ /******/ __webpack_require__.m = modules;
42
+ /******/
43
+ /******/ // expose the module cache
44
+ /******/ __webpack_require__.c = installedModules;
45
+ /******/
46
+ /******/ // define getter function for harmony exports
47
+ /******/ __webpack_require__.d = function(exports, name, getter) {
48
+ /******/ if(!__webpack_require__.o(exports, name)) {
49
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
+ /******/ }
51
+ /******/ };
52
+ /******/
53
+ /******/ // define __esModule on exports
54
+ /******/ __webpack_require__.r = function(exports) {
55
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
+ /******/ }
58
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
59
+ /******/ };
60
+ /******/
61
+ /******/ // create a fake namespace object
62
+ /******/ // mode & 1: value is a module id, require it
63
+ /******/ // mode & 2: merge all properties of value into the ns
64
+ /******/ // mode & 4: return value when already ns object
65
+ /******/ // mode & 8|1: behave like require
66
+ /******/ __webpack_require__.t = function(value, mode) {
67
+ /******/ if(mode & 1) value = __webpack_require__(value);
68
+ /******/ if(mode & 8) return value;
69
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
+ /******/ var ns = Object.create(null);
71
+ /******/ __webpack_require__.r(ns);
72
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
+ /******/ return ns;
75
+ /******/ };
76
+ /******/
77
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
78
+ /******/ __webpack_require__.n = function(module) {
79
+ /******/ var getter = module && module.__esModule ?
80
+ /******/ function getDefault() { return module['default']; } :
81
+ /******/ function getModuleExports() { return module; };
82
+ /******/ __webpack_require__.d(getter, 'a', getter);
83
+ /******/ return getter;
84
+ /******/ };
85
+ /******/
86
+ /******/ // Object.prototype.hasOwnProperty.call
87
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
+ /******/
89
+ /******/ // __webpack_public_path__
90
+ /******/ __webpack_require__.p = "";
91
+ /******/
92
+ /******/
93
+ /******/ // Load entry module and return exports
94
+ /******/ return __webpack_require__(__webpack_require__.s = "fb15");
95
+ /******/ })
96
+ /************************************************************************/
97
+ /******/ ({
98
+
99
+ /***/ "f699":
100
+ /***/ (function(module, exports, __webpack_require__) {
101
+
102
+ // extracted by mini-css-extract-plugin
103
+
104
+ /***/ }),
105
+
106
+ /***/ "fb15":
107
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
108
+
109
+ "use strict";
110
+ // ESM COMPAT FLAG
111
+ __webpack_require__.r(__webpack_exports__);
112
+
113
+ // EXPORTS
114
+ __webpack_require__.d(__webpack_exports__, "XtScroll", function() { return /* reexport */ xt_scroll; });
115
+
116
+ // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
117
+ // This file is imported into lib/wc client bundles.
118
+
119
+ if (typeof window !== 'undefined') {
120
+ var currentScript = window.document.currentScript
121
+ if (false) { var getCurrentScript; }
122
+
123
+ var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/)
124
+ if (src) {
125
+ __webpack_require__.p = src[1] // eslint-disable-line
126
+ }
127
+ }
128
+
129
+ // Indicate to webpack that this file can be concatenated
130
+ /* harmony default export */ var setPublicPath = (null);
131
+
132
+ // EXTERNAL MODULE: ./src/components/xt-scroll/style/index.scss
133
+ var style = __webpack_require__("f699");
134
+
135
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"1d9e3ae5-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/xt-scroll/index.vue?vue&type=template&id=74170e40
136
+ var render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"xt-scroll",class:[`xt-scroll--${_vm.scrollDirection}`],style:(_vm.containerStyle)},[_c('div',{ref:"scrollWrap",staticClass:"xt-scroll__wrap",class:[`xt-scroll__wrap--${_vm.scrollDirection}`],on:{"scroll":_vm.onScroll}},[(_vm.vScroll)?_c('div',{staticClass:"xt-scroll__virtual",style:(_vm.virtualWrapperStyle)},[(_vm.scrollDirection === 'vertical')?_c('div',{staticClass:"xt-scroll__phantom",style:({ height: _vm.totalSize + 'px' })},[_c('div',{style:({ transform: `translateY(${_vm.offsetStart}px)` })},[_vm._l((_vm.visibleData),function(item,index){return [_c('div',{key:_vm.getItemKey(item, index),staticClass:"xt-scroll__item",class:_vm.itemClassName,style:(_vm.itemStyle)},[_vm._t("item",function(){return [_vm._v(" "+_vm._s(item)+" ")]},{"item":item,"index":_vm.getOriginalIndex(index)})],2)]})],2)]):(_vm.scrollDirection === 'horizontal')?_c('div',{staticClass:"xt-scroll__phantom",style:({ width: _vm.totalSize + 'px' })},[_c('div',{style:({ transform: `translateX(${_vm.offsetStart}px)` })},[_vm._l((_vm.visibleData),function(item,index){return [_c('div',{key:_vm.getItemKey(item, index),staticClass:"xt-scroll__item",class:_vm.itemClassName,style:(_vm.itemStyle)},[_vm._t("item",function(){return [_vm._v(" "+_vm._s(item)+" ")]},{"item":item,"index":_vm.getOriginalIndex(index)})],2)]})],2)]):_vm._e()]):_vm._e(),(_vm.vScroll && (!_vm.data || !_vm.data.length) && !_vm.loading)?_c('div',{staticClass:"xt-scroll__empty"},[_vm._t("empty",function(){return [_c('span',[_vm._v(_vm._s(_vm.emptyText))])]})],2):_vm._e(),(_vm.loading)?_c('div',{staticClass:"xt-scroll__loading"},[_vm._t("loading",function(){return [_c('i',{staticClass:"el-icon-loading"}),_c('span',[_vm._v("加载中...")])]})],2):_vm._e(),(!_vm.vScroll)?_c('div',{staticClass:"xt-scroll__default"},[_vm._t("default")],2):_vm._e(),(_vm.vScroll && _vm.showLoadMore && !_vm.loading)?_c('div',{staticClass:"xt-scroll__loadmore",on:{"click":_vm.onLoadMore}},[_c('el-button',{attrs:{"type":"text","loading":_vm.loadMoreLoading}},[_vm._v(" "+_vm._s(_vm.loadMoreText)+" ")])],1):_vm._e()])])
137
+ }
138
+ var staticRenderFns = []
139
+
140
+
141
+ // CONCATENATED MODULE: ./src/components/xt-scroll/index.vue?vue&type=template&id=74170e40
142
+
143
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/xt-scroll/index.vue?vue&type=script&lang=js
144
+
145
+ /* harmony default export */ var xt_scrollvue_type_script_lang_js = ({
146
+ name: 'XtScroll',
147
+
148
+ props: {
149
+ // ========== 虚拟滚动配置 ==========
150
+ /** 是否启用虚拟滚动 */
151
+ vScroll: { type: Boolean, default: false },
152
+ /** 数据源 */
153
+ data: { type: Array, default: () => [] },
154
+ /** 每个 item 的固定尺寸(px),纵向为高度,横向为宽度 */
155
+ itemSize: { type: Number, default: 50 },
156
+ /** item 的唯一键字段名 */
157
+ keyField: { type: String, default: 'id' },
158
+ /** 预渲染缓冲区大小(item 数量) */
159
+ bufferSize: { type: Number, default: 5 },
160
+ /** 虚拟滚动方向 */
161
+ scrollDirection: {
162
+ type: String,
163
+ default: 'vertical',
164
+ validator: (v) => ['vertical', 'horizontal'].includes(v)
165
+ },
166
+ /** item 的自定义 CSS 类名 */
167
+ itemClassName: { type: String, default: '' },
168
+
169
+ // ========== 容器尺寸 ==========
170
+ height: { type: [Number, String], default: '' },
171
+ maxHeight: { type: [Number, String], default: '' },
172
+ width: { type: [Number, String], default: '' },
173
+ maxWidth: { type: [Number, String], default: '' },
174
+
175
+ // ========== 状态 ==========
176
+ loading: { type: Boolean, default: false },
177
+ emptyText: { type: String, default: '暂无数据' },
178
+
179
+ // ========== 加载更多 ==========
180
+ loadMore: { type: Boolean, default: false },
181
+ loadMoreText: { type: String, default: '加载更多' },
182
+ loadMoreLoading: { type: Boolean, default: false }
183
+ },
184
+
185
+ data() {
186
+ return {
187
+ scrollPos: 0,
188
+ containerSize: 0,
189
+ resizeObserver: null,
190
+ rafId: null
191
+ }
192
+ },
193
+
194
+ computed: {
195
+ containerStyle() {
196
+ const style = {}
197
+ if (this.height) {
198
+ style.height = typeof this.height === 'number' ? this.height + 'px' : this.height
199
+ }
200
+ if (this.maxHeight) {
201
+ style.maxHeight = typeof this.maxHeight === 'number' ? this.maxHeight + 'px' : this.maxHeight
202
+ }
203
+ if (this.width) {
204
+ style.width = typeof this.width === 'number' ? this.width + 'px' : this.width
205
+ }
206
+ if (this.maxWidth) {
207
+ style.maxWidth = typeof this.maxWidth === 'number' ? this.maxWidth + 'px' : this.maxWidth
208
+ }
209
+ return style
210
+ },
211
+
212
+ virtualWrapperStyle() {
213
+ const style = {}
214
+ if (this.scrollDirection === 'horizontal') {
215
+ style.height = '100%'
216
+ }
217
+ return style
218
+ },
219
+
220
+ itemStyle() {
221
+ return this.scrollDirection === 'vertical'
222
+ ? { height: this.itemSize + 'px' }
223
+ : { width: this.itemSize + 'px', display: 'inline-block' }
224
+ },
225
+
226
+ /** 数据总条数 */
227
+ dataCount() {
228
+ return (this.data && this.data.length) || 0
229
+ },
230
+
231
+ /** 总滚动尺寸 */
232
+ totalSize() {
233
+ return this.dataCount * this.itemSize
234
+ },
235
+
236
+ /** 虚拟滚动:可见范围起始索引 */
237
+ visibleStartIndex() {
238
+ if (!this.vScroll) return 0
239
+ const start = Math.floor(this.scrollPos / this.itemSize)
240
+ return Math.max(0, start - this.bufferSize)
241
+ },
242
+
243
+ /** 虚拟滚动:可见范围结束索引 */
244
+ visibleEndIndex() {
245
+ if (!this.vScroll) return this.dataCount
246
+ const visibleCount = Math.ceil(this.containerSize / this.itemSize)
247
+ const end = Math.ceil(this.scrollPos / this.itemSize) + visibleCount
248
+ return Math.min(this.dataCount, end + this.bufferSize)
249
+ },
250
+
251
+ /** 可见数据 */
252
+ visibleData() {
253
+ if (!this.vScroll || !this.data) return this.data || []
254
+ return this.data.slice(this.visibleStartIndex, this.visibleEndIndex)
255
+ },
256
+
257
+ /** 偏移量(px) */
258
+ offsetStart() {
259
+ return this.visibleStartIndex * this.itemSize
260
+ },
261
+
262
+ /** 是否显示加载更多 */
263
+ showLoadMore() {
264
+ if (!this.loadMore || !this.dataCount) return false
265
+ if (this.scrollDirection === 'vertical') {
266
+ return this.scrollPos + this.containerSize >= this.totalSize - this.itemSize * 2
267
+ }
268
+ return false
269
+ }
270
+ },
271
+
272
+ watch: {
273
+ data: {
274
+ handler() {
275
+ this.$nextTick(() => {
276
+ this.updateContainerSize()
277
+ })
278
+ }
279
+ },
280
+ vScroll(val) {
281
+ if (val) {
282
+ this.$nextTick(() => {
283
+ this.updateContainerSize()
284
+ this.bindResizeObserver()
285
+ })
286
+ }
287
+ }
288
+ },
289
+
290
+ mounted() {
291
+ this.$nextTick(() => {
292
+ this.updateContainerSize()
293
+ if (this.vScroll) {
294
+ this.bindResizeObserver()
295
+ }
296
+ })
297
+ },
298
+
299
+ beforeDestroy() {
300
+ this.unbindResizeObserver()
301
+ if (this.rafId && typeof cancelAnimationFrame !== 'undefined') {
302
+ cancelAnimationFrame(this.rafId)
303
+ this.rafId = null
304
+ }
305
+ },
306
+
307
+ methods: {
308
+ // ========== 虚拟滚动 ==========
309
+ onScroll() {
310
+ const wrap = this.$refs.scrollWrap
311
+ if (!wrap) return
312
+
313
+ const pos = this.scrollDirection === 'vertical' ? wrap.scrollTop : wrap.scrollLeft
314
+ this.scrollPos = pos
315
+
316
+ // 对外 emit scroll 事件,传递 scrollTop/scrollLeft 方便父组件使用
317
+ this.$emit('scroll', {
318
+ scrollTop: wrap.scrollTop,
319
+ scrollLeft: wrap.scrollLeft
320
+ })
321
+
322
+ if (this.rafId) return
323
+ if (typeof requestAnimationFrame === 'undefined') return
324
+ this.rafId = requestAnimationFrame(() => {
325
+ this.$forceUpdate()
326
+ this.rafId = null
327
+ })
328
+ },
329
+
330
+ getItemKey(item, index) {
331
+ if (item && typeof item === 'object' && this.keyField && item[this.keyField] != null) {
332
+ return item[this.keyField]
333
+ }
334
+ return `vitem_${this.visibleStartIndex + index}`
335
+ },
336
+
337
+ getOriginalIndex(index) {
338
+ return this.visibleStartIndex + index
339
+ },
340
+
341
+ // ========== 容器尺寸 ==========
342
+ updateContainerSize() {
343
+ const wrap = this.$refs.scrollWrap
344
+ if (!wrap) return
345
+
346
+ this.containerSize = this.scrollDirection === 'vertical'
347
+ ? wrap.clientHeight
348
+ : wrap.clientWidth
349
+ },
350
+
351
+ bindResizeObserver() {
352
+ if (typeof ResizeObserver === 'undefined') return
353
+ this.unbindResizeObserver()
354
+
355
+ const wrap = this.$refs.scrollWrap
356
+ if (!wrap) return
357
+
358
+ this.resizeObserver = new ResizeObserver(() => {
359
+ this.updateContainerSize()
360
+ })
361
+ this.resizeObserver.observe(wrap)
362
+ },
363
+
364
+ unbindResizeObserver() {
365
+ if (this.resizeObserver) {
366
+ this.resizeObserver.disconnect()
367
+ this.resizeObserver = null
368
+ }
369
+ },
370
+
371
+ // ========== 加载更多 ==========
372
+ onLoadMore() {
373
+ this.$emit('load-more')
374
+ },
375
+
376
+ // ========== 对外暴露方法 ==========
377
+ /** 获取原生滚动容器 DOM 元素 */
378
+ getScrollContainer() {
379
+ return this.$refs.scrollWrap
380
+ },
381
+
382
+ /** 滚动到指定位置 */
383
+ scrollTo(pos, behavior) {
384
+ const wrap = this.$refs.scrollWrap
385
+ if (!wrap) return
386
+
387
+ const opts = behavior && typeof behavior === 'string'
388
+ ? { behavior }
389
+ : { behavior: 'smooth' }
390
+
391
+ if (this.scrollDirection === 'vertical') {
392
+ wrap.scrollTo({ top: pos, ...opts })
393
+ } else {
394
+ wrap.scrollTo({ left: pos, ...opts })
395
+ }
396
+ },
397
+
398
+ /** 滚动到指定索引的 item */
399
+ scrollToItem(index) {
400
+ const pos = index * this.itemSize
401
+ this.scrollTo(pos)
402
+ },
403
+
404
+ /** 滚动到顶部/左侧 */
405
+ scrollToStart() {
406
+ this.scrollTo(0)
407
+ },
408
+
409
+ /** 滚动到底部/右侧 */
410
+ scrollToEnd() {
411
+ this.scrollTo(this.totalSize)
412
+ },
413
+
414
+ /** 获取当前滚动位置 */
415
+ getScrollPos() {
416
+ return this.scrollPos
417
+ }
418
+ }
419
+ });
420
+
421
+ // CONCATENATED MODULE: ./src/components/xt-scroll/index.vue?vue&type=script&lang=js
422
+ /* harmony default export */ var components_xt_scrollvue_type_script_lang_js = (xt_scrollvue_type_script_lang_js);
423
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
424
+ /* globals __VUE_SSR_CONTEXT__ */
425
+
426
+ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
427
+ // This module is a runtime utility for cleaner component module output and will
428
+ // be included in the final webpack user bundle.
429
+
430
+ function normalizeComponent(
431
+ scriptExports,
432
+ render,
433
+ staticRenderFns,
434
+ functionalTemplate,
435
+ injectStyles,
436
+ scopeId,
437
+ moduleIdentifier /* server only */,
438
+ shadowMode /* vue-cli only */
439
+ ) {
440
+ // Vue.extend constructor export interop
441
+ var options =
442
+ typeof scriptExports === 'function' ? scriptExports.options : scriptExports
443
+
444
+ // render functions
445
+ if (render) {
446
+ options.render = render
447
+ options.staticRenderFns = staticRenderFns
448
+ options._compiled = true
449
+ }
450
+
451
+ // functional template
452
+ if (functionalTemplate) {
453
+ options.functional = true
454
+ }
455
+
456
+ // scopedId
457
+ if (scopeId) {
458
+ options._scopeId = 'data-v-' + scopeId
459
+ }
460
+
461
+ var hook
462
+ if (moduleIdentifier) {
463
+ // server build
464
+ hook = function (context) {
465
+ // 2.3 injection
466
+ context =
467
+ context || // cached call
468
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
469
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
470
+ // 2.2 with runInNewContext: true
471
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
472
+ context = __VUE_SSR_CONTEXT__
473
+ }
474
+ // inject component styles
475
+ if (injectStyles) {
476
+ injectStyles.call(this, context)
477
+ }
478
+ // register component module identifier for async chunk inferrence
479
+ if (context && context._registeredComponents) {
480
+ context._registeredComponents.add(moduleIdentifier)
481
+ }
482
+ }
483
+ // used by ssr in case component is cached and beforeCreate
484
+ // never gets called
485
+ options._ssrRegister = hook
486
+ } else if (injectStyles) {
487
+ hook = shadowMode
488
+ ? function () {
489
+ injectStyles.call(
490
+ this,
491
+ (options.functional ? this.parent : this).$root.$options.shadowRoot
492
+ )
493
+ }
494
+ : injectStyles
495
+ }
496
+
497
+ if (hook) {
498
+ if (options.functional) {
499
+ // for template-only hot-reload because in that case the render fn doesn't
500
+ // go through the normalizer
501
+ options._injectStyles = hook
502
+ // register for functional component in vue file
503
+ var originalRender = options.render
504
+ options.render = function renderWithStyleInjection(h, context) {
505
+ hook.call(context)
506
+ return originalRender(h, context)
507
+ }
508
+ } else {
509
+ // inject component registration as beforeCreate hook
510
+ var existing = options.beforeCreate
511
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
512
+ }
513
+ }
514
+
515
+ return {
516
+ exports: scriptExports,
517
+ options: options
518
+ }
519
+ }
520
+
521
+ // CONCATENATED MODULE: ./src/components/xt-scroll/index.vue
522
+
523
+
524
+
525
+
526
+
527
+ /* normalize component */
528
+
529
+ var component = normalizeComponent(
530
+ components_xt_scrollvue_type_script_lang_js,
531
+ render,
532
+ staticRenderFns,
533
+ false,
534
+ null,
535
+ null,
536
+ null
537
+
538
+ )
539
+
540
+ /* harmony default export */ var xt_scroll = (component.exports);
541
+ // CONCATENATED MODULE: ./src/components/xt-scroll/index.js
542
+
543
+
544
+
545
+ xt_scroll.install = function (Vue) {
546
+ Vue.component(xt_scroll.name, xt_scroll)
547
+ }
548
+
549
+ /* harmony default export */ var components_xt_scroll = (xt_scroll);
550
+
551
+ // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
552
+
553
+
554
+ /* harmony default export */ var entry_lib = __webpack_exports__["default"] = (components_xt_scroll);
555
+
556
+
557
+
558
+ /***/ })
559
+
560
+ /******/ });
561
+ });
@@ -0,0 +1 @@
1
+ (function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["xt-scroll"]=e():t["xt-scroll"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var s=e[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(r,s,function(e){return t[e]}.bind(null,s));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s="fb15")}({f699:function(t,e,i){},fb15:function(t,e,i){"use strict";if(i.r(e),i.d(e,"XtScroll",(function(){return h})),"undefined"!==typeof window){var r=window.document.currentScript,s=r&&r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);s&&(i.p=s[1])}i("f699");var o=function(){var t=this,e=t._self._c;return e("div",{staticClass:"xt-scroll",class:["xt-scroll--"+t.scrollDirection],style:t.containerStyle},[e("div",{ref:"scrollWrap",staticClass:"xt-scroll__wrap",class:["xt-scroll__wrap--"+t.scrollDirection],on:{scroll:t.onScroll}},[t.vScroll?e("div",{staticClass:"xt-scroll__virtual",style:t.virtualWrapperStyle},["vertical"===t.scrollDirection?e("div",{staticClass:"xt-scroll__phantom",style:{height:t.totalSize+"px"}},[e("div",{style:{transform:`translateY(${t.offsetStart}px)`}},[t._l(t.visibleData,(function(i,r){return[e("div",{key:t.getItemKey(i,r),staticClass:"xt-scroll__item",class:t.itemClassName,style:t.itemStyle},[t._t("item",(function(){return[t._v(" "+t._s(i)+" ")]}),{item:i,index:t.getOriginalIndex(r)})],2)]}))],2)]):"horizontal"===t.scrollDirection?e("div",{staticClass:"xt-scroll__phantom",style:{width:t.totalSize+"px"}},[e("div",{style:{transform:`translateX(${t.offsetStart}px)`}},[t._l(t.visibleData,(function(i,r){return[e("div",{key:t.getItemKey(i,r),staticClass:"xt-scroll__item",class:t.itemClassName,style:t.itemStyle},[t._t("item",(function(){return[t._v(" "+t._s(i)+" ")]}),{item:i,index:t.getOriginalIndex(r)})],2)]}))],2)]):t._e()]):t._e(),!t.vScroll||t.data&&t.data.length||t.loading?t._e():e("div",{staticClass:"xt-scroll__empty"},[t._t("empty",(function(){return[e("span",[t._v(t._s(t.emptyText))])]}))],2),t.loading?e("div",{staticClass:"xt-scroll__loading"},[t._t("loading",(function(){return[e("i",{staticClass:"el-icon-loading"}),e("span",[t._v("加载中...")])]}))],2):t._e(),t.vScroll?t._e():e("div",{staticClass:"xt-scroll__default"},[t._t("default")],2),t.vScroll&&t.showLoadMore&&!t.loading?e("div",{staticClass:"xt-scroll__loadmore",on:{click:t.onLoadMore}},[e("el-button",{attrs:{type:"text",loading:t.loadMoreLoading}},[t._v(" "+t._s(t.loadMoreText)+" ")])],1):t._e()])])},l=[],n={name:"XtScroll",props:{vScroll:{type:Boolean,default:!1},data:{type:Array,default:()=>[]},itemSize:{type:Number,default:50},keyField:{type:String,default:"id"},bufferSize:{type:Number,default:5},scrollDirection:{type:String,default:"vertical",validator:t=>["vertical","horizontal"].includes(t)},itemClassName:{type:String,default:""},height:{type:[Number,String],default:""},maxHeight:{type:[Number,String],default:""},width:{type:[Number,String],default:""},maxWidth:{type:[Number,String],default:""},loading:{type:Boolean,default:!1},emptyText:{type:String,default:"暂无数据"},loadMore:{type:Boolean,default:!1},loadMoreText:{type:String,default:"加载更多"},loadMoreLoading:{type:Boolean,default:!1}},data(){return{scrollPos:0,containerSize:0,resizeObserver:null,rafId:null}},computed:{containerStyle(){const t={};return this.height&&(t.height="number"===typeof this.height?this.height+"px":this.height),this.maxHeight&&(t.maxHeight="number"===typeof this.maxHeight?this.maxHeight+"px":this.maxHeight),this.width&&(t.width="number"===typeof this.width?this.width+"px":this.width),this.maxWidth&&(t.maxWidth="number"===typeof this.maxWidth?this.maxWidth+"px":this.maxWidth),t},virtualWrapperStyle(){const t={};return"horizontal"===this.scrollDirection&&(t.height="100%"),t},itemStyle(){return"vertical"===this.scrollDirection?{height:this.itemSize+"px"}:{width:this.itemSize+"px",display:"inline-block"}},dataCount(){return this.data&&this.data.length||0},totalSize(){return this.dataCount*this.itemSize},visibleStartIndex(){if(!this.vScroll)return 0;const t=Math.floor(this.scrollPos/this.itemSize);return Math.max(0,t-this.bufferSize)},visibleEndIndex(){if(!this.vScroll)return this.dataCount;const t=Math.ceil(this.containerSize/this.itemSize),e=Math.ceil(this.scrollPos/this.itemSize)+t;return Math.min(this.dataCount,e+this.bufferSize)},visibleData(){return this.vScroll&&this.data?this.data.slice(this.visibleStartIndex,this.visibleEndIndex):this.data||[]},offsetStart(){return this.visibleStartIndex*this.itemSize},showLoadMore(){return!(!this.loadMore||!this.dataCount)&&("vertical"===this.scrollDirection&&this.scrollPos+this.containerSize>=this.totalSize-2*this.itemSize)}},watch:{data:{handler(){this.$nextTick(()=>{this.updateContainerSize()})}},vScroll(t){t&&this.$nextTick(()=>{this.updateContainerSize(),this.bindResizeObserver()})}},mounted(){this.$nextTick(()=>{this.updateContainerSize(),this.vScroll&&this.bindResizeObserver()})},beforeDestroy(){this.unbindResizeObserver(),this.rafId&&"undefined"!==typeof cancelAnimationFrame&&(cancelAnimationFrame(this.rafId),this.rafId=null)},methods:{onScroll(){const t=this.$refs.scrollWrap;if(!t)return;const e="vertical"===this.scrollDirection?t.scrollTop:t.scrollLeft;this.scrollPos=e,this.$emit("scroll",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),this.rafId||"undefined"!==typeof requestAnimationFrame&&(this.rafId=requestAnimationFrame(()=>{this.$forceUpdate(),this.rafId=null}))},getItemKey(t,e){return t&&"object"===typeof t&&this.keyField&&null!=t[this.keyField]?t[this.keyField]:"vitem_"+(this.visibleStartIndex+e)},getOriginalIndex(t){return this.visibleStartIndex+t},updateContainerSize(){const t=this.$refs.scrollWrap;t&&(this.containerSize="vertical"===this.scrollDirection?t.clientHeight:t.clientWidth)},bindResizeObserver(){if("undefined"===typeof ResizeObserver)return;this.unbindResizeObserver();const t=this.$refs.scrollWrap;t&&(this.resizeObserver=new ResizeObserver(()=>{this.updateContainerSize()}),this.resizeObserver.observe(t))},unbindResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)},onLoadMore(){this.$emit("load-more")},getScrollContainer(){return this.$refs.scrollWrap},scrollTo(t,e){const i=this.$refs.scrollWrap;if(!i)return;const r=e&&"string"===typeof e?{behavior:e}:{behavior:"smooth"};"vertical"===this.scrollDirection?i.scrollTo({top:t,...r}):i.scrollTo({left:t,...r})},scrollToItem(t){const e=t*this.itemSize;this.scrollTo(e)},scrollToStart(){this.scrollTo(0)},scrollToEnd(){this.scrollTo(this.totalSize)},getScrollPos(){return this.scrollPos}}},a=n;function c(t,e,i,r,s,o,l,n){var a,c="function"===typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=i,c._compiled=!0),r&&(c.functional=!0),o&&(c._scopeId="data-v-"+o),l?(a=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(l)},c._ssrRegister=a):s&&(a=n?function(){s.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:s),a)if(c.functional){c._injectStyles=a;var d=c.render;c.render=function(t,e){return a.call(e),d(t,e)}}else{var h=c.beforeCreate;c.beforeCreate=h?[].concat(h,a):[a]}return{exports:t,options:c}}var d=c(a,o,l,!1,null,null,null),h=d.exports;h.install=function(t){t.component(h.name,h)};var u=h;e["default"]=u}})}));