algolia-experiences 1.7.3 → 1.8.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.
@@ -1,4 +1,4 @@
1
- /*! algolia-experiences 1.7.3 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! algolia-experiences 1.8.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (factory) {
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  factory();
@@ -9930,7 +9930,7 @@
9930
9930
  };
9931
9931
  }
9932
9932
 
9933
- var version = '4.92.1';
9933
+ var version = '4.94.0';
9934
9934
 
9935
9935
  function hydrateSearchClient(client, results) {
9936
9936
  if (!results) {
@@ -13926,6 +13926,10 @@
13926
13926
  _this.setState({
13927
13927
  focused: true
13928
13928
  });
13929
+ }), _define_property(_this, "onAiModeClick", function(event) {
13930
+ var _this_props_onAiModeClick, _this_props;
13931
+ event.preventDefault();
13932
+ (_this_props_onAiModeClick = (_this_props = _this.props).onAiModeClick) === null || _this_props_onAiModeClick === void 0 ? void 0 : _this_props_onAiModeClick.call(_this_props, _this.state.query);
13929
13933
  });
13930
13934
  return _this;
13931
13935
  }
@@ -13961,7 +13965,7 @@
13961
13965
  {
13962
13966
  key: "render",
13963
13967
  value: function render() {
13964
- var _this_props = this.props, cssClasses = _this_props.cssClasses, placeholder = _this_props.placeholder, autofocus = _this_props.autofocus, showSubmit = _this_props.showSubmit, showReset = _this_props.showReset, showLoadingIndicator = _this_props.showLoadingIndicator, templates = _this_props.templates, isSearchStalled = _this_props.isSearchStalled, ariaLabel = _this_props.ariaLabel, inputProps = _this_props.inputProps;
13968
+ var _this_props = this.props, cssClasses = _this_props.cssClasses, placeholder = _this_props.placeholder, autofocus = _this_props.autofocus, showSubmit = _this_props.showSubmit, showReset = _this_props.showReset, showLoadingIndicator = _this_props.showLoadingIndicator, templates = _this_props.templates, isSearchStalled = _this_props.isSearchStalled, ariaLabel = _this_props.ariaLabel, inputProps = _this_props.inputProps, onAiModeClick = _this_props.onAiModeClick;
13965
13969
  return /*#__PURE__*/ h$1("div", {
13966
13970
  className: cssClasses.root
13967
13971
  }, /*#__PURE__*/ h$1("form", {
@@ -14029,6 +14033,19 @@
14029
14033
  data: {
14030
14034
  cssClasses: cssClasses
14031
14035
  }
14036
+ }), onAiModeClick && /*#__PURE__*/ h$1(Template, {
14037
+ templateKey: "aiMode",
14038
+ rootTagName: "button",
14039
+ rootProps: {
14040
+ className: cssClasses.aiModeButton,
14041
+ type: 'button',
14042
+ title: 'AI Mode',
14043
+ onClick: this.onAiModeClick
14044
+ },
14045
+ templates: templates,
14046
+ data: {
14047
+ cssClasses: cssClasses
14048
+ }
14032
14049
  })));
14033
14050
  }
14034
14051
  }
@@ -14756,9 +14773,9 @@
14756
14773
  return 'No results';
14757
14774
  },
14758
14775
  item: function item(data) {
14759
- return JSON.stringify(omit(data, [
14776
+ return /*#__PURE__*/ h$1(p$1, null, JSON.stringify(omit(data, [
14760
14777
  '__hitIndex'
14761
- ]), null, 2);
14778
+ ]), null, 2));
14762
14779
  }
14763
14780
  };
14764
14781
 
@@ -15523,9 +15540,9 @@
15523
15540
  return 'Show more results';
15524
15541
  },
15525
15542
  item: function item(data) {
15526
- return JSON.stringify(omit(data, [
15543
+ return /*#__PURE__*/ h$1(p$1, null, JSON.stringify(omit(data, [
15527
15544
  '__hitIndex'
15528
- ]), null, 2);
15545
+ ]), null, 2));
15529
15546
  }
15530
15547
  };
15531
15548
 
@@ -18807,6 +18824,30 @@
18807
18824
  }
18808
18825
 
