Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pro:search): support searchField placeholder #1322

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/pro/search/demo/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const searchFields: SearchField[] = [
type: 'input',
label: 'Keyword',
multiple: true,
placeholder: 'please input keyword',
fieldConfig: {
trim: true,
},
Expand Down
1 change: 1 addition & 0 deletions packages/pro/search/docs/Api.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ interface SearchItemConfirmContext<V = unknown> extends Partial<SearchValue<V>>
| `defaultOperator` | 默认的操作符 | `string` | - | - | 提供时,会自动填入默认的操作符 |
| `defaultValue` | 默认值 | - | - | - | 提供时,会自动填入默认值 |
| `inputClassName` | 输入框class | `string` | - | - | 用于自定义输入框样式 |
| `placeholder` | 输入框placeholder | `string` | - | - | 搜索值输入框的占位符 |
| `validator` | 搜索项校验函数 | `(value: SearchValue) => { message?: string } | undefined` | - | - | 返回错误信息 |

#### InputSearchField
Expand Down
4 changes: 3 additions & 1 deletion packages/pro/search/src/searchItem/Segment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export default defineComponent({
class={inputClasses.value}
value={props.input ?? ''}
disabled={props.disabled}
title={props.segment.placeholder}
placeholder={props.segment.placeholder}
onInput={handleInput}
onCompositionstart={handleCompositionStart}
onCompositionend={handleCompositionEnd}
Expand Down Expand Up @@ -206,7 +208,7 @@ export default defineComponent({
renderTrigger()
)}
<span class={`${prefixCls}-measure-span`} ref={measureSpanRef}>
{props.input ?? ''}
{props.input || props.segment.placeholder || ''}
</span>
</span>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function createDatePickerSegment(
return {
name: searchField.type,
inputClassName: [inputClassName, `${prefixCls}-date-picker-segment-input`],
placeholder: searchField.placeholder,
defaultValue,
parse: input => parseInput(input, dateConfig, searchField),
format: value => formatValue(value, dateConfig, searchField),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function createDateRangePickerSegment(
return {
name: searchField.type,
inputClassName: [inputClassName, `${prefixCls}-date-range-picker-segment-input`],
placeholder: searchField.placeholder,
defaultValue,
parse: input => parseInput(input, dateConfig, searchField),
format: value => formatValue(value, dateConfig, searchField),
Expand Down
1 change: 1 addition & 0 deletions packages/pro/search/src/segments/CreateSelectSegment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export function createSelectSegment(
return {
name: searchField.type,
inputClassName: [inputClassName, `${prefixCls}-select-segment-input`],
placeholder: searchField.placeholder,
defaultValue,
parse: input => parseInput(input, searchField),
format: value => formatValue(value, searchField),
Expand Down
1 change: 1 addition & 0 deletions packages/pro/search/src/segments/createCustomSegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function createCustomSegment(prefixCls: string, searchField: CustomSearch
return {
name: 'custom',
inputClassName: [inputClassName, `${prefixCls}-custom-segment-input`],
placeholder: searchField.placeholder,
defaultValue,
parse,
format,
Expand Down
1 change: 1 addition & 0 deletions packages/pro/search/src/segments/createInputSegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function createInputSegment(prefixCls: string, searchField: InputSearchFi
return {
name: 'input',
inputClassName: [inputClassName, `${prefixCls}-input-segment-input`],
placeholder: searchField.placeholder,
defaultValue,
parse: input => input,
format: value => (trim ? value?.trim() : value) ?? '',
Expand Down
4 changes: 4 additions & 0 deletions packages/pro/search/style/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import '../../style/mixins/reset.less';
@import '../../../components/select/style/index.less';
@import '../../../components/style/mixins/ellipsis.less';
@import '../../../components//style//mixins//placeholder.less';

.@{pro-search-prefix} {
.reset-component();
Expand Down Expand Up @@ -44,6 +45,7 @@
&-placeholder {
color: @pro-search-placeholder-color;
padding: 0 @pro-search-placeholder-padding-horizontal;
.ellipsis();
}
&-clear-icon {
position: absolute;
Expand Down Expand Up @@ -189,6 +191,8 @@
height: 100%;
max-width: 100%;
outline: none;

.placeholder(@pro-search-placeholder-color);
}

&-overlay {
Expand Down