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

tinper-bee-core

Package Overview
Dependencies
Maintainers
3
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinper-bee-core - npm Package Compare versions

Comparing version 0.2.9 to 0.2.10

39

js/Align.js

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

import React, { PropTypes, Component } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import createReactClass from 'create-react-class';
import align from 'dom-align';

@@ -32,5 +34,3 @@ import addEventListener from './addEventListener';

}
class Align extends Component{
static propTypes = {
const propTypes = {
childrenProps: PropTypes.object,

@@ -44,13 +44,20 @@ align: PropTypes.object.isRequired,

children: PropTypes.any,
};
}
static defaultProps = {
target() {
return window;
},
onAlign() {
},
monitorBufferTime: 50,
monitorWindowResize: false,
disabled: false,
const defaultProps = {
target() {
return window;
},
onAlign() {
},
monitorBufferTime: 50,
monitorWindowResize: false,
disabled: false,
}
class Align extends React.Component {
constructor(props) {
super(props);
}

@@ -100,3 +107,3 @@

startMonitorWindowResize = () => {
startMonitorWindowResize() {
if (!this.resizeHandler) {

@@ -140,2 +147,4 @@ this.bufferMonitor = buffer(this.forceAlign, this.props.monitorBufferTime);

Align.defaultProps = defaultProps;
Align.propTypes = propTypes;
export default Align;

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

var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _reactDom = require('react-dom');

@@ -14,2 +18,6 @@

var _createReactClass = require('create-react-class');
var _createReactClass2 = _interopRequireDefault(_createReactClass);
var _domAlign = require('dom-align');

@@ -58,33 +66,35 @@

}
var propTypes = {
childrenProps: _propTypes2.default.object,
align: _propTypes2.default.object.isRequired,
target: _propTypes2.default.func,
onAlign: _propTypes2.default.func,
monitorBufferTime: _propTypes2.default.number,
monitorWindowResize: _propTypes2.default.bool,
disabled: _propTypes2.default.bool,
children: _propTypes2.default.any
};
var Align = function (_Component) {
_inherits(Align, _Component);
var defaultProps = {
target: function target() {
return window;
},
onAlign: function onAlign() {},
function Align() {
var _temp, _this, _ret;
monitorBufferTime: 50,
monitorWindowResize: false,
disabled: false
};
var Align = function (_React$Component) {
_inherits(Align, _React$Component);
function Align(props) {
_classCallCheck(this, Align);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.startMonitorWindowResize = function () {
if (!_this.resizeHandler) {
_this.bufferMonitor = buffer(_this.forceAlign, _this.props.monitorBufferTime);
_this.resizeHandler = (0, _addEventListener2.default)(window, 'resize', _this.bufferMonitor);
}
}, _this.stopMonitorWindowResize = function () {
if (_this.resizeHandler) {
_this.bufferMonitor.clear();
_this.resizeHandler.remove();
_this.resizeHandler = null;
}
}, _this.forceAlign = function () {
var props = _this.props;
if (!props.disabled) {
var source = _reactDom2.default.findDOMNode(_this);
props.onAlign(source, (0, _domAlign2.default)(source, props.target(), props.align));
}
}, _temp), _possibleConstructorReturn(_this, _ret);
_initialiseProps.call(_this);
return _this;
}

@@ -134,2 +144,9 @@

Align.prototype.startMonitorWindowResize = function startMonitorWindowResize() {
if (!this.resizeHandler) {
this.bufferMonitor = buffer(this.forceAlign, this.props.monitorBufferTime);
this.resizeHandler = (0, _addEventListener2.default)(window, 'resize', this.bufferMonitor);
}
};
Align.prototype.render = function render() {

@@ -154,26 +171,28 @@ var _props = this.props,

return Align;
}(_react.Component);
}(_react2.default.Component);
Align.propTypes = {
childrenProps: _react.PropTypes.object,
align: _react.PropTypes.object.isRequired,
target: _react.PropTypes.func,
onAlign: _react.PropTypes.func,
monitorBufferTime: _react.PropTypes.number,
monitorWindowResize: _react.PropTypes.bool,
disabled: _react.PropTypes.bool,
children: _react.PropTypes.any
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.stopMonitorWindowResize = function () {
if (_this2.resizeHandler) {
_this2.bufferMonitor.clear();
_this2.resizeHandler.remove();
_this2.resizeHandler = null;
}
};
this.forceAlign = function () {
var props = _this2.props;
if (!props.disabled) {
var source = _reactDom2.default.findDOMNode(_this2);
props.onAlign(source, (0, _domAlign2.default)(source, props.target(), props.align));
}
};
};
Align.defaultProps = {
target: function target() {
return window;
},
onAlign: function onAlign() {},
monitorBufferTime: 50,
monitorWindowResize: false,
disabled: false
};
;
Align.defaultProps = defaultProps;
Align.propTypes = propTypes;
exports.default = Align;
{
"name": "tinper-bee-core",
"version": "0.2.9",
"version": "0.2.10",
"description": "style core and js util for tinper-bee",

@@ -25,4 +25,10 @@ "main": "lib/index.js",

},
"peerDependencies": {
"react": "^15.3.0 || ^16.0",
"react-dom": "^15.3.0 || ^16.0",
"prop-types": "15.6.0"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"prop-types": "^15.5.10",
"babel-plugin-istanbul": "^3.0.0",

@@ -29,0 +35,0 @@ "babel-plugin-transform-object-assign": "^6.8.0",

@@ -74,84 +74,1 @@ # bee-core

- UI组件的预设
### js方法
#### keyCode对象
引入方法:
```
import keyCode from 'tinper-bee-core/lib/keyCode';
//或者
import { keyCode } from 'tinper-bee-core';
```
方法:
- isTextModifyingKeyEvent 验证是否是特殊按键或组合按键
```
handleKeyDown = (e) => {
if(keyCode.isTextModifyingKeyEvent(e)){
//一些操作
}
}
...
<Input onKeyDown={this.handleKeyDown} />
```
- isCharacterKey 验证是否是文本键
```
handleKeyDown = (e) => {
if(keyCode.isCharacterKey(e)){
//一些操作
}
}
...
<Input onKeyDown={this.handleKeyDown} />
```
#### toArray 将数组安全的转换为react element 数组
#### splitComponentProps 通过父组件的propTypes拆分分别传给父子组件的props
```
const propTypes = {
color: PropTypes.string,
size: PropTypes.string
}
class ParentClass extends React.Component{
render() {
let props = this.props;
let [parentProps, childProps] = splitComponentProps(props);
return (
<div>
<ChildrenClass {...childProps} />
</div>
)
}
}
ParentClass.propTypes = propTypes;
```
#### createChainedFunction 创建链式调用方法
用法:
```
```
#### contains 检验是否包含
####

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