etudes 5.2.0 → 5.3.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/components/Accordion.js +171 -205
- package/components/BurgerButton.js +40 -94
- package/components/Carousel.js +87 -123
- package/components/Collection.js +84 -120
- package/components/Counter.js +32 -63
- package/components/CoverImage.js +24 -68
- package/components/CoverVideo.js +25 -69
- package/components/DebugConsole.js +27 -79
- package/components/Dial.js +28 -65
- package/components/Dropdown.js +86 -98
- package/components/FlatSVG.js +22 -71
- package/components/Image.js +21 -50
- package/components/MasonryGrid.js +122 -257
- package/components/Panorama.js +48 -92
- package/components/PanoramaSlider.js +57 -113
- package/components/RangeSlider.js +125 -182
- package/components/RotatingGallery.js +28 -59
- package/components/SelectableButton.js +10 -54
- package/components/Slider.js +108 -159
- package/components/StepwiseSlider.js +124 -176
- package/components/SwipeContainer.js +30 -73
- package/components/TextField.js +12 -49
- package/components/Video.js +31 -61
- package/components/WithTooltip.js +117 -111
- package/components/index.js +24 -0
- package/hooks/index.js +17 -0
- package/hooks/useClickOutsideEffect.js +8 -38
- package/hooks/useDragEffect.js +20 -53
- package/hooks/useDragValueEffect.js +31 -81
- package/hooks/useImageSize.js +16 -38
- package/hooks/useInterval.js +9 -41
- package/hooks/useLoadImageEffect.js +15 -48
- package/hooks/useLoadVideoMetadataEffect.js +15 -48
- package/hooks/useMounted.js +5 -25
- package/hooks/usePrevious.js +4 -9
- package/hooks/useRect.js +9 -29
- package/hooks/useResizeEffect.js +10 -44
- package/hooks/useScrollPositionEffect.js +19 -50
- package/hooks/useSearchParamState.js +12 -34
- package/hooks/useSize.js +9 -29
- package/hooks/useTimeout.js +8 -38
- package/hooks/useVideoSize.js +16 -38
- package/hooks/useViewportSize.js +7 -27
- package/operators/Conditional.js +6 -11
- package/operators/Each.js +6 -14
- package/operators/ExtractChild.js +9 -36
- package/operators/ExtractChildren.js +7 -34
- package/operators/Repeat.js +4 -37
- package/operators/index.js +5 -0
- package/package.json +27 -41
- package/providers/ScrollPositionProvider.js +37 -60
- package/providers/index.js +1 -0
- package/utils/asClassNameDict.js +1 -5
- package/utils/asComponentDict.js +11 -16
- package/utils/asStyleDict.js +1 -5
- package/utils/cloneStyledElement.js +14 -61
- package/utils/index.js +5 -22
- package/utils/styles.js +5 -21
- package/components/Accordion.d.ts +0 -219
- package/components/Accordion.js.map +0 -1
- package/components/BurgerButton.d.ts +0 -34
- package/components/BurgerButton.js.map +0 -1
- package/components/Carousel.d.ts +0 -53
- package/components/Carousel.js.map +0 -1
- package/components/Collection.d.ts +0 -171
- package/components/Collection.js.map +0 -1
- package/components/Counter.d.ts +0 -11
- package/components/Counter.js.map +0 -1
- package/components/CoverImage.d.ts +0 -28
- package/components/CoverImage.js.map +0 -1
- package/components/CoverVideo.d.ts +0 -28
- package/components/CoverVideo.js.map +0 -1
- package/components/DebugConsole.d.ts +0 -15
- package/components/DebugConsole.js.map +0 -1
- package/components/Dial.d.ts +0 -79
- package/components/Dial.js.map +0 -1
- package/components/Dropdown.d.ts +0 -109
- package/components/Dropdown.js.map +0 -1
- package/components/FlatSVG.d.ts +0 -72
- package/components/FlatSVG.js.map +0 -1
- package/components/Image.d.ts +0 -144
- package/components/Image.js.map +0 -1
- package/components/MasonryGrid.d.ts +0 -29
- package/components/MasonryGrid.js.map +0 -1
- package/components/Panorama.d.ts +0 -77
- package/components/Panorama.js.map +0 -1
- package/components/PanoramaSlider.d.ts +0 -71
- package/components/PanoramaSlider.js.map +0 -1
- package/components/RangeSlider.d.ts +0 -34
- package/components/RangeSlider.js.map +0 -1
- package/components/RotatingGallery.d.ts +0 -91
- package/components/RotatingGallery.js.map +0 -1
- package/components/SelectableButton.d.ts +0 -19
- package/components/SelectableButton.js.map +0 -1
- package/components/Slider.d.ts +0 -160
- package/components/Slider.js.map +0 -1
- package/components/StepwiseSlider.d.ts +0 -215
- package/components/StepwiseSlider.js.map +0 -1
- package/components/SwipeContainer.d.ts +0 -21
- package/components/SwipeContainer.js.map +0 -1
- package/components/TextField.d.ts +0 -21
- package/components/TextField.js.map +0 -1
- package/components/Video.d.ts +0 -38
- package/components/Video.js.map +0 -1
- package/components/WithTooltip.d.ts +0 -32
- package/components/WithTooltip.js.map +0 -1
- package/hooks/useClickOutsideEffect.d.ts +0 -2
- package/hooks/useClickOutsideEffect.js.map +0 -1
- package/hooks/useDragEffect.d.ts +0 -48
- package/hooks/useDragEffect.js.map +0 -1
- package/hooks/useDragValueEffect.d.ts +0 -56
- package/hooks/useDragValueEffect.js.map +0 -1
- package/hooks/useImageSize.d.ts +0 -21
- package/hooks/useImageSize.js.map +0 -1
- package/hooks/useInterval.d.ts +0 -18
- package/hooks/useInterval.js.map +0 -1
- package/hooks/useLoadImageEffect.d.ts +0 -43
- package/hooks/useLoadImageEffect.js.map +0 -1
- package/hooks/useLoadVideoMetadataEffect.d.ts +0 -35
- package/hooks/useLoadVideoMetadataEffect.js.map +0 -1
- package/hooks/useMounted.d.ts +0 -1
- package/hooks/useMounted.js.map +0 -1
- package/hooks/usePrevious.d.ts +0 -19
- package/hooks/usePrevious.js.map +0 -1
- package/hooks/useRect.d.ts +0 -11
- package/hooks/useRect.js.map +0 -1
- package/hooks/useResizeEffect.d.ts +0 -17
- package/hooks/useResizeEffect.js.map +0 -1
- package/hooks/useScrollPositionEffect.d.ts +0 -13
- package/hooks/useScrollPositionEffect.js.map +0 -1
- package/hooks/useSearchParamState.d.ts +0 -34
- package/hooks/useSearchParamState.js.map +0 -1
- package/hooks/useSize.d.ts +0 -10
- package/hooks/useSize.js.map +0 -1
- package/hooks/useTimeout.d.ts +0 -10
- package/hooks/useTimeout.js.map +0 -1
- package/hooks/useVideoSize.d.ts +0 -21
- package/hooks/useVideoSize.js.map +0 -1
- package/hooks/useViewportSize.d.ts +0 -7
- package/hooks/useViewportSize.js.map +0 -1
- package/operators/Conditional.d.ts +0 -5
- package/operators/Conditional.js.map +0 -1
- package/operators/Each.d.ts +0 -7
- package/operators/Each.js.map +0 -1
- package/operators/ExtractChild.d.ts +0 -8
- package/operators/ExtractChild.js.map +0 -1
- package/operators/ExtractChildren.d.ts +0 -6
- package/operators/ExtractChildren.js.map +0 -1
- package/operators/Repeat.d.ts +0 -11
- package/operators/Repeat.js.map +0 -1
- package/providers/ScrollPositionProvider.d.ts +0 -15
- package/providers/ScrollPositionProvider.js.map +0 -1
- package/utils/asClassNameDict.d.ts +0 -3
- package/utils/asClassNameDict.js.map +0 -1
- package/utils/asComponentDict.d.ts +0 -5
- package/utils/asComponentDict.js.map +0 -1
- package/utils/asStyleDict.d.ts +0 -4
- package/utils/asStyleDict.js.map +0 -1
- package/utils/cloneStyledElement.d.ts +0 -18
- package/utils/cloneStyledElement.js.map +0 -1
- package/utils/index.d.ts +0 -5
- package/utils/index.js.map +0 -1
- package/utils/styles.d.ts +0 -2
- package/utils/styles.js.map +0 -1
package/components/Slider.js
CHANGED
|
@@ -1,53 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
25
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26
|
-
if (!m) return o;
|
|
27
|
-
var i = m.call(o), r, ar = [], e;
|
|
28
|
-
try {
|
|
29
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
30
|
-
}
|
|
31
|
-
catch (error) { e = { error: error }; }
|
|
32
|
-
finally {
|
|
33
|
-
try {
|
|
34
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
35
|
-
}
|
|
36
|
-
finally { if (e) throw e.error; }
|
|
37
|
-
}
|
|
38
|
-
return ar;
|
|
39
|
-
};
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.SliderLabel = exports.SliderKnob = exports.SliderTrack = exports.Slider = void 0;
|
|
45
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
46
|
-
var clsx_1 = __importDefault(require("clsx"));
|
|
47
|
-
var react_1 = require("react");
|
|
48
|
-
var spase_1 = require("spase");
|
|
49
|
-
var useDragValueEffect_1 = require("../hooks/useDragValueEffect");
|
|
50
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { forwardRef, useEffect, useRef } from 'react';
|
|
4
|
+
import { Rect } from 'spase';
|
|
5
|
+
import { useDragValueEffect } from '../hooks/useDragValueEffect.js';
|
|
6
|
+
import { asClassNameDict, asComponentDict, asStyleDict, cloneStyledElement, styles } from '../utils/index.js';
|
|
51
7
|
/**
|
|
52
8
|
* A slider component supporting both horizontal and vertical orientations whose
|
|
53
9
|
* sliding position (a decimal between 0.0 and 1.0, inclusive) can be two-way
|
|
@@ -62,142 +18,125 @@ var utils_1 = require("../utils");
|
|
|
62
18
|
* @exports SliderTrack The component for the slide track on either side of the
|
|
63
19
|
* knob.
|
|
64
20
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var trueNewPositionY = truePosition * rect.height + dy;
|
|
74
|
-
var trueNewPosition = orientation === 'vertical' ? Math.max(0, Math.min(1, trueNewPositionY / rect.height)) : Math.max(0, Math.min(1, trueNewPositionX / rect.width));
|
|
75
|
-
var normalizedPosition = isInverted ? 1 - trueNewPosition : trueNewPosition;
|
|
21
|
+
export const Slider = forwardRef(({ children, className, isInverted = false, isTrackInteractive = true, knobHeight = 30, knobWidth = 30, labelProvider, onlyDispatchesOnDragEnd = false, orientation = 'vertical', position: externalPosition = 0, trackPadding = 0, usesDefaultStyles = false, onDragEnd, onDragStart, onPositionChange, ...props }, ref) => {
|
|
22
|
+
const mapDragValueToPosition = (value, dx, dy) => {
|
|
23
|
+
const rect = Rect.from(bodyRef.current) ?? new Rect();
|
|
24
|
+
const truePosition = isInverted ? 1 - value : value;
|
|
25
|
+
const trueNewPositionX = truePosition * rect.width + dx;
|
|
26
|
+
const trueNewPositionY = truePosition * rect.height + dy;
|
|
27
|
+
const trueNewPosition = orientation === 'vertical' ? Math.max(0, Math.min(1, trueNewPositionY / rect.height)) : Math.max(0, Math.min(1, trueNewPositionX / rect.width));
|
|
28
|
+
const normalizedPosition = isInverted ? 1 - trueNewPosition : trueNewPosition;
|
|
76
29
|
return normalizedPosition;
|
|
77
30
|
};
|
|
78
|
-
|
|
79
|
-
var _a;
|
|
31
|
+
const trackClickHandler = (event) => {
|
|
80
32
|
if (!isTrackInteractive)
|
|
81
33
|
return;
|
|
82
|
-
|
|
34
|
+
const rect = Rect.from(bodyRef.current) ?? new Rect();
|
|
83
35
|
switch (orientation) {
|
|
84
36
|
case 'horizontal': {
|
|
85
|
-
|
|
86
|
-
|
|
37
|
+
const trackPosition = (event.clientX - rect.left) / rect.width;
|
|
38
|
+
const normalizedPosition = isInverted ? 1 - trackPosition : trackPosition;
|
|
87
39
|
setPosition(normalizedPosition);
|
|
88
40
|
break;
|
|
89
41
|
}
|
|
90
42
|
case 'vertical': {
|
|
91
|
-
|
|
92
|
-
|
|
43
|
+
const trackPosition = (event.clientY - rect.top) / rect.height;
|
|
44
|
+
const normalizedPosition = isInverted ? 1 - trackPosition : trackPosition;
|
|
93
45
|
setPosition(normalizedPosition);
|
|
94
46
|
break;
|
|
95
47
|
}
|
|
96
48
|
default: break;
|
|
97
49
|
}
|
|
98
50
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
51
|
+
const bodyRef = useRef(null);
|
|
52
|
+
const knobContainerRef = useRef(null);
|
|
53
|
+
const { isDragging: [isDragging], isReleasing: [isReleasing], value: [position, setPosition] } = useDragValueEffect(knobContainerRef, {
|
|
102
54
|
initialValue: externalPosition,
|
|
103
55
|
transform: mapDragValueToPosition,
|
|
104
|
-
onDragStart
|
|
105
|
-
onDragEnd
|
|
106
|
-
})
|
|
56
|
+
onDragStart,
|
|
57
|
+
onDragEnd,
|
|
58
|
+
});
|
|
107
59
|
// Natural position is the position affecting internal components accounting
|
|
108
60
|
// for `isInverted`.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
61
|
+
const naturalPosition = isInverted ? 1 - position : position;
|
|
62
|
+
const isAtEnd = isInverted ? position === 0 : position === 1;
|
|
63
|
+
const isAtStart = isInverted ? position === 1 : position === 0;
|
|
64
|
+
useEffect(() => {
|
|
113
65
|
if (isDragging || externalPosition === position)
|
|
114
66
|
return;
|
|
115
67
|
setPosition(externalPosition);
|
|
116
68
|
}, [externalPosition]);
|
|
117
|
-
|
|
69
|
+
useEffect(() => {
|
|
118
70
|
if (isDragging && onlyDispatchesOnDragEnd)
|
|
119
71
|
return;
|
|
120
|
-
onPositionChange
|
|
72
|
+
onPositionChange?.(position, isDragging);
|
|
121
73
|
}, [position]);
|
|
122
|
-
|
|
74
|
+
useEffect(() => {
|
|
123
75
|
if (isDragging || !onlyDispatchesOnDragEnd)
|
|
124
76
|
return;
|
|
125
|
-
onPositionChange
|
|
77
|
+
onPositionChange?.(position, true);
|
|
126
78
|
}, [isDragging]);
|
|
127
|
-
|
|
128
|
-
knob:
|
|
129
|
-
label:
|
|
130
|
-
track:
|
|
79
|
+
const components = asComponentDict(children, {
|
|
80
|
+
knob: SliderKnob,
|
|
81
|
+
label: SliderLabel,
|
|
82
|
+
track: SliderTrack,
|
|
131
83
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return ((
|
|
136
|
-
className: (
|
|
137
|
-
style:
|
|
138
|
-
height:
|
|
84
|
+
const fixedClassNames = getFixedClassNames({ orientation, isAtEnd, isAtStart, isDragging, isReleasing });
|
|
85
|
+
const fixedStyles = getFixedStyles({ orientation, isDragging, naturalPosition, knobHeight, knobWidth, isTrackInteractive });
|
|
86
|
+
const defaultStyles = usesDefaultStyles ? getDefaultStyles({ knobHeight }) : undefined;
|
|
87
|
+
return (_jsx("div", { ...props, ref: ref, className: clsx(className, fixedClassNames.root), "data-component": 'slider', children: _jsxs("div", { ref: bodyRef, style: fixedStyles.body, children: [cloneStyledElement(components.track ?? _jsx(SliderTrack, { style: defaultStyles?.track }), {
|
|
88
|
+
className: clsx('start', fixedClassNames.track),
|
|
89
|
+
style: styles(fixedStyles.track, orientation === 'vertical' ? {
|
|
90
|
+
height: `calc(${naturalPosition * 100}% - ${trackPadding <= 0 ? 0 : knobHeight * 0.5}px - ${trackPadding}px)`,
|
|
139
91
|
top: '0',
|
|
140
92
|
} : {
|
|
141
93
|
left: '0',
|
|
142
|
-
width:
|
|
94
|
+
width: `calc(${naturalPosition * 100}% - ${trackPadding <= 0 ? 0 : knobWidth * 0.5}px - ${trackPadding}px)`,
|
|
143
95
|
}),
|
|
144
96
|
onClick: trackClickHandler,
|
|
145
|
-
}, (
|
|
146
|
-
className: (
|
|
147
|
-
style:
|
|
97
|
+
}, _jsx("div", { style: fixedStyles.trackHitbox })), cloneStyledElement(components.track ?? _jsx(SliderTrack, { style: defaultStyles?.track }), {
|
|
98
|
+
className: clsx('end', fixedClassNames.track),
|
|
99
|
+
style: styles(fixedStyles.track, orientation === 'vertical' ? {
|
|
148
100
|
bottom: '0',
|
|
149
|
-
height:
|
|
101
|
+
height: `calc(${(1 - naturalPosition) * 100}% - ${trackPadding <= 0 ? 0 : knobHeight * 0.5}px - ${trackPadding}px)`,
|
|
150
102
|
} : {
|
|
151
103
|
right: '0',
|
|
152
|
-
width:
|
|
104
|
+
width: `calc(${(1 - naturalPosition) * 100}% - ${trackPadding <= 0 ? 0 : knobWidth * 0.5}px - ${trackPadding}px)`,
|
|
153
105
|
}),
|
|
154
106
|
onClick: trackClickHandler,
|
|
155
|
-
}, (
|
|
156
|
-
className: (
|
|
157
|
-
style:
|
|
158
|
-
}, labelProvider &&
|
|
159
|
-
className: (
|
|
160
|
-
style:
|
|
161
|
-
}, labelProvider(position))) })] }) }))
|
|
107
|
+
}, _jsx("div", { style: fixedStyles.trackHitbox })), _jsx("button", { ref: knobContainerRef, style: fixedStyles.knobContainer, children: cloneStyledElement(components.knob ?? _jsx(SliderKnob, { style: defaultStyles?.knob }), {
|
|
108
|
+
className: clsx(fixedClassNames.knob),
|
|
109
|
+
style: styles(fixedStyles.knob),
|
|
110
|
+
}, labelProvider && cloneStyledElement(components.label ?? _jsx(SliderLabel, { style: defaultStyles?.label }), {
|
|
111
|
+
className: clsx(fixedClassNames.label),
|
|
112
|
+
style: styles(fixedStyles.label),
|
|
113
|
+
}, labelProvider(position))) })] }) }));
|
|
162
114
|
});
|
|
163
|
-
Object.defineProperty(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
var props = __rest(_a, []);
|
|
171
|
-
return (0, jsx_runtime_1.jsx)("div", __assign({}, props, { "data-child": 'knob' }));
|
|
172
|
-
};
|
|
173
|
-
exports.SliderKnob = SliderKnob;
|
|
174
|
-
var SliderLabel = function (_a) {
|
|
175
|
-
var props = __rest(_a, []);
|
|
176
|
-
return (0, jsx_runtime_1.jsx)("div", __assign({}, props, { "data-child": 'label' }));
|
|
177
|
-
};
|
|
178
|
-
exports.SliderLabel = SliderLabel;
|
|
179
|
-
function getFixedClassNames(_a) {
|
|
180
|
-
var _b = _a.orientation, orientation = _b === void 0 ? 'vertical' : _b, _c = _a.isAtEnd, isAtEnd = _c === void 0 ? false : _c, _d = _a.isAtStart, isAtStart = _d === void 0 ? false : _d, _e = _a.isDragging, isDragging = _e === void 0 ? false : _e, _f = _a.isReleasing, isReleasing = _f === void 0 ? false : _f;
|
|
181
|
-
return (0, utils_1.asClassNameDict)({
|
|
182
|
-
root: (0, clsx_1.default)(orientation, {
|
|
115
|
+
Object.defineProperty(Slider, 'displayName', { value: 'Slider', writable: false });
|
|
116
|
+
export const SliderTrack = ({ ...props }) => _jsx("div", { ...props, "data-child": 'track' });
|
|
117
|
+
export const SliderKnob = ({ ...props }) => _jsx("div", { ...props, "data-child": 'knob' });
|
|
118
|
+
export const SliderLabel = ({ ...props }) => _jsx("div", { ...props, "data-child": 'label' });
|
|
119
|
+
function getFixedClassNames({ orientation = 'vertical', isAtEnd = false, isAtStart = false, isDragging = false, isReleasing = false }) {
|
|
120
|
+
return asClassNameDict({
|
|
121
|
+
root: clsx(orientation, {
|
|
183
122
|
'at-end': isAtEnd,
|
|
184
123
|
'at-start': isAtStart,
|
|
185
124
|
'dragging': isDragging,
|
|
186
125
|
'releasing': isReleasing,
|
|
187
126
|
}),
|
|
188
|
-
track: (
|
|
127
|
+
track: clsx(orientation, {
|
|
189
128
|
'at-end': isAtEnd,
|
|
190
129
|
'at-start': isAtStart,
|
|
191
130
|
'dragging': isDragging,
|
|
192
131
|
'releasing': isReleasing,
|
|
193
132
|
}),
|
|
194
|
-
knob: (
|
|
133
|
+
knob: clsx(orientation, {
|
|
195
134
|
'at-end': isAtEnd,
|
|
196
135
|
'at-start': isAtStart,
|
|
197
136
|
'dragging': isDragging,
|
|
198
137
|
'releasing': isReleasing,
|
|
199
138
|
}),
|
|
200
|
-
label: (
|
|
139
|
+
label: clsx(orientation, {
|
|
201
140
|
'at-end': isAtEnd,
|
|
202
141
|
'at-start': isAtStart,
|
|
203
142
|
'dragging': isDragging,
|
|
@@ -205,42 +144,54 @@ function getFixedClassNames(_a) {
|
|
|
205
144
|
}),
|
|
206
145
|
});
|
|
207
146
|
}
|
|
208
|
-
function getFixedStyles(
|
|
209
|
-
|
|
210
|
-
return (0, utils_1.asStyleDict)({
|
|
147
|
+
function getFixedStyles({ orientation = 'vertical', isDragging = false, naturalPosition = 0, knobHeight = 0, knobWidth = 0, isTrackInteractive = true }) {
|
|
148
|
+
return asStyleDict({
|
|
211
149
|
body: {
|
|
212
150
|
height: '100%',
|
|
213
151
|
width: '100%',
|
|
214
152
|
},
|
|
215
|
-
knobContainer:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
153
|
+
knobContainer: {
|
|
154
|
+
background: 'none',
|
|
155
|
+
border: 'none',
|
|
156
|
+
outline: 'none',
|
|
157
|
+
position: 'absolute',
|
|
158
|
+
transform: 'translate3d(-50%, -50%, 0)',
|
|
159
|
+
zIndex: '1',
|
|
160
|
+
...orientation === 'vertical' ? {
|
|
161
|
+
left: '50%',
|
|
162
|
+
top: `${naturalPosition * 100}%`,
|
|
163
|
+
transition: isDragging === false ? 'top 100ms ease-out' : 'none',
|
|
164
|
+
} : {
|
|
165
|
+
left: `${naturalPosition * 100}%`,
|
|
166
|
+
top: '50%',
|
|
167
|
+
transition: isDragging === false ? 'left 100ms ease-out' : 'none',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
224
170
|
knob: {
|
|
225
|
-
height:
|
|
171
|
+
height: `${knobHeight}px`,
|
|
226
172
|
touchAction: 'none',
|
|
227
|
-
width:
|
|
173
|
+
width: `${knobWidth}px`,
|
|
228
174
|
},
|
|
229
175
|
label: {
|
|
230
176
|
pointerEvents: 'none',
|
|
231
177
|
userSelect: 'none',
|
|
232
178
|
},
|
|
233
|
-
track:
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
179
|
+
track: {
|
|
180
|
+
cursor: isTrackInteractive ? 'pointer' : 'auto',
|
|
181
|
+
pointerEvents: isTrackInteractive ? 'auto' : 'none',
|
|
182
|
+
position: 'absolute',
|
|
183
|
+
...orientation === 'vertical' ? {
|
|
184
|
+
left: '0',
|
|
185
|
+
margin: '0 auto',
|
|
186
|
+
right: '0',
|
|
187
|
+
width: '100%',
|
|
188
|
+
} : {
|
|
189
|
+
bottom: '0',
|
|
190
|
+
height: '100%',
|
|
191
|
+
margin: 'auto 0',
|
|
192
|
+
top: '0',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
244
195
|
trackHitbox: {
|
|
245
196
|
height: '100%',
|
|
246
197
|
minHeight: '20px',
|
|
@@ -251,9 +202,8 @@ function getFixedStyles(_a) {
|
|
|
251
202
|
},
|
|
252
203
|
});
|
|
253
204
|
}
|
|
254
|
-
function getDefaultStyles(
|
|
255
|
-
|
|
256
|
-
return (0, utils_1.asStyleDict)({
|
|
205
|
+
function getDefaultStyles({ knobHeight = 0 }) {
|
|
206
|
+
return asStyleDict({
|
|
257
207
|
knob: {
|
|
258
208
|
alignItems: 'center',
|
|
259
209
|
background: '#fff',
|
|
@@ -264,11 +214,10 @@ function getDefaultStyles(_a) {
|
|
|
264
214
|
label: {
|
|
265
215
|
color: '#000',
|
|
266
216
|
fontSize: '12px',
|
|
267
|
-
lineHeight:
|
|
217
|
+
lineHeight: `${knobHeight}px`,
|
|
268
218
|
},
|
|
269
219
|
track: {
|
|
270
220
|
background: '#fff',
|
|
271
221
|
},
|
|
272
222
|
});
|
|
273
223
|
}
|
|
274
|
-
//# sourceMappingURL=Slider.js.map
|