uview-ultra 4.5.71 → 4.5.74
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 +1679 -1635
- package/components/up-cropper/up-cropper.vue +1426 -1392
- package/components/up-form/up-form.uvue +281 -276
- package/components/up-form/up-form.vue +14 -6
- package/components/up-form-item/up-form-item.uvue +14 -1
- package/components/up-form-item/up-form-item.vue +14 -2
- package/components/up-input/up-input.uvue +4 -0
- package/components/up-input/up-input.vue +6 -1
- package/components/up-number-keyboard/up-number-keyboard.uvue +7 -1
- package/components/up-number-keyboard/up-number-keyboard.vue +8 -1
- package/components/up-root/root.js +1 -1
- package/components/up-select/up-select.uvue +328 -314
- package/components/up-select/up-select.vue +19 -2
- package/components/up-sticky/up-sticky.vue +4 -1
- package/components/up-upload/props.js +5 -0
- package/components/up-upload/props.uts +5 -0
- package/components/up-upload/types.uts +1 -0
- package/components/up-upload/up-upload.uvue +9 -0
- package/components/up-upload/up-upload.vue +1 -0
- package/components/up-upload/upload.js +2 -0
- package/components/up-upload/upload.uts +2 -0
- package/components/up-upload/utils.js +23 -12
- package/components/up-upload/utils.uts +4 -0
- package/libs/vite/app-icon-font.js +9 -5
- package/package.json +3 -2
- package/types/comps/upload.d.ts +5 -0
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="up-select">
|
|
3
|
-
<view :class="['up-select__content', disabled ? 'up-select__content--disabled' : '']">
|
|
4
|
-
<view class="up-select__label" @click="openSelect">
|
|
5
|
-
<slot name="text" :currentLabel="currentLabel">
|
|
6
|
-
<text class="up-select__text" v-if="showOptionsLabel">
|
|
7
|
-
{{ currentLabel }}
|
|
8
|
-
</text>
|
|
9
|
-
<text class="up-select__text" v-else>
|
|
10
|
-
{{ label }}
|
|
11
|
-
</text>
|
|
12
|
-
</slot>
|
|
13
|
-
<slot name="icon">
|
|
14
|
-
<up-icon name="arrow-down" :size="iconSize" :color="iconColor"></up-icon>
|
|
15
|
-
</slot>
|
|
16
|
-
</view>
|
|
17
|
-
<up-overlay :show="isOpen" @click="overlayClick" v-if="overlay" :zIndex="zIndex" :duration="duration + 50"
|
|
18
|
-
:customStyle="overlayStyle" :opacity="overlayOpacity" @touchmove.stop.prevent="stopOverlayTouchMove"></up-overlay>
|
|
19
|
-
<view class="up-select__options__wrap"
|
|
20
|
-
:style="optionsWrapStyle">
|
|
21
|
-
<view class="up-select__options" v-if="isOpen">
|
|
22
|
-
<slot name="options">
|
|
23
|
-
<view class="up-select__options-item" :class="getOptionClass(item)"
|
|
24
|
-
:key="index" v-for="(item, index) in options" @click="selectItem(item)">
|
|
25
|
-
<slot name="optionItem" :item="item">
|
|
26
|
-
<text class="up-select__item-text" :style="{color: itemColor}">
|
|
27
|
-
{{ getOptionLabel(item) }}
|
|
28
|
-
</text>
|
|
29
|
-
</slot>
|
|
30
|
-
</view>
|
|
31
|
-
</slot>
|
|
32
|
-
</view>
|
|
33
|
-
</view>
|
|
34
|
-
</view>
|
|
35
|
-
</view>
|
|
36
|
-
</template>
|
|
37
|
-
|
|
38
|
-
<script setup lang="uts">
|
|
39
|
-
import { computed, getCurrentInstance, nextTick, onMounted, ref } from 'vue'
|
|
40
|
-
import type { PropType } from 'vue';
|
|
41
|
-
import { getWindowInfo, upGetRect } from '../../libs/function/index.uts';
|
|
42
|
-
|
|
43
|
-
function createOptions(): UTSJSONObject[] {
|
|
44
|
-
return [] as UTSJSONObject[];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function createEmptyObject(): UTSJSONObject {
|
|
48
|
-
return {} as UTSJSONObject;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function valueToString(value: any | null): string {
|
|
52
|
-
return value == null ? '' : value.toString();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function normalizeNumber(value: any | null, fallback: number = 0): number {
|
|
56
|
-
if (typeof value === 'number') {
|
|
57
|
-
return value;
|
|
58
|
-
}
|
|
59
|
-
if (value == null) {
|
|
60
|
-
return fallback;
|
|
61
|
-
}
|
|
62
|
-
const parsed = parseFloat(value.toString());
|
|
63
|
-
return isNaN(parsed) ? fallback : parsed;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
defineOptions({
|
|
67
|
-
styleIsolation: 'app-and-page',
|
|
68
|
-
name: 'up-select'
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
const props = defineProps({
|
|
72
|
-
maxHeight: {
|
|
73
|
-
type: String,
|
|
74
|
-
default: '90vh'
|
|
75
|
-
},
|
|
1
|
+
<template>
|
|
2
|
+
<view class="up-select">
|
|
3
|
+
<view :class="['up-select__content', disabled ? 'up-select__content--disabled' : '']">
|
|
4
|
+
<view class="up-select__label" @click="openSelect">
|
|
5
|
+
<slot name="text" :currentLabel="currentLabel">
|
|
6
|
+
<text class="up-select__text" v-if="showOptionsLabel">
|
|
7
|
+
{{ currentLabel }}
|
|
8
|
+
</text>
|
|
9
|
+
<text class="up-select__text" v-else>
|
|
10
|
+
{{ label }}
|
|
11
|
+
</text>
|
|
12
|
+
</slot>
|
|
13
|
+
<slot name="icon">
|
|
14
|
+
<up-icon name="arrow-down" :size="iconSize" :color="iconColor"></up-icon>
|
|
15
|
+
</slot>
|
|
16
|
+
</view>
|
|
17
|
+
<up-overlay :show="isOpen" @click="overlayClick" v-if="overlay" :zIndex="zIndex" :duration="duration + 50"
|
|
18
|
+
:customStyle="overlayStyle" :opacity="overlayOpacity" @touchmove.stop.prevent="stopOverlayTouchMove"></up-overlay>
|
|
19
|
+
<view class="up-select__options__wrap"
|
|
20
|
+
:style="optionsWrapStyle">
|
|
21
|
+
<view class="up-select__options" v-if="isOpen">
|
|
22
|
+
<slot name="options">
|
|
23
|
+
<view class="up-select__options-item" :class="getOptionClass(item)"
|
|
24
|
+
:key="index" v-for="(item, index) in options" @click="selectItem(item)">
|
|
25
|
+
<slot name="optionItem" :item="item">
|
|
26
|
+
<text class="up-select__item-text" :style="{color: itemColor}">
|
|
27
|
+
{{ getOptionLabel(item) }}
|
|
28
|
+
</text>
|
|
29
|
+
</slot>
|
|
30
|
+
</view>
|
|
31
|
+
</slot>
|
|
32
|
+
</view>
|
|
33
|
+
</view>
|
|
34
|
+
</view>
|
|
35
|
+
</view>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script setup lang="uts">
|
|
39
|
+
import { computed, getCurrentInstance, nextTick, onMounted, ref } from 'vue'
|
|
40
|
+
import type { PropType } from 'vue';
|
|
41
|
+
import { getWindowInfo, upGetRect } from '../../libs/function/index.uts';
|
|
42
|
+
|
|
43
|
+
function createOptions(): UTSJSONObject[] {
|
|
44
|
+
return [] as UTSJSONObject[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function createEmptyObject(): UTSJSONObject {
|
|
48
|
+
return {} as UTSJSONObject;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function valueToString(value: any | null): string {
|
|
52
|
+
return value == null ? '' : value.toString();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function normalizeNumber(value: any | null, fallback: number = 0): number {
|
|
56
|
+
if (typeof value === 'number') {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
if (value == null) {
|
|
60
|
+
return fallback;
|
|
61
|
+
}
|
|
62
|
+
const parsed = parseFloat(value.toString());
|
|
63
|
+
return isNaN(parsed) ? fallback : parsed;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
defineOptions({
|
|
67
|
+
styleIsolation: 'app-and-page',
|
|
68
|
+
name: 'up-select'
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const props = defineProps({
|
|
72
|
+
maxHeight: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: '90vh'
|
|
75
|
+
},
|
|
76
76
|
overlay: {
|
|
77
77
|
type: Boolean,
|
|
78
78
|
default: true
|
|
@@ -82,242 +82,256 @@ const props = defineProps({
|
|
|
82
82
|
type: Number,
|
|
83
83
|
default: 0.15
|
|
84
84
|
},
|
|
85
|
-
overlayStyle: {
|
|
86
|
-
type: Object as PropType<UTSJSONObject>,
|
|
87
|
-
default(): UTSJSONObject {
|
|
88
|
-
return {} as UTSJSONObject;
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
duration: {
|
|
92
|
-
type: Number,
|
|
93
|
-
default: 300
|
|
94
|
-
},
|
|
95
|
-
label: {
|
|
96
|
-
type: String,
|
|
97
|
-
default: '选项'
|
|
98
|
-
},
|
|
99
|
-
options: {
|
|
100
|
-
type: Array as PropType<UTSJSONObject[]>,
|
|
101
|
-
default(): UTSJSONObject[] {
|
|
102
|
-
return [] as UTSJSONObject[];
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
keyName: {
|
|
106
|
-
type: String,
|
|
107
|
-
default: 'id'
|
|
108
|
-
},
|
|
109
|
-
labelName: {
|
|
110
|
-
type: String,
|
|
111
|
-
default: 'name'
|
|
112
|
-
},
|
|
113
|
-
showOptionsLabel: {
|
|
114
|
-
type: Boolean,
|
|
115
|
-
default: false
|
|
116
|
-
},
|
|
117
|
-
current: {
|
|
118
|
-
type: [String, Number],
|
|
119
|
-
default: ''
|
|
120
|
-
},
|
|
121
|
-
zIndex: {
|
|
122
|
-
type: Number,
|
|
123
|
-
default: 11000
|
|
124
|
-
},
|
|
125
|
-
itemColor: {
|
|
126
|
-
type: String,
|
|
127
|
-
default: '#333333'
|
|
128
|
-
},
|
|
129
|
-
iconColor: {
|
|
130
|
-
type: String,
|
|
131
|
-
default: ''
|
|
132
|
-
},
|
|
133
|
-
iconSize: {
|
|
134
|
-
type: String,
|
|
135
|
-
default: '13px'
|
|
136
|
-
},
|
|
137
|
-
disabled: {
|
|
138
|
-
type: Boolean,
|
|
139
|
-
default: false
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
const emit = defineEmits(['update:current', 'select'])
|
|
144
|
-
const instance = getCurrentInstance()!.proxy!
|
|
145
|
-
const isOpen = ref(false)
|
|
146
|
-
const optionsWrapLeft = ref('auto')
|
|
147
|
-
const optionsWrapRight = ref('auto')
|
|
148
|
-
const optionsWrapTop = ref('0px')
|
|
149
|
-
const optionsWrapMinWidth = ref('100px')
|
|
150
|
-
const optionsWrapMaxHeight = ref('90vh')
|
|
151
|
-
|
|
152
|
-
const currentLabel = computed((): string => {
|
|
153
|
-
const options = props.options as UTSJSONObject[];
|
|
154
|
-
for (let i = 0; i < options.length; i++) {
|
|
155
|
-
const item = options[i] as UTSJSONObject;
|
|
156
|
-
if (valueToString(item[props.keyName]) == valueToString(props.current)) {
|
|
157
|
-
return valueToString(item[props.labelName]);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return '';
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
const optionsWrapStyle = computed((): UTSJSONObject => {
|
|
164
|
-
return {
|
|
165
|
-
overflowY: 'auto',
|
|
166
|
-
position: 'fixed',
|
|
167
|
-
zIndex: props.zIndex + 1,
|
|
168
|
-
left: optionsWrapLeft.value,
|
|
169
|
-
right: optionsWrapRight.value,
|
|
170
|
-
top: optionsWrapTop.value,
|
|
171
|
-
minWidth: optionsWrapMinWidth.value,
|
|
172
|
-
maxHeight: optionsWrapMaxHeight.value
|
|
173
|
-
} as UTSJSONObject
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
const getOptionClass = (item: UTSJSONObject): string => {
|
|
177
|
-
return valueToString(item[props.keyName]) == valueToString(props.current) ? 'up-select__options-item--active' : ''
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const getOptionLabel = (item: UTSJSONObject): string => {
|
|
181
|
-
return valueToString(item[props.labelName])
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.up-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
85
|
+
overlayStyle: {
|
|
86
|
+
type: Object as PropType<UTSJSONObject>,
|
|
87
|
+
default(): UTSJSONObject {
|
|
88
|
+
return {} as UTSJSONObject;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
duration: {
|
|
92
|
+
type: Number,
|
|
93
|
+
default: 300
|
|
94
|
+
},
|
|
95
|
+
label: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: '选项'
|
|
98
|
+
},
|
|
99
|
+
options: {
|
|
100
|
+
type: Array as PropType<UTSJSONObject[]>,
|
|
101
|
+
default(): UTSJSONObject[] {
|
|
102
|
+
return [] as UTSJSONObject[];
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
keyName: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: 'id'
|
|
108
|
+
},
|
|
109
|
+
labelName: {
|
|
110
|
+
type: String,
|
|
111
|
+
default: 'name'
|
|
112
|
+
},
|
|
113
|
+
showOptionsLabel: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: false
|
|
116
|
+
},
|
|
117
|
+
current: {
|
|
118
|
+
type: [String, Number],
|
|
119
|
+
default: ''
|
|
120
|
+
},
|
|
121
|
+
zIndex: {
|
|
122
|
+
type: Number,
|
|
123
|
+
default: 11000
|
|
124
|
+
},
|
|
125
|
+
itemColor: {
|
|
126
|
+
type: String,
|
|
127
|
+
default: '#333333'
|
|
128
|
+
},
|
|
129
|
+
iconColor: {
|
|
130
|
+
type: String,
|
|
131
|
+
default: ''
|
|
132
|
+
},
|
|
133
|
+
iconSize: {
|
|
134
|
+
type: String,
|
|
135
|
+
default: '13px'
|
|
136
|
+
},
|
|
137
|
+
disabled: {
|
|
138
|
+
type: Boolean,
|
|
139
|
+
default: false
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const emit = defineEmits(['update:current', 'select'])
|
|
144
|
+
const instance = getCurrentInstance()!.proxy!
|
|
145
|
+
const isOpen = ref(false)
|
|
146
|
+
const optionsWrapLeft = ref('auto')
|
|
147
|
+
const optionsWrapRight = ref('auto')
|
|
148
|
+
const optionsWrapTop = ref('0px')
|
|
149
|
+
const optionsWrapMinWidth = ref('100px')
|
|
150
|
+
const optionsWrapMaxHeight = ref('90vh')
|
|
151
|
+
|
|
152
|
+
const currentLabel = computed((): string => {
|
|
153
|
+
const options = props.options as UTSJSONObject[];
|
|
154
|
+
for (let i = 0; i < options.length; i++) {
|
|
155
|
+
const item = options[i] as UTSJSONObject;
|
|
156
|
+
if (valueToString(item[props.keyName]) == valueToString(props.current)) {
|
|
157
|
+
return valueToString(item[props.labelName]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return '';
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
const optionsWrapStyle = computed((): UTSJSONObject => {
|
|
164
|
+
return {
|
|
165
|
+
overflowY: 'auto',
|
|
166
|
+
position: 'fixed',
|
|
167
|
+
zIndex: props.zIndex + 1,
|
|
168
|
+
left: optionsWrapLeft.value,
|
|
169
|
+
right: optionsWrapRight.value,
|
|
170
|
+
top: optionsWrapTop.value,
|
|
171
|
+
minWidth: optionsWrapMinWidth.value,
|
|
172
|
+
maxHeight: optionsWrapMaxHeight.value
|
|
173
|
+
} as UTSJSONObject
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
const getOptionClass = (item: UTSJSONObject): string => {
|
|
177
|
+
return valueToString(item[props.keyName]) == valueToString(props.current) ? 'up-select__options-item--active' : ''
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const getOptionLabel = (item: UTSJSONObject): string => {
|
|
181
|
+
return valueToString(item[props.labelName])
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// 应用面板的水平对齐:溢出判断用「触发区左缘 + 面板宽度」推算,
|
|
185
|
+
// 与查询瞬间面板所处的对齐状态无关,避免只按触发区宽度推算导致右侧被裁掉
|
|
186
|
+
const applyOptionsWrapAlign = (left: number, wrapWidth: number, windowWidth: number): void => {
|
|
187
|
+
if (left + wrapWidth > windowWidth) {
|
|
188
|
+
// 如果右侧被遮挡,则调整到左侧
|
|
189
|
+
optionsWrapLeft.value = 'auto';
|
|
190
|
+
optionsWrapRight.value = '0px';
|
|
191
|
+
} else {
|
|
192
|
+
optionsWrapLeft.value = left.toString() + 'px';
|
|
193
|
+
optionsWrapRight.value = 'auto';
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const adjustOptionsWrapPosition = (): void => {
|
|
198
|
+
const wi = getWindowInfo();
|
|
199
|
+
const windowWidth = wi.windowWidth;
|
|
200
|
+
const windowHeight = wi.windowHeight;
|
|
201
|
+
upGetRect('.up-select__label', false, instance).then((rect: NodeInfo) => {
|
|
202
|
+
const left = normalizeNumber(rect.left, 0);
|
|
203
|
+
const top = normalizeNumber(rect.top, 0);
|
|
204
|
+
const width = Math.max(100, normalizeNumber(rect.width, 100));
|
|
205
|
+
const height = normalizeNumber(rect.height, 0);
|
|
206
|
+
const dropdownTop = top + height;
|
|
207
|
+
const availableHeight = Math.max(80, windowHeight - dropdownTop - 8);
|
|
208
|
+
optionsWrapTop.value = dropdownTop.toString() + 'px';
|
|
209
|
+
optionsWrapMinWidth.value = width.toString() + 'px';
|
|
210
|
+
optionsWrapMaxHeight.value = availableHeight.toString() + 'px';
|
|
211
|
+
// 面板宽度由内容决定、可能比触发区更宽,这里再量一次面板自身宽度;
|
|
212
|
+
// 量不到(如刚打开尚未布局)时回退到触发区宽度
|
|
213
|
+
upGetRect('.up-select__options__wrap', false, instance).then((wrapRect: NodeInfo) => {
|
|
214
|
+
const wrapWidth = Math.max(width, normalizeNumber(wrapRect.width, width));
|
|
215
|
+
applyOptionsWrapAlign(left, wrapWidth, windowWidth);
|
|
216
|
+
}).catch((e: any) => {
|
|
217
|
+
applyOptionsWrapAlign(left, width, windowWidth);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const openSelect = (): void => {
|
|
223
|
+
if (props.disabled) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
isOpen.value = true;
|
|
227
|
+
nextTick(() => {
|
|
228
|
+
if (isOpen.value) {
|
|
229
|
+
adjustOptionsWrapPosition();
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const closeSelect = (): void => {
|
|
235
|
+
isOpen.value = false;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const overlayClick = (): void => {
|
|
239
|
+
isOpen.value = false;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const selectItem = (item: UTSJSONObject): void => {
|
|
243
|
+
isOpen.value = false;
|
|
244
|
+
emit('update:current', item[props.keyName]);
|
|
245
|
+
emit('select', item);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const stopOverlayTouchMove = (e: UniEvent): void => {
|
|
249
|
+
e.stopPropagation()
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
onMounted(() => {
|
|
253
|
+
if (props.maxHeight != null && props.maxHeight != '') {
|
|
254
|
+
optionsWrapMaxHeight.value = props.maxHeight
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
defineExpose({
|
|
259
|
+
isOpen,
|
|
260
|
+
optionsWrapLeft,
|
|
261
|
+
optionsWrapRight,
|
|
262
|
+
optionsWrapTop,
|
|
263
|
+
optionsWrapMinWidth,
|
|
264
|
+
optionsWrapMaxHeight,
|
|
265
|
+
currentLabel,
|
|
266
|
+
optionsWrapStyle,
|
|
267
|
+
getOptionClass,
|
|
268
|
+
getOptionLabel,
|
|
269
|
+
openSelect,
|
|
270
|
+
closeSelect,
|
|
271
|
+
overlayClick,
|
|
272
|
+
selectItem,
|
|
273
|
+
adjustOptionsWrapPosition,
|
|
274
|
+
stopOverlayTouchMove
|
|
275
|
+
})
|
|
276
|
+
</script>
|
|
277
|
+
|
|
278
|
+
<style lang="scss" scoped>
|
|
279
|
+
.up-select__content {
|
|
280
|
+
position: relative;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.up-select__content--disabled {
|
|
284
|
+
opacity: 0.6;
|
|
285
|
+
pointer-events: none;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.up-select__label {
|
|
289
|
+
display: flex;
|
|
290
|
+
flex-direction: row;
|
|
291
|
+
align-items: center;
|
|
292
|
+
justify-content: space-between;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* #ifdef H5 */
|
|
296
|
+
.up-select__label:hover {
|
|
297
|
+
cursor: pointer;
|
|
298
|
+
}
|
|
299
|
+
/* #endif */
|
|
300
|
+
|
|
301
|
+
.up-select__text {
|
|
302
|
+
margin-right: 2px;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.up-select__options__wrap {
|
|
306
|
+
position: fixed;
|
|
307
|
+
top: 0;
|
|
308
|
+
left: 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.up-select__options {
|
|
312
|
+
min-width: 100px;
|
|
313
|
+
box-sizing: border-box;
|
|
314
|
+
border-radius: 4px;
|
|
315
|
+
border: 1px solid #f1f1f1;
|
|
316
|
+
background-color: #fff;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.up-select__options-item {
|
|
320
|
+
padding: 10px 12px;
|
|
321
|
+
box-sizing: border-box;
|
|
322
|
+
width: 100%;
|
|
323
|
+
height: 100%;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/* #ifdef H5 */
|
|
327
|
+
.up-select__options-item:hover {
|
|
328
|
+
background-color: #f7f7f7;
|
|
329
|
+
cursor: pointer;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.up-select__item-text:hover {
|
|
333
|
+
cursor: pointer;
|
|
334
|
+
}
|
|
335
|
+
/* #endif */
|
|
336
|
+
</style>
|
|
337
|
+
|