New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/autocomplete-plugin-recent-searches

Package Overview
Dependencies
Maintainers
61
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/autocomplete-plugin-recent-searches - npm Package Compare versions

Comparing version 1.0.0-alpha.42 to 1.0.0-alpha.43

1

dist/esm/createRecentSearchesPlugin.d.ts

@@ -14,4 +14,5 @@ import { AutocompletePlugin } from '@algolia/autocomplete-core';

onRemove(id: string): void;
onTapAhead(item: TItem): void;
}): AutocompleteSource<TItem>;
};
export declare function createRecentSearchesPlugin<TItem extends RecentSearchesItem>({ storage, transformSource, }: CreateRecentSearchesPluginParams<TItem>): AutocompletePlugin<TItem, RecentSearchesPluginData>;

26

dist/esm/createRecentSearchesPlugin.js

@@ -43,6 +43,7 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

if (inputValue) {
if (source.sourceId === 'querySuggestionsPlugin' && inputValue) {
store.add({
id: inputValue,
query: inputValue
objectID: inputValue,
query: inputValue,
category: item.__autocomplete_qsCategory
});

@@ -58,3 +59,3 @@ }

store.add({
id: query,
objectID: query,
query: query

@@ -66,2 +67,3 @@ });

var query = _ref6.query,
setQuery = _ref6.setQuery,
refresh = _ref6.refresh;

@@ -75,5 +77,7 @@ lastItemsRef.current = store.getAll(query);

var templates = getTemplates({
onRemove: onRemove
});
function onTapAhead(item) {
setQuery(item.query);
refresh();
}
return Promise.resolve(lastItemsRef.current).then(function (items) {

@@ -94,5 +98,9 @@ if (items.length === 0) {

},
templates: templates
templates: getTemplates({
onRemove: onRemove,
onTapAhead: onTapAhead
})
},
onRemove: onRemove
onRemove: onRemove,
onTapAhead: onTapAhead
})];

@@ -99,0 +107,0 @@ });

export function createStore(storage) {
return {
add: function add(item) {
storage.onRemove(item.id);
storage.onRemove(item.objectID);
storage.onAdd(item);

@@ -6,0 +6,0 @@ },

/** @jsx createElement */
import { SourceTemplates } from '@algolia/autocomplete-js';
import { RecentSearchesItem } from './types';
export declare type GetTemplatesParams = {
export declare type GetTemplatesParams<TItem extends RecentSearchesItem> = {
onRemove(id: string): void;
onTapAhead(item: TItem): void;
};
export declare function getTemplates<TItem extends RecentSearchesItem>({ onRemove, }: GetTemplatesParams): SourceTemplates<TItem>;
export declare function getTemplates<TItem extends RecentSearchesItem>({ onRemove, onTapAhead, }: GetTemplatesParams<TItem>): SourceTemplates<TItem>;
/** @jsx createElement */
import { reverseHighlightHit } from '@algolia/autocomplete-js';
export function getTemplates(_ref) {
var onRemove = _ref.onRemove;
var onRemove = _ref.onRemove,
onTapAhead = _ref.onTapAhead;
return {

@@ -13,11 +14,8 @@ item: function item(_ref2) {

}, createElement("svg", {
width: "20",
height: "20",
viewBox: "0 0 22 22",
viewBox: "0 0 24 24",
width: "18",
height: "18",
fill: "currentColor"
}, createElement("path", {
d: "M0 0h24v24H0z",
fill: "none"
}), createElement("path", {
d: "M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"
d: "M12.516 6.984v5.25l4.5 2.672-0.75 1.266-5.25-3.188v-6h1.5zM12 20.016q3.281 0 5.648-2.367t2.367-5.648-2.367-5.648-5.648-2.367-5.648 2.367-2.367 5.648 2.367 5.648 5.648 2.367zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93z"
}))), createElement("div", {

@@ -31,3 +29,5 @@ className: "aa-ItemContent"

createElement: createElement
}))), createElement("div", {
})), item.category && createElement("div", {
className: "aa-ItemContentSubtitle"
}, "\u2013 in ", item.category)), createElement("div", {
className: "aa-ItemActions"

@@ -39,3 +39,3 @@ }, createElement("button", {

event.stopPropagation();
onRemove(item.id);
onRemove(item.objectID);
}

@@ -46,9 +46,19 @@ }, createElement("svg", {

height: "18",
fill: "none",
stroke: "currentColor"
fill: "currentColor"
}, createElement("path", {
d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",
strokeLinecap: "round",
strokeLinejoin: "round",
strokeWidth: 2
d: "M18 7v13c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-10c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-13zM17 5v-1c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-4c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v1h-4c-0.552 0-1 0.448-1 1s0.448 1 1 1h1v13c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h10c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-13h1c0.552 0 1-0.448 1-1s-0.448-1-1-1zM9 5v-1c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293h4c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v1zM9 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1zM13 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1z"
}))), createElement("button", {
className: "aa-ItemActionButton",
title: "Fill query with \"".concat(item.query, "\""),
onClick: function onClick(event) {
event.stopPropagation();
onTapAhead(item);
}
}, createElement("svg", {
viewBox: "0 0 24 24",
width: "18",
height: "18",
fill: "currentColor"
}, createElement("path", {
d: "M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z"
})))));

