uview-plus 3.1.51 → 3.2.3

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 (50) hide show
  1. package/changelog.md +47 -0
  2. package/components/u-action-sheet/u-action-sheet.vue +1 -1
  3. package/components/u-album/u-album.vue +261 -261
  4. package/components/u-avatar/u-avatar.vue +3 -2
  5. package/components/u-avatar-group/u-avatar-group.vue +106 -106
  6. package/components/u-button/u-button.vue +12 -7
  7. package/components/u-calendar/u-calendar.vue +4 -3
  8. package/components/u-cell/u-cell.vue +6 -3
  9. package/components/u-checkbox/props.js +5 -0
  10. package/components/u-checkbox/u-checkbox.vue +27 -15
  11. package/components/u-code/u-code.vue +1 -1
  12. package/components/u-copy/u-copy.vue +70 -0
  13. package/components/u-dropdown/props.js +8 -14
  14. package/components/u-dropdown/u-dropdown.vue +202 -77
  15. package/components/u-dropdown-item/props.js +45 -36
  16. package/components/u-dropdown-item/u-dropdown-item.vue +121 -148
  17. package/components/u-form/u-form.vue +1 -1
  18. package/components/u-form-item/props.js +6 -1
  19. package/components/u-form-item/u-form-item.vue +1 -1
  20. package/components/u-gap/u-gap.vue +5 -4
  21. package/components/u-grid/u-grid.vue +4 -2
  22. package/components/u-grid-item/u-grid-item.vue +8 -7
  23. package/components/u-input/u-input.vue +1 -1
  24. package/components/u-lazy-load/u-lazy-load.vue +251 -0
  25. package/components/u-picker/u-picker.vue +4 -1
  26. package/components/u-popup/u-popup.vue +1 -1
  27. package/components/u-read-more/u-read-more.vue +164 -160
  28. package/components/u-slider/u-slider.vue +6 -6
  29. package/components/u-steps-item/u-steps-item.vue +318 -318
  30. package/components/u-subsection/u-subsection.vue +14 -8
  31. package/components/u-swiper/u-swiper.vue +6 -8
  32. package/components/u-tabs/u-tabs.vue +1 -0
  33. package/components/u-tag/props.js +5 -2
  34. package/components/u-text/u-text.vue +226 -226
  35. package/components/u-textarea/u-textarea.vue +275 -275
  36. package/components/u-transition/u-transition.vue +1 -1
  37. package/components/u-waterfall/u-waterfall.vue +225 -0
  38. package/index.js +5 -1
  39. package/libs/config/props/formItem.js +1 -0
  40. package/libs/config/props/tag.js +30 -29
  41. package/libs/css/common.scss +1 -1
  42. package/libs/css/components.scss +5 -5
  43. package/libs/function/colorGradient.js +8 -8
  44. package/libs/function/debounce.js +2 -2
  45. package/libs/function/digit.js +5 -5
  46. package/libs/function/index.js +29 -29
  47. package/libs/function/test.js +28 -28
  48. package/libs/function/throttle.js +2 -2
  49. package/libs/mixin/mixin.js +2 -2
  50. package/package.json +2 -2
