hy-app 0.2.5 → 0.2.7

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.
Files changed (55) hide show
  1. package/common/index.ts +2 -1
  2. package/common/shakeService.ts +60 -0
  3. package/components/hy-action-sheet/hy-action-sheet.vue +184 -0
  4. package/components/hy-action-sheet/index.scss +123 -0
  5. package/components/hy-action-sheet/props.ts +18 -0
  6. package/components/hy-action-sheet/typing.d.ts +96 -0
  7. package/components/hy-address-picker/hy-address-picker.vue +75 -91
  8. package/components/hy-avatar/hy-avatar.vue +64 -73
  9. package/components/hy-button/hy-button.vue +3 -3
  10. package/components/hy-button/typing.d.ts +35 -31
  11. package/components/hy-cell/typing.d.ts +27 -24
  12. package/components/hy-empty/hy-empty.vue +30 -37
  13. package/components/hy-empty/icon.ts +78 -0
  14. package/components/hy-empty/index.scss +2 -1
  15. package/components/hy-empty/props.ts +10 -9
  16. package/components/hy-empty/typing.d.ts +39 -14
  17. package/components/hy-float-button/hy-float-button.vue +183 -17
  18. package/components/hy-float-button/props.ts +17 -15
  19. package/components/hy-float-button/typing.d.ts +51 -27
  20. package/components/hy-icon/hy-icon.vue +39 -41
  21. package/components/hy-icon/props.ts +17 -16
  22. package/components/hy-icon/typing.d.ts +24 -20
  23. package/components/hy-image/hy-image.vue +69 -104
  24. package/components/hy-image/index.scss +21 -5
  25. package/components/hy-image/props.ts +11 -10
  26. package/components/hy-image/typing.d.ts +23 -19
  27. package/components/hy-modal/hy-modal.vue +42 -54
  28. package/components/hy-modal/index.scss +56 -32
  29. package/components/hy-modal/props.ts +15 -14
  30. package/components/hy-modal/typing.d.ts +23 -17
  31. package/components/hy-popover/hy-popover.vue +200 -0
  32. package/components/hy-popover/index.scss +83 -0
  33. package/components/hy-popover/props.ts +13 -0
  34. package/components/hy-popover/typing.d.ts +56 -0
  35. package/components/hy-popup/index.scss +2 -2
  36. package/components/hy-popup/props.ts +7 -7
  37. package/components/hy-popup/typing.d.ts +17 -17
  38. package/components/hy-qrcode/hy-qrcode.vue +44 -45
  39. package/components/hy-rate/props.ts +6 -6
  40. package/components/hy-signature/props.ts +14 -14
  41. package/components/hy-tooltip/index.scss +2 -2
  42. package/components/hy-transition/hy-transition.vue +64 -72
  43. package/components/hy-transition/typing.d.ts +10 -6
  44. package/composables/index.ts +4 -2
  45. package/composables/usePopover.ts +221 -0
  46. package/composables/useQueue.ts +52 -0
  47. package/libs/css/_config.scss +5 -0
  48. package/libs/css/_function.scss +89 -0
  49. package/libs/css/mixin.scss +146 -21
  50. package/libs/css/vars.css +3 -1
  51. package/package.json +2 -2
  52. package/theme.scss +2 -1
  53. package/utils/inside.ts +96 -108
  54. package/utils/inspect.ts +48 -40
  55. package/utils/utils.ts +170 -187
@@ -1,80 +1,84 @@
1
- import { CSSProperties } from "vue";
1
+ import { CSSProperties } from 'vue'
2
2
 