18809
18826
  var defaultTemplate = {
18827
+ aiMode: function aiMode(param) {
18828
+ var cssClasses = param.cssClasses;
18829
+ return /*#__PURE__*/ h$1(p$1, null, /*#__PURE__*/ h$1("svg", {
18830
+ className: cssClasses.aiModeIcon,
18831
+ xmlns: "http://www.w3.org/2000/svg",
18832
+ fill: "none",
18833
+ viewBox: "0 0 20 20",
18834
+ width: "16",
18835
+ height: "16",
18836
+ "aria-hidden": "true"
18837
+ }, /*#__PURE__*/ h$1("path", {
18838
+ fill: "currentColor",
18839
+ "fill-rule": "evenodd",
18840
+ d: "M10 1.875c.27 0 .51.173.594.43l1.593 4.844a1.043 1.043 0 0 0 .664.664l4.844 1.593a.625.625 0 0 1 0 1.188l-4.844 1.593a1.043 1.043 0 0 0-.664.664l-1.593 4.844a.625.625 0 0 1-1.188 0l-1.593-4.844a1.042 1.042 0 0 0-.664-.664l-4.844-1.593a.625.625 0 0 1 0-1.188l4.844-1.593a1.042 1.042 0 0 0 .664-.664l1.593-4.844a.625.625 0 0 1 .594-.43ZM9 7.539A2.292 2.292 0 0 1 7.54 9L4.5 10l3.04 1A2.292 2.292 0 0 1 9 12.46l1 3.04 1-3.04A2.293 2.293 0 0 1 12.46 11l3.04-1-3.04-1A2.292 2.292 0 0 1 11 7.54L10 4.5 9 7.54ZM4.167 1.875c.345 0 .625.28.625.625v3.333a.625.625 0 0 1-1.25 0V2.5c0-.345.28-.625.625-.625ZM15.833 13.542c.345 0 .625.28.625.625V17.5a.625.625 0 1 1-1.25 0v-3.333c0-.345.28-.625.625-.625Z",
18841
+ "clip-rule": "evenodd"
18842
+ }), /*#__PURE__*/ h$1("path", {
18843
+ fill: "currentColor",
18844
+ "fill-rule": "evenodd",
18845
+ d: "M1.875 4.167c0-.346.28-.625.625-.625h3.333a.625.625 0 1 1 0 1.25H2.5a.625.625 0 0 1-.625-.625ZM13.542 15.833c0-.345.28-.625.625-.625H17.5a.625.625 0 0 1 0 1.25h-3.333a.625.625 0 0 1-.625-.625Z",
18846
+ "clip-rule": "evenodd"
18847
+ })), /*#__PURE__*/ h$1("span", {
18848
+ className: cssClasses.aiModeLabel
18849
+ }, "AI Mode"));
18850
+ },
18810
18851
  reset: function reset(param) {
18811
18852
  var cssClasses = param.cssClasses;
18812
18853
  return /*#__PURE__*/ h$1("svg", {
@@ -19068,10 +19109,26 @@
19068
19109
  name: 'search-box'
19069
19110
  });
19070
19111
  var suit$3 = component('SearchBox');
19112
+ var aiModeSuit = component('AiModeButton');
19071
19113
  var renderer$5 = function renderer(param) {
19072
- var containerNode = param.containerNode, cssClasses = param.cssClasses, placeholder = param.placeholder, templates = param.templates, autofocus = param.autofocus, searchAsYouType = param.searchAsYouType, ignoreCompositionEvents = param.ignoreCompositionEvents, showReset = param.showReset, showSubmit = param.showSubmit, showLoadingIndicator = param.showLoadingIndicator;
19114
+ var containerNode = param.containerNode, cssClasses = param.cssClasses, placeholder = param.placeholder, templates = param.templates, autofocus = param.autofocus, searchAsYouType = param.searchAsYouType, ignoreCompositionEvents = param.ignoreCompositionEvents, showReset = param.showReset, showSubmit = param.showSubmit, showLoadingIndicator = param.showLoadingIndicator, aiMode = param.aiMode;
19073
19115
  return function(param) {
19074
- var refine = param.refine, query = param.query, isSearchStalled = param.isSearchStalled;
19116
+ var refine = param.refine, query = param.query, isSearchStalled = param.isSearchStalled, instantSearchInstance = param.instantSearchInstance;
19117
+ var onAiModeClick = aiMode ? function(currentQuery) {
19118
+ var _instantSearchInstance_renderState_indexId;
19119
+ var indexId = instantSearchInstance.mainIndex.getIndexId();
19120
+ var chatRenderState = (_instantSearchInstance_renderState_indexId = instantSearchInstance.renderState[indexId]) === null || _instantSearchInstance_renderState_indexId === void 0 ? void 0 : _instantSearchInstance_renderState_indexId.chat;
19121
+ if (chatRenderState) {
19122
+ var _chatRenderState_setOpen;
19123
+ (_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
19124
+ if (currentQuery.trim()) {
19125
+ var _chatRenderState_sendMessage;
19126
+ (_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
19127
+ text: currentQuery
19128
+ });
19129
+ }
19130
+ }
19131
+ } : undefined;
19075
19132
  P(/*#__PURE__*/ h$1(SearchBox, {
19076
19133
  query: query,
19077
19134
  placeholder: placeholder,
@@ -19084,12 +19141,13 @@
19084
19141
  showReset: showReset,
19085
19142
  showLoadingIndicator: showLoadingIndicator,
19086
19143
  isSearchStalled: isSearchStalled,
19087
- cssClasses: cssClasses
19144
+ cssClasses: cssClasses,
19145
+ onAiModeClick: onAiModeClick
19088
19146
  }), containerNode);
19089
19147
  };
19090
19148
  };
19091
19149
  var searchBox = function searchBox(widgetParams) {
19092
- var _ref = widgetParams || {}, container = _ref.container, _ref_placeholder = _ref.placeholder, placeholder = _ref_placeholder === void 0 ? '' : _ref_placeholder, tmp = _ref.cssClasses, userCssClasses = tmp === void 0 ? {} : tmp, _ref_autofocus = _ref.autofocus, autofocus = _ref_autofocus === void 0 ? false : _ref_autofocus, _ref_searchAsYouType = _ref.searchAsYouType, searchAsYouType = _ref_searchAsYouType === void 0 ? true : _ref_searchAsYouType, _ref_ignoreCompositionEvents = _ref.ignoreCompositionEvents, ignoreCompositionEvents = _ref_ignoreCompositionEvents === void 0 ? false : _ref_ignoreCompositionEvents, _ref_showReset = _ref.showReset, showReset = _ref_showReset === void 0 ? true : _ref_showReset, _ref_showSubmit = _ref.showSubmit, showSubmit = _ref_showSubmit === void 0 ? true : _ref_showSubmit, _ref_showLoadingIndicator = _ref.showLoadingIndicator, showLoadingIndicator = _ref_showLoadingIndicator === void 0 ? true : _ref_showLoadingIndicator, queryHook = _ref.queryHook, tmp1 = _ref.templates, userTemplates = tmp1 === void 0 ? {} : tmp1;
19150
+ var _ref = widgetParams || {}, container = _ref.container, _ref_placeholder = _ref.placeholder, placeholder = _ref_placeholder === void 0 ? '' : _ref_placeholder, tmp = _ref.cssClasses, userCssClasses = tmp === void 0 ? {} : tmp, _ref_autofocus = _ref.autofocus, autofocus = _ref_autofocus === void 0 ? false : _ref_autofocus, _ref_searchAsYouType = _ref.searchAsYouType, searchAsYouType = _ref_searchAsYouType === void 0 ? true : _ref_searchAsYouType, _ref_ignoreCompositionEvents = _ref.ignoreCompositionEvents, ignoreCompositionEvents = _ref_ignoreCompositionEvents === void 0 ? false : _ref_ignoreCompositionEvents, _ref_showReset = _ref.showReset, showReset = _ref_showReset === void 0 ? true : _ref_showReset, _ref_showSubmit = _ref.showSubmit, showSubmit = _ref_showSubmit === void 0 ? true : _ref_showSubmit, _ref_showLoadingIndicator = _ref.showLoadingIndicator, showLoadingIndicator = _ref_showLoadingIndicator === void 0 ? true : _ref_showLoadingIndicator, queryHook = _ref.queryHook, tmp1 = _ref.templates, userTemplates = tmp1 === void 0 ? {} : tmp1, aiMode = _ref.aiMode;
19093
19151
  if (!container) {
19094
19152
  throw new Error(withUsage$c('The `container` option is required.'));
19095
19153
  }
@@ -19119,7 +19177,14 @@
19119
19177
  }), userCssClasses.loadingIndicator),
