@v-c/slider 1.0.1 → 1.0.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.
@@ -1,98 +1,111 @@
1
- import { computed as m } from "vue";
2
- function P(c, a, f, w, C, V) {
3
- const b = m(() => (n) => Math.max(c, Math.min(a, n))).value, g = m(() => (n) => {
4
- if (f !== null) {
5
- const l = c + Math.round((b(n) - c) / f) * f, r = (u) => (String(u).split(".")[1] || "").length, i = Math.max(r(f), r(a), r(c)), t = Number(l.toFixed(i));
1
+ import { computed as F } from "vue";
2
+ function R(c, a, h, S, C, V) {
3
+ const w = F(() => (r) => Math.max(c, Math.min(a, r))).value, g = (r) => {
4
+ if (h !== null) {
5
+ const i = c + Math.round((w(r) - c) / h) * h, l = (n) => (String(n).split(".")[1] || "").length, o = Math.max(l(h), l(a), l(c)), t = Number(i.toFixed(o));
6
6
  return c <= t && t <= a ? t : null;
7
7
  }
8
8
  return null;
9
- }).value, y = m(() => (n) => {
10
- const l = b(n), r = w.map((u) => u.value);
11
- f !== null && r.push(g(n)), r.push(c, a);
12
- let i = r[0], t = a - c;
13
- return r.forEach((u) => {
14
- const h = Math.abs(l - u);
15
- h <= t && (i = u, t = h);
16
- }), i;
17
- }).value, D = (n, l, r, i = "unit") => {
18
- if (typeof l == "number") {
9
+ }, b = (r) => {
10
+ const i = w(r), l = S.map((n) => n && n.value);
11
+ if (h !== null) {
12
+ const n = g(r);
13
+ n !== null && l.push(n);
14
+ }
15
+ l.push(c, a);
16
+ let o = l[0], t = a - c;
17
+ return l.forEach((n) => {
18
+ const f = Math.abs(i - n);
19
+ f <= t && (o = n, t = f);
20
+ }), o;
21
+ }, D = (r, i, l, o = "unit") => {
22
+ if (typeof i == "number") {
19
23
  let t;
20
- const u = n[r], h = u + l;
24
+ const n = r[l], f = n + i;
21
25
  let e = [];
22
- w.forEach((s) => {
23
- e.push(s.value);
24
- }), e.push(c, a), e.push(g(u));
25
- const o = l > 0 ? 1 : -1;
26
- i === "unit" ? e.push(g(u + o * f)) : e.push(g(h)), e = e.filter((s) => s !== null).filter((s) => l < 0 ? s <= u : s >= u), i === "unit" && (e = e.filter((s) => s !== u));
27
- const E = i === "unit" ? u : h;
26
+ S.forEach((u) => {
27
+ e.push(u.value);
28
+ }), e.push(c, a);
29
+ const s = g(n);
30
+ s !== null && e.push(s);
31
+ const m = i > 0 ? 1 : -1;
32
+ if (o === "unit") {
33
+ const u = g(n + m * h);
34
+ u !== null && e.push(u);
35
+ } else {
36
+ const u = g(f);
37
+ u !== null && e.push(u);
38
+ }
39
+ e = e.filter((u) => u !== null).filter((u) => i < 0 ? u <= n : u >= n), o === "unit" && (e = e.filter((u) => u !== n));
40
+ const y = o === "unit" ? n : f;
28
41
  t = e[0];
29
- let N = Math.abs(t - E);
30
- if (e.forEach((s) => {
31
- const S = Math.abs(s - E);
32
- S < N && (t = s, N = S);
42
+ let E = Math.abs(t - y);
43
+ if (e.forEach((u) => {
44
+ const N = Math.abs(u - y);
45
+ N < E && (t = u, E = N);
33
46
  }), t === void 0)
34
- return l < 0 ? c : a;
35
- if (i === "dist")
47
+ return i < 0 ? c : a;
48
+ if (o === "dist")
36
49
  return t;
37
- if (Math.abs(l) > 1) {
38
- const s = [...n];
39
- return s[r] = t, D(s, l - o, r, i);
50
+ if (Math.abs(i) > 1) {
51
+ const u = [...r];
52
+ return u[l] = t, D(u, i - m, l, o);
40
53
  }
41
54
  return t;
42
55
  } else {
43
- if (l === "min")
56
+ if (i === "min")
44
57
  return c;
45
- if (l === "max")
58
+ if (i === "max")
46
59
  return a;
47
60
  }
48
- }, p = (n, l, r, i = "unit") => {
49
- const t = n[r], u = D(n, l, r, i);
61
+ }, p = (r, i, l, o = "unit") => {
62
+ const t = r[l], n = D(r, i, l, o);
50
63
  return {
51
- value: u,
52
- changed: u !== t
64
+ value: n,
65
+ changed: n !== t
53
66
  };
54
- }, M = (n) => V === null && n === 0 || typeof V == "number" && n < V;
55
- return [y, (n, l, r, i = "unit") => {
56
- const t = n.map(y), u = t[r], h = D(t, l, r, i);
57
- if (t[r] = h, C) {
67
+ }, M = (r) => V === null && r === 0 || typeof V == "number" && r < V;
68
+ return [b, (r, i, l, o = "unit") => {
69
+ const t = r.map(b), n = t[l], f = D(t, i, l, o);
70
+ if (t[l] = f, C) {
58
71
  if (typeof V == "number" || V === null) {
59
- for (let e = r + 1; e < t.length; e += 1) {
60
- let o = !0;
61
- for (; M(t[e] - t[e - 1]) && o; )
62
- ({ value: t[e], changed: o } = p(t, 1, e));
72
+ for (let e = l + 1; e < t.length; e += 1) {
73
+ let s = !0;
74
+ for (; M(t[e] - t[e - 1]) && s; )
75
+ ({ value: t[e], changed: s } = p(t, 1, e));
63
76
  }
64
- for (let e = r; e > 0; e -= 1) {
65
- let o = !0;
66
- for (; M(t[e] - t[e - 1]) && o; )
67
- ({ value: t[e - 1], changed: o } = p(t, -1, e - 1));
77
+ for (let e = l; e > 0; e -= 1) {
78
+ let s = !0;
79
+ for (; M(t[e] - t[e - 1]) && s; )
80
+ ({ value: t[e - 1], changed: s } = p(t, -1, e - 1));
68
81
  }
69
82
  for (let e = t.length - 1; e > 0; e -= 1) {
70
- let o = !0;
71
- for (; M(t[e] - t[e - 1]) && o; )
72
- ({ value: t[e - 1], changed: o } = p(t, -1, e - 1));
83
+ let s = !0;
84
+ for (; M(t[e] - t[e - 1]) && s; )
85
+ ({ value: t[e - 1], changed: s } = p(t, -1, e - 1));
73
86
  }
74
87
  for (let e = 0; e < t.length - 1; e += 1) {
75
- let o = !0;
76
- for (; M(t[e + 1] - t[e]) && o; )
77
- ({ value: t[e + 1], changed: o } = p(t, 1, e + 1));
88
+ let s = !0;
89
+ for (; M(t[e + 1] - t[e]) && s; )
90
+ ({ value: t[e + 1], changed: s } = p(t, 1, e + 1));
78
91
  }
79
92
  }
80
93
  } else {
81
94
  const e = V || 0;
82
- r > 0 && t[r - 1] !== u && (t[r] = Math.max(
83
- t[r],
84
- t[r - 1] + e
85
- )), r < t.length - 1 && t[r + 1] !== u && (t[r] = Math.min(
86
- t[r],
87
- t[r + 1] - e
95
+ l > 0 && t[l - 1] !== n && (t[l] = Math.max(
96
+ t[l],
97
+ t[l - 1] + e
98
+ )), l < t.length - 1 && t[l + 1] !== n && (t[l] = Math.min(
99
+ t[l],
100
+ t[l + 1] - e
88
101
  ));
89
102
  }
90
103
  return {
91
- value: t[r],
104
+ value: t[l],
92
105
  values: t
93
106
  };
94
107
  }];
95
108
  }
96
109
  export {
97
- P as default
110
+ R as default
98
111
  };
package/docs/debug.vue CHANGED
@@ -10,7 +10,6 @@ const data = ref()
10
10
 
11
11
  function handleSliderChange(nextValues) {
12
12
  console.log('Change:', nextValues)
13
- data.value = nextValues
14
13
  }
15
14
 
16
15
  function handleSliderChangeComplete(v) {
@@ -41,8 +40,8 @@ function handleSliderChangeComplete(v) {
41
40
 
42
41
  <div style="height: 300px; width: 600px;">
43
42
  <Slider
43
+ v-model:value="data"
44
44
  :disabled="disabled"
45
- :value="data"
46
45
  :step="0.01"
47
46
  :default-value="0.81"
48
47
  :min="0"
package/docs/editable.vue CHANGED
@@ -20,12 +20,11 @@ function onDragChange(info: Parameters<UnstableContextProps['onDragChange']>[0])
20
20
  console.log('Move:', rawValues)
21
21
  }
22
22
 
23
- function handleChange(nextValue: number[]) {
23
+ function handleChange(nextValue: number | number[]) {
24
24
  console.error('Change:', nextValue)
25
- value.value = nextValue
26
25
  }
27
26
 
28
- function handleChangeComplete(nextValue: number[]) {
27
+ function handleChangeComplete(nextValue: number | number[]) {
29
28
  console.log('Complete', nextValue)
30
29
  }
31
30
  </script>
@@ -34,6 +33,7 @@ function handleChangeComplete(nextValue: number[]) {
34
33
  <div>
35
34
  <div :style="style">
36
35
  <Slider
36
+ v-model:value="value"
37
37
  :range="{
38
38
  editable: true,
39
39
  minCount: 1,
@@ -41,7 +41,6 @@ function handleChangeComplete(nextValue: number[]) {
41
41
  }"
42
42
  :min="0"
43
43
  :max="100"
44
- :value="value"
45
44
  :styles="{
46
45
  rail: {
47
46
  background: 'linear-gradient(to right, blue, red)',
package/docs/handle.vue CHANGED
@@ -1,8 +1,14 @@
1
1
  <script setup lang="ts">
2
2
  import type { CSSProperties } from 'vue'
3
3
  import Slider from '@v-c/slider'
4
+ import { ref } from 'vue'
4
5
  import TooltipSlider, { HandleRender } from './TooltipSlider.tsx'
5
6
 
7
+ const data1 = ref(3)
8
+ const data2 = ref(3)
9
+ const data3 = ref(20)
10
+ const data4 = ref([3, 10])
11
+ const data5 = ref(3)
6
12
  const wrapperStyle: CSSProperties = {
7
13
  width: '400px',
8
14
  margin: '50px',
@@ -13,29 +19,29 @@ const wrapperStyle: CSSProperties = {
13
19
  <div>
14
20
  <div :style="wrapperStyle">
15
21
  <p>Slider with custom handle</p>
16
- <Slider :min="0" :max="20" :default-value="3" :handle-render="HandleRender" />
22
+ <Slider v-model:value="data1" :min="0" :max="20" :handle-render="HandleRender" />
17
23
  </div>
18
24
  <div :style="wrapperStyle">
19
25
  <p>Reversed Slider with custom handle</p>
20
- <Slider :min="0" :max="20" reverse :default-value="3" :handle-render="HandleRender"/>
26
+ <Slider v-model:value="data2" :min="0" :max="20" reverse :handle-render="HandleRender" />
21
27
  </div>
22
28
  <div :style="wrapperStyle">
23
29
  <p>Slider with fixed values</p>
24
- <Slider :min="20" :default-value="20" :marks="{ 20: 20, 40: 40, 100: 100 }" :step="null" />
30
+ <Slider v-model:value="data3" :min="20" :marks="{ 20: 20, 40: 40, 100: 100 }" :step="null" />
25
31
  </div>
26
32
  <div :style="wrapperStyle">
27
33
  <p>Range with custom tooltip</p>
28
34
  <TooltipSlider
35
+ v-model:value="data4"
29
36
  range
30
37
  :min="0"
31
38
  :max="20"
32
- :default-value="[3, 10]"
33
39
  :tip-formatter="(value) => (`${value}!`)"
34
40
  />
35
41
  </div>
36
42
  <div :style="wrapperStyle">
37
43
  <p>Keyboard events disabled</p>
38
- <Slider :default-value="3" :keyboard="false" />
44
+ <Slider v-model:value="data5" :keyboard="false" />
39
45
  </div>
40
46
  </div>
41
47
  </template>
package/docs/marks.vue CHANGED
@@ -1,6 +1,16 @@
1
1
  <script setup lang="ts">
2
2
  import type { CSSProperties } from 'vue'
3
3
  import Slider from '@v-c/slider'
4
+ import { ref } from 'vue'
5
+
6
+ const data1 = ref(20)
7
+ const data2 = ref([-10, 0])
8
+ const data3 = ref(20)
9
+ const data4 = ref(20)
10
+ const data5 = ref(20)
11
+ const data6 = ref(20)
12
+ const data7 = ref([20, 25, 35, 40])
13
+ const data8 = ref([20, 40])
4
14
 
5
15
  const style: CSSProperties = {
6
16
  width: '400px',
@@ -21,8 +31,8 @@ const marks = {
21
31
  },
22
32
  }
23
33
 
24
- function log(value) {
25
- console.log(value); //eslint-disable-line
34
+ function log(value: unknown) {
35
+ console.log(value)
26
36
  }
27
37
  </script>
28
38
 
@@ -31,23 +41,32 @@ function log(value) {
31
41
  <div :style="style">
32
42
  <p>Slider with marks, `step=null`</p>
33
43
  <Slider
44
+ v-model:value="data1"
34
45
  :min="-10"
35
46
  :marks="marks"
36
47
  :step="null"
37
- :default-value="20"
38
48
  @change="log"
39
49
  @change-complete="(v) => console.log('AfterChange', v)"
40
- />
50
+ >
51
+ <template #mark="{ point, label }">
52
+ <template v-if="point === 100">
53
+ <strong>{{ label }}</strong>
54
+ </template>
55
+ <template v-else>
56
+ {{ label }}
57
+ </template>
58
+ </template>
59
+ </Slider>
41
60
  </div>
42
61
 
43
62
  <div :style="style">
44
63
  <p>Range Slider with marks, `step=null`, pushable, draggableTrack</p>
45
64
  <Slider
65
+ v-model:value="data2"
46
66
  range
47
67
  :min="-10"
48
68
  :marks="marks"
49
69
  :step="null"
50
- :default-value="[-10, 0]"
51
70
  :allow-cross="false"
52
71
  pushable
53
72
  @change="log"
@@ -57,29 +76,29 @@ function log(value) {
57
76
 
58
77
  <div :style="style">
59
78
  <p>Slider with marks and steps</p>
60
- <Slider dots :min="-10" :marks="marks" :step="10" :default-value="20" @change="log" />
79
+ <Slider v-model:value="data3" dots :min="-10" :marks="marks" :step="10" @change="log" />
61
80
  </div>
62
81
  <div :style="style">
63
82
  <p>Reversed Slider with marks and steps</p>
64
- <Slider dots reverse :min="-10" :marks="marks" :step="10" :default-value="20" @change="log" />
83
+ <Slider v-model:value="data4" dots reverse :min="-10" :marks="marks" :step="10" @change="log" />
65
84
  </div>
66
85
 
67
86
  <div :style="style">
68
87
  <p>Slider with marks, `included=false`</p>
69
- <Slider :min="-10" :marks="marks" :included="false" :default-value="20" />
88
+ <Slider v-model:value="data5" :min="-10" :marks="marks" :included="false" />
70
89
  </div>
71
90
  <div :style="style">
72
91
  <p>Slider with marks and steps, `included=false`</p>
73
- <Slider :min="-10" :marks="marks" :step="10" :included="false" :default-value="20" />
92
+ <Slider v-model:value="data6" :min="-10" :marks="marks" :step="10" :included="false" />
74
93
  </div>
75
94
 
76
95
  <div :style="style">
77
96
  <p>Range with marks</p>
78
- <Slider range :min="-10" :marks="marks" :default-value="[20, 25, 30, 40]" @change="log" />
97
+ <Slider v-model:value="data7" range :min="-10" :marks="marks" @change="log" />
79
98
  </div>
80
99
  <div :style="style">
81
100
  <p>Range with marks and steps</p>
82
- <Slider range :min="-10" :marks="marks" :step="10" :default-value="[20, 40]" @change="log" />
101
+ <Slider v-model:value="data8" range :min="-10" :marks="marks" :step="10" @change="log" />
83
102
  </div>
84
103
  </div>
85
104
  </template>
package/docs/multiple.vue CHANGED
@@ -8,10 +8,6 @@ const style: CSSProperties = {
8
8
  margin: '50px',
9
9
  }
10
10
 
11
- // const NodeWrapper = ({ children }: { children: React.ReactElement }) => {
12
- // return <div>{React.cloneElement(children, {}, <div>TOOLTIP</div>)}</div>;
13
- // };
14
-
15
11
  function NodeWrapper(props: any): VNode {
16
12
  return h('div', {}, [
17
13
  h('slot', {}, { default: () => props.node }),
@@ -28,10 +24,10 @@ const state = ref([0, 50, 80])
28
24
  <div>
29
25
  <div :style="style">
30
26
  <Slider
27
+ v-model:value="state"
31
28
  range
32
29
  :min="0"
33
30
  :max="100"
34
- :value="state"
35
31
  :styles="{
36
32
  tracks: {
37
33
  background: `linear-gradient(to right, blue, red)`,
package/docs/range.vue CHANGED
@@ -3,6 +3,19 @@ import type { CSSProperties } from 'vue'
3
3
  import Slider from '@v-c/slider'
4
4
  import { reactive, ref } from 'vue'
5
5
 
6
+ const data1 = ref([0, 20])
7
+ const data2 = ref([0, 20])
8
+ const data3 = ref([20, 20])
9
+ const data4 = ref([20, 40])
10
+ const data5 = ref([0, 20])
11
+ const data6 = ref([20, 40, 60, 80])
12
+ const data7 = ref([20, 40, 60, 80])
13
+ const data10 = ref([20, 50])
14
+ const data11 = ref([20, 40, 60, 80])
15
+ const data12 = ref([0, 40])
16
+ const data13 = ref([0, 40])
17
+ const data14 = ref([0, 20, 30, 40, 50])
18
+
6
19
  const style: CSSProperties = {
7
20
  width: '400px',
8
21
  margin: '50px',
@@ -82,23 +95,23 @@ function handlePureRenderRangeChange(value: any) {
82
95
  <div>
83
96
  <div :style="style">
84
97
  <p>Basic Range,`allowCross=false`</p>
85
- <Slider range :allow-cross="false" :default-value="[0, 20]" @change="log" />
98
+ <Slider v-model:value="data1" range :allow-cross="false" @change="log" />
86
99
  </div>
87
100
  <div :style="style">
88
101
  <p>Basic reverse Range`</p>
89
- <Slider range :allow-cross="false" :default-value="[0, 20]" reverse @change="log" />
102
+ <Slider v-model:value="data2" range :allow-cross="false" reverse @change="log" />
90
103
  </div>
91
104
  <div :style="style">
92
105
  <p>Basic Range,`step=20` </p>
93
- <Slider range :step="20" :default-value="[20, 20]" @before-change="log" />
106
+ <Slider v-model:value="data3" range :step="20" @before-change="log" />
94
107
  </div>
95
108
  <div :style="style">
96
109
  <p>Basic Range,`step=20, dots` </p>
97
- <Slider range dots :step="20" :default-value="[20, 40]" @change-complete="log" />
110
+ <Slider v-model:value="data4" range dots :step="20" @change-complete="log" />
98
111
  </div>
99
112
  <div :style="style">
100
113
  <p>Basic Range,disabled</p>
101
- <Slider range :allow-cross="false" :default-value="[0, 20]" disabled @change="log" />
114
+ <Slider v-model:value="data5" range :allow-cross="false" disabled @change="log" />
102
115
  </div>
103
116
  <div :style="style">
104
117
  <p>Controlled Range</p>
@@ -125,14 +138,14 @@ function handlePureRenderRangeChange(value: any) {
125
138
  </div>
126
139
  <div :style="style">
127
140
  <p>Multi Range, count=3 and pushable=true</p>
128
- <Slider range :count="3" :default-value="[20, 40, 60, 80]" pushable />
141
+ <Slider v-model:value="data6" range :count="3" pushable />
129
142
  </div>
130
143
  <div :style="style">
131
144
  <p>Multi Range with custom track and handle style and pushable</p>
132
145
  <Slider
146
+ v-model:value="data7"
133
147
  range
134
148
  :count="3"
135
- :default-value="[20, 40, 60, 80]"
136
149
  pushable
137
150
  :track-style="[{ backgroundColor: 'red' }, { backgroundColor: 'green' }]"
138
151
  :handle-style="[{ backgroundColor: 'yellow' }, { backgroundColor: 'gray' }]"
@@ -167,8 +180,8 @@ function handlePureRenderRangeChange(value: any) {
167
180
  <br>
168
181
  <br>
169
182
  <Slider
183
+ v-model:value="data10"
170
184
  range
171
- :default-value="[20, 50]"
172
185
  :min="dynamicBounds.min"
173
186
  :max="dynamicBounds.max"
174
187
  @change="onDynamicSliderChange"
@@ -178,32 +191,32 @@ function handlePureRenderRangeChange(value: any) {
178
191
  <div :style="style">
179
192
  <p>Range as child component</p>
180
193
  <Slider
194
+ v-model:value="data11"
181
195
  range
182
- :default-value="[20, 40, 60, 80]"
183
196
  :allow-cross="false"
184
197
  @change="handlePureRenderRangeChange"
185
198
  />
186
199
  </div>
187
200
  <div :style="style">
188
201
  <p>draggableTrack two points</p>
189
- <Slider :range="{ draggableTrack: true }" :allow-cross="false" :default-value="[0, 40]" @change="log" />
202
+ <Slider v-model:value="data12" :range="{ draggableTrack: true }" :allow-cross="false" @change="log" />
190
203
  </div>
191
204
  <div :style="style">
192
205
  <p>draggableTrack two points(reverse)</p>
193
206
  <Slider
207
+ v-model:value="data13"
194
208
  :range="{ draggableTrack: true }"
195
209
  :allow-cross="false"
196
210
  reverse
197
- :default-value="[0, 40]"
198
211
  @change="log"
199
212
  />
200
213
  </div>
201
214
  <div :style="style">
202
215
  <p>draggableTrack multiple points</p>
203
216
  <Slider
217
+ v-model:value="data14"
204
218
  :range="{ draggableTrack: true }"
205
219
  :allow-cross="false"
206
- :default-value="[0, 20, 30, 40, 50]"
207
220
  @change="log"
208
221
  />
209
222
  </div>
@@ -80,6 +80,22 @@ function onDynamicStepChange(e: any) {
80
80
  dynamicStep.value = +e.target.value || 1
81
81
  }
82
82
 
83
+ // 新增的data refs用于替换default-value
84
+ const data1 = ref(50)
85
+ const data2 = ref(100)
86
+ const data3 = ref(100)
87
+ const data4 = ref(30)
88
+
89
+ const data5 = ref(50)
90
+ const data6 = ref(30)
91
+ const data7 = ref(30)
92
+ const data8 = ref(30)
93
+ const data9 = ref(50)
94
+ const data10 = ref(null)
95
+ const data11 = ref(null)
96
+ const data12 = ref(20)
97
+ const data13 = ref(0)
98
+
83
99
  const labelStyle = { minWidth: '60px', display: 'inline-block' }
84
100
  const inputStyle = { marginBottom: '10px' }
85
101
  </script>
@@ -88,33 +104,33 @@ const inputStyle = { marginBottom: '10px' }
88
104
  <div>
89
105
  <div :style="style">
90
106
  <p>Basic Slider</p>
91
- <Slider @change="log" />
107
+ <Slider v-model:value="data5" @change="log" />
92
108
  </div>
93
109
  <div :style="style">
94
110
  <p>Basic Slider, `startPoint=50`</p>
95
- <Slider :start-point="50" @change="log" />
111
+ <Slider v-model:value="data9" :start-point="50" @change="log" />
96
112
  </div>
97
113
  <div :style="style">
98
114
  <p>Slider reverse</p>
99
- <Slider reverse :min="20" :max="60" @change="log" />
115
+ <Slider v-model:value="data13" reverse :min="20" :max="60" @change="log" />
100
116
  </div>
101
117
  <div :style="style">
102
118
  <p>Basic Slider,`step=20`</p>
103
- <Slider :step="20" :default-value="50" @before-change="log" />
119
+ <Slider v-model:value="data1" :step="20" @before-change="log" />
104
120
  </div>
105
121
  <div :style="style">
106
122
  <p>Basic Slider,`step=20, dots`</p>
107
- <Slider dots :step="20" :default-value="100" @change-complete="log" />
123
+ <Slider v-model:value="data2" dots :step="20" @change-complete="log" />
108
124
  </div>
109
125
  <div :style="style">
110
126
  <p>
111
- Basic Slider,`step=20, dots, dotStyle={"borderColor: 'orange'"}, activeDotStyle=
112
- {"borderColor: 'yellow'"}`
127
+ Basic Slider,`step=20, dots, dotStyle={"borderColor: 'orange'"}, activeDotStyle= {"borderColor: 'yellow'"}`
113
128
  </p>
129
+ />
114
130
  <Slider
131
+ v-model:value="data3"
115
132
  dots
116
133
  :step="20"
117
- :default-value="100"
118
134
  :dot-style="{ borderColor: 'orange' }"
119
135
  :active-dot-style="{ borderColor: 'yellow' }"
120
136
  @change-complete="log"
@@ -133,7 +149,7 @@ const inputStyle = { marginBottom: '10px' }
133
149
  Slider with custom handle and track style.<strong>(old api, will be deprecated)</strong>
134
150
  </p>
135
151
  <Slider
136
- :default-value="30"
152
+ v-model:value="data4"
137
153
  :rail-style="{ backgroundColor: 'red', height: 10 }"
138
154
  :track-style="{ backgroundColor: 'blue', height: 10 }"
139
155
  :handle-style="{
@@ -151,7 +167,7 @@ const inputStyle = { marginBottom: '10px' }
151
167
  Slider with custom handle and track style.<strong>(The recommended new api)</strong>
152
168
  </p>
153
169
  <Slider
154
- :default-value="30"
170
+ v-model:value="data6"
155
171
  :track-style="{ backgroundColor: 'blue', height: 10 }"
156
172
  :handle-style="{
157
173
  borderColor: 'blue',
@@ -170,7 +186,7 @@ const inputStyle = { marginBottom: '10px' }
170
186
  <strong>(The recommended new api)</strong>
171
187
  </p>
172
188
  <Slider
173
- :default-value="30"
189
+ v-model:value="data4"
174
190
  :track-style="{ backgroundColor: 'blue', height: 10 }"
175
191
  reverse
176
192
  :handle-style="{
@@ -186,16 +202,16 @@ const inputStyle = { marginBottom: '10px' }
186
202
  </div>
187
203
  <div :style="style">
188
204
  <p>Basic Slider, disabled</p>
189
- <Slider disabled @change="log" />
205
+ <Slider v-model:value="data12" disabled @change="log" />
190
206
  </div>
191
207
  <div :style="style">
192
208
  <p>Controlled Slider</p>
193
- <Slider :value="50" />
209
+ <Slider v-model:value="data5" />
194
210
  </div>
195
211
  <div :style="style">
196
212
  <p>Customized Slider</p>
197
213
  <Slider
198
- :value="customizedValue"
214
+ v-model:value="customizedValue"
199
215
  @change="onCustomizedSliderChange"
200
216
  @change-complete="onCustomizedSliderAfterChange"
201
217
  />
@@ -204,7 +220,7 @@ const inputStyle = { marginBottom: '10px' }
204
220
  <p>Slider with null value and reset button</p>
205
221
  <div>
206
222
  <Slider
207
- :value="nullableSliderValue"
223
+ v-model:value="nullableSliderValue"
208
224
  @change="onNullableSliderChange"
209
225
  @change-complete="onNullableSliderAfterChange"
210
226
  />
@@ -216,7 +232,7 @@ const inputStyle = { marginBottom: '10px' }
216
232
  <div :style="style">
217
233
  <p>Range Slider with null value and reset button</p>
218
234
  <div>
219
- <Slider range :value="nullableRangeValue" @change="setNullableRangeValue" />
235
+ <Slider v-model:value="nullableRangeValue" range @change="setNullableRangeValue" />
220
236
  <button type="button" @click="resetNullableRange">
221
237
  Reset
222
238
  </button>
@@ -255,7 +271,7 @@ const inputStyle = { marginBottom: '10px' }
255
271
  <br>
256
272
  <br>
257
273
  <Slider
258
- :value="dynamicValue"
274
+ v-model:value="dynamicValue"
259
275
  :min="dynamicMin"
260
276
  :max="dynamicMax"
261
277
  :step="dynamicStep"