hy-app 0.2.1 → 0.2.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.
Files changed (50) hide show
  1. package/components/hy-button/index.scss +4 -0
  2. package/components/hy-code-input/hy-code-input.vue +223 -0
  3. package/components/hy-code-input/index.scss +108 -0
  4. package/components/hy-code-input/props.ts +21 -0
  5. package/components/hy-code-input/typing.d.ts +65 -0
  6. package/components/hy-config-provider/hy-config-provider.vue +0 -1
  7. package/components/hy-dropdown/props.ts +1 -1
  8. package/components/hy-dropdown-item/hy-dropdown-item.vue +2 -5
  9. package/components/hy-dropdown-item/index.scss +11 -13
  10. package/components/hy-grid/hy-grid.vue +5 -5
  11. package/components/hy-icon/index.scss +1 -0
  12. package/components/hy-modal/hy-modal.vue +5 -5
  13. package/components/hy-modal/index.scss +0 -6
  14. package/components/hy-notify/hy-notify.vue +169 -0
  15. package/components/hy-notify/index.scss +25 -0
  16. package/components/hy-notify/props.ts +14 -0
  17. package/components/hy-notify/typing.d.ts +44 -0
  18. package/components/hy-pagination/hy-pagination.vue +125 -0
  19. package/components/hy-pagination/index.scss +46 -0
  20. package/components/hy-pagination/props.ts +15 -0
  21. package/components/hy-pagination/typing.d.ts +44 -0
  22. package/components/hy-picker/index.scss +4 -0
  23. package/components/hy-scroll-list/index.scss +1 -1
  24. package/components/hy-search/index.scss +1 -2
  25. package/components/hy-signature/canvasHelper.ts +51 -0
  26. package/components/hy-signature/hy-signature.vue +656 -0
  27. package/components/hy-signature/index.scss +31 -0
  28. package/components/hy-signature/props.ts +28 -0
  29. package/components/hy-signature/typing.d.ts +177 -0
  30. package/components/hy-slider/index.scss +5 -1
  31. package/components/hy-swipe-action/hy-swipe-action.vue +288 -248
  32. package/components/hy-swipe-action/index.scss +34 -0
  33. package/components/hy-swipe-action/index.ts +34 -0
  34. package/components/hy-swipe-action/props.ts +15 -9
  35. package/components/hy-swipe-action/typing.d.ts +20 -22
  36. package/components/hy-swiper/index.scss +5 -0
  37. package/components/hy-tabs/index.scss +2 -2
  38. package/components/hy-tag/index.scss +1 -1
  39. package/components/hy-textarea/hy-textarea.vue +5 -5
  40. package/components/hy-textarea/index.scss +5 -6
  41. package/components/hy-tooltip/index.scss +2 -2
  42. package/components/hy-upload/index.scss +1 -1
  43. package/composables/index.ts +1 -0
  44. package/composables/useTouch.ts +48 -0
  45. package/libs/css/mixin.scss +52 -13
  46. package/libs/css/vars.css +7 -1
  47. package/package.json +2 -2
  48. package/theme.scss +23 -46
  49. package/components/hy-swipe-action/index.wxs +0 -235
  50. package/components/hy-swipe-action/wxs.js +0 -15
@@ -1,6 +1,10 @@
1
1
  @use "../../libs/css/mixin.scss" as *;
2
2
  @use "../../theme.scss" as *;
3
3
 
