@quen-ui/components 1.1.0 → 1.2.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/dist/Banner/Banner.cjs.js +96 -0
- package/dist/Banner/Banner.d.ts +4 -0
- package/dist/Banner/Banner.es.js +96 -0
- package/dist/Banner/index.d.ts +2 -0
- package/dist/Banner/styles.cjs.js +113 -0
- package/dist/Banner/styles.d.ts +12 -0
- package/dist/Banner/styles.es.js +113 -0
- package/dist/Banner/types.d.ts +40 -0
- package/dist/Dropdown/Dropdown.cjs.js +47 -43
- package/dist/Dropdown/Dropdown.d.ts +1 -1
- package/dist/Dropdown/Dropdown.es.js +48 -44
- package/dist/Dropdown/DropdownItem.cjs.js +10 -13
- package/dist/Dropdown/DropdownItem.es.js +10 -13
- package/dist/Dropdown/DropdownList.cjs.js +0 -2
- package/dist/Dropdown/DropdownList.es.js +0 -2
- package/dist/InputBase/InputBase.cjs.js +55 -12
- package/dist/InputBase/InputBase.d.ts +1 -1
- package/dist/InputBase/InputBase.es.js +57 -14
- package/dist/InputBase/styles.cjs.js +44 -4
- package/dist/InputBase/styles.d.ts +7 -1
- package/dist/InputBase/styles.es.js +45 -5
- package/dist/InputBase/types.d.ts +5 -1
- package/dist/InputDate/styles.d.ts +1 -1
- package/dist/InputNumber/styles.d.ts +1 -1
- package/dist/Select/Select.cjs.js +2 -5
- package/dist/Select/Select.es.js +2 -5
- package/dist/Select/helpers.d.ts +8 -0
- package/dist/Select/styles.d.ts +1 -1
- package/dist/Select/useSelect.d.ts +8 -0
- package/dist/Slider/Slider.cjs.js +122 -224
- package/dist/Slider/Slider.d.ts +1 -1
- package/dist/Slider/Slider.es.js +125 -227
- package/dist/Slider/styles.cjs.js +49 -32
- package/dist/Slider/styles.d.ts +1 -1
- package/dist/Slider/styles.es.js +49 -32
- package/dist/Slider/useSlider.cjs.js +194 -0
- package/dist/Slider/useSlider.d.ts +11 -0
- package/dist/Slider/useSlider.es.js +194 -0
- package/dist/Stepper/Step.cjs.js +114 -0
- package/dist/Stepper/Step.d.ts +2 -0
- package/dist/Stepper/Step.es.js +114 -0
- package/dist/Stepper/StepContent.cjs.js +10 -0
- package/dist/Stepper/StepContent.d.ts +4 -0
- package/dist/Stepper/StepContent.es.js +10 -0
- package/dist/Stepper/StepLabel.cjs.js +28 -0
- package/dist/Stepper/StepLabel.d.ts +2 -0
- package/dist/Stepper/StepLabel.es.js +28 -0
- package/dist/Stepper/Stepper.cjs.js +54 -0
- package/dist/Stepper/Stepper.d.ts +2 -0
- package/dist/Stepper/Stepper.es.js +54 -0
- package/dist/Stepper/StepperContext.cjs.js +13 -0
- package/dist/Stepper/StepperContext.d.ts +3 -0
- package/dist/Stepper/StepperContext.es.js +13 -0
- package/dist/Stepper/index.cjs.js +10 -0
- package/dist/Stepper/index.d.ts +12 -0
- package/dist/Stepper/index.es.js +11 -0
- package/dist/Stepper/styles.cjs.js +149 -0
- package/dist/Stepper/styles.d.ts +44 -0
- package/dist/Stepper/styles.es.js +149 -0
- package/dist/Stepper/types.d.ts +70 -0
- package/dist/TextField/TextField.cjs.js +4 -0
- package/dist/TextField/TextField.d.ts +1 -1
- package/dist/TextField/TextField.es.js +4 -0
- package/dist/TextField/styles.d.ts +1 -1
- package/dist/Textarea/styles.d.ts +1 -1
- package/dist/Tooltip/Tooltip.cjs.js +3 -1
- package/dist/Tooltip/Tooltip.es.js +4 -2
- package/dist/index.cjs.js +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +4 -0
- package/package.json +1 -1
package/dist/Slider/Slider.es.js
CHANGED
|
@@ -1,272 +1,170 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { SliderTooltipStyled, SliderThumbStyled, SliderContainer, SliderTrackStyled, SliderProgressStyled, SliderMarksWrapperStyled, SliderMarkStyled, SliderDotStyled, SliderLabelStyled } from "./styles.es.js";
|
|
4
4
|
import { cnMerge } from "@quen-ui/helpers";
|
|
5
|
+
import { useSlider } from "./useSlider.es.js";
|
|
5
6
|
const Slider = ({
|
|
6
|
-
value = 0,
|
|
7
7
|
min = 0,
|
|
8
8
|
max = 100,
|
|
9
9
|
step = 1,
|
|
10
|
-
|
|
11
|
-
showTooltip = true,
|
|
12
|
-
range,
|
|
10
|
+
range = false,
|
|
13
11
|
orientation = "horizontal",
|
|
14
12
|
marks = [],
|
|
15
|
-
|
|
13
|
+
disabled = false,
|
|
14
|
+
showTooltip = true,
|
|
15
|
+
draggableTrack = false,
|
|
16
|
+
color = "violet",
|
|
16
17
|
tooltip,
|
|
17
18
|
style,
|
|
18
19
|
className,
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
value,
|
|
21
|
+
onChange
|
|
21
22
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
23
|
+
const {
|
|
24
|
+
values,
|
|
25
|
+
trackRef,
|
|
26
|
+
percentStart,
|
|
27
|
+
percentEnd,
|
|
28
|
+
onPointerDownThumb,
|
|
29
|
+
onPointerDownTrack,
|
|
30
|
+
onKeyDown,
|
|
31
|
+
isDragging
|
|
32
|
+
} = useSlider({
|
|
33
|
+
value,
|
|
34
|
+
min,
|
|
35
|
+
max,
|
|
36
|
+
step,
|
|
37
|
+
onChange,
|
|
38
|
+
range,
|
|
39
|
+
disabled,
|
|
40
|
+
orientation,
|
|
41
|
+
draggableTrack
|
|
42
|
+
});
|
|
43
|
+
const [isActive, setIsActive] = useState(false);
|
|
44
|
+
const renderThumb = useCallback(
|
|
45
|
+
(target, currentValue, percent) => {
|
|
46
|
+
const valText = `${target === "start" ? "From" : "To"} ${currentValue}`;
|
|
47
|
+
const isVert = orientation === "vertical";
|
|
48
|
+
return /* @__PURE__ */ jsxs(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
style: {
|
|
52
|
+
position: "absolute",
|
|
53
|
+
zIndex: 2,
|
|
54
|
+
overflow: "visible",
|
|
55
|
+
[isVert ? "top" : "left"]: isVert ? `${100 - percent}%` : `${percent}%`,
|
|
56
|
+
[isVert ? "left" : "top"]: "50%",
|
|
57
|
+
transform: "translate(-50%, -50%)"
|
|
58
|
+
},
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
SliderTooltipStyled,
|
|
62
|
+
{
|
|
63
|
+
isVertical: isVert,
|
|
64
|
+
open: isActive,
|
|
65
|
+
show: showTooltip,
|
|
66
|
+
text: currentValue,
|
|
67
|
+
position: isVert ? "right" : "top",
|
|
68
|
+
value: percent,
|
|
69
|
+
...tooltip,
|
|
70
|
+
classNameContent: cnMerge(
|
|
71
|
+
"quen-ui__slider__tooltip__content",
|
|
72
|
+
tooltip?.classNameContent
|
|
73
|
+
),
|
|
74
|
+
children: null
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
SliderThumbStyled,
|
|
79
|
+
{
|
|
80
|
+
role: "slider",
|
|
81
|
+
tabIndex: disabled ? -1 : 0,
|
|
82
|
+
"aria-disabled": disabled,
|
|
83
|
+
"aria-orientation": orientation,
|
|
84
|
+
"aria-valuemin": min,
|
|
85
|
+
"aria-valuemax": max,
|
|
86
|
+
"aria-valuenow": currentValue,
|
|
87
|
+
"aria-valuetext": valText,
|
|
88
|
+
"aria-label": range ? valText : "Slider value",
|
|
89
|
+
disabled,
|
|
90
|
+
color,
|
|
91
|
+
isVertical: isVert,
|
|
92
|
+
onPointerDown: (e) => {
|
|
93
|
+
setIsActive(true);
|
|
94
|
+
onPointerDownThumb(target, e);
|
|
95
|
+
},
|
|
96
|
+
onPointerUp: () => setIsActive(false),
|
|
97
|
+
onMouseEnter: () => setIsActive(true),
|
|
98
|
+
onMouseLeave: () => !isDragging && setIsActive(false),
|
|
99
|
+
onFocus: () => setIsActive(true),
|
|
100
|
+
onBlur: () => !isDragging && setIsActive(false),
|
|
101
|
+
onKeyDown: (e) => onKeyDown(target, e)
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
target
|
|
107
|
+
);
|
|
51
108
|
},
|
|
52
|
-
[
|
|
109
|
+
[
|
|
110
|
+
orientation,
|
|
111
|
+
showTooltip,
|
|
112
|
+
tooltip,
|
|
113
|
+
disabled,
|
|
114
|
+
min,
|
|
115
|
+
max,
|
|
116
|
+
color,
|
|
117
|
+
range,
|
|
118
|
+
isDragging,
|
|
119
|
+
isActive,
|
|
120
|
+
onPointerDownThumb,
|
|
121
|
+
onKeyDown
|
|
122
|
+
]
|
|
53
123
|
);
|
|
54
|
-
const setByValue = (raw, target) => {
|
|
55
|
-
const snapped = snap(raw);
|
|
56
|
-
let next = [0, 0];
|
|
57
|
-
if (target === "end") {
|
|
58
|
-
next = [startEndValues[0], snapped];
|
|
59
|
-
} else if (target === "start") {
|
|
60
|
-
next = [snapped, startEndValues[1]];
|
|
61
|
-
} else if (!range) {
|
|
62
|
-
next = [snapped, snapped];
|
|
63
|
-
} else if (range) {
|
|
64
|
-
const distanceToStart = Math.abs(snapped - startEndValues[0]);
|
|
65
|
-
const distanceToEnd = Math.abs(snapped - startEndValues[1]);
|
|
66
|
-
next = distanceToStart <= distanceToEnd ? [snapped, startEndValues[1]] : [startEndValues[0], snapped];
|
|
67
|
-
}
|
|
68
|
-
if (next[0] > next[1]) {
|
|
69
|
-
next = [next[1], next[0]];
|
|
70
|
-
}
|
|
71
|
-
updateValue(next);
|
|
72
|
-
};
|
|
73
|
-
const handleTrackClick = (e) => {
|
|
74
|
-
if (!trackRef.current || draggableRef.current) return;
|
|
75
|
-
const rect = trackRef.current.getBoundingClientRect();
|
|
76
|
-
const startClient = "touches" in e ? e.touches[0] : e;
|
|
77
|
-
const ratio = orientation === "vertical" ? 1 - (startClient.clientY - rect.top) / rect.height : (startClient.clientX - rect.left) / rect.width;
|
|
78
|
-
const raw = min + ratio * (max - min);
|
|
79
|
-
setByValue(raw);
|
|
80
|
-
};
|
|
81
|
-
const handleMove = (e, target) => {
|
|
82
|
-
if (!trackRef.current) return;
|
|
83
|
-
const rect = trackRef.current.getBoundingClientRect();
|
|
84
|
-
const client = "touches" in e ? e.touches[0] : e;
|
|
85
|
-
let ratio = orientation === "vertical" ? 1 - (client.clientY - rect.top) / rect.height : (client.clientX - rect.left) / rect.width;
|
|
86
|
-
ratio = Math.min(1, Math.max(0, ratio));
|
|
87
|
-
const rawValue = min + ratio * (max - min);
|
|
88
|
-
setByValue(rawValue, target);
|
|
89
|
-
};
|
|
90
|
-
const bindEvents = (target) => ({
|
|
91
|
-
onMouseDown: (e) => {
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
setCurrentHandle(target);
|
|
94
|
-
setIsMouseDown(true);
|
|
95
|
-
const move = (ev) => handleMove(ev, target);
|
|
96
|
-
const up = () => {
|
|
97
|
-
setCurrentHandle(null);
|
|
98
|
-
setIsMouseDown(false);
|
|
99
|
-
document.removeEventListener("mousemove", move);
|
|
100
|
-
document.removeEventListener("mouseup", up, { capture: true });
|
|
101
|
-
};
|
|
102
|
-
document.addEventListener("mousemove", move);
|
|
103
|
-
document.addEventListener("mouseup", up, { capture: true });
|
|
104
|
-
},
|
|
105
|
-
onTouchStart: () => {
|
|
106
|
-
setCurrentHandle(target);
|
|
107
|
-
setIsMouseDown(true);
|
|
108
|
-
const move = (ev) => handleMove(ev, target);
|
|
109
|
-
const up = () => {
|
|
110
|
-
setCurrentHandle(null);
|
|
111
|
-
setIsMouseDown(false);
|
|
112
|
-
document.removeEventListener("touchmove", move);
|
|
113
|
-
document.removeEventListener("touchend", up);
|
|
114
|
-
};
|
|
115
|
-
document.addEventListener("touchmove", move);
|
|
116
|
-
document.addEventListener("touchend", up);
|
|
117
|
-
},
|
|
118
|
-
onMouseMove: () => {
|
|
119
|
-
setCurrentHandle(target);
|
|
120
|
-
},
|
|
121
|
-
onMouseLeave: () => {
|
|
122
|
-
if (!isMouseDown) {
|
|
123
|
-
setCurrentHandle(null);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const startDragWholeRange = (e) => {
|
|
128
|
-
if (!draggableTrack || !range || !trackRef.current) {
|
|
129
|
-
handleTrackClick(e);
|
|
130
|
-
} else {
|
|
131
|
-
const rect = trackRef.current.getBoundingClientRect();
|
|
132
|
-
const startClient = "touches" in e ? e.touches[0] : e;
|
|
133
|
-
const startRatio = orientation === "vertical" ? 1 - (startClient.clientY - rect.top) / rect.height : (startClient.clientX - rect.left) / rect.width;
|
|
134
|
-
const startValue = min + startRatio * (max - min);
|
|
135
|
-
const rangeSize = startEndValues[1] - startEndValues[0];
|
|
136
|
-
const offsetInsideRange = startValue - startEndValues[0];
|
|
137
|
-
const move = (ev) => {
|
|
138
|
-
const client = "touches" in ev ? ev.touches[0] : ev;
|
|
139
|
-
let ratio = orientation === "vertical" ? 1 - (client.clientY - rect.top) / rect.height : (client.clientX - rect.left) / rect.width;
|
|
140
|
-
ratio = Math.min(1, Math.max(0, ratio));
|
|
141
|
-
const rawValue = min + ratio * (max - min);
|
|
142
|
-
let newStart = rawValue - offsetInsideRange;
|
|
143
|
-
let newEnd = newStart + rangeSize;
|
|
144
|
-
if (newStart < min) {
|
|
145
|
-
newStart = min;
|
|
146
|
-
newEnd = min + rangeSize;
|
|
147
|
-
}
|
|
148
|
-
if (newEnd > max) {
|
|
149
|
-
newStart = max - rangeSize;
|
|
150
|
-
}
|
|
151
|
-
const snappedStart = snap(newStart);
|
|
152
|
-
const snappedEnd = snap(snappedStart + rangeSize);
|
|
153
|
-
const next = [snappedStart, snappedEnd];
|
|
154
|
-
updateValue(next);
|
|
155
|
-
};
|
|
156
|
-
const stop = () => {
|
|
157
|
-
document.removeEventListener("mousemove", move);
|
|
158
|
-
document.removeEventListener("mouseup", stop);
|
|
159
|
-
document.removeEventListener("touchmove", move);
|
|
160
|
-
document.removeEventListener("touchend", stop);
|
|
161
|
-
setTimeout(() => {
|
|
162
|
-
draggableRef.current = false;
|
|
163
|
-
}, 500);
|
|
164
|
-
};
|
|
165
|
-
document.addEventListener("mousemove", move);
|
|
166
|
-
document.addEventListener("mouseup", stop);
|
|
167
|
-
document.addEventListener("touchmove", move);
|
|
168
|
-
document.addEventListener("touchend", stop);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
124
|
return /* @__PURE__ */ jsxs(
|
|
172
125
|
SliderContainer,
|
|
173
126
|
{
|
|
174
127
|
disabled,
|
|
175
128
|
style,
|
|
176
129
|
className,
|
|
177
|
-
role: "
|
|
178
|
-
"aria-label": "
|
|
179
|
-
"aria-orientation": orientation,
|
|
180
|
-
"aria-disabled": disabled,
|
|
181
|
-
"aria-valuemax": max,
|
|
182
|
-
"aria-valuemin": min,
|
|
183
|
-
"aria-valuenow": startEndValues[0],
|
|
130
|
+
role: "group",
|
|
131
|
+
"aria-label": "Slider",
|
|
184
132
|
children: [
|
|
185
133
|
/* @__PURE__ */ jsx(
|
|
186
134
|
SliderTrackStyled,
|
|
187
135
|
{
|
|
188
|
-
"data-testid": "slider-track",
|
|
189
|
-
disabled,
|
|
190
136
|
ref: trackRef,
|
|
137
|
+
disabled,
|
|
191
138
|
isVertical: orientation === "vertical",
|
|
192
|
-
|
|
139
|
+
onPointerDown: onPointerDownTrack
|
|
193
140
|
}
|
|
194
141
|
),
|
|
195
142
|
/* @__PURE__ */ jsx(
|
|
196
143
|
SliderProgressStyled,
|
|
197
144
|
{
|
|
198
145
|
isRange: range,
|
|
199
|
-
range: [
|
|
200
|
-
"data-testid": "slider-progress",
|
|
146
|
+
range: [percentStart, percentEnd],
|
|
201
147
|
disabled,
|
|
202
148
|
color,
|
|
203
|
-
onMouseDown: startDragWholeRange,
|
|
204
|
-
onTouchStart: startDragWholeRange,
|
|
205
149
|
isVertical: orientation === "vertical"
|
|
206
150
|
}
|
|
207
151
|
),
|
|
208
|
-
range
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
open: currentHandle === "start",
|
|
213
|
-
show: showTooltip,
|
|
214
|
-
text: startEndValues[0],
|
|
215
|
-
position: orientation === "vertical" ? "right" : "top",
|
|
216
|
-
value: percentOf(startEndValues[0]),
|
|
217
|
-
...tooltip,
|
|
218
|
-
classNameContent: cnMerge(
|
|
219
|
-
"quen-ui__slider__tooltip__content",
|
|
220
|
-
tooltip?.classNameContent
|
|
221
|
-
),
|
|
222
|
-
children: /* @__PURE__ */ jsx(
|
|
223
|
-
SliderThumbStyled,
|
|
224
|
-
{
|
|
225
|
-
disabled,
|
|
226
|
-
color,
|
|
227
|
-
isVertical: orientation === "vertical",
|
|
228
|
-
...bindEvents("start")
|
|
229
|
-
}
|
|
230
|
-
)
|
|
231
|
-
}
|
|
232
|
-
),
|
|
233
|
-
/* @__PURE__ */ jsx(
|
|
234
|
-
SliderTooltipStyled,
|
|
235
|
-
{
|
|
236
|
-
isVertical: orientation === "vertical",
|
|
237
|
-
open: currentHandle === "end",
|
|
238
|
-
show: showTooltip,
|
|
239
|
-
text: startEndValues[1],
|
|
240
|
-
position: orientation === "vertical" ? "right" : "top",
|
|
241
|
-
value: percentOf(startEndValues[1]),
|
|
242
|
-
...tooltip,
|
|
243
|
-
classNameContent: cnMerge(
|
|
244
|
-
"quen-ui__slider__tooltip__content",
|
|
245
|
-
tooltip?.classNameContent
|
|
246
|
-
),
|
|
247
|
-
children: /* @__PURE__ */ jsx(
|
|
248
|
-
SliderThumbStyled,
|
|
249
|
-
{
|
|
250
|
-
disabled,
|
|
251
|
-
color,
|
|
252
|
-
isVertical: orientation === "vertical",
|
|
253
|
-
...bindEvents("end")
|
|
254
|
-
}
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
),
|
|
152
|
+
range ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
153
|
+
renderThumb("start", values[0], percentStart),
|
|
154
|
+
renderThumb("end", values[1], percentEnd)
|
|
155
|
+
] }) : renderThumb("end", values[1], percentEnd),
|
|
258
156
|
/* @__PURE__ */ jsx(SliderMarksWrapperStyled, { isVertical: orientation === "vertical", children: marks.map((m) => /* @__PURE__ */ jsxs(
|
|
259
157
|
SliderMarkStyled,
|
|
260
158
|
{
|
|
261
159
|
className: m.className,
|
|
262
|
-
|
|
263
|
-
|
|
160
|
+
style: m.style,
|
|
161
|
+
isVertical: orientation === "vertical",
|
|
162
|
+
value: (m.value - min) / (max - min) * 100,
|
|
163
|
+
onPointerDown: (e) => {
|
|
164
|
+
if (disabled) return;
|
|
264
165
|
e.stopPropagation();
|
|
265
|
-
|
|
166
|
+
onPointerDownTrack(e);
|
|
266
167
|
},
|
|
267
|
-
isVertical: orientation === "vertical",
|
|
268
|
-
value: percentOf(m.value),
|
|
269
|
-
style: m.style,
|
|
270
168
|
children: [
|
|
271
169
|
/* @__PURE__ */ jsx(SliderDotStyled, {}),
|
|
272
170
|
m.label && /* @__PURE__ */ jsx(SliderLabelStyled, { isVertical: orientation === "vertical", children: m.label })
|
|
@@ -5,52 +5,59 @@ const Text = require("../typography/Text/Text.cjs.js");
|
|
|
5
5
|
const Tooltip = require("../Tooltip/Tooltip.cjs.js");
|
|
6
6
|
const SliderContainer = styled.div`
|
|
7
7
|
position: relative;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`};
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
padding: 0.5rem;
|
|
10
|
+
${({ disabled }) => disabled && `pointer-events: none;`}
|
|
12
11
|
`;
|
|
13
12
|
const SliderTrackStyled = styled.div.withConfig({
|
|
14
|
-
shouldForwardProp: (prop) => !["isVertical", "
|
|
13
|
+
shouldForwardProp: (prop) => !["isVertical", "disabled"].includes(prop)
|
|
15
14
|
})`
|
|
16
15
|
position: absolute;
|
|
17
16
|
background: ${({ theme, disabled }) => disabled ? theme.components.Slider.trackDisabledBackgroundColor : theme.components.Slider.trackBackgroundColor};
|
|
18
17
|
border-radius: ${({ theme }) => theme.components.Slider.radius};
|
|
19
18
|
cursor: pointer;
|
|
20
|
-
|
|
19
|
+
|
|
21
20
|
${({ isVertical }) => isVertical ? styled.css`
|
|
21
|
+
left: 50%;
|
|
22
|
+
top: 0;
|
|
23
|
+
bottom: 0;
|
|
22
24
|
width: 6px;
|
|
23
|
-
|
|
25
|
+
transform: translateX(-50%);
|
|
24
26
|
` : styled.css`
|
|
27
|
+
top: 50%;
|
|
28
|
+
left: 0;
|
|
29
|
+
right: 0;
|
|
25
30
|
height: 6px;
|
|
26
|
-
|
|
31
|
+
transform: translateY(-50%);
|
|
27
32
|
`}
|
|
28
33
|
`;
|
|
29
34
|
const SliderProgressStyled = styled.div.withConfig({
|
|
30
|
-
shouldForwardProp: (prop) => !["isVertical", "color", "range", "isRange"].includes(prop)
|
|
35
|
+
shouldForwardProp: (prop) => !["isVertical", "color", "range", "isRange", "disabled"].includes(prop)
|
|
31
36
|
})`
|
|
32
37
|
position: absolute;
|
|
33
|
-
${({ theme, isVertical }) => isVertical ? styled.css`
|
|
34
|
-
width: ${theme.components.Slider.height};
|
|
35
|
-
` : styled.css`
|
|
36
|
-
height: ${theme.components.Slider.height};
|
|
37
|
-
`};
|
|
38
38
|
background: ${({ theme, disabled, color = "violet" }) => disabled ? theme.components.Slider.progressDisabledBackgroundColor : theme.colors[color][9]};
|
|
39
39
|
border-radius: ${({ theme }) => theme.components.Slider.radius};
|
|
40
40
|
cursor: pointer;
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
z-index: 1;
|
|
42
|
+
|
|
43
|
+
${({ isVertical, range, isRange, theme }) => isVertical ? styled.css`
|
|
44
|
+
left: 50%;
|
|
45
|
+
width: ${theme.components.Slider.height || "6px"};
|
|
46
|
+
transform: translateX(-50%);
|
|
47
|
+
top: ${100 - (isRange ? range[1] : range[1])}%;
|
|
43
48
|
height: ${isRange ? range[1] - range[0] : range[1]}%;
|
|
44
|
-
bottom: ${isRange ? range[0] : 0}%;
|
|
45
49
|
` : styled.css`
|
|
50
|
+
top: 50%;
|
|
51
|
+
height: ${theme.components.Slider.height || "6px"};
|
|
52
|
+
transform: translateY(-50%);
|
|
46
53
|
left: ${isRange ? range[0] : 0}%;
|
|
47
|
-
width: ${isRange ?
|
|
54
|
+
width: ${isRange ? range[1] - range[0] : range[1]}%;
|
|
48
55
|
`}
|
|
49
56
|
`;
|
|
50
57
|
const SliderThumbStyled = styled.div.withConfig({
|
|
51
58
|
shouldForwardProp: (prop) => !["isVertical", "color"].includes(prop)
|
|
52
59
|
})`
|
|
53
|
-
position:
|
|
60
|
+
position: relative;
|
|
54
61
|
width: 1rem;
|
|
55
62
|
height: 1rem;
|
|
56
63
|
background: white;
|
|
@@ -58,7 +65,10 @@ const SliderThumbStyled = styled.div.withConfig({
|
|
|
58
65
|
${({ theme, disabled, color = "violet" }) => disabled ? theme.components.Slider.progressDisabledBackgroundColor : theme.colors[color][9]};
|
|
59
66
|
border-radius: 50%;
|
|
60
67
|
cursor: grab;
|
|
61
|
-
transition:
|
|
68
|
+
transition:
|
|
69
|
+
box-shadow 0.15s ease,
|
|
70
|
+
transform 0.15s ease;
|
|
71
|
+
z-index: 2;
|
|
62
72
|
|
|
63
73
|
&:active {
|
|
64
74
|
cursor: ${({ disabled }) => disabled ? "not-allowed" : "grabbing"};
|
|
@@ -115,21 +125,28 @@ const SliderLabelStyled = styled(Text).attrs({ size: "s" }).withConfig({
|
|
|
115
125
|
`}
|
|
116
126
|
`;
|
|
117
127
|
const SliderTooltipStyled = styled(Tooltip).withConfig({
|
|
118
|
-
shouldForwardProp: (prop) => !["isVertical"
|
|
128
|
+
shouldForwardProp: (prop) => !["isVertical"].includes(prop)
|
|
119
129
|
})`
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
z-index: 1;
|
|
124
|
-
position: absolute;
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
justify-content: center;
|
|
125
133
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
position: absolute;
|
|
135
|
+
z-index: 100;
|
|
136
|
+
pointer-events: none;
|
|
137
|
+
user-select: none;
|
|
138
|
+
|
|
139
|
+
transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
|
|
140
|
+
|
|
141
|
+
${({ isVertical }) => isVertical ? styled.css`
|
|
142
|
+
left: calc(100% + 8px);
|
|
143
|
+
top: 50%;
|
|
144
|
+
transform: translateY(-50%);
|
|
129
145
|
` : styled.css`
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
146
|
+
bottom: calc(100% + 8px);
|
|
147
|
+
left: 50%;
|
|
148
|
+
transform: translateX(-50%);
|
|
149
|
+
`}
|
|
133
150
|
`;
|
|
134
151
|
const SliderMarksWrapperStyled = styled.div.withConfig({
|
|
135
152
|
shouldForwardProp: (prop) => !["isVertical"].includes(prop)
|
package/dist/Slider/styles.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const SliderLabelStyled: import('styled-components/dist/types').I
|
|
|
28
28
|
}>> & string & Omit<import('react').FC<import('..').ITextProps>, keyof import('react').Component<any, {}, any>>;
|
|
29
29
|
export declare const SliderTooltipStyled: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('..').ITooltipProps, {
|
|
30
30
|
isVertical: boolean;
|
|
31
|
-
|
|
31
|
+
open: boolean;
|
|
32
32
|
}>> & string & Omit<({ children, text, position, open: controlledOpen, show, zIndex, color, width, className, classNameContent, ...props }: import('..').ITooltipProps) => React.ReactElement, keyof import('react').Component<any, {}, any>>;
|
|
33
33
|
export declare const SliderMarksWrapperStyled: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
34
34
|
isVertical: boolean;
|
package/dist/Slider/styles.es.js
CHANGED
|
@@ -3,52 +3,59 @@ import Text from "../typography/Text/Text.es.js";
|
|
|
3
3
|
import Tooltip from "../Tooltip/Tooltip.es.js";
|
|
4
4
|
const SliderContainer = styled.div`
|
|
5
5
|
position: relative;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`};
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
padding: 0.5rem;
|
|
8
|
+
${({ disabled }) => disabled && `pointer-events: none;`}
|
|
10
9
|
`;
|
|
11
10
|
const SliderTrackStyled = styled.div.withConfig({
|
|
12
|
-
shouldForwardProp: (prop) => !["isVertical", "
|
|
11
|
+
shouldForwardProp: (prop) => !["isVertical", "disabled"].includes(prop)
|
|
13
12
|
})`
|
|
14
13
|
position: absolute;
|
|
15
14
|
background: ${({ theme, disabled }) => disabled ? theme.components.Slider.trackDisabledBackgroundColor : theme.components.Slider.trackBackgroundColor};
|
|
16
15
|
border-radius: ${({ theme }) => theme.components.Slider.radius};
|
|
17
16
|
cursor: pointer;
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
${({ isVertical }) => isVertical ? css`
|
|
19
|
+
left: 50%;
|
|
20
|
+
top: 0;
|
|
21
|
+
bottom: 0;
|
|
20
22
|
width: 6px;
|
|
21
|
-
|
|
23
|
+
transform: translateX(-50%);
|
|
22
24
|
` : css`
|
|
25
|
+
top: 50%;
|
|
26
|
+
left: 0;
|
|
27
|
+
right: 0;
|
|
23
28
|
height: 6px;
|
|
24
|
-
|
|
29
|
+
transform: translateY(-50%);
|
|
25
30
|
`}
|
|
26
31
|
`;
|
|
27
32
|
const SliderProgressStyled = styled.div.withConfig({
|
|
28
|
-
shouldForwardProp: (prop) => !["isVertical", "color", "range", "isRange"].includes(prop)
|
|
33
|
+
shouldForwardProp: (prop) => !["isVertical", "color", "range", "isRange", "disabled"].includes(prop)
|
|
29
34
|
})`
|
|
30
35
|
position: absolute;
|
|
31
|
-
${({ theme, isVertical }) => isVertical ? css`
|
|
32
|
-
width: ${theme.components.Slider.height};
|
|
33
|
-
` : css`
|
|
34
|
-
height: ${theme.components.Slider.height};
|
|
35
|
-
`};
|
|
36
36
|
background: ${({ theme, disabled, color = "violet" }) => disabled ? theme.components.Slider.progressDisabledBackgroundColor : theme.colors[color][9]};
|
|
37
37
|
border-radius: ${({ theme }) => theme.components.Slider.radius};
|
|
38
38
|
cursor: pointer;
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
z-index: 1;
|
|
40
|
+
|
|
41
|
+
${({ isVertical, range, isRange, theme }) => isVertical ? css`
|
|
42
|
+
left: 50%;
|
|
43
|
+
width: ${theme.components.Slider.height || "6px"};
|
|
44
|
+
transform: translateX(-50%);
|
|
45
|
+
top: ${100 - (isRange ? range[1] : range[1])}%;
|
|
41
46
|
height: ${isRange ? range[1] - range[0] : range[1]}%;
|
|
42
|
-
bottom: ${isRange ? range[0] : 0}%;
|
|
43
47
|
` : css`
|
|
48
|
+
top: 50%;
|
|
49
|
+
height: ${theme.components.Slider.height || "6px"};
|
|
50
|
+
transform: translateY(-50%);
|
|
44
51
|
left: ${isRange ? range[0] : 0}%;
|
|
45
|
-
width: ${isRange ?
|
|
52
|
+
width: ${isRange ? range[1] - range[0] : range[1]}%;
|
|
46
53
|
`}
|
|
47
54
|
`;
|
|
48
55
|
const SliderThumbStyled = styled.div.withConfig({
|
|
49
56
|
shouldForwardProp: (prop) => !["isVertical", "color"].includes(prop)
|
|
50
57
|
})`
|
|
51
|
-
position:
|
|
58
|
+
position: relative;
|
|
52
59
|
width: 1rem;
|
|
53
60
|
height: 1rem;
|
|
54
61
|
background: white;
|
|
@@ -56,7 +63,10 @@ const SliderThumbStyled = styled.div.withConfig({
|
|
|
56
63
|
${({ theme, disabled, color = "violet" }) => disabled ? theme.components.Slider.progressDisabledBackgroundColor : theme.colors[color][9]};
|
|
57
64
|
border-radius: 50%;
|
|
58
65
|
cursor: grab;
|
|
59
|
-
transition:
|
|
66
|
+
transition:
|
|
67
|
+
box-shadow 0.15s ease,
|
|
68
|
+
transform 0.15s ease;
|
|
69
|
+
z-index: 2;
|
|
60
70
|
|
|
61
71
|
&:active {
|
|
62
72
|
cursor: ${({ disabled }) => disabled ? "not-allowed" : "grabbing"};
|
|
@@ -113,21 +123,28 @@ const SliderLabelStyled = styled(Text).attrs({ size: "s" }).withConfig({
|
|
|
113
123
|
`}
|
|
114
124
|
`;
|
|
115
125
|
const SliderTooltipStyled = styled(Tooltip).withConfig({
|
|
116
|
-
shouldForwardProp: (prop) => !["isVertical"
|
|
126
|
+
shouldForwardProp: (prop) => !["isVertical"].includes(prop)
|
|
117
127
|
})`
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
z-index: 1;
|
|
122
|
-
position: absolute;
|
|
128
|
+
display: flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
justify-content: center;
|
|
123
131
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
position: absolute;
|
|
133
|
+
z-index: 100;
|
|
134
|
+
pointer-events: none;
|
|
135
|
+
user-select: none;
|
|
136
|
+
|
|
137
|
+
transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
|
|
138
|
+
|
|
139
|
+
${({ isVertical }) => isVertical ? css`
|
|
140
|
+
left: calc(100% + 8px);
|
|
141
|
+
top: 50%;
|
|
142
|
+
transform: translateY(-50%);
|
|
127
143
|
` : css`
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
144
|
+
bottom: calc(100% + 8px);
|
|
145
|
+
left: 50%;
|
|
146
|
+
transform: translateX(-50%);
|
|
147
|
+
`}
|
|
131
148
|
`;
|
|
132
149
|
const SliderMarksWrapperStyled = styled.div.withConfig({
|
|
133
150
|
shouldForwardProp: (prop) => !["isVertical"].includes(prop)
|