hy-app 0.2.5 → 0.2.6

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 (37) hide show
  1. package/common/index.ts +2 -1
  2. package/common/shakeService.ts +62 -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-button/hy-button.vue +1 -1
  8. package/components/hy-button/typing.d.ts +35 -31
  9. package/components/hy-cell/typing.d.ts +27 -24
  10. package/components/hy-empty/hy-empty.vue +30 -37
  11. package/components/hy-empty/icon.ts +78 -0
  12. package/components/hy-empty/index.scss +2 -1
  13. package/components/hy-empty/props.ts +10 -9
  14. package/components/hy-empty/typing.d.ts +39 -14
  15. package/components/hy-float-button/hy-float-button.vue +98 -10
  16. package/components/hy-float-button/props.ts +16 -14
  17. package/components/hy-float-button/typing.d.ts +34 -23
  18. package/components/hy-icon/hy-icon.vue +40 -42
  19. package/components/hy-icon/props.ts +17 -16
  20. package/components/hy-icon/typing.d.ts +24 -20
  21. package/components/hy-modal/hy-modal.vue +42 -54
  22. package/components/hy-modal/index.scss +56 -32
  23. package/components/hy-modal/props.ts +15 -14
  24. package/components/hy-modal/typing.d.ts +23 -17
  25. package/components/hy-popup/index.scss +2 -2
  26. package/components/hy-popup/props.ts +7 -7
  27. package/components/hy-popup/typing.d.ts +17 -17
  28. package/components/hy-signature/props.ts +14 -14
  29. package/components/hy-tooltip/index.scss +2 -2
  30. package/libs/css/_config.scss +5 -0
  31. package/libs/css/_function.scss +89 -0
  32. package/libs/css/mixin.scss +58 -21
  33. package/libs/css/vars.css +3 -1
  34. package/package.json +2 -2
  35. package/theme.scss +2 -1
  36. package/utils/inspect.ts +48 -40
  37. package/utils/utils.ts +170 -187
@@ -1,93 +1,104 @@
1
- import type { CSSProperties } from "vue";
1
+ import type { CSSProperties } from 'vue'
2
2
 
3
3
  interface MenusVo {
4
4
  /**
5
5
  * @description 显示菜单文本
6
6
  * */
7
- label?: string;
7
+ label?: string
8
8
  /**
9
9
  * @description 跳转路径
10
10
  * */
11
- url?: string;
11
+ url?: string
12
12
  }
13
13
 
14
- export type MenusType = MenusVo | string;
14
+ export type MenusType = MenusVo | string
15
+ export type IGap = {
16
+ left?: number
17
+ right?: number
18
+ top?: number
19
+ bottom?: number
20
+ }
15
21
 
