@tuya-miniapp/smart-ui 2.13.1 → 2.13.2-beta-1

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 (111) hide show
  1. package/dist/action-sheet/README.md +631 -0
  2. package/dist/battery/README.md +102 -0
  3. package/dist/bottom-sheet/README.md +397 -0
  4. package/dist/button/README.md +205 -0
  5. package/dist/button/index.css +1 -1
  6. package/dist/button/index.wxss +1 -1
  7. package/dist/calendar/README.md +466 -0
  8. package/dist/cascader/README.md +235 -0
  9. package/dist/cell/README.md +240 -0
  10. package/dist/checkbox/README.md +359 -0
  11. package/dist/circle/README.md +116 -0
  12. package/dist/col/README.md +134 -0
  13. package/dist/collapse/README.md +223 -0
  14. package/dist/common/README.md +71 -0
  15. package/dist/config-provider/README.md +143 -0
  16. package/dist/count-down/README.md +194 -0
  17. package/dist/custom-keyboard/README.md +119 -0
  18. package/dist/datetime-picker/README.md +384 -0
  19. package/dist/dialog/README.md +412 -0
  20. package/dist/divider/README.md +100 -0
  21. package/dist/dropdown-menu/README.md +278 -0
  22. package/dist/empty/README.md +101 -0
  23. package/dist/field/README.md +439 -0
  24. package/dist/grid/README.md +197 -0
  25. package/dist/icon/README.md +143 -0
  26. package/dist/image/README.md +171 -0
  27. package/dist/index-bar/README.md +189 -0
  28. package/dist/loading/README.md +86 -0
  29. package/dist/nav-bar/README.md +378 -0
  30. package/dist/normal-slider/README.md +325 -0
  31. package/dist/notice-bar/README.md +216 -0
  32. package/dist/notify/README.md +120 -0
  33. package/dist/overlay/README.md +132 -0
  34. package/dist/picker/README.md +396 -0
  35. package/dist/popover/README.md +249 -0
  36. package/dist/popup/README.md +162 -0
  37. package/dist/progress/README.md +99 -0
  38. package/dist/radio/README.md +303 -0
  39. package/dist/rate/README.md +176 -0
  40. package/dist/search/README.md +235 -0
  41. package/dist/sidebar/README.md +160 -0
  42. package/dist/skeleton/README.md +98 -0
  43. package/dist/slider/README.md +366 -0
  44. package/dist/stepper/README.md +208 -0
  45. package/dist/stepper/index.js +16 -1
  46. package/dist/stepper/index.wxml +1 -1
  47. package/dist/sticky/README.md +124 -0
  48. package/dist/swipe-cell/README.md +172 -0
  49. package/dist/switch/README.md +204 -0
  50. package/dist/tab/README.md +414 -0
  51. package/dist/tabbar/README.md +333 -0
  52. package/dist/tag/README.md +184 -0
  53. package/dist/toast/README.md +220 -0
  54. package/dist/transition/README.md +114 -0
  55. package/dist/tree-select/README.md +199 -0
  56. package/lib/action-sheet/README.md +631 -0
  57. package/lib/battery/README.md +102 -0
  58. package/lib/bottom-sheet/README.md +397 -0
  59. package/lib/button/README.md +205 -0
  60. package/lib/button/index.css +1 -1
  61. package/lib/button/index.wxss +1 -1
  62. package/lib/calendar/README.md +466 -0
  63. package/lib/cascader/README.md +235 -0
  64. package/lib/cell/README.md +240 -0
  65. package/lib/checkbox/README.md +359 -0
  66. package/lib/circle/README.md +116 -0
  67. package/lib/col/README.md +134 -0
  68. package/lib/collapse/README.md +223 -0
  69. package/lib/common/README.md +71 -0
  70. package/lib/config-provider/README.md +143 -0
  71. package/lib/count-down/README.md +194 -0
  72. package/lib/custom-keyboard/README.md +119 -0
  73. package/lib/datetime-picker/README.md +384 -0
  74. package/lib/dialog/README.md +412 -0
  75. package/lib/divider/README.md +100 -0
  76. package/lib/dropdown-menu/README.md +278 -0
  77. package/lib/empty/README.md +101 -0
  78. package/lib/field/README.md +439 -0
  79. package/lib/grid/README.md +197 -0
  80. package/lib/icon/README.md +143 -0
  81. package/lib/image/README.md +171 -0
  82. package/lib/index-bar/README.md +189 -0
  83. package/lib/loading/README.md +86 -0
  84. package/lib/nav-bar/README.md +378 -0
  85. package/lib/normal-slider/README.md +325 -0
  86. package/lib/notice-bar/README.md +216 -0
  87. package/lib/notify/README.md +120 -0
  88. package/lib/overlay/README.md +132 -0
  89. package/lib/picker/README.md +396 -0
  90. package/lib/popover/README.md +249 -0
  91. package/lib/popup/README.md +162 -0
  92. package/lib/progress/README.md +99 -0
  93. package/lib/radio/README.md +303 -0
  94. package/lib/rate/README.md +176 -0
  95. package/lib/search/README.md +235 -0
  96. package/lib/sidebar/README.md +160 -0
  97. package/lib/skeleton/README.md +98 -0
  98. package/lib/slider/README.md +366 -0
  99. package/lib/stepper/README.md +208 -0
  100. package/lib/stepper/index.js +16 -1
  101. package/lib/stepper/index.wxml +1 -1
  102. package/lib/sticky/README.md +124 -0
  103. package/lib/swipe-cell/README.md +172 -0
  104. package/lib/switch/README.md +204 -0
  105. package/lib/tab/README.md +414 -0
  106. package/lib/tabbar/README.md +333 -0
  107. package/lib/tag/README.md +184 -0
  108. package/lib/toast/README.md +220 -0
  109. package/lib/transition/README.md +114 -0
  110. package/lib/tree-select/README.md +199 -0
  111. package/package.json +5 -4
