Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

instantsearch.js

Package Overview
Dependencies
Maintainers
7
Versions
420
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instantsearch.js - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

dist-es5-module/src/lib/show-more/defaultShowMoreTemplates.js

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="1.2.2"></a>
## [1.2.2](https://github.com/algolia/instantsearch.js/compare/v1.2.1...v1.2.2) (2016-02-03)
### Features
* **menu:** add showMore option ([e7e7677](https://github.com/algolia/instantsearch.js/commit/e7e7677)), closes [#815](https://github.com/algolia/instantsearch.js/issues/815)
<a name="1.2.1"></a>

@@ -2,0 +12,0 @@ ## [1.2.1](https://github.com/algolia/instantsearch.js/compare/v1.2.0...v1.2.1) (2016-02-02)

15

dist-es5-module/src/lib/utils.js

@@ -41,2 +41,6 @@ 'use strict';

var _lodashObjectMapKeys = require('lodash/object/mapKeys');
var _lodashObjectMapKeys2 = _interopRequireDefault(_lodashObjectMapKeys);
var utils = {

@@ -50,3 +54,4 @@ getContainerNode: getContainerNode,

clearRefinementsFromState: clearRefinementsFromState,
clearRefinementsAndSearch: clearRefinementsAndSearch
clearRefinementsAndSearch: clearRefinementsAndSearch,
prefixKeys: prefixKeys
};

@@ -257,3 +262,11 @@

function prefixKeys(prefix, obj) {
if (obj) {
return (0, _lodashObjectMapKeys2['default'])(obj, function (v, k) {
return prefix + k;
});
}
}
exports['default'] = utils;
module.exports = exports['default'];

2

dist-es5-module/src/lib/version.js

@@ -6,3 +6,3 @@ 'use strict';

});
exports['default'] = '1.2.1';
exports['default'] = '1.2.2';
module.exports = exports['default'];

@@ -46,3 +46,3 @@ 'use strict';

* @param {string} [options.showParentLevel=false] Show the parent level of the current refined value
* @param {number} [options.limit=100] How much facet values to get
* @param {number} [options.limit=10] How much facet values to get
* @param {string[]|Function} [options.sortBy=['name:asc']] How to sort refinements. Possible values: `count|isRefined|name:asc|desc`

@@ -70,3 +70,3 @@ * @param {Object} [options.templates] Templates to use for the widget

