hy-app 0.2.1 → 0.2.4

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 (78) hide show
  1. package/components/hy-button/index.scss +2 -0
  2. package/components/hy-cell/index.scss +0 -15
  3. package/components/hy-code-input/hy-code-input.vue +224 -0
  4. package/components/hy-code-input/index.scss +108 -0
  5. package/components/hy-code-input/props.ts +21 -0
  6. package/components/hy-code-input/typing.d.ts +65 -0
  7. package/components/hy-config-provider/hy-config-provider.vue +0 -1
  8. package/components/hy-config-provider/props.ts +1 -1
  9. package/components/hy-dropdown/props.ts +1 -1
  10. package/components/hy-dropdown-item/hy-dropdown-item.vue +2 -5
  11. package/components/hy-dropdown-item/index.scss +11 -13
  12. package/components/hy-grid/hy-grid.vue +7 -8
  13. package/components/hy-grid/props.ts +4 -0
  14. package/components/hy-grid/typing.d.ts +15 -0
  15. package/components/hy-icon/index.scss +2 -1
  16. package/components/hy-login/TheUserLogin.vue +0 -1
  17. package/components/hy-menu/hy-menu.vue +159 -0
  18. package/components/hy-menu/index.scss +58 -0
  19. package/components/hy-menu/props.ts +12 -0
  20. package/components/hy-menu/typing.d.ts +57 -0
  21. package/components/hy-modal/hy-modal.vue +5 -5
  22. package/components/hy-modal/index.scss +0 -6
  23. package/components/hy-notify/hy-notify.vue +169 -0
  24. package/components/hy-notify/index.scss +25 -0
  25. package/components/hy-notify/props.ts +14 -0
  26. package/components/hy-notify/typing.d.ts +44 -0
  27. package/components/hy-pagination/hy-pagination.vue +125 -0
  28. package/components/hy-pagination/index.scss +46 -0
  29. package/components/hy-pagination/props.ts +15 -0
  30. package/components/hy-pagination/typing.d.ts +44 -0
  31. package/components/hy-picker/index.scss +4 -0
  32. package/components/hy-scroll-list/index.scss +1 -1
  33. package/components/hy-search/index.scss +1 -2
  34. package/components/hy-signature/canvasHelper.ts +51 -0
  35. package/components/hy-signature/hy-signature.vue +656 -0
  36. package/components/hy-signature/index.scss +29 -0
  37. package/components/hy-signature/props.ts +29 -0
  38. package/components/hy-signature/typing.d.ts +181 -0
  39. package/components/hy-slider/index.scss +5 -1
  40. package/components/hy-subsection/hy-subsection.vue +15 -13
  41. package/components/hy-subsection/props.ts +2 -2
  42. package/components/hy-subsection/typing.d.ts +1 -1
  43. package/components/hy-swipe-action/hy-swipe-action.vue +288 -248
  44. package/components/hy-swipe-action/index.scss +34 -0
  45. package/components/hy-swipe-action/index.ts +34 -0
  46. package/components/hy-swipe-action/props.ts +15 -9
  47. package/components/hy-swipe-action/typing.d.ts +20 -22
  48. package/components/hy-swiper/index.scss +5 -0
  49. package/components/hy-tabBar/hy-tabBar.vue +96 -0
  50. package/components/hy-tabBar/index.scss +169 -0
  51. package/components/hy-tabBar/props.ts +13 -0
  52. package/components/hy-tabBar/typing.d.ts +54 -0
  53. package/components/hy-tabs/index.scss +2 -2
  54. package/components/hy-tag/index.scss +1 -1
  55. package/components/hy-text/index.scss +2 -2
  56. package/components/hy-textarea/hy-textarea.vue +5 -5
  57. package/components/hy-textarea/index.scss +5 -6
  58. package/components/hy-tooltip/index.scss +2 -2
  59. package/components/hy-upload/index.scss +1 -2
  60. package/components/hy-watermark/hy-watermark.vue +603 -0
  61. package/components/hy-watermark/index.scss +15 -0
  62. package/components/hy-watermark/props.ts +23 -0
  63. package/components/hy-watermark/typing.d.ts +76 -0
  64. package/components/index.ts +2 -2
  65. package/composables/index.ts +1 -0
  66. package/composables/useTouch.ts +48 -0
  67. package/index.ts +1 -1
  68. package/libs/css/mixin.scss +52 -13
  69. package/libs/css/vars.css +12 -2
  70. package/package.json +2 -2
  71. package/theme.scss +24 -46
  72. package/typing/modules/common.d.ts +1 -1
  73. package/utils/inspect.ts +20 -0
  74. package/utils/utils.ts +52 -22
  75. package/components/hy-swipe-action/index.wxs +0 -235
  76. package/components/hy-swipe-action/wxs.js +0 -15
  77. package/components/yk-tabbar/props.ts +0 -49
  78. package/components/yk-tabbar/yk-tabbar.vue +0 -224