@@ -0,0 +1,439 @@
1
+ ---
2
+ category: 数据录入
3
+ ---
4
+
5
+ # Field 输入框
6
+
7
+ ### 介绍
8
+
9
+ 用户可以在文本框内输入或编辑文字。
10
+
11
+ ### 引入
12
+
13
+ 在`app.json`或`index.json`中引入组件,详细介绍见[快速上手](/material/smartui?comId=help-getting-started&appType=miniapp)。
14
+
15
+ ```json
16
+ "usingComponents": {
17
+ "smart-field": "@tuya-miniapp/smart-ui/lib/field/index"
18
+ }
19
+ ```
20
+
21
+ ## 代码演示
22
+
23
+ ### 基础用法
24
+
25
+ `hidden-label` 可以隐藏整个左侧内容。
26
+
27
+ ```html
28
+ <smart-cell-group>
29
+ <smart-field
30
+ value="{{ value }}"
31
+ label="标题"
32
+ placeholder="请输入"
33
+ bind:change="onChange"
34
+ />
35
+ <smart-field
36
+ value="{{ value2 }}"
37
+ hidden-label
38
+ placeholder="{{I18n.t('pleaseEnter')}}"
39
+ />
40
+ </smart-cell-group>
41
+ ```
42
+
43
+ ```js
44
+ Page({
45
+ data: {
46
+ value: '',
47
+ value2: '',
48
+ },
49
+
50
+ onChange(event) {
51
+ // event.detail 为当前输入的值
52
+ console.log(event.detail);
53
+ },
54
+ onChange2(event) {
55
+ this.setData({
56
+ value2: event.detail
57
+ })
58
+ }
59
+ });
60
+ ```
61
+
62
+ ### 自定义类型
63
+
64
+ 根据`type`属性定义不同类型的输入框;`card-mode` 开启此模式可以开启卡片输入模式。
65
+
66
+ ```html
67
+ <smart-cell-group>
68
+ <smart-field
69
+ value="{{ password }}"
70
+ type="password"
71
+ label="密码"
72
+ placeholder="请输入"
73
+ />
74
+ <smart-field
75
+ value="{{ num }}"
76
+ card-mode
77
+ type="number"
78
+ sub-label="副标题"
79
+ label="标题"
80
+ placeholder="请输入"
81
+ />
82
+ </smart-cell-group>
83
+ ```
84
+
85
+ ### 禁用输入框
86
+
87
+ `disabled` 可以设置整个输入框禁用。
88
+
89
+ ```html
90
+ <smart-cell-group>
91
+ <smart-field
92
+ placeholder="输入框已禁用"
93
+ label="标题"
94
+ disabled
95
+ />
96
+ <smart-field
97
+ card-mode
98
+ disabled
99
+ sub-label="副标题"
100
+ label="标题"
101
+ placeholder="请输入"
102
+ />
103
+ </smart-cell-group>
104
+ ```
105
+
106
+ ### 显示图标
107
+
108
+ 使用插槽 `left-icon` 可以插入左侧的图标。
109
+
110
+ ```html
111
+ <smart-cell-group>
112
+ <smart-field
113
+ label="标题"
114
+ placeholder="请输入"
115
+ >
116
+ <smart-icon name="{{ sunIcon }}" slot="left-icon" color="#3678E3" size="22" />
117
+ </smart-field>
118
+ <smart-field
119
+ value="{{ num }}"
120
+ card-mode
121
+ label="标题"
122
+ placeholder="请输入"
123
+ >
124
+ <image
125
+ slot="left-icon"
126
+ style="height: 50px;width: 50px;"
127
+ src="https://images.tuyacn.com/rms-static/974a30f0-a624-11ef-be03-d1a4feb99779-1731986155903.png?tyName=light-img"
128
+ />
129
+ </smart-field>
130
+ </smart-cell-group>
131
+ ```
132
+
133
+ ### 错误提示
134
+
135
+ 通过`error-message`属性增加对应的错误提示;设置 `inter-error` 可以将错误信息覆盖 `placeholder` 的内容。
136
+
137
+ ```html
138
+ <smart-cell-group>
139
+ <smart-field
140
+ label="标题"
141
+ error-message="请输入用户名"
142
+ inter-error
143
+ required
144
+ />
145
+ <smart-field
146
+ value="{{ value2 }}"
147
+ label="标题"
148
+ placeholder="请输入"
149
+ error-message="格式错误"
150
+ required
151
+ />
152
+ <smart-field
153
+ value="{{ num }}"
154
+ card-mod
155
+ label="标题"
156
+ sub-label="标题"
157
+ placeholder="请输入"
158
+ error-message="格式错误"
159
+ required
160
+ >
161
+ <image
162
+ slot="left-icon"
163
+ style="height: 50px;width: 50px;"
164
+ src="https://images.tuyacn.com/rms-static/974a30f0-a624-11ef-be03-d1a4feb99779-1731986155903.png?tyName=light-img"
165
+ />
166
+ </smart-field>
167
+ </smart-cell-group>
168
+ ```
169
+
170
+ ### 插入按钮
171
+
172
+ 通过 button slot 可以在输入框尾部插入按钮。
173
+
174
+ ```html
175
+ <smart-cell-group>
176
+ <smart-cell-group>
177
+ <smart-field
178
+ label="标题"
179
+ placeholder="请输入短信验证码"
180
+ type="number"
181
+ input-align="left"
182
+ >
183
+ <smart-button slot="button" type="info" custom-class="button">发送验证码</smart-button>
184
+ </smart-field>
185
+ </smart-cell-group>
186
+ </smart-cell-group>
187
+ ```
188
+
189
+ ### 数字格式化 `v2.12.0`
190
+
191
+ 开启 `number-format` 后,组件会根据当前语言环境进行数字输入的千分位、小数位格式化展示;当然通过 `locale` 可指定地区格式(如 `de` 为德语 1.234,56,默认与英文为 1,234.56)。
192
+
193
+ ```html
194
+ <smart-cell-group>
195
+ <smart-field
196
+ value="{{ numberFormatValue }}"
197
+ number-format
198
+ label="金额"
199
+ placeholder="请输入"
200
+ />
201
+ <smart-field
202
+ value="{{ numberFormatValueDe }}"
203
+ number-format
204
+ locale="de"
205
+ label="金额(德语格式)"
206
+ placeholder="请输入"
207
+ />
208
+ </smart-cell-group>
209
+ ```
210
+
211
+ ### 留言
212
+
213
+ 设置 type 为 `textarea` 模式时,可以在末尾显示输入的字数数量和限制数量。
214
+
215
+ ```html
216
+ <smart-field
217
+ value="{{ message }}"
218
+ label="事项"
219
+ type="textarea"
220
+ placeholder="请输入留言"
221
+ show-word-limit
222
+ maxlength="{{ 200 }}"
223
+ />
224
+ ```
225
+
226
+ ### 替换输入框值
227
+
228
+ 在微信小程序中,bind:input 事件可以通过返回字符串或者一个对象来替换输入框的值以及调整光标的位置,在 Smart UI 中,可以通过调用 change 或 input 参数中的 callback 函数,传入参数来实现
229
+
230
+ ```html
231
+ <smart-field
232
+ value="{{ value }}"
233
+ placeholder="请输入用户名"
234
+ clearable
235
+ extra-event-params
236
+ bind:change="onChange"
237
+ />
238
+ ```
239
+
240
+ ```js
241
+ Page({
242
+ data: {
243
+ value: '',
244
+ },
245
+ onChange(e) {
246
+ const { value, callback } = e.detail;
247
+
248
+ callback({
249
+ value: value + 1,
250
+ cursor: 0,
251
+ });
252
+ },
253
+ });
254
+ ```
255
+
256
+ ## API
257
+
258
+ ### Props
259
+
260
+ | 参数 | 说明 | 类型 | 默认值 |
261
+ | ----------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------- | ------- |
262
+ | adjust-position | 键盘弹起时,是否自动上推页面 | _boolean_ | `true` |
263
+ | always-embed `v1.9.2` | 强制 input 处于同层状态,默认 focus 时 input 会切到非同层状态 (仅在 iOS 下生效) | _boolean_ | `false` |
264
+ | arrow-direction | 箭头方向,可选值为 `left` `up` `down` | _string_ | - |
265
+ | auto-focus `@deprecated 小程序不支持` | 自动聚焦,拉起键盘 | _boolean_ | `false` |
266
+ | autosize | 是否自适应内容高度,只对 textarea 有效,<br>可传入对象,如 { maxHeight: 100, minHeight: 50 },<br>单位为`px` | _boolean \| object_ | `false` |
267
+ | border | 是否显示内边框 | _boolean_ | `false` |
268
+ | center | 是否使内容垂直居中 | _boolean_ | `false` |
269
+ | clear-icon-aria-label `v2.13.0` | 清除按钮的无障碍读屏文案,透传至清除图标的 `aria-label` | _string_ | - |
270
+ | clear-trigger `v1.8.4` | 显示清除图标的时机,`always` 表示输入框不为空时展示,<br>`focus` 表示输入框聚焦且不为空时展示 | _string_ | `focus` |
271
+ | clearable | 是否启用清除控件 | _boolean_ | `false` |
272
+ | clickable | 是否开启点击反馈 | _boolean_ | `false` |
273
+ | confirm-hold | 点击键盘右下角按钮时是否保持键盘不收起,在 type='textarea' 时无效 | _boolean_ | `false` |
274
+ | confirm-type | 设置键盘右下角按钮的文字,仅在 type='text' 时生效 | _string_ | `done` |
275
+ | cursor | 指定 focus 时的光标位置 | _number_ | `-1` |
276
+ | cursor-spacing | 输入框聚焦时底部与键盘的距离 | _number_ | `50` |
277
+ | custom-style | 自定义样式 | _string_ | - |
278
+ | disable-default-padding | 是否去掉 iOS 下的默认内边距,只对 textarea 有效 | _boolean_ | `true` |
279
+ | disabled | 是否禁用输入框 | _boolean_ | `false` |
280
+ | error | 是否将输入内容标红 | _boolean_ | `false` |
281
+ | error-message | 底部错误提示文案,为空时不展示 | _string_ | `''` |
282
+ | error-message-align | 底部错误提示文案对齐方式,可选值为 `center` `right` | _string_ | `''` |
283
+ | extra-event-params `v1.10.12` | 开启事件增强模式,会在 input 和 change 事件额外提供 `cursor` 和 `keyCode` 参数,计划在下一个大版本作为默认行为 | _boolean_ | `false` |
284
+ | fixed | 如果 type 为 `textarea` 且在一个 `position:fixed` 的区域,需要显示指定属性 fixed 为 true | _boolean_ | `false` |
285
+ | focus `@deprecated 小程序不支持` | 获取焦点 | _boolean_ | `false` |
286
+ | hold-keyboard | focus 时,点击页面的时候不收起键盘 | _boolean_ | `false` |
287
+ | input-align | 输入框内容对齐方式,可选值为 `center` `right` | _string_ | - |
288
+ | is-link | 是否展示右侧箭头并开启点击反馈 | _boolean_ | `false` |
289
+ | label | 输入框左侧文本 | _string_ | - |
290
+ | left-icon | 左侧图标svg值或图片链接,可选值见 [Icon 组件](/material/smartui?comId=icon&appType=miniapp) | _string_ | - |
291
+ | maxlength | 最大输入长度,设置为 -1 的时候不限制最大长度 | _number_ | `-1` |
292
+ | name | 在表单内提交时的标识符。可以通过配置 `name` 来扩大点击区域 | _string_ | - |
293
+ | number-format `v2.12.0` | 是否开启数字格式化(千分位、小数位按 locale 展示) | _boolean_ | `false` |
294
+ | locale `v2.12.0` | 数字格式化使用的地区,如 `de`、`fr`,空则跟随系统 | _string_ | `''` |
295
+ | password | 是否是密码类型 | _boolean_ | `false` |
296
+ | placeholder | 输入框为空时占位符 | _string_ | - |
297
+ | placeholder-style | 指定 placeholder 的样式 | _string_ | - |
298
+ | readonly | 是否只读 | _boolean_ | `false` |
299
+ | required | 是否显示表单必填星号 | _boolean_ | `false` |
300
+ | right-icon | 右侧图标svg值或图片链接,可选值见 [Icon 组件](/material/smartui?comId=icon&appType=miniapp) | _string_ | - |
301
+ | right-icon-button-aria-label `v2.13.0` | 右侧图标按钮的无障碍读屏文案,设置在图标容器的 `aria-label` 上 | _string_ | - |
302
+ | selection-end | 光标结束位置,自动聚集时有效,需与 selection-start 搭配使用 | _number_ | `-1` |
303
+ | selection-start | 光标起始位置,自动聚集时有效,需与 selection-end 搭配使用 | _number_ | `-1` |
304
+ | show-confirm-bar | 是否显示键盘上方带有”完成“按钮那一栏,只对 textarea 有效 | _boolean_ | `true` |
305
+ | show-word-limit | 是否显示字数统计,需要设置`maxlength`属性 | _boolean_ | `false` |
306
+ | size | 单元格大小,可选值为 `large` | _string_ | - |
307
+ | title-width | 标题宽度 | _string_ | `6.2em` |
308
+ | type | 可设置为任意原生类型, 如 `number` `idcard` `textarea` `digit` `nickname` | _string_ | `text` |
309
+ | value | 当前输入的值 | _string \| number_ | - |
310
+ | inter-error `v2.1.0` | 错误信息是否在输入框内 | _boolean_ | - |
311
+ | sub-label `v2.1.0` | 副标题 | _string_ | - |
312
+ | card-mode `v2.1.0` | 卡片模式 | _boolean_ | - |
313
+ | hidden-label `v2.1.0` | 隐藏左侧label相关内容 | _boolean_ | - |
314
+
315
+ ### Events
316
+
317
+ | 事件 | 说明 | 回调参数 |
318
+ | ----------------------------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
319
+ | bind:blur | 输入框失焦时触发 | event.detail.value: 当前输入值; <br>event.detail.cursor: 游标位置(如果 `type` 不为 `textarea`,值为 `0`) |
320
+ | bind:change | 输入内容时触发 | event.detail: 当前输入值; 在 extra-event-params 为 `true` 时为 [InputDetail](#InputDetail) |
321
+ | bind:clear | 点击清空控件时触发 | - |
322
+ | bind:click-icon | 点击尾部图标时触发 | - |
323
+ | bind:click-input | 点击输入区域时触发 | - |
324
+ | bind:confirm | 点击完成按钮时触发 | event.detail: 当前输入值 |
325
+ | bind:focus | 输入框聚焦时触发 | event.detail.value: 当前输入值; <br>event.detail.height: 键盘高度 |
326
+ | bind:input | 输入内容时触发 | event.detail: 当前输入值; 在 extra-event-params 为 `true` 时为 [InputDetail](#InputDetail) |
327
+ | bind:keyboardheightchange | 键盘高度发生变化的时候触发此事件 | event.detail = { height: height, duration: duration } |
328
+ | bind:linechange | 输入框行数变化时调用,只对 textarea 有效 | event.detail = { height: 0, heightRpx: 0, lineCount: 0 } |
329
+ | bind:nicknamereview `v1.11.5` | 用户昵称审核完毕后触发,仅在 type 为 "nickname" 时有效 | event.detail = { pass, timeout } |
330
+
331
+ ### InputDetail
332
+
333
+ | 参数 | 说明 | 类型 | 默认值 |
334
+ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ------ |
335
+ | callback | 调用该函数传 `{ value: string, cursor: number }` 来替换输入框的内容,具体用法可以参考 [wx-input](https://developers.weixin.qq.com/miniprogram/dev/component/input.html) | _function_ | - |
336
+ | cursor | 光标位置 | _number_ | - |
337
+ | keyCode | 键值 | _number_ | - |
338
+ | value | 当前输入值 | _string_ | - |
339
+
340
+ ### Slot
341
+
342
+ | 名称 | 说明 |
343
+ | ---------- | ---------------------------------------------------------- |
344
+ | button | 自定义输入框尾部按钮 |
345
+ | input | 自定义输入框,使用此插槽后,与输入框相关的属性和事件将失效 |
346
+ | label | 自定义输入框标签,如果设置了`label`属性则不生效 |
347
+ | left-icon | 自定义输入框头部图标 |
348
+ | right-icon | 自定义输入框尾部图标 |
349
+
350
+ ### 外部样式类
351
+
352
+ | 类名 | 说明 |
353
+ | ----------------------- | -------------- |
354
+ | custom-class `v1.10.21` | 根节点样式类 |
355
+ | input-class | 输入框样式类 |
356
+ | label-class | 左侧文本样式类 |
357
+ | right-icon-class | 右侧图标样式类 |
358
+
359
+ ### 样式变量
360
+
361
+ 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider&appType=miniapp)。
362
+
363
+ | 名称 | 默认值 | 描述 |
364
+ | ----------------------------- | -------------------------------------- | ---- |
365
+ | --field-label-color | _var(--app-B6-N1, rgba(0, 0, 0, 1))_ | label颜色 |
366
+ | --field-input-text-color | _var(--app-B6-N1, rgba(0, 0, 0, 1))_ | input文字颜色 |
367
+ | --field-input-text-font-size `v2.1.0` | _16px_ | 输入框内的字体大小 |
368
+ | --field-input-error-text-color | _var(--app-M2, #f04c4c)_ | error模式文字颜色 |
369
+ | --field-placeholder-text-color | _var(--app-B6-N4, rgba(0, 0, 0, 0.4))_ | placeholder文字颜色 |
370
+ | --field-icon-size | _16px_ | icon字体大小 |
371
+ | --field-clear-icon-size | _16px_ | 清楚icon字体大小 |
372
+ | --field-clear-icon-color | _var(--app-B4-N4, rgba(0, 0, 0, 0.4))_ | 清除icon颜色 |
373
+ | --field-icon-container-color | _#969799_ | 右侧icon盒子字体颜色 |
374
+ | --field-error-message-color | _var(--app-M2, #f04c4c)_ | 错误提示文字颜色 |
375
+ | --field-error-message-text-font-size | _14px_ | 提示文字字体大小 |
376
+ | --field-text-area-min-height | _130px_ | textarea最小高度 |
377
+ | --field-word-limit-color | _var(--app-B6-N4, rgba(0, 0, 0, 0.4))_ | 输入长度限制文字颜色 |
378
+ | --field-disabled-opacity `v2.1.0` | _0.7_ | 禁用透明度 |
379
+ | --field-label-font-size `v2.1.0` | _16px_ | label字体大小 |
380
+ | --field-label-line-height `v2.1.0` | _18px_ | label标题字体高度 |
381
+ | --field-sub-label-font-size `v2.1.0` | _14px_ | 副标题字体大小 |
382
+ | --field-sub-label-line-height `v2.1.0` | _16px_ | 副标题字体高度 |
383
+ | --field-error-message-text-line-height `v2.1.0` | _16px_ | 错误提示字体高度 |
384
+ | --field-subtitle-text-color `v2.1.0` | _var(--app-B6-N3, rgba(0, 0, 0, 0.5))_ | 副标题颜色 |
385
+ | --field-left-icon-margin-right `v2.1.0` | _10px_ | icon的右侧外边距 |
386
+ | --field-left-body-padding-right `v2.1.0` | _16px_ | 左侧部分的右内边距 |
387
+
388
+ #### card模式CSS变量
389
+ | 名称 | 默认值 | 描述 |
390
+ | ----------------------------- | -------------------------------------- | ---- |
391
+ | --field-card-border-radius `v2.1.0` | _8px_ | 卡片边框圆角 |
392
+ | --field-card-background `v2.1.0` | _var(--app-B6-N7, rgba(0, 0, 0, 0.1))_ | 卡片输入输背景色 |
393
+ | --field-card-width `v2.1.0` | _105px_ | 卡片输入宽度 |
394
+ | --field-card-height `v2.1.0` | _38px_ | 卡片输入高度 |
395
+ | --field-card-padding `v2.1.0` | _0 10px_ | 卡片输入框内部padding |
396
+
397
+ #### textarea CSS变量
398
+ | 名称 | 默认值 | 描述 |
399
+ | ----------------------------- | -------------------------------------- | ---- |
400
+ | --field-word-limit-font-size | _10px_ | 输入长度限制文字字体大小 |
401
+ | --field-word-limit-line-height | _14px_ | 输入长度限制文字字体高度 |
402
+ | --field-word-num-full-color | _var(--app-M2, #f04c4c)_ | 输入长度超出限制文字颜色 |
403
+ | --field-textarea-background `v2.1.0` | _var(--app-B3, #ffffff)_ | 输入框背景色 |
404
+ | --field-textarea-border-radius `v2.1.0` | _8px_ | 输入框圆角 |
405
+ | --field-textarea-padding `v2.1.0` | _12px 8px_ | 输入内边距 |
406
+ | --field-textarea-limit-padding-bottom `v2.1.0` | _20px_ | 输入框底部显示限制字符串数量时的内边距 |
407
+
408
+
409
+ ## 常见问题
410
+
411
+ ### 真机上为什么会出现聚焦时 placeholder 加粗、闪烁的现象?
412
+
413
+ 由于微信小程序的 input 组件和 textarea 组件是原生组件,聚焦时会将原生的输入框覆盖在对应位置上,导致了这个现象的产生。
414
+
415
+ 相关的讨论可以查看[微信开放社区](https://developers.weixin.qq.com/community/search?query=placeholder%20%E9%97%AA%E7%83%81%20%E5%8A%A0%E7%B2%97)。
416
+
417
+ ### 真机上 placeholder 为什么会盖过 popup 等其它组件?
418
+
419
+ 由于微信小程序的 input 组件和 textarea 组件是原生组件,遵循原生组件的限制,详情可以查看[原生组件说明](https://developers.weixin.qq.com/miniprogram/dev/component/native-component.html)。
420
+
421
+ ### textarea 的 placeholder 在真机上为什么会偏移?
422
+
423
+ 微信小程序的 textarea 组件在 Android 和 iOS 中默认样式不同,在 iOS 中会有默认的 `padding`,且无法置 0。
424
+
425
+ 同时 `placeholder-style` 对 `vertical-align`、`line-height` 等大量 css 属性都不生效。
426
+
427
+ 这一系列的问题导致了 placeholder 在真机上可能会出现偏移。
428
+
429
+ 微信已经在 `2.10.0` 基础库版本后支持移除默认的 `padding`,但低版本仍有问题。详情可以查看 [微信开放社区](https://developers.weixin.qq.com/community/develop/issue/96)。
430
+
431
+ ### 手写输入法为什么会丢失部分字符 / 手写输入法为什么不会触发 input 事件?
432
+
433
+ 这是微信小程序的 input 组件本身的问题,如果需要兼容手写输入法的场景,可以在 `blur` 事件中取到输入的值。
434
+
435
+ 相关的讨论可以查看[微信开放社区](https://developers.weixin.qq.com/community/search?query=input%20%E6%89%8B%E5%86%99%E8%BE%93%E5%85%A5&page=1&block=1&random=1567079239098)。
436
+
437
+ ### 如何扩大点击区域?点击 label、错误信息 都能聚焦唤起键盘呢?
438
+
439
+ 升级至 1.10.21 版本及以上,配置 `name` 属性即可
@@ -0,0 +1,197 @@
1
+ ---
2
+ category: 布局
3
+ ---
4
+
5
+ # Grid 宫格
6
+
7
+ ### 介绍
8
+
9
+ 宫格可以在水平方向上把页面分隔成等宽度的区块,用于展示内容或进行页面导航。
10
+
11
+ ### 引入
12
+
13
+ 在`app.json`或`index.json`中引入组件,详细介绍见[快速上手](/material/smartui?comId=help-getting-started&appType=miniapp)。
14
+
15
+ ```json
16
+ "usingComponents": {
17
+ "smart-grid": "@tuya-miniapp/smart-ui/lib/grid/index",
18
+ "smart-grid-item": "@tuya-miniapp/smart-ui/lib/grid-item/index"
19
+ }
20
+ ```
21
+
22
+ ## 代码演示
23
+
24
+ ### 基本用法
25
+
26
+ 通过`icon`属性设置格子内的图标,`text`属性设置文字内容。
27
+
28
+ ```html
29
+ <smart-grid>
30
+ <smart-grid-item icon="photo-o" text="文字" />
31
+ <smart-grid-item icon="photo-o" text="文字" />
32
+ <smart-grid-item icon="photo-o" text="文字" />
33
+ <smart-grid-item icon="photo-o" text="文字" />
34
+ </smart-grid>
35
+ ```
36
+
37
+ ### 自定义列数
38
+
39
+ 默认一行展示四个格子,可以通过`column-num`自定义列数。
40
+
41
+ ```html
42
+ <smart-grid column-num="3">
43
+ <smart-grid-item icon="photo-o" text="文字" ty:for="{{ 6 }}" />
44
+ </smart-grid>
45
+ ```
46
+
47
+ ### 自定义内容
48
+
49
+ 通过插槽可以自定义格子展示的内容。
50
+
51
+ ```html
52
+ <smart-grid column-num="3" border="{{ false }}">
53
+ <smart-grid-item use-slot ty:for="{{ 3 }}" ty:for-item="index">
54
+ <image
55
+ style="width: 90px; height: 90px;"
56
+ src="https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png"
57
+ />
58
+ </smart-grid-item>
59
+ </smart-grid>
60
+ ```
61
+
62
+ ### 正方形格子
63
+
64
+ 设置`square`属性后,格子的高度会和宽度保持一致。
65
+
66
+ ```html
67
+ <smart-grid square>
68
+ <smart-grid-item icon="photo-o" text="文字" ty:for="{{ 8 }}" />
69
+ </smart-grid>
70
+ ```
71
+
72
+ ### 格子间距
73
+
74
+ 通过`gutter`属性设置格子之间的距离。
75
+
76
+ ```html
77
+ <smart-grid gutter="{{ 10 }}">
78
+ <smart-grid-item icon="photo-o" text="文字" ty:for="{{ 8 }}" />
79
+ </smart-grid>
80
+ ```
81
+
82
+ ### 内容横排
83
+
84
+ 将`direction`属性设置为`horizontal`,可以让宫格的内容呈横向排列。
85
+
86
+ ```html
87
+ <smart-grid direction="horizontal" column-num="2">
88
+ <smart-grid-item icon="photo-o" text="文字" />
89
+ <smart-grid-item icon="photo-o" text="文字" />
90
+ <smart-grid-item icon="photo-o" text="文字" />
91
+ </smart-grid>
92
+ ```
93
+
94
+ ### 页面跳转
95
+
96
+ 可以通过`url`属性进行页面跳转,通过`link-type`属性控制跳转类型。
97
+
98
+ ```html
99
+ <smart-grid clickable column-num="2">
100
+ <smart-grid-item
101
+ icon="home-o"
102
+ link-type="navigateTo"
103
+ url="/pages/dashboard/index"
104
+ text="Navigate 跳转"
105
+ />
106
+ <smart-grid-item
107
+ icon="search"
108
+ link-type="reLaunch"
109
+ url="/pages/dashboard/index"
110
+ text="ReLaunch 跳转"
111
+ />
112
+ </smart-grid>
113
+ ```
114
+
115
+ ### 提示信息
116
+
117
+ 设置`dot`属性后,会在图标右上角展示一个小红点。设置`badge`属性后,会在图标右上角展示相应的徽标。
118
+
119
+ ```html
120
+ <smart-grid column-num="2">
121
+ <smart-grid-item icon="home-o" text="文字" dot />
122
+ <smart-grid-item icon="search" text="文字" badge="99+" />
123
+ </smart-grid>
124
+ ```
125
+
126
+ ## API
127
+
128
+ ### Grid Props
129
+
130
+ | 参数 | 说明 | 类型 | 默认值 |
131
+ | ------------------ | ----------------------------------------- | ------------------ | ---------- |
132
+ | border | 是否显示边框 | _boolean_ | `true` |
133
+ | center | 是否将格子内容居中显示 | _boolean_ | `true` |
134
+ | clickable | 是否开启格子点击反馈 | _boolean_ | `false` |
135
+ | column-num | 列数 | _number_ | `4` |
136
+ | direction | 格子内容排列的方向,可选值为 `horizontal` | _string_ | `vertical` |
137
+ | gutter | 格子之间的间距,默认单位为`px` | _string \| number_ | `0` |
138
+ | icon-size `v1.3.2` | 图标大小,默认单位为`px` | _string_ | `28px` |
139
+ | reverse `v1.7.0` | 是否调换图标和文本的位置 | _boolean_ | `false` |
140
+ | square | 是否将格子固定为正方形 | _boolean_ | `false` |
141
+ | use-slot | 是否使用自定义内容的插槽 | _boolean_ | `false` |
142
+
143
+ ### Grid 外部样式类
144
+
145
+ | 类名 | 说明 |
146
+ | ------------ | ------------ |
147
+ | custom-class | 根节点样式类 |
148
+
149
+ ### GridItem Props
150
+
151
+ | 参数 | 说明 | 类型 | 默认值 |
152
+ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------ | ------------ |
153
+ | aria-label `v2.13.0` | 无障碍读屏文案,设置在根节点的 `aria-label` 上 | _string_ | - |
154
+ | badge | 图标右上角徽标的内容 | _string \| number_ | - |
155
+ | dot | 是否显示图标右上角小红点 | _boolean_ | `false` |
156
+ | icon | 图标 svg 值或图片链接,可选值见 [Icon 组件](/material/smartui?comId=icon&appType=miniapp) | _string_ | - |
157
+ | icon-color | 图标颜色 | _string_ | - |
158
+ | icon-prefix `v1.7.0` | 第三方图标前缀 | _string_ | `smart-icon` |
159
+ | link-type | 链接跳转类型,可选值为 `redirectTo` [`switchTab`](https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.switchTab.html) `reLaunch` | _string_ | `navigateTo` |
160
+ | text | 文字 | _string_ | - |
161
+ | url | 点击后跳转的链接地址 | _string_ | - |
162
+
163
+ ### GridItem Events
164
+
165
+ | 事件名 | 说明 | 回调参数 |
166
+ | ---------- | -------------- | -------- |
167
+ | bind:click | 点击格子时触发 | - |
168
+
169
+ ### GridItem Slots
170
+
171
+ | 名称 | 说明 |
172
+ | ---- | ------------------------------------------------------ |
173
+ | - | 自定义宫格的所有内容,需要设置`use-slot`属性 |
174
+ | icon | 自定义图标,如果设置了`use-slot`或者`icon`属性则不生效 |
175
+ | text | 自定义文字,如果设置了`use-slot`或者`text`属性则不生效 |
176
+
177
+ ### GridItem 外部样式类
178
+
179
+ | 类名 | 说明 |
180
+ | ------------- | ------------ |
181
+ | content-class | 内容样式类 |
182
+ | custom-class | 根节点样式类 |
183
+ | icon-class | 图标样式类 |
184
+ | text-class | 文本样式类 |
185
+
186
+ ### 样式变量
187
+
188
+ 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider&appType=miniapp)。
189
+
190
+ | 名称 | 默认值 | 描述 |
191
+ | ------------------------------------ | -------------------------------------- | ------------ |
192
+ | --grid-item-content-padding | _@padding-md @padding-xs_ | 内容内边距 |
193
+ | --grid-item-content-background-color | _var(--app-B3, #ffffff)_ | 背景颜色 |
194
+ | --grid-item-content-active-color | _#f2f3f5_ | 激活时颜色 |
195
+ | --grid-item-icon-size | _26px_ | 图标大小 |
196
+ | --grid-item-text-color | _var(--app-B6-N2, rgba(0, 0, 0, 0.7))_ | 文本颜色 |
197
+ | --grid-item-text-font-size | _12px_ | 文本字体大小 |