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

stardust

Package Overview
Dependencies
Maintainers
13
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stardust - npm Package Compare versions

Comparing version 0.46.2 to 0.46.3

50

dist/commonjs/collections/Menu/Menu.js

@@ -11,10 +11,6 @@ 'use strict';

var _get3 = require('lodash/get');
var _get2 = require('lodash/get');
var _get4 = _interopRequireDefault(_get3);
var _get3 = _interopRequireDefault(_get2);
var _findIndex2 = require('lodash/findIndex');
var _findIndex3 = _interopRequireDefault(_findIndex2);
var _without2 = require('lodash/without');

@@ -28,4 +24,2 @@

var _get2 = function get(object, property, receiver) { 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 { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _classnames = require('classnames');

@@ -41,2 +35,4 @@

var _factories = require('../../factories');
var _MenuHeader = require('./MenuHeader');

@@ -105,3 +101,3 @@

if ((0, _get4.default)(items[index], 'onClick')) items[index].onClick(e, { name: name, index: index });
if ((0, _get3.default)(items[index], 'onClick')) items[index].onClick(e, { name: name, index: index });
if (onItemClick) onItemClick(e, { name: name, index: index });

@@ -112,11 +108,2 @@ }, _temp), _possibleConstructorReturn(_this, _ret);

_createClass(Menu, [{
key: 'componentWillMount',
value: function componentWillMount() {
_get2(Menu.prototype.__proto__ || Object.getPrototypeOf(Menu.prototype), 'componentWillMount', this).call(this);
var items = this.props.items;
if (items) this.trySetState({ activeIndex: (0, _findIndex3.default)(items, ['active', true]) });
}
}, {
key: 'renderItems',

@@ -131,17 +118,14 @@ value: function renderItems() {

return (0, _map3.default)(items, function (item, index) {
var content = item.content;
var childKey = item.childKey;
var name = item.name;
var itemProps = item.itemProps;
var finalKey = childKey || [content, name].join('-');
return _react2.default.createElement(_MenuItem2.default, _extends({}, itemProps, {
return (0, _factories.createShorthand)(_MenuItem2.default, function (val) {
return { content: val };
}, item, {
active: activeIndex === index,
content: content,
childKey: function childKey(_ref3) {
var content = _ref3.content;
var name = _ref3.name;
return [content, name].join('-');
},
index: index,
key: finalKey,
name: name,
onClick: _this2.handleItemClick
}));
});
});

@@ -234,5 +218,5 @@ }

/** Shorthand array of props for Menu. Mutually exclusive with children. */
items: _lib.customPropTypes.every([_lib.customPropTypes.disallow(['children']), _react.PropTypes.arrayOf(_react.PropTypes.shape({
childKey: _react.PropTypes.oneOfType([_react.PropTypes.number, _react.PropTypes.string])
}))]),
items: _lib.customPropTypes.every([_lib.customPropTypes.disallow(['children']),
// Array of shorthands for MenuItem
_react.PropTypes.arrayOf(_react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.element, _react.PropTypes.object]))]),

@@ -239,0 +223,0 @@ /** onClick handler for MenuItem. Mutually exclusive with children. */

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

var _isFunction2 = require('lodash/isFunction');
var _isFunction3 = _interopRequireDefault(_isFunction2);
var _has2 = require('lodash/has');

@@ -55,16 +59,26 @@

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
/**
* Merges props and classNames.
*
* @param {object} defaultProps A props object
* @param {object} props A props object
* @param {object} extraProps A props object
* @returns {object} A new props object
*/
var mergePropsAndClassName = function mergePropsAndClassName(props, extraProps) {
var newProps = _extends({}, props, extraProps);
var mergePropsAndClassName = function mergePropsAndClassName(defaultProps, props) {
var _defaultProps$props = _extends({}, defaultProps, props);
if ((0, _has3.default)(props, 'className') || (0, _has3.default)(extraProps.className)) {
newProps.className = (0, _classnames2.default)(props.className, extraProps.className); // eslint-disable-line react/prop-types
var childKey = _defaultProps$props.childKey;
var newProps = _objectWithoutProperties(_defaultProps$props, ['childKey']);
if ((0, _has3.default)(props, 'className') || (0, _has3.default)(defaultProps.className)) {
newProps.className = (0, _classnames2.default)(defaultProps.className, props.className); // eslint-disable-line react/prop-types
}
if (!newProps.key) {
newProps.key = (0, _isFunction3.default)(childKey) ? childKey(newProps) : childKey;
}
return newProps;

@@ -80,11 +94,11 @@ };

* @param {string|object|function} val The value to create a ReactElement from
* @param {object} extraProps Additional props to add to the final ReactElement
* @param {object} defaultProps Default props to add to the final ReactElement
* @returns {function|null}
*/
function createShorthand(Component, mapValueToProps, val) {
var extraProps = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var defaultProps = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
// Clone ReactElements
if ((0, _react.isValidElement)(val)) {
return _react2.default.cloneElement(val, mergePropsAndClassName(val.props, extraProps));
return _react2.default.cloneElement(val, mergePropsAndClassName(defaultProps, val.props));
}

@@ -94,3 +108,3 @@

if ((0, _isPlainObject3.default)(val)) {
return _react2.default.createElement(Component, mergePropsAndClassName(val, extraProps));
return _react2.default.createElement(Component, mergePropsAndClassName(defaultProps, val));
}

@@ -100,3 +114,3 @@

if ((0, _isString3.default)(val) || (0, _isNumber3.default)(val)) {
return _react2.default.createElement(Component, mergePropsAndClassName(mapValueToProps(val), extraProps));
return _react2.default.createElement(Component, mergePropsAndClassName(defaultProps, mapValueToProps(val)));
}

@@ -103,0 +117,0 @@

{
"name": "stardust",
"version": "0.46.2",
"version": "0.46.3",
"description": "The official Semantic-UI-React integration.",

@@ -91,2 +91,3 @@ "main": "dist/commonjs/index.js",

"imports-loader": "^0.6.4",
"js-beautify": "^1.6.4",
"json-loader": "^0.5.3",

@@ -93,0 +94,0 @@ "karma": "^1.3.0",

@@ -17,2 +17,3 @@ import _ from 'lodash'

} from '../../lib'
import { createShorthand } from '../../factories'
import MenuHeader from './MenuHeader'

@@ -96,10 +97,8 @@ import MenuItem from './MenuItem'

customPropTypes.disallow(['children']),
PropTypes.arrayOf(PropTypes.shape({
childKey: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
// this object is spread on the MenuItem
// allow it to validate props instead
})),
// Array of shorthands for MenuItem
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.string,
PropTypes.element,
PropTypes.object,
])),
]),