4
+ uni-button {
5
+ margin: 0;
6
+ }
7
+
4
8
  @include b(button){
5
9
  height: 40px;
6
10
  position: relative;
@@ -0,0 +1,223 @@
1
+ <template>
2
+ <view class="hy-code-input">
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
+ ]"
10
+ :style="[itemStyle(index)]"
11
+ v-for="(item, index) in codeLength"
12
+ :key="index"
13
+ >
14
+ <view
15
+ class="hy-code-input--item__dot"
16
+ v-if="dot && current > index"
17
+ ></view>
18
+ <text
19
+ v-else
20
+ class="hy-code-input--item__text"
21
+ :style="{
22
+ fontSize: addUnit(fontSize),
23
+ fontWeight: bold ? 'bold' : 'normal',
24
+ color: color,
25
+ }"
26
+ >{{ codeArray[index] }}</text
27
+ >
28
+ </view>
29
+ <input
30
+ :disabled="disabledKeyboard"
31
+ type="number"
32
+ :focus="focus"
33
+ :value="inputValue"
34
+ :maxlength="maxlength"
35
+ :adjustPosition="adjustPosition"
36
+ class="hy-code-input__input"
37
+ @input="inputHandler"
38
+ :style="{
39
+ height: boxSize,
40
+ }"
41
+ @focus="isFocus = true"
42
+ @blur="isFocus = false"
43
+ />
44
+ </view>
45
+ </template>
46
+
47
+ <script lang="ts">
48
+ export default {
49
+ name: "hy-code-input",
50
+ options: {
51
+ addGlobalClass: true,
52
+ virtualHost: true,
53
+ styleIsolation: "shared",
54
+ },
55
+ };
56
+ </script>
57
+
58
+ <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";
71
+
72
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
73
+ const {
74
+ modelValue,
75
+ focus,
76
+ maxlength,
77
+ disabledDot,
78
+ size,
79
+ mode,
80
+ hairline,
81
+ space,
82
+ borderColor,
83
+ } = toRefs(props);
84
+ const emit = defineEmits(["change", "finish", "update:modelValue"]);
85
+
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);
94
+
95
+ watch(
96
+ () => modelValue.value,
97
+ (newValue: string | number) => {
98
+ inputValue.value = String(newValue).substring(0, maxlength.value);
99
+ current.value = newValue.toString().length;
100
+ },
101
+ { immediate: true },
102
+ );
103
+
104
+ watch(
105
+ () => isFocus.value,
106
+ (newValue) => {
107
+ // #ifdef APP-NVUE
108
+ if (newValue) {
109
+ timer = setInterval(() => {
110
+ opacity.value = Math.abs(opacity.value - 1);
111
+ }, 600);
112
+ } else {
113
+ clearInterval(timer);
114
+ }
115
+ // #endif
116
+ },
117
+ );
118
+
119
+ onUnmounted(() => {
120
+ // #ifdef APP-NVUE
121
+ clearInterval(timer);
122
+ // #endif
123
+ });
124
+
125
+ // 根据长度,循环输入框的个数,因为头条小程序数值不能用于v-for
126
+ const codeLength = computed(() => {
127
+ return new Array(Number(maxlength.value));
128
+ });
129
+ // 循环item的样式
130
+ const itemStyle = computed(() => {
131
+ return (index: number) => {
132
+ const style: CSSProperties = {
133
+ width: boxSize,
134
+ height: boxSize,
135
+ "--hy-border-color": borderColor.value,
136
+ };
137
+ // 盒子模式下,需要额外进行处理
138
+ if (mode.value === "box") {
139
+ // 设置盒子的边框,如果是细边框,则设置为1px宽度
140
+ style.borderWidth = borderWidth.value;
141
+ style.borderStyle = "solid";
142
+ style.borderColor = borderColor.value;
143
+ // 如果盒子间距为0的话
144
+ if (getPx(space.value) === 0) {
145
+ // 给第一和最后一个盒子设置圆角
146
+ if (index === 0) {
147
+ style.borderTopLeftRadius = "3px";
148
+ style.borderBottomLeftRadius = "3px";
149
+ }
150
+ if (index === codeLength.value.length - 1) {
151
+ style.borderTopRightRadius = "3px";
152
+ style.borderBottomRightRadius = "3px";
153
+ }
154
+ // 最后一个盒子的右边框需要保留
155
+ if (index !== codeLength.value.length - 1) {
156
+ style.borderRight = "none";
157
+ }
158
+ }
159
+ }
160
+ if (index !== codeLength.value.length - 1) {
161
+ // 设置验证码字符之间的距离,通过margin-right设置,最后一个字符,无需右边框
162
+ style.marginRight = addUnit(space.value);
163
+ } else {
164
+ // 最后一个盒子的有边框需要保留
165
+ style.marginRight = 0;
166
+ }
167
+
168
+ return style;
169
+ };
170
+ });
171
+
172
+ /**
173
+ * @description 将输入的值,转为数组,给item历遍时,根据当前的索引显示数组的元素
174
+ */
175
+ const codeArray = computed(() => {
176
+ return String(inputValue.value).split("");
177
+ });
178
+
179
+ /**
180
+ * @description 监听输入框的值发生变化
181
+ * */
182
+ const inputHandler = (e: any) => {
183
+ const value = e.detail.value;
184
+ inputValue.value = value;
185
+ // 是否允许输入“.”符号
186
+ if (disabledDot.value) {
187
+ nextTick(() => {
188
+ inputValue.value = value.replace(".", "");
189
+ });
190
+ }
191
+ // 未达到maxlength之前,发送change事件,达到后发送finish事件
192
+ emit("change", value);
193
+ // 修改通过v-model双向绑定的值
194
+ emit("update:modelValue", value);
195
+ // 达到用户指定输入长度时,发出完成事件
196
+ if (String(value).length >= Number(maxlength.value)) {
197
+ emit("finish", value);
198
+ }
199
+ };
200
+ </script>
201
+
202
+ <style scoped lang="scss">
203
+ @import "./index.scss";
204
+ @import "../../libs/css/mixin.scss";
205
+ @import "../../theme.scss";
206
+ @include b(code-input) {
207
+ @include m(item) {
208
+ &__box {
209
+ &__active {
210
+ width: v-bind(boxSize);
211
+ height: v-bind(boxSize);
212
+ border-width: v-bind(borderWidth);
213
+ }
214
+ }
215
+ &__line {
216
+ &::after {
217
+ height: v-bind(lineHeight);
218
+ background-color: var(--hy-border-color);
219
+ }
220
+ }
221
+ }
222
+ }
223
+ </style>
@@ -0,0 +1,108 @@
1
+ @use "../../theme.scss" as *;
2
+ @use "../../libs/css/mixin.scss" as *;
3
+
4
+ @include b(code-input) {
5
+ @include flex;
6
+ position: relative;
7
+ overflow: hidden;
8
+
9
+ @include m(item) {
10
+ @include flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ position: relative;
14
+
15
+ &__text {
16
+ font-size: 15px;
17
+ color: $hy-icon-color;
18
+ }
19
+
20
+ &__dot {
21
+ width: 7px;
22
+ height: 7px;
23
+ border-radius: 100px;
24
+ background-color: $hy-icon-color;
25
+ }
26
+
27
+ /* 方块模式 */
28
+ &__box {
29
+ border-color: $hy-border-color--2;
30
+ &__border {
31
+ border-color: $hy-primary !important;
32
+
33
+ @include b(code-input--item__dot) {
34
+ background-color: $hy-primary;
35
+ }
36
+
37
+ text {
38
+ color: $hy-primary;
39
+ }
40
+ }
41
+
42
+ &__active {
43
+ border-color: $hy-primary !important;
44
+ animation: 1.5s hy-cursor-flicker infinite;
45
+ }
46
+ }
47
+
48
+ /* 线条模式 */
49
+ &__line {
50
+ &::after {
51
+ content: "";
52
+ position: absolute;
53
+ bottom: 0;
54
+ border-radius: $hy-border-radius-semicircle;
55
+ width: 40px;
56
+ background-color: $hy-border-color--2;
57
+ }
58
+
59
+ /* 边框 */
60
+ &__border {
61
+ @include b(code-input--item__dot) {
62
+ background-color: $hy-primary;
63
+ }
64
+ &::after {
65
+ content: "";
66
+ background-color: $hy-primary !important;
67
+ }
68
+ text {
69
+ color: $hy-primary;
70
+ }
71
+ }
72
+
73
+ /* 状态 */
74
+ &__active {
75
+ &::after {
76
+ content: "";
77
+ background-color: $hy-primary !important;
78
+ animation: 1.5s hy-cursor-flicker infinite;
79
+ }
80
+ }
81
+ }
82
+ }
83
+
84
+ &__input {
85
+ // 之所以需要input输入框,是因为有它才能唤起键盘
86
+ // 这里将它设置为两倍的屏幕宽度,再将左边的一半移出屏幕,为了不让用户看到输入的内容
87
+ position: absolute;
88
+ left: -750rpx;
89
+ width: 1500rpx;
90
+ top: 0;
91
+ background-color: transparent;
92
+ text-align: left;
93
+ }
94
+ }
95
+
96
+ /* #ifndef APP-NVUE */
97
+ @keyframes hy-cursor-flicker {
98
+ 0% {
99
+ opacity: 0.2;
100
+ }
101
+ 50% {
102
+ opacity: 1;
103
+ }
104
+ 100% {
105
+ opacity: 0.2;
106
+ }
107
+ }
108
+ /* #endif */
@@ -0,0 +1,21 @@
1
+ import type IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ modelValue: "",
5
+ adjustPosition: true,
6
+ maxlength: 6,
7
+ dot: false,
8
+ mode: "box",
9
+ hairline: false,
10
+ space: 10,
11
+ focus: false,
12
+ bold: false,
13
+ color: "",
14
+ fontSize: 18,
15
+ size: 35,
16
+ disabledKeyboard: false,
17
+ borderColor: "",
18
+ disabledDot: true,
19
+ };
20
+
21
+ export default defaultProps;
@@ -0,0 +1,65 @@
1
+ import type { CSSProperties } from "vue";
2
+
3
+ export default interface HyOverlayProps {
4
+ modelValue: string | number;
5
+ /**
6
+ * @description 键盘弹起时,是否自动上推页面(默认 true )
7
+ * */
8
+ adjustPosition?: boolean;
9
+ /**
10
+ * @description 最大输入长度(默认 6 )
11
+ * */
12
+ maxlength?: number;
13
+ /**
14
+ * @description 是否用圆点填充(默认 false )
15
+ * */
16
+ dot?: boolean;
17
+ /**
18
+ * @description 显示模式,box-盒子模式,line-底部横线模式 (默认 'box' )
19
+ * */
20
+ mode?: "box" | string;
21
+ /**
22
+ * @description 是否细边框 (默认 false )
23
+ * */
24
+ hairline?: boolean;
25
+ /**
26
+ * @description 字符间的距离 (默认 10 )
27
+ * */
28
+ space?: number;
29
+ /**
30
+ * @description 是否自动获取焦点 (默认 false )
31
+ * */
32
+ focus?: boolean;
33
+ /**
34
+ * @description 字体是否加粗 (默认 false )
35
+ * */
36
+ bold?: boolean;
37
+ /**
38
+ * @description 字体颜色 (默认 '#606266' )
39
+ * */
40
+ color?: string;
41
+ /**
42
+ * @description 字体大小,单位px (默认 18 )
43
+ * */
44
+ fontSize?: number;
45
+ /**
46
+ * @description 输入框的大小,宽等于高 (默认 35 )
47
+ * */
48
+ size?: number | string;
49
+ /**
50
+ * @description 是否隐藏原生键盘,如果想用自定义键盘的话,需设置此参数为true (默认 false )
51
+ * */
52
+ disabledKeyboard?: boolean;
53
+ /**
54
+ * @description 边框和线条颜色 (默认 '#c9cacc' )
55
+ * */
56
+ borderColor?: string;
57
+ /**
58
+ * @description 是否禁止输入"."符号 (默认 true )
59
+ * */
60
+ disabledDot?: boolean;
61
+ /**
62
+ * @description 定义需要用到的外部样式
63
+ * */
64
+ customStyle?: CSSProperties;
65
+ }
@@ -37,7 +37,6 @@ const themeClass = computed(() => {
37
37
  });