16
22
  export default interface HyFloatButtonProps {
17
23
  /**
18
24
  * @description 菜单栏集合
19
25
  * */
20
- menus?: MenusType[];
26
+ menus?: MenusType[]
21
27
  /**
22
28
  * @description 打开方向,row-横向;column-纵向
23
29
  * */
24
- direction?: HyApp.DirectionType;
30
+ direction?: HyApp.DirectionType
25
31
  /**
26
32
  * @description 按钮显示的图标
27
33
  * */
28
- icon?: string;
34
+ icon?: string
29
35
  /**
30
36
  * @description 按钮图标大小
31
37
  * */
32
- iconSize?: string | number;
38
+ iconSize?: string | number
33
39
  /**
34
40
  * @description 按钮图标颜色
35
41
  * */
36
- iconColor?: string;
42
+ iconColor?: string
43
+ gap?: IGap
37
44
  /**
38
45
  * @description 按钮距离底部的距离,默认单位为px
39
46
  * */
40
- bottom?: number | string;
47
+ top?: number | string
41
48
  /**
42
49
  * @description 按钮距离左边的距离,默认单位为px
43
50
  * */
44
- left?: number | string;
51
+ left?: number | string
45
52
  /**
46
53
  * @description 层级(默认:10086)
47
54
  * */
48
- zIndex?: number;
55
+ zIndex?: number
49
56
  /**
50
57
  * @description 按钮背景颜色
51
58
  * */
52
- bgColor?: string;
59
+ bgColor?: string
53
60
  /**
54
61
  * @description 按钮文字
55
62
  * */
56
- text?: string;
63
+ text?: string
57
64
  /**
58
65
  * @description 按钮文字大小
59
66
  * */
60
- fontSize?: string | number;
67
+ fontSize?: string | number
61
68
  /**
62
69
  * @description 按钮文字的颜色
63
70
  * */
64
- textColor?: string;
71
+ textColor?: string
65
72
  /**
66
73
  * @description 按钮的尺寸
67
74
  * */
68
- size?: HyApp.SizeType | string | number;
75
+ size?: HyApp.SizeType | string | number
69
76
  /**
70
77
  * @description 按钮的形状
71
78
  * */
72
- shape?: HyApp.ShapeType;
79
+ shape?: HyApp.ShapeType
73
80
  /**
74
81
  * @description 按钮的透明度
75
82
  * */
76
- opacity?: number;
83
+ opacity?: number
77
84
  /**
78
85
  * @description 是否显示阴影(默认:true)
79
86
  * */
80
- shadow?: boolean;
87
+ shadow?: boolean
81
88
  /**
82
89
  * @description 是否显示漂浮的动画(默认:true)
83
90
  * */
84
- float?: boolean;
91
+ float?: boolean
85
92
  /**
86
93
  * @description 是否固定位置(默认:true)
87
94
  * */
88
- fixed?: boolean;
95
+ fixed?: boolean
96
+ /**
97
+ * @description 是否能拖动(默认:true)
98
+ * */
99
+ draggable?: boolean
89
100
  /**
90
101
  * @description 定义需要用到的外部样式
91
102
  * */
92
- customStyle?: CSSProperties;
103
+ customStyle?: CSSProperties
93
104
  }
@@ -1,18 +1,13 @@
1
1
  <template>
2
- <view class="hy-icon" @tap="clickHandler" :class="[`hy-icon--${labelPos}`]">
2
+ <view :class="`hy-icon ${customClass} hy-icon--${labelPos}`" @tap="clickHandler">
3
3
  <image
4
4
  class="hy-icon__img"
5
5
  v-if="isImg"
6
6
  :src="name"
7
7
  :mode="imgMode"
8
- :style="[imgStyle, customStyle]"
8
+ :style="[imgStyle]"
9
9
  ></image>
10
- <text
11
- v-else
12
- class="hy-icon__icon"
13
- :class="uClasses"
14
- :style="[iconStyle, customStyle]"
15
- ></text>
10
+ <text v-else class="hy-icon__icon" :class="uClasses" :style="[iconStyle, customStyle]"></text>
16
11
  <!-- 这里进行空字符串判断,如果仅仅是v-if="label",可能会出现传递0的时候,结果也无法显示 -->
17
12
  <text
18
13
  v-if="label !== ''"
@@ -23,8 +18,9 @@
23
18
  marginLeft: labelPos == 'right' ? addUnit(space) : 0,
24
19
  marginTop: labelPos == 'bottom' ? addUnit(space) : 0,
25
20
  }"
26
- >{{ label }}</text
27
21
  >
22
+ {{ label }}
23
+ </text>
28
24
  </view>
29
25
  </template>
30
26
 
@@ -34,18 +30,18 @@ export default {
34
30
  options: {
35
31
  addGlobalClass: true,
36
32
  virtualHost: true,
37
- styleIsolation: 'shared'
38
- }
33
+ styleIsolation: 'shared',
34
+ },
39
35
  }
40
36
  </script>
41
37
 
42
38
  <script setup lang="ts">
43
- import { computed, type CSSProperties, toRefs } from "vue";
44
- import { addUnit } from "../../utils";
45
- import defaultProps from "./props";
46
- import type IProps from "./typing";
39
+ import { computed, type CSSProperties, toRefs } from 'vue'
40
+ import { addUnit } from '../../utils'
41
+ import defaultProps from './props'
42
+ import type IProps from './typing'
47
43
 
