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

bee-switch

Package Overview
Dependencies
Maintainers
15
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bee-switch - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

30

build/Switch.js

@@ -35,4 +35,8 @@ "use strict";

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) : _defaults(subClass, superClass); }
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) : _defaults(subClass, superClass); } /**
* This source code is quoted from rc-switch.
* homepage: https://github.com/react-component/switch
*/
var propTypes = {

@@ -119,14 +123,18 @@ clsPrefix: _propTypes2["default"].string,

"span",
_extends({}, others, {
ref: this.saveNode,
onClick: this.clickHandler,
onKeyDown: this.handleKeyDown,
onMouseUp: this.handleMouseUp,
className: (0, _classnames2["default"])(className, classNames),
tabIndex: disabled ? -1 : 0
}),
{ className: disabled && checked ? clsPrefix + "-backdrop" : '' },
_react2["default"].createElement(
"span",
{ className: clsPrefix + "-inner" },
checked ? checkedChildren : unCheckedChildren
_extends({}, others, {
ref: this.saveNode,
onClick: this.clickHandler,
onKeyDown: this.handleKeyDown,
onMouseUp: this.handleMouseUp,
className: (0, _classnames2["default"])(className, classNames),
tabIndex: disabled ? -1 : 0
}),
_react2["default"].createElement(
"span",
{ className: clsPrefix + "-inner" },
checked ? checkedChildren : unCheckedChildren
)
)

@@ -133,0 +141,0 @@ );

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

<a name="2.0.3"></a>
## [2.0.3](https://github.com/tinper-bee/switch/compare/v2.0.2...v2.0.3) (2019-04-02)
<a name="2.0.2"></a>

@@ -2,0 +7,0 @@ ## [2.0.2](https://github.com/tinper-bee/switch/compare/v2.0.1...v2.0.2) (2019-02-28)

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

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { Con, Row, Col } from 'bee-layout';
import { Panel } from 'bee-panel';
import Button from 'bee-button';
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Drawer from 'bee-drawer';
import Clipboard from 'bee-clipboard';
import Button from '../src';
const CARET = <i className="uf uf-arrow-down"></i>;
const CARETUP = <i className="uf uf-arrow-up"></i>;
{demolist}

@@ -22,32 +19,44 @@

}
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
handleClick=()=> {
this.setState({ open: !this.state.open })
}
fCloseDrawer=()=>{
this.setState({
open: false
})
}
render () {
const { title, example, code, desc, scss_code } = this.props;
let caret = this.state.open ? CARETUP : CARET;
let text = this.state.open ? "隐藏代码" : "查看代码";
const header = (
<div>
{example}
<Button style={{"marginTop": "10px"}} shape="block" onClick={ this.handleClick }>
{ caret }
{ text }
</Button>
<p className='component-title'>{ title }</p>
<p>{ desc }</p>
<span className='component-code' onClick={this.handleClick}> 查看源码 <i className='uf uf-arrow-right'/> </span>
</div>
);
return (
<Col md={12} >
<h3>{ title }</h3>
<p>{ desc }</p>
<Panel collapsible headerContent expanded={ this.state.open } colors='bordered' header={ header } footerStyle = {{padding: 0}}>
<pre><code className="hljs javascript">{ code }</code></pre>
{ !!scss_code ? <pre><code className="hljs css">{ scss_code }</code></pre> : null }
</Panel>
</Col>
)
<Col md={12} id={title.trim()} className='component-demo'>
<Panel header={header}>
{example}
</Panel>
<Drawer className='component-drawerc' title={title} show={this.state.open} placement='right' onClose={this.fCloseDrawer}>
<div className='component-code-copy'> JS代码
<Clipboard action="copy" text={code}/>
</div>
<pre className="pre-js">
<code className="hljs javascript">{ code }</code>
</pre >
{!!scss_code ?<div className='component-code-copy copy-css'> SCSS代码
<Clipboard action="copy" text={scss_code}/>
</div>:null }
{ !!scss_code ? <pre className="pre-css">
<code className="hljs css">{ scss_code }</code>
</pre> : null }
</Drawer>
</Col>
)
}

@@ -62,12 +71,12 @@ }

return (
<Row>
{DemoArray.map((child,index) => {
<Row>
{DemoArray.map((child,index) => {
return (
<Demo example= {child.example} title= {child.title} code= {child.code} scss_code= {child.scss_code} desc= {child.desc} key= {index}/>
)
return (
<Demo example= {child.example} title= {child.title} code= {child.code} scss_code= {child.scss_code} desc= {child.desc} key= {index}/>
)
})}
</Row>
)
})}
</Row>
)
}

