@ray-js/smart-ui 2.13.2-beta-0 → 2.13.2-beta-2
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/es/@types/config-provider/index.d.ts +6 -2
- package/es/@types/config-provider/theme-vars.d.ts +1 -1
- package/es/action-sheet/README.md +613 -0
- package/es/battery/README.md +149 -0
- package/es/bottom-sheet/README.md +495 -0
- package/es/button/README.md +335 -0
- package/es/calendar/README.md +513 -0
- package/es/cascader/README.md +326 -0
- package/es/cell/README.md +317 -0
- package/es/checkbox/README.md +481 -0
- package/es/circle/README.md +132 -0
- package/es/col/README.md +162 -0
- package/es/collapse/README.md +127 -0
- package/es/config-provider/README.md +150 -0
- package/es/count-down/README.md +201 -0
- package/es/custom-keyboard/README.md +122 -0
- package/es/datetime-picker/README.md +438 -0
- package/es/dialog/README.md +451 -0
- package/es/divider/README.md +132 -0
- package/es/dropdown-menu/README.md +331 -0
- package/es/empty/README.md +119 -0
- package/es/field/README.md +455 -0
- package/es/grid/README.md +273 -0
- package/es/icon/README.md +178 -0
- package/es/image/README.md +225 -0
- package/es/index-bar/README.md +186 -0
- package/es/loading/README.md +120 -0
- package/es/nav-bar/README.md +410 -0
- package/es/notice-bar/README.md +274 -0
- package/es/notify/README.md +121 -0
- package/es/overlay/README.md +128 -0
- package/es/picker/README.md +412 -0
- package/es/popover/README.md +338 -0
- package/es/popup/README.md +272 -0
- package/es/progress/README.md +88 -0
- package/es/radio/README.md +423 -0
- package/es/rate/README.md +248 -0
- package/es/search/README.md +290 -0
- package/es/sidebar/README.md +176 -0
- package/es/skeleton/README.md +141 -0
- package/es/slider/README.md +444 -0
- package/es/stepper/README.md +231 -0
- package/es/sticky/README.md +91 -0
- package/es/swipe-cell/README.md +217 -0
- package/es/switch/README.md +316 -0
- package/es/tab/README.md +501 -0
- package/es/tabbar/README.md +397 -0
- package/es/tag/README.md +215 -0
- package/es/toast/README.md +293 -0
- package/es/transition/README.md +140 -0
- package/es/tree-select/README.md +348 -0
- package/lib/@types/config-provider/index.d.ts +6 -2
- package/lib/@types/config-provider/theme-vars.d.ts +1 -1
- package/lib/action-sheet/README.md +613 -0
- package/lib/battery/README.md +149 -0
- package/lib/bottom-sheet/README.md +495 -0
- package/lib/button/README.md +335 -0
- package/lib/calendar/README.md +513 -0
- package/lib/cascader/README.md +326 -0
- package/lib/cell/README.md +317 -0
- package/lib/checkbox/README.md +481 -0
- package/lib/circle/README.md +132 -0
- package/lib/col/README.md +162 -0
- package/lib/collapse/README.md +127 -0
- package/lib/config-provider/README.md +150 -0
- package/lib/count-down/README.md +201 -0
- package/lib/custom-keyboard/README.md +122 -0
- package/lib/datetime-picker/README.md +438 -0
- package/lib/dialog/README.md +451 -0
- package/lib/divider/README.md +132 -0
- package/lib/dropdown-menu/README.md +331 -0
- package/lib/empty/README.md +119 -0
- package/lib/field/README.md +455 -0
- package/lib/grid/README.md +273 -0
- package/lib/icon/README.md +178 -0
- package/lib/image/README.md +225 -0
- package/lib/index-bar/README.md +186 -0
- package/lib/loading/README.md +120 -0
- package/lib/nav-bar/README.md +410 -0
- package/lib/notice-bar/README.md +274 -0
- package/lib/notify/README.md +121 -0
- package/lib/overlay/README.md +128 -0
- package/lib/picker/README.md +412 -0
- package/lib/popover/README.md +338 -0
- package/lib/popup/README.md +272 -0
- package/lib/progress/README.md +88 -0
- package/lib/radio/README.md +423 -0
- package/lib/rate/README.md +248 -0
- package/lib/search/README.md +290 -0
- package/lib/sidebar/README.md +176 -0
- package/lib/skeleton/README.md +141 -0
- package/lib/slider/README.md +444 -0
- package/lib/stepper/README.md +231 -0
- package/lib/sticky/README.md +91 -0
- package/lib/swipe-cell/README.md +217 -0
- package/lib/switch/README.md +316 -0
- package/lib/tab/README.md +501 -0
- package/lib/tabbar/README.md +397 -0
- package/lib/tag/README.md +215 -0
- package/lib/toast/README.md +293 -0
- package/lib/transition/README.md +140 -0
- package/lib/tree-select/README.md +348 -0
- package/package.json +3 -3
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 数据录入
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Field 输入框
|
|
6
|
+
|
|
7
|
+
### 介绍
|
|
8
|
+
|
|
9
|
+
输入框
|
|
10
|
+
|
|
11
|
+
### 引入
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { Field } from '@ray-js/smart-ui';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 代码演示
|
|
18
|
+
|
|
19
|
+
### 基础用法
|
|
20
|
+
|
|
21
|
+
`hiddenLabel` 可以隐藏整个左侧内容。
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import { Field, CellGroup } from '@ray-js/smart-ui';
|
|
25
|
+
import React from 'react';
|
|
26
|
+
|
|
27
|
+
export default function Demo() {
|
|
28
|
+
const [value, setValue] = React.useState('');
|
|
29
|
+
const [value2, setValue2] = React.useState('');
|
|
30
|
+
const onChange = event => {
|
|
31
|
+
// event.detail 为当前输入的值
|
|
32
|
+
console.log(event.detail);
|
|
33
|
+
};
|
|
34
|
+
const onChange2 = event => {
|
|
35
|
+
setValue2(event.detail);
|
|
36
|
+
};
|
|
37
|
+
return (
|
|
38
|
+
<CellGroup>
|
|
39
|
+
<Field value={value} label="标题" placeholder="请输入" onChange={onChange} />
|
|
40
|
+
<Field value={value} label="标题" placeholder="请输入" hiddenLabel onChange={onChange2} />
|
|
41
|
+
</CellGroup>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 修改输入框内容 `v2.7.1`
|
|
47
|
+
|
|
48
|
+
`extraEventParams` 开启事件增强模式,会在 `onInput` 和 `onChange` 事件额外提供 `callback` 方法,将需要修改的值传入 `callback` 方法内就可以强行修改输入框的内容
|
|
49
|
+
|
|
50
|
+
```jsx
|
|
51
|
+
import { Field, CellGroup } from '@ray-js/smart-ui';
|
|
52
|
+
import React from 'react';
|
|
53
|
+
|
|
54
|
+
export default function Demo() {
|
|
55
|
+
const [value, setValue] = React.useState('');
|
|
56
|
+
const onChange = event => {
|
|
57
|
+
console.log(event, '--event');
|
|
58
|
+
const { value } = event.detail;
|
|
59
|
+
const showValue = `test${value.slice(-1)[0]}`;
|
|
60
|
+
event.detail.callback({ value: showValue });
|
|
61
|
+
setValue(showValue);
|
|
62
|
+
};
|
|
63
|
+
return (
|
|
64
|
+
<CellGroup>
|
|
65
|
+
<Field value={value} label="标题" placeholder="请输入" onChange={onChange} />
|
|
66
|
+
</CellGroup>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 自定义类型
|
|
72
|
+
|
|
73
|
+
根据`type`属性定义不同类型的输入框;`cardMode` 开启此模式可以开启卡片输入模式。
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
import { Field, CellGroup } from '@ray-js/smart-ui';
|
|
77
|
+
import React from 'react';
|
|
78
|
+
|
|
79
|
+
export default function Demo() {
|
|
80
|
+
const [password, setPassword] = React.useState('');
|
|
81
|
+
const [num, setNum] = React.useState('');
|
|
82
|
+
return (
|
|
83
|
+
<CellGroup>
|
|
84
|
+
<Field value={password} type="password" label="密码" placeholder="请输入" />
|
|
85
|
+
<Field
|
|
86
|
+
value={num}
|
|
87
|
+
cardMode
|
|
88
|
+
type="number"
|
|
89
|
+
subLabel="副标题"
|
|
90
|
+
label="标题"
|
|
91
|
+
placeholder="请输入"
|
|
92
|
+
/>
|
|
93
|
+
</CellGroup>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 禁用输入框
|
|
99
|
+
|
|
100
|
+
`disabled` 可以设置整个输入框禁用。
|
|
101
|
+
|
|
102
|
+
```jsx
|
|
103
|
+
import { Field, CellGroup } from '@ray-js/smart-ui';
|
|
104
|
+
import React from 'react';
|
|
105
|
+
|
|
106
|
+
export default function Demo() {
|
|
107
|
+
const [value, setValue] = React.useState('');
|
|
108
|
+
const [num, setNum] = React.useState('');
|
|
109
|
+
return (
|
|
110
|
+
<CellGroup>
|
|
111
|
+
<Field value={value} disabled placeholder="输入框已禁用" label="标题" />
|
|
112
|
+
<Field value={num} cardMode disabled subLabel="副标题" label="标题" placeholder="请输入" />
|
|
113
|
+
</CellGroup>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 显示图标
|
|
119
|
+
|
|
120
|
+
使用插槽 `leftIcon` 可以插入左侧的图标。
|
|
121
|
+
|
|
122
|
+
```jsx
|
|
123
|
+
import { Field, Icon, CellGroup } from '@ray-js/smart-ui';
|
|
124
|
+
import { Sun } from '@tuya-miniapp/icons/dist/svg/Sun';
|
|
125
|
+
import { Image } from '@ray-js/ray';
|
|
126
|
+
import React from 'react';
|
|
127
|
+
|
|
128
|
+
export default function Demo() {
|
|
129
|
+
const [num, setNum] = React.useState('');
|
|
130
|
+
return (
|
|
131
|
+
<CellGroup>
|
|
132
|
+
<Field
|
|
133
|
+
label="标题"
|
|
134
|
+
placeholder="请输入"
|
|
135
|
+
slot={{
|
|
136
|
+
leftIcon: <Icon name={Sun} color="#3678E3" size="22" />,
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
<Field
|
|
140
|
+
value={num}
|
|
141
|
+
cardMode
|
|
142
|
+
label="标题"
|
|
143
|
+
placeholder="请输入"
|
|
144
|
+
slot={{
|
|
145
|
+
leftIcon: (
|
|
146
|
+
<Image
|
|
147
|
+
style={{ height: '50px', width: '50px' }}
|
|
148
|
+
src="https://images.tuyacn.com/rms-static/974a30f0-a624-11ef-be03-d1a4feb99779-1731986155903.png?tyName=light-img"
|
|
149
|
+
/>
|
|
150
|
+
),
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
</CellGroup>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 错误提示
|
|
159
|
+
|
|
160
|
+
通过`errorMessage`属性增加对应的错误提示;设置 `interError` 可以将错误信息覆盖 `placeholder` 的内容。
|
|
161
|
+
|
|
162
|
+
```jsx
|
|
163
|
+
import { Field, Icon, CellGroup } from '@ray-js/smart-ui';
|
|
164
|
+
import { Image } from '@ray-js/ray';
|
|
165
|
+
import React from 'react';
|
|
166
|
+
|
|
167
|
+
export default function Demo() {
|
|
168
|
+
const [value, setValue] = React.useState('');
|
|
169
|
+
const [num, setNum] = React.useState('');
|
|
170
|
+
return (
|
|
171
|
+
<CellGroup>
|
|
172
|
+
<Field label="标题" errorMessage="请输入用户名" interError required />
|
|
173
|
+
<Field value={value} label="标题" placeholder="请输入" errorMessage="格式错误" required />
|
|
174
|
+
<Field
|
|
175
|
+
value={num}
|
|
176
|
+
cardMode
|
|
177
|
+
label="标题"
|
|
178
|
+
subLabel="标题"
|
|
179
|
+
placeholder="请输入"
|
|
180
|
+
errorMessage="格式错误"
|
|
181
|
+
required
|
|
182
|
+
slot={{
|
|
183
|
+
leftIcon: (
|
|
184
|
+
<Image
|
|
185
|
+
style={{ height: '50px', width: '50px' }}
|
|
186
|
+
src="https://images.tuyacn.com/rms-static/974a30f0-a624-11ef-be03-d1a4feb99779-1731986155903.png?tyName=light-img"
|
|
187
|
+
/>
|
|
188
|
+
),
|
|
189
|
+
}}
|
|
190
|
+
/>
|
|
191
|
+
</CellGroup>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 插入按钮
|
|
197
|
+
|
|
198
|
+
通过 button slot 可以在输入框尾部插入按钮。
|
|
199
|
+
|
|
200
|
+
```jsx
|
|
201
|
+
import { Field, Button, CellGroup } from '@ray-js/smart-ui';
|
|
202
|
+
import React from 'react';
|
|
203
|
+
|
|
204
|
+
export default function Demo() {
|
|
205
|
+
const [num, setNum] = React.useState('');
|
|
206
|
+
return (
|
|
207
|
+
<CellGroup>
|
|
208
|
+
<Field
|
|
209
|
+
value={num}
|
|
210
|
+
label="标题"
|
|
211
|
+
placeholder="请输入短信验证码"
|
|
212
|
+
type="number"
|
|
213
|
+
inputAlign="left"
|
|
214
|
+
slot={{
|
|
215
|
+
button: (
|
|
216
|
+
<Button type="info" custom-class="button">
|
|
217
|
+
发送验证码
|
|
218
|
+
</Button>
|
|
219
|
+
),
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
</CellGroup>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### 数字格式化 `v2.12.0`
|
|
228
|
+
|
|
229
|
+
开启 `numberFormat` 后,组件会根据当前语言环境进行数字输入的千分位、小数位格式化展示;通过 `locale` 可指定地区格式(如 `de` 为德语 1.234,56,默认与英文为 1,234.56)。
|
|
230
|
+
|
|
231
|
+
```jsx
|
|
232
|
+
import { Field, CellGroup } from '@ray-js/smart-ui';
|
|
233
|
+
import React from 'react';
|
|
234
|
+
|
|
235
|
+
export default function Demo() {
|
|
236
|
+
const [numberFormatValue, setNumberFormatValue] = React.useState(12345.67);
|
|
237
|
+
const [numberFormatValueDe, setNumberFormatValueDe] = React.useState(12345.67);
|
|
238
|
+
return (
|
|
239
|
+
<CellGroup>
|
|
240
|
+
<Field
|
|
241
|
+
value={numberFormatValue}
|
|
242
|
+
numberFormat
|
|
243
|
+
label="金额"
|
|
244
|
+
placeholder="请输入"
|
|
245
|
+
onInput={e => setNumberFormatValue(e.detail)}
|
|
246
|
+
/>
|
|
247
|
+
<Field
|
|
248
|
+
value={numberFormatValueDe}
|
|
249
|
+
numberFormat
|
|
250
|
+
locale="de"
|
|
251
|
+
label="金额(德语格式)"
|
|
252
|
+
placeholder="请输入"
|
|
253
|
+
onInput={e => setNumberFormatValueDe(e.detail)}
|
|
254
|
+
/>
|
|
255
|
+
</CellGroup>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
组件同时导出了以下数字格式化工具函数,可在组件外部独立使用:
|
|
261
|
+
|
|
262
|
+
```jsx
|
|
263
|
+
import { getNumberFormatConfig, parseFormattedNumber, formatNumber } from '@ray-js/smart-ui';
|
|
264
|
+
|
|
265
|
+
// 获取指定地区的千分位和小数点分隔符配置
|
|
266
|
+
const config = getNumberFormatConfig('de');
|
|
267
|
+
// => { thousandsSeparator: '.', decimalSeparator: ',' }
|
|
268
|
+
|
|
269
|
+
// 将纯数字字符串格式化为带千分位的展示值
|
|
270
|
+
const display = formatNumber('12345.67', 'de');
|
|
271
|
+
// => '12.345,67'
|
|
272
|
+
|
|
273
|
+
// 将格式化后的字符串解析回纯数字字符串
|
|
274
|
+
const raw = parseFormattedNumber('12.345,67', 'de');
|
|
275
|
+
// => '12345.67'
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### 留言
|
|
279
|
+
|
|
280
|
+
设置 type 为 `textarea` 模式时,可以在末尾显示输入的字数数量和限制数量。
|
|
281
|
+
|
|
282
|
+
```jsx
|
|
283
|
+
import { Field, CellGroup } from '@ray-js/smart-ui';
|
|
284
|
+
import React from 'react';
|
|
285
|
+
|
|
286
|
+
export default function Demo() {
|
|
287
|
+
const [message, setMessage] = React.useState('');
|
|
288
|
+
const onChange = event => {
|
|
289
|
+
setMessage(event.detail);
|
|
290
|
+
};
|
|
291
|
+
return (
|
|
292
|
+
<Field
|
|
293
|
+
value={message}
|
|
294
|
+
label="事项"
|
|
295
|
+
type="textarea"
|
|
296
|
+
placeholder="请输入留言"
|
|
297
|
+
showWordLimit
|
|
298
|
+
maxlength={200}
|
|
299
|
+
onChange={onChange}
|
|
300
|
+
/>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## API
|
|
306
|
+
|
|
307
|
+
### Props
|
|
308
|
+
|
|
309
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
310
|
+
| ----------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------- | ------- |
|
|
311
|
+
| adjustPosition | 键盘弹起时,是否自动上推页面 | _boolean_ | `true` |
|
|
312
|
+
| alwaysEmbed `v1.9.2` | 强制 input 处于同层状态,默认 focus 时 input 会切到非同层状态 (仅在 iOS 下生效) | _boolean_ | `false` |
|
|
313
|
+
| arrowDirection | 箭头方向,可选值为 `left` `up` `down` | _string_ | - |
|
|
314
|
+
| autoFocus `@deprecated 小程序不支持` | 自动聚焦,拉起键盘 | _boolean_ | `false` |
|
|
315
|
+
| autosize | 是否自适应内容高度,只对 textarea 有效,<br>可传入对象,如 { maxHeight: 100, minHeight: 50 },<br>单位为`px` | _boolean \| object_ | `false` |
|
|
316
|
+
| border | 是否显示内边框 | _boolean_ | `false` |
|
|
317
|
+
| center | 是否使内容垂直居中 | _boolean_ | `false` |
|
|
318
|
+
| clearIconAriaLabel `v2.13.0` | 清除按钮的无障碍读屏文案,透传至清除图标的 `aria-label` | _string_ | - |
|
|
319
|
+
| clearTrigger `v1.8.4` | 显示清除图标的时机,`always` 表示输入框不为空时展示,<br>`focus` 表示输入框聚焦且不为空时展示 | _string_ | `focus` |
|
|
320
|
+
| clearable | 是否启用清除控件 | _boolean_ | `false` |
|
|
321
|
+
| clickable | 是否开启点击反馈 | _boolean_ | `false` |
|
|
322
|
+
| confirmHold | 点击键盘右下角按钮时是否保持键盘不收起,在 type='textarea' 时无效 | _boolean_ | `false` |
|
|
323
|
+
| confirmType | 设置键盘右下角按钮的文字,仅在 type='text' 时生效 | _string_ | `done` |
|
|
324
|
+
| cursor | 指定 focus 时的光标位置 | _number_ | `-1` |
|
|
325
|
+
| cursorSpacing | 输入框聚焦时底部与键盘的距离 | _number_ | `50` |
|
|
326
|
+
| customStyle | 自定义样式 | _React.CSSProperties_ | - |
|
|
327
|
+
| disableDefaultPadding | 是否去掉 iOS 下的默认内边距,只对 textarea 有效 | _boolean_ | `true` |
|
|
328
|
+
| disabled | 是否禁用输入框 | _boolean_ | `false` |
|
|
329
|
+
| error | 是否将输入内容标红 | _boolean_ | `false` |
|
|
330
|
+
| errorMessage | 底部错误提示文案,为空时不展示 | _string_ | `''` |
|
|
331
|
+
| errorMessageAlign | 底部错误提示文案对齐方式,可选值为 `center` `right` | _string_ | `''` |
|
|
332
|
+
| extraEventParams `v1.10.12` | 开启事件增强模式,会在 input 和 change 事件额外提供 `cursor` 和 `keyCode` 参数,计划在下一个大版本作为默认行为 | _boolean_ | `false` |
|
|
333
|
+
| fixed | 如果 type 为 `textarea` 且在一个 `position:fixed` 的区域,需要显示指定属性 fixed 为 true | _boolean_ | `false` |
|
|
334
|
+
| focus `@deprecated 小程序不支持` | 获取焦点 | _boolean_ | `false` |
|
|
335
|
+
| holdKeyboard | focus 时,点击页面的时候不收起键盘 | _boolean_ | `false` |
|
|
336
|
+
| inputAlign | 输入框内容对齐方式,可选值为 `center` `right` | _string_ | - |
|
|
337
|
+
| isLink | 是否展示右侧箭头并开启点击反馈 | _boolean_ | `false` |
|
|
338
|
+
| label | 输入框左侧文本 | _string_ | - |
|
|
339
|
+
| leftIcon | 左侧图标svg值或图片链接,可选值见 [Icon 组件](/material/smartui?comId=icon) | _string_ | - |
|
|
340
|
+
| maxlength | 最大输入长度,设置为 -1 的时候不限制最大长度 | _number_ | `-1` |
|
|
341
|
+
| name | 在表单内提交时的标识符。可以通过配置 `name` 来扩大点击区域 | _string_ | - |
|
|
342
|
+
| numberFormat `v2.12.0` | 是否开启数字格式化(千分位、小数位按 locale 展示) | _boolean_ | `false` |
|
|
343
|
+
| locale `v2.12.0` | 数字格式化使用的地区,如 `de`、`fr`,空则跟随系统 | _string_ | `''` |
|
|
344
|
+
| password | 是否是密码类型 | _boolean_ | `false` |
|
|
345
|
+
| placeholder | 输入框为空时占位符 | _string_ | - |
|
|
346
|
+
| placeholderStyle | 指定 placeholder 的样式 | _React.CSSProperties_ | - |
|
|
347
|
+
| readonly | 是否只读 | _boolean_ | `false` |
|
|
348
|
+
| required | 是否显示表单必填星号 | _boolean_ | `false` |
|
|
349
|
+
| rightIcon | 右侧图标svg值或图片链接,可选值见 [Icon 组件](/material/smartui?comId=icon) | _string_ | - |
|
|
350
|
+
| rightIconButtonAriaLabel `v2.13.0` | 右侧图标按钮的无障碍读屏文案,设置在图标容器的 `aria-label` 上 | _string_ | - |
|
|
351
|
+
| selectionEnd | 光标结束位置,自动聚集时有效,需与 selection-start 搭配使用 | _number_ | `-1` |
|
|
352
|
+
| selectionStart | 光标起始位置,自动聚集时有效,需与 selection-end 搭配使用 | _number_ | `-1` |
|
|
353
|
+
| showConfirmBar | 是否显示键盘上方带有”完成“按钮那一栏,只对 textarea 有效 | _boolean_ | `true` |
|
|
354
|
+
| showWordLimit | 是否显示字数统计,需要设置`maxlength`属性 | _boolean_ | `false` |
|
|
355
|
+
| size | 单元格大小,可选值为 `large` | _string_ | - |
|
|
356
|
+
| titleWidth | 标题宽度 | _string_ | `6.2em` |
|
|
357
|
+
| type | 可设置为任意原生类型, 如 `number` `idcard` `textarea` `digit` `nickname` | _string_ | `text` |
|
|
358
|
+
| value | 当前输入的值 | _string \| number_ | - |
|
|
359
|
+
| interError `v2.1.0` | 错误信息是否在输入框内 | _boolean_ | - |
|
|
360
|
+
| subLabel `v2.1.0` | 副标题 | _string_ | - |
|
|
361
|
+
| cardMode `v2.1.0` | 卡片模式 | _boolean_ | - |
|
|
362
|
+
| hiddenLabel `v2.1.0` | 隐藏左侧label相关内容 | _boolean_ | - |
|
|
363
|
+
|
|
364
|
+
### Events
|
|
365
|
+
|
|
366
|
+
| 事件 | 说明 | 回调参数 |
|
|
367
|
+
| ----------------------------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
|
|
368
|
+
| onBlur | 输入框失焦时触发 | event.detail.value: 当前输入值; <br>event.detail.cursor: 游标位置(如果 `type` 不为 `textarea`,值为 `0`) |
|
|
369
|
+
| onChange | 输入内容时触发 | event.detail: 当前输入值; 在 extra-event-params 为 `true` 时为 [InputDetail](#InputDetail) |
|
|
370
|
+
| onClear | 点击清空控件时触发 | - |
|
|
371
|
+
| onClickIcon | 点击尾部图标时触发 | - |
|
|
372
|
+
| onClickInput | 点击输入区域时触发 | - |
|
|
373
|
+
| onConfirm | 点击完成按钮时触发 | event.detail: 当前输入值 |
|
|
374
|
+
| onFocus | 输入框聚焦时触发 | event.detail.value: 当前输入值; <br>event.detail.height: 键盘高度 |
|
|
375
|
+
| onInput | 输入内容时触发 | event.detail: 当前输入值; 在 extra-event-params 为 `true` 时为 [InputDetail](#InputDetail) |
|
|
376
|
+
| onKeyboardheightchange | 键盘高度发生变化的时候触发此事件 | event.detail = { height: height, duration: duration } |
|
|
377
|
+
| onLinechange | 输入框行数变化时调用,只对 textarea 有效 | event.detail = { height: 0, heightRpx: 0, lineCount: 0 } |
|
|
378
|
+
| onNicknamereview `v1.11.5` | 用户昵称审核完毕后触发,仅在 type 为 "nickname" 时有效 | event.detail = { pass, timeout } |
|
|
379
|
+
|
|
380
|
+
### InputDetail
|
|
381
|
+
|
|
382
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
383
|
+
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ------ |
|
|
384
|
+
| callback | 调用该函数传 `{ value: string, cursor: number }` 来替换输入框的内容,具体用法可以参考 [wx-input](https://developers.weixin.qq.com/miniprogram/dev/component/input.html) | _function_ | - |
|
|
385
|
+
| cursor | 光标位置 | _number_ | - |
|
|
386
|
+
| keyCode | 键值 | _number_ | - |
|
|
387
|
+
| value | 当前输入值 | _string_ | - |
|
|
388
|
+
|
|
389
|
+
### Slot
|
|
390
|
+
|
|
391
|
+
| 名称 | 说明 |
|
|
392
|
+
| ---------- | ---------------------------------------------------------- |
|
|
393
|
+
| button | 自定义输入框尾部按钮 |
|
|
394
|
+
| input | 自定义输入框,使用此插槽后,与输入框相关的属性和事件将失效 |
|
|
395
|
+
| label | 自定义输入框标签,如果设置了`label`属性则不生效 |
|
|
396
|
+
| leftIcon | 自定义输入框头部图标 |
|
|
397
|
+
| rightIcon | 自定义输入框尾部图标 |
|
|
398
|
+
|
|
399
|
+
### 外部样式类
|
|
400
|
+
|
|
401
|
+
| 类名 | 说明 |
|
|
402
|
+
| ----------------------- | -------------- |
|
|
403
|
+
| customClass `v1.10.21` | 根节点样式类 |
|
|
404
|
+
| inputClass | 输入框样式类 |
|
|
405
|
+
| labelClass | 左侧文本样式类 |
|
|
406
|
+
| rightIconClass | 右侧图标样式类 |
|
|
407
|
+
|
|
408
|
+
### 样式变量
|
|
409
|
+
|
|
410
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider)。
|
|
411
|
+
|
|
412
|
+
| 名称 | 默认值 | 描述 |
|
|
413
|
+
| ----------------------------- | -------------------------------------- | ---- |
|
|
414
|
+
| --field-label-color | _var(--app-B6-N1, rgba(0, 0, 0, 1))_ | label颜色 |
|
|
415
|
+
| --field-input-text-color | _var(--app-B6-N1, rgba(0, 0, 0, 1))_ | input文字颜色 |
|
|
416
|
+
| --field-input-text-font-size `v2.1.0` | _16px_ | 输入框内的字体大小 |
|
|
417
|
+
| --field-input-error-text-color | _var(--app-M2, #f04c4c)_ | error模式文字颜色 |
|
|
418
|
+
| --field-placeholder-text-color | _var(--app-B6-N4, rgba(0, 0, 0, 0.4))_ | placeholder文字颜色 |
|
|
419
|
+
| --field-icon-size | _16px_ | icon字体大小 |
|
|
420
|
+
| --field-clear-icon-size | _16px_ | 清楚icon字体大小 |
|
|
421
|
+
| --field-clear-icon-color | _var(--app-B4-N4, rgba(0, 0, 0, 0.4))_ | 清除icon颜色 |
|
|
422
|
+
| --field-icon-container-color | _#969799_ | 右侧icon盒子字体颜色 |
|
|
423
|
+
| --field-error-message-color | _var(--app-M2, #f04c4c)_ | 错误提示文字颜色 |
|
|
424
|
+
| --field-error-message-text-font-size | _14px_ | 提示文字字体大小 |
|
|
425
|
+
| --field-text-area-min-height | _130px_ | textarea最小高度 |
|
|
426
|
+
| --field-word-limit-color | _var(--app-B6-N4, rgba(0, 0, 0, 0.4))_ | 输入长度限制文字颜色 |
|
|
427
|
+
| --field-disabled-opacity `v2.1.0` | _0.7_ | 禁用透明度 |
|
|
428
|
+
| --field-label-font-size `v2.1.0` | _16px_ | label字体大小 |
|
|
429
|
+
| --field-label-line-height `v2.1.0` | _18px_ | label标题字体高度 |
|
|
430
|
+
| --field-sub-label-font-size `v2.1.0` | _14px_ | 副标题字体大小 |
|
|
431
|
+
| --field-sub-label-line-height `v2.1.0` | _16px_ | 副标题字体高度 |
|
|
432
|
+
| --field-error-message-text-line-height `v2.1.0` | _16px_ | 错误提示字体高度 |
|
|
433
|
+
| --field-subtitle-text-color `v2.1.0` | _var(--app-B6-N3, rgba(0, 0, 0, 0.5))_ | 副标题颜色 |
|
|
434
|
+
| --field-left-icon-margin-right `v2.1.0` | _10px_ | icon的右侧外边距 |
|
|
435
|
+
| --field-left-body-padding-right `v2.1.0` | _16px_ | 左侧部分的右内边距 |
|
|
436
|
+
|
|
437
|
+
#### card模式CSS变量
|
|
438
|
+
| 名称 | 默认值 | 描述 |
|
|
439
|
+
| ----------------------------- | -------------------------------------- | ---- |
|
|
440
|
+
| --field-card-border-radius `v2.1.0` | _8px_ | 卡片边框圆角 |
|
|
441
|
+
| --field-card-background `v2.1.0` | _var(--app-B6-N7, rgba(0, 0, 0, 0.1))_ | 卡片输入输背景色 |
|
|
442
|
+
| --field-card-width `v2.1.0` | _105px_ | 卡片输入宽度 |
|
|
443
|
+
| --field-card-height `v2.1.0` | _38px_ | 卡片输入高度 |
|
|
444
|
+
| --field-card-padding `v2.1.0` | _0 10px_ | 卡片输入框内部padding |
|
|
445
|
+
|
|
446
|
+
#### textarea CSS变量
|
|
447
|
+
| 名称 | 默认值 | 描述 |
|
|
448
|
+
| ----------------------------- | -------------------------------------- | ---- |
|
|
449
|
+
| --field-word-limit-font-size | _10px_ | 输入长度限制文字字体大小 |
|
|
450
|
+
| --field-word-limit-line-height | _14px_ | 输入长度限制文字字体高度 |
|
|
451
|
+
| --field-word-num-full-color | _var(--app-M2, #f04c4c)_ | 输入长度超出限制文字颜色 |
|
|
452
|
+
| --field-textarea-background `v2.1.0` | _var(--app-B3, #ffffff)_ | 输入框背景色 |
|
|
453
|
+
| --field-textarea-border-radius `v2.1.0` | _8px_ | 输入框圆角 |
|
|
454
|
+
| --field-textarea-padding `v2.1.0` | _12px 8px_ | 输入内边距 |
|
|
455
|
+
| --field-textarea-limit-padding-bottom `v2.1.0` | _20px_ | 输入框底部显示限制字符串数量时的内边距 |
|