hy-app 0.2.2 → 0.2.5

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 (62) hide show
  1. package/components/hy-button/hy-button.vue +88 -120
  2. package/components/hy-button/index.scss +1 -3
  3. package/components/hy-calendar/index.scss +1 -1
  4. package/components/hy-cell/index.scss +2 -17
  5. package/components/hy-checkbox/index.scss +10 -10
  6. package/components/hy-code-input/hy-code-input.vue +85 -74
  7. package/components/hy-code-input/index.scss +31 -1
  8. package/components/hy-code-input/props.ts +8 -7
  9. package/components/hy-code-input/typing.d.ts +22 -18
  10. package/components/hy-config-provider/props.ts +1 -1
  11. package/components/hy-config-provider/typing.d.ts +7 -7
  12. package/components/hy-dropdown-item/hy-dropdown-item.vue +69 -75
  13. package/components/hy-dropdown-item/index.scss +1 -1
  14. package/components/hy-float-button/hy-float-button.vue +69 -86
  15. package/components/hy-form/index.scss +1 -1
  16. package/components/hy-grid/hy-grid.vue +2 -3
  17. package/components/hy-grid/props.ts +4 -0
  18. package/components/hy-grid/typing.d.ts +15 -0
  19. package/components/hy-icon/index.scss +2 -2
  20. package/components/hy-login/TheUserLogin.vue +0 -1
  21. package/components/hy-menu/hy-menu.vue +159 -0
  22. package/components/hy-menu/index.scss +58 -0
  23. package/components/hy-menu/props.ts +12 -0
  24. package/components/hy-menu/typing.d.ts +57 -0
  25. package/components/hy-navbar/index.scss +2 -2
  26. package/components/hy-notice-bar/index.scss +3 -3
  27. package/components/hy-notify/typing.d.ts +1 -1
  28. package/components/hy-pagination/typing.d.ts +1 -1
  29. package/components/hy-picker/hy-picker.vue +9 -8
  30. package/components/hy-picker/index.scss +6 -2
  31. package/components/hy-radio/index.scss +2 -2
  32. package/components/hy-scroll-list/index.scss +1 -1
  33. package/components/hy-signature/hy-signature.vue +50 -50
  34. package/components/hy-signature/index.scss +2 -4
  35. package/components/hy-signature/props.ts +2 -1
  36. package/components/hy-signature/typing.d.ts +5 -1
  37. package/components/hy-subsection/hy-subsection.vue +15 -13
  38. package/components/hy-subsection/props.ts +2 -2
  39. package/components/hy-subsection/typing.d.ts +1 -1
  40. package/components/hy-tabBar/hy-tabBar.vue +96 -0
  41. package/components/hy-tabBar/index.scss +169 -0
  42. package/components/hy-tabBar/props.ts +13 -0
  43. package/components/hy-tabBar/typing.d.ts +54 -0
  44. package/components/hy-text/hy-text.vue +76 -87
  45. package/components/hy-text/index.scss +8 -8
  46. package/components/hy-upload/index.scss +0 -1
  47. package/components/hy-watermark/hy-watermark.vue +583 -0
  48. package/components/hy-watermark/index.scss +17 -0
  49. package/components/hy-watermark/props.ts +23 -0
  50. package/components/hy-watermark/typing.d.ts +76 -0
  51. package/components/index.ts +2 -2
  52. package/index.scss +1 -1
  53. package/index.ts +1 -1
  54. package/libs/css/common.scss +9 -1
  55. package/libs/css/vars.css +5 -1
  56. package/package.json +2 -2
  57. package/theme.scss +8 -18
  58. package/typing/modules/common.d.ts +1 -1
  59. package/utils/inspect.ts +20 -0
  60. package/utils/utils.ts +52 -22
  61. package/components/yk-tabbar/props.ts +0 -49
  62. package/components/yk-tabbar/yk-tabbar.vue +0 -224
@@ -1,12 +1,7 @@
1
1
  <template>
2
2
  <view class="hy-code-input">
3
3
  <view
4
- :class="[
5
- 'hy-code-input--item',
6
- `hy-code-input--item__${mode}`,
7
- current > index && `hy-code-input--item__${mode}__border`,
8
- isFocus && current === index && `hy-code-input--item__${mode}__active`,
9
- ]"
4
+ :class="itemClass(index)"
10
5
  :style="[itemStyle(index)]"
