@v-c/slider 1.0.3 → 1.0.5

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 +191 -1
  2. package/dist/Handles/Handle.d.ts +4 -4
  3. package/dist/Handles/Handle.js +187 -204
  4. package/dist/Handles/index.cjs +108 -1
  5. package/dist/Handles/index.d.ts +1 -1
  6. package/dist/Handles/index.js +105 -120
  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 +557 -1
  14. package/dist/Slider.d.ts +53 -267
  15. package/dist/Slider.js +551 -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 -110
  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 -59
  51. package/docs/editable.vue +0 -58
  52. package/docs/handle.vue +0 -51
  53. package/docs/marks.vue +0 -104
  54. package/docs/multiple.vue +0 -50
  55. package/docs/range.vue +0 -224
  56. package/docs/slider.stories.vue +0 -45
  57. package/docs/sliderDemo.vue +0 -283
  58. package/docs/vertical.vue +0 -135
  59. package/src/Handles/Handle.tsx +0 -232
  60. package/src/Handles/index.tsx +0 -132
  61. package/src/Marks/Mark.tsx +0 -40
  62. package/src/Marks/index.tsx +0 -40
  63. package/src/Slider.tsx +0 -602
  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 -272
  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 +1,21 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@v-c/util/dist/warning");function i(e){if(e===!0||!e)return[!!e,!1,!1,0];const{editable:t=!1,draggableTrack:r=!1,minCount:a,maxCount:n}=e;return process.env.NODE_ENV!=="production"&&u.warning(!t||!r,"`editable` can not work with `draggableTrack`."),[!0,t,!t&&r,a||0,n]}exports.default=i;
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
+ let __v_c_util_dist_warning = require("@v-c/util/dist/warning");
4
+ function useRange(range) {
5
+ if (range === true || !range) return [
6
+ !!range,
7
+ false,
8
+ false,
9
+ 0
10
+ ];
11
+ const { editable = false, draggableTrack = false, minCount, maxCount } = range;
12
+ if (process.env.NODE_ENV !== "production") (0, __v_c_util_dist_warning.warning)(!editable || !draggableTrack, "`editable` can not work with `draggableTrack`.");
13
+ return [
14
+ true,
15
+ editable,
16
+ !editable && draggableTrack,
17
+ minCount || 0,
18
+ maxCount
19
+ ];
20
+ }
21
+ exports.default = useRange;
@@ -1,10 +1,19 @@
1
- import { warning as o } from "@v-c/util/dist/warning";
2
- function u(e) {
3
- if (e === !0 || !e)
4
- return [!!e, !1, !1, 0];
5
- const { editable: t = !1, draggableTrack: a = !1, minCount: r, maxCount: n } = e;
6
- return process.env.NODE_ENV !== "production" && o(!t || !a, "`editable` can not work with `draggableTrack`."), [!0, t, !t && a, r || 0, n];
1
+ import { warning as warning$1 } from "@v-c/util/dist/warning";
2
+ function useRange(range) {
3
+ if (range === true || !range) return [
4
+ !!range,
5
+ false,
6
+ false,
7
+ 0
8
+ ];
9
+ const { editable = false, draggableTrack = false, minCount, maxCount } = range;
10
+ if (process.env.NODE_ENV !== "production") warning$1(!editable || !draggableTrack, "`editable` can not work with `draggableTrack`.");
11
+ return [
12
+ true,
13
+ editable,
14
+ !editable && draggableTrack,
15
+ minCount || 0,
16
+ maxCount
17
+ ];
7
18
  }
8
- export {
9
- u as default
10
- };
19
+ export { useRange as default };
package/dist/index.cjs CHANGED
@@ -1 +1,6 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Slider.cjs");exports.default=e.default;
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ const require_context = require("./context.cjs");
3
+ const require_Slider = require("./Slider.cjs");
4
+ var src_default = require_Slider.default;
5
+ exports.UnstableProvider = require_context.UnstableProvider;
6
+ exports.default = src_default;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { SliderProps, SliderRef, default as Slider } from './Slider';
2
+ export { UnstableProvider } from './context';
2
3
  export type { SliderProps, SliderRef };
3
4
  export default Slider;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import e from "./Slider.js";
2
- export {
3
- e as default
4
- };
1
+ import { UnstableProvider } from "./context.js";
2
+ import Slider_default from "./Slider.js";
3
+ var src_default = Slider_default;
4
+ export { UnstableProvider, src_default as default };
@@ -1 +0,0 @@
1
- "use strict";
package/dist/interface.js CHANGED
@@ -1 +0,0 @@
1
-
package/dist/util.cjs CHANGED
@@ -1 +1,32 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e,r,a){return(e-r)/(a-r)}function f(e,r,a,s){const n=o(r,a,s),t={};switch(e){case"rtl":t.right=`${n*100}%`,t.transform="translateX(50%)";break;case"btt":t.bottom=`${n*100}%`,t.transform="translateY(50%)";break;case"ttb":t.top=`${n*100}%`,t.transform="translateY(-50%)";break;default:t.left=`${n*100}%`,t.transform="translateX(-50%)";break}return t}function i(e,r){return Array.isArray(e)?e[r]:e}exports.getDirectionStyle=f;exports.getIndex=i;exports.getOffset=o;
1
+ function getOffset(value, min, max) {
2
+ return (value - min) / (max - min);
3
+ }
4
+ function getDirectionStyle(direction, value, min, max) {
5
+ const offset = getOffset(value, min, max);
6
+ const positionStyle = {};
7
+ switch (direction) {
8
+ case "rtl":
9
+ positionStyle.right = `${offset * 100}%`;
10
+ positionStyle.transform = "translateX(50%)";
11
+ break;
12
+ case "btt":
13
+ positionStyle.bottom = `${offset * 100}%`;
14
+ positionStyle.transform = "translateY(50%)";
15
+ break;
16
+ case "ttb":
17
+ positionStyle.top = `${offset * 100}%`;
18
+ positionStyle.transform = "translateY(-50%)";
19
+ break;
20
+ default:
21
+ positionStyle.left = `${offset * 100}%`;
22
+ positionStyle.transform = "translateX(-50%)";
23
+ break;
24
+ }
25
+ return positionStyle;
26
+ }
27
+ function getIndex(value, index) {
28
+ return Array.isArray(value) ? value[index] : value;
29
+ }
30
+ exports.getDirectionStyle = getDirectionStyle;
31
+ exports.getIndex = getIndex;
32
+ exports.getOffset = getOffset;
package/dist/util.js CHANGED
@@ -1,29 +1,30 @@
1
- function o(r, e, a) {
2
- return (r - e) / (a - e);
1
+ function getOffset(value, min, max) {
2
+ return (value - min) / (max - min);
3
3
  }
4
- function f(r, e, a, s) {
5
- const n = o(e, a, s), t = {};
6
- switch (r) {
7
- case "rtl":
8
- t.right = `${n * 100}%`, t.transform = "translateX(50%)";
9
- break;
10
- case "btt":
11
- t.bottom = `${n * 100}%`, t.transform = "translateY(50%)";
12
- break;
13
- case "ttb":
14
- t.top = `${n * 100}%`, t.transform = "translateY(-50%)";
15
- break;
16
- default:
17
- t.left = `${n * 100}%`, t.transform = "translateX(-50%)";
18
- break;
19
- }
20
- return t;
4
+ function getDirectionStyle(direction, value, min, max) {
5
+ const offset = getOffset(value, min, max);
6
+ const positionStyle = {};
7
+ switch (direction) {
8
+ case "rtl":
9
+ positionStyle.right = `${offset * 100}%`;
10
+ positionStyle.transform = "translateX(50%)";
11
+ break;
12
+ case "btt":
13
+ positionStyle.bottom = `${offset * 100}%`;
14
+ positionStyle.transform = "translateY(50%)";
15
+ break;
16
+ case "ttb":
17
+ positionStyle.top = `${offset * 100}%`;
18
+ positionStyle.transform = "translateY(-50%)";
19
+ break;
20
+ default:
21
+ positionStyle.left = `${offset * 100}%`;
22
+ positionStyle.transform = "translateX(-50%)";
23
+ break;
24
+ }
25
+ return positionStyle;
21
26
  }
22
- function c(r, e) {
23
- return Array.isArray(r) ? r[e] : r;
27
+ function getIndex(value, index) {
28
+ return Array.isArray(value) ? value[index] : value;
24
29
  }
25
- export {
26
- f as getDirectionStyle,
27
- c as getIndex,
28
- o as getOffset
29
- };
30
+ export { getDirectionStyle, getIndex, getOffset };
package/package.json CHANGED
@@ -1,8 +1,16 @@
1
1
  {
2
2
  "name": "@v-c/slider",
3
3
  "type": "module",
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "description": "",
6
+ "author": "",
7
+ "license": "MIT",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "keywords": [
12
+ "slider"
13
+ ],
6
14
  "exports": {
7
15
  ".": {
8
16
  "types": "./dist/index.d.ts",
@@ -13,23 +21,23 @@
13
21
  "./package.json": "./package.json"
14
22
  },
15
23
  "main": "index.js",
24
+ "files": [
25
+ "dist",
26
+ "package.json"
27
+ ],
16
28
  "peerDependencies": {
17
29
  "vue": "^3.0.0"
18
30
  },
19
31
  "dependencies": {
20
- "classnames": "^2.5.1",
21
- "@v-c/util": "0.0.4"
32
+ "@v-c/util": "^0.0.19"
22
33
  },
23
34
  "devDependencies": {
24
- "@v-c/tooltip": "1.0.0"
35
+ "@v-c/tooltip": "^0.0.16"
25
36
  },
26
- "keywords": [
27
- "slider"
28
- ],
29
- "author": "",
30
- "license": "MIT",
31
37
  "scripts": {
32
38
  "build": "vite build",
33
- "test": "vitest"
39
+ "test": "vitest run",
40
+ "prepublish": "pnpm build",
41
+ "bump": "bumpp --release patch"
34
42
  }
35
43
  }
@@ -1,94 +0,0 @@
1
- import type { PropType, VNode } from 'vue'
2
- import type { SliderProps } from '../src'
3
- import Tooltip from '@v-c/tooltip'
4
- import raf from '@v-c/util/dist/raf'
5
- import { defineComponent, ref, watchEffect } from 'vue'
6
- import Slider from '../src'
7
- import './assets/bootstrap.less'
8
-
9
- export const HandleTooltip = defineComponent({
10
- name: 'HandleTooltip',
11
- props: {
12
- value: { type: Number, required: true },
13
- visible: { type: Boolean, required: true },
14
- tipFormatter: { type: Function as PropType<(value: number) => string>, default: (val: number) => `${val} %` },
15
- },
16
- setup(props, { slots }) {
17
- const tooltipRef = ref()
18
- const rafRef = ref<number | null>(null)
19
-
20
- function cancelKeepAlign() {
21
- raf.cancel(rafRef.value!)
22
- }
23
-
24
- function keepAlign() {
25
- rafRef.value = raf(() => {
26
- tooltipRef.value?.forceAlign()
27
- })
28
- }
29
-
30
- watchEffect((onCleanup) => {
31
- if (props.visible) {
32
- keepAlign()
33
- }
34
- else {
35
- cancelKeepAlign()
36
- }
37
-
38
- onCleanup(cancelKeepAlign)
39
- })
40
- return () => (
41
- <Tooltip
42
- placement="top"
43
- overlayInnerStyle={{ minHeight: 'auto' }}
44
- ref={tooltipRef.value}
45
- visible={props.visible}
46
- v-slots={{
47
- default: slots.default,
48
- overlay: () => props.tipFormatter(props.value),
49
- }}
50
- />
51
- )
52
- },
53
- })
54
-
55
- interface HandleTooltipProps {
56
- index: number
57
- prefixCls: string
58
- value: number
59
- dragging: boolean
60
- draggingDelete: boolean
61
- node: HTMLElement
62
- }
63
- export function HandleRender(props: HandleTooltipProps) {
64
- return (
65
- <HandleTooltip value={props.value} visible={props.dragging}>
66
- {props.node}
67
- </HandleTooltip>
68
- )
69
- }
70
-
71
- interface TooltipSliderProps extends SliderProps {
72
- tipFormatter?: (value: number) => VNode
73
- tipProps?: any
74
- }
75
-
76
- const TooltipSlider = defineComponent<TooltipSliderProps>({
77
- name: 'TooltipSlider',
78
- props: {
79
- tipFormatter: Function as PropType<(value: number) => string>,
80
- tipProps: Object,
81
- },
82
- setup(_, { attrs }) {
83
- return () => {
84
- return (
85
- <Slider
86
- {...attrs}
87
- handleRender={HandleRender}
88
- />
89
- )
90
- }
91
- },
92
- })
93
-
94
- export default TooltipSlider
@@ -1,63 +0,0 @@
1
- .@{tooltip-prefix-cls} {
2
- .effect() {
3
- animation-duration: 0.3s;
4
- animation-fill-mode: both;
5
- }
6
-
7
- &&-zoom-appear,
8
- &&-zoom-enter {
9
- opacity: 0;
10
- }
11
-
12
- &&-zoom-enter, &&-zoom-leave {
13
- display: block;
14
- }
15
-
16
- &-zoom-enter, &-zoom-appear {
17
- opacity: 0;
18
- .effect();
19
- animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28);
20
- animation-play-state: paused;
21
- }
22
-
23
- &-zoom-leave {
24
- .effect();
25
- animation-timing-function: cubic-bezier(0.6, -0.3, 0.74, 0.05);
26
- animation-play-state: paused;
27
- }
28
-
29
- &-zoom-enter&-zoom-enter-active, &-zoom-appear&-zoom-appear-active {
30
- animation-name: rcToolTipZoomIn;
31
- animation-play-state: running;
32
- }
33
-
34
- &-zoom-leave&-zoom-leave-active {
35
- animation-name: rcToolTipZoomOut;
36
- animation-play-state: running;
37
- }
38
-
39
- @keyframes rcToolTipZoomIn {
40
- 0% {
41
- opacity: 0;
42
- transform-origin: 50% 50%;
43
- transform: scale(0, 0);
44
- }
45
- 100% {
46
- opacity: 1;
47
- transform-origin: 50% 50%;
48
- transform: scale(1, 1);
49
- }
50
- }
51
- @keyframes rcToolTipZoomOut {
52
- 0% {
53
- opacity: 1;
54
- transform-origin: 50% 50%;
55
- transform: scale(1, 1);
56
- }
57
- 100% {
58
- opacity: 0;
59
- transform-origin: 50% 50%;
60
- transform: scale(0, 0);
61
- }
62
- }
63
- }
@@ -1,163 +0,0 @@
1
- @import './anim.less';
2
-
3
- @tooltip-prefix-cls: vc-tooltip;
4
-
5
- //
6
- // Tooltips
7
- // --------------------------------------------------
8
- @font-size-base : 12px;
9
- @line-height-base : 1.5;
10
- @border-radius-base : 6px;
11
- @overlay-shadow : 0 0 4px rgba(0, 0, 0, 0.17);
12
- //** Tooltip text color
13
- @tooltip-color: #fff;
14
- //** Tooltip background color
15
- @tooltip-bg: #373737;
16
- @tooltip-opacity: 0.9;
17
-
18
- //** Tooltip arrow width
19
- @tooltip-arrow-width: 5px;
20
- //** Tooltip distance with trigger
21
- @tooltip-distance: @tooltip-arrow-width + 4;
22
- //** Tooltip arrow color
23
- @tooltip-arrow-color: @tooltip-bg;
24
-
25
- // Base class
26
- .@{tooltip-prefix-cls} {
27
- position: absolute;
28
- z-index: 1070;
29
- display: block;
30
- visibility: visible;
31
- // remove left/top by yiminghe
32
- // left: -9999px;
33
- // top: -9999px;
34
- font-size: @font-size-base;
35
- line-height: @line-height-base;
36
- opacity: @tooltip-opacity;
37
-
38
- &-hidden {
39
- display: none;
40
- }
41
-
42
- //&-placement-top, &-placement-topLeft, &-placement-topRight {
43
- // padding: @tooltip-arrow-width 0 @tooltip-distance 0;
44
- //}
45
- //&-placement-right, &-placement-rightTop, &-placement-rightBottom {
46
- // padding: 0 @tooltip-arrow-width 0 @tooltip-distance;
47
- //}
48
- //&-placement-bottom, &-placement-bottomLeft, &-placement-bottomRight {
49
- // padding: @tooltip-distance 0 @tooltip-arrow-width 0;
50
- //}
51
- //&-placement-left, &-placement-leftTop, &-placement-leftBottom {
52
- // padding: 0 @tooltip-distance 0 @tooltip-arrow-width;
53
- //}
54
- }
55
-
56
- // Wrapper for the tooltip content
57
- .@{tooltip-prefix-cls}-inner {
58
- padding: 8px 10px;
59
- color: @tooltip-color;
60
- text-align: left;
61
- text-decoration: none;
62
- background-color: @tooltip-bg;
63
- border-radius: @border-radius-base;
64
- box-shadow: @overlay-shadow;
65
- min-height: 34px;
66
- }
67
-
68
- // Arrows
69
- .@{tooltip-prefix-cls}-arrow {
70
- position: absolute;
71
- width: 0;
72
- height: 0;
73
- border-color: transparent;
74
- border-style: solid;
75
- }
76
-
77
- .@{tooltip-prefix-cls} {
78
- &-placement-top &-arrow,
79
- &-placement-topLeft &-arrow,
80
- &-placement-topRight &-arrow {
81
- bottom: @tooltip-distance - @tooltip-arrow-width;
82
- margin-left: -@tooltip-arrow-width;
83
- border-width: @tooltip-arrow-width @tooltip-arrow-width 0;
84
- border-top-color: @tooltip-arrow-color;
85
- }
86
-
87
- &-placement-top &-arrow {
88
- left: 50%;
89
- }
90
-
91
- &-placement-topLeft &-arrow {
92
- left: 15%;
93
- }
94
-
95
- &-placement-topRight &-arrow {
96
- right: 15%;
97
- }
98
-
99
- &-placement-right &-arrow,
100
- &-placement-rightTop &-arrow,
101
- &-placement-rightBottom &-arrow {
102
- left: @tooltip-distance - @tooltip-arrow-width;
103
- margin-top: -@tooltip-arrow-width;
104
- border-width: @tooltip-arrow-width @tooltip-arrow-width @tooltip-arrow-width 0;
105
- border-right-color: @tooltip-arrow-color;
106
- }
107
-
108
- &-placement-right &-arrow {
109
- top: 50%;
110
- }
111
-
112
- &-placement-rightTop &-arrow {
113
- top: 15%;
114
- margin-top: 0;
115
- }
116
-
117
- &-placement-rightBottom &-arrow {
118
- bottom: 15%;
119
- }
120
-
121
- &-placement-left &-arrow,
122
- &-placement-leftTop &-arrow,
123
- &-placement-leftBottom &-arrow {
124
- right: @tooltip-distance - @tooltip-arrow-width;
125
- margin-top: -@tooltip-arrow-width;
126
- border-width: @tooltip-arrow-width 0 @tooltip-arrow-width @tooltip-arrow-width;
127
- border-left-color: @tooltip-arrow-color;
128
- }
129
-
130
- &-placement-left &-arrow {
131
- top: 50%;
132
- }
133
-
134
- &-placement-leftTop &-arrow {
135
- top: 15%;
136
- margin-top: 0;
137
- }
138
-
139
- &-placement-leftBottom &-arrow {
140
- bottom: 15%;
141
- }
142
-
143
- &-placement-bottom &-arrow,
144
- &-placement-bottomLeft &-arrow,
145
- &-placement-bottomRight &-arrow {
146
- top: @tooltip-distance - @tooltip-arrow-width;
147
- margin-left: -@tooltip-arrow-width;
148
- border-width: 0 @tooltip-arrow-width @tooltip-arrow-width;
149
- border-bottom-color: @tooltip-arrow-color;
150
- }
151
-
152
- &-placement-bottom &-arrow {
153
- left: 50%;
154
- }
155
-
156
- &-placement-bottomLeft &-arrow {
157
- left: 15%;
158
- }
159
-
160
- &-placement-bottomRight &-arrow {
161
- right: 15%;
162
- }
163
- }