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

react-autowhatever

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-autowhatever - npm Package Compare versions

Comparing version 1.3.6 to 2.0.0

213

dist/Autowhatever.js
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })();
var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();
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; };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
Object.defineProperty(exports, "__esModule", {
value: true
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _react = require('react');

@@ -33,65 +25,23 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function noop() {}
var Autowhatever = (function (_Component) {
_inherits(Autowhatever, _Component);
_createClass(Autowhatever, null, [{
key: 'propTypes',
value: {
id: _react.PropTypes.string, // Used in aria-* attributes. If multiple Autowhatever's are rendered on a page, they must have unique ids.
multiSection: _react.PropTypes.bool, // Indicates whether a multi section layout should be rendered.
items: _react.PropTypes.array.isRequired, // Array of items or sections to render.
renderItem: _react.PropTypes.func, // This function renders a single item.
shouldRenderSection: _react.PropTypes.func, // This function gets a section and returns whether it should be rendered, or not.
renderSectionTitle: _react.PropTypes.func, // This function gets a section and renders its title.
getSectionItems: _react.PropTypes.func, // This function gets a section and returns its items, which will be passed into `renderItem` for rendering.
inputProps: _react.PropTypes.object, // Arbitrary input props
itemProps: _react.PropTypes.object, // Arbitrary item props
focusedSectionIndex: _react.PropTypes.number, // Section index of the focused item
focusedItemIndex: _react.PropTypes.number, // Focused item index (within a section)
theme: _react.PropTypes.object // Styles. See: https://github.com/markdalgleish/react-themeable
},
enumerable: true
}, {
key: 'defaultProps',
value: {
id: '1',
multiSection: false,
shouldRenderSection: function shouldRenderSection() {
return true;
},
renderItem: function renderItem() {
throw new Error('`renderItem` must be provided');
},
renderSectionTitle: function renderSectionTitle() {
throw new Error('`renderSectionTitle` must be provided');
},
getSectionItems: function getSectionItems() {
throw new Error('`getSectionItems` must be provided');
},
inputProps: {},
itemProps: {},
focusedSectionIndex: null,
focusedItemIndex: null,
theme: {
container: 'react-autowhatever__container',
'container--open': 'react-autowhatever__container--open',
input: 'react-autowhatever__input',
'items-container': 'react-autowhatever__items-container',
item: 'react-autowhatever__item',
'item--focused': 'react-autowhatever__item--focused',
'section-container': 'react-autowhatever__section-container',
'section-title': 'react-autowhatever__section-title',
'section-items-container': 'react-autowhatever__section-items-container'
}
},
enumerable: true
}]);
function Autowhatever(props) {
_classCallCheck(this, Autowhatever);
_get(Object.getPrototypeOf(Autowhatever.prototype), 'constructor', this).call(this, props);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Autowhatever).call(this, props));
this.onKeyDown = this.onKeyDown.bind(this);
}
_this.onKeyDown = _this.onKeyDown.bind(_this);
return _this;
} // Styles. See: https://github.com/markdalgleish/react-themeable

@@ -121,3 +71,3 @@ _createClass(Autowhatever, [{

value: function renderItemsList(theme, items, sectionIndex) {
var _this = this;
var _this2 = this;

@@ -128,25 +78,28 @@ var _props = this.props;

var focusedItemIndex = _props.focusedItemIndex;
var _props$itemProps = this.props.itemProps;
var onMouseEnter = _props$itemProps.onMouseEnter;
var onMouseLeave = _props$itemProps.onMouseLeave;
var onMouseDown = _props$itemProps.onMouseDown;
var onClick = _props$itemProps.onClick;
var isItemPropsFunction = typeof this.props.itemProps === 'function';
return items.map(function (item, itemIndex) {
var itemPropsObj = isItemPropsFunction ? _this2.props.itemProps({ sectionIndex: sectionIndex, itemIndex: itemIndex }) : _this2.props.itemProps;
var onMouseEnter = itemPropsObj.onMouseEnter;
var onMouseLeave = itemPropsObj.onMouseLeave;
var onMouseDown = itemPropsObj.onMouseDown;
var onClick = itemPropsObj.onClick;
var onMouseEnterFn = onMouseEnter ? function (event) {
return onMouseEnter(event, { sectionIndex: sectionIndex, itemIndex: itemIndex });
} : function () {};
} : noop;
var onMouseLeaveFn = onMouseLeave ? function (event) {
return onMouseLeave(event, { sectionIndex: sectionIndex, itemIndex: itemIndex });
} : function () {};
} : noop;
var onMouseDownFn = onMouseDown ? function (event) {
return onMouseDown(event, { sectionIndex: sectionIndex, itemIndex: itemIndex });
} : function () {};
} : noop;
var onClickFn = onClick ? function (event) {
return onClick(event, { sectionIndex: sectionIndex, itemIndex: itemIndex });
} : function () {};
} : noop;
var itemProps = _extends({
id: _this.getItemId(sectionIndex, itemIndex),
id: _this2.getItemId(sectionIndex, itemIndex),
role: 'option'
}, theme(itemIndex, 'item', sectionIndex === focusedSectionIndex && itemIndex === focusedItemIndex && 'item--focused'), _this.props.itemProps, {
}, theme(itemIndex, 'item', sectionIndex === focusedSectionIndex && itemIndex === focusedItemIndex && 'item--focused'), itemPropsObj, {
onMouseEnter: onMouseEnterFn,

@@ -158,3 +111,3 @@ onMouseLeave: onMouseLeaveFn,

return _react2['default'].createElement(
return _react2.default.createElement(
'li',

@@ -169,3 +122,3 @@ itemProps,

value: function renderSections(theme) {
var _this2 = this;
var _this3 = this;

@@ -191,3 +144,3 @@ var _props2 = this.props;

return _react2['default'].createElement(
return _react2.default.createElement(
'div',

@@ -204,7 +157,7 @@ _extends({ id: this.getItemsContainerId(),

return _react2['default'].createElement(
return _react2.default.createElement(
'div',
_extends({ key: sectionIndex
}, theme(sectionIndex, 'section-container')),
sectionTitle && _react2['default'].createElement(
sectionTitle && _react2.default.createElement(
'div',

@@ -214,6 +167,6 @@ theme('section-title', 'section-title'),

),
_react2['default'].createElement(
_react2.default.createElement(
'ul',
theme('section-items-container', 'section-items-container'),
_this2.renderItemsList(theme, sectionItemsArray[sectionIndex], sectionIndex)
_this3.renderItemsList(theme, sectionItemsArray[sectionIndex], sectionIndex)
)

@@ -233,3 +186,3 @@ );

return _react2['default'].createElement(
return _react2.default.createElement(
'ul',

@@ -249,3 +202,6 @@ _extends({ id: this.getItemsContainerId(),

var focusedItemIndex = _props4.focusedItemIndex;
var onKeyDown = inputProps.onKeyDown;
var onKeyDownFn = inputProps.onKeyDown; // Babel is throwing:
// "onKeyDown" is read-only
// on:
// const { onKeyDown } = inputProps;

@@ -255,8 +211,8 @@ switch (event.key) {

case 'ArrowUp':
var _props5 = this.props,
multiSection = _props5.multiSection,
items = _props5.items,
getSectionItems = _props5.getSectionItems;
var _props5 = this.props;
var multiSection = _props5.multiSection;
var items = _props5.items;
var getSectionItems = _props5.getSectionItems;
var sectionIterator = (0, _sectionIterator2['default'])({
var sectionIterator = (0, _sectionIterator2.default)({
multiSection: multiSection,

@@ -269,12 +225,14 @@ data: multiSection ? items.map(function (section) {

var _sectionIterator$nextPrev = sectionIterator[nextPrev]([focusedSectionIndex, focusedItemIndex]),
_sectionIterator$nextPrev2 = _slicedToArray(_sectionIterator$nextPrev, 2),
newFocusedSectionIndex = _sectionIterator$nextPrev2[0],
newFocusedItemIndex = _sectionIterator$nextPrev2[1];
var _sectionIterator$next = sectionIterator[nextPrev]([focusedSectionIndex, focusedItemIndex]);
onKeyDown(event, { newFocusedSectionIndex: newFocusedSectionIndex, newFocusedItemIndex: newFocusedItemIndex });
var _sectionIterator$next2 = _slicedToArray(_sectionIterator$next, 2);
var newFocusedSectionIndex = _sectionIterator$next2[0];
var newFocusedItemIndex = _sectionIterator$next2[1];
onKeyDownFn(event, { newFocusedSectionIndex: newFocusedSectionIndex, newFocusedItemIndex: newFocusedItemIndex });
break;
default:
onKeyDown(event, { focusedSectionIndex: focusedSectionIndex, focusedItemIndex: focusedItemIndex });
onKeyDownFn(event, { focusedSectionIndex: focusedSectionIndex, focusedItemIndex: focusedItemIndex });
}

@@ -290,3 +248,3 @@ }

var theme = (0, _reactThemeable2['default'])(this.props.theme);
var theme = (0, _reactThemeable2.default)(this.props.theme);
var renderedItems = multiSection ? this.renderSections(theme) : this.renderItems(theme);

@@ -309,6 +267,6 @@ var isOpen = renderedItems !== null;

return _react2['default'].createElement(
return _react2.default.createElement(
'div',
theme('container', 'container', isOpen && 'container--open'),
_react2['default'].createElement('input', inputProps),
_react2.default.createElement('input', inputProps),
renderedItems

@@ -322,3 +280,46 @@ );

exports['default'] = Autowhatever;
module.exports = exports['default'];
Autowhatever.propTypes = {
id: _react.PropTypes.string, // Used in aria-* attributes. If multiple Autowhatever's are rendered on a page, they must have unique ids.
multiSection: _react.PropTypes.bool, // Indicates whether a multi section layout should be rendered.
items: _react.PropTypes.array.isRequired, // Array of items or sections to render.
renderItem: _react.PropTypes.func, // This function renders a single item.
shouldRenderSection: _react.PropTypes.func, // This function gets a section and returns whether it should be rendered, or not.
renderSectionTitle: _react.PropTypes.func, // This function gets a section and renders its title.
getSectionItems: _react.PropTypes.func, // This function gets a section and returns its items, which will be passed into `renderItem` for rendering.
inputProps: _react.PropTypes.object, // Arbitrary input props
itemProps: _react.PropTypes.object, // Arbitrary item props
focusedSectionIndex: _react.PropTypes.number, // Section index of the focused item
focusedItemIndex: _react.PropTypes.number, // Focused item index (within a section)
theme: _react.PropTypes.object };
Autowhatever.defaultProps = {
id: '1',
multiSection: false,
shouldRenderSection: function shouldRenderSection() {
return true;
},
renderItem: function renderItem() {
throw new Error('`renderItem` must be provided');
},
renderSectionTitle: function renderSectionTitle() {
throw new Error('`renderSectionTitle` must be provided');
},
getSectionItems: function getSectionItems() {
throw new Error('`getSectionItems` must be provided');
},
inputProps: {},
itemProps: {},
focusedSectionIndex: null,
focusedItemIndex: null,
theme: {
container: 'react-autowhatever__container',
'container--open': 'react-autowhatever__container--open',
input: 'react-autowhatever__input',
'items-container': 'react-autowhatever__items-container',
item: 'react-autowhatever__item',
'item--focused': 'react-autowhatever__item--focused',
'section-container': 'react-autowhatever__section-container',
'section-title': 'react-autowhatever__section-title',
'section-items-container': 'react-autowhatever__section-items-container'
}
};
exports.default = Autowhatever;
{
"name": "react-autowhatever",
"version": "1.3.6",
"version": "2.0.0",
"description": "Accessible rendering layer for Autosuggest and Autocomplete components",

@@ -13,4 +13,4 @@ "main": "dist/Autowhatever.js",

"start": "mkdir -p demo/dist && npm run copy-static-files && node server",
"lint": "eslint demo/src src server.js webpack.dev.config.js",
"test": "mocha --opts mocha.opts",
"lint": "eslint demo/src src server.js webpack.dev.config.js webpack.gh-pages.config.js",
"test": "mocha --compilers js:babel-core/register --recursive src/**/*.test.js",
"copy-static-files": "cp demo/src/index.html demo/dist/",

@@ -26,28 +26,34 @@ "dist": "rm -rf dist && mkdir dist && babel src/Autowhatever.js --out-file dist/Autowhatever.js",

"dependencies": {
"react": "^0.14.0-beta3",
"react-themeable": "^1.0.1",
"section-iterator": "^1.1.0"
},
"peerDependencies": {
"react": "^0.14.5"
},
"devDependencies": {
"autoprefixer-loader": "^2.1.0",
"babel": "^5.8.23",
"babel-eslint": "^4.1.1",
"babel-loader": "^5.3.2",
"chai": "^3.2.0",
"css-loader": "^0.17.0",
"eslint": "^1.3.1",
"eslint-plugin-react": "^3.11.3",
"extract-text-webpack-plugin": "^0.8.2",
"less": "^2.5.1",
"less-loader": "^2.2.0",
"mocha": "^2.3.0",
"react-dom": "^0.14.0-beta3",
"autoprefixer-loader": "^3.1.0",
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-eslint": "^5.0.0-beta6",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"chai": "^3.4.1",
"css-loader": "^0.23.1",
"eslint": "^1.10.3",
"eslint-plugin-react": "^3.13.1",
"extract-text-webpack-plugin": "^0.9.1",
"less": "^2.5.3",
"less-loader": "^2.2.2",
"mocha": "^2.3.4",
"react-dom": "^0.14.5",
"react-hot-loader": "^1.3.0",
"react-redux": "^2.1.0",
"redux": "^2.0.0",
"redux-devtools": "^2.1.0",
"redux-devtools-diff-monitor": "^1.0.0",
"style-loader": "^0.12.3",
"webpack": "^1.12.1",
"webpack-dev-server": "^1.10.1"
"react-redux": "^4.0.6",
"redux": "^3.0.5",
"redux-devtools": "^3.0.1",
"redux-devtools-diff-monitor": "^3.0.0",
"style-loader": "^0.13.0",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},

@@ -54,0 +60,0 @@ "files": [

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