11
6
  v-for="(item, index) in codeLength"
12
7
  :key="index"
@@ -14,6 +9,7 @@
14
9
  <view
15
10
  class="hy-code-input--item__dot"
16
11
  v-if="dot && current > index"
12
+ :style="{ color: color }"
17
13
  ></view>
18
14
  <text
19
15
  v-else
@@ -23,8 +19,9 @@
23
19
  fontWeight: bold ? 'bold' : 'normal',
24
20
  color: color,
25
21
  }"
26
- >{{ codeArray[index] }}</text
27
22
  >
23
+ {{ codeArray[index] }}
24
+ </text>
28
25
  </view>
29
26
  <input
30
27
  :disabled="disabledKeyboard"
@@ -46,60 +43,53 @@
46
43
 
47
44
  <script lang="ts">
48
45
  export default {
49
- name: "hy-code-input",
46
+ name: 'hy-code-input',
50
47
  options: {
51
48
  addGlobalClass: true,
52
49
  virtualHost: true,
53
- styleIsolation: "shared",
50
+ styleIsolation: 'shared',
54
51
  },
55
- };
52
+ }
56
53
  </script>
57
54
 
58
55
  <script setup lang="ts">
59
- import {
60
- computed,
61
- type CSSProperties,
62
- nextTick,
63
- onUnmounted,
64
- ref,
65
- toRefs,
66
- watch,
67
- } from "vue";
68
- import type IProps from "./typing";
69
- import defaultProps from "./props";
70
- import { addUnit, getPx } from "../../utils";
56
+ import { computed, type CSSProperties, nextTick, onUnmounted, ref, toRefs, watch } from 'vue'
57
+ import type IProps from './typing'
58
+ import defaultProps from './props'
59
+ import { addUnit, getPx } from '../../utils'
71
60
 
72
- const props = withDefaults(defineProps<IProps>(), defaultProps);
61
+ const props = withDefaults(defineProps<IProps>(), defaultProps)
73
62
  const {
74
63
  modelValue,
75
64
  focus,
76
65
  maxlength,
66
+ border,
77
67
  disabledDot,
78
68
  size,
79
69
  mode,
80
70
  hairline,
81
71
  space,
82
72
  borderColor,
83
- } = toRefs(props);
84
- const emit = defineEmits(["change", "finish", "update:modelValue"]);
73
+ } = toRefs(props)
74
+ const emit = defineEmits(['change', 'finish', 'update:modelValue'])
85
75
 
86
- const current = ref(0);
87
- const inputValue = ref("");
88
- const isFocus = ref(focus.value);
89
- let timer: ReturnType<typeof setInterval>;
90
- const opacity = ref(1);
91
- const borderWidth = computed(() => (hairline.value ? "0.5px" : "2px"));
92
- const lineHeight = computed(() => (hairline.value ? "2px" : "4px"));
93
- const boxSize = addUnit(size.value);
76
+ const current = ref(0)
77
+ const inputValue = ref('')
78
+ const isFocus = ref(focus.value)
79
+ let timer: ReturnType<typeof setInterval>
80
+ const opacity = ref(1)
81
+ const borderWidth = computed(() => (hairline.value ? '0.5px' : '2px'))
82
+ const lineHeight = computed(() => (hairline.value ? '2px' : '4px'))
83
+ const boxSize = addUnit(size.value)
94
84
 
95
85
  watch(
96
86
  () => modelValue.value,
97
87
  (newValue: string | number) => {
98
- inputValue.value = String(newValue).substring(0, maxlength.value);
99
- current.value = newValue.toString().length;
88
+ inputValue.value = String(newValue).substring(0, maxlength.value)
89
+ current.value = newValue.toString().length
100
90
  },
101
91
  { immediate: true },
102
- );
92
+ )
103
93
 
104
94
  watch(
105
95
  () => isFocus.value,
@@ -107,102 +97,123 @@ watch(
107
97
  // #ifdef APP-NVUE
108
98
  if (newValue) {
109
99
  timer = setInterval(() => {
110
- opacity.value = Math.abs(opacity.value - 1);
111
- }, 600);
100
+ opacity.value = Math.abs(opacity.value - 1)
101
+ }, 600)
112
102
  } else {
113
- clearInterval(timer);
103
+ clearInterval(timer)
114
104
  }
