instantsearch.js 4.55.0 → 4.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/Breadcrumb/Breadcrumb.js +2 -2
- package/cjs/components/RangeInput/RangeInput.js +22 -11
- package/cjs/components/RefinementList/RefinementList.js +34 -52
- package/cjs/components/Slider/Rheostat.js +163 -249
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +22 -7
- package/cjs/lib/InstantSearch.js +2 -4
- package/cjs/lib/routers/history.js +54 -1
- package/cjs/lib/utils/render-args.js +3 -2
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/hits-per-page/hits-per-page.js +3 -1
- package/cjs/widgets/index/index.js +8 -8
- package/dist/instantsearch.development.d.ts +76 -76
- package/dist/instantsearch.development.js +345 -341
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +76 -76
- package/dist/instantsearch.production.min.d.ts +76 -76
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -2
- package/es/components/Breadcrumb/Breadcrumb.js +2 -2
- package/es/components/GeoSearchControls/GeoSearchButton.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchControls.d.ts +3 -3
- package/es/components/GeoSearchControls/GeoSearchToggle.d.ts +1 -1
- package/es/components/Pagination/Pagination.d.ts +2 -2
- package/es/components/RangeInput/RangeInput.d.ts +7 -4
- package/es/components/RangeInput/RangeInput.js +22 -11
- package/es/components/RefinementList/RefinementList.d.ts +0 -1
- package/es/components/RefinementList/RefinementList.js +34 -52
- package/es/components/RelevantSort/RelevantSort.d.ts +1 -1
- package/es/components/Selector/Selector.d.ts +2 -2
- package/es/components/Slider/Rheostat.d.ts +23 -17
- package/es/components/Slider/Rheostat.js +163 -249
- package/es/components/Slider/Slider.d.ts +1 -1
- package/es/connectors/current-refinements/connectCurrentRefinements.d.ts +2 -2
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +2 -2
- package/es/connectors/geo-search/connectGeoSearch.d.ts +7 -7
- package/es/connectors/infinite-hits/connectInfiniteHits.js +23 -8
- package/es/connectors/menu/connectMenu.d.ts +2 -2
- package/es/connectors/pagination/connectPagination.d.ts +1 -1
- package/es/connectors/range/connectRange.d.ts +3 -3
- package/es/connectors/refinement-list/connectRefinementList.d.ts +3 -3
- package/es/connectors/relevant-sort/connectRelevantSort.d.ts +1 -1
- package/es/lib/InstantSearch.d.ts +13 -13
- package/es/lib/InstantSearch.js +3 -5
- package/es/lib/routers/history.d.ts +2 -2
- package/es/lib/routers/history.js +55 -2
- package/es/lib/utils/defer.d.ts +2 -2
- package/es/lib/utils/render-args.js +3 -2
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/types/middleware.d.ts +6 -6
- package/es/types/router.d.ts +7 -7
- package/es/types/widget.d.ts +1 -1
- package/es/widgets/dynamic-widgets/dynamic-widgets.d.ts +2 -2
- package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -1
- package/es/widgets/geo-search/geo-search.d.ts +1 -1
- package/es/widgets/hits-per-page/hits-per-page.js +3 -1
- package/es/widgets/index/index.d.ts +20 -20
- package/es/widgets/index/index.js +8 -8
- package/es/widgets/panel/panel.d.ts +2 -2
- package/es/widgets/range-slider/range-slider.d.ts +1 -1
- package/package.json +6 -6
|
@@ -10,8 +10,8 @@ export type BreadcrumbProps = {
|
|
|
10
10
|
items: BreadcrumbConnectorParamsItem[];
|
|
11
11
|
cssClasses: BreadcrumbComponentCSSClasses;
|
|
12
12
|
templateProps: PreparedTemplateProps<BreadcrumbComponentTemplates>;
|
|
13
|
-
createURL(value
|
|
14
|
-
refine(value
|
|
13
|
+
createURL: (value: BreadcrumbConnectorParamsItem['value']) => string;
|
|
14
|
+
refine: (value: BreadcrumbConnectorParamsItem['value']) => void;
|
|
15
15
|
canRefine?: boolean;
|
|
16
16
|
};
|
|
17
17
|
declare const Breadcrumb: ({ items, cssClasses, templateProps, createURL, refine, }: BreadcrumbProps) => h.JSX.Element;
|
|
@@ -19,10 +19,10 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
19
19
|
rootTagName: "a",
|
|
20
20
|
rootProps: {
|
|
21
21
|
className: cssClasses.link,
|
|
22
|
-
href: createURL(
|
|
22
|
+
href: createURL(null),
|
|
23
23
|
onClick: function onClick(event) {
|
|
24
24
|
event.preventDefault();
|
|
25
|
-
refine(
|
|
25
|
+
refine(null);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}))), items.map(function (item, idx) {
|
|
@@ -11,9 +11,9 @@ type Props = {
|
|
|
11
11
|
isRefineOnMapMove: boolean;
|
|
12
12
|
isRefinedWithMap: boolean;
|
|
13
13
|
hasMapMoveSinceLastRefine: boolean;
|
|
14
|
-
onRefineToggle(event: Event)
|
|
15
|
-
onRefineClick(event: MouseEvent)
|
|
16
|
-
onClearClick(event: MouseEvent)
|
|
14
|
+
onRefineToggle: (event: Event) => void;
|
|
15
|
+
onRefineClick: (event: MouseEvent) => void;
|
|
16
|
+
onClearClick: (event: MouseEvent) => void;
|
|
17
17
|
templateProps: PreparedTemplateProps<GeoSearchTemplates>;
|
|
18
18
|
};
|
|
19
19
|
declare const GeoSearchControls: ({ cssClasses, enableRefine, enableRefineControl, enableClearMapRefinement, isRefineOnMapMove, isRefinedWithMap, hasMapMoveSinceLastRefine, onRefineToggle, onRefineClick, onClearClick, templateProps, }: Props) => h.JSX.Element;
|
|
@@ -5,7 +5,7 @@ type Props = {
|
|
|
5
5
|
classNameLabel: string;
|
|
6
6
|
classNameInput: string;
|
|
7
7
|
checked: boolean;
|
|
8
|
-
onToggle(event: Event)
|
|
8
|
+
onToggle: (event: Event) => void;
|
|
9
9
|
children: ComponentChildren;
|
|
10
10
|
};
|
|
11
11
|
declare const GeoSearchToggle: ({ classNameLabel, classNameInput, checked, onToggle, children, }: Props) => h.JSX.Element;
|
|
@@ -5,7 +5,7 @@ import type { PaginationCSSClasses, PaginationTemplates } from '../../widgets/pa
|
|
|
5
5
|
export type PaginationComponentCSSClasses = ComponentCSSClasses<PaginationCSSClasses>;
|
|
6
6
|
export type PaginationComponentTemplates = Required<PaginationTemplates>;
|
|
7
7
|
export type PaginationProps = {
|
|
8
|
-
createURL(value: number)
|
|
8
|
+
createURL: (value: number) => string;
|
|
9
9
|
cssClasses: PaginationComponentCSSClasses;
|
|
10
10
|
templates: PaginationComponentTemplates;
|
|
11
11
|
currentPage: number;
|
|
@@ -13,7 +13,7 @@ export type PaginationProps = {
|
|
|
13
13
|
pages: number[];
|
|
14
14
|
isFirstPage: boolean;
|
|
15
15
|
isLastPage: boolean;
|
|
16
|
-
setCurrentPage(value: number)
|
|
16
|
+
setCurrentPage: (value: number) => void;
|
|
17
17
|
showFirst?: boolean;
|
|
18
18
|
showLast?: boolean;
|
|
19
19
|
showPrevious?: boolean;
|
|
@@ -14,12 +14,15 @@ export type RangeInputProps = {
|
|
|
14
14
|
templateProps: {
|
|
15
15
|
templates: RangeInputComponentTemplates;
|
|
16
16
|
};
|
|
17
|
-
refine(rangeValue: RangeBoundaries)
|
|
17
|
+
refine: (rangeValue: RangeBoundaries) => void;
|
|
18
18
|
};
|
|
19
|
-
declare class RangeInput extends Component<RangeInputProps,
|
|
19
|
+
declare class RangeInput extends Component<RangeInputProps, {
|
|
20
|
+
min?: string;
|
|
21
|
+
max?: string;
|
|
22
|
+
}> {
|
|
20
23
|
state: {
|
|
21
|
-
min:
|
|
22
|
-
max:
|
|
24
|
+
min: string | undefined;
|
|
25
|
+
max: string | undefined;
|
|
23
26
|
};
|
|
24
27
|
componentWillReceiveProps(nextProps: RangeInputProps): void;
|
|
25
28
|
private onInput;
|
|
@@ -16,10 +16,17 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
16
16
|
import { cx } from '@algolia/ui-components-shared';
|
|
17
17
|
import { h, Component } from 'preact';
|
|
18
18
|
import Template from "../Template/Template.js";
|
|
19
|
+
// Strips leading `0` from a positive number value
|
|
20
|
+
function stripLeadingZeroFromInput(value) {
|
|
21
|
+
return value.replace(/^(0+)\d/, function (part) {
|
|
22
|
+
return Number(part).toString();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
19
25
|
var RangeInput = /*#__PURE__*/function (_Component) {
|
|
20
26
|
_inherits(RangeInput, _Component);
|
|
21
27
|
var _super = _createSuper(RangeInput);
|
|
22
28
|
function RangeInput() {
|
|
29
|
+
var _this$props$values$mi, _this$props$values$ma;
|
|
23
30
|
var _this;
|
|
24
31
|
_classCallCheck(this, RangeInput);
|
|
25
32
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -27,36 +34,40 @@ var RangeInput = /*#__PURE__*/function (_Component) {
|
|
|
27
34
|
}
|
|
28
35
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
29
36
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
30
|
-
min: _this.props.values.min,
|
|
31
|
-
max: _this.props.values.max
|
|
37
|
+
min: (_this$props$values$mi = _this.props.values.min) === null || _this$props$values$mi === void 0 ? void 0 : _this$props$values$mi.toString(),
|
|
38
|
+
max: (_this$props$values$ma = _this.props.values.max) === null || _this$props$values$ma === void 0 ? void 0 : _this$props$values$ma.toString()
|
|
32
39
|
});
|
|
33
40
|
_defineProperty(_assertThisInitialized(_this), "onInput", function (key) {
|
|
34
41
|
return function (event) {
|
|
35
42
|
var _ref = event.currentTarget,
|
|
36
43
|
value = _ref.value;
|
|
37
|
-
_this.setState(_defineProperty({}, key,
|
|
44
|
+
_this.setState(_defineProperty({}, key, value));
|
|
38
45
|
};
|
|
39
46
|
});
|
|
40
47
|
_defineProperty(_assertThisInitialized(_this), "onSubmit", function (event) {
|
|
41
48
|
event.preventDefault();
|
|
42
|
-
_this
|
|
49
|
+
var _this$state = _this.state,
|
|
50
|
+
min = _this$state.min,
|
|
51
|
+
max = _this$state.max;
|
|
52
|
+
_this.props.refine([min ? Number(min) : undefined, max ? Number(max) : undefined]);
|
|
43
53
|
});
|
|
44
54
|
return _this;
|
|
45
55
|
}
|
|
46
56
|
_createClass(RangeInput, [{
|
|
47
57
|
key: "componentWillReceiveProps",
|
|
48
58
|
value: function componentWillReceiveProps(nextProps) {
|
|
59
|
+
var _nextProps$values$min, _nextProps$values$max;
|
|
49
60
|
this.setState({
|
|
50
|
-
min: nextProps.values.min,
|
|
51
|
-
max: nextProps.values.max
|
|
61
|
+
min: (_nextProps$values$min = nextProps.values.min) === null || _nextProps$values$min === void 0 ? void 0 : _nextProps$values$min.toString(),
|
|
62
|
+
max: (_nextProps$values$max = nextProps.values.max) === null || _nextProps$values$max === void 0 ? void 0 : _nextProps$values$max.toString()
|
|
52
63
|
});
|
|
53
64
|
}
|
|
54
65
|
}, {
|
|
55
66
|
key: "render",
|
|
56
67
|
value: function render() {
|
|
57
|
-
var _this$
|
|
58
|
-
minValue = _this$
|
|
59
|
-
maxValue = _this$
|
|
68
|
+
var _this$state2 = this.state,
|
|
69
|
+
minValue = _this$state2.min,
|
|
70
|
+
maxValue = _this$state2.max;
|
|
60
71
|
var _this$props = this.props,
|
|
61
72
|
min = _this$props.min,
|
|
62
73
|
max = _this$props.max,
|
|
@@ -79,7 +90,7 @@ var RangeInput = /*#__PURE__*/function (_Component) {
|
|
|
79
90
|
min: min,
|
|
80
91
|
max: max,
|
|
81
92
|
step: step,
|
|
82
|
-
value: minValue !== null && minValue !== void 0 ? minValue : '',
|
|
93
|
+
value: stripLeadingZeroFromInput(minValue !== null && minValue !== void 0 ? minValue : ''),
|
|
83
94
|
onInput: this.onInput('min'),
|
|
84
95
|
placeholder: min === null || min === void 0 ? void 0 : min.toString(),
|
|
85
96
|
disabled: isDisabled
|
|
@@ -97,7 +108,7 @@ var RangeInput = /*#__PURE__*/function (_Component) {
|
|
|
97
108
|
min: min,
|
|
98
109
|
max: max,
|
|
99
110
|
step: step,
|
|
100
|
-
value: maxValue !== null && maxValue !== void 0 ? maxValue : '',
|
|
111
|
+
value: stripLeadingZeroFromInput(maxValue !== null && maxValue !== void 0 ? maxValue : ''),
|
|
101
112
|
onInput: this.onInput('max'),
|
|
102
113
|
placeholder: max === null || max === void 0 ? void 0 : max.toString(),
|
|
103
114
|
disabled: isDisabled
|
|
@@ -54,7 +54,6 @@ declare class RefinementList<TTemplates extends Templates> extends Component<Ref
|
|
|
54
54
|
depth: number;
|
|
55
55
|
};
|
|
56
56
|
private searchBox;
|
|
57
|
-
constructor(props: RefinementListPropsWithDefaultProps<TTemplates>);
|
|
58
57
|
shouldComponentUpdate(nextProps: RefinementListPropsWithDefaultProps<TTemplates>): boolean;
|
|
59
58
|
private refine;
|
|
60
59
|
private _generateFacetItem;
|
|
@@ -34,49 +34,36 @@ function isHierarchicalMenuItem(facetValue) {
|
|
|
34
34
|
var RefinementList = /*#__PURE__*/function (_Component) {
|
|
35
35
|
_inherits(RefinementList, _Component);
|
|
36
36
|
var _super = _createSuper(RefinementList);
|
|
37
|
-
function RefinementList(
|
|
37
|
+
function RefinementList() {
|
|
38
38
|
var _this;
|
|
39
39
|
_classCallCheck(this, RefinementList);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
_this.handleItemClick = _this.handleItemClick.bind(_assertThisInitialized(_this));
|
|
43
|
-
return _this;
|
|
44
|
-
}
|
|
45
|
-
_createClass(RefinementList, [{
|
|
46
|
-
key: "shouldComponentUpdate",
|
|
47
|
-
value: function shouldComponentUpdate(nextProps) {
|
|
48
|
-
var areFacetValuesDifferent = !isEqual(this.props.facetValues, nextProps.facetValues);
|
|
49
|
-
return areFacetValuesDifferent;
|
|
40
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
41
|
+
args[_key] = arguments[_key];
|
|
50
42
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.props.toggleRefinement(facetValueToRefine);
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "_generateFacetItem",
|
|
58
|
-
value: function _generateFacetItem(facetValue) {
|
|
43
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "searchBox", createRef());
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "_generateFacetItem", function (facetValue) {
|
|
59
46
|
var subItems;
|
|
60
47
|
if (isHierarchicalMenuItem(facetValue) && Array.isArray(facetValue.data) && facetValue.data.length > 0) {
|
|
61
|
-
var _this$props$cssClasse =
|
|
48
|
+
var _this$props$cssClasse = _this.props.cssClasses,
|
|
62
49
|
root = _this$props$cssClasse.root,
|
|
63
50
|
cssClasses = _objectWithoutProperties(_this$props$cssClasse, _excluded);
|
|
64
|
-
subItems = h(RefinementList, _extends({},
|
|
51
|
+
subItems = h(RefinementList, _extends({}, _this.props, {
|
|
65
52
|
// We want to keep `root` required for external usage but not for the
|
|
66
53
|
// sub items.
|
|
67
54
|
cssClasses: cssClasses,
|
|
68
|
-
depth:
|
|
55
|
+
depth: _this.props.depth + 1,
|
|
69
56
|
facetValues: facetValue.data,
|
|
70
57
|
showMore: false,
|
|
71
|
-
className:
|
|
58
|
+
className: _this.props.cssClasses.childList
|
|
72
59
|
}));
|
|
73
60
|
}
|
|
74
|
-
var url =
|
|
61
|
+
var url = _this.props.createURL(facetValue.value);
|
|
75
62
|
var templateData = _objectSpread(_objectSpread({}, facetValue), {}, {
|
|
76
63
|
url: url,
|
|
77
|
-
attribute:
|
|
78
|
-
cssClasses:
|
|
79
|
-
isFromSearch:
|
|
64
|
+
attribute: _this.props.attribute,
|
|
65
|
+
cssClasses: _this.props.cssClasses,
|
|
66
|
+
isFromSearch: _this.props.isFromSearch
|
|
80
67
|
});
|
|
81
68
|
var key = facetValue.value;
|
|
82
69
|
if (facetValue.isRefined !== undefined) {
|
|
@@ -85,38 +72,20 @@ var RefinementList = /*#__PURE__*/function (_Component) {
|
|
|
85
72
|
if (facetValue.count !== undefined) {
|
|
86
73
|
key += "/".concat(facetValue.count);
|
|
87
74
|
}
|
|
88
|
-
var refinementListItemClassName = cx(
|
|
75
|
+
var refinementListItemClassName = cx(_this.props.cssClasses.item, facetValue.isRefined && _this.props.cssClasses.selectedItem, !facetValue.count && _this.props.cssClasses.disabledItem, Boolean(isHierarchicalMenuItem(facetValue) && Array.isArray(facetValue.data) && facetValue.data.length > 0) && _this.props.cssClasses.parentItem);
|
|
89
76
|
return h(RefinementListItem, {
|
|
90
77
|
templateKey: "item",
|
|
91
78
|
key: key,
|
|
92
79
|
facetValueToRefine: facetValue.value,
|
|
93
|
-
handleClick:
|
|
80
|
+
handleClick: _this.handleItemClick,
|
|
94
81
|
isRefined: facetValue.isRefined,
|
|
95
82
|
className: refinementListItemClassName,
|
|
96
83
|
subItems: subItems,
|
|
97
84
|
templateData: templateData,
|
|
98
|
-
templateProps:
|
|
85
|
+
templateProps: _this.props.templateProps
|
|
99
86
|
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Click events on DOM tree like LABEL > INPUT will result in two click events
|
|
103
|
-
// instead of one.
|
|
104
|
-
// No matter the framework, see https://www.google.com/search?q=click+label+twice
|
|
105
|
-
//
|
|
106
|
-
// Thus making it hard to distinguish activation from deactivation because both click events
|
|
107
|
-
// are very close. Debounce is a solution but hacky.
|
|
108
|
-
//
|
|
109
|
-
// So the code here checks if the click was done on or in a LABEL. If this LABEL
|
|
110
|
-
// has a checkbox inside, we ignore the first click event because we will get another one.
|
|
111
|
-
//
|
|
112
|
-
// We also check if the click was done inside a link and then e.preventDefault() because we already
|
|
113
|
-
// handle the url
|
|
114
|
-
//
|
|
115
|
-
// Finally, we always stop propagation of the event to avoid multiple levels RefinementLists to fail: click
|
|
116
|
-
// on child would click on parent also
|
|
117
|
-
}, {
|
|
118
|
-
key: "handleItemClick",
|
|
119
|
-
value: function handleItemClick(_ref) {
|
|
87
|
+
});
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "handleItemClick", function (_ref) {
|
|
120
89
|
var facetValueToRefine = _ref.facetValueToRefine,
|
|
121
90
|
isRefined = _ref.isRefined,
|
|
122
91
|
originalEvent = _ref.originalEvent;
|
|
@@ -133,7 +102,7 @@ var RefinementList = /*#__PURE__*/function (_Component) {
|
|
|
133
102
|
return;
|
|
134
103
|
}
|
|
135
104
|
if (originalEvent.target.tagName === 'INPUT') {
|
|
136
|
-
|
|
105
|
+
_this.refine(facetValueToRefine);
|
|
137
106
|
return;
|
|
138
107
|
}
|
|
139
108
|
var parent = originalEvent.target;
|
|
@@ -147,7 +116,20 @@ var RefinementList = /*#__PURE__*/function (_Component) {
|
|
|
147
116
|
parent = parent.parentNode;
|
|
148
117
|
}
|
|
149
118
|
originalEvent.stopPropagation();
|
|
150
|
-
|
|
119
|
+
_this.refine(facetValueToRefine);
|
|
120
|
+
});
|
|
121
|
+
return _this;
|
|
122
|
+
}
|
|
123
|
+
_createClass(RefinementList, [{
|
|
124
|
+
key: "shouldComponentUpdate",
|
|
125
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
126
|
+
var areFacetValuesDifferent = !isEqual(this.props.facetValues, nextProps.facetValues);
|
|
127
|
+
return areFacetValuesDifferent;
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "refine",
|
|
131
|
+
value: function refine(facetValueToRefine) {
|
|
132
|
+
this.props.toggleRefinement(facetValueToRefine);
|
|
151
133
|
}
|
|
152
134
|
}, {
|
|
153
135
|
key: "componentWillReceiveProps",
|
|
@@ -9,7 +9,7 @@ type RelevantSortProps = {
|
|
|
9
9
|
templates: RelevantSortComponentTemplates;
|
|
10
10
|
isRelevantSorted: boolean;
|
|
11
11
|
isVirtualReplica: boolean;
|
|
12
|
-
refine(relevancyStrictness: number | undefined)
|
|
12
|
+
refine: (relevancyStrictness: number | undefined) => void;
|
|
13
13
|
};
|
|
14
14
|
declare const RelevantSort: ({ cssClasses, templates, isRelevantSorted, isVirtualReplica, refine, }: RelevantSortProps) => h.JSX.Element | null;
|
|
15
15
|
export default RelevantSort;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
export type SelectorOption = {
|
|
4
|
-
value
|
|
4
|
+
value: string | number | undefined;
|
|
5
5
|
label: string;
|
|
6
6
|
};
|
|
7
7
|
export type SelectorComponentCSSClasses = {
|
|
@@ -13,7 +13,7 @@ export type SelectorProps = {
|
|
|
13
13
|
cssClasses: SelectorComponentCSSClasses;
|
|
14
14
|
currentValue?: string | number;
|
|
15
15
|
options: SelectorOption[];
|
|
16
|
-
setValue(value:
|
|
16
|
+
setValue: (value: string) => void;
|
|
17
17
|
};
|
|
18
18
|
declare function Selector({ currentValue, options, cssClasses, setValue, }: SelectorProps): h.JSX.Element;
|
|
19
19
|
export default Selector;
|
|
@@ -40,6 +40,12 @@ export type HandleProps = {
|
|
|
40
40
|
style: JSX.HTMLAttributes['style'];
|
|
41
41
|
tabIndex: number;
|
|
42
42
|
};
|
|
43
|
+
type Bounds = [min: number, max: number];
|
|
44
|
+
type PublicState = {
|
|
45
|
+
max?: number;
|
|
46
|
+
min?: number;
|
|
47
|
+
values: Bounds;
|
|
48
|
+
};
|
|
43
49
|
type Props = {
|
|
44
50
|
children?: ComponentChildren;
|
|
45
51
|
className?: string;
|
|
@@ -47,24 +53,24 @@ type Props = {
|
|
|
47
53
|
handle?: ComponentType<HandleProps>;
|
|
48
54
|
max?: number;
|
|
49
55
|
min?: number;
|
|
50
|
-
onClick
|
|
51
|
-
onChange
|
|
52
|
-
onKeyPress
|
|
53
|
-
onSliderDragEnd
|
|
54
|
-
onSliderDragMove
|
|
55
|
-
onSliderDragStart
|
|
56
|
-
onValuesUpdated
|
|
56
|
+
onClick?: () => void;
|
|
57
|
+
onChange?: (state: PublicState) => void;
|
|
58
|
+
onKeyPress?: () => void;
|
|
59
|
+
onSliderDragEnd?: () => void;
|
|
60
|
+
onSliderDragMove?: () => void;
|
|
61
|
+
onSliderDragStart?: () => void;
|
|
62
|
+
onValuesUpdated?: (state: PublicState) => void;
|
|
57
63
|
orientation?: 'horizontal' | 'vertical';
|
|
58
64
|
pitComponent?: ComponentType<PitProps>;
|
|
59
65
|
pitPoints?: number[];
|
|
60
66
|
progressBar?: ComponentType<JSX.HTMLAttributes>;
|
|
61
67
|
snap?: boolean;
|
|
62
68
|
snapPoints?: number[];
|
|
63
|
-
values?:
|
|
69
|
+
values?: Bounds;
|
|
64
70
|
};
|
|
65
71
|
type State = {
|
|
66
72
|
className: string;
|
|
67
|
-
handlePos:
|
|
73
|
+
handlePos: Bounds;
|
|
68
74
|
handleDimensions: number;
|
|
69
75
|
mousePos: {
|
|
70
76
|
x: number;
|
|
@@ -72,7 +78,7 @@ type State = {
|
|
|
72
78
|
} | null;
|
|
73
79
|
sliderBox: Partial<BoundingBox>;
|
|
74
80
|
slidingIndex: number | null;
|
|
75
|
-
values:
|
|
81
|
+
values: Bounds;
|
|
76
82
|
};
|
|
77
83
|
declare class Rheostat extends Component<Props, State> {
|
|
78
84
|
static defaultProps: {
|
|
@@ -97,10 +103,10 @@ declare class Rheostat extends Component<Props, State> {
|
|
|
97
103
|
snapPoints: never[];
|
|
98
104
|
values: number[];
|
|
99
105
|
};
|
|
106
|
+
x: number[];
|
|
100
107
|
state: State;
|
|
101
108
|
private rheostat;
|
|
102
|
-
|
|
103
|
-
componentWillReceiveProps(nextProps: Required<Props>): void;
|
|
109
|
+
componentWillReceiveProps: (nextProps: Required<Props>) => void;
|
|
104
110
|
private getPublicState;
|
|
105
111
|
private getSliderBoundingBox;
|
|
106
112
|
private getProgressStyle;
|
|
@@ -123,10 +129,10 @@ declare class Rheostat extends Component<Props, State> {
|
|
|
123
129
|
private handleKeydown;
|
|
124
130
|
private validatePosition;
|
|
125
131
|
private validateValues;
|
|
126
|
-
canMove(idx: number, proposedPosition: number)
|
|
127
|
-
fireChangeEvent()
|
|
128
|
-
slideTo(idx: number, proposedPosition: number, onAfterSet?: () => void)
|
|
129
|
-
updateNewValues(nextProps: Required<Props>)
|
|
130
|
-
render()
|
|
132
|
+
canMove: (idx: number, proposedPosition: number) => boolean;
|
|
133
|
+
fireChangeEvent: () => void;
|
|
134
|
+
slideTo: (idx: number, proposedPosition: number, onAfterSet?: () => void) => void;
|
|
135
|
+
updateNewValues: (nextProps: Required<Props>) => void;
|
|
136
|
+
render: () => h.JSX.Element;
|
|
131
137
|
}
|
|
132
138
|
export default Rheostat;
|