├── .babelrc ├── .eslintrc.js ├── .gitignore ├── .jshintrc ├── .travis.yml ├── LICENSE ├── README.md ├── __tests__ └── time-test.js ├── component ├── Calendar.js ├── Carousel.js ├── CheckBox.js ├── CheckBoxGroup.js ├── ConfirmBox.js ├── DatePicker.js ├── DateTimePicker.js ├── DropDown.js ├── FlashMessage.js ├── Item.js ├── Menu.js ├── Modal.js ├── Notice.js ├── NoticeCenter.js ├── Pagination.js ├── Panel.js ├── Pin.js ├── Progress.js ├── Radio.js ├── RadioGroup.js ├── SlideMenu.js ├── Tab.js ├── TimeInput.js ├── TimePicker.js ├── Tooltip.js ├── high-order │ ├── defaultCheckedCmp.js │ ├── documentClickCmp.js │ ├── dropDownCmp.js │ ├── intervalCmp.js │ ├── popUpCmp.js │ ├── scrollCmp.js │ └── timeInputCmp.js ├── time-picker │ └── SelectorList.js └── util │ ├── className.js │ ├── constants.js │ ├── datetime.js │ ├── debounce.js │ ├── dom.js │ ├── misc.js │ ├── time.js │ └── typeCheck.js ├── css ├── all.less ├── carousel.less ├── checkbox.less ├── date-picker.less ├── datetime-picker.less ├── dropdown.less ├── flash-message.less ├── loader.less ├── menu.less ├── meta.less ├── modal.less ├── notice.less ├── pagination.less ├── panel.less ├── pin.less ├── popup.less ├── progress.less ├── reset.less ├── share.less ├── slide-menu.less ├── tab.less ├── time-picker.less └── transition.less ├── demo ├── css │ ├── carousel_demo.less │ ├── demo.less │ ├── menu_demo.less │ └── pin_demo.less ├── entre.js └── example │ ├── CalendarDemo.jsx │ ├── CarouselDemo.jsx │ ├── CheckBoxDemo.jsx │ ├── CheckBoxGroupDemo.jsx │ ├── ConfirmBoxDemo.jsx │ ├── DatePickerDemo.jsx │ ├── DateTimePickerDemo.jsx │ ├── DropDownDemo.jsx │ ├── FlashMessageDemo.jsx │ ├── MenuDemo.jsx │ ├── ModalDemo.jsx │ ├── NoticeDemo.jsx │ ├── PaginationDemo.jsx │ ├── PinDemo.jsx │ ├── ProgressDemo.jsx │ ├── RadioDemo.jsx │ ├── RadioGroupDemo.jsx │ ├── SlideMenuDemo.jsx │ ├── TabDemo.jsx │ ├── TimeInputDemo.jsx │ ├── TimePickerDemo.jsx │ ├── TooltipDemo.jsx │ └── index.js ├── dist └── demo.js ├── index.html ├── index.js ├── lib ├── Calendar.js ├── Carousel.js ├── CheckBox.js ├── CheckBoxGroup.js ├── ConfirmBox.js ├── DatePicker.js ├── DateTimePicker.js ├── DropDown.js ├── FlashMessage.js ├── Item.js ├── Menu.js ├── Modal.js ├── Notice.js ├── NoticeCenter.js ├── Pagination.js ├── Panel.js ├── Pin.js ├── Progress.js ├── Radio.js ├── RadioGroup.js ├── SlideMenu.js ├── Tab.js ├── TimeInput.js ├── TimePicker.js ├── Tooltip.js ├── high-order │ ├── defaultCheckedCmp.js │ ├── documentClickCmp.js │ ├── dropDownCmp.js │ ├── intervalCmp.js │ ├── popUpCmp.js │ ├── scrollCmp.js │ └── timeInputCmp.js ├── time-picker │ └── SelectorList.js └── util │ ├── className.js │ ├── constants.js │ ├── datetime.js │ ├── debounce.js │ ├── dom.js │ ├── misc.js │ ├── time.js │ └── typeCheck.js ├── package-lock.json ├── package.json ├── server.js ├── todo.md └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "react"], 3 | "plugins": [ 4 | "add-module-exports" 5 | ] 6 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | *.hot-update.* 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esnext": true, 3 | "asi": true, 4 | "boss": false, 5 | "camelcase": false, 6 | "curly": false, 7 | "eqeqeq": false, 8 | "eqnull": false, 9 | "es5": false, 10 | "evil": false, 11 | "expr": true, 12 | "forin": false, 13 | "funcscope": false, 14 | "immed": false, 15 | "indent": 2, 16 | "latedef": false, 17 | "loopfunc": false, 18 | "maxerr": 7, 19 | "newcap": false, 20 | "node": true, 21 | "nonew": false, 22 | "plusplus": false, 23 | "quotmark": "false", 24 | "regexdash": false, 25 | "shadow": false, 26 | "strict": false, 27 | "sub": false, 28 | "supernew": false, 29 | "trailing": false, 30 | "undef": false, 31 | "unused": false, 32 | "white": false 33 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: node_js 4 | 5 | node_js: 6 | - "5" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 jerry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-component 2 | 3 | [![Build Status](https://travis-ci.org/flyfloor/react-component.svg?branch=master)](https://travis-ci.org/flyfloor/react-component) 4 | [![Downloads](https://img.shields.io/npm/dt/react-ui-component.svg)](https://www.npmjs.com/package/react-ui-component) 5 | [![Version](https://img.shields.io/npm/v/react-ui-component.svg)](https://www.npmjs.com/package/react-ui-component) 6 | 7 | >some everyday use component built with reactjs. 8 | 9 | ## Demo 10 | 11 | [demo](http://flyfloor.github.io/react-component/#/?_k=pg3vqw) 12 | 13 | ===== 14 | 15 | ## Deprecated 16 | 17 | ## ========> React uikit is in progress: [React-uikits](https://github.com/flyfloor/react-uikits) <======== 18 | 19 | -------------------------------------------------------------------------------- /__tests__/time-test.js: -------------------------------------------------------------------------------- 1 | jest.unmock('../component/util/time'); 2 | jest.unmock('../component/util/typeCheck'); 3 | const {timeStr2Obj} = require('../component/util/time'); 4 | 5 | 6 | describe('timeStr2Obj', () => { 7 | it('0.0.0 should be 00:00:00', () => { 8 | expect(timeStr2Obj('0.0.0')).toEqual({ 9 | hour: 0, 10 | second: 0, 11 | minute: 0 12 | }); 13 | }); 14 | 15 | it('12:03:38 should be 12:03:38', () => { 16 | expect(timeStr2Obj('12:03:38')).toEqual({ 17 | hour: 12, 18 | minute: 3, 19 | second: 38, 20 | }); 21 | }); 22 | 23 | it('undefined, null, xxx, [] all should be 00:00:00', () => { 24 | const value = { 25 | hour: 0, 26 | minute: 0, 27 | second: 0, 28 | }; 29 | expect(timeStr2Obj(undefined)).toEqual(value); 30 | expect(timeStr2Obj(null)).toEqual(value); 31 | expect(timeStr2Obj([])).toEqual(value); 32 | }); 33 | 34 | it('*&X&D0,0fwaef.0a should be 00:00:00', () => { 35 | expect(timeStr2Obj('&X&D0,0fwaef.0a ')).toEqual({ 36 | hour: 0, 37 | second: 0, 38 | minute: 0 39 | }); 40 | }); 41 | 42 | it('25:68:120 should be 01:08:12', () => { 43 | expect(timeStr2Obj('25:68:120')).toEqual({ 44 | hour: 1, 45 | minute: 8, 46 | second: 0, 47 | }); 48 | }); 49 | 50 | it('-1.2:-2:-1 should be 00:00:00', () => { 51 | expect(timeStr2Obj('-1.2:-2:-1')).toEqual({ 52 | hour: 0, 53 | minute: 0, 54 | second: 0, 55 | }); 56 | }); 57 | }); -------------------------------------------------------------------------------- /component/CheckBox.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const klassName = require('./util/className') 5 | 6 | class CheckBox extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.checkedChange = this.checkedChange.bind(this) 10 | this.state = { 11 | checked: props.checked, 12 | } 13 | } 14 | 15 | checkedChange(e){ 16 | const {onChange, value} = this.props; 17 | this.setState({ 18 | checked: e.target.checked 19 | }); 20 | if(onChange) onChange(e, value); 21 | } 22 | 23 | componentWillReceiveProps(nextProps) { 24 | if (nextProps.checked !== this.props.checked) { 25 | this.setState({ 26 | checked: nextProps.checked 27 | }); 28 | } 29 | } 30 | 31 | render() { 32 | let {disabled, style, className, children} = this.props; 33 | if (disabled) { 34 | className = klassName('disabled', className); 35 | } 36 | className = klassName(className, 'checkbox'); 37 | const {checked} = this.state; 38 | return ( 39 | 44 | ) 45 | } 46 | } 47 | 48 | CheckBox.propTypes = { 49 | onChange: PropTypes.func, 50 | disabled: PropTypes.bool, 51 | checked: PropTypes.bool, 52 | className: PropTypes.string, 53 | } 54 | 55 | CheckBox.defaultProps = { 56 | className: '', 57 | checked: false, 58 | } 59 | 60 | module.exports = CheckBox 61 | -------------------------------------------------------------------------------- /component/CheckBoxGroup.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const CheckBox = require('./CheckBox') 5 | const klassName = require('./util/className') 6 | const defaultCheckedCmp = require('./high-order/defaultCheckedCmp') 7 | 8 | class CheckBoxGroup extends Component { 9 | constructor(props) { 10 | super(props); 11 | this.handleChange = this.handleChange.bind(this) 12 | this.addVal = this.addVal.bind(this) 13 | this.removeVal = this.removeVal.bind(this) 14 | this.valueChange = this.valueChange.bind(this) 15 | 16 | const { value } = props; 17 | this.state = { 18 | value 19 | } 20 | } 21 | 22 | componentDidMount() { 23 | let {value} = this.state 24 | let {defaultChecked} = this.props 25 | if (value.length === 0 && defaultChecked) { 26 | this.initDefaultCheckedValue({ multi: true }) 27 | } 28 | } 29 | 30 | componentWillReceiveProps(nextProps) { 31 | const { defaultChecked } = this.props 32 | this.optionsChangeReInitValue({ 33 | nextProps, 34 | defaultChecked, 35 | multi: true 36 | }) 37 | } 38 | 39 | handleChange(e, val){ 40 | e.target.checked ? this.addVal(val) : this.removeVal(val); 41 | } 42 | 43 | addVal(val){ 44 | let flag = false; 45 | const {value} = this.state; 46 | for (let i = 0; i < value.length; i++) { 47 | if (val === value[i]){ 48 | flag = true; 49 | break; 50 | } 51 | } 52 | if (!flag) { 53 | this.setState({ 54 | value: value.concat(val) 55 | }, this.valueChange); 56 | } 57 | } 58 | 59 | removeVal(val){ 60 | let index = this.state.value.indexOf(val); 61 | if (index > -1) { 62 | this.state.value.splice(index, 1); 63 | this.setState({ 64 | value: this.state.value 65 | }, this.valueChange); 66 | } 67 | } 68 | 69 | valueChange(){ 70 | this.props.onChange(this.state.value) 71 | } 72 | 73 | render() { 74 | const { labelName, valueName, className, options, style, children } = this.props; 75 | const { value } = this.state; 76 | let optionNodes = []; 77 | 78 | if (children) { 79 | optionNodes = React.Children.map(children, (node, i) => { 80 | let checked = value.indexOf(node.props.value) > -1; 81 | return ; 82 | }) 83 | } else { 84 | let itemNode = null; 85 | for (let i = 0; i < options.length; i++) { 86 | let itemChecked = false; 87 | let item = options[i]; 88 | for (let j = 0; j < value.length; j++) { 89 | if (value[j] === item[valueName]){ 90 | itemChecked = true; 91 | break; 92 | } 93 | } 94 | itemNode = 96 | {item[labelName]} 97 | ; 98 | optionNodes.push(itemNode); 99 | } 100 | } 101 | 102 | return ( 103 |
104 | {optionNodes} 105 |
106 | ); 107 | } 108 | } 109 | 110 | CheckBoxGroup.defaultProps = { 111 | value: [], 112 | labelName: 'name', 113 | valueName: 'value', 114 | options: [], 115 | } 116 | 117 | CheckBoxGroup.propTypes = { 118 | options: PropTypes.array, 119 | labelName: PropTypes.string, 120 | valueName: PropTypes.string, 121 | onChange: PropTypes.func.isRequired, 122 | defaultChecked: PropTypes.bool, 123 | } 124 | 125 | module.exports = defaultCheckedCmp(CheckBoxGroup) -------------------------------------------------------------------------------- /component/ConfirmBox.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const ReactDOM = require('react-dom') 3 | const Component = React.Component 4 | const PropTypes = require('prop-types') 5 | const ReactCssTransitionGroup = require('react-addons-css-transition-group') 6 | const documentClickCmp = require('./high-order/documentClickCmp') 7 | const popUpCmp = require('./high-order/popUpCmp') 8 | const klassName = require('./util/className') 9 | 10 | class ConfirmBox extends Component { 11 | constructor(props) { 12 | super(props); 13 | this.handleCancel = this.handleCancel.bind(this) 14 | this.handleConfirm = this.handleConfirm.bind(this) 15 | this.handleTrigger = this.handleTrigger.bind(this) 16 | } 17 | 18 | onOtherDomClick(){ 19 | if (!this.props.force) this.popUpClose(); 20 | } 21 | 22 | handleCancel(){ 23 | const { onCancel } = this.props; 24 | if (!onCancel) return this.popUpClose(); 25 | if(onCancel()) this.popUpClose(); 26 | } 27 | 28 | handleConfirm(){ 29 | const { onConfirm } = this.props; 30 | if (!onConfirm) return this.popUpClose(); 31 | if (onConfirm()) this.popUpClose(); 32 | } 33 | 34 | handleTrigger(e) { 35 | const contentDOM = ReactDOM.findDOMNode(this.content) 36 | if (e.target && contentDOM && (contentDOM === e.target || contentDOM.contains(e.target))) { 37 | return 38 | } 39 | this.onTrigger(e, true) 40 | } 41 | 42 | render() { 43 | let {confirm, cancel, position, className, content, style, children} = this.props; 44 | const { open } = this.state; 45 | className = klassName('confirm-box popup', className); 46 | if (open) { 47 | className = `${className} _active`; 48 | } 49 | 50 | return ( 51 | 56 | { this.trigger = ref }} 59 | > 60 | {children} 61 | 62 | 68 | { 69 | open ? 70 |
{ this.content = ref }} 73 | > 74 |
{content}
75 |
76 |
80 | { confirm ? confirm :
ok
} 81 |
82 |
86 | { cancel ? cancel :
cancel
} 87 |
88 |
89 | { this.arrow = ref }} 92 | > 93 | 94 |
95 | : null 96 | } 97 |
98 |
99 | ); 100 | } 101 | } 102 | 103 | ConfirmBox.propTypes = { 104 | onCancel: PropTypes.func, 105 | onConfirm: PropTypes.func, 106 | force: PropTypes.bool, 107 | content: PropTypes.element.isRequired, 108 | confirm: PropTypes.element, 109 | cancel: PropTypes.element, 110 | } 111 | 112 | ConfirmBox.defaultProps = { 113 | className: '' 114 | } 115 | 116 | module.exports = popUpCmp(documentClickCmp(ConfirmBox)) -------------------------------------------------------------------------------- /component/DatePicker.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const ReactCssTransitionGroup = require('react-addons-css-transition-group') 5 | const formatDate = require('./util/datetime').formatDate 6 | const documentClickCmp = require('./high-order/documentClickCmp') 7 | const dropDownCmp = require('./high-order/dropDownCmp') 8 | const Calendar = require('./Calendar') 9 | const klassName = require('./util/className') 10 | 11 | const _DATE_FORMAT = { 12 | day: 'yyyy-MM-dd', 13 | month: 'yyyy-MM', 14 | year: 'yyyy', 15 | } 16 | 17 | class DatePicker extends Component { 18 | constructor(props) { 19 | super(props); 20 | this.handleValChange = this.handleValChange.bind(this) 21 | 22 | const value = this.initDate(); 23 | this.state = { 24 | value, 25 | open: false, 26 | } 27 | } 28 | 29 | initDate(date=this.props.value){ 30 | if (!date) { 31 | return 32 | } 33 | return new Date(date.getTime()) 34 | } 35 | 36 | onOtherDomClick(){ 37 | this.setState({ 38 | open: false 39 | }); 40 | } 41 | 42 | handleValChange(value){ 43 | this.setState({ 44 | value, 45 | open: false 46 | }); 47 | this.props.onChange(new Date(value.getTime())) 48 | } 49 | 50 | componentWillReceiveProps(nextProps) { 51 | if (nextProps.value !== this.props.value) { 52 | this.setState({ 53 | value: this.initDate(nextProps.value) 54 | }); 55 | } 56 | } 57 | 58 | render() { 59 | const {open, value} = this.state; 60 | let { 61 | begin, end, className, placeHolder, 62 | showPreview, format, type, 63 | onClick, onBlur, onFocus, 64 | } = this.props; 65 | format = format || _DATE_FORMAT[type] 66 | let valueStr = value ? formatDate(value, format) : '' 67 | if (open) className += ' _active'; 68 | return ( 69 |
70 |
{ 71 | this.setState({ open: true }) 72 | if (onClick) onClick() 73 | }}> 74 | 76 | 77 |
78 | 80 | {open ? 81 | 84 | : null 85 | } 86 | 87 |
88 | ); 89 | } 90 | } 91 | 92 | DatePicker.propTypes = { 93 | onChange: PropTypes.func.isRequired, 94 | onClick: PropTypes.func, 95 | onBlur: PropTypes.func, 96 | onFocus: PropTypes.func, 97 | showPreview: PropTypes.bool, 98 | format: PropTypes.string, 99 | value: PropTypes.instanceOf(Date), 100 | type: PropTypes.oneOf(['day', 'month', 'year']), 101 | } 102 | 103 | DatePicker.defaultProps = { 104 | className: '', 105 | placeHolder: 'select date', 106 | showPreview: true, 107 | type: 'day', 108 | } 109 | 110 | module.exports = dropDownCmp(documentClickCmp(DatePicker)) -------------------------------------------------------------------------------- /component/FlashMessage.js: -------------------------------------------------------------------------------- 1 | const NoticeCenter = require('./NoticeCenter') 2 | const DEFAULT_PREFIX = 'flash-message' 3 | const DEFAULT_CONTENT = 'this is a flash message' 4 | const DEFAULT_DELAY = 5000 5 | const POSITIONS = ['top', 'center', 'bottom'] 6 | 7 | let instance = null 8 | 9 | const generateNotice = function({ content, position, delay, onClick, close }){ 10 | position = POSITIONS.indexOf(position) !== -1 ? position : POSITIONS[0] 11 | content = content || DEFAULT_CONTENT 12 | delay = delay || DEFAULT_DELAY 13 | instance = instance || NoticeCenter.init({ 14 | className: DEFAULT_PREFIX, 15 | prefix: DEFAULT_PREFIX, 16 | }) 17 | return instance.addNotice({ 18 | content, 19 | delay, 20 | close, 21 | className: `_${position}`, 22 | onClick, 23 | }) 24 | } 25 | 26 | const FlashMessage = function(){ 27 | return { 28 | show(msgObj){ 29 | return generateNotice(msgObj) 30 | } 31 | } 32 | }() 33 | 34 | module.exports = FlashMessage 35 | -------------------------------------------------------------------------------- /component/Item.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | 5 | class Item extends Component { 6 | constructor(props) { 7 | super(props); 8 | } 9 | render() { 10 | return ( 11 |
12 | ); 13 | } 14 | } 15 | 16 | Item.propTypes = { 17 | children: PropTypes.node, 18 | } 19 | 20 | Item.defaultProps = { 21 | className: '', 22 | } 23 | 24 | module.exports = Item 25 | -------------------------------------------------------------------------------- /component/Modal.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const klassName = require('./util/className') 5 | 6 | class Modal extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.handleConfirm = this.handleConfirm.bind(this) 10 | this.handleCancel = this.handleCancel.bind(this) 11 | this.close = this.close.bind(this) 12 | this.open = this.open.bind(this) 13 | 14 | this.state = { 15 | display: false, 16 | } 17 | } 18 | 19 | open(){ 20 | this.setState({ 21 | display: true 22 | }); 23 | } 24 | 25 | close(){ 26 | const {onClose} = this.props 27 | if (onClose && !onClose()) return 28 | this.setState({ 29 | display: false 30 | }); 31 | } 32 | 33 | handleConfirm(){ 34 | if (this.props.onConfirm()) this.close(); 35 | } 36 | 37 | handleCancel(){ 38 | if (this.props.onCancel()) this.close(); 39 | } 40 | 41 | render() { 42 | let {onConfirm, onCancel, confirm, 43 | className, cancel, title, children, 44 | style, force, close} = this.props; 45 | 46 | const {display} = this.state; 47 | let actionDOM = []; 48 | if (onConfirm) actionDOM.push(
50 | {confirm} 51 |
); 52 | if (onCancel) actionDOM.push(
54 | {cancel} 55 |
); 56 | 57 | let footer = onCancel || onConfirm 58 | ?
59 | {actionDOM} 60 |
61 | : null; 62 | 63 | className = klassName('modal', className); 64 | 65 | if (display) { 66 | className += ' _show'; 67 | } 68 | if (force) { 69 | className += ' _force'; 70 | } 71 | 72 | return ( 73 |
74 |
75 |
76 | {title ? 77 |
{title}
78 | : null} 79 |
80 | {children} 81 | {footer} 82 |
83 |
84 | {force 85 | ? null 86 | :
{close}
} 87 |
88 | {force 89 | ?
90 | :
91 | } 92 |
93 | ); 94 | } 95 | } 96 | 97 | Modal.propTypes = { 98 | title: PropTypes.element, 99 | confirm: PropTypes.oneOfType([PropTypes.element, PropTypes.string]), 100 | cancel: PropTypes.oneOfType([PropTypes.element, PropTypes.string]), 101 | onConfirm: PropTypes.func, 102 | onCancel: PropTypes.func, 103 | onClose: PropTypes.func, 104 | close: PropTypes.element, 105 | } 106 | 107 | Modal.defaultProps = { 108 | confirm: 'confirm', 109 | cancel: 'cancel', 110 | close: x, 111 | } 112 | 113 | module.exports = Modal -------------------------------------------------------------------------------- /component/Notice.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const klassName = require('./util/className') 5 | 6 | class Notice extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.handleClick = this.handleClick.bind(this) 10 | } 11 | 12 | componentDidMount() { 13 | const {delay, onClose} = this.props 14 | if (delay !== 0) { 15 | this._timer = setTimeout(() => { 16 | this.clearTimer() 17 | onClose() 18 | }, delay) 19 | } 20 | } 21 | 22 | componentWillUnmount() { 23 | this.clearTimer() 24 | } 25 | 26 | clearTimer(){ 27 | if (this._timer) { 28 | clearTimeout(this._timer) 29 | this._timer = null 30 | } 31 | } 32 | 33 | handleClick(){ 34 | const {onClick, onClose} = this.props 35 | if (onClick) { 36 | onClick(this.props) 37 | onClose() 38 | } 39 | } 40 | 41 | render() { 42 | let {title, content, className, close, onClose, icon} = this.props 43 | className = klassName(className, 'notice') 44 | return ( 45 |
46 | 47 | {icon ? 48 | icon : null} 49 |
50 | {title 51 | ?
{title}
52 | : null} 53 | {content} 54 | {close ? 55 |
{close}
56 | : null} 57 |
58 |
59 |
60 | ); 61 | } 62 | } 63 | 64 | Notice.propTypes = { 65 | delay: PropTypes.number, 66 | content: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), 67 | onClick: PropTypes.func, 68 | onClose: PropTypes.func.isRequired, 69 | close: PropTypes.element, 70 | } 71 | 72 | Notice.defaultProps = { 73 | content: null, 74 | delay: 5000, 75 | close: x, 76 | } 77 | 78 | module.exports = Notice -------------------------------------------------------------------------------- /component/NoticeCenter.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const ReactDOM = require('react-dom') 4 | const ReactCssTransitionGroup = require('react-addons-css-transition-group') 5 | const Notice = require('./Notice') 6 | const DEFAULT_PREFIX = 'notice' 7 | 8 | let __key = 0 9 | 10 | const generateNoticeKey = () => { 11 | let str = `notice_${__key}` 12 | __key += 1 13 | return str 14 | } 15 | 16 | class NoticeCenter extends Component { 17 | constructor(props) { 18 | super(props); 19 | this.addNotice = this.addNotice.bind(this) 20 | this.removeNotice = this.removeNotice.bind(this) 21 | 22 | this.state = { 23 | notices: [] 24 | } 25 | } 26 | addNotice(notice){ 27 | notice.key = generateNoticeKey() 28 | this.setState((state) => { 29 | return { 30 | notices: state.notices.concat(notice) 31 | } 32 | }) 33 | } 34 | 35 | removeNotice(key){ 36 | this.setState((state) => { 37 | return { 38 | notices: state.notices.filter(item => item.key !== key) 39 | } 40 | }) 41 | } 42 | 43 | render() { 44 | const {notices} = this.state 45 | let {className, prefix} = this.props 46 | return ( 47 | 49 | {notices.map((item) => { 50 | return { 51 | this.removeNotice(item.key, item) 52 | if (typeof item.onClose === 'function') { 53 | item.onClose(item) 54 | } 55 | }}/> 56 | })} 57 | 58 | ); 59 | } 60 | } 61 | 62 | NoticeCenter.defaultProps = { 63 | prefix: DEFAULT_PREFIX, 64 | className: 'notice-center', 65 | } 66 | 67 | NoticeCenter.init = function(props){ 68 | props = props || {} 69 | let prefix = props.prefix || DEFAULT_PREFIX 70 | let domId = `dot_${prefix}_center` 71 | if (!document.getElementById(domId)) { 72 | let dom = document.createElement('div') 73 | dom.setAttribute('id', domId) 74 | document.body.appendChild(dom) 75 | } 76 | let notification = ReactDOM.render(, document.getElementById(domId)) 77 | return { 78 | key: prefix, 79 | addNotice(notice){ 80 | // close icon 81 | if (props.close) { 82 | notice.close = props.close 83 | } 84 | notification.addNotice(notice) 85 | }, 86 | removeNotice(key){ 87 | notification.removeNotice(key) 88 | } 89 | } 90 | } 91 | 92 | module.exports = NoticeCenter 93 | -------------------------------------------------------------------------------- /component/Panel.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const klassName = require('./util/className') 5 | 6 | class Panel extends Component { 7 | constructor(props) { 8 | super(props); 9 | } 10 | render() { 11 | let {className, title} = this.props 12 | return ( 13 |
14 | {title ? 15 |
16 | {title} 17 |
18 | :null} 19 |
20 | {this.props.children} 21 |
22 |
23 | ); 24 | } 25 | } 26 | 27 | Panel.propTypes = { 28 | title: PropTypes.oneOfType([PropTypes.element, PropTypes.string]) 29 | } 30 | 31 | module.exports = Panel 32 | -------------------------------------------------------------------------------- /component/Pin.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const ReactDOM = require('react-dom') 5 | const scrollCmp = require('./high-order/scrollCmp') 6 | const klassName = require('./util/className') 7 | 8 | class Pin extends Component { 9 | constructor(props) { 10 | super(props); 11 | this.state = { 12 | fixed: false, 13 | baseTop: 0, 14 | } 15 | } 16 | 17 | componentDidMount() { 18 | this.setState({ 19 | baseTop: this.node2Top(), 20 | }); 21 | } 22 | 23 | node2Top(){ 24 | const {begin} = this.props; 25 | if (begin) return begin; 26 | const pinNode = ReactDOM.findDOMNode(this.pinNode); 27 | return pinNode.offsetTop; 28 | } 29 | 30 | onScroll(){ 31 | const {_top} = this.windowScrollOffset(); 32 | this.setState({ 33 | fixed: _top >= this.state.baseTop 34 | }); 35 | } 36 | 37 | render() { 38 | const {fixed} = this.state; 39 | let {top, children, className} = this.props; 40 | className = klassName(className, 'pin'); 41 | let stat = fixed ? 'fixed': ''; 42 | return ( 43 |
{ this.pinNode = ref } }> 46 | {children} 47 |
48 | ); 49 | } 50 | } 51 | 52 | Pin.propTypes = { 53 | top: PropTypes.number, 54 | begin: PropTypes.number, 55 | } 56 | 57 | Pin.defaultProps = { 58 | top: 0, 59 | className: '', 60 | } 61 | 62 | module.exports = scrollCmp(Pin); -------------------------------------------------------------------------------- /component/Progress.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const klassName = require('./util/className') 5 | 6 | class Progress extends Component { 7 | constructor(props) { 8 | super(props); 9 | } 10 | render() { 11 | let {value, className, status, size, disabled, children} = this.props; 12 | if (value < 0) value = 0; 13 | if (value > 100) value = 100; 14 | className = klassName(className, 'progress'); 15 | 16 | if (status) { 17 | className += ` _${status}`; 18 | } 19 | if (disabled) { 20 | className += ` _disabled`; 21 | } 22 | if (value === 100) { 23 | className += ' _completed'; 24 | } 25 | if (children) { 26 | className += ' _context'; 27 | } 28 | 29 | if (size) { 30 | className += ` _${size}` 31 | } 32 | 33 | 34 | return ( 35 |
36 |
37 | {children} 38 |
39 |
40 | ); 41 | } 42 | } 43 | 44 | 45 | Progress.propTypes = { 46 | value: PropTypes.number, 47 | disabled: PropTypes.bool, 48 | size: PropTypes.oneOf(['large', 'normal', 'small']), 49 | status: PropTypes.oneOf(['warning', 'failed', 'success', 'active']) 50 | } 51 | 52 | Progress.defaultProps = { 53 | value: 0, 54 | className: '', 55 | } 56 | 57 | module.exports = Progress; 58 | -------------------------------------------------------------------------------- /component/Radio.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const klassName = require('./util/className') 5 | 6 | class Radio extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.checkedChange = this.checkedChange.bind(this) 10 | } 11 | 12 | checkedChange(e){ 13 | const {value, onChange} = this.props; 14 | if(onChange) onChange(e, value); 15 | } 16 | 17 | render() { 18 | let {className, checked, disabled, style, children} = this.props; 19 | className = klassName(className, 'radio'); 20 | if (disabled) { 21 | className = `${className} _disabled`; 22 | } 23 | return ( 24 | 31 | ); 32 | } 33 | } 34 | 35 | Radio.propTypes = { 36 | onChange: PropTypes.func, 37 | checked: PropTypes.bool, 38 | disabled: PropTypes.bool, 39 | className: PropTypes.string, 40 | } 41 | 42 | Radio.defaultProps = { 43 | className: '', 44 | } 45 | 46 | module.exports = Radio; -------------------------------------------------------------------------------- /component/RadioGroup.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | 5 | const Radio = require('./Radio') 6 | const klassName = require('./util/className') 7 | const defaultCheckedCmp = require('./high-order/defaultCheckedCmp') 8 | 9 | class RadioGroup extends Component { 10 | constructor(props) { 11 | super(props); 12 | this.toggleChange = this.toggleChange.bind(this) 13 | 14 | const { value } = props; 15 | this.state = { 16 | value 17 | } 18 | } 19 | 20 | toggleChange(e, value){ 21 | this.setState({ value }, () => { 22 | const {onChange} = this.props 23 | if (onChange) onChange(this.state.value) 24 | }); 25 | } 26 | 27 | componentWillReceiveProps(nextProps) { 28 | const { defaultChecked } = this.props 29 | this.optionsChangeReInitValue({ 30 | defaultChecked, 31 | nextProps, 32 | multi: false 33 | }) 34 | } 35 | 36 | componentDidMount() { 37 | let {value} = this.state 38 | let {defaultChecked} = this.props 39 | if (!value && defaultChecked) { 40 | this.initDefaultCheckedValue() 41 | } 42 | } 43 | 44 | render() { 45 | let {labelName, valueName, options, className, style, children} = this.props; 46 | className = klassName(className, 'radio-group'); 47 | const {value} = this.state; 48 | let optionNodes = [], itemChecked; 49 | 50 | if (children) { 51 | React.Children.map(children, (node, i) => { 52 | itemChecked = node.props.value === value; 53 | if ((value === null || value === undefined ) && node.props.checked) itemChecked = true; 54 | optionNodes.push( 55 | ); 56 | }) 57 | } else { 58 | for (let i = 0; i < options.length; i++) { 59 | let item = options[i]; 60 | itemChecked = item[valueName] === value; 61 | optionNodes.push( 63 | {item[labelName]} 64 | ); 65 | } 66 | } 67 | 68 | 69 | return ( 70 |
71 | {optionNodes} 72 |
73 | ); 74 | } 75 | } 76 | 77 | RadioGroup.propTypes = { 78 | options: PropTypes.array, 79 | labelName: PropTypes.string, 80 | valueName: PropTypes.string, 81 | onChange: PropTypes.func.isRequired, 82 | defaultChecked: PropTypes.bool, 83 | } 84 | 85 | RadioGroup.defaultProps = { 86 | labelName: 'name', 87 | valueName: 'value', 88 | options: [], 89 | } 90 | 91 | module.exports = defaultCheckedCmp(RadioGroup) -------------------------------------------------------------------------------- /component/SlideMenu.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const klassName = require('./util/className') 5 | 6 | class SlideMenu extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.open = this.open.bind(this) 10 | this.close = this.close.bind(this) 11 | 12 | this.state = { 13 | display: false, 14 | } 15 | } 16 | 17 | calcPositionStyle(){ 18 | const {position, width} = this.props 19 | const {display} = this.state; 20 | let cord = display ? 0 : width; 21 | 22 | switch(position){ 23 | case 'left': 24 | return {transform: `translate3d(${-cord}px, 0, 0)`, 25 | width: `${width}px`, 26 | left: 0, 27 | top: 0} 28 | case 'top': 29 | return {transform: `translate3d(0, ${-cord}px, 0)`, 30 | height: `${width}px`, 31 | left: 0, 32 | top: 0} 33 | case 'bottom': 34 | return {transform: `translate3d(0, ${cord}px, 0)`, 35 | height: `${width}px`, 36 | left: 0, 37 | bottom: 0} 38 | default: 39 | return {transform: `translate3d(${cord}px, 0, 0)`, 40 | width: `${width}px`, 41 | right:0, 42 | top:0} 43 | } 44 | } 45 | 46 | open(){ 47 | this.setState({ 48 | display: true 49 | }); 50 | } 51 | 52 | close(){ 53 | const {onClose} = this.props 54 | if (onClose && !onClose()) return 55 | this.setState({ 56 | display: false 57 | }); 58 | } 59 | 60 | render() { 61 | const {display} = this.state; 62 | let {className, children} = this.props; 63 | className = klassName(className, 'slide-menu'); 64 | 65 | return ( 66 |
67 |
68 | {children} 69 |
70 |
71 |
72 | ); 73 | } 74 | } 75 | 76 | SlideMenu.propTypes = { 77 | position: PropTypes.oneOf(['left', 'right', 'top', 'bottom']), 78 | width: PropTypes.number, 79 | onClose: PropTypes.func, 80 | } 81 | 82 | SlideMenu.defaultProps = { 83 | width: 300, 84 | position: 'right', 85 | } 86 | 87 | module.exports = SlideMenu; -------------------------------------------------------------------------------- /component/Tab.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const klassName = require('./util/className') 5 | 6 | class Tab extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.handleItemClick = this.handleItemClick.bind(this) 10 | 11 | const {current} = props 12 | this.state = { 13 | current 14 | } 15 | } 16 | 17 | componentWillReceiveProps(nextProps) { 18 | const {current} = this.props; 19 | if (nextProps.current !== current) { 20 | this.setState({ 21 | current: nextProps.current 22 | }); 23 | } 24 | } 25 | 26 | handleItemClick(index){ 27 | const {onChange} = this.props; 28 | if (onChange) onChange(index); 29 | this.setState({ 30 | current: index, 31 | }); 32 | } 33 | 34 | makeTab(){ 35 | let {children, style, className, vertical, section, bottom} = this.props; 36 | className = klassName(className, 'tab'); 37 | if (vertical) { 38 | className += ' vertical' 39 | } 40 | if (section) { 41 | className += ' section' 42 | } 43 | if (bottom) { 44 | className += ' bottom' 45 | } 46 | const {current} = this.state; 47 | let tabs = [], 48 | contents = []; 49 | 50 | React.Children.map(children, (node, i) => { 51 | let {index, title=index, children} = node.props; 52 | if (index === null || index === undefined) { 53 | throw new Error('index is needed for children of tab'); 54 | } 55 | let cls = index === current ? `_item _active`: '_item'; 56 | if ((current === undefined || current === null) && i === 0) cls += ' _active'; 57 | tabs.push(
this.handleItemClick(index)}> 58 | {title} 59 |
); 60 | contents.push(
61 | {children} 62 |
); 63 | }) 64 | 65 | let node = bottom ? 66 |
67 |
{contents}
68 |
{tabs}
69 |
70 | :
71 |
{tabs}
72 |
{contents}
73 |
74 | 75 | return ( 76 | node 77 | ) 78 | } 79 | 80 | render() { 81 | return ( 82 | this.makeTab() 83 | ); 84 | } 85 | } 86 | 87 | Tab.propTypes = { 88 | onChange: PropTypes.func, 89 | bottom: PropTypes.bool, 90 | section: PropTypes.bool, 91 | vertical: PropTypes.bool, 92 | } 93 | 94 | Tab.defaultProps = { 95 | className: '', 96 | bottom: false, 97 | vertical: false, 98 | section: false, 99 | } 100 | 101 | module.exports = Tab; -------------------------------------------------------------------------------- /component/TimeInput.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const klassName = require('./util/className') 4 | const timeInputCmp = require('./high-order/timeInputCmp') 5 | 6 | class TimeInput extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.handleInputChange = this.handleInputChange.bind(this) 10 | this.handleClick = this.handleClick.bind(this) 11 | this.handleOnBlur = this.handleOnBlur.bind(this) 12 | 13 | let {value, displayValue} = this.initTime({ value: props.value }); 14 | this.state = { 15 | value, 16 | displayValue, 17 | } 18 | } 19 | 20 | handleInputChange(e){ 21 | this.setState({ displayValue: e.target.value }) 22 | } 23 | 24 | componentWillReceiveProps(nextProps) { 25 | if (nextProps.value !== this.props.value) { 26 | let { value, displayValue} = this.initTime({ value: nextProps.value }) 27 | this.setState({ 28 | value, 29 | displayValue 30 | }); 31 | } 32 | } 33 | 34 | handleClick(e){ 35 | let {onClick} = this.props 36 | if (onClick) { 37 | this.inputDOM.focus() 38 | onClick(e) 39 | } 40 | } 41 | 42 | handleOnBlur(){ 43 | const {value, displayValue} = this.initTime({ displayValue: this.state.displayValue}); 44 | let {onBlur} = this.props 45 | this.setState({ 46 | displayValue 47 | }); 48 | if (value !== this.state.value) { 49 | this.setState({ value }, () => this.props.onChange(value)); 50 | } 51 | 52 | if (onBlur) { 53 | onBlur(value) 54 | } 55 | } 56 | 57 | render() { 58 | const {displayValue} = this.state; 59 | let {className, placeHolder, simple, onFocus} = this.props; 60 | simple = simple ? '_simple' : '' 61 | className = klassName(className, 'timeinput', simple); 62 | return ( 63 |
64 |
65 | { this.inputDOM = input } } 67 | onFocus={onFocus} 68 | onBlur={this.handleOnBlur} value={displayValue} 69 | onChange={this.handleInputChange}/> 70 | 71 |
72 |
73 | ); 74 | } 75 | } 76 | 77 | TimeInput.defaultProps = { 78 | simple: false, 79 | className: '', 80 | placeHolder: 'input time', 81 | } 82 | 83 | module.exports = timeInputCmp(TimeInput); -------------------------------------------------------------------------------- /component/TimePicker.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const ReactCssTransitionGroup = require('react-addons-css-transition-group') 4 | const klassName = require('./util/className') 5 | const TimeInput = require('./TimeInput') 6 | const timeInputCmp = require('./high-order/timeInputCmp') 7 | const documentClickCmp = require('./high-order/documentClickCmp') 8 | const dropDownCmp = require('./high-order/dropDownCmp') 9 | const SelectorList = require('./time-picker/SelectorList') 10 | const timeUtil = require('./util/time') 11 | const {seconds2Obj, obj2Seconds} = timeUtil 12 | 13 | class TimePicker extends Component { 14 | constructor(props) { 15 | super(props); 16 | this.handleValueChange = this.handleValueChange.bind(this) 17 | this.handleInputClick = this.handleInputClick.bind(this) 18 | this.handleBlur = this.handleBlur.bind(this) 19 | this.handleTimeChange = this.handleTimeChange.bind(this) 20 | 21 | let {value} = this.initTime({value: props.value}); 22 | this.state = { 23 | open: false, 24 | value, 25 | } 26 | } 27 | 28 | onOtherDomClick(){ 29 | this.setState({ 30 | open: false 31 | }); 32 | } 33 | 34 | componentWillReceiveProps(nextProps) { 35 | if (nextProps.value !== this.props.value) { 36 | let {value} = this.initTime({ value: nextProps.value }) 37 | this.setState({ 38 | value 39 | }, () => this.props.onChange(value)); 40 | } 41 | } 42 | 43 | handleValueChange(val){ 44 | let {value} = this.initTime({ value: val }) 45 | if (value !== this.state.value) { 46 | this.setState({ 47 | value 48 | }); 49 | this.props.onChange(value) 50 | } 51 | } 52 | 53 | handleInputClick(){ 54 | const {onClick} = this.props 55 | this.setState({ 56 | open: true 57 | }); 58 | if (onClick) onClick() 59 | } 60 | 61 | handleBlur(){ 62 | const {onBlur} = this.props 63 | if (onBlur) onBlur() 64 | } 65 | 66 | handleTimeChange(type='hour', val){ 67 | let {value} = this.state 68 | let valueObj = seconds2Obj(value) 69 | valueObj[type] = val 70 | value = obj2Seconds(valueObj) 71 | 72 | this.setState({ 73 | value, 74 | }, () => this.props.onChange(value)); 75 | } 76 | 77 | render() { 78 | let {simple, className, onFocus} = this.props 79 | const {value, open} = this.state 80 | const {hour, second, minute} = seconds2Obj(value) 81 | 82 | className = klassName(className, 'timepicker', simple ? '_simple': '') 83 | return ( 84 |
85 | 91 | 93 | {open ? 94 | 97 | : null 98 | } 99 | 100 |
101 | ); 102 | } 103 | } 104 | 105 | TimePicker.defaultProps = { 106 | simple: false, 107 | className: '', 108 | placeHolder: 'input time', 109 | } 110 | 111 | module.exports = dropDownCmp(timeInputCmp(documentClickCmp(TimePicker))) 112 | -------------------------------------------------------------------------------- /component/Tooltip.js: -------------------------------------------------------------------------------- 1 | const React = require('react') 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const ReactCssTransitionGroup = require('react-addons-css-transition-group') 5 | const documentClickCmp = require('./high-order/documentClickCmp') 6 | const popUpCmp = require('./high-order/popUpCmp') 7 | const klassName = require('./util/className') 8 | 9 | class Tooltip extends Component { 10 | constructor(props) { 11 | super(props); 12 | } 13 | 14 | onOtherDomClick(){ 15 | this.popUpClose() 16 | } 17 | 18 | render() { 19 | const {open} = this.state; 20 | let {position, content, style, className, children, mode} = this.props; 21 | className = klassName('popup', className) 22 | if (open) { 23 | className = `${className} _active`; 24 | } 25 | 26 | let onMouseLeave = null, 27 | onMouseEnter = null, 28 | onClick = null; 29 | 30 | if (mode === 'click') { 31 | onClick = this.onTrigger 32 | } else { 33 | onMouseEnter = e => this.onTrigger(e, true) 34 | onMouseLeave = e => this.onTrigger(e, false) 35 | } 36 | 37 | return ( 38 | 45 | { this.trigger = ref } } 48 | > 49 | {children} 50 | 51 | 53 | {open ? 54 |
{ 55 | this.content = ref 56 | }} className='_content'> 57 |
58 | {content} 59 |
60 | { 61 | this.arrow = ref 62 | }}> 63 |
64 | : null 65 | } 66 |
67 |
68 | ); 69 | } 70 | } 71 | 72 | Tooltip.defaultProps = { 73 | className: '', 74 | mode: 'hover', 75 | } 76 | 77 | Tooltip.propTypes = { 78 | content: PropTypes.element.isRequired, 79 | mode: PropTypes.oneOf(['hover', 'click']) 80 | } 81 | 82 | module.exports = popUpCmp(documentClickCmp(Tooltip)); -------------------------------------------------------------------------------- /component/high-order/defaultCheckedCmp.js: -------------------------------------------------------------------------------- 1 | module.exports = Cmp => { 2 | return class DefaultCheckedCmp extends Cmp { 3 | constructor(props) { 4 | super(props) 5 | } 6 | 7 | componentWillReceiveProps(nextProps) { 8 | if (super.componentWillReceiveProps) { 9 | super.componentWillReceiveProps(nextProps) 10 | } 11 | 12 | if (this.props.value !== nextProps.value && ['', [], undefined, null].indexOf(nextProps.value) === -1) { 13 | this.setState({ 14 | value: nextProps.value 15 | }, () => this.props.onChange(this.state.value)); 16 | } 17 | } 18 | 19 | optionsChangeReInitValue({ 20 | defaultChecked, 21 | multi, 22 | nextProps 23 | }) { 24 | const { 25 | value, 26 | valueName, 27 | onChange 28 | } = this.props 29 | 30 | if (nextProps.options !== this.props.options) { 31 | // re-init value if value exist, but not fit options value 32 | if (['', [], undefined, null].indexOf(value) === -1) { 33 | const newOptions = nextProps.options 34 | for (let i = 0; i < newOptions.length; i++) { 35 | if (multi) { 36 | if (value.indexOf(newOptions[i][valueName]) !== -1) { 37 | return 38 | } 39 | } else { 40 | if (newOptions[i][valueName] === value) { 41 | return 42 | } 43 | } 44 | } 45 | } 46 | 47 | if (defaultChecked) { 48 | this.initDefaultCheckedValue({ 49 | multi, 50 | props: nextProps 51 | }) 52 | } else { 53 | this.setState({ 54 | value: multi ? [] : '' 55 | }, () => onChange(this.state.value)); 56 | } 57 | } 58 | } 59 | 60 | initDefaultCheckedValue({ multi, props} = { multi: false }){ 61 | let {valueName, options, onChange, children} = props || this.props 62 | let initVal = multi ? [] : '' 63 | if (options && options.length > 0) { 64 | initVal = options[0][valueName] 65 | } 66 | if (children && children.length > 0) { 67 | initVal = children[0].props[valueName] 68 | } 69 | this.setState({ 70 | value: multi ? [initVal] : initVal, 71 | }, () => onChange(this.state.value)); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /component/high-order/documentClickCmp.js: -------------------------------------------------------------------------------- 1 | const ReactDOM = require('react-dom') 2 | 3 | module.exports = Cmp => { 4 | return class DocumentClickCmp extends Cmp { 5 | constructor(props) { 6 | super(props) 7 | this.onClick = this.onClick.bind(this) 8 | this.onDocumentClick = this.onDocumentClick.bind(this) 9 | } 10 | 11 | componentDidMount() { 12 | document.addEventListener('click', this.onClick); 13 | if (super.componentDidMount) { 14 | super.componentDidMount() 15 | } 16 | } 17 | 18 | componentWillUnmount() { 19 | document.removeEventListener('click', this.onClick); 20 | if (super.componentWillUnmount) { 21 | super.componentWillUnmount() 22 | } 23 | } 24 | 25 | onClick(e) { 26 | this.onDocumentClick(e); 27 | } 28 | 29 | onDocumentClick(e) { 30 | const BASE_NODE = ReactDOM.findDOMNode(this); 31 | if(e.target == BASE_NODE || BASE_NODE.contains(e.target)) { 32 | if (this.onBaseDomClick) this.onBaseDomClick(e); 33 | } else { 34 | if (typeof document.contains === 'function' && document.contains(e.target) && typeof this.onOtherDomClick === 'function') { 35 | this.onOtherDomClick(e) 36 | } 37 | } 38 | e.stopPropagation(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /component/high-order/dropDownCmp.js: -------------------------------------------------------------------------------- 1 | const PropTypes = require('prop-types') 2 | const React = require('react') 3 | const klassName = require('../util/className') 4 | const POSITIONS = ['left', 'right', 'bottom', 'top'] 5 | 6 | module.exports = (Cmp, positions) => { 7 | class dropDownCmp extends Cmp { 8 | constructor(props) { 9 | super(props) 10 | } 11 | render(){ 12 | let {className, position} = this.props 13 | className = klassName(className, `_${position}`) 14 | return ( 15 | 16 | ) 17 | } 18 | } 19 | positions = positions instanceof Array ? positions : POSITIONS 20 | dropDownCmp.propTypes = { 21 | position: PropTypes.oneOf(positions), 22 | } 23 | 24 | dropDownCmp.defaultProps = { 25 | position: 'bottom', 26 | } 27 | return dropDownCmp 28 | } -------------------------------------------------------------------------------- /component/high-order/intervalCmp.js: -------------------------------------------------------------------------------- 1 | // interval high order component 2 | module.exports = (Cmp) => { 3 | return class IntervalCmp extends Cmp { 4 | constructor(props) { 5 | super(props); 6 | this.intervals = [] 7 | } 8 | 9 | setInterval (){ 10 | this.intervals.push(setInterval.apply(null, arguments)); 11 | } 12 | 13 | clearInterval (){ 14 | this.intervals.map(clearInterval); 15 | } 16 | 17 | componentWillUnmount () { 18 | this.clearInterval(); 19 | if (super.componentWillUnmount) { 20 | super.componentWillUnmount() 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /component/high-order/popUpCmp.js: -------------------------------------------------------------------------------- 1 | const PropTypes = require('prop-types') 2 | const ReactDOM = require('react-dom') 3 | 4 | module.exports = Cmp => { 5 | class PopUpCmp extends Cmp { 6 | constructor(props) { 7 | super(props) 8 | this.triggerSize = this.triggerSize.bind(this) 9 | this.onTrigger = this.onTrigger.bind(this) 10 | this.calcPosition = this.calcPosition.bind(this) 11 | 12 | this.state = { 13 | open: false, 14 | } 15 | } 16 | 17 | triggerSize(){ 18 | const TRG = ReactDOM.findDOMNode(this.trigger); 19 | return { 20 | tr_width: TRG.offsetWidth, 21 | tr_height: TRG.offsetHeight, 22 | }; 23 | } 24 | 25 | contentSize(){ 26 | const CONTENT = ReactDOM.findDOMNode(this.content); 27 | if (!CONTENT) return {width: 0, height: 0}; 28 | return { 29 | c_width: CONTENT.offsetWidth, 30 | c_height: CONTENT.offsetHeight, 31 | }; 32 | } 33 | 34 | // popup close 35 | popUpClose(){ 36 | this.setState({ 37 | open: false 38 | }); 39 | } 40 | 41 | onTrigger(e, open){ 42 | if (open === null || open === undefined) { 43 | open = !this.state.open 44 | } 45 | this.setState({ 46 | open 47 | }, () => { 48 | let contentDOM = ReactDOM.findDOMNode(this.content); 49 | if (contentDOM) contentDOM.setAttribute("style", this.calcPosition()); 50 | }); 51 | } 52 | 53 | calcPosition(){ 54 | const {tr_width, tr_height} = this.triggerSize() 55 | const {c_width, c_height} = this.contentSize() 56 | let style = '' 57 | 58 | 59 | switch(this.props.position){ 60 | case 'left': 61 | style = `left:${ -10 - c_width }px;top:${- (tr_height + c_height) / 2}px`; 62 | break; 63 | case 'right': 64 | style = `left:${ tr_width + 10 }px;top:${ - (tr_height + c_height) / 2}px`; 65 | break; 66 | case 'bottom': 67 | style = `left:${ tr_width / 2 - c_width / 2 }px;top:10px`; 68 | break; 69 | default: 70 | style = `left:${ tr_width / 2 - c_width / 2 }px;bottom:${ tr_height + 10 }px`; 71 | break; 72 | } 73 | 74 | return style; 75 | } 76 | } 77 | PopUpCmp.propTypes = { 78 | position: PropTypes.oneOf(['left', 'right', 'top', 'bottom']), 79 | } 80 | 81 | PopUpCmp.defaultProps = { 82 | position: 'top', 83 | } 84 | 85 | return PopUpCmp 86 | } -------------------------------------------------------------------------------- /component/high-order/scrollCmp.js: -------------------------------------------------------------------------------- 1 | module.exports = Cmp => { 2 | return class ScrollCmp extends Cmp { 3 | constructor(props) { 4 | super(props); 5 | this.onScroll = this.onScroll.bind(this) 6 | } 7 | componentDidMount() { 8 | document.addEventListener('scroll', this.onScroll); 9 | if (super.componentDidMount) { 10 | super.componentDidMount() 11 | } 12 | } 13 | 14 | componentWillUnmount() { 15 | document.removeEventListener('scroll', this.onScroll); 16 | if (super.componentWillUnmount) { 17 | super.componentWillUnmount() 18 | } 19 | } 20 | 21 | windowScrollOffset(){ 22 | const doc = document.documentElement; 23 | let left = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0); 24 | let top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); 25 | return { 26 | _left: left, 27 | _top: top, 28 | }; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /component/high-order/timeInputCmp.js: -------------------------------------------------------------------------------- 1 | const PropTypes = require('prop-types') 2 | const timeUtil = require('../util/time') 3 | const {timeStr2Obj, obj2TimeStr, seconds2Obj} = timeUtil 4 | 5 | module.exports = Cmp => { 6 | class TimeInputCmp extends Cmp { 7 | constructor(props) { 8 | super(props); 9 | } 10 | 11 | initTime({ displayValue, value }){ 12 | const {simple} = this.props; 13 | if ([undefined, '', null].indexOf(displayValue) !== -1 && value === undefined) { 14 | return {} 15 | } 16 | 17 | let rtnObj = [undefined, '', null].indexOf(displayValue) === -1 ? timeStr2Obj(displayValue) : seconds2Obj(value) 18 | let {hour, minute, second} = rtnObj 19 | 20 | value = hour * 3600 + minute * 60 + second 21 | 22 | displayValue = obj2TimeStr({ 23 | hour, minute, second 24 | }, { 25 | simple 26 | }); 27 | 28 | return { value, displayValue } 29 | } 30 | } 31 | 32 | TimeInputCmp.propTypes = { 33 | simple: PropTypes.bool, 34 | value: PropTypes.number, 35 | onChange: PropTypes.func.isRequired, 36 | onBlur: PropTypes.func, 37 | onFocus: PropTypes.func, 38 | className: PropTypes.string, 39 | placeHolder: PropTypes.string, 40 | onClick: PropTypes.func, 41 | } 42 | 43 | return TimeInputCmp 44 | } 45 | -------------------------------------------------------------------------------- /component/time-picker/SelectorList.js: -------------------------------------------------------------------------------- 1 | const React = require('react'); 2 | const Component = React.Component 3 | const PropTypes = require('prop-types') 4 | const ReactDOM = require('react-dom') 5 | 6 | class SelectorList extends Component { 7 | constructor(props) { 8 | super(props); 9 | } 10 | 11 | handleInitScroll(){ 12 | this.initScrollTo('hour') 13 | this.initScrollTo('minute') 14 | this.initScrollTo('second') 15 | } 16 | 17 | initScrollTo(type){ 18 | let val = this.props[type] 19 | let dom = ReactDOM.findDOMNode(this[type + 'List']) 20 | if (dom) { 21 | let selected = dom.children[0].children[parseInt(val)] 22 | let to = selected.offsetTop 23 | dom.scrollTop = to 24 | } 25 | } 26 | 27 | componentDidMount() { 28 | this.handleInitScroll() 29 | } 30 | 31 | handleTimeChange(type='hour', val){ 32 | this.props.onChange(type, val) 33 | } 34 | 35 | formatSelectList(type='hour'){ 36 | let val = this.props[type] 37 | let max = type === 'hour' ? 24 : 60 38 | let nodes = [] 39 | for (let i = 0; i < max; i++) { 40 | let _i = i < 10 ? `0${i}` : String(i) 41 | nodes.push( 42 |
  • this.handleTimeChange(type, i)}> 44 | {_i} 45 |
  • 46 | ) 47 | } 48 | return ( 49 |
      {nodes}
    50 | ) 51 | } 52 | 53 | render() { 54 | const {simple} = this.props 55 | return ( 56 |
    57 |
    { this.hourList = ref } }> 59 | {this.formatSelectList('hour')} 60 |
    61 |
    { this.minuteList = ref } }> 63 | {this.formatSelectList('minute')} 64 |
    65 | {simple ? 66 | null 67 | :
    { this.secondList = ref } }> 69 | {this.formatSelectList('second')} 70 |
    } 71 |
    72 | ); 73 | } 74 | } 75 | 76 | SelectorList.defaultProps = { 77 | hour: 0, 78 | minute: 0, 79 | second: 0, 80 | simple: false 81 | } 82 | 83 | SelectorList.propTypes = { 84 | onChange: PropTypes.func.isRequired, 85 | } 86 | 87 | module.exports = SelectorList 88 | -------------------------------------------------------------------------------- /component/util/className.js: -------------------------------------------------------------------------------- 1 | const klassName = function() { 2 | if (arguments.length === 0) { 3 | return '' 4 | } 5 | let cls = Array.prototype.slice.call(arguments) 6 | return cls.filter(l => l).join(' ') 7 | } 8 | 9 | module.exports = klassName -------------------------------------------------------------------------------- /component/util/constants.js: -------------------------------------------------------------------------------- 1 | const WEEK_LABEL = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; 2 | 3 | const MONTH_LABEL = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']; 4 | 5 | const BACKSPACE_KEYCODE = 8; 6 | const DOWN_KEYCODE = 40; 7 | const UP_KEYCODE = 38; 8 | const ENTER_KEYCODE = 13; 9 | 10 | module.exports = { 11 | WEEK_LABEL, 12 | MONTH_LABEL, 13 | BACKSPACE_KEYCODE, 14 | DOWN_KEYCODE, 15 | UP_KEYCODE, 16 | ENTER_KEYCODE 17 | }; -------------------------------------------------------------------------------- /component/util/datetime.js: -------------------------------------------------------------------------------- 1 | // date => date string 2 | const formatDate = (date, fmt="yyyy-MM-dd") => { 3 | if (!date) { 4 | return '' 5 | } 6 | let obj = { 7 | "M+": date.getMonth() + 1, 8 | "d+": date.getDate(), 9 | "h+": date.getHours(), 10 | "m+": date.getMinutes(), 11 | "s+": date.getSeconds(), 12 | "q+": Math.floor((date.getMonth() + 3) / 3), 13 | "S": date.getMilliseconds(), 14 | }; 15 | if (/(y+)/.test(fmt)) { 16 | fmt = fmt.replace(RegExp.$1, String(date.getFullYear()).substr(4 - RegExp.$1.length)); 17 | } 18 | for (let k in obj) { 19 | if (new RegExp("(" + k + ")").test(fmt)) { 20 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? obj[k] : `00${obj[k]}`.substr(String(obj[k]).length)); 21 | } 22 | } 23 | return fmt; 24 | } 25 | 26 | // extract date to {year, month, day, hour, minute, second, miniSecond} 27 | const extractDate = (date, opt) => { 28 | opt = opt || {} 29 | if (!date) { 30 | date = new Date() 31 | } 32 | if (!opt.showTime) { 33 | return { 34 | year: date.getFullYear(), 35 | month: date.getMonth() + 1, 36 | day: date.getDate(), 37 | } 38 | } 39 | return { 40 | year: date.getFullYear(), 41 | month: date.getMonth() + 1, 42 | day: date.getDate(), 43 | hour: date.getHours(), 44 | minute: date.getMinutes(), 45 | second: date.getSeconds(), 46 | miniSecond: date.getMilliseconds(), 47 | } 48 | } 49 | 50 | module.exports = { 51 | formatDate, extractDate 52 | } -------------------------------------------------------------------------------- /component/util/debounce.js: -------------------------------------------------------------------------------- 1 | let _timer = null 2 | 3 | module.exports = (fn, delay = 300) => { 4 | clearTimeout(_timer) 5 | return (...args) => { 6 | _timer = setTimeout(() => { 7 | fn.apply(this, args) 8 | }, delay) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /component/util/dom.js: -------------------------------------------------------------------------------- 1 | function toggleClass(el, className){ 2 | if (el && el instanceof Node && className) { 3 | if (hasClass(el, className)) { 4 | removeClass(el, className) 5 | } else { 6 | addClass(el, className) 7 | } 8 | } 9 | } 10 | 11 | function removeClass(el, className){ 12 | if (!el || !className) return; 13 | if (el instanceof NodeList) { 14 | const length = el.length; 15 | for (let i = 0; i < length; i++) { 16 | _removeClass(el[i], className); 17 | } 18 | return; 19 | } 20 | if (el instanceof Node) { 21 | _removeClass(el, className); 22 | } 23 | } 24 | 25 | function _removeClass(el, className){ 26 | if (hasClass(el, className)) { 27 | let old = ` ${el.className} ` 28 | old = old.replace(/(\s+)/gi, ' ') 29 | el.className = old.replace(' ' + className + ' ', ' ') 30 | .replace(/(^\s+)|(\s+$)/g, ''); 31 | } 32 | } 33 | 34 | function hasClass(el, className){ 35 | if (el && className && el instanceof Node) { 36 | return el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)')); 37 | } 38 | return false; 39 | } 40 | 41 | 42 | function addClass(el, className) { 43 | if (!hasClass(el, className)) { 44 | el.className += el.className ? (" " + className) : className 45 | } 46 | } 47 | 48 | function getClassList(el){ 49 | if (el && el instanceof Node) return el.className.split(/\s+/); 50 | return []; 51 | } 52 | 53 | module.exports = { 54 | toggleClass, removeClass, hasClass, addClass, getClassList 55 | } 56 | -------------------------------------------------------------------------------- /component/util/misc.js: -------------------------------------------------------------------------------- 1 | const capitalize = (str='') => { 2 | return str.charAt(0).toUpperCase() + str.slice(1) 3 | } 4 | 5 | module.exports = { 6 | capitalize, 7 | } -------------------------------------------------------------------------------- /component/util/time.js: -------------------------------------------------------------------------------- 1 | const isType = require('./typeCheck').isType 2 | 3 | const MAX_HOUR = 23; 4 | const MAX_MINUTE = 59; 5 | const MAX_SECOND = MAX_MINUTE; 6 | 7 | // 时间字符串 => {小时,分钟,秒} 8 | const timeStr2Obj = (value='00:00:00', options = { 9 | simple: false, 10 | }) => { 11 | value = isType(value, 'String') ? value : '00:00:00' 12 | let arr = value.split(':').slice(0, 3) 13 | let new_arr = []; 14 | 15 | for (let i = 0; i < arr.length; i++) { 16 | let item = String(arr[i]); 17 | if (item.length === 1) item = `0${item}`; 18 | if (!item) item = '00'; 19 | new_arr.push(item); 20 | } 21 | 22 | let [hour, minute, second] = new_arr; 23 | hour = validateUnitByMax(hour, MAX_HOUR); 24 | minute = validateUnitByMax(minute, MAX_MINUTE); 25 | 26 | if (options.simple) return { hour, minute }; 27 | 28 | second = validateUnitByMax(second, MAX_SECOND); 29 | 30 | return { hour, minute, second }; 31 | }; 32 | 33 | // {小时, 分钟, 秒} => 时间字符串 34 | const obj2TimeStr = ({ hour = 0, minute = 0, second = 0}, options = { 35 | simple: false, 36 | }) => { 37 | hour = validateUnitByMax(hour, MAX_HOUR) 38 | minute = validateUnitByMax(minute, MAX_MINUTE) 39 | 40 | if (hour < 10) { 41 | hour = `0${hour}` 42 | } 43 | if (minute < 10) { 44 | minute = `0${minute}` 45 | } 46 | 47 | if (options.simple) { 48 | return `${hour}:${minute}` 49 | } 50 | second = validateUnitByMax(second, MAX_SECOND) 51 | 52 | if (second < 10) { 53 | second = `0${second}` 54 | } 55 | 56 | return `${hour}:${minute}:${second}` 57 | } 58 | 59 | const seconds2Obj = value => { 60 | value = value || 0 61 | value = value % 86400 62 | let hour = parseInt(value / 3600) 63 | let minute = parseInt(value % 3600 / 60) 64 | let second = value % 3600 % 60 65 | return { 66 | hour, minute, second 67 | } 68 | } 69 | 70 | const obj2Seconds = ({ hour, minute, second}) => { 71 | hour = hour || 0 72 | minute = minute || 0 73 | second = second || 0 74 | return hour * 3600 + minute * 60 + second 75 | } 76 | 77 | const validateUnitByMax = (value, max) => { 78 | value = parseInt(value); 79 | if (value > max) value = Math.floor(value % (max + 1)); 80 | if (isNaN(value) || value < 0) value = 0; 81 | return value; 82 | }; 83 | 84 | module.exports = { 85 | timeStr2Obj, 86 | obj2TimeStr, 87 | seconds2Obj, 88 | obj2Seconds, 89 | } 90 | -------------------------------------------------------------------------------- /component/util/typeCheck.js: -------------------------------------------------------------------------------- 1 | function isType(obj, typeStr){ 2 | return Object.prototype.toString.call(obj).slice(8, -1) === typeStr 3 | } 4 | 5 | module.exports = { 6 | isType 7 | } -------------------------------------------------------------------------------- /css/all.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | @import url('share'); 3 | 4 | @import url('reset.less'); 5 | @import url('checkbox.less'); 6 | @import url('carousel.less'); 7 | @import url('popup.less'); 8 | @import url('dropdown.less'); 9 | @import url("menu.less"); 10 | @import url('modal.less'); 11 | @import url('pin.less'); 12 | @import url('tab.less'); 13 | @import url('slide-menu.less'); 14 | @import url('pagination.less'); 15 | @import url('time-picker.less'); 16 | @import url('date-picker.less'); 17 | @import url('datetime-picker.less'); 18 | @import url('progress.less'); 19 | @import url('flash-message.less'); 20 | @import url('notice.less'); 21 | @import url('panel.less'); 22 | @import url('loader.less'); -------------------------------------------------------------------------------- /css/carousel.less: -------------------------------------------------------------------------------- 1 | @import url('meta.less'); 2 | 3 | .carousel { 4 | overflow: hidden; 5 | position: relative; 6 | ._content { 7 | overflow: auto; 8 | ._item { 9 | overflow: hidden; 10 | display: block; 11 | float: left; 12 | height: 100%; 13 | text-align: center; 14 | opacity: 0.9; 15 | &._active { 16 | opacity: 1; 17 | } 18 | } 19 | &._slide { 20 | -webkit-transition: transform .5s ease; 21 | -o-transition: transform .5s ease; 22 | transition: transform .5s ease; 23 | } 24 | } 25 | 26 | ._dot { 27 | text-align: center; 28 | ._item { 29 | margin: 10px; 30 | font-size: 200%; 31 | color: @gray_b; 32 | &._active { 33 | color: @black; 34 | } 35 | } 36 | } 37 | ._arrow { 38 | .__arrow { 39 | cursor: pointer; 40 | color: @blue; 41 | position: absolute; 42 | overflow: hidden; 43 | top: 50%; 44 | margin-top: -15px; 45 | height: 30px; 46 | } 47 | ._prev { 48 | .__arrow; 49 | left: 10px; 50 | } 51 | ._next { 52 | .__arrow; 53 | right: 10px; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /css/checkbox.less: -------------------------------------------------------------------------------- 1 | @import url('meta.less'); 2 | 3 | .radio, .checkbox { 4 | margin-right: 10px; 5 | } -------------------------------------------------------------------------------- /css/datetime-picker.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | 3 | .datetime-picker { 4 | position: relative; 5 | width: 280px; 6 | ._input { 7 | position: relative; 8 | cursor: pointer; 9 | >input { 10 | width: 100%; 11 | line-height: 25px; 12 | height: 30px; 13 | padding: 0 10px; 14 | color: @black; 15 | border: 1px solid @gray_b; 16 | } 17 | } 18 | &._top>._wrap { 19 | top: initial; 20 | bottom: 30px; 21 | } 22 | &._left>._wrap { 23 | top: 0; 24 | left: -280px; 25 | } 26 | &._right>._wrap { 27 | top: 0; 28 | left: 280px; 29 | } 30 | 31 | >._wrap { 32 | position: absolute; 33 | left: 0; 34 | top: 30px; 35 | &:not(:empty) { 36 | border: 1px solid @gray_c; 37 | } 38 | overflow: hidden; 39 | ._datepicker .calendar, ._timepicker ._section { 40 | border-left: 0; 41 | border-right: 0; 42 | } 43 | ._action { 44 | padding: 20px; 45 | text-align: right; 46 | ._selector { 47 | margin-right: 5px; 48 | font-size: 13px; 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /css/dropdown.less: -------------------------------------------------------------------------------- 1 | @import url('meta.less'); 2 | @import url('transition.less'); 3 | 4 | 5 | .dropdown { 6 | @line_height: 25px; 7 | @height: 30px; 8 | 9 | position: relative; 10 | 11 | ._placeHolder { 12 | color: @gray_b; 13 | } 14 | 15 | .__label { 16 | color: @black_c; 17 | padding: 0 8px; 18 | line-height: @line_height; 19 | height: @height; 20 | border: 1px solid @gray_b; 21 | position: relative; 22 | &>input._transparent { 23 | position: absolute; 24 | left: 0; 25 | top: 0; 26 | bottom: 0; 27 | right: 0; 28 | width: 100%; 29 | opacity: 0; 30 | } 31 | >._text { 32 | .truncate; 33 | } 34 | } 35 | 36 | ._label { 37 | .__label; 38 | cursor: pointer; 39 | } 40 | ._list { 41 | margin-top: -1px; 42 | position: absolute; 43 | width: 100%; 44 | z-index: 100; 45 | background: @white; 46 | border: 1px solid @gray_b; 47 | max-height: @line_height * 10; 48 | overflow: auto; 49 | &:empty { 50 | border: none; 51 | } 52 | >._item { 53 | cursor: pointer; 54 | padding: 3px 16px; 55 | border-bottom: 1px solid transparent; 56 | &._active { 57 | background: @gray_c; 58 | border-color: @gray_d; 59 | } 60 | } 61 | 62 | } 63 | &._active { 64 | ._search ._text { 65 | color: @gray_b; 66 | } 67 | } 68 | 69 | ._overlay { 70 | position: absolute; 71 | left: 0; 72 | bottom: 0; 73 | right: 0; 74 | top: 0; 75 | height: 100%; 76 | width: 100%; 77 | height: 100%; 78 | text-align: center; 79 | z-index: 9; 80 | background: rgba(250, 250, 250, 0.5); 81 | .loader { 82 | position: absolute; 83 | left: 50%; 84 | top: 50%; 85 | -webkit-transform: translate3d(-50%, -50%, 0); 86 | -ms-transform: translate3d(-50%, -50%, 0); 87 | -o-transform: translate3d(-50%, -50%, 0); 88 | transform: translate3d(-50%, -50%, 0); 89 | } 90 | } 91 | 92 | ._search { 93 | .__label; 94 | position: relative; 95 | ._text { 96 | cursor: text; 97 | position: relative; 98 | background: none; 99 | display: inline-block; 100 | line-height: @line_height; 101 | z-index: 2; 102 | } 103 | ._input { 104 | background: none; 105 | padding: 0 5px; 106 | position: absolute; 107 | left: 0; 108 | top: 0; 109 | height: 100%; 110 | right: 0; 111 | bottom: 0; 112 | width: 100%; 113 | border: none; 114 | z-index: 3; 115 | } 116 | } 117 | 118 | ._multi { 119 | border: 1px solid @gray_b; 120 | line-height: @line_height; 121 | height: @height; 122 | width: 100%; 123 | padding: 1px 5px; 124 | ._input { 125 | border: none; 126 | display: inline; 127 | white-space: pre; 128 | max-width: 100%; 129 | } 130 | 131 | ._placeHolder { 132 | margin-left: -6px; 133 | } 134 | 135 | ._tag { 136 | cursor: pointer; 137 | margin-right: 3px; 138 | background: @gray_c; 139 | color: @black; 140 | font-size: 14px; 141 | padding: 0 3px; 142 | ._text { 143 | padding-right: 3px; 144 | } 145 | 146 | ._delete { 147 | color: @black; 148 | &:before { 149 | content: 'x'; 150 | } 151 | } 152 | } 153 | } 154 | 155 | &._top> ._list { 156 | bottom: 30px; 157 | } 158 | 159 | .basic_transition; 160 | } -------------------------------------------------------------------------------- /css/flash-message.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | 3 | .flash-message { 4 | @_top: 30px; 5 | @_width: 300px; 6 | >.notice { 7 | position: fixed; 8 | top: @_top; 9 | left: 50%; 10 | margin: 0 auto; 11 | margin-left: @_width * -0.5; 12 | width: @_width; 13 | display: block; 14 | background: @gray_c; 15 | border: 1px solid @gray_b; 16 | padding: 5px 10px; 17 | ._title { 18 | font-weight: bold; 19 | margin-bottom: 10px; 20 | } 21 | ._close { 22 | position: absolute; 23 | right: 5px; 24 | top: 5px; 25 | cursor: pointer; 26 | } 27 | } 28 | 29 | &-enter { 30 | transform: translate3d(0, @_width * -0.5, 0); 31 | opacity: 0.01; 32 | } 33 | 34 | &-enter&-enter-active { 35 | opacity: 1; 36 | transform: translate3d(0,0,0); 37 | transition: all .3s; 38 | } 39 | 40 | &-leave { 41 | opacity: 1; 42 | transform: translate3d(0,0,0); 43 | } 44 | 45 | &-leave&-leave-active { 46 | opacity: 0.01; 47 | transform: translate3d(0, @_width * -0.3,0); 48 | transition: all .3s; 49 | } 50 | 51 | >._center.notice { 52 | top: 45%; 53 | } 54 | &-enter._center { 55 | transform: scale(.5); 56 | opacity: 0.01; 57 | } 58 | 59 | &-enter&-enter-active._center { 60 | opacity: 1; 61 | transform: scale(1.02); 62 | transition: all .3s; 63 | } 64 | 65 | &-leave._center { 66 | opacity: 1; 67 | transform: scale(1); 68 | } 69 | 70 | &-leave&-leave-active._center { 71 | opacity: 0.01; 72 | transform: scale(.5); 73 | transition: all .3s; 74 | } 75 | 76 | >._bottom.notice { 77 | top: initial; 78 | bottom: @_top; 79 | } 80 | &-enter._bottom { 81 | transform: translate3d(0,@_width * 0.5,0); 82 | opacity: 0.01; 83 | } 84 | 85 | &-enter&-enter-active._bottom { 86 | opacity: 1; 87 | transform: translate3d(0,0,0); 88 | transition: all .3s; 89 | } 90 | 91 | &-leave._bottom { 92 | opacity: 1; 93 | transform: translate3d(0,0,0); 94 | } 95 | 96 | &-leave&-leave-active._bottom { 97 | opacity: 0.01; 98 | transform: translate3d(0, @_width * 0.3,0); 99 | transition: all .3s; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /css/menu.less: -------------------------------------------------------------------------------- 1 | @import url('meta.less'); 2 | 3 | .menu { 4 | @basic_motion: max-height .3s, opacity .3s, height .3s, overflow .3s, visibility .3s, transform .15s, border-color .3s; 5 | .__transition { 6 | -webkit-transition: @basic_motion; 7 | -o-transition: @basic_motion; 8 | transition: @basic_motion; 9 | } 10 | 11 | &.fluid { 12 | width: 100%; 13 | } 14 | 15 | display: inline-block; 16 | width: 220px; 17 | list-style-type: none; 18 | position: relative; 19 | border: 1px solid @gray_b; 20 | background: @white; 21 | 22 | ._item, ._title { 23 | padding: 0 16px; 24 | line-height: 32px; 25 | cursor: pointer; 26 | list-style-type: none; 27 | color: @black_c; 28 | } 29 | 30 | ._item { 31 | &._active { 32 | background: @gray_c; 33 | } 34 | >a { 35 | display: block; 36 | } 37 | } 38 | 39 | ._group { 40 | list-style-type: none; 41 | ._title { 42 | cursor: default; 43 | color: @gray_b; 44 | } 45 | } 46 | 47 | ._submenu { 48 | list-style-type: none; 49 | position: relative; 50 | >._content { 51 | .__transition; 52 | visibility: hidden; 53 | opacity: 0; 54 | max-height: 0; 55 | overflow: hidden; 56 | } 57 | &._open { 58 | >._title { 59 | color: @black; 60 | } 61 | >._content { 62 | .__transition; 63 | visibility: visible; 64 | opacity: 1; 65 | overflow: initial; 66 | max-height: 800px; 67 | } 68 | } 69 | } 70 | 71 | 72 | .__popuped() { 73 | ._submenu { 74 | >._content { 75 | position: absolute; 76 | z-index: 100; 77 | border: 1px solid @gray_b; 78 | width: 200px; 79 | left: 100%; 80 | background: @white; 81 | top: 0; 82 | transform-origin: 0 0; 83 | -webkit-transform: scale(0); 84 | -ms-transform: scale(0); 85 | -o-transform: scale(0); 86 | transform: scale(0); 87 | } 88 | &._active>._title { 89 | background: @gray_b; 90 | } 91 | &._open { 92 | >._content { 93 | -webkit-transform: scale(1); 94 | -ms-transform: scale(1); 95 | -o-transform: scale(1); 96 | transform: scale(1); 97 | } 98 | } 99 | } 100 | } 101 | 102 | 103 | &._horizontal { 104 | .__popuped(); 105 | width: 100%; 106 | padding: 0 10px; 107 | border: 0; 108 | border-bottom: 1px solid @gray_b; 109 | /*first level item and submenu*/ 110 | >._item, >._submenu { 111 | display: inline-block; 112 | } 113 | >._item { 114 | border-bottom: 2px solid transparent; 115 | .__transition; 116 | &._active { 117 | background: initial; 118 | border-color: @blue; 119 | } 120 | } 121 | 122 | /*fist level submenu title active and content no effect*/ 123 | >._submenu { 124 | >._title { 125 | .__transition; 126 | border-bottom: 2px solid transparent; 127 | } 128 | &._active>._title { 129 | border-color: @blue; 130 | background: none; 131 | } 132 | >._content { 133 | left: 0; 134 | -webkit-transform: none; 135 | -ms-transform: none; 136 | -o-transform: none; 137 | transform: none; 138 | top: initial; 139 | } 140 | } 141 | } 142 | 143 | &._popup { 144 | .__popuped(); 145 | } 146 | } -------------------------------------------------------------------------------- /css/meta.less: -------------------------------------------------------------------------------- 1 | @NS: .dot; 2 | 3 | @red: #F44336; 4 | 5 | @orange:#FFA726; 6 | 7 | @yellow:#FFEB3B; 8 | 9 | @green:#4CAF50; 10 | 11 | @cyan:#00BCD4; 12 | 13 | @blue: #2196F3; 14 | 15 | @purple:#9C27B0; 16 | 17 | @gray: #666666; 18 | @gray_a: #999999; 19 | @gray_b: #dddddd; 20 | @gray_c: #eeeeee; 21 | @gray_d: #f5f5f5; 22 | 23 | @white:#ffffff; 24 | @white_a: #fcfcfc; 25 | 26 | @black:#000000; 27 | @black_a:#222222; 28 | @black_b:#323232; 29 | @black_c:#555555; 30 | 31 | @border_radius: 2px; 32 | @padding: 10px; -------------------------------------------------------------------------------- /css/modal.less: -------------------------------------------------------------------------------- 1 | @import url('meta.less'); 2 | 3 | .modal { 4 | &._show { 5 | overflow: auto; 6 | z-index: 999; 7 | position: fixed; 8 | left: 0; 9 | right: 0; 10 | bottom: 0; 11 | top: 0; 12 | width: 100%; 13 | visibility: hidden; 14 | visibility: visible; 15 | } 16 | .__transition { 17 | -webkit-transition: background-color .3s, opacity .3s, transform .3s, visibility .3s; 18 | -o-transition: background-color .3s, opacity .3s, transform .3s, visibility .3s; 19 | transition: background-color .3s, opacity .3s, transform .3s, visibility .3s; 20 | } 21 | ._body { 22 | -webkit-transform: translateX(-50%) translateY(-50%); 23 | -ms-transform: translateX(-50%) translateY(-50%); 24 | -o-transform: translateX(-50%) translateY(-50%); 25 | transform: translateX(-50%) translateY(-50%); 26 | z-index: 1000; 27 | min-width: 400px; 28 | max-width: 600px; 29 | position: fixed; 30 | top: 50%; 31 | left: 50%; 32 | visibility: hidden; 33 | >._wrap { 34 | .__transition; 35 | max-height: 500px; 36 | overflow: auto; 37 | background-color: @white; 38 | border: 1px solid @gray_b; 39 | opacity: 0; 40 | -webkit-transform: scale(1.1); 41 | -ms-transform: scale(1.1); 42 | -o-transform: scale(1.1); 43 | transform: scale(1.1); 44 | } 45 | 46 | ._title { 47 | padding: 10px; 48 | } 49 | 50 | ._content { 51 | overflow: hidden; 52 | padding: 10px; 53 | ._actions { 54 | font-size: 90%; 55 | overflow: hidden; 56 | float: right; 57 | ._action-btn { 58 | cursor: pointer; 59 | display: inline-block; 60 | &:last-child { 61 | margin-left: 5px; 62 | } 63 | } 64 | } 65 | } 66 | ._close { 67 | cursor: pointer; 68 | position: absolute; 69 | right: 5px; 70 | top: 5px; 71 | } 72 | } 73 | ._overlay { 74 | .__transition; 75 | visibility: hidden; 76 | position: fixed; 77 | top: 0; 78 | bottom: 0; 79 | left: 0; 80 | right: 0; 81 | z-index: 100; 82 | opacity: 0; 83 | background-color: rgba(0,0,0,.7); 84 | } 85 | &._show { 86 | ._body { 87 | visibility: visible; 88 | >._wrap { 89 | -webkit-transform: scale(1); 90 | -ms-transform: scale(1); 91 | -o-transform: scale(1); 92 | transform: scale(1); 93 | opacity: 1; 94 | } 95 | } 96 | ._overlay { 97 | opacity: 1; 98 | visibility: visible; 99 | } 100 | } 101 | &._force { 102 | ._body { 103 | ._wrap { 104 | border: none; 105 | } 106 | } 107 | ._overlay { 108 | background-color: rgba(255,255,255,.9); 109 | } 110 | } 111 | } -------------------------------------------------------------------------------- /css/notice.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | 3 | .notice { 4 | @_width: 300px; 5 | &-center { 6 | position:fixed; 7 | width: @_width; 8 | overflow: hidden; 9 | top: 10px; 10 | right: 10px; 11 | z-index: 100; 12 | >.notice { 13 | position: relative; 14 | display: block; 15 | width: @_width; 16 | background: @gray_c; 17 | border: 1px solid @gray_b; 18 | padding: 5px 10px; 19 | margin-bottom: 10px; 20 | ._title { 21 | font-weight: bold; 22 | margin-bottom: 10px; 23 | } 24 | ._close { 25 | position: absolute; 26 | right: 5px; 27 | top: 5px; 28 | cursor: pointer; 29 | } 30 | } 31 | } 32 | 33 | &-enter { 34 | transform: translate3d(@_width,0,0); 35 | opacity: 0.01; 36 | } 37 | 38 | &-enter&-enter-active { 39 | opacity: 1; 40 | transform: translate3d(0,0,0); 41 | transition: all .3s; 42 | } 43 | 44 | &-leave { 45 | opacity: 1; 46 | transform: translate3d(0,0,0); 47 | } 48 | 49 | &-leave&-leave-active { 50 | opacity: 0.01; 51 | transform: translate3d(@_width,0,0); 52 | transition: all .3s; 53 | } 54 | } -------------------------------------------------------------------------------- /css/pagination.less: -------------------------------------------------------------------------------- 1 | @import url('meta.less'); 2 | 3 | .pagination { 4 | margin: 0; 5 | padding: 10px 0 0; 6 | >._item { 7 | display: inline-block; 8 | color: @blue; 9 | margin: 2px; 10 | overflow: hidden; 11 | cursor: pointer; 12 | line-height: 28px; 13 | height: 28px; 14 | min-width: 28px; 15 | font-size: 14px; 16 | text-align: center; 17 | &._active { 18 | cursor: default; 19 | background: @gray_c; 20 | color: @gray_a; 21 | border-radius: 15px; 22 | } 23 | } 24 | ._range, ._nav { 25 | width: auto; 26 | } 27 | ._jump { 28 | color: initial; 29 | padding: 0 5px; 30 | cursor: default; 31 | >input { 32 | width: 45px; 33 | padding: 4px; 34 | overflow: hidden; 35 | text-align: center; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /css/panel.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | 3 | .panel { 4 | background-color: @white; 5 | border: 1px solid @gray_c; 6 | >._title { 7 | font-size: 16px; 8 | font-weight: bold; 9 | color: @black; 10 | padding: 10px; 11 | } 12 | >._content { 13 | padding: 10px; 14 | } 15 | } -------------------------------------------------------------------------------- /css/pin.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | 3 | .pin { 4 | &.fixed { 5 | top: 0; 6 | position: fixed; 7 | z-index: 100; 8 | } 9 | } -------------------------------------------------------------------------------- /css/popup.less: -------------------------------------------------------------------------------- 1 | @import url('meta.less'); 2 | @import url('transition.less'); 3 | 4 | .popup { 5 | @short: 6px; 6 | @long: 8px; 7 | @base: -17px; 8 | 9 | .border_base { 10 | border-width: inherit; 11 | border-color: inherit; 12 | } 13 | 14 | ._trigger { 15 | display: inline-block; 16 | cursor: pointer; 17 | } 18 | 19 | ._wrap { 20 | display: block; 21 | position: relative; 22 | ._content { 23 | position: absolute; 24 | z-index: 100; 25 | max-width: 350px; 26 | min-width: 150px; 27 | background: @white; 28 | border-radius: @border_radius; 29 | text-align: center; 30 | padding: 10px; 31 | border: 1px solid @gray_b; 32 | } 33 | 34 | ._arrow { 35 | content: ''; 36 | position: absolute; 37 | width: 0; 38 | height: 0; 39 | border-style: solid; 40 | border-width: @long @short; 41 | border-color: @gray_b transparent transparent transparent; 42 | &:before { 43 | content: ''; 44 | position: absolute; 45 | border-style: solid; 46 | border-width: @long @short; 47 | } 48 | } 49 | 50 | &._top ._arrow { 51 | left: 50%; 52 | margin-left: -@short; 53 | bottom: @base; 54 | &:before { 55 | .border_base; 56 | left: inherit; 57 | margin-left: -@short; 58 | bottom: -@short; 59 | border-top-color: @white; 60 | } 61 | } 62 | 63 | &._left ._arrow { 64 | border-width: @short @long; 65 | right: @base; 66 | top: 50%; 67 | margin-top: -@long; 68 | border-color: transparent transparent transparent @gray_b; 69 | &:before { 70 | .border_base; 71 | top: inherit; 72 | margin-top: -@short; 73 | right: -@short; 74 | border-left-color: @white; 75 | } 76 | } 77 | 78 | &._right ._arrow { 79 | top: 50%; 80 | left: @base; 81 | margin-top: -@long; 82 | border-width: @short @long; 83 | border-color: transparent @gray_b transparent transparent; 84 | &:before { 85 | .border_base; 86 | top: inherit; 87 | margin-top: -@short; 88 | left: -@short; 89 | border-right-color: @white; 90 | } 91 | } 92 | 93 | &._bottom ._arrow { 94 | left: 50%; 95 | top: @base; 96 | margin-left: -@short; 97 | border-color: transparent transparent @gray_b transparent; 98 | &:before { 99 | .border_base; 100 | left: inherit; 101 | top: -@short; 102 | margin-left: -@short; 103 | border-bottom-color: @white; 104 | } 105 | } 106 | } 107 | .basic_transition; 108 | } 109 | 110 | .confirm-box { 111 | ._action { 112 | margin-top: 10px; 113 | font-size: 80%; 114 | text-align: center; 115 | ._cancel, ._confirm { 116 | cursor: pointer; 117 | display: inline-block; 118 | } 119 | ._confirm { 120 | margin-right:5px; 121 | } 122 | } 123 | } -------------------------------------------------------------------------------- /css/progress.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | 3 | .progress{ 4 | position: relative; 5 | background: @gray_d; 6 | border-radius: 3px; 7 | height: 6px; 8 | 9 | .__progressSize(@size){ 10 | & { 11 | @_h: @size * 1px; 12 | height: @_h; 13 | font-size: @_h; 14 | >.bar, >._progress { 15 | height: @_h; 16 | } 17 | } 18 | } 19 | 20 | @-webkit-keyframes progressbar { 21 | 0% { left: -100%;} 22 | 100% { left: 100%;} 23 | } 24 | @-o-keyframes progressbar { 25 | 0% { left: -100%;} 26 | 100% { left: 100%;} 27 | } 28 | @keyframes progressbar { 29 | 0% { left: -100%;} 30 | 100% { left: 100%;} 31 | } 32 | 33 | >._progress { 34 | overflow: hidden; 35 | -webkit-transition: all .3s; 36 | -o-transition: all .3s; 37 | transition: all .3s; 38 | text-align: center; 39 | color: @white; 40 | line-height: 6px; 41 | background: @blue; 42 | border-radius: 10px; 43 | position: absolute; 44 | left: 0; 45 | top: 0; 46 | height: 100%; 47 | } 48 | 49 | &._completed { 50 | >._progress { 51 | background: @green; 52 | } 53 | } 54 | &._failed { 55 | >._progress { 56 | background: @red; 57 | } 58 | } 59 | &._context { 60 | height: 15px; 61 | line-height: 15px; 62 | border-radius: 6px; 63 | font-size: 12px; 64 | >._progress { 65 | border-radius: inherit; 66 | font-size: inherit; 67 | line-height: inherit; 68 | } 69 | } 70 | &._disabled { 71 | >._progress { 72 | background: @gray_b; 73 | } 74 | } 75 | 76 | &._large { 77 | .__progressSize(10) 78 | } 79 | &._small { 80 | .__progressSize(2) 81 | } 82 | 83 | &._active { 84 | >._progress { 85 | &:before { 86 | content: ''; 87 | position: absolute; 88 | border-radius: inherit; 89 | top: 0; 90 | bottom: 0; 91 | width: 25%; 92 | border-radius: inherit; 93 | z-index: 1; 94 | -webkit-transition: all .3s; 95 | -o-transition: all .3s; 96 | transition: all .3s; 97 | background: rgba(255,255,255, .2); 98 | animation: progressbar 2s linear infinite; 99 | } 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /css/share.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | 3 | .truncate { 4 | max-width: 100%; 5 | display: inline-block; 6 | text-overflow: ellipsis; 7 | white-space: nowrap; 8 | overflow: hidden; 9 | :after { 10 | content: ''; 11 | background: @white; 12 | width: 16px; 13 | } 14 | } 15 | 16 | .text-center { 17 | text-align: center; 18 | } 19 | 20 | .clearfix { 21 | overflow: auto; 22 | zoom: 1; 23 | } 24 | -------------------------------------------------------------------------------- /css/slide-menu.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | 3 | 4 | .slide-menu { 5 | @basic_transition: background .3s 0s, visibility .3s 0s, opacity .3s 0s; 6 | ._content { 7 | -webkit-transition: transform 0.3s; 8 | -o-transition: transform 0.3s; 9 | transition: transform 0.3s; 10 | position: fixed; 11 | z-index: 1000; 12 | width: 100%; 13 | height: 100%; 14 | background: @white; 15 | } 16 | 17 | ._overlay { 18 | opacity: 0; 19 | position: fixed; 20 | visibility: hidden; 21 | width: 100%; 22 | height: 100%; 23 | left: 0; 24 | right: 0; 25 | bottom: 0; 26 | top: 0; 27 | z-index: -1; 28 | -webkit-transition: @basic_transition, z-index .3s .3s; 29 | -o-transition: @basic_transition, z-index .3s .3s; 30 | transition: @basic_transition, z-index .3s .3s; 31 | } 32 | 33 | &._display { 34 | ._overlay { 35 | opacity: 1; 36 | visibility: visible; 37 | z-index: 999; 38 | background: rgba(0,0,0,.5); 39 | -webkit-transition: @basic_transition; 40 | -o-transition: @basic_transition; 41 | transition: @basic_transition; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /css/tab.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | @import url('share'); 3 | 4 | @border: 1px solid transparent; 5 | .layout_h { 6 | float: left; 7 | display: inline-block; 8 | } 9 | 10 | .tab { 11 | ._tab { 12 | overflow: hidden; 13 | ._item { 14 | cursor: pointer; 15 | float: left; 16 | padding: 5px 10px; 17 | height: 35px; 18 | line-height: 25px; 19 | border: 1px solid transparent; 20 | &._active { 21 | border-color: @gray_c; 22 | color: @gray_a; 23 | background: @gray_d; 24 | } 25 | } 26 | } 27 | ._content { 28 | >._item { 29 | padding: 20px; 30 | border: 1px solid @gray_c; 31 | width: 100%; 32 | min-height: 200px; 33 | display: none; 34 | &._active { 35 | display: block; 36 | } 37 | } 38 | } 39 | &.vertical { 40 | >._tab { 41 | width: 200px; 42 | float: left; 43 | >._item { 44 | float: none; 45 | } 46 | >._tab { 47 | display: block; 48 | border: 1px solid transparent; 49 | margin-right: -1px; 50 | border-radius: 3px; 51 | border-top-right-radius: 0; 52 | border-bottom-right-radius: 0; 53 | &.active, &._active { 54 | border-color: @gray_b; 55 | border-right-color: transparent; 56 | } 57 | } 58 | } 59 | >._content { 60 | border-top-right-radius: 3px; 61 | margin-left: 200px; 62 | } 63 | &.bottom { 64 | display: table; 65 | table-layout: fixed; 66 | width: 100%; 67 | >.content, >._content { 68 | margin-left: 0; 69 | display: table-cell; 70 | border-radius: 3px 0 3px 3px; 71 | } 72 | >.bar, >._tab { 73 | vertical-align: top; 74 | display: table-cell; 75 | float: initial; 76 | >.item, >._item { 77 | margin-left: -1px; 78 | border-radius: 0 3px 3px 0; 79 | &.active, &._active { 80 | border-color: @gray_c; 81 | border-left-color: transparent; 82 | } 83 | } 84 | } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /css/time-picker.less: -------------------------------------------------------------------------------- 1 | @import url('meta'); 2 | @import url('transition.less'); 3 | 4 | .timeinput { 5 | position: relative; 6 | width: 160px; 7 | ._input { 8 | >input { 9 | border: 1px solid @gray_b; 10 | width: 100%; 11 | padding: 0 10px; 12 | line-height: 25px; 13 | height: 30px; 14 | font-size: 14px; 15 | } 16 | } 17 | } 18 | 19 | .timepicker, .datetime-picker { 20 | width: 160px; 21 | position: relative; 22 | .timeinput { 23 | width: 100%; 24 | } 25 | ul li { 26 | list-style-type: none; 27 | } 28 | ._wrap { 29 | display: block; 30 | position: absolute; 31 | left: 0; 32 | top: 30px; 33 | width: 100%; 34 | z-index: 100; 35 | background-color: @white; 36 | } 37 | &._top ._wrap { 38 | top: initial; 39 | bottom: 30px; 40 | } 41 | ._section { 42 | overflow: hidden; 43 | border: 1px solid @gray_c; 44 | } 45 | ._list { 46 | position: relative; 47 | width: 100/3%; 48 | float: left; 49 | max-height: 140px; 50 | margin: 0; 51 | overflow-y: scroll; 52 | &+._list { 53 | border-left: 1px solid @gray_c; 54 | } 55 | > ul { 56 | padding: 0 0 120px 0; 57 | display: block; 58 | } 59 | ._item { 60 | text-align: center; 61 | cursor: pointer; 62 | padding: 2px 0; 63 | color: @gray; 64 | font-size: 13px; 65 | line-height: 26px; 66 | &._active { 67 | color: @black_a; 68 | background-color: @gray_d; 69 | } 70 | } 71 | } 72 | &._simple { 73 | width: 120px; 74 | ._list { 75 | width: 50%; 76 | } 77 | } 78 | 79 | .basic_transition; 80 | } -------------------------------------------------------------------------------- /css/transition.less: -------------------------------------------------------------------------------- 1 | .basic_transition { 2 | &-enter { 3 | opacity: 0.01; 4 | } 5 | 6 | &-enter&-enter-active { 7 | opacity: 1; 8 | transition: all .3s; 9 | } 10 | 11 | &-leave { 12 | opacity: 1; 13 | } 14 | 15 | &-leave&-leave-active { 16 | opacity: 0.01; 17 | transition: all .3s; 18 | } 19 | } -------------------------------------------------------------------------------- /demo/css/carousel_demo.less: -------------------------------------------------------------------------------- 1 | @import url('../../css/meta'); 2 | 3 | .carousel-demo { 4 | >li { 5 | padding: 30px; 6 | img { 7 | height: 343px; 8 | overflow: hidden; 9 | background: @gray_c; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /demo/css/demo.less: -------------------------------------------------------------------------------- 1 | @import url('../../css/all.less'); 2 | @import url('menu_demo.less'); 3 | @import url('carousel_demo.less'); 4 | @import url('pin_demo.less'); 5 | 6 | a { 7 | color: @blue; 8 | } 9 | 10 | body { 11 | font-size: 15px; 12 | line-height: 22px; 13 | } 14 | 15 | ul { 16 | padding: 0; 17 | } 18 | 19 | .table { 20 | display: table; 21 | width: 100%; 22 | .row { 23 | display: table-row; 24 | } 25 | 26 | .cell { 27 | vertical-align: middle; 28 | display: table-cell; 29 | } 30 | } 31 | 32 | .center { 33 | text-align: center; 34 | } 35 | 36 | .container { 37 | width: 1080px; 38 | padding: 20px; 39 | margin: 0 auto; 40 | } 41 | 42 | .header { 43 | padding: 50px 0; 44 | color: @white; 45 | background: @black_b; 46 | span { 47 | font-size: 14px; 48 | &+span{ 49 | margin-left: 20px; 50 | } 51 | } 52 | a { 53 | color: @yellow; 54 | } 55 | } 56 | 57 | .footer { 58 | a { 59 | color: @red; 60 | } 61 | } 62 | 63 | .wrapper { 64 | background: @white; 65 | } 66 | 67 | ul { 68 | ._display { 69 | padding: 5px 0; 70 | display: inline-block; 71 | } 72 | } 73 | 74 | ._disabled { 75 | color: @gray_a !important; 76 | cursor: not-allowed !important; 77 | } 78 | 79 | .gap-word { 80 | span+span { 81 | &:before { 82 | content: ','; 83 | margin-right: 3px; 84 | } 85 | margin-left: 3px; 86 | } 87 | } 88 | 89 | #demo_list { 90 | overflow: hidden; 91 | .demo-nav { 92 | padding: 10px; 93 | width: 220px; 94 | float: left; 95 | a.active { 96 | color: @black; 97 | } 98 | } 99 | .children { 100 | min-height: 2000px; 101 | margin-left: 240px; 102 | padding: 10px; 103 | >div { 104 | >ul, >ol { 105 | >li { 106 | margin-bottom: 20px; 107 | } 108 | &.two { 109 | >li { 110 | float: left; 111 | width: 50%; 112 | display: inline-block; 113 | } 114 | } 115 | &.three { 116 | >li { 117 | float: left; 118 | width: 33.3%; 119 | display: inline-block; 120 | } 121 | } 122 | } 123 | } 124 | } 125 | } 126 | 127 | pre { 128 | margin: 10px 0; 129 | padding: 10px; 130 | background: @white_a; 131 | white-space: pre; 132 | overflow-y: hidden; 133 | display: block; 134 | overflow-x: auto; 135 | code { 136 | font-family: Monaco monospace; 137 | font-size: 12px; 138 | letter-spacing: 1px; 139 | line-height: 20px; 140 | overflow-y: hidden; 141 | display: block; 142 | color: @green; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /demo/css/menu_demo.less: -------------------------------------------------------------------------------- 1 | #menu_demo { 2 | min-height: 2800px; 3 | } 4 | -------------------------------------------------------------------------------- /demo/css/pin_demo.less: -------------------------------------------------------------------------------- 1 | @import url('../../css/meta'); 2 | .pin-demo { 3 | min-height: 1600px; 4 | .card { 5 | width: 200px; 6 | border: 1px solid @gray_b; 7 | background: @gray_d; 8 | padding: 10px; 9 | margin-right: 30px; 10 | &.last { 11 | background: @gray_b; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /demo/example/CalendarDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {Calendar} from './index.js'; 3 | import {formatDate} from '../../component/util/datetime'; 4 | 5 | 6 | export default class CalendarDemo extends Component { 7 | constructor(props){ 8 | super(props); 9 | this.state = { 10 | value: undefined, 11 | }; 12 | } 13 | 14 | handleChange(value){ 15 | this.setState({ 16 | value 17 | }); 18 | } 19 | 20 | render() { 21 | return ( 22 |
    23 |

    Calendar

    24 |
      25 |
    • 26 |

      Default Calendar

      27 | value}/> 28 |
      29 |                             
      30 |                                 {''}
      31 |                             
      32 |                         
      33 |
    • 34 |
    • 35 |

      Calendar with given value

      36 | value}/> 37 |
      38 |                             
      39 |                                 {''}
      40 |                             
      41 |                         
      42 |
    • 43 |
    • 44 |

      Calendar value change event

      45 |

      date changed to {formatDate(this.state.value)}

      46 | 47 |
      48 |                             
      49 |                                 {''}
      50 |                             
      51 |                         
      52 |
    • 53 |
    • 54 |

      Calendar with begin and end

      55 | value} /> 57 |
      58 |                             
      59 |                                 {''}
      60 |                             
      61 |                         
      62 |
    • 63 |
    • 64 |

      Calendar with no preview

      65 | value} /> 66 |
      67 |                             
      68 |                                 {''}
      69 |                             
      70 |                         
      71 |
    • 72 |
    • 73 |

      Calendar with type

      74 |

      month:

      75 | value} /> 76 |
      77 |                             
      78 |                                 {''}
      79 |                             
      80 |                         
      81 |
      82 |

      year:

      83 | value} /> 84 |
      85 |                             
      86 |                                 {''}
      87 |                             
      88 |                         
      89 |
      90 |
    • 91 |
    92 |
    93 | ); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /demo/example/CarouselDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {Carousel} from "./index.js"; 3 | 4 | const src = ['ambition-morty', 'awkward-morty', 'despise', 'pride-morty', 'surprise-morty']; 5 | const prefix = 'https://raw.githubusercontent.com/jerryshew/design/master/png'; 6 | const getImgs = function(){ 7 | return src.map(i => ) 8 | }; 9 | 10 | const imgNodes = getImgs(); 11 | 12 | export default class CarouselDemo extends Component { 13 | render() { 14 | let items = []; 15 | 16 | let prev =

    <<

    ; 17 | let next =

    >>

    ; 18 | return ( 19 |
    20 |

    Carousel

    21 |
      22 |
    • 23 |

      Default carousel

      24 | {imgNodes} 25 |
       26 |                             
       27 |                                 {''}
       28 |                                 
      29 | {' '} 30 |
      31 | {' '} 32 |
      33 | {' ...'} 34 |
      35 | {'
      '} 36 |
      37 |
      38 |
    • 39 |
    • 40 |

      Auto play carousel

      41 | 42 | {imgNodes} 43 | 44 |
       45 |                             
       46 |                                 {' autoPlay={true} delay={3000}>'}
       47 |                                 
      48 | {' '} 49 |
      50 | {' '} 51 |
      52 | {' ...'} 53 |
      54 | {'
      '} 55 |
      56 |
      57 |
    • 58 |
    • 59 |

      Carousel with control arrows

      60 | 61 | {imgNodes} 62 | 63 |
       64 |                             
       65 |                                 {' showArrow={true}>'}
       66 |                                 
      67 | {' '} 68 |
      69 | {' '} 70 |
      71 | {' ...'} 72 |
      73 | {'
      '} 74 |
      75 |
      76 |
    • 77 |
    • 78 |

      Carousel custom control arrows

      79 | 80 | {imgNodes} 81 | 82 |
       83 |                             
       84 |                                 {' prev={

      <<

      }\n\t next={

      >>

      }\n\t showArrow={true}>'} 85 |
      86 | {' '} 87 |
      88 | {' '} 89 |
      90 | {' ...'} 91 |
      92 | {'
      '} 93 |
      94 |
      95 |
    • 96 |
    97 |
    98 | ); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /demo/example/CheckBoxDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {CheckBox} from "./index.js"; 3 | 4 | export default class CheckBoxDemo extends Component { 5 | handleChange(e){ 6 | console.log('changed', e.target.checked); 7 | } 8 | render() { 9 | return ( 10 |
    11 |

    Checkbox

    12 |
      13 |
    • 14 |

      Default checkbox

      15 | checkbox 16 |
      17 |                             
      18 |                                 {'\n\tcheckbox\n'}
      19 |                             
      20 |                         
      21 |
    • 22 |
    • 23 |

      Checked checkbox

      24 | checked 25 |
      26 |                             
      27 |                                 {'checked'}
      28 |                             
      29 |                         
      30 |
    • 31 |
    • 32 |

      Disabled checkbox

      33 | disabled 34 |
      35 |                             
      36 |                                 {'disabled'}
      37 |                             
      38 |                         
      39 |
    • 40 |
    41 |
    42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /demo/example/CheckBoxGroupDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {CheckBoxGroup, CheckBox} from "./index.js"; 3 | 4 | const options = [ 5 | {'name': 'apple', 'value': 'a'}, 6 | {'name': 'banana', 'value': 'b', disabled: true}, 7 | {'name': 'cat', 'value': 'c'}, 8 | {'name': 'dog', 'value': 'd'}, 9 | ]; 10 | 11 | const checkedVal = ['a', 'd']; 12 | const checkedVal1 = ['banana']; 13 | 14 | export default class CheckBoxGroupDemo extends Component { 15 | constructor(props, refs){ 16 | super(props); 17 | this.state = { 18 | displayText: checkedVal.join(','), 19 | displayText1: checkedVal1.join(','), 20 | }; 21 | } 22 | 23 | displayChange(stat, value){ 24 | this.setState({ 25 | [String(stat)]: value.join(','), 26 | }); 27 | } 28 | 29 | render() { 30 | return ( 31 |
    32 |

    Checkbox group

    33 |
      34 |
    • 35 |

      Checkbox group

      36 |

      you selected value is {this.state.displayText}

      37 | 40 |
      41 |                             
      42 |                                 {'
      44 |                                 {'  valueName="value" value={value}'}
      45 |                                 
      46 | {' onChange={displayChange} />'} 47 |
      48 |
      49 |
    • 50 |
    • 51 |

      Checkbox group yield childrens

      52 |

      you selected value is {this.state.displayText1}

      53 | 54 | apple 55 | banana 56 | cat 57 | 58 |
      59 |                             
      60 |                                 {''}
      61 |                                 
      62 | {' apple'} 63 |
      64 | {' banana'} 65 |
      66 | {' cat'} 67 |
      68 | {'
      '} 69 |
      70 |
      71 |
    • 72 |
    73 |
    74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /demo/example/DateTimePickerDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {DateTimePicker} from './index'; 3 | 4 | import {formatDate} from '../../component/util/datetime'; 5 | 6 | export default class DateTimePickerDemo extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.state = { 10 | value: undefined, 11 | } 12 | } 13 | handleValueChange(value){ 14 | this.setState({ 15 | value 16 | }); 17 | } 18 | render() { 19 | return ( 20 |
    21 |

    datetime picker

    22 |
      23 |
    • 24 |

      Default datetime picker

      25 | console.log(val)} /> 26 |
      27 |                             
      28 |                                 {``}
      29 |                             
      30 |                         
      31 |
    • 32 |
    • 33 |

      Given value

      34 | console.log(val) }/> 35 |
      36 |                             
      37 |                                 {` `}
      38 |                             
      39 |                         
      40 |
    • 41 |
    • 42 |

      onChange function

      43 |

      selected value is {formatDate(this.state.value, 'yyyy-MM-dd hh:mm:ss')}

      44 | 45 |
      46 |                             
      47 |                                 {``}
      48 |                             
      49 |                         
      50 |
    • 51 |
    • 52 |

      begin and end

      53 | console.log(val) }/> 55 |
      56 |                             
      57 |                                 {``}
      58 |                             
      59 |                         
      60 |
    • 61 |
    • 62 |

      DateTimePicker with position

      63 |

      top/left/right/bottom, default is bottom

      64 | console.log(value) }/> 65 |
      66 | console.log(value) }/> 67 |
      68 | console.log(value) }/> 69 |
      70 |
      71 |                             
      72 |                                 {` console.log(value) }/>`}
      73 |                             
      74 |                         
      75 |
    • 76 |
    77 |
    78 | ); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /demo/example/FlashMessageDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {FlashMessage} from './index'; 3 | 4 | const onClick = () => { 5 | alert('onClick') 6 | window.open('http://braavos.me') 7 | } 8 | const onClose = () => { 9 | return confirm('close?') 10 | } 11 | 12 | export default class FlashMessageDemo extends Component { 13 | showMessage(props){ 14 | props.content =

    this is the message

    15 | FlashMessage.show(props) 16 | } 17 | render() { 18 | return ( 19 |
    20 |

    Message

    21 |
      22 |
    1. 23 |

      Default message

      24 | 25 |
       26 |                             
       27 | {`
       28 | FlashMessage.show({
       29 |     content: 

      content

      , 30 | }) 31 | `} 32 |
      33 |
      34 |
    2. 35 |
    3. 36 |

      Position

      37 |
        38 |
      • 39 | 40 |
         41 |                                     
         42 | {`
         43 | FlashMessage.show({
         44 |     content: 

        content

        , 45 | position: 'top', 46 | }) 47 | `} 48 |
        49 |
        50 |
      • 51 |
      • 52 | 53 |
         54 |                                     
         55 | {`
         56 | FlashMessage.show({
         57 |     content: 

        content

        , 58 | position: 'center', 59 | }) 60 | `} 61 |
        62 |
        63 |
      • 64 |
      • 65 | 66 |
         67 |                                     
         68 | {`
         69 | FlashMessage.show({
         70 |     content: 

        content

        , 71 | position: 'bottom', 72 | }) 73 | `} 74 |
        75 |
        76 |
      • 77 |
      78 |
    4. 79 |
    5. 80 |

      Delay time

      81 | 82 |
       83 |                             
       84 | {`
       85 | FlashMessage.show({
       86 |     content: 

      content

      , 87 | delay: 1000, 88 | }) 89 | `} 90 |
      91 |
      92 |
    6. 93 |
    7. 94 |

      custom close DOM

      95 | 96 |
       97 |                             
       98 | {`
       99 | FlashMessage.show({
      100 |     content: 

      content

      , 101 | close: close 102 | }) 103 | `} 104 |
      105 |
      106 |
    8. 107 |
    9. 108 |

      onClick event

      109 | 110 |
      111 |                             
      112 | {`
      113 | FlashMessage.show({
      114 |     content: 

      content

      , 115 | onClick: clickFunction, 116 | }) 117 | `} 118 |
      119 |
      120 |
    10. 121 |
    122 |
    123 | ); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /demo/example/PaginationDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {Pagination} from './index.js'; 3 | 4 | export default class PaginationDemo extends Component { 5 | constructor(props){ 6 | super(props); 7 | this.state = { 8 | current: 6, 9 | }; 10 | } 11 | 12 | handlePageChange(page){ 13 | this.setState({ 14 | current: page 15 | }); 16 | } 17 | 18 | render() { 19 | return ( 20 |
    21 |

    Pagination

    22 |
      23 |
    1. 24 |

      Default pagination

      25 | 26 |
       27 |                             
       28 |                                 {``}
       29 |                             
       30 |                         
      31 |
    2. 32 |
    3. 33 |

      Change event

      34 |

      this will change next pagination

      35 | 36 |
       37 |                             
       38 |                                 {``}
       39 |                             
       40 |                         
      41 |
    4. 42 |
    5. 43 |

      Pagination with given current page

      44 |

      now on page {this.state.current}

      45 | 46 |
       47 |                             
       48 |                                 {``}
       49 |                             
       50 |                         
      51 |
    6. 52 |
    7. 53 |

      Pagination with full range

      54 | 55 |
       56 |                             
       57 |                                 {``}
       58 |                             
       59 |                         
      60 |
    8. 61 |
    9. 62 |

      Pagination with custom range

      63 | 首页} end={末页} total={100}/> 64 |
       65 |                             
       66 |                                 {`首页} end={末页} />`}
       67 |                             
       68 |                         
      69 |
    10. 70 |
    11. 71 |

      Pagination with navigation

      72 | 73 |
       74 |                             
       75 |                                 {``}   
       76 |                             
       77 |                         
      78 |
    12. 79 |
    13. 80 |

      Pagination with custom navigation

      81 | 上一页} next={下一页}/> 82 |
       83 |                             
       84 |                                 {`上一页} next={下一页}/>`}   
       85 |                             
       86 |                         
      87 |
    14. 88 |
    15. 89 |

      Pagination with jump page navigation

      90 | 91 |
       92 |                             
       93 |                                 {``}   
       94 |                             
       95 |                         
      96 |
    16. 97 |
    98 |
    99 | ); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /demo/example/PinDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {Pin} from './index.js'; 3 | 4 | export default class PinDemo extends Component { 5 | 6 | render() { 7 | return ( 8 |
    9 |

    Pin

    10 |
      11 |
    • 12 |

      Default pin

      13 | 14 |
      15 |

      title

      16 |

      pin at top

      17 |
      18 |
      19 |
      20 |                             
      21 | {`
      22 | 
      23 |     
      24 |

      title

      25 |

      pin at top

      26 |
      27 |
      28 | `} 29 |
      30 |
      31 |
    • 32 |
    • 33 |

      Pin with offset top

      34 | 35 |
      36 |

      title

      37 |

      pin at position top 100px

      38 |
      39 |
      40 |
      41 |                             
      42 | {`
      43 | 
      44 |     ...
      45 | 
      46 | `}                                
      47 |                             
      48 |                         
      49 |
    • 50 |
    • 51 |

      Scroll to given top

      52 | 53 |
      54 |

      title

      55 |

      pin when scroll to 800px

      56 |
      57 |
      58 |
      59 |                             
      60 | {`
      61 | 
      62 |     ...
      63 | 
      64 | `}                                 
      65 |                             
      66 |                         
      67 |
    • 68 |
    69 |

    ↓↓ Scroll to bottom ↓↓

    70 |
    71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /demo/example/ProgressDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {Progress} from './index'; 3 | 4 | export default class ProgressDemo extends Component { 5 | constructor(props){ 6 | super(props); 7 | this.state = { 8 | value: 30, 9 | }; 10 | } 11 | 12 | handleMinus(){ 13 | let {value} = this.state; 14 | value -= 10; 15 | if (value < 0) value = 0; 16 | this.setState({ 17 | value, 18 | }); 19 | } 20 | 21 | handlePlus(){ 22 | let {value} = this.state; 23 | value += 10; 24 | if (value > 100) value = 100; 25 | this.setState({ 26 | value 27 | }); 28 | } 29 | 30 | render() { 31 | const {value} = this.state; 32 | return ( 33 |
    34 |

    Progress

    35 |
      36 |
    1. 37 |

      Default progress

      38 | 39 |

      40 | - 41 | 42 | + 43 |

      44 |
       45 |                             
       46 |                                 {``}                                
       47 |                             
       48 |                         
      49 |
    2. 50 |
    3. 51 |

      Animated progress

      52 | 53 |
       54 |                             
       55 |                                 {``}   
       56 |                             
       57 |                         
      58 |
    4. 59 |
    5. 60 |

      Completed progress

      61 | 62 |
       63 |                             
       64 |                                 {``}
       65 |                             
       66 |                         
      67 |
    6. 68 |
    7. 69 |

      Failed progress

      70 | 71 |
       72 |                             
       73 |                                 {``}
       74 |                             
       75 |                         
      76 |
    8. 77 |
    9. 78 |

      Disabled progress

      79 | 80 |
       81 |                             
       82 |                                 {``}
       83 |                             
       84 |                         
      85 |
    10. 86 |
    11. 87 |

      Different size progress

      88 |
      Large:
      89 | 90 |
      Small:
      91 | 92 |
       93 |                             
       94 |                                 {``}
       95 |                             
       96 |                         
      97 |
    12. 98 |
    13. 99 |

      Yield context

      100 | 101 | this progress now is 30% 102 | 103 |
      104 |                             
      105 | {`
      106 | 
      107 |     this progress now is 
      108 |     
      109 |         {value}
      110 |     
      111 | 
      112 | `}                                
      113 |                             
      114 |                         
      115 |
    14. 116 |
    117 |
    118 | ); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /demo/example/RadioDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {Radio} from './index.js'; 3 | 4 | export default class RadioDemo extends Component { 5 | handleChange(e){ 6 | 7 | } 8 | 9 | render() { 10 | return ( 11 |
    12 |

    Radio

    13 |
      14 |
    • 15 |

      Default radio

      16 | radio 17 |
      18 |                             
      19 |                                 {`radio`}
      20 |                             
      21 |                         
      22 |
    • 23 |
    • 24 |

      Checked radio

      25 | checked 26 |
      27 |                             
      28 |                                 {`checked`}
      29 |                             
      30 |                         
      31 |
    • 32 |
    • 33 |

      Disabled radio

      34 | disabled 35 |
      36 |                             
      37 |                                 {`disabled`}
      38 |                             
      39 |                         
      40 |
    • 41 |
    42 |
    43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /demo/example/RadioGroupDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {RadioGroup, Radio} from './index.js'; 3 | 4 | const options = [ 5 | {'name': 'apple', 'value': 'a'}, 6 | {'name': 'banana', 'value': 'b', disabled: true}, 7 | {'name': 'cat', 'value': 'c'}, 8 | {'name': 'dot', 'value': 'd'}, 9 | ]; 10 | 11 | const checkedVal = 'c'; 12 | 13 | export default class RadioDemo extends Component { 14 | constructor(props, refs){ 15 | super(props); 16 | this.state = { 17 | displayText: checkedVal, 18 | }; 19 | } 20 | 21 | displayChange(value){ 22 | this.setState({ 23 | displayText: value, 24 | }); 25 | } 26 | 27 | render() { 28 | return ( 29 |
    30 |

    Radio group

    31 |
      32 |
    • 33 |

      Default radio group

      34 | console.log(val)}/> 35 |
      36 |                             
      37 |                                 {``}
      38 |                             
      39 |                         
      40 |
    • 41 |
    • 42 |

      Radio group with default checked

      43 | console.log(value)} /> 45 |
      46 |                             
      47 |                                 {``}
      48 |                             
      49 |                         
      50 |
    • 51 |
    • 52 |

      Radio group selected change

      53 |

      you selected value is {this.state.displayText}

      54 | 55 |
      56 |                             
      57 |                                 {``}
      58 |                             
      59 |                         
      60 |
    • 61 |
    • 62 |

      Radio group with yield children

      63 | console.log(val)}> 64 | apple 65 | banana 66 | cat 67 | dog 68 | 69 |
      70 |                             
      71 | {`
      72 | 
      73 |     apple
      74 |     banana
      75 |     cat
      76 |     dog
      77 | 
      78 | `}                                
      79 |                             
      80 |                         
      81 |
    • 82 |
    83 |
    84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /demo/example/TimeInputDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {TimeInput} from './index.js'; 3 | import {seconds2Obj, obj2TimeStr} from '../../component/util/time'; 4 | 5 | export default class TimeInputDemo extends Component { 6 | constructor(props){ 7 | super(props); 8 | this.state = { 9 | showTime: 47551 10 | }; 11 | } 12 | 13 | handleTimeChange(value){ 14 | this.setState({ 15 | showTime: value 16 | }); 17 | } 18 | 19 | render() { 20 | return ( 21 |
    22 |

    Time input

    23 |
      24 |
    • 25 |

      Default time input

      26 | console.log(value)}/> 27 |
      28 |                             
      29 |                                 {``}
      30 |                             
      31 |                         
      32 |
    • 33 |
    • 34 |

      Time input with given value

      35 | console.log(value)}/> 36 |
      37 |                             
      38 |                                 {``}
      39 |                             
      40 |                         
      41 |
    • 42 |
    • 43 |

      Time input onchange event

      44 |

      time you selected value is {this.state.showTime}, display is {obj2TimeStr(seconds2Obj(this.state.showTime))}

      45 | 46 |
      47 |                             
      48 |                                 {``}
      49 |                             
      50 |                         
      51 |
    • 52 |
    • 53 |

      simple

      54 | console.log(value)}/> 55 |
      56 |                             
      57 |                                 {``}
      58 |                             
      59 |                         
      60 |
    • 61 |
    62 |
    63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /demo/example/TimePickerDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {TimePicker} from './index'; 3 | 4 | export default class TimePickerDemo extends Component { 5 | constructor(props) { 6 | super(props); 7 | this.state = { 8 | value: 47551 9 | } 10 | } 11 | handleValueChange(value) { 12 | this.setState({ 13 | value 14 | }); 15 | } 16 | render() { 17 | return ( 18 |
    19 |

    Time picker

    20 |
      21 |
    • 22 |

      default time picker

      23 | {} } /> 24 |
      25 |                             {``}
      26 |                         
      27 |
    • 28 |
    • 29 |

      time picker with given value

      30 | {} } /> 31 |
      32 |                             {``}
      33 |                         
      34 |
    • 35 |
    • 36 |

      time picker onChange, value is {this.state.value}

      37 | 38 |
      39 |                             {``}
      40 |                         
      41 |
    • 42 |
    • 43 |

      simple time picker

      44 | {} } /> 45 |
      46 |                             {``}
      47 |                         
      48 |
    • 49 |
    • 50 |

      TimePicker with position

      51 |

      top/bottom, default is bottom

      52 | value } /> 53 |
      54 |                             {``}
      55 |                         
      56 |
    • 57 |
    58 |
    59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /demo/example/TooltipDemo.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {Tooltip} from './index.js'; 3 | 4 | export default class TooltipDemo extends Component { 5 | render() { 6 | const contentNode =

    Some basic component

    ; 7 | return ( 8 |
    9 |

    Tooltip

    10 |
      11 |
    1. 12 |

      Default tooltip

      13 | Some component,build with ReactJs

      }> 14 | 15 |
      16 |
       17 |                             
       18 | {`
       19 | Some component,build with ReactJs

      }> 20 | 21 |
      22 | `} 23 |
      24 |
      25 |
    2. 26 |
    3. 27 |

      Tooltip with different position

      28 |
        29 |
      • 30 | huge text} position='left'> 31 |
        32 |

        hover to show tooltip at left

        33 |

        this is the content

        34 |
        35 |
        36 |
         37 |                                     
         38 | {`
         39 | huge text} position='left'>
         40 |     ...
         41 | 
         42 | `}                                            
         43 |                                     
         44 |                                 
        45 |
      • 46 |
      • 47 | 48 | 49 | 50 |
         51 |                                     
         52 | {`
         53 | huge text} position='right'>
         54 |     ...
         55 | 
         56 | `}                                          
         57 |                                     
         58 |                                 
        59 |
      • 60 |
      • 61 | 62 | 63 | 64 |
         65 |                                     
         66 | {`
         67 | huge text} position='top'>
         68 |     ...
         69 | 
         70 | `}                                          
         71 |                                     
         72 |                                 
        73 |
      • 74 |
      • 75 | 76 | 77 | 78 |
         79 |                                     
         80 | {`
         81 | huge text} position='bottom'>
         82 |     ...
         83 | 
         84 | `}                                          
         85 |                                     
         86 |                                 
        87 |
      • 88 |
      89 |
    4. 90 |
    5. 91 |

      Click mode

      92 | 93 | 94 | 95 |
       96 |                             
       97 | {`
       98 | huge text} mode="click">
       99 |     ...
      100 | 
      101 | `}                                  
      102 |                             
      103 |                         
      104 |
    6. 105 |
    106 |
    107 | ); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /demo/example/index.js: -------------------------------------------------------------------------------- 1 | import CheckBox from '../../component/CheckBox' 2 | import Radio from '../../component/Radio' 3 | import RadioGroup from '../../component/RadioGroup' 4 | import CheckBoxGroup from '../../component/CheckBoxGroup' 5 | import DropDown from '../../component/DropDown' 6 | import { Menu, MenuGroup, MenuItem, SubMenu } from '../../component/Menu' 7 | import Item from '../../component/Item' 8 | import ConfirmBox from '../../component/ConfirmBox' 9 | import Tooltip from '../../component/Tooltip' 10 | import Modal from '../../component/Modal' 11 | import Tab from '../../component/Tab' 12 | import Pin from '../../component/Pin' 13 | import Carousel from '../../component/Carousel' 14 | import Pagination from '../../component/Pagination' 15 | import SlideMenu from '../../component/SlideMenu' 16 | import TimeInput from '../../component/TimeInput' 17 | import TimePicker from '../../component/TimePicker' 18 | import DatePicker from '../../component/DatePicker' 19 | import DateTimePicker from '../../component/DateTimePicker' 20 | import Calendar from '../../component/Calendar' 21 | import Progress from '../../component/Progress' 22 | import FlashMessage from '../../component/FlashMessage' 23 | import Notice from '../../component/Notice' 24 | import NoticeCenter from '../../component/NoticeCenter' 25 | import Panel from '../../component/Panel' 26 | 27 | export { 28 | CheckBox, 29 | Radio, 30 | RadioGroup, 31 | CheckBoxGroup, 32 | DropDown, 33 | Modal, 34 | Menu, 35 | SubMenu, 36 | MenuGroup, 37 | MenuItem, 38 | Item, 39 | ConfirmBox, 40 | Tooltip, 41 | Tab, 42 | Pin, 43 | Carousel, 44 | Pagination, 45 | SlideMenu, 46 | TimeInput, 47 | TimePicker, 48 | DatePicker, 49 | DateTimePicker, 50 | Calendar, 51 | Progress, 52 | FlashMessage, 53 | Notice, 54 | NoticeCenter, 55 | Panel, 56 | }; -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | react component 7 | 8 | 9 | 10 |
    11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var CheckBox = require("./lib/CheckBox.js"); 4 | var Radio = require("./lib/Radio.js"); 5 | var RadioGroup = require("./lib/RadioGroup.js"); 6 | var CheckBoxGroup = require("./lib/CheckBoxGroup.js"); 7 | var DropDown = require("./lib/DropDown.js"); 8 | var Menu = require("./lib/Menu.js").Menu; 9 | var MenuGroup = require("./lib/Menu.js").MenuGroup; 10 | var MenuItem = require("./lib/Menu.js").MenuItem; 11 | var SubMenu = require("./lib/Menu.js").SubMenu; 12 | var Item = require("./lib/Item.js"); 13 | var ConfirmBox = require("./lib/ConfirmBox.js"); 14 | var Tooltip = require("./lib/Tooltip.js"); 15 | var Modal = require("./lib/Modal.js"); 16 | var Tab = require("./lib/Tab.js"); 17 | var Pin = require("./lib/Pin.js"); 18 | var Carousel = require("./lib/Carousel.js"); 19 | var Pagination = require("./lib/Pagination.js"); 20 | var SlideMenu = require("./lib/SlideMenu.js"); 21 | var TimeInput = require("./lib/TimeInput.js"); 22 | var TimePicker = require("./lib/TimePicker.js"); 23 | var DatePicker = require("./lib/DatePicker.js"); 24 | var DateTimePicker = require("./lib/DateTimePicker.js"); 25 | var Calendar = require("./lib/Calendar.js"); 26 | var Progress = require("./lib/Progress.js"); 27 | var FlashMessage = require("./lib/FlashMessage.js"); 28 | var NoticeCenter = require("./lib/NoticeCenter.js"); 29 | var Panel = require("./lib/Panel.js"); 30 | 31 | module.exports = { 32 | CheckBox: CheckBox, 33 | Radio: Radio, 34 | RadioGroup: RadioGroup, 35 | CheckBoxGroup: CheckBoxGroup, 36 | DropDown: DropDown, 37 | Menu: Menu, 38 | MenuGroup: MenuGroup, 39 | SubMenu: SubMenu, 40 | MenuItem: MenuItem, 41 | Item: Item, 42 | ConfirmBox: ConfirmBox, 43 | Tooltip: Tooltip, 44 | Modal: Modal, 45 | Tab: Tab, 46 | Pin: Pin, 47 | Carousel: Carousel, 48 | Pagination: Pagination, 49 | SlideMenu: SlideMenu, 50 | TimeInput: TimeInput, 51 | TimePicker: TimePicker, 52 | DatePicker: DatePicker, 53 | DateTimePicker: DateTimePicker, 54 | Calendar: Calendar, 55 | Progress: Progress, 56 | FlashMessage: FlashMessage, 57 | NoticeCenter: NoticeCenter, 58 | Panel: Panel, 59 | }; -------------------------------------------------------------------------------- /lib/CheckBox.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | 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; } 8 | 9 | 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; } 10 | 11 | var React = require('react'); 12 | var Component = React.Component; 13 | var PropTypes = require('prop-types'); 14 | var klassName = require('./util/className'); 15 | 16 | var CheckBox = function (_Component) { 17 | _inherits(CheckBox, _Component); 18 | 19 | function CheckBox(props) { 20 | _classCallCheck(this, CheckBox); 21 | 22 | var _this = _possibleConstructorReturn(this, (CheckBox.__proto__ || Object.getPrototypeOf(CheckBox)).call(this, props)); 23 | 24 | _this.checkedChange = _this.checkedChange.bind(_this); 25 | _this.state = { 26 | checked: props.checked 27 | }; 28 | return _this; 29 | } 30 | 31 | _createClass(CheckBox, [{ 32 | key: 'checkedChange', 33 | value: function checkedChange(e) { 34 | var _props = this.props, 35 | onChange = _props.onChange, 36 | value = _props.value; 37 | 38 | this.setState({ 39 | checked: e.target.checked 40 | }); 41 | if (onChange) onChange(e, value); 42 | } 43 | }, { 44 | key: 'componentWillReceiveProps', 45 | value: function componentWillReceiveProps(nextProps) { 46 | if (nextProps.checked !== this.props.checked) { 47 | this.setState({ 48 | checked: nextProps.checked 49 | }); 50 | } 51 | } 52 | }, { 53 | key: 'render', 54 | value: function render() { 55 | var _props2 = this.props, 56 | disabled = _props2.disabled, 57 | style = _props2.style, 58 | className = _props2.className, 59 | children = _props2.children; 60 | 61 | if (disabled) { 62 | className = klassName('disabled', className); 63 | } 64 | className = klassName(className, 'checkbox'); 65 | var checked = this.state.checked; 66 | 67 | return React.createElement( 68 | 'label', 69 | { style: style, className: className }, 70 | React.createElement('input', { type: 'checkbox', disabled: disabled, 71 | checked: checked, onChange: this.checkedChange }), 72 | React.createElement( 73 | 'span', 74 | null, 75 | children 76 | ) 77 | ); 78 | } 79 | }]); 80 | 81 | return CheckBox; 82 | }(Component); 83 | 84 | CheckBox.propTypes = { 85 | onChange: PropTypes.func, 86 | disabled: PropTypes.bool, 87 | checked: PropTypes.bool, 88 | className: PropTypes.string 89 | }; 90 | 91 | CheckBox.defaultProps = { 92 | className: '', 93 | checked: false 94 | }; 95 | 96 | module.exports = CheckBox; -------------------------------------------------------------------------------- /lib/FlashMessage.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var NoticeCenter = require('./NoticeCenter'); 4 | var DEFAULT_PREFIX = 'flash-message'; 5 | var DEFAULT_CONTENT = 'this is a flash message'; 6 | var DEFAULT_DELAY = 5000; 7 | var POSITIONS = ['top', 'center', 'bottom']; 8 | 9 | var instance = null; 10 | 11 | var generateNotice = function generateNotice(_ref) { 12 | var content = _ref.content, 13 | position = _ref.position, 14 | delay = _ref.delay, 15 | onClick = _ref.onClick, 16 | close = _ref.close; 17 | 18 | position = POSITIONS.indexOf(position) !== -1 ? position : POSITIONS[0]; 19 | content = content || DEFAULT_CONTENT; 20 | delay = delay || DEFAULT_DELAY; 21 | instance = instance || NoticeCenter.init({ 22 | className: DEFAULT_PREFIX, 23 | prefix: DEFAULT_PREFIX 24 | }); 25 | return instance.addNotice({ 26 | content: content, 27 | delay: delay, 28 | close: close, 29 | className: '_' + position, 30 | onClick: onClick 31 | }); 32 | }; 33 | 34 | var FlashMessage = function () { 35 | return { 36 | show: function show(msgObj) { 37 | return generateNotice(msgObj); 38 | } 39 | }; 40 | }(); 41 | 42 | module.exports = FlashMessage; -------------------------------------------------------------------------------- /lib/Item.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | 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; } 8 | 9 | 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; } 10 | 11 | var React = require('react'); 12 | var Component = React.Component; 13 | var PropTypes = require('prop-types'); 14 | 15 | var Item = function (_Component) { 16 | _inherits(Item, _Component); 17 | 18 | function Item(props) { 19 | _classCallCheck(this, Item); 20 | 21 | return _possibleConstructorReturn(this, (Item.__proto__ || Object.getPrototypeOf(Item)).call(this, props)); 22 | } 23 | 24 | _createClass(Item, [{ 25 | key: 'render', 26 | value: function render() { 27 | return React.createElement('div', this.props); 28 | } 29 | }]); 30 | 31 | return Item; 32 | }(Component); 33 | 34 | Item.propTypes = { 35 | children: PropTypes.node 36 | }; 37 | 38 | Item.defaultProps = { 39 | className: '' 40 | }; 41 | 42 | module.exports = Item; -------------------------------------------------------------------------------- /lib/Panel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | 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; } 8 | 9 | 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; } 10 | 11 | var React = require('react'); 12 | var Component = React.Component; 13 | var PropTypes = require('prop-types'); 14 | var klassName = require('./util/className'); 15 | 16 | var Panel = function (_Component) { 17 | _inherits(Panel, _Component); 18 | 19 | function Panel(props) { 20 | _classCallCheck(this, Panel); 21 | 22 | return _possibleConstructorReturn(this, (Panel.__proto__ || Object.getPrototypeOf(Panel)).call(this, props)); 23 | } 24 | 25 | _createClass(Panel, [{ 26 | key: 'render', 27 | value: function render() { 28 | var _props = this.props, 29 | className = _props.className, 30 | title = _props.title; 31 | 32 | return React.createElement( 33 | 'div', 34 | { className: klassName('panel', className) }, 35 | title ? React.createElement( 36 | 'div', 37 | { className: '_title' }, 38 | title 39 | ) : null, 40 | React.createElement( 41 | 'div', 42 | { className: '_content' }, 43 | this.props.children 44 | ) 45 | ); 46 | } 47 | }]); 48 | 49 | return Panel; 50 | }(Component); 51 | 52 | Panel.propTypes = { 53 | title: PropTypes.oneOfType([PropTypes.element, PropTypes.string]) 54 | }; 55 | 56 | module.exports = Panel; -------------------------------------------------------------------------------- /lib/Pin.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | 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; } 8 | 9 | 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; } 10 | 11 | var React = require('react'); 12 | var Component = React.Component; 13 | var PropTypes = require('prop-types'); 14 | var ReactDOM = require('react-dom'); 15 | var scrollCmp = require('./high-order/scrollCmp'); 16 | var klassName = require('./util/className'); 17 | 18 | var Pin = function (_Component) { 19 | _inherits(Pin, _Component); 20 | 21 | function Pin(props) { 22 | _classCallCheck(this, Pin); 23 | 24 | var _this = _possibleConstructorReturn(this, (Pin.__proto__ || Object.getPrototypeOf(Pin)).call(this, props)); 25 | 26 | _this.state = { 27 | fixed: false, 28 | baseTop: 0 29 | }; 30 | return _this; 31 | } 32 | 33 | _createClass(Pin, [{ 34 | key: 'componentDidMount', 35 | value: function componentDidMount() { 36 | this.setState({ 37 | baseTop: this.node2Top() 38 | }); 39 | } 40 | }, { 41 | key: 'node2Top', 42 | value: function node2Top() { 43 | var begin = this.props.begin; 44 | 45 | if (begin) return begin; 46 | var pinNode = ReactDOM.findDOMNode(this.pinNode); 47 | return pinNode.offsetTop; 48 | } 49 | }, { 50 | key: 'onScroll', 51 | value: function onScroll() { 52 | var _windowScrollOffset = this.windowScrollOffset(), 53 | _top = _windowScrollOffset._top; 54 | 55 | this.setState({ 56 | fixed: _top >= this.state.baseTop 57 | }); 58 | } 59 | }, { 60 | key: 'render', 61 | value: function render() { 62 | var _this2 = this; 63 | 64 | var fixed = this.state.fixed; 65 | var _props = this.props, 66 | top = _props.top, 67 | children = _props.children, 68 | className = _props.className; 69 | 70 | className = klassName(className, 'pin'); 71 | var stat = fixed ? 'fixed' : ''; 72 | return React.createElement( 73 | 'div', 74 | { className: className + ' ' + stat, 75 | style: { 'top': top }, 76 | ref: function ref(_ref) { 77 | _this2.pinNode = _ref; 78 | } }, 79 | children 80 | ); 81 | } 82 | }]); 83 | 84 | return Pin; 85 | }(Component); 86 | 87 | Pin.propTypes = { 88 | top: PropTypes.number, 89 | begin: PropTypes.number 90 | }; 91 | 92 | Pin.defaultProps = { 93 | top: 0, 94 | className: '' 95 | }; 96 | 97 | module.exports = scrollCmp(Pin); -------------------------------------------------------------------------------- /lib/Progress.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | 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; } 8 | 9 | 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; } 10 | 11 | var React = require('react'); 12 | var Component = React.Component; 13 | var PropTypes = require('prop-types'); 14 | var klassName = require('./util/className'); 15 | 16 | var Progress = function (_Component) { 17 | _inherits(Progress, _Component); 18 | 19 | function Progress(props) { 20 | _classCallCheck(this, Progress); 21 | 22 | return _possibleConstructorReturn(this, (Progress.__proto__ || Object.getPrototypeOf(Progress)).call(this, props)); 23 | } 24 | 25 | _createClass(Progress, [{ 26 | key: 'render', 27 | value: function render() { 28 | var _props = this.props, 29 | value = _props.value, 30 | className = _props.className, 31 | status = _props.status, 32 | size = _props.size, 33 | disabled = _props.disabled, 34 | children = _props.children; 35 | 36 | if (value < 0) value = 0; 37 | if (value > 100) value = 100; 38 | className = klassName(className, 'progress'); 39 | 40 | if (status) { 41 | className += ' _' + status; 42 | } 43 | if (disabled) { 44 | className += ' _disabled'; 45 | } 46 | if (value === 100) { 47 | className += ' _completed'; 48 | } 49 | if (children) { 50 | className += ' _context'; 51 | } 52 | 53 | if (size) { 54 | className += ' _' + size; 55 | } 56 | 57 | return React.createElement( 58 | 'div', 59 | { className: className }, 60 | React.createElement( 61 | 'div', 62 | { className: '_progress', style: { 'width': value + '%' } }, 63 | children 64 | ) 65 | ); 66 | } 67 | }]); 68 | 69 | return Progress; 70 | }(Component); 71 | 72 | Progress.propTypes = { 73 | value: PropTypes.number, 74 | disabled: PropTypes.bool, 75 | size: PropTypes.oneOf(['large', 'normal', 'small']), 76 | status: PropTypes.oneOf(['warning', 'failed', 'success', 'active']) 77 | }; 78 | 79 | Progress.defaultProps = { 80 | value: 0, 81 | className: '' 82 | }; 83 | 84 | module.exports = Progress; -------------------------------------------------------------------------------- /lib/Radio.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | 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; } 8 | 9 | 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; } 10 | 11 | var React = require('react'); 12 | var Component = React.Component; 13 | var PropTypes = require('prop-types'); 14 | var klassName = require('./util/className'); 15 | 16 | var Radio = function (_Component) { 17 | _inherits(Radio, _Component); 18 | 19 | function Radio(props) { 20 | _classCallCheck(this, Radio); 21 | 22 | var _this = _possibleConstructorReturn(this, (Radio.__proto__ || Object.getPrototypeOf(Radio)).call(this, props)); 23 | 24 | _this.checkedChange = _this.checkedChange.bind(_this); 25 | return _this; 26 | } 27 | 28 | _createClass(Radio, [{ 29 | key: 'checkedChange', 30 | value: function checkedChange(e) { 31 | var _props = this.props, 32 | value = _props.value, 33 | onChange = _props.onChange; 34 | 35 | if (onChange) onChange(e, value); 36 | } 37 | }, { 38 | key: 'render', 39 | value: function render() { 40 | var _props2 = this.props, 41 | className = _props2.className, 42 | checked = _props2.checked, 43 | disabled = _props2.disabled, 44 | style = _props2.style, 45 | children = _props2.children; 46 | 47 | className = klassName(className, 'radio'); 48 | if (disabled) { 49 | className = className + ' _disabled'; 50 | } 51 | return React.createElement( 52 | 'label', 53 | { style: style, className: className }, 54 | React.createElement('input', { type: 'radio', 55 | disabled: disabled, 56 | checked: checked, 57 | onChange: this.checkedChange }), 58 | React.createElement( 59 | 'span', 60 | null, 61 | children 62 | ) 63 | ); 64 | } 65 | }]); 66 | 67 | return Radio; 68 | }(Component); 69 | 70 | Radio.propTypes = { 71 | onChange: PropTypes.func, 72 | checked: PropTypes.bool, 73 | disabled: PropTypes.bool, 74 | className: PropTypes.string 75 | }; 76 | 77 | Radio.defaultProps = { 78 | className: '' 79 | }; 80 | 81 | module.exports = Radio; -------------------------------------------------------------------------------- /lib/high-order/documentClickCmp.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; }(); 4 | 5 | var _get = 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); } }; 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | 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; } 10 | 11 | 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; } 12 | 13 | var ReactDOM = require('react-dom'); 14 | 15 | module.exports = function (Cmp) { 16 | return function (_Cmp) { 17 | _inherits(DocumentClickCmp, _Cmp); 18 | 19 | function DocumentClickCmp(props) { 20 | _classCallCheck(this, DocumentClickCmp); 21 | 22 | var _this = _possibleConstructorReturn(this, (DocumentClickCmp.__proto__ || Object.getPrototypeOf(DocumentClickCmp)).call(this, props)); 23 | 24 | _this.onClick = _this.onClick.bind(_this); 25 | _this.onDocumentClick = _this.onDocumentClick.bind(_this); 26 | return _this; 27 | } 28 | 29 | _createClass(DocumentClickCmp, [{ 30 | key: 'componentDidMount', 31 | value: function componentDidMount() { 32 | document.addEventListener('click', this.onClick); 33 | if (_get(DocumentClickCmp.prototype.__proto__ || Object.getPrototypeOf(DocumentClickCmp.prototype), 'componentDidMount', this)) { 34 | _get(DocumentClickCmp.prototype.__proto__ || Object.getPrototypeOf(DocumentClickCmp.prototype), 'componentDidMount', this).call(this); 35 | } 36 | } 37 | }, { 38 | key: 'componentWillUnmount', 39 | value: function componentWillUnmount() { 40 | document.removeEventListener('click', this.onClick); 41 | if (_get(DocumentClickCmp.prototype.__proto__ || Object.getPrototypeOf(DocumentClickCmp.prototype), 'componentWillUnmount', this)) { 42 | _get(DocumentClickCmp.prototype.__proto__ || Object.getPrototypeOf(DocumentClickCmp.prototype), 'componentWillUnmount', this).call(this); 43 | } 44 | } 45 | }, { 46 | key: 'onClick', 47 | value: function onClick(e) { 48 | this.onDocumentClick(e); 49 | } 50 | }, { 51 | key: 'onDocumentClick', 52 | value: function onDocumentClick(e) { 53 | var BASE_NODE = ReactDOM.findDOMNode(this); 54 | if (e.target == BASE_NODE || BASE_NODE.contains(e.target)) { 55 | if (this.onBaseDomClick) this.onBaseDomClick(e); 56 | } else { 57 | if (typeof document.contains === 'function' && document.contains(e.target) && typeof this.onOtherDomClick === 'function') { 58 | this.onOtherDomClick(e); 59 | } 60 | } 61 | e.stopPropagation(); 62 | } 63 | }]); 64 | 65 | return DocumentClickCmp; 66 | }(Cmp); 67 | }; -------------------------------------------------------------------------------- /lib/high-order/dropDownCmp.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; 4 | 5 | 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; }; }(); 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | 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; } 10 | 11 | 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; } 12 | 13 | var PropTypes = require('prop-types'); 14 | var React = require('react'); 15 | var klassName = require('../util/className'); 16 | var POSITIONS = ['left', 'right', 'bottom', 'top']; 17 | 18 | module.exports = function (Cmp, positions) { 19 | var dropDownCmp = function (_Cmp) { 20 | _inherits(dropDownCmp, _Cmp); 21 | 22 | function dropDownCmp(props) { 23 | _classCallCheck(this, dropDownCmp); 24 | 25 | return _possibleConstructorReturn(this, (dropDownCmp.__proto__ || Object.getPrototypeOf(dropDownCmp)).call(this, props)); 26 | } 27 | 28 | _createClass(dropDownCmp, [{ 29 | key: 'render', 30 | value: function render() { 31 | var _props = this.props, 32 | className = _props.className, 33 | position = _props.position; 34 | 35 | className = klassName(className, '_' + position); 36 | return React.createElement(Cmp, _extends({}, this.props, { className: className })); 37 | } 38 | }]); 39 | 40 | return dropDownCmp; 41 | }(Cmp); 42 | 43 | positions = positions instanceof Array ? positions : POSITIONS; 44 | dropDownCmp.propTypes = { 45 | position: PropTypes.oneOf(positions) 46 | }; 47 | 48 | dropDownCmp.defaultProps = { 49 | position: 'bottom' 50 | }; 51 | return dropDownCmp; 52 | }; -------------------------------------------------------------------------------- /lib/high-order/intervalCmp.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | 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; }; }(); 4 | 5 | var _get = 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); } }; 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | 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; } 10 | 11 | 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; } 12 | 13 | // interval high order component 14 | module.exports = function (Cmp) { 15 | return function (_Cmp) { 16 | _inherits(IntervalCmp, _Cmp); 17 | 18 | function IntervalCmp(props) { 19 | _classCallCheck(this, IntervalCmp); 20 | 21 | var _this = _possibleConstructorReturn(this, (IntervalCmp.__proto__ || Object.getPrototypeOf(IntervalCmp)).call(this, props)); 22 | 23 | _this.intervals = []; 24 | return _this; 25 | } 26 | 27 | _createClass(IntervalCmp, [{ 28 | key: "setInterval", 29 | value: function (_setInterval) { 30 | function setInterval() { 31 | return _setInterval.apply(this, arguments); 32 | } 33 | 34 | setInterval.toString = function () { 35 | return _setInterval.toString(); 36 | }; 37 | 38 | return setInterval; 39 | }(function () { 40 | this.intervals.push(setInterval.apply(null, arguments)); 41 | }) 42 | }, { 43 | key: "clearInterval", 44 | value: function (_clearInterval) { 45 | function clearInterval() { 46 | return _clearInterval.apply(this, arguments); 47 | } 48 | 49 | clearInterval.toString = function () { 50 | return _clearInterval.toString(); 51 | }; 52 | 53 | return clearInterval; 54 | }(function () { 55 | this.intervals.map(clearInterval); 56 | }) 57 | }, { 58 | key: "componentWillUnmount", 59 | value: function componentWillUnmount() { 60 | this.clearInterval(); 61 | if (_get(IntervalCmp.prototype.__proto__ || Object.getPrototypeOf(IntervalCmp.prototype), "componentWillUnmount", this)) { 62 | _get(IntervalCmp.prototype.__proto__ || Object.getPrototypeOf(IntervalCmp.prototype), "componentWillUnmount", this).call(this); 63 | } 64 | } 65 | }]); 66 | 67 | return IntervalCmp; 68 | }(Cmp); 69 | }; -------------------------------------------------------------------------------- /lib/high-order/scrollCmp.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; }(); 4 | 5 | var _get = 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); } }; 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | 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; } 10 | 11 | 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; } 12 | 13 | module.exports = function (Cmp) { 14 | return function (_Cmp) { 15 | _inherits(ScrollCmp, _Cmp); 16 | 17 | function ScrollCmp(props) { 18 | _classCallCheck(this, ScrollCmp); 19 | 20 | var _this = _possibleConstructorReturn(this, (ScrollCmp.__proto__ || Object.getPrototypeOf(ScrollCmp)).call(this, props)); 21 | 22 | _this.onScroll = _this.onScroll.bind(_this); 23 | return _this; 24 | } 25 | 26 | _createClass(ScrollCmp, [{ 27 | key: 'componentDidMount', 28 | value: function componentDidMount() { 29 | document.addEventListener('scroll', this.onScroll); 30 | if (_get(ScrollCmp.prototype.__proto__ || Object.getPrototypeOf(ScrollCmp.prototype), 'componentDidMount', this)) { 31 | _get(ScrollCmp.prototype.__proto__ || Object.getPrototypeOf(ScrollCmp.prototype), 'componentDidMount', this).call(this); 32 | } 33 | } 34 | }, { 35 | key: 'componentWillUnmount', 36 | value: function componentWillUnmount() { 37 | document.removeEventListener('scroll', this.onScroll); 38 | if (_get(ScrollCmp.prototype.__proto__ || Object.getPrototypeOf(ScrollCmp.prototype), 'componentWillUnmount', this)) { 39 | _get(ScrollCmp.prototype.__proto__ || Object.getPrototypeOf(ScrollCmp.prototype), 'componentWillUnmount', this).call(this); 40 | } 41 | } 42 | }, { 43 | key: 'windowScrollOffset', 44 | value: function windowScrollOffset() { 45 | var doc = document.documentElement; 46 | var left = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0); 47 | var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); 48 | return { 49 | _left: left, 50 | _top: top 51 | }; 52 | } 53 | }]); 54 | 55 | return ScrollCmp; 56 | }(Cmp); 57 | }; -------------------------------------------------------------------------------- /lib/high-order/timeInputCmp.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 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; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | 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; } 8 | 9 | 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; } 10 | 11 | var PropTypes = require('prop-types'); 12 | var timeUtil = require('../util/time'); 13 | var timeStr2Obj = timeUtil.timeStr2Obj, 14 | obj2TimeStr = timeUtil.obj2TimeStr, 15 | seconds2Obj = timeUtil.seconds2Obj; 16 | 17 | 18 | module.exports = function (Cmp) { 19 | var TimeInputCmp = function (_Cmp) { 20 | _inherits(TimeInputCmp, _Cmp); 21 | 22 | function TimeInputCmp(props) { 23 | _classCallCheck(this, TimeInputCmp); 24 | 25 | return _possibleConstructorReturn(this, (TimeInputCmp.__proto__ || Object.getPrototypeOf(TimeInputCmp)).call(this, props)); 26 | } 27 | 28 | _createClass(TimeInputCmp, [{ 29 | key: 'initTime', 30 | value: function initTime(_ref) { 31 | var displayValue = _ref.displayValue, 32 | value = _ref.value; 33 | var simple = this.props.simple; 34 | 35 | if ([undefined, '', null].indexOf(displayValue) !== -1 && value === undefined) { 36 | return {}; 37 | } 38 | 39 | var rtnObj = [undefined, '', null].indexOf(displayValue) === -1 ? timeStr2Obj(displayValue) : seconds2Obj(value); 40 | var hour = rtnObj.hour, 41 | minute = rtnObj.minute, 42 | second = rtnObj.second; 43 | 44 | 45 | value = hour * 3600 + minute * 60 + second; 46 | 47 | displayValue = obj2TimeStr({ 48 | hour: hour, minute: minute, second: second 49 | }, { 50 | simple: simple 51 | }); 52 | 53 | return { value: value, displayValue: displayValue }; 54 | } 55 | }]); 56 | 57 | return TimeInputCmp; 58 | }(Cmp); 59 | 60 | TimeInputCmp.propTypes = { 61 | simple: PropTypes.bool, 62 | value: PropTypes.number, 63 | onChange: PropTypes.func.isRequired, 64 | onBlur: PropTypes.func, 65 | onFocus: PropTypes.func, 66 | className: PropTypes.string, 67 | placeHolder: PropTypes.string, 68 | onClick: PropTypes.func 69 | }; 70 | 71 | return TimeInputCmp; 72 | }; -------------------------------------------------------------------------------- /lib/util/className.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var klassName = function klassName() { 4 | if (arguments.length === 0) { 5 | return ''; 6 | } 7 | var cls = Array.prototype.slice.call(arguments); 8 | return cls.filter(function (l) { 9 | return l; 10 | }).join(' '); 11 | }; 12 | 13 | module.exports = klassName; -------------------------------------------------------------------------------- /lib/util/constants.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var WEEK_LABEL = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; 4 | 5 | var MONTH_LABEL = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']; 6 | 7 | var BACKSPACE_KEYCODE = 8; 8 | var DOWN_KEYCODE = 40; 9 | var UP_KEYCODE = 38; 10 | var ENTER_KEYCODE = 13; 11 | 12 | module.exports = { 13 | WEEK_LABEL: WEEK_LABEL, 14 | MONTH_LABEL: MONTH_LABEL, 15 | BACKSPACE_KEYCODE: BACKSPACE_KEYCODE, 16 | DOWN_KEYCODE: DOWN_KEYCODE, 17 | UP_KEYCODE: UP_KEYCODE, 18 | ENTER_KEYCODE: ENTER_KEYCODE 19 | }; -------------------------------------------------------------------------------- /lib/util/datetime.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // date => date string 4 | var formatDate = function formatDate(date) { 5 | var fmt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "yyyy-MM-dd"; 6 | 7 | if (!date) { 8 | return ''; 9 | } 10 | var obj = { 11 | "M+": date.getMonth() + 1, 12 | "d+": date.getDate(), 13 | "h+": date.getHours(), 14 | "m+": date.getMinutes(), 15 | "s+": date.getSeconds(), 16 | "q+": Math.floor((date.getMonth() + 3) / 3), 17 | "S": date.getMilliseconds() 18 | }; 19 | if (/(y+)/.test(fmt)) { 20 | fmt = fmt.replace(RegExp.$1, String(date.getFullYear()).substr(4 - RegExp.$1.length)); 21 | } 22 | for (var k in obj) { 23 | if (new RegExp("(" + k + ")").test(fmt)) { 24 | fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? obj[k] : ("00" + obj[k]).substr(String(obj[k]).length)); 25 | } 26 | } 27 | return fmt; 28 | }; 29 | 30 | // extract date to {year, month, day, hour, minute, second, miniSecond} 31 | var extractDate = function extractDate(date, opt) { 32 | opt = opt || {}; 33 | if (!date) { 34 | date = new Date(); 35 | } 36 | if (!opt.showTime) { 37 | return { 38 | year: date.getFullYear(), 39 | month: date.getMonth() + 1, 40 | day: date.getDate() 41 | }; 42 | } 43 | return { 44 | year: date.getFullYear(), 45 | month: date.getMonth() + 1, 46 | day: date.getDate(), 47 | hour: date.getHours(), 48 | minute: date.getMinutes(), 49 | second: date.getSeconds(), 50 | miniSecond: date.getMilliseconds() 51 | }; 52 | }; 53 | 54 | module.exports = { 55 | formatDate: formatDate, extractDate: extractDate 56 | }; -------------------------------------------------------------------------------- /lib/util/debounce.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _timer = null; 4 | 5 | module.exports = function (fn) { 6 | var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300; 7 | 8 | clearTimeout(_timer); 9 | return function () { 10 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 11 | args[_key] = arguments[_key]; 12 | } 13 | 14 | _timer = setTimeout(function () { 15 | fn.apply(undefined, args); 16 | }, delay); 17 | }; 18 | }; -------------------------------------------------------------------------------- /lib/util/dom.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function toggleClass(el, className) { 4 | if (el && el instanceof Node && className) { 5 | if (hasClass(el, className)) { 6 | removeClass(el, className); 7 | } else { 8 | addClass(el, className); 9 | } 10 | } 11 | } 12 | 13 | function removeClass(el, className) { 14 | if (!el || !className) return; 15 | if (el instanceof NodeList) { 16 | var length = el.length; 17 | for (var i = 0; i < length; i++) { 18 | _removeClass(el[i], className); 19 | } 20 | return; 21 | } 22 | if (el instanceof Node) { 23 | _removeClass(el, className); 24 | } 25 | } 26 | 27 | function _removeClass(el, className) { 28 | if (hasClass(el, className)) { 29 | var old = ' ' + el.className + ' '; 30 | old = old.replace(/(\s+)/gi, ' '); 31 | el.className = old.replace(' ' + className + ' ', ' ').replace(/(^\s+)|(\s+$)/g, ''); 32 | } 33 | } 34 | 35 | function hasClass(el, className) { 36 | if (el && className && el instanceof Node) { 37 | return el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)')); 38 | } 39 | return false; 40 | } 41 | 42 | function addClass(el, className) { 43 | if (!hasClass(el, className)) { 44 | el.className += el.className ? " " + className : className; 45 | } 46 | } 47 | 48 | function getClassList(el) { 49 | if (el && el instanceof Node) return el.className.split(/\s+/); 50 | return []; 51 | } 52 | 53 | module.exports = { 54 | toggleClass: toggleClass, removeClass: removeClass, hasClass: hasClass, addClass: addClass, getClassList: getClassList 55 | }; -------------------------------------------------------------------------------- /lib/util/misc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var capitalize = function capitalize() { 4 | var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 5 | 6 | return str.charAt(0).toUpperCase() + str.slice(1); 7 | }; 8 | 9 | module.exports = { 10 | capitalize: capitalize 11 | }; -------------------------------------------------------------------------------- /lib/util/time.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var isType = require('./typeCheck').isType; 4 | 5 | var MAX_HOUR = 23; 6 | var MAX_MINUTE = 59; 7 | var MAX_SECOND = MAX_MINUTE; 8 | 9 | // 时间字符串 => {小时,分钟,秒} 10 | var timeStr2Obj = function timeStr2Obj() { 11 | var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '00:00:00'; 12 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 13 | simple: false 14 | }; 15 | 16 | value = isType(value, 'String') ? value : '00:00:00'; 17 | var arr = value.split(':').slice(0, 3); 18 | var new_arr = []; 19 | 20 | for (var i = 0; i < arr.length; i++) { 21 | var item = String(arr[i]); 22 | if (item.length === 1) item = '0' + item; 23 | if (!item) item = '00'; 24 | new_arr.push(item); 25 | } 26 | 27 | var hour = new_arr[0], 28 | minute = new_arr[1], 29 | second = new_arr[2]; 30 | 31 | hour = validateUnitByMax(hour, MAX_HOUR); 32 | minute = validateUnitByMax(minute, MAX_MINUTE); 33 | 34 | if (options.simple) return { hour: hour, minute: minute }; 35 | 36 | second = validateUnitByMax(second, MAX_SECOND); 37 | 38 | return { hour: hour, minute: minute, second: second }; 39 | }; 40 | 41 | // {小时, 分钟, 秒} => 时间字符串 42 | var obj2TimeStr = function obj2TimeStr(_ref) { 43 | var _ref$hour = _ref.hour, 44 | hour = _ref$hour === undefined ? 0 : _ref$hour, 45 | _ref$minute = _ref.minute, 46 | minute = _ref$minute === undefined ? 0 : _ref$minute, 47 | _ref$second = _ref.second, 48 | second = _ref$second === undefined ? 0 : _ref$second; 49 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 50 | simple: false 51 | }; 52 | 53 | hour = validateUnitByMax(hour, MAX_HOUR); 54 | minute = validateUnitByMax(minute, MAX_MINUTE); 55 | 56 | if (hour < 10) { 57 | hour = '0' + hour; 58 | } 59 | if (minute < 10) { 60 | minute = '0' + minute; 61 | } 62 | 63 | if (options.simple) { 64 | return hour + ':' + minute; 65 | } 66 | second = validateUnitByMax(second, MAX_SECOND); 67 | 68 | if (second < 10) { 69 | second = '0' + second; 70 | } 71 | 72 | return hour + ':' + minute + ':' + second; 73 | }; 74 | 75 | var seconds2Obj = function seconds2Obj(value) { 76 | value = value || 0; 77 | value = value % 86400; 78 | var hour = parseInt(value / 3600); 79 | var minute = parseInt(value % 3600 / 60); 80 | var second = value % 3600 % 60; 81 | return { 82 | hour: hour, minute: minute, second: second 83 | }; 84 | }; 85 | 86 | var obj2Seconds = function obj2Seconds(_ref2) { 87 | var hour = _ref2.hour, 88 | minute = _ref2.minute, 89 | second = _ref2.second; 90 | 91 | hour = hour || 0; 92 | minute = minute || 0; 93 | second = second || 0; 94 | return hour * 3600 + minute * 60 + second; 95 | }; 96 | 97 | var validateUnitByMax = function validateUnitByMax(value, max) { 98 | value = parseInt(value); 99 | if (value > max) value = Math.floor(value % (max + 1)); 100 | if (isNaN(value) || value < 0) value = 0; 101 | return value; 102 | }; 103 | 104 | module.exports = { 105 | timeStr2Obj: timeStr2Obj, 106 | obj2TimeStr: obj2TimeStr, 107 | seconds2Obj: seconds2Obj, 108 | obj2Seconds: obj2Seconds 109 | }; -------------------------------------------------------------------------------- /lib/util/typeCheck.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | function isType(obj, typeStr) { 4 | return Object.prototype.toString.call(obj).slice(8, -1) === typeStr; 5 | } 6 | 7 | module.exports = { 8 | isType: isType 9 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-ui-component", 3 | "version": "2.0.3", 4 | "description": "some component build with ReactJs", 5 | "main": "main.js", 6 | "scripts": { 7 | "start": "babel --presets es2015,react --watch component/ --out-dir lib/ & cross-env NODE_ENV=dev node server.js", 8 | "build": "NODE_ENV=production webpack -p", 9 | "test": "jest", 10 | "lint": "eslint lib" 11 | }, 12 | "pre-commit": [ 13 | "lint" 14 | ], 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/jerryshew/react-component.git" 18 | }, 19 | "keywords": [ 20 | "react", 21 | "ui", 22 | "reactjs", 23 | "react component", 24 | "checkbox group", 25 | "drop down", 26 | "pagination", 27 | "carousel", 28 | "css framework" 29 | ], 30 | "author": "wecatch", 31 | "license": "MIT", 32 | "bugs": { 33 | "url": "https://github.com/jerryshew/react-component/issues" 34 | }, 35 | "devDependencies": { 36 | "autoprefixer": "^6.3.5", 37 | "babel-cli": "^6.18.0", 38 | "babel-core": "^6.18.0", 39 | "babel-jest": "^18.0.0", 40 | "babel-loader": "^6.0.0", 41 | "babel-plugin-add-module-exports": "^0.2.1", 42 | "babel-plugin-react-transform": "^1.1.1", 43 | "babel-polyfill": "^6.23.0", 44 | "babel-preset-es2015": "^6.18.0", 45 | "babel-preset-react": "^6.5.0", 46 | "babel-runtime": "^6.0.0", 47 | "cross-env": "^3.1.3", 48 | "css-loader": "^0.17.0", 49 | "eslint": "^3.9.1", 50 | "express": "^4.13.3", 51 | "force-case-sensitivity-webpack-plugin": "^0.1.1", 52 | "html-webpack-plugin": "^1.6.1", 53 | "jest": "^18.1.0", 54 | "jest-cli": "^18.1.0", 55 | "jsx-loader": "^0.13.2", 56 | "less": "^2.5.1", 57 | "less-loader": "^2.2.0", 58 | "postcss-loader": "^0.8.2", 59 | "pre-commit": "^1.1.3", 60 | "precss": "^1.4.0", 61 | "react-hot-loader": "^1.3.0", 62 | "react-router": "^4.2.0", 63 | "react-router-dom": "^4.2.2", 64 | "react-transform-hmr": "^1.0.0", 65 | "style-loader": "^0.12.3", 66 | "uglify-loader": "^1.2.0", 67 | "webpack": "^1.12.1", 68 | "webpack-dev-middleware": "^1.2.0", 69 | "webpack-hot-middleware": "^2.5.0" 70 | }, 71 | "homepage": "https://github.com/jerryshew/react-component", 72 | "dependencies": { 73 | "prop-types": "^15.6.0", 74 | "react": "^16.2.0", 75 | "react-addons-css-transition-group": "^15.6.2", 76 | "react-dom": "^16.2.0" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | var webpack = require('webpack'); 2 | var webpackDevMiddleware = require('webpack-dev-middleware'); 3 | var webpackHotMiddleware = require('webpack-hot-middleware'); 4 | var config = require('./webpack.config'); 5 | 6 | var app = new (require('express'))(); 7 | var port = process.env.PORT || (process.argv[2] || 3000); 8 | 9 | var compiler = webpack(config); 10 | app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath })); 11 | app.use(webpackHotMiddleware(compiler)); 12 | 13 | app.get("*", function(req, res) { 14 | res.sendFile(__dirname + '/index.html'); 15 | }); 16 | 17 | app.listen(port, function(error) { 18 | if (error) { 19 | console.error(error); 20 | } else { 21 | console.info("==> 🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.", port, port); 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /todo.md: -------------------------------------------------------------------------------- 1 | ###basic 2 | 3 | + ~~message~~ 4 | 5 | + ~~progress~~ 6 | 7 | ###inhence -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var webpack = require('webpack'); 3 | var HtmlWebpackPlugin = require('html-webpack-plugin'); 4 | var precss = require('precss'); 5 | var autoprefixer = require('autoprefixer'); 6 | var ForceCaseSensitivityPlugin = require('force-case-sensitivity-webpack-plugin'); 7 | var publicPath = process.env.NODE_ENV === 'dev' ? '/dist/' : ''; 8 | 9 | const plugins = [ 10 | new webpack.optimize.OccurenceOrderPlugin(), 11 | new webpack.HotModuleReplacementPlugin(), 12 | new webpack.NoErrorsPlugin(), 13 | new ForceCaseSensitivityPlugin(), 14 | ] 15 | if (process.env.NODE_ENV !== 'dev') { 16 | plugins.push( 17 | new webpack.DefinePlugin({ 18 | "process.env": { 19 | NODE_ENV: JSON.stringify("production") 20 | } 21 | }) 22 | ) 23 | } 24 | 25 | module.exports = { 26 | entry: { 27 | app: [ 28 | "./demo/entre.js", 29 | "webpack-hot-middleware/client?path=/__webpack_hmr&timeout=2000&overlay=false" 30 | ] 31 | }, 32 | output: { 33 | path: path.join(__dirname, 'dist'), 34 | filename: 'demo.js', 35 | publicPath: publicPath 36 | }, 37 | plugins: plugins, 38 | module: { 39 | loaders: [{ 40 | test: /\.less$/, 41 | loader: "style-loader!css-loader!postcss-loader!less-loader" 42 | }, { 43 | test: /\.css$/, 44 | loader: "style-loader!css-loader!postcss-loader" 45 | }, { 46 | test: /\.js$/, 47 | exclude: /(node_modules|bower_components)/, 48 | loader: "babel" 49 | }, { 50 | test: /\.jsx?$/, 51 | exclude: /(node_modules|bower_components)/, 52 | loader: 'babel', 53 | }], 54 | postcss: function() { 55 | return [autoprefixer, precss]; 56 | } 57 | }, 58 | 59 | }; --------------------------------------------------------------------------------