@@ -74,0 +83,0 @@ }

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

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { Con, Row, Col } from 'bee-layout';
import { Panel } from 'bee-panel';
import Button from 'bee-button';
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Drawer from 'bee-drawer';
import Clipboard from 'bee-clipboard';
import Button from '../src';
const CARET = <i className="uf uf-arrow-down"></i>;
const CARETUP = <i className="uf uf-arrow-up"></i>;
var Demo1 = require("./demolist/Demo1");var Demo2 = require("./demolist/Demo2");var Demo3 = require("./demolist/Demo3");var Demo4 = require("./demolist/Demo4");var DemoArray = [{"example":<Demo1 />,"title":" 默认开关","code":"/**\r\n *\r\n * @title 默认开关\r\n * @description\r\n *\r\n */\r\nimport React, { Component } from \"react\";\r\n\nimport { Switch, Row, Col } from 'tinper-bee';\r\n\r\nclass Demo1 extends Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n checked: true\r\n };\r\n }\r\n onChange = () => {\r\n this.setState({\r\n checked: !this.state.checked\r\n });\r\n };\r\n render() {\r\n return (\r\n <Row>\r\n <Col sm={2}>\r\n <Switch />\r\n </Col>\r\n <Col sm={2}>\r\n <Switch\r\n checked={this.state.checked}\r\n onChange={this.onChange}\r\n />\r\n </Col>\r\n </Row>\r\n );\r\n }\r\n}\r\n\r\n\r\n","desc":""},{"example":<Demo2 />,"title":" 不同大小的开关","code":"/**\r\n *\r\n * @title 不同大小的开关\r\n * @description 通过`size`属性控制开关的大小\r\n *\r\n */\r\n\r\nimport React, { Component } from \"react\";\r\n\nimport { Switch, Row, Col } from 'tinper-bee';\r\n\r\nclass Demo2 extends Component {\r\n render() {\r\n return (\r\n <Row>\r\n <Col sm={2}>\r\n <Switch size=\"sm\" />\r\n </Col>\r\n <Col sm={2}>\r\n <Switch />\r\n </Col>\r\n <Col sm={2}>\r\n <Switch size=\"lg\" />\r\n </Col>\r\n </Row>\r\n );\r\n }\r\n}\r\n\r\n\r\n","desc":" 通过`size`属性控制开关的大小"},{"example":<Demo3 />,"title":" 事件开关","code":"/**\r\n *\r\n * @title 事件开关\r\n * @description 点击开关触发事件\r\n *\r\n */\r\n\r\nimport React, { Component } from \"react\";\r\n\nimport { Switch, Row, Col } from 'tinper-bee';\r\n\r\nclass Demo3 extends Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n switch: \"\",\r\n checked: false\r\n };\r\n }\r\n onChange = e => {\r\n this.setState({\r\n switch: `${e}`,\r\n checked: !this.state.checked\r\n });\r\n };\r\n\r\n render() {\r\n return (\r\n <Row>\r\n <Col sm={2}>\r\n <Switch\r\n checked={this.state.checked}\r\n onChange={this.onChange}\r\n checkedChildren={\"on\"}\r\n unCheckedChildren={\"off\"}\r\n />\r\n </Col>\r\n <Col sm={2}>\r\n <span>{this.state.switch}</span>\r\n </Col>\r\n </Row>\r\n );\r\n }\r\n}\r\n\r\n\r\n","desc":" 点击开关触发事件"},{"example":<Demo4 />,"title":" 被禁用开关","code":"/**\r\n *\r\n * @title 被禁用开关\r\n * @description\r\n *\r\n */\r\nimport React, { Component } from \"react\";\r\n\nimport { Switch, Button, Row, Col } from 'tinper-bee';\r\n\n\r\nclass Demo4 extends Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n defaultDisabled: true\r\n };\r\n }\r\n onChange = () => {\r\n this.setState({\r\n defaultDisabled: !this.state.defaultDisabled\r\n });\r\n };\r\n onConsoleLog=(x)=>{\r\n console.log(x) \r\n }\r\n render() {\r\n return (\r\n <Row>\r\n <Col sm={2}>\r\n <Switch disabled={this.state.defaultDisabled}/>\r\n </Col>\r\n <Col sm={2}>\r\n <Button onClick={this.onChange}>toggle disabled</Button>\r\n </Col>\r\n </Row>\r\n );\r\n }\r\n}\r\n\r\n\r\n","desc":""}]