3
3
  export default interface HyIconProps {
4
4
  /**
5
5
  * @description 图标名称,见示例图标集
6
6
  * */
7
- name: string | HyIconConfig;
7
+ name: string | HyIconConfig
8
8
  /**
9
9
  * @description 图标颜色
10
10
  * */
11
- color?: string;
11
+ color?: string
12
12
  /**
13
13
  * @description 图标字体大小,单位px (默认 '16px' )
14
14
  * */
15
- size?: string | number;
15
+ size?: string | number
16
16
  /**
17
17
  * @description 是否显示粗体 (默认 false )
18
18
  * */
19
- bold?: boolean;
19
+ bold?: boolean
20
20
  /**
21
21
  * @description 点击图标的时候传递事件出去的index(用于区分点击了哪一个)
22
22
  * */
23
- index?: string | number;
23
+ index?: string | number
24
24
  /**
25
25
  * @description 自定义扩展前缀,方便用户扩展自己的图标库 (默认 'hy-icon' )
26
26
  * */
27
- customPrefix?: string;
27
+ customPrefix?: string
28
28
  /**
29
29
  * @description 图标右侧的label文字
30
30
  * */
31
- label?: string;
31
+ label?: string
32
32
  /**
33
33
  * @description label相对于图标的位置,只能right或bottom (默认 'right' )
34
34
  * */
35
- labelPos?: "right" | "bottom";
35
+ labelPos?: 'right' | 'bottom'
36
36
  /**
37
37
  * @description label字体大小,单位px (默认 '15px' )
38
38
  * */
39
- labelSize?: string | number;
39
+ labelSize?: string | number
40
40
  /**
41
41
  * @description 图标右侧的label文字颜色
42
42
  * */
43
- labelColor?: string;
43
+ labelColor?: string
44
44
  /**
45
45
  * @description label与图标的距离,单位px (默认 '3px' )
46
46
  * */
47
- space?: string | number;
47
+ space?: string | number
48
48
  /**
49
49
  * @description 图片的mode
50
50
  * */
51
- imgMode?: string;
51
+ imgMode?: string
52
52
  /**
53
53
  * @description 显示图片小图标时的宽度
54
54
  * */
55
- width?: string | number;
55
+ width?: string | number
56
56
  /**
57
57
  * @description 显示图片小图标时的高度
58
58
  * */
59
- height?: string | number;
59
+ height?: string | number
60
60
  /**
61
61
  * @description 图标在垂直方向上的定位 用于解决某些情况下,让图标垂直居中的用途 (默认 0 )
62
62
  * */
63
- top?: number | string;
63
+ top?: number | string
64
64
  /**
65
65
  * @description 是否阻止事件传播 (默认 false )
66
66
  * */
67
- stop?: boolean;
67
+ stop?: boolean
68
68
  /**
69
69
  * @description 是否旋转 (默认 false )
70
70
  * */
71
- isRotate?: boolean;
71
+ isRotate?: boolean
72
72
  /**
73
73
  * @description 图标圆角
74
74
  * */
75
- round?: string | number;
75
+ round?: string | number
76
76
  /**
77
77
  * @description 自定义样式
78
78
  * */
79
- customStyle?: CSSProperties;
79
+ customStyle?: CSSProperties
80
+ /**
81
+ * @description 自定义类名
82
+ * */
83
+ customClass?: string
80
84
  }
@@ -1,15 +1,6 @@
1
1
  <template>
2
- <HyTransition
3
- mode="fade"
4
- :show="show"
5
- :style="transStyle"
6
- :duration="fade ? 1000 : 0"
7
- >
8
- <view
9
- class="hy-image box-border"
10
- @tap="clickHandler"
11
- :style="[wrapStyle, backgroundStyle]"
12
- >
2
+ <HyTransition mode="fade" :show="show" :style="transStyle" :duration="fade ? 1000 : 0">
3
+ <view class="hy-image box-border" @tap="clickHandler" :style="[wrapStyle, backgroundStyle]">
13
4
  <image
14
5
  v-if="!isError"
15
6
  :src="src"
@@ -18,11 +9,11 @@
18
9
  @load="onLoadHandler"
19
10
  :show-menu-by-longpress="showMenuByLongPress"
20
11
  :lazy-load="lazyLoad"
21
- class="hy-image__image"
12
+ :class="['hy-image__url', indistinct && 'hy-image__indistinct']"
22
13
  :style="{
23
14
  width: addUnit(width),
24
15
  height: addUnit(height),
25
- borderRadius: shape == 'circle' ? '10000px' : addUnit(radius),
16
+ borderRadius: shape == 'circle' ? '1000px' : addUnit(radius),
26
17
  }"
27
18
  ></image>
28
19
  <view
@@ -36,7 +27,7 @@
36
27
  }"
37
28
  >
38
29
  <slot name="loading">
39
- <HyIcon :name="loadingIcon"></HyIcon>
30
+ <HyLoading :name="loadingIcon"></HyLoading>
40
31
  </slot>
41
32
  </view>
42
33
  <view
@@ -47,7 +38,7 @@
47
38
  }"
48
39
  >
49
40
  <slot name="error">
50
- <HyIcon :name="errorIcon"></HyIcon>
41
+ <HyIcon :name="errorIcon" size="30"></HyIcon>
51
42
  </slot>
52
43
  </view>
53
44
  </view>
@@ -56,34 +47,27 @@
56
47
 
57
48
  <script lang="ts">
