hy-app 0.4.13 → 0.5.0
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 +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- 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
|
@@ -1,283 +1,200 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
>
|
|
14
|
-
<view
|
|
15
|
-
:class="`hy-action-sheet ${customClass}`"
|
|
16
|
-
:style="`${
|
|
17
|
-
(actions && actions.length) || (panels && panels.length)
|
|
18
|
-
? 'margin: 0 10px calc(var(--window-bottom) + 10px) 10px; border-radius: 16px;'
|
|
19
|
-
: 'margin-bottom: var(--window-bottom);'
|
|
20
|
-
} ${customStyle}`"
|
|
21
|
-
>
|
|
22
|
-
<!-- 标题 -->
|
|
23
|
-
<view
|
|
24
|
-
v-if="title"
|
|
25
|
-
:class="`hy-action-sheet__header ${customHeaderClass}`"
|
|
2
|
+
<view>
|
|
3
|
+
<hy-popup
|
|
4
|
+
:show="showPopup"
|
|
5
|
+
:duration="duration"
|
|
6
|
+
mode="bottom"
|
|
7
|
+
:close-on-click-overlay="closeOnClickOverlay"
|
|
8
|
+
:safe-area-inset-bottom="safeAreaInsetBottom"
|
|
9
|
+
@open="onOpen"
|
|
10
|
+
@close="onClose"
|
|
11
|
+
:z-index="zIndex"
|
|
12
|
+
:round="round"
|
|
26
13
|
>
|
|
27
|
-
{{ title }}
|
|
28
|
-
<HyIcon
|
|
29
|
-
customClass="hy-action-sheet__close"
|
|
30
|
-
class="hy-action-sheet__close"
|
|
31
|
-
name="close"
|
|
32
|
-
@click="onClose"
|
|
33
|
-
/>
|
|
34
|
-
</view>
|
|
35
|
-
<!-- 标题 -->
|
|
36
|
-
|
|
37
|
-
<!-- 选项卡 -->
|
|
38
|
-
<view class="hy-action-sheet__actions" v-if="actions && actions.length">
|
|
39
|
-
<view
|
|
40
|
-
v-for="(action, rowIndex) in actions"
|
|
41
|
-
:key="rowIndex"
|
|
42
|
-
:class="`hy-action-sheet__action ${
|
|
43
|
-
action?.disabled ? 'hy-action-sheet__action--disabled' : ''
|
|
44
|
-
} ${action?.loading ? 'hy-action-sheet__action--loading' : ''}`"
|
|
45
|
-
:style="`color: ${action?.color}`"
|
|
46
|
-
@click="onSelect(rowIndex, 'action')"
|
|
47
|
-
>
|
|
48
|
-
<HyLoading :show="!!action?.loading" mode="circle" />
|
|
49
|
-
<view v-if="!action?.loading" class="hy-action-sheet__name">{{
|
|
50
|
-
action?.name
|
|
51
|
-
}}</view>
|
|
52
14
|
<view
|
|
53
|
-
|
|
54
|
-
|
|
15
|
+
:class="`hy-action-sheet ${customClass}`"
|
|
16
|
+
:style="`${
|
|
17
|
+
(actions && actions.length) || (panels && panels.length)
|
|
18
|
+
? 'margin: 0 10px calc(var(--window-bottom) + 10px) 10px; border-radius: 16px;'
|
|
19
|
+
: 'margin-bottom: var(--window-bottom);'
|
|
20
|
+
} ${customStyle}`"
|
|
55
21
|
>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
22
|
+
<!-- 标题 -->
|
|
23
|
+
<view v-if="title" :class="`hy-action-sheet__header ${customHeaderClass}`">
|
|
24
|
+
{{ title }}
|
|
25
|
+
<hy-icon
|
|
26
|
+
customClass="hy-action-sheet__close"
|
|
27
|
+
class="hy-action-sheet__close"
|
|
28
|
+
name="close"
|
|
29
|
+
@click="onClose"
|
|
30
|
+
/>
|
|
31
|
+
</view>
|
|
32
|
+
<!-- 标题 -->
|
|
61
33
|
|
|
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
|
-
</view>
|
|
87
|
-
<!-- 自定义面板 -->
|
|
34
|
+
<!-- 选项卡 -->
|
|
35
|
+
<view class="hy-action-sheet__actions" v-if="actions && actions.length">
|
|
36
|
+
<view
|
|
37
|
+
v-for="(action, rowIndex) in actions"
|
|
38
|
+
:key="rowIndex"
|
|
39
|
+
:class="`hy-action-sheet__action ${
|
|
40
|
+
action?.disabled ? 'hy-action-sheet__action--disabled' : ''
|
|
41
|
+
} ${action?.loading ? 'hy-action-sheet__action--loading' : ''}`"
|
|
42
|
+
:style="`color: ${action?.color}`"
|
|
43
|
+
@click="onSelect(rowIndex, 'action')"
|
|
44
|
+
>
|
|
45
|
+
<hy-loading :show="!!action?.loading" mode="circle" />
|
|
46
|
+
<view v-if="!action?.loading" class="hy-action-sheet__name">{{
|
|
47
|
+
action?.name
|
|
48
|
+
}}</view>
|
|
49
|
+
<view
|
|
50
|
+
v-if="!action?.loading && action?.sub"
|
|
51
|
+
class="hy-action-sheet__subname"
|
|
52
|
+
>
|
|
53
|
+
{{ action?.sub }}
|
|
54
|
+
</view>
|
|
55
|
+
</view>
|
|
56
|
+
</view>
|
|
57
|
+
<!-- 选项卡 -->
|
|
88
58
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
59
|
+
<!-- 自定义面板 -->
|
|
60
|
+
<view v-if="formatPanels && formatPanels.length">
|
|
61
|
+
<view
|
|
62
|
+
v-for="(panel, rowIndex) in formatPanels"
|
|
63
|
+
:key="rowIndex"
|
|
64
|
+
class="hy-action-sheet__panels"
|
|
65
|
+
>
|
|
66
|
+
<view class="hy-action-sheet__panels-content">
|
|
67
|
+
<view
|
|
68
|
+
v-for="(col, colIndex) in panel"
|
|
69
|
+
:key="colIndex"
|
|
70
|
+
class="hy-action-sheet__panel"
|
|
71
|
+
@click="onSelect(rowIndex, 'panels', colIndex)"
|
|
72
|
+
>
|
|
73
|
+
<image
|
|
74
|
+
class="hy-action-sheet__panel-img"
|
|
75
|
+
:src="(col as any).iconUrl"
|
|
76
|
+
/>
|
|
77
|
+
<view class="hy-action-sheet__panel-title">{{
|
|
78
|
+
(col as any).name
|
|
79
|
+
}}</view>
|
|
80
|
+
</view>
|
|
81
|
+
</view>
|
|
82
|
+
</view>
|
|
83
|
+
</view>
|
|
84
|
+
<!-- 自定义面板 -->
|
|
92
85
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
<!-- 面板插槽 -->
|
|
87
|
+
<slot />
|
|
88
|
+
<!-- 自定义面板 -->
|
|
89
|
+
|
|
90
|
+
<!-- 取消按钮 -->
|
|
91
|
+
<hy-button
|
|
92
|
+
v-if="cancelText"
|
|
93
|
+
:text="cancelText"
|
|
94
|
+
shape="circle"
|
|
95
|
+
custom-class="hy-action-sheet__cancel"
|
|
96
|
+
@click="handleCancel"
|
|
97
|
+
></hy-button>
|
|
98
|
+
<!-- 取消按钮 -->
|
|
99
|
+
</view>
|
|
100
|
+
</hy-popup>
|
|
101
|
+
</view>
|
|
105
102
|
</template>
|
|
106
103
|
|
|
107
104
|
<script lang="ts">
|
|
108
105
|
export default {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
106
|
+
name: 'hy-action-sheet',
|
|
107
|
+
options: {
|
|
108
|
+
addGlobalClass: true,
|
|
109
|
+
virtualHost: true,
|
|
110
|
+
styleIsolation: 'shared'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
116
113
|
</script>
|
|
117
114
|
|
|
118
115
|
<script lang="ts" setup>
|
|
119
|
-
import { watch, ref } from
|
|
120
|
-
import
|
|
121
|
-
import {
|
|
122
|
-
import
|
|
123
|
-
IActionSheetPanel,
|
|
124
|
-
IActionSheetEmits,
|
|
125
|
-
IActionSheetAction,
|
|
126
|
-
} from "./typing";
|
|
116
|
+
import { watch, ref } from 'vue'
|
|
117
|
+
import { isArray } from '../../libs'
|
|
118
|
+
import type { IActionSheetPanel, IActionSheetEmits } from './typing'
|
|
119
|
+
import actionSheetProps from './props'
|
|
127
120
|
// 组件
|
|
128
|
-
import HyIcon from
|
|
129
|
-
import HyPopup from
|
|
130
|
-
import HyLoading from
|
|
131
|
-
import HyButton from
|
|
121
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
122
|
+
import HyPopup from '../hy-popup/hy-popup.vue'
|
|
123
|
+
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
124
|
+
import HyButton from '../hy-button/hy-button.vue'
|
|
132
125
|
|
|
133
126
|
/**
|
|
134
127
|
* 本组件用于从底部弹出一个操作菜单,供用户选择并返回结果。本组件功能类似于uni的uni.showActionSheetAPI,配置更加灵活,所有平台都表现一致。
|
|
135
128
|
* @displayName hy-action-sheet
|
|
136
129
|
*/
|
|
137
|
-
defineOptions({})
|
|
130
|
+
defineOptions({})
|
|
138
131
|
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
/** 操作菜单是否展示 */
|
|
142
|
-
modelValue: {
|
|
143
|
-
type: Boolean,
|
|
144
|
-
default: false,
|
|
145
|
-
required: true,
|
|
146
|
-
},
|
|
147
|
-
/** 菜单选项列表 */
|
|
148
|
-
actions: {
|
|
149
|
-
type: Array as PropType<IActionSheetAction[]>,
|
|
150
|
-
default() {
|
|
151
|
-
return [];
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
/** 自定义面板项,可以为字符串数组,也可以为对象数组,如果为二维数组,则为多行展示 */
|
|
155
|
-
panels: {
|
|
156
|
-
type: Array as PropType<Array<IActionSheetPanel | IActionSheetPanel[]>>,
|
|
157
|
-
default() {
|
|
158
|
-
return [];
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
/** 操作菜单是否展示 */
|
|
162
|
-
round: {
|
|
163
|
-
type: [String, Number],
|
|
164
|
-
default: 20,
|
|
165
|
-
},
|
|
166
|
-
/** 标题 */
|
|
167
|
-
title: String,
|
|
168
|
-
/**
|
|
169
|
-
* 标题文字位置
|
|
170
|
-
* @values left,center,right
|
|
171
|
-
* */
|
|
172
|
-
titleAlign: {
|
|
173
|
-
type: String,
|
|
174
|
-
default: "center",
|
|
175
|
-
},
|
|
176
|
-
/** 取消按钮的提示文字,不为空时显示按钮 */
|
|
177
|
-
cancelText: String,
|
|
178
|
-
/** 点击某个菜单项时是否关闭弹窗 */
|
|
179
|
-
closeOnClickAction: {
|
|
180
|
-
type: Boolean,
|
|
181
|
-
default: true,
|
|
182
|
-
},
|
|
183
|
-
/** 点击遮罩是否允许关闭 */
|
|
184
|
-
closeOnClickOverlay: {
|
|
185
|
-
type: Boolean,
|
|
186
|
-
default: true,
|
|
187
|
-
},
|
|
188
|
-
/** 弹框动画持续时间 */
|
|
189
|
-
duration: {
|
|
190
|
-
type: Number,
|
|
191
|
-
default: 200,
|
|
192
|
-
},
|
|
193
|
-
/** 菜单层级 */
|
|
194
|
-
zIndex: {
|
|
195
|
-
type: Number,
|
|
196
|
-
default: 100,
|
|
197
|
-
},
|
|
198
|
-
/** 处理底部安全区 */
|
|
199
|
-
safeAreaInsetBottom: {
|
|
200
|
-
type: Boolean,
|
|
201
|
-
default: true,
|
|
202
|
-
},
|
|
203
|
-
/** 自定义外部样式 */
|
|
204
|
-
customStyle: Object as PropType<CSSProperties>,
|
|
205
|
-
/** 自定义外部类名 */
|
|
206
|
-
customClass: String,
|
|
207
|
-
/** 自定义标题类名 */
|
|
208
|
-
customHeaderClass: String,
|
|
209
|
-
});
|
|
210
|
-
const emit = defineEmits<IActionSheetEmits>();
|
|
132
|
+
const props = defineProps(actionSheetProps)
|
|
133
|
+
const emit = defineEmits<IActionSheetEmits>()
|
|
211
134
|
|
|
212
|
-
const formatPanels = ref<Array<IActionSheetPanel> | Array<IActionSheetPanel[]>>(
|
|
213
|
-
|
|
214
|
-
);
|
|
215
|
-
const showPopup = ref<boolean>(false);
|
|
135
|
+
const formatPanels = ref<Array<IActionSheetPanel> | Array<IActionSheetPanel[]>>([])
|
|
136
|
+
const showPopup = ref<boolean>(false)
|
|
216
137
|
|
|
217
|
-
watch(() => props.panels, computedValue, { deep: true, immediate: true })
|
|
138
|
+
watch(() => props.panels, computedValue, { deep: true, immediate: true })
|
|
218
139
|
|
|
219
140
|
watch(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
)
|
|
141
|
+
() => props.modelValue,
|
|
142
|
+
(newValue) => {
|
|
143
|
+
showPopup.value = newValue
|
|
144
|
+
},
|
|
145
|
+
{ deep: true, immediate: true }
|
|
146
|
+
)
|
|
226
147
|
|
|
227
148
|
function isPanelArray() {
|
|
228
|
-
|
|
149
|
+
return props.panels.length && !isArray(props.panels[0])
|
|
229
150
|
}
|
|
230
151
|
function computedValue() {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
152
|
+
formatPanels.value = isPanelArray()
|
|
153
|
+
? [props.panels as IActionSheetPanel[]]
|
|
154
|
+
: (props.panels as IActionSheetPanel[][])
|
|
234
155
|
}
|
|
235
156
|
|
|
236
|
-
function onSelect(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
157
|
+
function onSelect(rowIndex: number, type: 'action' | 'panels', colIndex?: number) {
|
|
158
|
+
if (type === 'action') {
|
|
159
|
+
if (props.actions[rowIndex].disabled || props.actions[rowIndex].loading) {
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
emit('select', {
|
|
163
|
+
item: props.actions[rowIndex],
|
|
164
|
+
index: rowIndex
|
|
165
|
+
})
|
|
166
|
+
} else if (isPanelArray()) {
|
|
167
|
+
emit('select', {
|
|
168
|
+
item: props.panels[Number(colIndex)],
|
|
169
|
+
index: colIndex
|
|
170
|
+
})
|
|
171
|
+
} else {
|
|
172
|
+
emit('select', {
|
|
173
|
+
item: (props.panels as IActionSheetPanel[][])[rowIndex][Number(colIndex)],
|
|
174
|
+
rowIndex,
|
|
175
|
+
colIndex
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
if (props.closeOnClickAction) {
|
|
179
|
+
onClose()
|
|
244
180
|
}
|
|
245
|
-
emit("select", {
|
|
246
|
-
item: props.actions[rowIndex],
|
|
247
|
-
index: rowIndex,
|
|
248
|
-
});
|
|
249
|
-
} else if (isPanelArray()) {
|
|
250
|
-
emit("select", {
|
|
251
|
-
item: props.panels[Number(colIndex)],
|
|
252
|
-
index: colIndex,
|
|
253
|
-
});
|
|
254
|
-
} else {
|
|
255
|
-
emit("select", {
|
|
256
|
-
item: (props.panels as IActionSheetPanel[][])[rowIndex][Number(colIndex)],
|
|
257
|
-
rowIndex,
|
|
258
|
-
colIndex,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
if (props.closeOnClickAction) {
|
|
262
|
-
onClose();
|
|
263
|
-
}
|
|
264
181
|
}
|
|
265
182
|
function handleCancel() {
|
|
266
|
-
|
|
267
|
-
|
|
183
|
+
emit('cancel')
|
|
184
|
+
onClose()
|
|
268
185
|
}
|
|
269
186
|
function onClose() {
|
|
270
|
-
|
|
271
|
-
|
|
187
|
+
emit('update:modelValue', false)
|
|
188
|
+
emit('close')
|
|
272
189
|
}
|
|
273
190
|
function onOpen() {
|
|
274
|
-
|
|
191
|
+
emit('open')
|
|
275
192
|
}
|
|
276
193
|
</script>
|
|
277
194
|
|
|
278
195
|
<style lang="scss" scoped>
|
|
279
|
-
@import
|
|
196
|
+
@import './index.scss';
|
|
280
197
|
.hy-action-sheet__header {
|
|
281
|
-
|
|
198
|
+
text-align: v-bind(titleAlign);
|
|
282
199
|
}
|
|
283
200
|
</style>
|
|
@@ -1,18 +1,71 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IActionSheetAction, IActionSheetPanel } from './typing'
|
|
2
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const actionSheetProps = {
|
|
5
|
+
/** 操作菜单是否展示 */
|
|
6
|
+
modelValue: {
|
|
7
|
+
type: Boolean,
|
|
8
|
+
default: false,
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
/** 菜单选项列表 */
|
|
12
|
+
actions: {
|
|
13
|
+
type: Array as PropType<IActionSheetAction[]>,
|
|
14
|
+
default: () => []
|
|
15
|
+
},
|
|
16
|
+
/** 自定义面板项,可以为字符串数组,也可以为对象数组,如果为二维数组,则为多行展示 */
|
|
17
|
+
panels: {
|
|
18
|
+
type: Array as PropType<Array<IActionSheetPanel | IActionSheetPanel[]>>,
|
|
19
|
+
default: () => []
|
|
20
|
+
},
|
|
21
|
+
/** 操作菜单是否展示 */
|
|
22
|
+
round: {
|
|
23
|
+
type: [String, Number],
|
|
24
|
+
default: 20
|
|
25
|
+
},
|
|
26
|
+
/** 标题 */
|
|
27
|
+
title: String,
|
|
28
|
+
/**
|
|
29
|
+
* 标题文字位置
|
|
30
|
+
* @values left,center,right
|
|
31
|
+
* */
|
|
32
|
+
titleAlign: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: 'center'
|
|
35
|
+
},
|
|
36
|
+
/** 取消按钮的提示文字,不为空时显示按钮 */
|
|
37
|
+
cancelText: String,
|
|
38
|
+
/** 点击某个菜单项时是否关闭弹窗 */
|
|
39
|
+
closeOnClickAction: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: true
|
|
42
|
+
},
|
|
43
|
+
/** 点击遮罩是否允许关闭 */
|
|
44
|
+
closeOnClickOverlay: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: true
|
|
47
|
+
},
|
|
48
|
+
/** 弹框动画持续时间 */
|
|
49
|
+
duration: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 200
|
|
52
|
+
},
|
|
53
|
+
/** 菜单层级 */
|
|
54
|
+
zIndex: {
|
|
55
|
+
type: Number,
|
|
56
|
+
default: 100
|
|
57
|
+
},
|
|
58
|
+
/** 处理底部安全区 */
|
|
59
|
+
safeAreaInsetBottom: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: true
|
|
62
|
+
},
|
|
63
|
+
/** 自定义外部样式 */
|
|
64
|
+
customStyle: Object as PropType<CSSProperties>,
|
|
65
|
+
/** 自定义外部类名 */
|
|
66
|
+
customClass: String,
|
|
67
|
+
/** 自定义标题类名 */
|
|
68
|
+
customHeaderClass: String
|
|
16
69
|
}
|
|
17
70
|
|
|
18
|
-
export default
|
|
71
|
+
export default actionSheetProps
|