xt-element-ui 2.0.2 → 2.0.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xt-element-ui",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "基于 Vue 2.7 + ElementUI 的企业级组件库,提供丰富的自定义组件和扩展组件",
5
5
  "main": "lib/index.common.js",
6
6
  "module": "lib/index.esm.js",
@@ -36,7 +36,8 @@
36
36
  "echarts": "^6.1.0",
37
37
  "element-ui": "^2.15.14",
38
38
  "sass": "^1.32.13",
39
- "vue-server-renderer": "^2.7.14"
39
+ "vue-server-renderer": "^2.7.14",
40
+ "xt-element-ui": "^2.0.2"
40
41
  },
41
42
  "keywords": [
42
43
  "vue",
@@ -40,4 +40,7 @@
40
40
  @import './xt-tabs/style/index.scss';
41
41
 
42
42
  // Badge 组件样式
43
- @import './xt-badge/style/index.scss';
43
+ @import './xt-badge/style/index.scss';
44
+
45
+ // ScrollArrow 组件样式
46
+ @import './xt-scroll-arrow/style/index.scss';
@@ -0,0 +1,8 @@
1
+ import XtScrollArrow from './index.vue'
2
+
3
+ XtScrollArrow.install = function (Vue) {
4
+ Vue.component(XtScrollArrow.name, XtScrollArrow)
5
+ }
6
+
7
+ export default XtScrollArrow
8
+ export { XtScrollArrow }
@@ -0,0 +1,190 @@
1
+ <template>
2
+ <div class="xt-scroll-arrow" :class="[`xt-scroll-arrow--${direction}`]" :style="containerStyle">
3
+ <div
4
+ v-if="showLeftArrow"
5
+ class="xt-scroll-arrow__btn xt-scroll-arrow__btn--left"
6
+ @click="scrollLeft"
7
+ >
8
+ <i class="el-icon-arrow-left"></i>
9
+ </div>
10
+
11
+ <div ref="scrollContainer" class="xt-scroll-arrow__content" @scroll="handleScroll">
12
+ <slot></slot>
13
+ </div>
14
+
15
+ <div
16
+ v-if="showRightArrow"
17
+ class="xt-scroll-arrow__btn xt-scroll-arrow__btn--right"
18
+ @click="scrollRight"
19
+ >
20
+ <i class="el-icon-arrow-right"></i>
21
+ </div>
22
+
23
+ <div
24
+ v-if="showTopArrow && direction === 'vertical'"
25
+ class="xt-scroll-arrow__btn xt-scroll-arrow__btn--top"
26
+ @click="scrollTop"
27
+ >
28
+ <i class="el-icon-arrow-up"></i>
29
+ </div>
30
+
31
+ <div
32
+ v-if="showBottomArrow && direction === 'vertical'"
33
+ class="xt-scroll-arrow__btn xt-scroll-arrow__btn--bottom"
34
+ @click="scrollBottom"
35
+ >
36
+ <i class="el-icon-arrow-down"></i>
37
+ </div>
38
+ </div>
39
+ </template>
40
+
41
+ <script>
42
+ export default {
43
+ name: 'XtScrollArrow',
44
+ props: {
45
+ direction: {
46
+ type: String,
47
+ default: 'horizontal',
48
+ validator: (val) => ['horizontal', 'vertical'].includes(val)
49
+ },
50
+ scrollStep: {
51
+ type: Number,
52
+ default: 100
53
+ },
54
+ autoHide: {
55
+ type: Boolean,
56
+ default: true
57
+ },
58
+ height: {
59
+ type: [String, Number],
60
+ default: ''
61
+ },
62
+ width: {
63
+ type: [String, Number],
64
+ default: ''
65
+ }
66
+ },
67
+ data() {
68
+ return {
69
+ showLeftArrow: false,
70
+ showRightArrow: false,
71
+ showTopArrow: false,
72
+ showBottomArrow: false
73
+ }
74
+ },
75
+ computed: {
76
+ containerStyle() {
77
+ const style = {}
78
+ if (this.height) {
79
+ style.height = typeof this.height === 'number' ? `${this.height}px` : this.height
80
+ }
81
+ if (this.width) {
82
+ style.width = typeof this.width === 'number' ? `${this.width}px` : this.width
83
+ }
84
+ return style
85
+ }
86
+ },
87
+ watch: {
88
+ direction() {
89
+ this.$nextTick(() => {
90
+ this.checkScroll()
91
+ })
92
+ }
93
+ },
94
+ mounted() {
95
+ this.$nextTick(() => {
96
+ this.checkScroll()
97
+ })
98
+ this.addResizeObserver()
99
+ },
100
+ beforeDestroy() {
101
+ this.removeResizeObserver()
102
+ },
103
+ methods: {
104
+ addResizeObserver() {
105
+ if (typeof ResizeObserver !== 'undefined') {
106
+ this.resizeObserver = new ResizeObserver(() => {
107
+ this.$nextTick(() => {
108
+ this.checkScroll()
109
+ })
110
+ })
111
+ const container = this.$refs.scrollContainer
112
+ if (container) {
113
+ this.resizeObserver.observe(container)
114
+ }
115
+ }
116
+ },
117
+ removeResizeObserver() {
118
+ if (this.resizeObserver) {
119
+ this.resizeObserver.disconnect()
120
+ }
121
+ },
122
+ checkScroll() {
123
+ const container = this.$refs.scrollContainer
124
+ if (!container) return
125
+
126
+ if (this.direction === 'horizontal') {
127
+ const scrollLeft = container.scrollLeft
128
+ const scrollWidth = container.scrollWidth
129
+ const clientWidth = container.clientWidth
130
+ const maxScroll = scrollWidth - clientWidth
131
+
132
+ this.showTopArrow = false
133
+ this.showBottomArrow = false
134
+
135
+ if (this.autoHide) {
136
+ this.showLeftArrow = scrollLeft > 0
137
+ this.showRightArrow = maxScroll > 0 && scrollLeft < maxScroll
138
+ } else {
139
+ this.showLeftArrow = maxScroll > 0
140
+ this.showRightArrow = maxScroll > 0
141
+ }
142
+ } else {
143
+ const scrollTop = container.scrollTop
144
+ const scrollHeight = container.scrollHeight
145
+ const clientHeight = container.clientHeight
146
+ const maxScroll = scrollHeight - clientHeight
147
+
148
+ this.showLeftArrow = false
149
+ this.showRightArrow = false
150
+
151
+ if (this.autoHide) {
152
+ this.showTopArrow = scrollTop > 0
153
+ this.showBottomArrow = maxScroll > 0 && scrollTop < maxScroll
154
+ } else {
155
+ this.showTopArrow = maxScroll > 0
156
+ this.showBottomArrow = maxScroll > 0
157
+ }
158
+ }
159
+ },
160
+ handleScroll() {
161
+ this.checkScroll()
162
+ this.$emit('scroll', this.$refs.scrollContainer)
163
+ },
164
+ scrollLeft() {
165
+ const container = this.$refs.scrollContainer
166
+ if (container) {
167
+ container.scrollBy({ left: -this.scrollStep, behavior: 'smooth' })
168
+ }
169
+ },
170
+ scrollRight() {
171
+ const container = this.$refs.scrollContainer
172
+ if (container) {
173
+ container.scrollBy({ left: this.scrollStep, behavior: 'smooth' })
174
+ }
175
+ },
176
+ scrollTop() {
177
+ const container = this.$refs.scrollContainer
178
+ if (container) {
179
+ container.scrollBy({ top: -this.scrollStep, behavior: 'smooth' })
180
+ }
181
+ },
182
+ scrollBottom() {
183
+ const container = this.$refs.scrollContainer
184
+ if (container) {
185
+ container.scrollBy({ top: this.scrollStep, behavior: 'smooth' })
186
+ }
187
+ }
188
+ }
189
+ }
190
+ </script>
@@ -0,0 +1,89 @@
1
+ @import '../../../styles/variables.scss';
2
+
3
+ .xt-scroll-arrow {
4
+ position: relative;
5
+ display: flex;
6
+ align-items: center;
7
+ overflow: hidden;
8
+
9
+ &--horizontal {
10
+ flex-direction: row;
11
+ }
12
+
13
+ &--vertical {
14
+ flex-direction: column;
15
+ }
16
+
17
+ &__content {
18
+ flex: 1;
19
+ overflow: auto;
20
+ scrollbar-width: none;
21
+ -ms-overflow-style: none;
22
+
23
+ &::-webkit-scrollbar {
24
+ display: none;
25
+ }
26
+ }
27
+
28
+ &__btn {
29
+ position: absolute;
30
+ z-index: 10;
31
+ width: 32px;
32
+ height: 32px;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ background: rgba(255, 255, 255, 0.9);
37
+ border-radius: 50%;
38
+ cursor: pointer;
39
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
40
+ transition: all 0.3s ease;
41
+ border: none;
42
+ padding: 0;
43
+
44
+ &:hover {
45
+ background: rgba(255, 255, 255, 1);
46
+ transform: scale(1.1);
47
+ }
48
+
49
+ &:active {
50
+ transform: scale(0.95);
51
+ }
52
+
53
+ &--left {
54
+ left: 8px;
55
+ }
56
+
57
+ &--right {
58
+ right: 8px;
59
+ }
60
+
61
+ &--top {
62
+ top: 8px;
63
+ left: 50%;
64
+ transform: translateX(-50%);
65
+
66
+ &:hover {
67
+ transform: translateX(-50%) scale(1.1);
68
+ }
69
+
70
+ &:active {
71
+ transform: translateX(-50%) scale(0.95);
72
+ }
73
+ }
74
+
75
+ &--bottom {
76
+ bottom: 8px;
77
+ left: 50%;
78
+ transform: translateX(-50%);
79
+
80
+ &:hover {
81
+ transform: translateX(-50%) scale(1.1);
82
+ }
83
+
84
+ &:active {
85
+ transform: translateX(-50%) scale(0.95);
86
+ }
87
+ }
88
+ }
89
+ }
package/src/index.js CHANGED
@@ -37,6 +37,7 @@ import XtDatePicker from './components/xt-date-picker'
37
37
  import XtChart from './components/xt-chart' // XtChart 组件(基于 ECharts 封装)
38
38
  import XtIcon from './components/xt-icon' // XtIcon 组件(支持 el-icon / svg / 自定义字体)
39
39
  import XtTable from './components/xt-table' // XtTable 组件(基于 ElementUI Table 封装)
40
+ import XtScrollArrow from './components/xt-scroll-arrow'
40
41
 
41
42
 
42
43
  const components = [
@@ -60,7 +61,8 @@ const components = [
60
61
  XtDatePicker,
61
62
  XtChart,
62
63
  XtIcon,
63
- XtTable
64
+ XtTable,
65
+ XtScrollArrow
64
66
  ]
65
67
 
66
68
  const install = function (Vue, options = {}) {
@@ -129,7 +131,8 @@ export default {
129
131
  XtBadge,
130
132
  XtDatePicker,
131
133
  XtIcon,
132
- XtTable
134
+ XtTable,
135
+ XtScrollArrow
133
136
  }
134
137
 
135
138
  // XtChart 组件按需导出(使用时需自行安装 echarts 依赖)