@algolia/autocomplete-js 1.13.0 → 1.15.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/dist/esm/autocomplete.js
CHANGED
|
@@ -280,20 +280,18 @@ export function autocomplete(options) {
|
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
function setIsModalOpen(value) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
});
|
|
283
|
+
var prevValue = props.value.core.environment.document.body.contains(dom.value.detachedOverlay);
|
|
284
|
+
if (value === prevValue) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (value) {
|
|
288
|
+
props.value.core.environment.document.body.appendChild(dom.value.detachedOverlay);
|
|
289
|
+
props.value.core.environment.document.body.classList.add('aa-Detached');
|
|
290
|
+
dom.value.input.focus();
|
|
291
|
+
} else {
|
|
292
|
+
props.value.core.environment.document.body.removeChild(dom.value.detachedOverlay);
|
|
293
|
+
props.value.core.environment.document.body.classList.remove('aa-Detached');
|
|
294
|
+
}
|
|
297
295
|
}
|
|
298
296
|
process.env.NODE_ENV !== 'production' ? warn(instancesCount === 0, "Autocomplete doesn't support multiple instances running at the same time. Make sure to destroy the previous instance before creating a new one.\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-destroy") : void 0;
|
|
299
297
|
instancesCount++;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @algolia/autocomplete-js 1.
|
|
1
|
+
/*! @algolia/autocomplete-js 1.15.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -347,7 +347,7 @@
|
|
|
347
347
|
return undefined;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
var version = '1.
|
|
350
|
+
var version = '1.15.0';
|
|
351
351
|
|
|
352
352
|
var userAgents$1 = [{
|
|
353
353
|
segment: 'autocomplete-core',
|
|
@@ -620,6 +620,15 @@
|
|
|
620
620
|
apiKey: apiKey
|
|
621
621
|
});
|
|
622
622
|
},
|
|
623
|
+
/**
|
|
624
|
+
* Sets the authenticated user token to attach to events.
|
|
625
|
+
* Unsets the authenticated token by passing `undefined`.
|
|
626
|
+
*
|
|
627
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/set-authenticated-user-token/
|
|
628
|
+
*/
|
|
629
|
+
setAuthenticatedUserToken: function setAuthenticatedUserToken(authenticatedUserToken) {
|
|
630
|
+
searchInsights('setAuthenticatedUserToken', authenticatedUserToken);
|
|
631
|
+
},
|
|
623
632
|
/**
|
|
624
633
|
* Sets the user token to attach to events.
|
|
625
634
|
*/
|
|
@@ -878,6 +887,7 @@
|
|
|
878
887
|
function createAlgoliaInsightsPlugin(options) {
|
|
879
888
|
var _getOptions = getOptions(options),
|
|
880
889
|
providedInsightsClient = _getOptions.insightsClient,
|
|
890
|
+
insightsInitParams = _getOptions.insightsInitParams,
|
|
881
891
|
onItemsChange = _getOptions.onItemsChange,
|
|
882
892
|
onSelectEvent = _getOptions.onSelect,
|
|
883
893
|
onActiveEvent = _getOptions.onActive,
|
|
@@ -915,6 +925,11 @@
|
|
|
915
925
|
if (!insightsClient) {
|
|
916
926
|
return {};
|
|
917
927
|
}
|
|
928
|
+
if (insightsInitParams) {
|
|
929
|
+
insightsClient('init', _objectSpread$f({
|
|
930
|
+
partial: true
|
|
931
|
+
}, insightsInitParams));
|
|
932
|
+
}
|
|
918
933
|
var insights = createSearchInsightsApi(insightsClient);
|
|
919
934
|
var previousItems = createRef([]);
|
|
920
935
|
var debouncedOnStateChange = debounce(function (_ref3) {
|
|
@@ -961,10 +976,28 @@
|
|
|
961
976
|
}
|
|
962
977
|
insightsClient('addAlgoliaAgent', 'insights-plugin');
|
|
963
978
|
setInsightsContext();
|
|
979
|
+
|
|
980
|
+
// Handles user token changes
|
|
964
981
|
insightsClient('onUserTokenChange', setInsightsContext);
|
|
965
982
|
insightsClient('getUserToken', null, function (_error, userToken) {
|
|
966
983
|
setInsightsContext(userToken);
|
|
967
984
|
});
|
|
985
|
+
|
|
986
|
+
// Handles authenticated user token changes
|
|
987
|
+
insightsClient('onAuthenticatedUserTokenChange', function (authenticatedUserToken) {
|
|
988
|
+
if (authenticatedUserToken) {
|
|
989
|
+
setInsightsContext(authenticatedUserToken);
|
|
990
|
+
} else {
|
|
991
|
+
insightsClient('getUserToken', null, function (_error, userToken) {
|
|
992
|
+
return setInsightsContext(userToken);
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
insightsClient('getAuthenticatedUserToken', null, function (_error, authenticatedUserToken) {
|
|
997
|
+
if (authenticatedUserToken) {
|
|
998
|
+
setInsightsContext(authenticatedUserToken);
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
968
1001
|
onSelect(function (_ref5) {
|
|
969
1002
|
var item = _ref5.item,
|
|
970
1003
|
state = _ref5.state,
|
|
@@ -5093,20 +5126,18 @@
|
|
|
5093
5126
|
});
|
|
5094
5127
|
}
|
|
5095
5128
|
function setIsModalOpen(value) {
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
}
|
|
5109
|
-
});
|
|
5129
|
+
var prevValue = props.value.core.environment.document.body.contains(dom.value.detachedOverlay);
|
|
5130
|
+
if (value === prevValue) {
|
|
5131
|
+
return;
|
|
5132
|
+
}
|
|
5133
|
+
if (value) {
|
|
5134
|
+
props.value.core.environment.document.body.appendChild(dom.value.detachedOverlay);
|
|
5135
|
+
props.value.core.environment.document.body.classList.add('aa-Detached');
|
|
5136
|
+
dom.value.input.focus();
|
|
5137
|
+
} else {
|
|
5138
|
+
props.value.core.environment.document.body.removeChild(dom.value.detachedOverlay);
|
|
5139
|
+
props.value.core.environment.document.body.classList.remove('aa-Detached');
|
|
5140
|
+
}
|
|
5110
5141
|
}
|
|
5111
5142
|
"development" !== 'production' ? warn(instancesCount === 0, "Autocomplete doesn't support multiple instances running at the same time. Make sure to destroy the previous instance before creating a new one.\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-destroy") : void 0;
|
|
5112
5143
|
instancesCount++;
|