hy-app 0.3.0 → 0.3.2
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/README.md +6 -3
- package/common/shakeService.ts +31 -29
- package/components/avatar.zip +0 -0
- package/components/hy-action-sheet/hy-action-sheet.vue +71 -46
- package/components/hy-address-picker/hy-address-picker.vue +94 -83
- package/components/hy-avatar/hy-avatar.vue +84 -85
- package/components/hy-back-top/hy-back-top.vue +8 -6
- package/components/hy-badge/hy-badge.vue +47 -46
- package/components/hy-button/hy-button.vue +117 -93
- package/components/hy-calendar/hy-calendar.vue +168 -160
- package/components/hy-card/hy-card.vue +50 -43
- package/components/hy-card/typing.d.ts +33 -32
- package/components/hy-cell/hy-cell.vue +73 -51
- package/components/hy-check-button/hy-check-button.vue +54 -47
- package/components/hy-checkbox/hy-checkbox.vue +97 -105
- package/components/hy-code-input/hy-code-input.vue +80 -89
- package/components/hy-config-provider/hy-config-provider.vue +20 -21
- package/components/hy-count-down/hy-count-down.vue +66 -67
- package/components/hy-count-to/hy-count-to.vue +105 -99
- package/components/hy-count-to/typing.d.ts +13 -12
- package/components/hy-datetime-picker/hy-datetime-picker.vue +261 -253
- package/components/hy-datetime-picker/typing.d.ts +42 -40
- package/components/hy-divider/hy-divider.vue +68 -73
- package/components/hy-dropdown/hy-dropdown.vue +20 -19
- package/components/hy-dropdown-item/hy-dropdown-item.vue +66 -61
- package/components/hy-dropdown-item/typing.d.ts +9 -9
- package/components/hy-empty/hy-empty.vue +42 -42
- package/components/hy-flex/hy-flex.vue +99 -0
- package/components/hy-flex/index.scss +8 -0
- package/components/hy-flex/typing.d.ts +23 -0
- package/components/hy-float-button/hy-float-button.vue +218 -210
- package/components/hy-folding-panel/hy-folding-panel.vue +32 -33
- package/components/hy-form/hy-form.vue +264 -252
- package/components/hy-form/typing.d.ts +4 -0
- package/components/hy-form-group/hy-form-group.vue +114 -183
- package/components/hy-form-item/hy-form-item.vue +12 -10
- package/components/hy-form-item/index.scss +2 -2
- package/components/hy-form-item/typing.d.ts +3 -6
- package/components/hy-grid/hy-grid.vue +44 -43
- package/components/hy-icon/hy-icon.vue +61 -67
- package/components/hy-image/hy-image.vue +112 -88
- package/components/hy-image/typing.d.ts +27 -23
- package/components/hy-input/hy-input.vue +157 -127
- package/components/hy-input/typing.d.ts +53 -47
- package/components/hy-line/hy-line.vue +26 -26
- package/components/hy-line-progress/hy-line-progress.vue +42 -35
- package/components/hy-list/hy-list.vue +76 -85
- package/components/hy-loading/hy-loading.vue +26 -23
- package/components/hy-login/TheUserLogin.vue +1 -1
- package/components/hy-menu/hy-menu.vue +48 -43
- package/components/hy-menu/typing.d.ts +18 -17
- package/components/hy-modal/hy-modal.vue +39 -35
- package/components/hy-navbar/hy-navbar.vue +25 -25
- package/components/hy-navbar/typing.d.ts +24 -22
- package/components/hy-notice-bar/hy-notice-bar.vue +26 -27
- package/components/hy-notify/hy-notify.vue +53 -53
- package/components/hy-number-step/hy-number-step.vue +134 -146
- package/components/hy-number-step/typing.d.ts +35 -35
- package/components/hy-overlay/hy-overlay.vue +23 -21
- package/components/hy-pagination/hy-pagination.vue +41 -36
- package/components/hy-picker/hy-picker.vue +184 -154
- package/components/hy-picker/typing.d.ts +39 -39
- package/components/hy-popover/hy-popover.vue +97 -77
- package/components/hy-popup/hy-popup.vue +107 -98
- package/components/hy-price/hy-price.vue +38 -34
- package/components/hy-qrcode/hy-qrcode.vue +50 -51
- package/components/hy-radio/hy-radio.vue +101 -113
- package/components/hy-rate/hy-rate.vue +107 -88
- package/components/hy-read-more/hy-read-more.vue +64 -49
- package/components/hy-scroll-list/hy-scroll-list.vue +45 -48
- package/components/hy-search/hy-search.vue +73 -66
- package/components/hy-search/typing.d.ts +36 -35
- package/components/hy-signature/hy-signature.vue +282 -240
- package/components/hy-slider/hy-slider.vue +195 -153
- package/components/hy-slider/typing.d.ts +21 -21
- package/components/hy-steps/hy-steps.vue +118 -90
- package/components/hy-steps/index.scss +31 -21
- package/components/hy-submit-bar/hy-submit-bar.vue +61 -70
- package/components/hy-subsection/hy-subsection.vue +99 -102
- package/components/hy-subsection/typing.d.ts +19 -19
- package/components/hy-swipe-action/hy-swipe-action.vue +131 -118
- package/components/hy-swiper/hy-swiper.vue +85 -71
- package/components/hy-switch/hy-switch.vue +67 -72
- package/components/hy-switch/typing.d.ts +21 -19
- package/components/hy-tabs/hy-tabs.vue +168 -113
- package/components/hy-tag/hy-tag.vue +90 -86
- package/components/hy-tag/typing.d.ts +26 -21
- package/components/hy-text/hy-text.vue +119 -111
- package/components/hy-textarea/hy-textarea.vue +100 -93
- package/components/hy-textarea/typing.d.ts +36 -31
- package/components/hy-toast/hy-toast.vue +77 -67
- package/components/hy-tooltip/hy-tooltip.vue +109 -91
- package/components/hy-transition/hy-transition.vue +62 -66
- package/components/hy-upload/hy-upload.vue +294 -152
- package/components/hy-upload/typing.d.ts +41 -36
- package/components/hy-warn/hy-warn.vue +34 -27
- package/components/hy-waterfall/hy-waterfall.vue +83 -74
- package/components/hy-watermark/hy-watermark.vue +134 -115
- package/components/index.ts +1 -1
- package/composables/usePopover.ts +236 -221
- package/composables/useQueue.ts +53 -52
- package/global.d.ts +1 -0
- package/package.json +2 -2
- package/store/index.ts +9 -1
- package/theme.scss +5 -5
- package/typing/index.ts +0 -1
- package/typing/modules/common.d.ts +0 -2
- package/web-types.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<!-- 标题栏 -->
|
|
3
|
-
<view
|
|
3
|
+
<view
|
|
4
|
+
:class="['hy-dropdown-item__header', isOpen && 'is-active']"
|
|
5
|
+
@click="handleClick"
|
|
6
|
+
>
|
|
4
7
|
<text
|
|
5
8
|
class="hy-dropdown-item__header--title"
|
|
6
9
|
:style="{ color: currentColor, fontSize: addUnit(titleSize) }"
|
|
@@ -17,7 +20,11 @@
|
|
|
17
20
|
></HyIcon>
|
|
18
21
|
</view>
|
|
19
22
|
<!-- 下拉弹窗 -->
|
|
20
|
-
<HyOverlay
|
|
23
|
+
<HyOverlay
|
|
24
|
+
:show="isOpen"
|
|
25
|
+
:custom-style="{ top: addUnit(dropPopupTop) }"
|
|
26
|
+
@click="closePopupFn"
|
|
27
|
+
>
|
|
21
28
|
<view
|
|
22
29
|
class="hy-dropdown-item__main"
|
|
23
30
|
:style="{ top: addUnit(dropPopupTop), height: addUnit(dropHeight) }"
|
|
@@ -59,11 +66,11 @@
|
|
|
59
66
|
|
|
60
67
|
<script lang="ts">
|
|
61
68
|
export default {
|
|
62
|
-
name:
|
|
69
|
+
name: "hy-dropdown-item",
|
|
63
70
|
options: {
|
|
64
|
-
styleIsolation:
|
|
71
|
+
styleIsolation: "shared",
|
|
65
72
|
},
|
|
66
|
-
}
|
|
73
|
+
};
|
|
67
74
|
</script>
|
|
68
75
|
|
|
69
76
|
<script setup lang="ts">
|
|
@@ -74,24 +81,22 @@ import {
|
|
|
74
81
|
onMounted,
|
|
75
82
|
watch,
|
|
76
83
|
useSlots,
|
|
77
|
-
toRefs,
|
|
78
84
|
getCurrentInstance,
|
|
79
85
|
type PropType,
|
|
80
|
-
} from
|
|
81
|
-
import type { IDropdownItemEmits } from
|
|
82
|
-
import type FatherIProps from
|
|
83
|
-
import
|
|
84
|
-
import {
|
|
85
|
-
import { IconConfig } from '../../config'
|
|
86
|
+
} from "vue";
|
|
87
|
+
import type { IDropdownItemEmits, DropdownMenuItem } from "./typing";
|
|
88
|
+
import type FatherIProps from "../hy-dropdown/typing";
|
|
89
|
+
import { addUnit, getRect, throttle } from "../../utils";
|
|
90
|
+
import { IconConfig } from "../../config";
|
|
86
91
|
// 组件
|
|
87
|
-
import HyOverlay from
|
|
88
|
-
import HyIcon from
|
|
92
|
+
import HyOverlay from "../hy-overlay/hy-overlay.vue";
|
|
93
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
89
94
|
|
|
90
95
|
/**
|
|
91
96
|
* 主要提供筛选下拉筛选框,内置基础筛选功能,可以根据自己的需求自定义筛选项。和hy-dropdown组合用法
|
|
92
97
|
* @displayName hy-dropdown-item
|
|
93
98
|
*/
|
|
94
|
-
defineOptions({})
|
|
99
|
+
defineOptions({});
|
|
95
100
|
|
|
96
101
|
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
97
102
|
const props = defineProps({
|
|
@@ -109,69 +114,69 @@ const props = defineProps({
|
|
|
109
114
|
type: Boolean,
|
|
110
115
|
default: false,
|
|
111
116
|
},
|
|
112
|
-
})
|
|
113
|
-
const
|
|
114
|
-
const emits = defineEmits<IDropdownItemEmits>()
|
|
117
|
+
});
|
|
118
|
+
const emit = defineEmits<IDropdownItemEmits>();
|
|
115
119
|
|
|
116
|
-
const slots = useSlots()
|
|
120
|
+
const slots = useSlots();
|
|
117
121
|
//是否有插槽
|
|
118
122
|
const hasSlot = computed(() => {
|
|
119
|
-
return Object.keys(slots).length > 0
|
|
120
|
-
})
|
|
121
|
-
const instance = getCurrentInstance()
|
|
123
|
+
return Object.keys(slots).length > 0;
|
|
124
|
+
});
|
|
125
|
+
const instance = getCurrentInstance();
|
|
122
126
|
//父的props值
|
|
123
|
-
const dropdownProps: FatherIProps | undefined = inject(
|
|
124
|
-
const { titleSize, menuIcon, menuIconSize, inactiveColor } =
|
|
127
|
+
const dropdownProps: FatherIProps | undefined = inject("dropdownProps");
|
|
128
|
+
const { titleSize, menuIcon, menuIconSize, inactiveColor } =
|
|
129
|
+
dropdownProps as FatherIProps;
|
|
125
130
|
//当前打开的dropItem项(标签名)
|
|
126
|
-
const currentDropItem: any = inject(
|
|
131
|
+
const currentDropItem: any = inject("currentDropItem");
|
|
127
132
|
//当前文字/箭头颜色
|
|
128
133
|
const currentColor = computed(() => {
|
|
129
|
-
return isOpen.value ? dropdownProps?.activeColor : inactiveColor
|
|
130
|
-
})
|
|
134
|
+
return isOpen.value ? dropdownProps?.activeColor : inactiveColor;
|
|
135
|
+
});
|
|
131
136
|
//是否打开
|
|
132
|
-
const isOpen = ref<boolean>(false)
|
|
137
|
+
const isOpen = ref<boolean>(false);
|
|
133
138
|
//下拉弹窗距离页面顶部距离
|
|
134
|
-
const dropPopupTop = ref(0)
|
|
139
|
+
const dropPopupTop = ref(0);
|
|
135
140
|
//下拉弹窗高度
|
|
136
|
-
const dropHeight = ref<string | number>(0)
|
|
141
|
+
const dropHeight = ref<string | number>(0);
|
|
137
142
|
//下拉选项当前选中的索引
|
|
138
|
-
const currentIndex = ref(-1)
|
|
143
|
+
const currentIndex = ref(-1);
|
|
139
144
|
|
|
140
145
|
//动态class
|
|
141
|
-
const customClass = computed(() => (isOpen.value ?
|
|
146
|
+
const customClass = computed(() => (isOpen.value ? "visible" : "hidden"));
|
|
142
147
|
|
|
143
148
|
onMounted(() => {
|
|
144
|
-
getDropPopupTop()
|
|
145
|
-
})
|
|
149
|
+
getDropPopupTop();
|
|
150
|
+
});
|
|
146
151
|
|
|
147
152
|
/**
|
|
148
153
|
* @description 计算下拉弹窗区域距离页面顶部距离
|
|
149
154
|
* */
|
|
150
155
|
const getDropPopupTop = () => {
|
|
151
|
-
getRect(
|
|
152
|
-
const { bottom } = rect as UniApp.NodeInfo
|
|
156
|
+
getRect(".hy-dropdown-item__header", false, instance).then((rect) => {
|
|
157
|
+
const { bottom } = rect as UniApp.NodeInfo;
|
|
153
158
|
// #ifdef H5
|
|
154
159
|
//H5需要加上导航栏高度,固定44px
|
|
155
|
-
dropPopupTop.value = (bottom || 0) + 44
|
|
160
|
+
dropPopupTop.value = (bottom || 0) + 44;
|
|
156
161
|
// #endif
|
|
157
162
|
// #ifndef H5
|
|
158
|
-
dropPopupTop.value = bottom || 0
|
|
163
|
+
dropPopupTop.value = bottom || 0;
|
|
159
164
|
// #endif
|
|
160
|
-
})
|
|
161
|
-
}
|
|
165
|
+
});
|
|
166
|
+
};
|
|
162
167
|
|
|
163
168
|
watch(isOpen, (v) => {
|
|
164
169
|
//打开状态显示父容器
|
|
165
170
|
if (v) {
|
|
166
|
-
dropHeight.value =
|
|
171
|
+
dropHeight.value = "auto";
|
|
167
172
|
} else {
|
|
168
173
|
//关闭状态隐藏父容器
|
|
169
174
|
//延迟改变使得关闭动画能完整呈现
|
|
170
175
|
setTimeout(() => {
|
|
171
|
-
dropHeight.value = 0
|
|
172
|
-
}, 200)
|
|
176
|
+
dropHeight.value = 0;
|
|
177
|
+
}, 200);
|
|
173
178
|
}
|
|
174
|
-
})
|
|
179
|
+
});
|
|
175
180
|
/**
|
|
176
181
|
* @description 动态控制开关,
|
|
177
182
|
* @desc 防止点击展开后在点击下一个,导致上一个没有关闭bug
|
|
@@ -181,29 +186,29 @@ watch(
|
|
|
181
186
|
(newVal) => {
|
|
182
187
|
//关闭其他条件的下拉弹窗
|
|
183
188
|
if (newVal !== props.title) {
|
|
184
|
-
isOpen.value = false
|
|
189
|
+
isOpen.value = false;
|
|
185
190
|
}
|
|
186
191
|
},
|
|
187
|
-
)
|
|
192
|
+
);
|
|
188
193
|
|
|
189
194
|
//根据双向绑定值动态设置下拉选中项索引
|
|
190
195
|
watch(
|
|
191
|
-
() => modelValue
|
|
196
|
+
() => props.modelValue,
|
|
192
197
|
(newVal) => {
|
|
193
|
-
currentIndex.value = menus.
|
|
198
|
+
currentIndex.value = props.menus.findIndex((item) => item.value === newVal);
|
|
194
199
|
},
|
|
195
200
|
{ immediate: true },
|
|
196
|
-
)
|
|
201
|
+
);
|
|
197
202
|
|
|
198
203
|
//选中监听
|
|
199
204
|
const onSelect = (item: DropdownMenuItem, index: number) => {
|
|
200
|
-
isOpen.value = false
|
|
205
|
+
isOpen.value = false;
|
|
201
206
|
if (index !== currentIndex.value) {
|
|
202
|
-
currentIndex.value = index
|
|
203
|
-
|
|
204
|
-
|
|
207
|
+
currentIndex.value = index;
|
|
208
|
+
emit("change", item, index);
|
|
209
|
+
emit("update:modelValue", item);
|
|
205
210
|
}
|
|
206
|
-
}
|
|
211
|
+
};
|
|
207
212
|
|
|
208
213
|
/**
|
|
209
214
|
* @description 打开或关闭
|
|
@@ -211,24 +216,24 @@ const onSelect = (item: DropdownMenuItem, index: number) => {
|
|
|
211
216
|
const handleClick = () =>
|
|
212
217
|
throttle(() => {
|
|
213
218
|
//节流处理,防止点击过快动画未结束又切换导致显示bug
|
|
214
|
-
isOpen.value = !isOpen.value
|
|
219
|
+
isOpen.value = !isOpen.value;
|
|
215
220
|
if (isOpen.value) {
|
|
216
221
|
// 防止点击展开后在点击下一个,导致上一个没有关闭bug
|
|
217
|
-
currentDropItem.value = props.title
|
|
218
|
-
getDropPopupTop()
|
|
222
|
+
currentDropItem.value = props.title;
|
|
223
|
+
getDropPopupTop();
|
|
219
224
|
}
|
|
220
|
-
})
|
|
225
|
+
});
|
|
221
226
|
|
|
222
227
|
/**
|
|
223
228
|
* @description 点击遮罩框关闭弹窗
|
|
224
229
|
* */
|
|
225
230
|
const closePopupFn = () => {
|
|
226
231
|
if (dropdownProps?.closeOnClickMask) {
|
|
227
|
-
isOpen.value = false
|
|
232
|
+
isOpen.value = false;
|
|
228
233
|
}
|
|
229
|
-
}
|
|
234
|
+
};
|
|
230
235
|
</script>
|
|
231
236
|
|
|
232
237
|
<style lang="scss" scoped>
|
|
233
|
-
@import
|
|
238
|
+
@import "./index.scss";
|
|
234
239
|
</style>
|
|
@@ -2,35 +2,35 @@ export interface DropdownMenuItem {
|
|
|
2
2
|
/**
|
|
3
3
|
* @description 展示标题
|
|
4
4
|
* */
|
|
5
|
-
label: string
|
|
5
|
+
label: string;
|
|
6
6
|
/**
|
|
7
7
|
* @description 值
|
|
8
8
|
* */
|
|
9
|
-
value: string | number
|
|
9
|
+
value: string | number;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export default interface HyDropdownItemProps {
|
|
13
13
|
/**
|
|
14
14
|
* @description 获取值
|
|
15
15
|
* */
|
|
16
|
-
modelValue: string | number
|
|
16
|
+
modelValue: string | number;
|
|
17
17
|
/**
|
|
18
18
|
* @description 标题
|
|
19
19
|
* */
|
|
20
|
-
title: string
|
|
20
|
+
title: string;
|
|
21
21
|
/**
|
|
22
22
|
* @description 下拉选择值
|
|
23
23
|
* */
|
|
24
|
-
menus?: DropdownMenuItem[]
|
|
24
|
+
menus?: DropdownMenuItem[];
|
|
25
25
|
/**
|
|
26
26
|
* @description 禁用组件点击
|
|
27
27
|
* */
|
|
28
|
-
disabled?: boolean
|
|
28
|
+
disabled?: boolean;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface IDropdownItemEmits {
|
|
32
32
|
/** 选中值触发 */
|
|
33
|
-
(e:
|
|
34
|
-
/**
|
|
35
|
-
(e:
|
|
33
|
+
(e: "change", item: DropdownMenuItem, index: number): void;
|
|
34
|
+
/** 值改变触发 */
|
|
35
|
+
(e: "update:modelValue", item: DropdownMenuItem): void;
|
|
36
36
|
}
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
</view>
|
|
14
14
|
<view class="hy-empty__description" v-else>
|
|
15
15
|
<slot v-if="$slots.description" name="description"></slot>
|
|
16
|
-
<text v-else :style="descriptionStyle">{{
|
|
16
|
+
<text v-else :style="descriptionStyle">{{
|
|
17
|
+
emptyDescription || emptyIcon[mode].name
|
|
18
|
+
}}</text>
|
|
17
19
|
<view class="hy-empty__button" v-if="button?.text">
|
|
18
20
|
<HyButton
|
|
19
21
|
:text="button?.text"
|
|
@@ -31,32 +33,31 @@
|
|
|
31
33
|
|
|
32
34
|
<script lang="ts">
|
|
33
35
|
export default {
|
|
34
|
-
name:
|
|
36
|
+
name: "hy-empty",
|
|
35
37
|
options: {
|
|
36
38
|
addGlobalClass: true,
|
|
37
39
|
virtualHost: true,
|
|
38
|
-
styleIsolation:
|
|
40
|
+
styleIsolation: "shared",
|
|
39
41
|
},
|
|
40
|
-
}
|
|
42
|
+
};
|
|
41
43
|
</script>
|
|
42
44
|
|
|
43
45
|
<script setup lang="ts">
|
|
44
|
-
import { computed
|
|
45
|
-
import type { CSSProperties, PropType } from
|
|
46
|
-
import { addUnit } from
|
|
47
|
-
import emptyIcon from
|
|
48
|
-
import type { HyButtonProps } from
|
|
49
|
-
import type { IEmptyEmits } from
|
|
50
|
-
|
|
46
|
+
import { computed } from "vue";
|
|
47
|
+
import type { CSSProperties, PropType } from "vue";
|
|
48
|
+
import { addUnit } from "../../utils";
|
|
49
|
+
import emptyIcon from "./icon";
|
|
50
|
+
import type { HyButtonProps } from "../hy-button/typing";
|
|
51
|
+
import type { IEmptyEmits } from "./typing";
|
|
51
52
|
// 组件
|
|
52
|
-
import HyButton from
|
|
53
|
-
import HyIcon from
|
|
53
|
+
import HyButton from "../hy-button/hy-button.vue";
|
|
54
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
57
|
* 加载的第一页数据就为空
|
|
57
58
|
* @displayName hy-empty
|
|
58
59
|
*/
|
|
59
|
-
defineOptions({})
|
|
60
|
+
defineOptions({});
|
|
60
61
|
|
|
61
62
|
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
62
63
|
const props = defineProps({
|
|
@@ -69,7 +70,7 @@ const props = defineProps({
|
|
|
69
70
|
/** 缺省页内容 */
|
|
70
71
|
mode: {
|
|
71
72
|
type: String,
|
|
72
|
-
default:
|
|
73
|
+
default: "car",
|
|
73
74
|
},
|
|
74
75
|
/** 空状态图片 */
|
|
75
76
|
imageUrl: String,
|
|
@@ -86,7 +87,7 @@ const props = defineProps({
|
|
|
86
87
|
/** icon高度 */
|
|
87
88
|
height: {
|
|
88
89
|
type: [String, Number],
|
|
89
|
-
default:
|
|
90
|
+
default: "auto",
|
|
90
91
|
},
|
|
91
92
|
/** 提示信息 */
|
|
92
93
|
description: String,
|
|
@@ -107,62 +108,61 @@ const props = defineProps({
|
|
|
107
108
|
/** 定义需要用到的外部样式 */
|
|
108
109
|
customStyle: {
|
|
109
110
|
type: Object as PropType<CSSProperties>,
|
|
111
|
+
default: () => {},
|
|
110
112
|
},
|
|
111
113
|
/** 自定义外部类名 */
|
|
112
114
|
customClass: String,
|
|
113
|
-
})
|
|
114
|
-
const
|
|
115
|
-
toRefs(props)
|
|
116
|
-
const emit = defineEmits<IEmptyEmits>()
|
|
115
|
+
});
|
|
116
|
+
const emit = defineEmits<IEmptyEmits>();
|
|
117
117
|
|
|
118
118
|
const emptyDescription = computed(() => {
|
|
119
|
-
return props.description
|
|
120
|
-
})
|
|
119
|
+
return props.description;
|
|
120
|
+
});
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* @description 整体样式
|
|
124
124
|
* */
|
|
125
125
|
const emptyStyle = computed<CSSProperties>(() => {
|
|
126
126
|
const style: CSSProperties = {
|
|
127
|
-
zIndex: zIndex
|
|
128
|
-
}
|
|
129
|
-
return Object.assign(style, customStyle
|
|
130
|
-
})
|
|
127
|
+
zIndex: props.zIndex,
|
|
128
|
+
};
|
|
129
|
+
return Object.assign(style, props.customStyle);
|
|
130
|
+
});
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* @description 提示信息样式
|
|
134
134
|
* */
|
|
135
135
|
const descriptionStyle = computed<CSSProperties>(() => {
|
|
136
136
|
const style: CSSProperties = {
|
|
137
|
-
fontSize: addUnit(desSize
|
|
138
|
-
color: desColor
|
|
139
|
-
}
|
|
140
|
-
return style
|
|
141
|
-
})
|
|
137
|
+
fontSize: addUnit(props.desSize),
|
|
138
|
+
color: props.desColor,
|
|
139
|
+
};
|
|
140
|
+
return style;
|
|
141
|
+
});
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* @description 图片样式
|
|
145
145
|
* */
|
|
146
146
|
const imgStyle = computed<CSSProperties>(() => {
|
|
147
147
|
return {
|
|
148
|
-
width: addUnit(width
|
|
149
|
-
height: addUnit(height
|
|
150
|
-
margin: imgMargin
|
|
151
|
-
}
|
|
152
|
-
})
|
|
148
|
+
width: addUnit(props.width),
|
|
149
|
+
height: addUnit(props.height),
|
|
150
|
+
margin: props.imgMargin,
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* @description 点击按钮,跳转页面
|
|
156
156
|
* */
|
|
157
157
|
const handleClick = () => {
|
|
158
|
-
emit(
|
|
159
|
-
if (navigateUrl
|
|
158
|
+
emit("click");
|
|
159
|
+
if (props.navigateUrl) {
|
|
160
160
|
uni.navigateTo({
|
|
161
|
-
url: navigateUrl
|
|
162
|
-
})
|
|
161
|
+
url: props.navigateUrl,
|
|
162
|
+
});
|
|
163
163
|
}
|
|
164
|
-
}
|
|
164
|
+
};
|
|
165
165
|
</script>
|
|
166
166
|
<style scoped lang="scss">
|
|
167
|
-
@import
|
|
167
|
+
@import "./index.scss";
|
|
168
168
|
</style>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="cls" :style="style">
|
|
3
|
+
<slot />
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
export default {
|
|
9
|
+
name: "hy-flex",
|
|
10
|
+
options: {
|
|
11
|
+
addGlobalClass: true,
|
|
12
|
+
virtualHost: true,
|
|
13
|
+
styleIsolation: "shared",
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { computed } from "vue";
|
|
20
|
+
import type { PropType } from "vue";
|
|
21
|
+
import type { FlexAlign, FlexDirection, FlexJustify, FlexWrap } from "./typing";
|
|
22
|
+
import { addUnit, isArray } from "../../utils";
|
|
23
|
+
|
|
24
|
+
const props = defineProps({
|
|
25
|
+
/** flex 主轴的方向是否垂直,使用 flex-direction: column */
|
|
26
|
+
vertical: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false,
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* 快捷设置 flex-direction
|
|
32
|
+
* @values row,row-reverse,column,column-reverse
|
|
33
|
+
* */
|
|
34
|
+
direction: String as PropType<FlexDirection>,
|
|
35
|
+
/**
|
|
36
|
+
* 设置元素在主轴方向上的对齐方式
|
|
37
|
+
* @values flex-start,flex-end,space-between,space-around,space-evenly,center
|
|
38
|
+
* */
|
|
39
|
+
justify: {
|
|
40
|
+
type: String as PropType<FlexJustify>,
|
|
41
|
+
default: "flex-start",
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* 设置元素在交叉轴方向上的对齐方式
|
|
45
|
+
* @values flex-start,center,flex-end,stretch,baseline
|
|
46
|
+
* */
|
|
47
|
+
align: {
|
|
48
|
+
type: String as PropType<FlexAlign>,
|
|
49
|
+
default: "flex-start",
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* 设置元素单行显示还是多行显示
|
|
53
|
+
* @values nowrap,wrap,wrap-reverse
|
|
54
|
+
* */
|
|
55
|
+
wrap: {
|
|
56
|
+
type: String as PropType<FlexWrap>,
|
|
57
|
+
default: "nowrap",
|
|
58
|
+
},
|
|
59
|
+
/** flex 属性,支持数字或字符串。如 1 或 'none' */
|
|
60
|
+
flex: {
|
|
61
|
+
type: [String, Number],
|
|
62
|
+
default: "initial",
|
|
63
|
+
},
|
|
64
|
+
/** 设置网格之间的间隙 */
|
|
65
|
+
gap: {
|
|
66
|
+
type: [String, Number, Array] as PropType<
|
|
67
|
+
string | number | (string | number)[]
|
|
68
|
+
>,
|
|
69
|
+
default: 0,
|
|
70
|
+
},
|
|
71
|
+
/** 快捷设置 */
|
|
72
|
+
basis: {
|
|
73
|
+
type: [String, Number],
|
|
74
|
+
default: "auto",
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// 计算 class
|
|
79
|
+
const cls = computed(() => ["hy-flex", props.vertical && "hy-flex--vertical"]);
|
|
80
|
+
|
|
81
|
+
// 计算 style
|
|
82
|
+
const style = computed(() => {
|
|
83
|
+
const gap = isArray(props.gap) ? props.gap : [props.gap, props.gap];
|
|
84
|
+
const [rowGap, colGap] = gap.map((v) => addUnit(v));
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
display: "flex",
|
|
88
|
+
"justify-content": props.justify,
|
|
89
|
+
"align-items": props.align,
|
|
90
|
+
"flex-wrap": props.wrap,
|
|
91
|
+
flex: props.flex,
|
|
92
|
+
"flex-basis": props.basis,
|
|
93
|
+
"row-gap": colGap,
|
|
94
|
+
"column-gap": rowGap,
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<style scoped></style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type FlexAlign = 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'
|
|
2
|
+
|
|
3
|
+
export type FlexJustify = HyApp.JustifyContentType
|
|
4
|
+
export type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse'
|
|
5
|
+
export type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse'
|
|
6
|
+
|
|
7
|
+
export interface FlexProps {
|
|
8
|
+
/** 主轴方向,等价于 flex-direction */
|
|
9
|
+
vertical?: boolean
|
|
10
|
+
direction?: FlexDirection
|
|
11
|
+
/** justify-content */
|
|
12
|
+
justify?: FlexJustify
|
|
13
|
+
/** align-items */
|
|
14
|
+
align?: FlexAlign
|
|
15
|
+
/** flex-wrap */
|
|
16
|
+
wrap?: FlexWrap
|
|
17
|
+
/** flex 属性,支持数字或字符串。如 1 或 'none' */
|
|
18
|
+
flex?: number | string
|
|
19
|
+
/** 子元素间距,支持数字(px)、字符串或数组 [row, column] */
|
|
20
|
+
gap?: number | string | [number | string, number | string]
|
|
21
|
+
/** flex-basis */
|
|
22
|
+
basis?: number | string
|
|
23
|
+
}
|