kui-vue 3.6.1 → 3.6.3
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/button/demo/size.md +1 -1
- package/components/card/card.jsx +19 -9
- package/components/card/demo/basic.md +3 -3
- package/components/card/demo/border.md +1 -7
- package/components/card/demo/index.jsx +9 -7
- package/components/card/demo/notitle.md +23 -0
- package/components/card/styles/index.less +5 -3
- package/components/checkbox/checkbox.jsx +17 -16
- package/components/checkbox/checkboxGroup.jsx +1 -1
- package/components/checkbox/styles/index.less +1 -0
- 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/collapse/styles/index.less +2 -2
- package/components/colorPicker/demo/basic.md +14 -2
- package/components/colorPicker/demo/index.jsx +0 -8
- package/components/colorPicker/demo/size.md +24 -10
- package/components/colorPicker/mode.jsx +1 -1
- package/components/components.js +3 -0
- package/components/datePicker/demo/size.md +1 -1
- package/components/drawer/demo/target.md +2 -2
- package/components/dropdown/demo/basic.md +1 -1
- package/components/dropdown/dropdownButton.jsx +18 -7
- package/components/dropdown/styles/index.less +1 -0
- 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/flex/demo/size.md +14 -5
- package/components/form/demo/align.md +10 -10
- package/components/form/demo/customvalid.md +1 -1
- package/components/form/demo/dynamicvalid.md +1 -1
- package/components/form/demo/length.md +1 -13
- package/components/form/demo/valid.md +11 -3
- package/components/form/form.jsx +2 -2
- package/components/form/formitem.jsx +1 -1
- 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/input.jsx +19 -15
- package/components/input/inputBox.jsx +2 -2
- package/components/inputNumber/demo/basic.md +1 -0
- package/components/inputNumber/demo/format.md +3 -8
- package/components/inputNumber/inputNumber.jsx +116 -139
- package/components/inputNumber/styles/index.less +3 -3
- package/components/layout/demo/layout5.md +0 -1
- package/components/locale/de.js +1 -0
- package/components/locale/el.js +1 -0
- package/components/locale/en.js +1 -0
- package/components/locale/fr.js +1 -0
- package/components/locale/it.js +1 -0
- package/components/locale/ja.js +1 -0
- package/components/locale/ko.js +1 -0
- package/components/locale/ru.js +1 -0
- package/components/locale/th.js +1 -0
- package/components/locale/uk.js +1 -0
- package/components/locale/vi.js +1 -0
- package/components/locale/zh-CN.js +1 -0
- package/components/locale/zh-TW.js +1 -0
- package/components/menu/demo/collapsed.md +9 -9
- package/components/menu/index.md +1 -0
- package/components/message/demo/close.md +1 -1
- package/components/message/group.jsx +13 -6
- 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/styles/index.less +7 -1
- package/components/popconfirm/popconfirm.jsx +14 -16
- package/components/progress/progress.jsx +1 -1
- package/components/radio/radio.jsx +14 -11
- package/components/radio/radioButton.jsx +1 -1
- package/components/radio/radioGroup.jsx +1 -1
- 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 +30 -6
- package/components/rate/star.jsx +20 -5
- package/components/select/demo/size.md +1 -1
- package/components/select/select.jsx +5 -4
- package/components/slider/demo/vertical.md +2 -1
- package/components/slider/demo/withNumber.md +0 -2
- package/components/slider/index.md +2 -3
- package/components/slider/slider.jsx +296 -291
- package/components/slider/styles/index.less +11 -12
- package/components/slider/thumb.jsx +70 -148
- package/components/space/styles/index.less +3 -1
- package/components/spin/demo/container.md +1 -1
- package/components/spin/demo/mode.md +1 -1
- package/components/spin/index.md +6 -5
- package/components/statCard/countup.js +254 -0
- package/components/statCard/countup.jsx +45 -0
- package/components/statCard/demo/basic.md +31 -0
- package/components/statCard/demo/card.md +40 -0
- package/components/statCard/demo/index.jsx +19 -0
- package/components/statCard/demo/info.md +9 -0
- package/components/statCard/demo/with-card.md +43 -0
- package/components/statCard/index.js +3 -0
- package/components/statCard/index.md +28 -0
- package/components/statCard/rollup.jsx +64 -0
- package/components/statCard/statCard.jsx +42 -0
- package/components/statCard/statNumber.jsx +53 -0
- package/components/statCard/styles/index.less +76 -0
- package/components/styles/color.less +4 -2
- package/components/styles/index.less +1 -0
- package/components/styles/sys.less +2 -3
- package/components/styles/var.less +1 -0
- package/components/switch/switch.jsx +1 -3
- package/components/table/demo/col-row-span.md +1 -1
- package/components/table/demo/fixed-col-head.md +1 -1
- package/components/table/demo/head-span.md +2 -2
- package/components/table/demo/size.md +2 -2
- package/components/table/demo/table-check.md +11 -1
- package/components/table/index.md +13 -12
- package/components/table/styles/index.less +67 -58
- package/components/table/table.jsx +7 -5
- package/components/tabs/demo/sample.md +1 -8
- package/components/tabs/index.md +9 -9
- package/components/tabs/tabs.jsx +7 -5
- package/components/tooltip/tooltip.jsx +13 -8
- package/components/treeselect/demo/basic.md +11 -8
- package/components/treeselect/demo/size.md +4 -3
- package/components/treeselect/demo/theme.md +0 -1
- package/components/treeselect/treeselect.jsx +5 -3
- package/components/upload/demo/custom.md +5 -2
- package/components/upload/demo/exceed.md +1 -1
- package/components/upload/demo/pictures.md +14 -0
- package/components/upload/fileList.jsx +24 -47
- package/components/upload/index.md +13 -4
- package/components/upload/selector.jsx +37 -117
- package/components/upload/styles/index.less +2 -3
- package/components/upload/upload.jsx +189 -117
- package/components/utils/number.js +79 -65
- package/components/utils/placement.js +62 -35
- package/dist/k-ui.cjs.js +2 -2
- package/dist/k-ui.css +2 -2
- package/dist/k-ui.d.ts +172 -129
- package/dist/k-ui.esm.js +2 -2
- package/dist/k-ui.umd.js +2 -2
- package/dist/locale/de.js +2 -2
- package/dist/locale/el.js +2 -2
- package/dist/locale/en.js +2 -2
- package/dist/locale/fr.js +2 -2
- package/dist/locale/it.js +2 -2
- package/dist/locale/ja.js +2 -2
- package/dist/locale/ko.js +2 -2
- package/dist/locale/ru.js +2 -2
- package/dist/locale/th.js +2 -2
- package/dist/locale/ua.js +1 -1
- package/dist/locale/uk.js +2 -2
- package/dist/locale/vi.js +2 -2
- package/dist/locale/zh-CN.js +2 -2
- package/dist/locale/zh-TW.js +2 -2
- package/package.json +3 -1
- package/types/checkbox/Checkbox.d.ts +1 -1
- package/types/collapse/Collapse.d.ts +1 -1
- package/types/index.d.ts +14 -10
- 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/rate/Rate.d.ts +1 -1
- package/types/slider/Slider.d.ts +7 -6
- package/types/statCard/StatCard.d.ts +20 -0
- package/types/statCard/StatNumber.d.ts +26 -0
- package/types/switch/Switch.d.ts +1 -2
- package/types/table/Table.d.ts +1 -0
- 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 -21
- 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/utils/element.js +0 -122
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import Icon from '../icon'
|
|
2
|
-
import { isNotEmpty } from '../utils/element'
|
|
3
|
-
import { Search, CloseCircle, EyeOutline, EyeOffOutline } from 'kui-icons';
|
|
4
|
-
import InputGroup from '../input/inputGroup'
|
|
5
|
-
export default {
|
|
6
|
-
name: "baseInput",
|
|
7
|
-
props: {
|
|
8
|
-
clearable: Boolean,
|
|
9
|
-
visiblePassword: Boolean,
|
|
10
|
-
visiblePasswordIcon: Boolean,
|
|
11
|
-
id: String,
|
|
12
|
-
size: {
|
|
13
|
-
default: 'default',
|
|
14
|
-
validator(value) {
|
|
15
|
-
return ["small", "large", "default"].indexOf(value) >= 0;
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
inputType: { type: String, default: "input" },
|
|
19
|
-
value: [String, Number, Array, Object],
|
|
20
|
-
disabled: Boolean,
|
|
21
|
-
type: {
|
|
22
|
-
validator(value) {
|
|
23
|
-
return (["text", "password", "url", "email", "date", "search", "hidden"].indexOf(value) >= 0);
|
|
24
|
-
},
|
|
25
|
-
default: 'text'
|
|
26
|
-
},
|
|
27
|
-
icon: [String, Array],
|
|
28
|
-
suffix: String,
|
|
29
|
-
prefix: String,
|
|
30
|
-
theme: String,
|
|
31
|
-
shape: String,
|
|
32
|
-
formatter: Function,
|
|
33
|
-
parser: Function,
|
|
34
|
-
placeholder: String
|
|
35
|
-
},
|
|
36
|
-
data() {
|
|
37
|
-
return {
|
|
38
|
-
currentValue: this.value,
|
|
39
|
-
isFocus: false,
|
|
40
|
-
isPassword: !this.visiblePassword,
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
inject: {
|
|
44
|
-
Input: { default: null },
|
|
45
|
-
InputNumber: { default: null },
|
|
46
|
-
},
|
|
47
|
-
watch: {
|
|
48
|
-
value(value) {
|
|
49
|
-
this.currentValue = value
|
|
50
|
-
},
|
|
51
|
-
visiblePassword(value) {
|
|
52
|
-
this.isPassword = !value
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
mounted() {
|
|
56
|
-
let textInput = (this.Input || this.InputNumber) || {}
|
|
57
|
-
textInput.focus = (e) => {
|
|
58
|
-
this.$nextTick(() => this.$refs.input.focus(e))
|
|
59
|
-
}
|
|
60
|
-
textInput.blur = (e) => {
|
|
61
|
-
this.$nextTick(() => this.$refs.input.blur(e))
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
methods: {
|
|
65
|
-
clear() {
|
|
66
|
-
this.setValue({ input: '', output: '' })
|
|
67
|
-
this.$nextTick(() => this.$refs.input.focus())
|
|
68
|
-
},
|
|
69
|
-
iconClick() {
|
|
70
|
-
!this.disabled && this.$emit("icon-click");
|
|
71
|
-
},
|
|
72
|
-
handleFocus(e) {
|
|
73
|
-
this.isFocus = true
|
|
74
|
-
let input = this.Input || this.InputNumber
|
|
75
|
-
input && input.$emit('focus', e)
|
|
76
|
-
},
|
|
77
|
-
handleBlur(e) {
|
|
78
|
-
this.$emit('blur', e);
|
|
79
|
-
this.isFocus = false
|
|
80
|
-
},
|
|
81
|
-
handleInput(e) {
|
|
82
|
-
let v = e.target.value + '', input = v, output = v + '';
|
|
83
|
-
let { parser, formatter } = this
|
|
84
|
-
|
|
85
|
-
if (parser) {
|
|
86
|
-
output = parser(v)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (output !== '' && formatter) {
|
|
91
|
-
input = formatter(output)
|
|
92
|
-
}
|
|
93
|
-
e.target.value = input
|
|
94
|
-
if (input === '') {
|
|
95
|
-
output = ''
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
this.setValue({ input, output })
|
|
99
|
-
},
|
|
100
|
-
showPassword() {
|
|
101
|
-
if (this.disabled) return;
|
|
102
|
-
this.isPassword = !this.isPassword
|
|
103
|
-
let type = this.isPassword ? 'text' : 'password'
|
|
104
|
-
this.$refs.input.type = type
|
|
105
|
-
},
|
|
106
|
-
setValue({ input, output }) {
|
|
107
|
-
this.currentValue = input
|
|
108
|
-
this.$emit('input', output)
|
|
109
|
-
// this.$emit('change', output)
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
searchEvent() {
|
|
113
|
-
if (this.disabled) return;
|
|
114
|
-
this.$listeners.search(this.currentValue)
|
|
115
|
-
},
|
|
116
|
-
getSuffix() {
|
|
117
|
-
let { $listeners, suffix, visiblePasswordIcon } = this
|
|
118
|
-
const SearchNode = ('search' in $listeners) ? <Icon type={Search} class="k-input-search-icon" onClick={this.searchEvent} /> : null
|
|
119
|
-
|
|
120
|
-
const Password = (this.type == 'password' && visiblePasswordIcon) ? <Icon class="k-input-password-icon" type={!this.isPassword ? EyeOutline : EyeOffOutline} onClick={this.showPassword} /> : null
|
|
121
|
-
|
|
122
|
-
return Password || SearchNode || this.$slots.suffix || (suffix ? <div class={[`k-${this.inputType}-suffix`]}>{suffix}</div> : null)
|
|
123
|
-
},
|
|
124
|
-
getTextInput(multiple) {
|
|
125
|
-
const { disabled, size, type, inputType, currentValue, id, theme, shape, placeholder } = this
|
|
126
|
-
const props = {
|
|
127
|
-
domProps: {
|
|
128
|
-
value: currentValue
|
|
129
|
-
},
|
|
130
|
-
class: [
|
|
131
|
-
{
|
|
132
|
-
[`k-${inputType}`]: !multiple,
|
|
133
|
-
[`k-${inputType}-text`]: multiple,
|
|
134
|
-
[`k-${inputType}-disabled`]: disabled,
|
|
135
|
-
[`k-${inputType}-sm`]: size == 'small' && !multiple,
|
|
136
|
-
[`k-${inputType}-lg`]: size == 'large' && !multiple,
|
|
137
|
-
[`k-${inputType}-${theme}`]: theme != 'solid' && !multiple && theme,
|
|
138
|
-
[`k-${inputType}-circle`]: shape == 'circle' && !multiple,
|
|
139
|
-
}
|
|
140
|
-
],
|
|
141
|
-
ref: 'input',
|
|
142
|
-
attrs: {
|
|
143
|
-
...this.$attrs,
|
|
144
|
-
disabled, id, placeholder
|
|
145
|
-
},
|
|
146
|
-
on: {
|
|
147
|
-
...this.$listeners,
|
|
148
|
-
focus: this.handleFocus,
|
|
149
|
-
blur: this.handleBlur,
|
|
150
|
-
input: this.handleInput
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
props.attrs.type = type
|
|
155
|
-
|
|
156
|
-
if (!this.isPassword && type == 'password') {
|
|
157
|
-
props.attrs.type = 'text'
|
|
158
|
-
}
|
|
159
|
-
return (<input {...props} single />)
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
render() {
|
|
163
|
-
const { inputType, icon, $slots, size, disabled, type, $listeners, clearable, suffix, theme, prefix, shape } = this
|
|
164
|
-
|
|
165
|
-
let multiple = (icon || ('search' in $listeners) || $slots.suffix || suffix || $slots.prefix || prefix || type == 'password' || clearable || $slots.controls) && type !== 'hidden'
|
|
166
|
-
let textInput = this.getTextInput(multiple)
|
|
167
|
-
|
|
168
|
-
if (!multiple) return textInput;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
let { isFocus, currentValue } = this
|
|
172
|
-
let clearableShow = clearable && isNotEmpty(currentValue)
|
|
173
|
-
const props = {
|
|
174
|
-
class: {
|
|
175
|
-
[`k-${inputType}`]: true,
|
|
176
|
-
[`k-${inputType}-focus`]: isFocus,
|
|
177
|
-
[`k-${inputType}-disabled`]: disabled,
|
|
178
|
-
[`k-${inputType}-sm`]: size == 'small',
|
|
179
|
-
[`k-${inputType}-lg`]: size == 'large',
|
|
180
|
-
[`k-${inputType}-${theme}`]: theme && theme != 'solid',
|
|
181
|
-
[`k-${inputType}-circle`]: shape == 'circle',
|
|
182
|
-
},
|
|
183
|
-
}
|
|
184
|
-
const suffixNode = this.getSuffix()
|
|
185
|
-
const prefixNode = (prefix ? <div class={`k-${inputType}-prefix`}>{prefix}</div> : null)
|
|
186
|
-
if ($slots.prefix || $slots.suffix) {
|
|
187
|
-
return <InputGroup size={size}>
|
|
188
|
-
{$slots.prefix ? <div class={{ "k-input-group-prefix": true }}>{$slots.prefix}</div> : null}
|
|
189
|
-
<div {...props} mult>
|
|
190
|
-
{icon ? <Icon type={icon} class={`k-${inputType}-icon`} onClick={this.iconClick} /> : null}
|
|
191
|
-
{prefixNode}
|
|
192
|
-
{textInput}
|
|
193
|
-
{clearable ? <Icon type={CloseCircle} class={[`k-${inputType}-clearable`, { [`k-${inputType}-clearable-hidden`]: !clearableShow }]} onClick={this.clear} /> : null}
|
|
194
|
-
{/* {suffixNode} */}
|
|
195
|
-
{$slots.controls}
|
|
196
|
-
</div>
|
|
197
|
-
{$slots.suffix ? <div class={{ "k-input-group-suffix": true }}>{$slots.suffix}</div> : null}
|
|
198
|
-
</InputGroup>
|
|
199
|
-
} else {
|
|
200
|
-
return <div {...props} mult>
|
|
201
|
-
{icon ? <Icon type={icon} class={`k-${inputType}-icon`} onClick={this.iconClick} /> : null}
|
|
202
|
-
{prefixNode}
|
|
203
|
-
{textInput}
|
|
204
|
-
{clearable ? <Icon type={CloseCircle} class={[`k-${inputType}-clearable`, { [`k-${inputType}-clearable-hidden`]: !clearableShow }]} onClick={this.clear} /> : null}
|
|
205
|
-
{suffixNode}
|
|
206
|
-
{$slots.controls}
|
|
207
|
-
</div>
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<cn>
|
|
2
|
-
### 禁用
|
|
3
|
-
设置为禁用状态。
|
|
4
|
-
</cn>
|
|
5
|
-
|
|
6
|
-
```vue
|
|
7
|
-
<template>
|
|
8
|
-
<Space class="demo-color-picker" vertical>
|
|
9
|
-
<ColorPicker :value="color" disabled />
|
|
10
|
-
<ColorPicker :value="color" disabled showText />
|
|
11
|
-
</Space>
|
|
12
|
-
</template>
|
|
13
|
-
<script setup>
|
|
14
|
-
const color = "#3a95ff";
|
|
15
|
-
</script>
|
|
16
|
-
```
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<cn>
|
|
2
|
-
### 颜色编码
|
|
3
|
-
编码格式,支持HEX、HSB、RGB。
|
|
4
|
-
</cn>
|
|
5
|
-
|
|
6
|
-
```vue
|
|
7
|
-
<template>
|
|
8
|
-
<Space class="demo-color-picker" vertical>
|
|
9
|
-
<Space> <ColorPicker v-model="color1" /> HEX: {{ color1 }} </Space>
|
|
10
|
-
<Space>
|
|
11
|
-
<ColorPicker v-model:value="color3" mode="hsl" /> HSL: {{ color3 }}
|
|
12
|
-
</Space>
|
|
13
|
-
</Space>
|
|
14
|
-
</template>
|
|
15
|
-
<script setup>
|
|
16
|
-
import { ref } from "vue";
|
|
17
|
-
const color1 = ref("#00ff00");
|
|
18
|
-
const color2 = ref("rgb(58, 149, 255)");
|
|
19
|
-
const color3 = ref("hsl(212, 100%, 61%)");
|
|
20
|
-
</script>
|
|
21
|
-
```
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<cn>
|
|
2
|
-
### 自定义颜色盘
|
|
3
|
-
可以定义默认的颜色盘
|
|
4
|
-
</cn>
|
|
5
|
-
|
|
6
|
-
```vue
|
|
7
|
-
<template>
|
|
8
|
-
<div class="demo-color-picker">
|
|
9
|
-
<ColorPicker v-model="color" :presets="colors" />
|
|
10
|
-
</div>
|
|
11
|
-
</template>
|
|
12
|
-
<script setup>
|
|
13
|
-
import { ref } from "vue";
|
|
14
|
-
const color = ref("#3a95ff");
|
|
15
|
-
const colors = ["#9c27b0", "red", "blue"];
|
|
16
|
-
</script>
|
|
17
|
-
```
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<cn>
|
|
2
|
-
### 自定义字符
|
|
3
|
-
可以自定义每一个字符。
|
|
4
|
-
</cn>
|
|
5
|
-
|
|
6
|
-
```vue
|
|
7
|
-
<template>
|
|
8
|
-
<Space vertical>
|
|
9
|
-
<Rate :character="(i) => i" :value="2" :count="9" />
|
|
10
|
-
<Rate :icon="(i) => icons[i - 1]" :value="3" />
|
|
11
|
-
</Space>
|
|
12
|
-
</template>
|
|
13
|
-
<script setup>
|
|
14
|
-
import {
|
|
15
|
-
VolumeOff,
|
|
16
|
-
VolumeLow,
|
|
17
|
-
VolumeMedium,
|
|
18
|
-
VolumeHigh,
|
|
19
|
-
VolumeMute,
|
|
20
|
-
} from "kui-icons";
|
|
21
|
-
const icons = [VolumeOff, VolumeLow, VolumeMedium, VolumeHigh, VolumeMute];
|
|
22
|
-
</script>
|
|
23
|
-
```
|
|
@@ -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
|
-
}
|