58
49
  export default {
59
- name: "hy-image",
50
+ name: 'hy-image',
60
51
  options: {
61
52
  addGlobalClass: true,
62
53
  virtualHost: true,
63
- styleIsolation: "shared",
54
+ styleIsolation: 'shared',
64
55
  },
65
- };
56
+ }
66
57
  </script>
67
58
 
68
59
  <script setup lang="ts">
69
- import {
70
- computed,
71
- type CSSProperties,
72
- onMounted,
73
- ref,
74
- toRefs,
75
- watch,
76
- } from "vue";
77
- import defaultProps from "./props";
78
- import type IProps from "./typing";
79
- import { addUnit, getPx } from "../../utils";
60
+ import { computed, type CSSProperties, onMounted, ref, toRefs, watch } from 'vue'
61
+ import defaultProps from './props'
62
+ import type IProps from './typing'
63
+ import { addUnit, getPx } from '../../utils'
80
64
 
81
65
  // 组件
66
+ import HyIcon from '../hy-icon/hy-icon.vue'
67
+ import HyTransition from '../hy-transition/hy-transition.vue'
68
+ import HyLoading from '../hy-loading/hy-loading.vue'
82
69
 
83
- import HyTransition from "../hy-transition/hy-transition.vue";
84
- import HyIcon from "../hy-icon/hy-icon.vue";
85
-
86
- const props = withDefaults(defineProps<IProps>(), defaultProps);
70
+ const props = withDefaults(defineProps<IProps>(), defaultProps)
87
71
  const {
88
72
  customStyle,
89
73
  duration,
@@ -95,133 +79,114 @@ const {
95
79
  radius,
96
80
  bgColor,
97
81
  previewImage,
98
- } = toRefs(props);
99
- const emit = defineEmits(["click", "error", "load"]);
82
+ indistinct,
83
+ } = toRefs(props)
84
+ const emit = defineEmits(['click', 'error', 'load'])
100
85
 
101
86
  // 图片是否加载错误,如果是,则显示错误占位图
102
- const isError = ref(false);
87
+ const isError = ref(false)
103
88
  // 初始化组件时,默认为加载中状态
104
- const loading = ref(true);
89
+ const loading = ref(true)
105
90
  // 不透明度,为了实现淡入淡出的效果
106
- const opacity = ref(1);
91
+ const opacity = ref(1)
107
92
  // 过渡时间,因为props的值无法修改,故需要一个中间值
108
- const durationTime = ref(duration.value);
93
+ const durationTime = ref(duration.value)
109
94
  // 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
110
- const backgroundStyle = ref({});
95
+ const backgroundStyle = ref({})
111
96
  // 用于fade模式的控制组件显示与否
112
- const show = ref(false);
97
+ const show = ref(false)
113
98
 
114
99
  watch(
115
100
  () => src.value,
116
101
  (newValue) => {
117
102
  if (!newValue) {
118
103
  // 如果传入null或者'',或者false,或者undefined,标记为错误状态
119
- isError.value = true;
104
+ isError.value = true
105
+ loading.value = false
120
106
  } else {
121
- isError.value = false;
122
- loading.value = true;
107
+ isError.value = false
108
+ loading.value = true
123
109
  }
124
110
  },
125
111
  { immediate: true },
126
- );
112
+ )
127
113
 
128
114
  const transStyle = computed<CSSProperties>(() => {
129
- const style: CSSProperties = {};
130
- if (
131
- loading.value ||
132
- isError.value ||
133
- width.value == "100%" ||
134
- mode.value != "heightFix"
135
- ) {
136
- style.width = addUnit(width.value);
115
+ const style: CSSProperties = {}
116
+ if (loading.value || isError.value || width.value == '100%' || mode.value != 'heightFix') {
117
+ style.width = addUnit(width.value)
137
118
  } else {
138
- style.width = "fit-content";
119
+ style.width = 'fit-content'
139
120
  }
140
- if (
141
- loading.value ||
142
- isError.value ||
143
- height.value == "100%" ||
144
- mode.value != "widthFix"
145
- ) {
146
- style.height = addUnit(height.value);
121
+ if (loading.value || isError.value || height.value == '100%' || mode.value != 'widthFix') {
122
+ style.height = addUnit(height.value)
147
123
  } else {
148
- style.height = "fit-content";
124
+ style.height = 'fit-content'
149
125
  }
150
- return style;
151
- });
126
+ return style
127
+ })
152
128
 