115
105
  // #endif
116
106
  },
117
- );
107
+ )
118
108
 
119
109
  onUnmounted(() => {
120
110
  // #ifdef APP-NVUE
121
- clearInterval(timer);
111
+ clearInterval(timer)
122
112
  // #endif
123
- });
113
+ })
124
114
 
125
115
  // 根据长度,循环输入框的个数,因为头条小程序数值不能用于v-for
126
116
  const codeLength = computed(() => {
127
- return new Array(Number(maxlength.value));
128
- });
117
+ return new Array(Number(maxlength.value))
118
+ })
129
119
  // 循环item的样式
130
120
  const itemStyle = computed(() => {
131
121
  return (index: number) => {
132
122
  const style: CSSProperties = {
133
123
  width: boxSize,
134
124
  height: boxSize,
135
- "--hy-border-color": borderColor.value,
136
- };
125
+ }
126
+ if (borderColor.value) {
127
+ style['--hy-border-color'] = borderColor.value
128
+ }
137
129
  // 盒子模式下,需要额外进行处理
138
- if (mode.value === "box") {
130
+ if (mode.value === 'box' && border.value) {
139
131
  // 设置盒子的边框,如果是细边框,则设置为1px宽度
140
- style.borderWidth = borderWidth.value;
141
- style.borderStyle = "solid";
142
- style.borderColor = borderColor.value;
132
+ style.borderWidth = borderWidth.value
133
+ style.borderStyle = 'solid'
134
+ style.borderColor = borderColor.value
143
135
  // 如果盒子间距为0的话
144
136
  if (getPx(space.value) === 0) {
145
137
  // 给第一和最后一个盒子设置圆角
146
138
  if (index === 0) {
147
- style.borderTopLeftRadius = "3px";
148
- style.borderBottomLeftRadius = "3px";
139
+ style.borderTopLeftRadius = '6px'
140
+ style.borderBottomLeftRadius = '6px'
149
141
  }
150
142
  if (index === codeLength.value.length - 1) {
151
- style.borderTopRightRadius = "3px";
152
- style.borderBottomRightRadius = "3px";
143
+ style.borderTopRightRadius = '6px'
144
+ style.borderBottomRightRadius = '6px'
153
145
  }
154
146
  // 最后一个盒子的右边框需要保留
155
147
  if (index !== codeLength.value.length - 1) {
156
- style.borderRight = "none";
148
+ style.borderRight = 'none'
157
149
  }
158
150
  }
159
151
  }
160
152
  if (index !== codeLength.value.length - 1) {
161
153
  // 设置验证码字符之间的距离,通过margin-right设置,最后一个字符,无需右边框
162
- style.marginRight = addUnit(space.value);
154
+ style.marginRight = addUnit(space.value)
163
155
  } else {
164
156
  // 最后一个盒子的有边框需要保留
165
- style.marginRight = 0;
157
+ style.marginRight = 0
166
158
  }
167
159
 
168
- return style;
169
- };
170
- });
160
+ return style
161
+ }
162
+ })
163
+
164
+ const itemClass = computed(() => {
165
+ return (index: number) => {
166
+ return [
167
+ 'hy-code-input--item',
168
+ border.value ? `hy-code-input--item__${mode.value}` : 'hy-code-input--item__not',
169
+ current.value > index &&
170
+ getPx(space.value) != 0 &&
171
+ border.value &&
172
+ `hy-code-input--item__${mode.value}__border`,
173
+ isFocus.value &&
174
+ current.value === index &&
175
+ getPx(space.value) != 0 &&
176
+ (border.value
177
+ ? `hy-code-input--item__${mode.value}__active`
178
+ : 'hy-code-input--item__not__active'),
179
+ ]
180
+ }
181
+ })
171
182
 
172
183
  /**
173
184
  * @description 将输入的值,转为数组,给item历遍时,根据当前的索引显示数组的元素
174
185
  */
175
186
  const codeArray = computed(() => {
176
- return String(inputValue.value).split("");
177
- });
187
+ return String(inputValue.value).split('')
188
+ })
178
189
 
179
190
  /**
180
191
  * @description 监听输入框的值发生变化
181
192
  * */
