instantsearch.js 4.86.1 → 4.87.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/connectors/autocomplete/connectAutocomplete.js +13 -5
- package/cjs/connectors/chat/connectChat.js +89 -17
- package/cjs/connectors/filter-suggestions/connectFilterSuggestions.js +255 -0
- package/cjs/connectors/index.js +7 -0
- package/cjs/connectors/index.umd.js +7 -0
- package/cjs/lib/chat/chat.js +3 -3
- package/cjs/lib/chat/index.js +5 -2
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/autocomplete/autocomplete.js +15 -6
- package/cjs/widgets/chat/chat.js +32 -3
- package/cjs/widgets/filter-suggestions/filter-suggestions.js +131 -0
- package/cjs/widgets/index.js +7 -0
- package/cjs/widgets/index.umd.js +7 -0
- package/dist/instantsearch.development.d.ts +885 -72
- package/dist/instantsearch.development.js +731 -184
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +885 -72
- package/dist/instantsearch.production.min.d.ts +885 -72
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/autocomplete/connectAutocomplete.d.ts +10 -0
- package/es/connectors/autocomplete/connectAutocomplete.js +13 -5
- package/es/connectors/chat/connectChat.d.ts +10 -0
- package/es/connectors/chat/connectChat.js +89 -17
- package/es/connectors/filter-suggestions/connectFilterSuggestions.d.ts +95 -0
- package/es/connectors/filter-suggestions/connectFilterSuggestions.js +249 -0
- package/es/connectors/index.d.ts +1 -0
- package/es/connectors/index.js +2 -1
- package/es/connectors/index.umd.d.ts +1 -0
- package/es/connectors/index.umd.js +2 -1
- package/es/lib/chat/chat.d.ts +1 -1
- package/es/lib/chat/chat.js +3 -3
- package/es/lib/chat/index.d.ts +3 -0
- package/es/lib/chat/index.js +4 -1
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/widgets/autocomplete/autocomplete.d.ts +2 -1
- package/es/widgets/autocomplete/autocomplete.js +15 -6
- package/es/widgets/chat/chat.d.ts +8 -0
- package/es/widgets/chat/chat.js +33 -4
- package/es/widgets/filter-suggestions/filter-suggestions.d.ts +689 -0
- package/es/widgets/filter-suggestions/filter-suggestions.js +124 -0
- package/es/widgets/index.d.ts +1 -0
- package/es/widgets/index.js +2 -1
- package/es/widgets/index.umd.d.ts +1 -0
- package/es/widgets/index.umd.js +2 -1
- package/package.json +6 -6
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
8
|
+
import { createFilterSuggestionsComponent } from 'instantsearch-ui-components';
|
|
9
|
+
import { h, render } from 'preact';
|
|
10
|
+
import TemplateComponent from "../../components/Template/Template.js";
|
|
11
|
+
import connectFilterSuggestions from "../../connectors/filter-suggestions/connectFilterSuggestions.js";
|
|
12
|
+
import { prepareTemplateProps } from "../../lib/templating/index.js";
|
|
13
|
+
import { getContainerNode, createDocumentationMessageGenerator } from "../../lib/utils/index.js";
|
|
14
|
+
var withUsage = createDocumentationMessageGenerator({
|
|
15
|
+
name: 'filter-suggestions'
|
|
16
|
+
});
|
|
17
|
+
var FilterSuggestions = createFilterSuggestionsComponent({
|
|
18
|
+
createElement: h,
|
|
19
|
+
Fragment: 'fragment'
|
|
20
|
+
});
|
|
21
|
+
var createRenderer = function createRenderer(_ref) {
|
|
22
|
+
var renderState = _ref.renderState,
|
|
23
|
+
cssClasses = _ref.cssClasses,
|
|
24
|
+
containerNode = _ref.containerNode,
|
|
25
|
+
templates = _ref.templates,
|
|
26
|
+
maxSuggestions = _ref.maxSuggestions;
|
|
27
|
+
return function (props, isFirstRendering) {
|
|
28
|
+
var suggestions = props.suggestions,
|
|
29
|
+
isLoading = props.isLoading,
|
|
30
|
+
refine = props.refine,
|
|
31
|
+
instantSearchInstance = props.instantSearchInstance;
|
|
32
|
+
var headerTemplate = templates.header === false ? undefined : templates.header;
|
|
33
|
+
if (isFirstRendering) {
|
|
34
|
+
renderState.templateProps = prepareTemplateProps({
|
|
35
|
+
defaultTemplates: {},
|
|
36
|
+
templatesConfig: instantSearchInstance.templatesConfig,
|
|
37
|
+
templates: {
|
|
38
|
+
header: headerTemplate,
|
|
39
|
+
item: templates.item,
|
|
40
|
+
empty: templates.empty
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var headerComponent;
|
|
46
|
+
if (templates.header === false) {
|
|
47
|
+
headerComponent = false;
|
|
48
|
+
} else if (headerTemplate) {
|
|
49
|
+
headerComponent = function headerComponent(headerProps) {
|
|
50
|
+
return h(TemplateComponent, _extends({}, renderState.templateProps, {
|
|
51
|
+
templateKey: "header",
|
|
52
|
+
rootTagName: "div",
|
|
53
|
+
data: headerProps
|
|
54
|
+
}));
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
var itemComponent = templates.item ? function (itemProps) {
|
|
58
|
+
return h(TemplateComponent, _extends({}, renderState.templateProps, {
|
|
59
|
+
templateKey: "item",
|
|
60
|
+
rootTagName: "fragment",
|
|
61
|
+
data: itemProps
|
|
62
|
+
}));
|
|
63
|
+
} : undefined;
|
|
64
|
+
var emptyComponent = templates.empty ? function (emptyProps) {
|
|
65
|
+
return h(TemplateComponent, _extends({}, renderState.templateProps, {
|
|
66
|
+
templateKey: "empty",
|
|
67
|
+
rootTagName: "div",
|
|
68
|
+
data: emptyProps
|
|
69
|
+
}));
|
|
70
|
+
} : undefined;
|
|
71
|
+
var uiProps = {
|
|
72
|
+
suggestions: suggestions,
|
|
73
|
+
isLoading: isLoading,
|
|
74
|
+
refine: refine,
|
|
75
|
+
skeletonCount: maxSuggestions,
|
|
76
|
+
itemComponent: itemComponent,
|
|
77
|
+
headerComponent: headerComponent,
|
|
78
|
+
emptyComponent: emptyComponent
|
|
79
|
+
};
|
|
80
|
+
render(h(FilterSuggestions, _extends({
|
|
81
|
+
classNames: cssClasses
|
|
82
|
+
}, uiProps)), containerNode);
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export default (function filterSuggestions(widgetParams) {
|
|
86
|
+
var _ref2 = widgetParams || {},
|
|
87
|
+
container = _ref2.container,
|
|
88
|
+
_ref2$templates = _ref2.templates,
|
|
89
|
+
templates = _ref2$templates === void 0 ? {} : _ref2$templates,
|
|
90
|
+
_ref2$cssClasses = _ref2.cssClasses,
|
|
91
|
+
cssClasses = _ref2$cssClasses === void 0 ? {} : _ref2$cssClasses,
|
|
92
|
+
agentId = _ref2.agentId,
|
|
93
|
+
attributes = _ref2.attributes,
|
|
94
|
+
maxSuggestions = _ref2.maxSuggestions,
|
|
95
|
+
debounceMs = _ref2.debounceMs,
|
|
96
|
+
hitsToSample = _ref2.hitsToSample,
|
|
97
|
+
transformItems = _ref2.transformItems,
|
|
98
|
+
transport = _ref2.transport;
|
|
99
|
+
if (!container) {
|
|
100
|
+
throw new Error(withUsage('The `container` option is required.'));
|
|
101
|
+
}
|
|
102
|
+
var containerNode = getContainerNode(container);
|
|
103
|
+
var specializedRenderer = createRenderer({
|
|
104
|
+
containerNode: containerNode,
|
|
105
|
+
cssClasses: cssClasses,
|
|
106
|
+
renderState: {},
|
|
107
|
+
templates: templates,
|
|
108
|
+
maxSuggestions: maxSuggestions
|
|
109
|
+
});
|
|
110
|
+
var makeWidget = connectFilterSuggestions(specializedRenderer, function () {
|
|
111
|
+
return render(null, containerNode);
|
|
112
|
+
});
|
|
113
|
+
return _objectSpread(_objectSpread({}, makeWidget({
|
|
114
|
+
agentId: agentId,
|
|
115
|
+
attributes: attributes,
|
|
116
|
+
maxSuggestions: maxSuggestions,
|
|
117
|
+
debounceMs: debounceMs,
|
|
118
|
+
hitsToSample: hitsToSample,
|
|
119
|
+
transformItems: transformItems,
|
|
120
|
+
transport: transport
|
|
121
|
+
})), {}, {
|
|
122
|
+
$$widgetType: 'ais.filterSuggestions'
|
|
123
|
+
});
|
|
124
|
+
});
|
package/es/widgets/index.d.ts
CHANGED
|
@@ -43,3 +43,4 @@ export { default as voiceSearch } from './voice-search/voice-search';
|
|
|
43
43
|
export { default as frequentlyBoughtTogether } from './frequently-bought-together/frequently-bought-together';
|
|
44
44
|
export { default as lookingSimilar } from './looking-similar/looking-similar';
|
|
45
45
|
export { default as chat } from './chat/chat';
|
|
46
|
+
export { default as filterSuggestions } from './filter-suggestions/filter-suggestions';
|
package/es/widgets/index.js
CHANGED
|
@@ -47,4 +47,5 @@ export { default as trendingItems } from "./trending-items/trending-items.js";
|
|
|
47
47
|
export { default as voiceSearch } from "./voice-search/voice-search.js";
|
|
48
48
|
export { default as frequentlyBoughtTogether } from "./frequently-bought-together/frequently-bought-together.js";
|
|
49
49
|
export { default as lookingSimilar } from "./looking-similar/looking-similar.js";
|
|
50
|
-
export { default as chat } from "./chat/chat.js";
|
|
50
|
+
export { default as chat } from "./chat/chat.js";
|
|
51
|
+
export { default as filterSuggestions } from "./filter-suggestions/filter-suggestions.js";
|
|
@@ -43,3 +43,4 @@ export { default as voiceSearch } from './voice-search/voice-search';
|
|
|
43
43
|
export { default as frequentlyBoughtTogether } from './frequently-bought-together/frequently-bought-together';
|
|
44
44
|
export { default as lookingSimilar } from './looking-similar/looking-similar';
|
|
45
45
|
export declare const chat: () => never;
|
|
46
|
+
export { default as filterSuggestions } from './filter-suggestions/filter-suggestions';
|
package/es/widgets/index.umd.js
CHANGED
|
@@ -49,4 +49,5 @@ export { default as frequentlyBoughtTogether } from "./frequently-bought-togethe
|
|
|
49
49
|
export { default as lookingSimilar } from "./looking-similar/looking-similar.js";
|
|
50
50
|
export var chat = function chat() {
|
|
51
51
|
throw new Error("\"chat\" is not available from the UMD build.\n\nPlease use InstantSearch.js with a packaging system:\nhttps://www.algolia.com/doc/guides/building-search-ui/installation/js/#with-a-packaging-system");
|
|
52
|
-
};
|
|
52
|
+
};
|
|
53
|
+
export { default as filterSuggestions } from "./filter-suggestions/filter-suggestions.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.87.0",
|
|
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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"algoliasearch-helper": "3.27.0",
|
|
36
36
|
"hogan.js": "^3.0.2",
|
|
37
37
|
"htm": "^3.0.0",
|
|
38
|
-
"instantsearch-ui-components": "0.
|
|
38
|
+
"instantsearch-ui-components": "0.17.0",
|
|
39
39
|
"preact": "^10.10.0",
|
|
40
40
|
"qs": "^6.5.1",
|
|
41
41
|
"react": ">= 0.14.0",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"watch:es": "yarn --silent build:es:base --watch"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@instantsearch/mocks": "1.
|
|
64
|
-
"@instantsearch/tests": "1.
|
|
65
|
-
"@instantsearch/testutils": "1.
|
|
63
|
+
"@instantsearch/mocks": "1.88.0",
|
|
64
|
+
"@instantsearch/tests": "1.88.0",
|
|
65
|
+
"@instantsearch/testutils": "1.77.0",
|
|
66
66
|
"@storybook/html": "5.3.9",
|
|
67
67
|
"@types/scriptjs": "0.0.2",
|
|
68
68
|
"algoliasearch": "5.1.1",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"scriptjs": "2.5.9",
|
|
71
71
|
"webpack": "4.47.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "c796f45db6153fb5fa627b90e334a572bbf31e33"
|
|
74
74
|
}
|