var bem = _libUtilsJs2['default'].bemHelper('ais-hierarchical-menu');
var usage = 'Usage:\nhierarchicalMenu({\n container,\n attributes,\n [ separator=\' > \' ],\n [ rootPath ],\n [ showParentLevel=true ],\n [ limit=1000 ],\n [ sortBy=[\'name:asc\'] ],\n [ cssClasses.{root , header, body, footer, list, depth, item, active, link}={} ],\n [ templates.{header, item, footer} ],\n [ transformData ],\n [ autoHideContainer=true ]\n})';
var usage = 'Usage:\nhierarchicalMenu({\n container,\n attributes,\n [ separator=\' > \' ],\n [ rootPath ],\n [ showParentLevel=true ],\n [ limit=10 ],\n [ sortBy=[\'name:asc\'] ],\n [ cssClasses.{root , header, body, footer, list, depth, item, active, link}={} ],\n [ templates.{header, item, footer} ],\n [ transformData ],\n [ autoHideContainer=true ]\n})';
function hierarchicalMenu() {

@@ -84,3 +84,3 @@ var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

var _ref$limit = _ref.limit;
var limit = _ref$limit === undefined ? 1000 : _ref$limit;
var limit = _ref$limit === undefined ? 10 : _ref$limit;
var _ref$sortBy = _ref.sortBy;

@@ -87,0 +87,0 @@ var sortBy = _ref$sortBy === undefined ? ['name:asc'] : _ref$sortBy;

@@ -7,2 +7,4 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

@@ -34,2 +36,6 @@

var _libShowMoreGetShowMoreConfigJs = require('../../lib/show-more/getShowMoreConfig.js');
var _libShowMoreGetShowMoreConfigJs2 = _interopRequireDefault(_libShowMoreGetShowMoreConfigJs);
var _defaultTemplatesJs = require('./defaultTemplates.js');

@@ -45,3 +51,8 @@

* @param {string[]|Function} [options.sortBy=['count:desc']] How to sort refinements. Possible values: `count|isRefined|name:asc|desc`
* @param {string} [options.limit=100] How many facets values to retrieve
* @param {string} [options.limit=10] How many facets values to retrieve
* @param {object|boolean} [options.showMore=false] Limit the number of results and display a showMore button
* @param {object} [options.showMore.templates] Templates to use for showMore
* @param {object} [options.showMore.templates.active] Template used when showMore was clicked
* @param {object} [options.showMore.templates.inactive] Template used when showMore not clicked
* @param {object} [options.showMore.limit] Max number of facets values to display when showMore is clicked
* @param {Object} [options.templates] Templates to use for the widget

@@ -67,3 +78,3 @@ * @param {string|Function} [options.templates.header=''] Header template

var bem = _libUtilsJs2['default'].bemHelper('ais-menu');
var usage = 'Usage:\nmenu({\n container,\n attributeName,\n [sortBy],\n [limit],\n [cssClasses.{root,list,item}],\n [templates.{header,item,footer}],\n [transformData],\n [autoHideContainer]\n})';
var usage = 'Usage:\nmenu({\n container,\n attributeName,\n [sortBy],\n [limit=10],\n [cssClasses.{root,list,item}],\n [templates.{header,item,footer}],\n [transformData],\n [autoHideContainer]\n [showMore.{templates: {active, inactive}, limit}]\n})';
function menu() {

@@ -77,3 +88,3 @@ var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

var _ref$limit = _ref.limit;
var limit = _ref$limit === undefined ? 100 : _ref$limit;
var limit = _ref$limit === undefined ? 10 : _ref$limit;
var _ref$cssClasses = _ref.cssClasses;

@@ -86,3 +97,11 @@ var userCssClasses = _ref$cssClasses === undefined ? {} : _ref$cssClasses;

var autoHideContainer = _ref$autoHideContainer === undefined ? true : _ref$autoHideContainer;
var _ref$showMore = _ref.showMore;
var showMore = _ref$showMore === undefined ? false : _ref$showMore;
var showMoreConfig = (0, _libShowMoreGetShowMoreConfigJs2['default'])(showMore);
if (showMoreConfig && showMoreConfig.limit < limit) {
throw new Error('showMore.limit configuration should be > than the limit in the main configuration'); // eslint-disable-line
}
var widgetMaxValuesPerFacet = showMoreConfig && showMoreConfig.limit || limit;
if (!container || !attributeName) {

@@ -102,5 +121,8 @@ throw new Error(usage);

var showMoreTemplates = showMoreConfig && _libUtilsJs2['default'].prefixKeys('show-more-', showMoreConfig.templates);
var allTemplates = showMoreTemplates ? _extends({}, templates, showMoreTemplates) : templates;
return {
getConfiguration: function getConfiguration() {
return {
getConfiguration: function getConfiguration(configuration) {
var widgetConfiguration = {
hierarchicalFacets: [{

@@ -111,2 +133,7 @@ name: hierarchicalFacetName,

};
var currentMaxValuesPerFacet = configuration.maxValuesPerFacet || 0;
widgetConfiguration.maxValuesPerFacet = Math.max(currentMaxValuesPerFacet, widgetMaxValuesPerFacet);
return widgetConfiguration;
},

@@ -120,3 +147,3 @@ render: function render(_ref2) {

var facetValues = getFacetValues(results, hierarchicalFacetName, sortBy, limit);
var facetValues = getFacetValues(results, hierarchicalFacetName, sortBy);
var hasNoFacetValues = facetValues.length === 0;

@@ -128,3 +155,3 @@

templatesConfig: templatesConfig,
templates: templates
templates: allTemplates
});

@@ -150,3 +177,6 @@

facetValues: facetValues,
limitMax: widgetMaxValuesPerFacet,
limitMin: limit,
shouldAutoHideContainer: hasNoFacetValues,
showMore: showMoreConfig !== null,
templateProps: templateProps,

@@ -163,6 +193,6 @@ toggleRefinement: toggleRefinement.bind(null, helper, hierarchicalFacetName)

function getFacetValues(results, hierarchicalFacetName, sortBy, limit) {
function getFacetValues(results, hierarchicalFacetName, sortBy) {
var values = results.getFacetValues(hierarchicalFacetName, { sortBy: sortBy });
return values.data && values.data.slice(0, limit) || [];
return values.data || [];
}

@@ -169,0 +199,0 @@

@@ -21,6 +21,2 @@ 'use strict';

var _lodashObjectMapKeys = require('lodash/object/mapKeys');
var _lodashObjectMapKeys2 = _interopRequireDefault(_lodashObjectMapKeys);
var _libUtilsJs = require('../../lib/utils.js');

@@ -42,2 +38,6 @@

var _libShowMoreGetShowMoreConfigJs = require('../../lib/show-more/getShowMoreConfig.js');
var _libShowMoreGetShowMoreConfigJs2 = _interopRequireDefault(_libShowMoreGetShowMoreConfigJs);
var _defaultTemplatesJs = require('./defaultTemplates.js');

@@ -47,6 +47,2 @@

var _defaultShowMoreTemplatesJs = require('./defaultShowMoreTemplates.js');
var _defaultShowMoreTemplatesJs2 = _interopRequireDefault(_defaultShowMoreTemplatesJs);
/**

@@ -60,7 +56,7 @@ * Instantiate a list of refinements based on a facet

* @param {string} [options.limit=10] How much facet values to get. When the show more feature is activated this is the minimun number of facets requested (the show more button is not in active state).
* @param {object|boolean} [options.showMore] pass a configuration object, or true to use the default configuration
* @param {object} [options.showMore.templates] templates to use
* @param {object} [options.showMore.templates.active] template used when more facets are displayed
* @param {object} [options.showMore.templates.inactive] template used when less facets are displayed
* @param {object} [options.showMore.limit] the max number of facets values to display when the show more feature is active
* @param {object|boolean} [options.showMore=false] Limit the number of results and display a showMore button
* @param {object} [options.showMore.templates] Templates to use for showMore
* @param {object} [options.showMore.templates.active] Template used when showMore was clicked
* @param {object} [options.showMore.templates.inactive] Template used when showMore not clicked
* @param {object} [options.showMore.limit] Max number of facets values to display when showMore is clicked
* @param {Object} [options.templates] Templates to use for the widget

@@ -104,5 +100,6 @@ * @param {string|Function} [options.templates.header] Header template

var autoHideContainer = _ref$autoHideContainer === undefined ? true : _ref$autoHideContainer;
var showMore = _ref.showMore;
var _ref$showMore = _ref.showMore;
var showMore = _ref$showMore === undefined ? false : _ref$showMore;
var showMoreConfig = getShowMoreConfig(showMore);
var showMoreConfig = (0, _libShowMoreGetShowMoreConfigJs2['default'])(showMore);
if (showMoreConfig && showMoreConfig.limit < limit) {

@@ -132,3 +129,3 @@ throw new Error('showMore.limit configuration should be > than the limit in the main configuration'); // eslint-disable-line

var showMoreTemplates = showMoreConfig && prefixKeys('show-more-', showMoreConfig.templates);
var showMoreTemplates = showMoreConfig && _libUtilsJs2['default'].prefixKeys('show-more-', showMoreConfig.templates);
var allTemplates = showMoreTemplates ? _extends({}, templates, showMoreTemplates) : templates;

@@ -198,32 +195,3 @@

var defaultShowMoreConfig = {
templates: _defaultShowMoreTemplatesJs2['default'],
limit: 100
};
function getShowMoreConfig(showMoreOptions) {
if (showMoreOptions === true) {
return defaultShowMoreConfig;
} else if (showMoreOptions) {
var config = _extends({}, showMoreOptions);
if (!showMoreOptions.templates) {
config.templates = defaultShowMoreConfig.templates;
}
if (!showMoreOptions.limit) {
config.limit = defaultShowMoreConfig.limit;
}
return config;
}
return null;
}
function prefixKeys(prefix, obj) {
if (obj) {
return (0, _lodashObjectMapKeys2['default'])(obj, function (v, k) {
return prefix + k;
});
}
}
exports['default'] = refinementList;
module.exports = exports['default'];
{
"name": "instantsearch.js",
"version": "1.2.1",
"version": "1.2.2",
"description": "instantsearch.js is a library of widgets to build high performance instant search experiences using Algolia",

@@ -5,0 +5,0 @@ "main": "dist-es5-module/index.js",

@@ -235,4 +235,4 @@ [![instantsearch.js logo][readme-logo]][logo-url]

```sh
docker pull elgalu/selenium:2.50.0b
docker run --net="host" --privileged --name=grid -e VNC_PASSWORD=fun -e NOVNC=true elgalu/selenium:2.50.0b
docker pull elgalu/selenium:2.50.1a
docker run --net="host" --privileged --name=grid -e VNC_PASSWORD=fun -e NOVNC=true elgalu/selenium:2.50.1a
```

@@ -239,0 +239,0 @@

@@ -8,2 +8,3 @@ import reduce from 'lodash/collection/reduce';

import uniq from 'lodash/array/uniq';
import mapKeys from 'lodash/object/mapKeys';

@@ -18,3 +19,4 @@ let utils = {

clearRefinementsFromState,
clearRefinementsAndSearch
clearRefinementsAndSearch,
prefixKeys
};

@@ -223,2 +225,10 @@

function prefixKeys(prefix, obj) {
if (obj) {
return mapKeys(obj, function(v, k) {
return prefix + k;
});
}
}
export default utils;

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

export default '1.2.1';
export default '1.2.2';

@@ -21,3 +21,3 @@ import React from 'react';

* @param {string} [options.showParentLevel=false] Show the parent level of the current refined value
* @param {number} [options.limit=100] How much facet values to get
* @param {number} [options.limit=10] How much facet values to get
* @param {string[]|Function} [options.sortBy=['name:asc']] How to sort refinements. Possible values: `count|isRefined|name:asc|desc`

@@ -50,3 +50,3 @@ * @param {Object} [options.templates] Templates to use for the widget

[ showParentLevel=true ],
[ limit=1000 ],
[ limit=10 ],
[ sortBy=['name:asc'] ],

@@ -64,3 +64,3 @@ [ cssClasses.{root , header, body, footer, list, depth, item, active, link}={} ],

showParentLevel = true,
limit = 1000,
limit = 10,
sortBy = ['name:asc'],

@@ -67,0 +67,0 @@ cssClasses: userCssClasses = {},

@@ -9,2 +9,3 @@ import React from 'react';

import headerFooterHOC from '../../decorators/headerFooter.js';
import getShowMoreConfig from '../../lib/show-more/getShowMoreConfig.js';

@@ -19,3 +20,8 @@ import defaultTemplates from './defaultTemplates.js';

* @param {string[]|Function} [options.sortBy=['count:desc']] How to sort refinements. Possible values: `count|isRefined|name:asc|desc`
* @param {string} [options.limit=100] How many facets values to retrieve
* @param {string} [options.limit=10] How many facets values to retrieve
* @param {object|boolean} [options.showMore=false] Limit the number of results and display a showMore button
* @param {object} [options.showMore.templates] Templates to use for showMore
* @param {object} [options.showMore.templates.active] Template used when showMore was clicked
* @param {object} [options.showMore.templates.inactive] Template used when showMore not clicked
* @param {object} [options.showMore.limit] Max number of facets values to display when showMore is clicked
* @param {Object} [options.templates] Templates to use for the widget

@@ -44,3 +50,3 @@ * @param {string|Function} [options.templates.header=''] Header template

[sortBy],
[limit],
[limit=10],
[cssClasses.{root,list,item}],

@@ -50,2 +56,3 @@ [templates.{header,item,footer}],

[autoHideContainer]
[showMore.{templates: {active, inactive}, limit}]
})`;

@@ -56,8 +63,15 @@ function menu({

sortBy = ['count:desc'],
limit = 100,
limit = 10,
cssClasses: userCssClasses = {},
templates = defaultTemplates,
transformData,
autoHideContainer = true
autoHideContainer = true,
showMore = false
} = {}) {
let showMoreConfig = getShowMoreConfig(showMore);
if (showMoreConfig && showMoreConfig.limit < limit) {
throw new Error('showMore.limit configuration should be > than the limit in the main configuration'); // eslint-disable-line
}
let widgetMaxValuesPerFacet = (showMoreConfig && showMoreConfig.limit) || limit;
if (!container || !attributeName) {

@@ -77,11 +91,24 @@ throw new Error(usage);

const showMoreTemplates = showMoreConfig && utils.prefixKeys('show-more-', showMoreConfig.templates);
const allTemplates =
showMoreTemplates ?
{...templates, ...showMoreTemplates} :
templates;
return {
getConfiguration: () => ({
hierarchicalFacets: [{
name: hierarchicalFacetName,
attributes: [attributeName]
}]
}),
getConfiguration: configuration => {
let widgetConfiguration = {
hierarchicalFacets: [{
name: hierarchicalFacetName,
attributes: [attributeName]
}]
};
let currentMaxValuesPerFacet = configuration.maxValuesPerFacet || 0;
widgetConfiguration.maxValuesPerFacet = Math.max(currentMaxValuesPerFacet, widgetMaxValuesPerFacet);
return widgetConfiguration;
},
render: function({results, helper, templatesConfig, state, createURL}) {
let facetValues = getFacetValues(results, hierarchicalFacetName, sortBy, limit);
let facetValues = getFacetValues(results, hierarchicalFacetName, sortBy);
let hasNoFacetValues = facetValues.length === 0;

@@ -93,3 +120,3 @@

templatesConfig,
templates
templates: allTemplates
});

@@ -114,3 +141,6 @@

facetValues={facetValues}
limitMax={widgetMaxValuesPerFacet}
limitMin={limit}
shouldAutoHideContainer={hasNoFacetValues}
showMore={showMoreConfig !== null}
templateProps={templateProps}

@@ -131,9 +161,9 @@ toggleRefinement={toggleRefinement.bind(null, helper, hierarchicalFacetName)}

function getFacetValues(results, hierarchicalFacetName, sortBy, limit) {
function getFacetValues(results, hierarchicalFacetName, sortBy) {
let values = results
.getFacetValues(hierarchicalFacetName, {sortBy: sortBy});
return values.data && values.data.slice(0, limit) || [];
return values.data || [];
}
export default menu;
import React from 'react';
import ReactDOM from 'react-dom';
import mapKeys from 'lodash/object/mapKeys';

@@ -11,5 +10,5 @@ import utils from '../../lib/utils.js';

import headerFooterHOC from '../../decorators/headerFooter.js';
import getShowMoreConfig from '../../lib/show-more/getShowMoreConfig.js';
import defaultTemplates from './defaultTemplates.js';
import defaultShowMoreTemplates from './defaultShowMoreTemplates.js';

@@ -24,7 +23,7 @@ /**

* @param {string} [options.limit=10] How much facet values to get. When the show more feature is activated this is the minimun number of facets requested (the show more button is not in active state).
* @param {object|boolean} [options.showMore] pass a configuration object, or true to use the default configuration
* @param {object} [options.showMore.templates] templates to use
* @param {object} [options.showMore.templates.active] template used when more facets are displayed
* @param {object} [options.showMore.templates.inactive] template used when less facets are displayed
* @param {object} [options.showMore.limit] the max number of facets values to display when the show more feature is active
* @param {object|boolean} [options.showMore=false] Limit the number of results and display a showMore button
* @param {object} [options.showMore.templates] Templates to use for showMore
* @param {object} [options.showMore.templates.active] Template used when showMore was clicked
* @param {object} [options.showMore.templates.inactive] Template used when showMore not clicked
* @param {object} [options.showMore.limit] Max number of facets values to display when showMore is clicked
* @param {Object} [options.templates] Templates to use for the widget

@@ -72,3 +71,3 @@ * @param {string|Function} [options.templates.header] Header template

autoHideContainer = true,
showMore
showMore = false
}) {

@@ -100,3 +99,3 @@ let showMoreConfig = getShowMoreConfig(showMore);

const showMoreTemplates = showMoreConfig && prefixKeys('show-more-', showMoreConfig.templates);
const showMoreTemplates = showMoreConfig && utils.prefixKeys('show-more-', showMoreConfig.templates);
const allTemplates =

@@ -168,31 +167,2 @@ showMoreTemplates ?

const defaultShowMoreConfig = {
templates: defaultShowMoreTemplates,
limit: 100
};
function getShowMoreConfig(showMoreOptions) {
if (showMoreOptions === true) {
return defaultShowMoreConfig;
} else if (showMoreOptions) {
let config = {...showMoreOptions};
if (!showMoreOptions.templates) {
config.templates = defaultShowMoreConfig.templates;
}
if (!showMoreOptions.limit) {
config.limit = defaultShowMoreConfig.limit;
}
return config;
}
return null;
}
function prefixKeys(prefix, obj) {
if (obj) {
return mapKeys(obj, function(v, k) {
return prefix + k;
});
}
}
export default refinementList;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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