@@ -154,9 +153,2 @@

componentWillMount() {
super.componentWillMount()
const { items } = this.props
if (items) this.trySetState({ activeIndex: _.findIndex(items, ['active', true]) })
}
handleItemClick = (e, { name, index }) => {

@@ -175,16 +167,8 @@ this.trySetState({ activeIndex: index })

return _.map(items, (item, index) => {
const { content, childKey, name, itemProps } = item
const finalKey = childKey || [content, name].join('-')
return (
<MenuItem
{...itemProps}
active={activeIndex === index}
content={content}
index={index}
key={finalKey}
name={name}
onClick={this.handleItemClick}
/>
)
return createShorthand(MenuItem, val => ({ content: val }), item, {
active: activeIndex === index,
childKey: ({ content, name }) => [content, name].join('-'),
index,
onClick: this.handleItemClick,
})
})

@@ -191,0 +175,0 @@ }

@@ -12,13 +12,17 @@ import _ from 'lodash'

*
* @param {object} defaultProps A props object
* @param {object} props A props object
* @param {object} extraProps A props object
* @returns {object} A new props object
*/
const mergePropsAndClassName = (props, extraProps) => {
const newProps = { ...props, ...extraProps }
const mergePropsAndClassName = (defaultProps, props) => {
const { childKey, ...newProps } = { ...defaultProps, ...props }
if (_.has(props, 'className') || _.has(extraProps.className)) {
newProps.className = cx(props.className, extraProps.className) // eslint-disable-line react/prop-types
if (_.has(props, 'className') || _.has(defaultProps.className)) {
newProps.className = cx(defaultProps.className, props.className) // eslint-disable-line react/prop-types
}
if (!newProps.key) {
newProps.key = _.isFunction(childKey) ? childKey(newProps) : childKey
}
return newProps

@@ -34,9 +38,9 @@ }

* @param {string|object|function} val The value to create a ReactElement from
* @param {object} extraProps Additional props to add to the final ReactElement
* @param {object} defaultProps Default props to add to the final ReactElement
* @returns {function|null}
*/
export function createShorthand(Component, mapValueToProps, val, extraProps = {}) {
export function createShorthand(Component, mapValueToProps, val, defaultProps = {}) {
// Clone ReactElements
if (isValidElement(val)) {
return React.cloneElement(val, mergePropsAndClassName(val.props, extraProps))
return React.cloneElement(val, mergePropsAndClassName(defaultProps, val.props))
}

@@ -46,3 +50,3 @@

if (_.isPlainObject(val)) {
return <Component {...mergePropsAndClassName(val, extraProps)} />
return <Component {...mergePropsAndClassName(defaultProps, val)} />
}

@@ -52,3 +56,3 @@

if (_.isString(val) || _.isNumber(val)) {
return <Component {...mergePropsAndClassName(mapValueToProps(val), extraProps)} />
return <Component {...mergePropsAndClassName(defaultProps, mapValueToProps(val))} />
}

@@ -55,0 +59,0 @@

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