@@ -55,0 +65,0 @@ }

export declare type RecentSearchesItem = {
id: string;
objectID: string;
query: string;
category?: string;
};

@@ -35,3 +35,3 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

storage.setItem(storage.getItem().filter(function (x) {
return x.id !== id;
return x.objectID !== id;
}));

@@ -38,0 +38,0 @@ }

@@ -1,2 +0,2 @@

/*! @algolia/autocomplete-plugin-recent-searches 1.0.0-alpha.42 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */
/*! @algolia/autocomplete-plugin-recent-searches 1.0.0-alpha.43 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
(function (global, factory) {

@@ -123,3 +123,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

add: function add(item) {
storage.onRemove(item.id);
storage.onRemove(item.objectID);
storage.onAdd(item);

@@ -376,3 +376,4 @@ },

function getTemplates(_ref) {
var onRemove = _ref.onRemove;
var onRemove = _ref.onRemove,
onTapAhead = _ref.onTapAhead;
return {

@@ -386,11 +387,8 @@ item: function item(_ref2) {

}, createElement("svg", {
width: "20",
height: "20",
viewBox: "0 0 22 22",
viewBox: "0 0 24 24",
width: "18",
height: "18",
fill: "currentColor"
}, createElement("path", {
d: "M0 0h24v24H0z",
fill: "none"
}), createElement("path", {
d: "M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"
d: "M12.516 6.984v5.25l4.5 2.672-0.75 1.266-5.25-3.188v-6h1.5zM12 20.016q3.281 0 5.648-2.367t2.367-5.648-2.367-5.648-5.648-2.367-5.648 2.367-2.367 5.648 2.367 5.648 5.648 2.367zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93z"
}))), createElement("div", {

@@ -404,3 +402,5 @@ className: "aa-ItemContent"

createElement: createElement
}))), createElement("div", {
})), item.category && createElement("div", {
className: "aa-ItemContentSubtitle"
}, "\u2013 in ", item.category)), createElement("div", {
className: "aa-ItemActions"

@@ -412,3 +412,3 @@ }, createElement("button", {

event.stopPropagation();
onRemove(item.id);
onRemove(item.objectID);
}

@@ -419,9 +419,19 @@ }, createElement("svg", {

height: "18",
fill: "none",
stroke: "currentColor"
fill: "currentColor"
}, createElement("path", {
d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",
strokeLinecap: "round",
strokeLinejoin: "round",
strokeWidth: 2
d: "M18 7v13c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-10c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-13zM17 5v-1c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-4c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v1h-4c-0.552 0-1 0.448-1 1s0.448 1 1 1h1v13c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h10c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-13h1c0.552 0 1-0.448 1-1s-0.448-1-1-1zM9 5v-1c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293h4c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v1zM9 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1zM13 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1z"
}))), createElement("button", {
className: "aa-ItemActionButton",
title: "Fill query with \"".concat(item.query, "\""),
onClick: function onClick(event) {
event.stopPropagation();
onTapAhead(item);
}
}, createElement("svg", {
viewBox: "0 0 24 24",
width: "18",
height: "18",
fill: "currentColor"
}, createElement("path", {
d: "M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z"
})))));

@@ -453,6 +463,7 @@ }

if (inputValue) {
if (source.sourceId === 'querySuggestionsPlugin' && inputValue) {
store.add({
id: inputValue,
query: inputValue
objectID: inputValue,
query: inputValue,
category: item.__autocomplete_qsCategory
});

@@ -468,3 +479,3 @@ }

store.add({
id: query,
objectID: query,
query: query

@@ -476,2 +487,3 @@ });

var query = _ref6.query,
setQuery = _ref6.setQuery,
refresh = _ref6.refresh;

@@ -485,5 +497,7 @@ lastItemsRef.current = store.getAll(query);

var templates = getTemplates({
onRemove: onRemove
});
function onTapAhead(item) {
setQuery(item.query);
refresh();
}
return Promise.resolve(lastItemsRef.current).then(function (items) {

@@ -504,5 +518,9 @@ if (items.length === 0) {

},
templates: templates
templates: getTemplates({
onRemove: onRemove,
onTapAhead: onTapAhead
})
},
onRemove: onRemove
onRemove: onRemove,
onTapAhead: onTapAhead
})];

@@ -594,3 +612,3 @@ });

storage.setItem(storage.getItem().filter(function (x) {
return x.id !== id;
return x.objectID !== id;
}));

@@ -597,0 +615,0 @@ }

@@ -1,3 +0,3 @@

/*! @algolia/autocomplete-plugin-recent-searches 1.0.0-alpha.42 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-plugin-recent-searches"]={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?r(Object(i),!0).forEach((function(r){t(e,r,i[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var u;function a(e,t,r){var n,i,o,u=arguments,a={};for(o in t)"key"==o?n=t[o]:"ref"==o?i=t[o]:a[o]=t[o];if(arguments.length>3)for(r=[r],o=3;o<arguments.length;o++)r.push(u[o]);if(null!=r&&(a.children=r),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===a[o]&&(a[o]=e.defaultProps[o]);return c(e,a,n,i,null)}function c(e,t,r,n,i){var o={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==i?++u.__v:i};return null!=u.vnode&&u.vnode(o),o}function l(e,t){return t.reduce((function(e,t){return e&&e[t]}),e)}u={__e:function(e,t){for(var r,n,i,o=t.__h;t=t.__;)if((r=t.__c)&&!r.__)try{if((n=r.constructor)&&null!=n.getDerivedStateFromError&&(r.setState(n.getDerivedStateFromError(e)),i=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e),i=r.__d),i)return t.__h=o,r.__E=r}catch(t){e=t}throw e},__v:0},"function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout;function f(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var g={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},h=new RegExp(/\w/i),m=/&(amp|quot|lt|gt|#39);/g,d=RegExp(m.source);function v(e,t){var r,n,i,o=e[t],u=(null===(r=e[t+1])||void 0===r?void 0:r.isHighlighted)||!0,a=(null===(n=e[t-1])||void 0===n?void 0:n.isHighlighted)||!0;return h.test((i=o.value)&&d.test(i)?i.replace(m,(function(e){return g[e]})):i)||a!==u?o.isHighlighted:a}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){b(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _(e){return n=(r=e).hit,i=r.attribute,o=Array.isArray(i)?i:[i],"string"!=typeof(u=l(n,["_highlightResult"].concat(f(o),["value"])))&&(u=l(n,o)||""),(t=function(e){var t=e.highlightedValue.split("__aa-highlight__"),r=t.shift(),n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{get:function(){return e},add:function(t){var r=e[e.length-1];(null==r?void 0:r.isHighlighted)===t.isHighlighted?e[e.length-1]={value:r.value+t.value,isHighlighted:r.isHighlighted}:e.push(t)}}}(r?[{value:r,isHighlighted:!1}]:[]);return t.forEach((function(e){var t=e.split("__/aa-highlight__");n.add({value:t[0],isHighlighted:!0}),""!==t[1]&&n.add({value:t[1],isHighlighted:!1})})),n.get()}({highlightedValue:u})).some((function(e){return e.isHighlighted}))?t.map((function(e,r){return y(y({},e),{},{isHighlighted:!v(t,r)})})):t.map((function(e){return y(y({},e),{},{isHighlighted:!1})}));var t,r,n,i,o,u}function O(e){var t=e.onRemove;return{item:function(e){var r=e.item,n=e.createElement;return n(e.Fragment,null,n("div",{className:"aa-ItemIcon aa-ItemIcon--no-border"},n("svg",{width:"20",height:"20",viewBox:"0 0 22 22",fill:"currentColor"},n("path",{d:"M0 0h24v24H0z",fill:"none"}),n("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"}))),n("div",{className:"aa-ItemContent"},n("div",{className:"aa-ItemContentTitle"},function(e){var t=e.hit,r=e.attribute,n=e.tagName,i=void 0===n?"mark":n,o=e.createElement,u=void 0===o?a:o;return _({hit:t,attribute:r}).map((function(e,t){return e.isHighlighted?u(i,{key:t},e.value):e.value}))}({hit:r,attribute:"query",createElement:n}))),n("div",{className:"aa-ItemActions"},n("button",{className:"aa-ItemActionButton",title:"Remove this search",onClick:function(e){e.stopPropagation(),t(r.id)}},n("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor"},n("path",{d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2})))))}}}function S(e){var t=e.storage,r=e.transformSource,o=void 0===r?function(e){return e.source}:r,u=function(e){return{add:function(t){e.onRemove(t.id),e.onAdd(t)},remove:function(t){e.onRemove(t)},getAll:function(t){return e.getAll(t)}}}(t),a={current:[]};return{subscribe:function(e){(0,e.onSelect)((function(e){var t=e.item,r=e.state,n=e.source.getItemInputValue({item:t,state:r});n&&u.add({id:n,query:n})}))},onSubmit:function(e){var t=e.state.query;t&&u.add({id:t,query:t})},getSources:function(e){var t=e.query,r=e.refresh;function n(e){u.remove(e),r()}a.current=u.getAll(t);var i=O({onRemove:n});return Promise.resolve(a.current).then((function(e){return 0===e.length?[]:[o({source:{sourceId:"recentSearchesPlugin",getItemInputValue:function(e){return e.item.query},getItems:function(){return e},templates:i},onRemove:n})]}))},data:{getAlgoliaSearchParams:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Array.isArray(a.current)?n(n({},r),{},{facetFilters:[].concat(i(null!==(e=r.facetFilters)&&void 0!==e?e:[]),i(a.current.map((function(e){return["objectID:-".concat(e.query)]})))),hitsPerPage:Math.max(1,(null!==(t=r.hitsPerPage)&&void 0!==t?t:10)-a.current.length)}):r}}}}var P="AUTOCOMPLETE_RECENT_SEARCHES",j="__AUTOCOMPLETE_RECENT_SEARCHES_PLUGIN_TEST_KEY__";function I(e){var t=e.key;return function(){try{return localStorage.setItem(j,""),localStorage.removeItem(j),!0}catch(e){return!1}}()?{setItem:function(e){return window.localStorage.setItem(t,JSON.stringify(e))},getItem:function(){var e=window.localStorage.getItem(t);return e?JSON.parse(e):[]}}:{setItem:function(){},getItem:function(){return[]}}}function w(e){var t=e.item,r=e.query;return n(n({},t),{},{_highlightResult:{query:{value:r?t.query.replace(new RegExp(r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),"__aa-highlight__".concat(r,"__/aa-highlight__")):t.query}}})}function A(e){var t=e.query,r=e.items,n=e.limit;return t?r.filter((function(e){return e.query.toLowerCase().includes(t.toLowerCase())})).slice(0,n).map((function(e){return w({item:e,query:t})})):r.slice(0,n).map((function(e){return w({item:e,query:t})}))}e.createLocalStorageRecentSearchesPlugin=function(e){var t=e.key,r=e.limit,n=void 0===r?5:r,o=e.transformSource,u=e.search,a=void 0===u?A:u;return S({transformSource:o,storage:function(e){var t=e.key,r=e.limit,n=e.search,o=I({key:t});return{getAll:function(){return n({query:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",items:o.getItem(),limit:r}).slice(0,r)},onAdd:function(e){o.setItem([e].concat(i(o.getItem())))},onRemove:function(e){o.setItem(o.getItem().filter((function(t){return t.id!==e})))}}}({key:[P,t].join(":"),limit:n,search:a})})},e.createRecentSearchesPlugin=S,e.getTemplates=O,Object.defineProperty(e,"__esModule",{value:!0})}));
/*! @algolia/autocomplete-plugin-recent-searches 1.0.0-alpha.43 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-plugin-recent-searches"]={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(r){t(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var u;function c(e,t,r){var n,o,i,u=arguments,c={};for(i in t)"key"==i?n=t[i]:"ref"==i?o=t[i]:c[i]=t[i];if(arguments.length>3)for(r=[r],i=3;i<arguments.length;i++)r.push(u[i]);if(null!=r&&(c.children=r),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===c[i]&&(c[i]=e.defaultProps[i]);return a(e,c,n,o,null)}function a(e,t,r,n,o){var i={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++u.__v:o};return null!=u.vnode&&u.vnode(i),i}function l(e,t){return t.reduce((function(e,t){return e&&e[t]}),e)}u={__e:function(e,t){for(var r,n,o,i=t.__h;t=t.__;)if((r=t.__c)&&!r.__)try{if((n=r.constructor)&&null!=n.getDerivedStateFromError&&(r.setState(n.getDerivedStateFromError(e)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e),o=r.__d),o)return t.__h=i,r.__E=r}catch(t){e=t}throw e},__v:0},"function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout;function s(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var g={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},h=new RegExp(/\w/i),m=/&(amp|quot|lt|gt|#39);/g,v=RegExp(m.source);function d(e,t){var r,n,o,i=e[t],u=(null===(r=e[t+1])||void 0===r?void 0:r.isHighlighted)||!0,c=(null===(n=e[t-1])||void 0===n?void 0:n.isHighlighted)||!0;return h.test((o=i.value)&&v.test(o)?o.replace(m,(function(e){return g[e]})):o)||c!==u?i.isHighlighted:c}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){b(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _(e){return n=(r=e).hit,o=r.attribute,i=Array.isArray(o)?o:[o],"string"!=typeof(u=l(n,["_highlightResult"].concat(s(i),["value"])))&&(u=l(n,i)||""),(t=function(e){var t=e.highlightedValue.split("__aa-highlight__"),r=t.shift(),n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{get:function(){return e},add:function(t){var r=e[e.length-1];(null==r?void 0:r.isHighlighted)===t.isHighlighted?e[e.length-1]={value:r.value+t.value,isHighlighted:r.isHighlighted}:e.push(t)}}}(r?[{value:r,isHighlighted:!1}]:[]);return t.forEach((function(e){var t=e.split("__/aa-highlight__");n.add({value:t[0],isHighlighted:!0}),""!==t[1]&&n.add({value:t[1],isHighlighted:!1})})),n.get()}({highlightedValue:u})).some((function(e){return e.isHighlighted}))?t.map((function(e,r){return y(y({},e),{},{isHighlighted:!d(t,r)})})):t.map((function(e){return y(y({},e),{},{isHighlighted:!1})}));var t,r,n,o,i,u}function O(e){var t=e.onRemove,r=e.onTapAhead;return{item:function(e){var n=e.item,o=e.createElement;return o(e.Fragment,null,o("div",{className:"aa-ItemIcon aa-ItemIcon--no-border"},o("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor"},o("path",{d:"M12.516 6.984v5.25l4.5 2.672-0.75 1.266-5.25-3.188v-6h1.5zM12 20.016q3.281 0 5.648-2.367t2.367-5.648-2.367-5.648-5.648-2.367-5.648 2.367-2.367 5.648 2.367 5.648 5.648 2.367zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93z"}))),o("div",{className:"aa-ItemContent"},o("div",{className:"aa-ItemContentTitle"},function(e){var t=e.hit,r=e.attribute,n=e.tagName,o=void 0===n?"mark":n,i=e.createElement,u=void 0===i?c:i;return _({hit:t,attribute:r}).map((function(e,t){return e.isHighlighted?u(o,{key:t},e.value):e.value}))}({hit:n,attribute:"query",createElement:o})),n.category&&o("div",{className:"aa-ItemContentSubtitle"},"– in ",n.category)),o("div",{className:"aa-ItemActions"},o("button",{className:"aa-ItemActionButton",title:"Remove this search",onClick:function(e){e.stopPropagation(),t(n.objectID)}},o("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor"},o("path",{d:"M18 7v13c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-10c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-13zM17 5v-1c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-4c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v1h-4c-0.552 0-1 0.448-1 1s0.448 1 1 1h1v13c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h10c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-13h1c0.552 0 1-0.448 1-1s-0.448-1-1-1zM9 5v-1c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293h4c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v1zM9 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1zM13 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1z"}))),o("button",{className:"aa-ItemActionButton",title:'Fill query with "'.concat(n.query,'"'),onClick:function(e){e.stopPropagation(),r(n)}},o("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor"},o("path",{d:"M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z"})))))}}}function I(e){var t=e.storage,r=e.transformSource,i=void 0===r?function(e){return e.source}:r,u=function(e){return{add:function(t){e.onRemove(t.objectID),e.onAdd(t)},remove:function(t){e.onRemove(t)},getAll:function(t){return e.getAll(t)}}}(t),c={current:[]};return{subscribe:function(e){(0,e.onSelect)((function(e){var t=e.item,r=e.state,n=e.source,o=n.getItemInputValue({item:t,state:r});"querySuggestionsPlugin"===n.sourceId&&o&&u.add({objectID:o,query:o,category:t.__autocomplete_qsCategory})}))},onSubmit:function(e){var t=e.state.query;t&&u.add({objectID:t,query:t})},getSources:function(e){var t=e.query,r=e.setQuery,n=e.refresh;function o(e){u.remove(e),n()}function a(e){r(e.query),n()}return c.current=u.getAll(t),Promise.resolve(c.current).then((function(e){return 0===e.length?[]:[i({source:{sourceId:"recentSearchesPlugin",getItemInputValue:function(e){return e.item.query},getItems:function(){return e},templates:O({onRemove:o,onTapAhead:a})},onRemove:o,onTapAhead:a})]}))},data:{getAlgoliaSearchParams:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Array.isArray(c.current)?n(n({},r),{},{facetFilters:[].concat(o(null!==(e=r.facetFilters)&&void 0!==e?e:[]),o(c.current.map((function(e){return["objectID:-".concat(e.query)]})))),hitsPerPage:Math.max(1,(null!==(t=r.hitsPerPage)&&void 0!==t?t:10)-c.current.length)}):r}}}}var j="AUTOCOMPLETE_RECENT_SEARCHES",S="__AUTOCOMPLETE_RECENT_SEARCHES_PLUGIN_TEST_KEY__";function P(e){var t=e.key;return function(){try{return localStorage.setItem(S,""),localStorage.removeItem(S),!0}catch(e){return!1}}()?{setItem:function(e){return window.localStorage.setItem(t,JSON.stringify(e))},getItem:function(){var e=window.localStorage.getItem(t);return e?JSON.parse(e):[]}}:{setItem:function(){},getItem:function(){return[]}}}function w(e){var t=e.item,r=e.query;return n(n({},t),{},{_highlightResult:{query:{value:r?t.query.replace(new RegExp(r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),"__aa-highlight__".concat(r,"__/aa-highlight__")):t.query}}})}function A(e){var t=e.query,r=e.items,n=e.limit;return t?r.filter((function(e){return e.query.toLowerCase().includes(t.toLowerCase())})).slice(0,n).map((function(e){return w({item:e,query:t})})):r.slice(0,n).map((function(e){return w({item:e,query:t})}))}e.createLocalStorageRecentSearchesPlugin=function(e){var t=e.key,r=e.limit,n=void 0===r?5:r,i=e.transformSource,u=e.search,c=void 0===u?A:u;return I({transformSource:i,storage:function(e){var t=e.key,r=e.limit,n=e.search,i=P({key:t});return{getAll:function(){return n({query:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",items:i.getItem(),limit:r}).slice(0,r)},onAdd:function(e){i.setItem([e].concat(o(i.getItem())))},onRemove:function(e){i.setItem(i.getItem().filter((function(t){return t.objectID!==e})))}}}({key:[j,t].join(":"),limit:n,search:c})})},e.createRecentSearchesPlugin=I,e.getTemplates=O,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@algolia/autocomplete-plugin-recent-searches",
"description": "A plugin to add recent searches to Algolia Autocomplete.",
"version": "1.0.0-alpha.42",
"version": "1.0.0-alpha.43",
"license": "MIT",
"homepage": "https://github.com/algolia/autocomplete.js",
"homepage": "https://github.com/algolia/autocomplete",
"repository": "algolia/autocomplete.js",

@@ -34,6 +34,6 @@ "author": {

"dependencies": {
"@algolia/autocomplete-core": "1.0.0-alpha.42",
"@algolia/autocomplete-js": "1.0.0-alpha.42",
"@algolia/autocomplete-preset-algolia": "1.0.0-alpha.42",
"@algolia/autocomplete-shared": "1.0.0-alpha.42"
"@algolia/autocomplete-core": "1.0.0-alpha.43",
"@algolia/autocomplete-js": "1.0.0-alpha.43",
"@algolia/autocomplete-preset-algolia": "1.0.0-alpha.43",
"@algolia/autocomplete-shared": "1.0.0-alpha.43"
},

@@ -40,0 +40,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc