vdesign-ui 0.1.23 → 0.1.24

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.
@@ -37,31 +37,6 @@
37
37
  <slot></slot>
38
38
  </span>
39
39
  </template>
40
- <!-- <div class="vd-checkbox-button__icon">
41
- <vd-icon
42
- v-if="icon"
43
- :name="icon"
44
- class="vd-checkbox-button__icon--large"
45
- :class="{ 'vd-checkbox-button__icon-mb': iconDescriptionText }"
46
- ></vd-icon>
47
- <vd-icon
48
- v-if="LeftIcon"
49
- :name="LeftIcon"
50
- class="vd-checkbox-button__icon--small"
51
- ></vd-icon>
52
- <span
53
- v-if="iconText"
54
- class="vd-checkbox-button__text"
55
- :class="{ 'vd-checkbox-button__text-mb': descriptionText }"
56
- >{{ iconText }}</span
57
- >
58
- </div>
59
- <span class="vd-checkbox-button-descript" v-if="descriptionText">{{
60
- descriptionText
61
- }}</span>
62
- <span class="vd-checkbox-button__icon-descript" v-if="iconDescriptionText">{{
63
- iconDescriptionText
64
- }}</span> -->
65
40
  </label>
66
41
  </template>
67
42
  <script>
@@ -97,7 +72,6 @@ export default {
97
72
  currentValue: this.value,
98
73
  group: false,
99
74
  parent: findComponentUpward(this, "vd-checkbox-group"),
100
- // name: "",
101
75
  };
102
76
  },
