kui-vue 3.6.0 → 3.6.2
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/{readme.md → README.md} +4 -10
- package/components/button/demo/group.md +1 -1
- package/components/button/demo/size.md +1 -1
- package/components/card/card.jsx +1 -1
- package/components/checkbox/checkbox.jsx +17 -16
- package/components/checkbox/checkboxGroup.jsx +5 -5
- package/components/checkbox/demo/group.md +17 -6
- package/components/checkbox/styles/index.less +4 -11
- package/components/collapse/collapse.jsx +9 -10
- package/components/collapse/demo/accordion.md +2 -2
- package/components/collapse/demo/basic.md +2 -2
- package/components/collapse/demo/extra.md +2 -2
- package/components/collapse/demo/nesting.md +4 -4
- package/components/collapse/demo/sample.md +2 -2
- package/components/collapse/index.md +6 -6
- package/components/colorPicker/colorpicker.jsx +5 -6
- package/components/colorPicker/demo/basic.md +14 -2
- package/components/colorPicker/demo/customTrigger.md +2 -2
- package/components/colorPicker/demo/index.jsx +0 -8
- package/components/colorPicker/demo/size.md +24 -10
- package/components/datePicker/datepicker.jsx +19 -11
- package/components/datePicker/demo/basic.md +15 -6
- package/components/datePicker/demo/lang.md +2 -2
- package/components/datePicker/demo/size.md +1 -1
- package/components/drawer/drawer.jsx +2 -2
- package/components/dropdown/dropdown.jsx +9 -40
- package/components/dropdown/dropdownButton.jsx +18 -7
- package/components/empty/demo/basic.md +1 -3
- package/components/empty/demo/nodesc.md +1 -3
- package/components/empty/demo/used.md +4 -6
- package/components/empty/empty.jsx +19 -17
- package/components/empty/styles/index.less +18 -5
- package/components/form/demo/align.md +10 -10
- package/components/form/demo/valid.md +3 -2
- package/components/form/form.jsx +1 -1
- package/components/form/formitem.jsx +1 -1
- package/components/image/image.jsx +1 -0
- package/components/image/preview.jsx +1 -1
- package/components/input/demo/basic.md +1 -1
- package/components/input/demo/group.md +1 -1
- package/components/input/index.md +1 -1
- package/components/input/input.jsx +7 -5
- package/components/input/inputBox.jsx +2 -2
- package/components/inputNumber/demo/basic.md +12 -5
- package/components/inputNumber/demo/format.md +0 -5
- package/components/inputNumber/index.md +1 -1
- package/components/inputNumber/inputNumber.jsx +3 -5
- package/components/inputNumber/styles/index.less +64 -64
- package/components/menu/submenu.jsx +5 -5
- package/components/message/demo/close.md +1 -1
- package/components/message/group.jsx +2 -2
- package/components/message/index.md +1 -1
- package/components/message/inner.jsx +26 -7
- package/components/notice/demo/close.md +1 -1
- package/components/notice/index.md +1 -1
- package/components/page/page.jsx +0 -1
- package/components/page/styles/index.less +7 -1
- package/components/popconfirm/popconfirm.jsx +18 -20
- package/components/poptip/poptip.jsx +4 -4
- package/components/progress/progress.jsx +1 -1
- package/components/radio/demo/group.md +16 -6
- package/components/radio/demo/radioButton.md +3 -8
- package/components/radio/radio.jsx +14 -11
- package/components/radio/radioButton.jsx +1 -1
- package/components/radio/radioGroup.jsx +9 -12
- package/components/radio/styles/index.less +10 -21
- package/components/rate/demo/basic.md +12 -2
- package/components/rate/demo/character.md +16 -2
- package/components/rate/demo/index.jsx +0 -8
- package/components/rate/demo/tips.md +15 -5
- package/components/rate/rate.jsx +24 -5
- package/components/select/demo/basic.md +16 -7
- package/components/select/demo/filterable.md +4 -2
- package/components/select/demo/size.md +1 -1
- package/components/select/index.md +23 -22
- package/components/select/option.jsx +7 -3
- package/components/select/select.jsx +43 -37
- package/components/select/styles/index.less +1 -0
- package/components/slider/demo/basic.md +2 -1
- package/components/slider/demo/withNumber.md +3 -3
- package/components/slider/slider.jsx +0 -25
- package/components/space/styles/index.less +5 -1
- package/components/spin/index.md +6 -5
- package/components/styles/sys.less +3 -0
- package/components/switch/switch.jsx +13 -5
- package/components/table/demo/size.md +1 -1
- package/components/table/styles/index.less +10 -5
- package/components/table/table.jsx +98 -69
- package/components/tabs/tabs.jsx +1 -1
- package/components/tooltip/tooltip.jsx +16 -11
- package/components/treeselect/demo/basic.md +11 -8
- package/components/treeselect/demo/size.md +6 -5
- package/components/treeselect/demo/theme.md +0 -1
- package/components/treeselect/treeselect.jsx +15 -20
- package/components/upload/upload.jsx +0 -1
- package/components/utils/placement.js +162 -124
- package/dist/k-ui.cjs.js +2 -2
- package/dist/k-ui.css +2 -2
- package/dist/k-ui.d.ts +131 -127
- package/dist/k-ui.esm.js +2 -2
- package/dist/k-ui.umd.js +2 -2
- package/dist/locale/de.js +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/ua.js +2 -2
- package/dist/locale/uk.js +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/zh-CN.js +1 -1
- package/dist/locale/zh-TW.js +1 -1
- package/package.json +5 -5
- package/test/i18n@8.x.html +6 -2
- package/types/checkbox/Checkbox.d.ts +1 -1
- package/types/collapse/Collapse.d.ts +1 -1
- package/types/image/KImage.d.ts +1 -0
- package/types/index.d.ts +12 -12
- package/types/popconfirm/Popconfirm.d.ts +1 -0
- package/types/radio/Radio.d.ts +1 -1
- package/types/radio/RadioButton.d.ts +1 -1
- package/types/switch/Switch.d.ts +2 -1
- package/types/tooltip/Tooltip.d.ts +1 -0
- package/components/base/collapse.jsx +0 -15
- package/components/base/input.jsx +0 -210
- package/components/colorPicker/demo/disabled.md +0 -16
- package/components/colorPicker/demo/disabledAlpha.md +0 -13
- package/components/colorPicker/demo/mode.md +0 -24
- package/components/colorPicker/demo/presets.md +0 -17
- package/components/rate/demo/clear.md +0 -13
- package/components/rate/demo/custom.md +0 -23
- package/components/rate/demo/disabled.md +0 -12
- package/components/rate/demo/half.md +0 -12
- package/components/steps/index.js +0 -4
- package/components/steps/step.vue +0 -82
- package/components/steps/steps.vue +0 -68
- package/components/steps/styles/index.less +0 -198
- package/components/utils/element.js +0 -122
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<template>
|
|
3
|
-
<div
|
|
4
|
-
:class="classes"
|
|
5
|
-
:style="styles"
|
|
6
|
-
>
|
|
7
|
-
<div class="k-step-tail">
|
|
8
|
-
<i />
|
|
9
|
-
</div>
|
|
10
|
-
<div class="k-step-icon">
|
|
11
|
-
<Icon
|
|
12
|
-
v-if="icon"
|
|
13
|
-
:type="icon"
|
|
14
|
-
/>
|
|
15
|
-
<div
|
|
16
|
-
v-if="!icon"
|
|
17
|
-
class="k-step-icon-inner"
|
|
18
|
-
>
|
|
19
|
-
<span v-if="state!='finish' && !icon && state!='error'">{{ step }}</span>
|
|
20
|
-
<Icon
|
|
21
|
-
v-if="!icon && state=='finish'"
|
|
22
|
-
type="checkmark"
|
|
23
|
-
/>
|
|
24
|
-
<Icon
|
|
25
|
-
v-if="!icon && state=='error'"
|
|
26
|
-
type="close"
|
|
27
|
-
/>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
<div class="k-step-main">
|
|
31
|
-
<div class="k-step-title">
|
|
32
|
-
{{ title }}
|
|
33
|
-
</div>
|
|
34
|
-
<div class="k-step-description">
|
|
35
|
-
{{ description }}
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
</template>
|
|
40
|
-
<script>
|
|
41
|
-
import Icon from '../icon'
|
|
42
|
-
import emitter from '@/mixins/emitter'
|
|
43
|
-
export default {
|
|
44
|
-
name: 'Step',
|
|
45
|
-
components: { Icon },
|
|
46
|
-
mixins: [emitter],
|
|
47
|
-
props: {
|
|
48
|
-
title: String,
|
|
49
|
-
description: String,
|
|
50
|
-
status: {
|
|
51
|
-
validator: (v) => {
|
|
52
|
-
return ['wait', 'process', 'finish', 'error'].indexOf(v) >= 0
|
|
53
|
-
},
|
|
54
|
-
default: 'wait'
|
|
55
|
-
},
|
|
56
|
-
icon: [String, Array]
|
|
57
|
-
},
|
|
58
|
-
data() {
|
|
59
|
-
return {
|
|
60
|
-
width: 0,
|
|
61
|
-
step: 0,
|
|
62
|
-
state: this.status
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
computed: {
|
|
66
|
-
styles() {
|
|
67
|
-
return this.width > 0 ? { width: `${this.width}%` } : {}
|
|
68
|
-
},
|
|
69
|
-
classes() {
|
|
70
|
-
return ['k-step-item', {
|
|
71
|
-
[`k-steps-${this.state}`]: this.state
|
|
72
|
-
}]
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
mounted() {
|
|
76
|
-
this.dispatch('Steps', 'steps-add', this)
|
|
77
|
-
},
|
|
78
|
-
beforeUnmount() {
|
|
79
|
-
this.dispatch('Step', 'steps-remove', this)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
</script>
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<template>
|
|
3
|
-
<div :class="classes">
|
|
4
|
-
<slot />
|
|
5
|
-
</div>
|
|
6
|
-
</template>
|
|
7
|
-
<script>
|
|
8
|
-
export default {
|
|
9
|
-
name: 'Steps',
|
|
10
|
-
props: {
|
|
11
|
-
current: [String, Number],
|
|
12
|
-
vertical: Boolean,
|
|
13
|
-
mini: Boolean,
|
|
14
|
-
status: {
|
|
15
|
-
validator: (v) => {
|
|
16
|
-
return ['wait', 'process', 'finish', 'error'].indexOf(v) >= 0
|
|
17
|
-
},
|
|
18
|
-
default: 'process'
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
data() {
|
|
22
|
-
return {
|
|
23
|
-
children: []
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
computed: {
|
|
27
|
-
classes() {
|
|
28
|
-
return ['k-steps', {
|
|
29
|
-
['k-steps-vertical']: this.vertical,
|
|
30
|
-
['k-steps-mini']: this.mini,
|
|
31
|
-
}]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
watch: {
|
|
35
|
-
current(v) {
|
|
36
|
-
this.setState()
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
created() {
|
|
40
|
-
this.$on('steps-add', this.add)
|
|
41
|
-
this.$on('steps-remove', this.remove)
|
|
42
|
-
},
|
|
43
|
-
mounted() {
|
|
44
|
-
this.setState()
|
|
45
|
-
},
|
|
46
|
-
methods: {
|
|
47
|
-
setState() {
|
|
48
|
-
this.children.forEach((child, index) => {
|
|
49
|
-
child.width = !this.vertical ? 100 / this.children.length : 0;
|
|
50
|
-
if (index == this.current) {
|
|
51
|
-
child.state = this.status == 'error' ? 'error' : 'process'
|
|
52
|
-
} else if (index > this.current) {
|
|
53
|
-
child.state = 'wait'
|
|
54
|
-
} else if (index < this.current) {
|
|
55
|
-
child.state = 'finish'
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
},
|
|
59
|
-
add(obj) {
|
|
60
|
-
this.children.push(obj)
|
|
61
|
-
obj.step = this.children.length
|
|
62
|
-
},
|
|
63
|
-
remove(obj) {
|
|
64
|
-
this.children.splice(this.children.indexOf(obj), 1)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
</script>
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
@import '../../styles/var.less';
|
|
2
|
-
.k-steps {
|
|
3
|
-
font-size: 0;
|
|
4
|
-
width: 100%;
|
|
5
|
-
.k-step-item {
|
|
6
|
-
position: relative;
|
|
7
|
-
display: inline-block;
|
|
8
|
-
vertical-align: top;
|
|
9
|
-
color: #999;
|
|
10
|
-
.k-step-tail {
|
|
11
|
-
width: 100%;
|
|
12
|
-
padding: 0 10px;
|
|
13
|
-
position: absolute;
|
|
14
|
-
left: 0;
|
|
15
|
-
top: 13px;
|
|
16
|
-
box-sizing: border-box;
|
|
17
|
-
i {
|
|
18
|
-
display: inline-block;
|
|
19
|
-
width: 100%;
|
|
20
|
-
height: 1px;
|
|
21
|
-
vertical-align: top;
|
|
22
|
-
background: #e9eaec;
|
|
23
|
-
border-radius: 1px;
|
|
24
|
-
position: relative;
|
|
25
|
-
&::before {
|
|
26
|
-
position: absolute;
|
|
27
|
-
left: 0;
|
|
28
|
-
top: 0;
|
|
29
|
-
content: '';
|
|
30
|
-
width: 0;
|
|
31
|
-
background: var(--kui-color-main);
|
|
32
|
-
height: 1px;
|
|
33
|
-
transition: width .3s ease-in-out;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
.k-step-icon {
|
|
38
|
-
display: inline-block;
|
|
39
|
-
position: relative;
|
|
40
|
-
background-color: #fff;
|
|
41
|
-
padding-right: 8px;
|
|
42
|
-
&>i {
|
|
43
|
-
font-size: 24px;
|
|
44
|
-
width: 20px;
|
|
45
|
-
height: 28px;
|
|
46
|
-
line-height: 28px;
|
|
47
|
-
text-align: center;
|
|
48
|
-
}
|
|
49
|
-
.k-step-icon-inner {
|
|
50
|
-
box-sizing: border-box;
|
|
51
|
-
width: 26px;
|
|
52
|
-
height: 26px;
|
|
53
|
-
display: block;
|
|
54
|
-
border: 1px solid #ccc;
|
|
55
|
-
line-height: 24px;
|
|
56
|
-
text-align: center;
|
|
57
|
-
border-radius: 50%;
|
|
58
|
-
font-size: 14px;
|
|
59
|
-
.k-ion-close{
|
|
60
|
-
font-size: 20px;
|
|
61
|
-
vertical-align: middle;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
.k-step-main {
|
|
66
|
-
display: inline-block;
|
|
67
|
-
position: relative;
|
|
68
|
-
vertical-align: top;
|
|
69
|
-
.k-step-title {
|
|
70
|
-
display: inline-block;
|
|
71
|
-
padding-right: 16px;
|
|
72
|
-
font-size: 14px;
|
|
73
|
-
font-weight: 500; // color: #999;
|
|
74
|
-
background: #fff;
|
|
75
|
-
line-height: 28px;
|
|
76
|
-
}
|
|
77
|
-
.k-step-description {
|
|
78
|
-
font-size: 12px;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
&:last-child {
|
|
82
|
-
.k-step-tail {
|
|
83
|
-
display: none;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
.k-steps-process {
|
|
88
|
-
color: #666;
|
|
89
|
-
.k-step-icon {
|
|
90
|
-
&>i {
|
|
91
|
-
color: var(--kui-color-main);
|
|
92
|
-
}
|
|
93
|
-
.k-step-icon-inner {
|
|
94
|
-
border-color: var(--kui-color-main);
|
|
95
|
-
background-color: var(--kui-color-main);
|
|
96
|
-
color: #fff;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
.k-steps-finish {
|
|
101
|
-
// color: #666;
|
|
102
|
-
.k-step-icon {
|
|
103
|
-
color: var(--kui-color-main);
|
|
104
|
-
font-weight: 500;
|
|
105
|
-
.k-step-icon-inner {
|
|
106
|
-
border-color: var(--kui-color-main); // background-color: var(--kui-color-main);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
.k-step-tail i {
|
|
110
|
-
&::before {
|
|
111
|
-
width: 100%;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
.k-steps-error {
|
|
116
|
-
color: var(--kui-color-danger);
|
|
117
|
-
.k-step-icon {
|
|
118
|
-
.k-step-icon-inner {
|
|
119
|
-
border-color: var(--kui-color-danger); // background-color: var(--kui-color-main);
|
|
120
|
-
color: var(--kui-color-danger);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.k-steps-vertical {
|
|
127
|
-
.k-step-item {
|
|
128
|
-
display: block;
|
|
129
|
-
.k-step-icon {
|
|
130
|
-
padding-right: 16px;
|
|
131
|
-
padding-bottom: 8px;
|
|
132
|
-
float: left;
|
|
133
|
-
}
|
|
134
|
-
.k-step-main {
|
|
135
|
-
min-height: 48px;
|
|
136
|
-
overflow: hidden;
|
|
137
|
-
display: block;
|
|
138
|
-
.k-step-description {
|
|
139
|
-
padding-bottom: 20px;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
.k-step-tail {
|
|
143
|
-
height: 100%;
|
|
144
|
-
padding: 0 0 5px 0;
|
|
145
|
-
left: 13px;
|
|
146
|
-
top: 0;
|
|
147
|
-
width: 1px;
|
|
148
|
-
i {
|
|
149
|
-
display: inline-block;
|
|
150
|
-
height: 100%;
|
|
151
|
-
width: 1px;
|
|
152
|
-
vertical-align: top;
|
|
153
|
-
&::before {
|
|
154
|
-
position: absolute;
|
|
155
|
-
left: 0;
|
|
156
|
-
top: 0;
|
|
157
|
-
height: 0;
|
|
158
|
-
content: '';
|
|
159
|
-
background: var(--kui-color-main);
|
|
160
|
-
width: 1px;
|
|
161
|
-
transition: height .3s ease-in-out;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
.k-steps-finish {
|
|
167
|
-
.k-step-tail i {
|
|
168
|
-
&::before {
|
|
169
|
-
height: 100%;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.k-steps-mini {
|
|
176
|
-
.k-step-item {
|
|
177
|
-
.k-step-tail {
|
|
178
|
-
top: 10px;
|
|
179
|
-
}
|
|
180
|
-
.k-step-icon {
|
|
181
|
-
.k-step-icon-inner {
|
|
182
|
-
width: 18px;
|
|
183
|
-
height: 18px;
|
|
184
|
-
line-height: 16px;
|
|
185
|
-
font-size: 12px;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
.k-step-main {
|
|
189
|
-
.k-step-title {
|
|
190
|
-
font-size: 12px;
|
|
191
|
-
line-height: 24px;
|
|
192
|
-
}
|
|
193
|
-
.k-step-description {
|
|
194
|
-
display: none;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
export function isEmptyNode(vnode = {}) {
|
|
2
|
-
return !(vnode.eml || vnode.tag || (vnode.text && vnode.text.trim() !== ""));
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function getChildren(children = [], name) {
|
|
6
|
-
// return child.filter(c => !isEmptyNode(c, name) )
|
|
7
|
-
return children.filter((c) => {
|
|
8
|
-
let tag_name = "";
|
|
9
|
-
if (
|
|
10
|
-
name &&
|
|
11
|
-
c.componentOptions != null &&
|
|
12
|
-
c.componentOptions.Ctor != undefined
|
|
13
|
-
) {
|
|
14
|
-
tag_name = c.componentOptions.Ctor.extendOptions.name;
|
|
15
|
-
}
|
|
16
|
-
if (!isEmptyNode(c) && name !== tag_name) {
|
|
17
|
-
return true;
|
|
18
|
-
} else {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function contains(ele, target) {
|
|
25
|
-
//ele是内部元素,target是你想找到的包裹元素
|
|
26
|
-
if (!ele || ele === document || !target) return false;
|
|
27
|
-
return ele === target ? true : contains(ele.parentNode, target);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//此处不能判断数组,要判断数组自行判断
|
|
31
|
-
export function isNotEmpty(str) {
|
|
32
|
-
return str !== "" && str !== undefined && str !== null;
|
|
33
|
-
}
|
|
34
|
-
export function isEmpty(str) {
|
|
35
|
-
return str === "" || str === undefined || str === null || str.length === 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function hasProp(context, key) {
|
|
39
|
-
const options = context.$options || {};
|
|
40
|
-
const props = options.propsData || {};
|
|
41
|
-
return key in props;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getElementPosBody(element) {
|
|
45
|
-
let pos = {
|
|
46
|
-
left: 0,
|
|
47
|
-
top: 0,
|
|
48
|
-
width: 0,
|
|
49
|
-
height: 0,
|
|
50
|
-
};
|
|
51
|
-
if (element) {
|
|
52
|
-
pos = element.getBoundingClientRect();
|
|
53
|
-
}
|
|
54
|
-
return pos;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function getElementPos(element) {
|
|
58
|
-
var parent = element; //.offsetParent;
|
|
59
|
-
let pos = {
|
|
60
|
-
left: 0,
|
|
61
|
-
top: 0,
|
|
62
|
-
width: parent.offsetWidth,
|
|
63
|
-
height: parent.offsetHeight,
|
|
64
|
-
};
|
|
65
|
-
while (parent !== null) {
|
|
66
|
-
pos.left += parent.offsetLeft;
|
|
67
|
-
pos.top += parent.offsetTop;
|
|
68
|
-
parent = parent.offsetParent;
|
|
69
|
-
}
|
|
70
|
-
return pos;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function getOffset(el) {
|
|
74
|
-
// const rect = el.getBoundingClientRect();
|
|
75
|
-
const pos = el
|
|
76
|
-
? {
|
|
77
|
-
left: el.offsetLeft, //rect.left,
|
|
78
|
-
top: el.offsetTop,
|
|
79
|
-
}
|
|
80
|
-
: { left: 0, top: 0 };
|
|
81
|
-
return pos;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
let _scrollBarWidth;
|
|
87
|
-
let _scrollBarHeight;
|
|
88
|
-
|
|
89
|
-
export function measureScrollBar(direction = "vertical") {
|
|
90
|
-
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
91
|
-
return 0;
|
|
92
|
-
}
|
|
93
|
-
const isVertical = direction == "vertical";
|
|
94
|
-
|
|
95
|
-
if (isVertical && _scrollBarWidth) return _scrollBarWidth;
|
|
96
|
-
if (!isVertical && _scrollBarHeight) return _scrollBarHeight;
|
|
97
|
-
|
|
98
|
-
const div = document.createElement("div");
|
|
99
|
-
const style = {
|
|
100
|
-
position: "absolute",
|
|
101
|
-
top: "-9999px",
|
|
102
|
-
width: "50px",
|
|
103
|
-
height: "50px",
|
|
104
|
-
};
|
|
105
|
-
Object.keys(style).forEach((st) => {
|
|
106
|
-
div.style[st] = style[st];
|
|
107
|
-
});
|
|
108
|
-
if (isVertical) {
|
|
109
|
-
div.style.overflowY = "scroll";
|
|
110
|
-
} else {
|
|
111
|
-
div.style.overflowX = "scroll";
|
|
112
|
-
}
|
|
113
|
-
document.body.appendChild(div);
|
|
114
|
-
let size = 0;
|
|
115
|
-
if (isVertical) {
|
|
116
|
-
size = _scrollBarWidth = div.offsetWidth - div.clientWidth;
|
|
117
|
-
} else {
|
|
118
|
-
size = _scrollBarHeight = div.offsetHeight - div.clientHeight;
|
|
119
|
-
}
|
|
120
|
-
document.body.removeChild(div);
|
|
121
|
-
return size;
|
|
122
|
-
}
|