etudes 3.3.1 → 3.5.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.
@@ -75,8 +75,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
75
75
  Object.defineProperty(exports, "__esModule", { value: true });
76
76
  exports.RangeSliderKnob = exports.RangeSliderHighlight = exports.RangeSliderLabel = exports.RangeSliderGutter = void 0;
77
77
  var classnames_1 = __importDefault(require("classnames"));
78
- var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
79
- var react_1 = __importStar(require("react"));
78
+ var react_1 = __importDefault(require("fast-deep-equal/react"));
79
+ var react_2 = __importStar(require("react"));
80
80
  var useDragEffect_1 = __importDefault(require("./hooks/useDragEffect"));
81
81
  var useResizeEffect_1 = __importDefault(require("./hooks/useResizeEffect"));
82
82
  var asClassNameDict_1 = __importDefault(require("./utils/asClassNameDict"));
@@ -84,7 +84,7 @@ var asComponentDict_1 = __importDefault(require("./utils/asComponentDict"));
84
84
  var asStyleDict_1 = __importDefault(require("./utils/asStyleDict"));
85
85
  var cloneStyledElement_1 = __importDefault(require("./utils/cloneStyledElement"));
86
86
  var styles_1 = __importDefault(require("./utils/styles"));
87
- exports.default = (0, react_1.forwardRef)(function (_a, ref) {
87
+ exports.default = (0, react_2.forwardRef)(function (_a, ref) {
88
88
  var _b, _c, _d, _e, _f, _g, _h, _j;
89
89
  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, onRangeChange = _a.onRangeChange, props = __rest(_a, ["children", "className", "areLabelsVisible", "decimalPlaces", "knobPadding", "max", "min", "orientation", "range", "steps", "onRangeChange"]);
90
90
  var getPositionByValue = function (value) { return (value - minValue) / (maxValue - minValue); };
@@ -107,11 +107,11 @@ exports.default = (0, react_1.forwardRef)(function (_a, ref) {
107
107
  }
108
108
  return breakpoints[idx];
109
109
  };
110
- var bodyRef = (0, react_1.useRef)(null);
111
- var startKnobRef = (0, react_1.useRef)(null);
112
- var endKnobRef = (0, react_1.useRef)(null);
110
+ var bodyRef = (0, react_2.useRef)(null);
111
+ var startKnobRef = (0, react_2.useRef)(null);
112
+ var endKnobRef = (0, react_2.useRef)(null);
113
113
  var _q = __read((0, useResizeEffect_1.default)(bodyRef), 1), size = _q[0];
114
- var _r = __read((0, react_1.useState)(externalRange !== null && externalRange !== void 0 ? externalRange : [minValue, maxValue]), 2), range = _r[0], setRange = _r[1];
114
+ var _r = __read((0, react_2.useState)(externalRange !== null && externalRange !== void 0 ? externalRange : [minValue, maxValue]), 2), range = _r[0], setRange = _r[1];
115
115
  var _s = (0, useDragEffect_1.default)(startKnobRef, {
116
116
  initialValue: (_b = externalRange === null || externalRange === void 0 ? void 0 : externalRange[0]) !== null && _b !== void 0 ? _b : minValue,
117
117
  transform: function (value, dx, dy) {
@@ -135,29 +135,29 @@ exports.default = (0, react_1.forwardRef)(function (_a, ref) {
135
135
  var breakpoints = __spreadArray(__spreadArray([minValue], __read(__spreadArray([], __read(Array(steps)), false).map(function (v, i) { return minValue + (i + 1) * (maxValue - minValue) / (1 + steps); })), false), [maxValue], false);
136
136
  var _0 = __read(range.map(getDisplacementByValue), 2), start = _0[0], end = _0[1];
137
137
  var highlightLength = end - start;
138
- (0, react_1.useEffect)(function () {
138
+ (0, react_2.useEffect)(function () {
139
139
  if (range[0] === startValue)
140
140
  return;
141
141
  setRange([startValue, range[1]]);
142
142
  onRangeChange === null || onRangeChange === void 0 ? void 0 : onRangeChange(range);
143
143
  }, [startValue]);
144
- (0, react_1.useEffect)(function () {
144
+ (0, react_2.useEffect)(function () {
145
145
  if (range[1] === endValue)
146
146
  return;
147
147
  setRange([range[0], endValue]);
148
148
  onRangeChange === null || onRangeChange === void 0 ? void 0 : onRangeChange(range);
149
149
  }, [endValue]);
150
- (0, react_1.useEffect)(function () {
151
- if (isDraggingStartKnob || isDraggingEndKnob || (0, fast_deep_equal_1.default)(externalRange, range))
150
+ (0, react_2.useEffect)(function () {
151
+ if (isDraggingStartKnob || isDraggingEndKnob || (0, react_1.default)(externalRange, range))
152
152
  return;
153
153
  setRange(externalRange !== null && externalRange !== void 0 ? externalRange : [minValue, maxValue]);
154
154
  }, [externalRange]);
155
- (0, react_1.useEffect)(function () {
155
+ (0, react_2.useEffect)(function () {
156
156
  if (steps < 0)
157
157
  return;
158
158
  setStartValue(getClosestSteppedValue(startValue));
159
159
  }, [isReleasingStartKnob]);
160
- (0, react_1.useEffect)(function () {
160
+ (0, react_2.useEffect)(function () {
161
161
  if (steps < 0 || !isReleasingEndKnob)
162
162
  return;
163
163
  setEndValue(getClosestSteppedValue(endValue));
@@ -248,34 +248,34 @@ exports.default = (0, react_1.forwardRef)(function (_a, ref) {
248
248
  left: 'calc(100% + 10px)',
249
249
  }),
250
250
  });
251
- return (react_1.default.createElement("div", __assign({}, props, { ref: ref, className: (0, classnames_1.default)(className, fixedClassNames.root) }),
252
- react_1.default.createElement("div", { ref: bodyRef, style: fixedStyles.body },
253
- (0, cloneStyledElement_1.default)((_d = components.gutter) !== null && _d !== void 0 ? _d : react_1.default.createElement(exports.RangeSliderGutter, { style: defaultStyles.gutter }), {
251
+ return (react_2.default.createElement("div", __assign({}, props, { ref: ref, className: (0, classnames_1.default)(className, fixedClassNames.root) }),
252
+ react_2.default.createElement("div", { ref: bodyRef, style: fixedStyles.body },
253
+ (0, cloneStyledElement_1.default)((_d = components.gutter) !== null && _d !== void 0 ? _d : react_2.default.createElement(exports.RangeSliderGutter, { style: defaultStyles.gutter }), {
254
254
  className: (0, classnames_1.default)(fixedClassNames.gutter),
255
255
  style: (0, styles_1.default)(fixedStyles.gutter),
256
256
  }),
257
- (0, cloneStyledElement_1.default)((_e = components.highlight) !== null && _e !== void 0 ? _e : react_1.default.createElement(exports.RangeSliderHighlight, { style: defaultStyles.highlight }), {
257
+ (0, cloneStyledElement_1.default)((_e = components.highlight) !== null && _e !== void 0 ? _e : react_2.default.createElement(exports.RangeSliderHighlight, { style: defaultStyles.highlight }), {
258
258
  className: (0, classnames_1.default)(fixedClassNames.highlight),
259
259
  style: (0, styles_1.default)(fixedStyles.highlight),
260
260
  }),
261
- (0, cloneStyledElement_1.default)((_f = components.knob) !== null && _f !== void 0 ? _f : react_1.default.createElement(exports.RangeSliderKnob, { style: (0, styles_1.default)(defaultStyles.knob, {
261
+ (0, cloneStyledElement_1.default)((_f = components.knob) !== null && _f !== void 0 ? _f : react_2.default.createElement(exports.RangeSliderKnob, { style: (0, styles_1.default)(defaultStyles.knob, {
262
262
  transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',
263
263
  }) }), {
264
264
  ref: startKnobRef,
265
- disabled: (0, fast_deep_equal_1.default)([startValue, endValue], [maxValue, maxValue]),
265
+ disabled: (0, react_1.default)([startValue, endValue], [maxValue, maxValue]),
266
266
  className: (0, classnames_1.default)(fixedClassNames.knob, {
267
267
  dragging: isDraggingStartKnob,
268
268
  releasing: isReleasingStartKnob,
269
269
  }),
270
270
  style: (0, styles_1.default)(fixedStyles.knob, {
271
- pointerEvents: (0, fast_deep_equal_1.default)([startValue, endValue], [minValue, minValue]) ? 'none' : 'auto',
271
+ pointerEvents: (0, react_1.default)([startValue, endValue], [minValue, minValue]) ? 'none' : 'auto',
272
272
  }, orientation === 'horizontal' ? {
273
273
  marginLeft: "".concat(start, "px"),
274
274
  } : {
275
275
  marginTop: "".concat(start, "px"),
276
276
  }),
277
- }, react_1.default.createElement("div", { style: fixedStyles.knobHitbox }), areLabelsVisible &&
278
- (0, cloneStyledElement_1.default)((_g = components.label) !== null && _g !== void 0 ? _g : react_1.default.createElement(exports.RangeSliderLabel, { style: (0, styles_1.default)(defaultStyles.label, {
277
+ }, react_2.default.createElement("div", { style: fixedStyles.knobHitbox }), areLabelsVisible &&
278
+ (0, cloneStyledElement_1.default)((_g = components.label) !== null && _g !== void 0 ? _g : react_2.default.createElement(exports.RangeSliderLabel, { style: (0, styles_1.default)(defaultStyles.label, {
279
279
  transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',
280
280
  }) }), {
281
281
  className: (0, classnames_1.default)(fixedClassNames.label, {
@@ -284,24 +284,24 @@ exports.default = (0, react_1.forwardRef)(function (_a, ref) {
284
284
  }),
285
285
  style: (0, styles_1.default)(fixedStyles.label),
286
286
  }, Number(startValue.toFixed(decimalPlaces)).toLocaleString())),
287
- (0, cloneStyledElement_1.default)((_h = components.knob) !== null && _h !== void 0 ? _h : react_1.default.createElement(exports.RangeSliderKnob, { style: (0, styles_1.default)(defaultStyles.knob, {
287
+ (0, cloneStyledElement_1.default)((_h = components.knob) !== null && _h !== void 0 ? _h : react_2.default.createElement(exports.RangeSliderKnob, { style: (0, styles_1.default)(defaultStyles.knob, {
288
288
  transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',
289
289
  }) }), {
290
290
  ref: endKnobRef,
291
- disabled: (0, fast_deep_equal_1.default)([startValue, endValue], [maxValue, maxValue]),
291
+ disabled: (0, react_1.default)([startValue, endValue], [maxValue, maxValue]),
292
292
  className: (0, classnames_1.default)(fixedClassNames.knob, {
293
293
  dragging: isDraggingEndKnob,
294
294
  releasing: isDraggingEndKnob,
295
295
  }),
296
296
  style: (0, styles_1.default)(fixedStyles.knob, {
297
- pointerEvents: (0, fast_deep_equal_1.default)([startValue, endValue], [maxValue, maxValue]) ? 'none' : 'auto',
297
+ pointerEvents: (0, react_1.default)([startValue, endValue], [maxValue, maxValue]) ? 'none' : 'auto',
298
298
  }, orientation === 'horizontal' ? {
299
299
  marginLeft: "".concat(end, "px"),
300
300
  } : {
301
301
  marginTop: "".concat(end, "px"),
302
302
  }),
303
- }, react_1.default.createElement("div", { style: fixedStyles.knobHitbox }), areLabelsVisible &&
304
- (0, cloneStyledElement_1.default)((_j = components.label) !== null && _j !== void 0 ? _j : react_1.default.createElement(exports.RangeSliderLabel, { style: (0, styles_1.default)(defaultStyles.label, {
303
+ }, react_2.default.createElement("div", { style: fixedStyles.knobHitbox }), areLabelsVisible &&
304
+ (0, cloneStyledElement_1.default)((_j = components.label) !== null && _j !== void 0 ? _j : react_2.default.createElement(exports.RangeSliderLabel, { style: (0, styles_1.default)(defaultStyles.label, {
305
305
  transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',
306
306
  }) }), {
307
307
  className: (0, classnames_1.default)(fixedClassNames.label, {
@@ -313,21 +313,21 @@ exports.default = (0, react_1.forwardRef)(function (_a, ref) {
313
313
  });
314
314
  var RangeSliderGutter = function (_a) {
315
315
  var props = __rest(_a, []);
316
- return react_1.default.createElement("div", __assign({}, props));
316
+ return react_2.default.createElement("div", __assign({}, props));
317
317
  };
318
318
  exports.RangeSliderGutter = RangeSliderGutter;
319
319
  var RangeSliderLabel = function (_a) {
320
320
  var props = __rest(_a, []);
321
- return react_1.default.createElement("div", __assign({}, props));
321
+ return react_2.default.createElement("div", __assign({}, props));
322
322
  };
323
323
  exports.RangeSliderLabel = RangeSliderLabel;
324
324
  var RangeSliderHighlight = function (_a) {
325
325
  var props = __rest(_a, []);
326
- return react_1.default.createElement("div", __assign({}, props));
326
+ return react_2.default.createElement("div", __assign({}, props));
327
327
  };
328
328
  exports.RangeSliderHighlight = RangeSliderHighlight;
329
- exports.RangeSliderKnob = (0, react_1.forwardRef)(function (_a, ref) {
329
+ exports.RangeSliderKnob = (0, react_2.forwardRef)(function (_a, ref) {
330
330
  var props = __rest(_a, []);
331
- return react_1.default.createElement("div", __assign({}, props, { ref: ref }));
331
+ return react_2.default.createElement("div", __assign({}, props, { ref: ref }));
332
332
  });
333
333
  //# sourceMappingURL=RangeSlider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RangeSlider.js","sourceRoot":"/","sources":["RangeSlider.tsx"],"names":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,CAAC,CAC7D,CACG,CACF,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEK,IAAM,iBAAiB,GAAG,UAAC,EAA4C;QAAvC,KAAK,cAAV,EAAY,CAAF;IAAuC,OAAA,kDAAS,KAAK,EAAG,CAAA;CAAA,CAAA;AAAvF,QAAA,iBAAiB,qBAAsE;AAE7F,IAAM,gBAAgB,GAAG,UAAC,EAA4C;QAAvC,KAAK,cAAV,EAAY,CAAF;IAAuC,OAAA,kDAAS,KAAK,EAAG,CAAA;CAAA,CAAA;AAAtF,QAAA,gBAAgB,oBAAsE;AAE5F,IAAM,oBAAoB,GAAG,UAAC,EAA4C;QAAvC,KAAK,cAAV,EAAY,CAAF;IAAuC,OAAA,kDAAS,KAAK,EAAG,CAAA;CAAA,CAAA;AAA1F,QAAA,oBAAoB,wBAAsE;AAE1F,QAAA,eAAe,GAAG,IAAA,kBAAU,EAAiD,UAAC,EAAY,EAAE,GAAG;QAAZ,KAAK,cAAV,EAAY,CAAF;IAAY,OAAA,kDAAS,KAAK,IAAE,GAAG,EAAE,GAAG,IAAG,CAAA;CAAA,CAAC,CAAA","sourcesContent":["import classNames from 'classnames'\nimport isEqual from 'fast-deep-equal'\nimport React, { forwardRef, useEffect, useRef, useState, type HTMLAttributes, type PropsWithChildren } from 'react'\nimport useDragEffect from './hooks/useDragEffect'\nimport useResizeEffect from './hooks/useResizeEffect'\nimport asClassNameDict from './utils/asClassNameDict'\nimport asComponentDict from './utils/asComponentDict'\nimport asStyleDict from './utils/asStyleDict'\nimport cloneStyledElement from './utils/cloneStyledElement'\nimport styles from './utils/styles'\n\ntype Orientation = 'horizontal' | 'vertical'\n\ntype Range = [number, number]\n\nexport type RangeSliderProps = HTMLAttributes<HTMLDivElement> & PropsWithChildren<{\n areLabelsVisible?: boolean\n decimalPlaces?: number\n knobPadding?: number\n max: number\n min: number\n orientation?: Orientation\n range?: Range\n steps?: number\n onRangeChange?: (range: Range) => void\n}>\n\nexport default forwardRef<HTMLDivElement, RangeSliderProps>(({\n children,\n className,\n areLabelsVisible = true,\n decimalPlaces = 2,\n knobPadding = 20,\n max: maxValue,\n min: minValue,\n orientation = 'vertical',\n range: externalRange,\n steps = -1,\n onRangeChange,\n ...props\n}, ref) => {\n const getPositionByValue = (value: number) => (value - minValue) / (maxValue - minValue)\n const getPositionByDisplacement = (displacement: number) => displacement / (orientation === 'horizontal' ? size.width : size.height)\n const getValueByPosition = (position: number) => position * (maxValue - minValue) + minValue\n const getValueByDisplacement = (displacement: number) => getValueByPosition(getPositionByDisplacement(displacement))\n const getDisplacementByPosition = (position: number) => position * (orientation === 'horizontal' ? size.width : size.height)\n const getDisplacementByValue = (value: number) => getDisplacementByPosition(getPositionByValue(value))\n\n const getClosestSteppedValue = (value: number) => {\n const n = breakpoints.length\n let idx = 0\n let diff = Infinity\n\n for (let i = 0; i < n; i++) {\n const t = breakpoints[i]\n const d = Math.abs(value - t)\n\n if (d < diff) {\n diff = d\n idx = i\n }\n }\n\n return breakpoints[idx]\n }\n\n const bodyRef = useRef<HTMLDivElement>(null)\n const startKnobRef = useRef<HTMLDivElement>(null)\n const endKnobRef = useRef<HTMLDivElement>(null)\n\n const [size] = useResizeEffect(bodyRef)\n\n const [range, setRange] = useState<Range>(externalRange ?? [minValue, maxValue])\n\n const { isDragging: [isDraggingStartKnob], isReleasing: [isReleasingStartKnob], value: [startValue, setStartValue] } = useDragEffect(startKnobRef, {\n initialValue: externalRange?.[0] ?? minValue,\n transform: (value: number, dx: number, dy: number) => {\n const delta = orientation === 'horizontal' ? dx : dy\n const dMin = getDisplacementByValue(minValue)\n const dMax = getDisplacementByValue(range[1])\n const dCurr = getDisplacementByValue(value) + delta\n\n return getValueByDisplacement(Math.max(dMin, Math.min(dMax, dCurr)))\n },\n }, [minValue, orientation, size, range[1]])\n\n const { isDragging: [isDraggingEndKnob], isReleasing: [isReleasingEndKnob], value: [endValue, setEndValue] } = useDragEffect(endKnobRef, {\n initialValue: externalRange?.[1] ?? maxValue,\n transform: (value: number, dx: number, dy: number) => {\n const delta = orientation === 'horizontal' ? dx : dy\n const dMin = getDisplacementByValue(range[0])\n const dMax = getDisplacementByValue(maxValue)\n const dCurr = getDisplacementByValue(value) + delta\n\n return getValueByDisplacement(Math.max(dMin, Math.min(dMax, dCurr)))\n },\n }, [maxValue, orientation, size, range[0]])\n\n const breakpoints = [minValue, ...[...Array(steps)].map((v, i) => minValue + (i + 1) * (maxValue - minValue) / (1 + steps)), maxValue]\n const [start, end] = range.map(getDisplacementByValue)\n const highlightLength = end - start\n\n useEffect(() => {\n if (range[0] === startValue) return\n setRange([startValue, range[1]])\n onRangeChange?.(range)\n }, [startValue])\n\n useEffect(() => {\n if (range[1] === endValue) return\n setRange([range[0], endValue])\n onRangeChange?.(range)\n }, [endValue])\n\n useEffect(() => {\n if (isDraggingStartKnob || isDraggingEndKnob || isEqual(externalRange, range)) return\n setRange(externalRange ?? [minValue, maxValue])\n }, [externalRange])\n\n useEffect(() => {\n if (steps < 0) return\n setStartValue(getClosestSteppedValue(startValue))\n }, [isReleasingStartKnob])\n\n useEffect(() => {\n if (steps < 0 || !isReleasingEndKnob) return\n setEndValue(getClosestSteppedValue(endValue))\n }, [isReleasingEndKnob])\n\n const components = asComponentDict(children, {\n gutter: RangeSliderGutter,\n highlight: RangeSliderHighlight,\n knob: RangeSliderKnob,\n label: RangeSliderLabel,\n })\n\n const fixedClassNames = asClassNameDict({\n root: classNames(orientation),\n gutter: classNames(orientation),\n highlight: classNames(orientation),\n knob: classNames(orientation),\n label: classNames(orientation),\n })\n\n const fixedStyles = asStyleDict({\n body: {\n height: '100%',\n width: '100%',\n },\n gutter: {\n display: 'block',\n top: '0',\n left: '0',\n position: 'absolute',\n width: '100%',\n height: '100%',\n },\n highlight: {\n height: '100%',\n left: '0',\n position: 'absolute',\n top: '0',\n ...orientation === 'horizontal' ? {\n width: `${highlightLength}px`,\n transform: `translate3d(${start}px, 0, 0)`,\n } : {\n height: `${highlightLength}px`,\n transform: `translate3d(0, ${start}px, 0)`,\n },\n },\n knob: {\n bottom: '0',\n left: '0',\n margin: 'auto',\n position: 'absolute',\n right: '0',\n top: '0',\n touchAction: 'none',\n zIndex: '1',\n },\n knobHitbox: {\n background: 'transparent',\n height: `calc(100% + ${knobPadding * 2}px)`,\n left: `-${knobPadding}px`,\n padding: `${knobPadding}px`,\n position: 'absolute',\n top: `-${knobPadding}px`,\n width: `calc(100% + ${knobPadding * 2}px)`,\n },\n label: {\n pointerEvents: 'none',\n position: 'relative',\n userSelect: 'none',\n },\n })\n\n const defaultStyles = asStyleDict({\n gutter: {\n background: 'rgba(255, 255, 255, .2)',\n },\n highlight: {\n background: '#fff',\n transitionDuration: '100ms',\n transitionProperty: (isReleasingStartKnob ? !isReleasingEndKnob : isReleasingEndKnob) ? 'opacity, width, transform' : 'opacity',\n transitionTimingFunction: 'ease-out',\n },\n knob: {\n alignItems: 'center',\n background: '#fff',\n borderRadius: '10px',\n boxSizing: 'border-box',\n display: 'flex',\n height: '20px',\n justifyContent: 'center',\n transitionDuration: '100ms',\n transitionTimingFunction: 'ease-out',\n width: '20px',\n },\n label: {\n background: 'transparent',\n color: '#fff',\n textAlign: 'center',\n transitionDuration: '100ms',\n transitionTimingFunction: 'ease-out',\n ...orientation === 'horizontal' ? {\n top: 'calc(100% + 10px)',\n } : {\n left: 'calc(100% + 10px)',\n },\n },\n })\n\n return (\n <div {...props} ref={ref} className={classNames(className, fixedClassNames.root)}>\n <div ref={bodyRef} style={fixedStyles.body}>\n {cloneStyledElement(components.gutter ?? <RangeSliderGutter style={defaultStyles.gutter}/>, {\n className: classNames(fixedClassNames.gutter),\n style: styles(fixedStyles.gutter),\n })}\n {cloneStyledElement(components.highlight ?? <RangeSliderHighlight style={defaultStyles.highlight}/>, {\n className: classNames(fixedClassNames.highlight),\n style: styles(fixedStyles.highlight),\n })}\n {cloneStyledElement(components.knob ?? <RangeSliderKnob style={styles(defaultStyles.knob, {\n transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',\n })}/>, {\n ref: startKnobRef,\n disabled: isEqual([startValue, endValue], [maxValue, maxValue]),\n className: classNames(fixedClassNames.knob, {\n dragging: isDraggingStartKnob,\n releasing: isReleasingStartKnob,\n }),\n style: styles(fixedStyles.knob, {\n pointerEvents: isEqual([startValue, endValue], [minValue, minValue]) ? 'none' : 'auto',\n }, orientation === 'horizontal' ? {\n marginLeft: `${start}px`,\n } : {\n marginTop: `${start}px`,\n }),\n }, <div style={fixedStyles.knobHitbox}/>, areLabelsVisible &&\n cloneStyledElement(components.label ?? <RangeSliderLabel style={styles(defaultStyles.label, {\n transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',\n })}/>, {\n className: classNames(fixedClassNames.label, {\n dragging: isDraggingStartKnob || isDraggingEndKnob,\n releasing: isReleasingStartKnob || isReleasingEndKnob,\n }),\n style: styles(fixedStyles.label),\n }, Number(startValue.toFixed(decimalPlaces)).toLocaleString())\n )}\n {cloneStyledElement(components.knob ?? <RangeSliderKnob style={styles(defaultStyles.knob, {\n transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',\n })}/>, {\n ref: endKnobRef,\n disabled: isEqual([startValue, endValue], [maxValue, maxValue]),\n className: classNames(fixedClassNames.knob, {\n dragging: isDraggingEndKnob,\n releasing: isDraggingEndKnob,\n }),\n style: styles(fixedStyles.knob, {\n pointerEvents: isEqual([startValue, endValue], [maxValue, maxValue]) ? 'none' : 'auto',\n }, orientation === 'horizontal' ? {\n marginLeft: `${end}px`,\n } : {\n marginTop: `${end}px`,\n }),\n }, <div style={fixedStyles.knobHitbox}/>, areLabelsVisible &&\n cloneStyledElement(components.label ?? <RangeSliderLabel style={styles(defaultStyles.label, {\n transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',\n })}/>, {\n className: classNames(fixedClassNames.label, {\n dragging: isDraggingEndKnob,\n releasing: isReleasingEndKnob,\n }),\n style: styles(fixedStyles.label),\n }, Number(endValue.toFixed(decimalPlaces)).toLocaleString())\n )}\n </div>\n </div>\n )\n})\n\nexport const RangeSliderGutter = ({ ...props }: HTMLAttributes<HTMLDivElement>) => <div {...props}/>\n\nexport const RangeSliderLabel = ({ ...props }: HTMLAttributes<HTMLDivElement>) => <div {...props}/>\n\nexport const RangeSliderHighlight = ({ ...props }: HTMLAttributes<HTMLDivElement>) => <div {...props}/>\n\nexport const RangeSliderKnob = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ ...props }, ref) => <div {...props} ref={ref}/>)\n"]}
1
+ {"version":3,"file":"RangeSlider.js","sourceRoot":"/","sources":["RangeSlider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,gEAA+C;AAC/C,6CAAmH;AACnH,wEAAiD;AACjD,4EAAqD;AACrD,4EAAqD;AACrD,4EAAqD;AACrD,oEAA6C;AAC7C,kFAA2D;AAC3D,0DAAmC;AAkBnC,kBAAe,IAAA,kBAAU,EAAmC,UAAC,EAa5D,EAAE,GAAG;;IAZJ,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,wBAAuB,EAAvB,gBAAgB,mBAAG,IAAI,KAAA,EACvB,qBAAiB,EAAjB,aAAa,mBAAG,CAAC,KAAA,EACjB,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,KAAA,EACX,QAAQ,SAAA,EACR,QAAQ,SAAA,EACb,mBAAwB,EAAxB,WAAW,mBAAG,UAAU,KAAA,EACjB,aAAa,WAAA,EACpB,aAAU,EAAV,KAAK,mBAAG,CAAC,CAAC,KAAA,EACV,aAAa,mBAAA,EACV,KAAK,cAZmD,6IAa5D,CADS;IAER,IAAM,kBAAkB,GAAG,UAAC,KAAa,IAAK,OAAA,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAA1C,CAA0C,CAAA;IACxF,IAAM,yBAAyB,GAAG,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kBAAkB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;qBAC1E,CAAC,GAAG,EAAE;oBACL,SAAS,EAAE,IAAA,oBAAU,EAAC,eAAe,CAAC,KAAK,EAAE;wBAC3C,QAAQ,EAAE,iBAAiB;wBAC3B,SAAS,EAAE,kBAAkB;qBAC9B,CAAC;oBACF,KAAK,EAAE,IAAA,gBAAM,EAAC,WAAW,CAAC,KAAK,CAAC;iBACjC,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAC7D,CACG,CACF,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEK,IAAM,iBAAiB,GAAG,UAAC,EAA4C;QAAvC,KAAK,cAAV,EAAY,CAAF;IAAuC,OAAA,kDAAS,KAAK,EAAG,CAAA;CAAA,CAAA;AAAvF,QAAA,iBAAiB,qBAAsE;AAE7F,IAAM,gBAAgB,GAAG,UAAC,EAA4C;QAAvC,KAAK,cAAV,EAAY,CAAF;IAAuC,OAAA,kDAAS,KAAK,EAAG,CAAA;CAAA,CAAA;AAAtF,QAAA,gBAAgB,oBAAsE;AAE5F,IAAM,oBAAoB,GAAG,UAAC,EAA4C;QAAvC,KAAK,cAAV,EAAY,CAAF;IAAuC,OAAA,kDAAS,KAAK,EAAG,CAAA;CAAA,CAAA;AAA1F,QAAA,oBAAoB,wBAAsE;AAE1F,QAAA,eAAe,GAAG,IAAA,kBAAU,EAAiD,UAAC,EAAY,EAAE,GAAG;QAAZ,KAAK,cAAV,EAAY,CAAF;IAAY,OAAA,kDAAS,KAAK,IAAE,GAAG,EAAE,GAAG,IAAG,CAAA;CAAA,CAAC,CAAA","sourcesContent":["import classNames from 'classnames'\nimport isDeepEqual from 'fast-deep-equal/react'\nimport React, { forwardRef, useEffect, useRef, useState, type HTMLAttributes, type PropsWithChildren } from 'react'\nimport useDragEffect from './hooks/useDragEffect'\nimport useResizeEffect from './hooks/useResizeEffect'\nimport asClassNameDict from './utils/asClassNameDict'\nimport asComponentDict from './utils/asComponentDict'\nimport asStyleDict from './utils/asStyleDict'\nimport cloneStyledElement from './utils/cloneStyledElement'\nimport styles from './utils/styles'\n\ntype Orientation = 'horizontal' | 'vertical'\n\ntype Range = [number, number]\n\nexport type RangeSliderProps = HTMLAttributes<HTMLDivElement> & PropsWithChildren<{\n areLabelsVisible?: boolean\n decimalPlaces?: number\n knobPadding?: number\n max: number\n min: number\n orientation?: Orientation\n range?: Range\n steps?: number\n onRangeChange?: (range: Range) => void\n}>\n\nexport default forwardRef<HTMLDivElement, RangeSliderProps>(({\n children,\n className,\n areLabelsVisible = true,\n decimalPlaces = 2,\n knobPadding = 20,\n max: maxValue,\n min: minValue,\n orientation = 'vertical',\n range: externalRange,\n steps = -1,\n onRangeChange,\n ...props\n}, ref) => {\n const getPositionByValue = (value: number) => (value - minValue) / (maxValue - minValue)\n const getPositionByDisplacement = (displacement: number) => displacement / (orientation === 'horizontal' ? size.width : size.height)\n const getValueByPosition = (position: number) => position * (maxValue - minValue) + minValue\n const getValueByDisplacement = (displacement: number) => getValueByPosition(getPositionByDisplacement(displacement))\n const getDisplacementByPosition = (position: number) => position * (orientation === 'horizontal' ? size.width : size.height)\n const getDisplacementByValue = (value: number) => getDisplacementByPosition(getPositionByValue(value))\n\n const getClosestSteppedValue = (value: number) => {\n const n = breakpoints.length\n let idx = 0\n let diff = Infinity\n\n for (let i = 0; i < n; i++) {\n const t = breakpoints[i]\n const d = Math.abs(value - t)\n\n if (d < diff) {\n diff = d\n idx = i\n }\n }\n\n return breakpoints[idx]\n }\n\n const bodyRef = useRef<HTMLDivElement>(null)\n const startKnobRef = useRef<HTMLDivElement>(null)\n const endKnobRef = useRef<HTMLDivElement>(null)\n\n const [size] = useResizeEffect(bodyRef)\n\n const [range, setRange] = useState<Range>(externalRange ?? [minValue, maxValue])\n\n const { isDragging: [isDraggingStartKnob], isReleasing: [isReleasingStartKnob], value: [startValue, setStartValue] } = useDragEffect(startKnobRef, {\n initialValue: externalRange?.[0] ?? minValue,\n transform: (value: number, dx: number, dy: number) => {\n const delta = orientation === 'horizontal' ? dx : dy\n const dMin = getDisplacementByValue(minValue)\n const dMax = getDisplacementByValue(range[1])\n const dCurr = getDisplacementByValue(value) + delta\n\n return getValueByDisplacement(Math.max(dMin, Math.min(dMax, dCurr)))\n },\n }, [minValue, orientation, size, range[1]])\n\n const { isDragging: [isDraggingEndKnob], isReleasing: [isReleasingEndKnob], value: [endValue, setEndValue] } = useDragEffect(endKnobRef, {\n initialValue: externalRange?.[1] ?? maxValue,\n transform: (value: number, dx: number, dy: number) => {\n const delta = orientation === 'horizontal' ? dx : dy\n const dMin = getDisplacementByValue(range[0])\n const dMax = getDisplacementByValue(maxValue)\n const dCurr = getDisplacementByValue(value) + delta\n\n return getValueByDisplacement(Math.max(dMin, Math.min(dMax, dCurr)))\n },\n }, [maxValue, orientation, size, range[0]])\n\n const breakpoints = [minValue, ...[...Array(steps)].map((v, i) => minValue + (i + 1) * (maxValue - minValue) / (1 + steps)), maxValue]\n const [start, end] = range.map(getDisplacementByValue)\n const highlightLength = end - start\n\n useEffect(() => {\n if (range[0] === startValue) return\n setRange([startValue, range[1]])\n onRangeChange?.(range)\n }, [startValue])\n\n useEffect(() => {\n if (range[1] === endValue) return\n setRange([range[0], endValue])\n onRangeChange?.(range)\n }, [endValue])\n\n useEffect(() => {\n if (isDraggingStartKnob || isDraggingEndKnob || isDeepEqual(externalRange, range)) return\n setRange(externalRange ?? [minValue, maxValue])\n }, [externalRange])\n\n useEffect(() => {\n if (steps < 0) return\n setStartValue(getClosestSteppedValue(startValue))\n }, [isReleasingStartKnob])\n\n useEffect(() => {\n if (steps < 0 || !isReleasingEndKnob) return\n setEndValue(getClosestSteppedValue(endValue))\n }, [isReleasingEndKnob])\n\n const components = asComponentDict(children, {\n gutter: RangeSliderGutter,\n highlight: RangeSliderHighlight,\n knob: RangeSliderKnob,\n label: RangeSliderLabel,\n })\n\n const fixedClassNames = asClassNameDict({\n root: classNames(orientation),\n gutter: classNames(orientation),\n highlight: classNames(orientation),\n knob: classNames(orientation),\n label: classNames(orientation),\n })\n\n const fixedStyles = asStyleDict({\n body: {\n height: '100%',\n width: '100%',\n },\n gutter: {\n display: 'block',\n top: '0',\n left: '0',\n position: 'absolute',\n width: '100%',\n height: '100%',\n },\n highlight: {\n height: '100%',\n left: '0',\n position: 'absolute',\n top: '0',\n ...orientation === 'horizontal' ? {\n width: `${highlightLength}px`,\n transform: `translate3d(${start}px, 0, 0)`,\n } : {\n height: `${highlightLength}px`,\n transform: `translate3d(0, ${start}px, 0)`,\n },\n },\n knob: {\n bottom: '0',\n left: '0',\n margin: 'auto',\n position: 'absolute',\n right: '0',\n top: '0',\n touchAction: 'none',\n zIndex: '1',\n },\n knobHitbox: {\n background: 'transparent',\n height: `calc(100% + ${knobPadding * 2}px)`,\n left: `-${knobPadding}px`,\n padding: `${knobPadding}px`,\n position: 'absolute',\n top: `-${knobPadding}px`,\n width: `calc(100% + ${knobPadding * 2}px)`,\n },\n label: {\n pointerEvents: 'none',\n position: 'relative',\n userSelect: 'none',\n },\n })\n\n const defaultStyles = asStyleDict({\n gutter: {\n background: 'rgba(255, 255, 255, .2)',\n },\n highlight: {\n background: '#fff',\n transitionDuration: '100ms',\n transitionProperty: (isReleasingStartKnob ? !isReleasingEndKnob : isReleasingEndKnob) ? 'opacity, width, transform' : 'opacity',\n transitionTimingFunction: 'ease-out',\n },\n knob: {\n alignItems: 'center',\n background: '#fff',\n borderRadius: '10px',\n boxSizing: 'border-box',\n display: 'flex',\n height: '20px',\n justifyContent: 'center',\n transitionDuration: '100ms',\n transitionTimingFunction: 'ease-out',\n width: '20px',\n },\n label: {\n background: 'transparent',\n color: '#fff',\n textAlign: 'center',\n transitionDuration: '100ms',\n transitionTimingFunction: 'ease-out',\n ...orientation === 'horizontal' ? {\n top: 'calc(100% + 10px)',\n } : {\n left: 'calc(100% + 10px)',\n },\n },\n })\n\n return (\n <div {...props} ref={ref} className={classNames(className, fixedClassNames.root)}>\n <div ref={bodyRef} style={fixedStyles.body}>\n {cloneStyledElement(components.gutter ?? <RangeSliderGutter style={defaultStyles.gutter}/>, {\n className: classNames(fixedClassNames.gutter),\n style: styles(fixedStyles.gutter),\n })}\n {cloneStyledElement(components.highlight ?? <RangeSliderHighlight style={defaultStyles.highlight}/>, {\n className: classNames(fixedClassNames.highlight),\n style: styles(fixedStyles.highlight),\n })}\n {cloneStyledElement(components.knob ?? <RangeSliderKnob style={styles(defaultStyles.knob, {\n transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',\n })}/>, {\n ref: startKnobRef,\n disabled: isDeepEqual([startValue, endValue], [maxValue, maxValue]),\n className: classNames(fixedClassNames.knob, {\n dragging: isDraggingStartKnob,\n releasing: isReleasingStartKnob,\n }),\n style: styles(fixedStyles.knob, {\n pointerEvents: isDeepEqual([startValue, endValue], [minValue, minValue]) ? 'none' : 'auto',\n }, orientation === 'horizontal' ? {\n marginLeft: `${start}px`,\n } : {\n marginTop: `${start}px`,\n }),\n }, <div style={fixedStyles.knobHitbox}/>, areLabelsVisible &&\n cloneStyledElement(components.label ?? <RangeSliderLabel style={styles(defaultStyles.label, {\n transitionProperty: isReleasingStartKnob ? 'opacity, transform' : 'opacity',\n })}/>, {\n className: classNames(fixedClassNames.label, {\n dragging: isDraggingStartKnob || isDraggingEndKnob,\n releasing: isReleasingStartKnob || isReleasingEndKnob,\n }),\n style: styles(fixedStyles.label),\n }, Number(startValue.toFixed(decimalPlaces)).toLocaleString())\n )}\n {cloneStyledElement(components.knob ?? <RangeSliderKnob style={styles(defaultStyles.knob, {\n transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',\n })}/>, {\n ref: endKnobRef,\n disabled: isDeepEqual([startValue, endValue], [maxValue, maxValue]),\n className: classNames(fixedClassNames.knob, {\n dragging: isDraggingEndKnob,\n releasing: isDraggingEndKnob,\n }),\n style: styles(fixedStyles.knob, {\n pointerEvents: isDeepEqual([startValue, endValue], [maxValue, maxValue]) ? 'none' : 'auto',\n }, orientation === 'horizontal' ? {\n marginLeft: `${end}px`,\n } : {\n marginTop: `${end}px`,\n }),\n }, <div style={fixedStyles.knobHitbox}/>, areLabelsVisible &&\n cloneStyledElement(components.label ?? <RangeSliderLabel style={styles(defaultStyles.label, {\n transitionProperty: isReleasingEndKnob ? 'opacity, transform' : 'opacity',\n })}/>, {\n className: classNames(fixedClassNames.label, {\n dragging: isDraggingEndKnob,\n releasing: isReleasingEndKnob,\n }),\n style: styles(fixedStyles.label),\n }, Number(endValue.toFixed(decimalPlaces)).toLocaleString())\n )}\n </div>\n </div>\n )\n})\n\nexport const RangeSliderGutter = ({ ...props }: HTMLAttributes<HTMLDivElement>) => <div {...props}/>\n\nexport const RangeSliderLabel = ({ ...props }: HTMLAttributes<HTMLDivElement>) => <div {...props}/>\n\nexport const RangeSliderHighlight = ({ ...props }: HTMLAttributes<HTMLDivElement>) => <div {...props}/>\n\nexport const RangeSliderKnob = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ ...props }, ref) => <div {...props} ref={ref}/>)\n"]}
@@ -50,9 +50,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
53
+ var react_1 = __importDefault(require("fast-deep-equal/react"));
54
54
  var interactjs_1 = __importDefault(require("interactjs"));
55
- var react_1 = require("react");
55
+ var react_2 = require("react");
56
56
  /**
57
57
  * Hook for adding effectful dragging interaction to an element.
58
58
  *
@@ -77,17 +77,17 @@ function useDragEffect(targetRef, _a, deps) {
77
77
  * @returns `true` if the value was set, `false` otherwise.
78
78
  */
79
79
  var setValueRef = function (value) {
80
- if ((0, fast_deep_equal_1.default)(valueRef.current, value))
80
+ if ((0, react_1.default)(valueRef.current, value))
81
81
  return false;
82
82
  valueRef.current = value;
83
83
  return true;
84
84
  };
85
- var valueRef = (0, react_1.useRef)(initialValue);
86
- var _b = __read((0, react_1.useState)(false), 2), hasDragged = _b[0], setHasDragged = _b[1];
87
- var _c = __read((0, react_1.useState)(false), 2), isDragging = _c[0], setIsDragging = _c[1];
88
- var _d = __read((0, react_1.useState)(false), 2), isReleasing = _d[0], setIsReleasing = _d[1];
89
- var _e = __read((0, react_1.useState)(initialValue), 2), value = _e[0], setValue = _e[1];
90
- (0, react_1.useEffect)(function () {
85
+ var valueRef = (0, react_2.useRef)(initialValue);
86
+ var _b = __read((0, react_2.useState)(false), 2), hasDragged = _b[0], setHasDragged = _b[1];
87
+ var _c = __read((0, react_2.useState)(false), 2), isDragging = _c[0], setIsDragging = _c[1];
88
+ var _d = __read((0, react_2.useState)(false), 2), isReleasing = _d[0], setIsReleasing = _d[1];
89
+ var _e = __read((0, react_2.useState)(initialValue), 2), value = _e[0], setValue = _e[1];
90
+ (0, react_2.useEffect)(function () {
91
91
  if (targetRef.current && !interactjs_1.default.isSet(targetRef.current)) {
92
92
  // Do not consume states in these listeners as they will remain their
93
93
  // initial values within the scope of the listeners.
@@ -117,12 +117,12 @@ function useDragEffect(targetRef, _a, deps) {
117
117
  }
118
118
  };
119
119
  }, __spreadArray([], __read(deps ? deps : []), false));
120
- (0, react_1.useEffect)(function () {
120
+ (0, react_2.useEffect)(function () {
121
121
  if (hasDragged)
122
122
  return;
123
123
  setValue(initialValue);
124
124
  }, [initialValue]);
125
- (0, react_1.useEffect)(function () {
125
+ (0, react_2.useEffect)(function () {
126
126
  setValueRef(value);
127
127
  }, [value]);
128
128
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"useDragEffect.js","sourceRoot":"/","sources":["hooks/useDragEffect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAqC;AACrC,0DAAiC;AACjC,+BAA4H;AAmD5H;;;;;;;;;;GAUG;AACH,SAAw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AEX,OAAO;QACL,UAAU,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC;QACvC,WAAW,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;QAC1C,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC;KACzB,CAAA;AACH,CAAC;AApFD,gCAoFC","sourcesContent":["import isEqual from 'fast-deep-equal'\nimport interact from 'interactjs'\nimport { useEffect, useRef, useState, type DependencyList, type Dispatch, type RefObject, type SetStateAction } from 'react'\n\ntype ReturnedStates<T> = {\n isDragging: [boolean, Dispatch<SetStateAction<boolean>>]\n isReleasing: [boolean, Dispatch<SetStateAction<boolean>>]\n value: [T, Dispatch<SetStateAction<T>>]\n}\n\ntype InteractDraggableOptions = Parameters<Interact.Interactable['draggable']>[0]\n\ntype Options<T> = Omit<InteractDraggableOptions, 'onstart' | 'onmove' | 'onend'> & {\n /**\n * The initial associated value of this hook.\n */\n initialValue: T\n\n /**\n * A function that transforms the drag move delta values to the associated\n * value of this hook.\n *\n * @param currentValue The current associated value.\n * @param dx The displacement on the x-axis (in pixels) since the last emitted\n * drag move event.\n * @param dy The displacement on the y-axis (in pixels) since the last emitted\n * drag move event.\n *\n * @returns The transformed value.\n */\n transform: (currentValue: T, dx: number, dy: number) => T\n\n /**\n * Handler invoked when dragging starts.\n */\n onDragStart?: () => void\n\n /**\n * Handler invoked when dragging.\n *\n * @param dx The displacement on the x-axis (in pixels) since the last emitted\n * drag move event.\n * @param dy The displacement on the y-axis (in pixels) since the last emitted\n * drag move event.\n */\n onDragMove?: (dx: number, dy: number) => void\n\n /**\n * Handler invoked when dragging ends.\n */\n onDragEnd?: () => void\n}\n\n/**\n * Hook for adding effectful dragging interaction to an element.\n *\n * @param targetRef The reference to the target element to add drag interaction\n * to.\n * @param options Additional options which include options for\n * `module:interactjs.draggable`.\n * @param deps Dependencies that trigger this effect.\n *\n * @returns The states created for this effect.\n */\nexport default function useDragEffect<T = [number, number]>(targetRef: RefObject<HTMLElement>, {\n initialValue,\n transform,\n onDragStart,\n onDragMove,\n onDragEnd,\n ...options\n}: Options<T>, deps?: DependencyList): ReturnedStates<T> {\n /**\n * Sets the current associated value reference. This reference object is equal\n * to the `value` state but differs slightly in how they are set. Because\n * states are asynchronous by nature, this reference object is used to cache\n * time-sensitive value changes while drag event happens.\n *\n * @param value The value to set the associated value to.\n *\n * @returns `true` if the value was set, `false` otherwise.\n */\n const setValueRef = (value: T): boolean => {\n if (isEqual(valueRef.current, value)) return false\n valueRef.current = value\n\n return true\n }\n\n const valueRef = useRef<T>(initialValue)\n const [hasDragged, setHasDragged] = useState<boolean>(false)\n const [isDragging, setIsDragging] = useState<boolean>(false)\n const [isReleasing, setIsReleasing] = useState<boolean>(false)\n const [value, setValue] = useState(initialValue)\n\n useEffect(() => {\n if (targetRef.current && !interact.isSet(targetRef.current)) {\n // Do not consume states in these listeners as they will remain their\n // initial values within the scope of the listeners.\n interact(targetRef.current).draggable({\n inertia: true,\n ...options,\n onstart: () => {\n setHasDragged(true)\n setIsDragging(true)\n setIsReleasing(false)\n onDragStart?.()\n },\n onmove: ({ dx, dy }) => {\n const newValue = transform(valueRef.current, dx, dy)\n\n if (setValueRef(newValue)) {\n setValue(newValue)\n }\n\n setIsDragging(true)\n setIsReleasing(false)\n onDragMove?.(dx, dy)\n },\n onend: () => {\n setIsDragging(false)\n setIsReleasing(true)\n onDragEnd?.()\n },\n })\n }\n\n return () => {\n if (targetRef.current && interact.isSet(targetRef.current)) {\n interact(targetRef.current).unset()\n }\n }\n }, [...deps ? deps : []])\n\n useEffect(() => {\n if (hasDragged) return\n setValue(initialValue)\n }, [initialValue])\n\n useEffect(() => {\n setValueRef(value)\n }, [value])\n\n return {\n isDragging: [isDragging, setIsDragging],\n isReleasing: [isReleasing, setIsReleasing],\n value: [value, setValue],\n }\n}\n"]}
1
+ {"version":3,"file":"useDragEffect.js","sourceRoot":"/","sources":["hooks/useDragEffect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IAAA,iBAAS,EAAC;QACR,WAAW,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,OAAO;QACL,UAAU,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC;QACvC,WAAW,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;QAC1C,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC;KACzB,CAAA;AACH,CAAC;AApFD,gCAoFC","sourcesContent":["import isDeepEqual from 'fast-deep-equal/react'\nimport interact from 'interactjs'\nimport { useEffect, useRef, useState, type DependencyList, type Dispatch, type RefObject, type SetStateAction } from 'react'\n\ntype ReturnedStates<T> = {\n isDragging: [boolean, Dispatch<SetStateAction<boolean>>]\n isReleasing: [boolean, Dispatch<SetStateAction<boolean>>]\n value: [T, Dispatch<SetStateAction<T>>]\n}\n\ntype InteractDraggableOptions = Parameters<Interact.Interactable['draggable']>[0]\n\ntype Options<T> = Omit<InteractDraggableOptions, 'onstart' | 'onmove' | 'onend'> & {\n /**\n * The initial associated value of this hook.\n */\n initialValue: T\n\n /**\n * A function that transforms the drag move delta values to the associated\n * value of this hook.\n *\n * @param currentValue The current associated value.\n * @param dx The displacement on the x-axis (in pixels) since the last emitted\n * drag move event.\n * @param dy The displacement on the y-axis (in pixels) since the last emitted\n * drag move event.\n *\n * @returns The transformed value.\n */\n transform: (currentValue: T, dx: number, dy: number) => T\n\n /**\n * Handler invoked when dragging starts.\n */\n onDragStart?: () => void\n\n /**\n * Handler invoked when dragging.\n *\n * @param dx The displacement on the x-axis (in pixels) since the last emitted\n * drag move event.\n * @param dy The displacement on the y-axis (in pixels) since the last emitted\n * drag move event.\n */\n onDragMove?: (dx: number, dy: number) => void\n\n /**\n * Handler invoked when dragging ends.\n */\n onDragEnd?: () => void\n}\n\n/**\n * Hook for adding effectful dragging interaction to an element.\n *\n * @param targetRef The reference to the target element to add drag interaction\n * to.\n * @param options Additional options which include options for\n * `module:interactjs.draggable`.\n * @param deps Dependencies that trigger this effect.\n *\n * @returns The states created for this effect.\n */\nexport default function useDragEffect<T = [number, number]>(targetRef: RefObject<HTMLElement>, {\n initialValue,\n transform,\n onDragStart,\n onDragMove,\n onDragEnd,\n ...options\n}: Options<T>, deps?: DependencyList): ReturnedStates<T> {\n /**\n * Sets the current associated value reference. This reference object is equal\n * to the `value` state but differs slightly in how they are set. Because\n * states are asynchronous by nature, this reference object is used to cache\n * time-sensitive value changes while drag event happens.\n *\n * @param value The value to set the associated value to.\n *\n * @returns `true` if the value was set, `false` otherwise.\n */\n const setValueRef = (value: T): boolean => {\n if (isDeepEqual(valueRef.current, value)) return false\n valueRef.current = value\n\n return true\n }\n\n const valueRef = useRef<T>(initialValue)\n const [hasDragged, setHasDragged] = useState<boolean>(false)\n const [isDragging, setIsDragging] = useState<boolean>(false)\n const [isReleasing, setIsReleasing] = useState<boolean>(false)\n const [value, setValue] = useState(initialValue)\n\n useEffect(() => {\n if (targetRef.current && !interact.isSet(targetRef.current)) {\n // Do not consume states in these listeners as they will remain their\n // initial values within the scope of the listeners.\n interact(targetRef.current).draggable({\n inertia: true,\n ...options,\n onstart: () => {\n setHasDragged(true)\n setIsDragging(true)\n setIsReleasing(false)\n onDragStart?.()\n },\n onmove: ({ dx, dy }) => {\n const newValue = transform(valueRef.current, dx, dy)\n\n if (setValueRef(newValue)) {\n setValue(newValue)\n }\n\n setIsDragging(true)\n setIsReleasing(false)\n onDragMove?.(dx, dy)\n },\n onend: () => {\n setIsDragging(false)\n setIsReleasing(true)\n onDragEnd?.()\n },\n })\n }\n\n return () => {\n if (targetRef.current && interact.isSet(targetRef.current)) {\n interact(targetRef.current).unset()\n }\n }\n }, [...deps ? deps : []])\n\n useEffect(() => {\n if (hasDragged) return\n setValue(initialValue)\n }, [initialValue])\n\n useEffect(() => {\n setValueRef(value)\n }, [value])\n\n return {\n isDragging: [isDragging, setIsDragging],\n isReleasing: [isReleasing, setIsReleasing],\n value: [value, setValue],\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "etudes",
3
- "version": "3.3.1",
3
+ "version": "3.5.0",
4
4
  "description": "A study of headless React components",
5
5
  "main": "lib",
6
6
  "scripts": {