182
193
  const inputHandler = (e: any) => {
183
- const value = e.detail.value;
184
- inputValue.value = value;
194
+ const value = e.detail.value
195
+ inputValue.value = value
185
196
  // 是否允许输入“.”符号
186
197
  if (disabledDot.value) {
187
198
  nextTick(() => {
188
- inputValue.value = value.replace(".", "");
189
- });
199
+ inputValue.value = value.replace('.', '')
200
+ })
190
201
  }
191
202
  // 未达到maxlength之前,发送change事件,达到后发送finish事件
192
- emit("change", value);
203
+ emit('change', value)
193
204
  // 修改通过v-model双向绑定的值
194
- emit("update:modelValue", value);
205
+ emit('update:modelValue', value)
195
206
  // 达到用户指定输入长度时,发出完成事件
196
207
  if (String(value).length >= Number(maxlength.value)) {
197
- emit("finish", value);
208
+ emit('finish', value)
198
209
  }
199
- };
210
+ }
200
211
  </script>
201
212
 
202
213
  <style scoped lang="scss">
203
- @import "./index.scss";
204
- @import "../../libs/css/mixin.scss";
205
- @import "../../theme.scss";
214
+ @import './index.scss';
215
+ @import '../../libs/css/mixin.scss';
216
+ @import '../../theme.scss';
206
217
  @include b(code-input) {
207
218
  @include m(item) {
208
219
  &__box {
@@ -215,7 +226,7 @@ const inputHandler = (e: any) => {
215
226
  &__line {
216
227
  &::after {
217
228
  height: v-bind(lineHeight);
218
- background-color: var(--hy-border-color);
229
+ background-color: $hy-border-color;
219
230
  }
220
231
  }
221
232
  }
@@ -24,6 +24,22 @@
24
24
  background-color: $hy-icon-color;
25
25
  }
26
26
 
27
+ /* 无边框 */
28
+ &__not {
29
+ background-color: $hy-background--track;
30
+ border-radius: $hy-border-radius-sm;
31
+ &__active {
32
+ &:before {
33
+ content: "";
34
+ background-color: $hy-text-color;
35
+ width: 1.5px;
36
+ border-radius: 2px;
37
+ height: 50%;
38
+ animation: 1s hy-cursor-flicker--2 infinite;
39
+ }
40
+ }
41
+ }
42
+
27
43
  /* 方块模式 */
28
44
  &__box {
29
45
  border-color: $hy-border-color--2;
@@ -93,6 +109,20 @@
93
109
  }
94
110
  }
95
111
 
112
+ /* #ifndef APP-NVUE */
113
+ @keyframes hy-cursor-flicker--2 {
114
+ 0% {
115
+ opacity: 0;
116
+ }
117
+ 50% {
118
+ opacity: 1;
119
+ }
120
+ 100% {
121
+ opacity: 0;
122
+ }
123
+ }
124
+ /* #endif */
125
+
96
126
  /* #ifndef APP-NVUE */
97
127
  @keyframes hy-cursor-flicker {
98
128
  0% {
@@ -105,4 +135,4 @@
105
135
  opacity: 0.2;
106
136
  }
107
137
  }
108
- /* #endif */
138
+ /* #endif */
@@ -1,21 +1,22 @@
1
- import type IProps from "./typing";
1
+ import type IProps from './typing'
2
2
 
3
3
  const defaultProps: IProps = {
4
- modelValue: "",
4
+ modelValue: '',
5
5
  adjustPosition: true,
6
6
  maxlength: 6,
7
+ border: true,
7
8
  dot: false,
8
- mode: "box",
9
+ mode: 'box',
9
10
  hairline: false,
10
11
  space: 10,
11
12
  focus: false,
12
13
  bold: false,
13
- color: "",
14
+ color: '',
14
15
  fontSize: 18,
15
16
  size: 35,
16
17
  disabledKeyboard: false,
17
- borderColor: "",
18
+ borderColor: '',
18
19
  disabledDot: true,
19
- };
20
+ }
20
21
 
21
- export default defaultProps;
22
+ export default defaultProps
@@ -1,65 +1,69 @@
1
- import type { CSSProperties } from "vue";
1
+ import type { CSSProperties } from 'vue'
2
2
 
