@v-c/slider 1.0.2 → 1.0.4

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.
Files changed (76) hide show
  1. package/dist/Handles/Handle.cjs +195 -1
  2. package/dist/Handles/Handle.d.ts +17 -5
  3. package/dist/Handles/Handle.js +191 -202
  4. package/dist/Handles/index.cjs +108 -1
  5. package/dist/Handles/index.d.ts +20 -4
  6. package/dist/Handles/index.js +105 -116
  7. package/dist/Marks/Mark.cjs +51 -1
  8. package/dist/Marks/Mark.d.ts +2 -2
  9. package/dist/Marks/Mark.js +48 -39
  10. package/dist/Marks/index.cjs +39 -1
  11. package/dist/Marks/index.d.ts +2 -2
  12. package/dist/Marks/index.js +36 -32
  13. package/dist/Slider.cjs +569 -1
  14. package/dist/Slider.d.ts +60 -263
  15. package/dist/Slider.js +563 -352
  16. package/dist/Steps/Dot.cjs +52 -1
  17. package/dist/Steps/Dot.d.ts +2 -2
  18. package/dist/Steps/Dot.js +49 -38
  19. package/dist/Steps/index.cjs +64 -1
  20. package/dist/Steps/index.d.ts +2 -2
  21. package/dist/Steps/index.js +61 -41
  22. package/dist/Tracks/Track.cjs +74 -1
  23. package/dist/Tracks/Track.js +70 -81
  24. package/dist/Tracks/index.cjs +70 -1
  25. package/dist/Tracks/index.js +66 -82
  26. package/dist/_virtual/rolldown_runtime.cjs +21 -0
  27. package/dist/context.cjs +39 -1
  28. package/dist/context.d.ts +13 -7
  29. package/dist/context.js +29 -24
  30. package/dist/hooks/useDrag.cjs +160 -1
  31. package/dist/hooks/useDrag.d.ts +2 -2
  32. package/dist/hooks/useDrag.js +155 -86
  33. package/dist/hooks/useOffset.cjs +124 -1
  34. package/dist/hooks/useOffset.d.ts +2 -1
  35. package/dist/hooks/useOffset.js +122 -97
  36. package/dist/hooks/useRange.cjs +21 -1
  37. package/dist/hooks/useRange.js +18 -9
  38. package/dist/index.cjs +6 -1
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.js +4 -4
  41. package/dist/interface.cjs +0 -1
  42. package/dist/interface.js +0 -1
  43. package/dist/util.cjs +32 -1
  44. package/dist/util.js +27 -26
  45. package/package.json +18 -10
  46. package/docs/TooltipSlider.tsx +0 -94
  47. package/docs/assets/anim.less +0 -63
  48. package/docs/assets/bootstrap.less +0 -163
  49. package/docs/assets/index.less +0 -337
  50. package/docs/debug.vue +0 -60
  51. package/docs/editable.vue +0 -59
  52. package/docs/handle.vue +0 -45
  53. package/docs/marks.vue +0 -94
  54. package/docs/multiple.vue +0 -54
  55. package/docs/range.vue +0 -211
  56. package/docs/slider.stories.vue +0 -45
  57. package/docs/sliderDemo.vue +0 -267
  58. package/docs/vertical.vue +0 -122
  59. package/src/Handles/Handle.tsx +0 -223
  60. package/src/Handles/index.tsx +0 -124
  61. package/src/Marks/Mark.tsx +0 -40
  62. package/src/Marks/index.tsx +0 -40
  63. package/src/Slider.tsx +0 -593
  64. package/src/Steps/Dot.tsx +0 -40
  65. package/src/Steps/index.tsx +0 -54
  66. package/src/Tracks/Track.tsx +0 -89
  67. package/src/Tracks/index.tsx +0 -92
  68. package/src/context.ts +0 -65
  69. package/src/hooks/useDrag.ts +0 -243
  70. package/src/hooks/useOffset.ts +0 -264
  71. package/src/hooks/useRange.ts +0 -24
  72. package/src/index.ts +0 -8
  73. package/src/interface.ts +0 -17
  74. package/src/util.ts +0 -41
  75. package/vite.config.ts +0 -18
  76. package/vitest.config.ts +0 -11
