|
@@ -3,7 +3,8 @@
|
|
|
center
|
|
center
|
|
|
:innerStyle="{
|
|
:innerStyle="{
|
|
|
...themeStyles.view.value,
|
|
...themeStyles.view.value,
|
|
|
- ...innerStyle
|
|
|
|
|
|
|
+ ...innerStyle,
|
|
|
|
|
+ background: theme.resolveThemeColor(inputBackgroundColor),
|
|
|
}"
|
|
}"
|
|
|
:flexShrink="0"
|
|
:flexShrink="0"
|
|
|
overflow="hidden"
|
|
overflow="hidden"
|
|
@@ -43,7 +44,6 @@
|
|
|
/>
|
|
/>
|
|
|
<slot name="rightIcon" />
|
|
<slot name="rightIcon" />
|
|
|
</FlexRow>
|
|
</FlexRow>
|
|
|
- <slot name="rightButton" :onCustomButtonClick="onCustomButtonClick" />
|
|
|
|
|
<slot
|
|
<slot
|
|
|
v-if="(
|
|
v-if="(
|
|
|
cancelState === 'show' ||
|
|
cancelState === 'show' ||
|
|
@@ -64,6 +64,24 @@
|
|
|
@click="onCancelPressed"
|
|
@click="onCancelPressed"
|
|
|
/>
|
|
/>
|
|
|
</slot>
|
|
</slot>
|
|
|
|
|
+ <slot
|
|
|
|
|
+ v-if="(
|
|
|
|
|
+ searchState === 'show' ||
|
|
|
|
|
+ (inputFocus && (searchState === 'show-active' || searchState === 'show-active-or-no-empty')) ||
|
|
|
|
|
+ (valueTemp !== '' && (searchState === 'show-no-empty' || searchState === 'show-active-or-no-empty'))
|
|
|
|
|
+ )"
|
|
|
|
|
+ name="searchButton"
|
|
|
|
|
+ :onSearchButtonClick="onSearchButtonClick"
|
|
|
|
|
+ >
|
|
|
|
|
+ <IconButton
|
|
|
|
|
+ :icon="searchIcon"
|
|
|
|
|
+ :size="searchIconSize"
|
|
|
|
|
+ :color="searchIconColor"
|
|
|
|
|
+ v-bind="searchIconProps"
|
|
|
|
|
+ @click="onSearchButtonClick"
|
|
|
|
|
+ />
|
|
|
|
|
+ </slot>
|
|
|
|
|
+ <slot name="rightButton" :onCustomButtonClick="onCustomButtonClick"/>
|
|
|
</FlexRow>
|
|
</FlexRow>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -73,8 +91,9 @@ import type { IconProps } from '../basic/Icon.vue';
|
|
|
import { type ViewStyle, type TextStyle, useTheme, propGetThemeVar } from '../theme/ThemeDefine';
|
|
import { type ViewStyle, type TextStyle, useTheme, propGetThemeVar } from '../theme/ThemeDefine';
|
|
|
import FlexRow from '../layout/FlexRow.vue';
|
|
import FlexRow from '../layout/FlexRow.vue';
|
|
|
import Button from '../basic/Button.vue';
|
|
import Button from '../basic/Button.vue';
|
|
|
-import { DynamicColor, DynamicSize } from '../theme/ThemeTools';
|
|
|
|
|
|
|
+import { DynamicSize } from '../theme/ThemeTools';
|
|
|
import Icon from '../basic/Icon.vue';
|
|
import Icon from '../basic/Icon.vue';
|
|
|
|
|
+import IconButton from '../basic/IconButton.vue';
|
|
|
|
|
|
|
|
export interface SearchBarProp {
|
|
export interface SearchBarProp {
|
|
|
/**
|
|
/**
|
|
@@ -87,6 +106,11 @@ export interface SearchBarProp {
|
|
|
*/
|
|
*/
|
|
|
inputColor?: string;
|
|
inputColor?: string;
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 输入框的背景颜色
|
|
|
|
|
+ * @default white
|
|
|
|
|
+ */
|
|
|
|
|
+ inputBackgroundColor?: string;
|
|
|
|
|
+ /**
|
|
|
* 输入框的placeholder
|
|
* 输入框的placeholder
|
|
|
*/
|
|
*/
|
|
|
placeholder?: string;
|
|
placeholder?: string;
|
|
@@ -137,6 +161,35 @@ export interface SearchBarProp {
|
|
|
*/
|
|
*/
|
|
|
cancelState?: 'hidden'|'show'|'show-active'|'show-no-empty'|'show-active-or-no-empty';
|
|
cancelState?: 'hidden'|'show'|'show-active'|'show-no-empty'|'show-active-or-no-empty';
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 搜索按钮显示
|
|
|
|
|
+ * * hidden 不显示
|
|
|
|
|
+ * * show 一直显示
|
|
|
|
|
+ * * show-active 当输入框激活时显示
|
|
|
|
|
+ * * show-no-empty 当输入框有文字时显示
|
|
|
|
|
+ * * show-active-or-no-empty 当输入框激活或者有文字时显示
|
|
|
|
|
+ * @default 'hidden'
|
|
|
|
|
+ */
|
|
|
|
|
+ searchState?: 'hidden'|'show'|'show-active'|'show-no-empty'|'show-active-or-no-empty';
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 搜索按钮图标
|
|
|
|
|
+ * @default 'search'
|
|
|
|
|
+ */
|
|
|
|
|
+ searchIcon?: string;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 搜索按钮图标大小
|
|
|
|
|
+ * @default 40
|
|
|
|
|
+ */
|
|
|
|
|
+ searchIconSize?: string|number;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 搜索按钮图标颜色
|
|
|
|
|
+ * @default text.content
|
|
|
|
|
+ */
|
|
|
|
|
+ searchIconColor?: string;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 图标自定义属性
|
|
|
|
|
+ */
|
|
|
|
|
+ searchIconProps?: Partial<IconProps>;
|
|
|
|
|
+ /**
|
|
|
* 自定义样式
|
|
* 自定义样式
|
|
|
*/
|
|
*/
|
|
|
innerStyle?: ViewStyle;
|
|
innerStyle?: ViewStyle;
|
|
@@ -164,6 +217,11 @@ const theme = useTheme();
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<SearchBarProp>(), {
|
|
const props = withDefaults(defineProps<SearchBarProp>(), {
|
|
|
inputColor: () => propGetThemeVar('SearchBarTextColor', 'text.content'),
|
|
inputColor: () => propGetThemeVar('SearchBarTextColor', 'text.content'),
|
|
|
|
|
+ inputBackgroundColor: () => propGetThemeVar('SearchBarBackgroundColor', 'white'),
|
|
|
|
|
+ searchState: 'hidden',
|
|
|
|
|
+ searchIcon: () => propGetThemeVar('SearchBarSearchIcon', 'search'),
|
|
|
|
|
+ searchIconSize: () => propGetThemeVar('SearchBarSearchIconSize', 40),
|
|
|
|
|
+ searchIconColor: () => propGetThemeVar('SearchBarSearchIconColor', 'text.content'),
|
|
|
placeholder: '',
|
|
placeholder: '',
|
|
|
placeholderTextColor: () => propGetThemeVar('SearchBarCancelTextColor', 'text.second'),
|
|
placeholderTextColor: () => propGetThemeVar('SearchBarCancelTextColor', 'text.second'),
|
|
|
cancelText: '取消',
|
|
cancelText: '取消',
|
|
@@ -189,7 +247,6 @@ function updateValue(v: string) {
|
|
|
const themeStyles = theme.useThemeStyles({
|
|
const themeStyles = theme.useThemeStyles({
|
|
|
view: {
|
|
view: {
|
|
|
position: 'relative',
|
|
position: 'relative',
|
|
|
- backgroundColor: DynamicColor('SearchBarBackgroundColor', 'white'),
|
|
|
|
|
borderRadius: DynamicSize('SearchBarBorderRadius', 40),
|
|
borderRadius: DynamicSize('SearchBarBorderRadius', 40),
|
|
|
paddingHorizontal: DynamicSize('SearchBarPaddingHorizontal', 28),
|
|
paddingHorizontal: DynamicSize('SearchBarPaddingHorizontal', 28),
|
|
|
paddingVertical: DynamicSize('SearchBarPaddingVertical', 16),
|
|
paddingVertical: DynamicSize('SearchBarPaddingVertical', 16),
|
|
@@ -231,6 +288,10 @@ function onCancelPressed() {
|
|
|
updateValue('');
|
|
updateValue('');
|
|
|
emit('cancel');
|
|
emit('cancel');
|
|
|
}
|
|
}
|
|
|
|
|
+function onSearchButtonClick() {
|
|
|
|
|
+ emit('search', valueTemp.value);
|
|
|
|
|
+ uni.hideKeyboard()
|
|
|
|
|
+}
|
|
|
function onSumit() {
|
|
function onSumit() {
|
|
|
emit('search', valueTemp.value);
|
|
emit('search', valueTemp.value);
|
|
|
uni.hideKeyboard()
|
|
uni.hideKeyboard()
|