uview-plus 3.4.9 → 3.4.11

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/changelog.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 3.4.10(2025-03-28)
2
+ feat: select组件新增多个props属性及优化
3
+
4
+ fix: 修复cate-tab报错index is not defined #661
5
+
1
6
 
2
7
  ## 3.4.9(2025-03-27)
3
8
  fix: 修复upload组件split报错
@@ -92,7 +92,7 @@
92
92
  watch: {
93
93
  current(nval) {
94
94
  this.innerCurrent = nval;
95
- this.leftMenuStatus(index);
95
+ this.leftMenuStatus(this.innerCurrent);
96
96
  }
97
97
  },
98
98
  methods: {
@@ -1,5 +1,7 @@
1
1
  <template>
2
- <view class="u-popup" :class="[customClass]">
2
+ <view class="u-popup" :class="[customClass]"
3
+ :style="{width: show == false ? '0px' : '',
4
+ height: show == false ? '0px' : ''}">
3
5
  <view class="u-popup__trigger">
4
6
  <slot name="trigger">
5
7
  </slot>
@@ -1,93 +1,165 @@
1
1
  <template>
2
2
  <view class="u-select">
3
- <view class="u-select__content">
4
- <view class="u-select__label" @click="openSelect">
5
- <slot name="text">
6
- <text class="u-select__text">
7
- {{ label }}
8
- </text>
9
- </slot>
10
- <slot name="icon">
11
- <u-icon name="arrow-down" :size="iconSize" :color="iconColor"></u-icon>
12
- </slot>
13
- </view>
14
- <view class="u-select__options"
15
- :style="{zIndex: zIndex}" v-if="isOpen">
16
- <slot name="options">
17
- <view class="u-select__options_item"
18
- :class="current == item[keyName] ? 'active': ''"
19
- :key="index" v-for="(item, index) in options"
20
- @click="selectItem(item)">
21
- <slot name="optionItem" :item="item">
22
- <text class="u-select__item_text" :style="{color: itemColor}">
23
- {{item.name}}
24
- </text>
25
- </slot>
26
- </view>
27
- </slot>
28
- </view>
29
- </view>
3
+ <view class="u-select__content">
4
+ <view class="u-select__label" @click="openSelect">
5
+ <slot name="text">
6
+ <text class="u-select__text" v-if="showOptionsLabel">
7
+ {{ currentLabel }}
8
+ </text>
9
+ <text class="u-select__text" v-else>
10
+ {{ label }}
11
+ </text>
12
+ </slot>
13
+ <slot name="icon">
14
+ <u-icon name="arrow-down" :size="iconSize" :color="iconColor"></u-icon>
15
+ </slot>
16
+ </view>
17
+ <u-overlay
18
+ :show="isOpen"
19
+ @click="overlayClick"
20
+ v-if="overlay"
21
+ :zIndex="zIndex"
22
+ :duration="duration + 50"
23
+ :customStyle="overlayStyle"
24
+ :opacity="overlayOpacity"
25
+ ></u-overlay>
26
+ <view class="u-select__options__wrap"
27
+ :style="{ zIndex: zIndex + 1, left: optionsWrapLeft, right: optionsWrapRight }">
28
+ <view class="u-select__options" v-if="isOpen">
29
+ <slot name="options">
30
+ <view class="u-select__options_item"
31
+ :class="current == item[keyName] ? 'active': ''"
32
+ :key="index" v-for="(item, index) in options"
33
+ @click="selectItem(item)">
34
+ <slot name="optionItem" :item="item">
35
+ <text class="u-select__item_text" :style="{color: itemColor}">
36
+ {{item[labelName]}}
37
+ </text>
38
+ </slot>
39
+ </view>
40
+ </slot>
41
+ </view>
42
+ </view>
43
+ </view>
30
44
  </view>
31
45
  </template>
32
46
 
33
47
  <script>
