uview-pro 0.2.3 → 0.3.0
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 +52 -0
- package/components/u-action-sheet/types.ts +2 -0
- package/components/u-action-sheet/u-action-sheet.vue +25 -7
- package/components/u-alert-tips/types.ts +2 -0
- package/components/u-alert-tips/u-alert-tips.vue +36 -10
- package/components/u-avatar/types.ts +2 -0
- package/components/u-avatar/u-avatar.vue +31 -7
- package/components/u-avatar-cropper/u-avatar-cropper.vue +13 -2
- package/components/u-avatar-cropper/weCropper.js +36 -8
- package/components/u-avatar-cropper/weCropper.ts +28 -7
- package/components/u-back-top/types.ts +2 -5
- package/components/u-back-top/u-back-top.vue +31 -16
- package/components/u-badge/types.ts +2 -0
- package/components/u-badge/u-badge.vue +33 -15
- package/components/u-button/types.ts +2 -2
- package/components/u-button/u-button.vue +34 -11
- package/components/u-calendar/types.ts +3 -1
- package/components/u-calendar/u-calendar.vue +172 -17
- package/components/u-car-keyboard/types.ts +2 -0
- package/components/u-car-keyboard/u-car-keyboard.vue +36 -8
- package/components/u-card/types.ts +2 -0
- package/components/u-card/u-card.vue +25 -10
- package/components/u-cell-group/types.ts +2 -0
- package/components/u-cell-group/u-cell-group.vue +15 -5
- package/components/u-cell-item/types.ts +2 -0
- package/components/u-cell-item/u-cell-item.vue +37 -13
- package/components/u-checkbox/types.ts +2 -0
- package/components/u-checkbox/u-checkbox.vue +9 -13
- package/components/u-checkbox-group/types.ts +2 -0
- package/components/u-checkbox-group/u-checkbox-group.vue +1 -1
- package/components/u-circle-progress/types.ts +2 -0
- package/components/u-circle-progress/u-circle-progress.vue +30 -11
- package/components/u-city-select/types.ts +2 -0
- package/components/u-city-select/u-city-select.vue +48 -8
- package/components/u-col/types.ts +2 -0
- package/components/u-col/u-col.vue +27 -8
- package/components/u-collapse/u-collapse.vue +8 -13
- package/components/u-collapse-item/u-collapse-item.vue +21 -42
- package/components/u-column-notice/types.ts +2 -0
- package/components/u-column-notice/u-column-notice.vue +54 -8
- package/components/u-count-down/types.ts +2 -0
- package/components/u-count-down/u-count-down.vue +39 -11
- package/components/u-count-to/types.ts +2 -0
- package/components/u-count-to/u-count-to.vue +34 -9
- package/components/u-divider/types.ts +2 -0
- package/components/u-divider/u-divider.vue +36 -12
- package/components/u-dropdown/types.ts +2 -0
- package/components/u-dropdown/u-dropdown.vue +64 -23
- package/components/u-dropdown-item/types.ts +2 -0
- package/components/u-dropdown-item/u-dropdown-item.vue +39 -42
- package/components/u-empty/types.ts +2 -0
- package/components/u-empty/u-empty.vue +20 -5
- package/components/u-field/types.ts +2 -0
- package/components/u-field/u-field.vue +41 -7
- package/components/u-form/types.ts +2 -0
- package/components/u-form/u-form.vue +25 -27
- package/components/u-form-item/types.ts +2 -0
- package/components/u-form-item/u-form-item.vue +104 -74
- package/components/u-full-screen/types.ts +2 -0
- package/components/u-full-screen/u-full-screen.vue +24 -3
- package/components/u-gap/types.ts +2 -0
- package/components/u-gap/u-gap.vue +15 -5
- package/components/u-grid/types.ts +2 -0
- package/components/u-grid/u-grid.vue +23 -25
- package/components/u-grid-item/types.ts +3 -3
- package/components/u-grid-item/u-grid-item.vue +43 -43
- package/components/u-icon/types.ts +0 -1
- package/components/u-icon/u-icon.vue +20 -5
- package/components/u-image/u-image.vue +23 -6
- package/components/u-index-anchor/types.ts +3 -3
- package/components/u-index-anchor/u-index-anchor.vue +18 -10
- package/components/u-index-list/u-index-list.vue +9 -12
- package/components/u-input/types.ts +2 -5
- package/components/u-input/u-input.vue +34 -10
- package/components/u-keyboard/u-keyboard.vue +26 -6
- package/components/u-lazy-load/u-lazy-load.vue +23 -10
- package/components/u-line/u-line.vue +13 -4
- package/components/u-line-progress/u-line-progress.vue +22 -5
- package/components/u-link/u-link.vue +13 -4
- package/components/u-loading/u-loading.vue +20 -5
- package/components/u-loading-popup/u-loading-popup.vue +14 -0
- package/components/u-loadmore/u-loadmore.vue +19 -3
- package/components/u-mask/types.ts +2 -5
- package/components/u-mask/u-mask.vue +21 -14
- package/components/u-message-input/u-message-input.vue +32 -6
- package/components/u-modal/u-modal.vue +21 -5
- package/components/u-navbar/u-navbar.vue +31 -6
- package/components/u-no-network/u-no-network.vue +16 -3
- package/components/u-notice-bar/u-notice-bar.vue +19 -4
- package/components/u-number-box/u-number-box.vue +13 -4
- package/components/u-number-keyboard/u-number-keyboard.vue +32 -10
- package/components/u-picker/u-picker.vue +62 -14
- package/components/u-popup/types.ts +2 -2
- package/components/u-popup/u-popup.vue +33 -7
- package/components/u-radio/types.ts +2 -0
- package/components/u-radio/u-radio.vue +45 -24
- package/components/u-radio-group/types.ts +2 -0
- package/components/u-radio-group/u-radio-group.vue +20 -22
- package/components/u-rate/types.ts +2 -0
- package/components/u-rate/u-rate.vue +20 -5
- package/components/u-read-more/types.ts +2 -0
- package/components/u-read-more/u-read-more.vue +30 -8
- package/components/u-root-portal/u-root-portal.vue +3 -1
- package/components/u-row/types.ts +2 -0
- package/components/u-row/u-row.vue +29 -11
- package/components/u-row-notice/types.ts +2 -0
- package/components/u-row-notice/u-row-notice.vue +51 -8
- package/components/u-safe-bottom/u-safe-bottom.vue +13 -2
- package/components/u-search/types.ts +2 -0
- package/components/u-search/u-search.vue +30 -7
- package/components/u-section/types.ts +2 -0
- package/components/u-section/u-section.vue +38 -13
- package/components/u-select/types.ts +2 -0
- package/components/u-select/u-select.vue +37 -10
- package/components/u-skeleton/types.ts +2 -0
- package/components/u-skeleton/u-skeleton.vue +32 -6
- package/components/u-slider/types.ts +2 -0
- package/components/u-slider/u-slider.vue +38 -21
- package/components/u-status-bar/u-status-bar.vue +13 -4
- package/components/u-steps/types.ts +2 -0
- package/components/u-steps/u-steps.vue +26 -5
- package/components/u-sticky/types.ts +2 -0
- package/components/u-sticky/u-sticky.vue +27 -8
- package/components/u-subsection/types.ts +2 -0
- package/components/u-subsection/u-subsection.vue +14 -3
- package/components/u-swipe-action/types.ts +2 -0
- package/components/u-swipe-action/u-swipe-action.vue +27 -4
- package/components/u-swiper/types.ts +2 -0
- package/components/u-swiper/u-swiper.vue +50 -8
- package/components/u-switch/types.ts +2 -0
- package/components/u-switch/u-switch.vue +19 -5
- package/components/u-tabbar/types.ts +2 -0
- package/components/u-tabbar/u-tabbar.vue +42 -7
- package/components/u-table/types.ts +2 -0
- package/components/u-table/u-table.vue +15 -3
- package/components/u-tabs/types.ts +2 -0
- package/components/u-tabs/u-tabs.vue +22 -4
- package/components/u-tabs-swiper/types.ts +2 -0
- package/components/u-tabs-swiper/u-tabs-swiper.vue +36 -6
- package/components/u-tag/types.ts +2 -0
- package/components/u-tag/u-tag.vue +31 -7
- package/components/u-td/types.ts +2 -0
- package/components/u-td/u-td.vue +14 -3
- package/components/u-text/types.ts +4 -1
- package/components/u-text/u-text.vue +22 -5
- package/components/u-th/types.ts +2 -0
- package/components/u-th/u-th.vue +14 -3
- package/components/u-time-line/u-time-line.vue +17 -3
- package/components/u-time-line-item/types.ts +2 -0
- package/components/u-time-line-item/u-time-line-item.vue +15 -3
- package/components/u-toast/types.ts +2 -0
- package/components/u-toast/u-toast.vue +15 -8
- package/components/u-top-tips/types.ts +2 -0
- package/components/u-top-tips/u-top-tips.vue +20 -3
- package/components/u-tr/types.ts +4 -1
- package/components/u-tr/u-tr.vue +17 -2
- package/components/u-upload/types.ts +10 -2
- package/components/u-upload/u-upload.vue +31 -8
- package/components/u-verification-code/types.ts +2 -0
- package/components/u-verification-code/u-verification-code.vue +15 -3
- package/components/u-waterfall/types.ts +2 -0
- package/components/u-waterfall/u-waterfall.vue +15 -3
- package/iconfont.css +2 -1
- package/libs/css/style.vue.scss +1 -1
- package/libs/function/$parent.ts +4 -1
- package/libs/function/colorGradient.ts +18 -4
- package/libs/function/deepMerge.ts +2 -1
- package/libs/function/getParent.ts +5 -1
- package/libs/function/md5.ts +17 -5
- package/libs/function/queryParams.ts +5 -1
- package/libs/function/test.ts +7 -3
- package/libs/function/timeFormat.ts +2 -1
- package/libs/function/type2icon.ts +4 -1
- package/libs/hooks/index.ts +2 -1
- package/libs/hooks/useCompRelation.ts +364 -0
- package/libs/hooks/useComponent.ts +485 -69
- package/libs/hooks/useEmitter.ts +4 -2
- package/libs/index.ts +56 -39
- package/libs/request/index.ts +24 -5
- package/libs/util/async-validator.d.ts +16 -3
- package/libs/util/emitter.ts +12 -2
- package/libs/util/mitt.ts +4 -1
- package/package.json +1 -1
- package/readme.md +6 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ExtractPropTypes, type PropType } from 'vue';
|
|
2
2
|
import type { Shape } from '../../types/global';
|
|
3
|
+
import { baseProps } from '../common/props';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* checkbox 复选框类型定义
|
|
@@ -8,6 +9,7 @@ import type { Shape } from '../../types/global';
|
|
|
8
9
|
export type CheckboxValue = string | number | boolean;
|
|
9
10
|
|
|
10
11
|
export const CheckboxProps = {
|
|
12
|
+
...baseProps,
|
|
11
13
|
/** checkbox的名称 */
|
|
12
14
|
name: { type: [String, Number], default: '' },
|
|
13
15
|
/** 形状,square为方形,circle为原型 */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="u-checkbox" :style="
|
|
2
|
+
<view class="u-checkbox" :style="$u.toStyle(checkboxStyle, customStyle)" :class="customClass">
|
|
3
3
|
<view class="u-checkbox__icon-wrap" @tap="toggle" :class="iconClass" :style="$u.toStyle(iconStyle)">
|
|
4
4
|
<u-icon
|
|
5
5
|
class="u-checkbox__icon-wrap__icon"
|
|
@@ -34,8 +34,8 @@ export default {
|
|
|
34
34
|
</script>
|
|
35
35
|
|
|
36
36
|
<script setup lang="ts">
|
|
37
|
-
import { computed
|
|
38
|
-
import { $u, useChildren
|
|
37
|
+
import { computed } from 'vue';
|
|
38
|
+
import { $u, useChildren } from '../..';
|
|
39
39
|
import { CheckboxProps } from './types';
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -57,7 +57,7 @@ const props = defineProps(CheckboxProps);
|
|
|
57
57
|
const emit = defineEmits(['change', 'update:modelValue']);
|
|
58
58
|
|
|
59
59
|
// 使用子组件Hook
|
|
60
|
-
const {
|
|
60
|
+
const { parentExposed } = useChildren('u-checkbox', 'u-checkbox-group');
|
|
61
61
|
|
|
62
62
|
// 是否禁用,如果父组件u-checkbox-group禁用的话,将会忽略子组件的配置
|
|
63
63
|
const isDisabled = computed(() => {
|
|
@@ -188,27 +188,23 @@ function setValue() {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
//
|
|
192
|
-
|
|
191
|
+
// 设置组件的modelValue值
|
|
192
|
+
function setChecked(data: any) {
|
|
193
193
|
if (!isDisabled.value) {
|
|
194
194
|
emit('update:modelValue', data.checked);
|
|
195
195
|
if (data.checked !== props.modelValue) {
|
|
196
196
|
emitEvent();
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// 在适当的时候取消监听
|
|
202
|
-
onUnmounted(() => {
|
|
203
|
-
unsubscribeSetChecked();
|
|
204
|
-
});
|
|
199
|
+
}
|
|
205
200
|
|
|
206
201
|
defineExpose({
|
|
207
202
|
isChecked: computed(() => props.modelValue),
|
|
208
203
|
name: props.name,
|
|
209
204
|
setValue,
|
|
210
205
|
emitEvent,
|
|
211
|
-
props
|
|
206
|
+
props,
|
|
207
|
+
setChecked
|
|
212
208
|
});
|
|
213
209
|
</script>
|
|
214
210
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ExtractPropTypes, type PropType } from 'vue';
|
|
2
2
|
import type { Shape } from '../../types/global';
|
|
3
|
+
import { baseProps } from '../common/props';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* checkbox-group 复选框组类型定义
|
|
@@ -7,6 +8,7 @@ import type { Shape } from '../../types/global';
|
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
export const CheckboxGroupProps = {
|
|
11
|
+
...baseProps,
|
|
10
12
|
/** 最多能选中多少个checkbox */
|
|
11
13
|
max: { type: Number, default: 999 },
|
|
12
14
|
/** 是否禁用所有复选框 */
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type ExtractPropTypes, type PropType } from 'vue';
|
|
2
2
|
import type { ThemeType } from '../../types/global';
|
|
3
|
+
import { baseProps } from '../common/props';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* circleProgress 环形进度条 Props
|
|
6
7
|
* @description 展示操作或任务的当前进度,比如上传文件,是一个圆形的进度条。注意:此组件的percent值只能动态增加,不能动态减少。
|
|
7
8
|
*/
|
|
8
9
|
export const CircleProgressProps = {
|
|
10
|
+
...baseProps,
|
|
9
11
|
/** 圆环进度百分比值 */
|
|
10
12
|
percent: {
|
|
11
13
|
type: Number,
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view
|
|
3
3
|
class="u-circle-progress"
|
|
4
|
-
:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
:class="customClass"
|
|
5
|
+
:style="
|
|
6
|
+
$u.toStyle(
|
|
7
|
+
{
|
|
8
|
+
width: widthPx + 'px',
|
|
9
|
+
height: widthPx + 'px',
|
|
10
|
+
backgroundColor: bgColor
|
|
11
|
+
},
|
|
12
|
+
customStyle
|
|
13
|
+
)
|
|
14
|
+
"
|
|
9
15
|
>
|
|
10
16
|
<!-- 支付宝小程序不支持canvas-id属性,必须用id属性 -->
|
|
11
17
|
<canvas
|
|
@@ -30,15 +36,24 @@
|
|
|
30
36
|
</view>
|
|
31
37
|
</template>
|
|
32
38
|
|
|
39
|
+
<script lang="ts">
|
|
40
|
+
export default {
|
|
41
|
+
name: 'u-circle-progress',
|
|
42
|
+
options: {
|
|
43
|
+
addGlobalClass: true,
|
|
44
|
+
// #ifndef MP-TOUTIAO
|
|
45
|
+
virtualHost: true,
|
|
46
|
+
// #endif
|
|
47
|
+
styleIsolation: 'shared'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
</script>
|
|
51
|
+
|
|
33
52
|
<script setup lang="ts">
|
|
34
53
|
import { ref, computed, watch, onMounted, getCurrentInstance } from 'vue';
|
|
35
54
|
import { $u } from '../..';
|
|
36
55
|
import { CircleProgressProps } from './types';
|
|
37
56
|
|
|
38
|
-
defineOptions({
|
|
39
|
-
name: 'u-circle-progress'
|
|
40
|
-
});
|
|
41
|
-
|
|
42
57
|
/**
|
|
43
58
|
* circleProgress 环形进度条
|
|
44
59
|
* @description 展示操作或任务的当前进度,比如上传文件,是一个圆形的进度条。注意:此组件的percent值只能动态增加,不能动态减少。
|
|
@@ -63,8 +78,12 @@ elId = 'uCircleProgressElId';
|
|
|
63
78
|
// #endif
|
|
64
79
|
const instance = getCurrentInstance();
|
|
65
80
|
|
|
66
|
-
const widthPx = computed(() =>
|
|
67
|
-
|
|
81
|
+
const widthPx = computed(() =>
|
|
82
|
+
typeof uni !== 'undefined' && uni.upx2px ? uni.upx2px(Number(props.width)) : Number(props.width)
|
|
83
|
+
);
|
|
84
|
+
const borderWidthPx = computed(() =>
|
|
85
|
+
typeof uni !== 'undefined' && uni.upx2px ? uni.upx2px(Number(props.borderWidth)) : Number(props.borderWidth)
|
|
86
|
+
);
|
|
68
87
|
const startAngle = -Math.PI / 2; // canvas画圆的起始角度,默认为3点钟方向,定位到12点钟方向
|
|
69
88
|
const progressContext = ref<any>(null); // 活动圆的canvas上下文
|
|
70
89
|
const newPercent = ref(props.percent); // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import { baseProps } from '../common/props';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* u-city-select 城市选择器 Props
|
|
5
6
|
* @description 用于选择省、市、区三级行政区域,支持回显和自定义初始值。
|
|
6
7
|
*/
|
|
7
8
|
export const CitySelectProps = {
|
|
9
|
+
...baseProps,
|
|
8
10
|
/** 控制弹窗显示与隐藏(v-model) */
|
|
9
11
|
modelValue: { type: Boolean, default: false },
|
|
10
12
|
/** 默认选中的省市区名称数组 */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<u-popup
|
|
3
3
|
v-model="popupValue"
|
|
4
|
+
:class="customClass"
|
|
5
|
+
:style="$u.toStyle(customStyle)"
|
|
4
6
|
mode="bottom"
|
|
5
7
|
:popup="false"
|
|
6
8
|
:mask="true"
|
|
@@ -11,7 +13,14 @@
|
|
|
11
13
|
:maskCloseAble="props.maskCloseAble"
|
|
12
14
|
@close="close"
|
|
13
15
|
>
|
|
14
|
-
<u-tabs
|
|
16
|
+
<u-tabs
|
|
17
|
+
v-if="popupValue"
|
|
18
|
+
:list="genTabsList"
|
|
19
|
+
:is-scroll="true"
|
|
20
|
+
:current="tabsIndex"
|
|
21
|
+
@change="tabsChange"
|
|
22
|
+
ref="tabs"
|
|
23
|
+
></u-tabs>
|
|
15
24
|
<view class="area-box">
|
|
16
25
|
<view class="u-flex" :class="{ change: isChange }">
|
|
17
26
|
<!-- 省 -->
|
|
@@ -19,7 +28,14 @@
|
|
|
19
28
|
<view class="u-padding-10 u-bg-gray" style="height: 100%">
|
|
20
29
|
<scroll-view :scroll-y="true" style="height: 100%">
|
|
21
30
|
<u-cell-group>
|
|
22
|
-
<u-cell-item
|
|
31
|
+
<u-cell-item
|
|
32
|
+
v-for="(item, index) in provincesList"
|
|
33
|
+
:title="item.label"
|
|
34
|
+
:arrow="false"
|
|
35
|
+
:index="index"
|
|
36
|
+
:key="index"
|
|
37
|
+
@click="provinceChange(index)"
|
|
38
|
+
>
|
|
23
39
|
<template v-if="isChooseP && province === index" #right-icon>
|
|
24
40
|
<u-icon size="34" name="checkbox-mark"></u-icon>
|
|
25
41
|
</template>
|
|
@@ -33,7 +49,14 @@
|
|
|
33
49
|
<view class="u-padding-10 u-bg-gray" style="height: 100%">
|
|
34
50
|
<scroll-view :scroll-y="true" style="height: 100%">
|
|
35
51
|
<u-cell-group v-if="isChooseP">
|
|
36
|
-
<u-cell-item
|
|
52
|
+
<u-cell-item
|
|
53
|
+
v-for="(item, index) in citys"
|
|
54
|
+
:title="item.label"
|
|
55
|
+
:arrow="false"
|
|
56
|
+
:index="index"
|
|
57
|
+
:key="index"
|
|
58
|
+
@click="cityChange(index)"
|
|
59
|
+
>
|
|
37
60
|
<template v-if="isChooseC && city === index" #right-icon>
|
|
38
61
|
<u-icon size="34" name="checkbox-mark"></u-icon>
|
|
39
62
|
</template>
|
|
@@ -47,7 +70,14 @@
|
|
|
47
70
|
<view class="u-padding-10 u-bg-gray" style="height: 100%">
|
|
48
71
|
<scroll-view :scroll-y="true" style="height: 100%">
|
|
49
72
|
<u-cell-group v-if="isChooseC">
|
|
50
|
-
<u-cell-item
|
|
73
|
+
<u-cell-item
|
|
74
|
+
v-for="(item, index) in areas"
|
|
75
|
+
:title="item.label"
|
|
76
|
+
:arrow="false"
|
|
77
|
+
:index="index"
|
|
78
|
+
:key="index"
|
|
79
|
+
@click="areaChange(index)"
|
|
80
|
+
>
|
|
51
81
|
<template v-if="isChooseA && area === index" #right-icon>
|
|
52
82
|
<u-icon size="34" name="checkbox-mark"></u-icon>
|
|
53
83
|
</template>
|
|
@@ -61,16 +91,26 @@
|
|
|
61
91
|
</u-popup>
|
|
62
92
|
</template>
|
|
63
93
|
|
|
94
|
+
<script lang="ts">
|
|
95
|
+
export default {
|
|
96
|
+
name: 'u-city-select',
|
|
97
|
+
options: {
|
|
98
|
+
addGlobalClass: true,
|
|
99
|
+
// #ifndef MP-TOUTIAO
|
|
100
|
+
virtualHost: true,
|
|
101
|
+
// #endif
|
|
102
|
+
styleIsolation: 'shared'
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
</script>
|
|
106
|
+
|
|
64
107
|
<script setup lang="ts">
|
|
65
108
|
import { ref, computed, onMounted } from 'vue';
|
|
66
109
|
import provinces from '../../libs/util/province';
|
|
67
110
|
import citysData from '../../libs/util/city';
|
|
68
111
|
import areasData from '../../libs/util/area';
|
|
69
112
|
import { CitySelectProps } from './types';
|
|
70
|
-
|
|
71
|
-
defineOptions({
|
|
72
|
-
name: 'u-city-select'
|
|
73
|
-
});
|
|
113
|
+
import { $u } from '../..';
|
|
74
114
|
|
|
75
115
|
/**
|
|
76
116
|
* u-city-select 城市选择器
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { AlignType, JustifyType } from '../../types/global';
|
|
3
|
+
import { baseProps } from '../common/props';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* u-col 布局单元格 Props
|
|
@@ -13,6 +14,7 @@ import type { AlignType, JustifyType } from '../../types/global';
|
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
export const ColProps = {
|
|
17
|
+
...baseProps,
|
|
16
18
|
/** 占父容器宽度的多少等分,总分为12份 */
|
|
17
19
|
span: { type: [Number, String] as PropType<number | string>, default: 12 },
|
|
18
20
|
/** 指定栅格左侧的间隔数(总12栏) */
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
2
|
+
<view
|
|
3
|
+
class="u-col"
|
|
4
|
+
:class="['u-col-' + span, customClass]"
|
|
5
|
+
:style="$u.toStyle(colStyle, customStyle)"
|
|
6
|
+
@tap="onClick"
|
|
7
|
+
>
|
|
3
8
|
<slot></slot>
|
|
4
9
|
</view>
|
|
5
10
|
</template>
|
|
6
11
|
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
export default {
|
|
14
|
+
name: 'u-col',
|
|
15
|
+
options: {
|
|
16
|
+
addGlobalClass: true,
|
|
17
|
+
// #ifndef MP-TOUTIAO
|
|
18
|
+
virtualHost: true,
|
|
19
|
+
// #endif
|
|
20
|
+
styleIsolation: 'shared'
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
</script>
|
|
24
|
+
|
|
7
25
|
<script setup lang="ts">
|
|
8
|
-
import { computed
|
|
26
|
+
import { computed } from 'vue';
|
|
9
27
|
import { ColProps } from './types';
|
|
10
|
-
|
|
11
|
-
defineOptions({
|
|
12
|
-
name: 'u-col'
|
|
13
|
-
});
|
|
28
|
+
import { $u, useChildren } from '../../';
|
|
14
29
|
|
|
15
30
|
/**
|
|
16
31
|
* col 布局单元格
|
|
@@ -26,10 +41,14 @@ const emit = defineEmits<{ (e: 'click'): void }>();
|
|
|
26
41
|
|
|
27
42
|
const props = defineProps(ColProps);
|
|
28
43
|
|
|
44
|
+
const { parentExposed } = useChildren('u-col', 'u-row');
|
|
45
|
+
|
|
29
46
|
/**
|
|
30
47
|
* gutter 给col添加间距,左右边距各占一半,从父组件u-row获取
|
|
31
48
|
*/
|
|
32
|
-
const gutter =
|
|
49
|
+
const gutter = computed(() => {
|
|
50
|
+
return parentExposed?.value?.props?.gutter ?? 20;
|
|
51
|
+
});
|
|
33
52
|
|
|
34
53
|
/**
|
|
35
54
|
* 计算水平排列方式
|
|
@@ -55,7 +74,7 @@ const uAlignItem = computed(() => {
|
|
|
55
74
|
* 计算样式对象
|
|
56
75
|
*/
|
|
57
76
|
const colStyle = computed<any>(() => ({
|
|
58
|
-
padding: `0 ${Number(gutter) / 2}
|
|
77
|
+
padding: `0 ${Number(gutter.value) / 2}px`,
|
|
59
78
|
marginLeft: `${(100 / 12) * Number(props.offset)}%`,
|
|
60
79
|
flex: `0 0 ${(100 / 12) * Number(props.span)}%`,
|
|
61
80
|
alignItems: uAlignItem.value,
|
|
@@ -92,13 +92,17 @@ function onChange(name: string | number) {
|
|
|
92
92
|
// 收集当前所有展开的项
|
|
93
93
|
let currentActiveNames: (string | number)[] = [];
|
|
94
94
|
if (props.accordion) {
|
|
95
|
-
currentActiveNames = activeName.value ? [activeName.value] : [];
|
|
95
|
+
currentActiveNames = activeName.value === 0 || activeName.value ? [activeName.value] : [];
|
|
96
96
|
} else {
|
|
97
|
-
//
|
|
97
|
+
// 对于非手风琴模式,我们不知道所有项的状态
|
|
98
98
|
currentActiveNames = [];
|
|
99
|
+
children.forEach(child => {
|
|
100
|
+
if (child.getExposed().isShow.value) {
|
|
101
|
+
currentActiveNames.push(child.getExposed().itemName);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
99
104
|
}
|
|
100
|
-
|
|
101
|
-
emit('change', props.accordion ? activeName.value || '' : currentActiveNames);
|
|
105
|
+
currentActiveNames.length > 0 && emit('change', props.accordion ? activeName.value || '' : currentActiveNames);
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
/**
|
|
@@ -161,15 +165,6 @@ function init() {
|
|
|
161
165
|
}, 150);
|
|
162
166
|
}
|
|
163
167
|
|
|
164
|
-
// 热更新处理 - 重新连接所有子组件
|
|
165
|
-
if (import.meta.hot) {
|
|
166
|
-
import.meta.hot.accept(() => {
|
|
167
|
-
setTimeout(() => {
|
|
168
|
-
broadcast('reconnect', {});
|
|
169
|
-
}, 100);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
168
|
// 使用defineExpose暴露给外部
|
|
174
169
|
defineExpose({
|
|
175
170
|
// props
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="u-collapse-item" :style="
|
|
2
|
+
<view class="u-collapse-item" :style="$u.toStyle(itemStyle, customStyle)" :class="customClass">
|
|
3
3
|
<view
|
|
4
4
|
:hover-stay-time="200"
|
|
5
5
|
class="u-collapse-head"
|
|
@@ -41,8 +41,8 @@ export default {
|
|
|
41
41
|
</script>
|
|
42
42
|
|
|
43
43
|
<script setup lang="ts">
|
|
44
|
-
import { ref, watch, onMounted, useSlots, getCurrentInstance, nextTick, computed
|
|
45
|
-
import { $u, useChildren
|
|
44
|
+
import { ref, watch, onMounted, useSlots, getCurrentInstance, nextTick, computed } from 'vue';
|
|
45
|
+
import { $u, useChildren } from '../..';
|
|
46
46
|
import { CollapseItemProps } from './types';
|
|
47
47
|
|
|
48
48
|
/**
|
|
@@ -148,11 +148,8 @@ function init() {
|
|
|
148
148
|
*/
|
|
149
149
|
function headClick() {
|
|
150
150
|
if (props.disabled) return;
|
|
151
|
-
|
|
152
151
|
// 通知父组件状态变化
|
|
153
|
-
|
|
154
|
-
parentExposed.value.onChange(itemName.value);
|
|
155
|
-
}
|
|
152
|
+
parentExposed?.value?.onChange(itemName.value);
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
/**
|
|
@@ -176,38 +173,35 @@ function queryRect() {
|
|
|
176
173
|
});
|
|
177
174
|
}
|
|
178
175
|
|
|
179
|
-
//
|
|
180
|
-
|
|
176
|
+
// 单选
|
|
177
|
+
function openSingle(data: any) {
|
|
181
178
|
// 只有目标项展开,其他都关闭
|
|
182
179
|
const shouldShow = data.targetName === itemName.value;
|
|
183
180
|
setShowState(shouldShow);
|
|
184
|
-
}
|
|
181
|
+
}
|
|
185
182
|
|
|
186
|
-
|
|
183
|
+
// 关闭所有
|
|
184
|
+
function closeAll() {
|
|
187
185
|
setShowState(false);
|
|
188
|
-
}
|
|
186
|
+
}
|
|
189
187
|
|
|
190
|
-
|
|
188
|
+
// 多选
|
|
189
|
+
function setMultiple(data: any) {
|
|
191
190
|
const shouldShow = data.targetNames.includes(itemName.value);
|
|
192
191
|
setShowState(shouldShow);
|
|
193
|
-
}
|
|
192
|
+
}
|
|
194
193
|
|
|
195
|
-
|
|
194
|
+
// 切换单个
|
|
195
|
+
function toggleSingle(data: any) {
|
|
196
196
|
// 只有目标项才切换状态
|
|
197
197
|
if (data.targetName === itemName.value) {
|
|
198
198
|
setShowState(!isShow.value);
|
|
199
199
|
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// 监听父组件的重连事件(热更新后)
|
|
203
|
-
const unsubscribeReconnect = onParentEvent(childId, 'reconnect', () => {
|
|
204
|
-
console.log('Collapse item reconnected to parent after hot update');
|
|
205
|
-
});
|
|
200
|
+
}
|
|
206
201
|
|
|
207
202
|
onMounted(() => {
|
|
208
203
|
// 关键修复:根据 open 属性设置初始状态
|
|
209
204
|
setShowState(props.open);
|
|
210
|
-
|
|
211
205
|
// 初始化
|
|
212
206
|
init();
|
|
213
207
|
});
|
|
@@ -231,25 +225,6 @@ watch(
|
|
|
231
225
|
{ deep: true, immediate: true }
|
|
232
226
|
);
|
|
233
227
|
|
|
234
|
-
// 组件卸载时清理事件监听
|
|
235
|
-
onUnmounted(() => {
|
|
236
|
-
unsubscribeOpenSingle();
|
|
237
|
-
unsubscribeCloseAll();
|
|
238
|
-
unsubscribeSetMultiple();
|
|
239
|
-
unsubscribeToggleSingle();
|
|
240
|
-
unsubscribeReconnect();
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
// 热更新处理
|
|
244
|
-
if (import.meta.hot) {
|
|
245
|
-
import.meta.hot.accept(() => {
|
|
246
|
-
setTimeout(() => {
|
|
247
|
-
console.log('Collapse item hot updated, reinitializing...');
|
|
248
|
-
init();
|
|
249
|
-
}, 150);
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
|
|
253
228
|
defineExpose({
|
|
254
229
|
init,
|
|
255
230
|
isShow,
|
|
@@ -262,7 +237,11 @@ defineExpose({
|
|
|
262
237
|
hoverClass,
|
|
263
238
|
itemName: itemName.value,
|
|
264
239
|
queryRect,
|
|
265
|
-
setShowState
|
|
240
|
+
setShowState,
|
|
241
|
+
openSingle,
|
|
242
|
+
closeAll,
|
|
243
|
+
setMultiple,
|
|
244
|
+
toggleSingle
|
|
266
245
|
});
|
|
267
246
|
</script>
|
|
268
247
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { Direction, PlayState, ScrollDirection, ThemeType } from '../../types/global';
|
|
3
|
+
import { baseProps } from '../common/props';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* u-column-notice 通告栏 Props
|
|
6
7
|
*/
|
|
7
8
|
export const ColumnNoticeProps = {
|
|
9
|
+
...baseProps,
|
|
8
10
|
/** 显示的内容,数组 */
|
|
9
11
|
list: { type: Array as PropType<string[]>, default: () => [] },
|
|
10
12
|
/** 显示的主题,success|error|primary|info|warning */
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
2
|
+
<view
|
|
3
|
+
class="u-notice-bar"
|
|
4
|
+
:style="$u.toStyle({ background: computeBgColor, padding: props.padding }, customStyle)"
|
|
5
|
+
:class="[props.type ? `u-type-${props.type}-light-bg` : '', customClass]"
|
|
6
|
+
>
|
|
3
7
|
<view class="u-icon-wrap">
|
|
4
|
-
<u-icon
|
|
8
|
+
<u-icon
|
|
9
|
+
class="u-left-icon"
|
|
10
|
+
v-if="props.volumeIcon"
|
|
11
|
+
name="volume-fill"
|
|
12
|
+
:size="props.volumeSize"
|
|
13
|
+
:color="computeColor"
|
|
14
|
+
></u-icon>
|
|
5
15
|
</view>
|
|
6
16
|
<swiper
|
|
7
17
|
:disable-touch="props.disableTouch"
|
|
@@ -13,23 +23,54 @@
|
|
|
13
23
|
class="u-swiper"
|
|
14
24
|
>
|
|
15
25
|
<swiper-item v-for="(item, index) in props.list" :key="index" class="u-swiper-item">
|
|
16
|
-
<view
|
|
26
|
+
<view
|
|
27
|
+
class="u-news-item u-line-1"
|
|
28
|
+
:style="textStyle"
|
|
29
|
+
@tap="click(index)"
|
|
30
|
+
:class="['u-type-' + props.type]"
|
|
31
|
+
>
|
|
17
32
|
{{ item }}
|
|
18
33
|
</view>
|
|
19
34
|
</swiper-item>
|
|
20
35
|
</swiper>
|
|
21
36
|
<view class="u-icon-wrap">
|
|
22
|
-
<u-icon
|
|
23
|
-
|
|
37
|
+
<u-icon
|
|
38
|
+
@click="getMore"
|
|
39
|
+
class="u-right-icon"
|
|
40
|
+
v-if="props.moreIcon"
|
|
41
|
+
name="arrow-right"
|
|
42
|
+
:size="26"
|
|
43
|
+
:color="computeColor"
|
|
44
|
+
></u-icon>
|
|
45
|
+
<u-icon
|
|
46
|
+
@click="close"
|
|
47
|
+
class="u-right-icon"
|
|
48
|
+
v-if="props.closeIcon"
|
|
49
|
+
name="close"
|
|
50
|
+
:size="24"
|
|
51
|
+
:color="computeColor"
|
|
52
|
+
></u-icon>
|
|
24
53
|
</view>
|
|
25
54
|
</view>
|
|
26
55
|
</template>
|
|
27
56
|
|
|
57
|
+
<script lang="ts">
|
|
58
|
+
export default {
|
|
59
|
+
name: 'u-column-notice',
|
|
60
|
+
options: {
|
|
61
|
+
addGlobalClass: true,
|
|
62
|
+
// #ifndef MP-TOUTIAO
|
|
63
|
+
virtualHost: true,
|
|
64
|
+
// #endif
|
|
65
|
+
styleIsolation: 'shared'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
</script>
|
|
69
|
+
|
|
28
70
|
<script setup lang="ts">
|
|
29
71
|
import { computed } from 'vue';
|
|
30
72
|
import { ColumnNoticeProps } from './types';
|
|
31
|
-
|
|
32
|
-
defineOptions({ name: 'u-column-notice' });
|
|
73
|
+
import { $u } from '../../';
|
|
33
74
|
|
|
34
75
|
/**
|
|
35
76
|
* u-column-notice 通告栏
|
|
@@ -56,7 +97,12 @@ defineOptions({ name: 'u-column-notice' });
|
|
|
56
97
|
|
|
57
98
|
const props = defineProps(ColumnNoticeProps);
|
|
58
99
|
|
|
59
|
-
const emit = defineEmits<{
|
|
100
|
+
const emit = defineEmits<{
|
|
101
|
+
(e: 'click', index: number): void;
|
|
102
|
+
(e: 'close'): void;
|
|
103
|
+
(e: 'getMore'): void;
|
|
104
|
+
(e: 'end'): void;
|
|
105
|
+
}>();
|
|
60
106
|
|
|
61
107
|
/**
|
|
62
108
|
* 计算字体颜色,如果没有自定义的,就用uview主题颜色
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import { baseProps } from '../common/props';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* u-count-down 倒计时 Props
|
|
5
6
|
* @description 该组件一般使用于某个活动的截止时间上,通过数字的变化,给用户明确的时间感受,提示用户进行某一个行为操作。
|
|
6
7
|
*/
|
|
7
8
|
export const CountDownProps = {
|
|
9
|
+
...baseProps,
|
|
8
10
|
/** 倒计时的时间,秒为单位 */
|
|
9
11
|
timestamp: { type: [Number, String] as PropType<number | string>, default: 0 },
|
|
10
12
|
/** 是否自动开始倒计时 */
|