Skip to content

Commit 1f37be0

Browse files
committed
feat: add props for search-box
1 parent 682d3c2 commit 1f37be0

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

one/docs/components/input.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
| ``clearable`` | `boolean=` | `false` | 是否显示清除按钮。 |
4848
| ``composition`` | `boolean=` | `false` | 是否感知输入法输入过程的值。 |
4949
| ``select-on-focus`` | `boolean=` | `false` | 聚焦时是否自动选中输入框文本。 |
50-
| ``get-length`` | `function(string): number=` | 自定义的字符长度计算函数。 |
51-
| ``trim`` | `boolean | string=` | `false` | [^trim] |
5250
| ``maxlength`` | `number=` | - | 最大可输入的字符长度。 |
51+
| ``get-length`` | `function(string): number=` | 自定义的字符长度计算函数。 |
5352
| ``strict`` | `boolean=` | `false` | 是否超出最大字符长度后不允许继续输入。 |
53+
| ``trim`` | `boolean | string=` | `false` | [^trim] |
5454

5555
^^^ui
5656
预设样式。

one/docs/components/search-box.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@
2929
| 名称 | 类型 | 默认值 | 描述 |
3030
| -- | -- | -- | -- |
3131
| ``ui`` | `string=` | - | [^ui] |
32-
| ``placeholder`` | `string` | - | 搜索框占位符。 |
3332
| ``value`` | `string` | - | [^value] |
33+
| ``disabled`` | `boolean=` | `false` | 是否为禁用状态。 |
34+
| ``readonly`` | `boolean=` | `false` | 是否为只读状态。 |
35+
| ``placeholder`` | `string` | - | 搜索框占位符。 |
3436
| ``autofocus`` | `boolean` | `false` | 是否自动聚焦。 |
3537
| ``clearable`` | `boolean` | `false` | 是否显示清除按钮。 |
3638
| ``select-on-focus`` | `boolean` | `false` | 聚焦时是否自动选择文本。 |
3739
| ``composition`` | `boolean` | `false` | 是否感知输入法状态。 |
3840
| ``suggestions`` | `Array<string>|Array<Object>` | - | [^suggestions] |
3941
| ``replace-on-select`` | `boolean` | `true` | 选择推荐项时是否自动使用其内容填充文本框。 |
42+
| ``maxlength`` | `number=` | - | 最大可输入的字符长度。 |
43+
| ``get-length`` | `function(string): number=` | 自定义的字符长度计算函数。 |
44+
| ``strict`` | `boolean=` | `false` | 是否超出最大字符长度后不允许继续输入。 |
45+
| ``trim`` | `boolean | string=` | `false` | [^trim] |
4046
| ``suggest-trigger`` | `Array<string>|string` | `input` | [^suggest-trigger] |
4147
| ``expanded`` | `boolean=` | `false` | [^expanded] |
42-
| ``disabled`` | `boolean=` | `false` | 是否为禁用状态。 |
43-
| ``readonly`` | `boolean=` | `false` | 是否为只读状态。 |
4448
| ``match`` | `(item, keyword, { ancestors }) => boolean | Array<[number, number]>` | - | 支持自定义高亮逻辑, 默认大小写不敏感,参考 [`Autocomplete`](./Autocomplete#自定义搜索逻辑)|
4549
| ``filter`` | `(item, keyword, { ancestors, offsets }) => boolean` | - | 支持自定义搜索命中逻辑,参考 [`Autocomplete`](./Autocomplete#自定义搜索逻辑)|
4650

@@ -97,6 +101,18 @@
97101
建议面板是否展开(如果 `suggestions` 中没有待选项,则即使为 `true` 时面板也会关闭)。
98102
^^^
99103

104+
^^^trim
105+
是否移除前后空格。当为 `true` 时,会移除前后空格,当为 `false` 时,不移除前后空格。设置为字符串时,按指定方式进行移除。
106+
107+
+++枚举值
108+
|| 描述 |
109+
| -- | -- |
110+
| `both` | 移除两端空格。等同于 `true` 时的行为。 |
111+
| `start` | 移除开始空格。 |
112+
| `end` | 移除末尾空格。 |
113+
+++
114+
^^^
115+
100116
### 插槽
101117

102118
| 名称 | 描述 |

one/docs/en-US/components/input.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ Use the [`disabled`](#props-disabled) prop to set an input to disabled state.
3535
| ``clearable`` | `boolean=` | `false` | Whether to show a clear button. |
3636
| ``composition`` | `boolean=` | `false` | Whether the input process should be aware of composition. |
3737
| ``select-on-focus`` | `boolean=` | `false` | Whether to select text content when focused. |
38+
| ``maxlength`` | `number=` | - | The maximum length of characters that can be entered. |
3839
| ``get-length`` | `function(string): number=` | Used to customize length calculation of the input. |
40+
| ``strict`` | `boolean=` | `false` | Whether to disallow further input after reaching the maximum character length. |
3941
| ``trim`` | `boolean | string=` | `false` | [^trim] |
4042

4143
^^^ui

one/docs/en-US/components/search-box.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,24 @@ Available size values for the [`ui`](#props-ui) prop: `xs` / `s` / `m` / `l`.
2929
| Name | Type | Default | Description |
3030
| -- | -- | -- | -- |
3131
| ``ui`` | `string=` | - | [^ui] |
32-
| ``placeholder`` | `string` | - | The placeholder text of the search box. |
3332
| ``value`` | `string` | - | [^value] |
33+
| ``disabled`` | `boolean=` | `false` | Whether the search box is disabled. |
34+
| ``readonly`` | `boolean=` | `false` | Whether the search box is read-only. |
35+
| ``placeholder`` | `string` | - | The placeholder text of the search box. |
3436
| ``autofocus`` | `boolean` | `false` | Whether the search box gains focus automatically. |
3537
| ``clearable`` | `boolean` | `false` | Whether the clear button is displayed. |
3638
| ``select-on-focus`` | `boolean` | `false` | Whether to select all content upon focus. |
3739
| ``composition`` | `boolean` | `false` | Whether the search box triggers value change upon composition of IME. |
3840
| ``suggestions`` | `Array<string>|Array<Object>` | - | [^suggestions] |
3941
| ``replace-on-select`` | `boolean` | `true` | Whether to replace the content with suggestion item value when it's selected. |
42+
| ``maxlength`` | `number=` | - | The maximum length of characters that can be entered. |
43+
| ``get-length`` | `function(string): number=` | Used to customize length calculation of the input. |
44+
| ``strict`` | `boolean=` | `false` | Whether to disallow further input after reaching the maximum character length. |
45+
| ``trim`` | `boolean | string=` | `false` | [^trim] |
4046
| ``suggest-trigger`` | `Array<string>|string` | `input` | [^suggest-trigger] |
4147
| ``expanded`` | `boolean=` | `false` | [^expanded] |
42-
| ``disabled`` | `boolean=` | `false` | Whether the search box is disabled. |
43-
| ``readonly`` | `boolean=` | `false` | Whether the search box is read-only. |
48+
| ``match`` | `(item, keyword, { ancestors }) => boolean | Array<[number, number]>` | - | Used to customize search highlighting logic. See [`Autocomplete`](./Autocomplete#customizing-search). |
49+
| ``filter`` | `(item, keyword, { ancestors, offsets }) => boolean` | - | Used to customize search hitting logic. See [`Autocomplete`](./Autocomplete#customizing-search). |
4450

4551
^^^ui
4652
Style variants.
@@ -96,6 +102,17 @@ Specifies when the suggestion list is displayed. Can be either an event name or
96102
Whether the suggestion list is expanded (if there are no items in `suggestions`, the list won't be expanded even the value is `false`).
97103
^^^
98104

105+
^^^trim
106+
Wether to trim the input value. If set to `true`, the input value will be trimmed from both ends. If set to `false`, the input value will not be trimmed. If set to a string, the input value will be trimmed from the specified side.
107+
108+
+++Enum
109+
| Value | Description |
110+
| -- | -- |
111+
| `both` | Trim from both ends. Equivalent to `true`. |
112+
| `start` | Trim from the start. |
113+
| `end` | Trim from the end. |
114+
+++
115+
99116
### Slots
100117

101118
| Name | Description |

0 commit comments

Comments
 (0)