@@ -1,148 +1,121 @@
1
- <template>
2
- <view class="u-drawdown-item">
3
- <u-overlay
4
- customStyle="top: 126px"
5
- :show="show"
6
- :closeOnClickOverlay="closeOnClickOverlay"
7
- @click="overlayClick"
8
- ></u-overlay>
9
- <view
10
- class="u-drawdown-item__content"
11
- :style="[style]"
12
- :animation="animationData"
13
- ref="animation"
14
- >
15
- <slot />
16
- </view>
17
- </view>
18
- </template>
19
-
20
- <script>
21
- // #ifdef APP-NVUE
22
- const animation = uni.requireNativePlugin('animation')
23
- const dom = uni.requireNativePlugin('dom')
24
- // #endif
25
- import props from './props.js';
26
- import mpMixin from '../../libs/mixin/mpMixin.js';
27
- import mixin from '../../libs/mixin/mixin.js';
28
- /**
29
- * Drawdownitem
30
- * @description
31
- * @tutorial url
32
- * @property {String}
33
- * @event {Function}
34
- * @example
35
- */
36
- export default {
37
- name: 'u-drawdown-item',
38
- mixins: [mpMixin, mixin, props],
39
- data() {
40
- return {
41
- show: false,
42
- top: '126px',
43
- // uni.createAnimation的导出数据
44
- animationData: {},
45
- }
46
- },
47
- mounted() {
48
- this.init()
49
- },
50
- watch: {
51
- // 发生变化时,需要去更新父组件对应的值
52
- dataChange(newValue, oldValue) {
53
- this.updateParentData()
54
- }
55
- },
56
- computed: {
57
- // 监听对应变量的变化
58
- dataChange() {
59
- return [this.title, this.disabled]
60
- },
61
- style() {
62
- const style = {
63
- zIndex: 10071,
64
- position: 'fixed',
65
- display: 'flex',
66
- left: 0,
67
- right: 0
68
- }
69
- style.top = uni.$u.addUnit(this.top)
70
- return style
71
- }
72
- },
73
- methods: {
74
- init() {
75
- this.updateParentData()
76
- },
77
- // 更新父组件所需的数据
78
- updateParentData() {
79
- // 获取父组件u-dropdown
80
- this.getParentData('u-dropdown')
81
- if (!this.parent) uni.$u.error('u-dropdown-item必须配合u-dropdown使用')
82
- // 查找父组件menuList数组中对应的标题数据
83
- const menuIndex = this.parent.menuList.findIndex(item => item.title === this.title)
84
- const menuContent = {
85
- title: this.title,
86
- disabled: this.disabled
87
- }
88
- if (menuIndex >= 0) {
89
- // 如果能找到,则直接修改
90
- this.parent.menuList[menuIndex] = menuContent;
91
- } else {
92
- // 如果无法找到,则为第一次添加,直接push即可
93
- this.parent.menuList.push(menuContent);
94
- }
95
- },
96
- async setContentAnimate(height) {
97
- this.animating = true
98
- // #ifdef APP-NVUE
99
- const ref = this.$refs['animation'].ref
100
- animation.transition(ref, {
101
- styles: {
102
- height: uni.$u.addUnit(height)
103
- },
104
- duration: this.duration,
105
- timingFunction: 'ease-in-out',
106
- }, () => {
107
- this.animating = false
108
- })
109
- // #endif
110
-
111
- // #ifndef APP-NVUE
112
- const animation = uni.createAnimation({
113
- timingFunction: 'ease-in-out',
114
- });
115
- animation
116
- .height(height)
117
- .step({
118
- duration: this.duration,
119
- })
120
- .step()
121
- // 导出动画数据给面板的animationData值
122
- this.animationData = animation.export()
123
- // 标识动画结束
124
- uni.$u.sleep(this.duration).then(() => {
125
- this.animating = false
126
- })
127
- // #endif
128
- },
129
- overlayClick() {
130
- this.show = false
131
- this.setContentAnimate(0)
132
- }
133
- },
134
- }
135
- </script>
136
-
137
- <style lang="scss" scoped>
138
- @import '../../libs/css/components.scss';
139
-
140
- .u-drawdown-item {
141
-
142
- &__content {
143
- background-color: #FFFFFF;
144
- overflow: hidden;
145
- height: 0;
146
- }
147
- }
148
- </style>
1
+ <template>
2
+ <view class="u-dropdown-item" v-if="active" @touchmove.stop.prevent="() => {}" @tap.stop.prevent="() => {}">
3
+ <block v-if="!$slots.default && !$slots.$default">
4
+ <scroll-view scroll-y="true" :style="{
5
+ height: $u.addUnit(height)
6
+ }">
7
+ <view class="u-dropdown-item__options">
8
+ <up-cell-group>
9
+ <up-cell @click="cellClick(item.value)" :arrow="false" :title="item.label" v-for="(item, index) in options"
10
+ :key="index" :title-style="{
11
+ color: modelValue == item.value ? activeColor : inactiveColor
12
+ }">
13
+ <up-icon v-if="modelValue == item.value" name="checkbox-mark" :color="activeColor" size="32"></up-icon>
14
+ </up-cell>
15
+ </up-cell-group>
16
+ </view>
17
+ </scroll-view>
18
+ </block>
19
+ <slot v-else />
20
+ </view>
21
+ </template>
22
+
23
+ <script>
24
+ import props from './props.js';
25
+ import mpMixin from '../../libs/mixin/mpMixin.js';
26
+ import mixin from '../../libs/mixin/mixin.js';
27
+ /**
28
+ * dropdown-item 下拉菜单
29
+ * @description 该组件一般用于向下展开菜单,同时可切换多个选项卡的场景
30
+ * @tutorial https://ijry.github.io/uview-plus/components/dropdown.html
31
+ * @property {String | Number} v-model 双向绑定选项卡选择值
32
+ * @property {String} title 菜单项标题
33
+ * @property {Array[Object]} options 选项数据,如果传入了默认slot,此参数无效
34
+ * @property {Boolean} disabled 是否禁用此选项卡(默认false)
35
+ * @property {String | Number} duration 选项卡展开和收起的过渡时间,单位ms(默认300)
36
+ * @property {String | Number} height 弹窗下拉内容的高度(内容超出将会滚动)(默认auto)
37
+ * @example <u-dropdown-item title="标题"></u-dropdown-item>
38
+ */
39
+ export default {
40
+ name: 'u-dropdown-item',
41
+ mixins: [mpMixin, mixin, props],
42
+ options: {
43
+ styleIsolation: 'shared',
44
+ },
45
+ data() {
46
+ return {
47
+ active: false, // 当前项是否处于展开状态
48
+ activeColor: '#2979ff', // 激活时左边文字和右边对勾图标的颜色
49
+ inactiveColor: '#606266', // 未激活时左边文字和右边对勾图标的颜色
50
+ }
51
+ },
52
+ computed: {
53
+ // 监听props是否发生了变化,有些值需要传递给父组件u-dropdown,无法双向绑定
54
+ propsChange() {
55
+ return `${this.title}-${this.disabled}`;
56
+ }
57
+ },
58
+ watch: {
59
+ propsChange(n) {
60
+ // 当值变化时,通知父组件重新初始化,让父组件执行每个子组件的init()方法
61
+ // 将所有子组件数据重新整理一遍
62
+ if (this.parent) this.parent.init();
63
+ }
64
+ },
65
+ created() {
66
+ // 父组件的实例
67
+ this.parent = false;
68
+ },
69
+ emits: ['update:modelValue', 'change'],
70
+ methods: {
71
+ init() {
72
+ // 获取父组件u-dropdown
73
+ let parent = this.$u.$parent.call(this, 'u-dropdown');
74
+ if (parent) {
75
+ this.parent = parent;
76
+ // 将子组件的激活颜色配置为父组件设置的激活和未激活时的颜色
77
+ this.activeColor = parent.activeColor;
78
+ this.inactiveColor = parent.inactiveColor;
79
+ // 将本组件的this,放入到父组件的children数组中,让父组件可以操作本(子)组件的方法和属性
80
+ // push进去前,显判断是否已经存在了本实例,因为在子组件内部数据变化时,会通过父组件重新初始化子组件
81
+ let exist = parent.children.find(val => {
82
+ return this === val;
83
+ })
84
+ if (!exist) parent.children.push(this);
85
+ if (parent.children.length == 1) this.active = true;
86
+ // 父组件无法监听children的变化,故将子组件的title,传入父组件的menuList数组中
87
+ parent.menuList.push({
88
+ title: this.title,
89
+ disabled: this.disabled
90
+ });
91
+ }
92
+ },
93
+ // cell被点击
94
+ cellClick(value) {
95
+ // 修改通过v-model绑定的值
96
+ // #ifdef VUE2
97
+ this.$emit('input', value);
98
+ // #endif
99
+ // #ifdef VUE3
100
+ this.$emit('update:modelValue', value);
101
+ // #endif
102
+ // 通知父组件(u-dropdown)收起菜单
103
+ this.parent.close();
104
+ // 发出事件,抛出当前勾选项的value
105
+ this.$emit('change', value);
106
+ }
107
+ },
108
+ mounted() {
109
+ this.init();
110
+ }
111
+ }
112
+ </script>
113
+
114
+ <style scoped lang="scss">
115
+ @import "../../libs/css/components.scss";
116
+ .u-dropdown-item__options {
117
+ ::v-deep .u-cell-group {
118
+ background: #ffffff;
119
+ }
120
+ }
121
+ </style>
@@ -23,7 +23,7 @@
23
23
  * @property {String | Number} labelWidth 提示文字的宽度,单位px ( 默认 45 )
