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

@semcore/button

Package Overview
Dependencies
Maintainers
1
Versions
301
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@semcore/button - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

lib/Button.d.ts

8

CHANGELOG.md

@@ -5,2 +5,10 @@ # Changelog

## [1.2.0] - 2018-11-23
### Added
- Добавлен autocomplete для IDE
- Добавлена возможность изменять тег на произвольный
- Добавлена возможность отключать размер и стили
## [1.1.1] - 2018-10-09

@@ -7,0 +15,0 @@

265

lib/index.js

@@ -7,6 +7,12 @@ 'use strict';

var _objectWithoutProperties = _interopDefault(require('@babel/runtime/helpers/objectWithoutProperties'));
var React = require('react');
var React__default = _interopDefault(React);
var Spin = _interopDefault(require('@semcore/spin'));
var PropTypes = _interopDefault(require('prop-types'));
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
var _classCallCheck = _interopDefault(require('@babel/runtime/helpers/classCallCheck'));
var _createClass = _interopDefault(require('@babel/runtime/helpers/createClass'));
var _possibleConstructorReturn = _interopDefault(require('@babel/runtime/helpers/possibleConstructorReturn'));
var _getPrototypeOf = _interopDefault(require('@babel/runtime/helpers/getPrototypeOf'));
var _inherits = _interopDefault(require('@babel/runtime/helpers/inherits'));
var cn = _interopDefault(require('classnames'));

