fit2cloud-ui-plus 0.0.1-beta.8 → 0.0.1-beta.9
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/lib/fit2cloud-ui-plus.es.js +284 -856
- package/lib/fit2cloud-ui-plus.umd.js +1 -1
- package/package.json +3 -1
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/filter-bar/FuFilter.vue +18 -13
- package/src/components/filter-bar/FuFilterBar.vue +14 -11
- package/src/components/filter-bar/FuSearchInput.vue +8 -2
- package/src/components/filter-bar/filter-components/FuFilterDate.vue +17 -13
- package/src/components/filter-bar/filter-components/FuFilterDateTime.vue +16 -13
- package/src/components/filter-bar/filter-components/FuFilterSelect.vue +17 -12
- package/src/components/filter-bar/index.ts +11 -12
- package/src/components/split-pane/FuSplitPane.vue +2 -2
- package/src/components/table/FuTable.vue +10 -11
- package/src/components/table/{table-column-dropdown/FuTableColumnDropdown.vue → FuTableColumnDropdown.vue} +0 -0
- package/src/components/table/index.ts +11 -7
- package/src/components/table/table-column-select/FuTableColumnSelectDialog.vue +3 -9
- package/src/components/table/table-column-select/FuTableColumnSelectPopover.vue +27 -24
- package/src/components/table/table-operations/FuTableButton.vue +1 -4
- package/src/components/table/table-operations/FuTableMoreButton.vue +1 -1
- package/src/components/table/table-operations/FuTableOperations.vue +1 -2
- package/src/components/table/types.ts +3 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-global-config/index.ts +0 -15
- package/src/hooks/use-size/index.ts +29 -0
- package/src/styles/common/variables.scss +1 -1
- package/src/styles/components/filter-bar.scss +3 -3
- package/src/tools/size.ts +6 -0
- package/src/tools/theme.ts +0 -12
- package/src/components/speed-dial/FuSpeedDial.vue +0 -278
- package/src/components/speed-dial/FuSpeedDialActionButton.vue +0 -88
- package/src/components/speed-dial/FuSpeedDialButton.vue +0 -42
- package/src/components/speed-dial/FuSpeedDialItem.vue +0 -88
- package/src/components/speed-dial/index.ts +0 -11
- package/src/components/steps/FuHorizontalNavigation.vue +0 -18
- package/src/components/steps/FuHorizontalSteps.vue +0 -94
- package/src/components/steps/FuStep.vue +0 -13
- package/src/components/steps/FuSteps.vue +0 -22
- package/src/components/steps/FuStepsFooter.ts +0 -79
- package/src/components/steps/FuVerticalNavigation.vue +0 -35
- package/src/components/steps/FuVerticalSteps.vue +0 -79
- package/src/components/steps/Stepper.ts +0 -188
- package/src/components/steps/index.ts +0 -11
- package/src/components/table/table-column-dropdown/index.ts +0 -7
- package/src/components/table/table-column-select/index.ts +0 -8
- package/src/components/table/table-operations/index.ts +0 -12
- package/src/components/virtual-scroller/FuVirtualHorizontalScroll.js +0 -96
- package/src/components/virtual-scroller/FuVirtualScroll.js +0 -15
- package/src/components/virtual-scroller/FuVirtualVerticalScroll.js +0 -95
- package/src/components/virtual-scroller/index.js +0 -10
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineComponent,
|
|
3
|
-
h,
|
|
4
|
-
inject,
|
|
5
|
-
ref,
|
|
6
|
-
computed
|
|
7
|
-
} from 'vue'
|
|
8
|
-
export default defineComponent({
|
|
9
|
-
name: "FuStepsFooter",
|
|
10
|
-
setup(props, { emit }) {
|
|
11
|
-
const stepper = inject('stepper')
|
|
12
|
-
const disabledButton = ref(false)
|
|
13
|
-
|
|
14
|
-
const isFirst = computed(() => {
|
|
15
|
-
return stepper.isFirst(stepper.index);
|
|
16
|
-
})
|
|
17
|
-
const isLast = computed(() => {
|
|
18
|
-
return stepper.isLast(stepper.index);
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const showCancel = computed(() => {
|
|
22
|
-
return stepper.showCancel !== false;
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const disabled = computed(() => {
|
|
26
|
-
return stepper?.isLoading || disabledButton.value;
|
|
27
|
-
})
|
|
28
|
-
const button = (value: string) => {
|
|
29
|
-
return h(
|
|
30
|
-
'el-button',
|
|
31
|
-
{
|
|
32
|
-
disabled: disabled,
|
|
33
|
-
size: stepper.buttonSize, // configSize
|
|
34
|
-
onClick: () => clickHandle(value)
|
|
35
|
-
},
|
|
36
|
-
stepper[`${value}ButtonText`]
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
function clickHandle(fnName: string) {
|
|
41
|
-
stepper[fnName]
|
|
42
|
-
? stepper[fnName]()
|
|
43
|
-
: emit("stepperFn", fnName);
|
|
44
|
-
disabledButton.value = true;
|
|
45
|
-
setTimeout(() => {
|
|
46
|
-
disabledButton.value = false;
|
|
47
|
-
}, 500);
|
|
48
|
-
}
|
|
49
|
-
return () => {
|
|
50
|
-
return h(
|
|
51
|
-
'div',
|
|
52
|
-
{
|
|
53
|
-
class: `fu-steps__footer--${stepper.footerAlign}`,
|
|
54
|
-
},
|
|
55
|
-
[
|
|
56
|
-
h(
|
|
57
|
-
'div',
|
|
58
|
-
{
|
|
59
|
-
class: 'fu-steps__footer--block',
|
|
60
|
-
style: 'margin-right:10px'
|
|
61
|
-
},
|
|
62
|
-
showCancel && button("cancel")
|
|
63
|
-
),
|
|
64
|
-
h(
|
|
65
|
-
'div',
|
|
66
|
-
{
|
|
67
|
-
class: 'fu-steps__footer--block',
|
|
68
|
-
},
|
|
69
|
-
[
|
|
70
|
-
!isFirst && button("prev"),
|
|
71
|
-
isLast ? button("finish") : button("next")
|
|
72
|
-
]
|
|
73
|
-
),
|
|
74
|
-
]
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-steps :active="stepper.index" v-bind="stepper">
|
|
3
|
-
<el-step v-for="(step, i) in steps" :key="i" v-bind="step" @click="click(i)"
|
|
4
|
-
:class="disable(i) && 'fu-step--disable'">
|
|
5
|
-
<template #description>
|
|
6
|
-
<span>{{ step.description }}</span>
|
|
7
|
-
<el-collapse-transition>
|
|
8
|
-
<div class="fu-steps__container" v-if="i === stepper.index" :style="heightStyle">
|
|
9
|
-
<slot v-bind:step="step"></slot>
|
|
10
|
-
</div>
|
|
11
|
-
</el-collapse-transition>
|
|
12
|
-
</template>
|
|
13
|
-
</el-step>
|
|
14
|
-
</el-steps>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script lang="ts" setup>
|
|
18
|
-
import { computed } from "vue";
|
|
19
|
-
const props = defineProps({
|
|
20
|
-
stepper: Object,
|
|
21
|
-
steps: Array,
|
|
22
|
-
disable: Function,
|
|
23
|
-
})
|
|
24
|
-
const emit = defineEmits(["active"])
|
|
25
|
-
|
|
26
|
-
const heightStyle = computed(() => {
|
|
27
|
-
return {
|
|
28
|
-
height: parseInt(props.stepper?.height) + "px" || "auto",
|
|
29
|
-
};
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
function click(index: number) {
|
|
33
|
-
!props.disable(index) && emit("active", index);
|
|
34
|
-
}
|
|
35
|
-
</script>
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import FuVerticalNavigation from "./FuVerticalNavigation.vue";
|
|
3
|
-
import FuStepsFooter from "./FuStepsFooter";
|
|
4
|
-
import { Stepper, Step } from "./Stepper";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
name: "FuVerticalSteps",
|
|
8
|
-
components: { FuVerticalNavigation, FuStepsFooter },
|
|
9
|
-
data() {
|
|
10
|
-
return {
|
|
11
|
-
stepper: new Stepper(),
|
|
12
|
-
};
|
|
13
|
-
},
|
|
14
|
-
created() {
|
|
15
|
-
this.stepper.activeSet.add(0);
|
|
16
|
-
},
|
|
17
|
-
provide() {
|
|
18
|
-
return {
|
|
19
|
-
stepper: this.stepper,
|
|
20
|
-
};
|
|
21
|
-
},
|
|
22
|
-
watch: {
|
|
23
|
-
"stepper.index"(value) {
|
|
24
|
-
this.$emit("change", this.stepper.steps[value]);
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
render() {
|
|
28
|
-
let currentNode;
|
|
29
|
-
let steps = [];
|
|
30
|
-
if (this.$slots.default) {
|
|
31
|
-
this.$slots.default.forEach((node, index) => {
|
|
32
|
-
const options = {
|
|
33
|
-
index: index,
|
|
34
|
-
...node.data.attrs,
|
|
35
|
-
};
|
|
36
|
-
const step = new Step(options);
|
|
37
|
-
steps.push(step);
|
|
38
|
-
if (this.stepper.isCurrent(index)) {
|
|
39
|
-
currentNode = node;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
this.stepper.steps = steps;
|
|
44
|
-
this.stepper = Object.assign(this.stepper, this.$attrs);
|
|
45
|
-
return (
|
|
46
|
-
<div class="fu-steps fu-steps--vertical">
|
|
47
|
-
<fu-vertical-navigation
|
|
48
|
-
stepper={this.stepper}
|
|
49
|
-
steps={steps}
|
|
50
|
-
v-on:active={this.active}
|
|
51
|
-
disable={this.disable} >
|
|
52
|
-
{currentNode}
|
|
53
|
-
</fu-vertical-navigation>
|
|
54
|
-
<div class="fu-steps__footer">
|
|
55
|
-
<fu-steps-footer vOn:stepperFn={this.$func} />
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
);
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
methods: {
|
|
62
|
-
active(index) {
|
|
63
|
-
this.stepper.active(index);
|
|
64
|
-
},
|
|
65
|
-
next() {
|
|
66
|
-
this.stepper.next();
|
|
67
|
-
},
|
|
68
|
-
prev() {
|
|
69
|
-
this.stepper.prev();
|
|
70
|
-
},
|
|
71
|
-
disable(index) {
|
|
72
|
-
return !this.stepper.isActive(index);
|
|
73
|
-
},
|
|
74
|
-
$func(name) {
|
|
75
|
-
this.$emit(name);
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
</script>
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { useLocale } from "@/hooks"
|
|
2
|
-
const { t } = useLocale()
|
|
3
|
-
|
|
4
|
-
interface StepperOptions {
|
|
5
|
-
steps: string
|
|
6
|
-
index: number
|
|
7
|
-
activeSet: any
|
|
8
|
-
isLoading?: string
|
|
9
|
-
cancelButtonText: string
|
|
10
|
-
finishButtonText: string
|
|
11
|
-
prevButtonText: string
|
|
12
|
-
nextButtonText: string
|
|
13
|
-
buttonSize: string
|
|
14
|
-
footerAlign: string
|
|
15
|
-
showCancel: any
|
|
16
|
-
beforeActive: Function
|
|
17
|
-
beforeLeave: Function
|
|
18
|
-
height: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class Stepper {
|
|
22
|
-
steps: string
|
|
23
|
-
index: number
|
|
24
|
-
activeSet: any
|
|
25
|
-
isLoading: string
|
|
26
|
-
cancelButtonText: string
|
|
27
|
-
finishButtonText: string
|
|
28
|
-
prevButtonText: string
|
|
29
|
-
nextButtonText: string
|
|
30
|
-
buttonSize: string
|
|
31
|
-
footerAlign: string
|
|
32
|
-
showCancel: any
|
|
33
|
-
beforeActive: Function
|
|
34
|
-
beforeLeave: Function
|
|
35
|
-
height: string
|
|
36
|
-
constructor(options?: StepperOptions) {
|
|
37
|
-
options = options || ({} as StepperOptions)
|
|
38
|
-
// 所有步骤节点(Step对象数组)
|
|
39
|
-
this.steps = options.steps
|
|
40
|
-
// 正在执行的节点的索引
|
|
41
|
-
this.index = options.index === undefined ? 0 : options.index
|
|
42
|
-
// 激活过的节点的索引
|
|
43
|
-
this.activeSet = new Set()
|
|
44
|
-
// loading状态
|
|
45
|
-
this.isLoading = options.isLoading
|
|
46
|
-
// footer 属性
|
|
47
|
-
this.cancelButtonText = options.cancelButtonText || t("fu.steps.cancel")
|
|
48
|
-
this.finishButtonText = options.finishButtonText || t("fu.steps.finish")
|
|
49
|
-
this.prevButtonText = options.prevButtonText || t("fu.steps.prev")
|
|
50
|
-
this.nextButtonText = options.nextButtonText || t("fu.steps.next")
|
|
51
|
-
this.buttonSize = options.buttonSize
|
|
52
|
-
this.footerAlign = options.footerAlign || 'flex'
|
|
53
|
-
// 是否显示取消按钮
|
|
54
|
-
this.showCancel = options.showCancel === undefined ? false : options.showCancel
|
|
55
|
-
// 激活前钩子
|
|
56
|
-
this.beforeActive = options.beforeActive
|
|
57
|
-
// 离开前钩子
|
|
58
|
-
this.beforeLeave = options.beforeLeave
|
|
59
|
-
// 高度
|
|
60
|
-
this.height = options.height
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// index是否为第一个节点
|
|
64
|
-
isFirst(index: number) {
|
|
65
|
-
return index === 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// index是否为最后一个节点
|
|
69
|
-
isLast(index: number) {
|
|
70
|
-
return index === this.steps.length - 1;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// index的节点是否激活过
|
|
74
|
-
isActive(index: number) {
|
|
75
|
-
return this.activeSet.has(index);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// index的节点是否为正在激活的节点
|
|
79
|
-
isCurrent(index: number) {
|
|
80
|
-
return this.index === index
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// 激活
|
|
84
|
-
active(index: number) {
|
|
85
|
-
// 在节点范围内,并且不等于当前节点
|
|
86
|
-
const isValid = index >= 0 && index < this.steps.length && this.index !== index
|
|
87
|
-
const forward = index > this.index
|
|
88
|
-
if (isValid) {
|
|
89
|
-
// 离开前钩子返回false,则不执行激活
|
|
90
|
-
if (this.executeHook("beforeLeave", this.index, forward) !== false) {
|
|
91
|
-
// 激活前钩子返回false,则不执行激活
|
|
92
|
-
if (this.executeHook("beforeActive", index, forward) !== false) {
|
|
93
|
-
// 激活
|
|
94
|
-
this.index = index
|
|
95
|
-
this.activeSet.add(index)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// 反激活
|
|
102
|
-
inactive(index: number) {
|
|
103
|
-
this.activeSet.delete(index)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// 下一步
|
|
107
|
-
next() {
|
|
108
|
-
if (!this.isLast(this.index)) {
|
|
109
|
-
this.active(this.index + 1)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// 上一步
|
|
114
|
-
prev() {
|
|
115
|
-
if (!this.isFirst(this.index)) {
|
|
116
|
-
this.active(this.index - 1)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// 使用索引获取Step对象
|
|
121
|
-
getStep(index: number) {
|
|
122
|
-
if (this.steps && this.steps.length > index) {
|
|
123
|
-
return this.steps[index]
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// 使用ID获取节点索引
|
|
128
|
-
getIndex(id: string) {
|
|
129
|
-
if (this.steps) {
|
|
130
|
-
for (let i = 0; i < this.steps.length; i++) {
|
|
131
|
-
let step = this.steps[i];
|
|
132
|
-
if (id === step.id) {
|
|
133
|
-
return i;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return -1;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
executeHook(functionName: string, index: number, forward: boolean) {
|
|
141
|
-
const step: any = this.getStep(index)
|
|
142
|
-
// 如果节点定义了钩子方法,执行节点的
|
|
143
|
-
if (step[functionName]) {
|
|
144
|
-
return step[functionName](step, forward)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// 节点没定义,则执行Steps的钩子方法
|
|
148
|
-
if (this[functionName]) {
|
|
149
|
-
return this[functionName](step, forward)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
interface StepOptions {
|
|
155
|
-
id: string
|
|
156
|
-
index: number
|
|
157
|
-
beforeActive: Function
|
|
158
|
-
beforeLeave: Function
|
|
159
|
-
title: string
|
|
160
|
-
description: string
|
|
161
|
-
icon: string
|
|
162
|
-
status: string
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export class Step {
|
|
166
|
-
id: string
|
|
167
|
-
index: number
|
|
168
|
-
beforeActive: Function
|
|
169
|
-
beforeLeave: Function
|
|
170
|
-
title: string
|
|
171
|
-
description: string
|
|
172
|
-
icon: string
|
|
173
|
-
status: string
|
|
174
|
-
constructor(options?: StepOptions) {
|
|
175
|
-
options = options || ({} as StepOptions)
|
|
176
|
-
this.id = options.id
|
|
177
|
-
this.index = options.index
|
|
178
|
-
// 激活前钩子
|
|
179
|
-
this.beforeActive = options.beforeActive
|
|
180
|
-
// 离开前钩子
|
|
181
|
-
this.beforeLeave = options.beforeLeave
|
|
182
|
-
// el-step 属性
|
|
183
|
-
this.title = options.title
|
|
184
|
-
this.description = options.description
|
|
185
|
-
this.icon = options.icon
|
|
186
|
-
this.status = options.status
|
|
187
|
-
}
|
|
188
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import FuTableOperations from "./FuTableOperations.vue";
|
|
2
|
-
import FuTableButton from "./FuTableButton.vue";
|
|
3
|
-
import FuTableMoreButton from "./FuTableMoreButton.vue";
|
|
4
|
-
import type { App } from 'vue'
|
|
5
|
-
|
|
6
|
-
FuTableOperations.install = (app: App): void => {
|
|
7
|
-
app.component(FuTableOperations.name, FuTableOperations);
|
|
8
|
-
app.component(FuTableButton.name, FuTableButton);
|
|
9
|
-
app.component(FuTableMoreButton.name, FuTableMoreButton);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default FuTableOperations;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import measurable from "@/mixins/measurable";
|
|
2
|
-
import {convertToUnit} from "@/tools/utils"
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
name: 'FuVirtualHorizontalScroll',
|
|
6
|
-
mixins: [measurable],
|
|
7
|
-
props: {
|
|
8
|
-
items: {
|
|
9
|
-
type: Array,
|
|
10
|
-
required: true
|
|
11
|
-
},
|
|
12
|
-
itemWidth: {
|
|
13
|
-
type: [Number, String],
|
|
14
|
-
required: true
|
|
15
|
-
},
|
|
16
|
-
buffer: {
|
|
17
|
-
type: [Number, String],
|
|
18
|
-
default: 1
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
data() {
|
|
22
|
-
return {
|
|
23
|
-
scrollLeft: 0,
|
|
24
|
-
first: 0,
|
|
25
|
-
last: 0,
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
watch: {
|
|
29
|
-
width: 'scroll',
|
|
30
|
-
itemWidth: 'scroll',
|
|
31
|
-
},
|
|
32
|
-
computed: {
|
|
33
|
-
intItemWidth() {
|
|
34
|
-
return parseInt(this.itemWidth, 10)
|
|
35
|
-
},
|
|
36
|
-
intBuffer() {
|
|
37
|
-
return parseInt(this.buffer, 10)
|
|
38
|
-
},
|
|
39
|
-
firstToRender({first, intBuffer}) {
|
|
40
|
-
return Math.max(0, first - intBuffer)
|
|
41
|
-
},
|
|
42
|
-
lastToRender({items, last, intBuffer}) {
|
|
43
|
-
return Math.min(items.length, last + intBuffer)
|
|
44
|
-
},
|
|
45
|
-
containerWidth({items, intItemWidth}) {
|
|
46
|
-
return items.length * intItemWidth
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
methods: {
|
|
50
|
-
createChild(item, index) {
|
|
51
|
-
index += this.firstToRender
|
|
52
|
-
const left = convertToUnit(index * this.intItemWidth)
|
|
53
|
-
|
|
54
|
-
let data = {
|
|
55
|
-
staticClass: 'fu-virtual-scroll__item',
|
|
56
|
-
style: {left},
|
|
57
|
-
key: index,
|
|
58
|
-
}
|
|
59
|
-
let children = this.$scopedSlots["default"]({index, item})
|
|
60
|
-
|
|
61
|
-
return this.$createElement('div', data, children)
|
|
62
|
-
},
|
|
63
|
-
getFirst() {
|
|
64
|
-
return Math.floor(this.scrollLeft / this.intItemWidth)
|
|
65
|
-
},
|
|
66
|
-
getLast() {
|
|
67
|
-
const width = parseInt(this.width || 0, 10) || this.$el.clientWidth
|
|
68
|
-
return this.first + Math.ceil(width / this.intItemWidth)
|
|
69
|
-
},
|
|
70
|
-
scroll() {
|
|
71
|
-
this.scrollLeft = this.$el.scrollLeft
|
|
72
|
-
this.first = this.getFirst()
|
|
73
|
-
this.last = this.getLast()
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
render(h) {
|
|
77
|
-
const children = this.items.slice(this.firstToRender, this.lastToRender,).map(this.createChild)
|
|
78
|
-
|
|
79
|
-
const content = h('div', {
|
|
80
|
-
staticClass: 'fu-virtual-scroll__container',
|
|
81
|
-
style: {
|
|
82
|
-
height: this.height || "100%",
|
|
83
|
-
width: convertToUnit(this.containerWidth),
|
|
84
|
-
},
|
|
85
|
-
}, children)
|
|
86
|
-
|
|
87
|
-
return h('div', {
|
|
88
|
-
staticClass: 'fu-virtual-scroll is-horizontal',
|
|
89
|
-
style: this.styles,
|
|
90
|
-
on: {scroll: this.scroll, ...this.$listeners},
|
|
91
|
-
}, [content])
|
|
92
|
-
},
|
|
93
|
-
mounted() {
|
|
94
|
-
this.last = this.getLast()
|
|
95
|
-
},
|
|
96
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import FuVirtualVerticalScroll from "./FuVirtualVerticalScroll";
|
|
2
|
-
import FuVirtualHorizontalScroll from "./FuVirtualHorizontalScroll";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
name: "FuVirtualScroll",
|
|
6
|
-
functional: true,
|
|
7
|
-
render(h, {props, data, children}) {
|
|
8
|
-
const {horizontal} = props
|
|
9
|
-
if (horizontal === undefined || horizontal === false) {
|
|
10
|
-
return h(FuVirtualVerticalScroll, data, children)
|
|
11
|
-
} else {
|
|
12
|
-
return h(FuVirtualHorizontalScroll, data, children)
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import measurable from "@/mixins/measurable";
|
|
2
|
-
import {convertToUnit} from "@/tools/utils"
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
name: 'FuVirtualVerticalScroll',
|
|
6
|
-
mixins: [measurable],
|
|
7
|
-
props: {
|
|
8
|
-
items: {
|
|
9
|
-
type: Array,
|
|
10
|
-
required: true
|
|
11
|
-
},
|
|
12
|
-
itemHeight: {
|
|
13
|
-
type: [Number, String],
|
|
14
|
-
required: true
|
|
15
|
-
},
|
|
16
|
-
buffer: {
|
|
17
|
-
type: [Number, String],
|
|
18
|
-
default: 1
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
data() {
|
|
22
|
-
return {
|
|
23
|
-
scrollTop: 0,
|
|
24
|
-
first: 0,
|
|
25
|
-
last: 0,
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
watch: {
|
|
29
|
-
height: 'scroll',
|
|
30
|
-
itemHeight: 'scroll',
|
|
31
|
-
},
|
|
32
|
-
computed: {
|
|
33
|
-
intItemHeight() {
|
|
34
|
-
return parseInt(this.itemHeight, 10)
|
|
35
|
-
},
|
|
36
|
-
intBuffer() {
|
|
37
|
-
return parseInt(this.buffer, 10)
|
|
38
|
-
},
|
|
39
|
-
firstToRender({first, intBuffer}) {
|
|
40
|
-
return Math.max(0, first - intBuffer)
|
|
41
|
-
},
|
|
42
|
-
lastToRender({items, last, intBuffer}) {
|
|
43
|
-
return Math.min(items.length, last + intBuffer)
|
|
44
|
-
},
|
|
45
|
-
containerHeight({items, intItemHeight}) {
|
|
46
|
-
return items.length * intItemHeight
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
methods: {
|
|
50
|
-
createChild(item, index) {
|
|
51
|
-
index += this.firstToRender
|
|
52
|
-
const top = convertToUnit(index * this.intItemHeight)
|
|
53
|
-
|
|
54
|
-
let data = {
|
|
55
|
-
staticClass: 'fu-virtual-scroll__item',
|
|
56
|
-
style: {top},
|
|
57
|
-
key: index,
|
|
58
|
-
}
|
|
59
|
-
let children = this.$scopedSlots["default"]({index, item})
|
|
60
|
-
|
|
61
|
-
return this.$createElement('div', data, children)
|
|
62
|
-
},
|
|
63
|
-
getFirst() {
|
|
64
|
-
return Math.floor(this.scrollTop / this.intItemHeight)
|
|
65
|
-
},
|
|
66
|
-
getLast() {
|
|
67
|
-
const height = parseInt(this.height || 0, 10) || this.$el.clientHeight
|
|
68
|
-
return this.first + Math.ceil(height / this.intItemHeight)
|
|
69
|
-
},
|
|
70
|
-
scroll() {
|
|
71
|
-
this.scrollTop = this.$el.scrollTop
|
|
72
|
-
this.first = this.getFirst()
|
|
73
|
-
this.last = this.getLast()
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
render(h) {
|
|
77
|
-
const children = this.items.slice(this.firstToRender, this.lastToRender,).map(this.createChild)
|
|
78
|
-
|
|
79
|
-
const content = h('div', {
|
|
80
|
-
staticClass: 'fu-virtual-scroll__container',
|
|
81
|
-
style: {
|
|
82
|
-
height: convertToUnit(this.containerHeight),
|
|
83
|
-
},
|
|
84
|
-
}, children)
|
|
85
|
-
|
|
86
|
-
return h('div', {
|
|
87
|
-
staticClass: 'fu-virtual-scroll',
|
|
88
|
-
style: this.styles,
|
|
89
|
-
on: {scroll: this.scroll, ...this.$listeners},
|
|
90
|
-
}, [content])
|
|
91
|
-
},
|
|
92
|
-
mounted() {
|
|
93
|
-
this.last = this.getLast()
|
|
94
|
-
},
|
|
95
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import FuVirtualScroll from "./FuVirtualScroll";
|
|
2
|
-
import locale from "@/locale";
|
|
3
|
-
|
|
4
|
-
FuVirtualScroll.install = function (Vue, opts = {}) {
|
|
5
|
-
locale.use(opts.locale)
|
|
6
|
-
locale.i18n(opts.i18n)
|
|
7
|
-
Vue.component(FuVirtualScroll.name, FuVirtualScroll)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default FuVirtualScroll
|