48
- const props = withDefaults(defineProps<IProps>(), defaultProps);
44
+ const props = withDefaults(defineProps<IProps>(), defaultProps)
49
45
  const {
50
46
  customPrefix,
51
47
  name,
@@ -59,66 +55,68 @@ const {
59
55
  index,
60
56
  isRotate,
61
57
  round,
62
- } = toRefs(props);
63
- const emit = defineEmits(["click"]);
58
+ customClass,
59
+ customStyle,
60
+ } = toRefs(props)
61
+ const emit = defineEmits(['click'])
64
62
 
65
63
  const uClasses = computed(() => {
66
64
  let classes: string | string[] = [
67
- "iconfont",
65
+ 'iconfont',
68
66
  `${customPrefix.value}-${name.value}`,
69
67
  customPrefix.value,
70
- ];
71
- if (isRotate.value) classes.push("hy-rotate");
68
+ ]
69
+ if (isRotate.value) classes.push('hy-rotate')
72
70
  if (color.value)
73
71
  // 主题色,通过类配置
74
- classes.push("hy-icon__icon--" + color.value);
72
+ classes.push('hy-icon__icon--' + color.value)
75
73
  // 阿里,头条,百度小程序通过数组绑定类名时,无法直接使用[a, b, c]的形式,否则无法识别
76
74
  // 故需将其拆成一个字符串的形式,通过空格隔开各个类名
77
75
  //#ifdef MP-ALIPAY || MP-TOUTIAO || MP-BAIDU
78
- classes = classes.join(" ");
76
+ classes = classes.join(' ')
79
77
  //#endif
80
- return classes;
81
- });
78
+ return classes
79
+ })
82
80
  const iconStyle = computed<CSSProperties>(() => {
83
- let style: CSSProperties = {};
81
+ let style: CSSProperties = {}
84
82
  style = {
85
83
  fontSize: addUnit(size.value),
86
84
  lineHeight: addUnit(size.value),
87
- fontWeight: bold.value ? "bold" : "normal",
85
+ fontWeight: bold.value ? 'bold' : 'normal',
88
86
  // 某些特殊情况需要设置一个到顶部的距离,才能更好的垂直居中
89
87
  top: addUnit(top.value),
90
88
  borderRadius: addUnit(round.value),
91
89
  color: color.value,
92
- };
90
+ }
93
91
 
94
- return style;
95
- });
92
+ return style
93
+ })
96
94
 
97
95
  /**
98
96
  * @description 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式
99
97
  * */
100
98
  const isImg = computed(() => {
101
- return name.value.indexOf("/") !== -1;
102
- });
99
+ return name.value.indexOf('/') !== -1
100
+ })
103
101
  const imgStyle = computed((): CSSProperties => {
104
- let style: CSSProperties = {};
102
+ let style: CSSProperties = {}
105
103
  // 如果设置width和height属性,则优先使用,否则使用size属性
106
- style.width = width.value ? addUnit(width.value) : addUnit(size.value);
107
- style.height = height.value ? addUnit(height.value) : addUnit(size.value);
108
- style.borderRadius = addUnit(round.value);
109
- return style;
110
- });
104
+ style.width = width.value ? addUnit(width.value) : addUnit(size.value)
105
+ style.height = height.value ? addUnit(height.value) : addUnit(size.value)
106
+ style.borderRadius = addUnit(round.value)
107
+ return style
108
+ })
111
109
 
112
110
  /**
113
111
  * @description 点击
114
112
  * */
115
113
  const clickHandler = (e: any) => {
116
- emit("click", index.value, e);
114
+ emit('click', index.value, e)
117
115
  // 是否阻止事件冒泡
118
- stop.value && e.stopPropagation();
119
- };
116
+ stop.value && e.stopPropagation()
117
+ }
120
118
  </script>
121
119
 
122
120
  <style lang="scss" scoped>
123
- @import "./index.scss";
121
+ @import './index.scss';
124
122
  </style>