@@ -1,337 +0,0 @@
1
-
2
- @prefixClass: vc-slider;
3
-
4
- @disabledColor: #ccc;
5
- @border-radius-base: 6px;
6
- @primary-color: #2db7f5;
7
- @tooltip-color: #fff;
8
- @tooltip-bg: tint(#666, 4%);
9
- @tooltip-arrow-width: 4px;
10
- @tooltip-distance: @tooltip-arrow-width+4;
11
- @tooltip-arrow-color: @tooltip-bg;
12
- @ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);
13
- @ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
14
-
15
- .borderBox() {
16
- box-sizing: border-box;
17
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0); // remove tap highlight color for mobile safari
18
-
19
- * {
20
- box-sizing: border-box;
21
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0); // remove tap highlight color for mobile safari
22
- }
23
- }
24
-
25
- .@{prefixClass} {
26
- position: relative;
27
- width: 100%;
28
- height: 14px;
29
- padding: 5px 0;
30
- border-radius: @border-radius-base;
31
- touch-action: none;
32
- .borderBox();
33
-
34
- &-rail {
35
- position: absolute;
36
- width: 100%;
37
- height: 4px;
38
- background-color: #e9e9e9;
39
- border-radius: @border-radius-base;
40
- }
41
-
42
- &-track,
43
- &-tracks {
44
- position: absolute;
45
- height: 4px;
46
- background-color: tint(@primary-color, 60%);
47
- border-radius: @border-radius-base;
48
- }
49
-
50
- &-track-draggable {
51
- z-index: 1;
52
- box-sizing: content-box;
53
- background-clip: content-box;
54
- border-top: 5px solid rgba(0, 0, 0, 0);
55
- border-bottom: 5px solid rgba(0, 0, 0, 0);
56
- transform: translateY(-5px);
57
- }
58
-
59
- &-handle {
60
- position: absolute;
61
- z-index: 1;
62
- width: 14px;
63
- height: 14px;
64
- margin-top: -5px;
65
- background-color: #fff;
66
- border: solid 2px tint(@primary-color, 50%);
67
- border-radius: 50%;
68
- cursor: pointer;
69
- cursor: -webkit-grab;
70
- cursor: grab;
71
- opacity: 0.8;
72
- user-select: none;
73
- touch-action: pan-x;
74
-
75
- &-dragging&-dragging&-dragging {
76
- border-color: tint(@primary-color, 20%);
77
- box-shadow: 0 0 0 5px tint(@primary-color, 50%);
78
-
79
- &-delete {
80
- opacity: 0;
81
- }
82
- }
83
-
84
- &:focus {
85
- outline: none;
86
- box-shadow: none;
87
- }
88
-
89
- &:focus-visible {
90
- border-color: @primary-color;
91
- box-shadow: 0 0 0 3px tint(@primary-color, 50%);
92
- }
93
-
94
- &-click-focused:focus {
95
- border-color: tint(@primary-color, 50%);
96
- box-shadow: unset;
97
- }
98
-
99
- &:hover {
100
- border-color: tint(@primary-color, 20%);
101
- }
102
-
103
- &:active {
104
- border-color: tint(@primary-color, 20%);
105
- box-shadow: 0 0 5px tint(@primary-color, 20%);
106
- cursor: -webkit-grabbing;
107
- cursor: grabbing;
108
- }
109
- }
110
-
111
- &-mark {
112
- position: absolute;
113
- top: 18px;
114
- left: 0;
115
- width: 100%;
116
- font-size: 12px;
117
- }
118
-
119
- &-mark-text {
120
- position: absolute;
121
- display: inline-block;
122
- color: #999;
123
- text-align: center;
124
- vertical-align: middle;
125
- cursor: pointer;
126
-
127
- &-active {
128
- color: #666;
129
- }
130
- }
131
-
132
- &-step {
133
- position: absolute;
134
- width: 100%;
135
- height: 4px;
136
- background: transparent;
137
- }
138
-
139
- &-dot {
140
- position: absolute;
141
- bottom: -2px;
142
- width: 8px;
143
- height: 8px;
144
- vertical-align: middle;
145
- background-color: #fff;
146
- border: 2px solid #e9e9e9;
147
- border-radius: 50%;
148
- cursor: pointer;
149
- &-active {
150
- border-color: tint(@primary-color, 50%);
151
- }
152
- &-reverse {
153
- margin-right: -4px;
154
- }
155
- }
156
-
157
- &-disabled {
158
- background-color: #e9e9e9;
159
-
160
- .@{prefixClass}-track {
161
- background-color: @disabledColor;
162
- }
163
-
164
- .@{prefixClass}-handle,
165
- .@{prefixClass}-dot {
166
- background-color: #fff;
167
- border-color: @disabledColor;
168
- box-shadow: none;
169
- cursor: not-allowed;
170
- }
171
-
172
- .@{prefixClass}-mark-text,
173
- .@{prefixClass}-dot {
174
- cursor: not-allowed !important;
175
- }
176
- }
177
- }
178
-
179
- .@{prefixClass}-vertical {
180
- width: 14px;
181
- height: 100%;
182
- padding: 0 5px;
183
-
184
- .@{prefixClass} {
185
- &-rail {
186
- width: 4px;
187
- height: 100%;
188
- }
189
-
190
- &-track {
191
- bottom: 0;
192
- left: 5px;
193
- width: 4px;
194
- }
195
-
196
- &-track-draggable {
197
- border-top: 0;
198
- border-right: 5px solid rgba(0, 0, 0, 0);
199
- border-bottom: 0;
200
- border-left: 5px solid rgba(0, 0, 0, 0);
201
- transform: translateX(-5px);
202
- }
203
-
204
- &-handle {
205
- position: absolute;
206
- z-index: 1;
207
- margin-top: 0;
208
- margin-left: -5px;
209
- touch-action: pan-y;
210
- }
211
-
212
- &-mark {
213
- top: 0;
214
- left: 18px;
215
- height: 100%;
216
- }
217
-
218
- &-step {
219
- width: 4px;
220
- height: 100%;
221
- }
222
-
223
- &-dot {
224
- margin-left: -2px;
225
- }
226
- }
227
- }
228
-
229
- .motion-common() {
230
- display: block !important;
231
- animation-duration: 0.3s;
232
- animation-fill-mode: both;
233
- }
234
-
235
- .make-motion(@className, @keyframeName) {
236
- .@{className}-enter,
237
- .@{className}-appear {
238
- .motion-common();
239
- animation-play-state: paused;
240
- }
241
- .@{className}-leave {
242
- .motion-common();
243
- animation-play-state: paused;
244
- }
245
- .@{className}-enter.@{className}-enter-active,
246
- .@{className}-appear.@{className}-appear-active {
247
- animation-name: ~'@{keyframeName}In';
248
- animation-play-state: running;
249
- }
250
- .@{className}-leave.@{className}-leave-active {
251
- animation-name: ~'@{keyframeName}Out';
252
- animation-play-state: running;
253
- }
254
- }
255
- .zoom-motion(@className, @keyframeName) {
256
- .make-motion(@className, @keyframeName);
257
- .@{className}-enter,
258
- .@{className}-appear {
259
- transform: scale(0, 0); // need this by yiminghe
260
- animation-timing-function: @ease-out-quint;
261
- }
262
- .@{className}-leave {
263
- animation-timing-function: @ease-in-quint;
264
- }
265
- }
266
- .zoom-motion(rc-slider-tooltip-zoom-down, rcSliderTooltipZoomDown);
267
-
268
- @keyframes rcSliderTooltipZoomDownIn {
269
- 0% {
270
- transform: scale(0, 0);
271
- transform-origin: 50% 100%;
272
- opacity: 0;
273
- }
274
- 100% {
275
- transform: scale(1, 1);
276
- transform-origin: 50% 100%;
277
- }
278
- }
279
-
280
- @keyframes rcSliderTooltipZoomDownOut {
281
- 0% {
282
- transform: scale(1, 1);
283
- transform-origin: 50% 100%;
284
- }
285
- 100% {
286
- transform: scale(0, 0);
287
- transform-origin: 50% 100%;
288
- opacity: 0;
289
- }
290
- }
291
-
292
- .@{prefixClass}-tooltip {
293
- position: absolute;
294
- top: -9999px;
295
- left: -9999px;
296
- visibility: visible;
297
-
298
- .borderBox();
299
-
300
- &-hidden {
301
- display: none;
302
- }
303
-
304
- &-placement-top {
305
- padding: @tooltip-arrow-width 0 @tooltip-distance 0;
306
- }
307
-
308
- &-inner {
309
- min-width: 24px;
310
- height: 24px;
311
- padding: 6px 2px;
312
- color: @tooltip-color;
313
- font-size: 12px;
314
- line-height: 1;
315
- text-align: center;
316
- text-decoration: none;
317
- background-color: @tooltip-bg;
318
- border-radius: @border-radius-base;
319
- box-shadow: 0 0 4px #d9d9d9;
320
- }
321
-
322
- &-arrow {
323
- position: absolute;
324
- width: 0;
325
- height: 0;
326
- border-color: transparent;
327
- border-style: solid;
328
- }
329
-
330
- &-placement-top &-arrow {
331
- bottom: @tooltip-distance - @tooltip-arrow-width;
332
- left: 50%;
333
- margin-left: -@tooltip-arrow-width;
334
- border-width: @tooltip-arrow-width @tooltip-arrow-width 0;
335
- border-top-color: @tooltip-arrow-color;
336
- }
337
- }
package/docs/debug.vue DELETED
@@ -1,60 +0,0 @@
1
- <script setup>
2
- import { ref } from 'vue'
3
- import Slider from '../src'
4
-
5
- const disabled = ref(false)
6
- const range = ref(false)
7
- const reverse = ref(false)
8
- const vertical = ref(false)
9
- const data = ref()
10
-
11
- function handleSliderChange(nextValues) {
12
- console.log('Change:', nextValues)
13
- data.value = nextValues
14
- }
15
-
16
- function handleSliderChangeComplete(v) {
17
- console.log('AfterChange:', v)
18
- }
19
- </script>
20
-
21
- <template>
22
- <div>
23
- <div>
24
- <label>
25
- <input v-model="disabled" type="checkbox">
26
- Disabled
27
- </label>
28
- <label>
29
- <input v-model="range" type="checkbox">
30
- Range
31
- </label>
32
- <label>
33
- <input v-model="reverse" type="checkbox">
34
- Reverse
35
- </label>
36
- <label>
37
- <input v-model="vertical" type="checkbox">
38
- Vertical
39
- </label>
40
- </div>
41
-
42
- <div style="height: 300px; width: 600px;">
43
- <Slider
44
- :disabled="disabled"
45
- :value="data"
46
- :step="0.01"
47
- :default-value="0.81"
48
- :min="0"
49
- :max="1"
50
- :vertical="vertical"
51
- :reverse="reverse"
52
- @change="handleSliderChange"
53
- @change-complete="handleSliderChangeComplete"
54
- />
55
- </div>
56
- </div>
57
- </template>
58
-
59
- <style scoped>
60
- </style>
package/docs/editable.vue DELETED
@@ -1,59 +0,0 @@
1
- <script setup lang="ts">
2
- import type { UnstableContextProps } from '../src/context'
3
- import { ref } from 'vue'
4
- import Slider from '../src'
5
-
6
- const style = {
7
- width: '400px',
8
- margin: '50px',
9
- }
10
-
11
- const value = ref([0, 50, 80])
12
-
13
- function onDragStart(info: Parameters<UnstableContextProps['onDragStart']>[0]) {
14
- const { rawValues } = info
15
- console.log('Start:', rawValues)
16
- }
17
-
18
- function onDragChange(info: Parameters<UnstableContextProps['onDragChange']>[0]) {
19
- const { rawValues } = info
20
- console.log('Move:', rawValues)
21
- }
22
-
23
- function handleChange(nextValue: number[]) {
24
- console.error('Change:', nextValue)
25
- value.value = nextValue
26
- }
27
-
28
- function handleChangeComplete(nextValue: number[]) {
29
- console.log('Complete', nextValue)
30
- }
31
- </script>
32
-
33
- <template>
34
- <div>
35
- <div :style="style">
36
- <Slider
37
- :range="{
38
- editable: true,
39
- minCount: 1,
40
- maxCount: 4,
41
- }"
42
- :min="0"
43
- :max="100"
44
- :value="value"
45
- :styles="{
46
- rail: {
47
- background: 'linear-gradient(to right, blue, red)',
48
- },
49
- track: {
50
- background: 'orange',
51
- },
52
- }"
53
- @change="handleChange"
54
- @change-complete="handleChangeComplete"
55
- />
56
- </div>
57
- <p>Here is a word that drag should not select it</p>
58
- </div>
59
- </template>
package/docs/handle.vue DELETED
@@ -1,45 +0,0 @@
1
- <script setup lang="ts">
2
- import type { CSSProperties } from 'vue'
3
- import Slider from '@v-c/slider'
4
- import TooltipSlider, { HandleRender } from './TooltipSlider.tsx'
5
-
6
- const wrapperStyle: CSSProperties = {
7
- width: '400px',
8
- margin: '50px',
9
- }
10
- </script>
11
-
12
- <template>
13
- <div>
14
- <div :style="wrapperStyle">
15
- <p>Slider with custom handle</p>
16
- <Slider :min="0" :max="20" :default-value="3" :handle-render="HandleRender" />
17
- </div>
18
- <div :style="wrapperStyle">
19
- <p>Reversed Slider with custom handle</p>
20
- <Slider :min="0" :max="20" reverse :default-value="3" :handle-render="HandleRender"/>
21
- </div>
22
- <div :style="wrapperStyle">
23
- <p>Slider with fixed values</p>
24
- <Slider :min="20" :default-value="20" :marks="{ 20: 20, 40: 40, 100: 100 }" :step="null" />
25
- </div>
26
- <div :style="wrapperStyle">
27
- <p>Range with custom tooltip</p>
28
- <TooltipSlider
29
- range
30
- :min="0"
31
- :max="20"
32
- :default-value="[3, 10]"
33
- :tip-formatter="(value) => (`${value}!`)"
34
- />
35
- </div>
36
- <div :style="wrapperStyle">
37
- <p>Keyboard events disabled</p>
38
- <Slider :default-value="3" :keyboard="false" />
39
- </div>
40
- </div>
41
- </template>
42
-
43
- <style scoped>
44
-
45
- </style>
package/docs/marks.vue DELETED
@@ -1,94 +0,0 @@
1
- <script setup lang="ts">
2
- import type { CSSProperties } from 'vue'
3
- import Slider from '@v-c/slider'
4
-
5
- const style: CSSProperties = {
6
- width: '400px',
7
- margin: '50px',
8
- }
9
-
10
- const marks = {
11
- '-10': '-10°C',
12
- '0': '0°C',
13
- '26': '26°C',
14
- '37': '37°C',
15
- '50': '50°C',
16
- '100': {
17
- style: {
18
- color: 'red',
19
- },
20
- label: '100°C',
21
- },
22
- }
23
-
24
- function log(value) {
25
- console.log(value); //eslint-disable-line
26
- }
27
- </script>
28
-
29
- <template>
30
- <div>
31
- <div :style="style">
32
- <p>Slider with marks, `step=null`</p>
33
- <Slider
34
- :min="-10"
35
- :marks="marks"
36
- :step="null"
37
- :default-value="20"
38
- @change="log"
39
- @change-complete="(v) => console.log('AfterChange', v)"
40
- >
41
- <template #mark="{ point, label }">
42
- <template v-if="point === 100">
43
- <strong>{{ label }}</strong>
44
- </template>
45
- <template v-else>
46
- {{ label }}
47
- </template>
48
- </template>
49
- </Slider>
50
- </div>
51
-
52
- <div :style="style">
53
- <p>Range Slider with marks, `step=null`, pushable, draggableTrack</p>
54
- <Slider
55
- range
56
- :min="-10"
57
- :marks="marks"
58
- :step="null"
59
- :default-value="[-10, 0]"
60
- :allow-cross="false"
61
- pushable
62
- @change="log"
63
- @change-complete="(v) => console.log('AfterChange', v)"
64
- />
65
- </div>
66
-
67
- <div :style="style">
68
- <p>Slider with marks and steps</p>
69
- <Slider dots :min="-10" :marks="marks" :step="10" :default-value="20" @change="log" />
70
- </div>
71
- <div :style="style">
72
- <p>Reversed Slider with marks and steps</p>
73
- <Slider dots reverse :min="-10" :marks="marks" :step="10" :default-value="20" @change="log" />
74
- </div>
75
-
76
- <div :style="style">
77
- <p>Slider with marks, `included=false`</p>
78
- <Slider :min="-10" :marks="marks" :included="false" :default-value="20" />
79
- </div>
80
- <div :style="style">
81
- <p>Slider with marks and steps, `included=false`</p>
82
- <Slider :min="-10" :marks="marks" :step="10" :included="false" :default-value="20" />
83
- </div>
84
-
85
- <div :style="style">
86
- <p>Range with marks</p>
87
- <Slider range :min="-10" :marks="marks" :default-value="[20, 25, 30, 40]" @change="log" />
88
- </div>
89
- <div :style="style">
90
- <p>Range with marks and steps</p>
91
- <Slider range :min="-10" :marks="marks" :step="10" :default-value="[20, 40]" @change="log" />
92
- </div>
93
- </div>
94
- </template>
package/docs/multiple.vue DELETED
@@ -1,54 +0,0 @@
1
- <script setup lang="ts">
2
- import type { CSSProperties, VNode } from 'vue'
3
- import Slider from '@v-c/slider'
4
- import { h, ref } from 'vue'
5
-
6
- const style: CSSProperties = {
7
- width: '400px',
8
- margin: '50px',
9
- }
10
-
11
- // const NodeWrapper = ({ children }: { children: React.ReactElement }) => {
12
- // return <div>{React.cloneElement(children, {}, <div>TOOLTIP</div>)}</div>;
13
- // };
14
-
15
- function NodeWrapper(props: any): VNode {
16
- return h('div', {}, [
17
- h('slot', {}, { default: () => props.node }),
18
- h('div', {}, 'TOOLTIP'),
19
- ])
20
- }
21
- function activeHandleRender(props: any) {
22
- return h(NodeWrapper, { ...props })
23
- }
24
- const state = ref([0, 50, 80])
25
- </script>
26
-
27
- <template>
28
- <div>
29
- <div :style="style">
30
- <Slider
31
- range
32
- :min="0"
33
- :max="100"
34
- :value="state"
35
- :styles="{
36
- tracks: {
37
- background: `linear-gradient(to right, blue, red)`,
38
- },
39
- track: {
40
- background: 'transparent',
41
- },
42
- }"
43
- :active-handle-render="activeHandleRender"
44
- @change="(nextValue) => {
45
- console.log('>>>', nextValue)
46
- }"
47
- />
48
- </div>
49
- </div>
50
- </template>
51
-
52
- <style scoped>
53
-
54
- </style>