instantsearch.js 4.40.2 → 4.40.5
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/CHANGELOG.md +27 -0
- package/cjs/connectors/breadcrumb/connectBreadcrumb.js +1 -1
- package/cjs/connectors/current-refinements/connectCurrentRefinements.js +13 -1
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -3
- package/cjs/connectors/menu/connectMenu.js +3 -2
- package/cjs/connectors/refinement-list/connectRefinementList.js +7 -5
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +6 -6
- package/cjs/lib/routers/history.js +46 -31
- package/cjs/lib/utils/escapeFacetValue.js +23 -0
- package/cjs/lib/utils/getRefinements.js +10 -14
- package/cjs/lib/utils/index.js +7 -9
- package/cjs/lib/version.js +1 -1
- package/dist/instantsearch.development.d.ts +3 -3
- package/dist/instantsearch.development.js +158 -79
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +3 -3
- package/dist/instantsearch.production.min.d.ts +3 -3
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/breadcrumb/connectBreadcrumb.js +1 -1
- package/es/connectors/current-refinements/connectCurrentRefinements.js +13 -1
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -3
- package/es/connectors/menu/connectMenu.js +3 -2
- package/es/connectors/refinement-list/connectRefinementList.js +7 -5
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +7 -7
- package/es/lib/routers/history.d.ts +3 -3
- package/es/lib/routers/history.js +46 -31
- package/es/lib/utils/escapeFacetValue.d.ts +4 -0
- package/es/lib/utils/escapeFacetValue.js +14 -0
- package/es/lib/utils/getRefinements.d.ts +22 -7
- package/es/lib/utils/getRefinements.js +10 -13
- package/es/lib/utils/index.d.ts +1 -2
- package/es/lib/utils/index.js +1 -2
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/types/results.d.ts +2 -7
- package/package.json +3 -3
- package/cjs/lib/utils/escapeRefinement.js +0 -17
- package/cjs/lib/utils/unescapeRefinement.js +0 -13
- package/es/lib/utils/escapeRefinement.d.ts +0 -3
- package/es/lib/utils/escapeRefinement.js +0 -9
- package/es/lib/utils/unescapeRefinement.d.ts +0 -2
- package/es/lib/utils/unescapeRefinement.js +0 -5
|
@@ -187,7 +187,7 @@ function getOperatorSymbol(operator) {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
function normalizeRefinement(refinement) {
|
|
190
|
-
var value =
|
|
190
|
+
var value = getValue(refinement);
|
|
191
191
|
var label = refinement.operator ? "".concat(getOperatorSymbol(refinement.operator), " ").concat(refinement.name) : refinement.name;
|
|
192
192
|
var normalizedRefinement = {
|
|
193
193
|
attribute: refinement.attribute,
|
|
@@ -211,4 +211,16 @@ function normalizeRefinement(refinement) {
|
|
|
211
211
|
return normalizedRefinement;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
function getValue(refinement) {
|
|
215
|
+
if (refinement.type === 'numeric') {
|
|
216
|
+
return Number(refinement.name);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if ('escapedValue' in refinement) {
|
|
220
|
+
return refinement.escapedValue;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return refinement.name;
|
|
224
|
+
}
|
|
225
|
+
|
|
214
226
|
export default connectCurrentRefinements;
|
|
@@ -106,13 +106,14 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
|
|
|
106
106
|
function _prepareFacetValues(facetValues) {
|
|
107
107
|
return facetValues.slice(0, getLimit()).map(function (_ref2) {
|
|
108
108
|
var label = _ref2.name,
|
|
109
|
-
value = _ref2.
|
|
109
|
+
value = _ref2.escapedValue,
|
|
110
110
|
data = _ref2.data,
|
|
111
|
-
|
|
111
|
+
path = _ref2.path,
|
|
112
|
+
subValue = _objectWithoutProperties(_ref2, ["name", "escapedValue", "data", "path"]);
|
|
112
113
|
|
|
113
114
|
var item = _objectSpread(_objectSpread({}, subValue), {}, {
|
|
114
|
-
label: label,
|
|
115
115
|
value: value,
|
|
116
|
+
label: label,
|
|
116
117
|
data: null
|
|
117
118
|
});
|
|
118
119
|
|
|
@@ -161,8 +161,9 @@ var connectMenu = function connectMenu(renderFn) {
|
|
|
161
161
|
canToggleShowMore = showMore && (isShowingMore || facetItems.length > getLimit());
|
|
162
162
|
items = transformItems(facetItems.slice(0, getLimit()).map(function (_ref3) {
|
|
163
163
|
var label = _ref3.name,
|
|
164
|
-
value = _ref3.
|
|
165
|
-
|
|
164
|
+
value = _ref3.escapedValue,
|
|
165
|
+
path = _ref3.path,
|
|
166
|
+
item = _objectWithoutProperties(_ref3, ["name", "escapedValue", "path"]);
|
|
166
167
|
|
|
167
168
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
168
169
|
label: label,
|
|
@@ -64,11 +64,12 @@ var connectRefinementList = function connectRefinementList(renderFn) {
|
|
|
64
64
|
|
|
65
65
|
var formatItems = function formatItems(_ref2) {
|
|
66
66
|
var label = _ref2.name,
|
|
67
|
-
|
|
67
|
+
value = _ref2.escapedValue,
|
|
68
|
+
item = _objectWithoutProperties(_ref2, ["name", "escapedValue"]);
|
|
68
69
|
|
|
69
70
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
71
|
+
value: value,
|
|
70
72
|
label: label,
|
|
71
|
-
value: label,
|
|
72
73
|
highlighted: label
|
|
73
74
|
});
|
|
74
75
|
};
|
|
@@ -126,11 +127,12 @@ var connectRefinementList = function connectRefinementList(renderFn) {
|
|
|
126
127
|
Math.min(getLimit(), 100), tags).then(function (results) {
|
|
127
128
|
var facetValues = escapeFacetValues ? escapeFacets(results.facetHits) : results.facetHits;
|
|
128
129
|
var normalizedFacetValues = transformItems(facetValues.map(function (_ref3) {
|
|
129
|
-
var
|
|
130
|
-
|
|
130
|
+
var escapedValue = _ref3.escapedValue,
|
|
131
|
+
value = _ref3.value,
|
|
132
|
+
item = _objectWithoutProperties(_ref3, ["escapedValue", "value"]);
|
|
131
133
|
|
|
132
134
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
133
|
-
value:
|
|
135
|
+
value: escapedValue,
|
|
134
136
|
label: value
|
|
135
137
|
});
|
|
136
138
|
}), {
|
|
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
-
import { checkRendering,
|
|
7
|
+
import { checkRendering, escapeFacetValue, createDocumentationMessageGenerator, find, noop, toArray } from "../../lib/utils/index.js";
|
|
8
8
|
var withUsage = createDocumentationMessageGenerator({
|
|
9
9
|
name: 'toggle-refinement',
|
|
10
10
|
connector: true
|
|
@@ -81,8 +81,8 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
var hasAnOffValue = userOff !== undefined;
|
|
84
|
-
var on = toArray(userOn).map(
|
|
85
|
-
var off = hasAnOffValue ? toArray(userOff).map(
|
|
84
|
+
var on = toArray(userOn).map(escapeFacetValue);
|
|
85
|
+
var off = hasAnOffValue ? toArray(userOff).map(escapeFacetValue) : undefined;
|
|
86
86
|
var sendEvent;
|
|
87
87
|
|
|
88
88
|
var toggleRefinementFactory = function toggleRefinementFactory(helper) {
|
|
@@ -195,16 +195,16 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
195
195
|
var allFacetValues = results.getFacetValues(attribute, {}) || [];
|
|
196
196
|
var onData = on.map(function (v) {
|
|
197
197
|
return find(allFacetValues, function (_ref7) {
|
|
198
|
-
var
|
|
199
|
-
return
|
|
198
|
+
var escapedValue = _ref7.escapedValue;
|
|
199
|
+
return escapedValue === escapeFacetValue(String(v));
|
|
200
200
|
});
|
|
201
201
|
}).filter(function (v) {
|
|
202
202
|
return v !== undefined;
|
|
203
203
|
});
|
|
204
204
|
var offData = hasAnOffValue ? offValue.map(function (v) {
|
|
205
205
|
return find(allFacetValues, function (_ref8) {
|
|
206
|
-
var
|
|
207
|
-
return
|
|
206
|
+
var escapedValue = _ref8.escapedValue;
|
|
207
|
+
return escapedValue === escapeFacetValue(String(v));
|
|
208
208
|
});
|
|
209
209
|
}).filter(function (v) {
|
|
210
210
|
return v !== undefined;
|
|
@@ -47,10 +47,9 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
47
47
|
private writeTimer?;
|
|
48
48
|
private _onPopState;
|
|
49
49
|
/**
|
|
50
|
-
* Indicates if
|
|
51
|
-
* It needs to avoid pushing state to history in case of back/forward in browser
|
|
50
|
+
* Indicates if last action was back/forward in the browser.
|
|
52
51
|
*/
|
|
53
|
-
private
|
|
52
|
+
private inPopState;
|
|
54
53
|
/**
|
|
55
54
|
* Indicates whether the history router is disposed or not.
|
|
56
55
|
*/
|
|
@@ -92,6 +91,7 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
92
91
|
* Removes the event listener and cleans up the URL.
|
|
93
92
|
*/
|
|
94
93
|
dispose(): void;
|
|
94
|
+
private shouldWrite;
|
|
95
95
|
}
|
|
96
96
|
export default function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
|
|
97
97
|
export {};
|
|
@@ -46,7 +46,7 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
46
46
|
|
|
47
47
|
_defineProperty(this, "writeTimer", void 0);
|
|
48
48
|
|
|
49
|
-
_defineProperty(this, "
|
|
49
|
+
_defineProperty(this, "inPopState", false);
|
|
50
50
|
|
|
51
51
|
_defineProperty(this, "isDisposed", false);
|
|
52
52
|
|
|
@@ -101,20 +101,14 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
_this2.writeTimer = setTimeout(function () {
|
|
104
|
-
setWindowTitle(title);
|
|
105
|
-
// - the router is not disposed, IS.js needs to update the URL
|
|
106
|
-
// OR
|
|
107
|
-
// - the last write was from InstantSearch.js
|
|
108
|
-
// (unlike a SPA, where it would have last written)
|
|
104
|
+
setWindowTitle(title);
|
|
109
105
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (_this2.shouldPushState && lastPushWasByISAfterDispose) {
|
|
106
|
+
if (_this2.shouldWrite(url)) {
|
|
113
107
|
window.history.pushState(routeState, title || '', url);
|
|
114
108
|
_this2.latestAcknowledgedHistory = window.history.length;
|
|
115
109
|
}
|
|
116
110
|
|
|
117
|
-
_this2.
|
|
111
|
+
_this2.inPopState = false;
|
|
118
112
|
_this2.writeTimer = undefined;
|
|
119
113
|
}, _this2.writeDelay);
|
|
120
114
|
});
|
|
@@ -135,7 +129,7 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
135
129
|
_this3.writeTimer = undefined;
|
|
136
130
|
}
|
|
137
131
|
|
|
138
|
-
_this3.
|
|
132
|
+
_this3.inPopState = true;
|
|
139
133
|
var routeState = event.state; // At initial load, the state is read from the URL without update.
|
|
140
134
|
// Therefore the state object is not available.
|
|
141
135
|
// In this case, we fallback and read the URL.
|
|
@@ -193,18 +187,39 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
193
187
|
|
|
194
188
|
this.write({});
|
|
195
189
|
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "shouldWrite",
|
|
192
|
+
value: function shouldWrite(url) {
|
|
193
|
+
var _this5 = this;
|
|
194
|
+
|
|
195
|
+
return safelyRunOnBrowser(function (_ref6) {
|
|
196
|
+
var window = _ref6.window;
|
|
197
|
+
// We do want to `pushState` if:
|
|
198
|
+
// - the router is not disposed, IS.js needs to update the URL
|
|
199
|
+
// OR
|
|
200
|
+
// - the last write was from InstantSearch.js
|
|
201
|
+
// (unlike a SPA, where it would have last written)
|
|
202
|
+
var lastPushWasByISAfterDispose = !(_this5.isDisposed && _this5.latestAcknowledgedHistory !== window.history.length);
|
|
203
|
+
return (// When the last state change was through popstate, the IS.js state changes,
|
|
204
|
+
// but that should not write the URL.
|
|
205
|
+
!_this5.inPopState && // When the previous pushState after dispose was by IS.js, we want to write the URL.
|
|
206
|
+
lastPushWasByISAfterDispose && // When the URL is the same as the current one, we do not want to write it.
|
|
207
|
+
url !== window.location.href
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
196
211
|
}]);
|
|
197
212
|
|
|
198
213
|
return BrowserHistory;
|
|
199
214
|
}();
|
|
200
215
|
|
|
201
216
|
export default function historyRouter() {
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
createURL =
|
|
205
|
-
var qsModule =
|
|
206
|
-
routeState =
|
|
207
|
-
location =
|
|
217
|
+
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
218
|
+
_ref7$createURL = _ref7.createURL,
|
|
219
|
+
createURL = _ref7$createURL === void 0 ? function (_ref8) {
|
|
220
|
+
var qsModule = _ref8.qsModule,
|
|
221
|
+
routeState = _ref8.routeState,
|
|
222
|
+
location = _ref8.location;
|
|
208
223
|
var protocol = location.protocol,
|
|
209
224
|
hostname = location.hostname,
|
|
210
225
|
_location$port = location.port,
|
|
@@ -220,11 +235,11 @@ export default function historyRouter() {
|
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
return "".concat(protocol, "//").concat(hostname).concat(portWithPrefix).concat(pathname, "?").concat(queryString).concat(hash);
|
|
223
|
-
} :
|
|
224
|
-
|
|
225
|
-
parseURL =
|
|
226
|
-
var qsModule =
|
|
227
|
-
location =
|
|
238
|
+
} : _ref7$createURL,
|
|
239
|
+
_ref7$parseURL = _ref7.parseURL,
|
|
240
|
+
parseURL = _ref7$parseURL === void 0 ? function (_ref9) {
|
|
241
|
+
var qsModule = _ref9.qsModule,
|
|
242
|
+
location = _ref9.location;
|
|
228
243
|
// `qs` by default converts arrays with more than 20 items to an object.
|
|
229
244
|
// We want to avoid this because the data structure manipulated can therefore vary.
|
|
230
245
|
// Setting the limit to `100` seems a good number because the engine's default is 100
|
|
@@ -238,21 +253,21 @@ export default function historyRouter() {
|
|
|
238
253
|
return qsModule.parse(location.search.slice(1), {
|
|
239
254
|
arrayLimit: 99
|
|
240
255
|
});
|
|
241
|
-
} :
|
|
242
|
-
|
|
243
|
-
writeDelay =
|
|
244
|
-
windowTitle =
|
|
245
|
-
|
|
246
|
-
getLocation =
|
|
247
|
-
return safelyRunOnBrowser(function (
|
|
248
|
-
var window =
|
|
256
|
+
} : _ref7$parseURL,
|
|
257
|
+
_ref7$writeDelay = _ref7.writeDelay,
|
|
258
|
+
writeDelay = _ref7$writeDelay === void 0 ? 400 : _ref7$writeDelay,
|
|
259
|
+
windowTitle = _ref7.windowTitle,
|
|
260
|
+
_ref7$getLocation = _ref7.getLocation,
|
|
261
|
+
getLocation = _ref7$getLocation === void 0 ? function () {
|
|
262
|
+
return safelyRunOnBrowser(function (_ref10) {
|
|
263
|
+
var window = _ref10.window;
|
|
249
264
|
return window.location;
|
|
250
265
|
}, {
|
|
251
266
|
fallback: function fallback() {
|
|
252
267
|
throw new Error('You need to provide `getLocation` to the `history` router in environments where `window` does not exist.');
|
|
253
268
|
}
|
|
254
269
|
});
|
|
255
|
-
} :
|
|
270
|
+
} : _ref7$getLocation;
|
|
256
271
|
|
|
257
272
|
return new BrowserHistory({
|
|
258
273
|
createURL: createURL,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare type FacetValue = string | number | undefined;
|
|
2
|
+
export declare function unescapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
|
|
3
|
+
export declare function escapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function unescapeFacetValue(value) {
|
|
2
|
+
if (typeof value === 'string') {
|
|
3
|
+
return value.replace(/^\\-/, '-');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
export function escapeFacetValue(value) {
|
|
9
|
+
if (typeof value === 'number' && value < 0 || typeof value === 'string') {
|
|
10
|
+
return String(value).replace(/^-/, '\\-');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
import type { SearchParameters, SearchResults } from 'algoliasearch-helper';
|
|
2
2
|
export declare type FacetRefinement = {
|
|
3
|
-
type: 'facet' | '
|
|
3
|
+
type: 'facet' | 'disjunctive' | 'hierarchical';
|
|
4
4
|
attribute: string;
|
|
5
5
|
name: string;
|
|
6
|
+
escapedValue: string;
|
|
6
7
|
count?: number;
|
|
7
8
|
exhaustive?: boolean;
|
|
8
9
|
};
|
|
10
|
+
export declare type TagRefinement = {
|
|
11
|
+
type: 'tag';
|
|
12
|
+
attribute: string;
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
9
15
|
export declare type QueryRefinement = {
|
|
10
16
|
type: 'query';
|
|
17
|
+
attribute: 'query';
|
|
11
18
|
query: string;
|
|
12
|
-
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
13
21
|
export declare type NumericRefinement = {
|
|
14
22
|
type: 'numeric';
|
|
15
23
|
numericValue: number;
|
|
16
24
|
operator: '<' | '<=' | '=' | '!=' | '>=' | '>';
|
|
17
|
-
|
|
25
|
+
attribute: string;
|
|
26
|
+
name: string;
|
|
27
|
+
count?: number;
|
|
28
|
+
exhaustive?: boolean;
|
|
29
|
+
};
|
|
18
30
|
export declare type FacetExcludeRefinement = {
|
|
19
31
|
type: 'exclude';
|
|
20
32
|
exclude: boolean;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
attribute: string;
|
|
34
|
+
name: string;
|
|
35
|
+
count?: number;
|
|
36
|
+
exhaustive?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare type Refinement = FacetRefinement | QueryRefinement | NumericRefinement | FacetExcludeRefinement | TagRefinement;
|
|
39
|
+
export default function getRefinements(results: SearchResults | Record<string, never>, state: SearchParameters, includesQuery?: boolean): Refinement[];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import find from "./find.js";
|
|
2
|
-
import
|
|
2
|
+
import { unescapeFacetValue, escapeFacetValue } from "./escapeFacetValue.js";
|
|
3
3
|
|
|
4
4
|
function getRefinement(state, type, attribute, name) {
|
|
5
5
|
var resultsFacets = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
6
6
|
var res = {
|
|
7
7
|
type: type,
|
|
8
8
|
attribute: attribute,
|
|
9
|
-
name: name
|
|
9
|
+
name: name,
|
|
10
|
+
escapedValue: escapeFacetValue(name)
|
|
10
11
|
};
|
|
11
12
|
var facet = find(resultsFacets, function (resultsFacet) {
|
|
12
13
|
return resultsFacet.name === attribute;
|
|
@@ -40,20 +41,18 @@ function getRefinement(state, type, attribute, name) {
|
|
|
40
41
|
count = facet && facet.data && facet.data[res.name];
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
var exhaustive = facet && facet.exhaustive;
|
|
44
|
-
|
|
45
44
|
if (count !== undefined) {
|
|
46
45
|
res.count = count;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
if (exhaustive !== undefined) {
|
|
50
|
-
res.exhaustive = exhaustive;
|
|
48
|
+
if (facet && facet.exhaustive !== undefined) {
|
|
49
|
+
res.exhaustive = facet.exhaustive;
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
return res;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
function getRefinements(results, state) {
|
|
55
|
+
export default function getRefinements(results, state) {
|
|
57
56
|
var includesQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
58
57
|
var refinements = [];
|
|
59
58
|
var _state$facetsRefineme = state.facetsRefinements,
|
|
@@ -88,9 +87,9 @@ function getRefinements(results, state) {
|
|
|
88
87
|
Object.keys(disjunctiveFacetsRefinements).forEach(function (attribute) {
|
|
89
88
|
var refinementNames = disjunctiveFacetsRefinements[attribute];
|
|
90
89
|
refinementNames.forEach(function (refinementName) {
|
|
91
|
-
refinements.push(getRefinement(state, 'disjunctive', attribute, // We unescape any disjunctive refined values with `
|
|
92
|
-
// they can be escaped on negative numeric values with `
|
|
93
|
-
|
|
90
|
+
refinements.push(getRefinement(state, 'disjunctive', attribute, // We unescape any disjunctive refined values with `unescapeFacetValue` because
|
|
91
|
+
// they can be escaped on negative numeric values with `escapeFacetValue`.
|
|
92
|
+
unescapeFacetValue(refinementName), results.disjunctiveFacets));
|
|
94
93
|
});
|
|
95
94
|
});
|
|
96
95
|
Object.keys(hierarchicalFacetsRefinements).forEach(function (attribute) {
|
|
@@ -134,6 +133,4 @@ function getRefinements(results, state) {
|
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
return refinements;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export default getRefinements;
|
|
136
|
+
}
|
package/es/lib/utils/index.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ export { default as prepareTemplateProps } from './prepareTemplateProps';
|
|
|
7
7
|
export { default as renderTemplate } from './renderTemplate';
|
|
8
8
|
export { default as getRefinements } from './getRefinements';
|
|
9
9
|
export { default as clearRefinements } from './clearRefinements';
|
|
10
|
-
export {
|
|
11
|
-
export { default as unescapeRefinement } from './unescapeRefinement';
|
|
10
|
+
export { escapeFacetValue, unescapeFacetValue } from './escapeFacetValue';
|
|
12
11
|
export { default as checkRendering } from './checkRendering';
|
|
13
12
|
export { checkIndexUiState } from './checkIndexUiState';
|
|
14
13
|
export { default as getPropertyByPath } from './getPropertyByPath';
|
package/es/lib/utils/index.js
CHANGED
|
@@ -7,8 +7,7 @@ export { default as prepareTemplateProps } from "./prepareTemplateProps.js";
|
|
|
7
7
|
export { default as renderTemplate } from "./renderTemplate.js";
|
|
8
8
|
export { default as getRefinements } from "./getRefinements.js";
|
|
9
9
|
export { default as clearRefinements } from "./clearRefinements.js";
|
|
10
|
-
export {
|
|
11
|
-
export { default as unescapeRefinement } from "./unescapeRefinement.js";
|
|
10
|
+
export { escapeFacetValue, unescapeFacetValue } from "./escapeFacetValue.js";
|
|
12
11
|
export { default as checkRendering } from "./checkRendering.js";
|
|
13
12
|
export { checkIndexUiState } from "./checkIndexUiState.js";
|
|
14
13
|
export { default as getPropertyByPath } from "./getPropertyByPath.js";
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.40.
|
|
1
|
+
declare const _default: "4.40.5";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.40.
|
|
1
|
+
export default '4.40.5';
|
package/es/types/results.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlainSearchParameters, SearchResults } from 'algoliasearch-helper';
|
|
1
|
+
import type { PlainSearchParameters, SearchForFacetValues, SearchResults } from 'algoliasearch-helper';
|
|
2
2
|
export declare type HitAttributeHighlightResult = {
|
|
3
3
|
value: string;
|
|
4
4
|
matchLevel: 'none' | 'partial' | 'full';
|
|
@@ -52,12 +52,7 @@ export declare type Hits = Hit[];
|
|
|
52
52
|
export declare type EscapedHits<THit = Hit> = THit[] & {
|
|
53
53
|
__escaped: boolean;
|
|
54
54
|
};
|
|
55
|
-
export declare type FacetHit =
|
|
56
|
-
value: string;
|
|
57
|
-
highlighted: string;
|
|
58
|
-
count: number;
|
|
59
|
-
isRefined: boolean;
|
|
60
|
-
};
|
|
55
|
+
export declare type FacetHit = SearchForFacetValues.Hit;
|
|
61
56
|
export declare type FacetRefinement = {
|
|
62
57
|
value: string;
|
|
63
58
|
type: 'conjunctive' | 'disjunctive' | 'exclude';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.40.
|
|
3
|
+
"version": "4.40.5",
|
|
4
4
|
"description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
|
|
5
5
|
"homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@types/google.maps": "^3.45.3",
|
|
57
57
|
"@types/hogan.js": "^3.0.0",
|
|
58
58
|
"@types/qs": "^6.5.3",
|
|
59
|
-
"algoliasearch-helper": "^3.
|
|
59
|
+
"algoliasearch-helper": "^3.8.2",
|
|
60
60
|
"classnames": "^2.2.5",
|
|
61
61
|
"@algolia/events": "^4.0.1",
|
|
62
62
|
"hogan.js": "^3.0.2",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"bundlesize": [
|
|
155
155
|
{
|
|
156
156
|
"path": "./dist/instantsearch.production.min.js",
|
|
157
|
-
"maxSize": "70.
|
|
157
|
+
"maxSize": "70.25 kB"
|
|
158
158
|
},
|
|
159
159
|
{
|
|
160
160
|
"path": "./dist/instantsearch.development.js",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
function escapeRefinement(value) {
|
|
9
|
-
if (typeof value === 'number' && value < 0) {
|
|
10
|
-
value = String(value).replace(/^-/, '\\-');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
var _default = escapeRefinement;
|
|
17
|
-
exports.default = _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
function unescapeRefinement(value) {
|
|
9
|
-
return String(value).replace(/^\\-/, '-');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
var _default = unescapeRefinement;
|
|
13
|
-
exports.default = _default;
|