3
- export default interface HyOverlayProps {
4
- modelValue: string | number;
3
+ export default interface HyCodeInputProps {
4
+ modelValue: string | number
5
5
  /**
6
6
  * @description 键盘弹起时,是否自动上推页面(默认 true )
7
7
  * */
8
- adjustPosition?: boolean;
8
+ adjustPosition?: boolean
9
9
  /**
10
10
  * @description 最大输入长度(默认 6 )
11
11
  * */
12
- maxlength?: number;
12
+ maxlength?: number
13
+ /**
14
+ * @description 显示border
15
+ * */
16
+ border?: boolean
13
17
  /**
14
18
  * @description 是否用圆点填充(默认 false )
15
19
  * */
16
- dot?: boolean;
20
+ dot?: boolean
17
21
  /**
18
22
  * @description 显示模式,box-盒子模式,line-底部横线模式 (默认 'box' )
19
23
  * */
20
- mode?: "box" | string;
24
+ mode?: 'box' | string
21
25
  /**
22
26
  * @description 是否细边框 (默认 false )
23
27
  * */
24
- hairline?: boolean;
28
+ hairline?: boolean
25
29
  /**
26
30
  * @description 字符间的距离 (默认 10 )
27
31
  * */
28
- space?: number;
32
+ space?: number
29
33
  /**
30
34
  * @description 是否自动获取焦点 (默认 false )
31
35
  * */
32
- focus?: boolean;
36
+ focus?: boolean
33
37
  /**
34
38
  * @description 字体是否加粗 (默认 false )
35
39
  * */
36
- bold?: boolean;
40
+ bold?: boolean
37
41
  /**
38
42
  * @description 字体颜色 (默认 '#606266' )
39
43
  * */
40
- color?: string;
44
+ color?: string
41
45
  /**
42
46
  * @description 字体大小,单位px (默认 18 )
43
47
  * */
44
- fontSize?: number;
48
+ fontSize?: number
45
49
  /**
46
50
  * @description 输入框的大小,宽等于高 (默认 35 )
47
51
  * */
48
- size?: number | string;
52
+ size?: number | string
49
53
  /**
50
54
  * @description 是否隐藏原生键盘,如果想用自定义键盘的话,需设置此参数为true (默认 false )
51
55
  * */
52
- disabledKeyboard?: boolean;
56
+ disabledKeyboard?: boolean
53
57
  /**
54
58
  * @description 边框和线条颜色 (默认 '#c9cacc' )
55
59
  * */
56
- borderColor?: string;
60
+ borderColor?: string
57
61
  /**
58
62
  * @description 是否禁止输入"."符号 (默认 true )
59
63
  * */
60
- disabledDot?: boolean;
64
+ disabledDot?: boolean
61
65
  /**
62
66
  * @description 定义需要用到的外部样式
63
67
  * */
64
- customStyle?: CSSProperties;
68
+ customStyle?: CSSProperties
65
69
  }
@@ -5,7 +5,7 @@ const defaultProps: IProps = {
5
5
  theme: "light",
6
6
  themeColor: ColorConfig.primary,
7
7
  themeLightColor: "#ecf5ff",
8
- padding: "10px",
8
+ padding: "",
9
9
  customClass: "",
10
10
  customStyle: {},
11
11
  };
@@ -1,28 +1,28 @@
1
- import type { CSSProperties } from "vue";
1
+ import type { CSSProperties } from 'vue'
2
2
 
3
3
  export default interface HyConfigProviderProps {
4
4
  /**
5
5
  * @description dark-暗色、light-亮色
6
6
  * */
7
- theme?: HyApp.DarkModeType;
7
+ theme?: HyApp.DarkModeType
8
8
  /**
9
9
  * @description 主题色(默认 #3c9cff )
10
10
  * */
11
- themeColor?: string;
11
+ themeColor?: string
12
12
  /**
13
13
  * @description 主题色(默认 #ecf5ff )
14
14
  * */
15
- themeLightColor?: string;
15
+ themeLightColor?: string
16
16
  /**
17
17
  * @description 内边距(默认 10px )
18
18
  * */
19
- padding?: string;
19
+ padding?: string
20
20
  /**
21
21
  * @description 定义需要用到的主题类名
22
22
  * */
23
- customClass?: string | string[];
23
+ customClass?: string | string[]
24
24
  /**
25
25
  * @description 定义需要用到的外部样式
26
26
  * */
27
- customStyle?: CSSProperties;
27
+ customStyle?: CSSProperties | CSSProperties[]
28
28
  }