@@ -1,24 +1,25 @@
1
- import type IProps from "./typing";
1
+ import type IProps from './typing'
2
2
 
3
3
  const defaultProps: IProps = {
4
- name: "",
5
- color: "",
6
- size: "20px",
4
+ name: '',
5
+ color: '',
6
+ size: '20px',
7
7
  bold: false,
8
- index: "",
9
- customPrefix: "hy-icon",
10
- label: "",
11
- labelPos: "right",
12
- labelSize: "",
13
- labelColor: "",
14
- space: "2px",
15
- imgMode: "",
16
- width: "",
17
- height: "",
8
+ index: '',
9
+ customPrefix: 'hy-icon',
10
+ label: '',
11
+ labelPos: 'right',
12
+ labelSize: '',
13
+ labelColor: '',
14
+ space: '2px',
15
+ imgMode: '',
16
+ width: '',
17
+ height: '',
18
18
  top: 0,
19
19
  stop: false,
20
20
  isRotate: false,
21
21
  round: 0,
22
- };
22
+ customClass: '',
23
+ }
23
24
 
24
- export default defaultProps;
25
+ export default defaultProps
@@ -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
  }
@@ -2,9 +2,9 @@
2
2
  <HyPopup
3
3
  mode="center"
4
4
  :zoom="zoom"
5
- :show="show"
5
+ :show="modelValue"
6
+ :round="round"
6
7
  :customStyle="{
7
- borderRadius: '6px',
8
8
  overflow: 'hidden',
9
9
  marginTop: `-${addUnit(negativeTop)}`,
10
10
  }"
@@ -32,53 +32,41 @@
32
32
  </text>
33
33
  </slot>
34
34
  </view>
35
- <view
36
- class="hy-modal__button-group--confirm-button"
37
- v-if="$slots.confirmButton"
38
- >
35
+ <view class="hy-modal__button-group--confirm-button" v-if="$slots.confirmButton">
39
36
  <slot name="confirmButton"></slot>
40
37
  </view>
41
38
  <template v-else>
42
39
  <view
43
- class="hy-modal__button-group"
40
+ :class="[
41
+ 'hy-modal__button-group',
42
+ showCancelButton &&
43
+ showConfirmButton &&
44
+ (!buttonReverse ? 'hy-modal__button-exact' : 'hy-modal__button-exact--reverse'),
45
+ ]"
44
46
  :style="{
45
47
  flexDirection: buttonReverse ? 'row-reverse' : 'row',
46
48
  }"
47
49
  >
48
50
  <view
49
- class="hy-modal__button-group__wrapper u-modal__button-group__wrapper--cancel"
51
+ class="hy-modal__button-group__wrapper hy-modal__button-group__wrapper--cancel"
50
52
  :hover-stay-time="150"
51
53
  hover-class="hy-modal__button-group__wrapper--hover"
52
- :class="[
53
- showCancelButton &&
54
- !showConfirmButton &&
55
- 'hy-modal__button-group__wrapper--only-cancel',
56
- ]"
57
54
  v-if="showCancelButton"
58
55
  @tap.stop="cancelHandler"
59
56
  >
60
57
  <text
61
- class="hy-modal__button-group__wrapper__text"
58
+ class="hy-modal__button-group__wrapper__text hy-modal__button-group__wrapper--cancel-text"
62
59
  :style="{
63
60
  color: cancelColor,
64
61
  }"
65
- >{{ cancelText }}</text
66
62
  >
63
+ {{ cancelText }}
64
+ </text>
67
65
  </view>
68
- <hy-line
69
- v-if="showConfirmButton && showCancelButton"
70
- length="48px"
71
- direction="column"
72
- ></hy-line>
73
66
  <view
74
67
  class="hy-modal__button-group__wrapper hy-modal__button-group__wrapper--confirm"
75
68
  :hover-stay-time="150"
76
69
  hover-class="hy-modal__button-group__wrapper--hover"
77
- :class="[
78
- !showCancelButton &&
79
- showConfirmButton &&
80
- 'hy-modal__button-group__wrapper--only-confirm',
81
- ]"
82
70
  v-if="showConfirmButton"
