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.
Files changed (164) hide show
  1. package/components/Accordion.js +171 -205
  2. package/components/BurgerButton.js +40 -94
  3. package/components/Carousel.js +87 -123
  4. package/components/Collection.js +84 -120
  5. package/components/Counter.js +32 -63
  6. package/components/CoverImage.js +24 -68
  7. package/components/CoverVideo.js +25 -69
  8. package/components/DebugConsole.js +27 -79
  9. package/components/Dial.js +28 -65
  10. package/components/Dropdown.js +86 -98
  11. package/components/FlatSVG.js +22 -71
  12. package/components/Image.js +21 -50
  13. package/components/MasonryGrid.js +122 -257
  14. package/components/Panorama.js +48 -92
  15. package/components/PanoramaSlider.js +57 -113
  16. package/components/RangeSlider.js +125 -182
  17. package/components/RotatingGallery.js +28 -59
  18. package/components/SelectableButton.js +10 -54
  19. package/components/Slider.js +108 -159
  20. package/components/StepwiseSlider.js +124 -176
  21. package/components/SwipeContainer.js +30 -73
  22. package/components/TextField.js +12 -49
  23. package/components/Video.js +31 -61
  24. package/components/WithTooltip.js +117 -111
  25. package/components/index.js +24 -0
  26. package/hooks/index.js +17 -0
  27. package/hooks/useClickOutsideEffect.js +8 -38
  28. package/hooks/useDragEffect.js +20 -53
  29. package/hooks/useDragValueEffect.js +31 -81
  30. package/hooks/useImageSize.js +16 -38
  31. package/hooks/useInterval.js +9 -41
  32. package/hooks/useLoadImageEffect.js +15 -48
  33. package/hooks/useLoadVideoMetadataEffect.js +15 -48
  34. package/hooks/useMounted.js +5 -25
  35. package/hooks/usePrevious.js +4 -9
  36. package/hooks/useRect.js +9 -29
  37. package/hooks/useResizeEffect.js +10 -44
  38. package/hooks/useScrollPositionEffect.js +19 -50
  39. package/hooks/useSearchParamState.js +12 -34
  40. package/hooks/useSize.js +9 -29
  41. package/hooks/useTimeout.js +8 -38
  42. package/hooks/useVideoSize.js +16 -38
  43. package/hooks/useViewportSize.js +7 -27
  44. package/operators/Conditional.js +6 -11
  45. package/operators/Each.js +6 -14
  46. package/operators/ExtractChild.js +9 -36
  47. package/operators/ExtractChildren.js +7 -34
  48. package/operators/Repeat.js +4 -37
  49. package/operators/index.js +5 -0
  50. package/package.json +27 -41
  51. package/providers/ScrollPositionProvider.js +37 -60
  52. package/providers/index.js +1 -0
  53. package/utils/asClassNameDict.js +1 -5
  54. package/utils/asComponentDict.js +11 -16
  55. package/utils/asStyleDict.js +1 -5
  56. package/utils/cloneStyledElement.js +14 -61
  57. package/utils/index.js +5 -22
  58. package/utils/styles.js +5 -21
  59. package/components/Accordion.d.ts +0 -219
  60. package/components/Accordion.js.map +0 -1
  61. package/components/BurgerButton.d.ts +0 -34
  62. package/components/BurgerButton.js.map +0 -1
  63. package/components/Carousel.d.ts +0 -53
  64. package/components/Carousel.js.map +0 -1
  65. package/components/Collection.d.ts +0 -171
  66. package/components/Collection.js.map +0 -1
  67. package/components/Counter.d.ts +0 -11
  68. package/components/Counter.js.map +0 -1
  69. package/components/CoverImage.d.ts +0 -28
  70. package/components/CoverImage.js.map +0 -1
  71. package/components/CoverVideo.d.ts +0 -28
  72. package/components/CoverVideo.js.map +0 -1
  73. package/components/DebugConsole.d.ts +0 -15
  74. package/components/DebugConsole.js.map +0 -1
  75. package/components/Dial.d.ts +0 -79
  76. package/components/Dial.js.map +0 -1
  77. package/components/Dropdown.d.ts +0 -109
  78. package/components/Dropdown.js.map +0 -1
  79. package/components/FlatSVG.d.ts +0 -72
  80. package/components/FlatSVG.js.map +0 -1
  81. package/components/Image.d.ts +0 -144
  82. package/components/Image.js.map +0 -1
  83. package/components/MasonryGrid.d.ts +0 -29
  84. package/components/MasonryGrid.js.map +0 -1
  85. package/components/Panorama.d.ts +0 -77
  86. package/components/Panorama.js.map +0 -1
  87. package/components/PanoramaSlider.d.ts +0 -71
  88. package/components/PanoramaSlider.js.map +0 -1
  89. package/components/RangeSlider.d.ts +0 -34
  90. package/components/RangeSlider.js.map +0 -1
  91. package/components/RotatingGallery.d.ts +0 -91
  92. package/components/RotatingGallery.js.map +0 -1
  93. package/components/SelectableButton.d.ts +0 -19
  94. package/components/SelectableButton.js.map +0 -1
  95. package/components/Slider.d.ts +0 -160
  96. package/components/Slider.js.map +0 -1
  97. package/components/StepwiseSlider.d.ts +0 -215
  98. package/components/StepwiseSlider.js.map +0 -1
  99. package/components/SwipeContainer.d.ts +0 -21
  100. package/components/SwipeContainer.js.map +0 -1
  101. package/components/TextField.d.ts +0 -21
  102. package/components/TextField.js.map +0 -1
  103. package/components/Video.d.ts +0 -38
  104. package/components/Video.js.map +0 -1
  105. package/components/WithTooltip.d.ts +0 -32
  106. package/components/WithTooltip.js.map +0 -1
  107. package/hooks/useClickOutsideEffect.d.ts +0 -2
  108. package/hooks/useClickOutsideEffect.js.map +0 -1
  109. package/hooks/useDragEffect.d.ts +0 -48
  110. package/hooks/useDragEffect.js.map +0 -1
  111. package/hooks/useDragValueEffect.d.ts +0 -56
  112. package/hooks/useDragValueEffect.js.map +0 -1
  113. package/hooks/useImageSize.d.ts +0 -21
  114. package/hooks/useImageSize.js.map +0 -1
  115. package/hooks/useInterval.d.ts +0 -18
  116. package/hooks/useInterval.js.map +0 -1
  117. package/hooks/useLoadImageEffect.d.ts +0 -43
  118. package/hooks/useLoadImageEffect.js.map +0 -1
  119. package/hooks/useLoadVideoMetadataEffect.d.ts +0 -35
  120. package/hooks/useLoadVideoMetadataEffect.js.map +0 -1
  121. package/hooks/useMounted.d.ts +0 -1
  122. package/hooks/useMounted.js.map +0 -1
  123. package/hooks/usePrevious.d.ts +0 -19
  124. package/hooks/usePrevious.js.map +0 -1
  125. package/hooks/useRect.d.ts +0 -11
  126. package/hooks/useRect.js.map +0 -1
  127. package/hooks/useResizeEffect.d.ts +0 -17
  128. package/hooks/useResizeEffect.js.map +0 -1
  129. package/hooks/useScrollPositionEffect.d.ts +0 -13
  130. package/hooks/useScrollPositionEffect.js.map +0 -1
  131. package/hooks/useSearchParamState.d.ts +0 -34
  132. package/hooks/useSearchParamState.js.map +0 -1
  133. package/hooks/useSize.d.ts +0 -10
  134. package/hooks/useSize.js.map +0 -1
  135. package/hooks/useTimeout.d.ts +0 -10
  136. package/hooks/useTimeout.js.map +0 -1
  137. package/hooks/useVideoSize.d.ts +0 -21
  138. package/hooks/useVideoSize.js.map +0 -1
  139. package/hooks/useViewportSize.d.ts +0 -7
  140. package/hooks/useViewportSize.js.map +0 -1
  141. package/operators/Conditional.d.ts +0 -5
  142. package/operators/Conditional.js.map +0 -1
  143. package/operators/Each.d.ts +0 -7
  144. package/operators/Each.js.map +0 -1
  145. package/operators/ExtractChild.d.ts +0 -8
  146. package/operators/ExtractChild.js.map +0 -1
  147. package/operators/ExtractChildren.d.ts +0 -6
  148. package/operators/ExtractChildren.js.map +0 -1
  149. package/operators/Repeat.d.ts +0 -11
  150. package/operators/Repeat.js.map +0 -1
  151. package/providers/ScrollPositionProvider.d.ts +0 -15
  152. package/providers/ScrollPositionProvider.js.map +0 -1
  153. package/utils/asClassNameDict.d.ts +0 -3
  154. package/utils/asClassNameDict.js.map +0 -1
  155. package/utils/asComponentDict.d.ts +0 -5
  156. package/utils/asComponentDict.js.map +0 -1
  157. package/utils/asStyleDict.d.ts +0 -4
  158. package/utils/asStyleDict.js.map +0 -1
  159. package/utils/cloneStyledElement.d.ts +0 -18
  160. package/utils/cloneStyledElement.js.map +0 -1
  161. package/utils/index.d.ts +0 -5
  162. package/utils/index.js.map +0 -1
  163. package/utils/styles.d.ts +0 -2
  164. package/utils/styles.js.map +0 -1