@@ -23,32 +20,44 @@

}
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
handleClick=()=> {
this.setState({ open: !this.state.open })
}
fCloseDrawer=()=>{
this.setState({
open: false
})
}
render () {
const { title, example, code, desc, scss_code } = this.props;
let caret = this.state.open ? CARETUP : CARET;
let text = this.state.open ? "隐藏代码" : "查看代码";
const header = (
<div>
{example}
<Button style={{"marginTop": "10px"}} shape="block" onClick={ this.handleClick }>
{ caret }
{ text }
</Button>
<p className='component-title'>{ title }</p>
<p>{ desc }</p>
<span className='component-code' onClick={this.handleClick}> 查看源码 <i className='uf uf-arrow-right'/> </span>
</div>
);
return (
<Col md={12} >
<h3>{ title }</h3>
<p>{ desc }</p>
<Panel collapsible headerContent expanded={ this.state.open } colors='bordered' header={ header } footerStyle = {{padding: 0}}>
<pre><code className="hljs javascript">{ code }</code></pre>
{ !!scss_code ? <pre><code className="hljs css">{ scss_code }</code></pre> : null }
</Panel>
</Col>
)
<Col md={12} id={title.trim()} className='component-demo'>
<Panel header={header}>
{example}
</Panel>
<Drawer className='component-drawerc' title={title} show={this.state.open} placement='right' onClose={this.fCloseDrawer}>
<div className='component-code-copy'> JS代码
<Clipboard action="copy" text={code}/>
</div>
<pre className="pre-js">
<code className="hljs javascript">{ code }</code>
</pre >
{!!scss_code ?<div className='component-code-copy copy-css'> SCSS代码
<Clipboard action="copy" text={scss_code}/>
</div>:null }
{ !!scss_code ? <pre className="pre-css">
<code className="hljs css">{ scss_code }</code>
</pre> : null }
</Drawer>
</Col>
)
}

@@ -63,12 +72,12 @@ }

return (
<Row>
{DemoArray.map((child,index) => {
<Row>
{DemoArray.map((child,index) => {
return (
<Demo example= {child.example} title= {child.title} code= {child.code} scss_code= {child.scss_code} desc= {child.desc} key= {index}/>
)
return (
<Demo example= {child.example} title= {child.title} code= {child.code} scss_code= {child.scss_code} desc= {child.desc} key= {index}/>
)
})}
</Row>
)
})}
</Row>
)
}

@@ -75,0 +84,0 @@ }

@@ -1,8 +0,24 @@

## Switch 开关
# 开关 Switch
切换开关交互来源于表示用户用于打开或关闭选项的物理开关。
## 何时使用
使用开关元素展示页面
## 如何使用
```
import { Switch } from 'tinper-bee';
or
import Switch from 'bee-switch';
import bee-switch/build/Switch.css;
```
## 代码演示
### API
## API

@@ -19,1 +35,8 @@ |参数|说明|类型|默认值|

|colors| 颜色设置,oneOf:`primary`,`success`,`info`,`dark`,`warning`''| string |''|
## 注意事项
暂无
## 更新日志
{
"name": "bee-switch",
"version": "2.0.2",
"version": "2.0.3",
"description": "switch ui component for react",

@@ -47,2 +47,4 @@ "keywords": [

"bee-button": "latest",
"bee-clipboard": "^2.0.0",
"bee-drawer": "0.0.2",
"bee-layout": "latest",

@@ -49,0 +51,0 @@ "bee-panel": "latest",

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

/**
* This source code is quoted from rc-switch.
* homepage: https://github.com/react-component/switch
*/
import React, { Component } from "react";

@@ -108,13 +112,15 @@ import ReactDOM from "react-dom";

return (
<span
{...others}
ref={this.saveNode}
onClick={this.clickHandler}
onKeyDown={this.handleKeyDown}
onMouseUp={this.handleMouseUp}
className={classnames(className, classNames)}
tabIndex={disabled ? -1 : 0}
>
<span className={`${clsPrefix}-inner`}>
{checked ? checkedChildren : unCheckedChildren}
<span className={disabled && checked ? `${clsPrefix}-backdrop` : ''}>
<span
{...others}
ref={this.saveNode}
onClick={this.clickHandler}
onKeyDown={this.handleKeyDown}
onMouseUp={this.handleMouseUp}
className={classnames(className, classNames)}
tabIndex={disabled ? -1 : 0}
>
<span className={`${clsPrefix}-inner`}>
{checked ? checkedChildren : unCheckedChildren}
</span>
</span>

@@ -121,0 +127,0 @@ </span>

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 not supported yet

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

Sorry, the diff of this file is not supported yet

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