instantsearch.js 4.55.0 → 4.56.1

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 (70) hide show
  1. package/cjs/components/Breadcrumb/Breadcrumb.js +2 -2
  2. package/cjs/components/Hits/Hits.js +4 -0
  3. package/cjs/components/InfiniteHits/InfiniteHits.js +4 -0
  4. package/cjs/components/RangeInput/RangeInput.js +22 -11
  5. package/cjs/components/RefinementList/RefinementList.js +34 -52
  6. package/cjs/components/Slider/Rheostat.js +163 -249
  7. package/cjs/connectors/infinite-hits/connectInfiniteHits.js +22 -7
  8. package/cjs/lib/InstantSearch.js +2 -4
  9. package/cjs/lib/routers/history.js +54 -1
  10. package/cjs/lib/utils/escape-highlight.js +2 -0
  11. package/cjs/lib/utils/getHighlightedParts.js +1 -0
  12. package/cjs/lib/utils/render-args.js +3 -2
  13. package/cjs/lib/version.js +1 -1
  14. package/cjs/widgets/hits-per-page/hits-per-page.js +3 -1
  15. package/cjs/widgets/index/index.js +8 -8
  16. package/dist/instantsearch.development.d.ts +76 -76
  17. package/dist/instantsearch.development.js +356 -341
  18. package/dist/instantsearch.development.js.map +1 -1
  19. package/dist/instantsearch.production.d.ts +76 -76
  20. package/dist/instantsearch.production.min.d.ts +76 -76
  21. package/dist/instantsearch.production.min.js +2 -2
  22. package/dist/instantsearch.production.min.js.map +1 -1
  23. package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -2
  24. package/es/components/Breadcrumb/Breadcrumb.js +2 -2
  25. package/es/components/GeoSearchControls/GeoSearchButton.d.ts +1 -1
  26. package/es/components/GeoSearchControls/GeoSearchControls.d.ts +3 -3
  27. package/es/components/GeoSearchControls/GeoSearchToggle.d.ts +1 -1
  28. package/es/components/Hits/Hits.js +4 -0
  29. package/es/components/InfiniteHits/InfiniteHits.js +4 -0
  30. package/es/components/Pagination/Pagination.d.ts +2 -2
  31. package/es/components/RangeInput/RangeInput.d.ts +7 -4
  32. package/es/components/RangeInput/RangeInput.js +22 -11
  33. package/es/components/RefinementList/RefinementList.d.ts +0 -1
  34. package/es/components/RefinementList/RefinementList.js +34 -52
  35. package/es/components/RelevantSort/RelevantSort.d.ts +1 -1
  36. package/es/components/Selector/Selector.d.ts +2 -2
  37. package/es/components/Slider/Rheostat.d.ts +23 -17
  38. package/es/components/Slider/Rheostat.js +163 -249
  39. package/es/components/Slider/Slider.d.ts +1 -1
  40. package/es/connectors/current-refinements/connectCurrentRefinements.d.ts +2 -2
  41. package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +2 -2
  42. package/es/connectors/geo-search/connectGeoSearch.d.ts +7 -7
  43. package/es/connectors/infinite-hits/connectInfiniteHits.js +23 -8
  44. package/es/connectors/menu/connectMenu.d.ts +2 -2
  45. package/es/connectors/pagination/connectPagination.d.ts +1 -1
  46. package/es/connectors/range/connectRange.d.ts +3 -3
  47. package/es/connectors/refinement-list/connectRefinementList.d.ts +3 -3
  48. package/es/connectors/relevant-sort/connectRelevantSort.d.ts +1 -1
  49. package/es/lib/InstantSearch.d.ts +13 -13
  50. package/es/lib/InstantSearch.js +3 -5
  51. package/es/lib/routers/history.d.ts +2 -2
  52. package/es/lib/routers/history.js +55 -2
  53. package/es/lib/utils/defer.d.ts +2 -2
  54. package/es/lib/utils/escape-highlight.js +2 -0
  55. package/es/lib/utils/getHighlightedParts.js +1 -0
  56. package/es/lib/utils/render-args.js +3 -2
  57. package/es/lib/version.d.ts +1 -1
  58. package/es/lib/version.js +1 -1
  59. package/es/types/middleware.d.ts +6 -6
  60. package/es/types/router.d.ts +7 -7
  61. package/es/types/widget.d.ts +1 -1
  62. package/es/widgets/dynamic-widgets/dynamic-widgets.d.ts +2 -2
  63. package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -1
  64. package/es/widgets/geo-search/geo-search.d.ts +1 -1
  65. package/es/widgets/hits-per-page/hits-per-page.js +3 -1
  66. package/es/widgets/index/index.d.ts +20 -20
  67. package/es/widgets/index/index.js +8 -8
  68. package/es/widgets/panel/panel.d.ts +2 -2
  69. package/es/widgets/range-slider/range-slider.d.ts +1 -1
  70. package/package.json +6 -6
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _preact = require("preact");
9
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
9
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
11
10
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
12
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
13
13
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14
14
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -70,10 +70,16 @@ var _ref6 = (0, _preact.h)("div", {
70
70
  var Rheostat = /*#__PURE__*/function (_Component) {
71
71
  _inherits(Rheostat, _Component);
72
72
  var _super = _createSuper(Rheostat);
73
- function Rheostat(props) {
73
+ function Rheostat() {
74
74
  var _this;
75
75
  _classCallCheck(this, Rheostat);
76
- _this = _super.call(this, props);
76
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
77
+ args[_key] = arguments[_key];
78
+ }
79
+ _this = _super.call.apply(_super, [this].concat(args));
80
+ _defineProperty(_assertThisInitialized(_this), "x", [0, 0].map(function (y) {
81
+ return y;
82
+ }));
77
83
  _defineProperty(_assertThisInitialized(_this), "state", {
78
84
  className: getClassName(_this.props),
79
85
  // non-null thanks to defaultProps
@@ -88,44 +94,14 @@ var Rheostat = /*#__PURE__*/function (_Component) {
88
94
  values: _this.props.values
89
95
  });
90
96
  _defineProperty(_assertThisInitialized(_this), "rheostat", (0, _preact.createRef)());
91
- _this.getPublicState = _this.getPublicState.bind(_assertThisInitialized(_this));
92
- _this.getSliderBoundingBox = _this.getSliderBoundingBox.bind(_assertThisInitialized(_this));
93
- _this.getProgressStyle = _this.getProgressStyle.bind(_assertThisInitialized(_this));
94
- _this.getMinValue = _this.getMinValue.bind(_assertThisInitialized(_this));
95
- _this.getMaxValue = _this.getMaxValue.bind(_assertThisInitialized(_this));
96
- _this.getHandleDimensions = _this.getHandleDimensions.bind(_assertThisInitialized(_this));
97
- _this.getClosestSnapPoint = _this.getClosestSnapPoint.bind(_assertThisInitialized(_this));
98
- _this.getSnapPosition = _this.getSnapPosition.bind(_assertThisInitialized(_this));
99
- _this.getNextPositionForKey = _this.getNextPositionForKey.bind(_assertThisInitialized(_this));
100
- _this.getNextState = _this.getNextState.bind(_assertThisInitialized(_this));
101
- _this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
102
- _this.getClosestHandle = _this.getClosestHandle.bind(_assertThisInitialized(_this));
103
- _this.setStartSlide = _this.setStartSlide.bind(_assertThisInitialized(_this));
104
- _this.startMouseSlide = _this.startMouseSlide.bind(_assertThisInitialized(_this));
105
- _this.startTouchSlide = _this.startTouchSlide.bind(_assertThisInitialized(_this));
106
- _this.handleMouseSlide = _this.handleMouseSlide.bind(_assertThisInitialized(_this));
107
- _this.handleTouchSlide = _this.handleTouchSlide.bind(_assertThisInitialized(_this));
108
- _this.handleSlide = _this.handleSlide.bind(_assertThisInitialized(_this));
109
- _this.endSlide = _this.endSlide.bind(_assertThisInitialized(_this));
110
- _this.handleKeydown = _this.handleKeydown.bind(_assertThisInitialized(_this));
111
- _this.validatePosition = _this.validatePosition.bind(_assertThisInitialized(_this));
112
- _this.validateValues = _this.validateValues.bind(_assertThisInitialized(_this));
113
- _this.canMove = _this.canMove.bind(_assertThisInitialized(_this));
114
- _this.fireChangeEvent = _this.fireChangeEvent.bind(_assertThisInitialized(_this));
115
- _this.slideTo = _this.slideTo.bind(_assertThisInitialized(_this));
116
- _this.updateNewValues = _this.updateNewValues.bind(_assertThisInitialized(_this));
117
- return _this;
118
- }
119
- _createClass(Rheostat, [{
120
- key: "componentWillReceiveProps",
121
- value: function componentWillReceiveProps(nextProps) {
122
- var _this$props = this.props,
97
+ _defineProperty(_assertThisInitialized(_this), "componentWillReceiveProps", function (nextProps) {
98
+ var _this$props = _this.props,
123
99
  className = _this$props.className,
124
100
  disabled = _this$props.disabled,
125
101
  min = _this$props.min,
126
102
  max = _this$props.max,
127
103
  orientation = _this$props.orientation;
128
- var _this$state = this.state,
104
+ var _this$state = _this.state,
129
105
  values = _this$state.values,
130
106
  slidingIndex = _this$state.slidingIndex;
131
107
  var minMaxChanged = nextProps.min !== min || nextProps.max !== max;
@@ -135,33 +111,29 @@ var Rheostat = /*#__PURE__*/function (_Component) {
135
111
  var orientationChanged = nextProps.className !== className || nextProps.orientation !== orientation;
136
112
  var willBeDisabled = nextProps.disabled && !disabled;
137
113
  if (orientationChanged) {
138
- this.setState({
114
+ _this.setState({
139
115
  className: getClassName(nextProps)
140
116
  });
141
117
  }
142
- if (minMaxChanged || valuesChanged) this.updateNewValues(nextProps);
118
+ if (minMaxChanged || valuesChanged) _this.updateNewValues(nextProps);
143
119
  if (willBeDisabled && slidingIndex !== null) {
144
- this.endSlide();
120
+ _this.endSlide();
145
121
  }
146
- }
147
- }, {
148
- key: "getPublicState",
149
- value: function getPublicState() {
150
- var _this$props2 = this.props,
122
+ });
123
+ _defineProperty(_assertThisInitialized(_this), "getPublicState", function () {
124
+ var _this$props2 = _this.props,
151
125
  min = _this$props2.min,
152
126
  max = _this$props2.max;
153
- var values = this.state.values;
127
+ var values = _this.state.values;
154
128
  return {
155
129
  max: max,
156
130
  min: min,
157
131
  values: values
158
132
  };
159
- }
160
- }, {
161
- key: "getSliderBoundingBox",
162
- value: function getSliderBoundingBox() {
133
+ });
134
+ _defineProperty(_assertThisInitialized(_this), "getSliderBoundingBox", function () {
163
135
  // only gets called after render, so it will always be defined
164
- var node = this.rheostat.current;
136
+ var node = _this.rheostat.current;
165
137
  var rect = node.getBoundingClientRect();
166
138
  return {
167
139
  height: rect.height || node.clientHeight,
@@ -169,14 +141,12 @@ var Rheostat = /*#__PURE__*/function (_Component) {
169
141
  top: rect.top,
170
142
  width: rect.width || node.clientWidth
171
143
  };
172
- }
173
- }, {
174
- key: "getProgressStyle",
175
- value: function getProgressStyle(idx) {
176
- var handlePos = this.state.handlePos;
144
+ });
145
+ _defineProperty(_assertThisInitialized(_this), "getProgressStyle", function (idx) {
146
+ var handlePos = _this.state.handlePos;
177
147
  var value = handlePos[idx];
178
148
  if (idx === 0) {
179
- return this.props.orientation === 'vertical' ? {
149
+ return _this.props.orientation === 'vertical' ? {
180
150
  height: "".concat(value, "%"),
181
151
  top: 0
182
152
  } : {
@@ -186,63 +156,51 @@ var Rheostat = /*#__PURE__*/function (_Component) {
186
156
  }
187
157
  var prevValue = handlePos[idx - 1];
188
158
  var diffValue = value - prevValue;
189
- return this.props.orientation === 'vertical' ? {
159
+ return _this.props.orientation === 'vertical' ? {
190
160
  height: "".concat(diffValue, "%"),
191
161
  top: "".concat(prevValue, "%")
192
162
  } : {
193
163
  left: "".concat(prevValue, "%"),
194
164
  width: "".concat(diffValue, "%")
195
165
  };
196
- }
197
- }, {
198
- key: "getMinValue",
199
- value: function getMinValue(idx) {
200
- return this.state.values[idx - 1] ? Math.max(this.props.min, this.state.values[idx - 1]) : this.props.min;
201
- }
202
- }, {
203
- key: "getMaxValue",
204
- value: function getMaxValue(idx) {
205
- return this.state.values[idx + 1] ? Math.min(this.props.max, this.state.values[idx + 1]) : this.props.max;
206
- }
207
- }, {
208
- key: "getHandleDimensions",
209
- value: function getHandleDimensions(ev, sliderBox) {
166
+ });
167
+ _defineProperty(_assertThisInitialized(_this), "getMinValue", function (idx) {
168
+ return _this.state.values[idx - 1] ? Math.max(_this.props.min, _this.state.values[idx - 1]) : _this.props.min;
169
+ });
170
+ _defineProperty(_assertThisInitialized(_this), "getMaxValue", function (idx) {
171
+ return _this.state.values[idx + 1] ? Math.min(_this.props.max, _this.state.values[idx + 1]) : _this.props.max;
172
+ });
173
+ _defineProperty(_assertThisInitialized(_this), "getHandleDimensions", function (ev, sliderBox) {
210
174
  var handleNode = ev.currentTarget || null;
211
175
  if (!handleNode) return 0;
212
- return this.props.orientation === 'vertical' ? handleNode.clientHeight / sliderBox.height * PERCENT_FULL / 2 : handleNode.clientWidth / sliderBox.width * PERCENT_FULL / 2;
213
- }
214
- }, {
215
- key: "getClosestSnapPoint",
216
- value: function getClosestSnapPoint(value) {
176
+ return _this.props.orientation === 'vertical' ? handleNode.clientHeight / sliderBox.height * PERCENT_FULL / 2 : handleNode.clientWidth / sliderBox.width * PERCENT_FULL / 2;
177
+ });
178
+ _defineProperty(_assertThisInitialized(_this), "getClosestSnapPoint", function (value) {
217
179
  // non-null thanks to defaultProps
218
- if (!this.props.snapPoints.length) return value;
219
- return this.props.snapPoints.reduce(function (snapTo, snap) {
180
+ if (!_this.props.snapPoints.length) return value;
181
+ return _this.props.snapPoints.reduce(function (snapTo, snap) {
220
182
  return Math.abs(snapTo - value) < Math.abs(snap - value) ? snapTo : snap;
221
183
  });
222
- }
223
- }, {
224
- key: "getSnapPosition",
225
- value: function getSnapPosition(positionPercent) {
226
- if (!this.props.snap) return positionPercent;
227
- var _ref = this.props,
184
+ });
185
+ _defineProperty(_assertThisInitialized(_this), "getSnapPosition", function (positionPercent) {
186
+ if (!_this.props.snap) return positionPercent;
187
+ var _ref = _this.props,
228
188
  max = _ref.max,
229
189
  min = _ref.min;
230
190
  var value = getValue(positionPercent, min, max);
231
- var snapValue = this.getClosestSnapPoint(value);
191
+ var snapValue = _this.getClosestSnapPoint(value);
232
192
  return getPosition(snapValue, min, max);
233
- }
234
- }, {
235
- key: "getNextPositionForKey",
236
- value: function getNextPositionForKey(idx, keyCode) {
193
+ });
194
+ _defineProperty(_assertThisInitialized(_this), "getNextPositionForKey", function (idx, keyCode) {
237
195
  var _stepMultiplier;
238
- var _this$state2 = this.state,
196
+ var _this$state2 = _this.state,
239
197
  handlePos = _this$state2.handlePos,
240
198
  values = _this$state2.values;
241
- var _ref2 = this.props,
199
+ var _ref2 = _this.props,
242
200
  max = _ref2.max,
243
201
  min = _ref2.min,
244
202
  snapPoints = _ref2.snapPoints;
245
- var shouldSnap = this.props.snap;
203
+ var shouldSnap = _this.props.snap;
246
204
  var proposedValue = values[idx];
247
205
  var proposedPercentage = handlePos[idx];
248
206
  var originalPercentage = proposedPercentage;
@@ -254,7 +212,7 @@ var Rheostat = /*#__PURE__*/function (_Component) {
254
212
  }
255
213
  var currentIndex = null;
256
214
  if (shouldSnap) {
257
- currentIndex = snapPoints.indexOf(this.getClosestSnapPoint(values[idx]));
215
+ currentIndex = snapPoints.indexOf(_this.getClosestSnapPoint(values[idx]));
258
216
  }
259
217
  var stepMultiplier = (_stepMultiplier = {}, _defineProperty(_stepMultiplier, KEYS.LEFT, function (v) {
260
218
  return v * -1;
@@ -298,15 +256,13 @@ var Rheostat = /*#__PURE__*/function (_Component) {
298
256
  return null;
299
257
  }
300
258
  return shouldSnap ? getPosition(proposedValue, min, max) : proposedPercentage;
301
- }
302
- }, {
303
- key: "getNextState",
304
- value: function getNextState(idx, proposedPosition) {
305
- var handlePos = this.state.handlePos;
306
- var _ref3 = this.props,
259
+ });
260
+ _defineProperty(_assertThisInitialized(_this), "getNextState", function (idx, proposedPosition) {
261
+ var handlePos = _this.state.handlePos;
262
+ var _ref3 = _this.props,
307
263
  max = _ref3.max,
308
264
  min = _ref3.min;
309
- var actualPosition = this.validatePosition(idx, proposedPosition);
265
+ var actualPosition = _this.validatePosition(idx, proposedPosition);
310
266
  var nextHandlePos = handlePos.map(function (pos, index) {
311
267
  return index === idx ? actualPosition : pos;
312
268
  });
@@ -316,23 +272,19 @@ var Rheostat = /*#__PURE__*/function (_Component) {
316
272
  return getValue(pos, min, max);
317
273
  })
318
274
  };
319
- }
320
- }, {
321
- key: "getClosestHandle",
322
- value: function getClosestHandle(positionPercent) {
323
- var handlePos = this.state.handlePos;
275
+ });
276
+ _defineProperty(_assertThisInitialized(_this), "getClosestHandle", function (positionPercent) {
277
+ var handlePos = _this.state.handlePos;
324
278
  return handlePos.reduce(function (closestIdx, _node, idx) {
325
279
  var challenger = Math.abs(handlePos[idx] - positionPercent);
326
280
  var current = Math.abs(handlePos[closestIdx] - positionPercent);
327
281
  return challenger < current ? idx : closestIdx;
328
282
  }, 0);
329
- }
330
- }, {
331
- key: "setStartSlide",
332
- value: function setStartSlide(ev, x, y) {
333
- var sliderBox = this.getSliderBoundingBox();
334
- this.setState({
335
- handleDimensions: this.getHandleDimensions(ev, sliderBox),
283
+ });
284
+ _defineProperty(_assertThisInitialized(_this), "setStartSlide", function (ev, x, y) {
285
+ var sliderBox = _this.getSliderBoundingBox();
286
+ _this.setState({
287
+ handleDimensions: _this.getHandleDimensions(ev, sliderBox),
336
288
  mousePos: {
337
289
  x: x,
338
290
  y: y
@@ -340,144 +292,118 @@ var Rheostat = /*#__PURE__*/function (_Component) {
340
292
  sliderBox: sliderBox,
341
293
  slidingIndex: getHandleFor(ev)
342
294
  });
343
- }
344
- }, {
345
- key: "startMouseSlide",
346
- value: function startMouseSlide(ev) {
347
- this.setStartSlide(ev, ev.clientX, ev.clientY);
348
- document.addEventListener('mousemove', this.handleMouseSlide, false);
349
- document.addEventListener('mouseup', this.endSlide, false);
295
+ });
296
+ _defineProperty(_assertThisInitialized(_this), "startMouseSlide", function (ev) {
297
+ _this.setStartSlide(ev, ev.clientX, ev.clientY);
298
+ document.addEventListener('mousemove', _this.handleMouseSlide, false);
299
+ document.addEventListener('mouseup', _this.endSlide, false);
350
300
  killEvent(ev);
351
- }
352
- }, {
353
- key: "startTouchSlide",
354
- value: function startTouchSlide(ev) {
301
+ });
302
+ _defineProperty(_assertThisInitialized(_this), "startTouchSlide", function (ev) {
355
303
  if (ev.changedTouches.length > 1) return;
356
304
  var touch = ev.changedTouches[0];
357
- this.setStartSlide(ev, touch.clientX, touch.clientY);
358
- document.addEventListener('touchmove', this.handleTouchSlide, false);
359
- document.addEventListener('touchend', this.endSlide, false);
360
- if (this.props.onSliderDragStart) this.props.onSliderDragStart();
305
+ _this.setStartSlide(ev, touch.clientX, touch.clientY);
306
+ document.addEventListener('touchmove', _this.handleTouchSlide, false);
307
+ document.addEventListener('touchend', _this.endSlide, false);
308
+ if (_this.props.onSliderDragStart) _this.props.onSliderDragStart();
361
309
  killEvent(ev);
362
- }
363
- }, {
364
- key: "handleMouseSlide",
365
- value: function handleMouseSlide(ev) {
366
- if (this.state.slidingIndex === null) return;
367
- this.handleSlide(ev.clientX, ev.clientY);
310
+ });
311
+ _defineProperty(_assertThisInitialized(_this), "handleMouseSlide", function (ev) {
312
+ if (_this.state.slidingIndex === null) return;
313
+ _this.handleSlide(ev.clientX, ev.clientY);
368
314
  killEvent(ev);
369
- }
370
- }, {
371
- key: "handleTouchSlide",
372
- value: function handleTouchSlide(ev) {
373
- if (this.state.slidingIndex === null) return;
315
+ });
316
+ _defineProperty(_assertThisInitialized(_this), "handleTouchSlide", function (ev) {
317
+ if (_this.state.slidingIndex === null) return;
374
318
  if (ev.changedTouches.length > 1) {
375
- this.endSlide();
319
+ _this.endSlide();
376
320
  return;
377
321
  }
378
322
  var touch = ev.changedTouches[0];
379
- this.handleSlide(touch.clientX, touch.clientY);
323
+ _this.handleSlide(touch.clientX, touch.clientY);
380
324
  killEvent(ev);
381
- }
382
- }, {
383
- key: "handleSlide",
384
- value: function handleSlide(x, y) {
385
- var _this$state3 = this.state,
325
+ });
326
+ _defineProperty(_assertThisInitialized(_this), "handleSlide", function (x, y) {
327
+ var _this$state3 = _this.state,
386
328
  idx = _this$state3.slidingIndex,
387
329
  sliderBox = _this$state3.sliderBox;
388
- var positionPercent = this.props.orientation === 'vertical' ? (y - sliderBox.top) / sliderBox.height * PERCENT_FULL : (x - sliderBox.left) / sliderBox.width * PERCENT_FULL;
389
- this.slideTo(idx, positionPercent);
390
- if (this.canMove(idx, positionPercent)) {
330
+ var positionPercent = _this.props.orientation === 'vertical' ? (y - sliderBox.top) / sliderBox.height * PERCENT_FULL : (x - sliderBox.left) / sliderBox.width * PERCENT_FULL;
331
+ _this.slideTo(idx, positionPercent);
332
+ if (_this.canMove(idx, positionPercent)) {
391
333
  // update mouse positions
392
- this.setState({
334
+ _this.setState({
393
335
  mousePos: {
394
336
  x: x,
395
337
  y: y
396
338
  }
397
339
  });
398
- if (this.props.onSliderDragMove) this.props.onSliderDragMove();
340
+ if (_this.props.onSliderDragMove) _this.props.onSliderDragMove();
399
341
  }
400
- }
401
- }, {
402
- key: "endSlide",
403
- value: function endSlide() {
404
- var _this2 = this;
405
- var idx = this.state.slidingIndex;
406
- this.setState({
342
+ });
343
+ _defineProperty(_assertThisInitialized(_this), "endSlide", function () {
344
+ var idx = _this.state.slidingIndex;
345
+ _this.setState({
407
346
  slidingIndex: null
408
347
  });
409
- document.removeEventListener('mouseup', this.endSlide, false);
410
- document.removeEventListener('touchend', this.endSlide, false);
411
- document.removeEventListener('touchmove', this.handleTouchSlide, false);
412
- document.removeEventListener('mousemove', this.handleMouseSlide, false);
413
- if (this.props.onSliderDragEnd) this.props.onSliderDragEnd();
414
- if (this.props.snap) {
415
- var positionPercent = this.getSnapPosition(this.state.handlePos[idx]);
416
- this.slideTo(idx, positionPercent, function () {
417
- return _this2.fireChangeEvent();
348
+ document.removeEventListener('mouseup', _this.endSlide, false);
349
+ document.removeEventListener('touchend', _this.endSlide, false);
350
+ document.removeEventListener('touchmove', _this.handleTouchSlide, false);
351
+ document.removeEventListener('mousemove', _this.handleMouseSlide, false);
352
+ if (_this.props.onSliderDragEnd) _this.props.onSliderDragEnd();
353
+ if (_this.props.snap) {
354
+ var positionPercent = _this.getSnapPosition(_this.state.handlePos[idx]);
355
+ _this.slideTo(idx, positionPercent, function () {
356
+ return _this.fireChangeEvent();
418
357
  });
419
358
  } else {
420
- this.fireChangeEvent();
359
+ _this.fireChangeEvent();
421
360
  }
422
- }
423
- }, {
424
- key: "handleClick",
425
- value: function handleClick(ev) {
426
- var _this3 = this;
361
+ });
362
+ _defineProperty(_assertThisInitialized(_this), "handleClick", function (ev) {
427
363
  if (ev.target.getAttribute('data-handle-key')) {
428
364
  return;
429
365
  }
430
366
 
431
367
  // Calculate the position of the slider on the page so we can determine
432
368
  // the position where you click in relativity.
433
- var sliderBox = this.getSliderBoundingBox();
434
- var positionDecimal = this.props.orientation === 'vertical' ? (ev.clientY - sliderBox.top) / sliderBox.height : (ev.clientX - sliderBox.left) / sliderBox.width;
369
+ var sliderBox = _this.getSliderBoundingBox();
370
+ var positionDecimal = _this.props.orientation === 'vertical' ? (ev.clientY - sliderBox.top) / sliderBox.height : (ev.clientX - sliderBox.left) / sliderBox.width;
435
371
  var positionPercent = positionDecimal * PERCENT_FULL;
436
- var handleId = this.getClosestHandle(positionPercent);
437
- var validPositionPercent = this.getSnapPosition(positionPercent);
372
+ var handleId = _this.getClosestHandle(positionPercent);
373
+ var validPositionPercent = _this.getSnapPosition(positionPercent);
438
374
 
439
375
  // Move the handle there
440
- this.slideTo(handleId, validPositionPercent, function () {
441
- return _this3.fireChangeEvent();
376
+ _this.slideTo(handleId, validPositionPercent, function () {
377
+ return _this.fireChangeEvent();
442
378
  });
443
- if (this.props.onClick) this.props.onClick();
444
- }
445
- }, {
446
- key: "handleKeydown",
447
- value: function handleKeydown(ev) {
448
- var _this4 = this;
379
+ if (_this.props.onClick) _this.props.onClick();
380
+ });
381
+ _defineProperty(_assertThisInitialized(_this), "handleKeydown", function (ev) {
449
382
  var idx = getHandleFor(ev);
450
383
  if (ev.keyCode === KEYS.ESC) {
451
384
  ev.currentTarget.blur();
452
385
  return;
453
386
  }
454
- var proposedPercentage = this.getNextPositionForKey(idx, ev.keyCode);
387
+ var proposedPercentage = _this.getNextPositionForKey(idx, ev.keyCode);
455
388
  if (proposedPercentage === null) return;
456
- if (this.canMove(idx, proposedPercentage)) {
457
- this.slideTo(idx, proposedPercentage, function () {
458
- return _this4.fireChangeEvent();
389
+ if (_this.canMove(idx, proposedPercentage)) {
390
+ _this.slideTo(idx, proposedPercentage, function () {
391
+ return _this.fireChangeEvent();
459
392
  });
460
- if (this.props.onKeyPress) this.props.onKeyPress();
393
+ if (_this.props.onKeyPress) _this.props.onKeyPress();
461
394
  }
462
395
  killEvent(ev);
463
- }
464
-
465
- // Make sure the proposed position respects the bounds and
466
- // does not collide with other handles too much.
467
- }, {
468
- key: "validatePosition",
469
- value: function validatePosition(idx, proposedPosition) {
470
- var _this$state4 = this.state,
396
+ });
397
+ _defineProperty(_assertThisInitialized(_this), "validatePosition", function (idx, proposedPosition) {
398
+ var _this$state4 = _this.state,
471
399
  handlePos = _this$state4.handlePos,
472
400
  handleDimensions = _this$state4.handleDimensions;
473
401
  return Math.max(Math.min(proposedPosition, handlePos[idx + 1] !== undefined ? handlePos[idx + 1] - handleDimensions : PERCENT_FULL // 100% is the highest value
474
402
  ), handlePos[idx - 1] !== undefined ? handlePos[idx - 1] + handleDimensions : PERCENT_EMPTY // 0% is the lowest value
475
403
  );
476
- }
477
- }, {
478
- key: "validateValues",
479
- value: function validateValues(proposedValues, props) {
480
- var _ref4 = props || this.props,
404
+ });
405
+ _defineProperty(_assertThisInitialized(_this), "validateValues", function (proposedValues, props) {
406
+ var _ref4 = props || _this.props,
481
407
  max = _ref4.max,
482
408
  min = _ref4.min;
483
409
  return proposedValues.map(function (value, idx, values) {
@@ -487,11 +413,9 @@ var Rheostat = /*#__PURE__*/function (_Component) {
487
413
  }
488
414
  return realValue;
489
415
  });
490
- }
491
- }, {
492
- key: "canMove",
493
- value: function canMove(idx, proposedPosition) {
494
- var _this$state5 = this.state,
416
+ });
417
+ _defineProperty(_assertThisInitialized(_this), "canMove", function (idx, proposedPosition) {
418
+ var _this$state5 = _this.state,
495
419
  handlePos = _this$state5.handlePos,
496
420
  handleDimensions = _this$state5.handleDimensions;
497
421
  if (proposedPosition < PERCENT_EMPTY) return false;
@@ -501,29 +425,21 @@ var Rheostat = /*#__PURE__*/function (_Component) {
501
425
  var prevHandlePosition = handlePos[idx - 1] !== undefined ? handlePos[idx - 1] + handleDimensions : -Infinity;
502
426
  if (proposedPosition < prevHandlePosition) return false;
503
427
  return true;
504
- }
505
- }, {
506
- key: "fireChangeEvent",
507
- value: function fireChangeEvent() {
508
- var onChange = this.props.onChange;
509
- if (onChange) onChange(this.getPublicState());
510
- }
511
- }, {
512
- key: "slideTo",
513
- value: function slideTo(idx, proposedPosition, onAfterSet) {
514
- var _this5 = this;
515
- var nextState = this.getNextState(idx, proposedPosition);
516
- this.setState(nextState, function () {
517
- var onValuesUpdated = _this5.props.onValuesUpdated;
518
- if (onValuesUpdated) onValuesUpdated(_this5.getPublicState());
428
+ });
429
+ _defineProperty(_assertThisInitialized(_this), "fireChangeEvent", function () {
430
+ var onChange = _this.props.onChange;
431
+ if (onChange) onChange(_this.getPublicState());
432
+ });
433
+ _defineProperty(_assertThisInitialized(_this), "slideTo", function (idx, proposedPosition, onAfterSet) {
434
+ var nextState = _this.getNextState(idx, proposedPosition);
435
+ _this.setState(nextState, function () {
436
+ var onValuesUpdated = _this.props.onValuesUpdated;
437
+ if (onValuesUpdated) onValuesUpdated(_this.getPublicState());
519
438
  if (onAfterSet) onAfterSet();
520
439
  });
521
- }
522
- }, {
523
- key: "updateNewValues",
524
- value: function updateNewValues(nextProps) {
525
- var _this6 = this;
526
- var slidingIndex = this.state.slidingIndex;
440
+ });
441
+ _defineProperty(_assertThisInitialized(_this), "updateNewValues", function (nextProps) {
442
+ var slidingIndex = _this.state.slidingIndex;
527
443
 
528
444
  // Don't update while the slider is sliding
529
445
  if (slidingIndex !== null) {
@@ -532,21 +448,18 @@ var Rheostat = /*#__PURE__*/function (_Component) {
532
448
  var max = nextProps.max,
533
449
  min = nextProps.min,
534
450
  values = nextProps.values;
535
- var nextValues = this.validateValues(values, nextProps);
536
- this.setState({
451
+ var nextValues = _this.validateValues(values, nextProps);
452
+ _this.setState({
537
453
  handlePos: nextValues.map(function (value) {
538
454
  return getPosition(value, min, max);
539
455
  }),
540
456
  values: nextValues
541
457
  }, function () {
542
- return _this6.fireChangeEvent();
458
+ return _this.fireChangeEvent();
543
459
  });
544
- }
545
- }, {
546
- key: "render",
547
- value: function render() {
548
- var _this7 = this;
549
- var _ref5 = this.props,
460
+ });
461
+ _defineProperty(_assertThisInitialized(_this), "render", function () {
462
+ var _ref5 = _this.props,
550
463
  children = _ref5.children,
551
464
  disabled = _ref5.disabled,
552
465
  Handle = _ref5.handle,
@@ -556,14 +469,14 @@ var Rheostat = /*#__PURE__*/function (_Component) {
556
469
  PitComponent = _ref5.pitComponent,
557
470
  pitPoints = _ref5.pitPoints,
558
471
  ProgressBar = _ref5.progressBar; // all required thanks to defaultProps
559
- var _this$state6 = this.state,
472
+ var _this$state6 = _this.state,
560
473
  className = _this$state6.className,
561
474
  handlePos = _this$state6.handlePos,
562
475
  values = _this$state6.values;
563
476
  return (0, _preact.h)("div", {
564
477
  className: className,
565
- ref: this.rheostat,
566
- onClick: disabled ? undefined : this.handleClick,
478
+ ref: _this.rheostat,
479
+ onClick: disabled ? undefined : _this.handleClick,
567
480
  style: {
568
481
  position: 'relative'
569
482
  }
@@ -576,17 +489,17 @@ var Rheostat = /*#__PURE__*/function (_Component) {
576
489
  position: 'absolute'
577
490
  };
578
491
  return (0, _preact.h)(Handle, {
579
- "aria-valuemax": _this7.getMaxValue(idx),
580
- "aria-valuemin": _this7.getMinValue(idx),
492
+ "aria-valuemax": _this.getMaxValue(idx),
493
+ "aria-valuemin": _this.getMinValue(idx),
581
494
  "aria-valuenow": values[idx],
582
495
  "aria-disabled": disabled,
583
496
  "data-handle-key": idx,
584
497
  className: "rheostat-handle",
585
498
  key: "handle-".concat(idx),
586
499
  onClick: killEvent,
587
- onKeyDown: disabled ? undefined : _this7.handleKeydown,
588
- onMouseDown: disabled ? undefined : _this7.startMouseSlide,
589
- onTouchStart: disabled ? undefined : _this7.startTouchSlide,
500
+ onKeyDown: disabled ? undefined : _this.handleKeydown,
501
+ onMouseDown: disabled ? undefined : _this.startMouseSlide,
502
+ onTouchStart: disabled ? undefined : _this.startTouchSlide,
590
503
  role: "slider",
591
504
  style: handleStyle,
592
505
  tabIndex: 0
@@ -598,7 +511,7 @@ var Rheostat = /*#__PURE__*/function (_Component) {
598
511
  return (0, _preact.h)(ProgressBar, {
599
512
  className: "rheostat-progress",
600
513
  key: "progress-bar-".concat(idx),
601
- style: _this7.getProgressStyle(idx)
514
+ style: _this.getProgressStyle(idx)
602
515
  });
603
516
  }), PitComponent && pitPoints.map(function (n) {
604
517
  var pos = getPosition(n, min, max);
@@ -614,9 +527,10 @@ var Rheostat = /*#__PURE__*/function (_Component) {
614
527
  style: pitStyle
615
528
  }, n);
616
529
  }), children);
617
- }
618
- }]);
619
- return Rheostat;
530
+ });
531
+ return _this;
532
+ }
533
+ return _createClass(Rheostat);
620
534
  }(_preact.Component);
621
535
  _defineProperty(Rheostat, "defaultProps", {
622
536
  className: '',