103
77
  computed: {
@@ -1,44 +1,36 @@
1
1
  <template>
2
2
  <div class="vd-dropdown" :class="wrapClasses" v-show="isMask">
3
- <transition :name="isAnimation ? 'vd-dropdown-fade' : ''">
3
+ <!-- <transition :name="isAnimation ? 'vd-dropdown-fade' : ''">
4
4
  <div class="vd-menu-mask" @click.stop="clickMenuMask"></div>
5
- </transition>
6
-
5
+ </transition> -->
7
6
  <transition :name="isAnimation ? 'vd-dropdown-slide-down' : ''">
8
- <div class="vd-dropdown-menu" v-show="value">
9
-
7
+ <div v-clickoutside="clickMenuMask" class="vd-dropdown-menu" v-show="value">
10
8
  <template v-if="!isMultiple && !$slots.custom">
11
9
  <div class="vd-dropdown-item" :class="itemClass(item)" v-for="(item, index) of datalist" :key="item.name"
12
10
  @click.stop="selectedItem(item, index)">
13
11
  <span class="vd-dropdown-left">
14
12
  <vd-icon v-if="item.icon" :name="item.icon" svg class="vd-dropdown-icon"></vd-icon>
15
13
  <span class="vd-dropdown-group-cell">
16
- <span class="vd-dropdown-text">
17
- {{ item.text }}
18
- </span>
19
- <span v-if="['group'].includes(types)" class="vd-dropdown-group-sub">
14
+ <span class="vd-dropdown-text">{{ item.text }}</span>
15
+ <span v-if="types === 'group'" class="vd-dropdown-group-sub">
20
16
  <vd-icon v-if="item.subIcon" :name="item.subIcon" svg class="vd-dropdown-sub-icon"></vd-icon>
21
17
  <span class="vd-dropdown-subtext" v-html="item.subText"></span>
22
18
  </span>
23
19
  </span>
24
20
  </span>
25
-
26
- <vd-icon v-if="['primary'].includes(types) && item.selected" class="vd-dropdown-active-select"
21
+ <vd-icon v-if="types === 'primary' && item.selected" class="vd-dropdown-active-select"
27
22
  name="icon_btn_singleslt" color="#1BC47D"></vd-icon>
28
- <span v-if="['state'].includes(types)" v-html="item.stateText" class="vd-dropdown-state-text"
23
+ <span v-if="types === 'state'" v-html="item.stateText" class="vd-dropdown-state-text"
29
24
  :class="`vd-dropdown-state-text--${item.state}`"></span>
30
25
  </div>
31
26
  </template>
32
27
 
33
28
  <template v-if="isMultiple">
34
29
  <div class="vd-dropdown-item" :class="itemClass(item)" v-for="item of datalist" :key="item.name">
35
-
36
- <vd-checkbox v-model="item.selected"
37
- :disabled="!item.selected && max <= list.filter(value => value.selected == true).length ? true : false">
30
+ <vd-checkbox v-model="item.selected" :disabled="!item.selected && max <= selectedCount">
38
31
  {{ item.text }}
39
32
  </vd-checkbox>
40
-
41
- <vd-icon v-if="['primary'].includes(types) && item.selected" class="vd-dropdown-active-select"
33
+ <vd-icon v-if="types === 'primary' && item.selected" class="vd-dropdown-active-select"
42
34
  name="icon_btn_singleslt" color="#1BC47D"></vd-icon>
43
35
  </div>
44
36
  <div class="vd-dropdown--btn">
@@ -52,16 +44,20 @@
52
44
  </div>
53
45
  </div>
54
46
  </transition>
55
-
56
47
  </div>
57
48
  </template>
49
+
58
50
  <script>
51
+ import clickoutside from "../mixins/clickoutside.js";
52
+
59
53
  const prefixCls = 'vd-dropdown';
60
54
  export default {
61
55
  name: 'vd-dropdown',
56
+ directives: {
57
+ clickoutside
58
+ },
62
59
  props: {
63
60
  isAnimation: {
64
- //是否有动画效果
65
61
  type: Boolean,
66
62
  default: false
67
63
  },
@@ -71,7 +67,6 @@ export default {
71
67
  validator: value => ['primary', 'secondary', 'state', 'group'].includes(value)
72
68
  },
73
69
  value: {
74
- //是否显示
75
70
  type: Boolean,
76
71
  default: false
77
72
  },
@@ -83,13 +78,17 @@ export default {
83
78
  type: Boolean,
84
79
  default: false
85
80
  },
81
+ alignment: {
82
+ type: String,
83
+ default: 'center',
84
+ validator: value => ['start', 'end', 'center'].includes(value)
85
+ },
86
86
  col: {
87
- //显示的列数
88
87
  type: [Number, String],
89
88
  default: 1
90
89
  },
91
90
  max: {
92
- type: [String, Number],
91
+ type: [Number, String],
93
92
  default: 5
94
93
  },
95
94
  custom: {
@@ -98,11 +97,8 @@ export default {
98
97
  },
99
98
  list: {
100
99
  type: Array,
101
- default: () => {
102
- return [];
103
- }
100
+ default: () => []
104
101
  },
105
- // state
106
102
  state: {
107
103
  type: String,
108
104
  default: 'close',
@@ -112,7 +108,6 @@ export default {
112
108
  type: String,
113
109
  default: ''
114
110
  },
115
- // group
116
111
  subText: {
117
112
  type: String,
118
113
  default: ''
@@ -122,25 +117,23 @@ export default {
122
117
  default: ''
123
118
  }
124
119
  },
125
- watch: {
126
- value(val) {
127
- this.isMask = val ? true : false
128
- }
129
- },
130
120
  data() {
131
121
  return {
132
122
  datalist: [],
133
- isMask: false
123
+ isMask: this.value
134
124
  };
135
125
  },
136
- mounted() {
137
- this.datalist = [...this.list];
126
+ watch: {
127
+ value(val) {
128
+ this.isMask = val;
129
+ }
138
130
  },
139
131
  computed: {
140
132
  wrapClasses() {
141
133
  return {
142
134
  [`${prefixCls}-${this.types}`]: this.types,
143
135
  [`${prefixCls}--divided`]: this.types !== 'state',
136
+ [`${prefixCls}-${this.alignment}`]: this.alignment
144
137
  };
145
138
  },
146
139
  okBtnTxt() {
@@ -148,14 +141,20 @@ export default {
148
141
  },
149
142
  resetBtnTxt() {
150
143
  return '重置';
144
+ },
145
+ selectedCount() {
146
+ return this.datalist.filter(item => item.selected).length;
151
147
  }
152
148
  },
149
+ mounted() {
150
+ this.datalist = [...this.list];
151
+ },
153
152
  methods: {
154
153
  itemClass(item) {
155
154
  return {
156
155
  [`${prefixCls}--disabled`]: item.disabled,
157
156
  [`${prefixCls}--active`]: item.selected
158
- }
157
+ };
159
158
  },
160
159
  clickMenuMask() {
161
160
  this.isMask = false;
@@ -164,16 +163,8 @@ export default {
164
163
  selectedItem(item, index) {
165
164
  this.$emit('change', item, index);
166
165
  },
167
- selectMultiple(index) {
168
- const count = this.datalist.filter(item => item.selected).length;
169
- if (!this.datalist[index].selected && count >= this.max) {
170
- this.$emit('maxTip');
171
- return;
172
- }
173
- this.$set(this.datalist[index], 'selected', !this.datalist[index].selected);
174
- },
175
166
  resetMenu() {
176
- this.datalist.map(value => (value.selected = false));
167
+ this.datalist.forEach(item => (item.selected = false));
177
168
  this.$emit('reset', this.datalist);
178
169
  },
179
170
  sureMenu() {
@@ -35,11 +35,33 @@
35
35
  transform-origin: top center;
36
36
  position: absolute;
37
37
  transition: transform 0.25s ease, opacity 0.25s ease;
38
- inset-inline-start: 50%;
39
38
  inset-block-start: 100%;
39
+ // 默认 center
40
+ inset-inline-start: 50%;
40
41
  transform: translate(var(--translate-x), 2px);
41
42
  }
42
43
 
44
+ &-start {
45
+ .@{dropdown-prefix-cls}-menu {
46
+ inset-inline-start: 0;
47
+ transform: translate(0, 2px);
48
+ }
49
+ }
50
+
51
+ &-end {
52
+ .@{dropdown-prefix-cls}-menu {
53
+ inset-inline-start: inherit;
54
+ inset-inline-end: 0;
55
+ transform: translate(0, 2px);
56
+ }
57
+ }
58
+
59
+ &-center {
60
+ .@{dropdown-prefix-cls}-menu {
61
+ inset-inline-start: 50%;
62
+ transform: translate(var(--translate-x), 2px);
63
+ }
64
+ }
43
65
 
44
66
  &-primary {
45
67
  .@{dropdown-prefix-cls}-menu {
@@ -35,9 +35,6 @@ export default {
35
35
  type: Boolean,
36
36
  default: false
37
37
  },
38
- // extra: {
39
- // type: [String, Number, Boolean],
40
- // },
41
38
  value: {
42
39
  type: [String, Number, Boolean],
43
40
  default: false
@@ -5,8 +5,9 @@
5
5
  <div :contenteditable="contenteditable" class="vd-selector__left">
6
6
  <vd-icon v-if="icon" :name="icon" svg :class="iconClasses"></vd-icon>
7
7
  <div :class="titleClasses">
8
- <slot v-if="!isSlotEmpty" name="content"></slot>
9
- <template v-else>{{ content }} </template>
8
+ <slot name="content">
9
+ {{ content }}
10
+ </slot>
10
11
  </div>
11
12
  </div>
12
13
  <vd-icon v-if="arrow" :name="arrow" :class="arrowClasses"></vd-icon>
@@ -17,43 +18,52 @@
17
18
 
18
19
  <script>
19
20
  const prefixCls = 'vd-selector';
21
+
20
22
  export default {
21
- name: "vd-selector",
22
- componentName: "vd-selector",
23
+ name: 'vd-selector',
23
24
  props: {
25
+ // 图标名称
24
26
  icon: {
25
27
  type: String,
26
28
  default: ''
27
29
  },
30
+ // 箭头图标名称或布尔值(是否显示箭头)
28
31
  arrow: {
29
32
  type: [String, Boolean],
30
33
  default: 'icon_btn_moredown'
31
34
  },
35
+ // 组件类型(用于自定义样式)
32
36
  type: {
33
37
  type: String,
34
- default: ''// form
38
+ default: '' // form
35
39
  },
40
+ // 组件尺寸
36
41
  size: {
37
42
  type: String,
38
43
  default: 'm',
39
44
  validator: value => ['s', 'm', 'l', 'xl'].includes(value)
40
45
  },
46
+ // 组件内容
41
47
  content: {
42
48
  type: [String, Array],
43
49
  default: ''
44
50
  },
51
+ // 是否禁用组件
45
52
  disabled: {
46
53
  type: Boolean,
47
54
  default: false
48
55
  },
56
+ // 是否激活组件
49
57
  active: {
50
58
  type: Boolean,
51
59
  default: false
52
60
  },
61
+ // 是否允许编辑内容
53
62
  contenteditable: {
54
63
  type: Boolean,
55
64
  default: false
56
65
  },
66
+ // 是否显示子菜单
57
67
  value: {
58
68
  type: Boolean,
59
69
  default: false
@@ -61,59 +71,64 @@ export default {
61
71
  },
62
72
  data() {
63
73
  return {
64
- showMenu: this.value,
65
- };
74
+ // 是否显示子菜单
75
+ showMenu: false
76
+ }
77
+ },
78
+ watch: {
79
+ // 监听 value 属性变化,同步更新 showMenu
80
+ value(newVal) {
81
+ this.showMenu = newVal;
82
+ }
66
83
  },
67
84
  computed: {
68
- isSlotEmpty() {
69
- return !this.$slots.content;
70
- },
85
+ // 计算外层容器的样式类
71
86
  wrapClasses() {
72
87
  return {
73
88
  [`${prefixCls}-${this.type}`]: this.type,
74
89
  [`${prefixCls}-${this.size}`]: this.size,
75
90
  [`${prefixCls}--disabled`]: this.disabled,
76
91
  [`${prefixCls}--active`]: this.showMenu || this.active,
77
- }
92
+ };
78
93
  },
94
+ // 计算标题的样式类
79
95
  titleClasses() {
80
96
  return {
81
97
  [`${prefixCls}-${this.type}__title`]: this.type,
82
98
  [`${prefixCls}-${this.size}__title`]: this.size,
83
- }
99
+ };
84
100
  },
101
+ // 计算图标的样式类
85
102
  iconClasses() {
86
103
  return {
87
104
  [`${prefixCls}-iconfont`]: true,
88
105
  [`${prefixCls}-${this.type}__icon`]: this.type,
89
106
  [`${prefixCls}-${this.size}__icon`]: this.size,
90
- }
107
+ };
91
108
  },
109
+ // 计算箭头的样式类
92
110
  arrowClasses() {
93
111
  return {
94
112
  [`${prefixCls}-iconfont`]: true,
95
113
  [`${prefixCls}-${this.type}__arrow`]: this.type,
96
114
  [`${prefixCls}-${this.size}__arrow`]: this.size,
97
115
  [`${prefixCls}__arrow--active`]: this.showMenu && this.arrow === 'icon_btn_moredown',
98
- }
116
+ };
99
117
  },
100
118
  },
101
- watch: {
102
- value(val) {
103
- this.showMenu = val;
104
- }
105
- },
106
119
  methods: {
120
+ // 关闭子菜单
107
121
  close() {
108
- this.showMenu = false
109
- this.$emit('close', false)
110
- this.$emit('input', false)
122
+ this.showMenu = false;
123
+ this.$emit('close', false);
124
+ this.$emit('input', false);
111
125
  },
126
+ // 处理点击事件
112
127
  handlerClick() {
113
128
  if (this.disabled) return;
114
- this.showMenu = !this.showMenu
115
- this.$emit('click', this.showMenu)
116
- this.$emit('input', this.showMenu)
129
+ this.showMenu = !this.showMenu;
130
+ // this.$emit('input', this.showMenu);
131
+ this.$emit('click', this.showMenu);
117
132
  }
118
133
  }
119
134
  };
@@ -59,15 +59,9 @@ export default {
59
59
  type: Number,
60
60
  default: 1
61
61
  },
62
- // disabled: {
63
- // type: Boolean,
64
- // default: false
65
- // },
66
62
  value: {
67
63
  type: Number
68
64
  },
69
- markLeft:Number,
70
- markRight:Number,
71
65
 
72
66
  },
73
67
  data() {
@@ -11,7 +11,7 @@
11
11
  <div class="vd-title--right" v-if="guideText || arrow || $slots.right">
12
12
  <slot name="right">
13
13
  <span v-if="guideText" :class="textRightClasses">{{ guideText }}</span>
14
- <vd-icon v-if="arrow" class="vd-title-arrow" name="ar_icon_nav_back"></vd-icon>
14
+ <vd-icon v-if="arrow" class="vd-title-arrow" name="icon_btn_next"></vd-icon>
15
15
  </slot>
16
16
  </div>
17
17
  </div>
@@ -15,7 +15,6 @@
15
15
  export default {
16
16
  name: 'vd-upload',
17
17
  inheritAttrs: false,
18
-
19
18
  props: {
20
19
  photo: {
21
20
  type: String,