@@ -1,53 +1,9 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
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
- 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
- exports.Slider = (0, react_1.forwardRef)(function (_a, ref) {
66
- var _b, _c, _d, _e;
67
- var children = _a.children, className = _a.className, _f = _a.isInverted, isInverted = _f === void 0 ? false : _f, _g = _a.isTrackInteractive, isTrackInteractive = _g === void 0 ? true : _g, _h = _a.knobHeight, knobHeight = _h === void 0 ? 30 : _h, _j = _a.knobWidth, knobWidth = _j === void 0 ? 30 : _j, labelProvider = _a.labelProvider, _k = _a.onlyDispatchesOnDragEnd, onlyDispatchesOnDragEnd = _k === void 0 ? false : _k, _l = _a.orientation, orientation = _l === void 0 ? 'vertical' : _l, _m = _a.position, externalPosition = _m === void 0 ? 0 : _m, _o = _a.trackPadding, trackPadding = _o === void 0 ? 0 : _o, _p = _a.usesDefaultStyles, usesDefaultStyles = _p === void 0 ? false : _p, onDragEnd = _a.onDragEnd, onDragStart = _a.onDragStart, onPositionChange = _a.onPositionChange, props = __rest(_a, ["children", "className", "isInverted", "isTrackInteractive", "knobHeight", "knobWidth", "labelProvider", "onlyDispatchesOnDragEnd", "orientation", "position", "trackPadding", "usesDefaultStyles", "onDragEnd", "onDragStart", "onPositionChange"]);
68
- var mapDragValueToPosition = function (value, dx, dy) {
69
- var _a;
70
- var rect = (_a = spase_1.Rect.from(bodyRef.current)) !== null && _a !== void 0 ? _a : new spase_1.Rect();
71
- var truePosition = isInverted ? 1 - value : value;
72
- var trueNewPositionX = truePosition * rect.width + dx;
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
- var trackClickHandler = function (event) {
79
- var _a;
31
+ const trackClickHandler = (event) => {
80
32
  if (!isTrackInteractive)
81
33
  return;
82
- var rect = (_a = spase_1.Rect.from(bodyRef.current)) !== null && _a !== void 0 ? _a : new spase_1.Rect();
34
+ const rect = Rect.from(bodyRef.current) ?? new Rect();
83
35
  switch (orientation) {
84
36
  case 'horizontal': {
85
- var trackPosition = (event.clientX - rect.left) / rect.width;
86
- var normalizedPosition = isInverted ? 1 - trackPosition : trackPosition;
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
- var trackPosition = (event.clientY - rect.top) / rect.height;
92
- var normalizedPosition = isInverted ? 1 - trackPosition : trackPosition;
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
- var bodyRef = (0, react_1.useRef)(null);
100
- var knobContainerRef = (0, react_1.useRef)(null);
101
- var _q = (0, useDragValueEffect_1.useDragValueEffect)(knobContainerRef, {
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: onDragStart,
105
- onDragEnd: onDragEnd,
106
- }), _r = __read(_q.isDragging, 1), isDragging = _r[0], _s = __read(_q.isReleasing, 1), isReleasing = _s[0], _t = __read(_q.value, 2), position = _t[0], setPosition = _t[1];
56
+ onDragStart,
57
+ onDragEnd,
58
+ });
107
59
  // Natural position is the position affecting internal components accounting
108
60
  // for `isInverted`.
109
- var naturalPosition = isInverted ? 1 - position : position;
110
- var isAtEnd = isInverted ? position === 0 : position === 1;
111
- var isAtStart = isInverted ? position === 1 : position === 0;
112
- (0, react_1.useEffect)(function () {
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
- (0, react_1.useEffect)(function () {
69
+ useEffect(() => {
118
70
  if (isDragging && onlyDispatchesOnDragEnd)
119
71
  return;
120
- onPositionChange === null || onPositionChange === void 0 ? void 0 : onPositionChange(position, isDragging);
72
+ onPositionChange?.(position, isDragging);
121
73
  }, [position]);
122
- (0, react_1.useEffect)(function () {
74
+ useEffect(() => {
123
75
  if (isDragging || !onlyDispatchesOnDragEnd)
124
76
  return;
125
- onPositionChange === null || onPositionChange === void 0 ? void 0 : onPositionChange(position, true);
77
+ onPositionChange?.(position, true);
126
78
  }, [isDragging]);
127
- var components = (0, utils_1.asComponentDict)(children, {
128
- knob: exports.SliderKnob,
129
- label: exports.SliderLabel,
130
- track: exports.SliderTrack,
79
+ const components = asComponentDict(children, {
80
+ knob: SliderKnob,
81
+ label: SliderLabel,
82
+ track: SliderTrack,
131
83
  });
132
- var fixedClassNames = getFixedClassNames({ orientation: orientation, isAtEnd: isAtEnd, isAtStart: isAtStart, isDragging: isDragging, isReleasing: isReleasing });
133
- var fixedStyles = getFixedStyles({ orientation: orientation, isDragging: isDragging, naturalPosition: naturalPosition, knobHeight: knobHeight, knobWidth: knobWidth, isTrackInteractive: isTrackInteractive });
134
- var defaultStyles = usesDefaultStyles ? getDefaultStyles({ knobHeight: knobHeight }) : undefined;
135
- return ((0, jsx_runtime_1.jsx)("div", __assign({}, props, { ref: ref, className: (0, clsx_1.default)(className, fixedClassNames.root), "data-component": 'slider', children: (0, jsx_runtime_1.jsxs)("div", { ref: bodyRef, style: fixedStyles.body, children: [(0, utils_1.cloneStyledElement)((_b = components.track) !== null && _b !== void 0 ? _b : (0, jsx_runtime_1.jsx)(exports.SliderTrack, { style: defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.track }), {
136
- className: (0, clsx_1.default)('start', fixedClassNames.track),
137
- style: (0, utils_1.styles)(fixedStyles.track, orientation === 'vertical' ? {
138
- height: "calc(".concat(naturalPosition * 100, "% - ").concat(trackPadding <= 0 ? 0 : knobHeight * 0.5, "px - ").concat(trackPadding, "px)"),
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: "calc(".concat(naturalPosition * 100, "% - ").concat(trackPadding <= 0 ? 0 : knobWidth * 0.5, "px - ").concat(trackPadding, "px)"),
94
+ width: `calc(${naturalPosition * 100}% - ${trackPadding <= 0 ? 0 : knobWidth * 0.5}px - ${trackPadding}px)`,
143
95
  }),
144
96
  onClick: trackClickHandler,
145
- }, (0, jsx_runtime_1.jsx)("div", { style: fixedStyles.trackHitbox })), (0, utils_1.cloneStyledElement)((_c = components.track) !== null && _c !== void 0 ? _c : (0, jsx_runtime_1.jsx)(exports.SliderTrack, { style: defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.track }), {
146
- className: (0, clsx_1.default)('end', fixedClassNames.track),
147
- style: (0, utils_1.styles)(fixedStyles.track, orientation === 'vertical' ? {
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: "calc(".concat((1 - naturalPosition) * 100, "% - ").concat(trackPadding <= 0 ? 0 : knobHeight * 0.5, "px - ").concat(trackPadding, "px)"),
101
+ height: `calc(${(1 - naturalPosition) * 100}% - ${trackPadding <= 0 ? 0 : knobHeight * 0.5}px - ${trackPadding}px)`,
150
102
  } : {
151
103
  right: '0',
152
- width: "calc(".concat((1 - naturalPosition) * 100, "% - ").concat(trackPadding <= 0 ? 0 : knobWidth * 0.5, "px - ").concat(trackPadding, "px)"),
104
+ width: `calc(${(1 - naturalPosition) * 100}% - ${trackPadding <= 0 ? 0 : knobWidth * 0.5}px - ${trackPadding}px)`,
153
105
  }),
154
106
  onClick: trackClickHandler,
155
- }, (0, jsx_runtime_1.jsx)("div", { style: fixedStyles.trackHitbox })), (0, jsx_runtime_1.jsx)("button", { ref: knobContainerRef, style: fixedStyles.knobContainer, children: (0, utils_1.cloneStyledElement)((_d = components.knob) !== null && _d !== void 0 ? _d : (0, jsx_runtime_1.jsx)(exports.SliderKnob, { style: defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.knob }), {
156
- className: (0, clsx_1.default)(fixedClassNames.knob),
157
- style: (0, utils_1.styles)(fixedStyles.knob),
158
- }, labelProvider && (0, utils_1.cloneStyledElement)((_e = components.label) !== null && _e !== void 0 ? _e : (0, jsx_runtime_1.jsx)(exports.SliderLabel, { style: defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.label }), {
159
- className: (0, clsx_1.default)(fixedClassNames.label),
160
- style: (0, utils_1.styles)(fixedStyles.label),
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(exports.Slider, 'displayName', { value: 'Slider', writable: false });
164
- var SliderTrack = function (_a) {
165
- var props = __rest(_a, []);
166
- return (0, jsx_runtime_1.jsx)("div", __assign({}, props, { "data-child": 'track' }));
167
- };
168
- exports.SliderTrack = SliderTrack;
169
- var SliderKnob = function (_a) {
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: (0, clsx_1.default)(orientation, {
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: (0, clsx_1.default)(orientation, {
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: (0, clsx_1.default)(orientation, {
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(_a) {
209
- var _b = _a.orientation, orientation = _b === void 0 ? 'vertical' : _b, _c = _a.isDragging, isDragging = _c === void 0 ? false : _c, _d = _a.naturalPosition, naturalPosition = _d === void 0 ? 0 : _d, _e = _a.knobHeight, knobHeight = _e === void 0 ? 0 : _e, _f = _a.knobWidth, knobWidth = _f === void 0 ? 0 : _f, _g = _a.isTrackInteractive, isTrackInteractive = _g === void 0 ? true : _g;
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: __assign({ background: 'none', border: 'none', outline: 'none', position: 'absolute', transform: 'translate3d(-50%, -50%, 0)', zIndex: '1' }, orientation === 'vertical' ? {
216
- left: '50%',
217
- top: "".concat(naturalPosition * 100, "%"),
218
- transition: isDragging === false ? 'top 100ms ease-out' : 'none',
219
- } : {
220
- left: "".concat(naturalPosition * 100, "%"),
221
- top: '50%',
222
- transition: isDragging === false ? 'left 100ms ease-out' : 'none',
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: "".concat(knobHeight, "px"),
171
+ height: `${knobHeight}px`,
226
172
  touchAction: 'none',
227
- width: "".concat(knobWidth, "px"),
173
+ width: `${knobWidth}px`,
228
174
  },
229
175
  label: {
230
176
  pointerEvents: 'none',
231
177
  userSelect: 'none',
232
178
  },
233
- track: __assign({ cursor: isTrackInteractive ? 'pointer' : 'auto', pointerEvents: isTrackInteractive ? 'auto' : 'none', position: 'absolute' }, orientation === 'vertical' ? {
234
- left: '0',
235
- margin: '0 auto',
236
- right: '0',
237
- width: '100%',
238
- } : {
239
- bottom: '0',
240
- height: '100%',
241
- margin: 'auto 0',
242
- top: '0',
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(_a) {
255
- var _b = _a.knobHeight, knobHeight = _b === void 0 ? 0 : _b;
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: "".concat(knobHeight, "px"),
217
+ lineHeight: `${knobHeight}px`,
268
218
  },
269
219
  track: {
270
220
  background: '#fff',
271
221
  },
272
222
  });
273
223
  }
274
- //# sourceMappingURL=Slider.js.map