@@ -0,0 +1,159 @@
1
+ <template>
2
+ <view class="hy-menu" :style="{ width: addUnit(width) }">
3
+ <template v-for="(item, i) in list">
4
+ <view
5
+ @click="handleClick(item, i)"
6
+ :class="menuItemClass(item, i)"
7
+ :style="customStyle"
8
+ >
9
+ <slot name="icon">
10
+ <hy-icon
11
+ class="hy-menu-item__icon"
12
+ :name="item.icon"
13
+ :color="current === i ? color || 'var(--hy-theme-color)' : ''"
14
+ :size="icon?.size || 16"
15
+ :bold="icon?.bold"
16
+ :customPrefix="icon?.customPrefix"
17
+ :imgMode="icon?.imgMode"
18
+ :width="icon?.width"
19
+ :height="icon?.height"
20
+ :top="icon?.top"
21
+ :stop="icon?.stop"
22
+ :round="icon?.round"
23
+ :customStyle="icon?.customStyle || { marginRight: '2px' }"
24
+ ></hy-icon>
25
+ </slot>
26
+ <slot>
27
+ <text class="hy-menu-item--title">{{ item.title }}</text>
28
+ </slot>
29
+ <hy-badge
30
+ :value="item?.badge"
31
+ :offset="badge?.offset"
32
+ :shape="badge?.shape"
33
+ :color="badge?.color"
34
+ :bg-color="badge?.bgColor"
35
+ :inverted="badge?.inverted"
36
+ :type="badge?.type"
37
+ :number-type="badge?.numberType"
38
+ :is-dot="badge?.isDot"
39
+ :absolute="badge?.absolute"
40
+ :max="badge?.max"
41
+ :show-zero="badge?.showZero"
42
+ :custom-style="badge?.customStyle"
43
+ >
44
+ </hy-badge>
45
+ </view>
46
+ </template>
47
+ </view>
48
+ </template>
49
+
50
+ <script lang="ts">
51
+ export default {
52
+ name: "hy-menu",
53
+ options: {
54
+ addGlobalClass: true,
55
+ virtualHost: true,
56
+ styleIsolation: "shared",
57
+ },
58
+ };
59
+ </script>
60
+
61
+ <script lang="ts" setup>
62
+ import { computed, ref, toRefs, watch } from "vue";
63
+ import type IProps from "./typing";
64
+ import type { MenusType } from "./typing";
65
+ import defaultProps from "./props";
66
+ import { addUnit } from "../../utils";
67
+
68
+ // 组件
69
+ import HyIcon from "../hy-icon/hy-icon.vue";
70
+ import HyBadge from "../hy-badge/hy-badge.vue";
71
+
72
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
73
+ const { modelValue, list, color } = toRefs(props);
74
+ const emit = defineEmits(["change", "update:modelValue"]);
75
+
76
+ const current = ref<string | number>(0);
77
+
78
+ watch(
79
+ () => modelValue.value,
80
+ (newVal: string | number) => {
81
+ current.value = list.value.findIndex((item) => item.id === newVal);
82
+ // current.value = newVal;
83
+ },
84
+ );
85
+
86
+ const menuItemClass = computed(() => {
87
+ return (temp: MenusType, i: number) => {
88
+ const classes = [
89
+ "hy-menu-item",
90
+ prefix.value && "hy-menu-item--prefix",
91
+ suffix.value && "hy-menu-item--suffix",
92
+ temp.disabled && "hy-menu-item--disabled",
93
+ ];
94
+ if (current.value === i) {
95
+ classes.push(
96
+ "hy-menu-item--active",
97
+ color.value && "hy-menu-item--active__color",
98
+ );
99
+ }
100
+
101
+ return classes;
102
+ };
103
+ });
104
+
105
+ const prefix = computed(() => {
106
+ // let prefix: boolean = false;
107
+ // if (sidebar) {
108
+ // let activeIndex: number = sidebar.children.findIndex((c: any) => {
109
+ // return c.value === sidebar.props.modelValue;
110
+ // });
111
+ //
112
+ // let currentIndex: number = sidebar.children.findIndex((c: any) => {
113
+ // return c.value === props.value;
114
+ // });
115
+ //
116
+ // if (currentIndex === activeIndex - 1) {
117
+ // prefix = true;
118
+ // }
119
+ // }
120
+ return prefix;
121
+ });
122
+
123
+ const suffix = computed(() => {
124
+ let suffix: boolean = false;
125
+ // if (sidebar) {
126
+ // let activeIndex: number = sidebar.children.findIndex((c: any) => {
127
+ // return c.value === sidebar.props.modelValue;
128
+ // });
129
+ //
130
+ // let currentIndex: number = sidebar.children.findIndex((c: any) => {
131
+ // return c.value === props.value;
132
+ // });
133
+ //
134
+ // if (currentIndex === activeIndex + 1) {
135
+ // suffix = true;
136
+ // }
137
+ // }
138
+ return suffix;
139
+ });
140
+
141
+ function handleClick(temp: MenusType, i: number) {
142
+ if (temp?.disabled) {
143
+ return;
144
+ }
145
+ current.value = i;
146
+ emit("update:modelValue", temp.id);
147
+ emit("change", temp);
148
+ }
149
+ </script>
150
+
151
+ <style lang="scss" scoped>
152
+ @import "./index.scss";
153
+ .hy-menu-item--active__color {
154
+ color: v-bind(color);
155
+ &::before {
156
+ background: v-bind(color);
157
+ }
158
+ }
159
+ </style>
@@ -0,0 +1,58 @@
1
+ @use "../../theme.scss" as *;
2
+ @use "../../libs/css/mixin.scss" as *;
3
+
4
+
5
+ @include b(menu) {
6
+ max-width: 260rpx;
7
+ background-color: $hy-background--track;
8
+
9
+ &-item {
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: flex-start;
13
+ position: relative;
14
+ padding: $hy-border-margin-padding-lg $hy-border-margin-padding-base;
15
+ //min-height: $-sidebar-item-height;
16
+ box-sizing: border-box;
17
+
18
+ &:active {
19
+ background-color: $hy-background--hover;
20
+ }
21
+
22
+ @include m(active) {
23
+ font-weight: 600;
24
+ background: $hy-background--active;
25
+ color: $hy-primary;
26
+
27
+ &::before {
28
+ content: "";
29
+ position: absolute;
30
+ top: 50%;
31
+ left: 0;
32
+ width: 4px;
33
+ height: 15px;
34
+ background: $hy-primary;
35
+ transform: translateY(-50%);
36
+ border-radius: $hy-border-radius-semicircle;
37
+ }
38
+
39
+ &:active {
40
+ background-color: transparent;
41
+ }
42
+ }
43
+ @include m(title) {
44
+ margin-left: 10rpx;
45
+ font-size: $hy-font-size-base;
46
+ line-height: $hy-font-size-base;
47
+ @include lineEllipsis;
48
+ position: relative;
49
+ }
50
+ @include m(disabled) {
51
+ color: $hy-text-color--disabled;
52
+ background-color: $hy-background--disabled;
53
+ cursor: not-allowed;
54
+
55
+ }
56
+
57
+ }
58
+ }
@@ -0,0 +1,12 @@
1
+ import type IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ modelValue: "",
5
+ list: [],
6
+ width: 120,
7
+ color: "",
8
+ icon: {},
9
+ badge: {},
10
+ };
11
+
12
+ export default defaultProps;
@@ -0,0 +1,57 @@
1
+ import type { CSSProperties } from "vue";
2
+ import type HyBadgeProps from "../hy-badge/typing";
3
+ import type HyIconProps from "../hy-icon/typing";
4
+
5
+ export interface MenusType {
6
+ /**
7
+ * @description 唯一id
8
+ * */
9
+ id: string | number;
10
+ /**
11
+ * @description 标题
12
+ * */
13
+ title: string;
14
+ /**
15
+ * @description 是否禁用
16
+ * */
17
+ disabled?: boolean;
18
+ /**
19
+ * @description icon
20
+ * */
21
+ icon?: string;
22
+ /**
23
+ * @description 徽标值
24
+ * */
25
+ badge?: number;
26
+ }
27
+
28
+ export default interface HyMenuProps {
29
+ /**
30
+ * @description 当前值
31
+ * */
32
+ modelValue: string | number;
33
+ /**
34
+ * @description 菜单数据集
35
+ * */
36
+ list: MenusType[];
37
+ /**
38
+ * @description 侧边菜单栏宽度
39
+ * */
40
+ width?: string | number;
41
+ /**
42
+ * @description 选中颜色
43
+ * */
44
+ color?: string;
45
+ /**
46
+ * @description 图标属性值
47
+ * */
48
+ icon?: Partial<HyIconProps>;
49
+ /**
50
+ * @description 徽标属性值
51
+ * */
52
+ badge?: Partial<HyBadgeProps>;
53
+ /**
54
+ * @description 定义需要用到的外部样式
55
+ * */
56
+ customStyle?: CSSProperties;
57
+ }
@@ -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;
@@ -0,0 +1,169 @@
1
+ <template>
2
+ <hy-transition mode="slide-down" :customStyle="containerStyle" :show="open">
3
+ <view
4
+ class="hy-notify"
5
+ :class="[`hy-notify--${tmpConfig?.type}`]"
6
+ :style="[backgroundColor, customStyle]"
7
+ >
8
+ <hy-status-bar v-if="tmpConfig?.safeAreaInsetTop"></hy-status-bar>
9
+ <view class="hy-notify--wrapper">
10
+ <slot name="icon">
11
+ <hy-icon
12
+ v-if="['success', 'warning', 'error'].includes(tmpConfig.type)"
13
+ :name="tmpConfig?.icon || icon"
14
+ :color="tmpConfig?.color"
15
+ :size="tmpConfig.fontSize"
16
+ :customStyle="{ marginRight: '4px' }"
17
+ ></hy-icon>
18
+ </slot>
19
+ <text
20
+ class="hy-notify--wrapper__text"
21
+ :style="{
22
+ fontSize: addUnit(tmpConfig?.fontSize),
23
+ color: tmpConfig?.color,
24
+ }"
25
+ >{{ tmpConfig?.message }}</text
26
+ >
27
+ </view>
28
+ </view>
29
+ </hy-transition>
30
+ </template>
31
+
32
+ <script lang="ts">
33
+ export default {
34
+ name: "hy-notify",
35
+ options: {
36
+ addGlobalClass: true,
37
+ virtualHost: true,
38
+ styleIsolation: "shared",
39
+ },
40
+ };
41
+ </script>
42
+
43
+ <script setup lang="ts">
44
+ import type IProps from "./typing";
45
+ import defaultProps from "./props";
46
+ import { computed, type CSSProperties, ref } from "vue";
47
+ import { addUnit } from "../../utils";
48
+ // 组件
49
+ import HyTransition from "../hy-transition/hy-transition.vue";
50
+ import HyStatusBar from "../hy-status-bar/hy-status-bar.vue";
51
+ import HyIcon from "../hy-icon/hy-icon.vue";
52
+ import { IconConfig } from "@/package";
53
+
54
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
55
+
56
+ const config = ref<IProps>({
57
+ // 到顶部的距离
58
+ top: props.top,
59
+ // type主题,primary,success,warning,error
60
+ type: props.type,
61
+ // 字体颜色
62
+ color: props.color,
63
+ // 背景颜色
64
+ bgColor: props.bgColor,
65
+ // 展示的文字内容
66
+ message: props.message,
67
+ // 展示时长,为0时不消失,单位ms
68
+ duration: props.duration,
69
+ // 字体大小
70
+ fontSize: props.fontSize,
71
+ // 是否留出顶部安全距离(状态栏高度)
72
+ safeAreaInsetTop: props.safeAreaInsetTop,
73
+ });
74
+ const tmpConfig = ref<IProps>({});
75
+ const open = ref(false);
76
+ let timer: ReturnType<typeof setTimeout>;
77
+
78
+ /**
79
+ * @description 容器样式
80
+ * */
81
+ const containerStyle = computed(() => {
82
+ let top = 0;
83
+ if (tmpConfig.value.top === 0) {
84
+ // #ifdef H5
85
+ // H5端,导航栏为普通元素,需要将组件移动到导航栏的下边沿
86
+ // H5的导航栏高度为44px
87
+ top = 44;
88
+ // #endif
89
+ }
90
+ const style: CSSProperties = {
91
+ top: addUnit(tmpConfig.value.top === 0 ? top : tmpConfig.value.top),
92
+ // 因为组件底层为hy-transition组件,必须将其设置为fixed定位
93
+ // 让其出现在导航栏底部
94
+ position: "fixed",
95
+ left: 0,
96
+ right: 0,
97
+ zIndex: 10076,
98
+ };
99
+ return style;
100
+ });
101
+ /**
102
+ * @description 组件背景颜色
103
+ */
104
+ const backgroundColor = computed(() => {
105
+ const style: CSSProperties = {};
106
+ if (tmpConfig.value.bgColor) {
107
+ style.backgroundColor = tmpConfig.value.bgColor;
108
+ }
109
+ return style;
110
+ });
111
+
112
+ /**
113
+ * @description 默认主题下的图标
114
+ * */
115
+ const icon = computed(() => {
116
+ let icon;
117
+ switch (tmpConfig.value.type) {
118
+ case "success":
119
+ return IconConfig.SUCCESS;
120
+ case "error":
121
+ return IconConfig.CLOSE_CIRCLE;
122
+ case "warning":
123
+ return IconConfig.NOTICE;
124
+ default:
125
+ return icon;
126
+ }
127
+ });
128
+
129
+ const show = (options: IProps) => {
130
+ // 不将结果合并到this.config变量,避免多次调用hy-toast,前后的配置造成混乱
131
+ tmpConfig.value = Object.assign(config.value, options);
132
+ // 任何定时器初始化之前,都要执行清除操作,否则可能会造成混乱
133
+ clearTimer();
134
+ open.value = true;
135
+ if (tmpConfig.value.duration && tmpConfig.value.duration! > 0) {
136
+ timer = setTimeout(() => {
137
+ open.value = false;
138
+ // 倒计时结束,清除定时器,隐藏toast组件
139
+ clearTimer();
140
+ // 判断是否存在callback方法,如果存在就执行
141
+ typeof tmpConfig.value.complete === "function" &&
142
+ tmpConfig.value.complete();
143
+ }, tmpConfig.value.duration);
144
+ }
145
+ };
146
+ /**
147
+ * @description 关闭notify
148
+ * */
149
+ const close = () => {
150
+ clearTimer();
151
+ };
152
+ /**
153
+ * @description 清除定时任务
154
+ * */
155
+ const clearTimer = () => {
156
+ open.value = false;
157
+ // 清除定时器
158
+ clearTimeout(timer);
159
+ };
160
+
161
+ defineExpose({
162
+ show,
163
+ close,
164
+ });
165
+ </script>
166
+
167
+ <style scoped lang="scss">
168
+ @import "./index.scss";
169
+ </style>
@@ -0,0 +1,25 @@
1
+ @use "../../theme.scss" as *;
2
+ @use "../../libs/css/mixin.scss" as *;
3
+
4
+
5
+ @include b(notify) {
6
+ padding: $hy-border-margin-padding-base;
7
+
8
+ @include m(wrapper) {
9
+ @include flex;
10
+ align-items: center;
11
+ text-align: center;
12
+ justify-content: center;
13
+
14
+ &__text {
15
+ font-size: $hy-font-size-base;
16
+ text-align: center;
17
+ }
18
+ }
19
+
20
+ @include themeColor(primary, $hy-primary);
21
+ @include themeColor(success, $hy-success);
22
+ @include themeColor(error, $hy-error);
23
+ @include themeColor(warning, $hy-warning);
24
+ @include themeColor(info, $hy-info);
25
+ }
@@ -0,0 +1,14 @@
1
+ import type IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ top: 0,
5
+ type: "primary",
6
+ color: "#ffffff",
7
+ bgColor: "",
8
+ message: "",
9
+ duration: 3000,
10
+ fontSize: 15,
11
+ safeAreaInsetTop: false,
12
+ };
13
+
14
+ export default defaultProps;
@@ -0,0 +1,44 @@
1
+ import type { CSSProperties } from "vue";
2
+
3
+ export default interface HyNotifyProps {
4
+ /**
5
+ * @description 到顶部的距离 ( 默认 0 )
6
+ * */
7
+ top?: number;
8
+ /**
9
+ * @description 主题,primary,success,warning,error ( 默认 'primary' )
10
+ * */
11
+ type?: HyApp.ThemeType;
12
+ /**
13
+ * @description 字体颜色 ( 默认 '#ffffff' )
14
+ * */
15
+ color?: string;
16
+ /**
17
+ * @description 背景颜色
18
+ * */
19
+ bgColor?: string;
20
+ /**
21
+ * @description 图标名称
22
+ * */
23
+ icon?: string;
24
+ /**
25
+ * @description 展示的文字内容
26
+ * */
27
+ message?: string;
28
+ /**
29
+ * @description 展示时长,为0时不消失,单位ms ( 默认 3000 )
30
+ * */
31
+ duration?: number;
32
+ /**
33
+ * @description 字体大小 ( 默认 15 )
34
+ * */
35
+ fontSize?: number;
36
+ /**
37
+ * @description 是否留出顶部安全距离(状态栏高度) ( 默认 false )
38
+ * */
39
+ safeAreaInsetTop?: boolean;
40
+ /**
41
+ * @description 定义需要用到的外部样式
42
+ * */
43
+ customStyle?: CSSProperties;
44
+ }