34
- export default {
35
- name:"up-select",
36
- emits: ['update:current', 'select'],
37
- props: {
38
- label: {
39
- type: String,
40
- default: '选项'
41
- },
42
- options: {
43
- type: Array,
44
- default: () => {
45
- return []
46
- }
47
- },
48
- keyName: {
49
- type: String,
50
- default: 'id'
51
- },
52
- current: {
53
- type: [String, Number],
54
- default: ''
55
- },
56
- zIndex: {
57
- type: Number,
58
- default: 10
59
- },
60
- itemColor: {
61
- type: String,
62
- default: '#333333'
63
- },
64
- iconColor: {
65
- type: String,
66
- default: ''
67
- },
68
- iconSize: {
69
- type: [String],
70
- default: '13px'
71
- }
72
- } ,
73
- data() {
74
- return {
75
- isOpen: false
48
+ import { getWindowInfo } from '../../libs/function/index';
49
+ export default {
50
+ name:"up-select",
51
+ emits: ['update:current', 'select'],
52
+ props: {
53
+ overlay: {
54
+ type: Boolean,
55
+ default: true
56
+ },
57
+ overlayOpacity: {
58
+ type: Number,
59
+ default: 0.01
60
+ },
61
+ overlayStyle: {
62
+ type: Object,
63
+ default: () => {
64
+ return {}
65
+ }
66
+ },
67
+ duration: {
68
+ type: Number,
69
+ default: 300
70
+ },
71
+ label: {
72
+ type: String,
73
+ default: '选项'
74
+ },
75
+ options: {
76
+ type: Array,
77
+ default: () => {
78
+ return []
76
79
  }
77
80
  },
78
- mounted() {
81
+ keyName: {
82
+ type: String,
83
+ default: 'id'
84
+ },
85
+ labelName: {
86
+ type: String,
87
+ default: 'name'
88
+ },
89
+ showOptionsLabel: {
90
+ type: Boolean,
91
+ default: false
92
+ },
93
+ current: {
94
+ type: [String, Number],
95
+ default: ''
96
+ },
97
+ zIndex: {
98
+ type: Number,
99
+ default: 11000
100
+ },
101
+ itemColor: {
102
+ type: String,
103
+ default: '#333333'
104
+ },
105
+ iconColor: {
106
+ type: String,
107
+ default: ''
108
+ },
109
+ iconSize: {
110
+ type: [String],
111
+ default: '13px'
112
+ }
113
+ },
114
+ data() {
115
+ return {
116
+ isOpen: false,
117
+ optionsWrapLeft: 'auto',
118
+ optionsWrapRight: 'auto'
119
+ }
120
+ },
121
+ computed: {
122
+ currentLabel() {
123
+ let name = '';
124
+ this.options.forEach((ele) => {
125
+ if (ele[this.keyName] === this.current) {
126
+ name = ele[this.labelName];
127
+ }
128
+ });
129
+ return name;
130
+ }
79
131
  },
80
132
  methods: {
81
133
  openSelect() {
82
- this.isOpen = !this.isOpen
134
+ this.isOpen = true;
135
+ this.$nextTick(() => {
136
+ if (this.isOpen) {
137
+ this.adjustOptionsWrapPosition();
138
+ }
139
+ });
83
140
  },
141
+ overlayClick() {
142
+ this.isOpen = false;
143
+ },
84
144
  selectItem(item) {
85
- this.isOpen = false
86
- this.$emit('update:current', item[this.keyName])
87
- this.$emit('select', item)
88
- }
145
+ this.isOpen = false;
146
+ this.$emit('update:current', item[this.keyName]);
147
+ this.$emit('select', item);
148
+ },
149
+ adjustOptionsWrapPosition() {
150
+ let wi = getWindowInfo();
151
+ let windowWidth = wi.windowWidth;
152
+ this.$uGetRect('.u-select__options__wrap').then(rect => {
153
+ console.log(rect)
154
+ if (rect.left + rect.width > windowWidth) {
155
+ // 如果右侧被遮挡,则调整到左侧
156
+ this.optionsWrapLeft = 'auto';
157
+ this.optionsWrapRight = `0px`;
158
+ }
159
+ });
160
+ }
89
161
  }
90
- }
162
+ }
91
163
  </script>
92
164
 
93
165
  <style lang="scss" scoped>
@@ -95,6 +167,7 @@
95
167
  position: relative;
96
168
  .u-select__label {
97
169
  display: flex;
170
+ justify-content: space-between;
98
171
  /* #ifdef H5 */
99
172
  &:hover {
100
173
  cursor: pointer;
@@ -104,17 +177,20 @@
104
177
  .u-select__text {
105
178
  margin-right: 2px;
106
179
  }
180
+ .u-select__options__wrap {
181
+ margin-bottom: 46px;
182
+ position: absolute;
183
+ top: 20px;
184
+ left: 0;
185
+ }
107
186
  .u-select__options {
108
- min-width: 100px;
187
+ min-width: 100px;
109
188
  box-sizing: border-box;
110
189
  border-radius: 4px;
111
190
  border: 1px solid #f1f1f1;
112
191
  background-color: #fff;
113
- position: absolute;
114
- top: 20px;
115
- left: 0;
116
192
  .u-select__options_item {
117
- padding: 10px 12px;
193
+ padding: 10px 12px;
118
194
  box-sizing: border-box;
119
195
  width: 100%;
120
196
  height: 100%;
@@ -125,19 +125,6 @@
125
125
  </view>
126
126
  </slot>
127
127
  </view>
128
- <up-popup
129
- mode="center"
130
- v-model:show="popupShow">
131
- <video id="myVideo"
132
- :src="currentItemIndex >= 0 ? lists[currentItemIndex].url : ''"
133
- @error="videoErrorCallback" show-center-play-btn
134
- object-fit='cover' show-fullscreen-btn='true'
135
- enable-play-gesture controls
136
- :autoplay="true" auto-pause-if-open-native
137
- @loadedmetadata="loadedVideoMetadata"
138
- :initial-time='0.1'>
139
- </video>
140
- </up-popup>
141
128
  </template>
142
129
  <canvas id="myCanvas" type="2d"
143
130
  style="width: 100px; height: 150px;display: none;"></canvas>
@@ -178,6 +165,19 @@
178
165
  </view>
179
166
  </template>
180
167
  </view>
168
+ <up-popup
169
+ mode="center"
170
+ v-model:show="popupShow">
171
+ <video id="myVideo"
172
+ :src="currentItemIndex >= 0 ? lists[currentItemIndex].url : ''"
173
+ @error="videoErrorCallback" show-center-play-btn
174
+ object-fit='cover' show-fullscreen-btn='true'
175
+ enable-play-gesture controls
176
+ :autoplay="true" auto-pause-if-open-native
177
+ @loadedmetadata="loadedVideoMetadata"
178
+ :initial-time='0.1'>
179
+ </video>
180
+ </up-popup>
181
181
  </view>
182
182
  </template>
183
183
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙移动组件库。",
5
- "version": "3.4.9",
5
+ "version": "3.4.11",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
7
7
  "keywords": [
8
8
  "uview",