@veritree/ui 0.85.0 → 0.86.0
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/package.json
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="range-slider" :style="style">
|
|
3
|
+
<input
|
|
4
|
+
v-model.number="computedValue"
|
|
5
|
+
:min="min"
|
|
6
|
+
:max="max"
|
|
7
|
+
:step="step"
|
|
8
|
+
type="range"
|
|
9
|
+
@input="onInput"
|
|
10
|
+
@change="onChange"
|
|
11
|
+
/>
|
|
12
|
+
<div class="range-slider-track" aria-hidden />
|
|
13
|
+
<div ref="thumb" class="range-slider-thumb" aria-hidden />
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
export default {
|
|
19
|
+
name: 'VTInputRanger',
|
|
20
|
+
|
|
21
|
+
model: {
|
|
22
|
+
prop: 'value',
|
|
23
|
+
event: 'input',
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
props: {
|
|
27
|
+
value: {
|
|
28
|
+
type: [Number, String],
|
|
29
|
+
default: 0,
|
|
30
|
+
},
|
|
31
|
+
min: {
|
|
32
|
+
type: Number,
|
|
33
|
+
default: 0,
|
|
34
|
+
},
|
|
35
|
+
max: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: 100,
|
|
38
|
+
},
|
|
39
|
+
step: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 1,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
data() {
|
|
46
|
+
return {
|
|
47
|
+
thumbSize: null,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
computed: {
|
|
52
|
+
computedValue: {
|
|
53
|
+
get() {
|
|
54
|
+
return Number(this.value);
|
|
55
|
+
},
|
|
56
|
+
set(value) {
|
|
57
|
+
this.$emit('input', value);
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
percentage() {
|
|
62
|
+
return ((this.computedValue - this.min) / (this.max - this.min)) * 100;
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
style() {
|
|
66
|
+
return {
|
|
67
|
+
'--value': `${this.percentage}%`,
|
|
68
|
+
'--thumb-left-position': `calc(${this.percentage}% - ${this.thumbSize * (this.percentage / 100)}px)`,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
mounted() {
|
|
74
|
+
this.thumbSize = 20;
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
methods: {
|
|
78
|
+
onInput(e) {
|
|
79
|
+
this.computedValue = e.target.value;
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
onChange(e) {
|
|
83
|
+
console.log(e.target);
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
</script>
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<transition
|
|
3
|
-
enter-active-class="duration-300 ease-out"
|
|
4
|
-
enter-class="transform opacity-0"
|
|
5
|
-
enter-to-class="opacity-100"
|
|
6
|
-
leave-active-class="duration-300 ease-in"
|
|
7
|
-
leave-class="opacity-100"
|
|
8
|
-
leave-to-class="transform opacity-0"
|
|
9
|
-
@after-enter="afterEnter"
|
|
10
|
-
@after-leave="afterLeave"
|
|
11
|
-
>
|
|
12
|
-
<div
|
|
13
|
-
v-if="visible"
|
|
14
|
-
class="bg-fd-700/75 fixed inset-0 z-50 flex flex-col justify-center"
|
|
15
|
-
tabindex="-1"
|
|
16
|
-
@keyup.esc="close"
|
|
17
|
-
@click="close"
|
|
18
|
-
>
|
|
19
|
-
<div
|
|
20
|
-
class="relative mx-auto flex max-w-lg flex-col justify-center rounded bg-white"
|
|
21
|
-
@click.stop
|
|
22
|
-
>
|
|
23
|
-
<div class="absolute right-4 top-4">
|
|
24
|
-
<VTButton variant="icon" @click.prevent="close"
|
|
25
|
-
><IconClose class="h-4 w-4"
|
|
26
|
-
/></VTButton>
|
|
27
|
-
</div>
|
|
28
|
-
<slot></slot>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
</transition>
|
|
32
|
-
</template>
|
|
33
|
-
|
|
34
|
-
<script>
|
|
35
|
-
import { IconClose } from '@veritree/icons';
|
|
36
|
-
import VTButton from '../Button/VTButton.vue';
|
|
37
|
-
|
|
38
|
-
export default {
|
|
39
|
-
name: 'VTModal',
|
|
40
|
-
|
|
41
|
-
components: { IconClose, VTButton },
|
|
42
|
-
|
|
43
|
-
model: {
|
|
44
|
-
prop: 'visible',
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
props: {
|
|
48
|
-
visible: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: false,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
methods: {
|
|
55
|
-
close() {
|
|
56
|
-
this.$emit('input', false);
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
afterEnter() {
|
|
60
|
-
this.$emit('shown');
|
|
61
|
-
this.$nextTick(() => this.$el.focus());
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
afterLeave() {
|
|
65
|
-
this.$emit('hidden');
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
</script>
|