hy-app 0.4.12 → 0.4.15
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.
- package/components/hy-card/index.scss +1 -1
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +175 -0
- package/components/hy-coupon/index.scss +469 -0
- package/components/hy-coupon/props.ts +144 -0
- package/components/hy-coupon/typing.d.ts +136 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +85 -333
- package/components/hy-folding-panel/typing.d.ts +57 -68
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +278 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-qrcode/hy-qrcode.vue +2 -2
- package/components/hy-submit-bar/hy-submit-bar.vue +5 -5
- package/components/hy-submit-bar/typing.d.ts +26 -25
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
- package/components/hy-folding-panel/props.ts +0 -17
|
@@ -1,68 +1,57 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
customStyle?: CSSProperties
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface IFoldingPanel {
|
|
62
|
-
/** 打开面板触发 */
|
|
63
|
-
(e: 'open', temp: PanelVo, index: number): void
|
|
64
|
-
/** 关闭面板触发 */
|
|
65
|
-
(e: 'close', temp: PanelVo, index: number): void
|
|
66
|
-
/** 改成面板开关状态触发 */
|
|
67
|
-
(e: 'change', temp: PanelVo, index: number): void
|
|
68
|
-
}
|
|
1
|
+
import type { Ref, ToRefs } from "vue";
|
|
2
|
+
|
|
3
|
+
// 折叠面板组组件的Props接口
|
|
4
|
+
export interface HyFoldingPanelGroupProps {
|
|
5
|
+
/**
|
|
6
|
+
* 当前激活的面板索引,支持v-model
|
|
7
|
+
*/
|
|
8
|
+
modelValue?: number;
|
|
9
|
+
/**
|
|
10
|
+
* 是否手风琴模式,默认false
|
|
11
|
+
*/
|
|
12
|
+
accordion?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* 是否禁用整个折叠面板组
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 是否显示边框,默认true
|
|
19
|
+
*/
|
|
20
|
+
border?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 面板大小 large, medium, small
|
|
23
|
+
*/
|
|
24
|
+
size?: HyApp.SizeType;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 父组件提供给子组件的配置接口
|
|
28
|
+
export interface HyFoldingPanelGroupConfig extends ToRefs<HyFoldingPanelGroupProps> {
|
|
29
|
+
/**
|
|
30
|
+
* 当前激活的索引
|
|
31
|
+
*/
|
|
32
|
+
activeIndex: Ref<number | string>;
|
|
33
|
+
/**
|
|
34
|
+
* 更新激活索引的方法
|
|
35
|
+
*/
|
|
36
|
+
updateActiveIndex: (index: number | string) => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 折叠面板组组件的事件接口
|
|
40
|
+
export interface HyFoldingPanelGroupEmits {
|
|
41
|
+
/**
|
|
42
|
+
* v-model 同步事件
|
|
43
|
+
*/
|
|
44
|
+
(e: "update:modelValue", value: number | string): void;
|
|
45
|
+
/**
|
|
46
|
+
* 面板状态改变时触发
|
|
47
|
+
*/
|
|
48
|
+
(e: "change", index: number | string): void;
|
|
49
|
+
/**
|
|
50
|
+
* 面板打开时触发
|
|
51
|
+
*/
|
|
52
|
+
(e: "open", index: number | string): void;
|
|
53
|
+
/**
|
|
54
|
+
* 面板关闭时触发
|
|
55
|
+
*/
|
|
56
|
+
(e: "close", index: number | string): void;
|
|
57
|
+
}
|
|
@@ -1,228 +1,278 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
:
|
|
6
|
-
|
|
7
|
-
:
|
|
8
|
-
:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
index:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="hy-folding-panel-item"
|
|
4
|
+
:class="{
|
|
5
|
+
'hy-folding-panel-item--disabled':
|
|
6
|
+
groupConfig?.disabled?.value || disabled,
|
|
7
|
+
'is-active': isExpanded,
|
|
8
|
+
'hy-folding-panel-item--border': groupConfig?.border?.value,
|
|
9
|
+
}"
|
|
10
|
+
>
|
|
11
|
+
<!-- 面板头部 -->
|
|
12
|
+
<view
|
|
13
|
+
:class="[
|
|
14
|
+
'hy-folding-panel-item__header',
|
|
15
|
+
`hy-folding-panel-item--${groupConfig?.size?.value}`,
|
|
16
|
+
]"
|
|
17
|
+
@click="handleClick"
|
|
18
|
+
>
|
|
19
|
+
<slot v-if="$slots.header" name="header"></slot>
|
|
20
|
+
<template v-else>
|
|
21
|
+
<view class="hy-folding-panel-item__left">
|
|
22
|
+
<slot v-if="$slots.title" name="title"></slot>
|
|
23
|
+
<template v-else>
|
|
24
|
+
<!-- 图标 -->
|
|
25
|
+
<view v-if="icon" class="hy-folding-panel-item__icon">
|
|
26
|
+
<hy-icon
|
|
27
|
+
v-if="icon"
|
|
28
|
+
:src="icon"
|
|
29
|
+
:color="iconColor"
|
|
30
|
+
:size="iconSize"
|
|
31
|
+
/>
|
|
32
|
+
</view>
|
|
33
|
+
<!-- 标题 -->
|
|
34
|
+
<text class="hy-folding-panel-item__title">{{ title }}</text>
|
|
35
|
+
</template>
|
|
36
|
+
</view>
|
|
37
|
+
<view class="hy-folding-panel-item__right">
|
|
38
|
+
<!-- 右侧值 -->
|
|
39
|
+
<text v-if="value" class="hy-folding-panel-item__value">{{
|
|
40
|
+
value
|
|
41
|
+
}}</text>
|
|
42
|
+
<!-- 箭头 -->
|
|
43
|
+
<view
|
|
44
|
+
class="hy-folding-panel-item__arrow"
|
|
45
|
+
:class="{ 'hy-folding-panel-item__arrow--up': isExpanded }"
|
|
46
|
+
>
|
|
47
|
+
<hy-icon :name="IconConfig.DOWN"></hy-icon>
|
|
48
|
+
</view>
|
|
49
|
+
</view>
|
|
50
|
+
</template>
|
|
51
|
+
</view>
|
|
52
|
+
|
|
53
|
+
<!-- 面板内容 -->
|
|
54
|
+
<view
|
|
55
|
+
class="hy-folding-panel-item__content"
|
|
56
|
+
:style="[
|
|
57
|
+
customStyle,
|
|
58
|
+
{
|
|
59
|
+
height: isExpanded
|
|
60
|
+
? contentHeight
|
|
61
|
+
? addUnit(contentHeight)
|
|
62
|
+
: 'auto'
|
|
63
|
+
: '0px',
|
|
64
|
+
overflow: 'hidden',
|
|
65
|
+
},
|
|
66
|
+
]"
|
|
67
|
+
>
|
|
68
|
+
<slot v-if="$slots.default"></slot>
|
|
69
|
+
<text v-else>{{ content || "" }}</text>
|
|
70
|
+
</view>
|
|
71
|
+
</view>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script lang="ts">
|
|
75
|
+
export default {
|
|
76
|
+
name: "hy-folding-panel-item",
|
|
77
|
+
};
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<script setup lang="ts">
|
|
81
|
+
import { ref, computed, inject, onMounted } from "vue";
|
|
82
|
+
import type { CSSProperties, PropType } from "vue";
|
|
83
|
+
import type { HyFoldingPanelItemEmits } from "./typing";
|
|
84
|
+
import type { HyFoldingPanelGroupConfig } from "../hy-folding-panel/typing";
|
|
85
|
+
import { addUnit, IconConfig } from "../../libs";
|
|
86
|
+
|
|
87
|
+
// 组件
|
|
88
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 折叠面板项组件
|
|
92
|
+
* 用于展示可展开/折叠的单个面板项
|
|
93
|
+
* @displayName hy-folding-panel-item
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
const props = defineProps({
|
|
97
|
+
/**
|
|
98
|
+
* 面板索引(由父组件自动设置)
|
|
99
|
+
*/
|
|
100
|
+
index: {
|
|
101
|
+
type: [Number, String],
|
|
102
|
+
default: -1,
|
|
103
|
+
required: true,
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* 面板标题
|
|
107
|
+
*/
|
|
108
|
+
title: {
|
|
109
|
+
type: String,
|
|
110
|
+
default: "",
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* 右侧显示的值
|
|
114
|
+
*/
|
|
115
|
+
value: {
|
|
116
|
+
type: String,
|
|
117
|
+
default: "",
|
|
118
|
+
},
|
|
119
|
+
/**
|
|
120
|
+
* 左侧图标
|
|
121
|
+
*/
|
|
122
|
+
icon: {
|
|
123
|
+
type: String,
|
|
124
|
+
default: "",
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* 左侧图标颜色
|
|
128
|
+
*/
|
|
129
|
+
iconColor: {
|
|
130
|
+
type: String,
|
|
131
|
+
default: "",
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* 左侧图标大小
|
|
135
|
+
*/
|
|
136
|
+
iconSize: {
|
|
137
|
+
type: [Number, String],
|
|
138
|
+
default: "",
|
|
139
|
+
},
|
|
140
|
+
/**
|
|
141
|
+
* 面板内容
|
|
142
|
+
*/
|
|
143
|
+
content: {
|
|
144
|
+
type: String,
|
|
145
|
+
default: "",
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* 是否禁用
|
|
149
|
+
*/
|
|
150
|
+
disabled: {
|
|
151
|
+
type: Boolean,
|
|
152
|
+
default: false,
|
|
153
|
+
},
|
|
154
|
+
/**
|
|
155
|
+
* 默认是否展开
|
|
156
|
+
*/
|
|
157
|
+
defaultOpen: {
|
|
158
|
+
type: Boolean,
|
|
159
|
+
default: false,
|
|
160
|
+
},
|
|
161
|
+
/**
|
|
162
|
+
* 内容区域最大高度
|
|
163
|
+
*/
|
|
164
|
+
contentHeight: {
|
|
165
|
+
type: [Number, String],
|
|
166
|
+
default: 150,
|
|
167
|
+
},
|
|
168
|
+
/**
|
|
169
|
+
* 自定义样式
|
|
170
|
+
*/
|
|
171
|
+
customStyle: {
|
|
172
|
+
type: Object as PropType<CSSProperties>,
|
|
173
|
+
default: () => ({}),
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// 事件定义
|
|
178
|
+
const emit = defineEmits<HyFoldingPanelItemEmits>();
|
|
179
|
+
|
|
180
|
+
// 尝试从父组件注入配置
|
|
181
|
+
const groupConfig = inject<HyFoldingPanelGroupConfig>("hy-folding-panel");
|
|
182
|
+
|
|
183
|
+
// 内部展开状态
|
|
184
|
+
const expanded = ref(props.defaultOpen);
|
|
185
|
+
|
|
186
|
+
// 计算当前是否展开
|
|
187
|
+
const isExpanded = computed(() => {
|
|
188
|
+
if (groupConfig?.accordion?.value) {
|
|
189
|
+
console.log(groupConfig.activeIndex.value, props.index);
|
|
190
|
+
// 如果在group中,根据group的activeIndex判断
|
|
191
|
+
return groupConfig.activeIndex.value === props.index;
|
|
192
|
+
}
|
|
193
|
+
// 独立使用时,使用内部状态
|
|
194
|
+
return expanded.value;
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// 处理点击事件
|
|
198
|
+
const handleClick = () => {
|
|
199
|
+
if (props.disabled) return;
|
|
200
|
+
console.log(groupConfig?.accordion?.value);
|
|
201
|
+
|
|
202
|
+
if (groupConfig?.accordion?.value) {
|
|
203
|
+
// 在group中时,通知group更新激活索引
|
|
204
|
+
groupConfig.updateActiveIndex(props.index);
|
|
205
|
+
emit("child-click", props.index);
|
|
206
|
+
} else {
|
|
207
|
+
// 独立使用时,切换内部状态
|
|
208
|
+
expanded.value = !expanded.value;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 触发事件
|
|
212
|
+
emit("click", props.index);
|
|
213
|
+
if (isExpanded.value) {
|
|
214
|
+
emit("close", props.index);
|
|
215
|
+
} else {
|
|
216
|
+
emit("open", props.index);
|
|
217
|
+
}
|
|
218
|
+
emit("change", !isExpanded.value, props.index);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// 对外暴露的方法
|
|
222
|
+
defineExpose({
|
|
223
|
+
/**
|
|
224
|
+
* 打开面板
|
|
225
|
+
*/
|
|
226
|
+
open: () => {
|
|
227
|
+
if (props.disabled) return;
|
|
228
|
+
|
|
229
|
+
if (groupConfig) {
|
|
230
|
+
groupConfig.activeIndex.value = props.index;
|
|
231
|
+
} else {
|
|
232
|
+
expanded.value = true;
|
|
233
|
+
}
|
|
234
|
+
emit("open", props.index);
|
|
235
|
+
emit("change", true, props.index);
|
|
236
|
+
},
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 关闭面板
|
|
240
|
+
*/
|
|
241
|
+
close: () => {
|
|
242
|
+
if (groupConfig) {
|
|
243
|
+
if (groupConfig?.accordion?.value) {
|
|
244
|
+
groupConfig.activeIndex.value = -1;
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
expanded.value = false;
|
|
248
|
+
}
|
|
249
|
+
emit("close", props.index);
|
|
250
|
+
emit("change", false, props.index);
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* 切换面板状态
|
|
255
|
+
*/
|
|
256
|
+
toggle: () => {
|
|
257
|
+
handleClick();
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 获取当前展开状态
|
|
262
|
+
*/
|
|
263
|
+
getExpanded: () => {
|
|
264
|
+
return isExpanded.value;
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// 初始化时如果默认打开且在group中,通知group
|
|
269
|
+
onMounted(() => {
|
|
270
|
+
if (props.defaultOpen && groupConfig && props.index !== -1) {
|
|
271
|
+
groupConfig.updateActiveIndex(props.index);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
</script>
|
|
275
|
+
|
|
276
|
+
<style lang="scss" scoped>
|
|
277
|
+
@import "./index.scss";
|
|
278
|
+
</style>
|