kui-vue 3.2.1-rc1 → 3.2.2-rc3
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.
- package/components/affix/index.md +6 -5
- package/components/anchor/anchor.jsx +11 -0
- package/components/anchor/demo/base.md +12 -0
- package/components/anchor/demo/index.vue +17 -0
- package/components/anchor/demo/info.md +7 -0
- package/components/anchor/index.js +3 -0
- package/components/anchor/index.md +4 -0
- package/components/anchor/link.jsx +11 -0
- package/components/anchor/styles/index.less +0 -0
- package/components/colorPicker/colorpicker.jsx +10 -11
- package/components/colorPicker/demo/size.md +6 -6
- package/components/colorPicker/styles/index.less +3 -0
- package/components/drawer/drawer.jsx +10 -8
- package/components/image/instance.js +1 -1
- package/components/image/preview.jsx +50 -20
- package/components/index.js +5 -0
- package/components/loading/demo/base.md +38 -0
- package/components/loading/demo/index.vue +17 -0
- package/components/loading/demo/info.md +55 -0
- package/components/loading/index.js +98 -104
- package/components/loading/index.md +8 -0
- package/components/loading/styles/index.less +12 -13
- package/components/modal/modal.jsx +10 -8
- package/components/rate/demo/base.md +12 -0
- package/components/rate/demo/character.md +16 -0
- package/components/rate/demo/clear.md +14 -0
- package/components/rate/demo/custom.md +30 -0
- package/components/rate/demo/disabled.md +18 -0
- package/components/rate/demo/half.md +12 -0
- package/components/rate/demo/index.vue +29 -0
- package/components/rate/demo/info.md +8 -0
- package/components/rate/demo/tips.md +23 -0
- package/components/rate/index.js +2 -0
- package/components/rate/index.md +12 -0
- package/components/rate/rate.jsx +94 -0
- package/components/rate/star.jsx +84 -0
- package/components/rate/styles/index.less +45 -0
- package/components/styles/index.less +2 -1
- package/components/styles.js +2 -0
- package/dist/k-ui.css +2 -2
- package/dist/k-ui.js +2 -2
- package/package.json +5 -9
- package/components/loading/demo/loading.js +0 -81
- package/components/loading/demo/loading.vue +0 -152
- package/components/loading/loading.vue +0 -62
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
## API
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
|
5
|
-
|
|
|
6
|
-
|
|
|
2
|
+
|
|
3
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
4
|
+
| ------------ | ----------------------------------------------------------- | -------------- | ------ |
|
|
5
|
+
| offsetTop | 距离窗口顶部达到指定偏移量后触发 | String, Number | 0 |
|
|
6
|
+
| offsetBottom | 距离窗口底部达到指定偏移量后触发 | String, Number | - |
|
|
7
|
+
| change | 在固定状态发生改变时触发, 返回当前固定状态 `false` , `true` | Function | - |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Info from './info.md'
|
|
3
|
+
import Base from './base.md'
|
|
4
|
+
import CN from '../index.md'
|
|
5
|
+
export default {
|
|
6
|
+
render() {
|
|
7
|
+
return (
|
|
8
|
+
<div>
|
|
9
|
+
<Info class="typo" />
|
|
10
|
+
<Base />
|
|
11
|
+
<CN class="typo" />
|
|
12
|
+
<div style="height:500px;text-align:center;color:#ddd;line-height:500px;">我是打酱油的,请忽略我...</div>
|
|
13
|
+
</div>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
File without changes
|
|
@@ -29,13 +29,14 @@ export default {
|
|
|
29
29
|
validator: function (value) { return value.length <= 20 }
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
-
watch: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
32
|
+
// watch: {
|
|
33
|
+
// value(v1, v2) {
|
|
34
|
+
// console.log(v1, v2, this.currentColor)
|
|
35
|
+
// if (v1 != this.currentColor) {
|
|
36
|
+
// // this.valueChange('COLOR', v1)
|
|
37
|
+
// }
|
|
38
|
+
// }
|
|
39
|
+
// },
|
|
39
40
|
data() {
|
|
40
41
|
return {
|
|
41
42
|
currentMode: this.mode,
|
|
@@ -135,9 +136,9 @@ export default {
|
|
|
135
136
|
value = A < 1 ? `hsla(${H},${S}%,${L}%,${A})` : `hsl(${H},${S}%,${L}%)`
|
|
136
137
|
}
|
|
137
138
|
// console.log(value)
|
|
139
|
+
this.currentColor = value
|
|
138
140
|
this.$emit('input', value)
|
|
139
141
|
this.$emit('change', value)
|
|
140
|
-
this.currentColor = value
|
|
141
142
|
this.opened = false
|
|
142
143
|
},
|
|
143
144
|
setMode() {
|
|
@@ -370,14 +371,12 @@ export default {
|
|
|
370
371
|
this.currentColor = this.value || '#000'
|
|
371
372
|
},
|
|
372
373
|
render: () => {
|
|
373
|
-
this.$nextTick(
|
|
374
|
+
this.$nextTick(() => {
|
|
374
375
|
let { paint, hue, alpha } = this.$refs
|
|
375
376
|
this.paintHelper = canvasHelper(paint)
|
|
376
|
-
|
|
377
377
|
this.initHueCanvas(hue)
|
|
378
378
|
this.initAlphaCanvas(alpha)
|
|
379
379
|
this.initPaintCanvas(paint)
|
|
380
|
-
|
|
381
380
|
this.valueChange('COLOR', this.value)
|
|
382
381
|
})
|
|
383
382
|
},
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
<template>
|
|
8
8
|
<div class="demo-color-picker">
|
|
9
9
|
<Form>
|
|
10
|
-
<
|
|
10
|
+
<FormItem label="large">
|
|
11
11
|
<ColorPicker showMode v-model="color1" size="large"/>
|
|
12
|
-
</
|
|
13
|
-
<
|
|
12
|
+
</FormItem>
|
|
13
|
+
<FormItem label="Default">
|
|
14
14
|
<ColorPicker showMode v-model="color2" mode="rgba"/>
|
|
15
|
-
</
|
|
16
|
-
<
|
|
15
|
+
</FormItem>
|
|
16
|
+
<FormItem label="small">
|
|
17
17
|
<ColorPicker showMode v-model="color3" mode="hsla" size="small" />
|
|
18
|
-
</
|
|
18
|
+
</FormItem>
|
|
19
19
|
</Form>
|
|
20
20
|
</div>
|
|
21
21
|
</template>
|
|
@@ -65,24 +65,26 @@ export default {
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
resetBodyStyle(opened) {
|
|
68
|
+
let target = this.target();
|
|
68
69
|
if (!this.visible && !cacheBodyOverflow.hasOwnProperty('overflow')) {
|
|
69
70
|
cacheBodyOverflow = {
|
|
70
|
-
width:
|
|
71
|
-
overflow:
|
|
72
|
-
overflowX:
|
|
73
|
-
overflowY:
|
|
71
|
+
width: target.width,
|
|
72
|
+
overflow: target.overflow,
|
|
73
|
+
overflowX: target.overflowX,
|
|
74
|
+
overflowY: target.overflowY,
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
if (opened) {
|
|
77
78
|
let barWidth = measureScrollBar(true)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
let hasBar = target.scrollHeight > target.clientHeight || target.offsetHeight > target.clientHeight
|
|
80
|
+
if (barWidth && hasBar) {
|
|
81
|
+
target.style.width = `calc(100% - ${barWidth}px)`
|
|
82
|
+
target.style.overflow = `hidden`
|
|
81
83
|
}
|
|
82
84
|
} else {
|
|
83
85
|
setTimeout(() => {
|
|
84
86
|
Object.keys(cacheBodyOverflow).forEach(key => {
|
|
85
|
-
|
|
87
|
+
target.style[key] = cacheBodyOverflow[key] || ''
|
|
86
88
|
delete cacheBodyOverflow[key]
|
|
87
89
|
})
|
|
88
90
|
}, 300)
|
|
@@ -33,6 +33,7 @@ export default {
|
|
|
33
33
|
vertical: true,
|
|
34
34
|
isShowPanel: this.showPanel,
|
|
35
35
|
panelRight: 0,
|
|
36
|
+
touch: false,
|
|
36
37
|
}
|
|
37
38
|
},
|
|
38
39
|
watch: {
|
|
@@ -96,14 +97,29 @@ export default {
|
|
|
96
97
|
this.$emit('input', false)
|
|
97
98
|
this.$emit('close')
|
|
98
99
|
},
|
|
100
|
+
touchstart(e) {
|
|
101
|
+
if (e.touches.length == 1 && this.$refs.imgRef && this.$refs.imgRef.contains(e.target)) {
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
},
|
|
99
105
|
mousedown(e) {
|
|
100
|
-
if (
|
|
106
|
+
if (this.$refs.imgRef && this.$refs.imgRef.contains(e.target)) {
|
|
107
|
+
if (e.button && e.button != 0) return;
|
|
108
|
+
let clientX, clientY;
|
|
109
|
+
if (e.touches && e.touches.length == 1) {
|
|
110
|
+
clientX = e.touches[0].clientX
|
|
111
|
+
clientY = e.touches[0].clientY
|
|
112
|
+
} else {
|
|
113
|
+
clientX = e.clientX
|
|
114
|
+
clientY = e.clientY
|
|
115
|
+
}
|
|
101
116
|
this.ismousedown = true
|
|
102
|
-
this.startPos = { x:
|
|
103
|
-
this.initPos = { x:
|
|
117
|
+
this.startPos = { x: clientX, y: clientY }
|
|
118
|
+
this.initPos = { x: clientX, y: clientY }
|
|
104
119
|
this.mousemove(e)
|
|
105
|
-
|
|
106
|
-
document.addEventListener(
|
|
120
|
+
let [e1, e2] = this.touch ? ['touchmove', 'touchend'] : ['mousemove', 'mouseup']
|
|
121
|
+
document.addEventListener(e1, this.mousemove, { passive: false })
|
|
122
|
+
document.addEventListener(e2, this.mouseup, { passive: false })
|
|
107
123
|
}
|
|
108
124
|
},
|
|
109
125
|
resetPosition() {
|
|
@@ -144,16 +160,25 @@ export default {
|
|
|
144
160
|
mouseup(e) {
|
|
145
161
|
this.ismousedown = false
|
|
146
162
|
this.resetPosition()
|
|
147
|
-
|
|
148
|
-
document.removeEventListener(
|
|
163
|
+
let [e1, e2] = this.touch ? ['touchmove', 'touchend'] : ['mousemove', 'mouseup']
|
|
164
|
+
document.removeEventListener(e1, this.mousemove)
|
|
165
|
+
document.removeEventListener(e2, this.mouseup)
|
|
149
166
|
},
|
|
150
167
|
mousemove(e) {
|
|
151
168
|
if (this.ismousedown) {
|
|
152
|
-
let { x, y } = this.startPos
|
|
153
|
-
this.left += e.clientX - x
|
|
154
|
-
this.top += e.clientY - y
|
|
155
|
-
this.startPos = { x: e.clientX, y: e.clientY }
|
|
156
169
|
e.preventDefault()
|
|
170
|
+
let clientX, clientY;
|
|
171
|
+
if (e.touches && e.touches.length == 1) {
|
|
172
|
+
clientX = e.touches[0].clientX
|
|
173
|
+
clientY = e.touches[0].clientY
|
|
174
|
+
} else {
|
|
175
|
+
clientX = e.clientX
|
|
176
|
+
clientY = e.clientY
|
|
177
|
+
}
|
|
178
|
+
let { x, y } = this.startPos
|
|
179
|
+
this.left += clientX - x
|
|
180
|
+
this.top += clientY - y
|
|
181
|
+
this.startPos = { x: clientX, y: clientY }
|
|
157
182
|
}
|
|
158
183
|
},
|
|
159
184
|
switchImage(left) {
|
|
@@ -175,24 +200,26 @@ export default {
|
|
|
175
200
|
}
|
|
176
201
|
},
|
|
177
202
|
resetBodyStyle(opened) {
|
|
203
|
+
let target = document.body
|
|
178
204
|
if (!this.show && !cacheBodyOverflow.hasOwnProperty('overflow')) {
|
|
179
205
|
cacheBodyOverflow = {
|
|
180
|
-
width:
|
|
181
|
-
overflow:
|
|
182
|
-
overflowX:
|
|
183
|
-
overflowY:
|
|
206
|
+
width: target.width,
|
|
207
|
+
overflow: target.overflow,
|
|
208
|
+
overflowX: target.overflowX,
|
|
209
|
+
overflowY: target.overflowY,
|
|
184
210
|
}
|
|
185
211
|
}
|
|
186
212
|
if (opened) {
|
|
187
213
|
let barWidth = measureScrollBar(true)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
214
|
+
let hasBar = target.scrollHeight > target.clientHeight || target.offsetHeight > target.clientHeight
|
|
215
|
+
if (barWidth && hasBar) {
|
|
216
|
+
target.style.width = `calc(100% - ${barWidth}px)`
|
|
217
|
+
target.style.overflow = `hidden`
|
|
191
218
|
}
|
|
192
219
|
} else {
|
|
193
220
|
setTimeout(() => {
|
|
194
221
|
Object.keys(cacheBodyOverflow).forEach(key => {
|
|
195
|
-
|
|
222
|
+
target.style[key] = cacheBodyOverflow[key] || ''
|
|
196
223
|
delete cacheBodyOverflow[key]
|
|
197
224
|
})
|
|
198
225
|
}, 300)
|
|
@@ -216,7 +243,10 @@ export default {
|
|
|
216
243
|
}
|
|
217
244
|
},
|
|
218
245
|
mounted() {
|
|
219
|
-
|
|
246
|
+
let touch = !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch)
|
|
247
|
+
this.touch = touch
|
|
248
|
+
let even = touch ? 'touchstart' : 'mousedown'
|
|
249
|
+
document.addEventListener(even, this.mousedown, { passive: false })
|
|
220
250
|
},
|
|
221
251
|
render(h) {
|
|
222
252
|
const { scale, rotate, visible, src, left, top, transfer, showSwitch, data, loading, panelRight, type } = this
|
package/components/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { Image, ImageGroup } from './image'
|
|
|
19
19
|
import Icon from './icon'
|
|
20
20
|
import { Input, TextArea } from './input'
|
|
21
21
|
import { Layout, Header, Footer, Content, Sider } from './layout'
|
|
22
|
+
import Loading from './loading'
|
|
22
23
|
import Modal from './modal'
|
|
23
24
|
import { Menu, MenuGroup, MenuItem, SubMenu, MenuDivider } from './menu'
|
|
24
25
|
import Message from './message'
|
|
@@ -28,6 +29,7 @@ import Poptip from './poptip'
|
|
|
28
29
|
import Popconfirm from './popconfirm'
|
|
29
30
|
import Progress from './progress'
|
|
30
31
|
import { Radio, RadioGroup, RadioButton } from './radio'
|
|
32
|
+
import Rate from './rate'
|
|
31
33
|
import Spin from './spin'
|
|
32
34
|
import Switch from './switch'
|
|
33
35
|
import { Select, Option } from './select'
|
|
@@ -69,12 +71,14 @@ const components = {
|
|
|
69
71
|
Modal,
|
|
70
72
|
Message,
|
|
71
73
|
Layout, Header, Footer, Content, Sider,
|
|
74
|
+
Loading,
|
|
72
75
|
Notice,
|
|
73
76
|
Page,
|
|
74
77
|
Poptip,
|
|
75
78
|
Popconfirm,
|
|
76
79
|
Progress,
|
|
77
80
|
Radio, RadioGroup, RadioButton,
|
|
81
|
+
Rate,
|
|
78
82
|
Spin,
|
|
79
83
|
Select, Option,
|
|
80
84
|
Table,
|
|
@@ -109,6 +113,7 @@ const UI = {
|
|
|
109
113
|
Vue.prototype.$Message = Message;
|
|
110
114
|
Vue.prototype.$Notice = Notice;
|
|
111
115
|
Vue.prototype.$Modal = Modal;
|
|
116
|
+
Vue.prototype.$Loading = Loading;
|
|
112
117
|
Vue.prototype.$Image = Image;
|
|
113
118
|
}
|
|
114
119
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<cn>
|
|
2
|
+
#### 基本用法
|
|
3
|
+
最简单的用法。
|
|
4
|
+
</cn>
|
|
5
|
+
|
|
6
|
+
```vue
|
|
7
|
+
<template>
|
|
8
|
+
<div>
|
|
9
|
+
<Button @click="start()">start</Button>
|
|
10
|
+
<Button @click="finish">finish</Button>
|
|
11
|
+
<Button @click="error">error</Button>
|
|
12
|
+
<Button @click="upload(30)">upload 30%</Button>
|
|
13
|
+
<Button @click="upload(80)">upload 80%</Button>
|
|
14
|
+
<Button @click="destroy()">destroy</Button>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
<script>
|
|
18
|
+
export default{
|
|
19
|
+
methods: {
|
|
20
|
+
upload(percent){
|
|
21
|
+
this.$Loading.upload(percent);
|
|
22
|
+
},
|
|
23
|
+
start() {
|
|
24
|
+
this.$Loading.start();
|
|
25
|
+
},
|
|
26
|
+
finish() {
|
|
27
|
+
this.$Loading.finish();
|
|
28
|
+
},
|
|
29
|
+
error() {
|
|
30
|
+
this.$Loading.error();
|
|
31
|
+
},
|
|
32
|
+
destroy(){
|
|
33
|
+
this.$Loading.destroy();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Info from "./info";
|
|
3
|
+
import Base from "./base";
|
|
4
|
+
|
|
5
|
+
import CN from "../index.md";
|
|
6
|
+
export default {
|
|
7
|
+
render() {
|
|
8
|
+
return (
|
|
9
|
+
<div class="switch-demo">
|
|
10
|
+
<Info class="typo" />
|
|
11
|
+
<Base />
|
|
12
|
+
<CN class="typo" />
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Loading 加载进度
|
|
2
|
+
进度加载。
|
|
3
|
+
|
|
4
|
+
## 何时使用
|
|
5
|
+
- 异步请求时展示进度
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 示例
|
|
9
|
+
|
|
10
|
+
模拟路由加载
|
|
11
|
+
```js
|
|
12
|
+
// # router.js
|
|
13
|
+
|
|
14
|
+
import Vue from 'vue'
|
|
15
|
+
import Router from 'vue-router'
|
|
16
|
+
import kui from 'kui-vue'
|
|
17
|
+
|
|
18
|
+
Vue.use(Router)
|
|
19
|
+
let router = new Router({
|
|
20
|
+
....
|
|
21
|
+
})
|
|
22
|
+
router.beforeEach((to, from, next) => {
|
|
23
|
+
kui.Loading.start();
|
|
24
|
+
next();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
router.afterEach(route => {
|
|
28
|
+
kui.Loading.finish();
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
模拟ajax 请求
|
|
33
|
+
```js
|
|
34
|
+
// 以jQuery的Ajax为例,部分代码省略
|
|
35
|
+
import $ from 'jquery';
|
|
36
|
+
export default {
|
|
37
|
+
methods: {
|
|
38
|
+
getData () {
|
|
39
|
+
this.$Loading.start();
|
|
40
|
+
$.ajax({
|
|
41
|
+
url: '/api/someurl',
|
|
42
|
+
type: 'get',
|
|
43
|
+
success: () => {
|
|
44
|
+
this.$Loading.finish();
|
|
45
|
+
}
|
|
46
|
+
error: () => {
|
|
47
|
+
this.$Loading.error();
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 代码演示
|