@v-c/slider 1.0.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/LICENSE +21 -0
- package/dist/Handles/Handle.cjs +1 -0
- package/dist/Handles/Handle.d.ts +107 -0
- package/dist/Handles/Handle.js +203 -0
- package/dist/Handles/index.cjs +1 -0
- package/dist/Handles/index.d.ts +98 -0
- package/dist/Handles/index.js +117 -0
- package/dist/Marks/Mark.cjs +1 -0
- package/dist/Marks/Mark.d.ts +9 -0
- package/dist/Marks/Mark.js +39 -0
- package/dist/Marks/index.cjs +1 -0
- package/dist/Marks/index.d.ts +15 -0
- package/dist/Marks/index.js +31 -0
- package/dist/Slider.cjs +1 -0
- package/dist/Slider.d.ts +253 -0
- package/dist/Slider.js +343 -0
- package/dist/Steps/Dot.cjs +1 -0
- package/dist/Steps/Dot.d.ts +9 -0
- package/dist/Steps/Dot.js +38 -0
- package/dist/Steps/index.cjs +1 -0
- package/dist/Steps/index.d.ts +11 -0
- package/dist/Steps/index.js +41 -0
- package/dist/Tracks/Track.cjs +1 -0
- package/dist/Tracks/Track.d.ts +61 -0
- package/dist/Tracks/Track.js +82 -0
- package/dist/Tracks/index.cjs +1 -0
- package/dist/Tracks/index.d.ts +47 -0
- package/dist/Tracks/index.js +83 -0
- package/dist/context.cjs +1 -0
- package/dist/context.d.ts +51 -0
- package/dist/context.js +27 -0
- package/dist/hooks/useDrag.cjs +1 -0
- package/dist/hooks/useDrag.d.ts +11 -0
- package/dist/hooks/useDrag.js +88 -0
- package/dist/hooks/useOffset.cjs +1 -0
- package/dist/hooks/useOffset.d.ts +10 -0
- package/dist/hooks/useOffset.js +98 -0
- package/dist/hooks/useRange.cjs +1 -0
- package/dist/hooks/useRange.d.ts +8 -0
- package/dist/hooks/useRange.js +10 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/interface.cjs +1 -0
- package/dist/interface.d.ts +7 -0
- package/dist/interface.js +1 -0
- package/dist/util.cjs +1 -0
- package/dist/util.d.ts +6 -0
- package/dist/util.js +29 -0
- package/docs/TooltipSlider.tsx +94 -0
- package/docs/assets/anim.less +63 -0
- package/docs/assets/bootstrap.less +163 -0
- package/docs/assets/index.less +337 -0
- package/docs/debug.vue +60 -0
- package/docs/editable.vue +59 -0
- package/docs/handle.vue +45 -0
- package/docs/marks.vue +85 -0
- package/docs/multiple.vue +54 -0
- package/docs/range.vue +211 -0
- package/docs/slider.stories.vue +45 -0
- package/docs/sliderDemo.vue +267 -0
- package/docs/vertical.vue +122 -0
- package/package.json +35 -0
- package/src/Handles/Handle.tsx +226 -0
- package/src/Handles/index.tsx +124 -0
- package/src/Marks/Mark.tsx +40 -0
- package/src/Marks/index.tsx +40 -0
- package/src/Slider.tsx +582 -0
- package/src/Steps/Dot.tsx +40 -0
- package/src/Steps/index.tsx +54 -0
- package/src/Tracks/Track.tsx +89 -0
- package/src/Tracks/index.tsx +92 -0
- package/src/context.ts +65 -0
- package/src/hooks/useDrag.ts +244 -0
- package/src/hooks/useOffset.ts +264 -0
- package/src/hooks/useRange.ts +24 -0
- package/src/index.ts +8 -0
- package/src/interface.ts +17 -0
- package/src/util.ts +41 -0
- package/vite.config.ts +18 -0
- package/vitest.config.ts +11 -0
package/dist/Slider.d.ts
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import { AriaValueFormat, SliderClassNames, SliderStyles } from './interface';
|
|
3
|
+
import { MarkObj } from './Marks';
|
|
4
|
+
export interface RangeConfig {
|
|
5
|
+
editable?: boolean;
|
|
6
|
+
draggableTrack?: boolean;
|
|
7
|
+
/** Set min count when `editable` */
|
|
8
|
+
minCount?: number;
|
|
9
|
+
/** Set max count when `editable` */
|
|
10
|
+
maxCount?: number;
|
|
11
|
+
}
|
|
12
|
+
declare function sliderProps(): {
|
|
13
|
+
prefixCls: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
className: StringConstructor;
|
|
18
|
+
classNames: PropType<SliderClassNames>;
|
|
19
|
+
styles: PropType<SliderStyles>;
|
|
20
|
+
id: StringConstructor;
|
|
21
|
+
disabled: {
|
|
22
|
+
type: BooleanConstructor;
|
|
23
|
+
default: boolean;
|
|
24
|
+
};
|
|
25
|
+
keyboard: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
29
|
+
autoFocus: BooleanConstructor;
|
|
30
|
+
min: {
|
|
31
|
+
type: NumberConstructor;
|
|
32
|
+
default: number;
|
|
33
|
+
};
|
|
34
|
+
max: {
|
|
35
|
+
type: NumberConstructor;
|
|
36
|
+
default: number;
|
|
37
|
+
};
|
|
38
|
+
step: {
|
|
39
|
+
type: NumberConstructor;
|
|
40
|
+
default: number;
|
|
41
|
+
};
|
|
42
|
+
value: PropType<number | number[]>;
|
|
43
|
+
defaultValue: PropType<number | number[]>;
|
|
44
|
+
range: PropType<boolean | RangeConfig>;
|
|
45
|
+
count: NumberConstructor;
|
|
46
|
+
allowCross: {
|
|
47
|
+
type: BooleanConstructor;
|
|
48
|
+
default: boolean;
|
|
49
|
+
};
|
|
50
|
+
pushable: {
|
|
51
|
+
type: (NumberConstructor | BooleanConstructor)[];
|
|
52
|
+
default: boolean;
|
|
53
|
+
};
|
|
54
|
+
reverse: BooleanConstructor;
|
|
55
|
+
vertical: BooleanConstructor;
|
|
56
|
+
included: {
|
|
57
|
+
type: BooleanConstructor;
|
|
58
|
+
default: boolean;
|
|
59
|
+
};
|
|
60
|
+
startPoint: NumberConstructor;
|
|
61
|
+
trackStyle: PropType<Record<string, any> | Record<string, any>[]>;
|
|
62
|
+
handleStyle: PropType<Record<string, any> | Record<string, any>[]>;
|
|
63
|
+
railStyle: PropType<Record<string, any>>;
|
|
64
|
+
dotStyle: PropType<Record<string, any> | ((dotValue: number) => Record<string, any>)>;
|
|
65
|
+
activeDotStyle: PropType<Record<string, any> | ((dotValue: number) => Record<string, any>)>;
|
|
66
|
+
marks: PropType<Record<string | number, any | MarkObj>>;
|
|
67
|
+
dots: BooleanConstructor;
|
|
68
|
+
handleRender: FunctionConstructor;
|
|
69
|
+
activeHandleRender: FunctionConstructor;
|
|
70
|
+
track: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: boolean;
|
|
73
|
+
};
|
|
74
|
+
tabIndex: {
|
|
75
|
+
type: PropType<number | number[]>;
|
|
76
|
+
default: number;
|
|
77
|
+
};
|
|
78
|
+
ariaLabelForHandle: PropType<string | string[]>;
|
|
79
|
+
ariaLabelledByForHandle: PropType<string | string[]>;
|
|
80
|
+
ariaRequired: BooleanConstructor;
|
|
81
|
+
ariaValueTextFormatterForHandle: PropType<AriaValueFormat | AriaValueFormat[]>;
|
|
82
|
+
};
|
|
83
|
+
export type SliderProps = Partial<ExtractPropTypes<ReturnType<typeof sliderProps>>>;
|
|
84
|
+
export interface SliderRef {
|
|
85
|
+
focus: () => void;
|
|
86
|
+
blur: () => void;
|
|
87
|
+
}
|
|
88
|
+
declare const _default: import('vue').DefineComponent<ExtractPropTypes<{
|
|
89
|
+
prefixCls: {
|
|
90
|
+
type: StringConstructor;
|
|
91
|
+
default: string;
|
|
92
|
+
};
|
|
93
|
+
className: StringConstructor;
|
|
94
|
+
classNames: PropType<SliderClassNames>;
|
|
95
|
+
styles: PropType<SliderStyles>;
|
|
96
|
+
id: StringConstructor;
|
|
97
|
+
disabled: {
|
|
98
|
+
type: BooleanConstructor;
|
|
99
|
+
default: boolean;
|
|
100
|
+
};
|
|
101
|
+
keyboard: {
|
|
102
|
+
type: BooleanConstructor;
|
|
103
|
+
default: boolean;
|
|
104
|
+
};
|
|
105
|
+
autoFocus: BooleanConstructor;
|
|
106
|
+
min: {
|
|
107
|
+
type: NumberConstructor;
|
|
108
|
+
default: number;
|
|
109
|
+
};
|
|
110
|
+
max: {
|
|
111
|
+
type: NumberConstructor;
|
|
112
|
+
default: number;
|
|
113
|
+
};
|
|
114
|
+
step: {
|
|
115
|
+
type: NumberConstructor;
|
|
116
|
+
default: number;
|
|
117
|
+
};
|
|
118
|
+
value: PropType<number | number[]>;
|
|
119
|
+
defaultValue: PropType<number | number[]>;
|
|
120
|
+
range: PropType<boolean | RangeConfig>;
|
|
121
|
+
count: NumberConstructor;
|
|
122
|
+
allowCross: {
|
|
123
|
+
type: BooleanConstructor;
|
|
124
|
+
default: boolean;
|
|
125
|
+
};
|
|
126
|
+
pushable: {
|
|
127
|
+
type: (NumberConstructor | BooleanConstructor)[];
|
|
128
|
+
default: boolean;
|
|
129
|
+
};
|
|
130
|
+
reverse: BooleanConstructor;
|
|
131
|
+
vertical: BooleanConstructor;
|
|
132
|
+
included: {
|
|
133
|
+
type: BooleanConstructor;
|
|
134
|
+
default: boolean;
|
|
135
|
+
};
|
|
136
|
+
startPoint: NumberConstructor;
|
|
137
|
+
trackStyle: PropType<Record<string, any> | Record<string, any>[]>;
|
|
138
|
+
handleStyle: PropType<Record<string, any> | Record<string, any>[]>;
|
|
139
|
+
railStyle: PropType<Record<string, any>>;
|
|
140
|
+
dotStyle: PropType<Record<string, any> | ((dotValue: number) => Record<string, any>)>;
|
|
141
|
+
activeDotStyle: PropType<Record<string, any> | ((dotValue: number) => Record<string, any>)>;
|
|
142
|
+
marks: PropType<Record<string | number, any | MarkObj>>;
|
|
143
|
+
dots: BooleanConstructor;
|
|
144
|
+
handleRender: FunctionConstructor;
|
|
145
|
+
activeHandleRender: FunctionConstructor;
|
|
146
|
+
track: {
|
|
147
|
+
type: BooleanConstructor;
|
|
148
|
+
default: boolean;
|
|
149
|
+
};
|
|
150
|
+
tabIndex: {
|
|
151
|
+
type: PropType<number | number[]>;
|
|
152
|
+
default: number;
|
|
153
|
+
};
|
|
154
|
+
ariaLabelForHandle: PropType<string | string[]>;
|
|
155
|
+
ariaLabelledByForHandle: PropType<string | string[]>;
|
|
156
|
+
ariaRequired: BooleanConstructor;
|
|
157
|
+
ariaValueTextFormatterForHandle: PropType<AriaValueFormat | AriaValueFormat[]>;
|
|
158
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("focus" | "changeComplete" | "blur" | "change" | "beforeChange" | "afterChange")[], "focus" | "changeComplete" | "blur" | "change" | "beforeChange" | "afterChange", import('vue').PublicProps, Readonly<ExtractPropTypes<{
|
|
159
|
+
prefixCls: {
|
|
160
|
+
type: StringConstructor;
|
|
161
|
+
default: string;
|
|
162
|
+
};
|
|
163
|
+
className: StringConstructor;
|
|
164
|
+
classNames: PropType<SliderClassNames>;
|
|
165
|
+
styles: PropType<SliderStyles>;
|
|
166
|
+
id: StringConstructor;
|
|
167
|
+
disabled: {
|
|
168
|
+
type: BooleanConstructor;
|
|
169
|
+
default: boolean;
|
|
170
|
+
};
|
|
171
|
+
keyboard: {
|
|
172
|
+
type: BooleanConstructor;
|
|
173
|
+
default: boolean;
|
|
174
|
+
};
|
|
175
|
+
autoFocus: BooleanConstructor;
|
|
176
|
+
min: {
|
|
177
|
+
type: NumberConstructor;
|
|
178
|
+
default: number;
|
|
179
|
+
};
|
|
180
|
+
max: {
|
|
181
|
+
type: NumberConstructor;
|
|
182
|
+
default: number;
|
|
183
|
+
};
|
|
184
|
+
step: {
|
|
185
|
+
type: NumberConstructor;
|
|
186
|
+
default: number;
|
|
187
|
+
};
|
|
188
|
+
value: PropType<number | number[]>;
|
|
189
|
+
defaultValue: PropType<number | number[]>;
|
|
190
|
+
range: PropType<boolean | RangeConfig>;
|
|
191
|
+
count: NumberConstructor;
|
|
192
|
+
allowCross: {
|
|
193
|
+
type: BooleanConstructor;
|
|
194
|
+
default: boolean;
|
|
195
|
+
};
|
|
196
|
+
pushable: {
|
|
197
|
+
type: (NumberConstructor | BooleanConstructor)[];
|
|
198
|
+
default: boolean;
|
|
199
|
+
};
|
|
200
|
+
reverse: BooleanConstructor;
|
|
201
|
+
vertical: BooleanConstructor;
|
|
202
|
+
included: {
|
|
203
|
+
type: BooleanConstructor;
|
|
204
|
+
default: boolean;
|
|
205
|
+
};
|
|
206
|
+
startPoint: NumberConstructor;
|
|
207
|
+
trackStyle: PropType<Record<string, any> | Record<string, any>[]>;
|
|
208
|
+
handleStyle: PropType<Record<string, any> | Record<string, any>[]>;
|
|
209
|
+
railStyle: PropType<Record<string, any>>;
|
|
210
|
+
dotStyle: PropType<Record<string, any> | ((dotValue: number) => Record<string, any>)>;
|
|
211
|
+
activeDotStyle: PropType<Record<string, any> | ((dotValue: number) => Record<string, any>)>;
|
|
212
|
+
marks: PropType<Record<string | number, any | MarkObj>>;
|
|
213
|
+
dots: BooleanConstructor;
|
|
214
|
+
handleRender: FunctionConstructor;
|
|
215
|
+
activeHandleRender: FunctionConstructor;
|
|
216
|
+
track: {
|
|
217
|
+
type: BooleanConstructor;
|
|
218
|
+
default: boolean;
|
|
219
|
+
};
|
|
220
|
+
tabIndex: {
|
|
221
|
+
type: PropType<number | number[]>;
|
|
222
|
+
default: number;
|
|
223
|
+
};
|
|
224
|
+
ariaLabelForHandle: PropType<string | string[]>;
|
|
225
|
+
ariaLabelledByForHandle: PropType<string | string[]>;
|
|
226
|
+
ariaRequired: BooleanConstructor;
|
|
227
|
+
ariaValueTextFormatterForHandle: PropType<AriaValueFormat | AriaValueFormat[]>;
|
|
228
|
+
}>> & Readonly<{
|
|
229
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
230
|
+
onChangeComplete?: ((...args: any[]) => any) | undefined;
|
|
231
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
232
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
233
|
+
onBeforeChange?: ((...args: any[]) => any) | undefined;
|
|
234
|
+
onAfterChange?: ((...args: any[]) => any) | undefined;
|
|
235
|
+
}>, {
|
|
236
|
+
track: boolean;
|
|
237
|
+
min: number;
|
|
238
|
+
max: number;
|
|
239
|
+
prefixCls: string;
|
|
240
|
+
reverse: boolean;
|
|
241
|
+
disabled: boolean;
|
|
242
|
+
keyboard: boolean;
|
|
243
|
+
tabIndex: number | number[];
|
|
244
|
+
ariaRequired: boolean;
|
|
245
|
+
vertical: boolean;
|
|
246
|
+
included: boolean;
|
|
247
|
+
autoFocus: boolean;
|
|
248
|
+
step: number;
|
|
249
|
+
allowCross: boolean;
|
|
250
|
+
pushable: number | boolean;
|
|
251
|
+
dots: boolean;
|
|
252
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
253
|
+
export default _default;
|
package/dist/Slider.js
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { defineComponent as de, ref as S, shallowRef as T, watch as ve, watchEffect as w, computed as k, isVNode as fe, createVNode as E } from "vue";
|
|
2
|
+
import ge from "@v-c/util/dist/isEqual";
|
|
3
|
+
import X from "@v-c/util/dist/warning";
|
|
4
|
+
import W from "classnames";
|
|
5
|
+
import { useProviderSliderContext as be } from "./context.js";
|
|
6
|
+
import me from "./Handles/index.js";
|
|
7
|
+
import he from "./hooks/useDrag.js";
|
|
8
|
+
import ye from "./hooks/useOffset.js";
|
|
9
|
+
import Ce from "./hooks/useRange.js";
|
|
10
|
+
import xe from "./Marks/index.js";
|
|
11
|
+
import Se from "./Steps/index.js";
|
|
12
|
+
import ke from "./Tracks/index.js";
|
|
13
|
+
function pe() {
|
|
14
|
+
return {
|
|
15
|
+
prefixCls: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: "vc-slider"
|
|
18
|
+
},
|
|
19
|
+
className: String,
|
|
20
|
+
classNames: Object,
|
|
21
|
+
styles: Object,
|
|
22
|
+
id: String,
|
|
23
|
+
disabled: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: !1
|
|
26
|
+
},
|
|
27
|
+
keyboard: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: !0
|
|
30
|
+
},
|
|
31
|
+
autoFocus: Boolean,
|
|
32
|
+
min: {
|
|
33
|
+
type: Number,
|
|
34
|
+
default: 0
|
|
35
|
+
},
|
|
36
|
+
max: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: 100
|
|
39
|
+
},
|
|
40
|
+
step: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 1
|
|
43
|
+
},
|
|
44
|
+
value: [Number, Array],
|
|
45
|
+
defaultValue: [Number, Array],
|
|
46
|
+
range: [Boolean, Object],
|
|
47
|
+
count: Number,
|
|
48
|
+
allowCross: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: !0
|
|
51
|
+
},
|
|
52
|
+
pushable: {
|
|
53
|
+
type: [Boolean, Number],
|
|
54
|
+
default: !1
|
|
55
|
+
},
|
|
56
|
+
reverse: Boolean,
|
|
57
|
+
vertical: Boolean,
|
|
58
|
+
included: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: !0
|
|
61
|
+
},
|
|
62
|
+
startPoint: Number,
|
|
63
|
+
trackStyle: [Object, Array],
|
|
64
|
+
handleStyle: [Object, Array],
|
|
65
|
+
railStyle: Object,
|
|
66
|
+
dotStyle: [Object, Function],
|
|
67
|
+
activeDotStyle: [Object, Function],
|
|
68
|
+
marks: Object,
|
|
69
|
+
dots: Boolean,
|
|
70
|
+
handleRender: Function,
|
|
71
|
+
activeHandleRender: Function,
|
|
72
|
+
track: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: !0
|
|
75
|
+
},
|
|
76
|
+
tabIndex: {
|
|
77
|
+
type: [Number, Array],
|
|
78
|
+
default: 0
|
|
79
|
+
},
|
|
80
|
+
ariaLabelForHandle: [String, Array],
|
|
81
|
+
ariaLabelledByForHandle: [String, Array],
|
|
82
|
+
ariaRequired: Boolean,
|
|
83
|
+
ariaValueTextFormatterForHandle: [Function, Array]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const Me = /* @__PURE__ */ de({
|
|
87
|
+
name: "Slider",
|
|
88
|
+
props: {
|
|
89
|
+
...pe()
|
|
90
|
+
},
|
|
91
|
+
emits: ["focus", "blur", "change", "beforeChange", "afterChange", "changeComplete"],
|
|
92
|
+
setup(l, {
|
|
93
|
+
attrs: Y,
|
|
94
|
+
emit: d,
|
|
95
|
+
expose: Z
|
|
96
|
+
}) {
|
|
97
|
+
const y = S(), R = S(), B = T("ltr");
|
|
98
|
+
ve([() => l.reverse, () => l.vertical], ([e, a]) => {
|
|
99
|
+
a ? B.value = e ? "ttb" : "btt" : B.value = e ? "rtl" : "ltr";
|
|
100
|
+
}, {
|
|
101
|
+
immediate: !0
|
|
102
|
+
});
|
|
103
|
+
const g = T(0), p = T(100), O = T(1), D = S([]), C = S(l.defaultValue || l.value), n = S([]), r = S(), V = S();
|
|
104
|
+
w(() => {
|
|
105
|
+
const {
|
|
106
|
+
range: e,
|
|
107
|
+
min: a,
|
|
108
|
+
max: t,
|
|
109
|
+
step: o,
|
|
110
|
+
pushable: i,
|
|
111
|
+
marks: b,
|
|
112
|
+
allowCross: x,
|
|
113
|
+
value: v,
|
|
114
|
+
count: f
|
|
115
|
+
} = l, [s, m, L, P, $] = Ce(e);
|
|
116
|
+
r.value = {
|
|
117
|
+
rangeEnabled: s,
|
|
118
|
+
rangeEditable: m,
|
|
119
|
+
rangeDraggableTrack: L,
|
|
120
|
+
minCount: P,
|
|
121
|
+
maxCount: $
|
|
122
|
+
}, g.value = isFinite(a) ? a : 0, p.value = isFinite(t) ? t : 100, O.value = o !== null && o <= 0 ? 1 : o;
|
|
123
|
+
const q = k(() => typeof i == "boolean" ? i ? O.value : !1 : i >= 0 ? i : !1);
|
|
124
|
+
D.value = Object.keys(b || {}).map((h) => {
|
|
125
|
+
const c = b?.[h], u = {
|
|
126
|
+
value: Number(h)
|
|
127
|
+
};
|
|
128
|
+
return c && typeof c == "object" && !fe(c) && ("label" in c || "style" in c) ? (u.style = c.style, u.label = c.label) : u.label = c, u;
|
|
129
|
+
}).filter(({
|
|
130
|
+
label: h
|
|
131
|
+
}) => h || typeof h == "number").sort((h, c) => h.value - c.value);
|
|
132
|
+
const [M, H] = ye(g.value, p.value, O.value, D.value, x, q.value);
|
|
133
|
+
V.value = {
|
|
134
|
+
formatValue: M,
|
|
135
|
+
offsetValues: H
|
|
136
|
+
}, v !== void 0 && (C.value = v);
|
|
137
|
+
const ce = k(() => {
|
|
138
|
+
const h = C.value === null || C.value === void 0 ? [] : Array.isArray(C.value) ? C.value : [C.value], [c = g.value] = h;
|
|
139
|
+
let u = C.value === null ? [] : [c];
|
|
140
|
+
if (s) {
|
|
141
|
+
if (u = [...h], f || C.value === void 0) {
|
|
142
|
+
const N = f >= 0 ? f + 1 : 2;
|
|
143
|
+
for (u = u.slice(0, N); u.length < N; )
|
|
144
|
+
u.push(u[u.length - 1] ?? g.value);
|
|
145
|
+
}
|
|
146
|
+
u.sort((N, z) => N - z);
|
|
147
|
+
}
|
|
148
|
+
return u.forEach((N, z) => {
|
|
149
|
+
u[z] = M(N);
|
|
150
|
+
}), u;
|
|
151
|
+
});
|
|
152
|
+
n.value = ce.value;
|
|
153
|
+
});
|
|
154
|
+
const F = (e) => r.value.rangeEnabled ? e : e[0], A = (e) => {
|
|
155
|
+
const a = [...e].sort((t, o) => t - o);
|
|
156
|
+
ge(a, n.value, !0) || d("change", F(a)), C.value = a;
|
|
157
|
+
}, _ = (e) => {
|
|
158
|
+
e && y.value?.hideHelp();
|
|
159
|
+
const a = F(n.value);
|
|
160
|
+
l.onAfterChange && (d("afterChange", a), X(!1, "[vc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead.")), d("changeComplete", a);
|
|
161
|
+
}, ee = (e) => {
|
|
162
|
+
if (l.disabled || !r.value.rangeEditable || n.value.length <= r.value.minCount)
|
|
163
|
+
return;
|
|
164
|
+
const a = [...n.value];
|
|
165
|
+
a.splice(e, 1), d("beforeChange", F(a)), A(a);
|
|
166
|
+
const t = Math.max(0, e - 1);
|
|
167
|
+
y.value?.hideHelp(), y.value?.focus(t);
|
|
168
|
+
}, [G, ae, le, J, K] = he(R, B, n, g, p, V.value.formatValue, A, _, V.value.offsetValues, r.value.rangeEditable, r.value.minCount), Q = (e, a) => {
|
|
169
|
+
if (!l.disabled) {
|
|
170
|
+
const t = [...n.value];
|
|
171
|
+
let o = 0, i = 0, b = p.value - g.value;
|
|
172
|
+
n.value.forEach((f, s) => {
|
|
173
|
+
const m = Math.abs(e - f);
|
|
174
|
+
m <= b && (b = m, o = s), f < e && (i = s);
|
|
175
|
+
});
|
|
176
|
+
let x = o;
|
|
177
|
+
r.value.rangeEditable && b !== 0 && (!r.value.maxCount || n.value.length < r.value.maxCount) ? (t.splice(i + 1, 0, e), x = i + 1) : t[o] = e, r.value.rangeEnabled && !n.value.length && l.count === void 0 && t.push(e);
|
|
178
|
+
const v = F(t);
|
|
179
|
+
d("beforeChange", v), A(t), a ? (document.activeElement?.blur?.(), y.value?.focus(x), K(a, x, t)) : (l.onAfterChange && (d("afterChange", v), X(!1, "[vc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead.")), d("changeComplete", v));
|
|
180
|
+
}
|
|
181
|
+
}, te = (e) => {
|
|
182
|
+
e.preventDefault();
|
|
183
|
+
const {
|
|
184
|
+
width: a,
|
|
185
|
+
height: t,
|
|
186
|
+
left: o,
|
|
187
|
+
top: i,
|
|
188
|
+
bottom: b,
|
|
189
|
+
right: x
|
|
190
|
+
} = R.value.getBoundingClientRect(), {
|
|
191
|
+
clientX: v,
|
|
192
|
+
clientY: f
|
|
193
|
+
} = e;
|
|
194
|
+
let s;
|
|
195
|
+
switch (B.value) {
|
|
196
|
+
case "btt":
|
|
197
|
+
s = (b - f) / t;
|
|
198
|
+
break;
|
|
199
|
+
case "ttb":
|
|
200
|
+
s = (f - i) / t;
|
|
201
|
+
break;
|
|
202
|
+
case "rtl":
|
|
203
|
+
s = (x - v) / a;
|
|
204
|
+
break;
|
|
205
|
+
default:
|
|
206
|
+
s = (v - o) / a;
|
|
207
|
+
}
|
|
208
|
+
const m = g.value + s * (p.value - g.value);
|
|
209
|
+
console.log("click", m, V.value.formatValue(m)), Q(V.value.formatValue(m), e);
|
|
210
|
+
}, j = S(null), ne = (e, a) => {
|
|
211
|
+
if (!l.disabled) {
|
|
212
|
+
const t = V.value.offsetValues(n.value, e, a);
|
|
213
|
+
d("beforeChange", F(n.value)), A(t.values), j.value = t.value;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
w(() => {
|
|
217
|
+
if (j.value !== null) {
|
|
218
|
+
const e = n.value.indexOf(j.value);
|
|
219
|
+
e >= 0 && y.value?.focus(e);
|
|
220
|
+
}
|
|
221
|
+
j.value = null;
|
|
222
|
+
});
|
|
223
|
+
const ue = k(() => r.value.rangeDraggableTrack && O.value === null ? (process.env.NODE_ENV !== "production" && X(!1, "`draggableTrack` is not supported when `step` is `null`."), !1) : r.value.rangeDraggableTrack), U = (e, a) => {
|
|
224
|
+
console.log("onStartMove-valueIndex", a), K(e, a), d("beforeChange", F(n.value));
|
|
225
|
+
}, re = k(() => G.value !== -1);
|
|
226
|
+
w(() => {
|
|
227
|
+
if (!re.value) {
|
|
228
|
+
const e = n.value.lastIndexOf(ae.value);
|
|
229
|
+
y.value?.focus(e);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
const I = k(() => [...J.value].sort((e, a) => e - a)), [oe, se] = k(() => r.value.rangeEnabled ? [I.value[0], I.value[I.value.length - 1]] : [g.value, I.value[0]]).value;
|
|
233
|
+
Z({
|
|
234
|
+
focus: () => {
|
|
235
|
+
y.value?.focus(0);
|
|
236
|
+
},
|
|
237
|
+
blur: () => {
|
|
238
|
+
const {
|
|
239
|
+
activeElement: e
|
|
240
|
+
} = document;
|
|
241
|
+
R.value?.contains(e) && e?.blur();
|
|
242
|
+
}
|
|
243
|
+
}), w(() => {
|
|
244
|
+
l.autoFocus && y.value?.focus(0);
|
|
245
|
+
});
|
|
246
|
+
const ie = k(() => ({
|
|
247
|
+
min: g,
|
|
248
|
+
max: p,
|
|
249
|
+
direction: B,
|
|
250
|
+
disabled: l.disabled,
|
|
251
|
+
keyboard: l.keyboard,
|
|
252
|
+
step: O,
|
|
253
|
+
included: l.included,
|
|
254
|
+
includedStart: oe,
|
|
255
|
+
includedEnd: se,
|
|
256
|
+
range: r.value.rangeEnabled,
|
|
257
|
+
tabIndex: l.tabIndex,
|
|
258
|
+
ariaLabelForHandle: l.ariaLabelForHandle,
|
|
259
|
+
ariaLabelledByForHandle: l.ariaLabelledByForHandle,
|
|
260
|
+
ariaRequired: l.ariaRequired,
|
|
261
|
+
ariaValueTextFormatterForHandle: l.ariaValueTextFormatterForHandle,
|
|
262
|
+
styles: l.styles || {},
|
|
263
|
+
classNames: l.classNames || {}
|
|
264
|
+
}));
|
|
265
|
+
return be(ie.value), () => {
|
|
266
|
+
const {
|
|
267
|
+
prefixCls: e = "vc-slider",
|
|
268
|
+
id: a,
|
|
269
|
+
// Status
|
|
270
|
+
disabled: t = !1,
|
|
271
|
+
vertical: o,
|
|
272
|
+
// Style
|
|
273
|
+
startPoint: i,
|
|
274
|
+
trackStyle: b,
|
|
275
|
+
handleStyle: x,
|
|
276
|
+
railStyle: v,
|
|
277
|
+
dotStyle: f,
|
|
278
|
+
activeDotStyle: s,
|
|
279
|
+
// Decorations
|
|
280
|
+
dots: m,
|
|
281
|
+
handleRender: L,
|
|
282
|
+
activeHandleRender: P,
|
|
283
|
+
// Components
|
|
284
|
+
track: $,
|
|
285
|
+
classNames: q,
|
|
286
|
+
styles: M
|
|
287
|
+
} = l;
|
|
288
|
+
return E("div", {
|
|
289
|
+
ref: R,
|
|
290
|
+
class: W(e, [Y.class], {
|
|
291
|
+
[`${e}-disabled`]: t,
|
|
292
|
+
[`${e}-vertical`]: o,
|
|
293
|
+
[`${e}-horizontal`]: !o,
|
|
294
|
+
[`${e}-with-marks`]: D.value.length
|
|
295
|
+
}),
|
|
296
|
+
style: Y.style,
|
|
297
|
+
onMousedown: te,
|
|
298
|
+
id: a
|
|
299
|
+
}, [E("div", {
|
|
300
|
+
class: W(`${e}-rail`, q?.rail),
|
|
301
|
+
style: {
|
|
302
|
+
...v,
|
|
303
|
+
...M?.rail
|
|
304
|
+
}
|
|
305
|
+
}, null), $ && E(ke, {
|
|
306
|
+
prefixCls: e,
|
|
307
|
+
trackStyle: b,
|
|
308
|
+
values: n.value,
|
|
309
|
+
startPoint: i,
|
|
310
|
+
onStartMove: ue.value ? U : void 0
|
|
311
|
+
}, null), E(Se, {
|
|
312
|
+
prefixCls: e,
|
|
313
|
+
marks: D.value,
|
|
314
|
+
dots: m,
|
|
315
|
+
style: f,
|
|
316
|
+
activeStyle: s
|
|
317
|
+
}, null), E(me, {
|
|
318
|
+
ref: y,
|
|
319
|
+
prefixCls: e,
|
|
320
|
+
handleStyle: x,
|
|
321
|
+
values: J.value,
|
|
322
|
+
draggingIndex: G.value,
|
|
323
|
+
draggingDelete: le.value,
|
|
324
|
+
onStartMove: U,
|
|
325
|
+
onOffsetChange: ne,
|
|
326
|
+
onFocus: (H) => d("focus", H),
|
|
327
|
+
onBlur: (H) => d("blur", H),
|
|
328
|
+
handleRender: L,
|
|
329
|
+
activeHandleRender: P,
|
|
330
|
+
onChangeComplete: _,
|
|
331
|
+
onDelete: r.value.rangeEditable ? ee : () => {
|
|
332
|
+
}
|
|
333
|
+
}, null), E(xe, {
|
|
334
|
+
prefixCls: e,
|
|
335
|
+
marks: D.value,
|
|
336
|
+
onClick: Q
|
|
337
|
+
}, null)]);
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
export {
|
|
342
|
+
Me as default
|
|
343
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=require("vue"),f=require("classnames"),m=require("../context.cjs"),g=require("../util.cjs"),p=(i,{attrs:u})=>{const{prefixCls:o,value:e,activeStyle:t}=i,{min:s,max:r,direction:a,included:d,includedStart:v,includedEnd:y}=m.useInjectSlider(),c=`${o}-dot`,n=d&&v<=e&&e<=y;let l={...g.getDirectionStyle(a.value,e,s.value,r.value)};return n&&(l={...l,...typeof t=="function"?t(e):t}),S.createVNode("span",{class:f(c,{[`${c}-active`]:n}),style:{...l,...u.style}},null)};exports.default=p;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSProperties, FunctionalComponent } from 'vue';
|
|
2
|
+
export interface DotProps {
|
|
3
|
+
prefixCls: string;
|
|
4
|
+
value: number;
|
|
5
|
+
style?: CSSProperties | ((dotValue: number) => CSSProperties);
|
|
6
|
+
activeStyle?: CSSProperties | ((dotValue: number) => CSSProperties);
|
|
7
|
+
}
|
|
8
|
+
declare const Dot: FunctionalComponent<DotProps>;
|
|
9
|
+
export default Dot;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createVNode as p } from "vue";
|
|
2
|
+
import v from "classnames";
|
|
3
|
+
import { useInjectSlider as y } from "../context.js";
|
|
4
|
+
import { getDirectionStyle as S } from "../util.js";
|
|
5
|
+
const N = (c, {
|
|
6
|
+
attrs: n
|
|
7
|
+
}) => {
|
|
8
|
+
const {
|
|
9
|
+
prefixCls: r,
|
|
10
|
+
value: e,
|
|
11
|
+
activeStyle: t
|
|
12
|
+
} = c, {
|
|
13
|
+
min: a,
|
|
14
|
+
max: s,
|
|
15
|
+
direction: d,
|
|
16
|
+
included: m,
|
|
17
|
+
includedStart: u,
|
|
18
|
+
includedEnd: f
|
|
19
|
+
} = y(), l = `${r}-dot`, i = m && u <= e && e <= f;
|
|
20
|
+
let o = {
|
|
21
|
+
...S(d.value, e, a.value, s.value)
|
|
22
|
+
};
|
|
23
|
+
return i && (o = {
|
|
24
|
+
...o,
|
|
25
|
+
...typeof t == "function" ? t(e) : t
|
|
26
|
+
}), p("span", {
|
|
27
|
+
class: v(l, {
|
|
28
|
+
[`${l}-active`]: i
|
|
29
|
+
}),
|
|
30
|
+
style: {
|
|
31
|
+
...o,
|
|
32
|
+
...n.style
|
|
33
|
+
}
|
|
34
|
+
}, null);
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
N as default
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),p=require("../context.cjs"),f=require("./Dot.cjs"),S=(u,{attrs:a})=>{const{prefixCls:l,marks:o,dots:c,activeStyle:n}=u,{min:i,max:d,step:s}=p.useInjectSlider(),v=r.computed(()=>{const e=new Set;if(o.forEach(t=>{e.add(t.value)}),c&&s!==null){let t=i.value;for(;t<=d.value;)e.add(t),t+=s.value}return Array.from(e)});return r.createVNode("div",{class:`${l}-step`},[v.value.map(e=>r.createVNode(f.default,{prefixCls:l,key:e,value:e,style:{...a.style},activeStyle:n},null))])};exports.default=S;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CSSProperties, FunctionalComponent } from 'vue';
|
|
2
|
+
import { InternalMarkObj } from '../Marks';
|
|
3
|
+
export interface StepsProps {
|
|
4
|
+
prefixCls: string;
|
|
5
|
+
marks: InternalMarkObj[];
|
|
6
|
+
dots?: boolean;
|
|
7
|
+
style?: CSSProperties | ((dotValue: number) => CSSProperties);
|
|
8
|
+
activeStyle?: CSSProperties | ((dotValue: number) => CSSProperties);
|
|
9
|
+
}
|
|
10
|
+
declare const Steps: FunctionalComponent<StepsProps>;
|
|
11
|
+
export default Steps;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { computed as d, createVNode as s } from "vue";
|
|
2
|
+
import { useInjectSlider as f } from "../context.js";
|
|
3
|
+
import v from "./Dot.js";
|
|
4
|
+
const h = (o, {
|
|
5
|
+
attrs: a
|
|
6
|
+
}) => {
|
|
7
|
+
const {
|
|
8
|
+
prefixCls: r,
|
|
9
|
+
marks: c,
|
|
10
|
+
dots: n,
|
|
11
|
+
activeStyle: u
|
|
12
|
+
} = o, {
|
|
13
|
+
min: i,
|
|
14
|
+
max: m,
|
|
15
|
+
step: l
|
|
16
|
+
} = f(), p = d(() => {
|
|
17
|
+
const e = /* @__PURE__ */ new Set();
|
|
18
|
+
if (c.forEach((t) => {
|
|
19
|
+
e.add(t.value);
|
|
20
|
+
}), n && l !== null) {
|
|
21
|
+
let t = i.value;
|
|
22
|
+
for (; t <= m.value; )
|
|
23
|
+
e.add(t), t += l.value;
|
|
24
|
+
}
|
|
25
|
+
return Array.from(e);
|
|
26
|
+
});
|
|
27
|
+
return s("div", {
|
|
28
|
+
class: `${r}-step`
|
|
29
|
+
}, [p.value.map((e) => s(v, {
|
|
30
|
+
prefixCls: r,
|
|
31
|
+
key: e,
|
|
32
|
+
value: e,
|
|
33
|
+
style: {
|
|
34
|
+
...a.style
|
|
35
|
+
},
|
|
36
|
+
activeStyle: u
|
|
37
|
+
}, null))]);
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
h as default
|
|
41
|
+
};
|