@elastic/search-ui
Advanced tools
Comparing version 1.10.0-rc.1 to 1.10.0
@@ -407,2 +407,12 @@ "use strict"; | ||
}); | ||
it("calculates pagingEnd correctly when resultsPerPage is one less than totalResults", () => { | ||
const mockSearchResponse = { totalResults: 41, totalPages: 2 }; | ||
const { stateAfterCreation } = (0, helpers_1.setupDriver)({ | ||
initialState, | ||
mockSearchResponse | ||
}); | ||
expect(stateAfterCreation.totalResults).toEqual(41); | ||
expect(stateAfterCreation.pagingStart).toEqual(21); | ||
expect(stateAfterCreation.pagingEnd).toEqual(40); | ||
}); | ||
it("zeroes out pagingStart and pagingEnd correctly", () => { | ||
@@ -409,0 +419,0 @@ const mockSearchResponse = { totalResults: 0 }; |
@@ -10,3 +10,4 @@ export { default as SearchDriver, DEFAULT_STATE } from "./SearchDriver"; | ||
}; | ||
export * from "./constants"; | ||
export * from "./types"; | ||
export type { SearchDriverActions } from "./actions"; |
@@ -34,2 +34,3 @@ "use strict"; | ||
exports.helpers = Object.assign({}, helpersSource); | ||
__exportStar(require("./constants"), exports); | ||
__exportStar(require("./types"), exports); |
@@ -45,2 +45,3 @@ import URLManager from "./URLManager"; | ||
startingState: SearchState; | ||
apiConnector: APIConnector; | ||
constructor({ apiConnector, autocompleteQuery, debug, initialState, onSearch, onAutocomplete, onResultClick, onAutocompleteResultClick, searchQuery, trackUrlState, urlPushDebounceLength, hasA11yNotifications, a11yNotificationMessages, alwaysSearchOnInitialLoad }: SearchDriverOptions); | ||
@@ -47,0 +48,0 @@ /** |
@@ -43,2 +43,3 @@ "use strict"; | ||
const helpers_1 = require("./helpers"); | ||
const _1 = require("."); | ||
const a11y = __importStar(require("./A11yNotifications")); | ||
@@ -213,3 +214,3 @@ function filterSearchParameters({ current, filters, resultsPerPage, searchTerm, sortDirection, sortField, sortList }) { | ||
const start = totalResults === 0 ? 0 : (current - 1) * resultsPerPage + 1; | ||
const end = totalResults <= start + resultsPerPage | ||
const end = totalResults < start + resultsPerPage | ||
? totalResults | ||
@@ -237,2 +238,11 @@ : start + resultsPerPage - 1; | ||
}, (error) => { | ||
var _a; | ||
if (error.message === _1.INVALID_CREDENTIALS) { | ||
// The connector should have invalidated the credentials in its state by now | ||
// Getting the latest state from the connector | ||
this._setState(Object.assign({}, (((_a = this.apiConnector) === null || _a === void 0 ? void 0 : _a.state) && Object.assign({}, this.apiConnector.state)))); | ||
// Stop execution of request | ||
// and let the consuming application handle the missing credentials | ||
return; | ||
} | ||
this._setState({ | ||
@@ -269,2 +279,3 @@ error: `An unexpected error occurred: ${error.message}` | ||
this.alwaysSearchOnInitialLoad = alwaysSearchOnInitialLoad; | ||
this.apiConnector = apiConnector; | ||
let urlState; | ||
@@ -297,3 +308,3 @@ if (trackUrlState) { | ||
// to the correct default values for the initial UI render | ||
this.state = Object.assign(Object.assign({}, this.state), searchParameters); | ||
this.state = Object.assign(Object.assign(Object.assign({}, this.state), ((apiConnector === null || apiConnector === void 0 ? void 0 : apiConnector.state) && Object.assign({}, apiConnector.state))), searchParameters); | ||
// We'll trigger an initial search if initial parameters contain | ||
@@ -300,0 +311,0 @@ // a search term or filters, or if alwaysSearchOnInitialLoad is set. |
@@ -42,3 +42,7 @@ import { SearchDriverActions } from ".."; | ||
}; | ||
export declare type SearchState = RequestState & { | ||
export declare type SearchState = RequestState & ResponseState & AutocompleteResponseState & { | ||
error: string; | ||
isLoading: boolean; | ||
}; | ||
export declare type AutocompleteResponseState = { | ||
autocompletedResults: AutocompletedResult[]; | ||
@@ -48,7 +52,6 @@ autocompletedResultsRequestId: string; | ||
autocompletedSuggestionsRequestId: string; | ||
error: string; | ||
isLoading: boolean; | ||
}; | ||
export declare type ResponseState = { | ||
requestId: string; | ||
facets: Record<string, any>; | ||
requestId: string; | ||
results: SearchResult[]; | ||
resultSearchTerm: string; | ||
@@ -59,3 +62,4 @@ totalPages: number; | ||
pagingEnd: number; | ||
wasSearched: false; | ||
wasSearched: boolean; | ||
results: SearchResult[]; | ||
rawResponse: any; | ||
@@ -82,3 +86,3 @@ }; | ||
size?: number; | ||
ranges?: FilterValueRange | FilterValueRange[]; | ||
ranges?: FilterValueRange[]; | ||
center?: string; | ||
@@ -85,0 +89,0 @@ unit?: string; |
@@ -383,2 +383,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}); | ||
it("calculates pagingEnd correctly when resultsPerPage is one less than totalResults", () => { | ||
const mockSearchResponse = { totalResults: 41, totalPages: 2 }; | ||
const { stateAfterCreation } = setupDriver({ | ||
initialState, | ||
mockSearchResponse | ||
}); | ||
expect(stateAfterCreation.totalResults).toEqual(41); | ||
expect(stateAfterCreation.pagingStart).toEqual(21); | ||
expect(stateAfterCreation.pagingEnd).toEqual(40); | ||
}); | ||
it("zeroes out pagingStart and pagingEnd correctly", () => { | ||
@@ -385,0 +395,0 @@ const mockSearchResponse = { totalResults: 0 }; |
@@ -10,3 +10,4 @@ export { default as SearchDriver, DEFAULT_STATE } from "./SearchDriver"; | ||
}; | ||
export * from "./constants"; | ||
export * from "./types"; | ||
export type { SearchDriverActions } from "./actions"; |
import * as helpersSource from "./helpers"; | ||
export { default as SearchDriver, DEFAULT_STATE } from "./SearchDriver"; | ||
export const helpers = Object.assign({}, helpersSource); | ||
export * from "./constants"; | ||
export * from "./types"; |
@@ -45,2 +45,3 @@ import URLManager from "./URLManager"; | ||
startingState: SearchState; | ||
apiConnector: APIConnector; | ||
constructor({ apiConnector, autocompleteQuery, debug, initialState, onSearch, onAutocomplete, onResultClick, onAutocompleteResultClick, searchQuery, trackUrlState, urlPushDebounceLength, hasA11yNotifications, a11yNotificationMessages, alwaysSearchOnInitialLoad }: SearchDriverOptions); | ||
@@ -47,0 +48,0 @@ /** |
@@ -18,2 +18,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { mergeFilters } from "./helpers"; | ||
import { INVALID_CREDENTIALS } from "."; | ||
import * as a11y from "./A11yNotifications"; | ||
@@ -188,3 +189,3 @@ function filterSearchParameters({ current, filters, resultsPerPage, searchTerm, sortDirection, sortField, sortList }) { | ||
const start = totalResults === 0 ? 0 : (current - 1) * resultsPerPage + 1; | ||
const end = totalResults <= start + resultsPerPage | ||
const end = totalResults < start + resultsPerPage | ||
? totalResults | ||
@@ -212,2 +213,11 @@ : start + resultsPerPage - 1; | ||
}, (error) => { | ||
var _a; | ||
if (error.message === INVALID_CREDENTIALS) { | ||
// The connector should have invalidated the credentials in its state by now | ||
// Getting the latest state from the connector | ||
this._setState(Object.assign({}, (((_a = this.apiConnector) === null || _a === void 0 ? void 0 : _a.state) && Object.assign({}, this.apiConnector.state)))); | ||
// Stop execution of request | ||
// and let the consuming application handle the missing credentials | ||
return; | ||
} | ||
this._setState({ | ||
@@ -244,2 +254,3 @@ error: `An unexpected error occurred: ${error.message}` | ||
this.alwaysSearchOnInitialLoad = alwaysSearchOnInitialLoad; | ||
this.apiConnector = apiConnector; | ||
let urlState; | ||
@@ -272,3 +283,3 @@ if (trackUrlState) { | ||
// to the correct default values for the initial UI render | ||
this.state = Object.assign(Object.assign({}, this.state), searchParameters); | ||
this.state = Object.assign(Object.assign(Object.assign({}, this.state), ((apiConnector === null || apiConnector === void 0 ? void 0 : apiConnector.state) && Object.assign({}, apiConnector.state))), searchParameters); | ||
// We'll trigger an initial search if initial parameters contain | ||
@@ -275,0 +286,0 @@ // a search term or filters, or if alwaysSearchOnInitialLoad is set. |
@@ -42,3 +42,7 @@ import { SearchDriverActions } from ".."; | ||
}; | ||
export declare type SearchState = RequestState & { | ||
export declare type SearchState = RequestState & ResponseState & AutocompleteResponseState & { | ||
error: string; | ||
isLoading: boolean; | ||
}; | ||
export declare type AutocompleteResponseState = { | ||
autocompletedResults: AutocompletedResult[]; | ||
@@ -48,7 +52,6 @@ autocompletedResultsRequestId: string; | ||
autocompletedSuggestionsRequestId: string; | ||
error: string; | ||
isLoading: boolean; | ||
}; | ||
export declare type ResponseState = { | ||
requestId: string; | ||
facets: Record<string, any>; | ||
requestId: string; | ||
results: SearchResult[]; | ||
resultSearchTerm: string; | ||
@@ -59,3 +62,4 @@ totalPages: number; | ||
pagingEnd: number; | ||
wasSearched: false; | ||
wasSearched: boolean; | ||
results: SearchResult[]; | ||
rawResponse: any; | ||
@@ -82,3 +86,3 @@ }; | ||
size?: number; | ||
ranges?: FilterValueRange | FilterValueRange[]; | ||
ranges?: FilterValueRange[]; | ||
center?: string; | ||
@@ -85,0 +89,0 @@ unit?: string; |
{ | ||
"name": "@elastic/search-ui", | ||
"version": "1.10.0-rc.1", | ||
"version": "1.10.0", | ||
"description": "A Headless Search UI library", | ||
@@ -28,4 +28,4 @@ "license": "Apache-2.0", | ||
"build-js": "./bin/build-js", | ||
"build": "run-s clean build-js", | ||
"watch": "run-p watch-js", | ||
"build": "npm run clean && npm run build-js", | ||
"watch": "npm run clean && npm run watch-js", | ||
"prepare": "npm run build" | ||
@@ -38,8 +38,4 @@ }, | ||
"@types/history": "^4.7.11", | ||
"@types/jest": "^27.4.0", | ||
"@types/qs": "^6.9.7", | ||
"jest": "^27.4.7", | ||
"npm-run-all": "^4.1.5", | ||
"rimraf": "^2.6.3", | ||
"ts-jest": "^27.1.3", | ||
"typescript": "^4.5.4" | ||
@@ -53,3 +49,3 @@ }, | ||
}, | ||
"gitHead": "4865eb97cb89b9536667997eb86aa88b0339d22b" | ||
"gitHead": "c0396e2072247a813fe80140f3f936660b88dc70" | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
390970
4
199
9360
1