dolphin-weex-ui 0.2.13 → 0.2.15

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 (45) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/index.native.js +3812 -1591
  3. package/dist/index.native.js.map +1 -1
  4. package/dist/index.web.js +4387 -1725
  5. package/dist/index.web.js.map +1 -1
  6. package/index.js +22 -0
  7. package/package.json +1 -1
  8. package/packages/dof-board/index.js +1 -0
  9. package/packages/dof-board/index.vue +63 -0
  10. package/packages/dof-card/index.js +1 -1
  11. package/packages/dof-card/index.vue +140 -411
  12. package/packages/dof-card-group/index.js +1 -0
  13. package/packages/dof-card-group/index.vue +18 -0
  14. package/packages/dof-card-item/index.js +1 -0
  15. package/packages/dof-card-item/index.vue +29 -0
  16. package/packages/dof-col/index.js +1 -0
  17. package/packages/dof-col/index.vue +23 -0
  18. package/packages/dof-icon-button/index.js +1 -0
  19. package/packages/dof-icon-button/index.vue +88 -0
  20. package/packages/dof-progress/index.vue +53 -56
  21. package/packages/dof-row/index.js +1 -0
  22. package/packages/dof-row/index.vue +21 -0
  23. package/packages/dof-slider/index.js +1 -0
  24. package/packages/dof-slider/index.vue +256 -0
  25. package/packages/dof-slider-scale/index.js +1 -0
  26. package/packages/dof-slider-scale/index.vue +52 -0
  27. package/packages/dof-step-action/index.js +1 -0
  28. package/packages/dof-step-action/index.vue +113 -0
  29. package/packages/dof-switch/index.vue +45 -7
  30. package/packages/dof-tag/index.js +1 -1
  31. package/packages/dof-tag/index.vue +60 -127
  32. package/packages/dof-tag-group/index.js +1 -0
  33. package/packages/dof-tag-group/index.vue +19 -0
  34. package/packages/dof-taged/index.js +1 -0
  35. package/packages/dof-taged/index.vue +140 -0
  36. package/packages/utils/direction.js +7 -0
  37. package/packages/utils/dom.js +11 -0
  38. package/packages/utils/math-extension.js +3 -0
  39. package/packages/utils/mix-child.js +57 -0
  40. package/packages/utils/mix-parent.js +14 -0
  41. package/packages/utils/mix-selectable-child.js +69 -0
  42. package/packages/utils/mix-selectable-parent.js +29 -0
  43. package/packages/utils/touch.js +76 -0
  44. package/packages/utils/transition.js +130 -0
  45. package/packages/utils/vue-extension.js +32 -0
@@ -0,0 +1,88 @@
1
+ <template>
2
+ <div class="dof-icon-button" @click="onClick">
3
+ <image :class="['dof-icon-button-img', round && 'dof-icon-button-img--round']" :src="src" :style="style"></image>
4
+ <slot>
5
+ <text v-if="text" class="dof-icon-button-text">{{ text }}</text>
6
+ </slot>
7
+ </div>
8
+ </template>
9
+
10
+ <script>
11
+ export default {
12
+ props: {
13
+ active: {
14
+ type: Boolean,
15
+ default: false
16
+ },
17
+ img: {
18
+ type: String,
19
+ required: true
20
+ },
21
+ color: {
22
+ type: String,
23
+ default: '#f2f2f2'
24
+ },
25
+ activeImg: {
26
+ type: String,
27
+ default: ''
28
+ },
29
+ activeColor: {
30
+ type: String,
31
+ default: '#267AFF'
32
+ },
33
+ round: {
34
+ type: Boolean,
35
+ default: true
36
+ },
37
+ text: {
38
+ type: String,
39
+ default: ''
40
+ }
41
+ },
42
+ model: {
43
+ prop: 'active',
44
+ event: 'change'
45
+ },
46
+ computed: {
47
+ src() {
48
+ const res = this.active ? this.activeImg : this.img
49
+ return res || this.img
50
+ },
51
+ style() {
52
+ const res = {
53
+ backgroundColor: this.active ? this.activeColor : this.color
54
+ }
55
+ return res
56
+ }
57
+ },
58
+ methods: {
59
+ onClick() {
60
+ this.$emit('change', !this.active)
61
+ }
62
+ }
63
+ }
64
+ </script>
65
+
66
+ <style scoped>
67
+ .dof-icon-button {
68
+ align-items: center;
69
+ }
70
+
71
+ .dof-icon-button-img {
72
+ width: 96px;
73
+ height: 96px;
74
+ }
75
+
76
+ .dof-icon-button-img--round {
77
+ border-radius: 48px;
78
+ }
79
+
80
+ .dof-icon-button-text {
81
+ margin-top: 24px;
82
+ font-family: PingFangSC-Regular;
83
+ font-size: 24px;
84
+ color: #000000;
85
+ text-align: center;
86
+ font-weight: 400;
87
+ }
88
+ </style>
@@ -1,71 +1,68 @@
1
1
  <template>
