sadais-piui 1.2.6-beta6 → 1.2.6

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.
@@ -18,7 +18,7 @@
18
18
  class="pi-subsection__item"
19
19
  :class="[itemClass(index)]"
20
20
  :style="[itemStyle(index)]"
21
- @tap="clickHandler(index)"
21
+ @tap="handleSelectItem(index)"
22
22
  >
23
23
  <text class="pi-subsection__item__text" :style="[textStyle(index)]">{{ getText(item) }}</text>
24
24
  </view>
@@ -30,6 +30,7 @@
30
30
  const dom = uni.requireNativePlugin('dom')
31
31
  const animation = uni.requireNativePlugin('animation')
32
32
  // #endif
33
+ import ValueSync from '../../mixin/value-sync'
33
34
  import { getConfig } from '../../config'
34
35
  const { subsection } = getConfig()
35
36
  /**
@@ -37,11 +38,21 @@ const { subsection } = getConfig()
37
38
  * @description 该分段器一般用于用户从几个选项中选择某一个的场景
38
39
  * @tutorial http://piui.sadais.com/docs/components/Subsection.html
39
40
  * @event {Function} change 分段器选项发生改变时触发 回调 index:选项的index索引值,从0开始
40
- * @example <pi-subsection :items="items" :current="curNow" @change="sectionChange" />
41
+ * @example <pi-subsection v-model="current" :items="items" @change="sectionChange" />
41
42
  */
