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
@@ -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 HyOverlayProps {
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
+ }
@@ -0,0 +1,125 @@
1
+ <template>
2
+ <view
3
+ class="hy-pagination"
4
+ :style="customStyle"
5
+ v-if="!(hideIfOnePage && totalPageNum === 1)"
6
+ >
7
+ <view class="hy-pagination__content">
8
+ <hy-button
9
+ :plain="modelValue > 1"
10
+ type="info"
11
+ size="small"
12
+ :disabled="modelValue <= 1"
13
+ shape="circle"
14
+ class="hy-pagination__nav"
15
+ @click="sub"
16
+ >
17
+ <text v-if="!showIcon">{{ prevText }}</text>
18
+ <hy-icon
19
+ v-else
20
+ :class="`hy-pagination__left hy-pagination__icon ${modelValue <= 1 ? 'hy-pagination__nav--disabled' : 'hy-pagination__nav--active'}`"
21
+ :name="IconConfig.LEFT"
22
+ ></hy-icon>
23
+ </hy-button>
24
+ <view class="hy-pagination__size">
25
+ <text class="hy-pagination__current">{{ modelValue }}</text>
26
+ <text class="hy-pagination__separator">/</text>
27
+ <text>{{ totalPageNum }}</text>
28
+ </view>
29
+ <hy-button
30
+ :plain="modelValue < totalPageNum"
31
+ type="info"
32
+ size="small"
33
+ :disabled="modelValue >= totalPageNum"
34
+ shape="circle"
35
+ @click="add"
36
+ >
37
+ <text v-if="!showIcon">{{ nextText }}</text>
38
+ <hy-icon
39
+ v-else
40
+ :custom-class="`hy-pagination__icon ${modelValue >= totalPageNum ? 'hy-pagination__nav--disabled' : 'hy-pagination__nav--active'}`"
41
+ :name="IconConfig.RIGHT"
42
+ ></hy-icon>
43
+ </hy-button>
44
+ </view>
45
+ <view class="hy-pagination__message" v-if="showMessage">
46
+ <text>当前页:{{ modelValue }},</text>
47
+ <text v-if="total">当前数据:{{ total }},</text>
48
+ <text>分页大小:{{ pageSize }}</text>
49
+ </view>
50
+ </view>
51
+ </template>
52
+
53
+ <script lang="ts">
54
+ export default {
55
+ name: "hy-pagination",
56
+ options: {
57
+ virtualHost: true,
58
+ addGlobalClass: true,
59
+ styleIsolation: "shared",
60
+ },
61
+ };
62
+ </script>
63
+
64
+ <script lang="ts" setup>
65
+ import HyIcon from "../hy-icon/hy-icon.vue";
66
+ import HyButton from "../hy-button/hy-button.vue";
67
+ import { ref, toRefs, watch } from "vue";
68
+ import type IProps from "./typing";
69
+ import defaultProps from "./props";
70
+ import { IconConfig } from "hy-app";
71
+
72
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
73
+ const { pageSize, totalPage } = toRefs(props);
74
+ const emit = defineEmits(["change", "update:modelValue"]);
75
+
76
+ const totalPageNum = ref<number>(0); // 总页数
77
+
78
+ watch(
79
+ () => totalPage.value,
80
+ (newValue) => {
81
+ if (!totalPageNum.value && newValue) {
82
+ totalPageNum.value = totalPageNum.value;
83
+ }
84
+ },
85
+ { immediate: true, deep: true },
86
+ );
87
+
88
+ watch(
89
+ () => props.total,
90
+ () => {
91
+ updateTotalPage();
92
+ },
93
+ { immediate: true, deep: true },
94
+ );
95
+
96
+ /**
97
+ * @description 加数
98
+ * */
99
+ const add = () => {
100
+ const { modelValue } = props;
101
+ if (modelValue > totalPageNum.value - 1) {
102
+ return;
103
+ }
104
+ emit("change", { value: modelValue + 1 });
105
+ emit("update:modelValue", modelValue + 1);
106
+ };
107
+
108
+ const sub = () => {
109
+ const { modelValue } = props;
110
+ if (modelValue < 2) {
111
+ return;
112
+ }
113
+ emit("change", { value: modelValue - 1 });
114
+ emit("update:modelValue", modelValue - 1);
115
+ };
116
+
117
+ function updateTotalPage() {
118
+ const { total, pageSize } = props;
119
+ totalPageNum.value = Math.ceil(total / pageSize);
120
+ }
121
+ </script>
122
+
123
+ <style lang="scss" scoped>
124
+ @import "./index.scss";
125
+ </style>
@@ -0,0 +1,46 @@
1
+ @use "../../theme.scss" as *;
2
+ @use "../../libs/css/mixin.scss" as *;
3
+
4
+
5
+ @include b(pagination) {
6
+ user-select: none;
7
+
8
+ //@include edeep(icon) {
9
+ // font-size: $-pagination-icon-size;
10
+ //}
11
+
12
+ @include e(content) {
13
+ display: flex;
14
+ justify-content: flex-start;
15
+ align-items: center;
16
+ padding: $hy-border-margin-padding-base;
17
+ }
18
+ @include e(message) {
19
+ text-align: center;
20
+ font-size: $hy-font-size-sm;
21
+ padding: 1px 0 16px 0;
22
+ }
23
+ &__nav {
24
+ min-width: 60px;
25
+ @include m(active){
26
+ color: rgba(0,0,0,0.65)
27
+ }
28
+ @include m(disabled){
29
+ color: rgba(0,0,0,0.15)
30
+ }
31
+ }
32
+ @include e(size){
33
+ flex: 1;
34
+ text-align: center;
35
+ font-size: $hy-font-size-sm;
36
+ }
37
+ @include e(separator){
38
+ padding: 0 4px;
39
+ }
40
+ &__left {
41
+ display: inline-block;
42
+ }
43
+ @include e(current){
44
+ color: $hy-primary;
45
+ }
46
+ }
@@ -0,0 +1,15 @@
1
+ import type IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ modelValue: 1,
5
+ totalPage: 1,
6
+ showIcon: false,
7
+ showMessage: false,
8
+ total: 0,
9
+ pageSize: 10,
10
+ prevText: "上一页",
11
+ nextText: "下一页",
12
+ hideIfOnePage: true,
13
+ };
14
+
15
+ export default defaultProps;
@@ -0,0 +1,44 @@
1
+ import type { CSSProperties } from "vue";
2
+
3
+ export default interface HyOverlayProps {
4
+ /**
5
+ * @description 当前页
6
+ */
7
+ modelValue: number;
8
+ /**
9
+ * @description 总页数,如果有total,则优先使用total计算页数
10
+ */
11
+ totalPage?: number;
12
+ /**
13
+ * @description 是否展示分页为Icon图标
14
+ */
15
+ showIcon?: boolean;
16
+ /**
17
+ * @desc 是否展示总条数
18
+ */
19
+ showMessage?: boolean;
20
+ /**
21
+ * @description 总条数
22
+ */
23
+ total?: number;
24
+ /**
25
+ * @description 每页条数
26
+ */
27
+ pageSize?: number;
28
+ /**
29
+ * @description 上一页文本
30
+ */
31
+ prevText?: string;
32
+ /**
33
+ * @description 下一页文本
34
+ */
35
+ nextText?: string;
36
+ /**
37
+ * @description 总页数只有一页时是否隐藏
38
+ */
39
+ hideIfOnePage?: boolean;
40
+ /**
41
+ * @description 定义需要用到的外部样式
42
+ * */
43
+ customStyle?: CSSProperties;
44
+ }
@@ -37,6 +37,10 @@
37
37
  flex: 1;
