instantsearch.js 4.46.0 → 4.46.2
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 +22 -1
- package/cjs/components/CurrentRefinements/CurrentRefinements.js +0 -1
- package/cjs/components/GeoSearchControls/GeoSearchButton.js +0 -1
- package/cjs/components/GeoSearchControls/GeoSearchToggle.js +0 -1
- package/cjs/components/PoweredBy/PoweredBy.js +0 -1
- package/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js +0 -1
- package/cjs/components/RelevantSort/RelevantSort.js +0 -1
- package/cjs/components/Selector/Selector.js +0 -1
- package/cjs/components/Template/Template.js +3 -1
- package/cjs/components/VoiceSearch/VoiceSearch.js +0 -1
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
- package/cjs/helpers/components/Highlight.js +5 -13
- package/cjs/helpers/components/ReverseHighlight.js +5 -13
- package/cjs/helpers/components/ReverseSnippet.js +5 -13
- package/cjs/helpers/components/Snippet.js +5 -13
- package/cjs/lib/InstantSearch.js +33 -24
- package/cjs/lib/insights/listener.js +0 -1
- package/cjs/lib/templating/index.js +31 -0
- package/cjs/lib/{utils → templating}/prepareTemplateProps.js +4 -9
- package/cjs/lib/{utils → templating}/renderTemplate.js +4 -7
- package/cjs/lib/utils/capitalize.js +2 -5
- package/cjs/lib/utils/checkIndexUiState.js +3 -5
- package/cjs/lib/utils/checkRendering.js +4 -9
- package/cjs/lib/utils/clearRefinements.js +3 -9
- package/cjs/lib/utils/concatHighlightedParts.js +1 -1
- package/cjs/lib/utils/createSendEventForFacet.js +2 -4
- package/cjs/lib/utils/defer.js +3 -6
- package/cjs/lib/utils/detect-insights-client.js +1 -1
- package/cjs/lib/utils/documentation.js +6 -9
- package/cjs/lib/utils/escape-highlight.js +4 -6
- package/cjs/lib/utils/escape-html.js +60 -0
- package/cjs/lib/utils/find.js +2 -5
- package/cjs/lib/utils/findIndex.js +2 -5
- package/cjs/lib/utils/getContainerNode.js +4 -9
- package/cjs/lib/utils/getHighlightFromSiblings.js +3 -5
- package/cjs/lib/utils/getHighlightedParts.js +1 -1
- package/cjs/lib/utils/getObjectType.js +2 -5
- package/cjs/lib/utils/getPropertyByPath.js +2 -5
- package/cjs/lib/utils/getRefinements.js +4 -6
- package/cjs/lib/utils/index.js +536 -440
- package/cjs/lib/utils/isDomElement.js +2 -5
- package/cjs/lib/utils/isEqual.js +2 -5
- package/cjs/lib/utils/isFacetRefined.js +1 -1
- package/cjs/lib/utils/isFiniteNumber.js +3 -5
- package/cjs/lib/utils/isIndexWidget.js +10 -0
- package/cjs/lib/utils/isPlainObject.js +2 -5
- package/cjs/lib/utils/isSpecialClick.js +2 -5
- package/cjs/lib/utils/logger.js +3 -5
- package/cjs/lib/utils/mergeSearchParameters.js +7 -10
- package/cjs/lib/utils/noop.js +2 -5
- package/cjs/lib/utils/range.js +2 -5
- package/cjs/lib/utils/resolveSearchParameters.js +3 -6
- package/cjs/lib/utils/reverseHighlightedParts.js +3 -5
- package/cjs/lib/utils/setIndexHelperState.js +28 -0
- package/cjs/lib/utils/toArray.js +2 -5
- package/cjs/lib/utils/uniq.js +2 -5
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +23 -30
- package/cjs/middlewares/createMetadataMiddleware.js +1 -0
- package/cjs/middlewares/createRouterMiddleware.js +1 -0
- package/cjs/widgets/answers/answers.js +3 -1
- package/cjs/widgets/breadcrumb/breadcrumb.js +3 -1
- package/cjs/widgets/clear-refinements/clear-refinements.js +3 -1
- package/cjs/widgets/geo-search/GeoSearchRenderer.js +1 -1
- package/cjs/widgets/geo-search/defaultTemplates.js +0 -1
- package/cjs/widgets/geo-search/geo-search.js +3 -1
- package/cjs/widgets/hierarchical-menu/defaultTemplates.js +0 -1
- package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +3 -1
- package/cjs/widgets/hits/hits.js +6 -4
- package/cjs/widgets/index/index.js +8 -12
- package/cjs/widgets/infinite-hits/infinite-hits.js +6 -4
- package/cjs/widgets/menu/defaultTemplates.js +0 -1
- package/cjs/widgets/menu/menu.js +3 -1
- package/cjs/widgets/menu-select/menu-select.js +3 -1
- package/cjs/widgets/numeric-menu/defaultTemplates.js +0 -1
- package/cjs/widgets/numeric-menu/numeric-menu.js +3 -1
- package/cjs/widgets/range-input/range-input.js +3 -1
- package/cjs/widgets/rating-menu/defaultTemplates.js +0 -1
- package/cjs/widgets/rating-menu/rating-menu.js +3 -1
- package/cjs/widgets/refinement-list/defaultTemplates.js +0 -1
- package/cjs/widgets/refinement-list/refinement-list.js +4 -2
- package/cjs/widgets/search-box/defaultTemplates.js +0 -1
- package/cjs/widgets/stats/stats.js +3 -1
- package/cjs/widgets/toggle-refinement/toggle-refinement.js +3 -1
- package/cjs/widgets/voice-search/defaultTemplates.js +0 -1
- package/dist/instantsearch.development.d.ts +11 -3
- package/dist/instantsearch.development.js +8513 -8482
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +11 -3
- package/dist/instantsearch.production.min.d.ts +11 -3
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Answers/Answers.d.ts +1 -1
- package/es/components/Answers/Answers.js +0 -1
- package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -2
- package/es/components/Breadcrumb/Breadcrumb.js +0 -1
- package/es/components/ClearRefinements/ClearRefinements.d.ts +2 -2
- package/es/components/ClearRefinements/ClearRefinements.js +0 -1
- package/es/components/CurrentRefinements/CurrentRefinements.d.ts +1 -1
- package/es/components/CurrentRefinements/CurrentRefinements.js +0 -1
- package/es/components/GeoSearchControls/GeoSearchButton.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchButton.js +0 -1
- package/es/components/GeoSearchControls/GeoSearchControls.d.ts +2 -2
- package/es/components/GeoSearchControls/GeoSearchControls.js +0 -1
- package/es/components/GeoSearchControls/GeoSearchToggle.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchToggle.js +0 -1
- package/es/components/Highlight/Highlight.js +0 -1
- package/es/components/Hits/Hits.d.ts +2 -2
- package/es/components/Hits/Hits.js +0 -1
- package/es/components/InfiniteHits/InfiniteHits.d.ts +1 -1
- package/es/components/InfiniteHits/InfiniteHits.js +0 -1
- package/es/components/MenuSelect/MenuSelect.d.ts +1 -1
- package/es/components/MenuSelect/MenuSelect.js +0 -1
- package/es/components/Pagination/Pagination.d.ts +1 -1
- package/es/components/Pagination/Pagination.js +0 -1
- package/es/components/Panel/Panel.d.ts +1 -1
- package/es/components/Panel/Panel.js +0 -1
- package/es/components/PoweredBy/PoweredBy.d.ts +1 -1
- package/es/components/PoweredBy/PoweredBy.js +0 -1
- package/es/components/QueryRuleCustomData/QueryRuleCustomData.d.ts +1 -1
- package/es/components/QueryRuleCustomData/QueryRuleCustomData.js +0 -1
- package/es/components/RangeInput/RangeInput.d.ts +1 -1
- package/es/components/RangeInput/RangeInput.js +0 -1
- package/es/components/RefinementList/RefinementList.d.ts +2 -2
- package/es/components/RefinementList/RefinementList.js +0 -1
- package/es/components/RefinementList/RefinementListItem.d.ts +1 -1
- package/es/components/RefinementList/RefinementListItem.js +0 -1
- package/es/components/RelevantSort/RelevantSort.d.ts +1 -1
- package/es/components/RelevantSort/RelevantSort.js +0 -1
- package/es/components/ReverseHighlight/ReverseHighlight.js +0 -1
- package/es/components/ReverseSnippet/ReverseSnippet.js +0 -1
- package/es/components/SearchBox/SearchBox.d.ts +1 -1
- package/es/components/SearchBox/SearchBox.js +0 -1
- package/es/components/Selector/Selector.d.ts +1 -1
- package/es/components/Selector/Selector.js +0 -1
- package/es/components/Slider/Pit.d.ts +1 -1
- package/es/components/Slider/Pit.js +0 -1
- package/es/components/Slider/Rheostat.d.ts +1 -1
- package/es/components/Slider/Rheostat.js +0 -2
- package/es/components/Slider/Slider.d.ts +1 -1
- package/es/components/Slider/Slider.js +0 -1
- package/es/components/Snippet/Snippet.js +0 -1
- package/es/components/Stats/Stats.d.ts +1 -1
- package/es/components/Stats/Stats.js +0 -1
- package/es/components/Template/Template.d.ts +2 -2
- package/es/components/Template/Template.js +2 -2
- package/es/components/ToggleRefinement/ToggleRefinement.d.ts +2 -5
- package/es/components/ToggleRefinement/ToggleRefinement.js +0 -5
- package/es/components/VoiceSearch/VoiceSearch.d.ts +1 -1
- package/es/components/VoiceSearch/VoiceSearch.js +0 -1
- package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +3 -2
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
- package/es/helpers/components/Highlight.d.ts +1 -1
- package/es/helpers/components/Highlight.js +2 -6
- package/es/helpers/components/ReverseHighlight.d.ts +1 -1
- package/es/helpers/components/ReverseHighlight.js +2 -6
- package/es/helpers/components/ReverseSnippet.d.ts +1 -1
- package/es/helpers/components/ReverseSnippet.js +2 -6
- package/es/helpers/components/Snippet.d.ts +1 -1
- package/es/helpers/components/Snippet.js +2 -6
- package/es/lib/InstantSearch.d.ts +6 -1
- package/es/lib/InstantSearch.js +34 -21
- package/es/lib/insights/listener.d.ts +1 -1
- package/es/lib/insights/listener.js +0 -1
- package/es/lib/templating/index.d.ts +2 -0
- package/es/lib/templating/index.js +2 -0
- package/es/lib/{utils → templating}/prepareTemplateProps.d.ts +2 -2
- package/es/lib/{utils → templating}/prepareTemplateProps.js +3 -5
- package/es/lib/{utils → templating}/renderTemplate.d.ts +2 -3
- package/es/lib/{utils → templating}/renderTemplate.js +3 -5
- package/es/lib/utils/capitalize.d.ts +1 -2
- package/es/lib/utils/capitalize.js +2 -4
- package/es/lib/utils/checkIndexUiState.js +1 -1
- package/es/lib/utils/checkRendering.d.ts +1 -2
- package/es/lib/utils/checkRendering.js +3 -6
- package/es/lib/utils/clearRefinements.d.ts +4 -8
- package/es/lib/utils/clearRefinements.js +3 -8
- package/es/lib/utils/concatHighlightedParts.d.ts +1 -1
- package/es/lib/utils/concatHighlightedParts.js +1 -1
- package/es/lib/utils/createSendEventForFacet.js +1 -1
- package/es/lib/utils/createSendEventForHits.d.ts +0 -3
- package/es/lib/utils/createSendEventForHits.js +0 -3
- package/es/lib/utils/defer.d.ts +2 -2
- package/es/lib/utils/defer.js +2 -5
- package/es/lib/utils/detect-insights-client.d.ts +1 -1
- package/es/lib/utils/detect-insights-client.js +1 -1
- package/es/lib/utils/documentation.d.ts +2 -2
- package/es/lib/utils/documentation.js +4 -4
- package/es/lib/utils/escape-highlight.js +2 -2
- package/es/lib/utils/{escape.d.ts → escape-html.d.ts} +6 -2
- package/es/lib/utils/escape-html.js +51 -0
- package/es/lib/utils/escapeFacetValue.d.ts +1 -1
- package/es/lib/utils/find.d.ts +1 -2
- package/es/lib/utils/find.js +2 -4
- package/es/lib/utils/findIndex.d.ts +1 -2
- package/es/lib/utils/findIndex.js +2 -4
- package/es/lib/utils/getContainerNode.d.ts +1 -2
- package/es/lib/utils/getContainerNode.js +3 -5
- package/es/lib/utils/getHighlightFromSiblings.d.ts +1 -1
- package/es/lib/utils/getHighlightFromSiblings.js +2 -2
- package/es/lib/utils/getHighlightedParts.d.ts +1 -1
- package/es/lib/utils/getHighlightedParts.js +1 -1
- package/es/lib/utils/getObjectType.d.ts +1 -2
- package/es/lib/utils/getObjectType.js +2 -4
- package/es/lib/utils/getPropertyByPath.d.ts +1 -2
- package/es/lib/utils/getPropertyByPath.js +2 -4
- package/es/lib/utils/getRefinements.d.ts +1 -1
- package/es/lib/utils/getRefinements.js +2 -2
- package/es/lib/utils/index.d.ts +44 -46
- package/es/lib/utils/index.js +44 -46
- package/es/lib/utils/isDomElement.d.ts +1 -2
- package/es/lib/utils/isDomElement.js +2 -4
- package/es/lib/utils/isEqual.d.ts +1 -2
- package/es/lib/utils/isEqual.js +2 -4
- package/es/lib/utils/isFacetRefined.d.ts +1 -1
- package/es/lib/utils/isFacetRefined.js +1 -1
- package/es/lib/utils/isFiniteNumber.d.ts +1 -2
- package/es/lib/utils/isFiniteNumber.js +3 -4
- package/es/lib/utils/isIndexWidget.d.ts +3 -0
- package/es/lib/utils/isIndexWidget.js +3 -0
- package/es/lib/utils/isPlainObject.d.ts +1 -2
- package/es/lib/utils/isPlainObject.js +2 -4
- package/es/lib/utils/isSpecialClick.d.ts +1 -2
- package/es/lib/utils/isSpecialClick.js +2 -4
- package/es/lib/utils/logger.js +1 -1
- package/es/lib/utils/mergeSearchParameters.d.ts +1 -2
- package/es/lib/utils/mergeSearchParameters.js +4 -6
- package/es/lib/utils/noop.d.ts +1 -2
- package/es/lib/utils/noop.js +1 -3
- package/es/lib/utils/range.d.ts +2 -2
- package/es/lib/utils/range.js +2 -4
- package/es/lib/utils/resolveSearchParameters.d.ts +1 -2
- package/es/lib/utils/resolveSearchParameters.js +2 -4
- package/es/lib/utils/reverseHighlightedParts.d.ts +1 -1
- package/es/lib/utils/reverseHighlightedParts.js +2 -2
- package/es/lib/utils/setIndexHelperState.d.ts +3 -0
- package/es/lib/utils/setIndexHelperState.js +19 -0
- package/es/lib/utils/toArray.d.ts +3 -2
- package/es/lib/utils/toArray.js +2 -4
- package/es/lib/utils/uniq.d.ts +1 -2
- package/es/lib/utils/uniq.js +2 -4
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.js +23 -27
- package/es/middlewares/createMetadataMiddleware.js +1 -0
- package/es/middlewares/createRouterMiddleware.js +1 -0
- package/es/types/middleware.d.ts +1 -0
- package/es/widgets/answers/answers.d.ts +1 -1
- package/es/widgets/answers/answers.js +2 -2
- package/es/widgets/breadcrumb/breadcrumb.d.ts +1 -1
- package/es/widgets/breadcrumb/breadcrumb.js +2 -2
- package/es/widgets/clear-refinements/clear-refinements.d.ts +1 -1
- package/es/widgets/clear-refinements/clear-refinements.js +2 -2
- package/es/widgets/current-refinements/current-refinements.d.ts +1 -1
- package/es/widgets/current-refinements/current-refinements.js +0 -1
- package/es/widgets/geo-search/GeoSearchRenderer.js +1 -2
- package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -1
- package/es/widgets/geo-search/defaultTemplates.d.ts +1 -1
- package/es/widgets/geo-search/defaultTemplates.js +0 -1
- package/es/widgets/geo-search/geo-search.js +2 -1
- package/es/widgets/hierarchical-menu/defaultTemplates.js +0 -1
- package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +1 -1
- package/es/widgets/hierarchical-menu/hierarchical-menu.js +2 -2
- package/es/widgets/hits/hits.d.ts +1 -1
- package/es/widgets/hits/hits.js +2 -2
- package/es/widgets/hits-per-page/hits-per-page.d.ts +1 -1
- package/es/widgets/hits-per-page/hits-per-page.js +0 -1
- package/es/widgets/index/index.d.ts +0 -1
- package/es/widgets/index/index.js +5 -6
- package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -1
- package/es/widgets/infinite-hits/infinite-hits.js +2 -2
- package/es/widgets/menu/defaultTemplates.js +0 -1
- package/es/widgets/menu/menu.d.ts +1 -1
- package/es/widgets/menu/menu.js +2 -2
- package/es/widgets/menu-select/menu-select.d.ts +1 -1
- package/es/widgets/menu-select/menu-select.js +2 -2
- package/es/widgets/numeric-menu/defaultTemplates.js +0 -1
- package/es/widgets/numeric-menu/numeric-menu.d.ts +1 -1
- package/es/widgets/numeric-menu/numeric-menu.js +2 -2
- package/es/widgets/pagination/pagination.d.ts +1 -1
- package/es/widgets/pagination/pagination.js +0 -1
- package/es/widgets/panel/panel.d.ts +1 -1
- package/es/widgets/panel/panel.js +0 -1
- package/es/widgets/powered-by/powered-by.d.ts +1 -1
- package/es/widgets/powered-by/powered-by.js +0 -1
- package/es/widgets/query-rule-custom-data/query-rule-custom-data.d.ts +1 -1
- package/es/widgets/query-rule-custom-data/query-rule-custom-data.js +0 -1
- package/es/widgets/range-input/range-input.d.ts +1 -1
- package/es/widgets/range-input/range-input.js +2 -2
- package/es/widgets/range-slider/range-slider.d.ts +1 -1
- package/es/widgets/range-slider/range-slider.js +0 -1
- package/es/widgets/rating-menu/defaultTemplates.js +0 -1
- package/es/widgets/rating-menu/rating-menu.d.ts +1 -1
- package/es/widgets/rating-menu/rating-menu.js +2 -2
- package/es/widgets/refinement-list/defaultTemplates.js +0 -1
- package/es/widgets/refinement-list/refinement-list.d.ts +1 -1
- package/es/widgets/refinement-list/refinement-list.js +2 -2
- package/es/widgets/relevant-sort/relevant-sort.d.ts +1 -1
- package/es/widgets/relevant-sort/relevant-sort.js +0 -1
- package/es/widgets/search-box/defaultTemplates.js +0 -1
- package/es/widgets/search-box/search-box.d.ts +1 -1
- package/es/widgets/search-box/search-box.js +0 -1
- package/es/widgets/sort-by/sort-by.d.ts +1 -1
- package/es/widgets/sort-by/sort-by.js +0 -1
- package/es/widgets/stats/stats.d.ts +1 -1
- package/es/widgets/stats/stats.js +2 -2
- package/es/widgets/toggle-refinement/toggle-refinement.d.ts +1 -1
- package/es/widgets/toggle-refinement/toggle-refinement.js +2 -2
- package/es/widgets/voice-search/defaultTemplates.js +0 -1
- package/es/widgets/voice-search/voice-search.d.ts +1 -1
- package/es/widgets/voice-search/voice-search.js +0 -1
- package/package.json +6 -6
- package/cjs/lib/utils/convertNumericRefinementsToFilters.js +0 -31
- package/cjs/lib/utils/escape.js +0 -35
- package/cjs/lib/utils/unescape.js +0 -32
- package/es/lib/utils/convertNumericRefinementsToFilters.d.ts +0 -2
- package/es/lib/utils/convertNumericRefinementsToFilters.js +0 -24
- package/es/lib/utils/escape.js +0 -27
- package/es/lib/utils/unescape.d.ts +0 -9
- package/es/lib/utils/unescape.js +0 -25
|
@@ -10,13 +10,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
10
10
|
|
|
11
11
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
12
|
|
|
13
|
-
/** @jsx h */
|
|
14
13
|
import { h } from 'preact';
|
|
15
14
|
import { ReverseSnippet as ReverseSnippetUiComponent } from "../../components/ReverseSnippet/ReverseSnippet.js";
|
|
16
|
-
import getHighlightedParts from "../../lib/utils/
|
|
17
|
-
import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
|
|
18
|
-
import unescape from "../../lib/utils/unescape.js";
|
|
19
|
-
import { warning } from "../../lib/utils/logger.js";
|
|
15
|
+
import { getPropertyByPath, unescape, toArray, warning, getHighlightedParts } from "../../lib/utils/index.js";
|
|
20
16
|
export function ReverseSnippet(_ref) {
|
|
21
17
|
var hit = _ref.hit,
|
|
22
18
|
attribute = _ref.attribute,
|
|
@@ -24,7 +20,7 @@ export function ReverseSnippet(_ref) {
|
|
|
24
20
|
props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
|
|
25
21
|
|
|
26
22
|
var property = getPropertyByPath(hit._snippetResult, attribute) || [];
|
|
27
|
-
var properties =
|
|
23
|
+
var properties = toArray(property);
|
|
28
24
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
29
25
|
var parts = properties.map(function (_ref2) {
|
|
30
26
|
var value = _ref2.value;
|
|
@@ -4,13 +4,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
4
4
|
|
|
5
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
6
|
|
|
7
|
-
/** @jsx h */
|
|
8
7
|
import { h } from 'preact';
|
|
9
8
|
import { Snippet as SnippetUiComponent } from "../../components/Snippet/Snippet.js";
|
|
10
|
-
import getHighlightedParts from "../../lib/utils/
|
|
11
|
-
import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
|
|
12
|
-
import unescape from "../../lib/utils/unescape.js";
|
|
13
|
-
import { warning } from "../../lib/utils/logger.js";
|
|
9
|
+
import { getPropertyByPath, unescape, toArray, warning, getHighlightedParts } from "../../lib/utils/index.js";
|
|
14
10
|
export function Snippet(_ref) {
|
|
15
11
|
var hit = _ref.hit,
|
|
16
12
|
attribute = _ref.attribute,
|
|
@@ -18,7 +14,7 @@ export function Snippet(_ref) {
|
|
|
18
14
|
props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
|
|
19
15
|
|
|
20
16
|
var property = getPropertyByPath(hit._snippetResult, attribute) || [];
|
|
21
|
-
var properties =
|
|
17
|
+
var properties = toArray(property);
|
|
22
18
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
23
19
|
var parts = properties.map(function (_ref2) {
|
|
24
20
|
var value = _ref2.value;
|
|
@@ -177,7 +177,12 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
177
177
|
cancel(): void;
|
|
178
178
|
};
|
|
179
179
|
scheduleStalledRender(): void;
|
|
180
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Set the UI state and trigger a search.
|
|
182
|
+
* @param uiState The next UI state or a function computing it from the current state
|
|
183
|
+
* @param callOnStateChange private parameter used to know if the method is called from a state change
|
|
184
|
+
*/
|
|
185
|
+
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
|
|
181
186
|
getUiState(): TUiState;
|
|
182
187
|
onInternalStateChange: ((...args: any[]) => void) & {
|
|
183
188
|
wait(): Promise<void>;
|
package/es/lib/InstantSearch.js
CHANGED
|
@@ -28,10 +28,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
28
28
|
|
|
29
29
|
import algoliasearchHelper from 'algoliasearch-helper';
|
|
30
30
|
import EventEmitter from '@algolia/events';
|
|
31
|
-
import index
|
|
31
|
+
import index from "../widgets/index/index.js";
|
|
32
32
|
import version from "./version.js";
|
|
33
33
|
import createHelpers from "./createHelpers.js";
|
|
34
|
-
import { createDocumentationMessageGenerator, createDocumentationLink, defer, noop, warning,
|
|
34
|
+
import { createDocumentationMessageGenerator, createDocumentationLink, defer, noop, warning, setIndexHelperState } from "./utils/index.js";
|
|
35
35
|
import { createRouterMiddleware } from "../middlewares/createRouterMiddleware.js";
|
|
36
36
|
import { createMetadataMiddleware, isMetadataEnabled } from "../middlewares/createMetadataMiddleware.js";
|
|
37
37
|
var withUsage = createDocumentationMessageGenerator({
|
|
@@ -233,6 +233,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
233
233
|
var newMiddlewareList = middleware.map(function (fn) {
|
|
234
234
|
var newMiddleware = _objectSpread({
|
|
235
235
|
subscribe: noop,
|
|
236
|
+
started: noop,
|
|
236
237
|
unsubscribe: noop,
|
|
237
238
|
onStateChange: noop
|
|
238
239
|
}, fn({
|
|
@@ -251,6 +252,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
251
252
|
if (this.started) {
|
|
252
253
|
newMiddlewareList.forEach(function (m) {
|
|
253
254
|
m.subscribe();
|
|
255
|
+
m.started();
|
|
254
256
|
});
|
|
255
257
|
}
|
|
256
258
|
|
|
@@ -487,6 +489,10 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
487
489
|
// to init them directly after add
|
|
488
490
|
|
|
489
491
|
this.started = true;
|
|
492
|
+
this.middleware.forEach(function (_ref6) {
|
|
493
|
+
var instance = _ref6.instance;
|
|
494
|
+
instance.started();
|
|
495
|
+
});
|
|
490
496
|
}
|
|
491
497
|
/**
|
|
492
498
|
* Removes all widgets without triggering a search afterwards. This is an **EXPERIMENTAL** feature,
|
|
@@ -513,8 +519,8 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
513
519
|
this.mainHelper.removeAllListeners();
|
|
514
520
|
this.mainHelper = null;
|
|
515
521
|
this.helper = null;
|
|
516
|
-
this.middleware.forEach(function (
|
|
517
|
-
var instance =
|
|
522
|
+
this.middleware.forEach(function (_ref7) {
|
|
523
|
+
var instance = _ref7.instance;
|
|
518
524
|
instance.unsubscribe();
|
|
519
525
|
});
|
|
520
526
|
}
|
|
@@ -531,9 +537,19 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
531
537
|
}, this._stalledSearchDelay);
|
|
532
538
|
}
|
|
533
539
|
}
|
|
540
|
+
/**
|
|
541
|
+
* Set the UI state and trigger a search.
|
|
542
|
+
* @param uiState The next UI state or a function computing it from the current state
|
|
543
|
+
* @param callOnStateChange private parameter used to know if the method is called from a state change
|
|
544
|
+
*/
|
|
545
|
+
|
|
534
546
|
}, {
|
|
535
547
|
key: "setUiState",
|
|
536
548
|
value: function setUiState(uiState) {
|
|
549
|
+
var _this5 = this;
|
|
550
|
+
|
|
551
|
+
var callOnStateChange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
552
|
+
|
|
537
553
|
if (!this.mainHelper) {
|
|
538
554
|
throw new Error(withUsage('The `start` method needs to be called before `setUiState`.'));
|
|
539
555
|
} // We refresh the index UI state to update the local UI state that the
|
|
@@ -543,25 +559,22 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
543
559
|
this.mainIndex.refreshUiState();
|
|
544
560
|
var nextUiState = typeof uiState === 'function' ? uiState(this.mainIndex.getWidgetUiState({})) : uiState;
|
|
545
561
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
index: indexWidget,
|
|
552
|
-
indexUiState: nextIndexUiState
|
|
553
|
-
});
|
|
554
|
-
}
|
|
562
|
+
if (this.onStateChange && callOnStateChange) {
|
|
563
|
+
this.onStateChange({
|
|
564
|
+
uiState: nextUiState,
|
|
565
|
+
setUiState: function setUiState(finalUiState) {
|
|
566
|
+
setIndexHelperState(typeof finalUiState === 'function' ? finalUiState(nextUiState) : finalUiState, _this5.mainIndex);
|
|
555
567
|
|
|
556
|
-
|
|
557
|
-
uiState: nextIndexUiState
|
|
558
|
-
}));
|
|
559
|
-
indexWidget.getWidgets().filter(isIndexWidget).forEach(setIndexHelperState);
|
|
560
|
-
};
|
|
568
|
+
_this5.scheduleSearch();
|
|
561
569
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
570
|
+
_this5.onInternalStateChange();
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
} else {
|
|
574
|
+
setIndexHelperState(nextUiState, this.mainIndex);
|
|
575
|
+
this.scheduleSearch();
|
|
576
|
+
this.onInternalStateChange();
|
|
577
|
+
}
|
|
565
578
|
}
|
|
566
579
|
}, {
|
|
567
580
|
key: "getUiState",
|
|
@@ -14,9 +14,9 @@ export declare type PreparedTemplateProps<TTemplates extends Templates> = {
|
|
|
14
14
|
/**
|
|
15
15
|
* Prepares an object to be passed to the Template widget
|
|
16
16
|
*/
|
|
17
|
-
declare function prepareTemplateProps<TTemplates extends Templates>({ defaultTemplates, templates, templatesConfig, }: {
|
|
17
|
+
export declare function prepareTemplateProps<TTemplates extends Templates>({ defaultTemplates, templates, templatesConfig, }: {
|
|
18
18
|
defaultTemplates: TTemplates;
|
|
19
19
|
templates?: Partial<TTemplates>;
|
|
20
20
|
templatesConfig: TemplatesConfig;
|
|
21
21
|
}): PreparedTemplateProps<TTemplates>;
|
|
22
|
-
export
|
|
22
|
+
export {};
|
|
@@ -16,7 +16,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
16
16
|
|
|
17
17
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
18
18
|
|
|
19
|
-
import uniq from "
|
|
19
|
+
import { uniq } from "../utils/uniq.js";
|
|
20
20
|
|
|
21
21
|
function prepareTemplates( // can not use = {} here, since the template could have different constraints
|
|
22
22
|
defaultTemplates) {
|
|
@@ -42,7 +42,7 @@ defaultTemplates) {
|
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
function prepareTemplateProps(_ref) {
|
|
45
|
+
export function prepareTemplateProps(_ref) {
|
|
46
46
|
var defaultTemplates = _ref.defaultTemplates,
|
|
47
47
|
templates = _ref.templates,
|
|
48
48
|
templatesConfig = _ref.templatesConfig;
|
|
@@ -50,6 +50,4 @@ function prepareTemplateProps(_ref) {
|
|
|
50
50
|
return _objectSpread({
|
|
51
51
|
templatesConfig: templatesConfig
|
|
52
52
|
}, preparedTemplates);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default prepareTemplateProps;
|
|
53
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HoganOptions } from 'hogan.js';
|
|
2
2
|
import type { Templates, HoganHelpers } from '../../types';
|
|
3
|
-
import type { BindEventForHits, SendEventForHits } from '
|
|
4
|
-
declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, sendEvent, }: {
|
|
3
|
+
import type { BindEventForHits, SendEventForHits } from '../utils/createSendEventForHits';
|
|
4
|
+
export declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, sendEvent, }: {
|
|
5
5
|
templates: Templates;
|
|
6
6
|
templateKey: string;
|
|
7
7
|
compileOptions?: HoganOptions;
|
|
@@ -10,4 +10,3 @@ declare function renderTemplate({ templates, templateKey, compileOptions, helper
|
|
|
10
10
|
bindEvent?: BindEventForHits;
|
|
11
11
|
sendEvent?: SendEventForHits;
|
|
12
12
|
}): string | import("preact").VNode<{}> | import("preact").VNode<{}>[];
|
|
13
|
-
export default renderTemplate;
|
|
@@ -7,8 +7,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
7
7
|
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; }
|
|
8
8
|
|
|
9
9
|
import hogan from 'hogan.js';
|
|
10
|
-
import { Highlight, ReverseHighlight, ReverseSnippet, Snippet } from "../../helpers/components/index.js";
|
|
11
10
|
import { html } from 'htm/preact';
|
|
11
|
+
import { Highlight, ReverseHighlight, ReverseSnippet, Snippet } from "../../helpers/components/index.js";
|
|
12
12
|
|
|
13
13
|
// We add all our template helper methods to the template as lambdas. Note
|
|
14
14
|
// that lambdas in Mustache are supposed to accept a second argument of
|
|
@@ -33,7 +33,7 @@ function transformHelpersToHogan() {
|
|
|
33
33
|
}, {});
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function renderTemplate(_ref) {
|
|
36
|
+
export function renderTemplate(_ref) {
|
|
37
37
|
var templates = _ref.templates,
|
|
38
38
|
templateKey = _ref.templateKey,
|
|
39
39
|
compileOptions = _ref.compileOptions,
|
|
@@ -67,6 +67,4 @@ function renderTemplate(_ref) {
|
|
|
67
67
|
})).replace(/[ \n\r\t\f\xA0]+/g, function (spaces) {
|
|
68
68
|
return spaces.replace(/(^|\xA0+)[^\xA0]+/g, '$1 ');
|
|
69
69
|
}).trim();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default renderTemplate;
|
|
70
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function capitalize(text: string): string;
|
|
2
|
-
export default capitalize;
|
|
1
|
+
export declare function capitalize(text: string): string;
|
|
@@ -18,7 +18,7 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
|
|
|
18
18
|
|
|
19
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
20
|
|
|
21
|
-
import capitalize from "./capitalize.js";
|
|
21
|
+
import { capitalize } from "./capitalize.js";
|
|
22
22
|
import { warning } from "./logger.js";
|
|
23
23
|
import { keys } from "./typedObject.js"; // Some connectors are responsible for multiple widgets so we need
|
|
24
24
|
// to map them.
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { Renderer } from '../../types/connector';
|
|
2
|
-
declare function checkRendering<TRenderOptions, TWidgetParams>(rendering: Renderer<TRenderOptions, TWidgetParams>, usage: string): void;
|
|
3
|
-
export default checkRendering;
|
|
2
|
+
export declare function checkRendering<TRenderOptions, TWidgetParams>(rendering: Renderer<TRenderOptions, TWidgetParams>, usage: string): void;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import getObjectType from "./getObjectType.js";
|
|
2
|
-
|
|
3
|
-
function checkRendering(rendering, usage) {
|
|
1
|
+
import { getObjectType } from "./getObjectType.js";
|
|
2
|
+
export function checkRendering(rendering, usage) {
|
|
4
3
|
if (rendering === undefined || typeof rendering !== 'function') {
|
|
5
4
|
throw new Error("The render function is not valid (received type ".concat(getObjectType(rendering), ").\n\n").concat(usage));
|
|
6
5
|
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default checkRendering;
|
|
6
|
+
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
|
|
1
|
+
import type { AlgoliaSearchHelper, SearchParameters } from 'algoliasearch-helper';
|
|
2
2
|
/**
|
|
3
3
|
* Clears the refinements of a SearchParameters object based on rules provided.
|
|
4
4
|
* The included attributes list is applied before the excluded attributes list. If the list
|
|
5
5
|
* is not provided, this list of all the currently refined attributes is used as included attributes.
|
|
6
|
-
* @
|
|
7
|
-
* @param {Helper} $0.helper instance of the Helper
|
|
8
|
-
* @param {string[]} [$0.attributesToClear = []] list of parameters to clear
|
|
9
|
-
* @returns {SearchParameters} search parameters with refinements cleared
|
|
6
|
+
* @returns search parameters with refinements cleared
|
|
10
7
|
*/
|
|
11
|
-
declare function clearRefinements({ helper, attributesToClear, }: {
|
|
8
|
+
export declare function clearRefinements({ helper, attributesToClear, }: {
|
|
12
9
|
helper: AlgoliaSearchHelper;
|
|
13
10
|
attributesToClear?: string[];
|
|
14
|
-
}):
|
|
15
|
-
export default clearRefinements;
|
|
11
|
+
}): SearchParameters;
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
* Clears the refinements of a SearchParameters object based on rules provided.
|
|
3
3
|
* The included attributes list is applied before the excluded attributes list. If the list
|
|
4
4
|
* is not provided, this list of all the currently refined attributes is used as included attributes.
|
|
5
|
-
* @
|
|
6
|
-
* @param {Helper} $0.helper instance of the Helper
|
|
7
|
-
* @param {string[]} [$0.attributesToClear = []] list of parameters to clear
|
|
8
|
-
* @returns {SearchParameters} search parameters with refinements cleared
|
|
5
|
+
* @returns search parameters with refinements cleared
|
|
9
6
|
*/
|
|
10
|
-
function clearRefinements(_ref) {
|
|
7
|
+
export function clearRefinements(_ref) {
|
|
11
8
|
var helper = _ref.helper,
|
|
12
9
|
_ref$attributesToClea = _ref.attributesToClear,
|
|
13
10
|
attributesToClear = _ref$attributesToClea === void 0 ? [] : _ref$attributesToClea;
|
|
@@ -37,6 +34,4 @@ function clearRefinements(_ref) {
|
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
return finalState;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default clearRefinements;
|
|
37
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { HighlightedParts } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export declare function concatHighlightedParts(parts: HighlightedParts[]): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TAG_REPLACEMENT } from "./escape-highlight.js";
|
|
2
|
-
export
|
|
2
|
+
export function concatHighlightedParts(parts) {
|
|
3
3
|
var highlightPreTag = TAG_REPLACEMENT.highlightPreTag,
|
|
4
4
|
highlightPostTag = TAG_REPLACEMENT.highlightPostTag;
|
|
5
5
|
return parts.map(function (part) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
|
-
import isFacetRefined from "./isFacetRefined.js";
|
|
3
|
+
import { isFacetRefined } from "./isFacetRefined.js";
|
|
4
4
|
export function createSendEventForFacet(_ref) {
|
|
5
5
|
var instantSearchInstance = _ref.instantSearchInstance,
|
|
6
6
|
helper = _ref.helper,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*/
|
|
4
1
|
import type { InstantSearch, Hit } from '../../types';
|
|
5
2
|
declare type BuiltInSendEventForHits = (eventType: string, hits: Hit | Hit[], eventName?: string) => void;
|
|
6
3
|
declare type CustomSendEventForHits = (customPayload: any) => void;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @jest-environment jsdom
|
|
5
|
-
*/
|
|
6
3
|
import { serializePayload } from "./serializer.js";
|
|
7
4
|
|
|
8
5
|
function chunk(arr) {
|
package/es/lib/utils/defer.d.ts
CHANGED
package/es/lib/utils/defer.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
var nextMicroTask = Promise.resolve();
|
|
2
|
-
|
|
3
|
-
var defer = function defer(callback) {
|
|
2
|
+
export function defer(callback) {
|
|
4
3
|
var progress = null;
|
|
5
4
|
var cancelled = false;
|
|
6
5
|
|
|
@@ -42,6 +41,4 @@ var defer = function defer(callback) {
|
|
|
42
41
|
};
|
|
43
42
|
|
|
44
43
|
return fn;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default defer;
|
|
44
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function hasDetectedInsightsClient(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { safelyRunOnBrowser } from "./safelyRunOnBrowser.js";
|
|
2
|
-
export
|
|
2
|
+
export function hasDetectedInsightsClient() {
|
|
3
3
|
return safelyRunOnBrowser(function (_ref) {
|
|
4
4
|
var window = _ref.window;
|
|
5
5
|
return Boolean(window.AlgoliaAnalyticsObject);
|
|
@@ -2,7 +2,7 @@ declare type WidgetParam = {
|
|
|
2
2
|
name: string;
|
|
3
3
|
connector?: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare
|
|
5
|
+
export declare function createDocumentationLink({ name, connector, }: WidgetParam): string;
|
|
6
6
|
declare type DocumentationMessageGenerator = (message?: string) => string;
|
|
7
|
-
export declare
|
|
7
|
+
export declare function createDocumentationMessageGenerator(...widgets: WidgetParam[]): DocumentationMessageGenerator;
|
|
8
8
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function createDocumentationLink(_ref) {
|
|
2
2
|
var name = _ref.name,
|
|
3
3
|
_ref$connector = _ref.connector,
|
|
4
4
|
connector = _ref$connector === void 0 ? false : _ref$connector;
|
|
5
5
|
return ['https://www.algolia.com/doc/api-reference/widgets/', name, '/js/', connector ? '#connector' : ''].join('');
|
|
6
|
-
}
|
|
7
|
-
export
|
|
6
|
+
}
|
|
7
|
+
export function createDocumentationMessageGenerator() {
|
|
8
8
|
for (var _len = arguments.length, widgets = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
9
|
widgets[_key] = arguments[_key];
|
|
10
10
|
}
|
|
@@ -15,4 +15,4 @@ export var createDocumentationMessageGenerator = function createDocumentationMes
|
|
|
15
15
|
return function (message) {
|
|
16
16
|
return [message, "See documentation: ".concat(links)].filter(Boolean).join('\n\n');
|
|
17
17
|
};
|
|
18
|
-
}
|
|
18
|
+
}
|
|
@@ -6,8 +6,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
6
6
|
|
|
7
7
|
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; }
|
|
8
8
|
|
|
9
|
-
import escape from "./escape.js";
|
|
10
|
-
import isPlainObject from "./isPlainObject.js";
|
|
9
|
+
import { escape } from "./escape-html.js";
|
|
10
|
+
import { isPlainObject } from "./isPlainObject.js";
|
|
11
11
|
export var TAG_PLACEHOLDER = {
|
|
12
12
|
highlightPreTag: '__ais-highlight__',
|
|
13
13
|
highlightPostTag: '__/ais-highlight__'
|
|
@@ -6,5 +6,9 @@
|
|
|
6
6
|
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
|
7
7
|
* corresponding HTML entities.
|
|
8
8
|
*/
|
|
9
|
-
declare function escape(value: string): string;
|
|
10
|
-
|
|
9
|
+
export declare function escape(value: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
|
|
12
|
+
* characters.
|
|
13
|
+
*/
|
|
14
|
+
export declare function unescape(value: string): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This implementation is taken from Lodash implementation.
|
|
3
|
+
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js
|
|
4
|
+
*/
|
|
5
|
+
// Used to map characters to HTML entities.
|
|
6
|
+
var htmlEntities = {
|
|
7
|
+
'&': '&',
|
|
8
|
+
'<': '<',
|
|
9
|
+
'>': '>',
|
|
10
|
+
'"': '"',
|
|
11
|
+
"'": '''
|
|
12
|
+
}; // Used to match HTML entities and HTML characters.
|
|
13
|
+
|
|
14
|
+
var regexUnescapedHtml = /[&<>"']/g;
|
|
15
|
+
var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);
|
|
16
|
+
/**
|
|
17
|
+
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
|
18
|
+
* corresponding HTML entities.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export function escape(value) {
|
|
22
|
+
return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) {
|
|
23
|
+
return htmlEntities[character];
|
|
24
|
+
}) : value;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* This implementation is taken from Lodash implementation.
|
|
28
|
+
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
|
|
29
|
+
*/
|
|
30
|
+
// Used to map HTML entities to characters.
|
|
31
|
+
|
|
32
|
+
var htmlCharacters = {
|
|
33
|
+
'&': '&',
|
|
34
|
+
'<': '<',
|
|
35
|
+
'>': '>',
|
|
36
|
+
'"': '"',
|
|
37
|
+
''': "'"
|
|
38
|
+
}; // Used to match HTML entities and HTML characters.
|
|
39
|
+
|
|
40
|
+
var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
|
|
41
|
+
var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
|
|
42
|
+
/**
|
|
43
|
+
* Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
|
|
44
|
+
* characters.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
export function unescape(value) {
|
|
48
|
+
return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
|
|
49
|
+
return htmlCharacters[character];
|
|
50
|
+
}) : value;
|
|
51
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type FacetValue = string | number | undefined;
|
|
1
|
+
declare type FacetValue = string | number | boolean | undefined;
|
|
2
2
|
export declare function unescapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
|
|
3
3
|
export declare function escapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
|
|
4
4
|
export {};
|
package/es/lib/utils/find.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function find<TItem>(items: TItem[], predicate: (value: TItem, index: number, obj: TItem[]) => boolean): TItem | undefined;
|
|
2
|
-
export default find;
|
|
1
|
+
export declare function find<TItem>(items: TItem[], predicate: (value: TItem, index: number, obj: TItem[]) => boolean): TItem | undefined;
|
package/es/lib/utils/find.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// was decided as too risky.
|
|
5
5
|
// @MAJOR Replace with the native `Array.prototype.find` method
|
|
6
6
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
|
7
|
-
function find(items, predicate) {
|
|
7
|
+
export function find(items, predicate) {
|
|
8
8
|
var value;
|
|
9
9
|
|
|
10
10
|
for (var i = 0; i < items.length; i++) {
|
|
@@ -16,6 +16,4 @@ function find(items, predicate) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
return undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default find;
|
|
19
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare function findIndex<TItem>(array: TItem[], comparator: (value: TItem) => boolean): number;
|
|
2
|
-
export default findIndex;
|
|
1
|
+
export declare function findIndex<TItem>(array: TItem[], comparator: (value: TItem) => boolean): number;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// was decided as too risky.
|
|
5
5
|
// @MAJOR Replace with the native `Array.prototype.findIndex` method
|
|
6
6
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
|
|
7
|
-
function findIndex(array, comparator) {
|
|
7
|
+
export function findIndex(array, comparator) {
|
|
8
8
|
if (!Array.isArray(array)) {
|
|
9
9
|
return -1;
|
|
10
10
|
}
|
|
@@ -16,6 +16,4 @@ function findIndex(array, comparator) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
return -1;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default findIndex;
|
|
19
|
+
}
|
|
@@ -7,5 +7,4 @@
|
|
|
7
7
|
* @return {HTMLElement} Container node
|
|
8
8
|
* @throws Error when the type is not correct
|
|
9
9
|
*/
|
|
10
|
-
declare function getContainerNode(selectorOrHTMLElement: string | HTMLElement): HTMLElement;
|
|
11
|
-
export default getContainerNode;
|
|
10
|
+
export declare function getContainerNode(selectorOrHTMLElement: string | HTMLElement): HTMLElement;
|