19120
19178
  loadingIcon: cx(suit$3({
19121
19179
  descendantName: 'loadingIcon'
19122
- }), userCssClasses.loadingIcon)
19180
+ }), userCssClasses.loadingIcon),
19181
+ aiModeButton: cx(aiModeSuit(), userCssClasses.aiModeButton),
19182
+ aiModeIcon: cx(aiModeSuit({
19183
+ descendantName: 'icon'
19184
+ }), userCssClasses.aiModeIcon),
19185
+ aiModeLabel: cx(aiModeSuit({
19186
+ descendantName: 'label'
19187
+ }), userCssClasses.aiModeLabel)
19123
19188
  };
19124
19189
  var templates = _object_spread({}, defaultTemplate, userTemplates);
19125
19190
  var specializedRenderer = renderer$5({
@@ -19132,7 +19197,8 @@
19132
19197
  ignoreCompositionEvents: ignoreCompositionEvents,
19133
19198
  showReset: showReset,
19134
19199
  showSubmit: showSubmit,
19135
- showLoadingIndicator: showLoadingIndicator
19200
+ showLoadingIndicator: showLoadingIndicator,
19201
+ aiMode: aiMode
19136
19202
  });
19137
19203
  var makeWidget = connectSearchBox(specializedRenderer, function() {
19138
19204
  return P(null, containerNode);