1 | import { __decorate } from "tslib";
|
2 | import { Component, Prop, Vue } from 'vue-property-decorator';
|
3 | import './styles/dot.scss';
|
4 | let VueSliderDot = (() => {
|
5 | let VueSliderDot = class VueSliderDot extends Vue {
|
6 | get dotClasses() {
|
7 | return [
|
8 | 'vue-slider-dot',
|
9 | {
|
10 | 'vue-slider-dot-hover': this.tooltip === 'hover' || this.tooltip === 'active',
|
11 | 'vue-slider-dot-disabled': this.disabled,
|
12 | 'vue-slider-dot-focus': this.focus,
|
13 | },
|
14 | ];
|
15 | }
|
16 | get handleClasses() {
|
17 | return [
|
18 | 'vue-slider-dot-handle',
|
19 | {
|
20 | 'vue-slider-dot-handle-disabled': this.disabled,
|
21 | 'vue-slider-dot-handle-focus': this.focus,
|
22 | },
|
23 | ];
|
24 | }
|
25 | get tooltipClasses() {
|
26 | return [
|
27 | 'vue-slider-dot-tooltip',
|
28 | [`vue-slider-dot-tooltip-${this.tooltipPlacement}`],
|
29 | {
|
30 | 'vue-slider-dot-tooltip-show': this.showTooltip,
|
31 | },
|
32 | ];
|
33 | }
|
34 | get tooltipInnerClasses() {
|
35 | return [
|
36 | 'vue-slider-dot-tooltip-inner',
|
37 | [`vue-slider-dot-tooltip-inner-${this.tooltipPlacement}`],
|
38 | {
|
39 | 'vue-slider-dot-tooltip-inner-disabled': this.disabled,
|
40 | 'vue-slider-dot-tooltip-inner-focus': this.focus,
|
41 | },
|
42 | ];
|
43 | }
|
44 | get showTooltip() {
|
45 | switch (this.tooltip) {
|
46 | case 'always':
|
47 | return true;
|
48 | case 'none':
|
49 | return false;
|
50 | case 'focus':
|
51 | case 'active':
|
52 | return !!this.focus;
|
53 | default:
|
54 | return false;
|
55 | }
|
56 | }
|
57 | get tooltipValue() {
|
58 | if (this.tooltipFormatter) {
|
59 | return typeof this.tooltipFormatter === 'string'
|
60 | ? this.tooltipFormatter.replace(/\{value\}/, String(this.value))
|
61 | : this.tooltipFormatter(this.value);
|
62 | }
|
63 | else {
|
64 | return this.value;
|
65 | }
|
66 | }
|
67 | dragStart(e) {
|
68 | if (this.disabled) {
|
69 | return false;
|
70 | }
|
71 | this.$emit('drag-start');
|
72 | }
|
73 | render() {
|
74 | return (<div ref="dot" class={this.dotClasses} aria-valuetext={typeof this.tooltipValue === 'number' ? this.tooltipValue.toString() : this.tooltipValue} onMousedown={this.dragStart} onTouchstart={this.dragStart}>
|
75 | {this.$slots.dot || <div class={this.handleClasses} style={this.dotStyle}/>}
|
76 | {this.tooltip !== 'none' ? (<div class={this.tooltipClasses}>
|
77 | {this.$slots.tooltip || (<div class={this.tooltipInnerClasses} style={this.tooltipStyle}>
|
78 | <span class={'vue-slider-dot-tooltip-text'}>{this.tooltipValue}</span>
|
79 | </div>)}
|
80 | </div>) : null}
|
81 | </div>);
|
82 | }
|
83 | };
|
84 | __decorate([
|
85 | Prop({ default: 0 })
|
86 | ], VueSliderDot.prototype, "value", void 0);
|
87 | __decorate([
|
88 | Prop()
|
89 | ], VueSliderDot.prototype, "tooltip", void 0);
|
90 | __decorate([
|
91 | Prop()
|
92 | ], VueSliderDot.prototype, "dotStyle", void 0);
|
93 | __decorate([
|
94 | Prop()
|
95 | ], VueSliderDot.prototype, "tooltipStyle", void 0);
|
96 | __decorate([
|
97 | Prop({
|
98 | type: String,
|
99 | validator: (val) => ['top', 'right', 'bottom', 'left'].indexOf(val) > -1,
|
100 | required: true,
|
101 | })
|
102 | ], VueSliderDot.prototype, "tooltipPlacement", void 0);
|
103 | __decorate([
|
104 | Prop({ type: [String, Function] })
|
105 | ], VueSliderDot.prototype, "tooltipFormatter", void 0);
|
106 | __decorate([
|
107 | Prop({ type: Boolean, default: false })
|
108 | ], VueSliderDot.prototype, "focus", void 0);
|
109 | __decorate([
|
110 | Prop({ default: false })
|
111 | ], VueSliderDot.prototype, "disabled", void 0);
|
112 | VueSliderDot = __decorate([
|
113 | Component({ name: 'VueSliderDot' })
|
114 | ], VueSliderDot);
|
115 | return VueSliderDot;
|
116 | })();
|
117 | export default VueSliderDot;
|
118 | //# sourceMappingURL=vue-slider-dot.jsx.map |
\ | No newline at end of file |