@mijadesign/nut-mcp 1.0.0-alpha.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.
Files changed (58) hide show
  1. package/README.md +147 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +16 -0
  4. package/dist/services/aliases.service.d.ts +1 -0
  5. package/dist/services/aliases.service.js +19 -0
  6. package/dist/services/doc-parser.service.d.ts +3 -0
  7. package/dist/services/doc-parser.service.js +162 -0
  8. package/dist/services/index.services.d.ts +3 -0
  9. package/dist/services/index.services.js +71 -0
  10. package/dist/services/paths.service.d.ts +5 -0
  11. package/dist/services/paths.service.js +18 -0
  12. package/dist/tools/base.tool.d.ts +8 -0
  13. package/dist/tools/base.tool.js +27 -0
  14. package/dist/tools/get-component-doc.tool.d.ts +12 -0
  15. package/dist/tools/get-component-doc.tool.js +40 -0
  16. package/dist/tools/index.d.ts +4 -0
  17. package/dist/tools/index.js +4 -0
  18. package/dist/tools/list-components.tool.d.ts +8 -0
  19. package/dist/tools/list-components.tool.js +32 -0
  20. package/dist/tools/search-components.tool.d.ts +12 -0
  21. package/dist/tools/search-components.tool.js +61 -0
  22. package/dist/types/index.d.ts +33 -0
  23. package/dist/types/index.js +1 -0
  24. package/docs/docs/aliases.json +59 -0
  25. package/docs/docs/components/base/button/index.md +415 -0
  26. package/docs/docs/components/base/cell/index.md +279 -0
  27. package/docs/docs/components/base/configprovider/index.md +215 -0
  28. package/docs/docs/components/base/image/index.md +282 -0
  29. package/docs/docs/components/base/overlay/index.md +288 -0
  30. package/docs/docs/components/dentry/cascader/index.md +1080 -0
  31. package/docs/docs/components/dentry/checkbox/index.md +842 -0
  32. package/docs/docs/components/dentry/datepicker/index.md +489 -0
  33. package/docs/docs/components/dentry/form/index.md +457 -0
  34. package/docs/docs/components/dentry/input/index.md +257 -0
  35. package/docs/docs/components/dentry/picker/index.md +621 -0
  36. package/docs/docs/components/dentry/radio/index.md +364 -0
  37. package/docs/docs/components/dentry/searchbar/index.md +317 -0
  38. package/docs/docs/components/dentry/selector/index.md +295 -0
  39. package/docs/docs/components/dentry/switch/index.md +300 -0
  40. package/docs/docs/components/dentry/textarea/index.md +231 -0
  41. package/docs/docs/components/dentry/uploader/index.md +745 -0
  42. package/docs/docs/components/exhibition/collapse/index.md +339 -0
  43. package/docs/docs/components/exhibition/swiper/index.md +385 -0
  44. package/docs/docs/components/exhibition/tag/index.md +253 -0
  45. package/docs/docs/components/feedback/dialog/index.md +306 -0
  46. package/docs/docs/components/feedback/drag/index.md +164 -0
  47. package/docs/docs/components/feedback/empty/index.md +211 -0
  48. package/docs/docs/components/feedback/infiniteloading/index.md +397 -0
  49. package/docs/docs/components/feedback/noticebar/index.md +175 -0
  50. package/docs/docs/components/feedback/popup/index.md +563 -0
  51. package/docs/docs/components/feedback/pulltorefresh/index.md +254 -0
  52. package/docs/docs/components/feedback/toast/index.md +355 -0
  53. package/docs/docs/components/layout/divider/index.md +162 -0
  54. package/docs/docs/components/layout/grid/index.md +386 -0
  55. package/docs/docs/components/layout/space/index.md +196 -0
  56. package/docs/docs/components/nav/tabs/index.md +955 -0
  57. package/docs/docs/components-index.json +233 -0
  58. package/package.json +34 -0
