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,350 +1,221 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
3
|
-
:class="['hy-search', customStyle]"
|
|
4
|
-
@tap="clickHandler"
|
|
5
|
-
:style="[
|
|
6
|
-
{
|
|
7
|
-
margin: margin,
|
|
8
|
-
},
|
|
9
|
-
customStyle,
|
|
10
|
-
]"
|
|
11
|
-
>
|
|
12
2
|
<view
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
backgroundColor: bgColor,
|
|
16
|
-
borderRadius: shape == 'circle' ? '100px' : '4px',
|
|
17
|
-
borderColor: borderColor,
|
|
18
|
-
}"
|
|
19
|
-
>
|
|
20
|
-
<template>
|
|
21
|
-
<slot v-if="$slots.label" name="label"></slot>
|
|
22
|
-
<text v-else-if="label" class="hy-search__content__label">{{
|
|
23
|
-
label
|
|
24
|
-
}}</text>
|
|
25
|
-
</template>
|
|
26
|
-
<view class="hy-search__content__icon" v-if="searchIcon">
|
|
27
|
-
<HyIcon
|
|
28
|
-
:name="searchIcon?.name || IconConfig.SEARCH"
|
|
29
|
-
:size="searchIcon?.size"
|
|
30
|
-
:color="searchIcon?.color || color"
|
|
31
|
-
:bold="searchIcon?.bold"
|
|
32
|
-
:customPrefix="searchIcon?.customPrefix"
|
|
33
|
-
:imgMode="searchIcon?.imgMode"
|
|
34
|
-
:width="searchIcon?.width"
|
|
35
|
-
:height="searchIcon?.height"
|
|
36
|
-
:top="searchIcon?.top"
|
|
37
|
-
:stop="searchIcon?.stop"
|
|
38
|
-
:round="searchIcon?.round"
|
|
39
|
-
:customStyle="searchIcon?.customStyle"
|
|
40
|
-
@tap="clickIcon"
|
|
41
|
-
></HyIcon>
|
|
42
|
-
</view>
|
|
43
|
-
<input
|
|
44
|
-
:confirm-type="confirmType"
|
|
45
|
-
:value="keyword"
|
|
46
|
-
:disabled="disabled"
|
|
47
|
-
:maxlength="maxlength"
|
|
48
|
-
:adjust-position="adjustPosition"
|
|
49
|
-
:focus="autoFocus"
|
|
50
|
-
:auto-blur="autoBlur"
|
|
51
|
-
placeholder-class="hy-search__content__input--placeholder"
|
|
52
|
-
:placeholder="placeholder"
|
|
53
|
-
:placeholder-style="`color: ${placeholderColor}`"
|
|
54
|
-
:class="[
|
|
55
|
-
'hy-search__content__input',
|
|
56
|
-
disabled && 'hy-search__content__input--disabled',
|
|
57
|
-
]"
|
|
58
|
-
type="text"
|
|
59
|
-
:always-embed="true"
|
|
3
|
+
:class="['hy-search', customStyle]"
|
|
4
|
+
@tap="clickHandler"
|
|
60
5
|
:style="[
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
backgroundColor: bgColor,
|
|
66
|
-
height: addUnit(height),
|
|
67
|
-
},
|
|
68
|
-
inputStyle,
|
|
6
|
+
{
|
|
7
|
+
margin: margin
|
|
8
|
+
},
|
|
9
|
+
customStyle
|
|
69
10
|
]"
|
|
70
|
-
@blur="onBlur"
|
|
71
|
-
@focus="onFocus"
|
|
72
|
-
@confirm="onSearch"
|
|
73
|
-
@input="inputChange"
|
|
74
|
-
/>
|
|
75
|
-
<view
|
|
76
|
-
class="hy-search__content__icon hy-search__content__close"
|
|
77
|
-
v-if="showClear"
|
|
78
|
-
@click="onClear"
|
|
79
|
-
>
|
|
80
|
-
<HyIcon :name="IconConfig.CLOSE"></HyIcon>
|
|
81
|
-
</view>
|
|
82
|
-
</view>
|
|
83
|
-
<text
|
|
84
|
-
:style="[actionStyle]"
|
|
85
|
-
class="hy-search__action"
|
|
86
|
-
:class="[(showActionBtn || show) && 'hy-search__action--active']"
|
|
87
|
-
@tap.stop.prevent="onConfirm"
|
|
88
11
|
>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
12
|
+
<view
|
|
13
|
+
class="hy-search__content"
|
|
14
|
+
:style="{
|
|
15
|
+
backgroundColor: bgColor,
|
|
16
|
+
borderRadius: shape == 'circle' ? '100px' : '4px',
|
|
17
|
+
borderColor: borderColor
|
|
18
|
+
}"
|
|
19
|
+
>
|
|
20
|
+
<template>
|
|
21
|
+
<slot v-if="$slots.label" name="label"></slot>
|
|
22
|
+
<text v-else-if="label" class="hy-search__content__label">{{ label }}</text>
|
|
23
|
+
</template>
|
|
24
|
+
<view class="hy-search__content__icon" v-if="searchIcon">
|
|
25
|
+
<hy-icon
|
|
26
|
+
:name="searchIcon?.name || IconConfig.SEARCH"
|
|
27
|
+
:size="searchIcon?.size"
|
|
28
|
+
:color="searchIcon?.color || color"
|
|
29
|
+
:bold="searchIcon?.bold"
|
|
30
|
+
:customPrefix="searchIcon?.customPrefix"
|
|
31
|
+
:imgMode="searchIcon?.imgMode"
|
|
32
|
+
:width="searchIcon?.width"
|
|
33
|
+
:height="searchIcon?.height"
|
|
34
|
+
:top="searchIcon?.top"
|
|
35
|
+
:stop="searchIcon?.stop"
|
|
36
|
+
:round="searchIcon?.round"
|
|
37
|
+
:customStyle="searchIcon?.customStyle"
|
|
38
|
+
@tap="clickIcon"
|
|
39
|
+
></hy-icon>
|
|
40
|
+
</view>
|
|
41
|
+
<input
|
|
42
|
+
:confirm-type="confirmType"
|
|
43
|
+
:value="keyword"
|
|
44
|
+
:disabled="disabled"
|
|
45
|
+
:maxlength="maxlength"
|
|
46
|
+
:adjust-position="adjustPosition"
|
|
47
|
+
:focus="autoFocus"
|
|
48
|
+
:auto-blur="autoBlur"
|
|
49
|
+
placeholder-class="hy-search__content__input--placeholder"
|
|
50
|
+
:placeholder="placeholder"
|
|
51
|
+
:placeholder-style="`color: ${placeholderColor}`"
|
|
52
|
+
:class="[
|
|
53
|
+
'hy-search__content__input',
|
|
54
|
+
disabled && 'hy-search__content__input--disabled'
|
|
55
|
+
]"
|
|
56
|
+
type="text"
|
|
57
|
+
:always-embed="true"
|
|
58
|
+
:style="[
|
|
59
|
+
{
|
|
60
|
+
pointerEvents: disabled ? 'none' : 'auto',
|
|
61
|
+
textAlign: inputAlign,
|
|
62
|
+
color: color,
|
|
63
|
+
backgroundColor: bgColor,
|
|
64
|
+
height: addUnit(height)
|
|
65
|
+
},
|
|
66
|
+
inputStyle
|
|
67
|
+
]"
|
|
68
|
+
@blur="onBlur"
|
|
69
|
+
@focus="onFocus"
|
|
70
|
+
@confirm="onSearch"
|
|
71
|
+
@input="inputChange"
|
|
72
|
+
/>
|
|
73
|
+
<view
|
|
74
|
+
class="hy-search__content__icon hy-search__content__close"
|
|
75
|
+
v-if="showClear"
|
|
76
|
+
@click="onClear"
|
|
77
|
+
>
|
|
78
|
+
<hy-icon :name="IconConfig.CLOSE"></hy-icon>
|
|
79
|
+
</view>
|
|
80
|
+
</view>
|
|
81
|
+
<text
|
|
82
|
+
:style="[actionStyle]"
|
|
83
|
+
class="hy-search__action"
|
|
84
|
+
:class="[(showActionBtn || show) && 'hy-search__action--active']"
|
|
85
|
+
@tap.stop.prevent="onConfirm"
|
|
86
|
+
>
|
|
87
|
+
{{ actionText }}
|
|
88
|
+
</text>
|
|
89
|
+
</view>
|
|
92
90
|
</template>
|
|
93
91
|
|
|
94
92
|
<script lang="ts">
|
|
95
93
|
export default {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
94
|
+
name: 'hy-search',
|
|
95
|
+
options: {
|
|
96
|
+
addGlobalClass: true,
|
|
97
|
+
virtualHost: true,
|
|
98
|
+
styleIsolation: 'shared'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
103
101
|
</script>
|
|
104
102
|
|
|
105
103
|
<script setup lang="ts">
|
|
106
|
-
import { computed, nextTick, ref, watch } from
|
|
107
|
-
import type {
|
|
108
|
-
import
|
|
109
|
-
import { addUnit, IconConfig } from "../../libs";
|
|
110
|
-
import type HyIconProps from "../hy-icon/typing";
|
|
104
|
+
import { computed, nextTick, ref, watch } from 'vue'
|
|
105
|
+
import type { ISearchEmits } from './typing'
|
|
106
|
+
import { addUnit, IconConfig } from '../../libs'
|
|
111
107
|
import type {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
108
|
+
InputOnBlurEvent,
|
|
109
|
+
InputOnConfirmEvent,
|
|
110
|
+
InputOnFocusEvent,
|
|
111
|
+
InputOnInputEvent
|
|
112
|
+
} from '@uni-helper/uni-types'
|
|
113
|
+
import searchProps from './props'
|
|
118
114
|
// 组件
|
|
119
|
-
import HyIcon from
|
|
115
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
120
116
|
|
|
121
117
|
/**
|
|
122
118
|
* 搜索组件,集成了常见搜索框所需功能,用户可以一键引入,开箱即用。
|
|
123
119
|
* @displayName hy-search
|
|
124
120
|
*/
|
|
125
|
-
defineOptions({})
|
|
121
|
+
defineOptions({})
|
|
126
122
|
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
/** 输入框初始值 */
|
|
130
|
-
modelValue: {
|
|
131
|
-
type: String,
|
|
132
|
-
default: "",
|
|
133
|
-
},
|
|
134
|
-
/**
|
|
135
|
-
* 搜索框形状
|
|
136
|
-
* @values circle,square
|
|
137
|
-
* */
|
|
138
|
-
shape: {
|
|
139
|
-
type: String,
|
|
140
|
-
default: "circle",
|
|
141
|
-
},
|
|
142
|
-
/** 搜索框背景颜色 */
|
|
143
|
-
bgColor: String,
|
|
144
|
-
/** 占位文字内容 */
|
|
145
|
-
placeholder: {
|
|
146
|
-
type: String,
|
|
147
|
-
default: "请输入关键字",
|
|
148
|
-
},
|
|
149
|
-
/**
|
|
150
|
-
* 设置右下角按钮的文字,兼容性详见uni-app文档
|
|
151
|
-
* @valuse send,search,next,go,done
|
|
152
|
-
* */
|
|
153
|
-
confirmType: {
|
|
154
|
-
type: String as PropType<InputConfirmType>,
|
|
155
|
-
default: "search",
|
|
156
|
-
},
|
|
157
|
-
/** 是否启用清除控件 */
|
|
158
|
-
clearable: {
|
|
159
|
-
type: Boolean,
|
|
160
|
-
default: true,
|
|
161
|
-
},
|
|
162
|
-
/** 是否自动获得焦点 */
|
|
163
|
-
autoFocus: {
|
|
164
|
-
type: Boolean,
|
|
165
|
-
default: false,
|
|
166
|
-
},
|
|
167
|
-
/** 键盘收起时,是否自动失去焦点 */
|
|
168
|
-
autoBlur: {
|
|
169
|
-
type: Boolean,
|
|
170
|
-
default: true,
|
|
171
|
-
},
|
|
172
|
-
/** 键盘弹起时,是否自动上推页面 */
|
|
173
|
-
adjustPosition: {
|
|
174
|
-
type: Boolean,
|
|
175
|
-
default: true,
|
|
176
|
-
},
|
|
177
|
-
/** 是否显示右侧控件 */
|
|
178
|
-
showAction: {
|
|
179
|
-
type: Boolean,
|
|
180
|
-
default: true,
|
|
181
|
-
},
|
|
182
|
-
/** 右侧控件文字 */
|
|
183
|
-
actionText: {
|
|
184
|
-
type: String,
|
|
185
|
-
default: "搜索",
|
|
186
|
-
},
|
|
187
|
-
/** 右侧控件的样式,对象形式 */
|
|
188
|
-
actionStyle: {
|
|
189
|
-
type: Object as PropType<CSSProperties>,
|
|
190
|
-
default: {},
|
|
191
|
-
},
|
|
192
|
-
/** 输入框内容水平对齐方式 */
|
|
193
|
-
inputAlign: {
|
|
194
|
-
type: String,
|
|
195
|
-
default: "left",
|
|
196
|
-
},
|
|
197
|
-
/** 自定义输入框样式,对象形式 */
|
|
198
|
-
inputStyle: {
|
|
199
|
-
type: Object as PropType<CSSProperties>,
|
|
200
|
-
default: {},
|
|
201
|
-
},
|
|
202
|
-
/** 是否启用输入框 */
|
|
203
|
-
disabled: {
|
|
204
|
-
type: Boolean,
|
|
205
|
-
default: false,
|
|
206
|
-
},
|
|
207
|
-
/** 边框颜色,配置了颜色,才会有边框 */
|
|
208
|
-
borderColor: {
|
|
209
|
-
type: String,
|
|
210
|
-
default: "transparent",
|
|
211
|
-
},
|
|
212
|
-
/** 输入框字体颜色 */
|
|
213
|
-
color: String,
|
|
214
|
-
/** placeholder的颜色 */
|
|
215
|
-
placeholderColor: {
|
|
216
|
-
type: String,
|
|
217
|
-
default: "",
|
|
218
|
-
},
|
|
219
|
-
/** 输入框左边的图标属性集合,可以为图标名称或图片路径 */
|
|
220
|
-
searchIcon: {
|
|
221
|
-
type: [Boolean, Object] as PropType<HyIconProps | boolean>,
|
|
222
|
-
default: { name: IconConfig.SEARCH },
|
|
223
|
-
},
|
|
224
|
-
/** 组件与其他上下左右之间的距离,带单位的字符串形式,如"30px" */
|
|
225
|
-
margin: {
|
|
226
|
-
type: [String, Number],
|
|
227
|
-
default: 0,
|
|
228
|
-
},
|
|
229
|
-
/** 是否开启动画,见上方说明 */
|
|
230
|
-
animation: {
|
|
231
|
-
type: Boolean,
|
|
232
|
-
default: false,
|
|
233
|
-
},
|
|
234
|
-
/** 输入框最大能输入的长度,-1为不限制长度 */
|
|
235
|
-
maxlength: {
|
|
236
|
-
type: Number,
|
|
237
|
-
default: -1,
|
|
238
|
-
},
|
|
239
|
-
/** 输入框高度,单位px */
|
|
240
|
-
height: {
|
|
241
|
-
type: Number,
|
|
242
|
-
default: 30,
|
|
243
|
-
},
|
|
244
|
-
/** 搜索框左边显示内容 */
|
|
245
|
-
label: String,
|
|
246
|
-
/** 定义需要用到的外部样式 */
|
|
247
|
-
customStyle: {
|
|
248
|
-
type: Object as PropType<CSSProperties>,
|
|
249
|
-
},
|
|
250
|
-
/** 自定义外部类名 */
|
|
251
|
-
customClass: String,
|
|
252
|
-
});
|
|
253
|
-
const emit = defineEmits<ISearchEmits>();
|
|
123
|
+
const props = defineProps(searchProps)
|
|
124
|
+
const emit = defineEmits<ISearchEmits>()
|
|
254
125
|
|
|
255
|
-
const keyword = ref<string>(props.modelValue)
|
|
126
|
+
const keyword = ref<string>(props.modelValue)
|
|
256
127
|
// 显示右边搜索按钮
|
|
257
|
-
const show = ref<boolean>(false)
|
|
128
|
+
const show = ref<boolean>(false)
|
|
258
129
|
// 标记input当前状态是否处于聚焦中,如果是,才会显示右侧的清除控件
|
|
259
|
-
const focused = ref(false)
|
|
130
|
+
const focused = ref(false)
|
|
260
131
|
|
|
261
132
|
watch(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
)
|
|
133
|
+
() => keyword.value,
|
|
134
|
+
(newValue: string) => {
|
|
135
|
+
emit('update:modelValue', newValue)
|
|
136
|
+
emit('change', newValue)
|
|
137
|
+
}
|
|
138
|
+
)
|
|
268
139
|
|
|
269
140
|
// 是否显示右边控件
|
|
270
141
|
const showActionBtn = computed<boolean>(() => {
|
|
271
|
-
|
|
272
|
-
})
|
|
142
|
+
return !props.animation && props.showAction
|
|
143
|
+
})
|
|
273
144
|
// 是否显示清除控件
|
|
274
145
|
const showClear = computed(() => {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
})
|
|
146
|
+
const { clearable, disabled } = props
|
|
147
|
+
return clearable && !disabled && !!focused.value && keyword.value !== ''
|
|
148
|
+
})
|
|
278
149
|
|
|
279
150
|
/**
|
|
280
151
|
* 值改变触发
|
|
281
152
|
* */
|
|
282
153
|
const inputChange = (e: InputOnInputEvent) => {
|
|
283
|
-
|
|
284
|
-
}
|
|
154
|
+
keyword.value = e.detail.value
|
|
155
|
+
}
|
|
285
156
|
/**
|
|
286
157
|
* @description 清空输入
|
|
287
158
|
* */
|
|
288
159
|
const onClear = () => {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
160
|
+
keyword.value = ''
|
|
161
|
+
// 延后发出事件,避免在父组件监听clear事件时,value为更新前的值(不为空)
|
|
162
|
+
nextTick(() => {
|
|
163
|
+
emit('clear')
|
|
164
|
+
})
|
|
165
|
+
}
|
|
295
166
|
/**
|
|
296
167
|
* @description 确定搜索
|
|
297
168
|
* */
|
|
298
169
|
const onSearch = (e: InputOnConfirmEvent) => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
170
|
+
emit('search', e, e.detail.value)
|
|
171
|
+
try {
|
|
172
|
+
// 收起键盘
|
|
173
|
+
uni.hideKeyboard()
|
|
174
|
+
} catch (e) {}
|
|
175
|
+
}
|
|
305
176
|
/**
|
|
306
177
|
* @description 点击右边自定义按钮的事件
|
|
307
178
|
*/
|
|
308
179
|
const onConfirm = () => {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
180
|
+
emit('confirm', keyword.value)
|
|
181
|
+
try {
|
|
182
|
+
// 收起键盘
|
|
183
|
+
uni.hideKeyboard()
|
|
184
|
+
} catch (e) {}
|
|
185
|
+
}
|
|
315
186
|
/**
|
|
316
187
|
* @description 获取焦点
|
|
317
188
|
* */
|
|
318
189
|
const onFocus = (e: InputOnFocusEvent) => {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
190
|
+
focused.value = true
|
|
191
|
+
// 开启右侧搜索按钮展开的动画效果
|
|
192
|
+
if (props.animation && props.showAction) show.value = true
|
|
193
|
+
emit('focus', e, keyword.value)
|
|
194
|
+
}
|
|
324
195
|
|
|
325
196
|
// 失去焦点
|
|
326
197
|
const onBlur = (e: InputOnBlurEvent) => {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
198
|
+
show.value = false
|
|
199
|
+
emit('blur', e, keyword.value)
|
|
200
|
+
}
|
|
330
201
|
/**
|
|
331
202
|
* @description 点击搜索框,只有disabled=true时才发出事件,因为禁止了输入,意味着是想跳转真正的搜索页
|
|
332
203
|
* */
|
|
333
204
|
const clickHandler = () => {
|
|
334
|
-
|
|
335
|
-
}
|
|
205
|
+
if (props.disabled) emit('click')
|
|
206
|
+
}
|
|
336
207
|
/**
|
|
337
208
|
* @description 点击左边图标
|
|
338
209
|
* */
|
|
339
210
|
const clickIcon = () => {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
211
|
+
emit('clickIcon', keyword.value)
|
|
212
|
+
try {
|
|
213
|
+
// 收起键盘
|
|
214
|
+
uni.hideKeyboard()
|
|
215
|
+
} catch (e) {}
|
|
216
|
+
}
|
|
346
217
|
</script>
|
|
347
218
|
|
|
348
219
|
<style lang="scss" scoped>
|
|
349
|
-
@import
|
|
220
|
+
@import './index.scss';
|
|
350
221
|
</style>
|
|
@@ -1,27 +1,132 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
+
import type { InputConfirmType } from '@uni-helper/uni-types'
|
|
3
|
+
import { IconConfig } from '../../libs'
|
|
4
|
+
import type HyIconProps from '../hy-icon/typing'
|
|
2
5
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
const searchProps = {
|
|
7
|
+
/** 输入框初始值 */
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: ''
|
|
11
|
+
},
|
|
12
|
+
/**
|
|
13
|
+
* 搜索框形状
|
|
14
|
+
* @values circle,square
|
|
15
|
+
* */
|
|
16
|
+
shape: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: 'circle'
|
|
19
|
+
},
|
|
20
|
+
/** 搜索框背景颜色 */
|
|
21
|
+
bgColor: String,
|
|
22
|
+
/** 占位文字内容 */
|
|
23
|
+
placeholder: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: '请输入关键字'
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* 设置右下角按钮的文字,兼容性详见uni-app文档
|
|
29
|
+
* @valuse send,search,next,go,done
|
|
30
|
+
* */
|
|
31
|
+
confirmType: {
|
|
32
|
+
type: String as PropType<InputConfirmType>,
|
|
33
|
+
default: 'search'
|
|
34
|
+
},
|
|
35
|
+
/** 是否启用清除控件 */
|
|
36
|
+
clearable: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: true
|
|
39
|
+
},
|
|
40
|
+
/** 是否自动获得焦点 */
|
|
41
|
+
autoFocus: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
},
|
|
45
|
+
/** 键盘收起时,是否自动失去焦点 */
|
|
46
|
+
autoBlur: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: true
|
|
49
|
+
},
|
|
50
|
+
/** 键盘弹起时,是否自动上推页面 */
|
|
51
|
+
adjustPosition: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: true
|
|
54
|
+
},
|
|
55
|
+
/** 是否显示右侧控件 */
|
|
56
|
+
showAction: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: true
|
|
59
|
+
},
|
|
60
|
+
/** 右侧控件文字 */
|
|
61
|
+
actionText: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: '搜索'
|
|
64
|
+
},
|
|
65
|
+
/** 右侧控件的样式,对象形式 */
|
|
66
|
+
actionStyle: {
|
|
67
|
+
type: Object as PropType<CSSProperties>,
|
|
68
|
+
default: {}
|
|
69
|
+
},
|
|
70
|
+
/** 输入框内容水平对齐方式 */
|
|
71
|
+
inputAlign: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: 'left'
|
|
74
|
+
},
|
|
75
|
+
/** 自定义输入框样式,对象形式 */
|
|
76
|
+
inputStyle: {
|
|
77
|
+
type: Object as PropType<CSSProperties>,
|
|
78
|
+
default: {}
|
|
79
|
+
},
|
|
80
|
+
/** 是否启用输入框 */
|
|
81
|
+
disabled: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: false
|
|
84
|
+
},
|
|
85
|
+
/** 边框颜色,配置了颜色,才会有边框 */
|
|
86
|
+
borderColor: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: 'transparent'
|
|
89
|
+
},
|
|
90
|
+
/** 输入框字体颜色 */
|
|
91
|
+
color: String,
|
|
92
|
+
/** placeholder的颜色 */
|
|
93
|
+
placeholderColor: {
|
|
94
|
+
type: String,
|
|
95
|
+
default: ''
|
|
96
|
+
},
|
|
97
|
+
/** 输入框左边的图标属性集合,可以为图标名称或图片路径 */
|
|
98
|
+
searchIcon: {
|
|
99
|
+
type: [Boolean, Object] as PropType<HyIconProps | boolean>,
|
|
100
|
+
default: { name: IconConfig.SEARCH }
|
|
101
|
+
},
|
|
102
|
+
/** 组件与其他上下左右之间的距离,带单位的字符串形式,如"30px" */
|
|
103
|
+
margin: {
|
|
104
|
+
type: [String, Number],
|
|
105
|
+
default: 0
|
|
106
|
+
},
|
|
107
|
+
/** 是否开启动画,见上方说明 */
|
|
108
|
+
animation: {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
default: false
|
|
111
|
+
},
|
|
112
|
+
/** 输入框最大能输入的长度,-1为不限制长度 */
|
|
113
|
+
maxlength: {
|
|
114
|
+
type: Number,
|
|
115
|
+
default: -1
|
|
116
|
+
},
|
|
117
|
+
/** 输入框高度,单位px */
|
|
118
|
+
height: {
|
|
119
|
+
type: Number,
|
|
120
|
+
default: 30
|
|
121
|
+
},
|
|
122
|
+
/** 搜索框左边显示内容 */
|
|
123
|
+
label: String,
|
|
124
|
+
/** 定义需要用到的外部样式 */
|
|
125
|
+
customStyle: {
|
|
126
|
+
type: Object as PropType<CSSProperties>
|
|
127
|
+
},
|
|
128
|
+
/** 自定义外部类名 */
|
|
129
|
+
customClass: String
|
|
130
|
+
}
|
|
26
131
|
|
|
27
|
-
export default
|
|
132
|
+
export default searchProps
|