@@ -19,154 +25,22 @@ var compose = _interopDefault(require('@semcore/utils/lib/compose'));

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
var SPIN_SIZE_MAP;
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);
}
}
(function (SPIN_SIZE_MAP) {
SPIN_SIZE_MAP["xl"] = "m";
SPIN_SIZE_MAP["l"] = "s";
SPIN_SIZE_MAP["m"] = "xs";
SPIN_SIZE_MAP["s"] = "xxs";
})(SPIN_SIZE_MAP || (SPIN_SIZE_MAP = {}));
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var SPIN_THEME_MAP;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
(function (SPIN_THEME_MAP) {
SPIN_THEME_MAP["primary-info"] = "invert";
SPIN_THEME_MAP["primary-success"] = "invert";
SPIN_THEME_MAP["primary-warning"] = "invert";
SPIN_THEME_MAP["primary-danger"] = "invert";
SPIN_THEME_MAP["secondary-invert"] = "invert";
SPIN_THEME_MAP["tertiary-invert"] = "invert";
})(SPIN_THEME_MAP || (SPIN_THEME_MAP = {}));
return obj;
}
function _extends() {
_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;
};
return _extends.apply(this, arguments);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
var SPIN_SIZE_MAP = {
xl: 'm',
l: 's',
m: 'xs',
s: 'xxs'
};
var SPIN_THEME_MAP = {
'primary-info': 'invert',
'primary-success': 'invert',
'primary-warning': 'invert',
'primary-danger': 'invert',
'secondary-invert': 'invert',
'tertiary-invert': 'invert'
};
function SpinButton(props) {

@@ -177,3 +51,3 @@ var theme = props.theme,

return React__default.createElement(Spin, _extends({
return React__default.createElement(Spin, Object.assign({
size: SPIN_SIZE_MAP[size],

@@ -330,10 +204,8 @@ theme: SPIN_THEME_MAP[theme] || 'dark'

};
var SIZES = ['xl', 'l', 'm', 's'];
var THEME = ['info', 'success', 'warning', 'danger', 'muted', 'invert'];
var USE = ['primary', 'secondary', 'tertiary'];
var MAP_USE_DEFAULT_THEME = {
primary: 'info',
secondary: 'muted',
tertiary: 'info'
};
(function (MAP_USE_DEFAULT_THEME) {
MAP_USE_DEFAULT_THEME["primary"] = "info";
MAP_USE_DEFAULT_THEME["secondary"] = "muted";
MAP_USE_DEFAULT_THEME["tertiary"] = "info";
})(exports.MAP_USE_DEFAULT_THEME || (exports.MAP_USE_DEFAULT_THEME = {}));
/**

@@ -345,2 +217,3 @@ * ```js

var Button =

@@ -352,4 +225,2 @@ /*#__PURE__*/

function Button() {
var _getPrototypeOf2;
var _this;

@@ -359,9 +230,5 @@

for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _possibleConstructorReturn(this, _getPrototypeOf(Button).apply(this, arguments));
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Button)).call.apply(_getPrototypeOf2, [this].concat(args)));
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "callbackRef", function (node) {
_this.callbackRef = function (node) {
var inputRef = _this.props.inputRef;

@@ -372,3 +239,3 @@

}
});
};

@@ -384,2 +251,3 @@ return _this;

var _this$props = this.props,
Tag = _this$props.tag,
disabledProp = _this$props.disabled,

@@ -398,5 +266,5 @@ loading = _this$props.loading,

var disabled = loading || disabledProp;
var theme = themeProp || MAP_USE_DEFAULT_THEME[use];
var theme = themeProp || exports.MAP_USE_DEFAULT_THEME[use];
var styles = {
button: cn(block(), block.size(size), block.theme("".concat(use, "-").concat(theme)), (_cn = {}, _defineProperty(_cn, block.neighborLocation(neighborLocation), neighborLocation), _defineProperty(_cn, block.keyboardFocused(), keyboardFocused), _defineProperty(_cn, block.fullWidth(), fullWidth), _defineProperty(_cn, block.disabled(), disabled), _cn), className),
button: cn(block(), (_cn = {}, _defineProperty(_cn, block.theme("".concat(use, "-").concat(theme)), use && theme), _defineProperty(_cn, block.size(size), size), _defineProperty(_cn, block.neighborLocation(neighborLocation), neighborLocation), _defineProperty(_cn, block.keyboardFocused(), keyboardFocused), _defineProperty(_cn, block.fullWidth(), fullWidth), _defineProperty(_cn, block.disabled(), disabled), _cn), className),
inner: cn(inner(), _defineProperty({}, inner.loading(), loading)),

@@ -406,3 +274,3 @@ text: cn(text(), text.size(size)),

};
return React__default.createElement("button", _extends({
return React__default.createElement(Tag, Object.assign({
tabIndex: 0

@@ -433,53 +301,14 @@ }, propsForElement(this.props), {

_defineProperty(Button, "UIname", 'Button');
_defineProperty(Button, "displayName", 'Button');
_defineProperty(Button, "defaultProps", {
Button.UIname = 'Button';
Button.displayName = 'Button';
Button.defaultProps = {
tag: 'button',
use: 'secondary',
size: 'm',
type: 'button'
});
};
var WrappedButton = compose(WithKeyboardFocus(), WithNeighborLocation())(Button);
_defineProperty(Button, "propTypes", {
/** Размер кнопки */
size: PropTypes.oneOf(SIZES).isRequired,
/** Тип использования кнопки */
use: PropTypes.oneOf(USE).isRequired,
theme: function theme(props, propName, componentName) {
if (/primary/.test(props['use']) && props[propName] === 'muted') {
return new Error("Not use prop ".concat(propName, "=\"").concat(props[propName], "\" with prop use=\"primary\" in ").concat(componentName, ". Validation failed."));
}
if (props[propName] && !THEME.includes(props[propName])) {
return new Error("Not use prop ".concat(propName, " value ").concat(props[propName], " not includes ").concat(THEME.split(','), " in ").concat(componentName, ". Validation failed."));
}
return null;
},
/** Занимает всю ширину родителя */
fullWidth: PropTypes.bool,
/** Элемент слева внутри кнопки */
before: PropTypes.node,
/** Элемент справа внутри кнопки */
after: PropTypes.node,
/** Устанавливает состояние загрузки */
loading: PropTypes.bool,
/** Значение отвечающее за показ фокуса при переходе по кнопкам */
keyboardFocused: PropTypes.bool,
/** Значение изменяющие слить в зависимости от расположения соседий */
neighborLocation: PropTypes.oneOf(['right', 'both', 'left']),
/** Значение отвечающее за активность кнопки */
disabled: PropTypes.bool
});
var Button$1 = compose(WithKeyboardFocus(), WithNeighborLocation())(Button);
exports.default = Button$1;
exports.default = WrappedButton;
exports.Button = Button;
//# sourceMappingURL=index.js.map
{
"name": "@semcore/button",
"description": "SEMRush Button Component",
"version": "1.1.1",
"version": "1.2.0",
"main": "lib/index.js",
"module": "lib/index.es.js",
"typings": "lib/index.d.ts",
"author": "Roman Lysov <r.lysov@semrush.com>",
"license": "MIT",
"scripts": {
"build": "rollup --config=node:rollup-config-react",
"build": "rollup --config=node:rollup-config-ts",
"test": "jest"
},
"dependencies": {
"@semcore/spin": "^1.0.0",
"@semcore/utils": "^1.1.0",
"classnames": "^2.2.5",
"prop-types": "^15.6.1"
"@semcore/spin": "^1.1.1",
"@semcore/utils": "^1.3.0",
"@types/react": "^16.7.6",
"@babel/runtime": "^7.1.5",
"classnames": "^2.2.5"
},

@@ -18,0 +21,0 @@ "peerDependencies": {

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