@@ -0,0 +1,457 @@
1
+ ---
2
+ order: 9
3
+ demoUrl: 'https://frontend.mishudata.com/mobile/demo/#/dentry/pages/form/index'
4
+ group:
5
+ title: 数据录入
6
+ order: 5
7
+ ---
8
+
9
+ # Form 表单 <Badge>2.0.0</Badge>
10
+
11
+
12
+ 用于数据录入、校验,支持输入框、单选框、复选框等类型。
13
+
14
+ ## 引入
15
+
16
+ ```tsx
17
+ import { Form } from '@mijadesign/mjui-react-taro'
18
+ ```
19
+
20
+ ## 示例代码
21
+
22
+ ### 基础样式
23
+
24
+
25
+ ```tsx
26
+ import React from 'react'
27
+ import { Form, Input } from '@mijadesign/mjui-react-taro'
28
+
29
+ const Demo1 = () => {
30
+ return (
31
+ <Form>
32
+ <Form.Item label="文本标签" name="text" rules={[{ required: true, message: '请输入用户名' }]}>
33
+ <Input align="right" placeholder="请输入" />
34
+ </Form.Item>
35
+ </Form>
36
+ )
37
+ }
38
+
39
+ export default Demo1
40
+
41
+ ```
42
+
43
+ ### 带图标样式
44
+
45
+
46
+ ```tsx
47
+ import React from 'react';
48
+ import { Form, Input } from '@mijadesign/mjui-react-taro';
49
+ import { Information } from '@mijadesign/mobile-icons';
50
+
51
+ const Demo2 = () => {
52
+ return (
53
+ <>
54
+ <Form>
55
+ <Form.Item
56
+ label='文本标签'
57
+ labelExtra={<Information style={{ color: '#999' }} />}
58
+ name='username'
59
+ rules={[{ required: true, message: '请输入' }]}
60
+ >
61
+ <Input align='right' placeholder='请输入' type='text' />
62
+ </Form.Item>
63
+ </Form>
64
+ </>
65
+ );
66
+ };
67
+
68
+ export default Demo2;
69
+
70
+ ```
71
+ ### 布局方式
72
+
73
+
74
+ ```tsx
75
+ import React from 'react';
76
+ import { Form, Input, TextArea } from '@mijadesign/mjui-react-taro';
77
+
78
+ const Demo3 = () => {
79
+ return (
80
+ <>
81
+ <Form>
82
+ <Form.Item label='水平布局' name='username' rules={[{ required: true }]}>
83
+ <Input placeholder='请输入' type='text' align='right' />
84
+ </Form.Item>
85
+ <Form.Item label='垂直布局' name='age' layout='vertical' rules={[{ required: true }]}>
86
+ <TextArea align='left' placeholder='请输入' maxLength={30} showCount />
87
+ </Form.Item>
88
+ </Form>
89
+ </>
90
+ );
91
+ };
92
+
93
+ export default Demo3;
94
+
95
+ ```
96
+ ### 关联展示
97
+
98
+
99
+ ```tsx
100
+ import React from 'react';
101
+ import { Form, Input, TextArea, type FormInstance } from '@mijadesign/mjui-react-taro';
102
+
103
+ const Demo4 = () => {
104
+ return (
105
+ <>
106
+ <Form>
107
+ <Form.Item label='文本标签' name='username' rules={[{ required: true }]}>
108
+ <Input align='right' placeholder='请输入' type='text' />
109
+ </Form.Item>
110
+ <Form.Item shouldUpdate noStyle>
111
+ {({ getFieldValue }: FormInstance) => {
112
+ const value = getFieldValue('username');
113
+ if (!value) return null;
114
+ return (
115
+ <Form.Item label='文本标签' name='age' rules={[{ required: true }]}>
116
+ <TextArea autoSize placeholder='请输入' maxLength={100} />
117
+ </Form.Item>
118
+ );
119
+ }}
120
+ </Form.Item>
121
+ </Form>
122
+ </>
123
+ );
124
+ };
125
+
126
+ export default Demo4;
127
+
128
+ ```
129
+
130
+ ### Form.useForm 对表单数据域进行交互。
131
+
132
+
133
+ ```tsx
134
+ import React from 'react';
135
+ import { Form, Input, Radio } from '@mijadesign/mjui-react-taro';
136
+ import Taro from '@tarojs/taro';
137
+
138
+ const Demo5 = () => {
139
+ const [form] = Form.useForm();
140
+ const submitFailed = (error: any) => {
141
+ Taro.showToast({ title: JSON.stringify(error), icon: 'error' });
142
+ };
143
+
144
+ const submitSucceed = (values: any) => {
145
+ Taro.showToast({ title: JSON.stringify(values), icon: 'success' });
146
+ };
147
+
148
+ const onMenuChange = (value: string | number | boolean) => {
149
+ switch (value) {
150
+ case 'male':
151
+ form.setFieldsValue({ note: '👨' });
152
+ break;
153
+ case 'female':
154
+ form.setFieldsValue({ note: '👩' });
155
+ break;
156
+ default:
157
+ }
158
+ };
159
+ return (
160
+ <>
161
+ <Form
162
+ form={form}
163
+ onFinish={(values) => submitSucceed(values)}
164
+ onFinishFailed={(values, errors) => submitFailed(errors)}
165
+ >
166
+ <Form.Item label='文本标签' name='username' rules={[{ required: true, message: '请输入' }]}>
167
+ <Input align='right' placeholder='请输入' type='text' />
168
+ </Form.Item>
169
+ <Form.Item label='标注' name='note'>
170
+ <Input align='right' placeholder='请输入' type='string' />
171
+ </Form.Item>
172
+ <Form.Item label='标注关联字段' name='gender'>
173
+ <Radio.Group direction='horizontal' style={{ justifyContent: 'flex-end' }} onChange={onMenuChange}>
174
+ <Radio value='male'>A</Radio>
175
+ <Radio value='female'>B</Radio>
176
+ </Radio.Group>
177
+ </Form.Item>
178
+ </Form>
179
+ </>
180
+ );
181
+ };
182
+
183
+ export default Demo5;
184
+
185
+ ```
186
+
187
+ ### 校验触发时机
188
+
189
+
190
+ ```tsx
191
+ import React from 'react';
192
+ import { Form, Input } from '@mijadesign/mjui-react-taro';
193
+
194
+ const Demo6 = () => {
195
+ return (
196
+ <>
197
+ <Form>
198
+ <Form.Item
199
+ label='文本标签'
200
+ name='username'
201
+ required
202
+ validateTrigger='onBlur'
203
+ rules={[{ required: true, message: '请输入' }]}
204
+ >
205
+ <Input align='right' placeholder='请输入' type='text' />
206
+ </Form.Item>
207
+ </Form>
208
+ </>
209
+ );
210
+ };
211
+
212
+ export default Demo6;
213
+
214
+ ```
215
+
216
+ ### 表单校验
217
+
218
+
219
+ ```tsx
220
+ import React from 'react'
221
+ import { Button, Form, Input, Toast, type FormItemRuleWithoutValidator } from '@mijadesign/mjui-react-taro'
222
+
223
+ const Demo7 = () => {
224
+ const submitFailed = (error: any) => {
225
+ Toast.show('toast', {
226
+ content: error?.[0]?.message,
227
+ })
228
+ }
229
+
230
+ const submitSucceed = (values: any) => {
231
+ Toast.show('toast', {
232
+ content: JSON.stringify(values),
233
+ })
234
+ }
235
+
236
+ // 函数校验
237
+ const customValidator = (rule: FormItemRuleWithoutValidator, value: string) => {
238
+ return /^\d+$/.test(value)
239
+ }
240
+
241
+ const valueRangeValidator = (rule: FormItemRuleWithoutValidator, value: string) => {
242
+ return /^(\d{1,2}|1\d{2}|200)$/.test(value)
243
+ }
244
+ return (
245
+ <>
246
+ <Form
247
+ toastId="toast"
248
+ onFinish={(values) => submitSucceed(values)}
249
+ onFinishFailed={(values, errors) => submitFailed(errors)}
250
+ footer={
251
+ <div
252
+ style={{
253
+ display: 'flex',
254
+ justifyContent: 'center',
255
+ width: '100%',
256
+ }}
257
+ >
258
+ <Button formType="reset" type="default" style={{ marginRight: '12px', flex: 1 }}>
259
+ 重置
260
+ </Button>
261
+ <Button formType="submit" type="primary" style={{ flex: 1 }}>
262
+ 提交
263
+ </Button>
264
+ </div>
265
+ }
266
+ >
267
+ <Form.Item label="文本标签" name="username" rules={[{ required: true, message: '请输入' }]}>
268
+ <Input align="right" placeholder="请输入" type="text" />
269
+ </Form.Item>
270
+ <Form.Item
271
+ label="文本标签"
272
+ name="age"
273
+ rules={[
274
+ { required: true, message: '请输入' },
275
+ { validator: customValidator, message: '必须输入数字' },
276
+ { validator: valueRangeValidator, message: '必须输入0-200区间' },
277
+ ]}
278
+ >
279
+ <Input align="right" placeholder="请输入" type="text" />
280
+ </Form.Item>
281
+ <Form.Item label="文本标签" name="tel" rules={[{ required: true, max: 13, message: '请输入' }]}>
282
+ <Input align="right" placeholder="请输入" type="number" />
283
+ </Form.Item>
284
+ <Form.Item label="文本标签" name="address" rules={[{ required: true, message: '请输入' }]}>
285
+ <Input align="right" placeholder="请输入" type="text" />
286
+ </Form.Item>
287
+ </Form>
288
+ <Toast id="toast" />
289
+ </>
290
+ )
291
+ }
292
+
293
+ export default Demo7
294
+
295
+ ```
296
+
297
+ ### Form.useWatch 对表单数据域进行交互。
298
+
299
+
300
+ ```tsx
301
+ import React from 'react';
302
+ import { Form, Input, Radio } from '@mijadesign/mjui-react-taro';
303
+ import { View } from '@tarojs/components';
304
+
305
+ const Demo8 = () => {
306
+ const [form] = Form.useForm();
307
+ const account = Form.useWatch('account', form);
308
+ const loginMethod = Form.useWatch('loginMethod', form);
309
+
310
+ return (
311
+ <Form
312
+ form={form}
313
+ initialValues={{ loginMethod: 'mobile', account: '123' }}
314
+ footer={
315
+ <>
316
+ <View
317
+ style={{
318
+ width: '100%',
319
+ }}
320
+ >
321
+ <View
322
+ style={{
323
+ fontSize: '12px',
324
+ textAlign: 'center',
325
+ marginBottom: '20px',
326
+ }}
327
+ >
328
+ 你将使用{loginMethod === 'mobile' ? '手机号' : '电子邮箱'}
329
+ {account}登录
330
+ </View>
331
+ </View>
332
+ </>
333
+ }
334
+ >
335
+ <Form.Item name='loginMethod' label='登录方式'>
336
+ <Radio.Group direction='horizontal' style={{ justifyContent: 'flex-end' }}>
337
+ <Radio value='mobile'>手机号</Radio>
338
+ <Radio value='email'>电子邮箱</Radio>
339
+ </Radio.Group>
340
+ </Form.Item>
341
+
342
+ <>
343
+ {loginMethod === 'mobile' && (
344
+ <Form.Item name='account' label='手机号'>
345
+ <Input align='right' placeholder='请输入手机号' />
346
+ </Form.Item>
347
+ )}
348
+ {loginMethod === 'email' && (
349
+ <Form.Item name='account' label='电子邮箱'>
350
+ <Input align='right' placeholder='请输入邮箱' />
351
+ </Form.Item>
352
+ )}
353
+ </>
354
+ </Form>
355
+ );
356
+ };
357
+
358
+ export default Demo8;
359
+
360
+ ```
361
+
362
+
363
+
364
+ ## Form
365
+
366
+ ### Props
367
+
368
+ | 属性 | 说明 | 类型 | 默认值 |
369
+ | --- | --- | --- | --- |
370
+ | form | 经 Form.useForm() 创建的 form 控制实例,不提供时会自动创建 | `FormInstance` | `-` |
371
+ | footer | 表单底部区域,一般放置确认和重置按钮 | `ReactNode` | `null` |
372
+ | initialValues | 表单初始值 | `any` | `-` |
373
+ | name | 表单名称 | `any` | `-` |
374
+ | labelPosition | 表单项 label 的位置 | \`\`'top' | 'left'\` | \`'left'\`\` |
375
+ | starPosition | 必填表单项 label 的红色星标位置 | `left` \| `right` | `right` |
376
+ | divider | 分割线 | `boolean` | `true` |
377
+ | requiredTipType | 触发校验形式 | `toast` \| `default` \| `none` | `toast` |
378
+ | validateTrigger | 统一设置字段触发验证的时机 | `string` \| `string[]`\| `false` | `onChange` |
379
+ | disabled | 是否禁用 | `boolean` | `false` |
380
+ | onFinish | 校验成功后触发 | `(values: any) => void` | `-` |
381
+ | onFinishFailed | 任一表单项被校验失败后触发 | `(values: any, errorFields: any) => void` | `-` |
382
+
383
+ ## Form.Item
384
+
385
+ ### Props
386
+
387
+ | 属性 | 说明 | 类型 | 默认值 |
388
+ | --- | --- | --- | --- |
389
+ | required | 必填表单项 label 的红色星标,仅用于控制样式 | `boolean` | `false` |
390
+ | name | 在使用表单校验功能的情况下,该属性是必填的 | `string` | `-` |
391
+ | label | 标签名 | `ReactNode` | `-` |
392
+ | labelExtra | 标签额外内容 | `ReactNode` | `-` |
393
+ | layout | 布局形式 | `vertical` \| `horizontal` | `horizontal` |
394
+ | errorMessageAlign | 错误提示文案对齐方式 | `center` \| `right` \| `left` | `left` |
395
+ | initialValue | 设置子元素默认值 | `any` | `-` |
396
+ | noStyle | 不使用样式,只使用字段管理 | `boolean` | `false` |
397
+ | shouldUpdate | 更新逻辑 | `boolean` | `false` |
398
+ | trigger | 设置收集字段值变更的时机 | `string` | `-` |
399
+ | align | 对齐方式 | `flex-start` \| `center` \| `flex-end` | `flex-start` |
400
+ | valuePropName | 子节点的值的属性,如 Checkbox 的是 'checked' | `string` | `-` |
401
+ | getValueFromEvent | 设置如何将 event 的值转换成字段值 | `(...args: any) => any` | `-` |
402
+ | validateTrigger | 统一设置字段触发验证的时机 | `string \| string[]` | `onChange` |
403
+ | onClick | 点击事件并收集子组件 Ref | `(event: React.MouseEvent, componentRef: React.MutableRefObject<any>) => void` | `-` |
404
+
405
+ ### Form.Item Rule
406
+
407
+ 规则校验处理基于[async-validator](https://github.com/yiminghe/async-validator) 更多规则配置可查看 async-validator 文档。 使用 Form.Item 的`rules`属性可以定义校验规则,可选属性如下:
408
+
409
+ | 属性 | 说明 | 类型 |
410
+ | --- | --- | --- |
411
+ | required | 是否为必选字段 | `boolean` |
412
+ | message | 错误提示文案 | `string` |
413
+ | len | string 类型时为字符串长度;number 类型时为确定数字; array 类型时为数组长度 | `number` |
414
+ | max | 必须设置 type:string 类型为字符串最大长度;number 类型时为最大值;array 类型时为数组最大长度 | `number` |
415
+ | min | 必须设置 type:string 类型为字符串最小长度;number 类型时为最小值;array 类型时为数组最小长度 | `number` |
416
+ | pattern | 正则表达式匹配 | `RegExp` |
417
+ | transform | 将字段值转换成目标值后进行校验 | `(value) => any` |
418
+ | validator | 自定义校验,接收 Promise 作为返回值 | `(rule, value) => Promise` |
419
+
420
+ ### FormInstance
421
+
422
+ `Form.useForm()`创建 Form 实例,用于管理所有数据状态。
423
+
424
+ | 属性 | 说明 | 类型 |
425
+ | --- | --- | --- |
426
+ | getFieldValue | 获取对应字段名的值 | `(name: NamePath) => any` |
427
+ | getFieldsValue | 获取一组字段名对应的值,会按照对应结构返回。默认返回现存字段值,当调用 getFieldsValue(true) 时返回所有值 | `(name: NamePath \| boolean) => any` |
428
+ | setFieldsValue | 设置表单的值(该值将直接传入 form store 中。如果你不希望传入对象被修改,请克隆后传入) | `(values) => void` |
429
+ | setFieldValue | 设置对应字段名的值 | `<T>(name: NamePath, value: T) => void` |
430
+ | resetFields | 重置表单提示状态 | `(namePaths?: NamePath[]) => void` |
431
+ | submit | 提交表单进行校验的方法 | `Promise` |
432
+
433
+ `Form.useWatch()`此方法将监视指定的输入并返回其值。它对于呈现输入值和确定根据条件呈现的内容很有用。
434
+
435
+ ## 主题定制
436
+
437
+ ### 样式变量
438
+
439
+ 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](#/zh-CN/component/configprovider)。
440
+
441
+ | 名称 | 说明 | 默认值 |
442
+ | --- | --- | --- |
443
+ | \--nutui-form-item-body-font-size | 表单容器的字号 | `$font-size-2` |
444
+ | \--nutui-form-item-body-input-text-align | 表单项输入框的文本对齐方式 | `left` |
445
+ | \--nutui-form-item-body-slots-text-align | 表单项文本对齐方式 | `left` |
446
+ | \--nutui-form-item-error-line-color | 错误信息边框颜色 | `$color-error` |
447
+ | \--nutui-form-item-error-message-color | 错误信息的文本颜色 | `$color-error` |
448
+ | \--nutui-form-item-label-font-size | label 字号 | `$font-size-2` |
449
+ | \--nutui-form-item-label-margin-right | label 右外边距 | `$spacing-3` |
450
+ | \--nutui-form-item-label-text-align | label 文本对齐方式 | `left` |
451
+ | \--nutui-form-item-label-width | label 宽度 | `90px` |
452
+ | \--nutui-form-item-required-color | 必选标识的字体颜色 | `$color-error` |
453
+ | \--nutui-form-item-required-margin-left | | `$spacing-0` |
454
+ | \--nutui-form-item-required-margin-right | label 必选的右外边距 | `4px` |
455
+ | \--nutui-form-item-tip-font-size | 错误信息的字号 | `$font-size-1` |
456
+ | \--nutui-form-item-tip-text-align | 错误信息的文本对齐方式 | `left` |
457
+ | \--nutui-form-item-vertical-gap | 垂直布局间距 | `$spacing-1` |
@@ -0,0 +1,257 @@
1
+ ---
2
+ order: 11
3
+ demoUrl: 'https://frontend.mishudata.com/mobile/demo/#/dentry/pages/input/index'
4
+ group:
5
+ title: 数据录入
6
+ order: 5
7
+ ---
8
+
9
+ # Input 输入框 <Badge>2.0.0</Badge>
10
+
11
+
12
+ 用户可以在文本框里输入内容。
13
+
14
+ ## 引入
15
+
16
+ ```tsx
17
+ import { Input } from '@mijadesign/mjui-react-taro';
18
+
19
+ ```
20
+
21
+ ## 示例代码
22
+
23
+ ### 基本用法
24
+
25
+
26
+ ```tsx
27
+ import React from 'react'
28
+ import { Input, Space } from '@mijadesign/mjui-react-taro'
29
+
30
+ const Demo1 = () => {
31
+ return (
32
+ <>
33
+ <Space style={{ padding: '0 16px' }} direction="vertical">
34
+ <Input underLine placeholder="请输入文本" />
35
+ </Space>
36
+ </>
37
+ )
38
+ }
39
+ export default Demo1
40
+
41
+ ```
42
+
43
+ ### 自定义类型
44
+
45
+
46
+ ```tsx
47
+ import React from 'react'
48
+ import { Input } from '@mijadesign/mjui-react-taro'
49
+
50
+ const Demo1 = () => {
51
+ return (
52
+ <div style={{ padding: '0 12px' }}>
53
+ <h4>01 仅支持数字</h4>
54
+ <Input underLine placeholder="请输入数字" type="digit" />
55
+ <h4>02 密码 - 支持密码可见</h4>
56
+ <Input underLine placeholder="请输入密码" type="password" />
57
+ <h4>03 整数</h4>
58
+ <Input underLine placeholder="请输入整数" type="number" />
59
+ </div>
60
+ )
61
+ }
62
+ export default Demo1
63
+
64
+ ```
65
+
66
+ ### 组件状态
67
+
68
+
69
+ ```tsx
70
+ import React from 'react'
71
+ import { Input, Space } from '@mijadesign/mjui-react-taro'
72
+
73
+ const Demo1 = () => {
74
+ return (
75
+ <>
76
+ <Space style={{ padding: '0 16px' }} direction="vertical">
77
+ <Input underLine value="只读状态" placeholder="只读状态" readOnly />
78
+ <Input underLine placeholder="禁用状态" disabled />
79
+ </Space>
80
+ </>
81
+ )
82
+ }
83
+ export default Demo1
84
+
85
+ ```
86
+
87
+ ### 显示清空图标
88
+
89
+
90
+ ```tsx
91
+ import React from 'react'
92
+ import { Input, Space } from '@mijadesign/mjui-react-taro'
93
+
94
+ const Demo4 = () => {
95
+ return (
96
+ <Space style={{ padding: '0 16px' }} direction="vertical">
97
+ <Input underLine placeholder="请输入文本" clearable />
98
+ </Space>
99
+ )
100
+ }
101
+ export default Demo4
102
+
103
+ ```
104
+
105
+ ### 字数统计
106
+
107
+
108
+ ```tsx
109
+ import React from 'react'
110
+ import { Input, Space } from '@mijadesign/mjui-react-taro'
111
+
112
+ const Demo5 = () => {
113
+ return (
114
+ <Space style={{ padding: '0 16px' }} direction="vertical">
115
+ <Input underLine placeholder="请输入文本" maxLength={20} showMaxCount />
116
+ </Space>
117
+ )
118
+ }
119
+ export default Demo5
120
+
121
+ ```
122
+
123
+ ### 对齐方式
124
+
125
+
126
+ ```tsx
127
+ import React from 'react'
128
+ import { Input, Space } from '@mijadesign/mjui-react-taro'
129
+
130
+ const Demo1 = () => {
131
+ return (
132
+ <Space style={{ padding: '0 16px' }} direction="vertical">
133
+ <Input underLine placeholder="请输入文本" />
134
+ <Input underLine placeholder="请输入文本" align="center" />
135
+ <Input underLine placeholder="请输入文本" align="right" />
136
+ </Space>
137
+ )
138
+ }
139
+ export default Demo1
140
+
141
+ ```
142
+
143
+ ### 操作配置
144
+
145
+
146
+ ```tsx
147
+ import React from 'react'
148
+ import { Input, Space } from '@mijadesign/mjui-react-taro'
149
+ import { Bankcard } from '@mijadesign/mobile-icons'
150
+
151
+ const Demo15 = () => {
152
+ return (
153
+ <Space style={{ padding: '0 16px' }} direction="vertical">
154
+ <Input underLine align="right" placeholder="支持配置右侧图标" extra={<Bankcard size={20} color="#006DFC" />} />
155
+ </Space>
156
+ )
157
+ }
158
+ export default Demo15
159
+
160
+ ```
161
+
162
+ ### 自定义边框
163
+
164
+
165
+ ```tsx
166
+ import React from 'react'
167
+ import { Input, Space } from '@mijadesign/mjui-react-taro'
168
+
169
+ const Demo5 = () => {
170
+ return (
171
+ <Space style={{ padding: '0 16px' }} direction="vertical">
172
+ <Input style={{ '--nutui-input-border-bottom-width': '1px' }} placeholder="边框" />
173
+ </Space>
174
+ )
175
+ }
176
+ export default Demo5
177
+
178
+ ```
179
+
180
+ ### 带按钮的输入
181
+
182
+
183
+ ```tsx
184
+ import React, { useState } from 'react'
185
+ import { Input, Button, Space } from '@mijadesign/mjui-react-taro'
186
+
187
+ const Demo5 = () => {
188
+ const [value, setValue] = useState<string>('')
189
+ return (
190
+ <Space style={{ padding: '0 16px' }} direction="vertical">
191
+ <Input
192
+ placeholder="请输入验证码"
193
+ underLine
194
+ value={value}
195
+ onChange={(val) => setValue(val)}
196
+ extra={
197
+ <Button size="small" onClick={() => setValue('123451')}>
198
+ 获取验证码
199
+ </Button>
200
+ }
201
+ />
202
+ </Space>
203
+ )
204
+ }
205
+ export default Demo5
206
+
207
+ ```
208
+
209
+ ## Input
210
+
211
+ ### Props
212
+
213
+ | 属性 | 说明 | 类型 | 默认值 |
214
+ | --- | --- | --- | --- |
215
+ | defaultValue | 初始默认值 | `string` | `-` |
216
+ | value | 初始默认值 | `string` | `-` |
217
+ | type | 输入框类型,支持原生 `input` 标签的所有 `type` 属性,另外还支持 `number` `digit` | `string` | `text` |
218
+ | name | 组件名字,用于表单提交获取数据 | `string` | `-` |
219
+ | placeholder | 输入框为空时占位符 | `string` | `-` |
220
+ | align | 输入框内容对齐方式,可选值 `left`、`center`、`right` | `string` | `right` |
221
+ | disabled | 是否禁用 | `boolean` | `false` |
222
+ | readOnly | 是否只读 | `boolean` | `false` |
223
+ | autoFocus | 是否自动获得焦点,iOS 系统不支持该属性 | `boolean` | `false` |
224
+ | maxLength | 限制最长输入字符 | `string` \| `number` | `-` |
225
+ | clearable | 展示清除 Icon | `boolean` | `false` |
226
+ | clearIcon | 清除图标 Icon <a href="#/icon">可参考 Icon </a> | `ReactNode` | `MaskClose` |
227
+ | confirmType | 键盘右下角按钮的文字,仅在type='text'时生效,可选值 send:发送、search:搜索、next:下一个、go:前往、done:完成 | `string` | `done` |
228
+ | formatter | 输入内容格式化函数 | `(val: string) => string` | `-` |
229
+ | formatTrigger | 格式化函数触发的时机,可选值为 `onChange`、`onBlur` | `string` | `-` |
230
+ | showPassword | 是否展示密码标识 | `boolean` | `true` |
231
+ | showMaxCount | 是否展示字数 | `boolean` | `false` |
232
+ | extra | 额外展示 | `ReactNode` | `-` |
233
+ | underLine | 是否展示底部分割线 | `boolean` | `false` |
234
+ | onChange | 输入框内容变化时触发 | `(value: string) => void` | `-` |
235
+ | onBlur | 失去焦点后触发 | `(value: string) => void` | `-` |
236
+ | onFocus | 获得焦点后触发 | `(value: string) => void` | `-` |
237
+ | onClear | 点击清空按钮时触发 | `(value: string) => void` | `-` |
238
+ | onClick | 点击 input 容器触发 | `(value: MouseEvent<HTMLDivElement>) => void` | `-` |
239
+
240
+ 此外还支持 Taro 中的 [Input 属性](https://docs.taro.zone/docs/components/forms/input/)
241
+
242
+ ## 主题定制
243
+
244
+ ### 样式变量
245
+
246
+ 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](#/zh-CN/component/configprovider)。
247
+
248
+ | 名称 | 说明 | 默认值 |
249
+ | --- | --- | --- |
250
+ | \--nutui-input-border-bottom | 边框颜色 | `$color-border` |
251
+ | \--nutui-input-border-bottom-width | 边框宽度 | `0px` |
252
+ | \--nutui-input-color | 文本颜色 | `$color-title` |
253
+ | \--nutui-input-disabled-color | 禁用的文本颜色 | `$color-text-disabled` |
254
+ | \--nutui-input-background-color | 输入框背景颜色 | `$color-white` |
255
+ | \--nutui-input-border-radius | 输入框圆角 | `8` |
256
+ | \--nutui-input-font-size | 文本字号 | `$font-size-2` |
257
+ | \--nutui-input-padding | 输入框容器的内边距 | `16px` |