2
- <div class="dof-progress"
3
- :style="runWayStyle"
4
- :accessible="true"
5
- :aria-label="`进度为百分之${value}`">
2
+ <div class="dof-progress" :style="runWayStyle" :accessible="true" :aria-label="`进度为百分之${value}`">
6
3
  <div class="progress" :style="progressStyle"></div>
7
4
  </div>
8
5
  </template>
9
6
 
10
7
  <style scoped>
11
- .dof-progress {
12
- background-color: #f2f3f4;
13
- }
8
+ .dof-progress {
9
+ background-color: #f2f3f4;
10
+ }
14
11
 
15
- .progress {
16
- position: absolute;
17
- background-color: #29c3ff;
18
- }
12
+ .progress {
13
+ position: absolute;
14
+ background-color: #29c3ff;
15
+ }
19
16
  </style>
20
17
 
21
18
  <script>
22
- export default {
23
- props: {
24
- barColor: {
25
- type: String,
26
- default: '#267aff'
27
- },
28
- barWidth: {
29
- type: Number,
30
- default: 600
31
- },
32
- barHeight: {
33
- type: Number,
34
- default: 8
35
- },
36
- barRadius: {
37
- type: Number,
38
- default: 0
39
- },
40
- value: {
41
- type: Number,
42
- default: 0
43
- },
44
- backgroundColor: {
45
- type: String,
46
- default: '#f2f3f4'
19
+ export default {
20
+ props: {
21
+ barColor: {
22
+ type: String,
23
+ default: '#267aff'
24
+ },
25
+ barWidth: {
26
+ type: Number,
27
+ default: 600
28
+ },
29
+ barHeight: {
30
+ type: Number,
31
+ default: 8
32
+ },
33
+ barRadius: {
34
+ type: Number,
35
+ default: 0
36
+ },
37
+ value: {
38
+ type: Number,
39
+ default: 0
40
+ },
41
+ backgroundColor: {
42
+ type: String,
43
+ default: '#f2f3f4'
44
+ }
45
+ },
46
+ computed: {
47
+ runWayStyle() {
48
+ const { barWidth, barHeight, barRadius, backgroundColor } = this
49
+ return {
50
+ width: barWidth + 'px',
51
+ height: barHeight + 'px',
52
+ borderRadius: barRadius + 'px',
53
+ backgroundColor
47
54
  }
48
55
  },
49
- computed: {
50
- runWayStyle () {
51
- const { barWidth, barHeight, barRadius, backgroundColor } = this;
52
- return {
53
- width: barWidth + 'px',
54
- height: barHeight + 'px',
55
- borderRadius: barRadius + 'px',
56
- backgroundColor
57
- };
58
- },
59
- progressStyle () {
60
- const { value, barWidth, barHeight, barColor, barRadius } = this;
61
- const newValue = value < 0 ? 0 : (value > 100 ? 100 : value);
62
- return {
63
- backgroundColor: barColor,
64
- borderRadius: barRadius + 'px',
65
- height: barHeight + 'px',
66
- width: newValue / 100 * barWidth + 'px'
67
- };
56
+ progressStyle() {
57
+ const { value, barWidth, barHeight, barColor, barRadius } = this
58
+ const newValue = value < 0 ? 0 : value > 100 ? 100 : value
59
+ return {
60
+ backgroundColor: barColor,
61
+ borderRadius: barRadius + 'px',
62
+ height: barHeight + 'px',
63
+ width: (newValue / 100) * barWidth + 'px'
68
64
  }
69
65
  }
70
- };
66
+ }
67
+ }
71
68
  </script>
@@ -0,0 +1 @@
1
+ export { default } from './index.vue'
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <div class="dof-row">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import { mixParent } from '../utils/mix-parent.js'
9
+
10
+ export default {
11
+ mixins: [mixParent('dof-row')]
12
+ }
13
+ </script>
14
+
15
+ <style scoped>
16
+ .dof-row {
17
+ flex-direction: row;
18
+ flex-wrap: nowrap;
19
+ overflow: hidden;
20
+ }
21
+ </style>
@@ -0,0 +1 @@
1
+ export { default } from './index.vue'
@@ -0,0 +1,256 @@
1
+ <template>
2
+ <div class="dof-slider">
3
+ <div class="dof-slider-track" ref="track" :style="trackStyle">
4
+ <div
5
+ :class="['dof-slider-bar', `dof-slider-bar--${this.theme}`]"
6
+ :style="barStyle"
7
+ @touchstart="onTouchStart"
8
+ @touchmove="onTouchMove"
9
+ @touchend="onTouchEnd"
10
+ >
11
+ <div class="dof-slider-button" :style="buttonStyle"></div>
12
+ </div>
13
+ </div>
14
+ <div class="dof-slider-scales" v-if="$slots.default">
15
+ <slot></slot>
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <script>
21
+ import { getBoundingClientRect } from '../utils/dom.js'
22
+ import { clamp } from '../utils/math-extension.js'
23
+ import { Touch } from '../utils/touch.js'
24
+ export default {
25
+ props: {
26
+ value: {
27
+ type: Number,
28
+ required: true
29
+ },
30
+ min: {
31
+ type: Number,
32
+ default: 0
33
+ },
34
+ max: {
35
+ type: Number,
36
+ default: 100
37
+ },
38
+ step: {
39
+ type: Number,
40
+ default: 1
41
+ },
42
+ disabled: {
43
+ type: Boolean,
44
+ default: false
45
+ },
46
+ readonly: {
47
+ type: Boolean,
48
+ default: false
49
+ },
50
+ trackHeight: {
51
+ type: Number,
52
+ default: 40
53
+ },
54
+ trackColor: {
55
+ type: String,
56
+ default: '#F2F2F2'
57
+ },
58
+ theme: {
59
+ type: String,
60
+ default: 'brand'
61
+ },
62
+ barColor: {
63
+ type: String,
64
+ default: ''
65
+ },
66
+ buttonColor: {
67
+ type: String,
68
+ default: '#ffffff'
69
+ },
70
+ buttonSize: {
71
+ type: Number,
72
+ default: 24
73
+ }
74
+ },
75
+ model: {
76
+ prop: 'value',
77
+ event: 'input'
78
+ },
79
+ data() {
80
+ return {
81
+ touch: Touch.Create(),
82
+ current: 0,
83
+ startValue: 0,
84
+ dragStatus: '',
85
+ width: 0
86
+ }
87
+ },
88
+ computed: {
89
+ scope() {
90
+ return this.max - this.min
91
+ },
92
+ interactive() {
93
+ return !this.disabled && !this.readonly
94
+ },
95
+ trackStyle() {
96
+ const res = {
97
+ height: `${this.trackHeight}px`,
98
+ backgroundColor: this.trackColor,
99
+ borderRadius: `${this.trackHeight / 2}px`
100
+ }
101
+ return res
102
+ },
103
+ barStyle() {
104
+ const width = ((this.value - this.min) / this.scope) * this.width
105
+ const res = {
106
+ width: `${clamp(width, this.trackHeight, this.width)}px`,
107
+ borderRadius: `${this.trackHeight / 2}px`,
108
+ height: `${this.trackHeight}px`
109
+ }
110
+
111
+ if (this.barColor) {
112
+ res.backgroundColor = this.barColor
113
+ }
114
+ return res
115
+ },
116
+ buttonStyle() {
117
+ const res = {
118
+ top: `${(this.trackHeight - this.buttonSize) / 2}px`,
119
+ right: `${(this.trackHeight - this.buttonSize) / 2}px`,
120
+ width: `${this.buttonSize}px`,
121
+ height: `${this.buttonSize}px`,
122
+ borderRadius: `${this.buttonSize / 2}px`,
123
+ backgroundColor: this.buttonColor
124
+ }
125
+ return res
126
+ }
127
+ },
128
+ mounted() {
129
+ setTimeout(() => {
130
+ getBoundingClientRect(this.$refs.track, res => {
131
+ if (res.result) {
132
+ this.width = res.size.width
133
+ }
134
+ })
135
+ }, 0)
136
+ },
137
+ methods: {
138
+ onTouchStart(e) {
139
+ if (!this.interactive) {
140
+ return
141
+ }
142
+
143
+ this.touch.start(e)
144
+ this.current = this.value
145
+
146
+ this.startValue = this.format(this.current)
147
+ this.dragStatus = 'start'
148
+ },
149
+ onTouchMove(e) {
150
+ if (!this.interactive) {
151
+ return
152
+ }
153
+
154
+ if (this.dragStatus === 'start') {
155
+ this.$emit('dragstart', e)
156
+ }
157
+
158
+ this.touch.move(e)
159
+ this.dragStatus = 'draging'
160
+
161
+ const delta = this.touch.deltaX
162
+ const total = this.width
163
+ const diff = (delta / total) * this.scope
164
+
165
+ this.current = this.startValue + diff
166
+
167
+ this.update(this.current)
168
+ },
169
+ onTouchEnd(e) {
170
+ if (!this.interactive) {
171
+ return
172
+ }
173
+
174
+ if (this.dragStatus === 'draging') {
175
+ this.update(this.current, true)
176
+ this.$emit('dragend', e)
177
+ }
178
+ this.dragStatus = ''
179
+ },
180
+ format(value) {
181
+ const min = +this.min
182
+ const max = +this.max
183
+ const step = +this.step
184
+
185
+ const val = clamp(value, min, max)
186
+ const diff = Math.round((val - min) / step) * step
187
+
188
+ return min + diff
189
+ },
190
+ update(value, end = false) {
191
+ const val = this.format(value)
192
+ if (val !== this.value) {
193
+ this.$emit('input', val)
194
+ }
195
+ if (end && val !== this.startValue) {
196
+ this.$emit('change', val)
197
+ }
198
+ }
199
+ }
200
+ }
201
+ </script>
202
+
203
+ <style scoped>
204
+ .dof-slider {
205
+ flex-direction: column;
206
+ flex: 1;
207
+ }
208
+
209
+ .dof-slider-track {
210
+ position: relative;
211
+ flex: 1;
212
+ }
213
+
214
+ .dof-slider-bar {
215
+ position: relative;
216
+ }
217
+
218
+ .dof-slider-bar--brand {
219
+ background-color: #267aff;
220
+ }
221
+
222
+ .dof-slider-bar--purple {
223
+ background-color: #995efc;
224
+ }
225
+ .dof-slider-bar--blue-purple {
226
+ background-color: #6575ff;
227
+ }
228
+ .dof-slider-bar--blue {
229
+ background-color: #29c3ff;
230
+ }
231
+ .dof-slider-bar--cyan {
232
+ background-color: #00cbb8;
233
+ }
234
+ .dof-slider-bar--yellow {
235
+ background-color: #ffaa10;
236
+ }
237
+ .dof-slider-bar--orange {
238
+ background-color: #ff8225;
239
+ }
240
+ .dof-slider-bar--orange-red {
241
+ background-color: #ff6a4c;
242
+ }
243
+ .dof-slider-bar--gray-offline {
244
+ background-color: #7c879b;
245
+ }
246
+
247
+ .dof-slider-button {
248
+ position: absolute;
249
+ }
250
+
251
+ .dof-slider-scales {
252
+ position: relative;
253
+ margin-top: 8px;
254
+ height: 20px;
255
+ }
256
+ </style>
@@ -0,0 +1 @@
1
+ export { default } from './index.vue'
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <text
3
+ :class="['dof-slider-scale', !isFirst && !isLast && 'dof-slider-scale--mid', isLast && `dof-slider-scale--last`]"
4
+ :style="style"
5
+ >
6
+ <slot></slot>
7
+ </text>
8
+ </template>
9
+
10
+ <script>
11
+ export default {
12
+ props: {
13
+ value: {
14
+ type: Number,
15
+ required: true
16
+ }
17
+ },
18
+ computed: {
19
+ isLast() {
20
+ return this.value >= this.$parent.max
21
+ },
22
+ isFirst() {
23
+ return this.value <= this.$parent.min
24
+ },
25
+ style() {
26
+ const style = {}
27
+ const left = ((this.value - this.$parent.min) / this.$parent.scope) * this.$parent.width
28
+ style.left = `${left}px`
29
+ return style
30
+ }
31
+ }
32
+ }
33
+ </script>
34
+
35
+ <style scoped>
36
+ .dof-slider-scale {
37
+ position: absolute;
38
+ white-space: nowrap;
39
+ font-family: PingFangSC-Regular;
40
+ font-size: 16px;
41
+ color: #8a8a8f;
42
+ font-weight: 400;
43
+ }
44
+
45
+ .dof-slider-scale--mid {
46
+ transform: translate(-50%, 0px);
47
+ }
48
+
49
+ .dof-slider-scale--last {
50
+ transform: translate(-100%, 0px);
51
+ }
52
+ </style>
@@ -0,0 +1 @@
1
+ export { default } from './index.vue'
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <div class="dof-step-action" :style="style">
3
+ <div @click="onSubClick">
4
+ <slot name="sub">
5
+ <image
6
+ src="http://dolphin-weex-dev.msmartlife.cn/static/component/step-action/image/sub.png"
7
+ :style="btnStyle"
8
+ ></image>
9
+ </slot>
10
+ </div>
11
+ <div class="dof-step-action-container">
12
+ <slot></slot>
13
+ </div>
14
+ <div @click="onAddClick">
15
+ <slot name="add">
16
+ <image
17
+ src="http://dolphin-weex-dev.msmartlife.cn/static/component/step-action/image/add.png"
18
+ :style="btnStyle"
19
+ ></image>
20
+ </slot>
21
+ </div>
22
+ </div>
23
+ </template>
24
+
25
+ <script>
26
+ export default {
27
+ props: {
28
+ height: {
29
+ type: Number,
30
+ default: 40
31
+ },
32
+ color: {
33
+ type: String,
34
+ default: '#f2f2f2'
35
+ },
36
+ vertical: {
37
+ type: String,
38
+ default: ''
39
+ },
40
+ max: {
41
+ type: Number,
42
+ default: 100
43
+ },
44
+ min: {
45
+ type: Number,
46
+ default: 0
47
+ },
48
+ step: {
49
+ type: Number,
50
+ default: 1
51
+ },
52
+ value: {
53
+ type: Number,
54
+ required: true
55
+ }
56
+ },
57
+ model: {
58
+ prop: 'value',
59
+ event: 'change'
60
+ },
61
+ computed: {
62
+ style() {
63
+ const res = {}
64
+ if (this.vertical) {
65
+ switch (this.vertical) {
66
+ case 'top':
67
+ res.alignItems = 'flex-start'
68
+ break
69
+ case 'middle':
70
+ res.alignItems = 'center'
71
+ break
72
+ case 'bottom':
73
+ res.alignItems = 'flex-end'
74
+ }
75
+ }
76
+ return res
77
+ },
78
+ btnStyle() {
79
+ const res = {
80
+ width: `${this.height}px`,
81
+ height: `${this.height}px`,
82
+ borderRadius: `${this.height / 2}px`,
83
+ backgroundColor: this.color
84
+ }
85
+ return res
86
+ }
87
+ },
88
+ methods: {
89
+ onSubClick() {
90
+ const value = Math.max(this.value - this.step, this.min)
91
+ this.$emit('change', value)
92
+ this.$emit('sub')
93
+ },
94
+ onAddClick() {
95
+ const value = Math.min(this.value + this.step, this.max)
96
+ this.$emit('change', value)
97
+ this.$emit('add')
98
+ }
99
+ }
100
+ }
101
+ </script>
102
+
103
+ <style scoped>
104
+ .dof-step-action {
105
+ flex-direction: row;
106
+ }
107
+
108
+ .dof-step-action-container {
109
+ flex: 1;
110
+ padding-left: 16px;
111
+ padding-right: 16px;
112
+ }
113
+ </style>