153
129
  const wrapStyle = computed(() => {
154
- const style: CSSProperties = {};
155
- if (
156
- loading.value ||
157
- isError.value ||
158
- width.value == "100%" ||
159
- mode.value != "heightFix"
160
- ) {
161
- style.width = addUnit(width.value);
130
+ const style: CSSProperties = {}
131
+ if (loading.value || isError.value || width.value == '100%' || mode.value != 'heightFix') {
132
+ style.width = addUnit(width.value)
162
133
  } else {
163
- style.width = "fit-content";
134
+ style.width = 'fit-content'
164
135
  }
165
- if (
166
- loading.value ||
167
- isError.value ||
168
- height.value == "100%" ||
169
- mode.value != "widthFix"
170
- ) {
171
- style.height = addUnit(height.value);
136
+ if (loading.value || isError.value || height.value == '100%' || mode.value != 'widthFix') {
137
+ style.height = addUnit(height.value)
172
138
  } else {
173
- style.height = "fit-content";
139
+ style.height = 'fit-content'
174
140
  }
175
141
  // 如果是显示圆形,设置一个很多的半径值即可
176
- style.borderRadius =
177
- shape.value == "circle" ? "10000px" : addUnit(radius.value);
142
+ style.borderRadius = shape.value == 'circle' ? '10000px' : addUnit(radius.value)
178
143
  // 如果设置圆角,必须要有hidden,否则可能圆角无效
179
- style.overflow = getPx(radius.value) > 0 ? "hidden" : "visible";
144
+ style.overflow = getPx(radius.value) > 0 ? 'hidden' : 'visible'
180
145
 
181
- return Object.assign(style, customStyle.value);
182
- });
146
+ return Object.assign(style, customStyle.value)
147
+ })
183
148
 
184
149
  onMounted(() => {
185
- show.value = true;
186
- });
150
+ show.value = true
151
+ })
187
152
 
188
153
  const clickHandler = () => {
189
- emit("click");
154
+ emit('click')
190
155
 
191
156
  if (previewImage.value) {
192
157
  uni.previewImage({
193
158
  urls: [src.value],
194
- });
159
+ })
195
160
  }
196
- };
161
+ }
197
162
 
198
163
  /**
199
164
  * @description 图片加载失败
200
165
  * */
201
166
  const onErrorHandler = (err: Event) => {
202
- loading.value = false;
203
- isError.value = true;
204
- emit("error", err);
205
- };
167
+ loading.value = false
168
+ isError.value = true
169
+ emit('error', err)
170
+ }
206
171
 
207
172
  /**
208
173
  * @description 图片加载成功
209
174
  * */
210
175
  const onLoadHandler = (e: Event) => {
211
- loading.value = false;
212
- isError.value = false;
213
- emit("load", e);
214
- removeBgColor();
215
- };
176
+ loading.value = false
177
+ isError.value = false
178
+ emit('load', e)
179
+ removeBgColor()
180
+ }
216
181
 
217
182
  const removeBgColor = () => {
218
183
  // 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
219
184
  backgroundStyle.value = {
220
- backgroundColor: bgColor.value || "",
221
- };
222
- };
185
+ backgroundColor: bgColor.value || '',
186
+ }
187
+ }
223
188
  </script>
224
189
 
225
190
  <style scoped lang="scss">
226
- @import "./index.scss";
191
+ @import './index.scss';
227
192
  </style>
