kui-vue 3.2.11-rc5 → 3.2.11-rc6
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/grid/col.jsx +34 -5
- package/components/grid/demo/gutter.md +52 -11
- package/components/grid/index.md +7 -7
- package/components/grid/row.jsx +19 -5
- package/components/slider/slider.jsx +5 -7
- package/dist/k-ui.css +1 -1
- package/dist/k-ui.js +2 -2
- package/package.json +1 -1
package/components/grid/col.jsx
CHANGED
|
@@ -23,17 +23,46 @@ export default {
|
|
|
23
23
|
render() {
|
|
24
24
|
let { offset, span, $slots, flex } = this
|
|
25
25
|
const gutter = this.Row.gutter
|
|
26
|
-
|
|
26
|
+
let props = {
|
|
27
27
|
class: [`k-col`, {
|
|
28
28
|
[`k-col-${span}`]: span,
|
|
29
|
-
[`k-col-offset-${offset}`]: offset > 0 && offset <= 24
|
|
29
|
+
// [`k-col-offset-${offset}`]: offset > 0 && offset <= 24
|
|
30
30
|
}],
|
|
31
31
|
style: {
|
|
32
|
-
paddingLeft: gutter ? `${gutter / 2}px` : null,
|
|
33
|
-
paddingRight: gutter ? `${gutter / 2}px` : null,
|
|
34
|
-
flex: flex ? this.parseFlex(flex) : null
|
|
32
|
+
// paddingLeft: gutter ? `${gutter / 2}px` : null,
|
|
33
|
+
// paddingRight: gutter ? `${gutter / 2}px` : null,
|
|
34
|
+
// flex: flex ? this.parseFlex(flex) : null
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
// console.log(gutter)
|
|
38
|
+
if (Array.isArray(gutter)) {
|
|
39
|
+
let [v = 0, h = 0] = gutter;
|
|
40
|
+
if ((v == h && v > 0)) {
|
|
41
|
+
props.style.padding = `${v / 2}px`
|
|
42
|
+
} else if (v > 0 && h > 0) {
|
|
43
|
+
props.style.padding = `${h / 2}px ${v / 2}px`
|
|
44
|
+
} else {
|
|
45
|
+
if (v > 0) {
|
|
46
|
+
props.style.paddingLeft = `${v / 2}px`
|
|
47
|
+
props.style.paddingRight = `${v / 2}px`
|
|
48
|
+
}
|
|
49
|
+
if (h > 0) {
|
|
50
|
+
props.style.paddingTop = `${v / 2}px`
|
|
51
|
+
props.style.paddingTop = `${v / 2}px`
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
} else if (!isNaN(Number(gutter)) && gutter > 0) {
|
|
56
|
+
props.style.paddingLeft = `${gutter / 2}px`
|
|
57
|
+
props.style.paddingRight = `${gutter / 2}px`
|
|
58
|
+
}
|
|
59
|
+
if (flex) {
|
|
60
|
+
props.style.flex = this.parseFlex(flex)
|
|
61
|
+
}
|
|
62
|
+
if (offset > 0 && offset <= 24) {
|
|
63
|
+
props.class.push(`k-col-offset-${offset}`)
|
|
64
|
+
}
|
|
65
|
+
|
|
37
66
|
return (
|
|
38
67
|
<div {...props}>
|
|
39
68
|
{$slots.default}
|
|
@@ -1,25 +1,66 @@
|
|
|
1
1
|
<cn>
|
|
2
2
|
#### 分栏间隔
|
|
3
|
-
使用 `gutter`
|
|
3
|
+
使用 `gutter` 熟悉来设置分栏的间隔,如果需要垂直间距,可以写成数组形式 [水平间距, 垂直间距]
|
|
4
4
|
</cn>
|
|
5
5
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
8
|
<div class="demo-grid">
|
|
9
|
+
gutter = 10
|
|
9
10
|
<Row :gutter="10" class="row-gutter">
|
|
10
|
-
<Col :span="
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
<Col :span="12"><div>col-12</div></Col>
|
|
12
|
+
<Col :span="12"><div>col-12</div></Col>
|
|
13
|
+
</Row>
|
|
14
|
+
<br />
|
|
15
|
+
<br />
|
|
16
|
+
Horizontal Gutter (px):
|
|
17
|
+
<div style="width:55%;padding:10px;">
|
|
18
|
+
<Slider v-model="h"
|
|
19
|
+
:min="8"
|
|
20
|
+
:marks="{8:'8',16:'16',24:'24',32:'32',40:'40'}"
|
|
21
|
+
:max="40"
|
|
22
|
+
:step="null" />
|
|
23
|
+
</div>
|
|
24
|
+
Vertical Gutter (px):
|
|
25
|
+
<div style="width:55%;padding:10px;">
|
|
26
|
+
<Slider v-model="v"
|
|
27
|
+
:min="8"
|
|
28
|
+
:max="40"
|
|
29
|
+
:marks="{8:'8',16:'16',24:'24',32:'32',40:'40'}"
|
|
30
|
+
:step="null" />
|
|
31
|
+
</div>
|
|
32
|
+
Column Count:
|
|
33
|
+
<div style="width:55%;padding:10px;">
|
|
34
|
+
<Slider v-model="cols"
|
|
35
|
+
:min="2"
|
|
36
|
+
:marks="{2:'2',3:'3',4:'4',6:'6',8:'8',12:'12'}"
|
|
37
|
+
:max="12"
|
|
38
|
+
:step="null" />
|
|
39
|
+
</div>
|
|
40
|
+
<Row :gutter="[v,h]"
|
|
41
|
+
class="row-gutter">
|
|
42
|
+
<Col :span="24/cols"
|
|
43
|
+
v-for="c in cols"
|
|
44
|
+
:key="c">
|
|
45
|
+
<div>col-{{cols}}</div>
|
|
18
46
|
</Col>
|
|
19
|
-
<Col :span="
|
|
20
|
-
|
|
47
|
+
<Col :span="24/cols"
|
|
48
|
+
v-for="x in cols"
|
|
49
|
+
:key="'_'+x">
|
|
50
|
+
<div>col-{{cols}}</div>
|
|
21
51
|
</Col>
|
|
22
52
|
</Row>
|
|
23
53
|
</div>
|
|
24
54
|
</template>
|
|
55
|
+
<script>
|
|
56
|
+
export default {
|
|
57
|
+
data() {
|
|
58
|
+
return {
|
|
59
|
+
h: 8,
|
|
60
|
+
v: 8,
|
|
61
|
+
cols: 4
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
25
66
|
```
|
package/components/grid/index.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
### Row API
|
|
2
|
-
| 属性 | 说明 | 类型
|
|
3
|
-
|
|
4
|
-
| align | flex 布局下的垂直对齐方式:`top` `middle` `bottom` | String
|
|
5
|
-
| justify | flex 布局下的水平排列方式:`start` `end` `center` `space-around` `space-between` | String
|
|
6
|
-
| gutter | 栅格间距,单位 px
|
|
7
|
-
| type | 布局模式,可选 flex,现代浏览器 下有效 | String
|
|
2
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
3
|
+
| ------- | -------------------------------------------------------------------------------- | ------------ | ------- |
|
|
4
|
+
| align | flex 布局下的垂直对齐方式:`top` `middle` `bottom` | String | `top` |
|
|
5
|
+
| justify | flex 布局下的水平排列方式:`start` `end` `center` `space-around` `space-between` | String | `start` |
|
|
6
|
+
| gutter | 栅格间距,单位 px,左右平分,使用数组形式同时设置 [水平间距, 垂直间距] | Number,Array | - |
|
|
7
|
+
| type | 布局模式,可选 flex,现代浏览器 下有效 | String | |
|
|
8
8
|
### Col API
|
|
9
9
|
| 属性 | 说明 | 类型 | 默认值 |
|
|
10
|
-
|
|
10
|
+
| ------ | -------------------------------------- | ------------- | ------ |
|
|
11
11
|
| span | 栅格的占位格数,可选值为0~24的整数 | Number | - |
|
|
12
12
|
| offset | 栅格左侧的间隔格数,可选值为1~24的整数 | Number | - |
|
|
13
13
|
| flex | flex 布局填充 | Number,String | - |
|
package/components/grid/row.jsx
CHANGED
|
@@ -36,11 +36,25 @@ export default {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
if (Array.isArray(gutter)) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
let [v = 0, h = 0] = gutter;
|
|
40
|
+
if ((v == h && v > 0)) {
|
|
41
|
+
props.style.margin = `-${v/2}px`
|
|
42
|
+
} else if (v > 0 && h > 0) {
|
|
43
|
+
props.style.margin = `-${h/2}px -${v/2}px`
|
|
44
|
+
} else {
|
|
45
|
+
if (v > 0) {
|
|
46
|
+
props.style.marginLeft = `-${v/2}px`
|
|
47
|
+
props.style.marginRight = `-${v/2}px`
|
|
48
|
+
}
|
|
49
|
+
if (h > 0) {
|
|
50
|
+
props.style.marginTop = `-${v/2}px`
|
|
51
|
+
props.style.marginTop = `-${v/2}px`
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
} else if (!isNaN(Number(gutter)) && gutter > 0) {
|
|
56
|
+
props.style.marginLeft = `-${gutter / 2}px`
|
|
57
|
+
props.style.marginRight = `-${gutter / 2}px`
|
|
44
58
|
}
|
|
45
59
|
return (<div {...props}>{$slots.default}</div >)
|
|
46
60
|
}
|
|
@@ -44,17 +44,15 @@ export default {
|
|
|
44
44
|
let { marks, step, min } = this
|
|
45
45
|
if (!marks) return times(Math.round((percent + min) / step), step)
|
|
46
46
|
let steps = Object.keys(marks)//, values = []
|
|
47
|
-
steps = steps.map(x => x
|
|
47
|
+
steps = steps.map(x => x - min)
|
|
48
48
|
if (step) {
|
|
49
|
-
steps.push(times(Math.round((percent
|
|
49
|
+
steps.push(times(Math.round((percent) / step), step))
|
|
50
50
|
}
|
|
51
|
-
// steps.forEach(x => {
|
|
52
|
-
// values.push(x == 0 ? 0 : times(Math.round((percent + min) / x), x))
|
|
53
|
-
// })
|
|
54
51
|
|
|
55
|
-
let result = steps.reduce((x, y) => Math.abs(x - percent
|
|
52
|
+
let result = steps.reduce((x, y) => Math.abs(x - percent) > Math.abs(y - percent) ? y : x)
|
|
53
|
+
// let result = steps.reduce((x, y) => Math.abs(x - percent) > Math.abs(y - percent) ? y : x)
|
|
56
54
|
// console.log(percent, result, steps)
|
|
57
|
-
return result
|
|
55
|
+
return result + min
|
|
58
56
|
},
|
|
59
57
|
getValue() {
|
|
60
58
|
let { value = 0, range, min, max } = this, v;
|
package/dist/k-ui.css
CHANGED