38
38
  justify-content: center;
39
39
 
40
+ :deep(.uni-picker-view-indicator) {
41
+ background: $hy-background--hover;
42
+ }
43
+
40
44
  &__item {
41
45
  @include flex;
42
46
  justify-content: center;
@@ -30,7 +30,7 @@
30
30
  height: 4px;
31
31
  border-radius: $hy-border-radius-semicircle;
32
32
  overflow: hidden;
33
- background-color: var(--hy-theme-color--light, $hy-border-color);
33
+ background-color: $hy-background--empty;
34
34
 
35
35
  &__bar {
36
36
  width: 20px;
@@ -33,8 +33,7 @@ $hy-search-close-size: 20px !default;
33
33
  }
34
34
 
35
35
  &__label {
36
- color:
37
- $hy-light-color;
36
+ color: $hy-text-color;
38
37
  font-size: $hy-font-size-base;
39
38
  margin: 0 4px;
40
39
  }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * 适配 canvas 2d 上下文
3
+ * @param ctx canvas 2d 上下文
4
+ * @returns
5
+ */
6
+ export function canvas2dAdapter(
7
+ ctx: CanvasRenderingContext2D,
8
+ ): UniApp.CanvasContext {
9
+ return Object.assign(ctx, {
10
+ setFillStyle(color: string | CanvasGradient) {
11
+ ctx.fillStyle = color;
12
+ },
13
+ setStrokeStyle(color: string | CanvasGradient | CanvasPattern) {
14
+ ctx.strokeStyle = color;
15
+ },
16
+ setLineWidth(lineWidth: number) {
17
+ ctx.lineWidth = lineWidth;
18
+ },
19
+ setLineCap(lineCap: "butt" | "round" | "square") {
20
+ ctx.lineCap = lineCap;
21
+ },
22
+
23
+ setFontSize(font: string) {
24
+ ctx.font = font;
25
+ },
26
+ setGlobalAlpha(alpha: number) {
27
+ ctx.globalAlpha = alpha;
28
+ },
29
+ setLineJoin(lineJoin: "bevel" | "round" | "miter") {
30
+ ctx.lineJoin = lineJoin;
31
+ },
32
+ setTextAlign(align: "left" | "center" | "right") {
33
+ ctx.textAlign = align;
34
+ },
35
+ setMiterLimit(miterLimit: number) {
36
+ ctx.miterLimit = miterLimit;
37
+ },
38
+ setShadow(offsetX: number, offsetY: number, blur: number, color: string) {
39
+ ctx.shadowOffsetX = offsetX;
40
+ ctx.shadowOffsetY = offsetY;
41
+ ctx.shadowBlur = blur;
42
+ ctx.shadowColor = color;
43
+ },
44
+ setTextBaseline(textBaseline: "top" | "bottom" | "middle") {
45
+ ctx.textBaseline = textBaseline;
46
+ },
47
+ createCircularGradient() {},
48
+ draw() {},
49
+ addColorStop() {},
50
+ }) as unknown as UniApp.CanvasContext;
51
+ }