38
38
 
39
39
  const themeStyle = computed(() => {
40
- console.log(colorGradient(themeColor.value)[90], themeColor.value);
41
40
  return [
42
41
  {
43
42
  "--hy-theme-color": themeColor.value,
@@ -3,7 +3,7 @@ import { IconConfig } from "@/package";
3
3
 
4
4
  const defaultProps: IProps = {
5
5
  activeColor: "",
6
- inactiveColor: "#606266",
6
+ inactiveColor: "",
7
7
  closeOnClickMask: true,
8
8
  sticky: true,
9
9
  height: 40,
@@ -1,10 +1,7 @@
1
1
  <template>
2
2
  <!-- 标题栏 -->
3
3
  <view
4
- :class="[
5
- 'hy-dropdown-item__header',
6
- isOpen && 'hy-dropdown-item__header--active',
7
- ]"
4
+ :class="['hy-dropdown-item__header', isOpen && 'is-active']"
8
5
  @click="handleClick"
9
6
  >
10
7
  <text
@@ -39,7 +36,7 @@
39
36
  <view
40
37
  :class="[
41
38
  'hy-dropdown-item__main--container__list-item',
42
- isOpen && 'hy-dropdown-item__main--container__list--active',
39
+ currentIndex === index && 'is-active',
43
40
  ]"
44
41
  v-for="(item, index) in menus"
45
42
  :key="item.value || index"
@@ -16,13 +16,12 @@
16
16
  position: relative;
17
17
  z-index: 999;
18
18
  background-color: $hy-background--container;
19
+ color: $hy-icon-color;
19
20
 
20
- @include m(active) {
21
+ @include is(active) {
21
22
  color: $hy-primary;
22
- :deep() {
23
- @include b(icon) {
24
- color: $hy-primary;
25
- }
23
+ :deep(.hy-icon) {
24
+ color: $hy-primary;
26
25
  }
27
26
  }
28
27
  }
@@ -57,14 +56,6 @@
57
56
  width: 100%;
58
57
  padding: 0 35rpx;
59
58
  box-sizing: border-box;
60
- &--active {
61
- color: $hy-primary;
62
- :deep() {
63
- @include b(icon) {
64
- color: $hy-primary;
65
- }
66
- }
67
- }
68
59
  &-item {
69
60
  width: 100%;
70
61
  padding: 30rpx 0;
@@ -72,6 +63,13 @@
72
63
  display: flex;
73
64
  align-items: center;
74
65
 
66
+ @include is(active) {
67
+ color: $hy-primary;
68
+ :deep(.hy-icon) {
69
+ color: $hy-primary;
70
+ }
71
+ }
72
+
75
73
  &:not(:last-of-type) {
76
74
  border-bottom: $hy-border-line;
77
75
  }
@@ -13,7 +13,7 @@
13
13
  :name="item?.icon"
14
14
  label-pos="bottom"
15
15
  :label="item?.name"
16
- :space="item?.iconConfig?.space || iconConfig?.space || 12"
16
+ :space="item?.iconConfig?.space || iconConfig?.space || 8"
17
17
  :color="item?.iconConfig?.color || iconConfig?.color"
18
18
  :size="item?.iconConfig?.size || iconConfig?.size || 30"
19
19
  :bold="item?.iconConfig?.bold || iconConfig?.bold"
@@ -37,13 +37,13 @@
37
37
 
38
38
  <script lang="ts">
39
39
  export default {
40
- name: 'hy-grid',
40
+ name: "hy-grid",
41
41
  options: {
42
42
  addGlobalClass: true,
43
43
  virtualHost: true,
44
- styleIsolation: 'shared'
45
- }
46
- }
44
+ styleIsolation: "shared",
45
+ },
46
+ };
47
47
  </script>
48
48
 
49
49
  <script setup lang="ts">
@@ -71,6 +71,7 @@
71
71
  line-height: 1;
72
72
  /* #endif */
73
73
  color: $hy-text-color--grey;
74
+ font-size: 12px;
74
75
  }
75
76
  }
76
77
  @include b(rotate) {
@@ -65,10 +65,11 @@
65
65
  >{{ cancelText }}</text
66
66
  >
67
67
  </view>
68
- <view
69
- class="hy-modal__button-group__wrapper--line"
68
+ <hy-line
70
69
  v-if="showConfirmButton && showCancelButton"
71
- ></view>
70
+ length="48px"
71
+ direction="column"
72
+ ></hy-line>
72
73
  <view
73
74
  class="hy-modal__button-group__wrapper hy-modal__button-group__wrapper--confirm"
74
75
  :hover-stay-time="150"
@@ -113,10 +114,9 @@ import { ref, toRefs, watch } from "vue";
113
114
  import defaultProps from "./props";
114
115
  import type IProps from "./typing";
115
116
  import { addUnit } from "../../utils";
116
- import { IconConfig } from "../../config";
117
117
 
118
118
  // 组件
119
- import HyIcon from "../hy-icon/hy-icon.vue";
119
+ import HyLine from "../hy-line/hy-line.vue";
120
120
  import HyPopup from "../hy-popup/hy-popup.vue";
121
121
  import HyLoading from "../hy-loading/hy-loading.vue";
122
122
 
@@ -47,12 +47,6 @@
47
47
  align-items: center;
48
48
  height: 48px;
49
49
 
50
- &--line {
51
- background: $hy-border-color;
52
- width: 1px;
53
- height: 48px;
54
- }
55
-
56
50
  &--confirm,
57
51
  &--only-cancel {
58
52
  border-bottom-right-radius: $hy-border-radius-base;