42
43
  export default {
43
44
  name: 'PiSubsection',
45
+ // 混入v-model
46
+ mixins: [ValueSync],
44
47
  props: {
48
+ // 当前活动的tab的index
49
+ value: {
50
+ type: Number,
51
+ // 0
52
+ default() {
53
+ return subsection.value
54
+ }
55
+ },
45
56
  // 自定义样式,对象形式
46
57
  customStyle: {
47
58
  type: Object,
@@ -66,14 +77,6 @@ export default {
66
77
  return subsection.items
67
78
  }
68
79
  },
69
- // 当前活动的tab的index
70
- current: {
71
- type: [String, Number],
72
- // 0
73
- default() {
74
- return subsection.current
75
- }
76
- },
77
80
  // 激活时的颜色
78
81
  activeColor: {
79
82
  type: String,
@@ -131,11 +134,11 @@ export default {
131
134
  }
132
135
  },
133
136
  // 从`items`元素对象中读取的键名
134
- keyName: {
137
+ keyField: {
135
138
  type: String,
136
139
  // name
137
140
  default() {
138
- return subsection.keyName
141
+ return subsection.keyField
139
142
  }
140
143
  }
141
144
  },
@@ -155,11 +158,11 @@ export default {
155
158
  let className = 'pi-subsection--button__bar'
156
159
  // 分段器模式
157
160
  if (this.mode === 'subsection') {
158
- if (this.current === 0) {
161
+ if (this.val === 0) {
159
162
  className = 'pi-subsection__bar--first'
160
- } else if (this.current > 0 && this.current < this.items.length - 1) {
163
+ } else if (this.val > 0 && this.val < this.items.length - 1) {
161
164
  className = 'pi-subsection__bar--center'
162
- } else if (this.current === this.items.length - 1) {
165
+ } else if (this.val === this.items.length - 1) {
163
166
  className = 'pi-subsection__bar--last'
164
167
  }
165
168
  }
@@ -169,7 +172,7 @@ export default {
169
172
  const style = {}
170
173
  // button模式时,设置背景色
171
174
  if (this.mode === 'button') {
172
- style.backgroundColor = this.bgColor
175
+ style.background = this.bgColor
173
176
  }
174
177
  return style
175
178
  },
@@ -180,11 +183,11 @@ export default {
180
183
  style.height = `${this.itemRect.height}px`
181
184
  // 通过translateX移动滑块,其移动的距离为索引*item的宽度
182
185
  // #ifndef APP-NVUE
183
- style.transform = `translateX(${this.current * this.itemRect.width}px)`
186
+ style.transform = `translateX(${this.val * this.itemRect.width}px)`
184
187
  // #endif
185
188
  if (this.mode === 'subsection') {
186
189
  // 在subsection模式下,需要动态设置滑块的圆角,因为移动滑块使用的是translateX,无法通过父元素设置overflow: hidden隐藏滑块的直角
187
- style.backgroundColor = this.activeColor
190
+ style.background = this.activeColor
188
191
  }
189
192
  // 按钮圆角模式 按钮模式生效
190
193
  if (this.round && this.mode === 'button') {
@@ -194,7 +197,7 @@ export default {
194
197
  },
195
198
  // 分段器item的样式
196
199
  itemStyle(index) {
197
- return (index) => {
200
+ return index => {
198
201
  const style = {}
199
202
  if (this.mode === 'subsection') {
200
203
  // 设置border的样式
@@ -217,12 +220,12 @@ export default {
217
220
  },
218
221
  // 分段器item的class
219
222
  itemClass(index) {
220
- return (index) => {
223
+ return index => {
221
224
  let className = `pi-subsection__item--${index}`
222
- if (index === 0) {
223
- className += ' pi-subsection__item--first'
224
- } else if (index < this.items.length - 1) {
225
+ if (index < this.items.length - 1) {
225
226
  className += ' pi-subsection__item--no-border-right'
227
+ } else if (index === 0) {
228
+ className += ' pi-subsection__item--first'
226
229
  } else if (index === this.items.length - 1) {
227
230
  className += ' pi-subsection__item--last'
228
231
  }
@@ -231,16 +234,16 @@ export default {
231
234
  },
232
235
  // 分段器文字颜色
233
236
  textStyle(index) {
234
- return (index) => {
237
+ return index => {
235
238
  const style = {}
236
- style.fontWeight = this.bold && this.current === index ? 'bold' : 'normal'
239
+ style.fontWeight = this.bold && this.val === index ? 'bold' : 'normal'
237
240
  style.fontSize = this.$pi.common.addUnit(this.fontSize)
238
241
  // subsection模式下,激活时默认为白色的文字
239
242
  if (this.mode === 'subsection') {
240
- style.color = this.current === index ? '#fff' : this.inactiveColor
243
+ style.color = this.val === index ? '#fff' : this.inactiveColor
241
244
  } else {
242
245
  // button模式下,激活时文字颜色默认为activeColor
243
- style.color = this.current === index ? this.activeColor : this.inactiveColor
246
+ style.color = this.val === index ? this.activeColor : this.inactiveColor
244
247
  }
245
248
  return style
246
249
  }
@@ -280,19 +283,19 @@ export default {
280
283
  },
281
284
  // 判断展示文本
282
285
  getText(item) {
283
- return typeof item === 'object' ? item[this.keyName] : item
286
+ return typeof item === 'object' ? item[this.keyField] : item
284
287
  },
285
288
  // 获取组件的尺寸
286
289
  getRect() {
287
290
  // #ifndef APP-NVUE
288
- this.$pi.common.queryRect(this, '.pi-subsection__item--0', false).then((size) => {
291
+ this.$pi.common.queryRect(this, '.pi-subsection__item--0', false).then(size => {
289
292
  this.itemRect = size
290
293
  })
291
294
  // #endif
292
295
  // #ifdef APP-NVUE
293
296
  const ref = this.$refs['pi-subsection__item--0'][0]
294
297
  ref &&
295
- dom.getComponentRect(ref, (res) => {
298
+ dom.getComponentRect(ref, res => {
296
299
  this.itemRect = res.size
297
300
  })
298
301
  // #endif
@@ -303,15 +306,16 @@ export default {
303
306
  * @returns {Promise} 返回promise
304
307
  */
305
308
  sleep(value = 30) {
306
- return new Promise((resolve) => {
309
+ return new Promise(resolve => {
307
310
  setTimeout(() => {
308
311
  resolve()
309
312
  }, value)
310
313
  })
311
314
  },
312
315
 
313
- clickHandler(index) {
314
- this.$emit('change', index)
316
+ handleSelectItem(index) {
317
+ this.val = index
318
+ this.handleEmitChange()
315
319
  }
316
320
  }
317
321
  }
@@ -0,0 +1,6 @@
1
+ export default {
2
+ customClass: '', // 自定义样式类,字符串形式('')
3
+ customStyle: {}, // 自定义样式,对象形式(默认值:{})
4
+ zIndex: 9999,
5
+ position: 'top'
6
+ }
@@ -0,0 +1,18 @@
1
+ import input from './input'
2
+ import calendar from './calendar'
3
+
4
+ export default {
5
+ customClass: '', // 自定义样式类,字符串形式('')
6
+ customStyle: {}, // 自定义样式,对象形式(默认值:{})
7
+ // input输入设置
8
+ input: {
9
+ ...input,
10
+ placeholder: '请选择',
11
+ disabled: true // 是否禁用
12
+ },
13
+ // 日历弹窗的配置,默认选项请参照calendar
14
+ calendar,
15
+ dateFormat: 'YYYY-MM-DD', // 已选择的时间格式化显示规则,默认('YYYY-MM-DD')
16
+ rangeSplit: '至', // 范围选择时间分隔符,默认('至')
17
+ parseValueFn: null // 解析值的方法,如果配置了,则读取该函数的返回值作为显示的内容
18
+ }
@@ -10,5 +10,6 @@ export default {
10
10
  size: 40, // checkbox大小,单位rpx
11
11
  iconSize: 28, // checkbox icon 大小,单位rpx
12
12
  activeColor: '', // 选中时图标的颜色
13
- activeMode: 'line' // 激活模式(line: 线框模式,fill: 实底模式)
13
+ activeMode: 'line', // 激活模式(line: 线框模式,fill: 实底模式)
14
+ onlyIconSelect: false // 是否点击图标才能选中,默认点击整行都能选中
14
15
  }
@@ -10,5 +10,6 @@ export default {
10
10
  size: 0, // checkbox大小,单位rpx
11
11
  iconSize: 0, // checkbox icon 大小,单位rpx
12
12
  activeColor: '', // 选中时图标的颜色
13
- activeMode: '' // 激活模式(line: 线框模式,fill: 实底模式)
13
+ activeMode: '', // 激活模式(line: 线框模式,fill: 实底模式)
14
+ onlyIconSelect: null // 是否点击图标才能选中,默认点击整行都能选中
14
15
  }
@@ -10,6 +10,7 @@ export default {
10
10
  startYear, // 开始年份(默认当前年份 - 30)
11
11
  endYear, // 结束年份(默认当前年份)
12
12
  field: 'day', // 选择器的粒度 year、month、day、hour、minute、second
13
+ dateType: 'datetime', // 日期类型,date、datetime、time(默认值:datetime)
13
14
  defaultValue: '', // 日期默认值
14
15
  format: '', // 返回的日期格式,为空的时候,返回的是日期对象
15
16
  itemHeight: 110, // 行高(默认:'110rpx')
@@ -0,0 +1,17 @@
1
+ import input from './input'
2
+ import datePicker from './datePicker'
3
+
4
+ export default {
5
+ customClass: '', // 自定义样式类,字符串形式('')
6
+ customStyle: {}, // 自定义样式,对象形式(默认值:{})
7
+ // input输入设置
8
+ input: {
9
+ ...input,
10
+ placeholder: '请选择',
11
+ disabled: true // 是否禁用
12
+ },
13
+ // 日期弹窗的配置,默认选项请参照datePicker
14
+ datePicker,
15
+ dateFormat: 'YYYY-MM-DD', // 已选择的时间格式化显示规则,默认('YYYY-MM-DD')
16
+ parseValueFn: null // 解析值的方法,如果配置了,则读取该函数的返回值作为显示的内容
17
+ }
package/config/input.js CHANGED
@@ -1,3 +1,5 @@
1
+ import icon from './icon'
2
+
1
3
  export default {
2
4
  customClass: '', // 自定义样式类,字符串形式('')
3
5
  customStyle: {}, // 自定义样式,对象形式(默认值:{})
@@ -22,5 +24,12 @@ export default {
22
24
  showConfirmbar: true, // 是否显示键盘上方带有”完成“按钮那一栏
23
25
  autoHeight: false, // 是否自动增高
24
26
  fixed: false, // 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true
25
- disableDefaultPadding: false // 是否去掉 iOS 下的默认内边距
27
+ disableDefaultPadding: false, // 是否去掉 iOS 下的默认内边距
28
+ clearable: false, // 是否可以清空
29
+ clearIcon: {
30
+ // 清空图标设置
31
+ ...icon,
32
+ name: 'close-line',
33
+ color: '#cccccc'
34
+ }
26
35
  }
package/config/radio.js CHANGED
@@ -4,12 +4,13 @@ export default {
4
4
  name: '', // 标识符
5
5
  shape: 'round', // 形状,可选值为 square round dot text
6
6
  borderRadius: 8, // 当shape为square的时候,设置圆角,单位rpx
7
- border: 4, // 边框大小,单位rpx
7
+ border: 2, // 边框大小,单位rpx
8
8
  disabled: false, // 是否禁用复选框
9
9
  readonly: false, // 是否只读模式
10
- size: 36, // radio大小,单位rpx
10
+ size: 40, // radio大小,单位rpx
11
11
  iconSize: 28, // radio icon 大小,单位rpx
12
12
  activeColor: '', // 选中时图标的颜色
13
13
  activeMode: 'line', // 激活模式(line: 线框模式,fill: 实底模式)
14
- canCancel: false // 能否取消选中状态
14
+ canCancel: false, // 能否取消选中状态
15
+ onlyIconSelect: false // 是否点击图标才能选中,默认点击整行都能选中
15
16
  }
@@ -5,12 +5,13 @@ export default {
5
5
  direction: 'horizontal', // 排列方向,可选值为 horizontal vertical
6
6
  shape: '', // 形状,可选值为 square round dot text button
7
7
  stretch: false, // 当shape为button的时候,选项否均分布局,可选值 `true`
8
- borderRadius: 0, // 当shape为square的时候,设置圆角,单位rpx
8
+ borderRadius: null, // 当shape为square的时候,设置圆角,单位rpx
9
9
  border: 0, // 边框大小,单位rpx
10
10
  disabled: false, // 是否禁用复选框
11
11
  size: 0, // checkbox大小,单位rpx
12
12
  iconSize: 0, // checkbox icon 大小,单位rpx
13
13
  activeColor: '', // 选中时图标的颜色
14
14
  activeMode: '', // 激活模式(line: 线框模式,fill: 实底模式)
15
- canCancel: null // 能否取消选中状态
15
+ canCancel: null, // 能否取消选中状态
16
+ onlyIconSelect: null // 是否点击图标才能选中,默认点击整行都能选中
16
17
  }
@@ -7,7 +7,8 @@ export default {
7
7
  regionsData, // 区域数据(考虑到体积,只包含了部分演示数据)
8
8
  keyField: 'code', // 选项id字段,默认为code
9
9
  displayField: 'name', // 选项显示字段,默认为name
10
- defaultValue: null, // 默认值,单选是传Object,多选时传Array,默认null
10
+ keyDefaultValue: false, // 是否只绑定keyField的默认值,默认false
11
+ defaultValue: null, // 默认值
11
12
  itemHeight: 110, // 行高(默认:'110rpx')
12
13
  showItemBottomBorder: true, // 是否显示item下边框(默认:'true')
13
14
  itemStyle: {}, // 行样式(默认:'{}')
@@ -0,0 +1,28 @@
1
+ /*
2
+ * @Author: zhangzhenfei
3
+ * @Date: 2022-05-20 16:47:46
4
+ * @LastEditTime: 2022-05-20 17:54:52
5
+ * @LastEditors: zhangzhenfei
6
+ * @Description:
7
+ * @FilePath: /hfmp-checkin-front/Users/feilin/workspace/piui/piui-awesome/src/piui/config/regionsSelectInput.js
8
+ */
9
+ import input from './input'
10
+ import regionsSelect from './regionsSelect'
11
+
12
+ export default {
13
+ customClass: '', // 自定义样式类,字符串形式('')
14
+ customStyle: {}, // 自定义样式,对象形式(默认值:{})
15
+ // input输入设置
16
+ input: {
17
+ ...input,
18
+ placeholder: '请选择',
19
+ disabled: true // 是否禁用
20
+ },
21
+ // 地区弹窗的配置,默认选项请参照regionsSelect
22
+ regionsSelect: {
23
+ ...regionsSelect,
24
+ keyDefaultValue: true
25
+ },
26
+ rangeSplit: '/', // 地区分隔符,默认('/')
27
+ parseValueFn: null // 解析值的方法,如果配置了,则读取该函数的返回值作为显示的内容
28
+ }
package/config/select.js CHANGED
@@ -8,6 +8,7 @@ export default {
8
8
  items: [], // 选项列表,默认([])
9
9
  keyField: 'id', // 选项id字段,默认为id
10
10
  displayField: 'text', // 选项显示字段,默认为text
11
+ keyDefaultValue: false, // 是否只绑定keyField的默认值,默认false
11
12
  defaultValue: null, // 默认值,单选是传Object,多选时传Array,默认null
12
13
  isMulti: false, // 是否多选,(默认:false)
13
14
  singleCancel: true, // 单选模式下,是否可取消选中
@@ -0,0 +1,28 @@
1
+ /*
2
+ * @Author: zhangzhenfei
3
+ * @Date: 2022-05-18 16:52:21
4
+ * @LastEditTime: 2022-05-19 11:53:43
5
+ * @LastEditors: zhangzhenfei
6
+ * @Description:
7
+ * @FilePath: /hfmp-checkin-front/Users/feilin/workspace/piui/piui-awesome/src/piui/config/selectInput.js
8
+ */
9
+ import input from './input'
10
+ import select from './select'
11
+
12
+ export default {
13
+ customClass: '', // 自定义样式类,字符串形式('')
14
+ customStyle: {}, // 自定义样式,对象形式(默认值:{})
15
+ // input输入设置
16
+ input: {
17
+ ...input,
18
+ placeholder: '请选择',
19
+ disabled: true // 是否禁用
20
+ },
21
+ // select弹窗的配置,默认选项请参照select
22
+ select: {
23
+ ...select,
24
+ keyDefaultValue: true
25
+ },
26
+ rangeSplit: ',', // 范围选择时间分隔符,默认(',')
27
+ parseValueFn: null // 解析值的方法,如果配置了,则读取该函数的返回值作为显示的内容
28
+ }
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  items: [], // tab的数据
3
- current: 0, // 当前活动的tab的index(默认 0 )
3
+ value: 0, // 当前活动的tab的index(默认 0 )
4
4
  activeColor: '#5a7dff', // 激活时的颜色(默认 '#5a7dff' )
5
5
  inactiveColor: '#303133', // 未激活时的颜色(默认 '#303133' )
6
6
  mode: 'button', // 模式选择,mode=button为按钮形式,mode=subsection时为分段模式(默认 'button' )
@@ -8,7 +8,7 @@ export default {
8
8
  fontSize: 24, // 字体大小,单位px(默认 24rpx )
9
9
  bold: true, // 激活选项的字体是否加粗(默认 true )
10
10
  bgColor: '', // 组件背景颜色,mode为button时有效(默认 '#eeeeef' )
11
- keyName: 'name', // 从`list`元素对象中读取的键名(默认 'name' )
11
+ keyField: 'name', // 从`list`元素对象中读取的键名(默认 'name' )
12
12
  customClass: '', // 自定义样式类,字符串形式('')
13
13
  customStyle: {} // 自定义样式,对象形式(默认值:{})
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.6beta6",
3
+ "version": "1.2.6",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "url": "git+https://github.com/sadais-org/piui.git"
12
12
  },
13
13
  "peerDependencies": {
14
- "@sadais/piui-tool": "^0.0.18"
14
+ "@sadais/piui-tool": ">=0.0.21"
15
15
  },
16
16
  "keywords": [
17
17
  "piui sadais-piui"