@@ -4,14 +4,31 @@
4
4
  @include b(image) {
5
5
  position: relative;
6
6
  transition: opacity 0.5s ease-in-out;
7
+ width: 250px;
8
+ height: 200px;
7
9
 
8
- &__image {
10
+ @include e(url) {
9
11
  width: 100%;
10
12
  height: 100%;
11
13
  }
14
+ @include e(indistinct) {
15
+ position: relative;
16
+ @include pseudo(after) {
17
+ content: "";
18
+ position: absolute;
19
+ top: 0;
20
+ left: 0;
21
+ width: 100%;
22
+ height: 100%;
23
+ background: rgba(0, 0, 0, 0.2); /* 半透明背景 */
24
+ backdrop-filter: blur(6px); /* 磨砂效果 */
25
+ filter: blur(6px);
26
+ -webkit-filter: blur(6px); /* 兼容 iOS */
27
+ z-index: 999;
28
+ }
29
+ }
12
30
 
13
- &__loading,
14
- &__error {
31
+ @include e(loading, error) {
15
32
  position: absolute;
16
33
  top: 0;
17
34
  left: 0;
@@ -22,6 +39,5 @@
22
39
  justify-content: center;
23
40
  background-color: $hy-background--empty;
24
41
  color: $hy-text-color--grey;
25
- font-size: 46px;
26
42
  }
27
- }
43
+ }
@@ -1,12 +1,12 @@
1
- import type IProps from "./typing";
2
- import { IconConfig } from "../../config";
1
+ import type IProps from './typing'
2
+ import { IconConfig } from '../../config'
3
3
 
4
4
  const defaultProps: IProps = {
5
- src: "",
6
- mode: "aspectFill",
7
- width: "200",
8
- height: "150",
9
- shape: "square",
5
+ src: '',
6
+ mode: 'aspectFill',
7
+ width: '',
8
+ height: '',
9
+ shape: 'square',
10
10
  radius: 0,
11
11
  lazyLoad: true,
12
12
  showMenuByLongPress: true,
@@ -17,8 +17,9 @@ const defaultProps: IProps = {
17
17
  fade: true,
18
18
  webp: false,
19
19
  duration: 500,
20
- bgColor: "",
20
+ bgColor: '',
21
+ indistinct: false,
21
22
  previewImage: false,
22
- };
23
+ }
23
24
 
24
- export default defaultProps;
25
+ export default defaultProps
@@ -1,76 +1,80 @@
1
- import type { CSSProperties } from "vue";
1
+ import type { CSSProperties } from 'vue'
2
2
 
3
3
  export default interface HyImageProps {
4
4
  /**
5
5
  * @description 图片地址
6
6
  * */
7
- src?: string;
7
+ src?: string
8
8
  /**
9
9
  * @description 裁剪模式,见官网说明 (默认 'aspectFill' )
10
10
  * */
11
- mode?: HyApp.ImageModeVo;
11
+ mode?: HyApp.ImageModeVo
12
12
  /**
13
13
  * @description 宽度,单位任意,如果为数值,则为px单位 (默认 '300' )
14
14
  * */
15
- width?: string | number;
15
+ width?: string | number
16
16
  /**
17
17
  * @description 高度,单位任意,如果为数值,则为px单位 (默认 '225' )
18
18
  * */
19
- height?: string | number;
19
+ height?: string | number
20
20
  /**
21
21
  * @description 图片形状,circle-圆形,square-方形 (默认 'square' )
22
22
  * */
23
- shape?: HyApp.ShapeType;
23
+ shape?: HyApp.ShapeType
24
24
  /**
25
25
  * @description 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
26
26
  * */
27
- radius?: number | string;
27
+ radius?: number | string
28
28
  /**
29
29
  * @description 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 (默认 true )
30
30
  * */
31
- lazyLoad?: boolean;
31
+ lazyLoad?: boolean
32
32
  /**
33
33
  * @description 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 (默认 true )
34
34
  * */
35
- showMenuByLongPress?: boolean;
35
+ showMenuByLongPress?: boolean
36
36
  /**
37
37
  * @description 加载中的图标,或者小图片 (默认 'photo' )
38
38
  * */
39
- loadingIcon?: string;
39
+ loadingIcon?: string
40
40
  /**
41
41
  * @description 加载失败的图标,或者小图片 (默认 'error-circle' )
42
42
  * */
43
- errorIcon?: string;
43
+ errorIcon?: string
44
44
  /**
45
45
  * @description 是否显示加载中的图标或者自定义的slot (默认 true )
46
46
  * */
47
- showLoading?: boolean;
47
+ showLoading?: boolean
48
48
  /**
49
49
  * @description 是否显示加载错误的图标或者自定义的slot (默认 true )
50
50
  * */
51
- showError?: boolean;
51
+ showError?: boolean
52
52
  /**
53
53
  * @description 是否需要淡入效果 (默认 true )
54
54
  * */
55
- fade?: boolean;
55
+ fade?: boolean
56
56
  /**
57
57
  * @description 只支持网络资源,只对微信小程序有效 (默认 false )
58
58
  * */
59
- webp?: boolean;
59
+ webp?: boolean
60
60
  /**
61
61
  * @description 搭配fade参数的过渡时间,单位ms (默认 500 )
62
62
  * */
63
- duration?: number;
63
+ duration?: number
64
64
  /**
65
65
  * @description 背景颜色,用于深色页面加载图片时,为了和背景色融合 (默认 '#f3f4f6' )
66
66
  * */
67
- bgColor?: string;
67
+ bgColor?: string
68
+ /**
69
+ * @description 是否模糊图片 (默认 false )
70
+ * */
71
+ indistinct?: boolean
68
72
  /**
69
73
  * @description 是否预览图片 (默认 false )
70
74
  * */
71
- previewImage?: boolean;
75
+ previewImage?: boolean
72
76
  /**
73
77
  * @description 定义需要用到的外部样式
74
78
  * */
75
- customStyle?: CSSProperties;
79
+ customStyle?: CSSProperties
76
80
  }