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
|
@@ -1,79 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
41
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
42
|
-
if (ar || !(i in from)) {
|
|
43
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
44
|
-
ar[i] = from[i];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.RangeSliderKnob = exports.RangeSliderHighlight = exports.RangeSliderLabel = exports.RangeSliderGutter = exports.RangeSlider = void 0;
|
|
54
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
55
|
-
var clsx_1 = __importDefault(require("clsx"));
|
|
56
|
-
var react_1 = __importDefault(require("fast-deep-equal/react"));
|
|
57
|
-
var react_2 = require("react");
|
|
58
|
-
var useDragValueEffect_1 = require("../hooks/useDragValueEffect");
|
|
59
|
-
var useRect_1 = require("../hooks/useRect");
|
|
60
|
-
var utils_1 = require("../utils");
|
|
61
|
-
exports.RangeSlider = (0, react_2.forwardRef)(function (_a, ref) {
|
|
62
|
-
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
63
|
-
var children = _a.children, className = _a.className, _k = _a.areLabelsVisible, areLabelsVisible = _k === void 0 ? true : _k, _l = _a.decimalPlaces, decimalPlaces = _l === void 0 ? 2 : _l, _m = _a.knobPadding, knobPadding = _m === void 0 ? 20 : _m, maxValue = _a.max, minValue = _a.min, _o = _a.orientation, orientation = _o === void 0 ? 'vertical' : _o, externalRange = _a.range, _p = _a.steps, steps = _p === void 0 ? -1 : _p, _q = _a.usesDefaultStyles, usesDefaultStyles = _q === void 0 ? false : _q, onRangeChange = _a.onRangeChange, props = __rest(_a, ["children", "className", "areLabelsVisible", "decimalPlaces", "knobPadding", "max", "min", "orientation", "range", "steps", "usesDefaultStyles", "onRangeChange"]);
|
|
64
|
-
var getPositionByValue = function (value) { return (value - minValue) / (maxValue - minValue); };
|
|
65
|
-
var getPositionByDisplacement = function (displacement) { return displacement / (orientation === 'horizontal' ? bodyRect.width : bodyRect.height); };
|
|
66
|
-
var getValueByPosition = function (position) { return position * (maxValue - minValue) + minValue; };
|
|
67
|
-
var getValueByDisplacement = function (displacement) { return getValueByPosition(getPositionByDisplacement(displacement)); };
|
|
68
|
-
var getDisplacementByPosition = function (position) { return position * (orientation === 'horizontal' ? bodyRect.width : bodyRect.height); };
|
|
69
|
-
var getDisplacementByValue = function (value) { return getDisplacementByPosition(getPositionByValue(value)); };
|
|
70
|
-
var getClosestSteppedValue = function (value) {
|
|
71
|
-
var n = breakpoints.length;
|
|
72
|
-
var idx = 0;
|
|
73
|
-
var diff = Infinity;
|
|
74
|
-
for (var i = 0; i < n; i++) {
|
|
75
|
-
var t = breakpoints[i];
|
|
76
|
-
var d = Math.abs(value - t);
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import isDeepEqual from 'fast-deep-equal/react';
|
|
4
|
+
import { forwardRef, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { useDragValueEffect } from '../hooks/useDragValueEffect.js';
|
|
6
|
+
import { useRect } from '../hooks/useRect.js';
|
|
7
|
+
import { asComponentDict, asStyleDict, cloneStyledElement, styles } from '../utils/index.js';
|
|
8
|
+
export const RangeSlider = forwardRef(({ children, className, areLabelsVisible = true, decimalPlaces = 2, knobPadding = 20, max: maxValue, min: minValue, orientation = 'vertical', range: externalRange, steps = -1, usesDefaultStyles = false, onRangeChange, ...props }, ref) => {
|
|
9
|
+
const getPositionByValue = (value) => (value - minValue) / (maxValue - minValue);
|
|
10
|
+
const getPositionByDisplacement = (displacement) => displacement / (orientation === 'horizontal' ? bodyRect.width : bodyRect.height);
|
|
11
|
+
const getValueByPosition = (position) => position * (maxValue - minValue) + minValue;
|
|
12
|
+
const getValueByDisplacement = (displacement) => getValueByPosition(getPositionByDisplacement(displacement));
|
|
13
|
+
const getDisplacementByPosition = (position) => position * (orientation === 'horizontal' ? bodyRect.width : bodyRect.height);
|
|
14
|
+
const getDisplacementByValue = (value) => getDisplacementByPosition(getPositionByValue(value));
|
|
15
|
+
const getClosestSteppedValue = (value) => {
|
|
16
|
+
const n = breakpoints.length;
|
|
17
|
+
let idx = 0;
|
|
18
|
+
let diff = Infinity;
|
|
19
|
+
for (let i = 0; i < n; i++) {
|
|
20
|
+
const t = breakpoints[i];
|
|
21
|
+
const d = Math.abs(value - t);
|
|
77
22
|
if (d < diff) {
|
|
78
23
|
diff = d;
|
|
79
24
|
idx = i;
|
|
@@ -81,143 +26,130 @@ exports.RangeSlider = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
81
26
|
}
|
|
82
27
|
return breakpoints[idx];
|
|
83
28
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
initialValue:
|
|
91
|
-
transform:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
29
|
+
const bodyRef = useRef(null);
|
|
30
|
+
const bodyRect = useRect(bodyRef);
|
|
31
|
+
const startKnobRef = useRef(null);
|
|
32
|
+
const endKnobRef = useRef(null);
|
|
33
|
+
const [range, setRange] = useState(externalRange ?? [minValue, maxValue]);
|
|
34
|
+
const { isDragging: [isDraggingStartKnob], isReleasing: [isReleasingStartKnob], value: [startValue, setStartValue] } = useDragValueEffect(startKnobRef, {
|
|
35
|
+
initialValue: externalRange?.[0] ?? minValue,
|
|
36
|
+
transform: (value, dx, dy) => {
|
|
37
|
+
const delta = orientation === 'horizontal' ? dx : dy;
|
|
38
|
+
const dMin = getDisplacementByValue(minValue);
|
|
39
|
+
const dMax = getDisplacementByValue(range[1]);
|
|
40
|
+
const dCurr = getDisplacementByValue(value) + delta;
|
|
96
41
|
return getValueByDisplacement(Math.max(dMin, Math.min(dMax, dCurr)));
|
|
97
42
|
},
|
|
98
|
-
}, [minValue, orientation, bodyRect.size.width, bodyRect.size.height, range[1]])
|
|
99
|
-
|
|
100
|
-
initialValue:
|
|
101
|
-
transform:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
43
|
+
}, [minValue, orientation, bodyRect.size.width, bodyRect.size.height, range[1]]);
|
|
44
|
+
const { isDragging: [isDraggingEndKnob], isReleasing: [isReleasingEndKnob], value: [endValue, setEndValue] } = useDragValueEffect(endKnobRef, {
|
|
45
|
+
initialValue: externalRange?.[1] ?? maxValue,
|
|
46
|
+
transform: (value, dx, dy) => {
|
|
47
|
+
const delta = orientation === 'horizontal' ? dx : dy;
|
|
48
|
+
const dMin = getDisplacementByValue(range[0]);
|
|
49
|
+
const dMax = getDisplacementByValue(maxValue);
|
|
50
|
+
const dCurr = getDisplacementByValue(value) + delta;
|
|
106
51
|
return getValueByDisplacement(Math.max(dMin, Math.min(dMax, dCurr)));
|
|
107
52
|
},
|
|
108
|
-
}, [maxValue, orientation, bodyRect.size.width, bodyRect.size.height, range[0]])
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
53
|
+
}, [maxValue, orientation, bodyRect.size.width, bodyRect.size.height, range[0]]);
|
|
54
|
+
const breakpoints = [minValue, ...[...Array(steps)].map((v, i) => minValue + (i + 1) * (maxValue - minValue) / (1 + steps)), maxValue];
|
|
55
|
+
const [start, end] = range.map(getDisplacementByValue);
|
|
56
|
+
const highlightLength = end - start;
|
|
57
|
+
useEffect(() => {
|
|
113
58
|
if (range[0] === startValue)
|
|
114
59
|
return;
|
|
115
60
|
setRange([startValue, range[1]]);
|
|
116
|
-
onRangeChange
|
|
61
|
+
onRangeChange?.(range);
|
|
117
62
|
}, [startValue]);
|
|
118
|
-
|
|
63
|
+
useEffect(() => {
|
|
119
64
|
if (range[1] === endValue)
|
|
120
65
|
return;
|
|
121
66
|
setRange([range[0], endValue]);
|
|
122
|
-
onRangeChange
|
|
67
|
+
onRangeChange?.(range);
|
|
123
68
|
}, [endValue]);
|
|
124
|
-
|
|
125
|
-
if (isDraggingStartKnob || isDraggingEndKnob || (
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (isDraggingStartKnob || isDraggingEndKnob || isDeepEqual(externalRange, range))
|
|
126
71
|
return;
|
|
127
|
-
setRange(externalRange
|
|
72
|
+
setRange(externalRange ?? [minValue, maxValue]);
|
|
128
73
|
}, [externalRange]);
|
|
129
|
-
|
|
74
|
+
useEffect(() => {
|
|
130
75
|
if (steps < 0)
|
|
131
76
|
return;
|
|
132
77
|
setStartValue(getClosestSteppedValue(startValue));
|
|
133
78
|
}, [isReleasingStartKnob]);
|
|
134
|
-
|
|
79
|
+
useEffect(() => {
|
|
135
80
|
if (steps < 0 || !isReleasingEndKnob)
|
|
136
81
|
return;
|
|
137
82
|
setEndValue(getClosestSteppedValue(endValue));
|
|
138
83
|
}, [isReleasingEndKnob]);
|
|
139
|
-
|
|
140
|
-
gutter:
|
|
141
|
-
highlight:
|
|
142
|
-
knob:
|
|
143
|
-
label:
|
|
84
|
+
const components = asComponentDict(children, {
|
|
85
|
+
gutter: RangeSliderGutter,
|
|
86
|
+
highlight: RangeSliderHighlight,
|
|
87
|
+
knob: RangeSliderKnob,
|
|
88
|
+
label: RangeSliderLabel,
|
|
144
89
|
});
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return ((
|
|
148
|
-
style:
|
|
149
|
-
}),
|
|
150
|
-
style:
|
|
151
|
-
}),
|
|
90
|
+
const fixedStyles = getFixedStyles({ orientation, highlightLength, start, knobPadding });
|
|
91
|
+
const defaultStyles = usesDefaultStyles ? getDefaultStyles({ isReleasingStartKnob, isReleasingEndKnob, orientation }) : undefined;
|
|
92
|
+
return (_jsx("div", { ...props, ref: ref, className: clsx(className, orientation), "data-component": 'range-slider', children: _jsxs("div", { ref: bodyRef, style: fixedStyles.body, children: [cloneStyledElement(components.gutter ?? _jsx(RangeSliderGutter, { style: defaultStyles?.gutter }), {
|
|
93
|
+
style: styles(fixedStyles.gutter),
|
|
94
|
+
}), cloneStyledElement(components.highlight ?? _jsx(RangeSliderHighlight, { style: defaultStyles?.highlight }), {
|
|
95
|
+
style: styles(fixedStyles.highlight),
|
|
96
|
+
}), cloneStyledElement(components.knob ?? _jsx(RangeSliderKnob, { style: styles(defaultStyles?.knob, {
|
|
152
97
|
transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',
|
|
153
98
|
}) }), {
|
|
154
99
|
ref: startKnobRef,
|
|
155
|
-
disabled: (
|
|
156
|
-
className: (
|
|
100
|
+
disabled: isDeepEqual([startValue, endValue], [maxValue, maxValue]),
|
|
101
|
+
className: clsx({
|
|
157
102
|
dragging: isDraggingStartKnob,
|
|
158
103
|
releasing: isReleasingStartKnob,
|
|
159
104
|
}),
|
|
160
|
-
style:
|
|
161
|
-
pointerEvents: (
|
|
105
|
+
style: styles(fixedStyles.knob, {
|
|
106
|
+
pointerEvents: isDeepEqual([startValue, endValue], [minValue, minValue]) ? 'none' : 'auto',
|
|
162
107
|
}, orientation === 'horizontal' ? {
|
|
163
|
-
marginLeft:
|
|
108
|
+
marginLeft: `${start}px`,
|
|
164
109
|
} : {
|
|
165
|
-
marginTop:
|
|
110
|
+
marginTop: `${start}px`,
|
|
166
111
|
}),
|
|
167
|
-
}, (
|
|
112
|
+
}, _jsx("div", { style: fixedStyles.knobHitbox }), areLabelsVisible && cloneStyledElement(components.label ?? _jsx(RangeSliderLabel, { style: styles(defaultStyles?.label, {
|
|
168
113
|
transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',
|
|
169
114
|
}) }), {
|
|
170
|
-
className: (
|
|
115
|
+
className: clsx({
|
|
171
116
|
dragging: isDraggingStartKnob || isDraggingEndKnob,
|
|
172
117
|
releasing: isReleasingStartKnob || isReleasingEndKnob,
|
|
173
118
|
}),
|
|
174
|
-
style:
|
|
175
|
-
}, Number(startValue.toFixed(decimalPlaces)).toLocaleString())),
|
|
119
|
+
style: styles(fixedStyles.label),
|
|
120
|
+
}, Number(startValue.toFixed(decimalPlaces)).toLocaleString())), cloneStyledElement(components.knob ?? _jsx(RangeSliderKnob, { style: styles(defaultStyles?.knob, {
|
|
176
121
|
transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',
|
|
177
122
|
}) }), {
|
|
178
123
|
ref: endKnobRef,
|
|
179
|
-
disabled: (
|
|
180
|
-
className: (
|
|
124
|
+
disabled: isDeepEqual([startValue, endValue], [maxValue, maxValue]),
|
|
125
|
+
className: clsx({
|
|
181
126
|
dragging: isDraggingEndKnob,
|
|
182
127
|
releasing: isDraggingEndKnob,
|
|
183
128
|
}),
|
|
184
|
-
style:
|
|
185
|
-
pointerEvents: (
|
|
129
|
+
style: styles(fixedStyles.knob, {
|
|
130
|
+
pointerEvents: isDeepEqual([startValue, endValue], [maxValue, maxValue]) ? 'none' : 'auto',
|
|
186
131
|
}, orientation === 'horizontal' ? {
|
|
187
|
-
marginLeft:
|
|
132
|
+
marginLeft: `${end}px`,
|
|
188
133
|
} : {
|
|
189
|
-
marginTop:
|
|
134
|
+
marginTop: `${end}px`,
|
|
190
135
|
}),
|
|
191
|
-
}, (
|
|
136
|
+
}, _jsx("div", { style: fixedStyles.knobHitbox }), areLabelsVisible && cloneStyledElement(components.label ?? _jsx(RangeSliderLabel, { style: styles(defaultStyles?.label, {
|
|
192
137
|
transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',
|
|
193
138
|
}) }), {
|
|
194
|
-
className: (
|
|
139
|
+
className: clsx({
|
|
195
140
|
dragging: isDraggingEndKnob,
|
|
196
141
|
releasing: isReleasingEndKnob,
|
|
197
142
|
}),
|
|
198
|
-
style:
|
|
199
|
-
}, Number(endValue.toFixed(decimalPlaces)).toLocaleString()))] }) }))
|
|
143
|
+
style: styles(fixedStyles.label),
|
|
144
|
+
}, Number(endValue.toFixed(decimalPlaces)).toLocaleString()))] }) }));
|
|
200
145
|
});
|
|
201
|
-
Object.defineProperty(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return (0, jsx_runtime_1.jsx)("div", __assign({}, props, { ref: ref, "data-child": 'label' }));
|
|
209
|
-
});
|
|
210
|
-
exports.RangeSliderHighlight = (0, react_2.forwardRef)(function (_a, ref) {
|
|
211
|
-
var props = __rest(_a, []);
|
|
212
|
-
return (0, jsx_runtime_1.jsx)("div", __assign({}, props, { ref: ref, "data-child": 'highlight' }));
|
|
213
|
-
});
|
|
214
|
-
exports.RangeSliderKnob = (0, react_2.forwardRef)(function (_a, ref) {
|
|
215
|
-
var props = __rest(_a, []);
|
|
216
|
-
return (0, jsx_runtime_1.jsx)("div", __assign({}, props, { ref: ref, "data-child": 'knob' }));
|
|
217
|
-
});
|
|
218
|
-
function getFixedStyles(_a) {
|
|
219
|
-
var _b = _a.orientation, orientation = _b === void 0 ? 'horizontal' : _b, _c = _a.highlightLength, highlightLength = _c === void 0 ? 0 : _c, _d = _a.start, start = _d === void 0 ? 0 : _d, _e = _a.knobPadding, knobPadding = _e === void 0 ? 0 : _e;
|
|
220
|
-
return (0, utils_1.asStyleDict)({
|
|
146
|
+
Object.defineProperty(RangeSlider, 'displayName', { value: 'RangeSlider', writable: false });
|
|
147
|
+
export const RangeSliderGutter = forwardRef(({ ...props }, ref) => _jsx("div", { ...props, ref: ref, "data-child": 'gutter' }));
|
|
148
|
+
export const RangeSliderLabel = forwardRef(({ ...props }, ref) => _jsx("div", { ...props, ref: ref, "data-child": 'label' }));
|
|
149
|
+
export const RangeSliderHighlight = forwardRef(({ ...props }, ref) => _jsx("div", { ...props, ref: ref, "data-child": 'highlight' }));
|
|
150
|
+
export const RangeSliderKnob = forwardRef(({ ...props }, ref) => _jsx("div", { ...props, ref: ref, "data-child": 'knob' }));
|
|
151
|
+
function getFixedStyles({ orientation = 'horizontal', highlightLength = 0, start = 0, knobPadding = 0 }) {
|
|
152
|
+
return asStyleDict({
|
|
221
153
|
body: {
|
|
222
154
|
height: '100%',
|
|
223
155
|
width: '100%',
|
|
@@ -230,13 +162,19 @@ function getFixedStyles(_a) {
|
|
|
230
162
|
width: '100%',
|
|
231
163
|
height: '100%',
|
|
232
164
|
},
|
|
233
|
-
highlight:
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
165
|
+
highlight: {
|
|
166
|
+
height: '100%',
|
|
167
|
+
left: '0',
|
|
168
|
+
position: 'absolute',
|
|
169
|
+
top: '0',
|
|
170
|
+
...orientation === 'horizontal' ? {
|
|
171
|
+
width: `${highlightLength}px`,
|
|
172
|
+
transform: `translate3d(${start}px, 0, 0)`,
|
|
173
|
+
} : {
|
|
174
|
+
height: `${highlightLength}px`,
|
|
175
|
+
transform: `translate3d(0, ${start}px, 0)`,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
240
178
|
knob: {
|
|
241
179
|
bottom: '0',
|
|
242
180
|
left: '0',
|
|
@@ -249,12 +187,12 @@ function getFixedStyles(_a) {
|
|
|
249
187
|
},
|
|
250
188
|
knobHitbox: {
|
|
251
189
|
background: 'transparent',
|
|
252
|
-
height:
|
|
253
|
-
left:
|
|
254
|
-
padding:
|
|
190
|
+
height: `calc(100% + ${knobPadding * 2}px)`,
|
|
191
|
+
left: `-${knobPadding}px`,
|
|
192
|
+
padding: `${knobPadding}px`,
|
|
255
193
|
position: 'absolute',
|
|
256
|
-
top:
|
|
257
|
-
width:
|
|
194
|
+
top: `-${knobPadding}px`,
|
|
195
|
+
width: `calc(100% + ${knobPadding * 2}px)`,
|
|
258
196
|
},
|
|
259
197
|
label: {
|
|
260
198
|
pointerEvents: 'none',
|
|
@@ -263,9 +201,8 @@ function getFixedStyles(_a) {
|
|
|
263
201
|
},
|
|
264
202
|
});
|
|
265
203
|
}
|
|
266
|
-
function getDefaultStyles(
|
|
267
|
-
|
|
268
|
-
return (0, utils_1.asStyleDict)({
|
|
204
|
+
function getDefaultStyles({ isReleasingStartKnob = false, isReleasingEndKnob = false, orientation = 'horizontal' }) {
|
|
205
|
+
return asStyleDict({
|
|
269
206
|
gutter: {
|
|
270
207
|
background: 'rgba(255, 255, 255, .2)',
|
|
271
208
|
},
|
|
@@ -287,11 +224,17 @@ function getDefaultStyles(_a) {
|
|
|
287
224
|
transitionTimingFunction: 'ease-out',
|
|
288
225
|
width: '20px',
|
|
289
226
|
},
|
|
290
|
-
label:
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
227
|
+
label: {
|
|
228
|
+
background: 'transparent',
|
|
229
|
+
color: '#fff',
|
|
230
|
+
textAlign: 'center',
|
|
231
|
+
transitionDuration: '100ms',
|
|
232
|
+
transitionTimingFunction: 'ease-out',
|
|
233
|
+
...orientation === 'horizontal' ? {
|
|
234
|
+
top: 'calc(100% + 10px)',
|
|
235
|
+
} : {
|
|
236
|
+
left: 'calc(100% + 10px)',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
295
239
|
});
|
|
296
240
|
}
|
|
297
|
-
//# sourceMappingURL=RangeSlider.js.map
|
|
@@ -1,89 +1,58 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.RotatingGallery = void 0;
|
|
29
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
|
-
var clsx_1 = __importDefault(require("clsx"));
|
|
31
|
-
var react_1 = require("react");
|
|
32
|
-
var useInterval_1 = require("../hooks/useInterval");
|
|
33
|
-
var Each_1 = require("../operators/Each");
|
|
34
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { forwardRef, useEffect } from 'react';
|
|
4
|
+
import { useInterval } from '../hooks/useInterval.js';
|
|
5
|
+
import { Each } from '../operators/Each.js';
|
|
6
|
+
import { asClassNameDict, asStyleDict, styles } from '../utils/index.js';
|
|
35
7
|
/**
|
|
36
8
|
* A component displaying rotating images.
|
|
37
9
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
onIndexChange === null || onIndexChange === void 0 ? void 0 : onIndexChange(newValue);
|
|
10
|
+
export const RotatingGallery = forwardRef(({ children, className, index = 0, lazy = true, rotationDuration = 5000, srcs = [], transitionDuration = 500, usesDefaultStyles = true, onIndexChange, ImageComponent, ...props }, ref) => {
|
|
11
|
+
const handleIndexChange = (newValue) => {
|
|
12
|
+
onIndexChange?.(newValue);
|
|
42
13
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
14
|
+
const fixedClassNames = getFixedClassNames();
|
|
15
|
+
const fixedStyles = getFixedStyles({ transitionDuration });
|
|
16
|
+
const defaultStyles = usesDefaultStyles ? getDefaultStyles() : undefined;
|
|
17
|
+
useInterval(() => {
|
|
47
18
|
handleIndexChange((index + 1) % srcs.length);
|
|
48
19
|
}, rotationDuration, undefined, [JSON.stringify(srcs), index]);
|
|
49
|
-
|
|
50
|
-
onIndexChange
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
onIndexChange?.(index);
|
|
51
22
|
}, [index]);
|
|
52
|
-
return ((
|
|
53
|
-
|
|
54
|
-
return ImageComponent ? ((
|
|
23
|
+
return (_jsx("div", { ...props, ref: ref, className: clsx(className, fixedClassNames.root), "data-component": 'rotating-gallery', children: _jsx(Each, { in: srcs, children: (src, idx) => {
|
|
24
|
+
const isVisible = idx === index;
|
|
25
|
+
return ImageComponent ? (_jsx(ImageComponent, { className: clsx(fixedClassNames.image), "data-child": 'item', index: idx, isVisible: isVisible, src: src, style: styles(fixedStyles.image, defaultStyles?.image, usesDefaultStyles ? {
|
|
55
26
|
opacity: isVisible ? '1' : '0',
|
|
56
|
-
} : {}) })) : ((
|
|
27
|
+
} : {}) })) : (_jsx("img", { className: clsx(fixedClassNames.image), "data-child": 'item', loading: lazy ? 'lazy' : 'eager', src: src, style: styles(fixedStyles.image, defaultStyles?.image, usesDefaultStyles ? {
|
|
57
28
|
opacity: isVisible ? '1' : '0',
|
|
58
29
|
} : {}) }));
|
|
59
|
-
} }) }))
|
|
30
|
+
} }) }));
|
|
60
31
|
});
|
|
61
|
-
Object.defineProperty(
|
|
32
|
+
Object.defineProperty(RotatingGallery, 'displayName', { value: 'RotatingGallery', writable: false });
|
|
62
33
|
function getFixedClassNames() {
|
|
63
|
-
return
|
|
64
|
-
root: (
|
|
65
|
-
image: (
|
|
34
|
+
return asClassNameDict({
|
|
35
|
+
root: clsx('rotating-gallery'),
|
|
36
|
+
image: clsx('image'),
|
|
66
37
|
});
|
|
67
38
|
}
|
|
68
|
-
function getFixedStyles(
|
|
69
|
-
|
|
70
|
-
return (0, utils_1.asStyleDict)({
|
|
39
|
+
function getFixedStyles({ transitionDuration = 0 }) {
|
|
40
|
+
return asStyleDict({
|
|
71
41
|
image: {
|
|
72
42
|
height: '100%',
|
|
73
43
|
left: '0',
|
|
74
44
|
position: 'absolute',
|
|
75
45
|
top: '0',
|
|
76
46
|
width: '100%',
|
|
77
|
-
transitionDuration:
|
|
47
|
+
transitionDuration: `${transitionDuration}ms`,
|
|
78
48
|
},
|
|
79
49
|
});
|
|
80
50
|
}
|
|
81
51
|
function getDefaultStyles() {
|
|
82
|
-
return
|
|
52
|
+
return asStyleDict({
|
|
83
53
|
image: {
|
|
84
54
|
transitionProperty: 'opacity',
|
|
85
55
|
transitionTimingFunction: 'linear',
|
|
86
56
|
},
|
|
87
57
|
});
|
|
88
58
|
}
|
|
89
|
-
//# sourceMappingURL=RotatingGallery.js.map
|
|
@@ -1,68 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.SelectableButton = void 0;
|
|
42
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
43
|
-
var react_1 = require("react");
|
|
44
|
-
exports.SelectableButton = (0, react_1.forwardRef)(function (_a, ref) {
|
|
45
|
-
var _b;
|
|
46
|
-
var children = _a.children, _c = _a.isDeselectable, isDeselectable = _c === void 0 ? false : _c, _d = _a.isDisabled, isDisabled = _d === void 0 ? false : _d, _e = _a.isSelected, externalIsSelected = _e === void 0 ? false : _e, label = _a.label, onDeselect = _a.onDeselect, onSelect = _a.onSelect, props = __rest(_a, ["children", "isDeselectable", "isDisabled", "isSelected", "label", "onDeselect", "onSelect"]);
|
|
47
|
-
var _f = __read((0, react_1.useState)(externalIsSelected), 2), isSelected = _f[0], setIsSelected = _f[1];
|
|
48
|
-
var toggleSelection = function () {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useState } from 'react';
|
|
3
|
+
export const SelectableButton = forwardRef(({ children, isDeselectable = false, isDisabled = false, isSelected: externalIsSelected = false, label, onDeselect, onSelect, ...props }, ref) => {
|
|
4
|
+
const [isSelected, setIsSelected] = useState(externalIsSelected);
|
|
5
|
+
const toggleSelection = () => {
|
|
49
6
|
if (isDisabled)
|
|
50
7
|
return;
|
|
51
8
|
if (isSelected) {
|
|
52
9
|
if (!isDeselectable)
|
|
53
10
|
return;
|
|
54
11
|
setIsSelected(false);
|
|
55
|
-
onDeselect
|
|
12
|
+
onDeselect?.();
|
|
56
13
|
}
|
|
57
14
|
else {
|
|
58
15
|
setIsSelected(true);
|
|
59
|
-
onSelect
|
|
16
|
+
onSelect?.();
|
|
60
17
|
}
|
|
61
18
|
};
|
|
62
|
-
|
|
19
|
+
useEffect(() => {
|
|
63
20
|
setIsSelected(externalIsSelected);
|
|
64
21
|
}, [externalIsSelected]);
|
|
65
|
-
return ((
|
|
22
|
+
return (_jsx("button", { ...props, ref: ref, "data-component": 'selectable-button', disabled: isDisabled || isSelected && !isDeselectable, onClick: () => toggleSelection(), children: children?.({ isDeselectable, isDisabled, isSelected, label }) ?? label }));
|
|
66
23
|
});
|
|
67
|
-
Object.defineProperty(
|
|
68
|
-
//# sourceMappingURL=SelectableButton.js.map
|
|
24
|
+
Object.defineProperty(SelectableButton, 'displayName', { value: 'SelectableButton', writable: false });
|