24
24
  * @property {String} labelAlign lable字体的对齐方式 ( 默认 ‘left' )
25
25
  * @property {Object} labelStyle lable的样式,对象形式
26
- * @example <u--formlabelPosition="left" :model="model1" :rules="rules" ref="form1"></u--form>
26
+ * @example <up-formlabelPosition="left" :model="model1" :rules="rules" ref="form1"></up-form>
27
27
  */
28
28
  export default {
29
29
  name: "u-form",
@@ -11,7 +11,7 @@ export default {
11
11
  default: () => uni.$u.props.formItem.prop
12
12
  },
13
13
  // 绑定的规则
14
- prop: {
14
+ rule: {
15
15
  type: String,
16
16
  default: () => uni.$u.props.formItem.rule
17
17
  },
@@ -20,6 +20,11 @@ export default {
20
20
  type: [String, Boolean],
21
21
  default: () => uni.$u.props.formItem.borderBottom
22
22
  },
23
+ // label的位置,left-左边,top-上边
24
+ labelPosition: {
25
+ type: String,
26
+ default: () => uni.$u.props.formItem.labelPosition
27
+ },
23
28
  // label的宽度,单位px
24
29
  labelWidth: {
25
30
  type: [String, Number],
@@ -4,7 +4,7 @@
4
4
  class="u-form-item__body"
5
5
  @tap="clickHandler"
6
6
  :style="[$u.addStyle(customStyle), {
7
- flexDirection: parentData.labelPosition === 'left' ? 'row' : 'column'
7
+ flexDirection: (labelPosition || parentData.labelPosition) === 'left' ? 'row' : 'column'
8
8
  }]"
9
9
  >
10
10
  <!-- 微信小程序中,将一个参数设置空字符串,结果会变成字符串"true" -->
@@ -6,6 +6,7 @@
6
6
  import props from './props.js';
7
7
  import mpMixin from '../../libs/mixin/mpMixin.js';
8
8
  import mixin from '../../libs/mixin/mixin.js';
9
+ import { addStyle, addUnit, deepMerge } from '../../libs/function/index.js';
9
10
  /**
10
11
  * gap 间隔槽
11
12
  * @description 该组件一般用于内容块之间的用一个灰色块隔开的场景,方便用户风格统一,减少工作量
@@ -25,11 +26,11 @@
25
26
  gapStyle() {
26
27
  const style = {
27
28
  backgroundColor: this.bgColor,
28
- height: uni.$u.addUnit(this.height),
29
- marginTop: uni.$u.addUnit(this.marginTop),
30
- marginBottom: uni.$u.addUnit(this.marginBottom),
29
+ height: addUnit(this.height),
30
+ marginTop: addUnit(this.marginTop),
31
+ marginBottom: addUnit(this.marginBottom),
31
32
  }
32
- return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
33
+ return deepMerge(style, addStyle(this.customStyle))
33
34
  }
34
35
  }
35
36
  };
@@ -71,7 +71,9 @@
71
71
  return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle));
72
72
  }
73
73
  },
74
- emits: ['click'], // 防止事件执行两次
74
+ emits: ['click'], // 防止事件执行两次
75
+ // virtualHost: true ,//将自定义节点设置成虚拟的,更加接近Vue组件的表现。我们不希望自定义组件的这个节点本身可以设置样式、响应 flex 布局等
76
+ },
75
77
  methods: {
76
78
  // 此方法由u-grid-item触发,用于在u-grid发出事件
77
79
  childClick(name) {
@@ -95,6 +97,6 @@
95
97
  justify-content: center;
96
98
  @include flex;
97
99
  flex-wrap: wrap;
98
- align-items: center;
100
+ align-items: center;
99
101
  }
100
102
  </style>
@@ -1,7 +1,6 @@
1
1
  <template>
2
- <!-- #ifndef APP-NVUE -->
3
- <view
4
- v-if="parentData.col > 0"
2
+ <!-- #ifndef APP-NVUE -->
3
+ <view
5
4
  class="u-grid-item"
6
5
  hover-class="u-grid-item--hover-class"
7
6
  :hover-stay-time="200"
@@ -50,6 +49,8 @@
50
49
  },
51
50
  // #ifdef APP-NVUE
52
51
  width: 0, // nvue下才这么计算,vue下放到computed中,否则会因为延时造成闪烁
52
+ // #endif
53
+ width: '100%',
53
54
  // #endif
54
55
  classes: [], // 类名集合,用于判断是否显示右边和下边框
55
56
  };
@@ -59,11 +60,11 @@
59
60
  },
60
61
  emits: ['click'],
61
62
  // 微信小程序中 options 选项
62
- options: {
63
- virtualHost: true //将自定义节点设置成虚拟的,更加接近Vue组件的表现。我们不希望自定义组件的这个节点本身可以设置样式、响应 flex 布局等
64
- },
63
+ // #ifdef MP-WEIXIN
64
+ virtualHost: true ,//将自定义节点设置成虚拟的,更加接近Vue组件的表现。我们不希望自定义组件的这个节点本身可以设置样式、响应 flex 布局等
65
+ },
65
66
  computed: {
66
- // #ifndef APP-NVUE
67
+ // #ifndef APP-NVUE || MP-TOUTIAO
67
68
  // vue下放到computed中,否则会因为延时造成闪烁
68
69
  width() {
69
70
  if (this.parentData.col > 0) {
@@ -37,7 +37,7 @@
37
37
  :adjust-position="adjustPosition"
38
38
  :selection-end="selectionEnd"
39
39
  :selection-start="selectionStart"
40
- :password="password || type === 'password' || undefined"
40
+ :password="password || type === 'password' || false"
41
41
  :ignoreCompositionEvent="ignoreCompositionEvent"
42
42
  @input="onInput"
43
43
  @blur="onBlur"