hy-app 0.2.14 → 0.2.16
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-action-sheet/hy-action-sheet.vue +81 -13
- package/components/hy-action-sheet/typing.d.ts +1 -3
- package/components/hy-address-picker/hy-address-picker.vue +109 -8
- package/components/hy-address-picker/index.scss +2 -2
- package/components/hy-address-picker/typing.d.ts +39 -30
- package/components/hy-avatar/hy-avatar.vue +78 -4
- package/components/hy-avatar/typing.d.ts +21 -16
- package/components/hy-back-top/hy-back-top.vue +86 -28
- package/components/hy-back-top/typing.d.ts +17 -12
- package/components/hy-badge/hy-badge.vue +114 -43
- package/components/hy-badge/typing.d.ts +20 -15
- package/components/hy-button/hy-button.vue +22 -40
- package/components/hy-calendar/hy-calendar.vue +290 -143
- package/components/hy-calendar/typing.d.ts +38 -31
- package/components/hy-card/hy-card.vue +139 -36
- package/components/hy-card/typing.d.ts +39 -28
- package/components/hy-cell/hy-cell.vue +131 -67
- package/components/hy-cell/typing.d.ts +6 -1
- package/components/hy-check-button/hy-check-button.vue +101 -32
- package/components/hy-check-button/typing.d.ts +26 -19
- package/components/hy-checkbox/hy-checkbox.vue +167 -78
- package/components/hy-checkbox/typing.d.ts +26 -19
- package/components/hy-code-input/hy-code-input.vue +101 -5
- package/components/hy-code-input/typing.d.ts +9 -0
- package/components/hy-config-provider/hy-config-provider.vue +44 -24
- package/components/hy-config-provider/typing.d.ts +0 -4
- package/components/hy-count-down/hy-count-down.vue +99 -62
- package/components/hy-count-down/typing.d.ts +18 -5
- package/components/hy-count-to/hy-count-to.vue +165 -113
- package/components/hy-count-to/typing.d.ts +15 -11
- package/components/hy-datetime-picker/hy-datetime-picker.vue +338 -232
- package/components/hy-datetime-picker/typing.d.ts +49 -39
- package/components/hy-divider/hy-divider.vue +128 -64
- package/components/hy-divider/typing.d.ts +16 -16
- package/components/hy-dropdown/hy-dropdown.vue +57 -19
- package/components/hy-dropdown/typing.d.ts +14 -14
- package/components/hy-dropdown-item/hy-dropdown-item.vue +34 -5
- package/components/hy-dropdown-item/typing.d.ts +13 -6
- package/components/hy-empty/hy-empty.vue +64 -6
- package/components/hy-empty/typing.d.ts +5 -0
- package/components/hy-float-button/hy-float-button.vue +117 -5
- package/components/hy-float-button/typing.d.ts +7 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +87 -25
- package/components/hy-folding-panel/typing.d.ts +24 -15
- package/components/hy-grid/hy-grid.vue +95 -35
- package/components/hy-grid/typing.d.ts +24 -19
- package/components/hy-icon/hy-icon.vue +84 -6
- package/components/hy-icon/typing.d.ts +5 -0
- package/components/hy-image/hy-image.vue +105 -6
- package/components/hy-image/typing.d.ts +9 -0
- package/components/hy-input/hy-input.vue +277 -130
- package/components/hy-input/props.ts +13 -14
- package/components/hy-input/typing.d.ts +59 -38
- package/components/hy-line/hy-line.vue +65 -25
- package/components/hy-line-progress/hy-line-progress.vue +68 -35
- package/components/hy-list/hy-list.vue +127 -61
- package/components/hy-list/typing.d.ts +19 -12
- package/components/hy-loading/hy-loading.vue +79 -25
- package/components/hy-menu/hy-menu.vue +69 -45
- package/components/hy-menu/typing.d.ts +22 -15
- package/components/hy-modal/hy-modal.vue +91 -4
- package/components/hy-modal/typing.d.ts +11 -0
- package/components/hy-navbar/hy-navbar.vue +105 -25
- package/components/hy-navbar/typing.d.ts +25 -20
- package/components/hy-notice-bar/hy-notice-bar.vue +97 -19
- package/components/hy-notice-bar/typing.d.ts +22 -17
- package/components/hy-notify/hy-notify.vue +106 -54
- package/components/hy-number-step/hy-number-step.vue +211 -120
- package/components/hy-number-step/typing.d.ts +45 -28
- package/components/hy-overlay/hy-overlay.vue +60 -16
- package/components/hy-overlay/typing.d.ts +11 -6
- package/components/hy-pagination/hy-pagination.vue +94 -37
- package/components/hy-pagination/typing.d.ts +20 -11
- package/components/hy-picker/hy-picker.vue +225 -160
- package/components/hy-picker/typing.d.ts +51 -28
- package/components/hy-popover/hy-popover.vue +55 -7
- package/components/hy-popover/typing.d.ts +21 -1
- package/components/hy-popup/hy-popup.vue +164 -99
- package/components/hy-popup/typing.d.ts +11 -0
- package/components/hy-price/hy-price.vue +77 -30
- package/components/hy-price/typing.d.ts +10 -10
- package/components/hy-qrcode/hy-qrcode.vue +75 -5
- package/components/hy-qrcode/typing.d.ts +25 -16
- package/components/hy-radio/hy-radio.vue +169 -88
- package/components/hy-radio/typing.d.ts +29 -22
- package/components/hy-rate/hy-rate.vue +155 -104
- package/components/hy-rate/typing.d.ts +23 -16
- package/components/hy-read-more/hy-read-more.vue +83 -56
- package/components/hy-read-more/typing.d.ts +18 -11
- package/components/hy-scroll-list/hy-scroll-list.vue +69 -58
- package/components/hy-scroll-list/typing.d.ts +14 -7
- package/components/hy-search/hy-search.vue +168 -62
- package/components/hy-search/typing.d.ts +47 -26
- package/components/hy-signature/hy-signature.vue +354 -272
- package/components/hy-signature/typing.d.ts +65 -52
- package/components/hy-slider/hy-slider.vue +208 -160
- package/components/hy-slider/typing.d.ts +28 -17
- package/components/hy-steps/hy-steps.vue +125 -99
- package/components/hy-steps/typing.d.ts +21 -14
- package/components/hy-submit-bar/hy-submit-bar.vue +129 -48
- package/components/hy-submit-bar/typing.d.ts +30 -23
- package/components/hy-subsection/hy-subsection.vue +139 -96
- package/components/hy-subsection/typing.d.ts +23 -16
- package/components/hy-swipe-action/hy-swipe-action.vue +161 -135
- package/components/hy-swipe-action/typing.d.ts +26 -17
- package/components/hy-swiper/hy-swiper.vue +178 -73
- package/components/hy-swiper/typing.d.ts +37 -28
- package/components/hy-switch/hy-switch.vue +107 -60
- package/components/hy-switch/typing.d.ts +25 -18
- package/components/hy-tabs/hy-tabs.vue +170 -160
- package/components/hy-tabs/typing.d.ts +36 -22
- package/components/hy-tag/hy-tag.vue +133 -58
- package/components/hy-tag/typing.d.ts +26 -18
- package/components/hy-text/hy-text.vue +106 -6
- package/components/hy-text/typing.d.ts +31 -26
- package/components/hy-textarea/hy-textarea.vue +183 -89
- package/components/hy-textarea/typing.d.ts +41 -24
- package/components/hy-tooltip/hy-tooltip.vue +145 -101
- package/components/hy-tooltip/typing.d.ts +18 -13
- package/components/hy-transition/hy-transition.vue +48 -13
- package/components/hy-transition/typing.d.ts +17 -0
- package/components/hy-upload/hy-upload.vue +113 -148
- package/components/hy-upload/typing.d.ts +71 -71
- package/components/hy-warn/hy-warn.vue +79 -36
- package/components/hy-warn/typing.d.ts +18 -11
- package/components/hy-waterfall/hy-waterfall.vue +90 -77
- package/components/hy-watermark/hy-watermark.vue +82 -5
- package/components/hy-watermark/typing.d.ts +20 -20
- package/global.d.ts +39 -59
- package/package.json +4 -19
- package/utils/inspect.ts +3 -1
- package/web-types.json +1 -1
- package/compiler.ts +0 -108
- package/component-helper.ts +0 -179
- package/components.json +0 -3287
- package/docgen.config.js +0 -13
- package/web-types.config.js +0 -7
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
:class="['hy-cell--title', showVertical && 'hy-cell--title__vertical']"
|
|
5
5
|
v-if="title || $slots['title']"
|
|
6
6
|
>
|
|
7
|
+
<!-- @slot 标题插槽 -->
|
|
7
8
|
<slot name="title" :title="title">
|
|
8
9
|
<text class="hy-cell--title__text">{{ title }}</text>
|
|
9
10
|
</slot>
|
|
10
11
|
</view>
|
|
11
|
-
<view
|
|
12
|
-
|
|
13
|
-
:style="{ 'border-radius': addUnit(borderRadius) }"
|
|
14
|
-
>
|
|
12
|
+
<view class="hy-cell__body" :style="{ 'border-radius': addUnit(borderRadius) }">
|
|
13
|
+
<!-- @slot 整体插槽 -->
|
|
15
14
|
<slot>
|
|
16
15
|
<template v-for="(item, i) in list" :key="i">
|
|
17
16
|
<view
|
|
@@ -19,20 +18,18 @@
|
|
|
19
18
|
:hover-class="containerClass(item)"
|
|
20
19
|
:hover-stay-time="250"
|
|
21
20
|
:style="{
|
|
22
|
-
borderBottom:
|
|
23
|
-
border && i !== list.length - 1 ? '1rpx solid #c8c7cc66' : '',
|
|
21
|
+
borderBottom: border && i !== list.length - 1 ? '1rpx solid #c8c7cc66' : '',
|
|
24
22
|
}"
|
|
25
23
|
@tap="clickHandler($event, item, i)"
|
|
26
24
|
>
|
|
27
25
|
<view class="hy-cell__body--container__content">
|
|
28
26
|
<view class="hy-cell__body--container__content-icon">
|
|
27
|
+
<!-- @slot 图标插槽 -->
|
|
29
28
|
<slot name="icon" :icon="item?.icon">
|
|
30
29
|
<HyIcon
|
|
31
30
|
:size="iconSize"
|
|
32
31
|
:name="item?.icon?.name"
|
|
33
|
-
:color="
|
|
34
|
-
disabled || item?.disabled ? '#c0c0c0' : item?.icon?.color
|
|
35
|
-
"
|
|
32
|
+
:color="disabled || item?.disabled ? '#c0c0c0' : item?.icon?.color"
|
|
36
33
|
:bold="item?.icon?.bold"
|
|
37
34
|
:customPrefix="item?.icon?.customPrefix"
|
|
38
35
|
:imgMode="item?.icon?.imgMode"
|
|
@@ -47,21 +44,23 @@
|
|
|
47
44
|
</view>
|
|
48
45
|
<view class="hy-cell__body--container__content-title">
|
|
49
46
|
<!-- 将slot与默认内容用if/else分开主要是因为微信小程序不支持slot嵌套传递,这样才能解决collapse组件的slot不失效问题,label暂时未用到。 -->
|
|
47
|
+
<!-- @slot 列表标题插槽 -->
|
|
50
48
|
<slot name="cell-title" :title="item?.title">
|
|
51
49
|
<text
|
|
52
50
|
class="hy-cell__body--container__content-title--text"
|
|
53
|
-
:class="[
|
|
54
|
-
(disabled || item?.disabled) && 'hy-cell--disabled',
|
|
55
|
-
]"
|
|
56
|
-
>{{ item?.title }}</text
|
|
51
|
+
:class="[(disabled || item?.disabled) && 'hy-cell--disabled']"
|
|
57
52
|
>
|
|
53
|
+
{{ item?.title }}
|
|
54
|
+
</text>
|
|
58
55
|
</slot>
|
|
56
|
+
<!-- @slot 列表小标题插槽 -->
|
|
59
57
|
<slot name="sub" v-if="item?.subhead" :sub="item.subhead">
|
|
60
58
|
<text
|
|
61
59
|
class="hy-cell__body--container__content-title--sub"
|
|
62
60
|
:class="[disabled && 'hy-cell--disabled']"
|
|
63
|
-
>{{ item.subhead }}</text
|
|
64
61
|
>
|
|
62
|
+
{{ item.subhead }}
|
|
63
|
+
</text>
|
|
65
64
|
</slot>
|
|
66
65
|
</view>
|
|
67
66
|
</view>
|
|
@@ -69,58 +68,50 @@
|
|
|
69
68
|
class="hy-cell__body--container__center"
|
|
70
69
|
:style="{
|
|
71
70
|
justifyContent:
|
|
72
|
-
arrange === 'left'
|
|
73
|
-
? 'flex-start'
|
|
74
|
-
: arrange === 'right'
|
|
75
|
-
? 'flex-end'
|
|
76
|
-
: 'center',
|
|
71
|
+
arrange === 'left' ? 'flex-start' : arrange === 'right' ? 'flex-end' : 'center',
|
|
77
72
|
}"
|
|
78
73
|
>
|
|
74
|
+
<!-- @slot 值内容插槽 -->
|
|
79
75
|
<slot name="value" :record="item">
|
|
80
76
|
<text
|
|
81
77
|
class="hy-cell__body--container__center__value"
|
|
82
78
|
:class="[disabled && 'hy-cell--disabled']"
|
|
83
79
|
v-if="value || item?.value"
|
|
84
|
-
>{{ item.value || value }}</text
|
|
85
80
|
>
|
|
81
|
+
{{ item.value || value }}
|
|
82
|
+
</text>
|
|
86
83
|
</slot>
|
|
87
84
|
</view>
|
|
88
85
|
<view
|
|
89
86
|
class="hy-cell__body--container__right-icon"
|
|
90
87
|
:class="[
|
|
91
|
-
`hy-cell__body--container__right-icon--${
|
|
92
|
-
item?.arrowDirection || arrowDirection
|
|
93
|
-
}`,
|
|
88
|
+
`hy-cell__body--container__right-icon--${item?.arrowDirection || arrowDirection}`,
|
|
94
89
|
]"
|
|
95
90
|
>
|
|
91
|
+
<!-- @slot 右边按钮插槽 -->
|
|
96
92
|
<slot name="right-icon" :icon="item?.rightIcon || rightIcon">
|
|
97
93
|
<HyIcon
|
|
98
|
-
:name="
|
|
99
|
-
item?.rightIcon?.name || rightIcon?.name || IconConfig.RIGHT
|
|
100
|
-
"
|
|
94
|
+
:name="item?.rightIcon?.name || rightIcon?.name || IconConfig.RIGHT"
|
|
101
95
|
:color="
|
|
102
96
|
disabled || item?.disabled
|
|
103
97
|
? '#c0c0c0'
|
|
104
98
|
: item?.rightIcon?.color || rightIcon?.color
|
|
105
99
|
"
|
|
106
100
|
:bold="item?.rightIcon?.bold || rightIcon?.bold"
|
|
107
|
-
:customPrefix="
|
|
108
|
-
item?.rightIcon?.customPrefix || rightIcon?.customPrefix
|
|
109
|
-
"
|
|
101
|
+
:customPrefix="item?.rightIcon?.customPrefix || rightIcon?.customPrefix"
|
|
110
102
|
:imgMode="item?.rightIcon?.imgMode || rightIcon?.imgMode"
|
|
111
103
|
:width="item?.rightIcon?.width || rightIcon?.width"
|
|
112
104
|
:height="item?.rightIcon?.height || rightIcon?.height"
|
|
113
105
|
:top="item?.rightIcon?.top || rightIcon?.name"
|
|
114
106
|
:stop="item?.rightIcon?.stop || rightIcon?.stop"
|
|
115
107
|
:round="item?.rightIcon?.round || rightIcon?.round"
|
|
116
|
-
:customStyle="
|
|
117
|
-
item?.rightIcon?.customStyle || rightIcon?.customStyle
|
|
118
|
-
"
|
|
108
|
+
:customStyle="item?.rightIcon?.customStyle || rightIcon?.customStyle"
|
|
119
109
|
></HyIcon>
|
|
120
110
|
</slot>
|
|
121
111
|
</view>
|
|
122
112
|
</view>
|
|
123
113
|
|
|
114
|
+
<!-- @slot 底部插槽 -->
|
|
124
115
|
<slot name="bottom" :record="item" />
|
|
125
116
|
</template>
|
|
126
117
|
</slot>
|
|
@@ -129,28 +120,104 @@
|
|
|
129
120
|
</template>
|
|
130
121
|
|
|
131
122
|
<script lang="ts">
|
|
123
|
+
/**
|
|
124
|
+
* cell单元格一般用于一组列表的情况,比如个人中心页,设置页等
|
|
125
|
+
* @displayName hy-cell
|
|
126
|
+
*/
|
|
127
|
+
defineOptions({})
|
|
132
128
|
export default {
|
|
133
|
-
name:
|
|
129
|
+
name: 'hy-cell',
|
|
134
130
|
options: {
|
|
135
131
|
virtualHost: true,
|
|
136
|
-
styleIsolation:
|
|
132
|
+
styleIsolation: 'shared',
|
|
137
133
|
},
|
|
138
|
-
}
|
|
134
|
+
}
|
|
139
135
|
</script>
|
|
140
136
|
|
|
141
137
|
<script setup lang="ts">
|
|
142
|
-
import
|
|
143
|
-
import type
|
|
144
|
-
import type {
|
|
145
|
-
import {
|
|
138
|
+
import { computed, toRefs } from 'vue'
|
|
139
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
140
|
+
import type { ICellEmits } from './typing'
|
|
141
|
+
import type { CellContentVo } from './typing'
|
|
142
|
+
import { IconConfig } from '../../config'
|
|
143
|
+
import { addUnit } from '../../utils'
|
|
146
144
|
|
|
147
|
-
|
|
148
|
-
import
|
|
149
|
-
import
|
|
145
|
+
// 组件
|
|
146
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
147
|
+
import type HyIconProps from '../hy-icon/typing'
|
|
150
148
|
|
|
151
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
152
|
-
const
|
|
153
|
-
|
|
149
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
150
|
+
const props = defineProps({
|
|
151
|
+
/** cell列表数据 */
|
|
152
|
+
list: {
|
|
153
|
+
type: Array as unknown as PropType<Array<CellContentVo>>,
|
|
154
|
+
default: [],
|
|
155
|
+
required: true,
|
|
156
|
+
},
|
|
157
|
+
/** 头部标题 */
|
|
158
|
+
title: String,
|
|
159
|
+
/** 是否显示标题前缀竖线 */
|
|
160
|
+
showVertical: {
|
|
161
|
+
type: Boolean,
|
|
162
|
+
default: true,
|
|
163
|
+
},
|
|
164
|
+
/** 是否显示cell下边框 */
|
|
165
|
+
border: {
|
|
166
|
+
type: Boolean,
|
|
167
|
+
default: true,
|
|
168
|
+
},
|
|
169
|
+
/** 圆角 */
|
|
170
|
+
borderRadius: {
|
|
171
|
+
type: String,
|
|
172
|
+
default: '5px',
|
|
173
|
+
},
|
|
174
|
+
/** 是否禁用cell */
|
|
175
|
+
disabled: {
|
|
176
|
+
type: Boolean,
|
|
177
|
+
default: false,
|
|
178
|
+
},
|
|
179
|
+
/** 是否开启点击反馈(表现为点击时加上灰色背景) */
|
|
180
|
+
clickable: {
|
|
181
|
+
type: Boolean,
|
|
182
|
+
default: false,
|
|
183
|
+
},
|
|
184
|
+
/**
|
|
185
|
+
* 单元的大小
|
|
186
|
+
* @values large,medium,small
|
|
187
|
+
* */
|
|
188
|
+
size: {
|
|
189
|
+
type: String,
|
|
190
|
+
default: 'medium',
|
|
191
|
+
},
|
|
192
|
+
/** 右侧的内容 */
|
|
193
|
+
value: String,
|
|
194
|
+
/**
|
|
195
|
+
* 内容是否垂直居中(主要是针对右侧的value部分)
|
|
196
|
+
* @values left,center,right
|
|
197
|
+
* */
|
|
198
|
+
arrange: {
|
|
199
|
+
type: String,
|
|
200
|
+
default: 'right',
|
|
201
|
+
},
|
|
202
|
+
/** cell列表数据 */
|
|
203
|
+
rightIcon: {
|
|
204
|
+
type: Object as unknown as PropType<HyIconProps>,
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* 右侧箭头的方向
|
|
208
|
+
* @values left,up,down
|
|
209
|
+
* */
|
|
210
|
+
arrowDirection: {
|
|
211
|
+
type: String,
|
|
212
|
+
default: 'right',
|
|
213
|
+
},
|
|
214
|
+
/** 定义需要用到的外部样式 */
|
|
215
|
+
customStyle: {
|
|
216
|
+
type: Object as PropType<CSSProperties>,
|
|
217
|
+
},
|
|
218
|
+
})
|
|
219
|
+
const { size, disabled, clickable, borderRadius } = toRefs(props)
|
|
220
|
+
const emit = defineEmits<ICellEmits>()
|
|
154
221
|
|
|
155
222
|
/**
|
|
156
223
|
* @description 计算什么时候出现点击状态
|
|
@@ -161,45 +228,42 @@ const containerClass = computed(() => {
|
|
|
161
228
|
!disabled.value &&
|
|
162
229
|
!temp?.disabled &&
|
|
163
230
|
clickable.value &&
|
|
164
|
-
|
|
231
|
+
'hy-cell__body--container__clickable',
|
|
165
232
|
]
|
|
166
233
|
.filter(Boolean)
|
|
167
|
-
.join()
|
|
168
|
-
}
|
|
169
|
-
})
|
|
234
|
+
.join()
|
|
235
|
+
}
|
|
236
|
+
})
|
|
170
237
|
const ItemClass = computed(() => {
|
|
171
|
-
return [
|
|
172
|
-
|
|
173
|
-
`hy-cell__body--container__${size.value}`,
|
|
174
|
-
];
|
|
175
|
-
});
|
|
238
|
+
return ['hy-cell__body--container', `hy-cell__body--container__${size.value}`]
|
|
239
|
+
})
|
|
176
240
|
|
|
177
241
|
const iconSize = computed(() => {
|
|
178
242
|
switch (size.value) {
|
|
179
|
-
case
|
|
180
|
-
return 25
|
|
181
|
-
case
|
|
182
|
-
return 20
|
|
183
|
-
case
|
|
184
|
-
return 15
|
|
243
|
+
case 'large':
|
|
244
|
+
return 25
|
|
245
|
+
case 'medium':
|
|
246
|
+
return 20
|
|
247
|
+
case 'small':
|
|
248
|
+
return 15
|
|
185
249
|
}
|
|
186
|
-
})
|
|
250
|
+
})
|
|
187
251
|
|
|
188
252
|
/**
|
|
189
253
|
* @description 点击cell
|
|
190
254
|
* */
|
|
191
255
|
const clickHandler = (e: Event, temp: CellContentVo, index: number) => {
|
|
192
|
-
if (disabled.value) return
|
|
193
|
-
emit(
|
|
256
|
+
if (disabled.value) return
|
|
257
|
+
emit('click', temp, index)
|
|
194
258
|
if (temp?.url) {
|
|
195
259
|
uni.navigateTo({
|
|
196
260
|
url: temp.url,
|
|
197
|
-
})
|
|
261
|
+
})
|
|
198
262
|
}
|
|
199
|
-
e.stopPropagation()
|
|
200
|
-
}
|
|
263
|
+
e.stopPropagation()
|
|
264
|
+
}
|
|
201
265
|
</script>
|
|
202
266
|
|
|
203
267
|
<style lang="scss" scoped>
|
|
204
|
-
@import
|
|
268
|
+
@import './index.scss';
|
|
205
269
|
</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'vue'
|
|
2
|
-
import { HyApp } from '
|
|
2
|
+
import { HyApp } from '../../typing'
|
|
3
3
|
import type HyIconProps from '../hy-icon/typing'
|
|
4
4
|
|
|
5
5
|
export interface CellContentVo extends AnyObject {
|
|
@@ -90,3 +90,8 @@ export default interface HyCellProps {
|
|
|
90
90
|
* */
|
|
91
91
|
customStyle?: CSSProperties
|
|
92
92
|
}
|
|
93
|
+
|
|
94
|
+
export interface ICellEmits {
|
|
95
|
+
/** 点击行触发 */
|
|
96
|
+
(e: 'click', temp: CellContentVo, index: number): void
|
|
97
|
+
}
|
|
@@ -16,71 +16,140 @@
|
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
18
|
<script lang="ts">
|
|
19
|
+
/**
|
|
20
|
+
* 该组件内部实现以tag二次封装按钮复选框和单选框
|
|
21
|
+
* @displayName hy-check-button
|
|
22
|
+
*/
|
|
23
|
+
defineOptions({})
|
|
19
24
|
export default {
|
|
20
25
|
name: 'hy-check-button',
|
|
21
26
|
options: {
|
|
22
27
|
addGlobalClass: true,
|
|
23
28
|
virtualHost: true,
|
|
24
|
-
styleIsolation: 'shared'
|
|
25
|
-
}
|
|
29
|
+
styleIsolation: 'shared',
|
|
30
|
+
},
|
|
26
31
|
}
|
|
27
32
|
</script>
|
|
28
33
|
|
|
29
34
|
<script setup lang="ts">
|
|
30
|
-
import { toRefs, watch, ref } from
|
|
31
|
-
import
|
|
32
|
-
import type
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
+
import { toRefs, watch, ref, type PropType } from 'vue'
|
|
36
|
+
import type { ICheckButtonEmits, IFieldNames } from './typing'
|
|
37
|
+
import type { CheckboxColumnsVo } from './typing'
|
|
38
|
+
import HyTag from '../hy-tag/hy-tag.vue'
|
|
39
|
+
import { isArray } from '../../utils'
|
|
35
40
|
|
|
36
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
37
|
-
const
|
|
38
|
-
|
|
41
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
42
|
+
const props = defineProps({
|
|
43
|
+
/** 选中得值,selectTypeW为radio是字符串,为checkbox是数组 */
|
|
44
|
+
modelValue: {
|
|
45
|
+
type: [String, Number, Array<string | number>],
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
48
|
+
/** 选择列表数据 */
|
|
49
|
+
columns: {
|
|
50
|
+
type: Array as unknown as PropType<Array<CheckboxColumnsVo>>,
|
|
51
|
+
default: [],
|
|
52
|
+
required: true,
|
|
53
|
+
},
|
|
54
|
+
/** columns对应得键 */
|
|
55
|
+
fieldNames: {
|
|
56
|
+
type: Object as unknown as PropType<IFieldNames>,
|
|
57
|
+
default: {
|
|
58
|
+
label: 'label',
|
|
59
|
+
value: 'value',
|
|
60
|
+
checked: 'checked',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* 选择单选框还是复选框
|
|
65
|
+
* @values checkbox, radio
|
|
66
|
+
* */
|
|
67
|
+
selectType: {
|
|
68
|
+
type: String,
|
|
69
|
+
default: 'checkbox',
|
|
70
|
+
},
|
|
71
|
+
/** 禁用 */
|
|
72
|
+
disabled: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: true,
|
|
75
|
+
},
|
|
76
|
+
/** 每行几列,每列等宽 */
|
|
77
|
+
col: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: 'repeat(3, 1fr)',
|
|
80
|
+
},
|
|
81
|
+
/** 设置每行间距,需要加单位 */
|
|
82
|
+
gap: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: '10px',
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* 标签类型
|
|
88
|
+
* @values info,primary,success,warning,error
|
|
89
|
+
* */
|
|
90
|
+
type: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: 'primary',
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* 标签的大小
|
|
96
|
+
* @values small,medium,large
|
|
97
|
+
* */
|
|
98
|
+
size: {
|
|
99
|
+
type: String,
|
|
100
|
+
default: 'medium',
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* 标签的形状
|
|
104
|
+
* @values circle,square
|
|
105
|
+
* */
|
|
106
|
+
shape: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: 'square',
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
const { modelValue, columns, fieldNames, disabled, selectType } = toRefs(props)
|
|
112
|
+
const emit = defineEmits<ICheckButtonEmits>()
|
|
39
113
|
|
|
40
|
-
const isDisabled = (disabledVal?: boolean): boolean =>
|
|
41
|
-
disabled.value || !!disabledVal;
|
|
114
|
+
const isDisabled = (disabledVal?: boolean): boolean => disabled.value || !!disabledVal
|
|
42
115
|
|
|
43
|
-
const columns_1 = ref<CheckboxColumnsVo[]>()
|
|
116
|
+
const columns_1 = ref<CheckboxColumnsVo[]>()
|
|
44
117
|
|
|
45
118
|
watch(
|
|
46
119
|
() => modelValue.value,
|
|
47
120
|
(newValue: string | number | (string | number)[]) => {
|
|
48
|
-
if (!columns.value.length) return
|
|
121
|
+
if (!isArray(columns.value) || !columns.value.length) return
|
|
49
122
|
columns_1.value = columns.value.map((item) => {
|
|
50
|
-
if (
|
|
51
|
-
item[fieldNames.value.checked] = newValue.includes(
|
|
52
|
-
item[fieldNames.value.value] as string,
|
|
53
|
-
);
|
|
123
|
+
if (isArray(newValue)) {
|
|
124
|
+
item[fieldNames.value.checked] = newValue.includes(item[fieldNames.value.value] as string)
|
|
54
125
|
} else {
|
|
55
|
-
item[fieldNames.value.checked] =
|
|
56
|
-
newValue === item[fieldNames.value.value];
|
|
126
|
+
item[fieldNames.value.checked] = newValue === item[fieldNames.value.value]
|
|
57
127
|
}
|
|
58
|
-
return item
|
|
59
|
-
})
|
|
128
|
+
return item
|
|
129
|
+
})
|
|
60
130
|
},
|
|
61
131
|
{ immediate: true },
|
|
62
|
-
)
|
|
132
|
+
)
|
|
63
133
|
|
|
64
134
|
const onCheckbox = ({ name }: { name: number }) => {
|
|
65
|
-
if (selectType.value ===
|
|
66
|
-
columns.value[name][fieldNames.value.checked] =
|
|
67
|
-
!columns.value[name][fieldNames.value.checked];
|
|
135
|
+
if (selectType.value === 'checkbox') {
|
|
136
|
+
columns.value[name][fieldNames.value.checked] = !columns.value[name][fieldNames.value.checked]
|
|
68
137
|
emit(
|
|
69
|
-
|
|
138
|
+
'update:modelValue',
|
|
70
139
|
columns.value
|
|
71
140
|
.filter((item) => item[fieldNames.value.checked])
|
|
72
141
|
.map((item) => item[fieldNames.value.value]),
|
|
73
|
-
)
|
|
142
|
+
)
|
|
74
143
|
} else {
|
|
75
|
-
emit(
|
|
144
|
+
emit('update:modelValue', columns.value[name][fieldNames.value.value])
|
|
76
145
|
}
|
|
77
146
|
|
|
78
|
-
emit(
|
|
79
|
-
}
|
|
147
|
+
emit('change', columns.value[name])
|
|
148
|
+
}
|
|
80
149
|
</script>
|
|
81
150
|
|
|
82
151
|
<style lang="scss" scoped>
|
|
83
|
-
@import
|
|
152
|
+
@import '../../libs/css/mixin.scss';
|
|
84
153
|
@include b(check-button) {
|
|
85
154
|
display: grid;
|
|
86
155
|
grid-template-columns: v-bind(col);
|
|
@@ -2,78 +2,85 @@ export interface CheckboxColumnsVo extends FieldNamesType {
|
|
|
2
2
|
/**
|
|
3
3
|
* @description 显示文本内容
|
|
4
4
|
* */
|
|
5
|
-
label?: string
|
|
5
|
+
label?: string
|
|
6
6
|
/**
|
|
7
7
|
* @description 值
|
|
8
8
|
* */
|
|
9
|
-
value?: string | number
|
|
9
|
+
value?: string | number
|
|
10
10
|
/**
|
|
11
11
|
* @description 是否选中
|
|
12
12
|
* */
|
|
13
|
-
checked?: boolean
|
|
13
|
+
checked?: boolean
|
|
14
14
|
/**
|
|
15
15
|
* @description 是否禁用
|
|
16
16
|
* */
|
|
17
|
-
disabled?: boolean
|
|
17
|
+
disabled?: boolean
|
|
18
18
|
}
|
|
19
19
|
export interface IFieldNames {
|
|
20
20
|
/**
|
|
21
21
|
* @description 自定义columns的文本键
|
|
22
22
|
* */
|
|
23
|
-
label: string
|
|
23
|
+
label: string
|
|
24
24
|
/**
|
|
25
25
|
* @description 自定义columns的值键
|
|
26
26
|
* */
|
|
27
|
-
value: string
|
|
27
|
+
value: string
|
|
28
28
|
/**
|
|
29
29
|
* @description 自定义columns的选中键
|
|
30
30
|
* */
|
|
31
|
-
checked: string
|
|
31
|
+
checked: string
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export type FieldNamesType = {
|
|
35
|
-
[key in keyof IFieldNames as IFieldNames[key]]?: string | number | boolean
|
|
36
|
-
}
|
|
35
|
+
[key in keyof IFieldNames as IFieldNames[key]]?: string | number | boolean
|
|
36
|
+
}
|
|
37
37
|
|
|
38
38
|
export default interface HyCheckButtonProps {
|
|
39
39
|
/**
|
|
40
40
|
* @description 选中得值,radio是字符串,checkbox是数组
|
|
41
41
|
* */
|
|
42
|
-
modelValue: (string | number) | (string | number)[]
|
|
42
|
+
modelValue: (string | number) | (string | number)[]
|
|
43
43
|
/**
|
|
44
44
|
* @description 选择列表数据
|
|
45
45
|
* */
|
|
46
|
-
columns: CheckboxColumnsVo[]
|
|
46
|
+
columns: CheckboxColumnsVo[]
|
|
47
47
|
/**
|
|
48
48
|
* @description columns对应得键
|
|
49
49
|
* */
|
|
50
|
-
fieldNames?: IFieldNames
|
|
50
|
+
fieldNames?: IFieldNames
|
|
51
51
|
/**
|
|
52
52
|
* @description 选择单选框还是复选框
|
|
53
53
|
* */
|
|
54
|
-
selectType?:
|
|
54
|
+
selectType?: 'checkbox' | 'radio'
|
|
55
55
|
/**
|
|
56
56
|
* @description 禁用
|
|
57
57
|
* */
|
|
58
|
-
disabled?: boolean
|
|
58
|
+
disabled?: boolean
|
|
59
59
|
/**
|
|
60
60
|
* @description 每行几列,每列等宽
|
|
61
61
|
* */
|
|
62
|
-
col?: string
|
|
62
|
+
col?: string
|
|
63
63
|
/**
|
|
64
64
|
* @description 设置每行间距,需要加单位
|
|
65
65
|
* */
|
|
66
|
-
gap?: string
|
|
66
|
+
gap?: string
|
|
67
67
|
/**
|
|
68
68
|
* @description 标签类型info、primary、success、warning、error (默认 'primary' )
|
|
69
69
|
* */
|
|
70
|
-
type?: HyApp.ThemeType
|
|
70
|
+
type?: HyApp.ThemeType
|
|
71
71
|
/**
|
|
72
72
|
* @description 标签的大小,large,medium,small (默认 'medium' )
|
|
73
73
|
* */
|
|
74
|
-
size?: HyApp.SizeType
|
|
74
|
+
size?: HyApp.SizeType
|
|
75
75
|
/**
|
|
76
76
|
* @description tag的形状,circle(两边半圆形), square(方形,带圆角)(默认 'square' )
|
|
77
77
|
* */
|
|
78
|
-
shape?: HyApp.ShapeType
|
|
78
|
+
shape?: HyApp.ShapeType
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ICheckButtonEmits {
|
|
82
|
+
/** 选择触发 */
|
|
83
|
+
(e: 'change', value: any): void
|
|
84
|
+
/** 更新值触发 */
|
|
85
|
+
(e: 'update:modelValue', value: any): void
|
|
79
86
|
}
|