83
71
  @tap="confirmHandler"
84
72
  >
@@ -89,8 +77,9 @@
89
77
  :style="{
90
78
  color: confirmColor,
91
79
  }"
92
- >{{ confirmText }}</text
93
80
  >
81
+ {{ confirmText }}
82
+ </text>
94
83
  </view>
95
84
  </view>
96
85
  </template>
@@ -100,38 +89,37 @@
100
89
 
101
90
  <script lang="ts">
102
91
  export default {
103
- name: "hy-modal",
92
+ name: 'hy-modal',
104
93
  options: {
105
94
  addGlobalClass: true,
106
95
  virtualHost: true,
107
- styleIsolation: "shared",
96
+ styleIsolation: 'shared',
108
97
  },
109
- };
98
+ }
110
99
  </script>
111
100
 
112
101
  <script setup lang="ts">
113
- import { ref, toRefs, watch } from "vue";
114
- import defaultProps from "./props";
115
- import type IProps from "./typing";
116
- import { addUnit } from "../../utils";
102
+ import { ref, toRefs, watch } from 'vue'
103
+ import defaultProps from './props'
104
+ import type IProps from './typing'
105
+ import { addUnit } from '../../utils'
117
106
 
118
107
  // 组件
119
- import HyLine from "../hy-line/hy-line.vue";
120
- import HyPopup from "../hy-popup/hy-popup.vue";
121
- import HyLoading from "../hy-loading/hy-loading.vue";
108
+ import HyPopup from '../hy-popup/hy-popup.vue'
109
+ import HyLoading from '../hy-loading/hy-loading.vue'
122
110
 
123
- const props = withDefaults(defineProps<IProps>(), defaultProps);
124
- const { show, asyncClose, closeOnClickOverlay } = toRefs(props);
125
- const emit = defineEmits(["confirm", "cancel", "close", "update:show"]);
111
+ const props = withDefaults(defineProps<IProps>(), defaultProps)
112
+ const { modelValue, asyncClose, closeOnClickOverlay } = toRefs(props)
113
+ const emit = defineEmits(['confirm', 'cancel', 'close', 'update:modelValue'])
126
114
 
127
- const loading = ref<boolean>(false);
115
+ const loading = ref<boolean>(false)
128
116
 
129
117
  watch(
130
- () => show.value,
118
+ () => modelValue.value,
131
119
  (newValue) => {
132
- if (newValue && loading.value) loading.value = false;
120
+ if (newValue && loading.value) loading.value = false
133
121
  },
134
- );
122
+ )
135
123
 
136
124
  /**
137
125
  * @description 点击确定按钮
@@ -139,34 +127,34 @@ watch(
139
127
  const confirmHandler = () => {
140
128
  // 如果配置了异步关闭,将按钮值为loading状态
141
129
  if (asyncClose.value) {
142
- loading.value = true;
130
+ loading.value = true
143
131
  } else {
144
- emit("update:show", false);
132
+ emit('update:modelValue', false)
145
133
  }
146
- emit("confirm");
147
- };
134
+ emit('confirm')
135
+ }
148
136
 
149
137
  /**
150
138
  * @description 点击取消按钮
151
139
  * */
152
140
  const cancelHandler = () => {
153
- emit("update:show", false);
154
- emit("cancel");
155
- };
141
+ emit('update:modelValue', false)
142
+ emit('cancel')
143
+ }
156
144
 
157
145
  /**
158
146
  * @description 点击遮罩
159
147
  * */
160
148
  const clickHandler = () => {
161
149
  if (closeOnClickOverlay.value) {
162
- emit("update:show", false);
163
- emit("close");
150
+ emit('update:modelValue', false)
151
+ emit('close')
164
152
  }
165
- };
153
+ }
166
154
  </script>
167
155
 
168
156
  <style lang="scss" scoped>
169
- @import "./index.scss";
157
+ @import './index.scss';
170
158
  .modal__content__text {
171
159
  text-align: v-bind(contentTextAlign);
172
160
  }