Skip to content

Commit 4831192

Browse files
AmyFoxFNdolymood
authored andcommitted
[feat] Picker-based: subtitle (#174)
* [feat]picker-based: subtitle
1 parent 2bdf04d commit 4831192

File tree

25 files changed

+231
-141
lines changed

25 files changed

+231
-141
lines changed

document/components/docs/en-US/cascade-picker.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@ __Notice:__ Cause this component used create-api, so you should read [create-api
222222

223223
| Attribute | Description | Type | Accepted Values | Default |
224224
| - | - | - | - | - |
225-
| title | title | String | '' | - |
226225
| data | the cascading data used to init option items | Array | [] | - |
227226
| selectedIndex | the index of the selected item, corresponding content will be displayed when picker shows | Array | [] | [1] |
227+
| title | title | String | '' | - |
228+
| subtitle<sup>1.8.1</sup> | subtitle | String | '' | - |
228229
| cancelTxt | the text of the cancel button | String | '取消' | - |
229230
| confirmTxt | the text of the confirm button | String | '确定' | - |
230231
| swipeTime | the duration of the momentum animation when user flicks the wheel of the picker, Unit: ms | Number | 2500 | - |

document/components/docs/en-US/date-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ __Notice:__ Cause this component used create-api, so you should read [create-api
242242
| columnCount | the count of column | Number | - | 3 | 6 |
243243
| format<sup>1.8.0+</sup> | date format | Object | - | { year: 'YYYY', month: 'M', date: 'D', hour: 'hh', minute: 'mm', second: 'ss' } | { year: 'YY年', month: 'MM月', date: '第 D 日' } |
244244
| title | title | String | - | '' | - |
245+
| subtitle<sup>1.8.1</sup> | subtitle | String | - | '' | - |
245246
| cancelTxt | the text of the cancel button | String | - | '取消' | - |
246247
| confirmTxt | the text of the confirm button | String | - | '确定' | - |
247248
| swipeTime | the duration of the momentum animation when user flicks the wheel of the picker, Unit: ms | Number | - | 2500 | - |

document/components/docs/en-US/picker.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,56 @@ __Notice:__ Cause this component used create-api, so you should read [create-api
177177
}
178178
```
179179

180+
- Subtitle
181+
182+
You could configure subtitle by the property `subtitle`.
183+
184+
```html
185+
<cube-button @click="showSubtitlePicker">Use subtitle</cube-button>
186+
```
187+
```js
188+
const col1Data = [{ text: '剧毒', value: '剧毒'}, { text: '蚂蚁', value: '蚂蚁' },
189+
{ text: '幽鬼', value: '幽鬼' }]
190+
export default {
191+
mounted () {
192+
this.subtitlePicker = this.$createPicker({
193+
title: 'Picker',
194+
subtitle: 'subtitle',
195+
data: [col1Data],
196+
onSelect: this.selectHandle,
197+
onCancel: this.cancelHandle
198+
})
199+
},
200+
methods: {
201+
showSubtitlePicker () {
202+
this.subtitlePicker.show()
203+
},
204+
selectHandle(selectedVal, selectedIndex, selectedText) {
205+
this.$createDialog({
206+
type: 'warn',
207+
content: `Selected Item: <br/> - value: ${selectedVal.join(', ')} <br/> - index: ${selectedIndex.join(', ')} <br/> - text: ${selectedText.join(' ')}`,
208+
icon: 'cubeic-alert'
209+
}).show()
210+
},
211+
cancelHandle() {
212+
this.$createToast({
213+
type: 'correct',
214+
txt: 'Picker canceled',
215+
time: 1000
216+
}).show()
217+
}
218+
}
219+
}
220+
```
221+
180222
### Props configuration
181223

182224
| Attribute | Description | Type | Accepted Values | Default |
183225
| - | - | - | - | - |
184-
| title | title | String | '' | - |
185226
| data | data that passed into picker, whose length determines the columns of picker | Array | [] | - |
186227
| selectedIndex | the index of the selected value, corresponding content will be displayed when picker shows | Array | [] | [1] |
228+
| title | title | String | '' | - |
229+
| subtitle<sup>1.8.1</sup> | subtitle | String | '' | - |
187230
| cancelTxt | the text of the cancel button | String | '取消' | - |
188231
| confirmTxt | the text of the confirm button | String | '确定' | - |
189232
| swipeTime | the duration of the momentum animation when user flicks the wheel of the picker, Unit: ms | Number | 2500 | - |

document/components/docs/en-US/segment-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ __Notice:__ Cause this component used create-api, so you should read [create-api
124124
| - | - | - | - | - |
125125
| data | define the component name and properties of each node picker | Array | [] | - |
126126
| title | title | String | '' | - |
127+
| subtitle<sup>1.8.1</sup> | subtitle | String | '' | - |
127128
| cancelTxt | the text of the cancel button | String | '取消' | - |
128129
| confirmTxt | the text of the confirm button | String | '确定' | - |
129130
| nextTxt | the text of the next button | String | '下一步' | - |

document/components/docs/en-US/time-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ __Notice:__ Cause this component used create-api, so you should read [create-api
148148
| showNow | whether to display current time | Boolean | true |
149149
| minuteStep | step of the minute | Number | 10 |
150150
| title | title | String | '选择时间' |
151+
| subtitle<sup>1.8.1</sup> | subtitle | String | '' |
151152
| cancelTxt<sup>1.8.1</sup> | the text of the cancel button | String | '取消' |
152153
| confirmTxt<sup>1.8.1</sup> | the text of the confirm button | String | '确定' |
153154
| swipeTime | the duration of the momentum animation when user flicks the wheel of the picker, Unit: ms | Number | 2500 |

document/components/docs/zh-CN/cascade-picker.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,10 @@ __注:__ 由于此组件基于 create-api 实现,所以在使用之前,请
212212

213213
| 参数 | 说明 | 类型 | 默认值 | 示例 |
214214
| - | - | - | - | - |
215-
| title | 标题 | String | '' | - |
216215
| data | 级联选择器的树形数据,用于初始化选项 | Array | [] | - |
217216
| selectedIndex | 被选中的索引值,拉起选择器后显示这个索引值对应的内容 | Array | [] | [1] |
217+
| title | 标题 | String | '' | - |
218+
| subtitle<sup>1.8.1</sup> | 副标题 | String | '' | - |
218219
| cancelTxt | 取消按钮文案 | String | '取消' | - |
219220
| confirmTxt | 确定按钮文案 | String | '确定' | - |
220221
| swipeTime | 快速滑动选择器滚轮时,惯性滚动动画的时长,单位:ms | Number | 2500 | - |

document/components/docs/zh-CN/date-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ __注:__ 由于此组件基于 create-api 实现,所以在使用之前,请
242242
| columnCount | 列数 | Number | - | 3 | 6 |
243243
| format<sup>1.8.0+</sup> | 日期格式 | Object | - | { year: 'YYYY', month: 'M', date: 'D', hour: 'hh', minute: 'mm', second: 'ss' } | { year: 'YY年', month: 'MM月', date: '第 D 日' } |
244244
| title | 标题 | String | - | '' | '时间选择' |
245+
| subtitle<sup>1.8.1</sup> | 副标题 | String | - | '' | - |
245246
| cancelTxt | 取消按钮文案 | String | - | '取消' | '返回' |
246247
| confirmTxt | 确定按钮文案 | String | - | '确定' | '选择' |
247248
| swipeTime | 快速滑动选择器滚轮时,惯性滚动动画的时长,单位:ms | Number | - | 2500 | - |

document/components/docs/zh-CN/picker.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,56 @@ __注:__ 由于此组件基于 create-api 实现,所以在使用之前,请
177177

178178
实例方法`setData`可接受2个参数,都为数组类型。第一个参数为滚轴需要显示的数据,第二个参数为选中值的索引。
179179

180+
- 副标题
181+
182+
通过 `subtitle` 属性,设置副标题。
183+
184+
```html
185+
<cube-button @click="showSubtitlePicker">Use subtitle</cube-button>
186+
```
187+
```js
188+
const col1Data = [{ text: '剧毒', value: '剧毒'}, { text: '蚂蚁', value: '蚂蚁' },
189+
{ text: '幽鬼', value: '幽鬼' }]
190+
export default {
191+
mounted () {
192+
this.subtitlePicker = this.$createPicker({
193+
title: 'Picker',
194+
subtitle: 'subtitle',
195+
data: [col1Data],
196+
onSelect: this.selectHandle,
197+
onCancel: this.cancelHandle
198+
})
199+
},
200+
methods: {
201+
showSubtitlePicker () {
202+
this.subtitlePicker.show()
203+
},
204+
selectHandle(selectedVal, selectedIndex, selectedText) {
205+
this.$createDialog({
206+
type: 'warn',
207+
content: `Selected Item: <br/> - value: ${selectedVal.join(', ')} <br/> - index: ${selectedIndex.join(', ')} <br/> - text: ${selectedText.join(' ')}`,
208+
icon: 'cubeic-alert'
209+
}).show()
210+
},
211+
cancelHandle() {
212+
this.$createToast({
213+
type: 'correct',
214+
txt: 'Picker canceled',
215+
time: 1000
216+
}).show()
217+
}
218+
}
219+
}
220+
```
221+
180222
### Props 配置
181223

182224
| 参数 | 说明 | 类型 | 默认值 | 示例 |
183225
| - | - | - | - | - |
184-
| title | 标题 | String | '' | - |
185226
| data | 传入 picker 数据,数组的长度决定了 picker 的列数 | Array | [] | - |
186227
| selectedIndex | 被选中的索引值,拉起 picker 后显示这个索引值对应的内容 | Array | [] | [1] |
228+
| title | 标题 | String | '' | - |
229+
| subtitle<sup>1.8.1</sup> | 副标题 | String | '' | - |
187230
| cancelTxt | 取消按钮文案 | String | '取消' | - |
188231
| confirmTxt | 确定按钮文案 | String | '确定' | - |
189232
| swipeTime | 快速滑动 picker 滚轮时,惯性滚动动画的时长,单位:ms | Number | 2500 | - |

document/components/docs/zh-CN/segment-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ __注:__ 由于此组件基于 create-api 实现,所以在使用之前,请
126126
| nextTxt | 下一步按钮文案 | String | '下一步' | - |
127127
| prevTxt | 上一步按钮文案 | String | '下一步' | - |
128128
| title | 标题 | String | '' | - |
129+
| subtitle<sup>1.8.1</sup> | 副标题 | String | '' | - |
129130
| cancelTxt | 取消按钮文案 | String | '取消' | - |
130131
| confirmTxt | 确定按钮文案 | String | '确定' | - |
131132
| swipeTime<sup>1.8.1</sup> | 快速滑动选择器滚轮时,惯性滚动动画的时长,单位:ms | Number | 2500 | - |

document/components/docs/zh-CN/time-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ __注:__ 由于此组件基于 create-api 实现,所以在使用之前,请
138138
| showNow | 是否显示当前时间 | Boolean | true |
139139
| minuteStep | 分钟数的步长 | Number | 10 |
140140
| title | 标题 | String | '选择时间' |
141+
| subtitle<sup>1.8.1</sup> | 副标题 | String | '' |
141142
| cancelTxt<sup>1.8.1</sup> | 取消按钮文案 | String | '取消' |
142143
| confirmTxt<sup>1.8.1</sup> | 确定按钮文案 | String | '确定' |
143144
| swipeTime | 快速滑动选择器滚轮时,惯性滚动动画的时长,单位:ms | Number | 2500 |

0 commit comments

Comments
 (0)